summaryrefslogtreecommitdiffstats
path: root/target/linux/ifxmips/files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/ifxmips/files')
-rw-r--r--target/linux/ifxmips/files/arch/mips/ifxmips/board.c11
-rw-r--r--target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c63
2 files changed, 55 insertions, 19 deletions
diff --git a/target/linux/ifxmips/files/arch/mips/ifxmips/board.c b/target/linux/ifxmips/files/arch/mips/ifxmips/board.c
index 8f3e166eb..6df17d855 100644
--- a/target/linux/ifxmips/files/arch/mips/ifxmips/board.c
+++ b/target/linux/ifxmips/files/arch/mips/ifxmips/board.c
@@ -25,9 +25,9 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/mtd/physmap.h>
-#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/reboot.h>
+#include <linux/platform_device.h>
#include <asm/bootinfo.h>
#include <asm/reboot.h>
#include <asm/time.h>
@@ -54,6 +54,14 @@ static struct platform_device ifxmips_gpio[] =
},
};
+static struct platform_device ifxmips_mii[] =
+{
+ {
+ .id = 0,
+ .name = "ifxmips_mii0",
+ },
+};
+
int __init ifxmips_init_devices(void)
{
/*
@@ -70,6 +78,7 @@ int __init ifxmips_init_devices(void)
ifxmips_devs[dev++] = ifxmips_led;
ifxmips_devs[dev++] = ifxmips_gpio;
+ ifxmips_devs[dev++] = ifxmips_mii;
return platform_add_devices(ifxmips_devs, dev);
}
diff --git a/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c b/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
index 50478bfe0..5764b449f 100644
--- a/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
+++ b/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
@@ -37,6 +37,7 @@
#include <linux/tcp.h>
#include <linux/skbuff.h>
#include <linux/mm.h>
+#include <linux/platform_device.h>
#include <linux/ethtool.h>
#include <asm/checksum.h>
#include <linux/init.h>
@@ -46,6 +47,8 @@
#include <asm/ifxmips/ifxmips_dma.h>
#include <asm/ifxmips/ifxmips_pmu.h>
+#define DRVNAME "ifxmips_mii0"
+
static struct net_device ifxmips_mii0_dev;
static unsigned char u_boot_ethaddr[MAX_ADDR_LEN];
@@ -119,7 +122,7 @@ switch_hw_receive (struct net_device* dev,struct dma_device_info* dma_dev)
if (len >= ETHERNET_PACKET_DMA_BUFFER_SIZE)
{
- printk("packet too large %d\n",len);
+ printk(KERN_INFO DRVNAME ": packet too large %d\n",len);
goto switch_hw_receive_err_exit;
}
@@ -127,13 +130,13 @@ switch_hw_receive (struct net_device* dev,struct dma_device_info* dma_dev)
len -= 4;
if (skb == NULL )
{
- printk("cannot restore pointer\n");
+ printk(KERN_INFO DRVNAME ": cannot restore pointer\n");
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_INFO DRVNAME ": BUG, len:%d end:%p tail:%p\n", (len+4), skb->end, skb->tail);
goto switch_hw_receive_err_exit;
}
@@ -234,7 +237,7 @@ dma_intr_handler (struct dma_device_info* dma_dev, int status)
break;
case TX_BUF_FULL_INT:
- printk("tx buffer full\n");
+ printk(KERN_INFO DRVNAME ": tx buffer full\n");
netif_stop_queue(&ifxmips_mii0_dev);
for (i = 0; i < dma_dev->max_tx_chan_num; i++)
{
@@ -301,7 +304,7 @@ switch_init (struct net_device *dev)
ether_setup(dev);
- printk("%s up\n", dev->name);
+ printk(KERN_INFO DRVNAME ": %s is up\n", dev->name);
dev->open = ifxmips_switch_open;
dev->stop = switch_release;
@@ -347,15 +350,13 @@ switch_init (struct net_device *dev)
/*read the mac address from the mac table and put them into the mac table.*/
for (i = 0; i < 6; i++)
- {
retval += u_boot_ethaddr[i];
- }
//TODO
/* ethaddr not set in u-boot ? */
if (retval == 0)
{
- printk("use default MAC address\n");
+ printk(KERN_INFO DRVNAME ": using default MAC address\n");
dev->dev_addr[0] = 0x00;
dev->dev_addr[1] = 0x11;
dev->dev_addr[2] = 0x22;
@@ -388,8 +389,8 @@ ifxmips_sw_chip_init (int mode)
wmb();
}
-int __init
-switch_init_module(void)
+static int
+ifxmips_mii_probe(struct platform_device *dev)
{
int result = 0;
@@ -401,24 +402,24 @@ switch_init_module(void)
result = register_netdev(&ifxmips_mii0_dev);
if (result)
{
- printk("error %i registering device \"%s\"\n", result, ifxmips_mii0_dev.name);
+ printk(KERN_INFO DRVNAME ": error %i registering device \"%s\"\n", result, ifxmips_mii0_dev.name);
goto out;
}
/* ifxmips eval kit connects the phy/switch in REV mode */
ifxmips_sw_chip_init(REV_MII_MODE);
- printk("ifxmips MAC driver loaded!\n");
+ printk(KERN_INFO DRVNAME ": driver loaded!\n");
out:
return result;
}
-static void __exit
-switch_cleanup(void)
+static int
+ifxmips_mii_remove(struct platform_device *dev)
{
struct switch_priv *priv = (struct switch_priv*)ifxmips_mii0_dev.priv;
- printk("ifxmips_mii0 cleanup\n");
+ printk(KERN_INFO DRVNAME ": ifxmips_mii0 cleanup\n");
dma_device_unregister(priv->dma_device);
dma_device_release(priv->dma_device);
@@ -426,8 +427,34 @@ switch_cleanup(void)
kfree(ifxmips_mii0_dev.priv);
unregister_netdev(&ifxmips_mii0_dev);
- return;
+ return 0;
+}
+
+static struct
+platform_driver ifxmips_mii_driver = {
+ .probe = ifxmips_mii_probe,
+ .remove = ifxmips_mii_remove,
+ .driver = {
+ .name = DRVNAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+int __init
+ifxmips_mii_init(void)
+{
+ int ret = platform_driver_register(&ifxmips_mii_driver);
+ if (ret)
+ printk(KERN_INFO DRVNAME ": Error registering platfom driver!");
+
+ return ret;
+}
+
+static void __exit
+ifxmips_mii_cleanup(void)
+{
+ platform_driver_unregister(&ifxmips_mii_driver);
}
-module_init(switch_init_module);
-module_exit(switch_cleanup);
+module_init(ifxmips_mii_init);
+module_exit(ifxmips_mii_cleanup);