]>
Commit | Line | Data |
---|---|---|
9b6553cd | 1 | /* |
f30c2269 | 2 | * linux/arch/arm/mach-omap2/board-apollon.c |
9b6553cd TL |
3 | * |
4 | * Copyright (C) 2005,2006 Samsung Electronics | |
5 | * Author: Kyungmin Park <kyungmin.park@samsung.com> | |
6 | * | |
7 | * Modified from mach-omap/omap2/board-h4.c | |
8 | * | |
9 | * Code for apollon OMAP2 board. Should work on many OMAP2 systems where | |
10 | * the bootloader passes the board-specific data to the kernel. | |
11 | * Do not put any board specific code to this file; create a new machine | |
12 | * type if you need custom low-level initializations. | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License version 2 as | |
16 | * published by the Free Software Foundation. | |
17 | */ | |
18 | ||
19 | #include <linux/kernel.h> | |
20 | #include <linux/init.h> | |
21 | #include <linux/platform_device.h> | |
22 | #include <linux/mtd/mtd.h> | |
23 | #include <linux/mtd/partitions.h> | |
24 | #include <linux/mtd/onenand.h> | |
9b6553cd | 25 | #include <linux/delay.h> |
f0248408 | 26 | #include <linux/leds.h> |
44595982 PW |
27 | #include <linux/err.h> |
28 | #include <linux/clk.h> | |
3bc48014 | 29 | #include <linux/smc91x.h> |
9b6553cd | 30 | |
a09e64fb | 31 | #include <mach/hardware.h> |
9b6553cd TL |
32 | #include <asm/mach-types.h> |
33 | #include <asm/mach/arch.h> | |
34 | #include <asm/mach/flash.h> | |
35 | ||
a09e64fb | 36 | #include <mach/gpio.h> |
ce491cf8 TL |
37 | #include <plat/led.h> |
38 | #include <plat/mux.h> | |
39 | #include <plat/usb.h> | |
40 | #include <plat/board.h> | |
41 | #include <plat/common.h> | |
42 | #include <plat/gpmc.h> | |
43 | #include <plat/control.h> | |
9b6553cd | 44 | |
b52b14ef TL |
45 | #include "mux.h" |
46 | ||
9b6553cd TL |
47 | /* LED & Switch macros */ |
48 | #define LED0_GPIO13 13 | |
49 | #define LED1_GPIO14 14 | |
50 | #define LED2_GPIO15 15 | |
51 | #define SW_ENTER_GPIO16 16 | |
52 | #define SW_UP_GPIO17 17 | |
53 | #define SW_DOWN_GPIO58 58 | |
54 | ||
f0248408 KP |
55 | #define APOLLON_FLASH_CS 0 |
56 | #define APOLLON_ETH_CS 1 | |
70554775 | 57 | #define APOLLON_ETHR_GPIO_IRQ 74 |
f0248408 | 58 | |
9b6553cd TL |
59 | static struct mtd_partition apollon_partitions[] = { |
60 | { | |
61 | .name = "X-Loader + U-Boot", | |
62 | .offset = 0, | |
63 | .size = SZ_128K, | |
64 | .mask_flags = MTD_WRITEABLE, | |
65 | }, | |
66 | { | |
67 | .name = "params", | |
68 | .offset = MTDPART_OFS_APPEND, | |
69 | .size = SZ_128K, | |
70 | }, | |
71 | { | |
72 | .name = "kernel", | |
73 | .offset = MTDPART_OFS_APPEND, | |
74 | .size = SZ_2M, | |
75 | }, | |
76 | { | |
77 | .name = "rootfs", | |
78 | .offset = MTDPART_OFS_APPEND, | |
79 | .size = SZ_16M, | |
80 | }, | |
81 | { | |
82 | .name = "filesystem00", | |
83 | .offset = MTDPART_OFS_APPEND, | |
84 | .size = SZ_32M, | |
85 | }, | |
86 | { | |
87 | .name = "filesystem01", | |
88 | .offset = MTDPART_OFS_APPEND, | |
89 | .size = MTDPART_SIZ_FULL, | |
90 | }, | |
91 | }; | |
92 | ||
778dbcc1 | 93 | static struct onenand_platform_data apollon_flash_data = { |
9b6553cd TL |
94 | .parts = apollon_partitions, |
95 | .nr_parts = ARRAY_SIZE(apollon_partitions), | |
96 | }; | |
97 | ||
f0248408 KP |
98 | static struct resource apollon_flash_resource[] = { |
99 | [0] = { | |
100 | .flags = IORESOURCE_MEM, | |
101 | }, | |
9b6553cd TL |
102 | }; |
103 | ||
104 | static struct platform_device apollon_onenand_device = { | |
778dbcc1 | 105 | .name = "onenand-flash", |
9b6553cd TL |
106 | .id = -1, |
107 | .dev = { | |
108 | .platform_data = &apollon_flash_data, | |
109 | }, | |
f0248408 KP |
110 | .num_resources = ARRAY_SIZE(apollon_flash_resource), |
111 | .resource = apollon_flash_resource, | |
9b6553cd TL |
112 | }; |
113 | ||
f0248408 KP |
114 | static void __init apollon_flash_init(void) |
115 | { | |
116 | unsigned long base; | |
117 | ||
118 | if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) { | |
119 | printk(KERN_ERR "Cannot request OneNAND GPMC CS\n"); | |
120 | return; | |
121 | } | |
122 | apollon_flash_resource[0].start = base; | |
123 | apollon_flash_resource[0].end = base + SZ_128K - 1; | |
124 | } | |
125 | ||
3bc48014 LM |
126 | static struct smc91x_platdata appolon_smc91x_info = { |
127 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, | |
128 | .leda = RPC_LED_100_10, | |
129 | .ledb = RPC_LED_TX_RX, | |
130 | }; | |
131 | ||
9b6553cd TL |
132 | static struct resource apollon_smc91x_resources[] = { |
133 | [0] = { | |
9b6553cd TL |
134 | .flags = IORESOURCE_MEM, |
135 | }, | |
136 | [1] = { | |
137 | .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
138 | .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
e7b3dc7e | 139 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
9b6553cd TL |
140 | }, |
141 | }; | |
142 | ||
143 | static struct platform_device apollon_smc91x_device = { | |
144 | .name = "smc91x", | |
145 | .id = -1, | |
3bc48014 LM |
146 | .dev = { |
147 | .platform_data = &appolon_smc91x_info, | |
148 | }, | |
9b6553cd TL |
149 | .num_resources = ARRAY_SIZE(apollon_smc91x_resources), |
150 | .resource = apollon_smc91x_resources, | |
151 | }; | |
152 | ||
153 | static struct platform_device apollon_lcd_device = { | |
154 | .name = "apollon_lcd", | |
155 | .id = -1, | |
156 | }; | |
157 | ||
f0248408 KP |
158 | static struct omap_led_config apollon_led_config[] = { |
159 | { | |
160 | .cdev = { | |
161 | .name = "apollon:led0", | |
162 | }, | |
163 | .gpio = LED0_GPIO13, | |
164 | }, | |
165 | { | |
166 | .cdev = { | |
167 | .name = "apollon:led1", | |
168 | }, | |
169 | .gpio = LED1_GPIO14, | |
170 | }, | |
171 | { | |
172 | .cdev = { | |
173 | .name = "apollon:led2", | |
174 | }, | |
175 | .gpio = LED2_GPIO15, | |
176 | }, | |
177 | }; | |
178 | ||
179 | static struct omap_led_platform_data apollon_led_data = { | |
180 | .nr_leds = ARRAY_SIZE(apollon_led_config), | |
181 | .leds = apollon_led_config, | |
182 | }; | |
183 | ||
184 | static struct platform_device apollon_led_device = { | |
185 | .name = "omap-led", | |
186 | .id = -1, | |
187 | .dev = { | |
188 | .platform_data = &apollon_led_data, | |
189 | }, | |
190 | }; | |
191 | ||
9b6553cd TL |
192 | static struct platform_device *apollon_devices[] __initdata = { |
193 | &apollon_onenand_device, | |
194 | &apollon_smc91x_device, | |
195 | &apollon_lcd_device, | |
f0248408 | 196 | &apollon_led_device, |
9b6553cd TL |
197 | }; |
198 | ||
199 | static inline void __init apollon_init_smc91x(void) | |
200 | { | |
f0248408 KP |
201 | unsigned long base; |
202 | ||
44595982 PW |
203 | unsigned int rate; |
204 | struct clk *gpmc_fck; | |
205 | int eth_cs; | |
206 | ||
207 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
208 | if (IS_ERR(gpmc_fck)) { | |
209 | WARN_ON(1); | |
210 | return; | |
211 | } | |
212 | ||
213 | clk_enable(gpmc_fck); | |
214 | rate = clk_get_rate(gpmc_fck); | |
215 | ||
216 | eth_cs = APOLLON_ETH_CS; | |
217 | ||
9b6553cd | 218 | /* Make sure CS1 timings are correct */ |
44595982 PW |
219 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); |
220 | ||
221 | if (rate >= 160000000) { | |
222 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
223 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
224 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
225 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
226 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
227 | } else if (rate >= 130000000) { | |
228 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
229 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
230 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
231 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
232 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
233 | } else {/* rate = 100000000 */ | |
234 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
235 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
236 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
237 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | |
238 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
239 | } | |
f0248408 KP |
240 | |
241 | if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { | |
242 | printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); | |
44595982 | 243 | goto out; |
f0248408 KP |
244 | } |
245 | apollon_smc91x_resources[0].start = base + 0x300; | |
246 | apollon_smc91x_resources[0].end = base + 0x30f; | |
9b6553cd TL |
247 | udelay(100); |
248 | ||
249 | omap_cfg_reg(W4__24XX_GPIO74); | |
f2d18fea | 250 | if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) { |
9b6553cd TL |
251 | printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", |
252 | APOLLON_ETHR_GPIO_IRQ); | |
f0248408 | 253 | gpmc_cs_free(APOLLON_ETH_CS); |
44595982 | 254 | goto out; |
9b6553cd | 255 | } |
40e3925b | 256 | gpio_direction_input(APOLLON_ETHR_GPIO_IRQ); |
44595982 PW |
257 | |
258 | out: | |
259 | clk_disable(gpmc_fck); | |
260 | clk_put(gpmc_fck); | |
9b6553cd TL |
261 | } |
262 | ||
f0248408 KP |
263 | static struct omap_usb_config apollon_usb_config __initdata = { |
264 | .register_dev = 1, | |
265 | .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */ | |
266 | ||
267 | .pins[0] = 6, | |
268 | }; | |
269 | ||
9b6553cd TL |
270 | static struct omap_lcd_config apollon_lcd_config __initdata = { |
271 | .ctrl_name = "internal", | |
272 | }; | |
273 | ||
274 | static struct omap_board_config_kernel apollon_config[] = { | |
9b6553cd TL |
275 | { OMAP_TAG_LCD, &apollon_lcd_config }, |
276 | }; | |
277 | ||
b3c6df3a PW |
278 | static void __init omap_apollon_init_irq(void) |
279 | { | |
280 | omap_board_config = apollon_config; | |
281 | omap_board_config_size = ARRAY_SIZE(apollon_config); | |
282 | omap2_init_common_hw(NULL, NULL); | |
283 | omap_init_irq(); | |
284 | omap_gpio_init(); | |
285 | apollon_init_smc91x(); | |
286 | } | |
287 | ||
9b6553cd TL |
288 | static void __init apollon_led_init(void) |
289 | { | |
290 | /* LED0 - AA10 */ | |
291 | omap_cfg_reg(AA10_242X_GPIO13); | |
73069e38 JN |
292 | gpio_request(LED0_GPIO13, "LED0"); |
293 | gpio_direction_output(LED0_GPIO13, 0); | |
9b6553cd TL |
294 | /* LED1 - AA6 */ |
295 | omap_cfg_reg(AA6_242X_GPIO14); | |
73069e38 JN |
296 | gpio_request(LED1_GPIO14, "LED1"); |
297 | gpio_direction_output(LED1_GPIO14, 0); | |
9b6553cd TL |
298 | /* LED2 - AA4 */ |
299 | omap_cfg_reg(AA4_242X_GPIO15); | |
73069e38 JN |
300 | gpio_request(LED2_GPIO15, "LED2"); |
301 | gpio_direction_output(LED2_GPIO15, 0); | |
9b6553cd TL |
302 | } |
303 | ||
f0248408 KP |
304 | static void __init apollon_usb_init(void) |
305 | { | |
306 | /* USB device */ | |
307 | /* DEVICE_SUSPEND */ | |
308 | omap_cfg_reg(P21_242X_GPIO12); | |
f2d18fea | 309 | gpio_request(12, "USB suspend"); |
e918edf7 | 310 | gpio_direction_output(12, 0); |
b5e8905b | 311 | omap2_usbfs_init(&apollon_usb_config); |
f0248408 KP |
312 | } |
313 | ||
b52b14ef TL |
314 | #ifdef CONFIG_OMAP_MUX |
315 | static struct omap_board_mux board_mux[] __initdata = { | |
316 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
317 | }; | |
318 | #else | |
319 | #define board_mux NULL | |
320 | #endif | |
321 | ||
9b6553cd TL |
322 | static void __init omap_apollon_init(void) |
323 | { | |
44595982 PW |
324 | u32 v; |
325 | ||
b52b14ef TL |
326 | omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); |
327 | ||
9b6553cd | 328 | apollon_led_init(); |
f0248408 KP |
329 | apollon_flash_init(); |
330 | apollon_usb_init(); | |
9b6553cd TL |
331 | |
332 | /* REVISIT: where's the correct place */ | |
333 | omap_cfg_reg(W19_24XX_SYS_NIRQ); | |
334 | ||
18dbe6c5 TL |
335 | /* LCD PWR_EN */ |
336 | omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); | |
337 | ||
abc45e1d | 338 | /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */ |
44595982 PW |
339 | v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
340 | v |= (1 << 24); | |
341 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); | |
abc45e1d | 342 | |
9b6553cd TL |
343 | /* |
344 | * Make sure the serial ports are muxed on at this point. | |
345 | * You have to mux them off in device drivers later on | |
346 | * if not needed. | |
347 | */ | |
348 | platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices)); | |
9b6553cd TL |
349 | omap_serial_init(); |
350 | } | |
351 | ||
352 | static void __init omap_apollon_map_io(void) | |
353 | { | |
c8d2eb8e | 354 | omap2_set_globals_242x(); |
6fbd55d0 | 355 | omap242x_map_common_io(); |
9b6553cd TL |
356 | } |
357 | ||
358 | MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") | |
359 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ | |
360 | .phys_io = 0x48000000, | |
b4224b23 | 361 | .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, |
9b6553cd TL |
362 | .boot_params = 0x80000100, |
363 | .map_io = omap_apollon_map_io, | |
364 | .init_irq = omap_apollon_init_irq, | |
365 | .init_machine = omap_apollon_init, | |
366 | .timer = &omap_timer, | |
367 | MACHINE_END |