Lines Matching refs:lp

61 u32 temac_ior(struct temac_local *lp, int offset)  in temac_ior()  argument
63 return in_be32((u32 *)(lp->regs + offset)); in temac_ior()
66 void temac_iow(struct temac_local *lp, int offset, u32 value) in temac_iow() argument
68 out_be32((u32 *) (lp->regs + offset), value); in temac_iow()
71 int temac_indirect_busywait(struct temac_local *lp) in temac_indirect_busywait() argument
75 while (!(temac_ior(lp, XTE_RDY0_OFFSET) & XTE_RDY0_HARD_ACS_RDY_MASK)) { in temac_indirect_busywait()
90 u32 temac_indirect_in32(struct temac_local *lp, int reg) in temac_indirect_in32() argument
94 if (temac_indirect_busywait(lp)) in temac_indirect_in32()
96 temac_iow(lp, XTE_CTL0_OFFSET, reg); in temac_indirect_in32()
97 if (temac_indirect_busywait(lp)) in temac_indirect_in32()
99 val = temac_ior(lp, XTE_LSW0_OFFSET); in temac_indirect_in32()
109 void temac_indirect_out32(struct temac_local *lp, int reg, u32 value) in temac_indirect_out32() argument
111 if (temac_indirect_busywait(lp)) in temac_indirect_out32()
113 temac_iow(lp, XTE_LSW0_OFFSET, value); in temac_indirect_out32()
114 temac_iow(lp, XTE_CTL0_OFFSET, CNTLREG_WRITE_ENABLE_MASK | reg); in temac_indirect_out32()
122 static u32 temac_dma_in32(struct temac_local *lp, int reg) in temac_dma_in32() argument
124 return in_be32((u32 *)(lp->sdma_regs + (reg << 2))); in temac_dma_in32()
132 static void temac_dma_out32(struct temac_local *lp, int reg, u32 value) in temac_dma_out32() argument
134 out_be32((u32 *)(lp->sdma_regs + (reg << 2)), value); in temac_dma_out32()
146 static u32 temac_dma_dcr_in(struct temac_local *lp, int reg) in temac_dma_dcr_in() argument
148 return dcr_read(lp->sdma_dcrs, reg); in temac_dma_dcr_in()
154 static void temac_dma_dcr_out(struct temac_local *lp, int reg, u32 value) in temac_dma_dcr_out() argument
156 dcr_write(lp->sdma_dcrs, reg, value); in temac_dma_dcr_out()
163 static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, in temac_dcr_setup() argument
172 lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0)); in temac_dcr_setup()
173 lp->dma_in = temac_dma_dcr_in; in temac_dcr_setup()
174 lp->dma_out = temac_dma_dcr_out; in temac_dcr_setup()
188 static int temac_dcr_setup(struct temac_local *lp, struct platform_device *op, in temac_dcr_setup() argument
201 struct temac_local *lp = netdev_priv(ndev); in temac_dma_bd_release() local
205 if (!lp->rx_skb[i]) in temac_dma_bd_release()
208 dma_unmap_single(ndev->dev.parent, lp->rx_bd_v[i].phys, in temac_dma_bd_release()
210 dev_kfree_skb(lp->rx_skb[i]); in temac_dma_bd_release()
213 if (lp->rx_bd_v) in temac_dma_bd_release()
215 sizeof(*lp->rx_bd_v) * RX_BD_NUM, in temac_dma_bd_release()
216 lp->rx_bd_v, lp->rx_bd_p); in temac_dma_bd_release()
217 if (lp->tx_bd_v) in temac_dma_bd_release()
219 sizeof(*lp->tx_bd_v) * TX_BD_NUM, in temac_dma_bd_release()
220 lp->tx_bd_v, lp->tx_bd_p); in temac_dma_bd_release()
221 if (lp->rx_skb) in temac_dma_bd_release()
222 kfree(lp->rx_skb); in temac_dma_bd_release()
230 struct temac_local *lp = netdev_priv(ndev); in temac_dma_bd_init() local
234 lp->rx_skb = kzalloc(sizeof(*lp->rx_skb) * RX_BD_NUM, GFP_KERNEL); in temac_dma_bd_init()
235 if (!lp->rx_skb) { in temac_dma_bd_init()
242 lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent, in temac_dma_bd_init()
243 sizeof(*lp->tx_bd_v) * TX_BD_NUM, in temac_dma_bd_init()
244 &lp->tx_bd_p, GFP_KERNEL); in temac_dma_bd_init()
245 if (!lp->tx_bd_v) { in temac_dma_bd_init()
250 lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent, in temac_dma_bd_init()
251 sizeof(*lp->rx_bd_v) * RX_BD_NUM, in temac_dma_bd_init()
252 &lp->rx_bd_p, GFP_KERNEL); in temac_dma_bd_init()
253 if (!lp->rx_bd_v) { in temac_dma_bd_init()
259 memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM); in temac_dma_bd_init()
261 lp->tx_bd_v[i].next = lp->tx_bd_p + in temac_dma_bd_init()
262 sizeof(*lp->tx_bd_v) * ((i + 1) % TX_BD_NUM); in temac_dma_bd_init()
265 memset(lp->rx_bd_v, 0, sizeof(*lp->rx_bd_v) * RX_BD_NUM); in temac_dma_bd_init()
267 lp->rx_bd_v[i].next = lp->rx_bd_p + in temac_dma_bd_init()
268 sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM); in temac_dma_bd_init()
277 lp->rx_skb[i] = skb; in temac_dma_bd_init()
279 lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent, in temac_dma_bd_init()
283 lp->rx_bd_v[i].len = XTE_MAX_JUMBO_FRAME_SIZE; in temac_dma_bd_init()
284 lp->rx_bd_v[i].app0 = STS_CTRL_APP0_IRQONEND; in temac_dma_bd_init()
287 lp->dma_out(lp, TX_CHNL_CTRL, 0x10220400 | in temac_dma_bd_init()
293 lp->dma_out(lp, RX_CHNL_CTRL, 0xff070000 | in temac_dma_bd_init()
300 lp->dma_out(lp, RX_CURDESC_PTR, lp->rx_bd_p); in temac_dma_bd_init()
301 lp->dma_out(lp, RX_TAILDESC_PTR, in temac_dma_bd_init()
302 lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); in temac_dma_bd_init()
303 lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p); in temac_dma_bd_init()
318 struct temac_local *lp = netdev_priv(ndev); in temac_set_mac_address() local
327 mutex_lock(&lp->indirect_mutex); in temac_set_mac_address()
328 temac_indirect_out32(lp, XTE_UAW0_OFFSET, in temac_set_mac_address()
335 temac_indirect_out32(lp, XTE_UAW1_OFFSET, in temac_set_mac_address()
338 mutex_unlock(&lp->indirect_mutex); in temac_set_mac_address()
352 struct temac_local *lp = netdev_priv(ndev); in temac_set_multicast_list() local
356 mutex_lock(&lp->indirect_mutex); in temac_set_multicast_list()
366 temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK); in temac_set_multicast_list()
379 temac_indirect_out32(lp, XTE_MAW0_OFFSET, in temac_set_multicast_list()
383 temac_indirect_out32(lp, XTE_MAW1_OFFSET, in temac_set_multicast_list()
388 val = temac_indirect_in32(lp, XTE_AFM_OFFSET); in temac_set_multicast_list()
389 temac_indirect_out32(lp, XTE_AFM_OFFSET, in temac_set_multicast_list()
391 temac_indirect_out32(lp, XTE_MAW0_OFFSET, 0); in temac_set_multicast_list()
392 temac_indirect_out32(lp, XTE_MAW1_OFFSET, 0); in temac_set_multicast_list()
395 mutex_unlock(&lp->indirect_mutex); in temac_set_multicast_list()
483 struct temac_local *lp = netdev_priv(ndev); in temac_setoptions() local
487 mutex_lock(&lp->indirect_mutex); in temac_setoptions()
489 reg = temac_indirect_in32(lp, tp->reg) & ~tp->m_or; in temac_setoptions()
492 temac_indirect_out32(lp, tp->reg, reg); in temac_setoptions()
495 lp->options |= options; in temac_setoptions()
496 mutex_unlock(&lp->indirect_mutex); in temac_setoptions()
504 struct temac_local *lp = netdev_priv(ndev); in temac_device_reset() local
515 mutex_lock(&lp->indirect_mutex); in temac_device_reset()
517 temac_indirect_out32(lp, XTE_RXC1_OFFSET, XTE_RXC1_RXRST_MASK); in temac_device_reset()
519 while (temac_indirect_in32(lp, XTE_RXC1_OFFSET) & XTE_RXC1_RXRST_MASK) { in temac_device_reset()
529 temac_indirect_out32(lp, XTE_TXC_OFFSET, XTE_TXC_TXRST_MASK); in temac_device_reset()
531 while (temac_indirect_in32(lp, XTE_TXC_OFFSET) & XTE_TXC_TXRST_MASK) { in temac_device_reset()
541 val = temac_indirect_in32(lp, XTE_RXC1_OFFSET); in temac_device_reset()
542 temac_indirect_out32(lp, XTE_RXC1_OFFSET, val & ~XTE_RXC1_RXEN_MASK); in temac_device_reset()
545 lp->dma_out(lp, DMA_CONTROL_REG, DMA_CONTROL_RST); in temac_device_reset()
547 while (lp->dma_in(lp, DMA_CONTROL_REG) & DMA_CONTROL_RST) { in temac_device_reset()
555 lp->dma_out(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE); in temac_device_reset()
562 temac_indirect_out32(lp, XTE_RXC0_OFFSET, 0); in temac_device_reset()
563 temac_indirect_out32(lp, XTE_RXC1_OFFSET, 0); in temac_device_reset()
564 temac_indirect_out32(lp, XTE_TXC_OFFSET, 0); in temac_device_reset()
565 temac_indirect_out32(lp, XTE_FCC_OFFSET, XTE_FCC_RXFLO_MASK); in temac_device_reset()
567 mutex_unlock(&lp->indirect_mutex); in temac_device_reset()
572 lp->options & ~(XTE_OPTION_TXEN | XTE_OPTION_RXEN)); in temac_device_reset()
578 if (temac_setoptions(ndev, lp->options)) in temac_device_reset()
587 struct temac_local *lp = netdev_priv(ndev); in temac_adjust_link() local
588 struct phy_device *phy = lp->phy_dev; in temac_adjust_link()
595 mutex_lock(&lp->indirect_mutex); in temac_adjust_link()
596 if (lp->last_link != link_state) { in temac_adjust_link()
597 mii_speed = temac_indirect_in32(lp, XTE_EMCFG_OFFSET); in temac_adjust_link()
607 temac_indirect_out32(lp, XTE_EMCFG_OFFSET, mii_speed); in temac_adjust_link()
608 lp->last_link = link_state; in temac_adjust_link()
611 mutex_unlock(&lp->indirect_mutex); in temac_adjust_link()
616 struct temac_local *lp = netdev_priv(ndev); in temac_start_xmit_done() local
620 cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; in temac_start_xmit_done()
637 lp->tx_bd_ci++; in temac_start_xmit_done()
638 if (lp->tx_bd_ci >= TX_BD_NUM) in temac_start_xmit_done()
639 lp->tx_bd_ci = 0; in temac_start_xmit_done()
641 cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; in temac_start_xmit_done()
648 static inline int temac_check_tx_bd_space(struct temac_local *lp, int num_frag) in temac_check_tx_bd_space() argument
653 tail = lp->tx_bd_tail; in temac_check_tx_bd_space()
654 cur_p = &lp->tx_bd_v[tail]; in temac_check_tx_bd_space()
664 cur_p = &lp->tx_bd_v[tail]; in temac_check_tx_bd_space()
673 struct temac_local *lp = netdev_priv(ndev); in temac_start_xmit() local
682 start_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; in temac_start_xmit()
683 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; in temac_start_xmit()
685 if (temac_check_tx_bd_space(lp, num_frag)) { in temac_start_xmit()
710 lp->tx_bd_tail++; in temac_start_xmit()
711 if (lp->tx_bd_tail >= TX_BD_NUM) in temac_start_xmit()
712 lp->tx_bd_tail = 0; in temac_start_xmit()
714 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; in temac_start_xmit()
725 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; in temac_start_xmit()
726 lp->tx_bd_tail++; in temac_start_xmit()
727 if (lp->tx_bd_tail >= TX_BD_NUM) in temac_start_xmit()
728 lp->tx_bd_tail = 0; in temac_start_xmit()
731 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */ in temac_start_xmit()
739 struct temac_local *lp = netdev_priv(ndev); in ll_temac_recv() local
747 spin_lock_irqsave(&lp->rx_lock, flags); in ll_temac_recv()
749 tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci; in ll_temac_recv()
750 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; in ll_temac_recv()
755 skb = lp->rx_skb[lp->rx_bd_ci]; in ll_temac_recv()
767 if (((lp->temac_features & TEMAC_FEATURE_RX_CSUM) != 0) && in ll_temac_recv()
785 spin_unlock_irqrestore(&lp->rx_lock, flags); in ll_temac_recv()
794 lp->rx_skb[lp->rx_bd_ci] = new_skb; in ll_temac_recv()
796 lp->rx_bd_ci++; in ll_temac_recv()
797 if (lp->rx_bd_ci >= RX_BD_NUM) in ll_temac_recv()
798 lp->rx_bd_ci = 0; in ll_temac_recv()
800 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; in ll_temac_recv()
803 lp->dma_out(lp, RX_TAILDESC_PTR, tail_p); in ll_temac_recv()
805 spin_unlock_irqrestore(&lp->rx_lock, flags); in ll_temac_recv()
811 struct temac_local *lp = netdev_priv(ndev); in ll_temac_tx_irq() local
814 status = lp->dma_in(lp, TX_IRQ_REG); in ll_temac_tx_irq()
815 lp->dma_out(lp, TX_IRQ_REG, status); in ll_temac_tx_irq()
818 temac_start_xmit_done(lp->ndev); in ll_temac_tx_irq()
828 struct temac_local *lp = netdev_priv(ndev); in ll_temac_rx_irq() local
832 status = lp->dma_in(lp, RX_IRQ_REG); in ll_temac_rx_irq()
833 lp->dma_out(lp, RX_IRQ_REG, status); in ll_temac_rx_irq()
836 ll_temac_recv(lp->ndev); in ll_temac_rx_irq()
843 struct temac_local *lp = netdev_priv(ndev); in temac_open() local
848 if (lp->phy_node) { in temac_open()
849 lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, in temac_open()
851 if (!lp->phy_dev) { in temac_open()
852 dev_err(lp->dev, "of_phy_connect() failed\n"); in temac_open()
856 phy_start(lp->phy_dev); in temac_open()
859 rc = request_irq(lp->tx_irq, ll_temac_tx_irq, 0, ndev->name, ndev); in temac_open()
862 rc = request_irq(lp->rx_irq, ll_temac_rx_irq, 0, ndev->name, ndev); in temac_open()
870 free_irq(lp->tx_irq, ndev); in temac_open()
872 if (lp->phy_dev) in temac_open()
873 phy_disconnect(lp->phy_dev); in temac_open()
874 lp->phy_dev = NULL; in temac_open()
875 dev_err(lp->dev, "request_irq() failed\n"); in temac_open()
881 struct temac_local *lp = netdev_priv(ndev); in temac_stop() local
885 free_irq(lp->tx_irq, ndev); in temac_stop()
886 free_irq(lp->rx_irq, ndev); in temac_stop()
888 if (lp->phy_dev) in temac_stop()
889 phy_disconnect(lp->phy_dev); in temac_stop()
890 lp->phy_dev = NULL; in temac_stop()
901 struct temac_local *lp = netdev_priv(ndev); in temac_poll_controller() local
903 disable_irq(lp->tx_irq); in temac_poll_controller()
904 disable_irq(lp->rx_irq); in temac_poll_controller()
906 ll_temac_rx_irq(lp->tx_irq, ndev); in temac_poll_controller()
907 ll_temac_tx_irq(lp->rx_irq, ndev); in temac_poll_controller()
909 enable_irq(lp->tx_irq); in temac_poll_controller()
910 enable_irq(lp->rx_irq); in temac_poll_controller()
933 struct temac_local *lp = netdev_priv(ndev); in temac_show_llink_regs() local
937 len += sprintf(buf + len, "%.8x%s", lp->dma_in(lp, i), in temac_show_llink_regs()
958 struct temac_local *lp; in temac_of_probe() local
965 ndev = alloc_etherdev(sizeof(*lp)); in temac_of_probe()
991 lp = netdev_priv(ndev); in temac_of_probe()
992 lp->ndev = ndev; in temac_of_probe()
993 lp->dev = &op->dev; in temac_of_probe()
994 lp->options = XTE_OPTION_DEFAULTS; in temac_of_probe()
995 spin_lock_init(&lp->rx_lock); in temac_of_probe()
996 mutex_init(&lp->indirect_mutex); in temac_of_probe()
999 lp->regs = of_iomap(op->dev.of_node, 0); in temac_of_probe()
1000 if (!lp->regs) { in temac_of_probe()
1006 lp->temac_features = 0; in temac_of_probe()
1009 lp->temac_features |= TEMAC_FEATURE_TX_CSUM; in temac_of_probe()
1015 lp->temac_features |= TEMAC_FEATURE_RX_CSUM; in temac_of_probe()
1025 if (temac_dcr_setup(lp, op, np)) { in temac_of_probe()
1028 lp->sdma_regs = of_iomap(np, 0); in temac_of_probe()
1029 if (lp->sdma_regs) { in temac_of_probe()
1030 lp->dma_in = temac_dma_in32; in temac_of_probe()
1031 lp->dma_out = temac_dma_out32; in temac_of_probe()
1032 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs); in temac_of_probe()
1040 lp->rx_irq = irq_of_parse_and_map(np, 0); in temac_of_probe()
1041 lp->tx_irq = irq_of_parse_and_map(np, 1); in temac_of_probe()
1045 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) { in temac_of_probe()
1061 rc = temac_mdio_setup(lp, op->dev.of_node); in temac_of_probe()
1065 lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0); in temac_of_probe()
1066 if (lp->phy_node) in temac_of_probe()
1067 dev_dbg(lp->dev, "using PHY node %s (%p)\n", np->full_name, np); in temac_of_probe()
1070 rc = sysfs_create_group(&lp->dev->kobj, &temac_attr_group); in temac_of_probe()
1072 dev_err(lp->dev, "Error creating sysfs files\n"); in temac_of_probe()
1076 rc = register_netdev(lp->ndev); in temac_of_probe()
1078 dev_err(lp->dev, "register_netdev() error (%i)\n", rc); in temac_of_probe()
1085 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); in temac_of_probe()
1087 if (lp->sdma_regs) in temac_of_probe()
1088 iounmap(lp->sdma_regs); in temac_of_probe()
1090 iounmap(lp->regs); in temac_of_probe()
1100 struct temac_local *lp = netdev_priv(ndev); in temac_of_remove() local
1102 temac_mdio_teardown(lp); in temac_of_remove()
1104 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); in temac_of_remove()
1105 if (lp->phy_node) in temac_of_remove()
1106 of_node_put(lp->phy_node); in temac_of_remove()
1107 lp->phy_node = NULL; in temac_of_remove()
1109 iounmap(lp->regs); in temac_of_remove()
1110 if (lp->sdma_regs) in temac_of_remove()
1111 iounmap(lp->sdma_regs); in temac_of_remove()