aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com>2014-08-15 09:00:38 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-16 23:15:54 -0400
commit21009686662fd21412ca35def7cb3cc8346e1c3d (patch)
treee1c0877d3158a8d879a0d776b8e7ffdebfc9ddf4
parent5b7911c1fccb063155a3d4705d39637e676e25be (diff)
net: phy: smsc: move smsc_phy_config_init reset part in a soft_reset function
On the one hand, phy_device.c provides a generic reset function if the phy driver does not provide a soft_reset pointer. This generic reset does not take into account the state of the phy, with a potential failure if the phy is in powerdown mode. On the other hand, smsc driver provides a function with both correct reset behaviour and configuration. This patch moves the reset part into a new smsc_phy_reset function and provides the soft_reset pointer to have a correct reset behaviour by default. Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@armadeus.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/smsc.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 180c49479c42..a4b08198fb9f 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -43,6 +43,22 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
43 43
44static int smsc_phy_config_init(struct phy_device *phydev) 44static int smsc_phy_config_init(struct phy_device *phydev)
45{ 45{
46 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
47
48 if (rc < 0)
49 return rc;
50
51 /* Enable energy detect mode for this SMSC Transceivers */
52 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
53 rc | MII_LAN83C185_EDPWRDOWN);
54 if (rc < 0)
55 return rc;
56
57 return smsc_phy_ack_interrupt(phydev);
58}
59
60static int smsc_phy_reset(struct phy_device *phydev)
61{
46 int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES); 62 int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
47 if (rc < 0) 63 if (rc < 0)
48 return rc; 64 return rc;
@@ -66,18 +82,7 @@ static int smsc_phy_config_init(struct phy_device *phydev)
66 rc = phy_read(phydev, MII_BMCR); 82 rc = phy_read(phydev, MII_BMCR);
67 } while (rc & BMCR_RESET); 83 } while (rc & BMCR_RESET);
68 } 84 }
69 85 return 0;
70 rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
71 if (rc < 0)
72 return rc;
73
74 /* Enable energy detect mode for this SMSC Transceivers */
75 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
76 rc | MII_LAN83C185_EDPWRDOWN);
77 if (rc < 0)
78 return rc;
79
80 return smsc_phy_ack_interrupt (phydev);
81} 86}
82 87
83static int lan911x_config_init(struct phy_device *phydev) 88static int lan911x_config_init(struct phy_device *phydev)
@@ -142,6 +147,7 @@ static struct phy_driver smsc_phy_driver[] = {
142 .config_aneg = genphy_config_aneg, 147 .config_aneg = genphy_config_aneg,
143 .read_status = genphy_read_status, 148 .read_status = genphy_read_status,
144 .config_init = smsc_phy_config_init, 149 .config_init = smsc_phy_config_init,
150 .soft_reset = smsc_phy_reset,
145 151
146 /* IRQ related */ 152 /* IRQ related */
147 .ack_interrupt = smsc_phy_ack_interrupt, 153 .ack_interrupt = smsc_phy_ack_interrupt,
@@ -164,6 +170,7 @@ static struct phy_driver smsc_phy_driver[] = {
164 .config_aneg = genphy_config_aneg, 170 .config_aneg = genphy_config_aneg,
165 .read_status = genphy_read_status, 171 .read_status = genphy_read_status,
166 .config_init = smsc_phy_config_init, 172 .config_init = smsc_phy_config_init,
173 .soft_reset = smsc_phy_reset,
167 174
168 /* IRQ related */ 175 /* IRQ related */
169 .ack_interrupt = smsc_phy_ack_interrupt, 176 .ack_interrupt = smsc_phy_ack_interrupt,
@@ -186,6 +193,7 @@ static struct phy_driver smsc_phy_driver[] = {
186 .config_aneg = genphy_config_aneg, 193 .config_aneg = genphy_config_aneg,
187 .read_status = genphy_read_status, 194 .read_status = genphy_read_status,
188 .config_init = smsc_phy_config_init, 195 .config_init = smsc_phy_config_init,
196 .soft_reset = smsc_phy_reset,
189 197
190 /* IRQ related */ 198 /* IRQ related */
191 .ack_interrupt = smsc_phy_ack_interrupt, 199 .ack_interrupt = smsc_phy_ack_interrupt,
@@ -230,6 +238,7 @@ static struct phy_driver smsc_phy_driver[] = {
230 .config_aneg = genphy_config_aneg, 238 .config_aneg = genphy_config_aneg,
231 .read_status = lan87xx_read_status, 239 .read_status = lan87xx_read_status,
232 .config_init = smsc_phy_config_init, 240 .config_init = smsc_phy_config_init,
241 .soft_reset = smsc_phy_reset,
233 242
234 /* IRQ related */ 243 /* IRQ related */
235 .ack_interrupt = smsc_phy_ack_interrupt, 244 .ack_interrupt = smsc_phy_ack_interrupt,