• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/net/

Lines Matching defs:lp

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