summaryrefslogtreecommitdiff
path: root/target/linux
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2010-01-01 21:44:37 +0000
committerHauke Mehrtens <hauke@hauke-m.de>2010-01-01 21:44:37 +0000
commit023c474951a4948ddd4ad1b1e9f9f0b7bce06c5c (patch)
treee414dc5bc7cd2f352a45cf0158e5dfcecf2d8b22 /target/linux
parent953ff0cf43e7ec2f99479dd7e7a5d076e31f9c28 (diff)
downloadmtk-20170518-023c474951a4948ddd4ad1b1e9f9f0b7bce06c5c.zip
mtk-20170518-023c474951a4948ddd4ad1b1e9f9f0b7bce06c5c.tar.gz
mtk-20170518-023c474951a4948ddd4ad1b1e9f9f0b7bce06c5c.tar.bz2
mazon: use platform_device for most drivers and fix some printk's
SVN-Revision: 18989
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/amazon/config-2.6.301
-rw-r--r--target/linux/amazon/files/arch/mips/amazon/Makefile2
-rw-r--r--target/linux/amazon/files/arch/mips/amazon/board.c69
-rw-r--r--target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c35
-rw-r--r--target/linux/amazon/files/drivers/mtd/maps/amazon.c46
-rw-r--r--target/linux/amazon/files/drivers/net/amazon_sw.c50
-rw-r--r--target/linux/amazon/files/drivers/serial/amazon_asc.c33
7 files changed, 197 insertions, 39 deletions
diff --git a/target/linux/amazon/config-2.6.30 b/target/linux/amazon/config-2.6.30
index bb6bca0..f912479 100644
--- a/target/linux/amazon/config-2.6.30
+++ b/target/linux/amazon/config-2.6.30
@@ -146,4 +146,5 @@ CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
CONFIG_TRACING_SUPPORT=y
CONFIG_TRAD_SIGNALS=y
+CONFIG_USB_SUPPORT=y
CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/amazon/files/arch/mips/amazon/Makefile b/target/linux/amazon/files/arch/mips/amazon/Makefile
index 9cdc100..47761a2 100644
--- a/target/linux/amazon/files/arch/mips/amazon/Makefile
+++ b/target/linux/amazon/files/arch/mips/amazon/Makefile
@@ -4,6 +4,6 @@
#
# Makefile for Infineon Amazon
#
-obj-y := dma-core.o interrupt.o prom.o setup.o
+obj-y := dma-core.o interrupt.o prom.o setup.o board.o
obj-$(CONFIG_PCI) += pci.o
diff --git a/target/linux/amazon/files/arch/mips/amazon/board.c b/target/linux/amazon/files/arch/mips/amazon/board.c
new file mode 100644
index 0000000..330cec6
--- /dev/null
+++ b/target/linux/amazon/files/arch/mips/amazon/board.c
@@ -0,0 +1,69 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) 2009 Hauke Mehrtens <hauke@hauke-m.de>
+ */
+
+
+#include <linux/platform_device.h>
+#include <asm/amazon/irq.h>
+
+#define AMAZON_FLASH_START 0x13000000
+#define AMAZON_FLASH_MAX 0x1000000
+
+static struct platform_device amazon_mii = {
+ .id = 0,
+ .name = "amazon_mii0",
+// .dev = {
+// .platform_data = amazon_ethaddr,
+// }
+};
+
+static struct platform_device amazon_wdt = {
+ .id = 0,
+ .name = "amazon_wdt",
+};
+
+static struct platform_device amazon_asc = {
+ .id = 0,
+ .name = "amazon_asc",
+};
+
+static struct resource amazon_mtd_resource = {
+ .start = AMAZON_FLASH_START,
+ .end = AMAZON_FLASH_START + AMAZON_FLASH_MAX - 1,
+ .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device amazon_mtd = {
+ .id = 0,
+ .name = "amazon_mtd",
+ .num_resources = 1,
+ .resource = &amazon_mtd_resource,
+};
+
+
+struct platform_device *amazon_devs[] = {
+ &amazon_mii, &amazon_mtd, &amazon_wdt, &amazon_asc
+};
+
+
+int __init amazon_init_devices(void)
+{
+ printk(KERN_INFO "");
+ return platform_add_devices(amazon_devs, 4);
+}
+
+arch_initcall(amazon_init_devices);
diff --git a/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c b/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c
index e06203d..6e1eb79 100644
--- a/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c
+++ b/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c
@@ -36,6 +36,7 @@
#include <linux/ioctl.h>
#include <asm/uaccess.h>
#include <asm/system.h>
+#include <linux/platform_device.h>
#include <asm/amazon/amazon.h>
#include <asm/amazon/amazon_wdt.h>
@@ -206,7 +207,7 @@ static struct file_operations wdt_fops = {
release: wdt_release,
};
-int __init amazon_wdt_init_module(void)
+static int __init amazon_wdt_probe(struct platform_device *dev)
{
int result = result = register_chrdev(0, "watchdog", &wdt_fops);
@@ -226,7 +227,7 @@ int __init amazon_wdt_init_module(void)
return 0;
}
-void amazon_wdt_cleanup_module(void)
+static int amazon_wdt_remove(struct platform_device *dev)
{
unregister_chrdev(0, "watchdog");
#ifdef AMAZON_WDT_DEBUG
@@ -234,13 +235,35 @@ void amazon_wdt_cleanup_module(void)
remove_proc_entry("amazon_wdt", NULL);
#endif
printk(KERN_INFO DRV_NAME "unregistered\n");
- return;
+ return 0;
+}
+
+static struct platform_driver amazon_wdt_driver = {
+ .probe = amazon_wdt_probe,
+ .remove = amazon_wdt_remove,
+ .driver = {
+ .name = "amazon_wdt",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init amazon_wdt_init(void)
+{
+ int ret = platform_driver_register(&amazon_wdt_driver);
+ if (ret)
+ printk(KERN_WARNING "amazon_wdt: error registering platfom driver!\n");
+ return ret;
}
+static void __exit amazon_wdt_exit(void)
+{
+ platform_driver_unregister(&amazon_wdt_driver);
+}
+
+module_init(amazon_wdt_init);
+module_exit(amazon_wdt_exit);
+
MODULE_LICENSE ("GPL");
MODULE_AUTHOR("Infineon / John Crispin <blogic@openwrt.org>");
MODULE_DESCRIPTION("AMAZON WDT driver");
-module_init(amazon_wdt_init_module);
-module_exit(amazon_wdt_cleanup_module);
-
diff --git a/target/linux/amazon/files/drivers/mtd/maps/amazon.c b/target/linux/amazon/files/drivers/mtd/maps/amazon.c
index 8c31141..55bfe32 100644
--- a/target/linux/amazon/files/drivers/mtd/maps/amazon.c
+++ b/target/linux/amazon/files/drivers/mtd/maps/amazon.c
@@ -20,6 +20,7 @@
// copyright 2007 john crispin <blogic@openwrt.org>
// copyright 2007 felix fietkau <nbd@openwrt.org>
+// copyright 2009 hauke mehrtens <hauke@hauke-m.de>
#include <linux/module.h>
#include <linux/types.h>
@@ -32,6 +33,7 @@
#include <linux/mtd/partitions.h>
#include <linux/mtd/cfi.h>
#include <linux/mutex.h>
+#include <linux/platform_device.h>
#include <asm/amazon/amazon.h>
#define AMAZON_PCI_ARB_CTL_ALT 0xb100205c
@@ -41,7 +43,6 @@
static struct map_info amazon_map = {
.name = "AMAZON_FLASH",
.bankwidth = 2,
- .size = 0x1000000,
};
static map_word amazon_read16(struct map_info * map, unsigned long ofs)
@@ -62,7 +63,6 @@ void amazon_copy_from(struct map_info *map, void *to, unsigned long from, ssize_
{
u8 *p;
u8 *to_8;
- ssize_t l = len;
from = (unsigned long) (from + map->virt);
p = (u8 *) from;
to_8 = (u8 *) to;
@@ -102,9 +102,6 @@ static struct mtd_partition amazon_partitions[3] = {
},
};
-
-unsigned long flash_start = 0x13000000;
-unsigned long flash_size = 0x800000;
unsigned long uImage_size = 0x10000d;
int find_uImage_size(unsigned long start_offset)
@@ -121,9 +118,8 @@ int find_uImage_size(unsigned long start_offset)
return temp + 0x40;
}
-int __init init_amazon_mtd(void)
+static int __init amazon_mtd_probe(struct platform_device *dev)
{
- int ret = 0;
unsigned long uimage_size;
struct mtd_info *mymtd = NULL;
struct mtd_partition *parts = NULL;
@@ -135,18 +131,19 @@ int __init init_amazon_mtd(void)
amazon_map.copy_from = amazon_copy_from;
amazon_map.copy_to = amazon_copy_to;
- amazon_map.phys = flash_start;
- amazon_map.virt = ioremap_nocache(flash_start, flash_size);
+ amazon_map.phys = dev->resource->start;
+ amazon_map.size = dev->resource->end - amazon_map.phys + 1;
+ amazon_map.virt = ioremap_nocache(amazon_map.phys, amazon_map.size);
if (!amazon_map.virt) {
- printk(KERN_WARNING "Failed to ioremap!\n");
+ printk(KERN_WARNING "amazon_mtd: Failed to ioremap!\n");
return -EIO;
}
mymtd = (struct mtd_info *) do_map_probe("cfi_probe", &amazon_map);
if (!mymtd) {
iounmap(amazon_map.virt);
- printk("probing failed\n");
+ printk(KERN_WARNING "amazon_mtd: probing failed\n");
return -ENXIO;
}
@@ -173,18 +170,35 @@ int __init init_amazon_mtd(void)
add_mtd_partitions(mymtd, parts, 3);
printk(KERN_INFO "amazon_mtd: added %s flash with %dMB\n",
- amazon_map.name, mymtd->size >> 20);
+ amazon_map.name, ((int)mymtd->size) >> 20);
return 0;
}
-static void __exit cleanup_amazon_mtd(void)
+static struct platform_driver amazon_mtd_driver = {
+ .probe = amazon_mtd_probe,
+ .driver = {
+ .name = "amazon_mtd",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init amazon_mtd_init(void)
{
- /* FIXME! */
+ int ret = platform_driver_register(&amazon_mtd_driver);
+ if (ret)
+ printk(KERN_WARNING "amazon_mtd: error registering platfom driver!\n");
+ return ret;
}
-module_init(init_amazon_mtd);
-module_exit(cleanup_amazon_mtd);
+static void __exit amazon_mtd_cleanup(void)
+{
+ platform_driver_unregister(&amazon_mtd_driver);
+}
+
+module_init(amazon_mtd_init);
+module_exit(amazon_mtd_cleanup);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("john crispin blogic@openwrt.org");
MODULE_DESCRIPTION("MTD map driver for AMAZON boards");
+
diff --git a/target/linux/amazon/files/drivers/net/amazon_sw.c b/target/linux/amazon/files/drivers/net/amazon_sw.c
index 14d3a85..1101d84 100644
--- a/target/linux/amazon/files/drivers/net/amazon_sw.c
+++ b/target/linux/amazon/files/drivers/net/amazon_sw.c
@@ -38,6 +38,7 @@
// copyright 2007 john crispin <blogic@openwrt.org>
// copyright 2007 felix fietkau <nbd@openwrt.org>
+// copyright 2009 hauke mehrtens <hauke@hauke-m.de>
// TODO
@@ -85,6 +86,7 @@
#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>
@@ -263,7 +265,7 @@ static int __init ethaddr_setup(char *line)
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;
}
@@ -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) {
- printk("Hardware Flow Control register fails\n");
+ printk(KERN_WARNING "amazon_mii0: Hardware Flow Control register fails\n");
}
#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) {
- 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) {
- 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)) {
- 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);
@@ -784,7 +786,7 @@ int switch_init(struct net_device *dev)
int result;
struct switch_priv *priv;
ether_setup(dev); /* assign some of the fields */
- printk("%s up using ", dev->name);
+ printk(KERN_INFO "amazon_mii0: %s up using ", dev->name);
dev->open = switch_open;
dev->stop = switch_release;
dev->hard_start_xmit = switch_tx;
@@ -827,7 +829,7 @@ int switch_init(struct net_device *dev)
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;
@@ -839,7 +841,7 @@ int switch_init_module(void)
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++;
}
@@ -847,7 +849,7 @@ int switch_init_module(void)
return device_present ? 0 : -ENODEV;
}
-void switch_cleanup(void)
+static int amazon_mii_remove(struct platform_device *dev)
{
int i;
struct switch_priv *priv;
@@ -860,11 +862,35 @@ void switch_cleanup(void)
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_DESCRIPTION("ethernet driver for AMAZON boards");
+
diff --git a/target/linux/amazon/files/drivers/serial/amazon_asc.c b/target/linux/amazon/files/drivers/serial/amazon_asc.c
index 6297549..f7fa907 100644
--- a/target/linux/amazon/files/drivers/serial/amazon_asc.c
+++ b/target/linux/amazon/files/drivers/serial/amazon_asc.c
@@ -44,6 +44,7 @@
#include <linux/console.h>
#include <linux/sysrq.h>
#include <linux/irq.h>
+#include <linux/platform_device.h>
#include <asm/system.h>
#include <asm/io.h>
@@ -670,7 +671,7 @@ static struct uart_driver amazonasc_reg = {
.cons = &amazonasc_console,
};
-static int __init amazonasc_init(void)
+static int __init amazon_asc_probe(struct platform_device *dev)
{
unsigned char res;
uart_register_driver(&amazonasc_reg);
@@ -678,14 +679,38 @@ static int __init amazonasc_init(void)
return res;
}
-static void __exit amazonasc_exit(void)
+static int __exit amazon_asc_remove(struct platform_device *dev)
{
uart_unregister_driver(&amazonasc_reg);
+ return 0;
+}
+
+static struct platform_driver amazon_asc_driver = {
+ .probe = amazon_asc_probe,
+ .remove = amazon_asc_remove,
+ .driver = {
+ .name = "amazon_asc",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init amazon_asc_init(void)
+{
+ int ret = platform_driver_register(&amazon_asc_driver);
+ if (ret)
+ printk(KERN_WARNING "amazon_asc: error registering platfom driver!\n");
+ return ret;
+}
+
+static void __exit amazon_asc_cleanup(void)
+{
+ platform_driver_unregister(&amazon_asc_driver);
}
-module_init(amazonasc_init);
-module_exit(amazonasc_exit);
+module_init(amazon_asc_init);
+module_exit(amazon_asc_cleanup);
MODULE_AUTHOR("Gary Jennejohn, Felix Fietkau, John Crispin");
MODULE_DESCRIPTION("MIPS AMAZONASC serial port driver");
MODULE_LICENSE("GPL");
+