static int jz_eth_init (struct eth_device* dev, bd_t * bd) { u16 id; dev = dev; /* verify chip id */ id = get_reg_init_bus (PP_ChipID); if (id != 0x630e) { printf ("CS8900 jz_eth_init error!\n"); return 0; } eth_reset (); /* set the ethernet address */ //printf("MAC = %02x:%02x:%02x:%02x:%02x:%02x\r\n", // bd->bi_enetaddr[5],bd->bi_enetaddr[4], // bd->bi_enetaddr[3],bd->bi_enetaddr[2], // bd->bi_enetaddr[1],bd->bi_enetaddr[0]); put_reg (PP_IA + 0, bd->bi_enetaddr[0] | (bd->bi_enetaddr[1] << 8)); put_reg (PP_IA + 2, bd->bi_enetaddr[2] | (bd->bi_enetaddr[3] << 8)); put_reg (PP_IA + 4, bd->bi_enetaddr[4] | (bd->bi_enetaddr[5] << 8)); eth_reginit (); return 0; }
/* Send a data block via Ethernet. */ extern int eth_send (volatile void *packet, int length) { volatile unsigned short *addr; int tmo; unsigned short s; retry: /* initiate a transmit sequence */ CS8900_TxCMD = PP_TxCmd_TxStart_Full; CS8900_TxLEN = length; /* Test to see if the chip has allocated memory for the packet */ if ((get_reg (PP_BusSTAT) & (PP_BusSTAT_TxRDY)) == 0) { /* Oops... this should not happen! */ #ifdef DEBUG printf ("cs: unable to send packet; retrying...\n"); #endif for (tmo = get_timer (0) + 5 * CFG_HZ; get_timer (0) < tmo;) /*NOP*/; eth_reset (); eth_reginit (); goto retry; } /* Write the contents of the packet */ /* assume even number of bytes */ for (addr = packet; length > 0; length -= 2) { unsigned short data = *addr; CS8900_RTDATA = SW(data); addr++; } /* wait for transfer to succeed */ tmo = get_timer (0) + 5 * CFG_HZ; while ((s = get_reg (PP_TER) & ~0x1F) == 0) { if (get_timer (0) >= tmo) break; } /* nothing */ ; if ((s & (PP_TER_CRS | PP_TER_TxOK)) != PP_TER_TxOK) { #ifdef DEBUG printf ("\ntransmission error %#x\n", s); #endif } return 0; }
int eth_init (bd_t * bd) { /* verify chip id */ if (get_reg_init_bus (PP_ChipID) != 0x630e) { printf ("CS8900 Ethernet chip not found?!\n"); return 0; } eth_reset (); /* set the ethernet address */ put_reg (PP_IA + 0, bd->bi_enetaddr[0] | (bd->bi_enetaddr[1] << 8)); put_reg (PP_IA + 2, bd->bi_enetaddr[2] | (bd->bi_enetaddr[3] << 8)); put_reg (PP_IA + 4, bd->bi_enetaddr[4] | (bd->bi_enetaddr[5] << 8)); eth_reginit (); return 0; }
//int eth_init (bd_t * bd) int eth_init () { /* verify chip id */ if (get_reg_init_bus (PP_ChipID) != 0x630e) { printf ("CS8900 Ethernet chip not found?!\n"); return 0; } eth_reset (); /* set the ethernet address */ //put_reg (PP_IA + 0, 0x09 | 0x00 << 8); //put_reg (PP_IA + 2, 0xD8 | 0x58 << 8); //put_reg (PP_IA + 4, 0x22 | 0x11 << 8); put_reg (PP_IA + 0, 0x00 | 0x09 << 8); put_reg (PP_IA + 2, 0x58 | 0xD8 << 8); put_reg (PP_IA + 4, 0x11 | 0x22 << 8); eth_reginit (); return 0; }
int eth_init (bd_t * bd) { uchar enetaddr[6]; gpio_init_cs8900(); /* verify chip id */ if (get_reg_init_bus (PP_ChipID) != 0x630e) { printf ("CS8900 Ethernet chip not found?!\n"); return 0; } eth_reset (); /* set the ethernet address */ eth_getenv_enetaddr("ethaddr", enetaddr); put_reg (PP_IA + 0, enetaddr[0] | (enetaddr[1] << 8)); put_reg (PP_IA + 2, enetaddr[2] | (enetaddr[3] << 8)); put_reg (PP_IA + 4, enetaddr[4] | (enetaddr[5] << 8)); eth_reginit (); return 0; }