From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nobuhiro Iwamatsu Date: Fri, 04 Jul 2008 16:22:12 +0900 Subject: [U-Boot-Users] =?iso-2022-jp?b?W1BBVENIGyRCISEbKEJ2Ml0gbmV0OiBz?= =?iso-2022-jp?b?bWM5MTF4OiBBZGQgc3VwcG9ydCBSU0s3MjAzIGJvYXJkIHRvIHNtYzkx?= =?iso-2022-jp?b?MXg=?= Message-ID: <486DCFA4.6050704@renesas.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The RSK board has the SMSC9118 wired up 'incorrectly'. Byte-swapping is necessary, and so poor performance is inevitable. This problem cannot evade by the swap function of CHIP, this can evade by software Byte-swapping. And this has problem by FIFO access only. pkt_data_pull/pkt_data_push functions necessary to solve this problem. Signed-off-by: Nobuhiro Iwamatsu --- drivers/net/smc911x.c | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 1484b0b..cc8aaf0 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -1,5 +1,5 @@ /* - * SMSC LAN9[12]1[567] Network driver + * SMSC LAN9[12]1[5678] Network driver * * (c) 2007 Pengutronix, Sascha Hauer * @@ -26,6 +26,7 @@ #include #include #include +#include #if defined (CONFIG_DRIVER_SMC911X_32_BIT) && \ defined (CONFIG_DRIVER_SMC911X_16_BIT) @@ -53,6 +54,33 @@ static inline void reg_write(u32 addr, u32 val) *(volatile u16*)addr = (u16)val; *(volatile u16*)(addr + 2) = (u16)(val >> 16); } + +#if defined(CONFIG_RSK7203) +/* + * The RSK board has the SMSC9118 wired up 'incorrectly'. + * Byte-swapping is necessary, and so poor performance is inevitable. + * This problem cannot evade by the swap function of CHIP, this can + * evade by software Byte-swapping. + * And this has problem by FIFO access only. pkt_data_pull/pkt_data_push + * functions necessary to solve this problem. + */ +static inline u32 pkt_data_pull(u32 addr) +{ + volatile u16 *addr_16 = (u16 *)addr; + return (((swab16(*addr_16) << 16) & 0xFFFF0000)|swab16(*(addr_16 + 1))); +} + +static inline void pkt_data_push(u32 addr, u32 val) +{ + *(volatile u16 *)(addr + 2) = swab16((u16)val); + *(volatile u16 *)(addr) = swab16((u16)(val >> 16)); +} + +#else +# define pkt_data_pull(x) reg_read(x) +# define pkt_data_push(x, l) reg_write(x, l) +#endif /* CONFIG_RSK7203 */ + #else #error "SMC911X: undefined bus width" #endif /* CONFIG_DRIVER_SMC911X_16_BIT */ @@ -641,7 +669,7 @@ int eth_send(volatile void *packet, int length) tmplen = (length + 3) / 4; while (tmplen--) - reg_write(TX_DATA_FIFO, *data++); + pkt_data_push(TX_DATA_FIFO, *data++); /* wait for transmission */ while (!((reg_read(TX_FIFO_INF) & TX_FIFO_INF_TSUSED) >> 16)); @@ -684,7 +712,7 @@ int eth_rx(void) tmplen = (pktlen + 2+ 3) / 4; while (tmplen--) - *data++ = reg_read(RX_DATA_FIFO); + *data++ = pkt_data_pull(RX_DATA_FIFO); if (status & RX_STS_ES) printf(DRIVERNAME -- 1.5.5.1