Lines Matching refs:pd
373 static void s6gmac_rx_fillfifo(struct s6gmac *pd)
376 while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) &&
377 (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) &&
379 pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb;
380 s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan,
381 pd->io, (u32)skb->data, S6_MAX_FRLEN);
387 struct s6gmac *pd = netdev_priv(dev);
390 while (((u8)(pd->rx_skb_i - pd->rx_skb_o)) >
391 s6dmac_pending_count(pd->rx_dma, pd->rx_chan)) {
392 skb = pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB];
393 pfx = readl(pd->reg + S6_GMAC_BURST_POSTRD);
408 struct s6gmac *pd = netdev_priv(dev);
409 while (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >
410 s6dmac_pending_count(pd->tx_dma, pd->tx_chan)) {
411 dev_kfree_skb_irq(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
413 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
467 static void s6gmac_stats_collect(struct s6gmac *pd,
473 pd->stats[inf[b].net_index] +=
474 readl(pd->reg + S6_GMAC_STAT_REGS
480 static void s6gmac_stats_carry(struct s6gmac *pd,
487 pd->carry[inf[b].net_index] += (1 << inf[b].reg_size);
491 static inline u32 s6gmac_stats_pending(struct s6gmac *pd, int carry)
493 int r = readl(pd->reg + S6_GMAC_STATCARRY(carry)) &
494 ~readl(pd->reg + S6_GMAC_STATCARRYMSK(carry));
498 static inline void s6gmac_stats_interrupt(struct s6gmac *pd, int carry)
501 mask = s6gmac_stats_pending(pd, carry);
503 writel(mask, pd->reg + S6_GMAC_STATCARRY(carry));
504 s6gmac_stats_carry(pd, &statinf[carry][0], mask);
511 struct s6gmac *pd = netdev_priv(dev);
514 spin_lock(&pd->lock);
515 if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan))
517 s6gmac_rx_fillfifo(pd);
518 if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan))
520 s6gmac_stats_interrupt(pd, 0);
521 s6gmac_stats_interrupt(pd, 1);
522 spin_unlock(&pd->lock);
526 static inline void s6gmac_set_dstaddr(struct s6gmac *pd, int n,
529 writel(addrlo, pd->reg + S6_GMAC_HOST_DSTADDRLO(n));
530 writel(addrhi, pd->reg + S6_GMAC_HOST_DSTADDRHI(n));
531 writel(masklo, pd->reg + S6_GMAC_HOST_DSTMASKLO(n));
532 writel(maskhi, pd->reg + S6_GMAC_HOST_DSTMASKHI(n));
537 struct s6gmac *pd = netdev_priv(dev);
538 writel(0, pd->reg + S6_GMAC_MACCONF1);
543 struct s6gmac *pd = netdev_priv(dev);
544 int is_rgmii = !!(pd->phydev->supported
546 writel(1 << S6_GMAC_MACCONF1_SOFTRES, pd->reg + S6_GMAC_MACCONF1);
549 pd->reg + S6_GMAC_MACCONF1);
552 pd->reg + S6_GMAC_HOST_PBLKCTRL);
558 pd->reg + S6_GMAC_HOST_PBLKCTRL);
563 pd->reg + S6_GMAC_MACCONF1);
566 pd->reg + S6_GMAC_MACMAXFRAMELEN);
567 writel((pd->link.full ? 1 : 0) << S6_GMAC_MACCONF2_FULL |
570 (pd->link.giga ?
575 pd->reg + S6_GMAC_MACCONF2);
576 writel(0, pd->reg + S6_GMAC_MACSTATADDR1);
577 writel(0, pd->reg + S6_GMAC_MACSTATADDR2);
583 pd->reg + S6_GMAC_FIFOCONF0);
586 pd->reg + S6_GMAC_FIFOCONF3);
597 pd->link.giga << S6_GMAC_FIFOCONF5_CFGBYTM |
599 pd->reg + S6_GMAC_FIFOCONF5);
607 pd->reg + S6_GMAC_FIFOCONF4);
608 s6gmac_set_dstaddr(pd, 0,
610 s6gmac_set_dstaddr(pd, 1,
618 s6gmac_set_dstaddr(pd, 2,
620 s6gmac_set_dstaddr(pd, 3,
629 pd->reg + S6_GMAC_HOST_PBLKCTRL);
632 static void s6mii_enable(struct s6gmac *pd)
634 writel(readl(pd->reg + S6_GMAC_MACCONF1) &
636 pd->reg + S6_GMAC_MACCONF1);
637 writel((readl(pd->reg + S6_GMAC_MACMIICONF)
640 pd->reg + S6_GMAC_MACMIICONF);
643 static int s6mii_busy(struct s6gmac *pd, int tmo)
645 while (readl(pd->reg + S6_GMAC_MACMIIINDI)) {
655 struct s6gmac *pd = bus->priv;
656 s6mii_enable(pd);
657 if (s6mii_busy(pd, 256))
661 pd->reg + S6_GMAC_MACMIIADDR);
662 writel(1 << S6_GMAC_MACMIICMD_READ, pd->reg + S6_GMAC_MACMIICMD);
663 writel(0, pd->reg + S6_GMAC_MACMIICMD);
664 if (s6mii_busy(pd, 256))
666 return (u16)readl(pd->reg + S6_GMAC_MACMIISTAT);
671 struct s6gmac *pd = bus->priv;
672 s6mii_enable(pd);
673 if (s6mii_busy(pd, 256))
677 pd->reg + S6_GMAC_MACMIIADDR);
678 writel(value, pd->reg + S6_GMAC_MACMIICTRL);
679 if (s6mii_busy(pd, 256))
686 struct s6gmac *pd = bus->priv;
687 s6mii_enable(pd);
688 if (s6mii_busy(pd, PHY_INIT_TIMEOUT))
693 static void s6gmac_set_rgmii_txclock(struct s6gmac *pd)
697 switch (pd->link.mbit) {
715 struct s6gmac *pd = netdev_priv(dev);
716 struct phy_device *phydev = pd->phydev;
718 pd->link.full = phydev->duplex;
719 pd->link.giga = (phydev->speed == 1000);
720 if (pd->link.mbit != phydev->speed) {
721 pd->link.mbit = phydev->speed;
722 s6gmac_set_rgmii_txclock(pd);
724 pd->link.isup = isup;
732 struct s6gmac *pd = netdev_priv(dev);
733 struct phy_device *phydev = pd->phydev;
734 if (pd->link.isup &&
736 (pd->link.mbit != phydev->speed) ||
737 (pd->link.full != phydev->duplex))) {
738 pd->link.isup = 0;
745 if (!pd->link.isup && phydev->link) {
746 if (pd->link.full != phydev->duplex) {
747 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
752 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
755 if (pd->link.giga != (phydev->speed == 1000)) {
756 u32 fifocfg = readl(pd->reg + S6_GMAC_FIFOCONF5);
757 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
769 writel(fifocfg, pd->reg + S6_GMAC_FIFOCONF5);
770 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
773 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
781 struct s6gmac *pd = netdev_priv(dev);
784 while ((i < PHY_MAX_ADDR) && (!(p = pd->mii.bus->phy_map[i])))
794 pd->phydev = p;
800 struct s6gmac *pd = netdev_priv(dev);
814 writel(mask, pd->reg + S6_GMAC_STATCARRY(0));
815 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(0));
827 writel(mask, pd->reg + S6_GMAC_STATCARRY(1));
828 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(1));
833 struct s6gmac *pd = netdev_priv(dev);
834 s6dmac_disable_chan(pd->tx_dma, pd->tx_chan);
835 s6dmac_disable_chan(pd->rx_dma, pd->rx_chan);
836 s6dmac_disable_error_irqs(pd->tx_dma, 1 << S6_HIFDMA_GMACTX);
837 s6dmac_disable_error_irqs(pd->rx_dma, 1 << S6_HIFDMA_GMACRX);
842 struct s6gmac *pd = netdev_priv(dev);
845 spin_lock_irqsave(&pd->lock, flags);
851 pd->reg + S6_GMAC_BURST_PREWR);
852 s6dmac_put_fifo_cache(pd->tx_dma, pd->tx_chan,
853 (u32)skb->data, pd->io, skb->len);
854 if (s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
856 if (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >= S6_NUM_TX_SKB) {
858 pd->tx_skb_o, pd->tx_skb_i);
861 pd->tx_skb[(pd->tx_skb_i++) % S6_NUM_TX_SKB] = skb;
862 spin_unlock_irqrestore(&pd->lock, flags);
868 struct s6gmac *pd = netdev_priv(dev);
870 spin_lock_irqsave(&pd->lock, flags);
872 spin_unlock_irqrestore(&pd->lock, flags);
877 struct s6gmac *pd = netdev_priv(dev);
879 phy_read_status(pd->phydev);
880 spin_lock_irqsave(&pd->lock, flags);
881 pd->link.mbit = 0;
882 s6gmac_linkisup(dev, pd->phydev->link);
886 s6gmac_rx_fillfifo(pd);
887 s6dmac_enable_chan(pd->rx_dma, pd->rx_chan,
889 s6dmac_enable_chan(pd->tx_dma, pd->tx_chan,
896 pd->reg + S6_GMAC_HOST_INTMASK);
897 spin_unlock_irqrestore(&pd->lock, flags);
898 phy_start(pd->phydev);
905 struct s6gmac *pd = netdev_priv(dev);
908 phy_stop(pd->phydev);
909 spin_lock_irqsave(&pd->lock, flags);
912 while (pd->tx_skb_i != pd->tx_skb_o)
913 dev_kfree_skb(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
914 while (pd->rx_skb_i != pd->rx_skb_o)
915 dev_kfree_skb(pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB]);
916 spin_unlock_irqrestore(&pd->lock, flags);
922 struct s6gmac *pd = netdev_priv(dev);
923 struct net_device_stats *st = (struct net_device_stats *)&pd->stats;
927 spin_lock_irqsave(&pd->lock, flags);
928 for (i = 0; i < sizeof(pd->stats) / sizeof(unsigned long); i++)
929 pd->stats[i] =
930 pd->carry[i] << (S6_GMAC_STAT_SIZE_MIN - 1);
931 s6gmac_stats_collect(pd, &statinf[0][0]);
932 s6gmac_stats_collect(pd, &statinf[1][0]);
933 i = s6gmac_stats_pending(pd, 0) |
934 s6gmac_stats_pending(pd, 1);
935 spin_unlock_irqrestore(&pd->lock, flags);
948 struct s6gmac *pd;
952 dev = alloc_etherdev(sizeof(*pd));
964 pd = netdev_priv(dev);
965 memset(pd, 0, sizeof(*pd));
966 spin_lock_init(&pd->lock);
967 pd->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0)->start;
969 pd->tx_dma = DMA_MASK_DMAC(i);
970 pd->tx_chan = DMA_INDEX_CHNL(i);
972 pd->rx_dma = DMA_MASK_DMAC(i);
973 pd->rx_chan = DMA_INDEX_CHNL(i);
974 pd->io = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
995 mb->priv = pd;
998 mb->irq = &pd->mii.irq[0];
1003 pd->mii.irq[i] = n;
1006 pd->mii.bus = mb;
1025 struct s6gmac *pd = netdev_priv(dev);
1026 mdiobus_unregister(pd->mii.bus);