Lines Matching refs:dev
94 static inline u16 cirrus_read (struct net_device *dev,u16 reg) in cirrus_read() argument
96 outw (reg,dev->base_addr + PP_Address); in cirrus_read()
97 return (inw (dev->base_addr + PP_Data)); in cirrus_read()
100 static inline void cirrus_write (struct net_device *dev,u16 reg,u16 value) in cirrus_write() argument
102 outw (reg,dev->base_addr + PP_Address); in cirrus_write()
103 outw (value,dev->base_addr + PP_Data); in cirrus_write()
106 static inline void cirrus_set (struct net_device *dev,u16 reg,u16 value) in cirrus_set() argument
108 cirrus_write (dev,reg,cirrus_read (dev,reg) | value); in cirrus_set()
111 static inline void cirrus_clear (struct net_device *dev,u16 reg,u16 value) in cirrus_clear() argument
113 cirrus_write (dev,reg,cirrus_read (dev,reg) & ~value); in cirrus_clear()
116 static inline void cirrus_frame_read (struct net_device *dev,struct sk_buff *skb,u16 length) in cirrus_frame_read() argument
118 insw (dev->base_addr,skb_put (skb,length),(length + 1) / 2); in cirrus_frame_read()
121 static inline void cirrus_frame_write (struct net_device *dev,struct sk_buff *skb) in cirrus_frame_write() argument
123 outsw (dev->base_addr,skb->data,(skb->len + 1) / 2); in cirrus_frame_write()
139 static void dump16 (struct net_device *dev,const u8 *s,size_t len) in dump16() argument
161 printk (KERN_DEBUG "%s: %s\n",dev->name,str); in dump16()
164 static void hexdump (struct net_device *dev,const void *ptr,size_t size) in hexdump() argument
168 for (i = 0; i < size / 16; i++, s += 16) dump16 (dev,s,16); in hexdump()
169 dump16 (dev,s,size % 16); in hexdump()
172 static void dump_packet (struct net_device *dev,struct sk_buff *skb,const char *type) in dump_packet() argument
175 dev->name, in dump_packet()
181 if (skb->len < 0x100) hexdump (dev,skb->data,skb->len); in dump_packet()
189 static void cirrus_receive (struct net_device *dev) in cirrus_receive() argument
191 cirrus_t *priv = (cirrus_t *) dev->priv; in cirrus_receive()
195 status = cirrus_read (dev,PP_RxStatus); in cirrus_receive()
196 length = cirrus_read (dev,PP_RxLength); in cirrus_receive()
210 skb->dev = dev; in cirrus_receive()
213 cirrus_frame_read (dev,skb,length); in cirrus_receive()
216 dump_packet (dev,skb,"recv"); in cirrus_receive()
219 skb->protocol = eth_type_trans (skb,dev); in cirrus_receive()
222 dev->last_rx = jiffies; in cirrus_receive()
228 static int cirrus_send_start (struct sk_buff *skb,struct net_device *dev) in cirrus_send_start() argument
230 cirrus_t *priv = (cirrus_t *) dev->priv; in cirrus_send_start()
233 netif_stop_queue (dev); in cirrus_send_start()
235 cirrus_write (dev,PP_TxCMD,TxStart (After5)); in cirrus_send_start()
236 cirrus_write (dev,PP_TxLength,skb->len); in cirrus_send_start()
238 status = cirrus_read (dev,PP_BusST); in cirrus_send_start()
241 printk (KERN_WARNING "%s: Invalid frame size %d!\n",dev->name,skb->len); in cirrus_send_start()
249 printk (KERN_WARNING "%s: Transmit buffer not free!\n",dev->name); in cirrus_send_start()
256 cirrus_frame_write (dev,skb); in cirrus_send_start()
259 dump_packet (dev,skb,"send"); in cirrus_send_start()
262 dev->trans_start = jiffies; in cirrus_send_start()
273 struct net_device *dev = (struct net_device *) id; in cirrus_interrupt() local
277 if (dev->priv == NULL) { in cirrus_interrupt()
278 printk (KERN_WARNING "%s: irq %d for unknown device.\n",dev->name,irq); in cirrus_interrupt()
282 priv = (cirrus_t *) dev->priv; in cirrus_interrupt()
284 while ((status = cirrus_read (dev,PP_ISQ))) { in cirrus_interrupt()
287 cirrus_receive (dev); in cirrus_interrupt()
291 priv->stats.collisions += ColCount (cirrus_read (dev,PP_TxCOL)); in cirrus_interrupt()
302 netif_wake_queue (dev); in cirrus_interrupt()
307 u16 missed = MissCount (cirrus_read (dev,PP_RxMISS)); in cirrus_interrupt()
317 netif_wake_queue (dev); in cirrus_interrupt()
321 priv->stats.collisions += ColCount (cirrus_read (dev,PP_TxCOL)); in cirrus_interrupt()
325 status = MissCount (cirrus_read (dev,PP_RxMISS)); in cirrus_interrupt()
333 static void cirrus_transmit_timeout (struct net_device *dev) in cirrus_transmit_timeout() argument
335 cirrus_t *priv = (cirrus_t *) dev->priv; in cirrus_transmit_timeout()
339 netif_wake_queue (dev); in cirrus_transmit_timeout()
342 static int cirrus_start (struct net_device *dev) in cirrus_start() argument
347 if (!is_valid_ether_addr(dev->dev_addr)) { in cirrus_start()
348 printk(KERN_ERR "%s: invalid ethernet MAC address\n",dev->name); in cirrus_start()
353 if ((result = request_irq (dev->irq,&cirrus_interrupt,0,dev->name,dev)) < 0) { in cirrus_start()
354 printk (KERN_ERR "%s: could not register interrupt %d\n",dev->name,dev->irq); in cirrus_start()
359 cirrus_set (dev,PP_RxCFG,RxOKiE | BufferCRC | CRCerroriE | RuntiE | ExtradataiE); in cirrus_start()
360 cirrus_set (dev,PP_RxCTL,RxOKA | IndividualA | BroadcastA); in cirrus_start()
361 cirrus_set (dev,PP_TxCFG,TxOKiE | Out_of_windowiE | JabberiE); in cirrus_start()
362 cirrus_set (dev,PP_BufCFG,Rdy4TxiE | RxMissiE | TxUnderruniE | TxColOvfiE | MissOvfloiE); in cirrus_start()
363 cirrus_set (dev,PP_LineCTL,SerRxON | SerTxON); in cirrus_start()
364 cirrus_set (dev,PP_BusCTL,EnableRQ); in cirrus_start()
367 cirrus_set (dev,PP_TestCTL,FDX); in cirrus_start()
371 netif_start_queue (dev); in cirrus_start()
378 static int cirrus_stop (struct net_device *dev) in cirrus_stop() argument
381 cirrus_write (dev,PP_BusCTL,0); in cirrus_stop()
382 cirrus_write (dev,PP_TestCTL,0); in cirrus_stop()
383 cirrus_write (dev,PP_SelfCTL,0); in cirrus_stop()
384 cirrus_write (dev,PP_LineCTL,0); in cirrus_stop()
385 cirrus_write (dev,PP_BufCFG,0); in cirrus_stop()
386 cirrus_write (dev,PP_TxCFG,0); in cirrus_stop()
387 cirrus_write (dev,PP_RxCTL,0); in cirrus_stop()
388 cirrus_write (dev,PP_RxCFG,0); in cirrus_stop()
391 free_irq (dev->irq,dev); in cirrus_stop()
394 netif_stop_queue (dev); in cirrus_stop()
401 static int cirrus_set_mac_address (struct net_device *dev, void *p) in cirrus_set_mac_address() argument
406 if (netif_running(dev)) in cirrus_set_mac_address()
409 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); in cirrus_set_mac_address()
413 cirrus_write (dev,PP_IA + i,dev->dev_addr[i] | (dev->dev_addr[i + 1] << 8)); in cirrus_set_mac_address()
418 static struct net_device_stats *cirrus_get_stats (struct net_device *dev) in cirrus_get_stats() argument
420 cirrus_t *priv = (cirrus_t *) dev->priv; in cirrus_get_stats()
424 static void cirrus_set_receive_mode (struct net_device *dev) in cirrus_set_receive_mode() argument
426 if ((dev->flags & IFF_PROMISC)) in cirrus_set_receive_mode()
427 cirrus_set (dev,PP_RxCTL,PromiscuousA); in cirrus_set_receive_mode()
429 cirrus_clear (dev,PP_RxCTL,PromiscuousA); in cirrus_set_receive_mode()
431 if ((dev->flags & IFF_ALLMULTI) && dev->mc_list) in cirrus_set_receive_mode()
432 cirrus_set (dev,PP_RxCTL,MulticastA); in cirrus_set_receive_mode()
434 cirrus_clear (dev,PP_RxCTL,MulticastA); in cirrus_set_receive_mode()
437 static int cirrus_eeprom_wait (struct net_device *dev) in cirrus_eeprom_wait() argument
442 if (!(cirrus_read (dev,PP_SelfST) & SIBUSY)) in cirrus_eeprom_wait()
450 static int cirrus_eeprom_read (struct net_device *dev,u16 *value,u16 offset) in cirrus_eeprom_read() argument
452 if (cirrus_eeprom_wait (dev) < 0) in cirrus_eeprom_read()
455 cirrus_write (dev,PP_EEPROMCommand,offset | EEReadRegister); in cirrus_eeprom_read()
457 if (cirrus_eeprom_wait (dev) < 0) in cirrus_eeprom_read()
460 *value = cirrus_read (dev,PP_EEPROMData); in cirrus_eeprom_read()
465 static int cirrus_eeprom (struct net_device *dev,cirrus_eeprom_t *eeprom) in cirrus_eeprom() argument
470 if (cirrus_eeprom_read (dev,buf,0) < 0) { in cirrus_eeprom()
472 printk (KERN_DEBUG "%s: EEPROM read timed out\n",dev->name); in cirrus_eeprom()
477 printk (KERN_DEBUG "%s: No EEPROM present\n",dev->name); in cirrus_eeprom()
483 printk (KERN_DEBUG "%s: EEPROM too small\n",dev->name); in cirrus_eeprom()
488 if (cirrus_eeprom_read (dev,buf + offset,offset) < 0) in cirrus_eeprom()
496 printk (KERN_DEBUG "%s: Group Header #1 mismatch\n",dev->name); in cirrus_eeprom()
501 printk (KERN_DEBUG "%s: Group Header #2 mismatch\n",dev->name); in cirrus_eeprom()
506 printk (KERN_DEBUG "%s: Group Header #3 mismatch\n",dev->name); in cirrus_eeprom()
523 if (cirrus_eeprom_read (dev,&offset,0x10) < 0) in cirrus_eeprom()
528 dev->name, in cirrus_eeprom()
542 static void frodo_reset (struct net_device *dev) in frodo_reset() argument
554 for (i = 0; i < 3; i++) value = cirrus_read (dev,0); in frodo_reset()
567 int __init cirrus_probe (struct net_device *dev) in cirrus_probe() argument
578 ether_setup (dev); in cirrus_probe()
580 dev->open = cirrus_start; in cirrus_probe()
581 dev->stop = cirrus_stop; in cirrus_probe()
582 dev->hard_start_xmit = cirrus_send_start; in cirrus_probe()
583 dev->get_stats = cirrus_get_stats; in cirrus_probe()
584 dev->set_multicast_list = cirrus_set_receive_mode; in cirrus_probe()
585 dev->set_mac_address = cirrus_set_mac_address; in cirrus_probe()
586 dev->tx_timeout = cirrus_transmit_timeout; in cirrus_probe()
587 dev->watchdog_timeo = HZ; in cirrus_probe()
589 dev->dev_addr[0] = 0x00; in cirrus_probe()
590 dev->dev_addr[1] = 0x00; in cirrus_probe()
591 dev->dev_addr[2] = 0x00; in cirrus_probe()
592 dev->dev_addr[3] = 0x00; in cirrus_probe()
593 dev->dev_addr[4] = 0x00; in cirrus_probe()
594 dev->dev_addr[5] = 0x00; in cirrus_probe()
596 dev->if_port = IF_PORT_10BASET; in cirrus_probe()
597 dev->priv = (void *) &priv; in cirrus_probe()
599 SET_MODULE_OWNER (dev); in cirrus_probe()
601 dev->base_addr = CIRRUS_DEFAULT_IO; in cirrus_probe()
602 dev->irq = CIRRUS_DEFAULT_IRQ; in cirrus_probe()
605 if (io > 0) dev->base_addr = io; in cirrus_probe()
606 if (irq > 0) dev->irq = irq; in cirrus_probe()
608 if (!dev->base_addr) { in cirrus_probe()
612 dev->name,dev->name); in cirrus_probe()
616 if (!dev->irq) { in cirrus_probe()
620 dev->name,dev->name); in cirrus_probe()
624 if ((result = check_region (dev->base_addr,16))) { in cirrus_probe()
625 printk (KERN_ERR "%s: can't get I/O port address 0x%lx\n",dev->name,dev->base_addr); in cirrus_probe()
629 if (!request_region (dev->base_addr,16,dev->name)) in cirrus_probe()
633 frodo_reset (dev); in cirrus_probe()
637 if (!cirrus_eeprom (dev,&eeprom)) in cirrus_probe()
639 dev->dev_addr[i] = eeprom.mac[i]; in cirrus_probe()
642 if ((value = cirrus_read (dev,PP_ProductID)) != EISA_REG_CODE) { in cirrus_probe()
643 printk (KERN_ERR "%s: incorrect signature 0x%.4x\n",dev->name,value); in cirrus_probe()
648 value = cirrus_read (dev,PP_ProductID + 2); in cirrus_probe()
650 printk (KERN_ERR "%s: unknown chip version 0x%.8x\n",dev->name,VERSION (value)); in cirrus_probe()
653 printk (KERN_INFO "%s: CS8900A rev %c detected\n",dev->name,'B' + REVISION (value) - REV_B); in cirrus_probe()
656 cirrus_write (dev,PP_IntNum,0); in cirrus_probe()
660 cirrus_write (dev,PP_IA + i,dev->dev_addr[i] | (dev->dev_addr[i + 1] << 8)); in cirrus_probe()
667 static struct net_device dev; variable
671 memset (&dev,0,sizeof (struct net_device)); in cirrus_init()
672 dev.init = cirrus_probe; in cirrus_init()
673 return (register_netdev (&dev)); in cirrus_init()
678 release_region (dev.base_addr,16); in cirrus_cleanup()
679 unregister_netdev (&dev); in cirrus_cleanup()