Commit c624d168bf87e5558a58e99c58b162f5e5b6368e

Authored by Bhupesh Sharma
Committed by Joe Hershberger
1 parent 2eb60902a0

net: phy/realtek: Add support for RTL8211DN and RTL8211E phy modules

This patch adds support for Realtek PHY modules RTL8211DN and
RTL8211E (variants: RTL8211E-VB-CG, RTL8211E-VL-CG, RTL8211EG-VB-CG),
which can be found on Freescale's T1040RDB boards.

To make the driver more generic across 8211 family, a generic name 8211x
is added for macros and function names.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com>
Acked-by: York Sun <yorksun@freescale.com>

Showing 1 changed file with 51 additions and 26 deletions Side-by-side Diff

drivers/net/phy/realtek.c
... ... @@ -12,18 +12,18 @@
12 12  
13 13 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
14 14  
15   -/* RTL8211B PHY Status Register */
16   -#define MIIM_RTL8211B_PHY_STATUS 0x11
17   -#define MIIM_RTL8211B_PHYSTAT_SPEED 0xc000
18   -#define MIIM_RTL8211B_PHYSTAT_GBIT 0x8000
19   -#define MIIM_RTL8211B_PHYSTAT_100 0x4000
20   -#define MIIM_RTL8211B_PHYSTAT_DUPLEX 0x2000
21   -#define MIIM_RTL8211B_PHYSTAT_SPDDONE 0x0800
22   -#define MIIM_RTL8211B_PHYSTAT_LINK 0x0400
  15 +/* RTL8211x PHY Status Register */
  16 +#define MIIM_RTL8211x_PHY_STATUS 0x11
  17 +#define MIIM_RTL8211x_PHYSTAT_SPEED 0xc000
  18 +#define MIIM_RTL8211x_PHYSTAT_GBIT 0x8000
  19 +#define MIIM_RTL8211x_PHYSTAT_100 0x4000
  20 +#define MIIM_RTL8211x_PHYSTAT_DUPLEX 0x2000
  21 +#define MIIM_RTL8211x_PHYSTAT_SPDDONE 0x0800
  22 +#define MIIM_RTL8211x_PHYSTAT_LINK 0x0400
23 23  
24 24  
25   -/* RealTek RTL8211B */
26   -static int rtl8211b_config(struct phy_device *phydev)
  25 +/* RealTek RTL8211x */
  26 +static int rtl8211x_config(struct phy_device *phydev)
27 27 {
28 28 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
29 29  
30 30  
31 31  
32 32  
... ... @@ -32,20 +32,20 @@
32 32 return 0;
33 33 }
34 34  
35   -static int rtl8211b_parse_status(struct phy_device *phydev)
  35 +static int rtl8211x_parse_status(struct phy_device *phydev)
36 36 {
37 37 unsigned int speed;
38 38 unsigned int mii_reg;
39 39  
40   - mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211B_PHY_STATUS);
  40 + mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_STATUS);
41 41  
42   - if (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) {
  42 + if (!(mii_reg & MIIM_RTL8211x_PHYSTAT_SPDDONE)) {
43 43 int i = 0;
44 44  
45 45 /* in case of timeout ->link is cleared */
46 46 phydev->link = 1;
47 47 puts("Waiting for PHY realtime link");
48   - while (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) {
  48 + while (!(mii_reg & MIIM_RTL8211x_PHYSTAT_SPDDONE)) {
49 49 /* Timeout reached ? */
50 50 if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
51 51 puts(" TIMEOUT !\n");
52 52  
53 53  
54 54  
55 55  
56 56  
... ... @@ -57,29 +57,29 @@
57 57 putc('.');
58 58 udelay(1000); /* 1 ms */
59 59 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE,
60   - MIIM_RTL8211B_PHY_STATUS);
  60 + MIIM_RTL8211x_PHY_STATUS);
61 61 }
62 62 puts(" done\n");
63 63 udelay(500000); /* another 500 ms (results in faster booting) */
64 64 } else {
65   - if (mii_reg & MIIM_RTL8211B_PHYSTAT_LINK)
  65 + if (mii_reg & MIIM_RTL8211x_PHYSTAT_LINK)
66 66 phydev->link = 1;
67 67 else
68 68 phydev->link = 0;
69 69 }
70 70  
71   - if (mii_reg & MIIM_RTL8211B_PHYSTAT_DUPLEX)
  71 + if (mii_reg & MIIM_RTL8211x_PHYSTAT_DUPLEX)
72 72 phydev->duplex = DUPLEX_FULL;
73 73 else
74 74 phydev->duplex = DUPLEX_HALF;
75 75  
76   - speed = (mii_reg & MIIM_RTL8211B_PHYSTAT_SPEED);
  76 + speed = (mii_reg & MIIM_RTL8211x_PHYSTAT_SPEED);
77 77  
78 78 switch (speed) {
79   - case MIIM_RTL8211B_PHYSTAT_GBIT:
  79 + case MIIM_RTL8211x_PHYSTAT_GBIT:
80 80 phydev->speed = SPEED_1000;
81 81 break;
82   - case MIIM_RTL8211B_PHYSTAT_100:
  82 + case MIIM_RTL8211x_PHYSTAT_100:
83 83 phydev->speed = SPEED_100;
84 84 break;
85 85 default:
86 86  
87 87  
88 88  
89 89  
90 90  
... ... @@ -89,28 +89,53 @@
89 89 return 0;
90 90 }
91 91  
92   -static int rtl8211b_startup(struct phy_device *phydev)
  92 +static int rtl8211x_startup(struct phy_device *phydev)
93 93 {
94 94 /* Read the Status (2x to make sure link is right) */
95 95 genphy_update_link(phydev);
96   - rtl8211b_parse_status(phydev);
  96 + rtl8211x_parse_status(phydev);
97 97  
98 98 return 0;
99 99 }
100 100  
  101 +/* Support for RTL8211B PHY */
101 102 static struct phy_driver RTL8211B_driver = {
102 103 .name = "RealTek RTL8211B",
103 104 .uid = 0x1cc910,
104 105 .mask = 0xfffff0,
105 106 .features = PHY_GBIT_FEATURES,
106   - .config = &rtl8211b_config,
107   - .startup = &rtl8211b_startup,
  107 + .config = &rtl8211x_config,
  108 + .startup = &rtl8211x_startup,
108 109 .shutdown = &genphy_shutdown,
109 110 };
110 111  
  112 +/* Support for RTL8211E-VB-CG, RTL8211E-VL-CG and RTL8211EG-VB-CG PHYs */
  113 +static struct phy_driver RTL8211E_driver = {
  114 + .name = "RealTek RTL8211E",
  115 + .uid = 0x1cc915,
  116 + .mask = 0xfffff0,
  117 + .features = PHY_GBIT_FEATURES,
  118 + .config = &rtl8211x_config,
  119 + .startup = &rtl8211x_startup,
  120 + .shutdown = &genphy_shutdown,
  121 +};
  122 +
  123 +/* Support for RTL8211DN PHY */
  124 +static struct phy_driver RTL8211DN_driver = {
  125 + .name = "RealTek RTL8211DN",
  126 + .uid = 0x1cc914,
  127 + .mask = 0xfffff0,
  128 + .features = PHY_GBIT_FEATURES,
  129 + .config = &rtl8211x_config,
  130 + .startup = &rtl8211x_startup,
  131 + .shutdown = &genphy_shutdown,
  132 +};
  133 +
111 134 int phy_realtek_init(void)
112 135 {
113 136 phy_register(&RTL8211B_driver);
  137 + phy_register(&RTL8211E_driver);
  138 + phy_register(&RTL8211DN_driver);
114 139  
115 140 return 0;
116 141 }