Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1356663
| From | Caesar Wang <wxt@rock-chips.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2.1 3/9] net: arc_emac: support the phy reset for emac driver |
| Date | 2016-03-13 11:10 +0100 |
| Message-ID | <rcb8e-4dl-11@gated-at.bofh.it> (permalink) |
| References | <rcaca-3ul-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This patch adds to support the emac phy reset.
Different boards may require different phy reset duration. Add property
phy-reset-duration for emac driver, so that the boards that need
a longer reset duration can specify it in their device tree.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---
Changes in v2.1:
- missing the include head file.
Changes in v2:
- As the pervious version, Sergei and Heiko comments on
https://patchwork.kernel.org/patch/8564571/.
- Nevermind, add signed-off since Heiko the original patch,
refer the Heiko's test patch on
https://github.com/mmind/linux-rockchip/commit/a943c588783438ff1c508dfa8c79f1709aa5775e
:)
drivers/net/ethernet/arc/emac.h | 6 ++++++
drivers/net/ethernet/arc/emac_mdio.c | 37 ++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/drivers/net/ethernet/arc/emac.h b/drivers/net/ethernet/arc/emac.h
index dae1ac3..1a40403 100644
--- a/drivers/net/ethernet/arc/emac.h
+++ b/drivers/net/ethernet/arc/emac.h
@@ -102,6 +102,11 @@ struct buffer_state {
DEFINE_DMA_UNMAP_LEN(len);
};
+struct arc_emac_mdio_bus_data {
+ struct gpio_desc *reset_gpio;
+ int msec;
+};
+
/**
* struct arc_emac_priv - Storage of EMAC's private information.
* @dev: Pointer to the current device.
@@ -131,6 +136,7 @@ struct arc_emac_priv {
struct device *dev;
struct phy_device *phy_dev;
struct mii_bus *bus;
+ struct arc_emac_mdio_bus_data bus_data;
void __iomem *regs;
struct clk *clk;
diff --git a/drivers/net/ethernet/arc/emac_mdio.c b/drivers/net/ethernet/arc/emac_mdio.c
index d5ee986..0ab62d4 100644
--- a/drivers/net/ethernet/arc/emac_mdio.c
+++ b/drivers/net/ethernet/arc/emac_mdio.c
@@ -7,6 +7,7 @@
#include <linux/delay.h>
#include <linux/of_mdio.h>
#include <linux/platform_device.h>
+#include <linux/gpio/consumer.h>
#include "emac.h"
@@ -99,6 +100,25 @@ static int arc_mdio_write(struct mii_bus *bus, int phy_addr,
}
/**
+ * arc_mdio_reset
+ * @bus: points to the mii_bus structure
+ * Description: reset the MII bus
+ */
+int arc_mdio_reset(struct mii_bus *bus)
+{
+ struct arc_emac_priv *priv = bus->priv;
+ struct arc_emac_mdio_bus_data *data = &priv->bus_data;
+
+ if (data->reset_gpio) {
+ gpiod_set_value_cansleep(data->reset_gpio, 1);
+ msleep(data->msec);
+ gpiod_set_value_cansleep(data->reset_gpio, 0);
+ }
+
+ return 0;
+}
+
+/**
* arc_mdio_probe - MDIO probe function.
* @priv: Pointer to ARC EMAC private data structure.
*
@@ -109,6 +129,8 @@ static int arc_mdio_write(struct mii_bus *bus, int phy_addr,
*/
int arc_mdio_probe(struct arc_emac_priv *priv)
{
+ struct arc_emac_mdio_bus_data *data = &priv->bus_data;
+ struct device_node *np = priv->dev->of_node;
struct mii_bus *bus;
int error;
@@ -122,6 +144,21 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
bus->name = "Synopsys MII Bus",
bus->read = &arc_mdio_read;
bus->write = &arc_mdio_write;
+ bus->reset = &arc_mdio_reset;
+
+ /* optional reset-related properties */
+ data->reset_gpio = devm_gpiod_get_optional(priv->dev, "reset",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(data->reset_gpio)) {
+ error = PTR_ERR(data->reset_gpio);
+ dev_err(priv->dev, "Failed to request gpio: %d\n", error);
+ return error;
+ }
+
+ of_property_read_u32(np, "phy-reset-duration", &data->msec);
+ /* A sane reset duration should not be longer than 1s */
+ if (data->msec > 1000)
+ data->msec = 1;
snprintf(bus->id, MII_BUS_ID_SIZE, "%s", bus->name);
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/9] arc_emac: fixes the emac issues and cleanup emac drivers Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
[PATCH v2 1/9] net: arc_emac: make the rockchip emac document more compatible Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
[PATCH v2 2/9] net: arc_emac: add phy reset is optional for device tree Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
Re: [PATCH v2 2/9] net: arc_emac: add phy reset is optional for device tree Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-03-13 15:40 +0100
[PATCH v2 9/9] ARM: dts: rockchip: add support emac for RK3036 Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
[PATCH v2 5/9] clk: rockchip: add node-id for rk3036 emac hclk Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
[PATCH v2 7/9] clk: rockchip: add clock-id for rk3036 emac pll source clock Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
[PATCH v2 6/9] clk: rockchip: associate the rk3036 HCLK_EMAC clock-id Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:10 +0100
Re: [PATCH v2 6/9] clk: rockchip: associate the rk3036 HCLK_EMAC clock-id Stephen Boyd <sboyd@codeaurora.org> - 2016-03-15 19:50 +0100
[PATCH v2 8/9] clk: rockchip: associate SCLK_MAC_PLL and disable reparenting on rk3036 Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:20 +0100
Re: [PATCH v2 8/9] clk: rockchip: associate SCLK_MAC_PLL and disable reparenting on rk3036 Stephen Boyd <sboyd@codeaurora.org> - 2016-03-15 19:50 +0100
[PATCH v2 3/9] net: arc_emac: support the phy reset for emac driver Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:20 +0100
[PATCH v2 4/9] net: arc: trivial: cleanup the emac driver Caesar Wang <wxt@rock-chips.com> - 2016-03-13 10:20 +0100
[PATCH v2.1 3/9] net: arc_emac: support the phy reset for emac driver Caesar Wang <wxt@rock-chips.com> - 2016-03-13 11:10 +0100
Re: [PATCH v2.1 3/9] net: arc_emac: support the phy reset for emac driver David Miller <davem@davemloft.net> - 2016-03-13 19:10 +0100
Re: [PATCH v2.1 3/9] net: arc_emac: support the phy reset for emac driver Caesar Wang <caesar.upstream@gmail.com> - 2016-03-14 01:30 +0100
csiph-web