1111#include <linux/packing.h>
1212#include <net/pkt_sched.h>
1313#include <linux/iopoll.h>
14+ #include <linux/mdio.h>
1415#include <linux/pci.h>
1516#include "felix.h"
1617
1718#define VSC9959_VCAP_IS2_CNT 1024
1819#define VSC9959_VCAP_IS2_ENTRY_WIDTH 376
1920#define VSC9959_VCAP_PORT_CNT 6
20-
21- /* TODO: should find a better place for these */
22- #define USXGMII_BMCR_RESET BIT(15)
23- #define USXGMII_BMCR_AN_EN BIT(12)
24- #define USXGMII_BMCR_RST_AN BIT(9)
25- #define USXGMII_BMSR_LNKS (status ) (((status) & GENMASK(2, 2)) >> 2)
26- #define USXGMII_BMSR_AN_CMPL (status ) (((status) & GENMASK(5, 5)) >> 5)
27- #define USXGMII_ADVERTISE_LNKS (x ) (((x) << 15) & BIT(15))
28- #define USXGMII_ADVERTISE_FDX BIT(12)
29- #define USXGMII_ADVERTISE_SPEED (x ) (((x) << 9) & GENMASK(11, 9))
30- #define USXGMII_LPA_LNKS (lpa ) ((lpa) >> 15)
31- #define USXGMII_LPA_DUPLEX (lpa ) (((lpa) & GENMASK(12, 12)) >> 12)
32- #define USXGMII_LPA_SPEED (lpa ) (((lpa) & GENMASK(11, 9)) >> 9)
33-
3421#define VSC9959_TAS_GCL_ENTRY_MAX 63
3522
36- enum usxgmii_speed {
37- USXGMII_SPEED_10 = 0 ,
38- USXGMII_SPEED_100 = 1 ,
39- USXGMII_SPEED_1000 = 2 ,
40- USXGMII_SPEED_2500 = 4 ,
41- };
42-
4323static const u32 vsc9959_ana_regmap [] = {
4424 REG (ANA_ADVLEARN , 0x0089a0 ),
4525 REG (ANA_VLANMASK , 0x0089a4 ),
@@ -845,11 +825,10 @@ static void vsc9959_pcs_config_usxgmii(struct phy_device *pcs,
845825{
846826 /* Configure device ability for the USXGMII Replicator */
847827 phy_write_mmd (pcs , MDIO_MMD_VEND2 , MII_ADVERTISE ,
848- USXGMII_ADVERTISE_SPEED ( USXGMII_SPEED_2500 ) |
849- USXGMII_ADVERTISE_LNKS ( 1 ) |
828+ MDIO_USXGMII_2500FULL |
829+ MDIO_USXGMII_LINK |
850830 ADVERTISE_SGMII |
851- ADVERTISE_LPACK |
852- USXGMII_ADVERTISE_FDX );
831+ ADVERTISE_LPACK );
853832}
854833
855834void vsc9959_pcs_config (struct ocelot * ocelot , int port ,
@@ -1063,8 +1042,8 @@ static void vsc9959_pcs_link_state_usxgmii(struct phy_device *pcs,
10631042 return ;
10641043
10651044 pcs -> autoneg = true;
1066- pcs -> autoneg_complete = USXGMII_BMSR_AN_CMPL (status );
1067- pcs -> link = USXGMII_BMSR_LNKS (status );
1045+ pcs -> autoneg_complete = !! (status & BMSR_ANEGCOMPLETE );
1046+ pcs -> link = !! (status & BMSR_LSTATUS );
10681047
10691048 if (!pcs -> link || !pcs -> autoneg_complete )
10701049 return ;
@@ -1073,24 +1052,24 @@ static void vsc9959_pcs_link_state_usxgmii(struct phy_device *pcs,
10731052 if (lpa < 0 )
10741053 return ;
10751054
1076- switch (USXGMII_LPA_SPEED ( lpa ) ) {
1077- case USXGMII_SPEED_10 :
1055+ switch (lpa & MDIO_USXGMII_SPD_MASK ) {
1056+ case MDIO_USXGMII_10 :
10781057 pcs -> speed = SPEED_10 ;
10791058 break ;
1080- case USXGMII_SPEED_100 :
1059+ case MDIO_USXGMII_100 :
10811060 pcs -> speed = SPEED_100 ;
10821061 break ;
1083- case USXGMII_SPEED_1000 :
1062+ case MDIO_USXGMII_1000 :
10841063 pcs -> speed = SPEED_1000 ;
10851064 break ;
1086- case USXGMII_SPEED_2500 :
1065+ case MDIO_USXGMII_2500 :
10871066 pcs -> speed = SPEED_2500 ;
10881067 break ;
10891068 default :
10901069 break ;
10911070 }
10921071
1093- if (USXGMII_LPA_DUPLEX ( lpa ) )
1072+ if (lpa & MDIO_USXGMII_FULL_DUPLEX )
10941073 pcs -> duplex = DUPLEX_FULL ;
10951074 else
10961075 pcs -> duplex = DUPLEX_HALF ;
0 commit comments