Lines Matching refs:dev
80 #define RESET_DM9102(dev) {\ argument
82 i=INL(dev, 0x0);\
84 OUTL(dev, i | BMR_SWR, DE4X5_BMR);\
88 #define RESET_DE4X5(dev) {\ argument
90 i=INL(dev, DE4X5_BMR);\
92 OUTL(dev, i | BMR_SWR, DE4X5_BMR);\
94 OUTL(dev, i, DE4X5_BMR);\
96 for (i=0;i<5;i++) {INL(dev, DE4X5_BMR); udelay(10000);}\
101 #define START_DE4X5(dev) {\ argument
103 omr = INL(dev, DE4X5_OMR);\
105 OUTL(dev, omr, DE4X5_OMR); /* Enable the TX and/or RX */\
108 #define STOP_DE4X5(dev) {\ argument
110 omr = INL(dev, DE4X5_OMR);\
112 OUTL(dev, omr, DE4X5_OMR); /* Disable the TX and/or RX */ \
143 static void sendto_srom(struct eth_device* dev, u_int command, u_long addr);
144 static int getfrom_srom(struct eth_device* dev, u_long addr);
145 static int do_eeprom_cmd(struct eth_device *dev, u_long ioaddr,int cmd,int cmd_len);
146 static int do_read_eeprom(struct eth_device *dev,u_long ioaddr,int location,int addr_len);
149 static int write_srom(struct eth_device *dev, u_long ioaddr, int index, int new_value);
150 static void update_srom(struct eth_device *dev, bd_t *bis);
153 static int read_srom(struct eth_device *dev, u_long ioaddr, int index);
154 static void read_hw_addr(struct eth_device* dev, bd_t * bis);
156 static void send_setup_frame(struct eth_device* dev, bd_t * bis);
158 static int dc21x4x_init(struct eth_device* dev, bd_t* bis);
159 static int dc21x4x_send(struct eth_device *dev, void *packet, int length);
160 static int dc21x4x_recv(struct eth_device* dev);
161 static void dc21x4x_halt(struct eth_device* dev);
163 extern void dc21x4x_select_media(struct eth_device* dev);
169 #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
172 static int INL(struct eth_device* dev, u_long addr) in INL() argument
174 return le32_to_cpu(*(volatile u_long *)(addr + dev->iobase)); in INL()
177 static void OUTL(struct eth_device* dev, int command, u_long addr) in OUTL() argument
179 *(volatile u_long *)(addr + dev->iobase) = cpu_to_le32(command); in OUTL()
200 struct eth_device* dev; in dc21x4x_initialize() local
264 dev = (struct eth_device*) malloc(sizeof *dev); in dc21x4x_initialize()
266 if (!dev) { in dc21x4x_initialize()
270 memset(dev, 0, sizeof(*dev)); in dc21x4x_initialize()
273 sprintf(dev->name, "Davicom#%d", card_number); in dc21x4x_initialize()
275 sprintf(dev->name, "dc21x4x#%d", card_number); in dc21x4x_initialize()
279 dev->iobase = pci_io_to_phys(devbusfn, iobase); in dc21x4x_initialize()
281 dev->iobase = pci_mem_to_phys(devbusfn, iobase); in dc21x4x_initialize()
283 dev->priv = (void*) devbusfn; in dc21x4x_initialize()
284 dev->init = dc21x4x_init; in dc21x4x_initialize()
285 dev->halt = dc21x4x_halt; in dc21x4x_initialize()
286 dev->send = dc21x4x_send; in dc21x4x_initialize()
287 dev->recv = dc21x4x_recv; in dc21x4x_initialize()
295 read_hw_addr(dev, bis); in dc21x4x_initialize()
297 eth_register(dev); in dc21x4x_initialize()
305 static int dc21x4x_init(struct eth_device* dev, bd_t* bis) in dc21x4x_init() argument
308 int devbusfn = (int) dev->priv; in dc21x4x_init()
314 RESET_DM9102(dev); in dc21x4x_init()
316 RESET_DE4X5(dev); in dc21x4x_init()
319 if ((INL(dev, DE4X5_STS) & (STS_TS | STS_RS)) != 0) { in dc21x4x_init()
325 dc21x4x_select_media(dev); in dc21x4x_init()
327 OUTL(dev, OMR_SDP | OMR_PS | OMR_PM, DE4X5_OMR); in dc21x4x_init()
363 OUTL(dev, phys_to_bus((u32) &rx_ring), DE4X5_RRBA); in dc21x4x_init()
364 OUTL(dev, phys_to_bus((u32) &tx_ring), DE4X5_TRBA); in dc21x4x_init()
366 START_DE4X5(dev); in dc21x4x_init()
371 send_setup_frame(dev, bis); in dc21x4x_init()
376 static int dc21x4x_send(struct eth_device *dev, void *packet, int length) in dc21x4x_send() argument
382 printf("%s: bad packet size: %d\n", dev->name, length); in dc21x4x_send()
388 printf("%s: tx error buffer not ready\n", dev->name); in dc21x4x_send()
397 OUTL(dev, POLL_DEMAND, DE4X5_TPD); in dc21x4x_send()
401 printf(".%s: tx buffer not ready\n", dev->name); in dc21x4x_send()
422 static int dc21x4x_recv(struct eth_device* dev) in dc21x4x_recv() argument
468 static void dc21x4x_halt(struct eth_device* dev) in dc21x4x_halt() argument
470 int devbusfn = (int) dev->priv; in dc21x4x_halt()
472 STOP_DE4X5(dev); in dc21x4x_halt()
473 OUTL(dev, 0, DE4X5_SICR); in dc21x4x_halt()
478 static void send_setup_frame(struct eth_device* dev, bd_t *bis) in send_setup_frame() argument
487 *(pa + (i & 1)) = dev->enetaddr[i]; in send_setup_frame()
495 printf("%s: tx error buffer not ready\n", dev->name); in send_setup_frame()
504 OUTL(dev, POLL_DEMAND, DE4X5_TPD); in send_setup_frame()
508 printf("%s: tx buffer not ready\n", dev->name); in send_setup_frame()
526 sendto_srom(struct eth_device* dev, u_int command, u_long addr) in sendto_srom() argument
528 OUTL(dev, command, addr); in sendto_srom()
533 getfrom_srom(struct eth_device* dev, u_long addr) in getfrom_srom() argument
537 tmp = INL(dev, addr); in getfrom_srom()
544 static int do_read_eeprom(struct eth_device *dev, u_long ioaddr, int location, int addr_len) in do_read_eeprom() argument
550 sendto_srom(dev, SROM_RD | SROM_SR, ioaddr); in do_read_eeprom()
551 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
560 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS | dataval, ioaddr); in do_read_eeprom()
562 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS | dataval | DT_CLK, ioaddr); in do_read_eeprom()
565 printf("%X", getfrom_srom(dev, ioaddr) & 15); in do_read_eeprom()
567 retval = (retval << 1) | ((getfrom_srom(dev, ioaddr) & EE_DATA_READ) ? 1 : 0); in do_read_eeprom()
570 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
573 printf(" :%X:", getfrom_srom(dev, ioaddr) & 15); in do_read_eeprom()
577 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS | DT_CLK, ioaddr); in do_read_eeprom()
580 printf("%X", getfrom_srom(dev, ioaddr) & 15); in do_read_eeprom()
582 retval = (retval << 1) | ((getfrom_srom(dev, ioaddr) & EE_DATA_READ) ? 1 : 0); in do_read_eeprom()
583 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
588 sendto_srom(dev, SROM_RD | SROM_SR, ioaddr); in do_read_eeprom()
603 static int do_eeprom_cmd(struct eth_device *dev, u_long ioaddr, int cmd, int cmd_len) in do_eeprom_cmd() argument
611 sendto_srom(dev,SROM_RD | SROM_SR | DT_CS | DT_CLK, ioaddr); in do_eeprom_cmd()
616 sendto_srom(dev,dataval, ioaddr); in do_eeprom_cmd()
620 printf("%X", getfrom_srom(dev,ioaddr) & 15); in do_eeprom_cmd()
623 sendto_srom(dev,dataval | DT_CLK, ioaddr); in do_eeprom_cmd()
625 retval = (retval << 1) | ((getfrom_srom(dev,ioaddr) & EE_DATA_READ) ? 1 : 0); in do_eeprom_cmd()
627 sendto_srom(dev,SROM_RD | SROM_SR | DT_CS, ioaddr); in do_eeprom_cmd()
630 sendto_srom(dev,SROM_RD | SROM_SR, ioaddr); in do_eeprom_cmd()
641 static int read_srom(struct eth_device *dev, u_long ioaddr, int index) in read_srom() argument
643 int ee_addr_size = do_read_eeprom(dev, ioaddr, 0xff, 8) & 0x40000 ? 8 : 6; in read_srom()
645 return do_eeprom_cmd(dev, ioaddr, in read_srom()
652 static int write_srom(struct eth_device *dev, u_long ioaddr, int index, int new_value) in write_srom() argument
654 int ee_addr_size = do_read_eeprom(dev, ioaddr, 0xff, 8) & 0x40000 ? 8 : 6; in write_srom()
666 do_eeprom_cmd(dev, ioaddr, (0x4f << (ee_addr_size-4)), 3+ee_addr_size); in write_srom()
669 do_eeprom_cmd(dev, ioaddr, in write_srom()
674 sendto_srom(dev, SROM_RD | SROM_SR | DT_CS, ioaddr); in write_srom()
676 if (getfrom_srom(dev, ioaddr) & EE_DATA_READ) in write_srom()
684 do_eeprom_cmd(dev, ioaddr, (0x40 << (ee_addr_size-4)), 3 + ee_addr_size); in write_srom()
687 newval = do_eeprom_cmd(dev, ioaddr, in write_srom()
698 static void read_hw_addr(struct eth_device *dev, bd_t *bis) in read_hw_addr() argument
700 u_short tmp, *p = (u_short *)(&dev->enetaddr[0]); in read_hw_addr()
704 tmp = read_srom(dev, DE4X5_APROM, ((SROM_HWADD >> 1) + i)); in read_hw_addr()
710 memset (dev->enetaddr, 0, ETH_ALEN); in read_hw_addr()
719 update_srom(dev, bis); in read_hw_addr()
726 static void update_srom(struct eth_device *dev, bd_t *bis) in update_srom() argument
757 write_srom(dev, DE4X5_APROM, i, eeprom[i]); in update_srom()