Lines Matching full:lp
267 #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
268 lp->tx_old+TX_RING_MOD_MASK-lp->tx_new:\
269 lp->tx_old - lp->tx_new-1)
295 static void load_csrs(struct lance_private *lp) in load_csrs() argument
299 if (lp->pio_buffer) in load_csrs()
302 leptr = LANCE_ADDR(lp->init_block_dvma); in load_csrs()
304 sbus_writew(LE_CSR1, lp->lregs + RAP); in load_csrs()
305 sbus_writew(leptr & 0xffff, lp->lregs + RDP); in load_csrs()
306 sbus_writew(LE_CSR2, lp->lregs + RAP); in load_csrs()
307 sbus_writew(leptr >> 16, lp->lregs + RDP); in load_csrs()
308 sbus_writew(LE_CSR3, lp->lregs + RAP); in load_csrs()
309 sbus_writew(lp->busmaster_regval, lp->lregs + RDP); in load_csrs()
312 sbus_writew(LE_CSR0, lp->lregs + RAP); in load_csrs()
318 struct lance_private *lp = netdev_priv(dev); in lance_init_ring_dvma() local
319 struct lance_init_block *ib = lp->init_block_mem; in lance_init_ring_dvma()
320 dma_addr_t aib = lp->init_block_dvma; in lance_init_ring_dvma()
326 lp->rx_new = lp->tx_new = 0; in lance_init_ring_dvma()
327 lp->rx_old = lp->tx_old = 0; in lance_init_ring_dvma()
375 struct lance_private *lp = netdev_priv(dev); in lance_init_ring_pio() local
376 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_init_ring_pio()
382 lp->rx_new = lp->tx_new = 0; in lance_init_ring_pio()
383 lp->rx_old = lp->tx_old = 0; in lance_init_ring_pio()
434 static void init_restart_ledma(struct lance_private *lp) in init_restart_ledma() argument
436 u32 csr = sbus_readl(lp->dregs + DMA_CSR); in init_restart_ledma()
440 while (sbus_readl(lp->dregs + DMA_CSR) & DMA_FIFO_ISDRAIN) in init_restart_ledma()
444 csr = sbus_readl(lp->dregs + DMA_CSR); in init_restart_ledma()
446 if (lp->burst_sizes & DMA_BURST32) in init_restart_ledma()
453 if (lp->tpe) in init_restart_ledma()
458 sbus_writel(csr, lp->dregs + DMA_CSR); in init_restart_ledma()
462 static int init_restart_lance(struct lance_private *lp) in init_restart_lance() argument
467 if (lp->dregs) in init_restart_lance()
468 init_restart_ledma(lp); in init_restart_lance()
470 sbus_writew(LE_CSR0, lp->lregs + RAP); in init_restart_lance()
471 sbus_writew(LE_C0_INIT, lp->lregs + RDP); in init_restart_lance()
475 regval = sbus_readw(lp->lregs + RDP); in init_restart_lance()
484 if (lp->dregs) in init_restart_lance()
485 printk("dcsr=%8.8x\n", sbus_readl(lp->dregs + DMA_CSR)); in init_restart_lance()
490 sbus_writew(LE_C0_IDON, lp->lregs + RDP); in init_restart_lance()
491 sbus_writew(LE_C0_INEA | LE_C0_STRT, lp->lregs + RDP); in init_restart_lance()
493 if (lp->dregs) { in init_restart_lance()
494 u32 csr = sbus_readl(lp->dregs + DMA_CSR); in init_restart_lance()
497 sbus_writel(csr, lp->dregs + DMA_CSR); in init_restart_lance()
505 struct lance_private *lp = netdev_priv(dev); in lance_rx_dvma() local
506 struct lance_init_block *ib = lp->init_block_mem; in lance_rx_dvma()
509 int len, entry = lp->rx_new; in lance_rx_dvma()
537 lp->rx_new = RX_NEXT(entry); in lance_rx_dvma()
559 lp->rx_new = entry; in lance_rx_dvma()
564 struct lance_private *lp = netdev_priv(dev); in lance_tx_dvma() local
565 struct lance_init_block *ib = lp->init_block_mem; in lance_tx_dvma()
568 spin_lock(&lp->lock); in lance_tx_dvma()
570 j = lp->tx_old; in lance_tx_dvma()
571 for (i = j; i != lp->tx_new; i = j) { in lance_tx_dvma()
588 if (lp->auto_select) { in lance_tx_dvma()
589 lp->tpe = 1 - lp->tpe; in lance_tx_dvma()
591 dev->name, lp->tpe?"TPE":"AUI"); in lance_tx_dvma()
592 STOP_LANCE(lp); in lance_tx_dvma()
593 lp->init_ring(dev); in lance_tx_dvma()
594 load_csrs(lp); in lance_tx_dvma()
595 init_restart_lance(lp); in lance_tx_dvma()
608 STOP_LANCE(lp); in lance_tx_dvma()
609 lp->init_ring(dev); in lance_tx_dvma()
610 load_csrs(lp); in lance_tx_dvma()
611 init_restart_lance(lp); in lance_tx_dvma()
633 lp->tx_old = j; in lance_tx_dvma()
639 spin_unlock(&lp->lock); in lance_tx_dvma()
674 struct lance_private *lp = netdev_priv(dev); in lance_rx_pio() local
675 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_rx_pio()
681 entry = lp->rx_new; in lance_rx_pio()
707 lp->rx_new = RX_NEXT(entry); in lance_rx_pio()
727 lp->rx_new = entry; in lance_rx_pio()
732 struct lance_private *lp = netdev_priv(dev); in lance_tx_pio() local
733 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_tx_pio()
736 spin_lock(&lp->lock); in lance_tx_pio()
738 j = lp->tx_old; in lance_tx_pio()
739 for (i = j; i != lp->tx_new; i = j) { in lance_tx_pio()
756 if (lp->auto_select) { in lance_tx_pio()
757 lp->tpe = 1 - lp->tpe; in lance_tx_pio()
759 dev->name, lp->tpe?"TPE":"AUI"); in lance_tx_pio()
760 STOP_LANCE(lp); in lance_tx_pio()
761 lp->init_ring(dev); in lance_tx_pio()
762 load_csrs(lp); in lance_tx_pio()
763 init_restart_lance(lp); in lance_tx_pio()
776 STOP_LANCE(lp); in lance_tx_pio()
777 lp->init_ring(dev); in lance_tx_pio()
778 load_csrs(lp); in lance_tx_pio()
779 init_restart_lance(lp); in lance_tx_pio()
801 lp->tx_old = j; in lance_tx_pio()
807 spin_unlock(&lp->lock); in lance_tx_pio()
813 struct lance_private *lp = netdev_priv(dev); in lance_interrupt() local
816 sbus_writew(LE_CSR0, lp->lregs + RAP); in lance_interrupt()
817 csr0 = sbus_readw(lp->lregs + RDP); in lance_interrupt()
821 lp->lregs + RDP); in lance_interrupt()
827 lp->lregs + RDP); in lance_interrupt()
831 lp->rx(dev); in lance_interrupt()
834 lp->tx(dev); in lance_interrupt()
843 if (lp->dregs) { in lance_interrupt()
844 u32 addr = sbus_readl(lp->dregs + DMA_ADDR); in lance_interrupt()
853 sbus_writew(LE_C0_STOP, lp->lregs + RDP); in lance_interrupt()
855 if (lp->dregs) { in lance_interrupt()
856 u32 dma_csr = sbus_readl(lp->dregs + DMA_CSR); in lance_interrupt()
859 sbus_writel(dma_csr, lp->dregs + DMA_CSR); in lance_interrupt()
862 lp->init_ring(dev); in lance_interrupt()
863 load_csrs(lp); in lance_interrupt()
864 init_restart_lance(lp); in lance_interrupt()
868 sbus_writew(LE_C0_INEA, lp->lregs + RDP); in lance_interrupt()
874 static void build_fake_packet(struct lance_private *lp) in build_fake_packet() argument
876 struct net_device *dev = lp->dev; in build_fake_packet()
879 entry = lp->tx_new & TX_RING_MOD_MASK; in build_fake_packet()
880 if (lp->pio_buffer) { in build_fake_packet()
881 struct lance_init_block __iomem *ib = lp->init_block_iomem; in build_fake_packet()
894 struct lance_init_block *ib = lp->init_block_mem; in build_fake_packet()
906 lp->tx_new = TX_NEXT(entry); in build_fake_packet()
911 struct lance_private *lp = netdev_priv(dev); in lance_open() local
914 STOP_LANCE(lp); in lance_open()
923 if (lp->dregs) { in lance_open()
924 u32 regval = lp->init_block_dvma & 0xff000000; in lance_open()
926 sbus_writel(regval, lp->dregs + DMA_TEST); in lance_open()
935 if (lp->pio_buffer) { in lance_open()
936 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_open()
941 struct lance_init_block *ib = lp->init_block_mem; in lance_open()
947 lp->init_ring(dev); in lance_open()
948 load_csrs(lp); in lance_open()
952 status = init_restart_lance(lp); in lance_open()
953 if (!status && lp->auto_select) { in lance_open()
954 build_fake_packet(lp); in lance_open()
955 sbus_writew(LE_C0_INEA | LE_C0_TDMD, lp->lregs + RDP); in lance_open()
963 struct lance_private *lp = netdev_priv(dev); in lance_close() local
966 del_timer_sync(&lp->multicast_timer); in lance_close()
968 STOP_LANCE(lp); in lance_close()
976 struct lance_private *lp = netdev_priv(dev); in lance_reset() local
979 STOP_LANCE(lp); in lance_reset()
982 if (lp->dregs) { in lance_reset()
986 csr = sbus_readl(lp->dregs + DMA_CSR); in lance_reset()
987 sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); in lance_reset()
989 sbus_writel(csr & ~DMA_RST_ENET, lp->dregs + DMA_CSR); in lance_reset()
991 addr = lp->init_block_dvma & 0xff000000; in lance_reset()
992 sbus_writel(addr, lp->dregs + DMA_TEST); in lance_reset()
994 lp->init_ring(dev); in lance_reset()
995 load_csrs(lp); in lance_reset()
997 status = init_restart_lance(lp); in lance_reset()
1097 struct lance_private *lp = netdev_priv(dev); in lance_tx_timeout() local
1100 dev->name, sbus_readw(lp->lregs + RDP)); in lance_tx_timeout()
1107 struct lance_private *lp = netdev_priv(dev); in lance_start_xmit() local
1114 spin_lock_irq(&lp->lock); in lance_start_xmit()
1118 entry = lp->tx_new & TX_RING_MOD_MASK; in lance_start_xmit()
1119 if (lp->pio_buffer) { in lance_start_xmit()
1120 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_start_xmit()
1128 struct lance_init_block *ib = lp->init_block_mem; in lance_start_xmit()
1137 lp->tx_new = TX_NEXT(entry); in lance_start_xmit()
1143 sbus_writew(LE_C0_INEA | LE_C0_TDMD, lp->lregs + RDP); in lance_start_xmit()
1148 if (lp->dregs) in lance_start_xmit()
1149 sbus_readw(lp->lregs + RDP); in lance_start_xmit()
1151 spin_unlock_irq(&lp->lock); in lance_start_xmit()
1161 struct lance_private *lp = netdev_priv(dev); in lance_load_multicast() local
1172 if (lp->pio_buffer) { in lance_load_multicast()
1173 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_load_multicast()
1177 struct lance_init_block *ib = lp->init_block_mem; in lance_load_multicast()
1189 if (lp->pio_buffer) { in lance_load_multicast()
1190 struct lance_init_block __iomem *ib = lp->init_block_iomem; in lance_load_multicast()
1196 struct lance_init_block *ib = lp->init_block_mem; in lance_load_multicast()
1205 struct lance_private *lp = netdev_priv(dev); in lance_set_multicast() local
1206 struct lance_init_block *ib_mem = lp->init_block_mem; in lance_set_multicast()
1207 struct lance_init_block __iomem *ib_iomem = lp->init_block_iomem; in lance_set_multicast()
1213 if (lp->tx_old != lp->tx_new) { in lance_set_multicast()
1214 mod_timer(&lp->multicast_timer, jiffies + 4); in lance_set_multicast()
1221 STOP_LANCE(lp); in lance_set_multicast()
1222 lp->init_ring(dev); in lance_set_multicast()
1224 if (lp->pio_buffer) in lance_set_multicast()
1230 if (lp->pio_buffer) in lance_set_multicast()
1236 if (lp->pio_buffer) in lance_set_multicast()
1242 load_csrs(lp); in lance_set_multicast()
1243 init_restart_lance(lp); in lance_set_multicast()
1249 struct lance_private *lp = from_timer(lp, t, multicast_timer); in lance_set_multicast_retry() local
1250 struct net_device *dev = lp->dev; in lance_set_multicast_retry()
1255 static void lance_free_hwresources(struct lance_private *lp) in lance_free_hwresources() argument
1257 if (lp->lregs) in lance_free_hwresources()
1258 of_iounmap(&lp->op->resource[0], lp->lregs, LANCE_REG_SIZE); in lance_free_hwresources()
1259 if (lp->dregs) { in lance_free_hwresources()
1260 struct platform_device *ledma = lp->ledma; in lance_free_hwresources()
1262 of_iounmap(&ledma->resource[0], lp->dregs, in lance_free_hwresources()
1265 if (lp->init_block_iomem) { in lance_free_hwresources()
1266 of_iounmap(&lp->lebuffer->resource[0], lp->init_block_iomem, in lance_free_hwresources()
1268 } else if (lp->init_block_mem) { in lance_free_hwresources()
1269 dma_free_coherent(&lp->op->dev, in lance_free_hwresources()
1271 lp->init_block_mem, in lance_free_hwresources()
1272 lp->init_block_dvma); in lance_free_hwresources()
1302 struct lance_private *lp; in sparc_lance_probe_one() local
1309 lp = netdev_priv(dev); in sparc_lance_probe_one()
1311 spin_lock_init(&lp->lock); in sparc_lance_probe_one()
1320 lp->lregs = of_ioremap(&op->resource[0], 0, in sparc_lance_probe_one()
1322 if (!lp->lregs) { in sparc_lance_probe_one()
1327 lp->ledma = ledma; in sparc_lance_probe_one()
1328 if (lp->ledma) { in sparc_lance_probe_one()
1329 lp->dregs = of_ioremap(&ledma->resource[0], 0, in sparc_lance_probe_one()
1332 if (!lp->dregs) { in sparc_lance_probe_one()
1339 lp->op = op; in sparc_lance_probe_one()
1340 lp->lebuffer = lebuffer; in sparc_lance_probe_one()
1347 lp->init_block_iomem = in sparc_lance_probe_one()
1350 if (!lp->init_block_iomem) { in sparc_lance_probe_one()
1354 lp->init_block_dvma = 0; in sparc_lance_probe_one()
1355 lp->pio_buffer = 1; in sparc_lance_probe_one()
1356 lp->init_ring = lance_init_ring_pio; in sparc_lance_probe_one()
1357 lp->rx = lance_rx_pio; in sparc_lance_probe_one()
1358 lp->tx = lance_tx_pio; in sparc_lance_probe_one()
1360 lp->init_block_mem = in sparc_lance_probe_one()
1363 &lp->init_block_dvma, GFP_ATOMIC); in sparc_lance_probe_one()
1364 if (!lp->init_block_mem) in sparc_lance_probe_one()
1367 lp->pio_buffer = 0; in sparc_lance_probe_one()
1368 lp->init_ring = lance_init_ring_dvma; in sparc_lance_probe_one()
1369 lp->rx = lance_rx_dvma; in sparc_lance_probe_one()
1370 lp->tx = lance_tx_dvma; in sparc_lance_probe_one()
1372 lp->busmaster_regval = of_getintprop_default(dp, "busmaster-regval", in sparc_lance_probe_one()
1377 lp->name = lancestr; in sparc_lance_probe_one()
1379 lp->burst_sizes = 0; in sparc_lance_probe_one()
1380 if (lp->ledma) { in sparc_lance_probe_one()
1388 lp->burst_sizes = of_getintprop_default(ledma_dp, in sparc_lance_probe_one()
1395 lp->burst_sizes &= sbmask; in sparc_lance_probe_one()
1423 lp->auto_select = 1; in sparc_lance_probe_one()
1424 lp->tpe = 0; in sparc_lance_probe_one()
1426 lp->auto_select = 0; in sparc_lance_probe_one()
1427 lp->tpe = 0; in sparc_lance_probe_one()
1429 lp->auto_select = 0; in sparc_lance_probe_one()
1430 lp->tpe = 1; in sparc_lance_probe_one()
1434 csr = sbus_readl(lp->dregs + DMA_CSR); in sparc_lance_probe_one()
1435 sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); in sparc_lance_probe_one()
1437 sbus_writel(csr & ~DMA_RST_ENET, lp->dregs + DMA_CSR); in sparc_lance_probe_one()
1439 lp->dregs = NULL; in sparc_lance_probe_one()
1441 lp->dev = dev; in sparc_lance_probe_one()
1454 timer_setup(&lp->multicast_timer, lance_set_multicast_retry, 0); in sparc_lance_probe_one()
1461 platform_set_drvdata(op, lp); in sparc_lance_probe_one()
1469 lance_free_hwresources(lp); in sparc_lance_probe_one()
1492 struct lance_private *lp = platform_get_drvdata(op); in sunlance_sbus_remove() local
1493 struct net_device *net_dev = lp->dev; in sunlance_sbus_remove()
1497 lance_free_hwresources(lp); in sunlance_sbus_remove()