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

drv.h (15319B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        drv.h
      8  * Purpose:     Link Layer interface (PHY)
      9  */
     10 
     11 #ifndef _PHY_DRV_H
     12 #define _PHY_DRV_H
     13 
     14 #include <shared/port.h>
     15 #include <shared/phyconfig.h>
     16 
     17 #include <soc/defs.h>
     18 #include <soc/macipadr.h>
     19 #include <soc/portmode.h>
     20 #include <soc/phyctrl.h>
     21 #include <soc/phy/phyctrl.h>
     22 #include <soc/port_ability.h>
     23 #include <soc/timesync.h>
     24 #include <soc/oam.h>
     25 
     26 /*
     27  * Typedef:
     28  *      phy_driver_t
     29  * Purpose:
     30  *      Maps out entry points into PHY drivers.
     31  * Notes:
     32  *      Supplied functions are:
     33  *
     34  *      pd_init         - Initialize the PHY to a known good state.
     35  *      pd_reset        - Reset and setup the PHY (used by pd_init, after
     36  *                        link_down, etc.)
     37  *      pd_link_get     - Retrieve current link status from PHY.
     38  *      pd_enable_set   - Enable/Disable the PHY physical interface.
     39  *      pd_enable_get   - Retrieve current PHY Enable/disable mode.
     40  *      pd_duplex_set   - Set the non-negotiated duplex mode (does not
     41  *                        disable autonegotiation at this layer).
     42  *      pd_duplex_get   - Get the current operating duplicity (if
     43  *                        auto-negotiation is enabled, negotiated speed
     44  *                        returned, otherwise fixed speed returned).
     45  *      pd_speed_set    - Set the non-negotiated speed in the PHY (does
     46  *                        not disable auto-negotiation at this layer).
     47  *      pd_speed_get    - Get the current operating speed (if
     48  *                        auto-negotiation is enabled, negotiated speed
     49  *                        returned, otherwise fixed speed returned).
     50  *      pd_master_set   - Set the master/slave mode for PHYs that need it
     51  *                        (does not disable auto-negotiation at this layer).
     52  *      pd_master_get   - Get the current master/slave mode for the PHY
     53  *                        (if auto-negotiation is enabled, negotiated master
     54  *                        returned, otherwise fixed master returned).
     55  *      pd_an_set       - Enable/Disable autonegotiation
     56  *      pd_an_get       - Retrieve current autonegotiation settings.
     57  *      pd_adv_local_set- Set local advertisement (does not enable
     58  *                        autonegotiation).
     59  *      pd_adv_local_get- Get local advertisement for auto-negotiation.
     60  *      pd_adv_remote_get- Retrieve remote advertisement if auto-negotiation
     61  *                        is enabled.
     62  *      pd_lb_set       - Enable/Disable PHY loopback.
     63  *      pd_lb_get       - Retrieve current PHY loopback mode.
     64  *      pd_interface_set- Set MAC-PHY interface type (SOC_PORT_IF_*)
     65  *      pd_interface_get- Get MAC-PHY interface type
     66  *      pd_ability      - Retrieve PHY abilities.
     67  *      pd_linkup_evt   - Call back for link up event
     68  *      pd_linkdn_evt   - Call back for link down event
     69  *      pd_mdix_set          - Set MDIX mode for the port
     70  *      pd_mdix_get          - Get the MDIX mode for the port
     71  *      pd_mdix_status_get   - Get the MDI crossover status for the port
     72  *      pd_medium_config_set - Set medium-dependent configuration
     73  *      pd_medium_config_get - Get medium-dependent configuration
     74  *      pd_medium_get        - Get active medium
     75  *      pd_cable_diag   - Run Cable Diagnostics
     76  *      pd_control_set  - Set PHY specific control settings
     77  *      pd_control_get  - Get PHY specific control settings
     78  *
     79  * All routines return SOC_E_XXX values.
     80  * Null pointers for routines will cause SOC_E_UNAVAIL to be returned.
     81  *
     82  * Macros are provided to access the fields.
     83  */
     84 typedef struct phy_driver_s {
     85     char *drv_name;
     86     int  (*pd_init)(int, soc_port_t);
     87     int  (*pd_reset)(int, soc_port_t, void *);
     88     int  (*pd_link_get)(int, soc_port_t, int *);
     89     int  (*pd_enable_set)(int, soc_port_t, int);
     90     int  (*pd_enable_get)(int, soc_port_t, int *);
     91     int  (*pd_duplex_set)(int, soc_port_t, int);
     92     int  (*pd_duplex_get)(int, soc_port_t, int *);
     93     int  (*pd_speed_set)(int, soc_port_t, int);
     94     int  (*pd_speed_get)(int, soc_port_t, int *);
     95     int  (*pd_master_set)(int, soc_port_t, int);
     96     int  (*pd_master_get)(int, soc_port_t, int *);
     97     int  (*pd_an_set)(int, soc_port_t, int);
     98     int  (*pd_an_get)(int, soc_port_t, int *, int *);
     99     int  (*pd_adv_local_set)(int, soc_port_t, soc_port_mode_t);
    100     int  (*pd_adv_local_get)(int, soc_port_t, soc_port_mode_t *);
    101     int  (*pd_adv_remote_get)(int, soc_port_t, soc_port_mode_t *);
    102     int  (*pd_lb_set)(int, soc_port_t, int);
    103     int  (*pd_lb_get)(int, soc_port_t, int *);
    104     int  (*pd_interface_set)(int, soc_port_t, soc_port_if_t);
    105     int  (*pd_interface_get)(int, soc_port_t, soc_port_if_t *);
    106     int  (*pd_ability)(int, soc_port_t, soc_port_mode_t *);
    107     int  (*pd_linkup_evt)(int, soc_port_t);
    108     int  (*pd_linkdn_evt)(int, soc_port_t);
    109     int  (*pd_mdix_set)(int, soc_port_t, soc_port_mdix_t);
    110     int  (*pd_mdix_get)(int, soc_port_t, soc_port_mdix_t *);
    111     int  (*pd_mdix_status_get)(int, soc_port_t,
    112                                soc_port_mdix_status_t *);
    113     int  (*pd_medium_config_set)(int, soc_port_t, soc_port_medium_t,
    114                                  soc_phy_config_t *);
    115     int  (*pd_medium_config_get)(int, soc_port_t, soc_port_medium_t,
    116                                  soc_phy_config_t *);
    117     int  (*pd_medium_get)(int, soc_port_t, soc_port_medium_t *);
    118     int  (*pd_cable_diag)(int, soc_port_t, soc_port_cable_diag_t *);
    119     int  (*pd_link_change)(int, soc_port_t, int *);
    120     int  (*pd_control_set)(int, soc_port_t, soc_phy_control_t, uint32); 
    121     int  (*pd_control_get)(int, soc_port_t, soc_phy_control_t, uint32 *); 
    122     int  (*pd_reg_read)(int, soc_port_t, uint32, uint32, uint32 *);
    123     int  (*pd_reg_write)(int, soc_port_t, uint32, uint32, uint32);
    124     int  (*pd_reg_modify)(int, soc_port_t, uint32, uint32, uint32, uint32);
    125     int  (*pd_notify)(int, soc_port_t, soc_phy_event_t, uint32);
    126     int  (*pd_probe)(int, phy_ctrl_t *);
    127     int  (*pd_ability_advert_set)(int, soc_port_t, soc_port_ability_t *);
    128     int  (*pd_ability_advert_get)(int, soc_port_t, soc_port_ability_t *);
    129     int  (*pd_ability_remote_get)(int, soc_port_t, soc_port_ability_t *);
    130     int  (*pd_ability_local_get)(int, soc_port_t, soc_port_ability_t *);
    131     int  (*pd_firmware_set)(int,soc_port_t,int,uint8 *,int);
    132     int  (*pd_timesync_config_set)(int, soc_port_t, soc_port_phy_timesync_config_t *);
    133     int  (*pd_timesync_config_get)(int, soc_port_t, soc_port_phy_timesync_config_t *);
    134     int  (*pd_timesync_control_set)(int, soc_port_t, soc_port_control_phy_timesync_t, uint64);
    135     int  (*pd_timesync_control_get)(int, soc_port_t, soc_port_control_phy_timesync_t, uint64 *);
    136     int  (*pd_diag_ctrl)(int,soc_port_t,uint32,int,int,void *);
    137     int  (*pd_lane_control_set)(int, soc_port_t, int, soc_phy_control_t, uint32); 
    138     int  (*pd_lane_control_get)(int, soc_port_t, int, soc_phy_control_t, uint32 *); 
    139     int  (*pd_lane_reg_read)(int, soc_port_t, int, uint32, uint32, uint32 *);
    140     int  (*pd_lane_reg_write)(int, soc_port_t, int, uint32, uint32, uint32);
    141     int  (*pd_oam_config_set)(int, soc_port_t, soc_port_config_phy_oam_t *);
    142     int  (*pd_oam_config_get)(int, soc_port_t, soc_port_config_phy_oam_t *);
    143     int  (*pd_oam_control_set)(int, soc_port_t, soc_port_control_phy_oam_t, uint64);
    144     int  (*pd_oam_control_get)(int, soc_port_t, soc_port_control_phy_oam_t, uint64 *);
    145     int  (*pd_timesync_enhanced_capture_get)(int, soc_port_t, soc_port_phy_timesync_enhanced_capture_t *);
    146     int  (*pd_multi_get)(int, soc_port_t, uint32, uint32, uint32, int, uint8 *, int *);
    147     int  (*pd_precondition_before_probe)(int, phy_ctrl_t *);
    148     int  (*pd_linkfault_get)(int, soc_port_t, int *);
    149     int  (*pd_synce_clk_ctrl_set)(int, soc_port_t, uint32, uint32, uint32);
    150     int  (*pd_synce_clk_ctrl_get)(int, soc_port_t, uint32 *, uint32 *, uint32 *);
    151 } phy_driver_t;
    152 
    153 #define _PHY_CALL(_pd, _pf, _pa) \
    154         ((_pd) == 0 ? SOC_E_PARAM : \
    155          ((_pd)->_pf == 0 ? SOC_E_UNAVAIL : (_pd)->_pf _pa))
    156 
    157 #define PHY_INIT(_pd, _u, _p) \
    158         _PHY_CALL((_pd), pd_init, ((_u), (_p)))
    159 
    160 #define PHY_RESET(_pd, _u, _p) \
    161         _PHY_CALL((_pd), pd_reset, ((_u), (_p), NULL))
    162 
    163 #define PHY_LINK_GET(_pd, _u, _p, _l) \
    164         _PHY_CALL((_pd), pd_link_get, ((_u), (_p), (_l)))
    165 
    166 #define PHY_LINKFAULT_GET(_pd, _u, _p, _l) \
    167         _PHY_CALL((_pd), pd_linkfault_get, ((_u), (_p), (_l)))
    168 
    169 #define PHY_ENABLE_SET(_pd, _u, _p, _l) \
    170         _PHY_CALL((_pd), pd_enable_set, ((_u), (_p), (_l)))
    171 
    172 #define PHY_ENABLE_GET(_pd, _u, _p, _l) \
    173         _PHY_CALL((_pd), pd_enable_get, ((_u), (_p), (_l)))
    174 
    175 #define PHY_DUPLEX_SET(_pd, _u, _p, _d) \
    176         _PHY_CALL((_pd), pd_duplex_set, ((_u), (_p), (_d)))
    177 
    178 #define PHY_DUPLEX_GET(_pd, _u, _p, _d) \
    179         _PHY_CALL((_pd), pd_duplex_get, ((_u), (_p), (_d)))
    180 
    181 #define PHY_SPEED_SET(_pd, _u, _p, _s) \
    182         _PHY_CALL((_pd), pd_speed_set, ((_u), (_p), (_s)))
    183 
    184 #define PHY_SPEED_GET(_pd, _u, _p, _s) \
    185         _PHY_CALL((_pd), pd_speed_get, ((_u), (_p), (_s)))
    186 
    187 #define PHY_MASTER_SET(_pd, _u, _p, _s) \
    188         _PHY_CALL((_pd), pd_master_set, ((_u), (_p), (_s)))
    189 
    190 #define PHY_MASTER_GET(_pd, _u, _p, _s) \
    191         _PHY_CALL((_pd), pd_master_get, ((_u), (_p), (_s)))
    192 
    193 #define PHY_AUTO_NEGOTIATE_SET(_pd, _u, _p, _a) \
    194         _PHY_CALL((_pd), pd_an_set, ((_u), (_p), (_a)))
    195 
    196 #define PHY_AUTO_NEGOTIATE_GET(_pd, _u, _p, _a, _b) \
    197         _PHY_CALL((_pd), pd_an_get, ((_u), (_p), (_a), (_b)))
    198 
    199 #define PHY_ADV_SET(_pd, _u, _p, _a) \
    200         _PHY_CALL((_pd), pd_adv_local_set, ((_u), (_p), (_a)))
    201 
    202 #define PHY_ADV_GET(_pd, _u, _p, _a) \
    203         _PHY_CALL((_pd), pd_adv_local_get, ((_u), (_p), (_a)))
    204 
    205 #define PHY_LOOPBACK_SET(_pd, _u, _p, _l) \
    206         _PHY_CALL((_pd), pd_lb_set, ((_u), (_p), (_l)))
    207 
    208 #define PHY_LOOPBACK_GET(_pd, _u, _p, _l) \
    209         _PHY_CALL((_pd), pd_lb_get, ((_u), (_p), (_l)))
    210 
    211 #define PHY_INTERFACE_SET(_pd, _u, _p, _i) \
    212         _PHY_CALL((_pd), pd_interface_set, ((_u), (_p), (_i)))
    213 
    214 #define PHY_INTERFACE_GET(_pd, _u, _p, _i) \
    215         _PHY_CALL((_pd), pd_interface_get, ((_u), (_p), (_i)))
    216 
    217 #define PHY_ABILITY_GET(_pd, _u, _p, _m) \
    218         _PHY_CALL((_pd), pd_ability, ((_u), (_p), (_m)))
    219 
    220 #define PHY_LINKUP_EVT(_pd, _u, _p) \
    221         _PHY_CALL((_pd), pd_linkup_evt, ((_u), (_p)))
    222 
    223 #define PHY_LINKDN_EVT(_pd, _u, _p) \
    224         _PHY_CALL((_pd), pd_linkdn_evt, ((_u), (_p)))
    225 
    226 #define PHY_ADV_REMOTE_GET(_pd, _u, _p, _m) \
    227         _PHY_CALL((_pd), pd_adv_remote_get, ((_u), (_p), (_m)))
    228 
    229 #define PHY_MDIX_SET(_pd, _u, _p, _m) \
    230         _PHY_CALL((_pd), pd_mdix_set, ((_u), (_p), (_m)))
    231 
    232 #define PHY_MDIX_GET(_pd, _u, _p, _m) \
    233         _PHY_CALL((_pd), pd_mdix_get, ((_u), (_p), (_m)))
    234 
    235 #define PHY_MDIX_STATUS_GET(_pd, _u, _p, _s) \
    236         _PHY_CALL((_pd), pd_mdix_status_get, ((_u), (_p), (_s)))
    237 
    238 #define PHY_MEDIUM_CONFIG_SET(_pd, _u, _p, _m, _c) \
    239         _PHY_CALL((_pd), pd_medium_config_set, ((_u), (_p), (_m), (_c)))
    240 
    241 #define PHY_MEDIUM_CONFIG_GET(_pd, _u, _p, _m, _c) \
    242         _PHY_CALL((_pd), pd_medium_config_get, ((_u), (_p), (_m), (_c)))
    243 
    244 #define PHY_MEDIUM_GET(_pd, _u, _p, _m) \
    245         _PHY_CALL((_pd), pd_medium_get, ((_u), (_p), (_m)))
    246 
    247 #define PHY_CABLE_DIAG(_pd, _u, _p, _status) \
    248         _PHY_CALL((_pd), pd_cable_diag, ((_u), (_p), (_status)))
    249 
    250 #define PHY_LINK_CHANGE(_pd, _u, _p, _l) \
    251         _PHY_CALL((_pd), pd_link_change, ((_u), (_p), (_l)))
    252 
    253 #define PHY_CONTROL_SET(_pd, _u, _p, _t, _v) \
    254         _PHY_CALL((_pd), pd_control_set, ((_u), (_p), (_t), (_v)))
    255 
    256 #define PHY_CONTROL_GET(_pd, _u, _p, _t, _v) \
    257         _PHY_CALL((_pd), pd_control_get, ((_u), (_p), (_t), (_v)))
    258 
    259 #define PHY_REG_READ(_pd, _u, _p, _f, _a, _v) \
    260         _PHY_CALL((_pd), pd_reg_read, ((_u), (_p), (_f), (_a), (_v)))
    261 
    262 #define PHY_REG_WRITE(_pd, _u, _p, _f, _a, _v) \
    263         _PHY_CALL((_pd), pd_reg_write, ((_u), (_p), (_f), (_a), (_v)))
    264 
    265 #define PHY_REG_MODIFY(_pd, _u, _p, _f, _a, _v, _m) \
    266         _PHY_CALL((_pd), pd_reg_modify, ((_u), (_p), (_f), (_a), (_v), (_m)))
    267 
    268 #define PHY_NOTIFY(_pd, _u, _p, _e, _v) \
    269         _PHY_CALL((_pd), pd_notify, ((_u), (_p), (_e), (_v)))
    270 
    271 #define PHY_PROBE(_pd, _u, _pc) \
    272         _PHY_CALL((_pd), pd_probe, ((_u), (_pc)))
    273 
    274 #define PHY_PRECONDITION_BEFORE_PROBE(_pd, _u, _pc) \
    275         _PHY_CALL((_pd), pd_precondition_before_probe, ((_u), (_pc)))
    276 
    277 #define PHY_ABILITY_ADVERT_SET(_pd, _u, _p, _pa) \
    278         _PHY_CALL((_pd), pd_ability_advert_set, ((_u), (_p), (_pa)))
    279 
    280 #define PHY_ABILITY_ADVERT_GET(_pd, _u, _p, _pa) \
    281         _PHY_CALL((_pd), pd_ability_advert_get, ((_u), (_p), (_pa)))
    282 
    283 #define PHY_ABILITY_REMOTE_GET(_pd, _u, _p, _pa) \
    284         _PHY_CALL((_pd), pd_ability_remote_get, ((_u), (_p), (_pa)))
    285  
    286 #define PHY_ABILITY_LOCAL_GET(_pd, _u, _p, _pa) \
    287         _PHY_CALL((_pd), pd_ability_local_get, ((_u), (_p), (_pa)))
    288 
    289 #define PHY_FIRMWARE_SET(_pd, _u, _p, _o, _a, _l) \
    290         _PHY_CALL((_pd), pd_firmware_set, ((_u),(_p),(_o),(_a),(_l)))
    291 
    292 #define PHY_TIMESYNC_CONFIG_SET(_pd, _u, _p, _c) \
    293         _PHY_CALL((_pd), pd_timesync_config_set, ((_u),(_p),(_c)))
    294 
    295 #define PHY_TIMESYNC_CONFIG_GET(_pd, _u, _p, _c) \
    296         _PHY_CALL((_pd), pd_timesync_config_get, ((_u),(_p),(_c)))
    297 
    298 #define PHY_TIMESYNC_CONTROL_SET(_pd, _u, _p, _t, _v) \
    299         _PHY_CALL((_pd), pd_timesync_control_set, ((_u),(_p),(_t),(_v)))
    300 
    301 #define PHY_TIMESYNC_CONTROL_GET(_pd, _u, _p, _t, _v) \
    302         _PHY_CALL((_pd), pd_timesync_control_get, ((_u),(_p),(_t),(_v)))
    303 
    304 #define PHY_TIMESYNC_ENHANCED_CAPTURE_GET(_pd, _u, _p, _c) \
    305         _PHY_CALL((_pd), pd_timesync_enhanced_capture_get, ((_u),(_p),(_c)))
    306 
    307 #define PHY_DIAG_CTRL(_pd, _u, _p, _i, _o, _c,_a) \
    308         _PHY_CALL((_pd), pd_diag_ctrl, ((_u),(_p),(_i),(_o),(_c),(_a)))
    309 
    310 #define PHY_LANE_CONTROL_SET(_pd, _u, _p, _l, _t, _v) \
    311         _PHY_CALL((_pd), pd_lane_control_set, ((_u), (_p), (_l), (_t), (_v)))
    312 
    313 #define PHY_LANE_CONTROL_GET(_pd, _u, _p, _l, _t, _v) \
    314         _PHY_CALL((_pd), pd_lane_control_get, ((_u), (_p), (_l), (_t), (_v)))
    315 
    316 #define PHY_LANE_REG_READ(_pd, _u, _p, _l, _f, _a, _v) \
    317         _PHY_CALL((_pd), pd_lane_reg_read, \
    318                                 ((_u), (_p), (_l), (_f), (_a), (_v)))
    319 
    320 #define PHY_LANE_REG_WRITE(_pd, _u, _p, _l, _f, _a, _v) \
    321         _PHY_CALL((_pd), pd_lane_reg_write, \
    322                                 ((_u), (_p), (_l), (_f), (_a), (_v)))
    323 #define PHY_OAM_CONFIG_SET(_pd, _u, _p, _c) \
    324         _PHY_CALL((_pd), pd_oam_config_set, ((_u),(_p),(_c)))
    325 
    326 #define PHY_OAM_CONFIG_GET(_pd, _u, _p, _c) \
    327         _PHY_CALL((_pd), pd_oam_config_get, ((_u),(_p),(_c)))
    328 
    329 #define PHY_OAM_CONTROL_SET(_pd, _u, _p, _t, _v) \
    330         _PHY_CALL((_pd), pd_oam_control_set, ((_u),(_p),(_t),(_v)))
    331 
    332 #define PHY_OAM_CONTROL_GET(_pd, _u, _p, _t, _v) \
    333         _PHY_CALL((_pd), pd_oam_control_get, ((_u),(_p),(_t),(_v)))
    334 
    335 #define PHY_MULTI_GET(_pd, _u, _p, _f, _a, _o, _m, _d, _s) \
    336         _PHY_CALL((_pd), pd_multi_get, ((_u),(_p), (_f), (_a), (_o), (_m), (_d), (_s)))
    337 
    338 #define PHY_SYNCE_CLK_SET(_pd, _u, _p, _m0, _m1, _v) \
    339         _PHY_CALL((_pd), pd_synce_clk_ctrl_set, ((_u),(_p),(_m0),(_m1),(_v)))
    340 
    341 #define PHY_SYNCE_CLK_GET(_pd, _u, _p, _m0, _m1, _v) \
    342         _PHY_CALL((_pd), pd_synce_clk_ctrl_get, ((_u),(_p),(_m0),(_m1),(_v)))
    343 
    344 extern  int soc_phy_nocxn(int unit, phy_driver_t **phyd_ptr);
    345 
    346 #endif  /* _PHY_DRV_H */