public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv
@ 2018-03-10  1:19 Peng Fan
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

From: Ye Li <ye.li@nxp.com>

When using ethernet DM driver, the recv interface has a
change with non-DM interface, that driver needs to set
the packet pointer and provide it to upper layer to process.

In fec driver, the fecmxc_recv functions does not handle the
packet pointer parameter. This may cause crash in upper layer
processing because the packet pointer is not set.

This patch allocates a buffer for the packet pointer and free it
through free_pkt interface.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/fec_mxc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ff7ad91116..7c396d8d95 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -806,7 +806,16 @@ static int fec_recv(struct eth_device *dev)
 	uint16_t bd_status;
 	ulong addr, size, end;
 	int i;
+
+#ifdef CONFIG_DM_ETH
+	*packetp = memalign(ARCH_DMA_MINALIGN, FEC_MAX_PKT_SIZE);
+	if (*packetp == 0) {
+		printf("%s: error allocating packetp\n", __func__);
+		return -ENOMEM;
+	}
+#else
 	ALLOC_CACHE_ALIGN_BUFFER(uchar, buff, FEC_MAX_PKT_SIZE);
+#endif
 
 	/* Check if any critical events have happened */
 	ievent = readl(&fec->eth->ievent);
@@ -882,8 +891,13 @@ static int fec_recv(struct eth_device *dev)
 #ifdef CONFIG_FEC_MXC_SWAP_PACKET
 			swap_packet((uint32_t *)addr, frame_length);
 #endif
+
+#ifdef CONFIG_DM_ETH
+			memcpy(*packetp, (char *)addr, frame_length);
+#else
 			memcpy(buff, (char *)addr, frame_length);
 			net_process_received_packet(buff, frame_length);
+#endif
 			len = frame_length;
 		} else {
 			if (bd_status & FEC_RBD_ERR)
@@ -917,6 +931,16 @@ static int fec_recv(struct eth_device *dev)
 	return len;
 }
 
+static int fecmxc_free_pkt(struct udevice *dev, uchar *packet, int length)
+{
+#ifdef CONFIG_DM_ETH
+	if (packet)
+		free(packet);
+#endif
+
+	return 0;
+}
+
 static void fec_set_dev_name(char *dest, int dev_id)
 {
 	sprintf(dest, (dev_id == -1) ? "FEC" : "FEC%i", dev_id);
@@ -1205,6 +1229,7 @@ static const struct eth_ops fecmxc_ops = {
 	.start			= fecmxc_init,
 	.send			= fecmxc_send,
 	.recv			= fecmxc_recv,
+	.free_pkt		= fecmxc_free_pkt,
 	.stop			= fecmxc_halt,
 	.write_hwaddr		= fecmxc_set_hwaddr,
 	.read_rom_hwaddr	= fecmxc_read_rom_hwaddr,
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
@ 2018-03-10  1:19 ` Peng Fan
  2018-03-19 21:18   ` Joe Hershberger
  2018-03-20  8:49   ` Lothar Waßmann
  2018-03-10  1:19 ` [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id Peng Fan
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

No need to provide two prototype for this function.
Use ulong for the first parameter, then this function
could be shared for DM/non DM case.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/fec_mxc.c | 13 ++-----------
 include/netdev.h      |  6 +-----
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 7c396d8d95..2bd4ba4ef1 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1021,18 +1021,9 @@ static void fec_free_descs(struct fec_priv *fec)
 	free(fec->tbd_base);
 }
 
-#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
+struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
 {
-#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 *)(ulong)base_addr;
-#endif
 	struct mii_dev *bus;
 	int ret;
 
@@ -1284,7 +1275,7 @@ static int fecmxc_probe(struct udevice *dev)
 	fec_reg_setup(priv);
 	priv->dev_id = (dev_id == -1) ? 0 : dev_id;
 
-	bus = fec_get_miibus(dev, dev_id);
+	bus = fec_get_miibus((ulong)priv->eth, dev_id);
 	if (!bus) {
 		ret = -ENOMEM;
 		goto err_mii;
diff --git a/include/netdev.h b/include/netdev.h
index 3958a4cd32..c96f851be0 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -119,11 +119,7 @@ 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
+struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id);
 
 #ifdef CONFIG_PHYLIB
 struct phy_device;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id
  2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
@ 2018-03-10  1:19 ` Peng Fan
  2018-03-19 21:19   ` Joe Hershberger
  2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

To platforms has two enet interface, using dev->seq could
avoid conflict.

i.MX6UL/ULL evk board net get the wrong MAC address from fuse,
eth1 get MAC0 address, eth0 get MAC1 address from fuse. Set the
priv->dev_id to device->seq as the real net interface alias id then
.fec_get_hwaddr() read the related MAC address from fuse.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/fec_mxc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 2bd4ba4ef1..2c3171ecc9 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1252,7 +1252,6 @@ static int fecmxc_probe(struct udevice *dev)
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct fec_priv *priv = dev_get_priv(dev);
 	struct mii_dev *bus = NULL;
-	int dev_id = -1;
 	uint32_t start;
 	int ret;
 
@@ -1273,9 +1272,9 @@ static int fecmxc_probe(struct udevice *dev)
 	}
 
 	fec_reg_setup(priv);
-	priv->dev_id = (dev_id == -1) ? 0 : dev_id;
 
-	bus = fec_get_miibus((ulong)priv->eth, dev_id);
+	priv->dev_id = dev->seq;
+	bus = fec_get_miibus((ulong)priv->eth, dev->seq);
 	if (!bus) {
 		ret = -ENOMEM;
 		goto err_mii;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers
  2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
  2018-03-10  1:19 ` [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id Peng Fan
@ 2018-03-10  1:19 ` Peng Fan
  2018-03-19 21:21   ` Joe Hershberger
  2018-03-20  8:51   ` Lothar Waßmann
  2018-03-10  1:19 ` [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible Peng Fan
  2018-03-19 21:17 ` [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Joe Hershberger
  4 siblings, 2 replies; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

On i.MX6SX, 6UL and 7D, there are two enet controllers each has a
MDIO port. But Some boards share one MDIO port for the two enets. So
introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate
the MDIO port for sharing.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/Kconfig   | 7 +++++++
 drivers/net/fec_mxc.c | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index de1947ccc1..3a468a7c59 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -147,6 +147,13 @@ config ETHOC
 	help
 	  This MAC is present in OpenRISC and Xtensa XTFPGA boards.
 
+config FEC_MXC_MDIO_BASE
+	hex "MDIO base address for the FEC controller"
+	depends on FEC_MXC
+	help
+	  This specifies the MDIO registers base address. It is used when
+	  two FEC controllers share MDIO bus.
+
 config FEC_MXC
 	bool "FEC Ethernet controller"
 	depends on MX5 || MX6
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 2c3171ecc9..e8f8fef66a 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1161,8 +1161,12 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
 	 * Only the first one can access the MDIO bus.
 	 */
 	base_mii = MXS_ENET0_BASE;
+#else
+#ifdef CONFIG_FEC_MXC_MDIO_BASE
+	base_mii = CONFIG_FEC_MXC_MDIO_BASE;
 #else
 	base_mii = addr;
+#endif
 #endif
 	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
 	bus = fec_get_miibus(base_mii, dev_id);
@@ -1274,7 +1278,12 @@ static int fecmxc_probe(struct udevice *dev)
 	fec_reg_setup(priv);
 
 	priv->dev_id = dev->seq;
+
+#ifdef CONFIG_FEC_MXC_MDIO_BASE
+	bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
+#else
 	bus = fec_get_miibus((ulong)priv->eth, dev->seq);
+#endif
 	if (!bus) {
 		ret = -ENOMEM;
 		goto err_mii;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible
  2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
                   ` (2 preceding siblings ...)
  2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
@ 2018-03-10  1:19 ` Peng Fan
  2018-03-19 21:21   ` Joe Hershberger
  2018-03-19 21:17 ` [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Joe Hershberger
  4 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2018-03-10  1:19 UTC (permalink / raw)
  To: u-boot

Add i.MX6UL/SX/SL compatible.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/net/fec_mxc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index e8f8fef66a..ffe3bae59f 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1349,6 +1349,9 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id fecmxc_ids[] = {
 	{ .compatible = "fsl,imx6q-fec" },
+	{ .compatible = "fsl,imx6sl-fec" },
+	{ .compatible = "fsl,imx6sx-fec" },
+	{ .compatible = "fsl,imx6ul-fec" },
 	{ }
 };
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv
  2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
                   ` (3 preceding siblings ...)
  2018-03-10  1:19 ` [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible Peng Fan
@ 2018-03-19 21:17 ` Joe Hershberger
  4 siblings, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-19 21:17 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 9, 2018 at 7:19 PM, Peng Fan <peng.fan@nxp.com> wrote:
> From: Ye Li <ye.li@nxp.com>
>
> When using ethernet DM driver, the recv interface has a
> change with non-DM interface, that driver needs to set
> the packet pointer and provide it to upper layer to process.
>
> In fec driver, the fecmxc_recv functions does not handle the
> packet pointer parameter. This may cause crash in upper layer
> processing because the packet pointer is not set.
>
> This patch allocates a buffer for the packet pointer and free it
> through free_pkt interface.
>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
@ 2018-03-19 21:18   ` Joe Hershberger
  2018-03-20  8:49   ` Lothar Waßmann
  1 sibling, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-19 21:18 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 9, 2018 at 7:19 PM, Peng Fan <peng.fan@nxp.com> wrote:
> No need to provide two prototype for this function.
> Use ulong for the first parameter, then this function
> could be shared for DM/non DM case.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id
  2018-03-10  1:19 ` [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id Peng Fan
@ 2018-03-19 21:19   ` Joe Hershberger
  0 siblings, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-19 21:19 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 9, 2018 at 7:19 PM, Peng Fan <peng.fan@nxp.com> wrote:
> To platforms has two enet interface, using dev->seq could
> avoid conflict.
>
> i.MX6UL/ULL evk board net get the wrong MAC address from fuse,
> eth1 get MAC0 address, eth0 get MAC1 address from fuse. Set the
> priv->dev_id to device->seq as the real net interface alias id then
> .fec_get_hwaddr() read the related MAC address from fuse.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers
  2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
@ 2018-03-19 21:21   ` Joe Hershberger
  2018-03-20  8:51   ` Lothar Waßmann
  1 sibling, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-19 21:21 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 9, 2018 at 7:19 PM, Peng Fan <peng.fan@nxp.com> wrote:
> On i.MX6SX, 6UL and 7D, there are two enet controllers each has a
> MDIO port. But Some boards share one MDIO port for the two enets. So
> introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate
> the MDIO port for sharing.

It seems like this should be described in the device tree, but it's
currently missing from DM.

> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible
  2018-03-10  1:19 ` [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible Peng Fan
@ 2018-03-19 21:21   ` Joe Hershberger
  0 siblings, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-19 21:21 UTC (permalink / raw)
  To: u-boot

On Fri, Mar 9, 2018 at 7:19 PM, Peng Fan <peng.fan@nxp.com> wrote:
> Add i.MX6UL/SX/SL compatible.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
  2018-03-19 21:18   ` Joe Hershberger
@ 2018-03-20  8:49   ` Lothar Waßmann
  2018-03-20  9:29     ` Peng Fan
  1 sibling, 1 reply; 16+ messages in thread
From: Lothar Waßmann @ 2018-03-20  8:49 UTC (permalink / raw)
  To: u-boot

Hi,

On Sat, 10 Mar 2018 09:19:54 +0800 Peng Fan wrote:
> No need to provide two prototype for this function.
> Use ulong for the first parameter, then this function
> could be shared for DM/non DM case.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/net/fec_mxc.c | 13 ++-----------
>  include/netdev.h      |  6 +-----
>  2 files changed, 3 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 7c396d8d95..2bd4ba4ef1 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1021,18 +1021,9 @@ static void fec_free_descs(struct fec_priv *fec)
>  	free(fec->tbd_base);
>  }
>  
> -#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
> +struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
>  {
> -#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 *)(ulong)base_addr;
>
The (ulong) is redundant here.



Lothar Waßmann

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers
  2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
  2018-03-19 21:21   ` Joe Hershberger
@ 2018-03-20  8:51   ` Lothar Waßmann
  2018-03-21  1:59     ` Peng Fan
  1 sibling, 1 reply; 16+ messages in thread
From: Lothar Waßmann @ 2018-03-20  8:51 UTC (permalink / raw)
  To: u-boot

Hi,

On Sat, 10 Mar 2018 09:19:56 +0800 Peng Fan wrote:
> On i.MX6SX, 6UL and 7D, there are two enet controllers each has a
> MDIO port. But Some boards share one MDIO port for the two enets. So
> introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate
> the MDIO port for sharing.
> 
This is already the case for i.MX28. There is no need to implement a
second mechanism to achieve the same result.


> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/net/Kconfig   | 7 +++++++
>  drivers/net/fec_mxc.c | 9 +++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index de1947ccc1..3a468a7c59 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -147,6 +147,13 @@ config ETHOC
>  	help
>  	  This MAC is present in OpenRISC and Xtensa XTFPGA boards.
>  
> +config FEC_MXC_MDIO_BASE
> +	hex "MDIO base address for the FEC controller"
> +	depends on FEC_MXC
> +	help
> +	  This specifies the MDIO registers base address. It is used when
> +	  two FEC controllers share MDIO bus.
> +
>  config FEC_MXC
>  	bool "FEC Ethernet controller"
>  	depends on MX5 || MX6
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 2c3171ecc9..e8f8fef66a 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -1161,8 +1161,12 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
>  	 * Only the first one can access the MDIO bus.
>  	 */
>  	base_mii = MXS_ENET0_BASE;
> +#else
> +#ifdef CONFIG_FEC_MXC_MDIO_BASE
> +	base_mii = CONFIG_FEC_MXC_MDIO_BASE;
>  #else
>  	base_mii = addr;
> +#endif
>  #endif
>  	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
>  	bus = fec_get_miibus(base_mii, dev_id);
> @@ -1274,7 +1278,12 @@ static int fecmxc_probe(struct udevice *dev)
>  	fec_reg_setup(priv);
>  
>  	priv->dev_id = dev->seq;
> +
> +#ifdef CONFIG_FEC_MXC_MDIO_BASE
> +	bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
> +#else
>  	bus = fec_get_miibus((ulong)priv->eth, dev->seq);
> +#endif
>  	if (!bus) {
>  		ret = -ENOMEM;
>  		goto err_mii;


Lothar Waßmann

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-20  8:49   ` Lothar Waßmann
@ 2018-03-20  9:29     ` Peng Fan
  2018-03-21 19:13       ` Joe Hershberger
  0 siblings, 1 reply; 16+ messages in thread
From: Peng Fan @ 2018-03-20  9:29 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Lothar Waßmann [mailto:LW at KARO-electronics.de]
> Sent: 2018年3月20日 16:50
> To: Peng Fan <peng.fan@nxp.com>
> Cc: joe.hershberger at ni.com; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
> 
> Hi,
> 
> On Sat, 10 Mar 2018 09:19:54 +0800 Peng Fan wrote:
> > No need to provide two prototype for this function.
> > Use ulong for the first parameter, then this function could be shared
> > for DM/non DM case.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/net/fec_mxc.c | 13 ++-----------
> >  include/netdev.h      |  6 +-----
> >  2 files changed, 3 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index
> > 7c396d8d95..2bd4ba4ef1 100644
> > --- a/drivers/net/fec_mxc.c
> > +++ b/drivers/net/fec_mxc.c
> > @@ -1021,18 +1021,9 @@ static void fec_free_descs(struct fec_priv *fec)
> >  	free(fec->tbd_base);
> >  }
> >
> > -#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
> > +struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
> >  {
> > -#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
> > *)(ulong)base_addr;
> >
> The (ulong) is redundant here.
Thanks. 
Joe, would you mind help fix when you commit the patch,
or you need me send out v2?

Thanks,
Peng.
> 
> 
> 
> Lothar Waßmann

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers
  2018-03-20  8:51   ` Lothar Waßmann
@ 2018-03-21  1:59     ` Peng Fan
  0 siblings, 0 replies; 16+ messages in thread
From: Peng Fan @ 2018-03-21  1:59 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Lothar Waßmann [mailto:LW at KARO-electronics.de]
> Sent: 2018年3月20日 16:52
> To: Peng Fan <peng.fan@nxp.com>
> Cc: joe.hershberger at ni.com; u-boot at lists.denx.de
> Subject: Re: [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet
> controllers
> 
> Hi,
> 
> On Sat, 10 Mar 2018 09:19:56 +0800 Peng Fan wrote:
> > On i.MX6SX, 6UL and 7D, there are two enet controllers each has a MDIO
> > port. But Some boards share one MDIO port for the two enets. So
> > introduce a configuration CONFIG_FEC_MXC_MDIO_BASE to indicate the
> > MDIO port for sharing.
> >
> This is already the case for i.MX28. There is no need to implement a second
> mechanism to achieve the same result.

Thanks for pointing this out. I think mx28 could adapt to use the new code.
I'll fix in V2.

Thanks,
Peng.

> 
> 
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/net/Kconfig   | 7 +++++++
> >  drivers/net/fec_mxc.c | 9 +++++++++
> >  2 files changed, 16 insertions(+)
> >
> > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index
> > de1947ccc1..3a468a7c59 100644
> > --- a/drivers/net/Kconfig
> > +++ b/drivers/net/Kconfig
> > @@ -147,6 +147,13 @@ config ETHOC
> >  	help
> >  	  This MAC is present in OpenRISC and Xtensa XTFPGA boards.
> >
> > +config FEC_MXC_MDIO_BASE
> > +	hex "MDIO base address for the FEC controller"
> > +	depends on FEC_MXC
> > +	help
> > +	  This specifies the MDIO registers base address. It is used when
> > +	  two FEC controllers share MDIO bus.
> > +
> >  config FEC_MXC
> >  	bool "FEC Ethernet controller"
> >  	depends on MX5 || MX6
> > diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index
> > 2c3171ecc9..e8f8fef66a 100644
> > --- a/drivers/net/fec_mxc.c
> > +++ b/drivers/net/fec_mxc.c
> > @@ -1161,8 +1161,12 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id,
> int phy_id, uint32_t addr)
> >  	 * Only the first one can access the MDIO bus.
> >  	 */
> >  	base_mii = MXS_ENET0_BASE;
> > +#else
> > +#ifdef CONFIG_FEC_MXC_MDIO_BASE
> > +	base_mii = CONFIG_FEC_MXC_MDIO_BASE;
> >  #else
> >  	base_mii = addr;
> > +#endif
> >  #endif
> >  	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
> >  	bus = fec_get_miibus(base_mii, dev_id); @@ -1274,7 +1278,12 @@
> > static int fecmxc_probe(struct udevice *dev)
> >  	fec_reg_setup(priv);
> >
> >  	priv->dev_id = dev->seq;
> > +
> > +#ifdef CONFIG_FEC_MXC_MDIO_BASE
> > +	bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
> > +#else
> >  	bus = fec_get_miibus((ulong)priv->eth, dev->seq);
> > +#endif
> >  	if (!bus) {
> >  		ret = -ENOMEM;
> >  		goto err_mii;
> 
> 
> Lothar Waßmann

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-20  9:29     ` Peng Fan
@ 2018-03-21 19:13       ` Joe Hershberger
  2018-03-21 19:20         ` Joe Hershberger
  0 siblings, 1 reply; 16+ messages in thread
From: Joe Hershberger @ 2018-03-21 19:13 UTC (permalink / raw)
  To: u-boot

On Tue, Mar 20, 2018 at 4:29 AM, Peng Fan <peng.fan@nxp.com> wrote:
>
>
>> -----Original Message-----
>> From: Lothar Waßmann [mailto:LW at KARO-electronics.de]
>> Sent: 2018年3月20日 16:50
>> To: Peng Fan <peng.fan@nxp.com>
>> Cc: joe.hershberger at ni.com; u-boot at lists.denx.de
>> Subject: Re: [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
>>
>> Hi,
>>
>> On Sat, 10 Mar 2018 09:19:54 +0800 Peng Fan wrote:
>> > No need to provide two prototype for this function.
>> > Use ulong for the first parameter, then this function could be shared
>> > for DM/non DM case.
>> >
>> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> > ---
>> >  drivers/net/fec_mxc.c | 13 ++-----------
>> >  include/netdev.h      |  6 +-----
>> >  2 files changed, 3 insertions(+), 16 deletions(-)
>> >
>> > diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index
>> > 7c396d8d95..2bd4ba4ef1 100644
>> > --- a/drivers/net/fec_mxc.c
>> > +++ b/drivers/net/fec_mxc.c
>> > @@ -1021,18 +1021,9 @@ static void fec_free_descs(struct fec_priv *fec)
>> >     free(fec->tbd_base);
>> >  }
>> >
>> > -#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
>> > +struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
>> >  {
>> > -#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
>> > *)(ulong)base_addr;
>> >
>> The (ulong) is redundant here.
> Thanks.
> Joe, would you mind help fix when you commit the patch,
> or you need me send out v2?

I can fix it up.

-Joe

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
  2018-03-21 19:13       ` Joe Hershberger
@ 2018-03-21 19:20         ` Joe Hershberger
  0 siblings, 0 replies; 16+ messages in thread
From: Joe Hershberger @ 2018-03-21 19:20 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 21, 2018 at 2:13 PM, Joe Hershberger <joe.hershberger@ni.com> wrote:
> On Tue, Mar 20, 2018 at 4:29 AM, Peng Fan <peng.fan@nxp.com> wrote:
>>
>>
>>> -----Original Message-----
>>> From: Lothar Waßmann [mailto:LW at KARO-electronics.de]
>>> Sent: 2018年3月20日 16:50
>>> To: Peng Fan <peng.fan@nxp.com>
>>> Cc: joe.hershberger at ni.com; u-boot at lists.denx.de
>>> Subject: Re: [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus
>>>
>>> Hi,
>>>
>>> On Sat, 10 Mar 2018 09:19:54 +0800 Peng Fan wrote:
>>> > No need to provide two prototype for this function.
>>> > Use ulong for the first parameter, then this function could be shared
>>> > for DM/non DM case.
>>> >
>>> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>> > ---
>>> >  drivers/net/fec_mxc.c | 13 ++-----------
>>> >  include/netdev.h      |  6 +-----
>>> >  2 files changed, 3 insertions(+), 16 deletions(-)
>>> >
>>> > diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index
>>> > 7c396d8d95..2bd4ba4ef1 100644
>>> > --- a/drivers/net/fec_mxc.c
>>> > +++ b/drivers/net/fec_mxc.c
>>> > @@ -1021,18 +1021,9 @@ static void fec_free_descs(struct fec_priv *fec)
>>> >     free(fec->tbd_base);
>>> >  }
>>> >
>>> > -#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
>>> > +struct mii_dev *fec_get_miibus(ulong base_addr, int dev_id)
>>> >  {
>>> > -#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
>>> > *)(ulong)base_addr;
>>> >
>>> The (ulong) is redundant here.
>> Thanks.
>> Joe, would you mind help fix when you commit the patch,
>> or you need me send out v2?
>
> I can fix it up.

Looks like you already did.

-Joe

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-03-21 19:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-10  1:19 [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Peng Fan
2018-03-10  1:19 ` [U-Boot] [PATCH 2/5] net: fec_mxc: simplify fec_get_miibus Peng Fan
2018-03-19 21:18   ` Joe Hershberger
2018-03-20  8:49   ` Lothar Waßmann
2018-03-20  9:29     ` Peng Fan
2018-03-21 19:13       ` Joe Hershberger
2018-03-21 19:20         ` Joe Hershberger
2018-03-10  1:19 ` [U-Boot] [PATCH 3/5] net: fec: set dev->seq to priv->dev_id Peng Fan
2018-03-19 21:19   ` Joe Hershberger
2018-03-10  1:19 ` [U-Boot] [PATCH 4/5] net: fec: sharing MDIO for two enet controllers Peng Fan
2018-03-19 21:21   ` Joe Hershberger
2018-03-20  8:51   ` Lothar Waßmann
2018-03-21  1:59     ` Peng Fan
2018-03-10  1:19 ` [U-Boot] [PATCH 5/5] net: fex_mxc: add i.MX6UL/SX/SL compatible Peng Fan
2018-03-19 21:21   ` Joe Hershberger
2018-03-19 21:17 ` [U-Boot] [PATCH 1/5] net: fec_mxc: Fix DM driver issue in recv Joe Hershberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox