• Home
  • Raw
  • Download

Lines Matching refs:bp

97 static void qec_init(struct bigmac *bp)  in qec_init()  argument
99 struct platform_device *qec_op = bp->qec_op; in qec_init()
100 void __iomem *gregs = bp->gregs; in qec_init()
101 u8 bsizes = bp->bigmac_bursts; in qec_init()
164 static void bigmac_stop(struct bigmac *bp) in bigmac_stop() argument
166 bigmac_tx_reset(bp->bregs); in bigmac_stop()
167 bigmac_rx_reset(bp->bregs); in bigmac_stop()
170 static void bigmac_get_counters(struct bigmac *bp, void __iomem *bregs) in bigmac_get_counters() argument
172 struct net_device_stats *stats = &bp->enet_stats; in bigmac_get_counters()
192 static void bigmac_clean_rings(struct bigmac *bp) in bigmac_clean_rings() argument
197 if (bp->rx_skbs[i] != NULL) { in bigmac_clean_rings()
198 dev_kfree_skb_any(bp->rx_skbs[i]); in bigmac_clean_rings()
199 bp->rx_skbs[i] = NULL; in bigmac_clean_rings()
204 if (bp->tx_skbs[i] != NULL) { in bigmac_clean_rings()
205 dev_kfree_skb_any(bp->tx_skbs[i]); in bigmac_clean_rings()
206 bp->tx_skbs[i] = NULL; in bigmac_clean_rings()
211 static void bigmac_init_rings(struct bigmac *bp, int from_irq) in bigmac_init_rings() argument
213 struct bmac_init_block *bb = bp->bmac_block; in bigmac_init_rings()
220 bp->rx_new = bp->rx_old = bp->tx_new = bp->tx_old = 0; in bigmac_init_rings()
223 bigmac_clean_rings(bp); in bigmac_init_rings()
233 bp->rx_skbs[i] = skb; in bigmac_init_rings()
240 dma_map_single(&bp->bigmac_op->dev, in bigmac_init_rings()
267 static void write_tcvr_bit(struct bigmac *bp, void __iomem *tregs, int bit) in write_tcvr_bit() argument
269 if (bp->tcvr_type == internal) { in write_tcvr_bit()
277 } else if (bp->tcvr_type == external) { in write_tcvr_bit()
290 static int read_tcvr_bit(struct bigmac *bp, void __iomem *tregs) in read_tcvr_bit() argument
294 if (bp->tcvr_type == internal) { in read_tcvr_bit()
301 } else if (bp->tcvr_type == external) { in read_tcvr_bit()
313 static int read_tcvr_bit2(struct bigmac *bp, void __iomem *tregs) in read_tcvr_bit2() argument
317 if (bp->tcvr_type == internal) { in read_tcvr_bit2()
323 } else if (bp->tcvr_type == external) { in read_tcvr_bit2()
335 static void put_tcvr_byte(struct bigmac *bp, in put_tcvr_byte() argument
342 write_tcvr_bit(bp, tregs, ((byte >> shift) & 1)); in put_tcvr_byte()
347 static void bigmac_tcvr_write(struct bigmac *bp, void __iomem *tregs, in bigmac_tcvr_write() argument
354 switch(bp->tcvr_type) { in bigmac_tcvr_write()
365 write_tcvr_bit(bp, tregs, 0); in bigmac_tcvr_write()
366 write_tcvr_bit(bp, tregs, 1); in bigmac_tcvr_write()
367 write_tcvr_bit(bp, tregs, 0); in bigmac_tcvr_write()
368 write_tcvr_bit(bp, tregs, 1); in bigmac_tcvr_write()
370 put_tcvr_byte(bp, tregs, in bigmac_tcvr_write()
371 ((bp->tcvr_type == internal) ? in bigmac_tcvr_write()
374 put_tcvr_byte(bp, tregs, reg); in bigmac_tcvr_write()
376 write_tcvr_bit(bp, tregs, 1); in bigmac_tcvr_write()
377 write_tcvr_bit(bp, tregs, 0); in bigmac_tcvr_write()
381 write_tcvr_bit(bp, tregs, (val >> shift) & 1); in bigmac_tcvr_write()
386 static unsigned short bigmac_tcvr_read(struct bigmac *bp, in bigmac_tcvr_read() argument
393 switch(bp->tcvr_type) { in bigmac_tcvr_read()
404 write_tcvr_bit(bp, tregs, 0); in bigmac_tcvr_read()
405 write_tcvr_bit(bp, tregs, 1); in bigmac_tcvr_read()
406 write_tcvr_bit(bp, tregs, 1); in bigmac_tcvr_read()
407 write_tcvr_bit(bp, tregs, 0); in bigmac_tcvr_read()
409 put_tcvr_byte(bp, tregs, in bigmac_tcvr_read()
410 ((bp->tcvr_type == internal) ? in bigmac_tcvr_read()
413 put_tcvr_byte(bp, tregs, reg); in bigmac_tcvr_read()
415 if (bp->tcvr_type == external) { in bigmac_tcvr_read()
418 (void) read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
419 (void) read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
424 tmp = read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
429 (void) read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
430 (void) read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
431 (void) read_tcvr_bit2(bp, tregs); in bigmac_tcvr_read()
435 (void) read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
436 (void) read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
441 tmp = read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
446 (void) read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
447 (void) read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
448 (void) read_tcvr_bit(bp, tregs); in bigmac_tcvr_read()
453 static void bigmac_tcvr_init(struct bigmac *bp) in bigmac_tcvr_init() argument
455 void __iomem *tregs = bp->tregs; in bigmac_tcvr_init()
472 bp->tcvr_type = external; in bigmac_tcvr_init()
477 bp->tcvr_type = internal; in bigmac_tcvr_init()
493 static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) in try_next_permutation() argument
495 if (bp->sw_bmcr & BMCR_SPEED100) { in try_next_permutation()
499 bp->sw_bmcr = (BMCR_ISOLATE | BMCR_PDOWN | BMCR_LOOPBACK); in try_next_permutation()
500 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in try_next_permutation()
501 bp->sw_bmcr = (BMCR_RESET); in try_next_permutation()
502 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in try_next_permutation()
506 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in try_next_permutation()
507 if ((bp->sw_bmcr & BMCR_RESET) == 0) in try_next_permutation()
512 printk(KERN_ERR "%s: PHY reset failed.\n", bp->dev->name); in try_next_permutation()
514 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in try_next_permutation()
517 bp->sw_bmcr &= ~(BMCR_SPEED100); in try_next_permutation()
518 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in try_next_permutation()
528 struct bigmac *bp = (struct bigmac *) data; in bigmac_timer() local
529 void __iomem *tregs = bp->tregs; in bigmac_timer()
532 bp->timer_ticks++; in bigmac_timer()
533 if (bp->timer_state == ltrywait) { in bigmac_timer()
534 bp->sw_bmsr = bigmac_tcvr_read(bp, tregs, MII_BMSR); in bigmac_timer()
535 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in bigmac_timer()
536 if (bp->sw_bmsr & BMSR_LSTATUS) { in bigmac_timer()
538 bp->dev->name, in bigmac_timer()
539 (bp->sw_bmcr & BMCR_SPEED100) ? in bigmac_timer()
541 bp->timer_state = asleep; in bigmac_timer()
544 if (bp->timer_ticks >= 4) { in bigmac_timer()
547 ret = try_next_permutation(bp, tregs); in bigmac_timer()
550 bp->dev->name); in bigmac_timer()
551 ret = bigmac_init_hw(bp, 0); in bigmac_timer()
554 "BigMAC.\n", bp->dev->name); in bigmac_timer()
558 bp->timer_ticks = 0; in bigmac_timer()
567 bp->dev->name); in bigmac_timer()
569 bp->timer_ticks = 0; in bigmac_timer()
570 bp->timer_state = asleep; /* foo on you */ in bigmac_timer()
574 bp->bigmac_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2 sec. */ in bigmac_timer()
575 add_timer(&bp->bigmac_timer); in bigmac_timer()
582 static void bigmac_begin_auto_negotiation(struct bigmac *bp) in bigmac_begin_auto_negotiation() argument
584 void __iomem *tregs = bp->tregs; in bigmac_begin_auto_negotiation()
588 bp->sw_bmsr = bigmac_tcvr_read(bp, tregs, MII_BMSR); in bigmac_begin_auto_negotiation()
589 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in bigmac_begin_auto_negotiation()
592 bp->sw_bmcr = (BMCR_ISOLATE | BMCR_PDOWN | BMCR_LOOPBACK); in bigmac_begin_auto_negotiation()
593 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in bigmac_begin_auto_negotiation()
594 bp->sw_bmcr = (BMCR_RESET); in bigmac_begin_auto_negotiation()
595 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in bigmac_begin_auto_negotiation()
599 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in bigmac_begin_auto_negotiation()
600 if ((bp->sw_bmcr & BMCR_RESET) == 0) in bigmac_begin_auto_negotiation()
605 printk(KERN_ERR "%s: PHY reset failed.\n", bp->dev->name); in bigmac_begin_auto_negotiation()
607 bp->sw_bmcr = bigmac_tcvr_read(bp, tregs, MII_BMCR); in bigmac_begin_auto_negotiation()
610 bp->sw_bmcr |= BMCR_SPEED100; in bigmac_begin_auto_negotiation()
611 bigmac_tcvr_write(bp, tregs, MII_BMCR, bp->sw_bmcr); in bigmac_begin_auto_negotiation()
613 bp->timer_state = ltrywait; in bigmac_begin_auto_negotiation()
614 bp->timer_ticks = 0; in bigmac_begin_auto_negotiation()
615 bp->bigmac_timer.expires = jiffies + (12 * HZ) / 10; in bigmac_begin_auto_negotiation()
616 bp->bigmac_timer.data = (unsigned long) bp; in bigmac_begin_auto_negotiation()
617 bp->bigmac_timer.function = bigmac_timer; in bigmac_begin_auto_negotiation()
618 add_timer(&bp->bigmac_timer); in bigmac_begin_auto_negotiation()
621 static int bigmac_init_hw(struct bigmac *bp, int from_irq) in bigmac_init_hw() argument
623 void __iomem *gregs = bp->gregs; in bigmac_init_hw()
624 void __iomem *cregs = bp->creg; in bigmac_init_hw()
625 void __iomem *bregs = bp->bregs; in bigmac_init_hw()
626 unsigned char *e = &bp->dev->dev_addr[0]; in bigmac_init_hw()
629 bigmac_get_counters(bp, bregs); in bigmac_init_hw()
635 qec_init(bp); in bigmac_init_hw()
638 bigmac_init_rings(bp, from_irq); in bigmac_init_hw()
641 bigmac_tcvr_init(bp); in bigmac_init_hw()
644 bigmac_stop(bp); in bigmac_init_hw()
674 sbus_writel(bp->bblock_dvma + bib_offset(be_rxd, 0), in bigmac_init_hw()
676 sbus_writel(bp->bblock_dvma + bib_offset(be_txd, 0), in bigmac_init_hw()
710 bigmac_begin_auto_negotiation(bp); in bigmac_init_hw()
717 static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_status) in bigmac_is_medium_rare() argument
752 bigmac_init_hw(bp, 1); in bigmac_is_medium_rare()
756 static void bigmac_tx(struct bigmac *bp) in bigmac_tx() argument
758 struct be_txd *txbase = &bp->bmac_block->be_txd[0]; in bigmac_tx()
759 struct net_device *dev = bp->dev; in bigmac_tx()
762 spin_lock(&bp->lock); in bigmac_tx()
764 elem = bp->tx_old; in bigmac_tx()
766 while (elem != bp->tx_new) { in bigmac_tx()
775 skb = bp->tx_skbs[elem]; in bigmac_tx()
776 bp->enet_stats.tx_packets++; in bigmac_tx()
777 bp->enet_stats.tx_bytes += skb->len; in bigmac_tx()
778 dma_unmap_single(&bp->bigmac_op->dev, in bigmac_tx()
783 bp->tx_skbs[elem] = NULL; in bigmac_tx()
789 bp->tx_old = elem; in bigmac_tx()
792 TX_BUFFS_AVAIL(bp) > 0) in bigmac_tx()
793 netif_wake_queue(bp->dev); in bigmac_tx()
795 spin_unlock(&bp->lock); in bigmac_tx()
799 static void bigmac_rx(struct bigmac *bp) in bigmac_rx() argument
801 struct be_rxd *rxbase = &bp->bmac_block->be_rxd[0]; in bigmac_rx()
803 int elem = bp->rx_new, drops = 0; in bigmac_rx()
813 bp->enet_stats.rx_errors++; in bigmac_rx()
814 bp->enet_stats.rx_length_errors++; in bigmac_rx()
818 bp->enet_stats.rx_dropped++; in bigmac_rx()
823 skb = bp->rx_skbs[elem]; in bigmac_rx()
833 dma_unmap_single(&bp->bigmac_op->dev, in bigmac_rx()
837 bp->rx_skbs[elem] = new_skb; in bigmac_rx()
841 dma_map_single(&bp->bigmac_op->dev, in bigmac_rx()
851 struct sk_buff *copy_skb = netdev_alloc_skb(bp->dev, len + 2); in bigmac_rx()
859 dma_sync_single_for_cpu(&bp->bigmac_op->dev, in bigmac_rx()
863 dma_sync_single_for_device(&bp->bigmac_op->dev, in bigmac_rx()
875 skb->protocol = eth_type_trans(skb, bp->dev); in bigmac_rx()
877 bp->enet_stats.rx_packets++; in bigmac_rx()
878 bp->enet_stats.rx_bytes += len; in bigmac_rx()
883 bp->rx_new = elem; in bigmac_rx()
885 printk(KERN_NOTICE "%s: Memory squeeze, deferring packet.\n", bp->dev->name); in bigmac_rx()
890 struct bigmac *bp = (struct bigmac *) dev_id; in bigmac_interrupt() local
896 bmac_status = sbus_readl(bp->creg + CREG_STAT); in bigmac_interrupt()
897 qec_status = sbus_readl(bp->gregs + GLOB_STAT); in bigmac_interrupt()
902 bigmac_is_medium_rare(bp, qec_status, bmac_status); in bigmac_interrupt()
905 bigmac_tx(bp); in bigmac_interrupt()
908 bigmac_rx(bp); in bigmac_interrupt()
915 struct bigmac *bp = netdev_priv(dev); in bigmac_open() local
918 ret = request_irq(dev->irq, bigmac_interrupt, IRQF_SHARED, dev->name, bp); in bigmac_open()
923 init_timer(&bp->bigmac_timer); in bigmac_open()
924 ret = bigmac_init_hw(bp, 0); in bigmac_open()
926 free_irq(dev->irq, bp); in bigmac_open()
932 struct bigmac *bp = netdev_priv(dev); in bigmac_close() local
934 del_timer(&bp->bigmac_timer); in bigmac_close()
935 bp->timer_state = asleep; in bigmac_close()
936 bp->timer_ticks = 0; in bigmac_close()
938 bigmac_stop(bp); in bigmac_close()
939 bigmac_clean_rings(bp); in bigmac_close()
940 free_irq(dev->irq, bp); in bigmac_close()
946 struct bigmac *bp = netdev_priv(dev); in bigmac_tx_timeout() local
948 bigmac_init_hw(bp, 0); in bigmac_tx_timeout()
955 struct bigmac *bp = netdev_priv(dev); in bigmac_start_xmit() local
960 mapping = dma_map_single(&bp->bigmac_op->dev, skb->data, in bigmac_start_xmit()
964 spin_lock_irq(&bp->lock); in bigmac_start_xmit()
965 entry = bp->tx_new; in bigmac_start_xmit()
967 bp->bmac_block->be_txd[entry].tx_flags = TXD_UPDATE; in bigmac_start_xmit()
968 bp->tx_skbs[entry] = skb; in bigmac_start_xmit()
969 bp->bmac_block->be_txd[entry].tx_addr = mapping; in bigmac_start_xmit()
970 bp->bmac_block->be_txd[entry].tx_flags = in bigmac_start_xmit()
972 bp->tx_new = NEXT_TX(entry); in bigmac_start_xmit()
973 if (TX_BUFFS_AVAIL(bp) <= 0) in bigmac_start_xmit()
975 spin_unlock_irq(&bp->lock); in bigmac_start_xmit()
978 sbus_writel(CREG_CTRL_TWAKEUP, bp->creg + CREG_CTRL); in bigmac_start_xmit()
986 struct bigmac *bp = netdev_priv(dev); in bigmac_get_stats() local
988 bigmac_get_counters(bp, bp->bregs); in bigmac_get_stats()
989 return &bp->enet_stats; in bigmac_get_stats()
994 struct bigmac *bp = netdev_priv(dev); in bigmac_set_multicast() local
995 void __iomem *bregs = bp->bregs; in bigmac_set_multicast()
1046 struct bigmac *bp = netdev_priv(dev); in bigmac_get_link() local
1048 spin_lock_irq(&bp->lock); in bigmac_get_link()
1049 bp->sw_bmsr = bigmac_tcvr_read(bp, bp->tregs, MII_BMSR); in bigmac_get_link()
1050 spin_unlock_irq(&bp->lock); in bigmac_get_link()
1052 return (bp->sw_bmsr & BMSR_LSTATUS); in bigmac_get_link()
1078 struct bigmac *bp; in bigmac_ether_init() local
1093 bp = netdev_priv(dev); in bigmac_ether_init()
1094 bp->qec_op = qec_op; in bigmac_ether_init()
1095 bp->bigmac_op = op; in bigmac_ether_init()
1099 spin_lock_init(&bp->lock); in bigmac_ether_init()
1102 bp->gregs = of_ioremap(&qec_op->resource[0], 0, in bigmac_ether_init()
1104 if (!bp->gregs) { in bigmac_ether_init()
1110 if ((sbus_readl(bp->gregs + GLOB_CTRL) & 0xf0000000) != GLOB_CTRL_BMODE) { in bigmac_ether_init()
1116 if (qec_global_reset(bp->gregs)) in bigmac_ether_init()
1129 bp->bigmac_bursts = bsizes; in bigmac_ether_init()
1132 qec_init(bp); in bigmac_ether_init()
1135 bp->creg = of_ioremap(&op->resource[0], 0, in bigmac_ether_init()
1137 if (!bp->creg) { in bigmac_ether_init()
1143 bp->bregs = of_ioremap(&op->resource[1], 0, in bigmac_ether_init()
1145 if (!bp->bregs) { in bigmac_ether_init()
1153 bp->tregs = of_ioremap(&op->resource[2], 0, in bigmac_ether_init()
1155 if (!bp->tregs) { in bigmac_ether_init()
1161 bigmac_stop(bp); in bigmac_ether_init()
1164 bp->bmac_block = dma_alloc_coherent(&bp->bigmac_op->dev, in bigmac_ether_init()
1166 &bp->bblock_dvma, GFP_ATOMIC); in bigmac_ether_init()
1167 if (bp->bmac_block == NULL || bp->bblock_dvma == 0) in bigmac_ether_init()
1171 bp->board_rev = of_getintprop_default(bp->bigmac_op->dev.of_node, in bigmac_ether_init()
1175 init_timer(&bp->bigmac_timer); in bigmac_ether_init()
1176 bp->timer_state = asleep; in bigmac_ether_init()
1177 bp->timer_ticks = 0; in bigmac_ether_init()
1180 bp->dev = dev; in bigmac_ether_init()
1188 dev->irq = bp->bigmac_op->archdata.irqs[0]; in bigmac_ether_init()
1196 dev_set_drvdata(&bp->bigmac_op->dev, bp); in bigmac_ether_init()
1206 if (bp->gregs) in bigmac_ether_init()
1207 of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE); in bigmac_ether_init()
1208 if (bp->creg) in bigmac_ether_init()
1209 of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE); in bigmac_ether_init()
1210 if (bp->bregs) in bigmac_ether_init()
1211 of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE); in bigmac_ether_init()
1212 if (bp->tregs) in bigmac_ether_init()
1213 of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE); in bigmac_ether_init()
1215 if (bp->bmac_block) in bigmac_ether_init()
1216 dma_free_coherent(&bp->bigmac_op->dev, in bigmac_ether_init()
1218 bp->bmac_block, in bigmac_ether_init()
1219 bp->bblock_dvma); in bigmac_ether_init()
1241 struct bigmac *bp = platform_get_drvdata(op); in bigmac_sbus_remove() local
1243 struct net_device *net_dev = bp->dev; in bigmac_sbus_remove()
1250 of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE); in bigmac_sbus_remove()
1251 of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE); in bigmac_sbus_remove()
1252 of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE); in bigmac_sbus_remove()
1253 of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE); in bigmac_sbus_remove()
1256 bp->bmac_block, in bigmac_sbus_remove()
1257 bp->bblock_dvma); in bigmac_sbus_remove()