aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/micrel.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/micrel.c')
-rw-r--r--drivers/net/phy/micrel.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 5a8993b0cafc..5ad971a55c5d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -148,15 +148,52 @@ static int ks8737_config_intr(struct phy_device *phydev)
148 return rc < 0 ? rc : 0; 148 return rc < 0 ? rc : 0;
149} 149}
150 150
151static int kszphy_setup_led(struct phy_device *phydev,
152 unsigned int reg, unsigned int shift)
153{
154
155 struct device *dev = &phydev->dev;
156 struct device_node *of_node = dev->of_node;
157 int rc, temp;
158 u32 val;
159
160 if (!of_node && dev->parent->of_node)
161 of_node = dev->parent->of_node;
162
163 if (of_property_read_u32(of_node, "micrel,led-mode", &val))
164 return 0;
165
166 temp = phy_read(phydev, reg);
167 if (temp < 0)
168 return temp;
169
170 temp &= ~(3 << shift);
171 temp |= val << shift;
172 rc = phy_write(phydev, reg, temp);
173
174 return rc < 0 ? rc : 0;
175}
176
151static int kszphy_config_init(struct phy_device *phydev) 177static int kszphy_config_init(struct phy_device *phydev)
152{ 178{
153 return 0; 179 return 0;
154} 180}
155 181
182static int kszphy_config_init_led8041(struct phy_device *phydev)
183{
184 /* single led control, register 0x1e bits 15..14 */
185 return kszphy_setup_led(phydev, 0x1e, 14);
186}
187
156static int ksz8021_config_init(struct phy_device *phydev) 188static int ksz8021_config_init(struct phy_device *phydev)
157{ 189{
158 int rc;
159 const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE; 190 const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
191 int rc;
192
193 rc = kszphy_setup_led(phydev, 0x1f, 4);
194 if (rc)
195 dev_err(&phydev->dev, "failed to set led mode\n");
196
160 phy_write(phydev, MII_KSZPHY_OMSO, val); 197 phy_write(phydev, MII_KSZPHY_OMSO, val);
161 rc = ksz_config_flags(phydev); 198 rc = ksz_config_flags(phydev);
162 return rc < 0 ? rc : 0; 199 return rc < 0 ? rc : 0;
@@ -166,6 +203,10 @@ static int ks8051_config_init(struct phy_device *phydev)
166{ 203{
167 int rc; 204 int rc;
168 205
206 rc = kszphy_setup_led(phydev, 0x1f, 4);
207 if (rc)
208 dev_err(&phydev->dev, "failed to set led mode\n");
209
169 rc = ksz_config_flags(phydev); 210 rc = ksz_config_flags(phydev);
170 return rc < 0 ? rc : 0; 211 return rc < 0 ? rc : 0;
171} 212}
@@ -327,7 +368,7 @@ static struct phy_driver ksphy_driver[] = {
327 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause 368 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
328 | SUPPORTED_Asym_Pause), 369 | SUPPORTED_Asym_Pause),
329 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 370 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
330 .config_init = kszphy_config_init, 371 .config_init = kszphy_config_init_led8041,
331 .config_aneg = genphy_config_aneg, 372 .config_aneg = genphy_config_aneg,
332 .read_status = genphy_read_status, 373 .read_status = genphy_read_status,
333 .ack_interrupt = kszphy_ack_interrupt, 374 .ack_interrupt = kszphy_ack_interrupt,
@@ -342,7 +383,7 @@ static struct phy_driver ksphy_driver[] = {
342 .features = PHY_BASIC_FEATURES | 383 .features = PHY_BASIC_FEATURES |
343 SUPPORTED_Pause | SUPPORTED_Asym_Pause, 384 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
344 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 385 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
345 .config_init = kszphy_config_init, 386 .config_init = kszphy_config_init_led8041,
346 .config_aneg = genphy_config_aneg, 387 .config_aneg = genphy_config_aneg,
347 .read_status = genphy_read_status, 388 .read_status = genphy_read_status,
348 .ack_interrupt = kszphy_ack_interrupt, 389 .ack_interrupt = kszphy_ack_interrupt,
@@ -371,7 +412,7 @@ static struct phy_driver ksphy_driver[] = {
371 .phy_id_mask = 0x00ffffff, 412 .phy_id_mask = 0x00ffffff,
372 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), 413 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
373 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 414 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
374 .config_init = kszphy_config_init, 415 .config_init = kszphy_config_init_led8041,
375 .config_aneg = genphy_config_aneg, 416 .config_aneg = genphy_config_aneg,
376 .read_status = genphy_read_status, 417 .read_status = genphy_read_status,
377 .ack_interrupt = kszphy_ack_interrupt, 418 .ack_interrupt = kszphy_ack_interrupt,