723f27fe703f4293f5feeb3734e6ead4e4480ad5
[openwrt/openwrt.git] / target / linux / adm5120-2.6 / files / arch / mips / adm5120 / platform.c
1 /*
2 * $Id$
3 *
4 * Generic ADM5120 platform devices
5 *
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 *
24 */
25
26 #include <linux/init.h>
27 #include <linux/kernel.h>
28 #include <linux/list.h>
29 #include <linux/device.h>
30 #include <linux/platform_device.h>
31
32 #include <asm/bootinfo.h>
33 #include <asm/gpio.h>
34
35 #include <asm/mach-adm5120/adm5120_defs.h>
36 #include <asm/mach-adm5120/adm5120_info.h>
37 #include <asm/mach-adm5120/adm5120_irq.h>
38 #include <asm/mach-adm5120/adm5120_switch.h>
39 #include <asm/mach-adm5120/adm5120_platform.h>
40
41 static void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
42 unsigned int mctrl);
43
44 #if 1
45 /*
46 * TODO:remove global adm5120_eth* variables when the switch driver will be
47 * converted into a real platform driver
48 */
49 unsigned int adm5120_eth_num_ports = 6;
50 unsigned char adm5120_eth_macs[6][6] = {
51 {'\00', 'A', 'D', 'M', '\x51', '\x20' },
52 {'\00', 'A', 'D', 'M', '\x51', '\x21' },
53 {'\00', 'A', 'D', 'M', '\x51', '\x22' },
54 {'\00', 'A', 'D', 'M', '\x51', '\x23' },
55 {'\00', 'A', 'D', 'M', '\x51', '\x24' },
56 {'\00', 'A', 'D', 'M', '\x51', '\x25' }
57 };
58
59 EXPORT_SYMBOL_GPL(adm5120_eth_num_ports);
60 EXPORT_SYMBOL_GPL(adm5120_eth_macs);
61 #else
62 /* Built-in ethernet switch */
63 struct adm5120_switch_platform_data adm5120_switch_data;
64 struct platform_device adm5120_switch_device = {
65 .name = "adm5120-switch",
66 .id = -1,
67 .dev.platform_data = &adm5120_switch_data,
68 };
69 #endif
70
71 /* PCI Host Controller */
72 struct adm5120_pci_platform_data adm5120_pci_data;
73 struct platform_device adm5120_pci_device = {
74 .name = "adm5120-pci",
75 .id = -1,
76 .dev.platform_data = &adm5120_pci_data,
77 };
78
79 /* USB Host Controller */
80 struct resource adm5120_usbc_resources[] = {
81 [0] = {
82 .start = ADM5120_USBC_BASE,
83 .end = ADM5120_USBC_BASE+ADM5120_USBC_SIZE-1,
84 .flags = IORESOURCE_MEM,
85 },
86 [1] = {
87 .start = ADM5120_IRQ_USBC,
88 .end = ADM5120_IRQ_USBC,
89 .flags = IORESOURCE_IRQ,
90 },
91 };
92
93 struct platform_device adm5120_usbc_device = {
94 .name = "adm5120-usbc",
95 .id = -1,
96 .num_resources = ARRAY_SIZE(adm5120_usbc_resources),
97 .resource = adm5120_usbc_resources,
98 };
99
100 /* NOR flash 0 */
101 struct adm5120_flash_platform_data adm5120_flash0_data;
102 struct platform_device adm5120_flash0_device = {
103 .name = "adm5120-flash",
104 .id = 0,
105 .dev.platform_data = &adm5120_flash0_data,
106 };
107
108 /* NOR flash 1 */
109 struct adm5120_flash_platform_data adm5120_flash1_data;
110 struct platform_device adm5120_flash1_device = {
111 .name = "adm5120-flash",
112 .id = 1,
113 .dev.platform_data = &adm5120_flash1_data,
114 };
115
116 /* NAND flash */
117 struct resource adm5120_nand_resource[] = {
118 [0] = {
119 .start = ADM5120_SRAM1_BASE,
120 .end = ADM5120_SRAM1_BASE+ADM5120_MPMC_SIZE-1,
121 .flags = IORESOURCE_MEM,
122 },
123 };
124
125 struct adm5120_nand_platform_data adm5120_nand_data;
126
127 struct platform_device adm5120_nand_device = {
128 .name = "adm5120-nand",
129 .id = -1,
130 .dev.platform_data = &adm5120_nand_data,
131 .num_resources = ARRAY_SIZE(adm5120_nand_resource),
132 .resource = adm5120_nand_resource,
133 };
134
135 /* built-in UARTs */
136 struct amba_pl010_data adm5120_uart0_data = {
137 .set_mctrl = adm5120_uart_set_mctrl
138 };
139
140 struct amba_device adm5120_uart0_device = {
141 .dev = {
142 .bus_id = "APB:UART0",
143 .platform_data = &adm5120_uart0_data,
144 },
145 .res = {
146 .start = ADM5120_UART0_BASE,
147 .end = ADM5120_UART0_BASE + ADM5120_UART_SIZE - 1,
148 .flags = IORESOURCE_MEM,
149 },
150 .irq = { ADM5120_IRQ_UART0, -1 },
151 .periphid = 0x0041010,
152 };
153
154 struct amba_pl010_data adm5120_uart1_data = {
155 .set_mctrl = adm5120_uart_set_mctrl
156 };
157
158 struct amba_device adm5120_uart1_device = {
159 .dev = {
160 .bus_id = "APB:UART1",
161 .platform_data = &adm5120_uart1_data,
162 },
163 .res = {
164 .start = ADM5120_UART1_BASE,
165 .end = ADM5120_UART1_BASE + ADM5120_UART_SIZE - 1,
166 .flags = IORESOURCE_MEM,
167 },
168 .irq = { ADM5120_IRQ_UART1, -1 },
169 .periphid = 0x0041010,
170 };
171
172 static void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
173 unsigned int mctrl)
174 {
175 }