* [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver.
@ 2011-11-09 13:38 Srinivas KANDAGATLA
2011-11-14 19:42 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Srinivas KANDAGATLA @ 2011-11-09 13:38 UTC (permalink / raw)
To: netdev; +Cc: davem, stuart.menefy
From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
This patch adds phy reset functionality to mdio-bitbang 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>
Cc: Stuart Menefy <stuart.menefy@st.com>
---
Hi All,
Recently In my attempt to get mdio-bitbang driver working to debug
an issue, I have noticed that mii bus reset functionality is
missing in the mdio-bitbang driver.
This functionality is very much needed to reset devices on the mii-bus.
Without this functionality BSP level code has to add code to do reset
before the mdio-bitbang driver probe is called.
As mii-bus infrastructure already provides the mii-bus drivers to
support reset function callbacks, Its much neat way to get reset
functionality support in to mdio-bitbang driver.
This patch adds reset functionality to mdio-gpio driver.
thanks,
srini
drivers/net/phy/mdio-bitbang.c | 9 +++++++++
drivers/net/phy/mdio-gpio.c | 1 +
include/linux/mdio-bitbang.h | 3 +++
include/linux/mdio-gpio.h | 2 ++
4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 6539189..4b99cfc 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)
return 0;
}
+static int mdiobb_reset(struct mii_bus *bus)
+{
+ struct mdiobb_ctrl *ctrl = bus->priv;
+ if (ctrl->ops->reset)
+ ctrl->ops->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;
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 2843c90..367e0d0 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -97,6 +97,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
bitbang->ctrl.ops = &mdio_gpio_ops;
bitbang->mdc = pdata->mdc;
bitbang->mdio = pdata->mdio;
+ mdio_gpio_ops.reset = pdata->reset;
new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
if (!new_bus)
diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h
index 8ea9a42..7c88677 100644
--- a/include/linux/mdio-bitbang.h
+++ b/include/linux/mdio-bitbang.h
@@ -27,6 +27,9 @@ struct mdiobb_ops {
/* Retrieve the state Management Data I/O pin. */
int (*get_mdio_data)(struct mdiobb_ctrl *ctrl);
+
+ /* reset callback */
+ int (*reset)(struct mii_bus *bus);
};
struct mdiobb_ctrl {
diff --git a/include/linux/mdio-gpio.h b/include/linux/mdio-gpio.h
index e9d3fdf..7c9fe3c 100644
--- a/include/linux/mdio-gpio.h
+++ b/include/linux/mdio-gpio.h
@@ -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 */
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver.
2011-11-09 13:38 [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver Srinivas KANDAGATLA
@ 2011-11-14 19:42 ` David Miller
2011-11-15 12:07 ` Srinivas KANDAGATLA
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2011-11-14 19:42 UTC (permalink / raw)
To: srinivas.kandagatla; +Cc: netdev, stuart.menefy
From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com>
Date: Wed, 9 Nov 2011 13:38:51 +0000
> + mdio_gpio_ops.reset = pdata->reset;
What if I have multiple types of devices backing a mdio_gpio, each using
different reset operations?
You can't write this variable method into a globally used set of ops.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver.
2011-11-14 19:42 ` David Miller
@ 2011-11-15 12:07 ` Srinivas KANDAGATLA
2011-11-15 21:56 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Srinivas KANDAGATLA @ 2011-11-15 12:07 UTC (permalink / raw)
To: David Miller; +Cc: netdev, stuart.menefy
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
Hi Dave,
Thanks for the comments,
David Miller wrote:
> From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com>
> Date: Wed, 9 Nov 2011 13:38:51 +0000
>
>> + mdio_gpio_ops.reset = pdata->reset;
>
> What if I have multiple types of devices backing a mdio_gpio, each using
> different reset operations?
>
> You can't write this variable method into a globally used set of ops.
I agree with your comment.
Here is the modified patch, which moves the reset function pointer to
mdiobb_ctrl struct.
Thanks
srini
[-- Attachment #2: 0001-mdio-gpio-Add-reset-functionality-to-mdio-gpio-drive.patch --]
[-- Type: text/x-patch, Size: 2918 bytes --]
>From ea136182ac86535252bed85b1c465ff8cf586f60 Mon Sep 17 00:00:00 2001
From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Date: Tue, 15 Nov 2011 11:54:15 +0000
Subject: [PATCH Kernel-3.1.0] 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>
---
drivers/net/phy/mdio-bitbang.c | 9 +++++++++
drivers/net/phy/mdio-gpio.c | 1 +
include/linux/mdio-bitbang.h | 2 ++
include/linux/mdio-gpio.h | 2 ++
4 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 6539189..daec9b0 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)
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;
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 2843c90..89c5a3e 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,
goto out;
bitbang->ctrl.ops = &mdio_gpio_ops;
+ bitbang->ctrl.reset = pdata->reset;
bitbang->mdc = pdata->mdc;
bitbang->mdio = pdata->mdio;
diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h
index 8ea9a42..e8e7e1d 100644
--- a/include/linux/mdio-bitbang.h
+++ b/include/linux/mdio-bitbang.h
@@ -31,6 +31,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. */
diff --git a/include/linux/mdio-gpio.h b/include/linux/mdio-gpio.h
index e9d3fdf..7c9fe3c 100644
--- a/include/linux/mdio-gpio.h
+++ b/include/linux/mdio-gpio.h
@@ -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 */
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver.
2011-11-15 12:07 ` Srinivas KANDAGATLA
@ 2011-11-15 21:56 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-11-15 21:56 UTC (permalink / raw)
To: srinivas.kandagatla; +Cc: netdev, stuart.menefy
From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com>
Date: Tue, 15 Nov 2011 12:07:36 +0000
> Subject: [PATCH Kernel-3.1.0] 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>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-15 21:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09 13:38 [PATCH Kernel-3.1.0] mdio-gpio: Add reset functionality to mdio-gpio driver Srinivas KANDAGATLA
2011-11-14 19:42 ` David Miller
2011-11-15 12:07 ` Srinivas KANDAGATLA
2011-11-15 21:56 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).