Skip to contentSkip to conversation

net: introduce phylib

PATCH In review Jean-Christophe PLAGNIOL-VILLARD 4 participants 26 messages Sep 24, 2012 – Oct 2, 2012

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

v7 cover net: introduce phylib

HI,

v7:
- drop the duplicate platform_data for fec driver as we need to update both with the same data (piss me off)

v6:
- probe phy at mdiobus_register
- reimplement the mdiobuss support

v5:
- drop edev in mii_device

v4:
- move phy_dev attachement to eth_device instead of mii_device this will allow multiple phy_device per mii bus
- move phy cdev to phy_device
- add interface type support (so phy driver can configure themselves if MII/RMII/RGMII etc...
- manage link status at framework level
- mx6 update to fixup the phy at device opening

v3:
- fix comment
- add phy_driver probe and remove
- renambe phydev.h to phy.h and phylib.c to phy.c as in linux

please pull
The following changes since commit 0b3c3e77945243c262f9ff1275479e6d8ea1d5c3:

net: catch error on eth_send (2012-09-16 20:39:07 +0800)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/net_phylib

for you to fetch changes up to aa3e78ab068ca81416d6150fc545b6c5e271dad2:

net: introduce phylib (2012-09-24 05:35:20 +0800)

----------------------------------------------------------------
net: check error and introduce phylib

Adapt phylib from linux

This will allow to have
- phy drivers
- to only connect the phy at then opening of the device
- if the phy is not ready or down fail on open

Same behaviour as in linux and will allow to share code and simplify porting.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (1):
net: introduce phylib

 arch/arm/boards/freescale-mx6-arm2/board.c      |   43 ++---
 arch/arm/boards/freescale-mx6-sabrelite/board.c |   40 ++--
 arch/arm/configs/phycard_a_l1_defconfig         |    2 +-
 arch/arm/configs/tx51stk5_defconfig             |    2 +-
 arch/ppc/boards/pcm030/pcm030.c                 |    4 +-
 arch/ppc/mach-mpc5xxx/include/mach/fec.h        |   14 --
 drivers/net/Kconfig                             |   30 +--
 drivers/net/Makefile                            |    2 +-
 drivers/net/altera_tse.c                        |   48 +++--
 drivers/net/altera_tse.h                        |    3 +-
 drivers/net/at91_ether.c                        |   49 ++---
 drivers/net/designware.c                        |   62 ++++---
 drivers/net/dm9k.c                              |   50 +++--
 drivers/net/ep93xx.c                            |   35 ++--
 drivers/net/ep93xx.h                            |    2 +-
 drivers/net/fec_imx.c                           |   89 +++++----
 drivers/net/fec_imx.h                           |    6 +-
 drivers/net/fec_mpc5200.c                       |   58 +++---
 drivers/net/fec_mpc5200.h                       |    4 +-
 drivers/net/gianfar.c                           |   61 +++---
 drivers/net/gianfar.h                           |    2 +-
 drivers/net/ks8851_mll.c                        |   36 ++--
 drivers/net/macb.c                              |   79 ++++----
 drivers/net/miidev.c                            |  316 -------------------------------
 drivers/net/netx_eth.c                          |   26 +--
 drivers/net/phy/Kconfig                         |   17 ++
 drivers/net/phy/Makefile                        |    2 +
 drivers/net/phy/generic.c                       |   36 ++++
 drivers/net/phy/mdio_bus.c                      |  250 +++++++++++++++++++++++++
 drivers/net/phy/phy.c                           |  568 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/smc91111.c                          |   47 ++---
 drivers/net/smc911x.c                           |   37 ++--
 drivers/net/usb/Kconfig                         |    4 +-
 drivers/net/usb/asix.c                          |   29 ++-
 drivers/net/usb/smsc95xx.c                      |   41 ++--
 drivers/net/usb/usbnet.c                        |   11 +-
 include/fec.h                                   |    3 +
 include/linux/ethtool.h                         |  114 ++++++++++++
 include/linux/mii.h                             |  421 ++++++++++++++++++++++++++++++-----------
 include/linux/phy.h                             |  266 ++++++++++++++++++++++++++
 include/miidev.h                                |   51 +----
 include/net.h                                   |    4 +
 include/usb/usbnet.h                            |    5 +-
 net/eth.c                                       |    8 +-
 44 files changed, 2038 insertions(+), 939 deletions(-)
 delete mode 100644 arch/ppc/mach-mpc5xxx/include/mach/fec.h
 delete mode 100644 drivers/net/miidev.c
 create mode 100644 drivers/net/phy/Kconfig
 create mode 100644 drivers/net/phy/Makefile
 create mode 100644 drivers/net/phy/generic.c
 create mode 100644 drivers/net/phy/mdio_bus.c
 create mode 100644 drivers/net/phy/phy.c
 create mode 100644 include/linux/ethtool.h
 create mode 100644 include/linux/phy.h

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v7 1/1 net: introduce phylib

Adapt phylib from linux

switch all the driver to it
reimplement mii bus

This will allow to have
- phy drivers
- to only connect the phy at then opening of the device
- if the phy is not ready or not up fail on open

Same behaviour as in linux and will allow to share code and simplify porting.

---
 arch/arm/boards/freescale-mx6-arm2/board.c      |   43 +-
 arch/arm/boards/freescale-mx6-sabrelite/board.c |   40 +-
 arch/arm/configs/phycard_a_l1_defconfig         |    2 +-
 arch/arm/configs/tx51stk5_defconfig             |    2 +-
 arch/ppc/boards/pcm030/pcm030.c                 |    4 +-
 arch/ppc/mach-mpc5xxx/include/mach/fec.h        |   14 -
 drivers/net/Kconfig                             |   30 +-
 drivers/net/Makefile                            |    2 +-
 drivers/net/altera_tse.c                        |   48 +-
 drivers/net/altera_tse.h                        |    3 +-
 drivers/net/at91_ether.c                        |   49 +-
 drivers/net/designware.c                        |   62 ++-
 drivers/net/dm9k.c                              |   50 +-
 drivers/net/ep93xx.c                            |   35 +-
 drivers/net/ep93xx.h                            |    2 +-
 drivers/net/fec_imx.c                           |   89 +--
 drivers/net/fec_imx.h                           |    6 +-
 drivers/net/fec_mpc5200.c                       |   58 +-
 drivers/net/fec_mpc5200.h                       |    4 +-
 drivers/net/gianfar.c                           |   61 +-
 drivers/net/gianfar.h                           |    2 +-
 drivers/net/ks8851_mll.c                        |   36 +-
 drivers/net/macb.c                              |   79 +--
 drivers/net/miidev.c                            |  316 -----------
 drivers/net/netx_eth.c                          |   26 +-
 drivers/net/phy/Kconfig                         |   17 +
 drivers/net/phy/Makefile                        |    2 +
 include/fec.h => drivers/net/phy/generic.c      |   43 +-
 drivers/net/phy/mdio_bus.c                      |  250 +++++++++
 drivers/net/phy/phy.c                           |  568 +++++++++++++++++++
 drivers/net/smc91111.c                          |   47 +-
 drivers/net/smc911x.c                           |   37 +-
 drivers/net/usb/Kconfig                         |    4 +-
 drivers/net/usb/asix.c                          |   29 +-
 drivers/net/usb/smsc95xx.c                      |   41 +-
 drivers/net/usb/usbnet.c                        |   11 +-
 include/fec.h                                   |    3 +
 include/linux/ethtool.h                         |  114 ++++
 include/linux/mii.h                             |  675 +++++++++++++++--------
 include/linux/phy.h                             |  266 +++++++++
 include/miidev.h                                |   51 +-
 include/net.h                                   |    4 +
 include/usb/usbnet.h                            |    5 +-
 net/eth.c                                       |    8 +-
 44 files changed, 2144 insertions(+), 1094 deletions(-)
 delete mode 100644 arch/ppc/mach-mpc5xxx/include/mach/fec.h
 delete mode 100644 drivers/net/miidev.c
 create mode 100644 drivers/net/phy/Kconfig
 create mode 100644 drivers/net/phy/Makefile
 copy include/fec.h => drivers/net/phy/generic.c (53%)
 create mode 100644 drivers/net/phy/mdio_bus.c
 create mode 100644 drivers/net/phy/phy.c
 create mode 100644 include/linux/ethtool.h
 rewrite include/linux/mii.h (70%)
 create mode 100644 include/linux/phy.h
arch/arm/boards/freescale-mx6-arm2/board.c +16 -27
index e4a9a49..0e853a6 100644
@@ -26,7 +26,7 @@
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
 #include <partition.h>
-#include <miidev.h>
+#include <linux/phy.h>
 #include <asm/io.h>
 #include <asm/mmu.h>
 #include <mach/generic.h>
@@ -104,50 +104,39 @@ static int arm2_mem_init(void)
 }
 mem_initcall(arm2_mem_init);
 
-static struct fec_platform_data fec_info = {
-	.xcv_type = RGMII,
-	.phy_addr = 0,
-};
-
-static int mx6_rgmii_rework(void)
+static void mx6_rgmii_rework(struct phy_device *dev)
 {
-	struct mii_device *mdev;
 	u16 val;
 
-	mdev = mii_open("phy0");
-	if (!mdev) {
-		printf("unable to open phy0\n");
-		return -ENODEV;
-	}
-
 	/* To enable AR8031 ouput a 125MHz clk from CLK_25M */
-	mii_write(mdev, mdev->address, 0xd, 0x7);
-	mii_write(mdev, mdev->address, 0xe, 0x8016);
-	mii_write(mdev, mdev->address, 0xd, 0x4007);
+	phy_write(dev, 0xd, 0x7);
+	phy_write(dev, 0xe, 0x8016);
+	phy_write(dev, 0xd, 0x4007);
 
-	val = mii_read(mdev, mdev->address, 0xe);
+	val = phy_read(dev, 0xe);
 	val &= 0xffe3;
 	val |= 0x18;
-	mii_write(mdev, mdev->address, 0xe, val);
+	phy_write(dev, 0xe, val);
 
 	/* introduce tx clock delay */
-	mii_write(mdev, mdev->address, 0x1d, 0x5);
+	phy_write(dev, 0x1d, 0x5);
 
-	val = mii_read(mdev, mdev->address, 0x1e);
+	val = phy_read(dev, 0x1e);
 	val |= 0x0100;
-	mii_write(mdev, mdev->address, 0x1e, val);
-
-	mii_close(mdev);
-
-	return 0;
+	phy_write(dev, 0x1e, val);
 }
 
+static struct fec_platform_data fec_info = {
+	.xcv_type = RGMII,
+	.phy_init = mx6_rgmii_rework,
+	.phy_addr = 0,
+};
+
 static int arm2_devices_init(void)
 {
 	imx6_add_mmc3(NULL);
 
 	imx6_add_fec(&fec_info);
-	mx6_rgmii_rework();
 
 	armlinux_set_bootparams((void *)0x10000100);
 	armlinux_set_architecture(3837);
arch/arm/boards/freescale-mx6-sabrelite/board.c +14 -26
index c5bcf8b..6070e2e 100644
@@ -28,7 +28,7 @@
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
 #include <partition.h>
-#include <miidev.h>
+#include <linux/phy.h>
 #include <asm/io.h>
 #include <asm/mmu.h>
 #include <mach/generic.h>
@@ -136,38 +136,27 @@ static int sabrelite_mem_init(void)
 }
 mem_initcall(sabrelite_mem_init);
 
-static struct fec_platform_data fec_info = {
-	.xcv_type = RGMII,
-	.phy_addr = 6,
-};
-
-int mx6_rgmii_rework(void)
+static void mx6_rgmii_rework(struct phy_device *dev)
 {
-	struct mii_device *mdev;
-
-	mdev = mii_open("phy0");
-	if (!mdev) {
-		printf("unable to open phy0\n");
-		return -ENODEV;
-	}
-
-	mii_write(mdev, mdev->address, 0x09, 0x0f00);
+	phy_write(dev, 0x09, 0x0f00);
 
 	/* do same as linux kernel */
 	/* min rx data delay */
-	mii_write(mdev, mdev->address, 0x0b, 0x8105);
-	mii_write(mdev, mdev->address, 0x0c, 0x0000);
+	phy_write(dev, 0x0b, 0x8105);
+	phy_write(dev, 0x0c, 0x0000);
 
 	/* max rx/tx clock delay, min rx/tx control delay */
-	mii_write(mdev, mdev->address, 0x0b, 0x8104);
-	mii_write(mdev, mdev->address, 0x0c, 0xf0f0);
-	mii_write(mdev, mdev->address, 0x0b, 0x104);
-
-	mii_close(mdev);
-
-	return 0;
+	phy_write(dev, 0x0b, 0x8104);
+	phy_write(dev, 0x0c, 0xf0f0);
+	phy_write(dev, 0x0b, 0x104);
 }
 
+static struct fec_platform_data fec_info = {
+	.xcv_type = RGMII,
+	.phy_init = mx6_rgmii_rework,
+	.phy_addr = 6,
+};
+
 static int sabrelite_ksz9021rn_setup(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(sabrelite_enet_pads, ARRAY_SIZE(sabrelite_enet_pads));
@@ -266,7 +255,6 @@ static int sabrelite_devices_init(void)
 	sabrelite_ksz9021rn_setup();
 	imx6_iim_register_fec_ethaddr();
 	imx6_add_fec(&fec_info);
-	mx6_rgmii_rework();
 
 	sabrelite_ehci_init();
 
arch/arm/configs/phycard_a_l1_defconfig +1 -1
index cf980f7..4cf2d21 100644
@@ -134,7 +134,7 @@ CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
-CONFIG_MIIDEV=y
+CONFIG_PHYLIB=y
 CONFIG_DRIVER_NET_SMC911X=y
 CONFIG_DRIVER_NET_SMC911X_ADDRESS_SHIFT=0
 CONFIG_SPI=n
arch/arm/configs/tx51stk5_defconfig +1 -1
index 7fff0f0..2c83189 100644
@@ -110,7 +110,7 @@ CONFIG_NET_TFTP=y
 CONFIG_NET_TFTP_PUSH=y
 CONFIG_DRIVER_SERIAL_IMX=y
 CONFIG_ARCH_HAS_FEC_IMX=y
-CONFIG_MIIDEV=y
+CONFIG_PHYLIB=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 CONFIG_DRIVER_SPI_IMX_2_3=y
 CONFIG_MTD=y
arch/ppc/boards/pcm030/pcm030.c +2 -2
index ba6aa43..7eedb00 100644
@@ -31,7 +31,7 @@
 #include <driver.h>
 #include <init.h>
 #include <mach/mpc5xxx.h>
-#include <mach/fec.h>
+#include <fec.h>
 #include <types.h>
 #include <partition.h>
 #include <memory.h>
@@ -39,7 +39,7 @@
 #include <linux/stat.h>
 #include <fs.h>
 
-static struct mpc5xxx_fec_platform_data fec_info = {
+static struct fec_platform_data fec_info = {
 	.xcv_type = MII100,
 };
 
arch/ppc/mach-mpc5xxx/include/mach/fec.h deleted +0 -14
deleted file mode 100644
index a3e04b4..0000000
@@ -1,14 +0,0 @@
-#ifndef __INCLUDE_ASM_ARCH_FEC_H
-#define __INCLUDE_ASM_ARCH_FEC_H
-
-struct mpc5xxx_fec_platform_data {
-        ulong  xcv_type;
-};
-
-typedef enum {
-	SEVENWIRE,			/* 7-wire       */
-	MII10,				/* MII 10Mbps   */
-	MII100				/* MII 100Mbps  */
-} xceiver_type;
-
-#endif /* __INCLUDE_ASM_ARCH_FEC_H */
drivers/net/Kconfig +16 -14
index 3c5f729..99757d3 100644
@@ -19,26 +19,28 @@ config HAS_DESIGNWARE_ETH
 config ARCH_HAS_FEC_IMX
 	bool
 
-config MIIDEV
+config PHYLIB
 	bool
 
 menu "Network drivers               "
 	depends on NET
 
+source "drivers/net/phy/Kconfig"
+
 config DRIVER_NET_CS8900
 	bool "cs8900 ethernet driver"
 	depends on HAS_CS8900
 
 config DRIVER_NET_SMC911X
 	bool "smc911x ethernet driver"
-	select MIIDEV
+	select PHYLIB
 	help
 	  This option enables support for the SMSC LAN9[12]1[567]
 	  ethernet chip.
 
 config DRIVER_NET_SMC91111
 	bool "smc91111 ethernet driver"
-	select MIIDEV
+	select PHYLIB
 	help
 	  This option enables support for the SMSC LAN91C111
 	  ethernet chip.
@@ -46,37 +48,37 @@ config DRIVER_NET_SMC91111
 config DRIVER_NET_DM9K
 	bool "Davicom dm9k[E|A|B] ethernet driver"
 	depends on HAS_DM9000
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_NETX
 	bool "Hilscher Netx ethernet driver"
 	depends on HAS_NETX_ETHER
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_AT91_ETHER
 	bool "at91 ethernet driver"
 	depends on HAS_AT91_ETHER
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_MPC5200
 	bool "MPC5200 Ethernet driver"
 	depends on ARCH_MPC5200
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_FEC_IMX
 	bool "i.MX FEC Ethernet driver"
 	depends on ARCH_HAS_FEC_IMX
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_EP93XX
 	bool "EP93xx Ethernet driver"
 	depends on ARCH_EP93XX
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_MACB
 	bool "macb Ethernet driver"
 	depends on HAS_MACB
-	select MIIDEV
+	select PHYLIB
 
 config DRIVER_NET_TAP
 	bool "tap Ethernet driver"
@@ -85,7 +87,7 @@ config DRIVER_NET_TAP
 config DRIVER_NET_TSE
 	depends on NIOS2
 	bool "Altera TSE ethernet driver"
-	select MIIDEV
+	select PHYLIB
 	help
 	  This option enables support for the Altera TSE MAC.
 
@@ -100,14 +102,14 @@ config TSE_USE_DEDICATED_DESC_MEM
 
 config DRIVER_NET_KS8851_MLL
 	bool "ks8851 mll ethernet driver"
-	select MIIDEV
+	select PHYLIB
 	help
 	  This option enables support for the Micrel KS8851 MLL
 	  ethernet chip.
 
 config DRIVER_NET_DESIGNWARE
 	bool "Designware Universal MAC ethernet driver"
-	select MIIDEV
+	select PHYLIB
 	depends on HAS_DESIGNWARE_ETH
 	help
 	  This option enables support for the Synopsys
@@ -121,7 +123,7 @@ config DRIVER_NET_DESIGNWARE_ALTDESCRIPTOR
 config DRIVER_NET_GIANFAR
 	bool "Gianfar Ethernet"
 	depends on ARCH_MPC85XX
-	select MIIDEV
+	select PHYLIB
 
 source "drivers/net/usb/Kconfig"
 
drivers/net/Makefile +1 -1
index 4d960e8..4939b7f 100644
@@ -9,7 +9,7 @@ obj-$(CONFIG_DRIVER_NET_FEC_IMX)	+= fec_imx.o
 obj-$(CONFIG_DRIVER_NET_EP93XX)		+= ep93xx.o
 obj-$(CONFIG_DRIVER_NET_MACB)		+= macb.o
 obj-$(CONFIG_DRIVER_NET_TAP)		+= tap.o
-obj-$(CONFIG_MIIDEV)			+= miidev.o
+obj-$(CONFIG_PHYLIB)			+= phy/
 obj-$(CONFIG_NET_USB)			+= usb/
 obj-$(CONFIG_DRIVER_NET_TSE)		+= altera_tse.o
 obj-$(CONFIG_DRIVER_NET_KS8851_MLL)	+= ks8851_mll.o
drivers/net/altera_tse.c +22 -26

112 lines not on this page · raw message

drivers/net/altera_tse.h +2 -1
index 866dbce..5a66a7d 100644
@@ -292,7 +292,8 @@ struct altera_tse_priv {
 	void __iomem *sgdma_tx_regs;
 	void __iomem *rx_desc;
 	void __iomem *tx_desc;
-	struct mii_device *miidev;
+	int phy_addr;
+	struct mii_bus *miibus;
 };
 
 #endif /* _ALTERA_TSE_H_ */
drivers/net/at91_ether.c +26 -23

131 lines not on this page · raw message

drivers/net/designware.c +33 -29

132 lines not on this page · raw message

drivers/net/dm9k.c +21 -29

142 lines not on this page · raw message

drivers/net/ep93xx.c +20 -15
index c28fb79..a14c0ea 100644
@@ -34,17 +34,17 @@
 #include <command.h>
 #include <init.h>
 #include <malloc.h>
-#include <miidev.h>
 #include <io.h>
 #include <linux/types.h>
 #include <mach/ep93xx-regs.h>
+#include <linux/phy.h>
 #include "ep93xx.h"
 
 #define EP93XX_MAX_PKT_SIZE    1536
 
-static int ep93xx_phy_read(struct mii_device *mdev, int phy_addr, int phy_reg);
-static int ep93xx_phy_write(struct mii_device *mdev, int phy_addr, int phy_reg,
-			    int value);
+static int ep93xx_phy_read(struct mii_bus *bus, int phy_addr, int phy_reg);
+static int ep93xx_phy_write(struct mii_bus *bus, int phy_addr, int phy_reg,
+			    u16 value);
 
 static inline struct ep93xx_eth_priv *ep93xx_get_priv(struct eth_device *edev)
 {
@@ -199,9 +199,15 @@ static int ep93xx_eth_open(struct eth_device *edev)
 	struct ep93xx_eth_priv *priv = ep93xx_get_priv(edev);
 	struct mac_regs *regs = ep93xx_get_regs(edev);
 	int i;
+	int ret;
 
 	pr_debug("+ep93xx_eth_open\n");
 
+	ret = phy_device_connect(edev, &priv->miibus, 0, NULL,
+				 0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
+
 	ep93xx_eth_reset(edev);
 
 	/* Reset the descriptor queues' current and end address values */
@@ -498,11 +504,10 @@ static int ep93xx_eth_probe(struct device_d *dev)
 	edev->set_ethaddr = ep93xx_eth_set_ethaddr;
 	edev->parent = dev;
 
-	priv->miidev.read = ep93xx_phy_read;
-	priv->miidev.write = ep93xx_phy_write;
-	priv->miidev.address = 0;
-	priv->miidev.flags = 0;
-	priv->miidev.parent = dev;
+	priv->miibus.read = ep93xx_phy_read;
+	priv->miibus.write = ep93xx_phy_write;
+	priv->miibus.parent = dev;
+	priv->miibus.priv = edev;
 
 	priv->tx_dq.base = calloc(NUMTXDESC,
 				sizeof(struct tx_descriptor));
@@ -532,7 +537,7 @@ static int ep93xx_eth_probe(struct device_d *dev)
 		goto eth_probe_failed_3;
 	}
 
-	mii_register(&priv->miidev);
+	mdiobus_register(&priv->miibus);
 	eth_register(edev);
 
 	ret = 0;
@@ -575,9 +580,9 @@ eth_probe_done:
 /**
  * Read a 16-bit value from an MII register.
  */
-static int ep93xx_phy_read(struct mii_device *mdev, int phy_addr, int phy_reg)
+static int ep93xx_phy_read(struct mii_bus *bus, int phy_addr, int phy_reg)
 {
-	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	struct mac_regs *regs = ep93xx_get_regs(bus->priv);
 	int value = -1;
 	uint32_t self_ctl;
 
@@ -618,10 +623,10 @@ static int ep93xx_phy_read(struct mii_device *mdev, int phy_addr, int phy_reg)
 /**
  * Write a 16-bit value to an MII register.
  */
-static int ep93xx_phy_write(struct mii_device *mdev, int phy_addr,
-			int phy_reg, int value)
+static int ep93xx_phy_write(struct mii_bus *bus, int phy_addr,
+			int phy_reg, u16 value)
 {
-	struct mac_regs *regs = ep93xx_get_regs(mdev->edev);
+	struct mac_regs *regs = ep93xx_get_regs(bus->priv);
 	uint32_t self_ctl;
 
 	pr_debug("+ep93xx_phy_write\n");
drivers/net/ep93xx.h +1 -1
index 875715f..4d50f70 100644
@@ -141,7 +141,7 @@ struct ep93xx_eth_priv {
 	struct tx_descriptor_queue	tx_dq;
 	struct tx_status_queue		tx_sq;
 
-	struct mii_device miidev;
+	struct mii_bus miibus;
 };
 
 #endif
drivers/net/fec_imx.c +52 -37

140 lines not on this page · raw message

drivers/net/fec_imx.h +5 -1
index b75b4d6..c8e758b 100644
@@ -137,7 +137,11 @@ struct fec_priv {
 	int rbd_index;				/* next receive BD to read   */
 	struct buffer_descriptor __iomem *tbd_base;	/* TBD ring                  */
 	int tbd_index;				/* next transmit BD to write */
-	struct mii_device miidev;
+	int phy_addr;
+	phy_interface_t interface;
+	u32 phy_flags;
+	struct mii_bus miibus;
+	void (*phy_init)(struct phy_device *dev);
 };
 
 /**
drivers/net/fec_mpc5200.c +33 -25

111 lines not on this page · raw message

drivers/net/fec_mpc5200.h +3 -1
index f6da3e5..20ac607 100644
@@ -260,7 +260,9 @@ typedef struct {
 	uint16_t usedTbdIndex;		/* next transmit BD to clean */
 	uint16_t cleanTbdNum;		/* the number of available transmit BDs */
 
-	struct mii_device miidev;
+	phy_interface_t interface;
+	u32 phy_flags;
+	struct mii_bus miibus;
 } mpc5xxx_fec_priv;
 
 /* Ethernet parameter area */
drivers/net/gianfar.c +26 -35

138 lines not on this page · raw message

drivers/net/gianfar.h +1 -1
index a4ad99e..b52cc5a 100644
@@ -269,7 +269,7 @@ struct gfar_private {
 	void __iomem *phyregs;
 	void __iomem *phyregs_sgmii;
 	struct phy_info *phyinfo;
-	struct mii_device miidev;
+	struct mii_bus miibus;
 	volatile struct txbd8 *txbd;
 	volatile struct rxbd8 *rxbd;
 	uint txidx;
drivers/net/ks8851_mll.c +16 -20
index 71391cc..926c433 100644
@@ -26,13 +26,13 @@
 
 #include <command.h>
 #include <net.h>
-#include <miidev.h>
 #include <malloc.h>
 #include <init.h>
 #include <xfuncs.h>
 #include <errno.h>
 #include <clock.h>
 #include <io.h>
+#include <linux/phy.h>
 
 #define MAX_RECV_FRAMES			32
 #define MAX_BUF_SIZE			2048
@@ -372,7 +372,7 @@
 
 struct ks_net {
 	struct eth_device	edev;
-	struct mii_device	miidev;
+	struct mii_bus	miibus;
 	void __iomem		*hw_addr;
 	void __iomem		*hw_addr_cmd;
 	struct platform_device	*pdev;
@@ -536,10 +536,9 @@ static int ks_phy_reg(int reg)
  * caller. The mii-tool that the driver was tested with takes any -ve error
  * as real PHY capabilities, thus displaying incorrect data to the user.
  */
-static int ks_phy_read(struct mii_device *mdev, int addr, int reg)
+static int ks_phy_read(struct mii_bus *bus, int addr, int reg)
 {
-	struct eth_device *edev = mdev->edev;
-	struct ks_net *priv = (struct ks_net *)edev->priv;
+	struct ks_net *priv = (struct ks_net *)bus->priv;
 	int ksreg;
 	int result;
 
@@ -552,10 +551,9 @@ static int ks_phy_read(struct mii_device *mdev, int addr, int reg)
 	return result;
 }
 
-static int ks_phy_write(struct mii_device *mdev, int addr, int reg, int val)
+static int ks_phy_write(struct mii_bus *bus, int addr, int reg, u16 val)
 {
-	struct eth_device *edev = mdev->edev;
-	struct ks_net *priv = (struct ks_net *)edev->priv;
+	struct ks_net *priv = (struct ks_net *)bus->priv;
 	int ksreg;
 
 	ksreg = ks_phy_reg(reg);
@@ -783,11 +781,14 @@ static int ks8851_eth_open(struct eth_device *edev)
 {
 	struct ks_net *priv = (struct ks_net *)edev->priv;
 	struct device_d *dev = &edev->dev;
+	int ret;
 
 	ks_enable_qmu(priv);
 
-	miidev_wait_aneg(&priv->miidev);
-	miidev_print_status(&priv->miidev);
+	ret = phy_device_connect(edev, &priv->miibus, 1, NULL,
+				 0, PHY_INTERFACE_MODE_NA);
+	if (ret)
+		return ret;
 
 	dev_dbg(dev, "eth_open\n");
 
@@ -796,9 +797,6 @@ static int ks8851_eth_open(struct eth_device *edev)
 
 static int ks8851_init_dev(struct eth_device *edev)
 {
-	struct ks_net *priv = (struct ks_net *)edev->priv;
-
-	miidev_restart_aneg(&priv->miidev);
 	return 0;
 }
 
@@ -842,12 +840,10 @@ static int ks8851_probe(struct device_d *dev)
 	edev->parent = dev;
 
 	/* setup mii state */
-	ks->miidev.read = ks_phy_read;
-	ks->miidev.write = ks_phy_write;
-	ks->miidev.address = 1;
-	ks->miidev.flags = 0;
-	ks->miidev.edev = edev;
-	ks->miidev.parent = dev;
+	ks->miibus.read = ks_phy_read;
+	ks->miibus.write = ks_phy_write;
+	ks->miibus.priv = ks;
+	ks->miibus.parent = dev;
 
 	/* simple check for a valid chip being connected to the bus */
 
@@ -868,7 +864,7 @@ static int ks8851_probe(struct device_d *dev)
 	ks_soft_reset(ks, GRR_GSR);
 	ks_setup(ks);
 
-	mii_register(&ks->miidev);
+	mdiobus_register(&ks->miibus);
 	eth_register(edev);
 	dev_dbg(dev, "%s MARL 0x%04x MARM 0x%04x MARH 0x%04x\n", __func__,
 		ks_rdreg16(ks, KS_MARL), ks_rdreg16(ks, KS_MARM),
drivers/net/macb.c +46 -33

145 lines not on this page · raw message

drivers/net/miidev.c deleted +0 -316

316 lines not on this page · raw message

drivers/net/netx_eth.c +13 -13
index 2d92a2e..a476425 100644
@@ -2,13 +2,13 @@
 #include <command.h>
 #include <net.h>
 #include <io.h>
-#include <miidev.h>
 #include <mach/netx-xc.h>
 #include <mach/netx-eth.h>
 #include <mach/netx-regs.h>
 #include <xfuncs.h>
 #include <init.h>
 #include <driver.h>
+#include <linux/phy.h>
 
 #define ETH_MAC_LOCAL_CONFIG 0x1560
 #define ETH_MAC_4321         0x1564
@@ -47,7 +47,7 @@
 #define CON_FIFO_PORT_LO(xcno)  (6 + ((xcno) << 3))    /* Index of the FIFO where sent Data packages are confirmed */
 
 struct netx_eth_priv {
-	struct mii_device miidev;
+	struct mii_bus miibus;
 	int xcno;
 };
 
@@ -118,7 +118,7 @@ static int netx_eth_rx (struct eth_device *edev)
 	return 0;
 }
 
-static int netx_miidev_read(struct mii_device *mdev, int phy_addr, int reg)
+static int netx_miibus_read(struct mii_bus *bus, int phy_addr, int reg)
 {
 	int value;
 
@@ -135,8 +135,8 @@ static int netx_miidev_read(struct mii_device *mdev, int phy_addr, int reg)
 	return value;
 }
 
-static int netx_miidev_write(struct mii_device *mdev, int phy_addr,
-	int reg, int val)
+static int netx_miibus_write(struct mii_bus *bus, int phy_addr,
+	int reg, u16 val)
 {
 	debug("%s: addr: 0x%02x reg: 0x%02x val: 0x%04x\n",__func__,
 	      phy_addr, reg, val);
@@ -189,13 +189,15 @@ static int netx_eth_init_dev(struct eth_device *edev)
 	for (i = 2; i <= 18; i++)
 		PFIFO_REG( PFIFO_BASE(EMPTY_PTR_FIFO(xcno)) ) = FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(xcno);
 
-	miidev_restart_aneg(&priv->miidev);
 	return 0;
 }
 
 static int netx_eth_open(struct eth_device *edev)
 {
-	return 0;
+	struct netx_eth_priv *priv = (struct netx_eth_priv *)edev->priv;
+
+	return phy_device_connect(edev, &priv->miibus, 0, NULL,
+				 0, PHY_INTERFACE_MODE_NA);
 }
 
 static void netx_eth_halt (struct eth_device *edev)
@@ -259,14 +261,12 @@ static int netx_eth_probe(struct device_d *dev)
 	edev->set_ethaddr = netx_eth_set_ethaddr;
 	edev->parent = dev;
 
-	priv->miidev.read = netx_miidev_read;
-	priv->miidev.write = netx_miidev_write;
-	priv->miidev.address = 0;
-	priv->miidev.flags = 0;
-	priv->miidev.parent = dev;
+	priv->miibus.read = netx_miibus_read;
+	priv->miibus.write = netx_miibus_write;
+	priv->miibus.parent = dev;
 
 	netx_eth_init_phy();
-	mii_register(&priv->miidev);
+	mdiobus_register(&priv->miibus);
 	eth_register(edev);
 
         return 0;
drivers/net/phy/Kconfig new file +17 -0
new file mode 100644
index 0000000..b66261a
@@ -0,0 +1,17 @@
+#
+# PHY Layer Configuration
+#
+
+menu "phylib                       "
+
+if PHYLIB
+
+comment "MII PHY device drivers"
+
+config GENERIC_PHY
+	bool "Drivers for the Generic PHYs"
+	default y
+
+endif
+
+endmenu
drivers/net/phy/Makefile new file +2 -0
new file mode 100644
index 0000000..82e90d4
@@ -0,0 +1,2 @@
+obj-y += phy.o mdio_bus.o
+obj-$(CONFIG_GENERIC_PHY) += generic.o
drivers/net/phy/generic.c renamed from include/fec.h +15 -28

55 lines not on this page · raw message

drivers/net/phy/mdio_bus.c new file +250 -0

250 lines not on this page · raw message

drivers/net/phy/phy.c new file +568 -0

568 lines not on this page · raw message

drivers/net/smc91111.c +19 -28

103 lines not on this page · raw message

drivers/net/smc911x.c +17 -20
index f697608..c58ea72 100644
@@ -30,7 +30,6 @@
 
 #include <command.h>
 #include <net.h>
-#include <miidev.h>
 #include <malloc.h>
 #include <init.h>
 #include <xfuncs.h>
@@ -38,12 +37,13 @@
 #include <clock.h>
 #include <io.h>
 #include <smc911x.h>
+#include <linux/phy.h>
 
 #include "smc911x.h"
 
 struct smc911x_priv {
 	struct eth_device edev;
-	struct mii_device miidev;
+	struct mii_bus miibus;
 	void __iomem *base;
 
 	int shift;
@@ -198,9 +198,9 @@ static int smc911x_set_ethaddr(struct eth_device *edev, unsigned char *m)
 	return 0;
 }
 
-static int smc911x_phy_read(struct mii_device *mdev, int phy_addr, int reg)
+static int smc911x_phy_read(struct mii_bus *bus, int phy_addr, int reg)
 {
-	struct eth_device *edev = mdev->edev;
+	struct eth_device *edev = bus->priv;
 
 	while (smc911x_get_mac_csr(edev, MII_ACC) & MII_ACC_MII_BUSY);
 
@@ -212,10 +212,10 @@ static int smc911x_phy_read(struct mii_device *mdev, int phy_addr, int reg)
 	return smc911x_get_mac_csr(edev, MII_DATA);
 }
 
-static int smc911x_phy_write(struct mii_device *mdev, int phy_addr,
-	int reg, int val)
+static int smc911x_phy_write(struct mii_bus *bus, int phy_addr,
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/net/usb/Kconfig +2 -2
index b53dcc7..adb1b0b 100644

Lines of this file are not shown. View the raw message.

drivers/net/usb/asix.c +13 -16
index be5a170..97680cf 100644

Lines of this file are not shown. View the raw message.

drivers/net/usb/smsc95xx.c +19 -22

41 lines not on this page · raw message

drivers/net/usb/usbnet.c +3 -8
index c7e3606..80b4ae7 100644

Lines of this file are not shown. View the raw message.

include/fec.h +3 -0
index f56b023..6e1e1cd 100644

Lines of this file are not shown. View the raw message.

include/linux/ethtool.h new file +114 -0

114 lines not on this page · raw message

include/linux/mii.h +443 -232

675 lines not on this page · raw message

include/linux/phy.h new file +266 -0

266 lines not on this page · raw message

include/miidev.h +9 -42

51 lines not on this page · raw message

include/net.h +4 -0
index 9152943..39fad12 100644

Lines of this file are not shown. View the raw message.

include/usb/usbnet.h +3 -2
index 1609b2e..cb8ff03 100644

Lines of this file are not shown. View the raw message.

net/eth.c +6 -2
index c034eaa..6cfe4f2 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Part of the diff is not shown here. View the raw message.

maintainer
#2 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

v7:
- drop the duplicate platform_data for fec driver as we need to update both with the same data (piss me off)

Already fixed this up. Is there anything else why I should use this version instead of the one currently in -next?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
Quoted 9 lines · Sascha Hauer
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

v7:
- drop the duplicate platform_data for fec driver as we need to update both with the same data (piss me off)

Already fixed this up. Is there anything else why I should use this version instead of the one currently in -next?

there is a fix for at91_ether IIRC I just send a fix for macb if you can squash them will be nice

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD
 include/linux/phy.h                             |  266 ++++++++++++++++++++++++++
 include/miidev.h                                |   51 +----

We now have a "struct mii_bus" in include/linux/phy.h and include/miidev.h. Is this intentional?

Regards,
Jan

Signature · 10 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#6 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

v7:
- drop the duplicate platform_data for fec driver as we need to update both with the same data (piss me off)

v6:
- probe phy at mdiobus_register
- reimplement the mdiobuss support

v5:
- drop edev in mii_device

v4:
- move phy_dev attachement to eth_device instead of mii_device this will allow multiple phy_device per mii bus
- move phy cdev to phy_device
- add interface type support (so phy driver can configure themselves if MII/RMII/RGMII etc...
- manage link status at framework level
- mx6 update to fixup the phy at device opening

Quoted 4 lines

v3:
- fix comment
- add phy_driver probe and remove
- renambe phydev.h to phy.h and phylib.c to phy.c as in linux

I think the main reason you introduced phylib was proper link handling, but what we have now is worse than ever!

Now when no cable is connected, the phylib internally recognizes it but the status is never propagated. So without cable I get:

barebox@Freescale i.MX51 PDK:/ dhcp
T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout

Plugging in a cable does not help, since the link status is only evaluated once during eth_open. If then a cable is plugged, adjust_link is never called, so the driver never adjusts to the actual link.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw
Quoted 41 lines · Sascha Hauer
Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD

HI,

v7:
- drop the duplicate platform_data for fec driver as we need to update both with the same data (piss me off)

v6:
- probe phy at mdiobus_register
- reimplement the mdiobuss support

v5:
- drop edev in mii_device

v4:
- move phy_dev attachement to eth_device instead of mii_device this will allow multiple phy_device per mii bus
- move phy cdev to phy_device
- add interface type support (so phy driver can configure themselves if MII/RMII/RGMII etc...
- manage link status at framework level
- mx6 update to fixup the phy at device opening

Quoted 4 lines

v3:
- fix comment
- add phy_driver probe and remove
- renambe phydev.h to phy.h and phylib.c to phy.c as in linux

I think the main reason you introduced phylib was proper link handling, but what we have now is worse than ever!

Now when no cable is connected, the phylib internally recognizes it but the status is never propagated. So without cable I get:

barebox@Freescale i.MX51 PDK:/ dhcp
T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout

Quoted 3 lines

Plugging in a cable does not help, since the link status is only evaluated once during eth_open. If then a cable is plugged, adjust_link is never called, so the driver never adjusts to the actual link.

no this should not happend with the current code
eth_send set the device as not active if eth_open failled of phy is not up

so eth_open is called again so phy_connect too

This only part we do not have is a poller to check the phy is still up

Best Regards,
J.

Quoted 8 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

maintainer
#8 lore raw
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Sascha Hauer

barebox@Freescale i.MX51 PDK:/ dhcp
T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout

Quoted 4 lines
Quoted 3 lines

Plugging in a cable does not help, since the link status is only evaluated once during eth_open. If then a cable is plugged, adjust_link is never called, so the driver never adjusts to the actual link.

no this should not happend with the current code

Appearantly the code does not know what should and what should not happen.

Quoted 1 line

eth_send set the device as not active if eth_open failled of phy is not up

eth_send doesn't, but eth_rx does.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw
Quoted 13 lines · Sascha Hauer
Quoted 12 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 11 lines · Sascha Hauer

barebox@Freescale i.MX51 PDK:/ dhcp
T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout
T T transmission timeout

Plugging in a cable does not help, since the link status is only evaluated once during eth_open. If then a cable is plugged, adjust_link is never called, so the driver never adjusts to the actual link.

Quoted 8 lines
Quoted 1 line

no this should not happend with the current code

Appearantly the code does not know what should and what should not happen.

Quoted 1 line

eth_send set the device as not active if eth_open failled of phy is not up

eth_send doesn't, but eth_rx does.

no it really in eth_send I found the bug I did a mistake in v7 I drop a check in eth_send that report the phy down

I send the fix

Best Regards,
J.

Quoted 8 lines

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#10 lore raw

PATCH 1/2 calao: at91 qil/tny/usb auto detect the phy addr

In reply to Sascha Hauer
---
 arch/arm/boards/qil-a9260/init.c |    2 +-
 arch/arm/boards/tny-a926x/init.c |    2 +-
 arch/arm/boards/usb-a926x/init.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/boards/qil-a9260/init.c +1 -1
index 6b1ed85..8a12b17 100644
@@ -80,7 +80,7 @@ static void qil_a9260_add_device_mci(void) {}
 #ifdef CONFIG_CALAO_MB_QIL_A9260
 static struct at91_ether_platform_data macb_pdata = {
 	.flags		= AT91SAM_ETHER_RMII,
-	.phy_addr	= 0,
+	.phy_addr	= -1,
 };
 
 static void qil_a9260_phy_reset(void)
arch/arm/boards/tny-a926x/init.c +1 -1
index 1e8a732..ce36570 100644
@@ -114,7 +114,7 @@ static void tny_a9260_add_device_nand(void)
 #ifdef CONFIG_DRIVER_NET_MACB
 static struct at91_ether_platform_data macb_pdata = {
 	.flags		= AT91SAM_ETHER_RMII,
-	.phy_addr	= 0,
+	.phy_addr	= -1,
 };
 
 static void __init ek_add_device_macb(void)
arch/arm/boards/usb-a926x/init.c +1 -1
index 2366c77..7b946a3 100644
@@ -113,7 +113,7 @@ static void usb_a9260_add_device_nand(void)
 
 static struct at91_ether_platform_data macb_pdata = {
 	.flags		= AT91SAM_ETHER_RMII,
-	.phy_addr	= 0,
+	.phy_addr	= -1,
 };
 
 static void usb_a9260_phy_reset(void)
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

PATCH 2/2 net/eth: fix missing check on eth active

I drop this check in the phylib v7 by mistake. This check is needed to report when the phy is down

---
 net/eth.c |    3 +++
 1 file changed, 3 insertions(+)
net/eth.c +3 -0
index beedd22..d3bda81 100644
@@ -142,6 +142,9 @@ int eth_send(void *packet, int length)
 			eth_current->active = 1;
 	}
 
+	if (!eth_current->active)
+		return -ENETDOWN;
+
 	led_trigger_network(LED_TRIGGER_NET_TX);
 
 	return eth_current->send(eth_current, packet, length);
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

PATCH 3/3 net/eth: fix link handling

In reply to Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx

---
 net/eth.c |   25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
net/eth.c +15 -10
index d3bda81..402e479 100644
@@ -124,7 +124,7 @@ int eth_complete(struct string_list *sl, char *instr)
 }
 #endif
 
-int eth_send(void *packet, int length)
+int eth_open(void)
 {
 	int ret;
 
@@ -145,6 +145,17 @@ int eth_send(void *packet, int length)
 	if (!eth_current->active)
 		return -ENETDOWN;
 
+	return 0;
+}
+
+int eth_send(void *packet, int length)
+{
+	int ret;
+
+	ret = eth_open();
+	if (ret)
+		return ret;
+
 	led_trigger_network(LED_TRIGGER_NET_TX);
 
 	return eth_current->send(eth_current, packet, length);
@@ -154,15 +165,9 @@ int eth_rx(void)
 {
 	int ret;
 
-	if (!eth_current)
-		return -ENODEV;
-
-	if (!eth_current->active) {
-		ret = eth_current->open(eth_current);
-		if (ret)
-			return ret;
-		eth_current->active = 1;
-	}
+	ret = eth_open();
+	if (ret)
+		return ret;
 
 	return eth_current->recv(eth_current);
 }
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#13 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx

---

This is broken. For better readability I refer to the result, not to the patch:

Quoted 15 lines

int eth_open(void)

{
	int ret;

	if (!eth_current)
		return -ENODEV;

	if (!eth_current->active) {
		ret = eth_current->open(eth_current);
		if (ret)
			return ret;

		if (eth_current->phydev)
			eth_current->active = eth_current->phydev->link;
		else
Quoted 8 lines
			eth_current->active = 1;
	}

	if (!eth_current->active)
		return -ENETDOWN;

	return 0;
}

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#14 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

Quoted 8 lines · Sascha Hauer

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

Yes. We should not repeatedly open the device to check link status again. A open (active==1) device with no link is perfectly valid, it just can't be used for TX/RX.

So if we have an open device in TX/RX and
link down: recheck link
link up: recheck link if the last check is "too old"

This way we notice both link going down and up, while not wasting time when we are waiting for link up.

Regards,
Jan

Signature · 10 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

Quoted 14 lines · Jan Lübbe
Quoted 8 lines · Sascha Hauer

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

Yes. We should not repeatedly open the device to check link status again. A open (active==1) device with no link is perfectly valid, it just can't be used for TX/RX.

Quoted 6 lines

So if we have an open device in TX/RX and
link down: recheck link
link up: recheck link if the last check is "too old"

This way we notice both link going down and up, while not wasting time when we are waiting for link up.

except this can not work in barebox. In linux you can as you have a schedule work that check the phy status. In barebox we do not do so and I do not want it (slow down the boot). So we check it at the open only and only once. When the phy is up we do not check it again.

Remember we are in a bootloader not in an os we need to do some concession.

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#18 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

In reply to Sascha Hauer
Quoted 33 lines · Sascha Hauer
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx

---

This is broken. For better readability I refer to the result, not to the patch:

Quoted 15 lines

int eth_open(void)

{
	int ret;

	if (!eth_current)
		return -ENODEV;

	if (!eth_current->active) {
		ret = eth_current->open(eth_current);
		if (ret)
			return ret;

		if (eth_current->phydev)
			eth_current->active = eth_current->phydev->link;
		else
Quoted 8 lines
			eth_current->active = 1;
	}

	if (!eth_current->active)
		return -ENETDOWN;

	return 0;
}
Quoted 8 lines

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

ok we can have both but the current will not not monitor the phy status

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

maintainer
#16 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 18 lines · Jan Lübbe
Quoted 8 lines · Sascha Hauer

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

Yes. We should not repeatedly open the device to check link status again. A open (active==1) device with no link is perfectly valid, it just can't be used for TX/RX.

So if we have an open device in TX/RX and
link down: recheck link
link up: recheck link if the last check is "too old"

Quoted 8 lines
Quoted 2 lines

This way we notice both link going down and up, while not wasting time when we are waiting for link up.

except this can not work in barebox. In linux you can as you have a schedule work that check the phy status. In barebox we do not do so and I do not want it (slow down the boot). So we check it at the open only and only once. When the phy is up we do not check it again.

Remember we are in a bootloader not in an os we need to do some concession.

int check_link_status(void)

{
	if (is_timeout(last_link_check, SECOND)) {
		do_link_check();
		last_link_check = get_time_ns();
	}
}

eth_rx(void)

{
	check_link_status();
}

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw

Re: [PATCH 3/3] net/eth: fix link handling

Quoted 29 lines · Sascha Hauer
Quoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 18 lines · Jan Lübbe
Quoted 8 lines · Sascha Hauer

The eth->active is for tracking whether a device is opened (thus we have to call eth->halt). With this patch eth->active == 0 could mean:

a) device not opened
b) opened, but no link

This is asking for trouble. A bit only has two states, you should not encode three states in it.

Yes. We should not repeatedly open the device to check link status again. A open (active==1) device with no link is perfectly valid, it just can't be used for TX/RX.

So if we have an open device in TX/RX and
link down: recheck link
link up: recheck link if the last check is "too old"

Quoted 8 lines
Quoted 2 lines

This way we notice both link going down and up, while not wasting time when we are waiting for link up.

except this can not work in barebox. In linux you can as you have a schedule work that check the phy status. In barebox we do not do so and I do not want it (slow down the boot). So we check it at the open only and only once. When the phy is up we do not check it again.

Remember we are in a bootloader not in an os we need to do some concession.

Quoted 7 lines

int check_link_status(void)

{
	if (is_timeout(last_link_check, SECOND)) {
		do_link_check();
		last_link_check = get_time_ns();
	}
}

we can do this but every second is too much this will slow down nfs/tftp transfert every 30s or 10s will be better

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#19 lore raw

PATCH v7 1/1 net/eth: fix link handling

In reply to Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx The current code use activate for both open and link up.

Now we handle both seperatly and update the link at first rx or tx not at open.

---
 drivers/net/phy/phy.c |   34 ++++++++++++++++-------
 include/linux/phy.h   |    3 +++
 include/net.h         |    4 +++
 net/eth.c             |   72 ++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 85 insertions(+), 28 deletions(-)
drivers/net/phy/phy.c +24 -10
index e1a24fa..56cc25b 100644
@@ -29,6 +29,29 @@
 
 static int genphy_config_init(struct phy_device *phydev);
 
+int phy_update_status(struct phy_device *dev)
+{
+	struct phy_driver *drv = to_phy_driver(dev->dev.driver);
+	struct eth_device *edev = dev->attached_dev;
+	int ret;
+
+	ret = drv->read_status(dev);
+	if (ret)
+		return ret;
+
+	if (dev->link == edev->carrier)
+		return 0;
+
+	dev->adjust_link(edev);
+	edev->carrier = dev->link;
+
+	if (dev->link)
+		printf("%dMbps %s duplex link detected\n", dev->speed,
+			dev->duplex ? "full" : "half");
+
+	return 0;
+}
+
 struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id)
 {
 	struct phy_device *dev;
@@ -172,16 +195,7 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 
 	drv->config_aneg(dev);
 
-	ret = drv->read_status(dev);
-	if (ret < 0)
-		return ret;
-
-	if (dev->link)
-		printf("%dMbps %s duplex link detected\n", dev->speed,
-			dev->duplex ? "full" : "half");
-
-	if (adjust_link)
-		adjust_link(edev);
+	dev->adjust_link = adjust_link;
 
 	return 0;
 
include/linux/phy.h +3 -0
index 8fe6b86..76f9edb 100644
@@ -164,6 +164,7 @@ struct phy_device {
 	void *priv;
 
 	struct eth_device *attached_dev;
+	void (*adjust_link)(struct eth_device *dev);
 
 	struct cdev cdev;
 };
@@ -253,6 +254,8 @@ int phy_device_connect(struct eth_device *dev, struct mii_bus *bus, int addr,
 		       void (*adjust_link) (struct eth_device *edev),
 		       u32 flags, phy_interface_t interface);
 
+int phy_update_status(struct phy_device *phydev);
+
 /* Generic PHY support and helper functions */
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
include/net.h +4 -0
index 39fad12..a3474a5 100644
@@ -32,6 +32,10 @@ struct device_d;
 
 struct eth_device {
 	int active;
+	#define CARRIER_ON	0
+	#define CARRIER_OFF	1
+	#define	CARRIER_UNKNOW	-1
+	int carrier;
 
 	int  (*init) (struct eth_device*);
 
net/eth.c +54 -18

99 lines not on this page · raw message

Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#20 lore raw

Re: [PATCH 1/1] net/eth: fix link handling

Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx The current code use activate for both open and link up.

Now we handle both seperatly and update the link at first rx or tx not at open.

---
 drivers/net/phy/phy.c |   34 ++++++++++++++++-------
 include/linux/phy.h   |    3 +++
 include/net.h         |    4 +++
 net/eth.c             |   72 ++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 85 insertions(+), 28 deletions(-)
drivers/net/phy/phy.c +5 -0
index e1a24fa..56cc25b 100644
@@ -29,6 +29,29 @@
 
 static int genphy_config_init(struct phy_device *phydev);
 
+int phy_update_status(struct phy_device *dev)
+{
+	struct phy_driver *drv = to_phy_driver(dev->dev.driver);
+	struct eth_device *edev = dev->attached_dev;
+	int ret;

drivers/net/phy/phy.c line 46

Quoted 10 lines
drivers/net/phy/phy.c +10 -0
+
+	ret = drv->read_status(dev);
+	if (ret)
+		return ret;
+
+	if (dev->link == edev->carrier)
+		return 0;
+
+	dev->adjust_link(edev);
+	edev->carrier = dev->link;

dev->link is 0 for no link, 1 for link. According to this patch carrier should be one of CARRIER_ON, CARRIER_OFF, CARRIER_UNKNOW...

Quoted 9 lines
drivers/net/phy/phy.c +1 -0
+
 /* Generic PHY support and helper functions */
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
include/net.h +0 -0
index 39fad12..a3474a5 100644

include/net.h struct device_d; · line 36

Quoted 5 lines
include/net.h +2 -0
@@ -32,6 +32,10 @@ struct device_d;
 
 struct eth_device {
 	int active;
+	#define CARRIER_ON	0
+	#define CARRIER_OFF	1

... so when the link is up you set edev->link to CARRIER_OFF

Quoted 23 lines
include/net.h +8 -5
@@ -124,24 +125,61 @@ int eth_complete(struct string_list *sl, char *instr)
 }
 #endif
 
-int eth_send(void *packet, int length)
+static int eth_carrier_check(void)
 {
 	int ret;
 
-	if (!eth_current)
-		return -ENODEV;
+	if (!eth_current->phydev) {
+		eth_current->carrier = CARRIER_ON;
+		return 0;
+	}
 
-	if (!eth_current->active) {
-		ret = eth_current->open(eth_current);
+	if (eth_current->carrier == CARRIER_UNKNOW ||
+	    is_timeout(last_link_check, 10 * SECOND)) {
+		ret = phy_update_status(eth_current->phydev);
 		if (ret)
 			return ret;

include/net.h int eth_complete(struct string_list *sl, char *instr) · line 146

Quoted 10 lines
include/net.h +3 -5
-
-		if (eth_current->phydev)
-			eth_current->active = eth_current->phydev->link;
-		else
-			eth_current->active = 1;
+		last_link_check = get_time_ns();
 	}
 
+	if (!eth_current->carrier)
+		return -ENETDOWN;

So we have:

	if (eth_current->carrier == CARRIER_ON)
		return -ENETDOWN;

Could you do us a favour and look at your code before sending it?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#21 lore raw

Re: [PATCH 1/1] net/eth: fix link handling

Quoted 95 lines · Sascha Hauer
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD

The current code handle just the send where we are supposed to the same on rx The current code use activate for both open and link up.

Now we handle both seperatly and update the link at first rx or tx not at open.

---
 drivers/net/phy/phy.c |   34 ++++++++++++++++-------
 include/linux/phy.h   |    3 +++
 include/net.h         |    4 +++
 net/eth.c             |   72 ++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 85 insertions(+), 28 deletions(-)
drivers/net/phy/phy.c +5 -0
index e1a24fa..56cc25b 100644
@@ -29,6 +29,29 @@
 
 static int genphy_config_init(struct phy_device *phydev);
 
+int phy_update_status(struct phy_device *dev)
+{
+	struct phy_driver *drv = to_phy_driver(dev->dev.driver);
+	struct eth_device *edev = dev->attached_dev;
+	int ret;

drivers/net/phy/phy.c line 46

Quoted 10 lines
drivers/net/phy/phy.c +10 -0
+
+	ret = drv->read_status(dev);
+	if (ret)
+		return ret;
+
+	if (dev->link == edev->carrier)
+		return 0;
+
+	dev->adjust_link(edev);
+	edev->carrier = dev->link;

dev->link is 0 for no link, 1 for link. According to this patch carrier should be one of CARRIER_ON, CARRIER_OFF, CARRIER_UNKNOW...

Quoted 9 lines
drivers/net/phy/phy.c +1 -0
+
 /* Generic PHY support and helper functions */
 int genphy_restart_aneg(struct phy_device *phydev);
 int genphy_config_aneg(struct phy_device *phydev);
include/net.h +0 -0
index 39fad12..a3474a5 100644

include/net.h struct device_d; · line 36

Quoted 5 lines
include/net.h +2 -0
@@ -32,6 +32,10 @@ struct device_d;
 
 struct eth_device {
 	int active;
+	#define CARRIER_ON	0
+	#define CARRIER_OFF	1

... so when the link is up you set edev->link to CARRIER_OFF

Quoted 23 lines
include/net.h +8 -5
@@ -124,24 +125,61 @@ int eth_complete(struct string_list *sl, char *instr)
 }
 #endif
 
-int eth_send(void *packet, int length)
+static int eth_carrier_check(void)
 {
 	int ret;
 
-	if (!eth_current)
-		return -ENODEV;
+	if (!eth_current->phydev) {
+		eth_current->carrier = CARRIER_ON;
+		return 0;
+	}
 
-	if (!eth_current->active) {
-		ret = eth_current->open(eth_current);
+	if (eth_current->carrier == CARRIER_UNKNOW ||
+	    is_timeout(last_link_check, 10 * SECOND)) {
+		ret = phy_update_status(eth_current->phydev);
 		if (ret)
 			return ret;

include/net.h int eth_complete(struct string_list *sl, char *instr) · line 146

Quoted 10 lines
include/net.h +3 -5
-
-		if (eth_current->phydev)
-			eth_current->active = eth_current->phydev->link;
-		else
-			eth_current->active = 1;
+		last_link_check = get_time_ns();
 	}
 
+	if (!eth_current->carrier)
+		return -ENETDOWN;

So we have:

Quoted 4 lines
	if (eth_current->carrier == CARRIER_ON)
		return -ENETDOWN;

Could you do us a favour and look at your code before sending it?

ok I invert the the macro that I should not even put

but the current code does work

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#22 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 28 lines · Jean-Christophe PLAGNIOL-VILLARD

Adapt phylib from linux

This will allow to have
- phy drivers
- to only connect the phy at then opening of the device
- if the phy is not ready or down fail on open

Same behaviour as in linux and will allow to share code and simplify porting.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (1):
net: introduce phylib

 arch/arm/boards/freescale-mx6-arm2/board.c      |   43 ++---
 arch/arm/boards/freescale-mx6-sabrelite/board.c |   40 ++--
 arch/arm/configs/phycard_a_l1_defconfig         |    2 +-
 arch/arm/configs/tx51stk5_defconfig             |    2 +-
 arch/ppc/boards/pcm030/pcm030.c                 |    4 +-
 arch/ppc/mach-mpc5xxx/include/mach/fec.h        |   14 --
 drivers/net/Kconfig                             |   30 +--
 drivers/net/Makefile                            |    2 +-
 drivers/net/altera_tse.c                        |   48 +++--
 drivers/net/altera_tse.h                        |    3 +-
 drivers/net/at91_ether.c                        |   49 ++---
 drivers/net/designware.c                        |   62 ++++---
Quoted 8 lines
 drivers/net/dm9k.c                              |   50 +++--
 drivers/net/ep93xx.c                            |   35 ++--
 drivers/net/ep93xx.h                            |    2 +-
 drivers/net/fec_imx.c                           |   89 +++++----
 drivers/net/fec_imx.h                           |    6 +-
 drivers/net/fec_mpc5200.c                       |   58 +++---
 drivers/net/fec_mpc5200.h                       |    4 +-
 drivers/net/gianfar.c                           |   61 +++---

The mdiobus_scan performed when registering the mdio bus at probe time has an impact on boot time. I have a 85xx board whose PHY needs 450ms to be ready for access.

I will send a patch for the gianfar driver to register the mdio bus only when the device is open.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#23 lore raw
Quoted 38 lines · Renaud Barbier
Quoted 28 lines · Jean-Christophe PLAGNIOL-VILLARD

Adapt phylib from linux

This will allow to have
- phy drivers
- to only connect the phy at then opening of the device
- if the phy is not ready or down fail on open

Same behaviour as in linux and will allow to share code and simplify porting.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (1):
net: introduce phylib

 arch/arm/boards/freescale-mx6-arm2/board.c      |   43 ++---
 arch/arm/boards/freescale-mx6-sabrelite/board.c |   40 ++--
 arch/arm/configs/phycard_a_l1_defconfig         |    2 +-
 arch/arm/configs/tx51stk5_defconfig             |    2 +-
 arch/ppc/boards/pcm030/pcm030.c                 |    4 +-
 arch/ppc/mach-mpc5xxx/include/mach/fec.h        |   14 --
 drivers/net/Kconfig                             |   30 +--
 drivers/net/Makefile                            |    2 +-
 drivers/net/altera_tse.c                        |   48 +++--
 drivers/net/altera_tse.h                        |    3 +-
 drivers/net/at91_ether.c                        |   49 ++---
 drivers/net/designware.c                        |   62 ++++---
Quoted 8 lines
 drivers/net/dm9k.c                              |   50 +++--
 drivers/net/ep93xx.c                            |   35 ++--
 drivers/net/ep93xx.h                            |    2 +-
 drivers/net/fec_imx.c                           |   89 +++++----
 drivers/net/fec_imx.h                           |    6 +-
 drivers/net/fec_mpc5200.c                       |   58 +++---
 drivers/net/fec_mpc5200.h                       |    4 +-
 drivers/net/gianfar.c                           |   61 +++---
Quoted 6 lines

The mdiobus_scan performed when registering the mdio bus at probe time has an impact on boot time. I have a 85xx board whose PHY needs 450ms to be ready for access.

I will send a patch for the gianfar driver to register the mdio bus only when the device is open.

That why I did at the first open before

and I guess your case is not the only one

I do not like the idea to register the bus later

we need to have defer probe

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

maintainer
#24 lore raw
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines

The mdiobus_scan performed when registering the mdio bus at probe time has an impact on boot time. I have a 85xx board whose PHY needs 450ms to be ready for access.

I will send a patch for the gianfar driver to register the mdio bus only when the device is open.

Quoted 7 lines

That why I did at the first open before

and I guess your case is not the only one

I do not like the idea to register the bus later

we need to have defer probe

Yes, that's probably the best. Normally, when a phy address is given, we do not have to scan the bus at all, we only have to do it when -1 is given as phy address.

Another idea would be to pass a bitmask for valid phy addresses rather than a number. Maybe some board has a phy at a known address and another one at some to be detected address. Then for one phy the mask would be 0x00010000 and for the other 0xfffeffff. Given that this would be more effort to change all the platform data we can do this should the need arise.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#25 lore raw
Quoted 19 lines · Sascha Hauer
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines

The mdiobus_scan performed when registering the mdio bus at probe time has an impact on boot time. I have a 85xx board whose PHY needs 450ms to be ready for access.

I will send a patch for the gianfar driver to register the mdio bus only when the device is open.

Quoted 7 lines

That why I did at the first open before

and I guess your case is not the only one

I do not like the idea to register the bus later

we need to have defer probe

Yes, that's probably the best. Normally, when a phy address is given, we do not have to scan the bus at all, we only have to do it when -1 is given as phy address.

Quoted 6 lines

Another idea would be to pass a bitmask for valid phy addresses rather than a number. Maybe some board has a phy at a known address and another one at some to be detected address. Then for one phy the mask would be 0x00010000 and for the other 0xfffeffff. Given that this would be more effort to change all the platform data we can do this should the need arise.

scan the bus take nothing 100ms normally the mdio lock is 3MHz to 6MHz, the issue is that some phy need to be reset and you need wait for it and the bus reset

so I think we need to add:

- device probe defer support
- phy reset support at phylib level

phy mask will just reduce a few the bus scan

Best Regards,
J.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox