]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
mdio-gpio: Add reset functionality to mdio-gpio driver(v2).
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>
Tue, 15 Nov 2011 11:54:15 +0000 (11:54 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 15 Nov 2011 21:56:17 +0000 (16:56 -0500)
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>
drivers/net/phy/mdio-bitbang.c
drivers/net/phy/mdio-gpio.c
include/linux/mdio-bitbang.h
include/linux/mdio-gpio.h

index 65391891d8c41a180592d500825df75f67b44e4c..daec9b05d168ca4f0f103f3638fcc3259e9ea304 100644 (file)
@@ -202,6 +202,14 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
        return 0;
 }
 
+static int mdiobb_reset(struct mii_bus *bus)
+{
+       struct mdiobb_ctrl *ctrl = bus->priv;
+       if (ctrl->reset)
+               ctrl->reset(bus);
+       return 0;
+}
+
 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
 {
        struct mii_bus *bus;
@@ -214,6 +222,7 @@ struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
 
        bus->read = mdiobb_read;
        bus->write = mdiobb_write;
+       bus->reset = mdiobb_reset;
        bus->priv = ctrl;
 
        return bus;
index 2843c90f712f40c27c0688cb336dc87dbede054e..89c5a3eccc12daa760fa0e1e6c73e392c0a81f3e 100644 (file)
@@ -95,6 +95,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
                goto out;
 
        bitbang->ctrl.ops = &mdio_gpio_ops;
+       bitbang->ctrl.reset = pdata->reset;
        bitbang->mdc = pdata->mdc;
        bitbang->mdio = pdata->mdio;
 
index 0fe00cd4c93ca3b26fb8841b6becfd8ef10a02cd..76f52bbbb2f430b822524b4e60ef90fa05a4f476 100644 (file)
@@ -32,6 +32,8 @@ struct mdiobb_ops {
 
 struct mdiobb_ctrl {
        const struct mdiobb_ops *ops;
+       /* reset callback */
+       int (*reset)(struct mii_bus *bus);
 };
 
 /* The returned bus is not yet registered with the phy layer. */
index e9d3fdfe41d71a9dc42c1b456a928e93e049bbc7..7c9fe3c2be73a771d53fbf4208832203032cfa07 100644 (file)
@@ -20,6 +20,8 @@ struct mdio_gpio_platform_data {
 
        unsigned int phy_mask;
        int irqs[PHY_MAX_ADDR];
+       /* reset callback */
+       int (*reset)(struct mii_bus *bus);
 };
 
 #endif /* __LINUX_MDIO_GPIO_H */