diff options
Diffstat (limited to 'arch/arm/mach-mx3/mach-kzm_arm11_01.c')
-rw-r--r-- | arch/arm/mach-mx3/mach-kzm_arm11_01.c | 273 |
1 files changed, 273 insertions, 0 deletions
diff --git a/arch/arm/mach-mx3/mach-kzm_arm11_01.c b/arch/arm/mach-mx3/mach-kzm_arm11_01.c new file mode 100644 index 000000000000..f085d5d1a6de --- /dev/null +++ b/arch/arm/mach-mx3/mach-kzm_arm11_01.c | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * KZM-ARM11-01 support | ||
3 | * Copyright (C) 2009 Yoichi Yuasa <yuasa@linux-mips.org> | ||
4 | * | ||
5 | * based on code for MX31ADS, | ||
6 | * Copyright (C) 2000 Deep Blue Solutions Ltd | ||
7 | * Copyright (C) 2002 Shane Nay (shane@minirl.com) | ||
8 | * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | #include <linux/gpio.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/serial_8250.h> | ||
29 | #include <linux/smsc911x.h> | ||
30 | #include <linux/types.h> | ||
31 | |||
32 | #include <asm/irq.h> | ||
33 | #include <asm/mach-types.h> | ||
34 | #include <asm/setup.h> | ||
35 | #include <asm/mach/arch.h> | ||
36 | #include <asm/mach/irq.h> | ||
37 | #include <asm/mach/map.h> | ||
38 | #include <asm/mach/time.h> | ||
39 | |||
40 | #include <mach/board-kzmarm11.h> | ||
41 | #include <mach/clock.h> | ||
42 | #include <mach/common.h> | ||
43 | #include <mach/imx-uart.h> | ||
44 | #include <mach/iomux-mx3.h> | ||
45 | #include <mach/memory.h> | ||
46 | |||
47 | #include "devices.h" | ||
48 | |||
49 | #define KZM_ARM11_IO_ADDRESS(x) ( \ | ||
50 | IMX_IO_ADDRESS(x, MX31_CS4) ?: \ | ||
51 | IMX_IO_ADDRESS(x, MX31_CS5) ?: \ | ||
52 | MX31_IO_ADDRESS(x)) | ||
53 | |||
54 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) | ||
55 | /* | ||
56 | * KZM-ARM11-01 has an external UART on FPGA | ||
57 | */ | ||
58 | static struct plat_serial8250_port serial_platform_data[] = { | ||
59 | { | ||
60 | .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550), | ||
61 | .mapbase = KZM_ARM11_16550, | ||
62 | .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), | ||
63 | .irqflags = IRQ_TYPE_EDGE_RISING, | ||
64 | .uartclk = 14745600, | ||
65 | .regshift = 0, | ||
66 | .iotype = UPIO_MEM, | ||
67 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | | ||
68 | UPF_BUGGY_UART, | ||
69 | }, | ||
70 | {}, | ||
71 | }; | ||
72 | |||
73 | static struct resource serial8250_resources[] = { | ||
74 | { | ||
75 | .start = KZM_ARM11_16550, | ||
76 | .end = KZM_ARM11_16550 + 0x10, | ||
77 | .flags = IORESOURCE_MEM, | ||
78 | }, | ||
79 | { | ||
80 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), | ||
81 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), | ||
82 | .flags = IORESOURCE_IRQ, | ||
83 | }, | ||
84 | }; | ||
85 | |||
86 | static struct platform_device serial_device = { | ||
87 | .name = "serial8250", | ||
88 | .id = PLAT8250_DEV_PLATFORM, | ||
89 | .dev = { | ||
90 | .platform_data = serial_platform_data, | ||
91 | }, | ||
92 | .num_resources = ARRAY_SIZE(serial8250_resources), | ||
93 | .resource = serial8250_resources, | ||
94 | }; | ||
95 | |||
96 | static int __init kzm_init_ext_uart(void) | ||
97 | { | ||
98 | u8 tmp; | ||
99 | |||
100 | /* | ||
101 | * GPIO 1-1: external UART interrupt line | ||
102 | */ | ||
103 | mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO)); | ||
104 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int"); | ||
105 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)); | ||
106 | |||
107 | /* | ||
108 | * Unmask UART interrupt | ||
109 | */ | ||
110 | tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); | ||
111 | tmp |= 0x2; | ||
112 | __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1)); | ||
113 | |||
114 | return platform_device_register(&serial_device); | ||
115 | } | ||
116 | #else | ||
117 | static inline int kzm_init_ext_uart(void) | ||
118 | { | ||
119 | return 0; | ||
120 | } | ||
121 | #endif | ||
122 | |||
123 | /* | ||
124 | * SMSC LAN9118 | ||
125 | */ | ||
126 | #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) | ||
127 | static struct smsc911x_platform_config kzm_smsc9118_config = { | ||
128 | .phy_interface = PHY_INTERFACE_MODE_MII, | ||
129 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, | ||
130 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | ||
131 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, | ||
132 | }; | ||
133 | |||
134 | static struct resource kzm_smsc9118_resources[] = { | ||
135 | { | ||
136 | .start = MX31_CS5_BASE_ADDR, | ||
137 | .end = MX31_CS5_BASE_ADDR + SZ_128K - 1, | ||
138 | .flags = IORESOURCE_MEM, | ||
139 | }, | ||
140 | { | ||
141 | .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2), | ||
142 | .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2), | ||
143 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | ||
144 | }, | ||
145 | }; | ||
146 | |||
147 | static struct platform_device kzm_smsc9118_device = { | ||
148 | .name = "smsc911x", | ||
149 | .id = -1, | ||
150 | .num_resources = ARRAY_SIZE(kzm_smsc9118_resources), | ||
151 | .resource = kzm_smsc9118_resources, | ||
152 | .dev = { | ||
153 | .platform_data = &kzm_smsc9118_config, | ||
154 | }, | ||
155 | }; | ||
156 | |||
157 | static int __init kzm_init_smsc9118(void) | ||
158 | { | ||
159 | /* | ||
160 | * GPIO 1-2: SMSC9118 interrupt line | ||
161 | */ | ||
162 | mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO)); | ||
163 | gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int"); | ||
164 | gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2)); | ||
165 | |||
166 | return platform_device_register(&kzm_smsc9118_device); | ||
167 | } | ||
168 | #else | ||
169 | static inline int kzm_init_smsc9118(void) | ||
170 | { | ||
171 | return 0; | ||
172 | } | ||
173 | #endif | ||
174 | |||
175 | #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE) | ||
176 | static struct imxuart_platform_data uart_pdata = { | ||
177 | .flags = IMXUART_HAVE_RTSCTS, | ||
178 | }; | ||
179 | |||
180 | static void __init kzm_init_imx_uart(void) | ||
181 | { | ||
182 | mxc_register_device(&mxc_uart_device0, &uart_pdata); | ||
183 | |||
184 | mxc_register_device(&mxc_uart_device1, &uart_pdata); | ||
185 | } | ||
186 | #else | ||
187 | static inline void kzm_init_imx_uart(void) | ||
188 | { | ||
189 | } | ||
190 | #endif | ||
191 | |||
192 | static int kzm_pins[] __initdata = { | ||
193 | MX31_PIN_CTS1__CTS1, | ||
194 | MX31_PIN_RTS1__RTS1, | ||
195 | MX31_PIN_TXD1__TXD1, | ||
196 | MX31_PIN_RXD1__RXD1, | ||
197 | MX31_PIN_DCD_DCE1__DCD_DCE1, | ||
198 | MX31_PIN_RI_DCE1__RI_DCE1, | ||
199 | MX31_PIN_DSR_DCE1__DSR_DCE1, | ||
200 | MX31_PIN_DTR_DCE1__DTR_DCE1, | ||
201 | MX31_PIN_CTS2__CTS2, | ||
202 | MX31_PIN_RTS2__RTS2, | ||
203 | MX31_PIN_TXD2__TXD2, | ||
204 | MX31_PIN_RXD2__RXD2, | ||
205 | MX31_PIN_DCD_DTE1__DCD_DTE2, | ||
206 | MX31_PIN_RI_DTE1__RI_DTE2, | ||
207 | MX31_PIN_DSR_DTE1__DSR_DTE2, | ||
208 | MX31_PIN_DTR_DTE1__DTR_DTE2, | ||
209 | }; | ||
210 | |||
211 | /* | ||
212 | * Board specific initialization. | ||
213 | */ | ||
214 | static void __init kzm_board_init(void) | ||
215 | { | ||
216 | mxc_iomux_setup_multiple_pins(kzm_pins, | ||
217 | ARRAY_SIZE(kzm_pins), "kzm"); | ||
218 | kzm_init_ext_uart(); | ||
219 | kzm_init_smsc9118(); | ||
220 | kzm_init_imx_uart(); | ||
221 | |||
222 | pr_info("Clock input source is 26MHz\n"); | ||
223 | } | ||
224 | |||
225 | /* | ||
226 | * This structure defines static mappings for the kzm-arm11-01 board. | ||
227 | */ | ||
228 | static struct map_desc kzm_io_desc[] __initdata = { | ||
229 | { | ||
230 | .virtual = MX31_CS4_BASE_ADDR_VIRT, | ||
231 | .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR), | ||
232 | .length = MX31_CS4_SIZE, | ||
233 | .type = MT_DEVICE | ||
234 | }, | ||
235 | { | ||
236 | .virtual = MX31_CS5_BASE_ADDR_VIRT, | ||
237 | .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR), | ||
238 | .length = MX31_CS5_SIZE, | ||
239 | .type = MT_DEVICE | ||
240 | }, | ||
241 | }; | ||
242 | |||
243 | /* | ||
244 | * Set up static virtual mappings. | ||
245 | */ | ||
246 | static void __init kzm_map_io(void) | ||
247 | { | ||
248 | mx31_map_io(); | ||
249 | iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc)); | ||
250 | } | ||
251 | |||
252 | static void __init kzm_timer_init(void) | ||
253 | { | ||
254 | mx31_clocks_init(26000000); | ||
255 | } | ||
256 | |||
257 | static struct sys_timer kzm_timer = { | ||
258 | .init = kzm_timer_init, | ||
259 | }; | ||
260 | |||
261 | /* | ||
262 | * The following uses standard kernel macros define in arch.h in order to | ||
263 | * initialize __mach_desc_KZM_ARM11_01 data structure. | ||
264 | */ | ||
265 | MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01") | ||
266 | .phys_io = MX31_AIPS1_BASE_ADDR, | ||
267 | .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc, | ||
268 | .boot_params = MX3x_PHYS_OFFSET + 0x100, | ||
269 | .map_io = kzm_map_io, | ||
270 | .init_irq = mx31_init_irq, | ||
271 | .init_machine = kzm_board_init, | ||
272 | .timer = &kzm_timer, | ||
273 | MACHINE_END | ||