Lines Matching refs:lp

174 	struct korina_private *lp = netdev_priv(dev);  in korina_abort_tx()  local
176 korina_abort_dma(dev, lp->tx_dma_regs); in korina_abort_tx()
181 struct korina_private *lp = netdev_priv(dev); in korina_abort_rx() local
183 korina_abort_dma(dev, lp->rx_dma_regs); in korina_abort_rx()
186 static void korina_start_rx(struct korina_private *lp, in korina_start_rx() argument
189 korina_start_dma(lp->rx_dma_regs, CPHYSADDR(rd)); in korina_start_rx()
192 static void korina_chain_rx(struct korina_private *lp, in korina_chain_rx() argument
195 korina_chain_dma(lp->rx_dma_regs, CPHYSADDR(rd)); in korina_chain_rx()
201 struct korina_private *lp = netdev_priv(dev); in korina_send_packet() local
207 spin_lock_irqsave(&lp->lock, flags); in korina_send_packet()
209 td = &lp->td_ring[lp->tx_chain_tail]; in korina_send_packet()
212 if (lp->tx_count >= (KORINA_NUM_TDS - 2)) { in korina_send_packet()
213 lp->tx_full = 1; in korina_send_packet()
215 if (lp->tx_count == (KORINA_NUM_TDS - 2)) in korina_send_packet()
220 spin_unlock_irqrestore(&lp->lock, flags); in korina_send_packet()
226 lp->tx_count++; in korina_send_packet()
228 lp->tx_skb[lp->tx_chain_tail] = skb; in korina_send_packet()
236 chain_prev = (lp->tx_chain_tail - 1) & KORINA_TDS_MASK; in korina_send_packet()
237 chain_next = (lp->tx_chain_tail + 1) & KORINA_TDS_MASK; in korina_send_packet()
239 if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) { in korina_send_packet()
240 if (lp->tx_chain_status == desc_empty) { in korina_send_packet()
245 lp->tx_chain_tail = chain_next; in korina_send_packet()
247 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), in korina_send_packet()
248 &lp->tx_dma_regs->dmandptr); in korina_send_packet()
250 lp->tx_chain_head = lp->tx_chain_tail; in korina_send_packet()
256 lp->td_ring[chain_prev].control &= in korina_send_packet()
259 lp->td_ring[chain_prev].link = CPHYSADDR(td); in korina_send_packet()
261 lp->tx_chain_tail = chain_next; in korina_send_packet()
263 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), in korina_send_packet()
264 &(lp->tx_dma_regs->dmandptr)); in korina_send_packet()
266 lp->tx_chain_head = lp->tx_chain_tail; in korina_send_packet()
267 lp->tx_chain_status = desc_empty; in korina_send_packet()
270 if (lp->tx_chain_status == desc_empty) { in korina_send_packet()
275 lp->tx_chain_tail = chain_next; in korina_send_packet()
276 lp->tx_chain_status = desc_filled; in korina_send_packet()
281 lp->td_ring[chain_prev].control &= in korina_send_packet()
283 lp->td_ring[chain_prev].link = CPHYSADDR(td); in korina_send_packet()
284 lp->tx_chain_tail = chain_next; in korina_send_packet()
290 spin_unlock_irqrestore(&lp->lock, flags); in korina_send_packet()
297 struct korina_private *lp = netdev_priv(dev); in mdio_read() local
300 mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8); in mdio_read()
302 writel(0, &lp->eth_regs->miimcfg); in mdio_read()
303 writel(0, &lp->eth_regs->miimcmd); in mdio_read()
304 writel(mii_id | reg, &lp->eth_regs->miimaddr); in mdio_read()
305 writel(ETH_MII_CMD_SCN, &lp->eth_regs->miimcmd); in mdio_read()
307 ret = (int)(readl(&lp->eth_regs->miimrdd)); in mdio_read()
313 struct korina_private *lp = netdev_priv(dev); in mdio_write() local
315 mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8); in mdio_write()
317 writel(0, &lp->eth_regs->miimcfg); in mdio_write()
318 writel(1, &lp->eth_regs->miimcmd); in mdio_write()
319 writel(mii_id | reg, &lp->eth_regs->miimaddr); in mdio_write()
320 writel(ETH_MII_CMD_SCN, &lp->eth_regs->miimcmd); in mdio_write()
321 writel(val, &lp->eth_regs->miimwtd); in mdio_write()
328 struct korina_private *lp = netdev_priv(dev); in korina_rx_dma_interrupt() local
332 dmas = readl(&lp->rx_dma_regs->dmas); in korina_rx_dma_interrupt()
334 dmasm = readl(&lp->rx_dma_regs->dmasm); in korina_rx_dma_interrupt()
337 &lp->rx_dma_regs->dmasm); in korina_rx_dma_interrupt()
339 napi_schedule(&lp->napi); in korina_rx_dma_interrupt()
353 struct korina_private *lp = netdev_priv(dev); in korina_rx() local
354 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done]; in korina_rx()
363 skb = lp->rx_skb[lp->rx_next_done]; in korina_rx()
398 pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data; in korina_rx()
421 lp->rx_skb[lp->rx_next_done] = skb_new; in korina_rx()
434 lp->rd_ring[(lp->rx_next_done - 1) & in korina_rx()
438 lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK; in korina_rx()
440 rd = &lp->rd_ring[lp->rx_next_done]; in korina_rx()
441 writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas); in korina_rx()
444 dmas = readl(&lp->rx_dma_regs->dmas); in korina_rx()
448 &lp->rx_dma_regs->dmas); in korina_rx()
450 lp->dma_halt_cnt++; in korina_rx()
452 skb = lp->rx_skb[lp->rx_next_done]; in korina_rx()
455 korina_chain_rx(lp, rd); in korina_rx()
463 struct korina_private *lp = in korina_poll() local
465 struct net_device *dev = lp->dev; in korina_poll()
472 writel(readl(&lp->rx_dma_regs->dmasm) & in korina_poll()
474 &lp->rx_dma_regs->dmasm); in korina_poll()
484 struct korina_private *lp = netdev_priv(dev); in korina_multicast_list() local
521 &lp->eth_regs->ethhash0); in korina_multicast_list()
523 &lp->eth_regs->ethhash1); in korina_multicast_list()
526 spin_lock_irqsave(&lp->lock, flags); in korina_multicast_list()
527 writel(recognise, &lp->eth_regs->etharc); in korina_multicast_list()
528 spin_unlock_irqrestore(&lp->lock, flags); in korina_multicast_list()
533 struct korina_private *lp = netdev_priv(dev); in korina_tx() local
534 struct dma_desc *td = &lp->td_ring[lp->tx_next_done]; in korina_tx()
538 spin_lock(&lp->lock); in korina_tx()
542 if (lp->tx_full == 1) { in korina_tx()
544 lp->tx_full = 0; in korina_tx()
547 devcs = lp->td_ring[lp->tx_next_done].devcs; in korina_tx()
559 lp->tx_skb[lp->tx_next_done]->len; in korina_tx()
586 if (lp->tx_skb[lp->tx_next_done]) { in korina_tx()
587 dev_kfree_skb_any(lp->tx_skb[lp->tx_next_done]); in korina_tx()
588 lp->tx_skb[lp->tx_next_done] = NULL; in korina_tx()
591 lp->td_ring[lp->tx_next_done].control = DMA_DESC_IOF; in korina_tx()
592 lp->td_ring[lp->tx_next_done].devcs = ETH_TX_FD | ETH_TX_LD; in korina_tx()
593 lp->td_ring[lp->tx_next_done].link = 0; in korina_tx()
594 lp->td_ring[lp->tx_next_done].ca = 0; in korina_tx()
595 lp->tx_count--; in korina_tx()
598 lp->tx_next_done = (lp->tx_next_done + 1) & KORINA_TDS_MASK; in korina_tx()
599 td = &lp->td_ring[lp->tx_next_done]; in korina_tx()
604 dmas = readl(&lp->tx_dma_regs->dmas); in korina_tx()
605 writel(~dmas, &lp->tx_dma_regs->dmas); in korina_tx()
607 writel(readl(&lp->tx_dma_regs->dmasm) & in korina_tx()
609 &lp->tx_dma_regs->dmasm); in korina_tx()
611 spin_unlock(&lp->lock); in korina_tx()
618 struct korina_private *lp = netdev_priv(dev); in korina_tx_dma_interrupt() local
622 dmas = readl(&lp->tx_dma_regs->dmas); in korina_tx_dma_interrupt()
625 dmasm = readl(&lp->tx_dma_regs->dmasm); in korina_tx_dma_interrupt()
627 &lp->tx_dma_regs->dmasm); in korina_tx_dma_interrupt()
631 if (lp->tx_chain_status == desc_filled && in korina_tx_dma_interrupt()
632 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) { in korina_tx_dma_interrupt()
633 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), in korina_tx_dma_interrupt()
634 &(lp->tx_dma_regs->dmandptr)); in korina_tx_dma_interrupt()
635 lp->tx_chain_status = desc_empty; in korina_tx_dma_interrupt()
636 lp->tx_chain_head = lp->tx_chain_tail; in korina_tx_dma_interrupt()
652 struct korina_private *lp = netdev_priv(dev); in korina_check_media() local
654 mii_check_media(&lp->mii_if, 0, init_media); in korina_check_media()
656 if (lp->mii_if.full_duplex) in korina_check_media()
657 writel(readl(&lp->eth_regs->ethmac2) | ETH_MAC2_FD, in korina_check_media()
658 &lp->eth_regs->ethmac2); in korina_check_media()
660 writel(readl(&lp->eth_regs->ethmac2) & ~ETH_MAC2_FD, in korina_check_media()
661 &lp->eth_regs->ethmac2); in korina_check_media()
667 struct korina_private *lp = netdev_priv(dev); in korina_poll_media() local
670 mod_timer(&lp->media_check_timer, jiffies + HZ); in korina_poll_media()
685 struct korina_private *lp = netdev_priv(dev); in korina_ioctl() local
691 spin_lock_irq(&lp->lock); in korina_ioctl()
692 rc = generic_mii_ioctl(&lp->mii_if, data, cmd, NULL); in korina_ioctl()
693 spin_unlock_irq(&lp->lock); in korina_ioctl()
694 korina_set_carrier(&lp->mii_if); in korina_ioctl()
703 struct korina_private *lp = netdev_priv(dev); in netdev_get_drvinfo() local
707 strcpy(info->bus_info, lp->dev->name); in netdev_get_drvinfo()
712 struct korina_private *lp = netdev_priv(dev); in netdev_get_settings() local
715 spin_lock_irq(&lp->lock); in netdev_get_settings()
716 rc = mii_ethtool_gset(&lp->mii_if, cmd); in netdev_get_settings()
717 spin_unlock_irq(&lp->lock); in netdev_get_settings()
724 struct korina_private *lp = netdev_priv(dev); in netdev_set_settings() local
727 spin_lock_irq(&lp->lock); in netdev_set_settings()
728 rc = mii_ethtool_sset(&lp->mii_if, cmd); in netdev_set_settings()
729 spin_unlock_irq(&lp->lock); in netdev_set_settings()
730 korina_set_carrier(&lp->mii_if); in netdev_set_settings()
737 struct korina_private *lp = netdev_priv(dev); in netdev_get_link() local
739 return mii_link_ok(&lp->mii_if); in netdev_get_link()
751 struct korina_private *lp = netdev_priv(dev); in korina_alloc_ring() local
757 lp->td_ring[i].control = DMA_DESC_IOF; in korina_alloc_ring()
758 lp->td_ring[i].devcs = ETH_TX_FD | ETH_TX_LD; in korina_alloc_ring()
759 lp->td_ring[i].ca = 0; in korina_alloc_ring()
760 lp->td_ring[i].link = 0; in korina_alloc_ring()
762 lp->tx_next_done = lp->tx_chain_head = lp->tx_chain_tail = in korina_alloc_ring()
763 lp->tx_full = lp->tx_count = 0; in korina_alloc_ring()
764 lp->tx_chain_status = desc_empty; in korina_alloc_ring()
771 lp->rx_skb[i] = skb; in korina_alloc_ring()
772 lp->rd_ring[i].control = DMA_DESC_IOD | in korina_alloc_ring()
774 lp->rd_ring[i].devcs = 0; in korina_alloc_ring()
775 lp->rd_ring[i].ca = CPHYSADDR(skb->data); in korina_alloc_ring()
776 lp->rd_ring[i].link = CPHYSADDR(&lp->rd_ring[i+1]); in korina_alloc_ring()
781 lp->rd_ring[i - 1].link = CPHYSADDR(&lp->rd_ring[0]); in korina_alloc_ring()
782 lp->rd_ring[i - 1].control |= DMA_DESC_COD; in korina_alloc_ring()
784 lp->rx_next_done = 0; in korina_alloc_ring()
785 lp->rx_chain_head = 0; in korina_alloc_ring()
786 lp->rx_chain_tail = 0; in korina_alloc_ring()
787 lp->rx_chain_status = desc_empty; in korina_alloc_ring()
794 struct korina_private *lp = netdev_priv(dev); in korina_free_ring() local
798 lp->rd_ring[i].control = 0; in korina_free_ring()
799 if (lp->rx_skb[i]) in korina_free_ring()
800 dev_kfree_skb_any(lp->rx_skb[i]); in korina_free_ring()
801 lp->rx_skb[i] = NULL; in korina_free_ring()
805 lp->td_ring[i].control = 0; in korina_free_ring()
806 if (lp->tx_skb[i]) in korina_free_ring()
807 dev_kfree_skb_any(lp->tx_skb[i]); in korina_free_ring()
808 lp->tx_skb[i] = NULL; in korina_free_ring()
817 struct korina_private *lp = netdev_priv(dev); in korina_init() local
824 writel(0, &lp->eth_regs->ethintfc); in korina_init()
825 while ((readl(&lp->eth_regs->ethintfc) & ETH_INT_FC_RIP)) in korina_init()
829 writel(ETH_INT_FC_EN, &lp->eth_regs->ethintfc); in korina_init()
838 writel(0, &lp->rx_dma_regs->dmas); in korina_init()
840 korina_start_rx(lp, &lp->rd_ring[0]); in korina_init()
842 writel(readl(&lp->tx_dma_regs->dmasm) & in korina_init()
844 &lp->tx_dma_regs->dmasm); in korina_init()
845 writel(readl(&lp->rx_dma_regs->dmasm) & in korina_init()
847 &lp->rx_dma_regs->dmasm); in korina_init()
850 writel(ETH_ARC_AB, &lp->eth_regs->etharc); in korina_init()
853 writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal0); in korina_init()
854 writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah0); in korina_init()
856 writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal1); in korina_init()
857 writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah1); in korina_init()
859 writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal2); in korina_init()
860 writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah2); in korina_init()
862 writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal3); in korina_init()
863 writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah3); in korina_init()
868 &lp->eth_regs->ethmac2); in korina_init()
871 writel(0x15, &lp->eth_regs->ethipgt); in korina_init()
873 writel(0x12, &lp->eth_regs->ethipgr); in korina_init()
878 &lp->eth_regs->ethmcp); in korina_init()
881 writel(48, &lp->eth_regs->ethfifott); in korina_init()
883 writel(ETH_MAC1_RE, &lp->eth_regs->ethmac1); in korina_init()
885 napi_enable(&lp->napi); in korina_init()
896 struct korina_private *lp = container_of(work, in korina_restart_task() local
898 struct net_device *dev = lp->dev; in korina_restart_task()
903 disable_irq(lp->rx_irq); in korina_restart_task()
904 disable_irq(lp->tx_irq); in korina_restart_task()
905 disable_irq(lp->ovr_irq); in korina_restart_task()
906 disable_irq(lp->und_irq); in korina_restart_task()
908 writel(readl(&lp->tx_dma_regs->dmasm) | in korina_restart_task()
910 &lp->tx_dma_regs->dmasm); in korina_restart_task()
911 writel(readl(&lp->rx_dma_regs->dmasm) | in korina_restart_task()
913 &lp->rx_dma_regs->dmasm); in korina_restart_task()
917 napi_disable(&lp->napi); in korina_restart_task()
925 enable_irq(lp->und_irq); in korina_restart_task()
926 enable_irq(lp->ovr_irq); in korina_restart_task()
927 enable_irq(lp->tx_irq); in korina_restart_task()
928 enable_irq(lp->rx_irq); in korina_restart_task()
933 struct korina_private *lp = netdev_priv(dev); in korina_clear_and_restart() local
936 writel(value, &lp->eth_regs->ethintfc); in korina_clear_and_restart()
937 schedule_work(&lp->restart_task); in korina_clear_and_restart()
944 struct korina_private *lp = netdev_priv(dev); in korina_und_interrupt() local
947 spin_lock(&lp->lock); in korina_und_interrupt()
949 und = readl(&lp->eth_regs->ethintfc); in korina_und_interrupt()
954 spin_unlock(&lp->lock); in korina_und_interrupt()
961 struct korina_private *lp = netdev_priv(dev); in korina_tx_timeout() local
963 schedule_work(&lp->restart_task); in korina_tx_timeout()
971 struct korina_private *lp = netdev_priv(dev); in korina_ovr_interrupt() local
974 spin_lock(&lp->lock); in korina_ovr_interrupt()
975 ovr = readl(&lp->eth_regs->ethintfc); in korina_ovr_interrupt()
980 spin_unlock(&lp->lock); in korina_ovr_interrupt()
996 struct korina_private *lp = netdev_priv(dev); in korina_open() local
1009 ret = request_irq(lp->rx_irq, korina_rx_dma_interrupt, in korina_open()
1013 dev->name, lp->rx_irq); in korina_open()
1016 ret = request_irq(lp->tx_irq, korina_tx_dma_interrupt, in korina_open()
1020 dev->name, lp->tx_irq); in korina_open()
1025 ret = request_irq(lp->ovr_irq, korina_ovr_interrupt, in korina_open()
1029 dev->name, lp->ovr_irq); in korina_open()
1034 ret = request_irq(lp->und_irq, korina_und_interrupt, in korina_open()
1038 dev->name, lp->und_irq); in korina_open()
1041 mod_timer(&lp->media_check_timer, jiffies + 1); in korina_open()
1046 free_irq(lp->ovr_irq, dev); in korina_open()
1048 free_irq(lp->tx_irq, dev); in korina_open()
1050 free_irq(lp->rx_irq, dev); in korina_open()
1058 struct korina_private *lp = netdev_priv(dev); in korina_close() local
1061 del_timer(&lp->media_check_timer); in korina_close()
1064 disable_irq(lp->rx_irq); in korina_close()
1065 disable_irq(lp->tx_irq); in korina_close()
1066 disable_irq(lp->ovr_irq); in korina_close()
1067 disable_irq(lp->und_irq); in korina_close()
1070 tmp = readl(&lp->tx_dma_regs->dmasm); in korina_close()
1072 writel(tmp, &lp->tx_dma_regs->dmasm); in korina_close()
1075 tmp = readl(&lp->rx_dma_regs->dmasm); in korina_close()
1077 writel(tmp, &lp->rx_dma_regs->dmasm); in korina_close()
1081 napi_disable(&lp->napi); in korina_close()
1083 cancel_work_sync(&lp->restart_task); in korina_close()
1085 free_irq(lp->rx_irq, dev); in korina_close()
1086 free_irq(lp->tx_irq, dev); in korina_close()
1087 free_irq(lp->ovr_irq, dev); in korina_close()
1088 free_irq(lp->und_irq, dev); in korina_close()
1111 struct korina_private *lp; in korina_probe() local
1122 lp = netdev_priv(dev); in korina_probe()
1127 lp->rx_irq = platform_get_irq_byname(pdev, "korina_rx"); in korina_probe()
1128 lp->tx_irq = platform_get_irq_byname(pdev, "korina_tx"); in korina_probe()
1129 lp->ovr_irq = platform_get_irq_byname(pdev, "korina_ovr"); in korina_probe()
1130 lp->und_irq = platform_get_irq_byname(pdev, "korina_und"); in korina_probe()
1134 lp->eth_regs = ioremap_nocache(r->start, resource_size(r)); in korina_probe()
1135 if (!lp->eth_regs) { in korina_probe()
1142 lp->rx_dma_regs = ioremap_nocache(r->start, resource_size(r)); in korina_probe()
1143 if (!lp->rx_dma_regs) { in korina_probe()
1150 lp->tx_dma_regs = ioremap_nocache(r->start, resource_size(r)); in korina_probe()
1151 if (!lp->tx_dma_regs) { in korina_probe()
1157 lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL); in korina_probe()
1158 if (!lp->td_ring) { in korina_probe()
1164 dma_cache_inv((unsigned long)(lp->td_ring), in korina_probe()
1168 lp->td_ring = (struct dma_desc *)KSEG1ADDR(lp->td_ring); in korina_probe()
1169 lp->rd_ring = &lp->td_ring[KORINA_NUM_TDS]; in korina_probe()
1171 spin_lock_init(&lp->lock); in korina_probe()
1173 dev->irq = lp->rx_irq; in korina_probe()
1174 lp->dev = dev; in korina_probe()
1179 netif_napi_add(dev, &lp->napi, korina_poll, 64); in korina_probe()
1181 lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05); in korina_probe()
1182 lp->mii_if.dev = dev; in korina_probe()
1183 lp->mii_if.mdio_read = mdio_read; in korina_probe()
1184 lp->mii_if.mdio_write = mdio_write; in korina_probe()
1185 lp->mii_if.phy_id = lp->phy_addr; in korina_probe()
1186 lp->mii_if.phy_id_mask = 0x1f; in korina_probe()
1187 lp->mii_if.reg_num_mask = 0x1f; in korina_probe()
1195 setup_timer(&lp->media_check_timer, korina_poll_media, (unsigned long) dev); in korina_probe()
1197 INIT_WORK(&lp->restart_task, korina_restart_task); in korina_probe()
1205 kfree(lp->td_ring); in korina_probe()
1207 iounmap(lp->tx_dma_regs); in korina_probe()
1209 iounmap(lp->rx_dma_regs); in korina_probe()
1211 iounmap(lp->eth_regs); in korina_probe()
1220 struct korina_private *lp = netdev_priv(bif->dev); in korina_remove() local
1222 iounmap(lp->eth_regs); in korina_remove()
1223 iounmap(lp->rx_dma_regs); in korina_remove()
1224 iounmap(lp->tx_dma_regs); in korina_remove()