[mcs814x] remove platform specific initialization from ethernet driver
[openwrt/svn-archive/archive.git] / target / linux / mcs814x / files-3.3 / drivers / net / ethernet / mcs8140 / nuport_mac.c
index 6979d41bc00d06ebbd999b50d58057f8a232b19d..655749dc4bcc37a6c98ec39111da59db7f2d935f 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <asm/unaligned.h>
 #include <asm/sizes.h>
-#include <mach/hardware.h>
 
 /* Hardware registers */
 #define MAC_BASE_ADDR          ((priv->mac_base))
@@ -140,28 +139,9 @@ struct nuport_mac_priv {
        int                     old_link;
        int                     old_duplex;
        u32                     msg_level;
+       unsigned int            buffer_shifting_len;
 };
 
-void dcache_invalidate_only(unsigned long start, unsigned long end)
-{
-       asm("\n"
-           "       bic     r0, r0, #31\n"
-           "1:     mcr     p15, 0, r0, c7, c6, 1\n"
-           "       add     r0, r0, #32\n"
-           "       cmp     r0, r1\n" "       blo     1b\n");
-}
-
-void dcache_clean_range(unsigned long start, unsigned long end)
-{
-       asm("\n"
-           "       bic     r0, r0, #31\n"
-           "1:     mcr     p15, 0, r0, c7, c10, 1 @ clean D entry\n"
-           "       add     r0, r0, #32\n"
-           "       cmp     r0, r1\n"
-           "       blo     1b\n" \
-           "       mcr     p15, 0, r0, c7, c10, 4 @ drain WB\n");
-}
-
 static inline int nuport_mac_mii_busy_wait(struct nuport_mac_priv *priv)
 {
        unsigned long curr;
@@ -533,12 +513,10 @@ static int nuport_mac_rx(struct net_device *dev, int limit)
        while (count < limit && !priv->irq_rxskb[priv->cur_rx]) {
                skb = priv->rx_skb[priv->cur_rx];
                len = priv->pkt_len[priv->cur_rx];
-               dcache_invalidate_only(((u32) skb->data),
-                                      ((u32) (skb->data + len + 4)));
 
                /* Remove 2 bytes added by RX buffer shifting */
-               len = len - 2;
-               skb->data = skb->data + 2;
+               len = len - priv->buffer_shifting_len;
+               skb->data = skb->data + priv->buffer_shifting_len;
 
                /* Get packet status */
                status = get_unaligned((u32 *) (skb->data + len));
@@ -713,18 +691,6 @@ static int nuport_mac_open(struct net_device *dev)
        int ret;
        struct nuport_mac_priv *priv = netdev_priv(dev);
        unsigned long flags;
-       u32 reg;
-       u8 tmp;
-
-       /* Enable hardware filters */
-       reg = nuport_mac_readl((void __iomem *)_CONFADDR_DBGLED);
-       reg |= 0x80;
-       nuport_mac_writel(reg, (void __iomem *)_CONFADDR_DBGLED);
-
-       /* Set LEDs to Link act and RX/TX mode */
-       reg = nuport_mac_readl((void __iomem *)(_CONFADDR_SYSDBG + 0x04));
-       reg |= 0x01;
-       nuport_mac_writel(reg, (void __iomem *)(_CONFADDR_SYSDBG + 0x04));
 
        ret = clk_enable(priv->emac_clk);
        if (ret) {
@@ -769,11 +735,6 @@ static int nuport_mac_open(struct net_device *dev)
                goto out_tx_irq;
        }
 
-       /* Enable buffer shifting in RX */
-       tmp = nuport_mac_readb((void __iomem *)(_CONFADDR_SYSDBG + 0x1D));
-       tmp |= 0x01;
-       nuport_mac_writeb(tmp, (void __iomem *)(_CONFADDR_SYSDBG + 0x1D));
-
        netif_start_queue(dev);
 
        nuport_mac_init_tx_ring(priv);
@@ -969,6 +930,7 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
        int ret = 0;
        int rx_irq, tx_irq, link_irq;
        int i;
+       const unsigned int *intspec;
 
        dev = alloc_etherdev(sizeof(struct nuport_mac_priv));
        if (!dev) {
@@ -999,6 +961,13 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
        priv->dev = dev;
        spin_lock_init(&priv->lock);
 
+       intspec = of_get_property(pdev->dev.of_node,
+                               "nuport-mac,buffer-shifting", NULL);
+       if (!intspec)
+               priv->buffer_shifting_len = 0;
+       else
+               priv->buffer_shifting_len = 2;
+
        priv->mac_base = devm_ioremap(&pdev->dev,
                                regs->start, resource_size(regs));
        if (!priv->mac_base) {