aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>2011-11-15 06:54:15 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-15 16:56:17 -0500
commit64882709ef07f3eae29c7afc5aa8b84d12733a72 (patch)
treee5504eef06ec6841b429f47e4b4cddf52d9fe5fa
parent229a66e3bec97563aa92e25dfe0bc60b0d468619 (diff)
mdio-gpio: Add reset functionality to mdio-gpio driver(v2).
This patch adds phy reset functionality to mdio-gpio driver. Now mdio_gpio_platform_data has new member as function pointer which can be filled at the bsp level for a callback from phy infrastructure. Also the mdio-bitbang driver fills-in the reset function of mii_bus structure. Without this patch the bsp level code has to takecare of the reseting PHY's on the bus, which become bit hacky for every bsp and phy-infrastructure is ignored aswell. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/mdio-bitbang.c9
-rw-r--r--drivers/net/phy/mdio-gpio.c1
-rw-r--r--include/linux/mdio-bitbang.h2
-rw-r--r--include/linux/mdio-gpio.h2
4 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 65391891d8c4..daec9b05d168 100644
--- a/drivers/net/phy/mdio-bitbang.c
+++ b/drivers/net/phy/mdio-bitbang.c
@@ -202,6 +202,14 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
202 return 0; 202 return 0;
203} 203}
204 204
205static int mdiobb_reset(struct mii_bus *bus)
206{
207 struct mdiobb_ctrl *ctrl = bus->priv;
208 if (ctrl->reset)
209 ctrl->reset(bus);
210 return 0;
211}
212
205struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) 213struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
206{ 214{
207 struct mii_bus *bus; 215 struct mii_bus *bus;
@@ -214,6 +222,7 @@ struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
214 222
215 bus->read = mdiobb_read; 223 bus->read = mdiobb_read;
216 bus->write = mdiobb_write; 224 bus->write = mdiobb_write;
225 bus->reset = mdiobb_reset;
217 bus->priv = ctrl; 226 bus->priv = ctrl;
218 227
219 return bus; 228 return bus;
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 2843c90f712f..89c5a3eccc12 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -95,6 +95,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
95 goto out; 95 goto out;
96 96
97 bitbang->ctrl.ops = &mdio_gpio_ops; 97 bitbang->ctrl.ops = &mdio_gpio_ops;
98 bitbang->ctrl.reset = pdata->reset;
98 bitbang->mdc = pdata->mdc; 99 bitbang->mdc = pdata->mdc;
99 bitbang->mdio = pdata->mdio; 100 bitbang->mdio = pdata->mdio;
100 101
diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h
index 0fe00cd4c93c..76f52bbbb2f4 100644
--- a/include/linux/mdio-bitbang.h
+++ b/include/linux/mdio-bitbang.h
@@ -32,6 +32,8 @@ struct mdiobb_ops {
32 32
33struct mdiobb_ctrl { 33struct mdiobb_ctrl {
34 const struct mdiobb_ops *ops; 34 const struct mdiobb_ops *ops;
35 /* reset callback */
36 int (*reset)(struct mii_bus *bus);
35}; 37};
36 38
37/* The returned bus is not yet registered with the phy layer. */ 39/* The returned bus is not yet registered with the phy layer. */
diff --git a/include/linux/mdio-gpio.h b/include/linux/mdio-gpio.h
index e9d3fdfe41d7..7c9fe3c2be73 100644
--- a/include/linux/mdio-gpio.h
+++ b/include/linux/mdio-gpio.h
@@ -20,6 +20,8 @@ struct mdio_gpio_platform_data {
20 20
21 unsigned int phy_mask; 21 unsigned int phy_mask;
22 int irqs[PHY_MAX_ADDR]; 22 int irqs[PHY_MAX_ADDR];
23 /* reset callback */
24 int (*reset)(struct mii_bus *bus);
23}; 25};
24 26
25#endif /* __LINUX_MDIO_GPIO_H */ 27#endif /* __LINUX_MDIO_GPIO_H */