replace the custom mtd driver with a partition parser
[openwrt/staging/chunkeey.git] / target / linux / adm8668 / files / arch / mips / adm8668 / platform.c
1 /*
2 * Infineon/ADMTek 8668 (WildPass) platform devices support
3 *
4 * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
5 * Copyright (C) 2012 Florian Fainelli <florian@openwrt.org>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/pci.h>
18 #include <linux/slab.h>
19 #include <linux/ioport.h>
20 #include <linux/amba/bus.h>
21 #include <linux/amba/serial.h>
22
23 #include <asm/reboot.h>
24 #include <asm/time.h>
25 #include <asm/addrspace.h>
26 #include <asm/bootinfo.h>
27 #include <asm/io.h>
28 #include <adm8668.h>
29
30 static void adm8668_uart_set_mctrl(struct amba_device *dev,
31 void __iomem *base,
32 unsigned int mcrtl)
33 {
34 }
35
36 static struct amba_pl010_data adm8668_uart0_data = {
37 .set_mctrl = adm8668_uart_set_mctrl,
38 };
39
40 static struct amba_device adm8668_uart0_device = {
41 .dev = {
42 .init_name = "apb:uart0",
43 .platform_data = &adm8668_uart0_data,
44 },
45 .res = {
46 .start = ADM8668_UART0_BASE,
47 .end = ADM8668_UART0_BASE + 0xF,
48 .flags = IORESOURCE_MEM,
49 },
50 .irq = {
51 INT_LVL_UART0,
52 -1
53 },
54 .periphid = 0x0041010,
55 };
56
57 static struct resource eth0_resources[] = {
58 {
59 .start = ADM8668_LAN_BASE,
60 .end = ADM8668_LAN_BASE + 256,
61 .flags = IORESOURCE_MEM,
62 },
63 {
64 .start = INT_LVL_LAN,
65 .flags = IORESOURCE_IRQ,
66 },
67 };
68
69 static struct platform_device adm8668_eth0_device = {
70 .name = "adm8668_eth",
71 .id = 0,
72 .resource = eth0_resources,
73 .num_resources = ARRAY_SIZE(eth0_resources),
74 };
75
76 static struct resource eth1_resources[] = {
77 {
78 .start = ADM8668_WAN_BASE,
79 .end = ADM8668_WAN_BASE + 256,
80 .flags = IORESOURCE_MEM,
81 },
82 {
83 .start = INT_LVL_WAN,
84 .flags = IORESOURCE_IRQ,
85 },
86 };
87
88 static struct platform_device adm8668_eth1_device = {
89 .name = "adm8668_eth",
90 .id = 1,
91 .resource = eth1_resources,
92 .num_resources = ARRAY_SIZE(eth1_resources),
93 };
94
95 static const char *nor_probe_types[] = { "adm8668part", NULL };
96
97 static struct physmap_flash_data nor_flash_data = {
98 .width = 2,
99 .part_probe_types = nor_probe_types,
100 };
101
102 static struct resource nor_resources[] = {
103 {
104 .start = ADM8668_SMEM1_BASE,
105 .end = ADM8668_SMEM1_BASE + 0x800000 - 1,
106 .flags = IORESOURCE_MEM,
107 },
108 };
109
110 static struct platform_device adm8668_nor_device = {
111 .name = "physmap-flash",
112 .id = -1,
113 .resource = nor_resources,
114 .num_resources = ARRAY_SIZE(nor_resources),
115 .dev.platform_data = &nor_flash_data,
116 };
117
118 static struct platform_device *adm8668_devs[] = {
119 &adm8668_eth0_device,
120 &adm8668_eth1_device,
121 &adm8668_nor_device,
122 };
123
124 int __devinit adm8668_devs_register(void)
125 {
126 int ret;
127
128 ret = amba_device_register(&adm8668_uart0_device, &iomem_resource);
129 if (ret)
130 panic("failed to register AMBA UART");
131
132 return platform_add_devices(adm8668_devs, ARRAY_SIZE(adm8668_devs));
133 }
134 arch_initcall(adm8668_devs_register);