net: introduce phylib
Subsystems (10)
v4 cover net: introduce phylib
HI,
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 udpdate 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 f58d255dd01b394607ade918fa7f61a6d13c7f6b:
net: introduce phylib (2012-09-16 20:39:21 +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 | 41 ++++----- arch/arm/boards/freescale-mx6-sabrelite/board.c | 38 +++------ drivers/net/Kconfig | 2 + drivers/net/Makefile | 2 +- drivers/net/altera_tse.c | 19 ++--- drivers/net/altera_tse.h | 1 + drivers/net/at91_ether.c | 31 ++++--- drivers/net/designware.c | 39 +++++---- drivers/net/dm9k.c | 11 +-- drivers/net/ep93xx.c | 9 +- drivers/net/fec_imx.c | 64 +++++++++----- drivers/net/fec_imx.h | 4 + drivers/net/fec_mpc5200.c | 26 ++++-- drivers/net/gianfar.c | 34 +++----- drivers/net/ks8851_mll.c | 13 ++- drivers/net/macb.c | 56 +++++++----- drivers/net/miidev.c | 250 +---------------------------------------------------- drivers/net/netx_eth.c | 9 +- drivers/net/phy/Kconfig | 17 ++++ drivers/net/phy/Makefile | 2 + drivers/net/phy/generic.c | 36 ++++++++ drivers/net/phy/phy.c | 688 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/smc91111.c | 22 ++--- drivers/net/smc911x.c | 14 ++- drivers/net/usb/asix.c | 3 +- drivers/net/usb/smsc95xx.c | 3 +- drivers/net/usb/usbnet.c | 11 +-- include/fec.h | 3 + include/linux/ethtool.h | 114 +++++++++++++++++++++++++ include/linux/mii.h | 421 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- include/linux/phy.h | 206 ++++++++++++++++++++++++++++++++++++++++++++ include/miidev.h | 18 ---- include/net.h | 4 + include/usb/usbnet.h | 1 + net/eth.c | 6 +- 35 files changed, 1628 insertions(+), 590 deletions(-) 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/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
PATCH 1/1 net: introduce phylib
Adapt phylib from linux
switch all the driver to it
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 | 41 +- arch/arm/boards/freescale-mx6-sabrelite/board.c | 38 +- drivers/net/Kconfig | 2 + drivers/net/Makefile | 2 +- drivers/net/altera_tse.c | 19 +- drivers/net/altera_tse.h | 1 + drivers/net/at91_ether.c | 31 +- drivers/net/designware.c | 39 +- drivers/net/dm9k.c | 11 +- drivers/net/ep93xx.c | 9 +- drivers/net/fec_imx.c | 64 ++- drivers/net/fec_imx.h | 4 + drivers/net/fec_mpc5200.c | 26 +- drivers/net/gianfar.c | 34 +- drivers/net/ks8851_mll.c | 13 +- drivers/net/macb.c | 56 +- drivers/net/miidev.c | 384 +++---------- drivers/net/netx_eth.c | 9 +- drivers/net/phy/Kconfig | 17 + drivers/net/phy/Makefile | 2 + include/fec.h => drivers/net/phy/generic.c | 43 +- drivers/net/phy/phy.c | 688 +++++++++++++++++++++++ drivers/net/smc91111.c | 22 +- drivers/net/smc911x.c | 14 +- drivers/net/usb/asix.c | 3 +- drivers/net/usb/smsc95xx.c | 3 +- drivers/net/usb/usbnet.c | 11 +- include/fec.h | 3 + include/linux/ethtool.h | 114 ++++ include/linux/mii.h | 675 ++++++++++++++-------- include/linux/phy.h | 206 +++++++ include/miidev.h | 18 - include/net.h | 4 + include/usb/usbnet.h | 1 + net/eth.c | 6 +- 35 files changed, 1801 insertions(+), 812 deletions(-) rewrite drivers/net/miidev.c (76%) 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/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 +15 -26
@@ -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 +13 -25
@@ -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 ();
drivers/net/Kconfig +2 -0
@@ -25,6 +25,8 @@ config MIIDEV menu "Network drivers " depends on NET +source "drivers/net/phy/Kconfig" + config DRIVER_NET_CS8900 bool "cs8900 ethernet driver" depends on HAS_CS8900
drivers/net/Makefile +1 -1
@@ -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_MIIDEV) += miidev.o 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 +9 -10
@@ -30,6 +30,7 @@#include <init.h> #include <clock.h> #include <linux/mii.h> +#include <linux/phy.h> #include <io.h> #include <asm/dma-mapping.h>
@@ -347,9 +348,12 @@ static void tse_reset(struct eth_device *edev)static int tse_eth_open (struct eth_device *edev) {struct altera_tse_priv *priv = edev->priv; +int ret; -miidev_wait_aneg (priv->miidev); -miidev_print_status (priv->miidev); + ret =phy_device_connect (priv->miidev, priv->phy_addr,NULL ,0 , +PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;return 0 ; }
@@ -488,8 +492,6 @@ static int tse_init_dev(struct eth_device *edev)/* enable MAC */ writel (ALTERA_TSE_CMD_TX_ENA_MSK |ALTERA_TSE_CMD_RX_ENA_MSK , &mac_dev->command_config); -miidev_restart_aneg (priv->miidev); -return 0 ; }
@@ -545,16 +547,13 @@ static int tse_probe(struct device_d *dev) miidev->read = tse_phy_read; miidev->write = tse_phy_write; - miidev->flags =0 ; miidev->edev = edev; miidev->parent = dev;if (dev->platform_data !=NULL ) - miidev->address = *((int8_t *)(dev->platform_data)); -else { -printf ("No PHY address specified.\n" ); -return -ENODEV ; - } + priv->phy_addr = *((int8_t *)(dev->platform_data)); +else + priv->phy_addr =-1 ;mii_register (miidev);
drivers/net/altera_tse.h +1 -0
@@ -292,6 +292,7 @@ struct altera_tse_priv {void __iomem *sgdma_tx_regs;void __iomem *rx_desc;void __iomem *tx_desc; +int phy_addr;struct mii_device *miidev; };
drivers/net/at91_ether.c +18 -13
@@ -40,18 +40,18 @@#include <linux/mii.h> #include <errno.h> #include <asm/mmu.h> +#include <linux/phy.h> #include "at91_ether.h" -#define SPEED_100 1 -#define DUPLEX_FULL 1 -struct ether_device {struct eth_device netdev;struct mii_device miidev;struct rbf_t *rbfp;struct rbf_t *rbfdt;unsigned char *rbf_framebuf; +int phy_addr; +phy_interface_t interface; };#define to_ether (_nd) container_of(_nd, struct ether_device, netdev)
@@ -136,19 +136,19 @@ static int at91_ether_mii_write(struct mii_device *dev, int addr, int reg, int vreturn ret; } -static void update_linkspeed (struct mii_device *dev,int speed,int duplex) +static void update_linkspeed (struct eth_device *edev) {unsigned int mac_cfg;/* Update the MAC */ mac_cfg =at91_emac_read (AT91_EMAC_CFG ) & ~(AT91_EMAC_SPD |AT91_EMAC_FD ); -if (speed ==SPEED_100 ) { -if (duplex ==DUPLEX_FULL )/* 100 Full Duplex */ +if (edev->phydev->speed ==SPEED_100 ) { +if (edev->phydev->duplex) mac_cfg |=AT91_EMAC_SPD |AT91_EMAC_FD ;else /* 100 Half Duplex */ mac_cfg |=AT91_EMAC_SPD ; }else { -if (duplex ==DUPLEX_FULL )/* 10 Full Duplex */ +if (edev->phydev->duplex) mac_cfg |=AT91_EMAC_FD ;else {}/* 10 Half Duplex */ }
@@ -161,11 +161,12 @@ static int at91_ether_open(struct eth_device *edev)unsigned long ctl;struct ether_device *etdev =to_ether (edev);unsigned char *rbf_framebuf = etdev->rbf_framebuf; +int ret; -miidev_wait_aneg (&etdev->miidev); -miidev_print_status (&etdev->miidev); - -update_linkspeed (&etdev->miidev,SPEED_100 ,DUPLEX_FULL ); + ret =phy_device_connect (&etdev->miidev, etdev->phy_addr, + update_linkspeed,0 , etdev->interface); +if (ret) +return ret;/* Clear internal statistics */ ctl =at91_emac_read (AT91_EMAC_CTL );
@@ -327,7 +328,7 @@ static int at91_ether_probe(struct device_d *dev) ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ ); ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR ); - miidev->address = pdata->phy_addr; + ether_dev->phy_addr = pdata->phy_addr; miidev->read = at91_ether_mii_read; miidev->write = at91_ether_mii_write; miidev->edev = edev;
@@ -347,8 +348,12 @@ static int at91_ether_probe(struct device_d *dev) mac_cfg |=AT91_EMAC_CLK_DIV32 |AT91_EMAC_BIG ; -if (pdata->flags &AT91SAM_ETHER_RMII ) +if (pdata->flags &AT91SAM_ETHER_RMII ) { + ether_dev->interface =PHY_INTERFACE_MODE_RGMII ; mac_cfg |=AT91_EMAC_RMII ; + }else { + ether_dev->interface =PHY_INTERFACE_MODE_MII ; + }at91_emac_write (AT91_EMAC_CFG , mac_cfg);
drivers/net/designware.c +22 -17
@@ -32,6 +32,7 @@#include <miidev.h> #include <asm/mmu.h> #include <net/designware.h> +#include <linux/phy.h> #include "designware.h"
@@ -52,6 +53,7 @@ struct dw_eth_dev {struct eth_mac_regs *mac_regs_p;struct eth_dma_regs *dma_regs_p; +int phy_addr; };/* Speed specific definitions */
@@ -222,34 +224,37 @@ static int dwc_ether_init(struct eth_device *dev)return 0 ; } -static int dwc_ether_open (struct eth_device *dev) +static void dwc_update_linkspeed (struct eth_device *edev) { -struct dw_eth_dev *priv = dev->priv; -struct eth_mac_regs *mac_p = priv->mac_regs_p; -struct eth_dma_regs *dma_p = priv->dma_regs_p; +struct dw_eth_dev *priv = edev->priv;u32 conf; -int link, speed; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); - link =miidev_get_status (&priv->miidev); - -if (priv->fix_mac_speed) { - speed = link &MIIDEV_STATUS_IS_1000MBIT ?1000 : - (link &MIIDEV_STATUS_IS_100MBIT ?100 :10 ); - priv->fix_mac_speed (speed); - } +if (priv->fix_mac_speed) + priv->fix_mac_speed (edev->phydev->speed); conf =readl (&mac_p->conf); -if (link &MIIDEV_STATUS_IS_FULL_DUPLEX ) +if (edev->phydev->duplex) conf |=FULLDPLXMODE ;else conf &= ~FULLDPLXMODE ; -if (link &MIIDEV_STATUS_IS_1000MBIT ) +if (mdev->phydev->speed ==SPEED_1000 ) conf &= ~MII_PORTSELECT ;else conf |=MII_PORTSELECT ;writel (conf, &mac_p->conf); +} + +static int dwc_ether_open (struct eth_device *dev) +{ +struct dw_eth_dev *priv = dev->priv; +struct eth_mac_regs *mac_p = priv->mac_regs_p; +struct eth_dma_regs *dma_p = priv->dma_regs_p; +int ret; + + ret =phy_device_connect (&priv->miidev, priv->phy_addr, +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;descs_init (dev);
@@ -408,7 +413,7 @@ static int dwc_ether_probe(struct device_d *dev) edev->get_ethaddr = dwc_ether_get_ethaddr; edev->set_ethaddr = dwc_ether_set_ethaddr; - miidev->address = pdata->phy_addr; + priv->phy_addr = pdata->phy_addr; miidev->read = dwc_ether_mii_read; miidev->write = dwc_ether_mii_write; miidev->edev = edev;
drivers/net/dm9k.c +3 -8
@@ -32,6 +32,7 @@#include <xfuncs.h> #include <dm9000.h> #include <errno.h> +#include <linux/phy.h> #define DM9K_ID 0x90000A46#define CHIPR_DM9000A 0x19
@@ -472,9 +473,8 @@ static int dm9k_eth_open(struct eth_device *edev) {struct dm9k *priv = (struct dm9k *)edev->priv; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); -return 0 ; +return phy_device_connect (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void dm9k_write_length (struct dm9k *priv,unsigned length)
@@ -696,9 +696,6 @@ static int dm9k_set_ethaddr(struct eth_device *edev, unsigned char *adr)static int dm9k_init_dev (struct eth_device *edev) { -struct dm9k *priv = (struct dm9k *)edev->priv; - -miidev_restart_aneg (&priv->miidev);return 0 ; }
@@ -742,8 +739,6 @@ static int dm9k_probe(struct device_d *dev) priv->miidev.read = dm9k_phy_read; priv->miidev.write = dm9k_phy_write; - priv->miidev.address =0 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/ep93xx.c +7 -2
@@ -38,6 +38,7 @@#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
@@ -199,9 +200,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 (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret; +ep93xx_eth_reset (edev);/* Reset the descriptor queues' current and end address values */
@@ -500,8 +507,6 @@ static int ep93xx_eth_probe(struct device_d *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->tx_dq.base = calloc(NUMTXDESC,
drivers/net/fec_imx.c +41 -23
99 lines not on this page · raw message
drivers/net/fec_imx.h +4 -0
@@ -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 */ +int phy_addr; +phy_interface_t interface; +u32 phy_flags;struct mii_device miidev; +void (*phy_init)(struct phy_device *dev); };/**
drivers/net/fec_mpc5200.c +19 -7
@@ -17,6 +17,7 @@#include <mach/fec.h> #include <mach/clocks.h> #include <miidev.h> +#include <linux/phy.h> #include "fec_mpc5200.h" #define CONFIG_PHY_ADDR 1/* FIXME */
@@ -381,9 +382,6 @@ static int mpc5xxx_fec_init(struct eth_device *dev)debug ("mpc5xxx_fec_init... Done \n" ); -if (fec->xcv_type !=SEVENWIRE ) -miidev_restart_aneg (&fec->miidev); -return 0 ; }
@@ -413,8 +411,8 @@ static int mpc5xxx_fec_open(struct eth_device *edev)SDMA_TASK_ENABLE (FEC_RECV_TASK_NO );if (fec->xcv_type !=SEVENWIRE ) { -miidev_wait_aneg (&fec->miidev); -miidev_print_status (&fec->miidev); +return phy_device_connect (&fec->miidev,CONFIG_PHY_ADDR , +NULL , fec->phy_flags, fec->interface); }return 0 ;
@@ -685,8 +683,22 @@ int mpc5xxx_fec_probe(struct device_d *dev)if (fec->xcv_type !=SEVENWIRE ) { fec->miidev.read = fec5xxx_miidev_read; fec->miidev.write = fec5xxx_miidev_write; - fec->miidev.address =CONFIG_PHY_ADDR ; - fec->miidev.flags = pdata->xcv_type ==MII10 ?MIIDEV_FORCE_10 :0 ; +switch (pdata->xcv_type) { +case RMII : + fec->interface =PHY_INTERFACE_MODE_RMII ; +break ; +case RGMII : + fec->interface =PHY_INTERFACE_MODE_RGMII ; +break ; +case MII10 : + fec->phy_flags =MIIDEV_FORCE_10 ; +case MII100 : + fec->interface =PHY_INTERFACE_MODE_MII ; +break ; +case SEVENWIRE : + fec->interface =PHY_INTERFACE_MODE_NA ; +break ; + } fec->miidev.edev = edev; fec->miidev.parent = dev;
drivers/net/gianfar.c +14 -20
@@ -21,6 +21,7 @@#include <command.h> #include <errno.h> #include <asm/io.h> +#include <linux/phy.h> #include "gianfar.h" /* 2 seems to be the minimum number of TX descriptors to make it work. */
@@ -80,22 +81,16 @@ static void gfar_init_registers(void __iomem *regs)static void gfar_adjust_link (struct eth_device *edev) {struct gfar_private *priv = edev->priv; -struct device_d *mdev = priv->miidev.parent;void __iomem *regs = priv->regs;u32 ecntrl, maccfg2;uint32_t status; - status =miidev_get_status (&priv->miidev); + priv->link = edev->phydev->link; + priv->duplexity =edev->phydev->duplex; - priv->link = status &MIIDEV_STATUS_IS_UP ; -if (status &MIIDEV_STATUS_IS_FULL_DUPLEX ) - priv->duplexity =1 ; -else - priv->duplexity =0 ; - -if (status &MIIDEV_STATUS_IS_1000MBIT ) +if (edev->phydev->speed ==SPEED_1000 ) priv->speed =1000 ; -else if (status &MIIDEV_STATUS_IS_100MBIT ) +if (edev->phydev->speed ==SPEED_100 ) priv->speed =100 ;else priv->speed =10 ;
@@ -128,18 +123,18 @@ static void gfar_adjust_link(struct eth_device *edev) ecntrl |=GFAR_ECNTRL_R100 ;break ;default : -dev_info (mdev,"Speed is unknown\n" ); +dev_info (&edev->dev,"Speed is unknown\n" );break ; }out_be32 (regs +GFAR_ECNTRL_OFFSET , ecntrl);out_be32 (regs +GFAR_MACCFG2_OFFSET , maccfg2); -dev_info (mdev,"Speed: %d, %s duplex\n" , priv->speed, +dev_info (&edev->dev,"Speed: %d, %s duplex\n" , priv->speed, (priv->duplexity) ?"full" :"half" ); }else { -dev_info (mdev,"No link.\n" ); +dev_info (&edev->dev,"No link.\n" ); } }
@@ -184,8 +179,6 @@ static int gfar_init(struct eth_device *edev)gfar_init_registers (regs); -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -194,6 +187,12 @@ static int gfar_open(struct eth_device *edev)int ix;struct gfar_private *priv = edev->priv;void __iomem *regs = priv->regs; +int ret; + + ret =phy_device_connect (&priv->miidev, priv->phyaddr, + gfar_adjust_link,0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;/* Point to the buffer descriptors */ out_be32 (regs +GFAR_TBASE0_OFFSET , (unsigned int )priv->txbd);
@@ -215,9 +214,6 @@ static int gfar_open(struct eth_device *edev) } priv->txbd[TX_BUF_CNT -1 ].status |=TXBD_WRAP ; -miidev_wait_aneg (&priv->miidev); -gfar_adjust_link (edev); -/* Enable Transmit and Receive */ setbits_be32 (regs +GFAR_MACCFG1_OFFSET ,GFAR_MACCFG1_RX_EN |GFAR_MACCFG1_TX_EN );
@@ -522,8 +518,6 @@ static int gfar_probe(struct device_d *dev) priv->miidev.read = gfar_miiphy_read; priv->miidev.write = gfar_miiphy_write; - priv->miidev.address = priv->phyaddr; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/ks8851_mll.c +6 -7
@@ -33,6 +33,7 @@#include <errno.h> #include <clock.h> #include <io.h> +#include <linux/phy.h> #define MAX_RECV_FRAMES 32#define MAX_BUF_SIZE 2048
@@ -783,11 +784,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 (&priv->miidev,1 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;dev_dbg (dev,"eth_open\n" );
@@ -796,9 +800,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 ; }
@@ -844,8 +845,6 @@ static int ks8851_probe(struct device_d *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;
drivers/net/macb.c +36 -20
99 lines not on this page · raw message
drivers/net/miidev.c +68 -316
384 lines not on this page · raw message
drivers/net/netx_eth.c +5 -4
@@ -9,6 +9,7 @@#include <xfuncs.h> #include <init.h> #include <driver.h> +#include <linux/phy.h> #define ETH_MAC_LOCAL_CONFIG 0x1560#define ETH_MAC_4321 0x1564
@@ -189,13 +190,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 (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void netx_eth_halt (struct eth_device *edev)
@@ -261,8 +264,6 @@ static int netx_eth_probe(struct device_d *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;netx_eth_init_phy ();
drivers/net/phy/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# PHY Layer Configuration +# + +menu "phylib " + +if MIIDEV + +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
@@ -0,0 +1,2 @@ +obj-y += phy.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/phy.c new file +688 -0
688 lines not on this page · raw message
drivers/net/smc91111.c +8 -14
@@ -74,6 +74,7 @@#include <errno.h> #include <clock.h> #include <io.h> +#include <linux/phy.h> /*--------------------------------------------------------------- .
@@ -892,12 +893,15 @@ static void smc91c111_enable(struct eth_device *edev)static int smc91c111_eth_open (struct eth_device *edev) {struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv; -smc91c111_enable (edev); -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); +/* Configure the Receive/Phy Control register */ +SMC_SELECT_BANK (priv,0 ); +SMC_outw (priv,RPC_DEFAULT ,RPC_REG ); -return 0 ; +smc91c111_enable (edev); + +return phy_device_connect (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); } static int smc91c111_eth_send(struct eth_device *edev, void *packet,
@@ -1279,14 +1283,6 @@ static void print_packet( unsigned char * buf, int length )static int smc91c111_init_dev (struct eth_device *edev) { -struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv; - -/* Configure the Receive/Phy Control register */ -SMC_SELECT_BANK (priv,0 ); -SMC_outw (priv,RPC_DEFAULT ,RPC_REG ); - -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -1314,8 +1310,6 @@ static int smc91c111_probe(struct device_d *dev) priv->miidev.read = smc91c111_phy_read; priv->miidev.write = smc91c111_phy_write; - priv->miidev.address =0 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev; priv->base =dev_request_mem_region (dev,0 );
drivers/net/smc911x.c +6 -8
@@ -38,6 +38,7 @@#include <clock.h> #include <io.h> #include <smc911x.h> +#include <linux/phy.h> #include "smc911x.h"
@@ -308,9 +309,12 @@ static void smc911x_enable(struct eth_device *edev)static int smc911x_eth_open (struct eth_device *edev) {struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; +int ret; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); + ret =phy_device_connect (&priv->miidev,1 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;/* Turn on Tx + Rx */ smc911x_enable (edev);
@@ -405,13 +409,9 @@ static int smc911x_eth_rx(struct eth_device *edev)static int smc911x_init_dev (struct eth_device *edev) { -struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; -smc911x_set_mac_csr (edev,MAC_CR ,MAC_CR_TXEN |MAC_CR_RXEN |MAC_CR_HBDIS ); -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -538,8 +538,6 @@ static int smc911x_probe(struct device_d *dev) priv->miidev.read = smc911x_phy_read; priv->miidev.write = smc911x_phy_write; - priv->miidev.address =1 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/usb/asix.c +1 -2
@@ -471,8 +471,7 @@ static int asix_init_mii(struct usbnet *dev) { dev->miidev.read = asix_mdio_read; dev->miidev.write = asix_mdio_write; - dev->miidev.address =asix_get_phy_addr (dev); - dev->miidev.flags =0 ; + dev->phy_addr =asix_get_phy_addr (dev); dev->miidev.edev = &dev->edev; dev->miidev.parent = &dev->udev->dev;
drivers/net/usb/smsc95xx.c +1 -2
@@ -441,8 +441,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)/* Initialize MII structure */ dev->miidev.read = smsc95xx_mdio_read; dev->miidev.write = smsc95xx_mdio_write; - dev->miidev.address =1 ;/* FIXME: asix_get_phy_addr(dev); */ - dev->miidev.flags =0 ; + dev->phy_addr =1 ;/* FIXME: asix_get_phy_addr(dev); */ dev->miidev.edev = &dev->edev; dev->miidev.parent = &dev->udev->dev;// dev->miidev.name = dev->edev.name;
drivers/net/usb/usbnet.c +3 -8
@@ -4,6 +4,7 @@#include <asm/byteorder.h> #include <errno.h> #include <malloc.h> +#include <linux/phy.h> static inline int usb_endpoint_dir_in (const struct usb_endpoint_descriptor *epd) {
@@ -160,8 +161,6 @@ static int usbnet_init(struct eth_device *edev)return ret; } -miidev_restart_aneg (&dev->miidev); -return 0 ; }
@@ -171,12 +170,8 @@ static int usbnet_open(struct eth_device *edev)dev_dbg (&edev->dev,"%s\n" ,__func__); -if (miidev_wait_aneg (&dev->miidev)) -return -1 ; - -miidev_print_status (&dev->miidev); - -return 0 ; +return phy_device_connect (&dev->miidev, dev->phy_addr,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void usbnet_halt (struct eth_device *edev)
include/fec.h +3 -0
@@ -25,6 +25,8 @@#ifndef __INCLUDE_NETWORK_FEC_H#define __INCLUDE_NETWORK_FEC_H +#include <linux/phy.h> +/* * Supported phy types on this platform */
@@ -43,6 +45,7 @@ typedef enum {struct fec_platform_data {xceiver_type xcv_type;int phy_addr; +void (*phy_init)(struct phy_device *dev); };#endif /* __INCLUDE_NETWORK_FEC_H */
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 +206 -0
76 lines not on this page · 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.
PATCH 1/1 net: introduce phylib
In reply to Jean-Christophe PLAGNIOL-VILLARDAdapt phylib from linux
switch all the driver to it
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 | 41 +- arch/arm/boards/freescale-mx6-sabrelite/board.c | 38 +- drivers/net/Kconfig | 2 + drivers/net/Makefile | 2 +- drivers/net/altera_tse.c | 19 +- drivers/net/altera_tse.h | 1 + drivers/net/at91_ether.c | 31 +- drivers/net/designware.c | 39 +- drivers/net/dm9k.c | 11 +- drivers/net/ep93xx.c | 9 +- drivers/net/fec_imx.c | 64 ++- drivers/net/fec_imx.h | 4 + drivers/net/fec_mpc5200.c | 26 +- drivers/net/gianfar.c | 34 +- drivers/net/ks8851_mll.c | 13 +- drivers/net/macb.c | 56 +- drivers/net/miidev.c | 384 +++---------- drivers/net/netx_eth.c | 9 +- drivers/net/phy/Kconfig | 17 + drivers/net/phy/Makefile | 2 + include/fec.h => drivers/net/phy/generic.c | 43 +- drivers/net/phy/phy.c | 688 +++++++++++++++++++++++ drivers/net/smc91111.c | 22 +- drivers/net/smc911x.c | 14 +- drivers/net/usb/asix.c | 3 +- drivers/net/usb/smsc95xx.c | 3 +- drivers/net/usb/usbnet.c | 11 +- include/fec.h | 3 + include/linux/ethtool.h | 114 ++++ include/linux/mii.h | 675 ++++++++++++++-------- include/linux/phy.h | 206 +++++++ include/miidev.h | 18 - include/net.h | 4 + include/usb/usbnet.h | 1 + net/eth.c | 6 +- 35 files changed, 1801 insertions(+), 812 deletions(-) rewrite drivers/net/miidev.c (76%) 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/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 +15 -26
@@ -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 +13 -25
@@ -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 ();
drivers/net/Kconfig +2 -0
@@ -25,6 +25,8 @@ config MIIDEV menu "Network drivers " depends on NET +source "drivers/net/phy/Kconfig" + config DRIVER_NET_CS8900 bool "cs8900 ethernet driver" depends on HAS_CS8900
drivers/net/Makefile +1 -1
@@ -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_MIIDEV) += miidev.o 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 +9 -10
@@ -30,6 +30,7 @@#include <init.h> #include <clock.h> #include <linux/mii.h> +#include <linux/phy.h> #include <io.h> #include <asm/dma-mapping.h>
@@ -347,9 +348,12 @@ static void tse_reset(struct eth_device *edev)static int tse_eth_open (struct eth_device *edev) {struct altera_tse_priv *priv = edev->priv; +int ret; -miidev_wait_aneg (priv->miidev); -miidev_print_status (priv->miidev); + ret =phy_device_connect (priv->miidev, priv->phy_addr,NULL ,0 , +PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;return 0 ; }
@@ -488,8 +492,6 @@ static int tse_init_dev(struct eth_device *edev)/* enable MAC */ writel (ALTERA_TSE_CMD_TX_ENA_MSK |ALTERA_TSE_CMD_RX_ENA_MSK , &mac_dev->command_config); -miidev_restart_aneg (priv->miidev); -return 0 ; }
@@ -545,16 +547,13 @@ static int tse_probe(struct device_d *dev) miidev->read = tse_phy_read; miidev->write = tse_phy_write; - miidev->flags =0 ; miidev->edev = edev; miidev->parent = dev;if (dev->platform_data !=NULL ) - miidev->address = *((int8_t *)(dev->platform_data)); -else { -printf ("No PHY address specified.\n" ); -return -ENODEV ; - } + priv->phy_addr = *((int8_t *)(dev->platform_data)); +else + priv->phy_addr =-1 ;mii_register (miidev);
drivers/net/altera_tse.h +1 -0
@@ -292,6 +292,7 @@ struct altera_tse_priv {void __iomem *sgdma_tx_regs;void __iomem *rx_desc;void __iomem *tx_desc; +int phy_addr;struct mii_device *miidev; };
drivers/net/at91_ether.c +18 -13
@@ -40,18 +40,18 @@#include <linux/mii.h> #include <errno.h> #include <asm/mmu.h> +#include <linux/phy.h> #include "at91_ether.h" -#define SPEED_100 1 -#define DUPLEX_FULL 1 -struct ether_device {struct eth_device netdev;struct mii_device miidev;struct rbf_t *rbfp;struct rbf_t *rbfdt;unsigned char *rbf_framebuf; +int phy_addr; +phy_interface_t interface; };#define to_ether (_nd) container_of(_nd, struct ether_device, netdev)
@@ -136,19 +136,19 @@ static int at91_ether_mii_write(struct mii_device *dev, int addr, int reg, int vreturn ret; } -static void update_linkspeed (struct mii_device *dev,int speed,int duplex) +static void update_linkspeed (struct eth_device *edev) {unsigned int mac_cfg;/* Update the MAC */ mac_cfg =at91_emac_read (AT91_EMAC_CFG ) & ~(AT91_EMAC_SPD |AT91_EMAC_FD ); -if (speed ==SPEED_100 ) { -if (duplex ==DUPLEX_FULL )/* 100 Full Duplex */ +if (edev->phydev->speed ==SPEED_100 ) { +if (edev->phydev->duplex) mac_cfg |=AT91_EMAC_SPD |AT91_EMAC_FD ;else /* 100 Half Duplex */ mac_cfg |=AT91_EMAC_SPD ; }else { -if (duplex ==DUPLEX_FULL )/* 10 Full Duplex */ +if (edev->phydev->duplex) mac_cfg |=AT91_EMAC_FD ;else {}/* 10 Half Duplex */ }
@@ -161,11 +161,12 @@ static int at91_ether_open(struct eth_device *edev)unsigned long ctl;struct ether_device *etdev =to_ether (edev);unsigned char *rbf_framebuf = etdev->rbf_framebuf; +int ret; -miidev_wait_aneg (&etdev->miidev); -miidev_print_status (&etdev->miidev); - -update_linkspeed (&etdev->miidev,SPEED_100 ,DUPLEX_FULL ); + ret =phy_device_connect (&etdev->miidev, etdev->phy_addr, + update_linkspeed,0 , etdev->interface); +if (ret) +return ret;/* Clear internal statistics */ ctl =at91_emac_read (AT91_EMAC_CTL );
@@ -327,7 +328,7 @@ static int at91_ether_probe(struct device_d *dev) ether_dev->rbf_framebuf =dma_alloc_coherent (MAX_RX_DESCR *MAX_RBUFF_SZ ); ether_dev->rbfdt =dma_alloc_coherent (sizeof (struct rbf_t ) *MAX_RX_DESCR ); - miidev->address = pdata->phy_addr; + ether_dev->phy_addr = pdata->phy_addr; miidev->read = at91_ether_mii_read; miidev->write = at91_ether_mii_write; miidev->edev = edev;
@@ -347,8 +348,12 @@ static int at91_ether_probe(struct device_d *dev) mac_cfg |=AT91_EMAC_CLK_DIV32 |AT91_EMAC_BIG ; -if (pdata->flags &AT91SAM_ETHER_RMII ) +if (pdata->flags &AT91SAM_ETHER_RMII ) { + ether_dev->interface =PHY_INTERFACE_MODE_RGMII ; mac_cfg |=AT91_EMAC_RMII ; + }else { + ether_dev->interface =PHY_INTERFACE_MODE_MII ; + }at91_emac_write (AT91_EMAC_CFG , mac_cfg);
drivers/net/designware.c +22 -17
@@ -32,6 +32,7 @@#include <miidev.h> #include <asm/mmu.h> #include <net/designware.h> +#include <linux/phy.h> #include "designware.h"
@@ -52,6 +53,7 @@ struct dw_eth_dev {struct eth_mac_regs *mac_regs_p;struct eth_dma_regs *dma_regs_p; +int phy_addr; };/* Speed specific definitions */
@@ -222,34 +224,37 @@ static int dwc_ether_init(struct eth_device *dev)return 0 ; } -static int dwc_ether_open (struct eth_device *dev) +static void dwc_update_linkspeed (struct eth_device *edev) { -struct dw_eth_dev *priv = dev->priv; -struct eth_mac_regs *mac_p = priv->mac_regs_p; -struct eth_dma_regs *dma_p = priv->dma_regs_p; +struct dw_eth_dev *priv = edev->priv;u32 conf; -int link, speed; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); - link =miidev_get_status (&priv->miidev); - -if (priv->fix_mac_speed) { - speed = link &MIIDEV_STATUS_IS_1000MBIT ?1000 : - (link &MIIDEV_STATUS_IS_100MBIT ?100 :10 ); - priv->fix_mac_speed (speed); - } +if (priv->fix_mac_speed) + priv->fix_mac_speed (edev->phydev->speed); conf =readl (&mac_p->conf); -if (link &MIIDEV_STATUS_IS_FULL_DUPLEX ) +if (edev->phydev->duplex) conf |=FULLDPLXMODE ;else conf &= ~FULLDPLXMODE ; -if (link &MIIDEV_STATUS_IS_1000MBIT ) +if (mdev->phydev->speed ==SPEED_1000 ) conf &= ~MII_PORTSELECT ;else conf |=MII_PORTSELECT ;writel (conf, &mac_p->conf); +} + +static int dwc_ether_open (struct eth_device *dev) +{ +struct dw_eth_dev *priv = dev->priv; +struct eth_mac_regs *mac_p = priv->mac_regs_p; +struct eth_dma_regs *dma_p = priv->dma_regs_p; +int ret; + + ret =phy_device_connect (&priv->miidev, priv->phy_addr, +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;descs_init (dev);
@@ -408,7 +413,7 @@ static int dwc_ether_probe(struct device_d *dev) edev->get_ethaddr = dwc_ether_get_ethaddr; edev->set_ethaddr = dwc_ether_set_ethaddr; - miidev->address = pdata->phy_addr; + priv->phy_addr = pdata->phy_addr; miidev->read = dwc_ether_mii_read; miidev->write = dwc_ether_mii_write; miidev->edev = edev;
drivers/net/dm9k.c +3 -8
@@ -32,6 +32,7 @@#include <xfuncs.h> #include <dm9000.h> #include <errno.h> +#include <linux/phy.h> #define DM9K_ID 0x90000A46#define CHIPR_DM9000A 0x19
@@ -472,9 +473,8 @@ static int dm9k_eth_open(struct eth_device *edev) {struct dm9k *priv = (struct dm9k *)edev->priv; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); -return 0 ; +return phy_device_connect (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void dm9k_write_length (struct dm9k *priv,unsigned length)
@@ -696,9 +696,6 @@ static int dm9k_set_ethaddr(struct eth_device *edev, unsigned char *adr)static int dm9k_init_dev (struct eth_device *edev) { -struct dm9k *priv = (struct dm9k *)edev->priv; - -miidev_restart_aneg (&priv->miidev);return 0 ; }
@@ -742,8 +739,6 @@ static int dm9k_probe(struct device_d *dev) priv->miidev.read = dm9k_phy_read; priv->miidev.write = dm9k_phy_write; - priv->miidev.address =0 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/ep93xx.c +7 -2
@@ -38,6 +38,7 @@#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
@@ -199,9 +200,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 (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret; +ep93xx_eth_reset (edev);/* Reset the descriptor queues' current and end address values */
@@ -500,8 +507,6 @@ static int ep93xx_eth_probe(struct device_d *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->tx_dq.base = calloc(NUMTXDESC,
drivers/net/fec_imx.c +41 -23
99 lines not on this page · raw message
drivers/net/fec_imx.h +4 -0
@@ -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 */ +int phy_addr; +phy_interface_t interface; +u32 phy_flags;struct mii_device miidev; +void (*phy_init)(struct phy_device *dev); };/**
drivers/net/fec_mpc5200.c +19 -7
@@ -17,6 +17,7 @@#include <mach/fec.h> #include <mach/clocks.h> #include <miidev.h> +#include <linux/phy.h> #include "fec_mpc5200.h" #define CONFIG_PHY_ADDR 1/* FIXME */
@@ -381,9 +382,6 @@ static int mpc5xxx_fec_init(struct eth_device *dev)debug ("mpc5xxx_fec_init... Done \n" ); -if (fec->xcv_type !=SEVENWIRE ) -miidev_restart_aneg (&fec->miidev); -return 0 ; }
@@ -413,8 +411,8 @@ static int mpc5xxx_fec_open(struct eth_device *edev)SDMA_TASK_ENABLE (FEC_RECV_TASK_NO );if (fec->xcv_type !=SEVENWIRE ) { -miidev_wait_aneg (&fec->miidev); -miidev_print_status (&fec->miidev); +return phy_device_connect (&fec->miidev,CONFIG_PHY_ADDR , +NULL , fec->phy_flags, fec->interface); }return 0 ;
@@ -685,8 +683,22 @@ int mpc5xxx_fec_probe(struct device_d *dev)if (fec->xcv_type !=SEVENWIRE ) { fec->miidev.read = fec5xxx_miidev_read; fec->miidev.write = fec5xxx_miidev_write; - fec->miidev.address =CONFIG_PHY_ADDR ; - fec->miidev.flags = pdata->xcv_type ==MII10 ?MIIDEV_FORCE_10 :0 ; +switch (pdata->xcv_type) { +case RMII : + fec->interface =PHY_INTERFACE_MODE_RMII ; +break ; +case RGMII : + fec->interface =PHY_INTERFACE_MODE_RGMII ; +break ; +case MII10 : + fec->phy_flags =MIIDEV_FORCE_10 ; +case MII100 : + fec->interface =PHY_INTERFACE_MODE_MII ; +break ; +case SEVENWIRE : + fec->interface =PHY_INTERFACE_MODE_NA ; +break ; + } fec->miidev.edev = edev; fec->miidev.parent = dev;
drivers/net/gianfar.c +14 -20
@@ -21,6 +21,7 @@#include <command.h> #include <errno.h> #include <asm/io.h> +#include <linux/phy.h> #include "gianfar.h" /* 2 seems to be the minimum number of TX descriptors to make it work. */
@@ -80,22 +81,16 @@ static void gfar_init_registers(void __iomem *regs)static void gfar_adjust_link (struct eth_device *edev) {struct gfar_private *priv = edev->priv; -struct device_d *mdev = priv->miidev.parent;void __iomem *regs = priv->regs;u32 ecntrl, maccfg2;uint32_t status; - status =miidev_get_status (&priv->miidev); + priv->link = edev->phydev->link; + priv->duplexity =edev->phydev->duplex; - priv->link = status &MIIDEV_STATUS_IS_UP ; -if (status &MIIDEV_STATUS_IS_FULL_DUPLEX ) - priv->duplexity =1 ; -else - priv->duplexity =0 ; - -if (status &MIIDEV_STATUS_IS_1000MBIT ) +if (edev->phydev->speed ==SPEED_1000 ) priv->speed =1000 ; -else if (status &MIIDEV_STATUS_IS_100MBIT ) +if (edev->phydev->speed ==SPEED_100 ) priv->speed =100 ;else priv->speed =10 ;
@@ -128,18 +123,18 @@ static void gfar_adjust_link(struct eth_device *edev) ecntrl |=GFAR_ECNTRL_R100 ;break ;default : -dev_info (mdev,"Speed is unknown\n" ); +dev_info (&edev->dev,"Speed is unknown\n" );break ; }out_be32 (regs +GFAR_ECNTRL_OFFSET , ecntrl);out_be32 (regs +GFAR_MACCFG2_OFFSET , maccfg2); -dev_info (mdev,"Speed: %d, %s duplex\n" , priv->speed, +dev_info (&edev->dev,"Speed: %d, %s duplex\n" , priv->speed, (priv->duplexity) ?"full" :"half" ); }else { -dev_info (mdev,"No link.\n" ); +dev_info (&edev->dev,"No link.\n" ); } }
@@ -184,8 +179,6 @@ static int gfar_init(struct eth_device *edev)gfar_init_registers (regs); -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -194,6 +187,12 @@ static int gfar_open(struct eth_device *edev)int ix;struct gfar_private *priv = edev->priv;void __iomem *regs = priv->regs; +int ret; + + ret =phy_device_connect (&priv->miidev, priv->phyaddr, + gfar_adjust_link,0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;/* Point to the buffer descriptors */ out_be32 (regs +GFAR_TBASE0_OFFSET , (unsigned int )priv->txbd);
@@ -215,9 +214,6 @@ static int gfar_open(struct eth_device *edev) } priv->txbd[TX_BUF_CNT -1 ].status |=TXBD_WRAP ; -miidev_wait_aneg (&priv->miidev); -gfar_adjust_link (edev); -/* Enable Transmit and Receive */ setbits_be32 (regs +GFAR_MACCFG1_OFFSET ,GFAR_MACCFG1_RX_EN |GFAR_MACCFG1_TX_EN );
@@ -522,8 +518,6 @@ static int gfar_probe(struct device_d *dev) priv->miidev.read = gfar_miiphy_read; priv->miidev.write = gfar_miiphy_write; - priv->miidev.address = priv->phyaddr; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/ks8851_mll.c +6 -7
@@ -33,6 +33,7 @@#include <errno.h> #include <clock.h> #include <io.h> +#include <linux/phy.h> #define MAX_RECV_FRAMES 32#define MAX_BUF_SIZE 2048
@@ -783,11 +784,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 (&priv->miidev,1 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;dev_dbg (dev,"eth_open\n" );
@@ -796,9 +800,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 ; }
@@ -844,8 +845,6 @@ static int ks8851_probe(struct device_d *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;
drivers/net/macb.c +36 -20
99 lines not on this page · raw message
drivers/net/miidev.c +68 -316
384 lines not on this page · raw message
drivers/net/netx_eth.c +5 -4
@@ -9,6 +9,7 @@#include <xfuncs.h> #include <init.h> #include <driver.h> +#include <linux/phy.h> #define ETH_MAC_LOCAL_CONFIG 0x1560#define ETH_MAC_4321 0x1564
@@ -189,13 +190,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 (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void netx_eth_halt (struct eth_device *edev)
@@ -261,8 +264,6 @@ static int netx_eth_probe(struct device_d *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;netx_eth_init_phy ();
drivers/net/phy/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# PHY Layer Configuration +# + +menu "phylib " + +if MIIDEV + +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
@@ -0,0 +1,2 @@ +obj-y += phy.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/phy.c new file +688 -0
688 lines not on this page · raw message
drivers/net/smc91111.c +8 -14
@@ -74,6 +74,7 @@#include <errno.h> #include <clock.h> #include <io.h> +#include <linux/phy.h> /*--------------------------------------------------------------- .
@@ -892,12 +893,15 @@ static void smc91c111_enable(struct eth_device *edev)static int smc91c111_eth_open (struct eth_device *edev) {struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv; -smc91c111_enable (edev); -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); +/* Configure the Receive/Phy Control register */ +SMC_SELECT_BANK (priv,0 ); +SMC_outw (priv,RPC_DEFAULT ,RPC_REG ); -return 0 ; +smc91c111_enable (edev); + +return phy_device_connect (&priv->miidev,0 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); } static int smc91c111_eth_send(struct eth_device *edev, void *packet,
@@ -1279,14 +1283,6 @@ static void print_packet( unsigned char * buf, int length )static int smc91c111_init_dev (struct eth_device *edev) { -struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv; - -/* Configure the Receive/Phy Control register */ -SMC_SELECT_BANK (priv,0 ); -SMC_outw (priv,RPC_DEFAULT ,RPC_REG ); - -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -1314,8 +1310,6 @@ static int smc91c111_probe(struct device_d *dev) priv->miidev.read = smc91c111_phy_read; priv->miidev.write = smc91c111_phy_write; - priv->miidev.address =0 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev; priv->base =dev_request_mem_region (dev,0 );
drivers/net/smc911x.c +6 -8
@@ -38,6 +38,7 @@#include <clock.h> #include <io.h> #include <smc911x.h> +#include <linux/phy.h> #include "smc911x.h"
@@ -308,9 +309,12 @@ static void smc911x_enable(struct eth_device *edev)static int smc911x_eth_open (struct eth_device *edev) {struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; +int ret; -miidev_wait_aneg (&priv->miidev); -miidev_print_status (&priv->miidev); + ret =phy_device_connect (&priv->miidev,1 ,NULL , +0 ,PHY_INTERFACE_MODE_NA ); +if (ret) +return ret;/* Turn on Tx + Rx */ smc911x_enable (edev);
@@ -405,13 +409,9 @@ static int smc911x_eth_rx(struct eth_device *edev)static int smc911x_init_dev (struct eth_device *edev) { -struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv; -smc911x_set_mac_csr (edev,MAC_CR ,MAC_CR_TXEN |MAC_CR_RXEN |MAC_CR_HBDIS ); -miidev_restart_aneg (&priv->miidev); -return 0 ; }
@@ -538,8 +538,6 @@ static int smc911x_probe(struct device_d *dev) priv->miidev.read = smc911x_phy_read; priv->miidev.write = smc911x_phy_write; - priv->miidev.address =1 ; - priv->miidev.flags =0 ; priv->miidev.edev = edev; priv->miidev.parent = dev;
drivers/net/usb/asix.c +1 -2
@@ -471,8 +471,7 @@ static int asix_init_mii(struct usbnet *dev) { dev->miidev.read = asix_mdio_read; dev->miidev.write = asix_mdio_write; - dev->miidev.address =asix_get_phy_addr (dev); - dev->miidev.flags =0 ; + dev->phy_addr =asix_get_phy_addr (dev); dev->miidev.edev = &dev->edev; dev->miidev.parent = &dev->udev->dev;
drivers/net/usb/smsc95xx.c +1 -2
@@ -441,8 +441,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)/* Initialize MII structure */ dev->miidev.read = smsc95xx_mdio_read; dev->miidev.write = smsc95xx_mdio_write; - dev->miidev.address =1 ;/* FIXME: asix_get_phy_addr(dev); */ - dev->miidev.flags =0 ; + dev->phy_addr =1 ;/* FIXME: asix_get_phy_addr(dev); */ dev->miidev.edev = &dev->edev; dev->miidev.parent = &dev->udev->dev;// dev->miidev.name = dev->edev.name;
drivers/net/usb/usbnet.c +3 -8
@@ -4,6 +4,7 @@#include <asm/byteorder.h> #include <errno.h> #include <malloc.h> +#include <linux/phy.h> static inline int usb_endpoint_dir_in (const struct usb_endpoint_descriptor *epd) {
@@ -160,8 +161,6 @@ static int usbnet_init(struct eth_device *edev)return ret; } -miidev_restart_aneg (&dev->miidev); -return 0 ; }
@@ -171,12 +170,8 @@ static int usbnet_open(struct eth_device *edev)dev_dbg (&edev->dev,"%s\n" ,__func__); -if (miidev_wait_aneg (&dev->miidev)) -return -1 ; - -miidev_print_status (&dev->miidev); - -return 0 ; +return phy_device_connect (&dev->miidev, dev->phy_addr,NULL , +0 ,PHY_INTERFACE_MODE_NA ); }static void usbnet_halt (struct eth_device *edev)
include/fec.h +3 -0
@@ -25,6 +25,8 @@#ifndef __INCLUDE_NETWORK_FEC_H#define __INCLUDE_NETWORK_FEC_H +#include <linux/phy.h> +/* * Supported phy types on this platform */
@@ -43,6 +45,7 @@ typedef enum {struct fec_platform_data {xceiver_type xcv_type;int phy_addr; +void (*phy_init)(struct phy_device *dev); };#endif /* __INCLUDE_NETWORK_FEC_H */
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 +206 -0
76 lines not on this page · 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.
Sascha Hauer
maintainerQuoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Adapt phylib from linux
switch all the driver to it
Quoted 8 lines
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 openSame behaviour as in linux and will allow to share code and simplify porting.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
config: ppc pcm030_defconfigdrivers/net/fec_mpc5200.c: In function 'mpc5xxx_fec_open':drivers/net/fec_mpc5200.c:415:15: error: 'mpc5xxx_fec_priv' has no member named 'phy_flags' drivers/net/fec_mpc5200.c:415:31: error: 'mpc5xxx_fec_priv' has no member named 'interface' drivers/net/fec_mpc5200.c: In function 'mpc5xxx_fec_probe':drivers/net/fec_mpc5200.c:687:8: error: 'RMII' undeclared (first use in this function) drivers/net/fec_mpc5200.c:687:8: note: each undeclared identifier is reported only once for each function it appears in drivers/net/fec_mpc5200.c:688:7: error: 'mpc5xxx_fec_priv' has no member named 'interface' drivers/net/fec_mpc5200.c:690:8: error: 'RGMII' undeclared (first use in this function) drivers/net/fec_mpc5200.c:691:7: error: 'mpc5xxx_fec_priv' has no member named 'interface' drivers/net/fec_mpc5200.c:694:7: error: 'mpc5xxx_fec_priv' has no member named 'phy_flags' drivers/net/fec_mpc5200.c:696:7: error: 'mpc5xxx_fec_priv' has no member named 'interface' drivers/net/fec_mpc5200.c:699:7: error: 'mpc5xxx_fec_priv' has no member named 'interface'
make[2]: *** [drivers/net/fec_mpc5200.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....
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
Sascha Hauer
maintainerQuoted 13 lines · Jean-Christophe PLAGNIOL-VILLARD
Adapt phylib from linux
switch all the driver to it
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 openSame behaviour as in linux and will allow to share code and simplify porting.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
drivers/net/phy/phy.c line 127
Quoted 6 lines
drivers/net/phy/phy.c new file +6
-0+/* Automatically gets and returns the PHY device */ +int phy_device_connect (struct mii_device *bus,int addr, +void (*adjust_link) (struct eth_device *edev), +u32 flags,phy_interface_t interface) +{ +struct eth_device *edev = bus->edev;
You should pass in a struct eth_device pointer here instead of getting it from bus->edev because a struct mii_device can have multiple ethernet devices. The next step would be to remove the edev member from struct mii_dev and add it to struct phy_device insted.
BTW no typedefs please. Use enum phy_interface instead.
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
Quoted 14 lines · Sascha Hauer
Quoted 12 lines · Jean-Christophe PLAGNIOL-VILLARD
Adapt phylib from linux
switch all the driver to it
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 openSame behaviour as in linux and will allow to share code and simplify porting.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Quoted 11 lines
drivers/net/phy/phy.c line 127
Quoted 6 lines
drivers/net/phy/phy.c new file +6
-0+/* Automatically gets and returns the PHY device */ +int phy_device_connect (struct mii_device *bus,int addr, +void (*adjust_link) (struct eth_device *edev), +u32 flags,phy_interface_t interface) +{ +struct eth_device *edev = bus->edev;You should pass in a struct
eth_devicepointer here instead of getting it frombus->edevbecause a structmii_devicecan have multiple ethernet devices. The next step would be to remove the edev member from structmii_devand add it to structphy_deviceinsted.
pass the edev ok.
drop the edbua in mii_device ok.
add the phy_device no
the miidev is just the bus do not care about the phydev. we add attached the phydev to the eth_device not the mii_device
Quoted 2 lines
BTW no typedefs please. Use enum
phy_interfaceinstead.
linux code I really do not want to touch it
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
Quoted 24 lines · Sascha Hauer
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Adapt phylib from linux
switch all the driver to it
Quoted 8 lines
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 openSame behaviour as in linux and will allow to share code and simplify porting.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>config: ppc
pcm030_defconfigdrivers/net/fec_mpc5200.c: In function 'mpc5xxx_fec_open':drivers/net/fec_mpc5200.c:415:15: error: 'mpc5xxx_fec_priv' has no member named 'phy_flags'drivers/net/fec_mpc5200.c:415:31: error: 'mpc5xxx_fec_priv' has no member named 'interface'drivers/net/fec_mpc5200.c: In function 'mpc5xxx_fec_probe':drivers/net/fec_mpc5200.c:687:8: error: 'RMII' undeclared (first use in this function)drivers/net/fec_mpc5200.c:687:8: note: each undeclared identifier is reported only once for each function it appears indrivers/net/fec_mpc5200.c:688:7: error: 'mpc5xxx_fec_priv' has no member named 'interface'drivers/net/fec_mpc5200.c:690:8: error: 'RGMII' undeclared (first use in this function)drivers/net/fec_mpc5200.c:691:7: error: 'mpc5xxx_fec_priv' has no member named 'interface'
Quoted 8 lines
drivers/net/fec_mpc5200.c:694:7: error: 'mpc5xxx_fec_priv' has no member named 'phy_flags'drivers/net/fec_mpc5200.c:696:7: error: 'mpc5xxx_fec_priv' has no member named 'interface'drivers/net/fec_mpc5200.c:699:7: error: 'mpc5xxx_fec_priv' has no member named 'interface' make[2]: *** [drivers/net/fec_mpc5200.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....
we really need to cleanup this driver to share code with teh arm one instead of copy and paste everywhere
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox