[brcm63xx] alwasy read imagetag with 64K erase block size
[openwrt.git] / target / linux / amazon / files / drivers / net / amazon_sw.c
index 14d3a85..54a7062 100644 (file)
@@ -38,6 +38,7 @@
 
 // copyright 2007 john crispin <blogic@openwrt.org>
 // copyright 2007 felix fietkau <nbd@openwrt.org>
 
 // copyright 2007 john crispin <blogic@openwrt.org>
 // copyright 2007 felix fietkau <nbd@openwrt.org>
+// copyright 2009 hauke mehrtens <hauke@hauke-m.de>
 
 
 // TODO
 
 
 // TODO
@@ -85,6 +86,7 @@
 #include <linux/ethtool.h>
 #include <asm/checksum.h>
 #include <linux/init.h>
 #include <linux/ethtool.h>
 #include <asm/checksum.h>
 #include <linux/init.h>
+#include <linux/platform_device.h>
 
 #include <asm/amazon/amazon.h>
 #include <asm/amazon/amazon_dma.h>
 
 #include <asm/amazon/amazon.h>
 #include <asm/amazon/amazon_dma.h>
@@ -263,7 +265,7 @@ static int __init ethaddr_setup(char *line)
                if (line)
                        line = (*ep) ? ep + 1 : ep;
        }
                if (line)
                        line = (*ep) ? ep + 1 : ep;
        }
-       printk("mac address %2x-%2x-%2x-%2x-%2x-%2x \n", my_ethaddr[0], my_ethaddr[1], my_ethaddr[2], my_ethaddr[3], my_ethaddr[4], my_ethaddr[5]);
+       printk(KERN_INFO "amazon_mii0: mac address %2x-%2x-%2x-%2x-%2x-%2x \n", my_ethaddr[0], my_ethaddr[1], my_ethaddr[2], my_ethaddr[3], my_ethaddr[4], my_ethaddr[5]);
        return 0;
 }
 
        return 0;
 }
 
@@ -311,7 +313,7 @@ int switch_open(struct net_device *dev)
 
 #ifdef CONFIG_NET_HW_FLOWCONTROL
        if ((priv->fc_bit = netdev_register_fc(dev, amazon_xon)) == 0) {
 
 #ifdef CONFIG_NET_HW_FLOWCONTROL
        if ((priv->fc_bit = netdev_register_fc(dev, amazon_xon)) == 0) {
-               printk("Hardware Flow Control register fails\n");
+               printk(KERN_WARNING "amazon_mii0: Hardware Flow Control register fails\n");
        }
 #endif
 
        }
 #endif
 
@@ -660,18 +662,18 @@ int switch_hw_receive(struct net_device *dev, struct dma_device_info *dma_dev)
        len = dma_device_read(dma_dev, &buf, (void **) &skb);
 
        if (len >= 0x600) {
        len = dma_device_read(dma_dev, &buf, (void **) &skb);
 
        if (len >= 0x600) {
-               printk("packet too large %d\n", len);
+               printk(KERN_WARNING "amazon_mii0: packet too large %d\n", len);
                goto switch_hw_receive_err_exit;
        }
 
        /* remove CRC */
        len -= 4;
        if (skb == NULL) {
                goto switch_hw_receive_err_exit;
        }
 
        /* remove CRC */
        len -= 4;
        if (skb == NULL) {
-               printk("cannot restore pointer\n");
+               printk(KERN_WARNING "amazon_mii0: cannot restore pointer\n");
                goto switch_hw_receive_err_exit;
        }
        if (len > (skb->end - skb->tail)) {
                goto switch_hw_receive_err_exit;
        }
        if (len > (skb->end - skb->tail)) {
-               printk("BUG, len:%d end:%p tail:%p\n", (len + 4), skb->end, skb->tail);
+               printk(KERN_WARNING "amazon_mii0: BUG, len:%d end:%p tail:%p\n", (len + 4), skb->end, skb->tail);
                goto switch_hw_receive_err_exit;
        }
        skb_put(skb, len);
                goto switch_hw_receive_err_exit;
        }
        skb_put(skb, len);
@@ -776,6 +778,17 @@ int switch_set_mac_address(struct net_device *dev, void *p)
        return OK;
 }
 
        return OK;
 }
 
+static const struct net_device_ops amazon_mii_ops = {
+       .ndo_init               = switch_init,
+       .ndo_open               = switch_open,
+       .ndo_stop               = switch_release,
+       .ndo_start_xmit         = switch_tx,
+       .ndo_do_ioctl           = switch_ioctl,
+       .ndo_get_stats          = switch_stats,
+       .ndo_change_mtu         = switch_change_mtu,
+       .ndo_set_mac_address            = switch_set_mac_address,
+       .ndo_tx_timeout         = switch_tx_timeout,
+};
 
 int switch_init(struct net_device *dev)
 {
 
 int switch_init(struct net_device *dev)
 {
@@ -784,15 +797,7 @@ int switch_init(struct net_device *dev)
        int result;
        struct switch_priv *priv;
        ether_setup(dev);                       /* assign some of the fields */
        int result;
        struct switch_priv *priv;
        ether_setup(dev);                       /* assign some of the fields */
-       printk("%s up using ", dev->name);
-       dev->open = switch_open;
-       dev->stop = switch_release;
-       dev->hard_start_xmit = switch_tx;
-       dev->do_ioctl = switch_ioctl;
-       dev->get_stats = switch_stats;
-       dev->change_mtu = switch_change_mtu;
-       dev->set_mac_address = switch_set_mac_address;
-       dev->tx_timeout = switch_tx_timeout;
+       printk(KERN_INFO "amazon_mii0: %s up using ", dev->name);
        dev->watchdog_timeo = timeout;
 
        priv = netdev_priv(dev);
        dev->watchdog_timeo = timeout;
 
        priv = netdev_priv(dev);
@@ -827,19 +832,19 @@ int switch_init(struct net_device *dev)
        return OK;
 }
 
        return OK;
 }
 
-int switch_init_module(void)
+static int amazon_mii_probe(struct platform_device *dev)
 {
        int i = 0, result, device_present = 0;
        struct switch_priv *priv;
 
        for (i = 0; i < AMAZON_SW_INT_NO; i++) {
                switch_devs[i] = alloc_etherdev(sizeof(struct switch_priv));
 {
        int i = 0, result, device_present = 0;
        struct switch_priv *priv;
 
        for (i = 0; i < AMAZON_SW_INT_NO; i++) {
                switch_devs[i] = alloc_etherdev(sizeof(struct switch_priv));
-               switch_devs[i]->init = switch_init;
+               switch_devs[i]->netdev_ops = &amazon_mii_ops;
                strcpy(switch_devs[i]->name, "eth%d");
                priv = (struct switch_priv *) netdev_priv(switch_devs[i]);
                priv->num = i;
                if ((result = register_netdev(switch_devs[i])))
                strcpy(switch_devs[i]->name, "eth%d");
                priv = (struct switch_priv *) netdev_priv(switch_devs[i]);
                priv->num = i;
                if ((result = register_netdev(switch_devs[i])))
-                       printk("error %i registering device \"%s\"\n", result, switch_devs[i]->name);
+                       printk(KERN_WARNING "amazon_mii0: error %i registering device \"%s\"\n", result, switch_devs[i]->name);
                else
                        device_present++;
        }
                else
                        device_present++;
        }
@@ -847,7 +852,7 @@ int switch_init_module(void)
        return device_present ? 0 : -ENODEV;
 }
 
        return device_present ? 0 : -ENODEV;
 }
 
-void switch_cleanup(void)
+static int amazon_mii_remove(struct platform_device *dev)
 {
        int i;
        struct switch_priv *priv;
 {
        int i;
        struct switch_priv *priv;
@@ -860,11 +865,35 @@ void switch_cleanup(void)
                kfree(netdev_priv(switch_devs[i]));
                unregister_netdev(switch_devs[i]);
        }
                kfree(netdev_priv(switch_devs[i]));
                unregister_netdev(switch_devs[i]);
        }
-       return;
+       return 0;
+}
+
+static struct platform_driver amazon_mii_driver = {
+       .probe = amazon_mii_probe,
+       .remove = amazon_mii_remove,
+       .driver = {
+               .name = "amazon_mii0",
+               .owner = THIS_MODULE,
+       },
+};
+
+static int __init amazon_mii_init(void)
+{
+       int ret = platform_driver_register(&amazon_mii_driver);
+       if (ret)
+               printk(KERN_WARNING "amazon_mii0: Error registering platfom driver!\n");
+       return ret;
 }
 
 }
 
-module_init(switch_init_module);
-module_exit(switch_cleanup);
+static void __exit amazon_mii_cleanup(void)
+{
+       platform_driver_unregister(&amazon_mii_driver);
+}
+
+module_init(amazon_mii_init);
+module_exit(amazon_mii_cleanup);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Wu Qi Ming");
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Wu Qi Ming");
+MODULE_DESCRIPTION("ethernet driver for AMAZON boards");
+
This page took 0.032335 seconds and 4 git commands to generate.