From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v7 14/17] net: fec_mxc: Add 'phy-reset-gpios' support
Date: Tue, 23 May 2017 13:28:27 +0530 [thread overview]
Message-ID: <1495526310-5543-15-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1495526310-5543-1-git-send-email-jteki@openedev.com>
From: Jagan Teki <jagan@openedev.com>
phy-reset-gpios property needed for adding mii_dev
reset bus operation, so the board code not take care
of phy_reset anymore if it use DM_ETH
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Jagan Teki <jagan@openedev.com>
---
drivers/net/fec_mxc.c | 64 +++++++++++++++++++++++++++++++++++++++++++++------
drivers/net/fec_mxc.h | 8 +++++++
include/netdev.h | 5 ++++
3 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 08bea8b..5e16f02 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -180,13 +180,27 @@ static int fec_mdio_write(struct ethernet_regs *eth, uint8_t phyaddr,
static int fec_phy_read(struct mii_dev *bus, int phyaddr, int dev_addr,
int regaddr)
{
- return fec_mdio_read(bus->priv, phyaddr, regaddr);
+#ifdef CONFIG_DM_ETH
+ struct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);
+ struct ethernet_regs *eth = priv->eth;
+#else
+ struct ethernet_regs *eth = bus->priv;
+#endif
+
+ return fec_mdio_read(eth, phyaddr, regaddr);
}
static int fec_phy_write(struct mii_dev *bus, int phyaddr, int dev_addr,
int regaddr, u16 data)
{
- return fec_mdio_write(bus->priv, phyaddr, regaddr, data);
+#ifdef CONFIG_DM_ETH
+ struct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);
+ struct ethernet_regs *eth = priv->eth;
+#else
+ struct ethernet_regs *eth = bus->priv;
+#endif
+
+ return fec_mdio_write(eth, phyaddr, regaddr, data);
}
#ifndef CONFIG_PHYLIB
@@ -985,9 +999,36 @@ static void fec_free_descs(struct fec_priv *fec)
free(fec->tbd_base);
}
+#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_GPIO)
+static int fec_phy_reset(struct mii_dev *bus)
+{
+ struct fec_priv *priv = dev_get_priv((struct udevice *)bus->priv);
+
+ if (!dm_gpio_is_valid(&priv->reset_gpio))
+ return 0;
+
+ /* phy reset */
+ dm_gpio_set_value(&priv->reset_gpio, 0);
+ udelay(100);
+ dm_gpio_set_value(&priv->reset_gpio, 1);
+ udelay(100);
+
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_DM_ETH
+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id)
+#else
struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)
+#endif
{
+#ifdef CONFIG_DM_ETH
+ struct fec_priv *priv = dev_get_priv(dev);
+ struct ethernet_regs *eth = priv->eth;
+#else
struct ethernet_regs *eth = (struct ethernet_regs *)base_addr;
+#endif
struct mii_dev *bus;
int ret;
@@ -998,7 +1039,14 @@ struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)
}
bus->read = fec_phy_read;
bus->write = fec_phy_write;
+#ifdef CONFIG_DM_ETH
+ bus->priv = dev;
+# ifdef CONFIG_DM_GPIO
+ bus->reset = fec_phy_reset;
+# endif
+#else
bus->priv = eth;
+#endif
fec_set_dev_name(bus->name, dev_id);
ret = mdio_register(bus);
@@ -1223,7 +1271,7 @@ static int fecmxc_probe(struct udevice *dev)
if (ret)
return ret;
- bus = fec_get_miibus((uint32_t)priv->eth, dev_id);
+ bus = fec_get_miibus(dev, dev_id);
if (!bus)
goto err_mii;
@@ -1292,10 +1340,12 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
return -EINVAL;
}
- /* TODO
- * Need to get the reset-gpio and related properties from DT
- * and implemet the enet reset code on .probe call
- */
+#ifdef CONFIG_DM_GPIO
+ /* phy reset gpio */
+ gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
+ "phy-reset-gpios", 0,
+ &priv->reset_gpio, GPIOD_IS_OUT);
+#endif
return 0;
}
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 43a7d7b..74ede4a 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -17,6 +17,10 @@
#ifndef __FEC_MXC_H
#define __FEC_MXC_H
+#ifdef CONFIG_DM_GPIO
+# include <asm-generic/gpio.h>
+#endif
+
/* Layout description of the FEC */
struct ethernet_regs {
/* [10:2]addr = 00 */
@@ -254,6 +258,10 @@ struct fec_priv {
#ifdef CONFIG_DM_ETH
u32 interface;
+
+# ifdef CONFIG_DM_GPIO
+ struct gpio_desc reset_gpio;
+# endif
#endif
};
diff --git a/include/netdev.h b/include/netdev.h
index 8eb8b46..e5668f4 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -133,7 +133,12 @@ static inline int pci_eth_init(bd_t *bis)
return num;
}
+#ifdef CONFIG_DM_ETH
+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id);
+#else
struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id);
+#endif
+
#ifdef CONFIG_PHYLIB
struct phy_device;
int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
--
1.9.1
next prev parent reply other threads:[~2017-05-23 7:58 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 7:58 [U-Boot] [PATCH v7 00/17] ARM: i.MX6: SabreSD: Add dts support Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 01/17] ARM: i.MX6: sabresd: Remove SPL_I2C_SUPPORT Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 02/17] ARM: dts: i.MX6: Add imx6qdl-sabresd.dtsi Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 03/17] ARM: dts: i.MX6: Add imx6q-sabresd.dts Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 04/17] ARM: dts: i.MX6: Add imx6dl-sabresd.dts Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 05/17] ARM: dts: i.MX6: Add imx6qp.dtsi Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 06/17] ARM: dts: i.MX6: Add imx6qp-sabresd.dts Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 07/17] sabresd: i.MX6Q: Add initial dts support Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 08/17] sabresd: i.MX6QP: " Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 09/17] SabreSD: i.MX6DL: " Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 10/17] SabreSD: Move CONFIG_SYS_I2C_MXC to defconfigs Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 11/17] SabreSD: Enable CONFIG_DM_REGULATOR Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 12/17] SabreSD: Enable DM_USB Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 13/17] i.MX6: Sabre: Move CONFIG_FEC_MXC to defconfigs Jagan Teki
2017-05-23 7:58 ` Jagan Teki [this message]
2017-05-23 10:53 ` [U-Boot] [PATCH v7 14/17] net: fec_mxc: Add 'phy-reset-gpios' support Fabio Estevam
2017-06-16 14:13 ` Lothar Waßmann
2017-05-23 7:58 ` [U-Boot] [PATCH v7 15/17] i.MX6: SabreSD: Enable DM_ETH Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 16/17] i.MX6: sabresd: Drop checkboard Jagan Teki
2017-05-23 7:58 ` [U-Boot] [PATCH v7 17/17] i.MX6: SabreSD: Cleanup board code Jagan Teki
2017-05-26 16:41 ` [U-Boot] [PATCH v7 00/17] ARM: i.MX6: SabreSD: Add dts support Jagan Teki
2017-05-26 16:47 ` Fabio Estevam
2017-05-26 16:49 ` Jagan Teki
2017-05-26 16:52 ` Fabio Estevam
2017-05-26 16:55 ` Jagan Teki
2017-05-26 17:04 ` Fabio Estevam
2017-05-26 17:14 ` Jagan Teki
2017-05-26 17:17 ` Fabio Estevam
2017-05-26 17:28 ` Jagan Teki
2017-05-26 17:34 ` Fabio Estevam
2017-05-26 17:45 ` Jagan Teki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1495526310-5543-15-git-send-email-jteki@openedev.com \
--to=jagannadh.teki@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox