aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/cadence/macb.c
diff options
context:
space:
mode:
authorJamie Iles <jamie.iles@mathembedded.com>2011-11-08 05:12:32 -0500
committerJamie Iles <jamie@jamieiles.com>2011-11-22 10:21:17 -0500
commitf75ba50bdc2bcfab591bdf903312557033d0ac68 (patch)
tree4ccc618be2fb9f998eed75549ca69b31712b0d0e /drivers/net/ethernet/cadence/macb.c
parentc220f8cd01198552a616c4216f2a8e719fdb5fd9 (diff)
macb: initial support for Cadence GEM
The Cadence GEM is based on the MACB Ethernet controller but has a few small changes with regards to register and bitfield placement. This patch detects the presence of a GEM by reading the module ID register and setting a flag appropriately. This handles the new HW address, USRIO and hash register base register locations in GEM. v3: - convert to macb_is_gem() inline rather than storing a boolean flag - handle rx_overrun stats for gem Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Jamie Iles <jamie@jamieiles.com> Tested-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers/net/ethernet/cadence/macb.c')
-rw-r--r--drivers/net/ethernet/cadence/macb.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index aa1d597091a8..4e61a8610d6a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Atmel MACB Ethernet Controller driver 2 * Cadence MACB/GEM Ethernet Controller driver
3 * 3 *
4 * Copyright (C) 2004-2006 Atmel Corporation 4 * Copyright (C) 2004-2006 Atmel Corporation
5 * 5 *
@@ -59,9 +59,9 @@ static void __macb_set_hwaddr(struct macb *bp)
59 u16 top; 59 u16 top;
60 60
61 bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr)); 61 bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr));
62 macb_writel(bp, SA1B, bottom); 62 macb_or_gem_writel(bp, SA1B, bottom);
63 top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4))); 63 top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
64 macb_writel(bp, SA1T, top); 64 macb_or_gem_writel(bp, SA1T, top);
65} 65}
66 66
67static void __init macb_get_hwaddr(struct macb *bp) 67static void __init macb_get_hwaddr(struct macb *bp)
@@ -70,8 +70,8 @@ static void __init macb_get_hwaddr(struct macb *bp)
70 u16 top; 70 u16 top;
71 u8 addr[6]; 71 u8 addr[6];
72 72
73 bottom = macb_readl(bp, SA1B); 73 bottom = macb_or_gem_readl(bp, SA1B);
74 top = macb_readl(bp, SA1T); 74 top = macb_or_gem_readl(bp, SA1T);
75 75
76 addr[0] = bottom & 0xff; 76 addr[0] = bottom & 0xff;
77 addr[1] = (bottom >> 8) & 0xff; 77 addr[1] = (bottom >> 8) & 0xff;
@@ -580,7 +580,10 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
580 580
581 if (status & MACB_BIT(ISR_ROVR)) { 581 if (status & MACB_BIT(ISR_ROVR)) {
582 /* We missed at least one packet */ 582 /* We missed at least one packet */
583 bp->hw_stats.rx_overruns++; 583 if (macb_is_gem(bp))
584 bp->hw_stats.gem.rx_overruns++;
585 else
586 bp->hw_stats.macb.rx_overruns++;
584 } 587 }
585 588
586 if (status & MACB_BIT(HRESP)) { 589 if (status & MACB_BIT(HRESP)) {
@@ -902,8 +905,8 @@ static void macb_sethashtable(struct net_device *dev)
902 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 905 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
903 } 906 }
904 907
905 macb_writel(bp, HRB, mc_filter[0]); 908 macb_or_gem_writel(bp, HRB, mc_filter[0]);
906 macb_writel(bp, HRT, mc_filter[1]); 909 macb_or_gem_writel(bp, HRT, mc_filter[1]);
907} 910}
908 911
909/* 912/*
@@ -925,8 +928,8 @@ static void macb_set_rx_mode(struct net_device *dev)
925 928
926 if (dev->flags & IFF_ALLMULTI) { 929 if (dev->flags & IFF_ALLMULTI) {
927 /* Enable all multicast mode */ 930 /* Enable all multicast mode */
928 macb_writel(bp, HRB, -1); 931 macb_or_gem_writel(bp, HRB, -1);
929 macb_writel(bp, HRT, -1); 932 macb_or_gem_writel(bp, HRT, -1);
930 cfg |= MACB_BIT(NCFGR_MTI); 933 cfg |= MACB_BIT(NCFGR_MTI);
931 } else if (!netdev_mc_empty(dev)) { 934 } else if (!netdev_mc_empty(dev)) {
932 /* Enable specific multicasts */ 935 /* Enable specific multicasts */
@@ -934,8 +937,8 @@ static void macb_set_rx_mode(struct net_device *dev)
934 cfg |= MACB_BIT(NCFGR_MTI); 937 cfg |= MACB_BIT(NCFGR_MTI);
935 } else if (dev->flags & (~IFF_ALLMULTI)) { 938 } else if (dev->flags & (~IFF_ALLMULTI)) {
936 /* Disable all multicast mode */ 939 /* Disable all multicast mode */
937 macb_writel(bp, HRB, 0); 940 macb_or_gem_writel(bp, HRB, 0);
938 macb_writel(bp, HRT, 0); 941 macb_or_gem_writel(bp, HRT, 0);
939 cfg &= ~MACB_BIT(NCFGR_MTI); 942 cfg &= ~MACB_BIT(NCFGR_MTI);
940 } 943 }
941 944
@@ -1196,15 +1199,16 @@ static int __init macb_probe(struct platform_device *pdev)
1196 1199
1197 if (pdata && pdata->is_rmii) 1200 if (pdata && pdata->is_rmii)
1198#if defined(CONFIG_ARCH_AT91) 1201#if defined(CONFIG_ARCH_AT91)
1199 macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) ); 1202 macb_or_gem_writel(bp, USRIO, (MACB_BIT(RMII) |
1203 MACB_BIT(CLKEN)));
1200#else 1204#else
1201 macb_writel(bp, USRIO, 0); 1205 macb_or_gem_writel(bp, USRIO, 0);
1202#endif 1206#endif
1203 else 1207 else
1204#if defined(CONFIG_ARCH_AT91) 1208#if defined(CONFIG_ARCH_AT91)
1205 macb_writel(bp, USRIO, MACB_BIT(CLKEN)); 1209 macb_or_gem_writel(bp, USRIO, MACB_BIT(CLKEN));
1206#else 1210#else
1207 macb_writel(bp, USRIO, MACB_BIT(MII)); 1211 macb_or_gem_writel(bp, USRIO, MACB_BIT(MII));
1208#endif 1212#endif
1209 1213
1210 bp->tx_pending = DEF_TX_RING_PENDING; 1214 bp->tx_pending = DEF_TX_RING_PENDING;
@@ -1221,8 +1225,9 @@ static int __init macb_probe(struct platform_device *pdev)
1221 1225
1222 platform_set_drvdata(pdev, dev); 1226 platform_set_drvdata(pdev, dev);
1223 1227
1224 netdev_info(dev, "Atmel MACB at 0x%08lx irq %d (%pM)\n", 1228 netdev_info(dev, "Cadence %s at 0x%08lx irq %d (%pM)\n",
1225 dev->base_addr, dev->irq, dev->dev_addr); 1229 macb_is_gem(bp) ? "GEM" : "MACB", dev->base_addr,
1230 dev->irq, dev->dev_addr);
1226 1231
1227 phydev = bp->phy_dev; 1232 phydev = bp->phy_dev;
1228 netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", 1233 netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
@@ -1332,6 +1337,6 @@ module_init(macb_init);
1332module_exit(macb_exit); 1337module_exit(macb_exit);
1333 1338
1334MODULE_LICENSE("GPL"); 1339MODULE_LICENSE("GPL");
1335MODULE_DESCRIPTION("Atmel MACB Ethernet driver"); 1340MODULE_DESCRIPTION("Cadence MACB/GEM Ethernet driver");
1336MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); 1341MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
1337MODULE_ALIAS("platform:macb"); 1342MODULE_ALIAS("platform:macb");