net: smc911x: sh: Add support RSK7203 board to smc911x
PATCH 1/1 net: smc911x: sh: Add support RSK7203 board to smc911x
The RSK board has the SMSC9118 wired up 'incorrectly'. This problem can support in the software side. I put a code to evade it.
--- drivers/net/smc911x.c | 37 +++++++++++++++++++++++++++++++++++-- 1 files changed, 35 insertions(+), 2 deletions(-)
drivers/net/smc911x.c +35 -2
@@ -53,6 +53,39 @@ static inline void reg_write(u32 addr, u32 val) *(volatile u16 *)addr = (u16 )val; *(volatile u16 *)(addr +2 ) = (u16)(val >>16 ); } + +#if 0 //defined(CONFIG_RSK7203) +/* +* The RSK board has the SMSC9118 wired up 'incorrectly'. +* Byte-swapping is necessary, and so poor performance is inevitable. +* It seems that this is a problem with the SMSC chip, which has an +* endian facility, but it only works at the word level so... +*/ +/* 2301_6745 --> 0123_4567 */ +#define PKT_SWAP (x) ((vu_long)((((vu_long)x << 8) & 0x0000FF00)|\ + (((vu_long)x >> 8) & 0x000000FF)|\ + (((vu_long)x << 8) & 0xFF000000)|\ + (((vu_long)x >> 8) & 0x00FF0000))) + +static inline u32 pkt_data_pull (u32 addr) +{ +volatile u16 *addr_16 = (u16 *)addr; +u32 d0 = (((*addr_16) <<16 ) &0xFFFF0000 ); +u32 d1 = ((*(addr_16 +1 ) &0x0000FFFF )); +return PKT_SWAP ((d0|d1)); +} + +static inline void pkt_data_push (u32 addr,u32 val) +{ + *(volatile u16 *)(addr +2 ) =PKT_SWAP ((u16 )val); + *(volatile u16 *)(addr) =PKT_SWAP ((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 +674,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 +717,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
Signature · 1 line
1.5.5.1
PATCH 1/1 net: smc911x: sh: Add support RSK7203 board to smc911x
Hi Nobuhiro,
Quoted 5 lines · Nobuhiro Iwamatsu
The RSK board has the SMSC9118 wired up 'incorrectly'. This problem can support in the software side. I put a code to evade it.
Putting a board fix in a common driver is not cool. Please provide more generic word-swapping versions of reg_read and reg_write, or something else like that.
regards,
Ben
PATCH 1/1 net: smc911x: sh: Add support RSK7203 board to smc911x
Hi, Ben.
Thank you for your comments.
2008/7/4 Ben Warren <[email protected]>:
Quoted 9 lines
Hi Nobuhiro,
Quoted 5 lines · Nobuhiro Iwamatsu
The RSK board has the SMSC9118 wired up 'incorrectly'. This problem can support in the software side. I put a code to evade it.
Putting a board fix in a common driver is not cool.
Yes , I know.
However, this problem occurs in read/write of FIFO. Therefore, I made a pkt_data_pull/pkt_data_push function newly. And I change it with a preprocessor.
Quoted 3 lines
Please provide more
generic word-swapping versions ofreg_readandreg_write, or something else like that.
OK, I will change swabXX and resend.
Best regards,
Nobuhiro