openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

huracan.c (6980B)


      1 /*
      2  *         
      3  * 
      4  * 
      5  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      6  * 
      7  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      8  */
      9 
     10 #include <phymod/phymod.h>
     11 #include <phymod/phymod_dispatch.h>
     12 
     13 #ifdef PHYMOD_HURACAN_SUPPORT
     14 
     15 
     16 #include <phymod/chip/huracan.h>
     17 
     18 /* To be defined */
     19 /* #include "../tier1/huracan_types.h" */
     20 #include "../tier1/huracan_cfg_seq.h"
     21 #include "../tier1/huracan_reg_access.h"
     22 #include "../tier1/bcmi_huracan_defs.h"
     23 
     24 
     25 
     26 
     27 int huracan_core_identify(const phymod_core_access_t* core, uint32_t core_id, uint32_t* is_identified)
     28 {
     29         
     30     uint32_t chip_id = 0;
     31     chip_id =  _huracan_get_chip_id(&core->access);
     32 
     33     *is_identified = 0;
     34     /* APO cretae macro for 0x82109 ../tier1/hurican_types.h*/
     35     if (chip_id == 0x2109 || chip_id == 0x2181)
     36     {
     37         /* PHY IDs match */
     38         *is_identified = 1;
     39     }
     40         
     41     return PHYMOD_E_NONE;
     42     
     43 }
     44 
     45 
     46 int huracan_core_info_get(const phymod_core_access_t* core, phymod_core_info_t* info)
     47 {
     48     uint32_t chip_id;
     49 
     50     chip_id =  _huracan_get_chip_id(&core->access);
     51     info->serdes_id = chip_id;
     52     info->core_version = phymodCoreVersionHuracan;
     53     PHYMOD_STRNCPY(info->name, "Huracan", PHYMOD_STRLEN("Huracan")+1);
     54 
     55     return PHYMOD_E_NONE;
     56     
     57 }
     58 
     59 int huracan_phy_interface_config_set(const phymod_phy_access_t* phy,
     60                                    uint32_t flags,
     61                                    const phymod_phy_inf_config_t* config)
     62 {
     63     return PHYMOD_E_NONE;
     64     
     65 }
     66 
     67 /**   Get Interface config 
     68  *    This function retrieves interface configuration(interface, speed and 
     69  *    frequency of operation) from the device. 
     70  *
     71  *    @param phy                Pointer to phymod phy access structure 
     72  *    @param flags              Currently unused and reserved for future use 
     73  *    @param config             Interface config structure where  
     74  *                              interface, speed and the frequency of operation
     75  *                              will be populated from device .
     76  *
     77  *    @return PHYMOD_E_NONE     successful function execution 
     78  */
     79 int huracan_phy_interface_config_get(const phymod_phy_access_t* phy,
     80                                    uint32_t flags,
     81                                    phymod_ref_clk_t ref_clock,
     82                                    phymod_phy_inf_config_t* config)
     83 {
     84     return PHYMOD_E_NONE;
     85 }
     86 
     87 
     88 
     89 int huracan_core_reset_set(const phymod_core_access_t* core, phymod_reset_mode_t reset_mode, phymod_reset_direction_t direction)
     90 {
     91         
     92     PHYMOD_IF_ERR_RETURN (
     93          huracan_hard_reset(&core->access, reset_mode, direction));
     94         
     95     return PHYMOD_E_NONE;
     96     
     97 }
     98 
     99 int huracan_core_reset_get(const phymod_core_access_t* core, phymod_reset_mode_t reset_mode, phymod_reset_direction_t* direction)
    100 {
    101     return PHYMOD_E_UNAVAIL;
    102 
    103 }
    104 
    105 
    106 int huracan_phy_power_set(const phymod_phy_access_t* phy, const phymod_phy_power_t* power)
    107 {
    108     return _huracan_phy_power_set(&phy->access, power);
    109 }
    110 
    111 int huracan_phy_power_get(const phymod_phy_access_t* phy, phymod_phy_power_t* power)
    112 {
    113     return _huracan_phy_power_get(&phy->access, power);
    114 }
    115 
    116 
    117 int huracan_phy_tx_lane_control_set(const phymod_phy_access_t* phy, phymod_phy_tx_lane_control_t tx_control)
    118 {
    119     return huracan_tx_lane_control_set(&phy->access, tx_control);
    120 }
    121 
    122 int huracan_phy_tx_lane_control_get(const phymod_phy_access_t* phy, phymod_phy_tx_lane_control_t* tx_control)
    123 {
    124     int enable = 0;
    125     *tx_control = phymodTxSquelchOn;
    126 
    127     PHYMOD_IF_ERR_RETURN (
    128        huracan_tx_squelch_get(&phy->access, &enable));
    129     
    130     if (!enable) {
    131         *tx_control = phymodTxSquelchOff;
    132     }
    133 
    134     return PHYMOD_E_NONE;
    135     
    136 }
    137 
    138 
    139 int huracan_phy_rx_lane_control_set(const phymod_phy_access_t* phy, phymod_phy_rx_lane_control_t rx_control)
    140 {
    141     return huracan_rx_lane_control_set(&phy->access, rx_control);
    142 }
    143 
    144 int huracan_phy_rx_lane_control_get(const phymod_phy_access_t* phy, phymod_phy_rx_lane_control_t* rx_control)
    145 {
    146     int enable = 0;
    147     *rx_control = phymodRxSquelchOn;
    148     PHYMOD_IF_ERR_RETURN (
    149        huracan_rx_squelch_get(&phy->access, &enable));
    150     if (!enable) {
    151         *rx_control = phymodRxSquelchOff;
    152     }
    153     return PHYMOD_E_NONE;
    154     
    155 }
    156 
    157 
    158 int huracan_core_init(const phymod_core_access_t* core, const phymod_core_init_config_t* init_config, const phymod_core_status_t* core_status)
    159 {
    160         
    161     PHYMOD_IF_ERR_RETURN (
    162          huracan_hard_reset(&core->access,
    163                             phymodResetModeHard, phymodResetDirectionInOut));
    164 
    165         
    166     return PHYMOD_E_NONE;
    167     
    168 }
    169 
    170 
    171 int huracan_phy_init(const phymod_phy_access_t* phy, const phymod_phy_init_config_t* init_config)
    172 {
    173         
    174     
    175     /* Place your code here */
    176 
    177         
    178     return PHYMOD_E_NONE;
    179     
    180 }
    181 
    182 
    183 int huracan_phy_rx_pmd_locked_get(const phymod_phy_access_t* phy, uint32_t* rx_pmd_locked)
    184 {
    185         
    186     return PHYMOD_E_NONE;
    187     
    188 }
    189 
    190 
    191 int huracan_phy_link_status_get(const phymod_phy_access_t* phy, uint32_t* link_status)
    192 {
    193         
    194     return huracan_link_status(&phy->access, link_status);
    195     
    196 }
    197 
    198 
    199 int huracan_phy_reg_read(const phymod_phy_access_t* phy, uint32_t reg_addr, uint32_t* val)
    200 {
    201     return huracan_reg_read(&phy->access,\
    202                   HURACAN_CLAUSE45_ADDR((phy->access.devad), (reg_addr)),\
    203                   val);
    204     
    205 }
    206 
    207 
    208 int huracan_phy_reg_write(const phymod_phy_access_t* phy, uint32_t reg_addr, uint32_t val)
    209 {
    210     return huracan_reg_write(&phy->access,\
    211                   HURACAN_CLAUSE45_ADDR((phy->access.devad), (reg_addr)),\
    212                   val);
    213     
    214 }
    215 
    216 
    217 int huracan_phy_gpio_config_set(const phymod_phy_access_t* phy, int pin_no, phymod_gpio_mode_t gpio_mode)
    218 {
    219         
    220     return huracan_gpio_config_set(&phy->access, pin_no, gpio_mode);
    221 }
    222 
    223 int huracan_phy_gpio_config_get(const phymod_phy_access_t* phy, int pin_no, phymod_gpio_mode_t *gpio_mode)
    224 {
    225     return huracan_gpio_config_get(&phy->access, pin_no, gpio_mode);
    226 }
    227 
    228 
    229 int huracan_phy_gpio_pin_value_set(const phymod_phy_access_t* phy, int pin_no, int value)
    230 {
    231     return huracan_gpio_pin_value_set(&phy->access, pin_no, value);
    232 }
    233 
    234 int huracan_phy_gpio_pin_value_get(const phymod_phy_access_t* phy, int pin_no, int* value)
    235 {
    236     return huracan_gpio_pin_value_get(&phy->access, pin_no, value);
    237 }
    238 
    239 
    240 /**  PHY rev id 
    241  *   PHY revision id This function is used to get revision id of a chip
    242  *
    243  *    @param phy                Pointer to phymod phy access structure 
    244  *    @param rev_id             Pointer to get revision id 
    245  *
    246  *    @return PHYMOD_E_NONE     successful function execution 
    247  */
    248 int huracan_phy_rev_id(const phymod_phy_access_t* phy, uint32_t *rev_id)
    249 {
    250     return huracan_rev_id(&phy->access, rev_id);
    251 }
    252 
    253 int huracan_phy_status_dump(const phymod_phy_access_t* phy)
    254 {
    255         return _huracan_phy_status_dump(&phy->access);
    256 }
    257 
    258 int huracan_phy_op_mode_get(const phymod_phy_access_t* phy, phymod_operation_mode_t* op_mode)
    259 {
    260     return PHYMOD_E_UNAVAIL;
    261 }
    262 
    263 #endif /* PHYMOD_HURACAN_SUPPORT */