diff options
Diffstat (limited to 'drivers/net/smc91111.c')
-rw-r--r-- | drivers/net/smc91111.c | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c index 55d93676b2..100688ccf8 100644 --- a/drivers/net/smc91111.c +++ b/drivers/net/smc91111.c @@ -152,6 +152,7 @@ /* Memory Information Register */ /* BANK 0 */ #define MIR_REG 0x0008 +#define MIR_FREE_MASK 0xff00 /* Receive/Phy Control Register */ /* BANK 0 */ @@ -582,6 +583,43 @@ static inline void SMC_SELECT_BANK(struct smc91c111_priv *p, int bank) SMC_outw(p, bank, BANK_SELECT); } +#if SMC_DEBUG > 2 +static void print_packet( unsigned char * buf, int length ) +{ + int i; + int remainder; + int lines; + + printf("Packet of length %d \n", length ); + +#if SMC_DEBUG > 3 + lines = length / 16; + remainder = length % 16; + + for ( i = 0; i < lines ; i ++ ) { + int cur; + + for ( cur = 0; cur < 8; cur ++ ) { + unsigned char a, b; + + a = *(buf ++ ); + b = *(buf ++ ); + printf("%02x%02x ", a, b ); + } + printf("\n"); + } + for ( i = 0; i < remainder/2 ; i++ ) { + unsigned char a, b; + + a = *(buf ++ ); + b = *(buf ++ ); + printf("%02x%02x ", a, b ); + } + printf("\n"); +#endif +} +#endif + /* note: timeout in seconds */ static int poll4int(struct smc91c111_priv *priv, unsigned char mask, int timeout) @@ -916,6 +954,30 @@ static int smc91c111_eth_open(struct eth_device *edev) return 0; } +static void smc91c111_ensure_freemem(struct eth_device *edev) +{ + struct smc91c111_priv *priv = (struct smc91c111_priv *)edev->priv; + u16 mir, rxfifo; + + SMC_SELECT_BANK(priv, 0); + mir = SMC_inw(priv, MIR_REG); + SMC_SELECT_BANK(priv, 2); + + if ((mir & MIR_FREE_MASK) == 0) { + do { + SMC_outw(priv, MC_RELEASE, MMU_CMD_REG); + smc_wait_mmu_release_complete(priv); + + SMC_SELECT_BANK(priv, 0); + mir = SMC_inw(priv, MIR_REG); + SMC_SELECT_BANK(priv, 2); + rxfifo = SMC_inw(priv, RXFIFO_REG); + dev_dbg(&edev->dev, "%s: card memory saturated, tidying up (rx_tx_fifo=0x%04x mir=0x%04x)\n", + SMC_DEV_NAME, rxfifo, mir); + } while (!(rxfifo & RXFIFO_REMPTY)); + } +} + static int smc91c111_eth_send(struct eth_device *edev, void *packet, int packet_length) { @@ -957,6 +1019,7 @@ static int smc91c111_eth_send(struct eth_device *edev, void *packet, return -EOVERFLOW; } + smc91c111_ensure_freemem(edev); /* now, try to allocate the memory */ SMC_SELECT_BANK(priv, 2); SMC_outw(priv, MC_ALLOC | numPages, MMU_CMD_REG); @@ -1255,44 +1318,6 @@ static void smc_dump_mii_stream (unsigned char * bits, int size) } #endif - -#if SMC_DEBUG > 2 -static void print_packet( unsigned char * buf, int length ) -{ - int i; - int remainder; - int lines; - - printf("Packet of length %d \n", length ); - -#if SMC_DEBUG > 3 - lines = length / 16; - remainder = length % 16; - - for ( i = 0; i < lines ; i ++ ) { - int cur; - - for ( cur = 0; cur < 8; cur ++ ) { - unsigned char a, b; - - a = *(buf ++ ); - b = *(buf ++ ); - printf("%02x%02x ", a, b ); - } - printf("\n"); - } - for ( i = 0; i < remainder/2 ; i++ ) { - unsigned char a, b; - - a = *(buf ++ ); - b = *(buf ++ ); - printf("%02x%02x ", a, b ); - } - printf("\n"); -#endif -} -#endif - static int smc91c111_init_dev(struct eth_device *edev) { return 0; |