Universal PHY Infrastructure
Subsystems (6)
v5 cover Universal PHY Infrastructure
Or PHY Lib for U-Boot.
This sequence of patches adds infrastructure for universally-available PHY drivers (and MDIO drivers). It piggy-backs on the existing miiphy code, for backwards compatibility, but it also creates a new set of APIs. This was necessary partly to provide cleaner interfaces for more robust driver support, and partly because one goal was to support 10G (802.3 Clause 45) MDIO buses, which has an extra argument for addressing PHY registers.
Special thanks goes to Mingkai Hu, who did a substantial amount of work up front to convert the tsec PHY code into something more usable, which I have mostly copied for the purposes of PHY Lib.
In this version, I slightly re-architected the 10G support (mmds are now specified in the driver initialization, and the code which auto-detects the mmds is now its own function). I added a phy_reset() function, which works with 10G PHYs as well. I put a reset early in phy_connect(), so that many more PHYs work out of the box. I also fix the Marvell PHY code, which had dropped a number of the resets which were necessary.
One last major change was to eliminate fsl_phy_enet_if, and replace it with the phy_interface_t enum. I've made this its own patch, as it touches many files.
The new mdio command loses the "busname:addr" addressing mechanism, as "busname addr" felt more natural to me (though I expect most people will go with "ethname", as the ethernet names are much more visible. In addition, the <devad> argument is now optional by way of being combined with the reg
argument: [<devad>.]<regnum>. This makes sense, as this is also how the registers are described in the specs and in the data sheets. ie:
Register 7.1 - AN Status
I've put the relevant changelogs in the patches. Enjoy!
I pushed this new version to git://git.denx.de/u-boot/u-boot-mmc.git
in the phylib branch
Andy Fleming (7):
Remove instances of phy_read/write
miiphy: Fix some formatting issues
Create PHY Lib for U-Boot
phylib: Add a bunch of PHY drivers from tsec
tsec: Convert tsec to use PHY Lib
fsl: Change fsl_phy_enet_if to phy_interface_t
Add mdio command for new PHY infrastructure
Mingkai Hu (2):
tsec: use IO accessors for IO accesses
tsec: arrange the code to avoid useless function declaration
arch/powerpc/cpu/mpc8xxx/fdt.c | 23 +- arch/powerpc/include/asm/config.h | 9 + arch/powerpc/include/asm/fsl_enet.h | 27 +- board/freescale/mpc8360emds/mpc8360emds.c | 10 +- board/freescale/mpc837xemds/mpc837xemds.c | 10 +- board/freescale/mpc8536ds/mpc8536ds.c | 6 + board/freescale/mpc8544ds/mpc8544ds.c | 30 + board/freescale/mpc8569mds/mpc8569mds.c | 4 +- board/freescale/mpc8572ds/mpc8572ds.c | 6 + board/freescale/p1022ds/p1022ds.c | 6 + board/freescale/p1_p2_rdb/p1_p2_rdb.c | 6 + board/freescale/p2020ds/p2020ds.c | 7 + common/Makefile | 4 + common/cmd_mdio.c | 286 +++++ common/miiphyutil.c | 311 +++-- drivers/net/Makefile | 2 +- drivers/net/dm9000x.c | 18 +- drivers/net/enc28j60.c | 24 +- drivers/net/fsl_mdio.c | 120 ++ drivers/net/phy/Makefile | 13 + drivers/net/phy/atheros.c | 48 + drivers/net/phy/broadcom.c | 286 +++++ drivers/net/phy/davicom.c | 98 ++ drivers/net/phy/generic_10g.c | 105 ++ drivers/net/phy/lxt.c | 87 ++ drivers/net/phy/marvell.c | 367 ++++++ drivers/net/phy/micrel.c | 40 + drivers/net/phy/natsemi.c | 96 ++ drivers/net/phy/phy.c | 753 +++++++++++ drivers/net/phy/realtek.c | 130 ++ drivers/net/phy/teranetics.c | 62 + drivers/net/phy/vitesse.c | 242 ++++ drivers/net/tsec.c | 1992 ++++------------------------- drivers/net/uli526x.c | 24 +- drivers/qe/uec.c | 59 +- drivers/qe/uec.h | 3 +- drivers/qe/uec_phy.c | 181 ++-- include/config_phylib_all_drivers.h | 32 + include/configs/MPC8323ERDB.h | 4 +- include/configs/MPC832XEMDS.h | 4 +- include/configs/MPC8360EMDS.h | 4 +- include/configs/MPC8360ERDK.h | 4 +- include/configs/MPC8568MDS.h | 4 +- include/configs/MPC8569MDS.h | 20 +- include/configs/kmeter1.h | 2 +- include/fsl_mdio.h | 62 + include/linux/ethtool.h | 721 +++++++++++ include/linux/mdio.h | 278 ++++ include/miiphy.h | 53 +- include/phy.h | 229 ++++ include/tsec.h | 302 +---- net/eth.c | 6 + 52 files changed, 4898 insertions(+), 2322 deletions(-) create mode 100644 common/cmd_mdio.c create mode 100644 drivers/net/fsl_mdio.c create mode 100644 drivers/net/phy/atheros.c create mode 100644 drivers/net/phy/broadcom.c create mode 100644 drivers/net/phy/davicom.c create mode 100644 drivers/net/phy/generic_10g.c create mode 100644 drivers/net/phy/lxt.c create mode 100644 drivers/net/phy/marvell.c create mode 100644 drivers/net/phy/micrel.c create mode 100644 drivers/net/phy/natsemi.c create mode 100644 drivers/net/phy/phy.c create mode 100644 drivers/net/phy/realtek.c create mode 100644 drivers/net/phy/teranetics.c create mode 100644 drivers/net/phy/vitesse.c create mode 100644 include/config_phylib_all_drivers.h create mode 100644 include/fsl_mdio.h create mode 100644 include/linux/ethtool.h create mode 100644 include/linux/mdio.h create mode 100644 include/phy.h
PATCH v5 1/9 tsec: use IO accessors for IO accesses
From: Mingkai Hu <[email protected]>
---
v3: Removed unnecessary syncs
v2: Fixed the commit message's spelling
drivers/net/tsec.c | 249 ++++++++++++++++++++++++++-------------------------- include/tsec.h | 8 +- 2 files changed, 130 insertions(+), 127 deletions(-)
drivers/net/tsec.c +126 -123
@@ -5,7 +5,7 @@* terms of the GNU Public License, Version 2, incorporated * herein by reference. * -* Copyright 2004-2010 Freescale Semiconductor, Inc. +* Copyright 2004-2011 Freescale Semiconductor, Inc. * (C) Copyright 2003, Motorola, Inc. * author Andy Fleming *
@@ -50,7 +50,7 @@ static int tsec_recv(struct eth_device *dev);static int tsec_init (struct eth_device *dev,bd_t * bd);static int tsec_initialize (bd_t * bis,struct tsec_info_struct *tsec_info);static void tsec_halt (struct eth_device *dev); -static void init_registers (volatile tsec_t * regs); +static void init_registers (tsec_t *regs);static void startup_tsec (struct eth_device *dev);static int init_phy (struct eth_device *dev);void write_phy_reg (struct tsec_private *priv,uint regnum,uint value);
@@ -166,9 +166,9 @@ static int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info)eth_register (dev);/* Reset the MAC */ - priv->regs->maccfg1 |=MACCFG1_SOFT_RESET ; +setbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET );udelay (2 );/* Soft Reset must be asserted for 3 TX clocks */ - priv->regs->maccfg1 &= ~(MACCFG1_SOFT_RESET ); +clrbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET );#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) \ && !defined(BITBANGMII )
@@ -190,16 +190,16 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)char tmpbuf[MAC_ADDR_LEN ];int i;struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs;/* Make sure the controller is stopped */ tsec_halt (dev);/* Init MACCFG2. Defaults to GMII */ - regs->maccfg2 =MACCFG2_INIT_SETTINGS ; +out_be32 (®s->maccfg2,MACCFG2_INIT_SETTINGS );/* Init ECNTRL */ - regs->ecntrl =ECNTRL_INIT_SETTINGS ; +out_be32 (®s->ecntrl,ECNTRL_INIT_SETTINGS );/* Copy the station address into the address registers. * Backwards, because little endian MACS are dumb */
@@ -209,11 +209,11 @@ static int tsec_init(struct eth_device *dev, bd_t * bd) tempval = (tmpbuf[0 ] <<24 ) | (tmpbuf[1 ] <<16 ) | (tmpbuf[2 ] <<8 ) | tmpbuf[3 ]; - regs->macstnaddr1 = tempval; +out_be32 (®s->macstnaddr1, tempval); tempval = *((uint *) (tmpbuf +4 )); - regs->macstnaddr2 = tempval; +out_be32 (®s->macstnaddr2, tempval);/* reset the indices to zero */ rxIdx =0 ;
@@ -230,17 +230,17 @@ static int tsec_init(struct eth_device *dev, bd_t * bd) }/* Writes the given phy's reg with value, using the specified MDIO regs */ -static void tsec_local_mdio_write (volatile tsec_mdio_t *phyregs,uint addr, +static void tsec_local_mdio_write (tsec_mdio_t *phyregs,uint addr,uint reg,uint value) {int timeout =1000000 ; - phyregs->miimadd = (addr <<8 ) | reg; - phyregs->miimcon = value; - asm("sync" ); +out_be32 (&phyregs->miimadd, (addr <<8 ) | reg); +out_be32 (&phyregs->miimcon, value); timeout =1000000 ; -while ((phyregs->miimind &MIIMIND_BUSY ) && timeout--) ; +while ((in_be32 (&phyregs->miimind) &MIIMIND_BUSY ) && timeout--) + ; }
@@ -254,28 +254,26 @@ static void tsec_local_mdio_write(volatile tsec_mdio_t *phyregs, uint addr,* notvalid bit cleared), and the bus to cease activity (miimind * busy bit cleared), and then returns the value */ -static uint tsec_local_mdio_read (volatile tsec_mdio_t *phyregs, -uint phyid,uint regnum) +static uint tsec_local_mdio_read (tsec_mdio_t *phyregs,uint phyid,uint regnum) {uint value;/* Put the address of the phy, and the register * number into MIIMADD */ - phyregs->miimadd = (phyid <<8 ) | regnum; +out_be32 (&phyregs->miimadd, (phyid <<8 ) | regnum);/* Clear the command register, and wait */ - phyregs->miimcom =0 ; - asm("sync" ); +out_be32 (&phyregs->miimcom,0 );/* Initiate a read command, and wait */ - phyregs->miimcom =MIIM_READ_COMMAND ; - asm("sync" ); +out_be32 (&phyregs->miimcom,MIIM_READ_COMMAND );/* Wait for the the indication that the read is done */ -while ((phyregs->miimind & (MIIMIND_NOTVALID |MIIMIND_BUSY ))) ; +while ((in_be32 (&phyregs->miimind) & (MIIMIND_NOTVALID |MIIMIND_BUSY ))) + ;/* Grab the value read from the PHY */ - value = phyregs->miimstat; + value =in_be32 (&phyregs->miimstat);return value; }
@@ -321,18 +319,16 @@ static int init_phy(struct eth_device *dev) {struct tsec_private *priv = (struct tsec_private *)dev->priv;struct phy_info *curphy; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs;/* Assign a Physical address to the TBI */ - regs->tbipa =CONFIG_SYS_TBIPA_VALUE ; - asm("sync" ); +out_be32 (®s->tbipa,CONFIG_SYS_TBIPA_VALUE );/* Reset MII (due to new addresses) */ - priv->phyregs->miimcfg =MIIMCFG_RESET ; - asm("sync" ); - priv->phyregs->miimcfg =MIIMCFG_INIT_VALUE ; - asm("sync" ); -while (priv->phyregs->miimind &MIIMIND_BUSY ) ; +out_be32 (&priv->phyregs->miimcfg,MIIMCFG_RESET ); +out_be32 (&priv->phyregs->miimcfg,MIIMCFG_INIT_VALUE ); +while (in_be32 (&priv->phyregs->miimind) &MIIMIND_BUSY ) + ;/* Get the cmd structure corresponding to the attached * PHY */
@@ -345,7 +341,7 @@ static int init_phy(struct eth_device *dev)return 0 ; } -if (regs->ecntrl &ECNTRL_SGMII_MODE ) +if (in_be32 (®s->ecntrl) &ECNTRL_SGMII_MODE )tsec_configure_serdes (priv); priv->phyinfo = curphy;
@@ -838,16 +834,16 @@ static uint mii_parse_dm9161_scsr(uint mii_reg, struct tsec_private * priv)static uint mii_cis8204_fixled (uint mii_reg,struct tsec_private * priv) {uint phyid; -volatile tsec_mdio_t *regbase = priv->phyregs; +tsec_mdio_t *regbase = priv->phyregs;int timeout =1000000 ;for (phyid =0 ; phyid <4 ; phyid++) { - regbase->miimadd = (phyid <<8 ) | mii_reg; - regbase->miimcon =MIIM_CIS8204_SLEDCON_INIT ; - asm("sync" ); +out_be32 (®base->miimadd, (phyid <<8 ) | mii_reg); +out_be32 (®base->miimcon,MIIM_CIS8204_SLEDCON_INIT ); timeout =1000000 ; -while ((regbase->miimind &MIIMIND_BUSY ) && timeout--) ; +while ((in_be32 (®base->miimind) &MIIMIND_BUSY ) && timeout--) + ; }return MIIM_CIS8204_SLEDCON_INIT ;
@@ -874,45 +870,45 @@ static uint mii_m88e1111s_setmode(uint mii_reg, struct tsec_private *priv)* those we don't care about (unless zero is bad, in which case, * choose a more appropriate value) */ -static void init_registers (volatile tsec_t * regs) +static void init_registers (tsec_t *regs) {/* Clear IEVENT */ - regs->ievent =IEVENT_INIT_CLEAR ; - - regs->imask =IMASK_INIT_CLEAR ; - - regs->hash.iaddr0 =0 ; - regs->hash.iaddr1 =0 ; - regs->hash.iaddr2 =0 ; - regs->hash.iaddr3 =0 ; - regs->hash.iaddr4 =0 ; - regs->hash.iaddr5 =0 ; - regs->hash.iaddr6 =0 ; - regs->hash.iaddr7 =0 ; - - regs->hash.gaddr0 =0 ; - regs->hash.gaddr1 =0 ; - regs->hash.gaddr2 =0 ; - regs->hash.gaddr3 =0 ; - regs->hash.gaddr4 =0 ; - regs->hash.gaddr5 =0 ; - regs->hash.gaddr6 =0 ; - regs->hash.gaddr7 =0 ; - - regs->rctrl =0x00000000 ; +out_be32 (®s->ievent,IEVENT_INIT_CLEAR ); + +out_be32 (®s->imask,IMASK_INIT_CLEAR ); + +out_be32 (®s->hash.iaddr0,0 ); +out_be32 (®s->hash.iaddr1,0 ); +out_be32 (®s->hash.iaddr2,0 ); +out_be32 (®s->hash.iaddr3,0 ); +out_be32 (®s->hash.iaddr4,0 ); +out_be32 (®s->hash.iaddr5,0 ); +out_be32 (®s->hash.iaddr6,0 ); +out_be32 (®s->hash.iaddr7,0 ); + +out_be32 (®s->hash.gaddr0,0 ); +out_be32 (®s->hash.gaddr1,0 ); +out_be32 (®s->hash.gaddr2,0 ); +out_be32 (®s->hash.gaddr3,0 ); +out_be32 (®s->hash.gaddr4,0 ); +out_be32 (®s->hash.gaddr5,0 ); +out_be32 (®s->hash.gaddr6,0 ); +out_be32 (®s->hash.gaddr7,0 ); + +out_be32 (®s->rctrl,0x00000000 );/* Init RMON mib registers */ memset ((void *)&(regs->rmon),0 ,sizeof (rmon_mib_t)); - regs->rmon.cam1 =0xffffffff ; - regs->rmon.cam2 =0xffffffff ; +out_be32 (®s->rmon.cam1,0xffffffff ); +out_be32 (®s->rmon.cam2,0xffffffff ); - regs->mrblr =MRBLR_INIT_SETTINGS ; +out_be32 (®s->mrblr,MRBLR_INIT_SETTINGS ); - regs->minflr =MINFLR_INIT_SETTINGS ; +out_be32 (®s->minflr,MINFLR_INIT_SETTINGS ); - regs->attr =ATTR_INIT_SETTINGS ; - regs->attreli =ATTRELI_INIT_SETTINGS ; +out_be32 (®s->attr,ATTR_INIT_SETTINGS ); +out_be32 (®s->attreli,ATTRELI_INIT_SETTINGS ); }
@@ -922,44 +918,49 @@ static void init_registers(volatile tsec_t * regs)static void adjust_link (struct eth_device *dev) {struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs; +u32 ecntrl, maccfg2; -if (priv->link) { -if (priv->duplexity !=0 ) - regs->maccfg2 |=MACCFG2_FULL_DUPLEX ; -else - regs->maccfg2 &= ~(MACCFG2_FULL_DUPLEX ); +if (!priv->link) { +printf ("%s: No link.\n" , dev->name); +return ; + } -switch (priv->speed) { -case 1000 : - regs->maccfg2 = ((regs->maccfg2 & ~(MACCFG2_IF )) - |MACCFG2_GMII ); -break ; -case 100 : -case 10 : - regs->maccfg2 = ((regs->maccfg2 & ~(MACCFG2_IF )) - |MACCFG2_MII ); +/* clear all bits relative with interface mode */ + ecntrl =in_be32 (®s->ecntrl); + ecntrl &= ~ECNTRL_R100 ; -/* Set R100 bit in all modes although -* it is only used in RGMII mode -*/ -if (priv->speed ==100 ) - regs->ecntrl |=ECNTRL_R100 ; -else - regs->ecntrl &= ~(ECNTRL_R100 ); -break ; -default : -printf ("%s: Speed was bad\n" , dev->name); -break ; - } + maccfg2 =in_be32 (®s->maccfg2); + maccfg2 &= ~(MACCFG2_IF |MACCFG2_FULL_DUPLEX ); -printf ("Speed: %d, %s duplex%s\n" , priv->speed, - (priv->duplexity) ?"full" :"half" , - (priv->flags &TSEC_FIBER ) ?", fiber mode" :"" ); +if (priv->duplexity) + maccfg2 |=MACCFG2_FULL_DUPLEX ; - }else { -printf ("%s: No link.\n" , dev->name); +switch (priv->speed) { +case 1000 : + maccfg2 |=MACCFG2_GMII ; +break ; +case 100 : +case 10 : + maccfg2 |=MACCFG2_MII ; + +/* Set R100 bit in all modes although +* it is only used in RGMII mode +*/ +if (priv->speed ==100 ) + ecntrl |=ECNTRL_R100 ; +break ; +default : +printf ("%s: Speed was bad\n" , dev->name); +break ; } + +out_be32 (®s->ecntrl, ecntrl); +out_be32 (®s->maccfg2, maccfg2); + +printf ("Speed: %d, %s duplex%s\n" , priv->speed, + (priv->duplexity) ?"full" :"half" , + (priv->flags &TSEC_FIBER ) ?", fiber mode" :"" ); }/* Set up the buffers and their descriptors, and bring up the
@@ -969,11 +970,11 @@ static void startup_tsec(struct eth_device *dev) {int i;struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs;/* Point to the buffer descriptors */ - regs->tbase = (unsigned int )(&rtx.txbd[txIdx]); - regs->rbase = (unsigned int )(&rtx.rxbd[rxIdx]); +out_be32 (®s->tbase, (unsigned int )(&rtx.txbd[txIdx])); +out_be32 (®s->rbase, (unsigned int )(&rtx.rxbd[rxIdx]));/* Initialize the Rx Buffer descriptors */ for (i =0 ; i <PKTBUFSRX ; i++) {
@@ -998,13 +999,13 @@ static void startup_tsec(struct eth_device *dev)adjust_link (dev);/* Enable Transmit and Receive */ - regs->maccfg1 |= (MACCFG1_RX_EN |MACCFG1_TX_EN ); +setbits_be32 (®s->maccfg1,MACCFG1_RX_EN |MACCFG1_TX_EN );/* Tell the DMA it is clear to go */ - regs->dmactrl |=DMACTRL_INIT_SETTINGS ; - regs->tstat =TSTAT_CLEAR_THALT ; - regs->rstat =RSTAT_CLEAR_RHALT ; - regs->dmactrl &= ~(DMACTRL_GRS |DMACTRL_GTS ); +setbits_be32 (®s->dmactrl,DMACTRL_INIT_SETTINGS ); +out_be32 (®s->tstat,TSTAT_CLEAR_THALT ); +out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); +clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); }/* This returns the status bits of the device. The return value
@@ -1017,7 +1018,7 @@ static int tsec_send(struct eth_device *dev, volatile void *packet, int length)int i;int result =0 ;struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs;/* Find an empty buffer descriptor */ for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) {
@@ -1033,7 +1034,7 @@ static int tsec_send(struct eth_device *dev, volatile void *packet, int length) (TXBD_READY |TXBD_LAST |TXBD_CRC |TXBD_INTERRUPT );/* Tell the DMA to go */ - regs->tstat =TSTAT_CLEAR_THALT ; +out_be32 (®s->tstat,TSTAT_CLEAR_THALT );/* Wait for buffer to be transmitted */ for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) {
@@ -1053,7 +1054,7 @@ static int tsec_recv(struct eth_device *dev) {int length;struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs;while (!(rtx.rxbd[rxIdx].status &RXBD_EMPTY )) {
@@ -1076,9 +1077,9 @@ static int tsec_recv(struct eth_device *dev) rxIdx = (rxIdx +1 ) %PKTBUFSRX ; } -if (regs->ievent &IEVENT_BSY ) { - regs->ievent =IEVENT_BSY ; - regs->rstat =RSTAT_CLEAR_RHALT ; +if (in_be32 (®s->ievent) &IEVENT_BSY ) { +out_be32 (®s->ievent,IEVENT_BSY ); +out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); }return -1 ;
@@ -1089,15 +1090,16 @@ static int tsec_recv(struct eth_device *dev)static void tsec_halt (struct eth_device *dev) {struct tsec_private *priv = (struct tsec_private *)dev->priv; -volatile tsec_t *regs = priv->regs; +tsec_t *regs = priv->regs; - regs->dmactrl &= ~(DMACTRL_GRS |DMACTRL_GTS ); - regs->dmactrl |= (DMACTRL_GRS |DMACTRL_GTS ); +clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); +setbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); -while ((regs->ievent & (IEVENT_GRSC |IEVENT_GTSC )) - != (IEVENT_GRSC |IEVENT_GTSC )) ; +while ((in_be32 (®s->ievent) & (IEVENT_GRSC |IEVENT_GTSC )) + != (IEVENT_GRSC |IEVENT_GTSC )) + ; - regs->maccfg1 &= ~(MACCFG1_TX_EN |MACCFG1_RX_EN ); +clrbits_be32 (®s->maccfg1,MACCFG1_TX_EN |MACCFG1_RX_EN );/* Shut down the PHY, as needed */ if (priv->phyinfo)
@@ -1904,13 +1906,14 @@ static void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd) {int i;uint result; -volatile tsec_mdio_t *phyregs = priv->phyregs; +tsec_mdio_t *phyregs = priv->phyregs; - phyregs->miimcfg =MIIMCFG_RESET ; +out_be32 (&phyregs->miimcfg,MIIMCFG_RESET ); - phyregs->miimcfg =MIIMCFG_INIT_VALUE ; +out_be32 (&phyregs->miimcfg,MIIMCFG_INIT_VALUE ); -while (phyregs->miimind &MIIMIND_BUSY ) ; +while (in_be32 (&phyregs->miimind) &MIIMIND_BUSY ) + ;for (i =0 ; cmd->mii_reg != miim_end; i++) {if (cmd->mii_data == miim_read) {
include/tsec.h +4 -4
@@ -7,7 +7,7 @@* terms of the GNU Public License, Version 2, incorporated * herein by reference. * -* Copyright 2004, 2007, 2009 Freescale Semiconductor, Inc. +* Copyright 2004, 2007, 2009, 2011 Freescale Semiconductor, Inc. * (C) Copyright 2003, Motorola, Inc. * maintained by Xianghua Xiao (x.xiao at motorola.com) * author Andy Fleming
@@ -587,9 +587,9 @@ typedef struct tsec#define TSEC_FIBER (1 << 3)/* PHY uses fiber, eg 1000 Base-X */ struct tsec_private { -volatile tsec_t *regs; -volatile tsec_mdio_t *phyregs; -volatile tsec_mdio_t *phyregs_sgmii; +tsec_t *regs; +tsec_mdio_t *phyregs; +tsec_mdio_t *phyregs_sgmii;struct phy_info *phyinfo;uint phyaddr;u32 flags;
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 2/9 tsec: arrange the code to avoid useless function declaration
From: Mingkai Hu <[email protected]>
This is merely a rearrangement. No changes to the code, except to remove now-useless declarations.
--- drivers/net/tsec.c | 855 +++++++++++++++++++++++++--------------------------- 1 files changed, 415 insertions(+), 440 deletions(-)
drivers/net/tsec.c +415 -440
@@ -44,31 +44,6 @@ static RTXBD rtx __attribute__ ((aligned(8)));#error "rtx must be 64-bit aligned"#endif -static int tsec_send (struct eth_device *dev, -volatile void *packet,int length); -static int tsec_recv (struct eth_device *dev); -static int tsec_init (struct eth_device *dev,bd_t * bd); -static int tsec_initialize (bd_t * bis,struct tsec_info_struct *tsec_info); -static void tsec_halt (struct eth_device *dev); -static void init_registers (tsec_t *regs); -static void startup_tsec (struct eth_device *dev); -static int init_phy (struct eth_device *dev); -void write_phy_reg (struct tsec_private *priv,uint regnum,uint value); -uint read_phy_reg (struct tsec_private *priv,uint regnum); -static struct phy_info *get_phy_info (struct eth_device *dev); -static void phy_run_commands (struct tsec_private *priv,struct phy_cmd *cmd); -static void adjust_link (struct eth_device *dev); -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) \ - && !defined(BITBANGMII ) -static int tsec_miiphy_write (const char *devname,unsigned char addr, -unsigned char reg,unsigned short value); -static int tsec_miiphy_read (const char *devname,unsigned char addr, -unsigned char reg,unsigned short *value); -#endif -#ifdef CONFIG_MCAST_TFTP -static int tsec_mcast_addr (struct eth_device *dev,u8 mcast_mac,u8 set); -#endif -/* Default initializations for TSEC controllers. */ static struct tsec_info_struct tsec_info[] = {
@@ -95,140 +70,6 @@ static struct tsec_info_struct tsec_info[] = {#endif }; -/* -* Initialize all the TSEC devices -* -* Returns the number of TSEC devices that were initialized -*/ -int tsec_eth_init (bd_t *bis,struct tsec_info_struct *tsecs,int num) -{ -int i; -int ret, count =0 ; - -for (i =0 ; i < num; i++) { - ret =tsec_initialize (bis, &tsecs[i]); -if (ret >0 ) - count += ret; - } - -return count; -} - -int tsec_standard_init (bd_t *bis) -{ -return tsec_eth_init (bis, tsec_info,ARRAY_SIZE (tsec_info)); -} - -/* Initialize device structure. Returns success if PHY -* initialization succeeded (i.e. if it recognizes the PHY) -*/ -static int tsec_initialize (bd_t * bis,struct tsec_info_struct *tsec_info) -{ -struct eth_device *dev; -int i; -struct tsec_private *priv; - - dev = (struct eth_device *)malloc (sizeof *dev); - -if (NULL == dev) -return 0 ; - -memset (dev,0 ,sizeof *dev); - - priv = (struct tsec_private *)malloc (sizeof (*priv)); - -if (NULL == priv) -return 0 ; - - privlist[num_tsecs++] = priv; - priv->regs = tsec_info->regs; - priv->phyregs = tsec_info->miiregs; - priv->phyregs_sgmii = tsec_info->miiregs_sgmii; - - priv->phyaddr = tsec_info->phyaddr; - priv->flags = tsec_info->flags; - -sprintf (dev->name, tsec_info->devname); - dev->iobase =0 ; - dev->priv = priv; - dev->init = tsec_init; - dev->halt = tsec_halt; - dev->send = tsec_send; - dev->recv = tsec_recv; -#ifdef CONFIG_MCAST_TFTP - dev->mcast = tsec_mcast_addr; -#endif - -/* Tell u-boot to get the addr from the env */ -for (i =0 ; i <6 ; i++) - dev->enetaddr[i] =0 ; - -eth_register (dev); - -/* Reset the MAC */ -setbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET ); -udelay (2 );/* Soft Reset must be asserted for 3 TX clocks */ -clrbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET ); - -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) \ - && !defined(BITBANGMII ) -miiphy_register (dev->name, tsec_miiphy_read, tsec_miiphy_write); -#endif - -/* Try to initialize PHY here, and return */ -return init_phy (dev); -} - -/* Initializes data structures and registers for the controller, -* and brings the interface up. Returns the link status, meaning -* that it returns success if the link is up, failure otherwise. -* This allows u-boot to find the first active controller. -*/ -static int tsec_init (struct eth_device *dev,bd_t * bd) -{ -uint tempval; -char tmpbuf[MAC_ADDR_LEN ]; -int i; -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; - -/* Make sure the controller is stopped */ -tsec_halt (dev); - -/* Init MACCFG2. Defaults to GMII */ -out_be32 (®s->maccfg2,MACCFG2_INIT_SETTINGS ); - -/* Init ECNTRL */ -out_be32 (®s->ecntrl,ECNTRL_INIT_SETTINGS ); - -/* Copy the station address into the address registers. -* Backwards, because little endian MACS are dumb */ -for (i =0 ; i <MAC_ADDR_LEN ; i++) { - tmpbuf[MAC_ADDR_LEN -1 - i] = dev->enetaddr[i]; - } - tempval = (tmpbuf[0 ] <<24 ) | (tmpbuf[1 ] <<16 ) | (tmpbuf[2 ] <<8 ) | - tmpbuf[3 ]; - -out_be32 (®s->macstnaddr1, tempval); - - tempval = *((uint *) (tmpbuf +4 )); - -out_be32 (®s->macstnaddr2, tempval); - -/* reset the indices to zero */ - rxIdx =0 ; - txIdx =0 ; - -/* Clear out (for the most part) the other registers */ -init_registers (regs); - -/* Ready the device for tx/rx */ -startup_tsec (dev); - -/* If there's no link, fail */ -return (priv->link ?0 :-1 ); -} -/* Writes the given phy's reg with value, using the specified MDIO regs */ static void tsec_local_mdio_write (tsec_mdio_t *phyregs,uint addr,uint reg,uint value)
@@ -243,7 +84,6 @@ static void tsec_local_mdio_write(tsec_mdio_t *phyregs, uint addr, ; } -/* Provide the default behavior of writing the PHY of this ethernet device */ #define write_phy_reg (priv, regnum, value) \ tsec_local_mdio_write(priv->phyregs,priv->phyaddr,regnum,value)
@@ -311,46 +151,6 @@ static void tsec_configure_serdes(struct tsec_private *priv) CONFIG_TSEC_TBICR_SETTINGS); } -/* Discover which PHY is attached to the device, and configure it -* properly. If the PHY is not recognized, then return 0 -* (failure). Otherwise, return 1 -*/ -static int init_phy (struct eth_device *dev) -{ -struct tsec_private *priv = (struct tsec_private *)dev->priv; -struct phy_info *curphy; -tsec_t *regs = priv->regs; - -/* Assign a Physical address to the TBI */ -out_be32 (®s->tbipa,CONFIG_SYS_TBIPA_VALUE ); - -/* Reset MII (due to new addresses) */ -out_be32 (&priv->phyregs->miimcfg,MIIMCFG_RESET ); -out_be32 (&priv->phyregs->miimcfg,MIIMCFG_INIT_VALUE ); -while (in_be32 (&priv->phyregs->miimind) &MIIMIND_BUSY ) - ; - -/* Get the cmd structure corresponding to the attached -* PHY */ - curphy =get_phy_info (dev); - -if (curphy ==NULL ) { - priv->phyinfo =NULL ; -printf ("%s: No PHY found\n" , dev->name); - -return 0 ; - } - -if (in_be32 (®s->ecntrl) &ECNTRL_SGMII_MODE ) -tsec_configure_serdes (priv); - - priv->phyinfo = curphy; - -phy_run_commands (priv, priv->phyinfo->config); - -return 1 ; -} -/* * Returns which value to write to the control register. * For 10/100, the value is slightly different
@@ -866,246 +666,6 @@ static uint mii_m88e1111s_setmode(uint mii_reg, struct tsec_private *priv)return mii_data; } -/* Initialized required registers to appropriate values, zeroing -* those we don't care about (unless zero is bad, in which case, -* choose a more appropriate value) -*/ -static void init_registers (tsec_t *regs) -{ -/* Clear IEVENT */ -out_be32 (®s->ievent,IEVENT_INIT_CLEAR ); - -out_be32 (®s->imask,IMASK_INIT_CLEAR ); - -out_be32 (®s->hash.iaddr0,0 ); -out_be32 (®s->hash.iaddr1,0 ); -out_be32 (®s->hash.iaddr2,0 ); -out_be32 (®s->hash.iaddr3,0 ); -out_be32 (®s->hash.iaddr4,0 ); -out_be32 (®s->hash.iaddr5,0 ); -out_be32 (®s->hash.iaddr6,0 ); -out_be32 (®s->hash.iaddr7,0 ); - -out_be32 (®s->hash.gaddr0,0 ); -out_be32 (®s->hash.gaddr1,0 ); -out_be32 (®s->hash.gaddr2,0 ); -out_be32 (®s->hash.gaddr3,0 ); -out_be32 (®s->hash.gaddr4,0 ); -out_be32 (®s->hash.gaddr5,0 ); -out_be32 (®s->hash.gaddr6,0 ); -out_be32 (®s->hash.gaddr7,0 ); - -out_be32 (®s->rctrl,0x00000000 ); - -/* Init RMON mib registers */ -memset ((void *)&(regs->rmon),0 ,sizeof (rmon_mib_t)); - -out_be32 (®s->rmon.cam1,0xffffffff ); -out_be32 (®s->rmon.cam2,0xffffffff ); - -out_be32 (®s->mrblr,MRBLR_INIT_SETTINGS ); - -out_be32 (®s->minflr,MINFLR_INIT_SETTINGS ); - -out_be32 (®s->attr,ATTR_INIT_SETTINGS ); -out_be32 (®s->attreli,ATTRELI_INIT_SETTINGS ); - -} - -/* Configure maccfg2 based on negotiated speed and duplex -* reported by PHY handling code -*/ -static void adjust_link (struct eth_device *dev) -{ -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; -u32 ecntrl, maccfg2; - -if (!priv->link) { -printf ("%s: No link.\n" , dev->name); -return ; - } - -/* clear all bits relative with interface mode */ - ecntrl =in_be32 (®s->ecntrl); - ecntrl &= ~ECNTRL_R100 ; - - maccfg2 =in_be32 (®s->maccfg2); - maccfg2 &= ~(MACCFG2_IF |MACCFG2_FULL_DUPLEX ); - -if (priv->duplexity) - maccfg2 |=MACCFG2_FULL_DUPLEX ; - -switch (priv->speed) { -case 1000 : - maccfg2 |=MACCFG2_GMII ; -break ; -case 100 : -case 10 : - maccfg2 |=MACCFG2_MII ; - -/* Set R100 bit in all modes although -* it is only used in RGMII mode -*/ -if (priv->speed ==100 ) - ecntrl |=ECNTRL_R100 ; -break ; -default : -printf ("%s: Speed was bad\n" , dev->name); -break ; - } - -out_be32 (®s->ecntrl, ecntrl); -out_be32 (®s->maccfg2, maccfg2); - -printf ("Speed: %d, %s duplex%s\n" , priv->speed, - (priv->duplexity) ?"full" :"half" , - (priv->flags &TSEC_FIBER ) ?", fiber mode" :"" ); -} - -/* Set up the buffers and their descriptors, and bring up the -* interface -*/ -static void startup_tsec (struct eth_device *dev) -{ -int i; -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; - -/* Point to the buffer descriptors */ -out_be32 (®s->tbase, (unsigned int )(&rtx.txbd[txIdx])); -out_be32 (®s->rbase, (unsigned int )(&rtx.rxbd[rxIdx])); - -/* Initialize the Rx Buffer descriptors */ -for (i =0 ; i <PKTBUFSRX ; i++) { - rtx.rxbd[i].status =RXBD_EMPTY ; - rtx.rxbd[i].length =0 ; - rtx.rxbd[i].bufPtr = (uint ) NetRxPackets[i]; - } - rtx.rxbd[PKTBUFSRX -1 ].status |=RXBD_WRAP ; - -/* Initialize the TX Buffer Descriptors */ -for (i =0 ; i <TX_BUF_CNT ; i++) { - rtx.txbd[i].status =0 ; - rtx.txbd[i].length =0 ; - rtx.txbd[i].bufPtr =0 ; - } - rtx.txbd[TX_BUF_CNT -1 ].status |=TXBD_WRAP ; - -/* Start up the PHY */ -if (priv->phyinfo) -phy_run_commands (priv, priv->phyinfo->startup); - -adjust_link (dev); - -/* Enable Transmit and Receive */ -setbits_be32 (®s->maccfg1,MACCFG1_RX_EN |MACCFG1_TX_EN ); - -/* Tell the DMA it is clear to go */ -setbits_be32 (®s->dmactrl,DMACTRL_INIT_SETTINGS ); -out_be32 (®s->tstat,TSTAT_CLEAR_THALT ); -out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); -clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); -} - -/* This returns the status bits of the device. The return value -* is never checked, and this is what the 8260 driver did, so we -* do the same. Presumably, this would be zero if there were no -* errors -*/ -static int tsec_send (struct eth_device *dev,volatile void *packet,int length) -{ -int i; -int result =0 ; -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; - -/* Find an empty buffer descriptor */ -for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) { -if (i >=TOUT_LOOP ) { -debug ("%s: tsec: tx buffers full\n" , dev->name); -return result; - } - } - - rtx.txbd[txIdx].bufPtr = (uint ) packet; - rtx.txbd[txIdx].length = length; - rtx.txbd[txIdx].status |= - (TXBD_READY |TXBD_LAST |TXBD_CRC |TXBD_INTERRUPT ); - -/* Tell the DMA to go */ -out_be32 (®s->tstat,TSTAT_CLEAR_THALT ); - -/* Wait for buffer to be transmitted */ -for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) { -if (i >=TOUT_LOOP ) { -debug ("%s: tsec: tx error\n" , dev->name); -return result; - } - } - - txIdx = (txIdx +1 ) %TX_BUF_CNT ; - result = rtx.txbd[txIdx].status &TXBD_STATS ; - -return result; -} - -static int tsec_recv (struct eth_device *dev) -{ -int length; -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; - -while (!(rtx.rxbd[rxIdx].status &RXBD_EMPTY )) { - - length = rtx.rxbd[rxIdx].length; - -/* Send the packet up if there were no errors */ -if (!(rtx.rxbd[rxIdx].status &RXBD_STATS )) { -NetReceive (NetRxPackets[rxIdx], length -4 ); - }else { -printf ("Got error %x\n" , - (rtx.rxbd[rxIdx].status &RXBD_STATS )); - } - - rtx.rxbd[rxIdx].length =0 ; - -/* Set the wrap bit if this is the last element in the list */ - rtx.rxbd[rxIdx].status = -RXBD_EMPTY | (((rxIdx +1 ) ==PKTBUFSRX ) ?RXBD_WRAP :0 ); - - rxIdx = (rxIdx +1 ) %PKTBUFSRX ; - } - -if (in_be32 (®s->ievent) &IEVENT_BSY ) { -out_be32 (®s->ievent,IEVENT_BSY ); -out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); - } - -return -1 ; - -} - -/* Stop the interface */ -static void tsec_halt (struct eth_device *dev) -{ -struct tsec_private *priv = (struct tsec_private *)dev->priv; -tsec_t *regs = priv->regs; - -clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); -setbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); - -while ((in_be32 (®s->ievent) & (IEVENT_GRSC |IEVENT_GTSC )) - != (IEVENT_GRSC |IEVENT_GTSC )) - ; - -clrbits_be32 (®s->maccfg1,MACCFG1_TX_EN |MACCFG1_RX_EN ); - -/* Shut down the PHY, as needed */ -if (priv->phyinfo) -phy_run_commands (priv, priv->phyinfo->shutdown); -} -static struct phy_info phy_info_M88E1149S = {0x1410ca ,"Marvell 88E1149S" ,
@@ -2025,3 +1585,418 @@ tsec_mcast_addr (struct eth_device *dev, u8 mcast_mac, u8 set)return 0 ; }#endif /* Multicast TFTP ? */ + +/* Initialized required registers to appropriate values, zeroing +* those we don't care about (unless zero is bad, in which case, +* choose a more appropriate value) +*/ +static void init_registers (tsec_t *regs) +{ +/* Clear IEVENT */ +out_be32 (®s->ievent,IEVENT_INIT_CLEAR ); + +out_be32 (®s->imask,IMASK_INIT_CLEAR ); + +out_be32 (®s->hash.iaddr0,0 ); +out_be32 (®s->hash.iaddr1,0 ); +out_be32 (®s->hash.iaddr2,0 ); +out_be32 (®s->hash.iaddr3,0 ); +out_be32 (®s->hash.iaddr4,0 ); +out_be32 (®s->hash.iaddr5,0 ); +out_be32 (®s->hash.iaddr6,0 ); +out_be32 (®s->hash.iaddr7,0 ); + +out_be32 (®s->hash.gaddr0,0 ); +out_be32 (®s->hash.gaddr1,0 ); +out_be32 (®s->hash.gaddr2,0 ); +out_be32 (®s->hash.gaddr3,0 ); +out_be32 (®s->hash.gaddr4,0 ); +out_be32 (®s->hash.gaddr5,0 ); +out_be32 (®s->hash.gaddr6,0 ); +out_be32 (®s->hash.gaddr7,0 ); + +out_be32 (®s->rctrl,0x00000000 ); + +/* Init RMON mib registers */ +memset ((void *)&(regs->rmon),0 ,sizeof (rmon_mib_t)); + +out_be32 (®s->rmon.cam1,0xffffffff ); +out_be32 (®s->rmon.cam2,0xffffffff ); + +out_be32 (®s->mrblr,MRBLR_INIT_SETTINGS ); + +out_be32 (®s->minflr,MINFLR_INIT_SETTINGS ); + +out_be32 (®s->attr,ATTR_INIT_SETTINGS ); +out_be32 (®s->attreli,ATTRELI_INIT_SETTINGS ); + +} + +/* Configure maccfg2 based on negotiated speed and duplex +* reported by PHY handling code +*/ +static void adjust_link (struct eth_device *dev) +{ +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; +u32 ecntrl, maccfg2; + +if (!priv->link) { +printf ("%s: No link.\n" , dev->name); +return ; + } + +/* clear all bits relative with interface mode */ + ecntrl =in_be32 (®s->ecntrl); + ecntrl &= ~ECNTRL_R100 ; + + maccfg2 =in_be32 (®s->maccfg2); + maccfg2 &= ~(MACCFG2_IF |MACCFG2_FULL_DUPLEX ); + +if (priv->duplexity) + maccfg2 |=MACCFG2_FULL_DUPLEX ; + +switch (priv->speed) { +case 1000 : + maccfg2 |=MACCFG2_GMII ; +break ; +case 100 : +case 10 : + maccfg2 |=MACCFG2_MII ; + +/* Set R100 bit in all modes although +* it is only used in RGMII mode +*/ +if (priv->speed ==100 ) + ecntrl |=ECNTRL_R100 ; +break ; +default : +printf ("%s: Speed was bad\n" , dev->name); +break ; + } + +out_be32 (®s->ecntrl, ecntrl); +out_be32 (®s->maccfg2, maccfg2); + +printf ("Speed: %d, %s duplex%s\n" , priv->speed, + (priv->duplexity) ?"full" :"half" , + (priv->flags &TSEC_FIBER ) ?", fiber mode" :"" ); +} + +/* Set up the buffers and their descriptors, and bring up the +* interface +*/ +static void startup_tsec (struct eth_device *dev) +{ +int i; +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; + +/* Point to the buffer descriptors */ +out_be32 (®s->tbase, (unsigned int )(&rtx.txbd[txIdx])); +out_be32 (®s->rbase, (unsigned int )(&rtx.rxbd[rxIdx])); + +/* Initialize the Rx Buffer descriptors */ +for (i =0 ; i <PKTBUFSRX ; i++) { + rtx.rxbd[i].status =RXBD_EMPTY ; + rtx.rxbd[i].length =0 ; + rtx.rxbd[i].bufPtr = (uint ) NetRxPackets[i]; + } + rtx.rxbd[PKTBUFSRX -1 ].status |=RXBD_WRAP ; + +/* Initialize the TX Buffer Descriptors */ +for (i =0 ; i <TX_BUF_CNT ; i++) { + rtx.txbd[i].status =0 ; + rtx.txbd[i].length =0 ; + rtx.txbd[i].bufPtr =0 ; + } + rtx.txbd[TX_BUF_CNT -1 ].status |=TXBD_WRAP ; + +/* Start up the PHY */ +if (priv->phyinfo) +phy_run_commands (priv, priv->phyinfo->startup); + +adjust_link (dev); + +/* Enable Transmit and Receive */ +setbits_be32 (®s->maccfg1,MACCFG1_RX_EN |MACCFG1_TX_EN ); + +/* Tell the DMA it is clear to go */ +setbits_be32 (®s->dmactrl,DMACTRL_INIT_SETTINGS ); +out_be32 (®s->tstat,TSTAT_CLEAR_THALT ); +out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); +clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); +} + +/* This returns the status bits of the device. The return value +* is never checked, and this is what the 8260 driver did, so we +* do the same. Presumably, this would be zero if there were no +* errors +*/ +static int tsec_send (struct eth_device *dev,volatile void *packet,int length) +{ +int i; +int result =0 ; +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; + +/* Find an empty buffer descriptor */ +for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) { +if (i >=TOUT_LOOP ) { +debug ("%s: tsec: tx buffers full\n" , dev->name); +return result; + } + } + + rtx.txbd[txIdx].bufPtr = (uint ) packet; + rtx.txbd[txIdx].length = length; + rtx.txbd[txIdx].status |= + (TXBD_READY |TXBD_LAST |TXBD_CRC |TXBD_INTERRUPT ); + +/* Tell the DMA to go */ +out_be32 (®s->tstat,TSTAT_CLEAR_THALT ); + +/* Wait for buffer to be transmitted */ +for (i =0 ; rtx.txbd[txIdx].status &TXBD_READY ; i++) { +if (i >=TOUT_LOOP ) { +debug ("%s: tsec: tx error\n" , dev->name); +return result; + } + } + + txIdx = (txIdx +1 ) %TX_BUF_CNT ; + result = rtx.txbd[txIdx].status &TXBD_STATS ; + +return result; +} + +static int tsec_recv (struct eth_device *dev) +{ +int length; +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; + +while (!(rtx.rxbd[rxIdx].status &RXBD_EMPTY )) { + + length = rtx.rxbd[rxIdx].length; + +/* Send the packet up if there were no errors */ +if (!(rtx.rxbd[rxIdx].status &RXBD_STATS )) { +NetReceive (NetRxPackets[rxIdx], length -4 ); + }else { +printf ("Got error %x\n" , + (rtx.rxbd[rxIdx].status &RXBD_STATS )); + } + + rtx.rxbd[rxIdx].length =0 ; + +/* Set the wrap bit if this is the last element in the list */ + rtx.rxbd[rxIdx].status = +RXBD_EMPTY | (((rxIdx +1 ) ==PKTBUFSRX ) ?RXBD_WRAP :0 ); + + rxIdx = (rxIdx +1 ) %PKTBUFSRX ; + } + +if (in_be32 (®s->ievent) &IEVENT_BSY ) { +out_be32 (®s->ievent,IEVENT_BSY ); +out_be32 (®s->rstat,RSTAT_CLEAR_RHALT ); + } + +return -1 ; + +} + +/* Stop the interface */ +static void tsec_halt (struct eth_device *dev) +{ +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; + +clrbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); +setbits_be32 (®s->dmactrl,DMACTRL_GRS |DMACTRL_GTS ); + +while ((in_be32 (®s->ievent) & (IEVENT_GRSC |IEVENT_GTSC )) + != (IEVENT_GRSC |IEVENT_GTSC )) + ; + +clrbits_be32 (®s->maccfg1,MACCFG1_TX_EN |MACCFG1_RX_EN ); + +/* Shut down the PHY, as needed */ +if (priv->phyinfo) +phy_run_commands (priv, priv->phyinfo->shutdown); +} + +/* Initializes data structures and registers for the controller, +* and brings the interface up. Returns the link status, meaning +* that it returns success if the link is up, failure otherwise. +* This allows u-boot to find the first active controller. +*/ +static int tsec_init (struct eth_device *dev,bd_t * bd) +{ +uint tempval; +char tmpbuf[MAC_ADDR_LEN ]; +int i; +struct tsec_private *priv = (struct tsec_private *)dev->priv; +tsec_t *regs = priv->regs; + +/* Make sure the controller is stopped */ +tsec_halt (dev); + +/* Init MACCFG2. Defaults to GMII */ +out_be32 (®s->maccfg2,MACCFG2_INIT_SETTINGS ); + +/* Init ECNTRL */ +out_be32 (®s->ecntrl,ECNTRL_INIT_SETTINGS ); + +/* Copy the station address into the address registers. +* Backwards, because little endian MACS are dumb */ +for (i =0 ; i <MAC_ADDR_LEN ; i++) + tmpbuf[MAC_ADDR_LEN -1 - i] = dev->enetaddr[i]; + + tempval = (tmpbuf[0 ] <<24 ) | (tmpbuf[1 ] <<16 ) | (tmpbuf[2 ] <<8 ) | + tmpbuf[3 ]; + +out_be32 (®s->macstnaddr1, tempval); + + tempval = *((uint *) (tmpbuf +4 )); + +out_be32 (®s->macstnaddr2, tempval); + +/* reset the indices to zero */ + rxIdx =0 ; + txIdx =0 ; + +/* Clear out (for the most part) the other registers */ +init_registers (regs); + +/* Ready the device for tx/rx */ +startup_tsec (dev); + +/* If there's no link, fail */ +return priv->link ?0 :-1 ; +} + +/* Discover which PHY is attached to the device, and configure it +* properly. If the PHY is not recognized, then return 0 +* (failure). Otherwise, return 1 +*/ +static int init_phy (struct eth_device *dev) +{ +struct tsec_private *priv = (struct tsec_private *)dev->priv; +struct phy_info *curphy; +tsec_t *regs = priv->regs; + +/* Assign a Physical address to the TBI */ +out_be32 (®s->tbipa,CONFIG_SYS_TBIPA_VALUE ); + +/* Reset MII (due to new addresses) */ +out_be32 (&priv->phyregs->miimcfg,MIIMCFG_RESET ); +out_be32 (&priv->phyregs->miimcfg,MIIMCFG_INIT_VALUE ); +while (in_be32 (&priv->phyregs->miimind) &MIIMIND_BUSY ) + ; + +/* Get the cmd structure corresponding to the attached +* PHY */ + curphy =get_phy_info (dev); + +if (curphy ==NULL ) { + priv->phyinfo =NULL ; +printf ("%s: No PHY found\n" , dev->name); + +return 0 ; + } + +if (in_be32 (®s->ecntrl) &ECNTRL_SGMII_MODE ) +tsec_configure_serdes (priv); + + priv->phyinfo = curphy; + +phy_run_commands (priv, priv->phyinfo->config); + +return 1 ; +} + +/* Initialize device structure. Returns success if PHY +* initialization succeeded (i.e. if it recognizes the PHY) +*/ +static int tsec_initialize (bd_t *bis,struct tsec_info_struct *tsec_info) +{ +struct eth_device *dev; +int i; +struct tsec_private *priv; + + dev = (struct eth_device *)malloc (sizeof *dev); + +if (NULL == dev) +return 0 ; + +memset (dev,0 ,sizeof *dev); + + priv = (struct tsec_private *)malloc (sizeof (*priv)); + +if (NULL == priv) +return 0 ; + + privlist[num_tsecs++] = priv; + priv->regs = tsec_info->regs; + priv->phyregs = tsec_info->miiregs; + priv->phyregs_sgmii = tsec_info->miiregs_sgmii; + + priv->phyaddr = tsec_info->phyaddr; + priv->flags = tsec_info->flags; + +sprintf (dev->name, tsec_info->devname); + dev->iobase =0 ; + dev->priv = priv; + dev->init = tsec_init; + dev->halt = tsec_halt; + dev->send = tsec_send; + dev->recv = tsec_recv; +#ifdef CONFIG_MCAST_TFTP + dev->mcast = tsec_mcast_addr; +#endif + +/* Tell u-boot to get the addr from the env */ +for (i =0 ; i <6 ; i++) + dev->enetaddr[i] =0 ; + +eth_register (dev); + +/* Reset the MAC */ +setbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET ); +udelay (2 );/* Soft Reset must be asserted for 3 TX clocks */ +clrbits_be32 (&priv->regs->maccfg1,MACCFG1_SOFT_RESET ); + +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) \ + && !defined(BITBANGMII ) +miiphy_register (dev->name, tsec_miiphy_read, tsec_miiphy_write); +#endif + +/* Try to initialize PHY here, and return */ +return init_phy (dev); +} + +/* +* Initialize all the TSEC devices +* +* Returns the number of TSEC devices that were initialized +*/ +int tsec_eth_init (bd_t *bis,struct tsec_info_struct *tsecs,int num) +{ +int i; +int ret, count =0 ; + +for (i =0 ; i < num; i++) { + ret =tsec_initialize (bis, &tsecs[i]); +if (ret >0 ) + count += ret; + } + +return count; +} + +int tsec_standard_init (bd_t *bis) +{ +return tsec_eth_init (bis, tsec_info,ARRAY_SIZE (tsec_info)); +} +
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 3/9 Remove instances of phy_read/write
There were a few files which were already using phy_read and phy_write for their PHY function names. It's only a few places, and the name seems most appropriate for the high-level abstraction, so let's rename the other versions to something more specific.
Also, uec_phy.c had a marvell_init function which I renamed to not conflict with the one in marvell.c
Lastly, uec_phy.c was putting a space between the phy writing function names, and the open paren, so I fixed that
--- drivers/net/dm9000x.c | 18 +++--- drivers/net/enc28j60.c | 24 ++++---- drivers/net/uli526x.c | 24 ++++---- drivers/qe/uec.c | 3 - drivers/qe/uec_phy.c | 145 ++++++++++++++++++++++++------------------------ 5 files changed, 107 insertions(+), 107 deletions(-)
drivers/net/dm9000x.c +9 -9
@@ -110,8 +110,8 @@ static board_info_t dm9000_info;/* function declaration ------------------------------------- */ static int dm9000_probe (void ); -static u16 phy_read (int ); -static void phy_write (int ,u16 ); +static u16 dm9000_phy_read (int ); +static void dm9000_phy_write (int ,u16 );static u8 DM9000_ior (int );static void DM9000_iow (int reg,u8 value);
@@ -361,7 +361,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)DM9000_iow (DM9000_IMR ,IMR_PAR ); i =0 ; -while (!(phy_read (1 ) &0x20 )) {/* autonegation complete bit */ +while (!(dm9000_phy_read (1 ) &0x20 )) {/* autonegation complete bit */ udelay (1000 ); i++;if (i ==10000 ) {
@@ -371,7 +371,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd) }/* see what we've got */ - lnk =phy_read (17 ) >>12 ; + lnk =dm9000_phy_read (17 ) >>12 ;printf ("operating at " );switch (lnk) {case 1 :
@@ -445,7 +445,7 @@ static void dm9000_halt(struct eth_device *netdev)DM9000_DBG ("%s\n" , __func__);/* RESET devie */ -phy_write (0 ,0x8000 );/* PHY RESET */ +dm9000_phy_write (0 ,0x8000 );/* PHY RESET */ DM9000_iow (DM9000_GPR ,0x01 );/* Power-Down PHY */ DM9000_iow (DM9000_IMR ,0x80 );/* Disable all interrupt */ DM9000_iow (DM9000_RCR ,0x00 );/* Disable RX */
@@ -581,7 +581,7 @@ DM9000_iow(int reg, u8 value)Read a word from phyxcer */ static u16 -phy_read (int reg) +dm9000_phy_read (int reg) {u16 val;
@@ -593,7 +593,7 @@ phy_read(int reg) val = (DM9000_ior (DM9000_EPDRH ) <<8 ) |DM9000_ior (DM9000_EPDRL );/* The read data keeps on REG_0D & REG_0E */ -DM9000_DBG ("phy_read(0x%x): 0x%x\n" , reg, val); +DM9000_DBG ("dm9000_phy_read(0x%x): 0x%x\n" , reg, val);return val; }
@@ -601,7 +601,7 @@ phy_read(int reg)Write a word to phyxcer */ static void -phy_write (int reg,u16 value) +dm9000_phy_write (int reg,u16 value) {/* Fill the phyxcer register into REG_0C */
@@ -613,7 +613,7 @@ phy_write(int reg, u16 value)DM9000_iow (DM9000_EPCR ,0xa );/* Issue phyxcer write command */ udelay (500 );/* Wait write complete */ DM9000_iow (DM9000_EPCR ,0x0 );/* Clear phyxcer write command */ -DM9000_DBG ("phy_write(reg:0x%x, value:0x%x)\n" , reg, value); +DM9000_DBG ("dm9000_phy_write(reg:0x%x, value:0x%x)\n" , reg, value); }int dm9000_initialize (bd_t *bis)
drivers/net/enc28j60.c +12 -12
@@ -314,7 +314,7 @@ static void enc_release_bus(enc_dev_t *enc)/* * Read PHY register */ -static u16 phy_read (enc_dev_t *enc,const u8 addr) +static u16 enc_phy_read (enc_dev_t *enc,const u8 addr) {uint64_t etime;u8 status;
@@ -339,7 +339,7 @@ static u16 phy_read(enc_dev_t *enc, const u8 addr)/* * Write PHY register */ -static void phy_write (enc_dev_t *enc,const u8 addr,const u16 data) +static void enc_phy_write (enc_dev_t *enc,const u8 addr,const u16 data) {uint64_t etime;u8 status;
@@ -374,7 +374,7 @@ static int enc_phy_link_wait(enc_dev_t *enc)#ifdef CONFIG_ENC_SILENTLINK /* check if we have a link, then just return */ - status =phy_read (enc,PHY_REG_PHSTAT1 ); + status =enc_phy_read (enc,PHY_REG_PHSTAT1 );if (status &ENC_PHSTAT1_LLSTAT )return 0 ;#endif
@@ -382,10 +382,10 @@ static int enc_phy_link_wait(enc_dev_t *enc)/* wait for link with 1 second timeout */ etime =get_ticks () +get_tbclk ();while (get_ticks () <= etime) { - status =phy_read (enc,PHY_REG_PHSTAT1 ); + status =enc_phy_read (enc,PHY_REG_PHSTAT1 );if (status &ENC_PHSTAT1_LLSTAT ) {/* now we have a link */ - status =phy_read (enc,PHY_REG_PHSTAT2 ); + status =enc_phy_read (enc,PHY_REG_PHSTAT2 ); duplex = (status &ENC_PHSTAT2_DPXSTAT ) ?1 :0 ;printf ("%s: link up, 10Mbps %s-duplex\n" , enc->dev->name, duplex ?"full" :"half" );
@@ -678,8 +678,8 @@ static int enc_setup(enc_dev_t *enc) enc->bank =0xff ;/* invalidate current bank in enc28j60 */ /* verify PHY identification */ - phid1 =phy_read (enc,PHY_REG_PHID1 ); - phid2 =phy_read (enc,PHY_REG_PHID2 ) &ENC_PHID2_MASK ; + phid1 =enc_phy_read (enc,PHY_REG_PHID1 ); + phid2 =enc_phy_read (enc,PHY_REG_PHID2 ) &ENC_PHID2_MASK ;if (phid1 !=ENC_PHID1_VALUE || phid2 !=ENC_PHID2_VALUE ) {printf ("%s: failed to identify PHY. Found %04x:%04x\n" , enc->dev->name, phid1, phid2);
@@ -694,7 +694,7 @@ static int enc_setup(enc_dev_t *enc)* Prevent automatic loopback of data beeing transmitted by setting * ENC_PHCON2_HDLDIS */ -phy_write (enc,PHY_REG_PHCON2 , (1 <<8 )); +enc_phy_write (enc,PHY_REG_PHCON2 , (1 <<8 ));/* * LEDs configuration
@@ -702,10 +702,10 @@ static int enc_setup(enc_dev_t *enc)* LEDB: LBCFG = 0111 -> display TX & RX activity * STRCH = 1 -> LED pulses */ -phy_write (enc,PHY_REG_PHLCON ,0x0472 ); +enc_phy_write (enc,PHY_REG_PHLCON ,0x0472 );/* Reset PDPXMD-bit => half duplex */ -phy_write (enc,PHY_REG_PHCON1 ,0 ); +enc_phy_write (enc,PHY_REG_PHCON1 ,0 );#ifdef CONFIG_USE_IRQ /* enable interrupts */
@@ -771,7 +771,7 @@ int enc_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)enc_release_bus (enc);return -1 ; } - *value =phy_read (enc, reg); + *value =enc_phy_read (enc, reg);enc_release_bus (enc);return 0 ; }
@@ -796,7 +796,7 @@ int enc_miiphy_write(const char *devname, u8 phy_adr, u8 reg, u16 value)enc_release_bus (enc);return -1 ; } -phy_write (enc, reg, value); +enc_phy_write (enc, reg, value);enc_release_bus (enc);return 0 ; }
drivers/net/uli526x.c +13 -11
@@ -175,9 +175,9 @@ static u16 read_srom_word(long, int);static void uli526x_descriptor_init (struct uli526x_board_info *,unsigned long );static void allocate_rx_buffer (struct uli526x_board_info *);static void update_cr6 (u32 ,unsigned long ); -static u16 phy_read (unsigned long ,u8 ,u8 ,u32 ); +static u16 uli_phy_read (unsigned long ,u8 ,u8 ,u32 );static u16 phy_readby_cr10 (unsigned long ,u8 ,u8 ); -static void phy_write (unsigned long ,u8 ,u8 ,u16 ,u32 ); +static void uli_phy_write (unsigned long ,u8 ,u8 ,u16 ,u32 );static void phy_writeby_cr10 (unsigned long ,u8 ,u8 ,u16 );static void phy_write_1bit (unsigned long ,u32 ,u32 );static u16 phy_read_1bit (unsigned long ,u32 );
@@ -349,7 +349,7 @@ static void uli526x_disable(struct eth_device *dev)/* Reset & stop ULI526X board */ outl (ULI526X_RESET , db->ioaddr +DCR0 );udelay (5 ); -phy_write (db->ioaddr, db->phy_addr,0 ,0x8000 , db->chip_id); +uli_phy_write (db->ioaddr, db->phy_addr,0 ,0x8000 , db->chip_id);/* reset the board */ db->cr6_data &= ~(CR6_RXSC |CR6_TXSC );/* Disable Tx/Rx */
@@ -385,7 +385,7 @@ static void uli526x_init(struct eth_device *dev) db->tx_packet_cnt =0 ;for (phy_tmp =0 ; phy_tmp <32 ; phy_tmp++) {/* peer add */ - phy_value =phy_read (db->ioaddr, phy_tmp,3 , db->chip_id); + phy_value =uli_phy_read (db->ioaddr, phy_tmp,3 , db->chip_id);if (phy_value !=0xffff && phy_value !=0 ) { db->phy_addr = phy_tmp;break ;
@@ -404,10 +404,10 @@ static void uli526x_init(struct eth_device *dev)if (!(inl (db->ioaddr +DCR12 ) &0x8 )) {/* Phyxcer capability setting */ - phy_reg_reset =phy_read (db->ioaddr, + phy_reg_reset =uli_phy_read (db->ioaddr, db->phy_addr,0 , db->chip_id); phy_reg_reset = (phy_reg_reset |0x8000 ); -phy_write (db->ioaddr, db->phy_addr,0 , +uli_phy_write (db->ioaddr, db->phy_addr,0 , phy_reg_reset, db->chip_id);udelay (500 );
@@ -781,7 +781,8 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db)u16 phy_reg;/* Phyxcer capability setting */ - phy_reg =phy_read (db->ioaddr, db->phy_addr,4 , db->chip_id) & ~0x01e0 ; + phy_reg =uli_phy_read (db->ioaddr, + db->phy_addr,4 , db->chip_id) & ~0x01e0 ;if (db->media_mode &ULI526X_AUTO ) {/* AUTO Mode */
@@ -802,10 +803,10 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db) phy_reg |= db->PHY_reg4; db->media_mode |=ULI526X_AUTO ; } -phy_write (db->ioaddr, db->phy_addr,4 , phy_reg, db->chip_id); +uli_phy_write (db->ioaddr, db->phy_addr,4 , phy_reg, db->chip_id);/* Restart Auto-Negotiation */ -phy_write (db->ioaddr, db->phy_addr,0 ,0x1200 , db->chip_id); +uli_phy_write (db->ioaddr, db->phy_addr,0 ,0x1200 , db->chip_id);udelay (50 ); }
@@ -813,7 +814,7 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db)* Write a word to Phy register */ -static void phy_write (unsigned long iobase,u8 phy_addr,u8 offset, +static void uli_phy_write (unsigned long iobase,u8 phy_addr,u8 offset,u16 phy_data,u32 chip_id) {u16 i;
@@ -862,7 +863,8 @@ static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset,* Read a word data from phy register */ -static u16 phy_read (unsigned long iobase,u8 phy_addr,u8 offset,u32 chip_id) +static u16 uli_phy_read (unsigned long iobase,u8 phy_addr,u8 offset, +u32 chip_id) {int i;u16 phy_data;
drivers/qe/uec.c +0 -3
@@ -67,9 +67,6 @@ static uec_info_t uec_info[] = {static struct eth_device *devlist[MAXCONTROLLERS ]; -u16 phy_read (struct uec_mii_info *mii_info,u16 regnum); -void phy_write (struct uec_mii_info *mii_info,u16 regnum,u16 val); -static int uec_mac_enable (uec_private_t *uec,comm_dir_e mode) {uec_t *uec_regs;
drivers/qe/uec_phy.c +73 -72
360 lines not on this page · raw message
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 4/9 miiphy: Fix some formatting issues
Mostly putting a space between function name and "(", and doing return (foo)
---
v3: split off from the phylib changes to miiphyutil.c and miiphy.h
common/miiphyutil.c | 144 +++++++++++++++++++++++++------------------------- include/miiphy.h | 36 ++++++------ 2 files changed, 90 insertions(+), 90 deletions(-)
common/miiphyutil.c +72 -72
@@ -39,17 +39,17 @@#undef debug#ifdef MII_DEBUG -#define debug(fmt,args...) printf (fmt ,##args) +#define debug(fmt, args...) printf(fmt, ##args)#else -#define debug(fmt,args...) +#define debug(fmt, args...)#endif /* MII_DEBUG */ struct mii_dev {struct list_head link;const char *name; -int (*read) (const char *devname,unsigned char addr, +int (*read)(const char *devname,unsigned char addr,unsigned char reg,unsigned short *value); -int (*write) (const char *devname,unsigned char addr, +int (*write)(const char *devname,unsigned char addr,unsigned char reg,unsigned short value); };
@@ -86,7 +86,7 @@ static struct mii_dev *miiphy_get_dev_by_name(const char *devname, int quiet)*/ void miiphy_init (void ) { -INIT_LIST_HEAD (&mii_devs); +INIT_LIST_HEAD (&mii_devs); current_mii =NULL ; }
@@ -95,9 +95,9 @@ void miiphy_init(void)* Register read and write MII access routines for the device <name>. */ void miiphy_register (const char *name, -int (*read) (const char *devname,unsigned char addr, +int (*read)(const char *devname,unsigned char addr,unsigned char reg,unsigned short *value), -int (*write) (const char *devname,unsigned char addr, +int (*write)(const char *devname,unsigned char addr,unsigned char reg,unsigned short value)) {struct mii_dev *new_dev;
@@ -112,30 +112,30 @@ void miiphy_register(const char *name, }/* allocate memory */ - name_len =strlen (name); + name_len =strlen (name); new_dev = - (struct mii_dev *)malloc (sizeof (struct mii_dev ) + name_len +1 ); + (struct mii_dev *)malloc (sizeof (struct mii_dev ) + name_len +1 );if (new_dev ==NULL ) { -printf ("miiphy_register: cannot allocate memory for '%s'\n" , +printf ("miiphy_register: cannot allocate memory for '%s'\n" , name);return ; } -memset (new_dev,0 ,sizeof (struct mii_dev ) + name_len); +memset (new_dev,0 ,sizeof (struct mii_dev ) + name_len);/* initalize mii_dev struct fields */ -INIT_LIST_HEAD (&new_dev->link); +INIT_LIST_HEAD (&new_dev->link); new_dev->read = read; new_dev->write = write; new_dev->name = new_name = (char *)(new_dev +1 ); -strncpy (new_name, name, name_len); +strncpy (new_name, name, name_len); new_name[name_len] ='\0' ; -debug ("miiphy_register: added '%s', read=0x%08lx, write=0x%08lx\n" , +debug ("miiphy_register: added '%s', read=0x%08lx, write=0x%08lx\n" , new_dev->name, new_dev->read, new_dev->write);/* add it to the list */ -list_add_tail (&new_dev->link, &mii_devs); +list_add_tail (&new_dev->link, &mii_devs);if (!current_mii) current_mii = new_dev;
@@ -220,20 +220,20 @@ int miiphy_write(const char *devname, unsigned char addr, unsigned char reg,* * Print out list of registered MII capable devices. */ -void miiphy_listdev (void ) +void miiphy_listdev (void ) {struct list_head *entry;struct mii_dev *dev; -puts ("MII devices: " ); - list_for_each (entry, &mii_devs) { - dev = list_entry (entry, struct mii_dev, link); -printf ("'%s' " , dev->name); +puts ("MII devices: " ); +list_for_each (entry, &mii_devs) { + dev = list_entry(entry, struct mii_dev, link); +printf ("'%s' " , dev->name); } -puts ("\n" ); +puts ("\n" );if (current_mii) -printf ("Current device: '%s'\n" , current_mii->name); +printf ("Current device: '%s'\n" , current_mii->name); }/*****************************************************************************
@@ -253,30 +253,30 @@ int miiphy_info(const char *devname, unsigned char addr, unsigned int *oui,unsigned int reg =0 ;unsigned short tmp; -if (miiphy_read (devname, addr,MII_PHYSID2 , &tmp) !=0 ) { -debug ("PHY ID register 2 read failed\n" ); -return (-1 ); +if (miiphy_read (devname, addr,MII_PHYSID2 , &tmp) !=0 ) { +debug ("PHY ID register 2 read failed\n" ); +return -1 ; } reg = tmp; -debug ("MII_PHYSID2 @ 0x%x = 0x%04x\n" , addr, reg); +debug ("MII_PHYSID2 @ 0x%x = 0x%04x\n" , addr, reg);if (reg ==0xFFFF ) {/* No physical device present at this address */ -return (-1 ); +return -1 ; } -if (miiphy_read (devname, addr,MII_PHYSID1 , &tmp) !=0 ) { -debug ("PHY ID register 1 read failed\n" ); -return (-1 ); +if (miiphy_read (devname, addr,MII_PHYSID1 , &tmp) !=0 ) { +debug ("PHY ID register 1 read failed\n" ); +return -1 ; } reg |= tmp <<16 ; -debug ("PHY_PHYIDR[1,2] @ 0x%x = 0x%08x\n" , addr, reg); +debug ("PHY_PHYIDR[1,2] @ 0x%x = 0x%08x\n" , addr, reg); *oui = (reg >>10 ); *model = (unsigned char )((reg >>4 ) &0x0000003F ); *rev = (unsigned char )(reg &0x0000000F ); -return (0 ); +return 0 ; }/*****************************************************************************
@@ -290,16 +290,16 @@ int miiphy_reset(const char *devname, unsigned char addr)unsigned short reg;int timeout =500 ; -if (miiphy_read (devname, addr,MII_BMCR , ®) !=0 ) { -debug ("PHY status read failed\n" ); -return (-1 ); +if (miiphy_read (devname, addr,MII_BMCR , ®) !=0 ) { +debug ("PHY status read failed\n" ); +return -1 ; } -if (miiphy_write (devname, addr,MII_BMCR , reg |BMCR_RESET ) !=0 ) { -debug ("PHY reset failed\n" ); -return (-1 ); +if (miiphy_write (devname, addr,MII_BMCR , reg |BMCR_RESET ) !=0 ) { +debug ("PHY reset failed\n" ); +return -1 ; }#ifdef CONFIG_PHY_RESET_DELAY -udelay (CONFIG_PHY_RESET_DELAY );/* Intel LXT971A needs this */ +udelay (CONFIG_PHY_RESET_DELAY );/* Intel LXT971A needs this */ #endif /* * Poll the control register for the reset bit to go to 0 (it is
@@ -315,12 +315,12 @@ int miiphy_reset(const char *devname, unsigned char addr)udelay (1000 ); }if ((reg &0x8000 ) ==0 ) { -return (0 ); +return 0 ; }else { -puts ("PHY reset timed out\n" ); -return (-1 ); +puts ("PHY reset timed out\n" ); +return -1 ; } -return (0 ); +return 0 ; }/*****************************************************************************
@@ -338,33 +338,33 @@ int miiphy_speed(const char *devname, unsigned char addr)* Check for 1000BASE-X. If it is supported, then assume that the speed * is 1000. */ -if (miiphy_is_1000base_x (devname, addr)) { +if (miiphy_is_1000base_x (devname, addr))return _1000BASET; - } +/* * No 1000BASE-X, so assume 1000BASE-T/100BASE-TX/10BASE-T register set. */ /* Check for 1000BASE-T. */ -if (miiphy_read (devname, addr,MII_STAT1000 , &btsr)) { -printf ("PHY 1000BT status" ); +if (miiphy_read (devname, addr,MII_STAT1000 , &btsr)) { +printf ("PHY 1000BT status" ); goto miiphy_read_failed; }if (btsr !=0xFFFF && - (btsr & (PHY_1000BTSR_1000FD |PHY_1000BTSR_1000HD ))) { + (btsr & (PHY_1000BTSR_1000FD |PHY_1000BTSR_1000HD )))return _1000BASET; - } +#endif /* CONFIG_PHY_GIGE */ /* Check Basic Management Control Register first. */ -if (miiphy_read (devname, addr,MII_BMCR , &bmcr)) { -printf ("PHY speed" ); +if (miiphy_read (devname, addr,MII_BMCR , &bmcr)) { +printf ("PHY speed" ); goto miiphy_read_failed; }/* Check if auto-negotiation is on. */ if (bmcr &BMCR_ANENABLE ) {/* Get auto-negotiation results. */ -if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { -printf ("PHY AN speed" ); +if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { +printf ("PHY AN speed" ); goto miiphy_read_failed; }return (anlpar &LPA_100 ) ? _100BASET : _10BASET;
@@ -373,7 +373,7 @@ int miiphy_speed(const char *devname, unsigned char addr)return (bmcr &BMCR_SPEED100 ) ? _100BASET : _10BASET; miiphy_read_failed: -printf (" read failed, assuming 10BASE-T\n" ); +printf (" read failed, assuming 10BASE-T\n" );return _10BASET; }
@@ -389,10 +389,10 @@ int miiphy_duplex(const char *devname, unsigned char addr)u16 btsr;/* Check for 1000BASE-X. */ -if (miiphy_is_1000base_x (devname, addr)) { +if (miiphy_is_1000base_x (devname, addr)) {/* 1000BASE-X */ -if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { -printf ("1000BASE-X PHY AN duplex" ); +if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { +printf ("1000BASE-X PHY AN duplex" ); goto miiphy_read_failed; } }
@@ -400,8 +400,8 @@ int miiphy_duplex(const char *devname, unsigned char addr)* No 1000BASE-X, so assume 1000BASE-T/100BASE-TX/10BASE-T register set. */ /* Check for 1000BASE-T. */ -if (miiphy_read (devname, addr,MII_STAT1000 , &btsr)) { -printf ("PHY 1000BT status" ); +if (miiphy_read (devname, addr,MII_STAT1000 , &btsr)) { +printf ("PHY 1000BT status" ); goto miiphy_read_failed; }if (btsr !=0xFFFF ) {
@@ -414,15 +414,15 @@ int miiphy_duplex(const char *devname, unsigned char addr)#endif /* CONFIG_PHY_GIGE */ /* Check Basic Management Control Register first. */ -if (miiphy_read (devname, addr,MII_BMCR , &bmcr)) { -puts ("PHY duplex" ); +if (miiphy_read (devname, addr,MII_BMCR , &bmcr)) { +puts ("PHY duplex" ); goto miiphy_read_failed; }/* Check if auto-negotiation is on. */ if (bmcr &BMCR_ANENABLE ) {/* Get auto-negotiation results. */ -if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { -puts ("PHY AN duplex" ); +if (miiphy_read (devname, addr,MII_LPA , &anlpar)) { +puts ("PHY AN duplex" ); goto miiphy_read_failed; } return (anlpar & (LPA_10FULL | LPA_100FULL)) ?
@@ -432,7 +432,7 @@ int miiphy_duplex(const char *devname, unsigned char addr)return (bmcr &BMCR_FULLDPLX ) ?FULL :HALF ; miiphy_read_failed: -printf (" read failed, assuming half duplex\n" ); +printf (" read failed, assuming half duplex\n" );return HALF ; }
@@ -446,8 +446,8 @@ int miiphy_is_1000base_x(const char *devname, unsigned char addr)#if defined(CONFIG_PHY_GIGE )u16 exsr; -if (miiphy_read (devname, addr,MII_ESTATUS , &exsr)) { -printf ("PHY extended status read failed, assuming no " +if (miiphy_read (devname, addr,MII_ESTATUS , &exsr)) { +printf ("PHY extended status read failed, assuming no " "1000BASE-X\n" );return 0 ; }
@@ -467,17 +467,17 @@ int miiphy_link(const char *devname, unsigned char addr)unsigned short reg;/* dummy read; needed to latch some phys */ - (void )miiphy_read (devname, addr,MII_BMSR , ®); -if (miiphy_read (devname, addr,MII_BMSR , ®)) { -puts ("MII_BMSR read failed, assuming no link\n" ); -return (0 ); + (void )miiphy_read (devname, addr,MII_BMSR , ®); +if (miiphy_read (devname, addr,MII_BMSR , ®)) { +puts ("MII_BMSR read failed, assuming no link\n" ); +return 0 ; }/* Determine if a link is active */ if ((reg &BMSR_LSTATUS ) !=0 ) { -return (1 ); +return 1 ; }else { -return (0 ); +return 0 ; } }#endif
include/miiphy.h +18 -18
@@ -37,32 +37,32 @@#include <linux/mii.h> #include <net.h> -int miiphy_read (const char *devname,unsigned char addr,unsigned char reg, +int miiphy_read (const char *devname,unsigned char addr,unsigned char reg,unsigned short *value); -int miiphy_write (const char *devname,unsigned char addr,unsigned char reg, +int miiphy_write (const char *devname,unsigned char addr,unsigned char reg,unsigned short value); -int miiphy_info (const char *devname,unsigned char addr,unsigned int *oui, +int miiphy_info (const char *devname,unsigned char addr,unsigned int *oui,unsigned char *model,unsigned char *rev); -int miiphy_reset (const char *devname,unsigned char addr); -int miiphy_speed (const char *devname,unsigned char addr); -int miiphy_duplex (const char *devname,unsigned char addr); -int miiphy_is_1000base_x (const char *devname,unsigned char addr); +int miiphy_reset (const char *devname,unsigned char addr); +int miiphy_speed (const char *devname,unsigned char addr); +int miiphy_duplex (const char *devname,unsigned char addr); +int miiphy_is_1000base_x (const char *devname,unsigned char addr);#ifdef CONFIG_SYS_FAULT_ECHO_LINK_DOWN -int miiphy_link (const char *devname,unsigned char addr); +int miiphy_link (const char *devname,unsigned char addr);#endif -void miiphy_init (void ); +void miiphy_init (void ); -void miiphy_register (const char *devname, -int (*read) (const char *devname,unsigned char addr, +void miiphy_register (const char *devname, +int (*read)(const char *devname,unsigned char addr,unsigned char reg,unsigned short *value), -int (*write) (const char *devname,unsigned char addr, +int (*write)(const char *devname,unsigned char addr,unsigned char reg,unsigned short value)); -int miiphy_set_current_dev (const char *devname); -const char *miiphy_get_current_dev (void ); +int miiphy_set_current_dev (const char *devname); +const char *miiphy_get_current_dev (void ); -void miiphy_listdev (void ); +void miiphy_listdev (void );#ifdef CONFIG_BITBANGMII
@@ -85,10 +85,10 @@ struct bb_miiphy_bus {extern struct bb_miiphy_bus bb_miiphy_buses[];extern int bb_miiphy_buses_num; -void bb_miiphy_init (void ); -int bb_miiphy_read (const char *devname,unsigned char addr, +void bb_miiphy_init (void ); +int bb_miiphy_read (const char *devname,unsigned char addr,unsigned char reg,unsigned short *value); -int bb_miiphy_write (const char *devname,unsigned char addr, +int bb_miiphy_write (const char *devname,unsigned char addr,unsigned char reg,unsigned short value);#endif
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 5/9 Create PHY Lib for U-Boot
Extends the mii_dev structure to participate in a full-blown MDIO and PHY driver scheme. The mii_dev structure and miiphy calls are modified in such a way to allow the original mii command and miiphy infrastructure to work as before, but also to support a new set of APIs which allow (among other things) sharing of PHY driver code and 10G support
The mii command will continue to support normal PHY management functions (Clause 22 of 802.3), but will not be changed to support 10G (Clause 45).
The basic design is similar to PHY Lib from Linux, but simplified for U-Boot's network and driver infrastructure.
We now have MDIO drivers and PHY drivers
An MDIO driver provides:
read
write
reset
A PHY driver provides:
(optionally): probe
config - initial setup, starting of auto-negotiation startup - waiting for AN, and reading link state shutdown - any cleanup needed
The ethernet drivers interact with the PHY Lib using these functions:phy_connect()phy_config()phy_startup()phy_shutdown()
Each PHY driver can be configured separately, or all at once using config_phylib_all_drivers.h (added in the patch which adds the drivers)
We also provide generic drivers for Clause 22 (10/100/1000), and Clause 45 (10G) PHYs.
We also implement phy_reset(), and call it in phy_connect(). Because phy_reset() is essentially the same as miiphy_reset, but:
a) must support 10G PHYs, and
b) should use the phylib primitives,
we implement miiphy_reset, using phy_reset(), but only when CONFIG_PHYLIB is set. Otherwise, we just use the old version. In this way, we save on compile size, even if we don't manage to save code size.
Pulled ethtool.h and mdio.h from:git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6782d640afd15af7a1faf01cfe566ca4ac511319d
With many, many deletions so as to enable compilation under u-boot
---
v5:
* Add phy_reset(), and modify miiphy_reset() when using PHYLIB
* Add a function to return a string to describe an interface type
* Modify 10G drivers to specify mmds in the driver definition
* Reset all PHYs in phy_connect()
* Add a 15ms wait for the PHY to come out of POR
v4:
* Grabbed newer version of ethtool.h and mdio.h
* Added attribution for those new versions
* Still cleaned up for compilation issues
v3:
* Made mii_dev->name an array, and added a warning for if someone ever tries to register a bus with more than 32 characters
* Fixed some minor formatting issues
* Changed phy_read and phy_write to be inline functions in phy.h
* Moved mii_dev definition to phy.h (necessary for phy_read/phy_write)
* Split out 10G support so it's only built if CONFIG_PHYLIB_10G is defined
* Removed constants stolen from linux, and added linux/mdio.h and linux/ethtool.h
* Tweaked a number of things in those headers to get things to compile
* Statically initialize the phy_drivers list_head
v2:
* Fixed some sparse warnings/errors
* Changed headers for new files to GPL v2+
* Removed the unexplained 500ms delay after autonegotiation
common/Makefile | 1 + common/miiphyutil.c | 181 ++++++++-- drivers/net/phy/Makefile | 2 + drivers/net/phy/generic_10g.c | 105 ++++++ drivers/net/phy/phy.c | 722 +++++++++++++++++++++++++++++++++++++++++ include/linux/ethtool.h | 721 ++++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 278 ++++++++++++++++ include/miiphy.h | 17 + include/phy.h | 219 +++++++++++++ net/eth.c | 6 + 10 files changed, 2216 insertions(+), 36 deletions(-) create mode 100644 drivers/net/phy/generic_10g.c create mode 100644 drivers/net/phy/phy.c create mode 100644 include/linux/ethtool.h create mode 100644 include/linux/mdio.h create mode 100644 include/phy.h
common/Makefile +1 -0
@@ -115,6 +115,7 @@ COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_CMD_MG_DISK) += cmd_mgdisk.o COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o +COBJS-$(CONFIG_PHYLIB) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += cmd_mii.o COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
common/miiphyutil.c +145 -36
286 lines not on this page · raw message
drivers/net/phy/Makefile +2 -0
@@ -27,6 +27,8 @@ LIB := $(obj)libphy.o COBJS-$(CONFIG_BITBANGMII) += miiphybb.o COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o +COBJS-$(CONFIG_PHYLIB) += phy.o +COBJS-$(CONFIG_PHYLIB_10G) += generic_10g.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/net/phy/generic_10g.c new file +105 -0
105 lines not on this page · raw message
drivers/net/phy/phy.c new file +722 -0
722 lines not on this page · raw message
include/linux/ethtool.h new file +721 -0
721 lines not on this page · raw message
include/linux/mdio.h new file +278 -0
278 lines not on this page · raw message
include/miiphy.h +17 -0
@@ -34,8 +34,18 @@#ifndef _miiphy_h_#define _miiphy_h_ +#include <common.h> #include <linux/mii.h> +#include <linux/list.h> #include <net.h> +#include <phy.h> + +struct legacy_mii_dev { +int (*read)(const char *devname,unsigned char addr, +unsigned char reg,unsigned short *value); +int (*write)(const char *devname,unsigned char addr, +unsigned char reg,unsigned short value); +};int miiphy_read (const char *devname,unsigned char addr,unsigned char reg,unsigned short *value);
@@ -61,9 +71,16 @@ void miiphy_register(const char *devname,int miiphy_set_current_dev (const char *devname);const char *miiphy_get_current_dev (void ); +struct mii_dev *mdio_get_current_dev (void ); +struct mii_dev *miiphy_get_dev_by_name (const char *devname); +struct phy_device *mdio_phydev_for_ethname (const char *devname);void miiphy_listdev (void ); +struct mii_dev *mdio_alloc (void ); +int mdio_register (struct mii_dev *bus); +void mdio_list_devices (void ); +#ifdef CONFIG_BITBANGMII #define BB_MII_DEVNAME "bb_miiphy"
include/phy.h new file +219 -0
219 lines not on this page · raw message
net/eth.c +6 -0
@@ -25,6 +25,7 @@#include <command.h> #include <net.h> #include <miiphy.h> +#include <phy.h> void eth_parse_enetaddr (const char *addr,uchar *enetaddr) {
@@ -217,6 +218,11 @@ int eth_initialize(bd_t *bis)#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_init ();#endif + +#ifdef CONFIG_PHYLIB +phy_init (); +#endif +/* * If board-specific initialization exists, call it. * If not, call a CPU-specific one
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 6/9 phylib: Add a bunch of PHY drivers from tsec
The tsec driver had a bunch of PHY drivers already written. This converts them all into PHY Lib drivers, and serves as the first set of PHY drivers for PHY Lib.
While doing that, cleaned up a number of magic numbers (though not all of them, as PHY vendors like to keep their numbers as magical as possible). Also, noticed that almost all of the vitesse/cicada PHYs had the same config/parse/startup functions, so those have been collapsed into one.
---
v5:
* Fix Marvell PHY drivers so they reset after a reconfig
* Modify Teranetics driver to use more constants and specify mmds in the driver definition
v3:
* Add phy_ prefix to PHY driver init functions
* Rename phylib_all_drivers.h to config_phylib_all_drivers.h
* Make some minor changes to support 10G under the new divided paradigm
v2:
* Added teranetics_init() to init function
* Sorted init functions in phy_init and in phy.h
* Sorted PHYs in drivers/net/phy/Makefile
* GPL v2+ on all new files
* Left the 500ms delay after autonegotiation for PHY drivers that had it, as I don't want to break the driver-specific functionality. I suspect that either we've already fixed the bug this was really working around, or we will need a bug fix in the generic code. Either way, this code doesn't change the previous behavior, and can always be fixed at a later date, when one of us has time to actually test it out.
* Added many constants and consolidated the vitesse functions
drivers/net/phy/Makefile | 11 + drivers/net/phy/atheros.c | 48 +++++ drivers/net/phy/broadcom.c | 286 +++++++++++++++++++++++++++ drivers/net/phy/davicom.c | 98 ++++++++++ drivers/net/phy/lxt.c | 87 ++++++++ drivers/net/phy/marvell.c | 367 +++++++++++++++++++++++++++++++++++ drivers/net/phy/micrel.c | 40 ++++ drivers/net/phy/natsemi.c | 96 +++++++++ drivers/net/phy/phy.c | 31 +++ drivers/net/phy/realtek.c | 130 ++++++++++++ drivers/net/phy/teranetics.c | 62 ++++++ drivers/net/phy/vitesse.c | 242 +++++++++++++++++++++++ include/config_phylib_all_drivers.h | 32 +++ include/phy.h | 10 + 14 files changed, 1540 insertions(+), 0 deletions(-) create mode 100644 drivers/net/phy/atheros.c create mode 100644 drivers/net/phy/broadcom.c create mode 100644 drivers/net/phy/davicom.c create mode 100644 drivers/net/phy/lxt.c create mode 100644 drivers/net/phy/marvell.c create mode 100644 drivers/net/phy/micrel.c create mode 100644 drivers/net/phy/natsemi.c create mode 100644 drivers/net/phy/realtek.c create mode 100644 drivers/net/phy/teranetics.c create mode 100644 drivers/net/phy/vitesse.c create mode 100644 include/config_phylib_all_drivers.h
drivers/net/phy/Makefile +11 -0
@@ -27,8 +27,19 @@ LIB := $(obj)libphy.o COBJS-$(CONFIG_BITBANGMII) += miiphybb.o COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o + COBJS-$(CONFIG_PHYLIB) += phy.o COBJS-$(CONFIG_PHYLIB_10G) += generic_10g.o +COBJS-$(CONFIG_PHY_ATHEROS) += atheros.o +COBJS-$(CONFIG_PHY_BROADCOM) += broadcom.o +COBJS-$(CONFIG_PHY_DAVICOM) += davicom.o +COBJS-$(CONFIG_PHY_LXT) += lxt.o +COBJS-$(CONFIG_PHY_MARVELL) += marvell.o +COBJS-$(CONFIG_PHY_MICREL) += micrel.o +COBJS-$(CONFIG_PHY_NATSEMI) += natsemi.o +COBJS-$(CONFIG_PHY_REALTEK) += realtek.o +COBJS-$(CONFIG_PHY_TERANETICS) += teranetics.o +COBJS-$(CONFIG_PHY_VITESSE) += vitesse.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/net/phy/atheros.c new file +48 -0
48 lines not on this page · raw message
drivers/net/phy/broadcom.c new file +286 -0
286 lines not on this page · raw message
drivers/net/phy/davicom.c new file +98 -0
98 lines not on this page · raw message
drivers/net/phy/lxt.c new file +87 -0
87 lines not on this page · raw message
drivers/net/phy/marvell.c new file +367 -0
367 lines not on this page · raw message
drivers/net/phy/micrel.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Micrel PHY drivers +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +* Copyright 2010-2011 Freescale Semiconductor, Inc. +* author Andy Fleming +* +*/ +#include <phy.h> + +static struct phy_driver KSZ804_driver = { + .name ="Micrel KSZ804" , + .uid =0x221510 , + .mask =0xfffff0 , + .features =PHY_BASIC_FEATURES , + .config = &genphy_config, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; + +int phy_micrel_init (void ) +{ +phy_register (&KSZ804_driver); + +return 0 ; +}
drivers/net/phy/natsemi.c new file +96 -0
96 lines not on this page · raw message
drivers/net/phy/phy.c +31 -0
@@ -420,6 +420,37 @@ static LIST_HEAD(phy_drivers);int phy_init (void ) { +#ifdef CONFIG_PHY_ATHEROS +phy_atheros_init (); +#endif +#ifdef CONFIG_PHY_BROADCOM +phy_broadcom_init (); +#endif +#ifdef CONFIG_PHY_DAVICOM +phy_davicom_init (); +#endif +#ifdef CONFIG_PHY_LXT +phy_lxt_init (); +#endif +#ifdef CONFIG_PHY_MARVELL +phy_marvell_init (); +#endif +#ifdef CONFIG_PHY_MICREL +phy_micrel_init (); +#endif +#ifdef CONFIG_PHY_NATSEMI +phy_natsemi_init (); +#endif +#ifdef CONFIG_PHY_REALTEK +phy_realtek_init (); +#endif +#ifdef CONFIG_PHY_TERANETICS +phy_teranetics_init (); +#endif +#ifdef CONFIG_PHY_VITESSE +phy_vitesse_init (); +#endif +return 0 ; }
drivers/net/phy/realtek.c new file +130 -0
130 lines not on this page · raw message
drivers/net/phy/teranetics.c new file +62 -0
62 lines not on this page · raw message
drivers/net/phy/vitesse.c new file +242 -0
242 lines not on this page · raw message
include/config_phylib_all_drivers.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Enable all PHYs +* +* This software may be used and distributed according to the +* terms of the GNU Public License, Version 2, incorporated +* herein by reference. +* +* Copyright 2011 Freescale Semiconductor, Inc. +* author Andy Fleming +* +*/ +#ifndef _CONFIG_PHYLIB_ALL_H +#define _CONFIG_PHYLIB_ALL_H + +#ifdef CONFIG_PHYLIB + +#define CONFIG_PHY_VITESSE +#define CONFIG_PHY_MARVELL +#define CONFIG_PHY_MICREL +#define CONFIG_PHY_BROADCOM +#define CONFIG_PHY_DAVICOM +#define CONFIG_PHY_REALTEK +#define CONFIG_PHY_NATSEMI +#define CONFIG_PHY_LXT + +#ifdef CONFIG_PHYLIB_10G +#define CONFIG_PHY_TERANETICS +#endif /* CONFIG_PHYLIB_10G */ + +#endif /* CONFIG_PHYLIB */ + +#endif /*_CONFIG_PHYLIB_ALL_H */
include/phy.h +10 -0
@@ -216,4 +216,14 @@ int gen10g_startup(struct phy_device *phydev);int gen10g_shutdown (struct phy_device *phydev);int gen10g_discover_mmds (struct phy_device *phydev); +int phy_atheros_init (void ); +int phy_broadcom_init (void ); +int phy_davicom_init (void ); +int phy_lxt_init (void ); +int phy_marvell_init (void ); +int phy_micrel_init (void ); +int phy_natsemi_init (void ); +int phy_realtek_init (void ); +int phy_teranetics_init (void ); +int phy_vitesse_init (void );#endif
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 7/9 tsec: Convert tsec to use PHY Lib
This converts tsec to use the new PHY Lib. All of the old PHY support is ripped out. The old MDIO driver is split off, and placed in fsl_mdio.c. The initialization is modified to initialize the MDIO driver as well. The powerpc config file is modified to configure PHYLIB if TSEC_ENET is configured.
---
v4:
* Cleaned up config setup
v3:
* Fix include of config_phylib_all_drivers.h
* Eliminate tsec_mii_t typedef
v2: Fixed numerous sparse warnings/errors
arch/powerpc/include/asm/config.h | 9 + arch/powerpc/include/asm/fsl_enet.h | 10 + board/freescale/mpc837xemds/mpc837xemds.c | 7 + board/freescale/mpc8536ds/mpc8536ds.c | 6 + board/freescale/mpc8544ds/mpc8544ds.c | 30 + board/freescale/mpc8572ds/mpc8572ds.c | 6 + board/freescale/p1022ds/p1022ds.c | 6 + board/freescale/p1_p2_rdb/p1_p2_rdb.c | 6 + board/freescale/p2020ds/p2020ds.c | 7 + drivers/net/Makefile | 2 +- drivers/net/fsl_mdio.c | 120 +++ drivers/net/tsec.c | 1602 ++--------------------------- include/fsl_mdio.h | 62 ++ include/tsec.h | 298 +----- 14 files changed, 391 insertions(+), 1780 deletions(-) create mode 100644 drivers/net/fsl_mdio.c create mode 100644 include/fsl_mdio.h
arch/powerpc/include/asm/config.h +9 -0
@@ -80,6 +80,15 @@#endif #endif +/* The TSEC driver uses the PHYLIB infrastructure */ +#ifndef CONFIG_PHYLIB +#if defined(CONFIG_TSEC_ENET ) +#define CONFIG_PHYLIB + +#include <config_phylib_all_drivers.h> +#endif /* TSEC_ENET */ +#endif /* !CONFIG_PHYLIB */ +/* All PPC boards must swap IDE bytes */ #define CONFIG_IDE_SWAP_IO
arch/powerpc/include/asm/fsl_enet.h +10 -0
@@ -28,6 +28,16 @@ enum fsl_phy_enet_if { FSL_ETH_IF_NONE, }; +struct tsec_mii_mng { +u32 miimcfg;/* MII management configuration reg */ +u32 miimcom;/* MII management command reg */ +u32 miimadd;/* MII management address reg */ +u32 miimcon;/* MII management control reg */ +u32 miimstat;/* MII management status reg */ +u32 miimind;/* MII management indication reg */ +u32 ifstat;/* Interface Status Register */ +} __attribute__ ((packed)); +int fdt_fixup_phy_connection (void *blob,int offset,enum fsl_phy_enet_if phyc);#endif /* __ASM_PPC_FSL_ENET_H */
board/freescale/mpc837xemds/mpc837xemds.c +7 -0
@@ -21,6 +21,7 @@#include <libfdt.h> #include <fdt_support.h> #include <fsl_esdhc.h> +#include <fsl_mdio.h> #include "pci.h" #include "../common/pq-mds-pib.h"
@@ -86,6 +87,7 @@ int board_mmc_init(bd_t *bd)#if defined(CONFIG_TSEC1 ) || defined(CONFIG_TSEC2 )int board_eth_init (bd_t *bd) { +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[2 ];struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR ;u32 rcwh =in_be32 (&im->reset.rcwh);
@@ -131,6 +133,11 @@ int board_eth_init(bd_t *bd) } num++;#endif + + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bd, &mdio_info); +return tsec_eth_init (bd, tsec_info, num); }
board/freescale/mpc8536ds/mpc8536ds.c +6 -0
@@ -36,6 +36,7 @@#include <libfdt.h> #include <spd_sdram.h> #include <fdt_support.h> +#include <fsl_mdio.h> #include <tsec.h> #include <netdev.h> #include <sata.h>
@@ -234,6 +235,7 @@ int board_early_init_r(void)int board_eth_init (bd_t *bis) {#ifdef CONFIG_TSEC_ENET +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[2 ];int num =0 ;
@@ -268,6 +270,10 @@ int board_eth_init(bd_t *bis) }#endif + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bis, &mdio_info); +tsec_eth_init (bis, tsec_info, num);#endif return pci_eth_init (bis);
board/freescale/mpc8544ds/mpc8544ds.c +30 -0
@@ -33,6 +33,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <fsl_mdio.h> #include <tsec.h> #include <netdev.h>
@@ -248,9 +249,35 @@ get_board_sys_clk(ulong dummy)return val; } + +#define MIIM_CIS8204_SLED_CON 0x1b +#define MIIM_CIS8204_SLEDCON_INIT 0x1115 +/* +* Hack to write all 4 PHYs with the LED values +*/ +int board_phy_config (struct phy_device *phydev) +{ +static int do_once; +uint phyid; +struct mii_dev *bus = phydev->bus; + +if (do_once) +return 0 ; + +for (phyid =0 ; phyid <4 ; phyid++) + bus->write (bus, phyid,MDIO_DEVAD_NONE ,MIIM_CIS8204_SLED_CON , +MIIM_CIS8204_SLEDCON_INIT ); + + do_once =1 ; + +return 0 ; +} + +int board_eth_init (bd_t *bis) {#ifdef CONFIG_TSEC_ENET +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[2 ];int num =0 ;
@@ -282,6 +309,9 @@ int board_eth_init(bd_t *bis) fsl_sgmii_riser_init(tsec_info, num); } + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bis, &mdio_info);tsec_eth_init (bis, tsec_info, num);#endif
board/freescale/mpc8572ds/mpc8572ds.c +6 -0
@@ -35,6 +35,7 @@#include <libfdt.h> #include <fdt_support.h> #include <tsec.h> +#include <fsl_mdio.h> #include <netdev.h> #include "../common/sgmii_riser.h"
@@ -187,6 +188,7 @@ int board_early_init_r(void)#ifdef CONFIG_TSEC_ENET int board_eth_init (bd_t *bis) { +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[4 ];int num =0 ;
@@ -233,6 +235,10 @@ int board_eth_init(bd_t *bis)fsl_sgmii_riser_init (tsec_info, num);#endif + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bis, &mdio_info); +tsec_eth_init (bis, tsec_info, num);return pci_eth_init (bis);
board/freescale/p1022ds/p1022ds.c +6 -0
@@ -22,6 +22,7 @@#include <asm/io.h> #include <libfdt.h> #include <fdt_support.h> +#include <fsl_mdio.h> #include <tsec.h> #include <asm/fsl_law.h> #include <netdev.h>
@@ -279,6 +280,7 @@ int board_early_init_r(void)*/ int board_eth_init (bd_t *bis) { +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[2 ];unsigned int num =0 ;
@@ -291,6 +293,10 @@ int board_eth_init(bd_t *bis) num++;#endif + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bis, &mdio_info); +return tsec_eth_init (bis, tsec_info, num) +pci_eth_init (bis); }
board/freescale/p1_p2_rdb/p1_p2_rdb.c +6 -0
@@ -31,6 +31,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <fsl_mdio.h> #include <tsec.h> #include <vsc7385.h> #include <netdev.h>
@@ -179,6 +180,7 @@ int board_early_init_r(void)#ifdef CONFIG_TSEC_ENET int board_eth_init (bd_t *bis) { +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[4 ];int num =0 ;char *tmp;
@@ -216,6 +218,10 @@ int board_eth_init(bd_t *bis)puts ("No address specified for VSC7385 microcode.\n" );#endif + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; +fsl_pq_mdio_init (bis, &mdio_info); +tsec_eth_init (bis, tsec_info, num);return pci_eth_init (bis);
board/freescale/p2020ds/p2020ds.c +7 -0
@@ -34,6 +34,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <fsl_mdio.h> #include <tsec.h> #include <asm/fsl_law.h> #include <netdev.h>
@@ -201,6 +202,7 @@ int board_early_init_r(void)#ifdef CONFIG_TSEC_ENET int board_eth_init (bd_t *bis) { +struct fsl_pq_mdio_info mdio_info;struct tsec_info_struct tsec_info[4 ];int num =0 ;
@@ -235,6 +237,11 @@ int board_eth_init(bd_t *bis)fsl_sgmii_riser_init (tsec_info, num);#endif + mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR ; + mdio_info.name =DEFAULT_MII_NAME ; + +fsl_pq_mdio_init (bis, &mdio_info); +tsec_eth_init (bis, tsec_info, num);return pci_eth_init (bis);
drivers/net/Makefile +1 -1
@@ -79,7 +79,7 @@ COBJS-$(CONFIG_TIGON3) += tigon3.o COBJS-$(CONFIG_TIGON3) += bcm570x_autoneg.o COBJS-$(CONFIG_TIGON3) += 5701rls.o COBJS-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o -COBJS-$(CONFIG_TSEC_ENET) += tsec.o +COBJS-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o COBJS-$(CONFIG_TSI108_ETH) += tsi108_eth.o COBJS-$(CONFIG_ULI526X) += uli526x.o COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o
drivers/net/fsl_mdio.c new file +120 -0
120 lines not on this page · raw message
drivers/net/tsec.c +98 -1504
1,738 lines not on this page · raw message
include/fsl_mdio.h new file +62 -0
62 lines not on this page · raw message
include/tsec.h +23 -275
366 lines not on this page · raw message
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 8/9 fsl: Change fsl_phy_enet_if to phy_interface_t
The fsl_phy_enet_if enum was, essentially, the phy_interface_t enum. This meant that drivers which used fsl_phy_enet_if to deal with PHY interfaces would have to convert between the two (or we would have to have them mirror each other, and deal with the ensuing maintenance headache). Instead, we switch all clients of fsl_phy_enet_if over to phy_interface_t, which should become the standard, anyway.
--- arch/powerpc/cpu/mpc8xxx/fdt.c | 23 ++---------- arch/powerpc/include/asm/fsl_enet.h | 17 +-------- board/freescale/mpc8360emds/mpc8360emds.c | 10 +++-- board/freescale/mpc837xemds/mpc837xemds.c | 3 +- board/freescale/mpc8569mds/mpc8569mds.c | 4 ++- drivers/qe/uec.c | 56 +++++++++++++++-------------- drivers/qe/uec.h | 3 +- drivers/qe/uec_phy.c | 36 +++++++++--------- include/configs/MPC8323ERDB.h | 4 +- include/configs/MPC832XEMDS.h | 4 +- include/configs/MPC8360EMDS.h | 4 +- include/configs/MPC8360ERDK.h | 4 +- include/configs/MPC8568MDS.h | 4 +- include/configs/MPC8569MDS.h | 20 +++++----- include/configs/kmeter1.h | 2 +- 15 files changed, 86 insertions(+), 108 deletions(-)
arch/powerpc/cpu/mpc8xxx/fdt.c +3 -20
@@ -27,8 +27,8 @@#include <libfdt.h> #include <fdt_support.h> #include <asm/mp.h> -#include <asm/fsl_enet.h> #include <asm/fsl_serdes.h> +#include <phy.h> #if defined(CONFIG_MP ) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))static int ft_del_cpuhandle (void *blob,int cpuhandle)
@@ -218,27 +218,10 @@ void fdt_fixup_crypto_node(void *blob, int sec_rev) }#endif -int fdt_fixup_phy_connection (void *blob,int offset,enum fsl_phy_enet_if phyc) +int fdt_fixup_phy_connection (void *blob,int offset,phy_interface_t phyc) { -static const char *fsl_phy_enet_if_str[] = { - [MII ] ="mii" , - [RMII ] ="rmii" , - [GMII ] ="gmii" , - [RGMII ] ="rgmii" , - [RGMII_ID ] ="rgmii-id" , - [RGMII_RXID ] ="rgmii-rxid" , - [SGMII ] ="sgmii" , - [TBI ] ="tbi" , - [RTBI ] ="rtbi" , - [XAUI ] ="xgmii" , - [FSL_ETH_IF_NONE ] ="" , - }; - -if (phyc >ARRAY_SIZE (fsl_phy_enet_if_str)) -return fdt_setprop_string (blob, offset,"phy-connection-type" ,"" ); -return fdt_setprop_string (blob, offset,"phy-connection-type" , - fsl_phy_enet_if_str[phyc]); +phy_string_for_interface (phyc)); }#ifdef CONFIG_SYS_SRIO
arch/powerpc/include/asm/fsl_enet.h +2 -15
@@ -13,20 +13,7 @@ #ifndef __ASM_PPC_FSL_ENET_H #define __ASM_PPC_FSL_ENET_H -enum fsl_phy_enet_if { - MII, - RMII, - GMII, - RGMII, - RGMII_ID, - RGMII_RXID, - RGMII_TXID, - SGMII, - TBI, - RTBI, - XAUI, - FSL_ETH_IF_NONE, -}; +#include <phy.h> struct tsec_mii_mng { u32 miimcfg; /* MII management configuration reg */
@@ -38,6 +25,6 @@ struct tsec_mii_mng {u32 ifstat;/* Interface Status Register */ } __attribute__ ((packed)); -int fdt_fixup_phy_connection (void *blob,int offset,enum fsl_phy_enet_if phyc); +int fdt_fixup_phy_connection (void *blob,int offset,phy_interface_t phyc);#endif /* __ASM_PPC_FSL_ENET_H */
board/freescale/mpc8360emds/mpc8360emds.c +6 -4
@@ -16,6 +16,7 @@#include <mpc83xx.h> #include <i2c.h> #include <miiphy.h> +#include <phy.h> #if defined(CONFIG_PCI )#include <pci.h> #endif
@@ -160,8 +161,9 @@ int board_eth_init(bd_t *bd)int i;for (i =0 ; i <ARRAY_SIZE (uec_info); i++) - uec_info[i].enet_interface_type =RGMII_RXID ; - uec_info[i].speed =1000 ; + uec_info[i].enet_interface_type = +PHY_INTERFACE_MODE_RGMII_RXID ; + uec_info[i].speed =SPEED_1000 ; }return uec_eth_init (bd, uec_info,ARRAY_SIZE (uec_info)); }
@@ -398,7 +400,7 @@ void ft_board_setup(void *blob, bd_t *bd) "phy-connection-type", 0);if (prop && (strcmp (prop,"rgmii-id" ) ==0 ))fdt_fixup_phy_connection (blob, path, - RGMII_RXID); + PHY_INTERFACE_MODE_RGMII_RXID); }#endif #if defined(CONFIG_HAS_ETH1 )
@@ -410,7 +412,7 @@ void ft_board_setup(void *blob, bd_t *bd) "phy-connection-type", 0);if (prop && (strcmp (prop,"rgmii-id" ) ==0 ))fdt_fixup_phy_connection (blob, path, - RGMII_RXID); + PHY_INTERFACE_MODE_RGMII_RXID); }#endif }
board/freescale/mpc837xemds/mpc837xemds.c +2 -1
@@ -22,6 +22,7 @@#include <fdt_support.h> #include <fsl_esdhc.h> #include <fsl_mdio.h> +#include <phy.h> #include "pci.h" #include "../common/pq-mds-pib.h"
@@ -155,7 +156,7 @@ static void __ft_tsec_fixup(void *blob, bd_t *bd, const char *alias,return ; } - err =fdt_fixup_phy_connection (blob, off,SGMII ); + err =fdt_fixup_phy_connection (blob, off,PHY_INTERFACE_MODE_SGMII );if (err) { printf("WARNING: could not set phy-connection-type for %s: "
board/freescale/mpc8569mds/mpc8569mds.c +3 -1
@@ -39,6 +39,7 @@#include <libfdt.h> #include <fdt_support.h> #include <fsl_esdhc.h> +#include <phy.h> #include "bcsr.h" #if defined(CONFIG_PQ_MDS_PIB )
@@ -550,7 +551,8 @@ void ft_board_setup(void *blob, bd_t *bd)break ; } - err =fdt_fixup_phy_connection (blob, nodeoff,RMII ); + err =fdt_fixup_phy_connection (blob, nodeoff, +PHY_INTERFACE_MODE_RMII );if (err <0 ) { printf("WARNING: could not set phy-connection-type "
drivers/qe/uec.c +29 -27
131 lines not on this page · raw message
drivers/qe/uec.h +2 -1
@@ -25,6 +25,7 @@#include "qe.h" #include "uccf.h" +#include <phy.h> #include <asm/fsl_enet.h> #define MAX_TX_THREADS 8
@@ -691,7 +692,7 @@ typedef struct uec_info {u16 rx_bd_ring_len;u16 tx_bd_ring_len;u8 phy_address; -enum fsl_phy_enet_if enet_interface_type; +phy_interface_t enet_interface_type;int speed; } uec_info_t;
drivers/qe/uec_phy.c +18 -18
@@ -25,6 +25,7 @@#include "uec.h" #include "uec_phy.h" #include "miiphy.h" +#include <phy.h> #define ugphy_printk(format, arg...) \ printf(format "\n", ## arg)
@@ -456,8 +457,9 @@ static int bcm_init(struct uec_mii_info *mii_info)gbit_config_aneg (mii_info); -if ((uec->uec_info->enet_interface_type ==RGMII_RXID ) && - (uec->uec_info->speed ==1000 )) { +if ((uec->uec_info->enet_interface_type == +PHY_INTERFACE_MODE_RGMII_RXID ) && + (uec->uec_info->speed ==SPEED_1000 )) {u16 val;int cnt =50 ;
@@ -485,22 +487,22 @@ static int uec_marvell_init(struct uec_mii_info *mii_info) {struct eth_device *edev = mii_info->dev;uec_private_t *uec = edev->priv; -enum fsl_phy_enet_if iface = uec->uec_info->enet_interface_type; +phy_interface_t iface = uec->uec_info->enet_interface_type;int speed = uec->uec_info->speed; -if ((speed ==1000 ) && - (iface ==RGMII_ID || - iface ==RGMII_RXID || - iface ==RGMII_TXID )) { +if ((speed ==SPEED_1000 ) && + (iface ==PHY_INTERFACE_MODE_RGMII_ID || + iface ==PHY_INTERFACE_MODE_RGMII_RXID || + iface ==PHY_INTERFACE_MODE_RGMII_TXID )) {int temp; temp =uec_phy_read (mii_info,MII_M1111_PHY_EXT_CR ); -if (iface ==RGMII_ID ) { +if (iface ==PHY_INTERFACE_MODE_RGMII_ID ) { temp |=MII_M1111_RX_DELAY |MII_M1111_TX_DELAY ; - }else if (iface ==RGMII_RXID ) { + }else if (iface ==PHY_INTERFACE_MODE_RGMII_RXID ) { temp &= ~MII_M1111_TX_DELAY ; temp |=MII_M1111_RX_DELAY ; - }else if (iface ==RGMII_TXID ) { + }else if (iface ==PHY_INTERFACE_MODE_RGMII_TXID ) { temp &= ~MII_M1111_RX_DELAY ; temp |=MII_M1111_TX_DELAY ; }
@@ -853,10 +855,8 @@ struct phy_info *uec_get_phy_info (struct uec_mii_info *mii_info)return theInfo; } -void marvell_phy_interface_mode (struct eth_device *dev, -enum fsl_phy_enet_if type, -int speed - ) +void marvell_phy_interface_mode (struct eth_device *dev,phy_interface_t type, +int speed) {uec_private_t *uec = (uec_private_t *) dev->priv;struct uec_mii_info *mii_info;
@@ -868,8 +868,8 @@ void marvell_phy_interface_mode (struct eth_device *dev, } mii_info = uec->mii_info; -if (type ==RGMII ) { -if (speed ==100 ) { +if (type ==PHY_INTERFACE_MODE_RGMII ) { +if (speed ==SPEED_100 ) {uec_phy_write (mii_info,0x00 ,0x9140 );uec_phy_write (mii_info,0x1d ,0x001f );uec_phy_write (mii_info,0x1e ,0x200c );
@@ -890,7 +890,7 @@ void marvell_phy_interface_mode (struct eth_device *dev,uec_phy_write (mii_info,0x00 ,0xa100 );uec_phy_write (mii_info,0x00 ,0x2100 );udelay (1000000 ); - }else if (speed ==10 ) { + }else if (speed ==SPEED_10 ) {uec_phy_write (mii_info,0x14 ,0x8e40 );uec_phy_write (mii_info,0x1b ,0x800b );uec_phy_write (mii_info,0x14 ,0x0c82 );
@@ -908,7 +908,7 @@ void marvell_phy_interface_mode (struct eth_device *dev, }void change_phy_interface_mode (struct eth_device *dev, -enum fsl_phy_enet_if type,int speed) +phy_interface_t type,int speed) {#ifdef CONFIG_PHY_MODE_NEED_CHANGE marvell_phy_interface_mode (dev, type, speed);
include/configs/MPC8323ERDB.h +2 -2
@@ -348,7 +348,7 @@#define CONFIG_SYS_UEC1_TX_CLK QE_CLK10#define CONFIG_SYS_UEC1_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 4 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE MII +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_MII#define CONFIG_SYS_UEC1_INTERFACE_SPEED 100#endif
@@ -360,7 +360,7 @@#define CONFIG_SYS_UEC2_TX_CLK QE_CLK3#define CONFIG_SYS_UEC2_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 0 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE MII +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_MII#define CONFIG_SYS_UEC2_INTERFACE_SPEED 100#endif
include/configs/MPC832XEMDS.h +2 -2
@@ -361,7 +361,7 @@#define CONFIG_SYS_UEC1_TX_CLK QE_CLK10#define CONFIG_SYS_UEC1_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 3 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE MII +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_MII#define CONFIG_SYS_UEC1_INTERFACE_SPEED 100#endif
@@ -373,7 +373,7 @@#define CONFIG_SYS_UEC2_TX_CLK QE_CLK8#define CONFIG_SYS_UEC2_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 4 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE MII +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_MII#define CONFIG_SYS_UEC2_INTERFACE_SPEED 100#endif
include/configs/MPC8360EMDS.h +2 -2
@@ -402,7 +402,7 @@#define CONFIG_SYS_UEC1_TX_CLK QE_CLK9#define CONFIG_SYS_UEC1_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 0 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC1_INTERFACE_SPEED 1000#endif
@@ -414,7 +414,7 @@#define CONFIG_SYS_UEC2_TX_CLK QE_CLK4#define CONFIG_SYS_UEC2_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 1 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC2_INTERFACE_SPEED 1000#endif
include/configs/MPC8360ERDK.h +2 -2
@@ -319,7 +319,7 @@#define CONFIG_SYS_UEC1_TX_CLK QE_CLK9#define CONFIG_SYS_UEC1_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 2 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RGMII_RXID +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_RXID#define CONFIG_SYS_UEC1_INTERFACE_SPEED 1000#endif
@@ -331,7 +331,7 @@#define CONFIG_SYS_UEC2_TX_CLK QE_CLK4#define CONFIG_SYS_UEC2_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 4 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE RGMII_RXID +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_RXID#define CONFIG_SYS_UEC2_INTERFACE_SPEED 1000#endif
include/configs/MPC8568MDS.h +2 -2
@@ -334,7 +334,7 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC1_TX_CLK QE_CLK16#define CONFIG_SYS_UEC1_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 7 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC1_INTERFACE_SPEED 1000#endif
@@ -346,7 +346,7 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC2_TX_CLK QE_CLK16#define CONFIG_SYS_UEC2_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 1 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC2_INTERFACE_SPEED 1000#endif #endif /* CONFIG_QE */
include/configs/MPC8569MDS.h +10 -10
@@ -385,13 +385,13 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC1_TX_CLK QE_CLK12#define CONFIG_SYS_UEC1_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 7 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC1_INTERFACE_SPEED 1000#elif defined(CONFIG_SYS_UCC_RMII_MODE )#define CONFIG_SYS_UEC1_TX_CLK QE_CLK16/* CLK16 for RMII */ #define CONFIG_SYS_UEC1_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 8/* 0x8 for RMII */ -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RMII +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RMII#define CONFIG_SYS_UEC1_INTERFACE_SPEED 100#endif /* CONFIG_SYS_UCC_RGMII_MODE */ #endif /* CONFIG_UEC_ETH1 */
@@ -406,13 +406,13 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC2_TX_CLK QE_CLK17#define CONFIG_SYS_UEC2_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 1 -#define CONFIG_SYS_UEC2_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC2_INTERFACE_SPEED 1000#elif defined(CONFIG_SYS_UCC_RMII_MODE )#define CONFIG_SYS_UEC2_TX_CLK QE_CLK16/* CLK 16 for RMII */ #define CONFIG_SYS_UEC2_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC2_PHY_ADDR 0x9/* 0x9 for RMII */ -#define CONFIG_SYS_UEC2_INTERFACE_TYPE RMII +#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RMII#define CONFIG_SYS_UEC2_INTERFACE_SPEED 100#endif /* CONFIG_SYS_UCC_RGMII_MODE */ #endif /* CONFIG_UEC_ETH2 */
@@ -427,13 +427,13 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC3_TX_CLK QE_CLK12#define CONFIG_SYS_UEC3_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC3_PHY_ADDR 2 -#define CONFIG_SYS_UEC3_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC3_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC3_INTERFACE_SPEED 1000#elif defined(CONFIG_SYS_UCC_RMII_MODE )#define CONFIG_SYS_UEC3_TX_CLK QE_CLK16/* CLK_16 for RMII */ #define CONFIG_SYS_UEC3_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC3_PHY_ADDR 0xA/* 0xA for RMII */ -#define CONFIG_SYS_UEC3_INTERFACE_TYPE RMII +#define CONFIG_SYS_UEC3_INTERFACE_TYPE PHY_INTERFACE_MODE_RMII#define CONFIG_SYS_UEC3_INTERFACE_SPEED 100#endif /* CONFIG_SYS_UCC_RGMII_MODE */ #endif /* CONFIG_UEC_ETH3 */
@@ -448,13 +448,13 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC4_TX_CLK QE_CLK17#define CONFIG_SYS_UEC4_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC4_PHY_ADDR 3 -#define CONFIG_SYS_UEC4_INTERFACE_TYPE RGMII_ID +#define CONFIG_SYS_UEC4_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID#define CONFIG_SYS_UEC4_INTERFACE_SPEED 1000#elif defined(CONFIG_SYS_UCC_RMII_MODE )#define CONFIG_SYS_UEC4_TX_CLK QE_CLK16/* CLK16 for RMII */ #define CONFIG_SYS_UEC4_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC4_PHY_ADDR 0xB/* 0xB for RMII */ -#define CONFIG_SYS_UEC4_INTERFACE_TYPE RMII +#define CONFIG_SYS_UEC4_INTERFACE_TYPE PHY_INTERFACE_MODE_RMII#define CONFIG_SYS_UEC4_INTERFACE_SPEED 100#endif /* CONFIG_SYS_UCC_RGMII_MODE */ #endif /* CONFIG_UEC_ETH4 */
@@ -468,7 +468,7 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC6_TX_CLK QE_CLK_NONE#define CONFIG_SYS_UEC6_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC6_PHY_ADDR 4 -#define CONFIG_SYS_UEC6_INTERFACE_TYPE SGMII +#define CONFIG_SYS_UEC6_INTERFACE_TYPE PHY_INTERFACE_MODE_SGMII#define CONFIG_SYS_UEC6_INTERFACE_SPEED 1000#endif /* CONFIG_UEC_ETH6 */
@@ -481,7 +481,7 @@ extern unsigned long get_clock_freq(void);#define CONFIG_SYS_UEC8_TX_CLK QE_CLK_NONE#define CONFIG_SYS_UEC8_ETH_TYPE GIGA_ETH#define CONFIG_SYS_UEC8_PHY_ADDR 6 -#define CONFIG_SYS_UEC8_INTERFACE_TYPE SGMII +#define CONFIG_SYS_UEC8_INTERFACE_TYPE PHY_INTERFACE_MODE_SGMII#define CONFIG_SYS_UEC8_INTERFACE_SPEED 1000#endif /* CONFIG_UEC_ETH8 */
include/configs/kmeter1.h +1 -1
@@ -295,7 +295,7 @@#define CONFIG_SYS_UEC1_TX_CLK QE_CLK17#define CONFIG_SYS_UEC1_ETH_TYPE FAST_ETH#define CONFIG_SYS_UEC1_PHY_ADDR 0 -#define CONFIG_SYS_UEC1_INTERFACE_TYPE RMII +#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RMII#define CONFIG_SYS_UEC1_INTERFACE_SPEED 100#endif
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 9/9 Add mdio command for new PHY infrastructure
The new mdio command doesn't have all of the features of the mii command, but it provides the necessary read/write primitives, and allows users to interact with 10G PHYs, and other PHYs which use Clause 45 of 802.3. This means that the mdio command requires a "Device Address" argument, though for clause 22 PHYs, the argument can be "-".
--- common/Makefile | 3 + common/cmd_mdio.c | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 289 insertions(+), 0 deletions(-) create mode 100644 common/cmd_mdio.c
common/Makefile +3 -0
@@ -117,6 +117,9 @@ COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o COBJS-$(CONFIG_PHYLIB) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += cmd_mii.o +ifdef CONFIG_PHYLIB +COBJS-$(CONFIG_CMD_MII) += cmd_mdio.o +endif COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o COBJS-$(CONFIG_MP) += cmd_mp.o
common/cmd_mdio.c new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
1.6.5.2.g6ff9a
PATCH v5 8/9 fsl: Change fsl_phy_enet_if to phy_interface_t
In reply to Andy FlemingHi Andy,
Quoted 8 lines
The
fsl_phy_enet_ifenum was, essentially, thephy_interface_tenum. This meant that drivers which usedfsl_phy_enet_ifto deal with PHY interfaces would have to convert between the two (or we would have to have them mirror each other, and deal with the ensuing maintenance headache). Instead, we switch all clients offsl_phy_enet_ifover tophy_interface_t, which should become the standard, anyway.Signed-off-by Andy Fleming <[email protected]>
Looks good, so
Cheers
Detlev
Signature · 8 lines
Ich glaube, da? die Weltanschauung, die aus der modernen Physik hervorgeht, mit unserer gegenw?rtigen Gesellschaft unvereinbar ist, weil sie den har- monischen Zusammenh?ngen, die wir in der Natur beaobachten, nicht Rechnung tr?gt. -- Fritjof Capra -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
v5 cover Universal PHY Infrastructure
In reply to Andy FlemingHi Andy,
Quoted 1 line
Or PHY Lib for U-Boot.
I've given acked-bys to parts of the changes that you sent already. As you already ignored them the last time, I'm not reposting them. If you want, you can add them yourself of course.
Cheers
Detlev
Signature · 8 lines
Modern methods of production have given us the possibility of ease and
security for all; we have chosen, instead, to have overwork for some
and starvation for others.
-- Bertrand Russell
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.dev5 cover Universal PHY Infrastructure
Quoted 7 lines · Detlev Zundel
Hi Andy,
Quoted 1 line
Or PHY Lib for U-Boot.
I've given acked-bys to parts of the changes that you sent already. As you already ignored them the last time, I'm not reposting them. If you want, you can add them yourself of course.
I apologize for not including them. Duly corrected in the phylib branch, and in my repository. :)
Andy