: arm:Kirkwood network driver fixes
cover : arm:Kirkwood network driver fixes
Hi!
Three patches to fix various network driver issues on kirkwood. Patch 3 is a repost of the patch sent earlier today which is rebased on top of the other two.
// Simon
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
--- drivers/net/kirkwood_egiga.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/kirkwood_egiga.c +10 -4
@@ -38,6 +38,8 @@#include <asm/arch/kirkwood.h> #include "kirkwood_egiga.h" +#define KIRKWOOD_PHY_ADR_REQUEST 0xee +/* * smi_reg_read - miiphy_read callback function. *
@@ -52,7 +54,8 @@ static int smi_reg_read(char *devname, u8 phy_adr, u8 reg_ofs, u16 * data)u32 timeout;/* Phyadr read request */ -if (phy_adr ==0xEE && reg_ofs ==0xEE ) { +if (phy_adr ==KIRKWOOD_PHY_ADR_REQUEST && + reg_ofs ==KIRKWOOD_PHY_ADR_REQUEST ) {/* */ *data = (u16) (KWGBEREG_RD (regs->phyadr) &PHYADR_MASK );return 0 ;
@@ -127,7 +130,8 @@ static int smi_reg_write(char *devname, u8 phy_adr, u8 reg_ofs, u16 data)u32 timeout;/* Phyadr write request*/ -if (phy_adr ==0xEE && reg_ofs ==0xEE ) { +if (phy_adr ==KIRKWOOD_PHY_ADR_REQUEST && + reg_ofs ==KIRKWOOD_PHY_ADR_REQUEST ) {KWGBEREG_WR (regs->phyadr, data);return 0 ; }
@@ -444,7 +448,8 @@ static int kwgbe_init(struct eth_device *dev)#if (defined (CONFIG_MII ) || defined (CONFIG_CMD_MII )) \ && defined (CONFIG_SYS_FAULT_ECHO_LINK_DOWN )u16 phyadr; -miiphy_read (dev->name,0xEE ,0xEE , &phyadr); +miiphy_read (dev->name,KIRKWOOD_PHY_ADR_REQUEST , +KIRKWOOD_PHY_ADR_REQUEST , &phyadr);if (!miiphy_link (dev->name, phyadr)) {printf ("%s: No link on %s\n" , __FUNCTION__, dev->name);return -1 ;
@@ -670,7 +675,8 @@ int kirkwood_egiga_initialize(bd_t * bis)#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_register (dev->name, smi_reg_read, smi_reg_write);/* Set phy address of the port */ -miiphy_write (dev->name,0xEE ,0xEE ,PHY_BASE_ADR + devnum); +miiphy_write (dev->name,KIRKWOOD_PHY_ADR_REQUEST , +KIRKWOOD_PHY_ADR_REQUEST ,PHY_BASE_ADR + devnum);#endif }return 0 ;
Signature · 1 line
1.6.0.4
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
Quoted 21 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Kagstrom
Sent: Thursday, August 20, 2009 1:42 PM
Cc: U-Boot ML
Subject: [U-Boot] [PATCH 1/3]: arm:kirkwood Define kirkwood phy address magic numberSigned-off-by Simon Kagstrom <[email protected]>--- drivers/net/kirkwood_egiga.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)drivers/net/kirkwood_egiga.c +0
-0
drivers/net/kirkwood_egiga.c line 41
Quoted 4 lines
drivers/net/kirkwood_egiga.c +1
-0@@ -38,6 +38,8 @@#include <asm/arch/kirkwood.h> #include "kirkwood_egiga.h" +#define KIRKWOOD_PHY_ADR_REQUEST 0xee
define this in header file
Basically this is needed in drivers/net/phy/mv88e61xx.c for multi chip support in this case we need to define this in include/miiphy.h.
which conflicts with other phy address definition, that's why not done earlier
It makes more sense to add APIs miiphy_read/write_phyadr to miiutils
Regards..
Prafulla . .
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
Quoted 9 lines · On Thu, 20 Aug 2009 02:40:48 -0700 Prafulla Wadaskar <[email protected]>…
Quoted 2 lines
+#define
KIRKWOOD_PHY_ADR_REQUEST0xeedefine this in header file
Basically this is needed in
drivers/net/phy/mv88e61xx.cfor multi chip support in this case we need to define this ininclude/miiphy.h.
which conflicts with other phy address definition, that's why not done earlierIt makes more sense to add APIs miiphy_read/write_phyadr to miiutils
But is this really general functionality? miiphy.h is something I suppose should be generic between phys and not contain device-specific things like this.
Perhaps we should revive the patches that move out the phy initialization from sheevaplug.c and place the define and some implementation there?
// Simon
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
Quoted 21 lines
-----Original Message-----
From: Simon Kagstrom [mailto:simon.kagstrom at netinsight.net]
Sent: Thursday, August 20, 2009 5:17 PM
To: Prafulla Wadaskar
Cc: U-Boot ML; Ashish Karkare; Prabhanjan Sarnaik
Subject: Re: [U-Boot] [PATCH 1/3]: arm:kirkwood Define kirkwood phy address magic numberQuoted 5 lines · On Thu, 20 Aug 2009 02:40:48 -0700 Prafulla Wadaskar <[email protected]>…
Quoted 2 lines
+#define
KIRKWOOD_PHY_ADR_REQUEST0xeedefine this in header file
Basically this is needed in
drivers/net/phy/mv88e61xx.cformulti chip support
Quoted 2 lines
in this case we need to define this in
include/miiphy.h. which conflicts with other phy address definition, that's
Quoted 7 lines
why not done earlier
Quoted 2 lines
It makes more sense to add APIs miiphy_read/write_phyadr to miiutils
But is this really general functionality?
miiphy.his something I suppose should be generic between phys and not contain device-specific things like this.
Agreed,
Current PHY support need to be re-architected to support switches in generic ways This is old pending issue, may be we should re-trigger it again after scheduled release
Quoted 4 lines
Perhaps we should revive the patches that move out the phy initialization from
sheevaplug.cand place the define and some implementation there?
Sure
the code can be abstracted from sheevaplug as well as rd6281a for MV88E1116 initialization.
In the beginning I had posted my first patch as separate driver for MV88E1116, but again this is gated due to above rework to be done
Regards..
Prafulla . .
Quoted 3 lines
// Simon
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
Quoted 9 lines · On Thu, 20 Aug 2009 20:20:08 -0700 Prafulla Wadaskar <[email protected]>…
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
+#define
KIRKWOOD_PHY_ADR_REQUEST0xeedefine this in header file
Basically this is needed in
drivers/net/phy/mv88e61xx.cformulti chip support
Quoted 2 lines
in this case we need to define this in
include/miiphy.h. which conflicts with other phy address definition, that'swhy not done earlier
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
It makes more sense to add APIs miiphy_read/write_phyadr to miiutils
But is this really general functionality?
miiphy.his something I suppose should be generic between phys and not contain device-specific things like this.Agreed,
Current PHY support need to be re-architected to support switches in generic ways This is old pending issue, may be we should re-trigger it again after scheduled release
Right. But for now, perhaps it's OK to merge the patch as-is and then correct the location of the define when the restructuring is done?
In the same way, I guess we should postspone moving out PHY initialization from sheevaplug and keep it duplicated until it's clear what to do there?
// Simon
PATCH 1/3 : arm:kirkwood Define kirkwood phy address magic number
In reply to Simon KagstromQuoted 5 lines · Simon Kagstrom
Signed-off-by Simon Kagstrom <[email protected]>--- drivers/net/kirkwood_egiga.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
Patches 1-3 applied to net repo.
thanks,
Ben
PATCH 2/3 : Wait for the link to come up on kirkwood network init
In reply to Simon KagstromThis patch makes the device wait for up to 5 seconds for the link to come up, similar to what many of the other network drivers do. This avoids confusing situations where, e.g., a tftp fails when initiated early after U-boot has started (before the link has come up).
v2: Remove function name from printout
--- drivers/net/kirkwood_egiga.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/kirkwood_egiga.c +14 -6
@@ -400,6 +400,7 @@ static int kwgbe_init(struct eth_device *dev) {struct kwgbe_device *dkwgbe =to_dkwgbe (dev);struct kwgbe_registers *regs = dkwgbe->regs; +int i;/* setup RX rings */ kwgbe_init_rx_desc_ring (dkwgbe);
@@ -447,13 +448,20 @@ static int kwgbe_init(struct eth_device *dev)#if (defined (CONFIG_MII ) || defined (CONFIG_CMD_MII )) \ && defined (CONFIG_SYS_FAULT_ECHO_LINK_DOWN ) -u16 phyadr; -miiphy_read (dev->name,KIRKWOOD_PHY_ADR_REQUEST , -KIRKWOOD_PHY_ADR_REQUEST , &phyadr); -if (!miiphy_link (dev->name, phyadr)) { -printf ("%s: No link on %s\n" , __FUNCTION__, dev->name); -return -1 ; +/* Wait up to 5s for the link status */ +for (i =0 ; i <5 ; i++) { +u16 phyadr; + +miiphy_read (dev->name,KIRKWOOD_PHY_ADR_REQUEST , +KIRKWOOD_PHY_ADR_REQUEST , &phyadr); +/* Return if we get link up */ +if (miiphy_link (dev->name, phyadr)) +return 0 ; +udelay (1000000 ); } + +printf ("No link on %s\n" , dev->name); +return -1 ;#endif return 0 ; }
Signature · 1 line
1.6.0.4
PATCH 3/3 : arm: kirkwood: See to it that sent data is 8-byte aligned
In reply to Simon KagstromU-boot might use non-8-byte-aligned addresses for sending data, which the kwgbe_send doesn't accept (bootp does this for me). This patch copies the data to be sent to a malloced temporary buffer if it is non-aligned.
v2: Malloc send buffer
v3: No need to use jumbo frames, use 1518 bytes buffer instead
v4: Correct alignment passed to memalign (should be 8!),
allocate buffer at initialization(), use PKTSIZE_ALIGN
--- drivers/net/kirkwood_egiga.c | 21 +++++++++++++++++---- drivers/net/kirkwood_egiga.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/net/kirkwood_egiga.c +17 -4
@@ -500,18 +500,26 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,struct kwgbe_device *dkwgbe =to_dkwgbe (dev);struct kwgbe_registers *regs = dkwgbe->regs;struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc; +void *p = (void *)dataptr;u32 cmd_sts; +/* Copy buffer if it's misaligned */ if ((u32 ) dataptr &0x07 ) { -printf ("Err..(%s) xmit dataptr not 64bit aligned\n" , - __FUNCTION__); -return -1 ; +if (datasize >PKTSIZE_ALIGN ) { +printf ("Non-aligned data too large (%d)\n" , + datasize); +return -1 ; + } + +memcpy (dkwgbe->p_aligned_txbuf, p, datasize); + p = dkwgbe->p_aligned_txbuf; } + p_txdesc->cmd_sts =KWGBE_ZERO_PADDING |KWGBE_GEN_CRC ; p_txdesc->cmd_sts |=KWGBE_TX_FIRST_DESC |KWGBE_TX_LAST_DESC ; p_txdesc->cmd_sts |=KWGBE_BUFFER_OWNED_BY_DMA ; p_txdesc->cmd_sts |=KWGBE_TX_EN_INTERRUPT ; - p_txdesc->buf_ptr = (u8 *) dataptr; + p_txdesc->buf_ptr = (u8 *) p; p_txdesc->byte_cnt = datasize;/* Apply send command using zeroth RXUQ */
@@ -628,8 +636,13 @@ int kirkwood_egiga_initialize(bd_t * bis) * PKTSIZE_ALIGN + 1))) goto error3; +if (!(dkwgbe->p_aligned_txbuf =memalign (8 ,PKTSIZE_ALIGN ))) + goto error4; +if (!(dkwgbe->p_txdesc = (struct kwgbe_txdesc *)memalign (PKTALIGN ,sizeof (struct kwgbe_txdesc ) +1 ))) { +free (dkwgbe->p_aligned_txbuf); + error4:free (dkwgbe->p_rxbuf); error3:free (dkwgbe->p_rxdesc);
drivers/net/kirkwood_egiga.h +1 -0
@@ -499,6 +499,7 @@ struct kwgbe_device {struct kwgbe_rxdesc *p_rxdesc;struct kwgbe_rxdesc *p_rxdesc_curr;u8 *p_rxbuf; + u8 *p_aligned_txbuf; };#endif /* __EGIGA_H__ */
Signature · 1 line
1.6.0.4
PATCH 3/3 : arm: kirkwood: See to it that sent data is 8-byte aligned
Quoted 14 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Kagstrom
Sent: Thursday, August 20, 2009 1:44 PM
To: U-Boot ML
Subject: [U-Boot] [PATCH 3/3] [repost]: arm: kirkwood: See to it that sent data is 8-byte alignedU-boot might use non-8-byte-aligned addresses for sending data, which the
kwgbe_senddoesn't accept (bootp does this for me). This patch copies the data to be sent to a malloced temporary buffer if it is non-aligned.
<snip...>
Quoted 16 lines
drivers/net/kirkwood_egiga.h +1
-0@@ -499,6 +499,7 @@ struct kwgbe_device {struct kwgbe_rxdesc *p_rxdesc;struct kwgbe_rxdesc *p_rxdesc_curr;u8 *p_rxbuf; + u8 *p_aligned_txbuf; };#endif /* __EGIGA_H__ */ Signature · 1 line
1.6.0.4
Ack,
Technically this patch is okay,
Unless we all agree this to be done in low level drivers :-)
Regards..
Prafulla . .
Quoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot