17 #include <linux/module.h>
22 #define BRCM_PHY_MODEL(phydev) \
23 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
25 #define BRCM_PHY_REV(phydev) \
26 ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
29 #define MII_BCM54XX_ECR 0x10
30 #define MII_BCM54XX_ECR_IM 0x1000
31 #define MII_BCM54XX_ECR_IF 0x0800
33 #define MII_BCM54XX_ESR 0x11
34 #define MII_BCM54XX_ESR_IS 0x1000
36 #define MII_BCM54XX_EXP_DATA 0x15
37 #define MII_BCM54XX_EXP_SEL 0x17
38 #define MII_BCM54XX_EXP_SEL_SSD 0x0e00
39 #define MII_BCM54XX_EXP_SEL_ER 0x0f00
41 #define MII_BCM54XX_AUX_CTL 0x18
42 #define MII_BCM54XX_ISR 0x1a
43 #define MII_BCM54XX_IMR 0x1b
44 #define MII_BCM54XX_INT_CRCERR 0x0001
45 #define MII_BCM54XX_INT_LINK 0x0002
46 #define MII_BCM54XX_INT_SPEED 0x0004
47 #define MII_BCM54XX_INT_DUPLEX 0x0008
48 #define MII_BCM54XX_INT_LRS 0x0010
49 #define MII_BCM54XX_INT_RRS 0x0020
50 #define MII_BCM54XX_INT_SSERR 0x0040
51 #define MII_BCM54XX_INT_UHCD 0x0080
52 #define MII_BCM54XX_INT_NHCD 0x0100
53 #define MII_BCM54XX_INT_NHCDL 0x0200
54 #define MII_BCM54XX_INT_ANPR 0x0400
55 #define MII_BCM54XX_INT_LC 0x0800
56 #define MII_BCM54XX_INT_HC 0x1000
57 #define MII_BCM54XX_INT_MDIX 0x2000
58 #define MII_BCM54XX_INT_PSERR 0x4000
60 #define MII_BCM54XX_SHD 0x1c
61 #define MII_BCM54XX_SHD_WRITE 0x8000
62 #define MII_BCM54XX_SHD_VAL(x) ((x & 0x1f) << 10)
63 #define MII_BCM54XX_SHD_DATA(x) ((x & 0x3ff) << 0)
68 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL 0x0000
69 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB 0x0400
70 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA 0x0800
72 #define MII_BCM54XX_AUXCTL_MISC_WREN 0x8000
73 #define MII_BCM54XX_AUXCTL_MISC_FORCE_AMDIX 0x0200
74 #define MII_BCM54XX_AUXCTL_MISC_RDSEL_MISC 0x7000
75 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC 0x0007
77 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL 0x0000
84 #define BCM_LED_SRC_LINKSPD1 0x0
85 #define BCM_LED_SRC_LINKSPD2 0x1
86 #define BCM_LED_SRC_XMITLED 0x2
87 #define BCM_LED_SRC_ACTIVITYLED 0x3
88 #define BCM_LED_SRC_FDXLED 0x4
89 #define BCM_LED_SRC_SLAVE 0x5
90 #define BCM_LED_SRC_INTR 0x6
91 #define BCM_LED_SRC_QUALITY 0x7
92 #define BCM_LED_SRC_RCVLED 0x8
93 #define BCM_LED_SRC_MULTICOLOR1 0xa
94 #define BCM_LED_SRC_OPENSHORT 0xb
95 #define BCM_LED_SRC_OFF 0xe
96 #define BCM_LED_SRC_ON 0xf
105 #define BCM54XX_SHD_SCR3 0x05
106 #define BCM54XX_SHD_SCR3_DEF_CLK125 0x0001
107 #define BCM54XX_SHD_SCR3_DLLAPD_DIS 0x0002
108 #define BCM54XX_SHD_SCR3_TRDDAPD 0x0004
111 #define BCM54XX_SHD_APD 0x0a
112 #define BCM54XX_SHD_APD_EN 0x0020
114 #define BCM5482_SHD_LEDS1 0x0d
116 #define BCM5482_SHD_LEDS1_LED3(src) ((src & 0xf) << 4)
118 #define BCM5482_SHD_LEDS1_LED1(src) ((src & 0xf) << 0)
119 #define BCM54XX_SHD_RGMII_MODE 0x0b
120 #define BCM5482_SHD_SSD 0x14
121 #define BCM5482_SHD_SSD_LEDM 0x0008
122 #define BCM5482_SHD_SSD_EN 0x0001
123 #define BCM5482_SHD_MODE 0x1f
124 #define BCM5482_SHD_MODE_1000BX 0x0001
130 #define MII_BCM54XX_EXP_AADJ1CH0 0x001f
131 #define MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN 0x0200
132 #define MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF 0x0100
133 #define MII_BCM54XX_EXP_AADJ1CH3 0x601f
134 #define MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ 0x0002
135 #define MII_BCM54XX_EXP_EXP08 0x0F08
136 #define MII_BCM54XX_EXP_EXP08_RJCT_2MHZ 0x0001
137 #define MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE 0x0200
138 #define MII_BCM54XX_EXP_EXP75 0x0f75
139 #define MII_BCM54XX_EXP_EXP75_VDACCTRL 0x003c
140 #define MII_BCM54XX_EXP_EXP75_CM_OSC 0x0001
141 #define MII_BCM54XX_EXP_EXP96 0x0f96
142 #define MII_BCM54XX_EXP_EXP96_MYST 0x0010
143 #define MII_BCM54XX_EXP_EXP97 0x0f97
144 #define MII_BCM54XX_EXP_EXP97_MYST 0x0c0c
149 #define BCM5482_SSD_1000BX_CTL 0x00
150 #define BCM5482_SSD_1000BX_CTL_PWRDOWN 0x0800
151 #define BCM5482_SSD_SGMII_SLAVE 0x15
152 #define BCM5482_SSD_SGMII_SLAVE_EN 0x0002
153 #define BCM5482_SSD_SGMII_SLAVE_AD 0x0001
160 #define MII_BRCM_FET_INTREG 0x1a
161 #define MII_BRCM_FET_IR_MASK 0x0100
162 #define MII_BRCM_FET_IR_LINK_EN 0x0200
163 #define MII_BRCM_FET_IR_SPEED_EN 0x0400
164 #define MII_BRCM_FET_IR_DUPLEX_EN 0x0800
165 #define MII_BRCM_FET_IR_ENABLE 0x4000
167 #define MII_BRCM_FET_BRCMTEST 0x1f
168 #define MII_BRCM_FET_BT_SRE 0x0080
173 #define MII_BRCM_FET_SHDW_MISCCTRL 0x10
174 #define MII_BRCM_FET_SHDW_MC_FAME 0x4000
176 #define MII_BRCM_FET_SHDW_AUXMODE4 0x1a
177 #define MII_BRCM_FET_SHDW_AM4_LED_MASK 0x0003
178 #define MII_BRCM_FET_SHDW_AM4_LED_MODE1 0x0001
180 #define MII_BRCM_FET_SHDW_AUXSTAT2 0x1b
181 #define MII_BRCM_FET_SHDW_AS2_APDE 0x0020
207 static int bcm54xx_exp_read(
struct phy_device *phydev,
u16 regnum)
223 static int bcm54xx_exp_write(
struct phy_device *phydev,
u16 regnum,
u16 val)
239 static int bcm54xx_auxctl_write(
struct phy_device *phydev,
u16 regnum,
u16 val)
245 static int bcm50610_a0_workaround(
struct phy_device *phydev)
276 static int bcm54xx_phydsp_config(
struct phy_device *phydev)
281 err = bcm54xx_auxctl_write(phydev,
297 err = bcm50610_a0_workaround(phydev);
316 err2 = bcm54xx_auxctl_write(phydev,
321 return err ? err : err2;
324 static void bcm54xx_adjust_rxrefclk(
struct phy_device *phydev)
328 bool clk125en =
true;
384 static int bcm54xx_config_init(
struct phy_device *phydev)
414 bcm54xx_adjust_rxrefclk(phydev);
416 bcm54xx_phydsp_config(phydev);
421 static int bcm5482_config_init(
struct phy_device *phydev)
425 err = bcm54xx_config_init(phydev);
441 err = bcm54xx_exp_read(phydev, reg);
444 err = bcm54xx_exp_write(phydev, reg, err |
454 err = bcm54xx_exp_read(phydev, reg);
457 err = bcm54xx_exp_write(phydev, reg,
491 static int bcm5482_read_status(
struct phy_device *phydev)
511 static int bcm54xx_ack_interrupt(
struct phy_device *phydev)
523 static int bcm54xx_config_intr(
struct phy_device *phydev)
540 static int bcm5481_config_aneg(
struct phy_device *phydev)
561 reg = 0x7 | (0x7 << 12);
575 static int brcm_phy_setbits(
struct phy_device *phydev,
int reg,
int set)
583 return phy_write(phydev, reg, val |
set);
586 static int brcm_fet_config_init(
struct phy_device *phydev)
588 int reg,
err, err2, brcmtest;
656 static int brcm_fet_ack_interrupt(
struct phy_device *phydev)
668 static int brcm_fet_config_intr(
struct phy_device *phydev)
685 static struct phy_driver broadcom_drivers[] = {
688 .phy_id_mask = 0xfffffff0,
689 .name =
"Broadcom BCM5411",
693 .config_init = bcm54xx_config_init,
696 .ack_interrupt = bcm54xx_ack_interrupt,
697 .config_intr = bcm54xx_config_intr,
701 .phy_id_mask = 0xfffffff0,
702 .name =
"Broadcom BCM5421",
706 .config_init = bcm54xx_config_init,
709 .ack_interrupt = bcm54xx_ack_interrupt,
710 .config_intr = bcm54xx_config_intr,
714 .phy_id_mask = 0xfffffff0,
715 .name =
"Broadcom BCM5461",
719 .config_init = bcm54xx_config_init,
722 .ack_interrupt = bcm54xx_ack_interrupt,
723 .config_intr = bcm54xx_config_intr,
727 .phy_id_mask = 0xfffffff0,
728 .name =
"Broadcom BCM5464",
732 .config_init = bcm54xx_config_init,
735 .ack_interrupt = bcm54xx_ack_interrupt,
736 .config_intr = bcm54xx_config_intr,
740 .phy_id_mask = 0xfffffff0,
741 .name =
"Broadcom BCM5481",
745 .config_init = bcm54xx_config_init,
746 .config_aneg = bcm5481_config_aneg,
748 .ack_interrupt = bcm54xx_ack_interrupt,
749 .config_intr = bcm54xx_config_intr,
753 .phy_id_mask = 0xfffffff0,
754 .name =
"Broadcom BCM5482",
758 .config_init = bcm5482_config_init,
760 .read_status = bcm5482_read_status,
761 .ack_interrupt = bcm54xx_ack_interrupt,
762 .config_intr = bcm54xx_config_intr,
766 .phy_id_mask = 0xfffffff0,
767 .name =
"Broadcom BCM50610",
771 .config_init = bcm54xx_config_init,
774 .ack_interrupt = bcm54xx_ack_interrupt,
775 .config_intr = bcm54xx_config_intr,
779 .phy_id_mask = 0xfffffff0,
780 .name =
"Broadcom BCM50610M",
784 .config_init = bcm54xx_config_init,
787 .ack_interrupt = bcm54xx_ack_interrupt,
788 .config_intr = bcm54xx_config_intr,
792 .phy_id_mask = 0xfffffff0,
793 .name =
"Broadcom BCM57780",
797 .config_init = bcm54xx_config_init,
800 .ack_interrupt = bcm54xx_ack_interrupt,
801 .config_intr = bcm54xx_config_intr,
805 .phy_id_mask = 0xfffffff0,
806 .name =
"Broadcom BCMAC131",
810 .config_init = brcm_fet_config_init,
813 .ack_interrupt = brcm_fet_ack_interrupt,
814 .config_intr = brcm_fet_config_intr,
818 .phy_id_mask = 0xfffffff0,
819 .name =
"Broadcom BCM5241",
823 .config_init = brcm_fet_config_init,
826 .ack_interrupt = brcm_fet_ack_interrupt,
827 .config_intr = brcm_fet_config_intr,
831 static int __init broadcom_init(
void)
837 static void __exit broadcom_exit(
void)