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> |
f9fa1bb9 | 30 | #include <linux/gpio.h> |
9b6553cd | 31 | |
a09e64fb | 32 | #include <mach/hardware.h> |
9b6553cd TL |
33 | #include <asm/mach-types.h> |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/flash.h> | |
36 | ||
ce491cf8 | 37 | #include <plat/led.h> |
ce491cf8 TL |
38 | #include <plat/usb.h> |
39 | #include <plat/board.h> | |
40 | #include <plat/common.h> | |
41 | #include <plat/gpmc.h> | |
9b6553cd | 42 | |
b52b14ef | 43 | #include "mux.h" |
4814ced5 | 44 | #include "control.h" |
b52b14ef | 45 | |
9b6553cd TL |
46 | /* LED & Switch macros */ |
47 | #define LED0_GPIO13 13 | |
48 | #define LED1_GPIO14 14 | |
49 | #define LED2_GPIO15 15 | |
50 | #define SW_ENTER_GPIO16 16 | |
51 | #define SW_UP_GPIO17 17 | |
52 | #define SW_DOWN_GPIO58 58 | |
53 | ||
f0248408 KP |
54 | #define APOLLON_FLASH_CS 0 |
55 | #define APOLLON_ETH_CS 1 | |
70554775 | 56 | #define APOLLON_ETHR_GPIO_IRQ 74 |
f0248408 | 57 | |
9b6553cd TL |
58 | static struct mtd_partition apollon_partitions[] = { |
59 | { | |
60 | .name = "X-Loader + U-Boot", | |
61 | .offset = 0, | |
62 | .size = SZ_128K, | |
63 | .mask_flags = MTD_WRITEABLE, | |
64 | }, | |
65 | { | |
66 | .name = "params", | |
67 | .offset = MTDPART_OFS_APPEND, | |
68 | .size = SZ_128K, | |
69 | }, | |
70 | { | |
71 | .name = "kernel", | |
72 | .offset = MTDPART_OFS_APPEND, | |
73 | .size = SZ_2M, | |
74 | }, | |
75 | { | |
76 | .name = "rootfs", | |
77 | .offset = MTDPART_OFS_APPEND, | |
78 | .size = SZ_16M, | |
79 | }, | |
80 | { | |
81 | .name = "filesystem00", | |
82 | .offset = MTDPART_OFS_APPEND, | |
83 | .size = SZ_32M, | |
84 | }, | |
85 | { | |
86 | .name = "filesystem01", | |
87 | .offset = MTDPART_OFS_APPEND, | |
88 | .size = MTDPART_SIZ_FULL, | |
89 | }, | |
90 | }; | |
91 | ||
778dbcc1 | 92 | static struct onenand_platform_data apollon_flash_data = { |
9b6553cd TL |
93 | .parts = apollon_partitions, |
94 | .nr_parts = ARRAY_SIZE(apollon_partitions), | |
95 | }; | |
96 | ||
f0248408 KP |
97 | static struct resource apollon_flash_resource[] = { |
98 | [0] = { | |
99 | .flags = IORESOURCE_MEM, | |
100 | }, | |
9b6553cd TL |
101 | }; |
102 | ||
103 | static struct platform_device apollon_onenand_device = { | |
778dbcc1 | 104 | .name = "onenand-flash", |
9b6553cd TL |
105 | .id = -1, |
106 | .dev = { | |
107 | .platform_data = &apollon_flash_data, | |
108 | }, | |
f0248408 KP |
109 | .num_resources = ARRAY_SIZE(apollon_flash_resource), |
110 | .resource = apollon_flash_resource, | |
9b6553cd TL |
111 | }; |
112 | ||
f0248408 KP |
113 | static void __init apollon_flash_init(void) |
114 | { | |
115 | unsigned long base; | |
116 | ||
117 | if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) { | |
118 | printk(KERN_ERR "Cannot request OneNAND GPMC CS\n"); | |
119 | return; | |
120 | } | |
121 | apollon_flash_resource[0].start = base; | |
122 | apollon_flash_resource[0].end = base + SZ_128K - 1; | |
123 | } | |
124 | ||
3bc48014 LM |
125 | static struct smc91x_platdata appolon_smc91x_info = { |
126 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, | |
127 | .leda = RPC_LED_100_10, | |
128 | .ledb = RPC_LED_TX_RX, | |
129 | }; | |
130 | ||
9b6553cd TL |
131 | static struct resource apollon_smc91x_resources[] = { |
132 | [0] = { | |
9b6553cd TL |
133 | .flags = IORESOURCE_MEM, |
134 | }, | |
135 | [1] = { | |
136 | .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
137 | .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
e7b3dc7e | 138 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
9b6553cd TL |
139 | }, |
140 | }; | |
141 | ||
142 | static struct platform_device apollon_smc91x_device = { | |
143 | .name = "smc91x", | |
144 | .id = -1, | |
3bc48014 LM |
145 | .dev = { |
146 | .platform_data = &appolon_smc91x_info, | |
147 | }, | |
9b6553cd TL |
148 | .num_resources = ARRAY_SIZE(apollon_smc91x_resources), |
149 | .resource = apollon_smc91x_resources, | |
150 | }; | |
151 | ||
152 | static struct platform_device apollon_lcd_device = { | |
153 | .name = "apollon_lcd", | |
154 | .id = -1, | |
155 | }; | |
156 | ||
f0248408 KP |
157 | static struct omap_led_config apollon_led_config[] = { |
158 | { | |
159 | .cdev = { | |
160 | .name = "apollon:led0", | |
161 | }, | |
162 | .gpio = LED0_GPIO13, | |
163 | }, | |
164 | { | |
165 | .cdev = { | |
166 | .name = "apollon:led1", | |
167 | }, | |
168 | .gpio = LED1_GPIO14, | |
169 | }, | |
170 | { | |
171 | .cdev = { | |
172 | .name = "apollon:led2", | |
173 | }, | |
174 | .gpio = LED2_GPIO15, | |
175 | }, | |
176 | }; | |
177 | ||
178 | static struct omap_led_platform_data apollon_led_data = { | |
179 | .nr_leds = ARRAY_SIZE(apollon_led_config), | |
180 | .leds = apollon_led_config, | |
181 | }; | |
182 | ||
183 | static struct platform_device apollon_led_device = { | |
184 | .name = "omap-led", | |
185 | .id = -1, | |
186 | .dev = { | |
187 | .platform_data = &apollon_led_data, | |
188 | }, | |
189 | }; | |
190 | ||
9b6553cd TL |
191 | static struct platform_device *apollon_devices[] __initdata = { |
192 | &apollon_onenand_device, | |
193 | &apollon_smc91x_device, | |
194 | &apollon_lcd_device, | |
f0248408 | 195 | &apollon_led_device, |
9b6553cd TL |
196 | }; |
197 | ||
198 | static inline void __init apollon_init_smc91x(void) | |
199 | { | |
f0248408 KP |
200 | unsigned long base; |
201 | ||
44595982 PW |
202 | unsigned int rate; |
203 | struct clk *gpmc_fck; | |
204 | int eth_cs; | |
bc593f5d | 205 | int err; |
44595982 PW |
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 | ||
bc593f5d IG |
249 | omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0); |
250 | err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq"); | |
251 | if (err) { | |
9b6553cd TL |
252 | printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", |
253 | APOLLON_ETHR_GPIO_IRQ); | |
f0248408 | 254 | gpmc_cs_free(APOLLON_ETH_CS); |
9b6553cd | 255 | } |
44595982 PW |
256 | out: |
257 | clk_disable(gpmc_fck); | |
258 | clk_put(gpmc_fck); | |
9b6553cd TL |
259 | } |
260 | ||
f0248408 KP |
261 | static struct omap_usb_config apollon_usb_config __initdata = { |
262 | .register_dev = 1, | |
263 | .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */ | |
264 | ||
265 | .pins[0] = 6, | |
266 | }; | |
267 | ||
9b6553cd TL |
268 | static struct omap_lcd_config apollon_lcd_config __initdata = { |
269 | .ctrl_name = "internal", | |
270 | }; | |
271 | ||
1a6b5923 | 272 | static struct omap_board_config_kernel apollon_config[] __initdata = { |
9b6553cd TL |
273 | { OMAP_TAG_LCD, &apollon_lcd_config }, |
274 | }; | |
275 | ||
bc593f5d IG |
276 | static struct gpio apollon_gpio_leds[] __initdata = { |
277 | { LED0_GPIO13, GPIOF_OUT_INIT_LOW, "LED0" }, /* LED0 - AA10 */ | |
278 | { LED1_GPIO14, GPIOF_OUT_INIT_LOW, "LED1" }, /* LED1 - AA6 */ | |
279 | { LED2_GPIO15, GPIOF_OUT_INIT_LOW, "LED2" }, /* LED2 - AA4 */ | |
280 | }; | |
281 | ||
9b6553cd TL |
282 | static void __init apollon_led_init(void) |
283 | { | |
f99bf16d | 284 | omap_mux_init_signal("vlynq_clk.gpio_13", 0); |
f99bf16d | 285 | omap_mux_init_signal("vlynq_rx1.gpio_14", 0); |
f99bf16d | 286 | omap_mux_init_signal("vlynq_rx0.gpio_15", 0); |
bc593f5d IG |
287 | |
288 | gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds)); | |
9b6553cd TL |
289 | } |
290 | ||
f0248408 KP |
291 | static void __init apollon_usb_init(void) |
292 | { | |
293 | /* USB device */ | |
294 | /* DEVICE_SUSPEND */ | |
f99bf16d | 295 | omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0); |
bc593f5d | 296 | gpio_request_one(12, GPIOF_OUT_INIT_LOW, "USB suspend"); |
b5e8905b | 297 | omap2_usbfs_init(&apollon_usb_config); |
f0248408 KP |
298 | } |
299 | ||
b52b14ef TL |
300 | #ifdef CONFIG_OMAP_MUX |
301 | static struct omap_board_mux board_mux[] __initdata = { | |
302 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
303 | }; | |
b52b14ef TL |
304 | #endif |
305 | ||
9b6553cd TL |
306 | static void __init omap_apollon_init(void) |
307 | { | |
44595982 PW |
308 | u32 v; |
309 | ||
b52b14ef | 310 | omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); |
e41cccfe TL |
311 | omap_board_config = apollon_config; |
312 | omap_board_config_size = ARRAY_SIZE(apollon_config); | |
b52b14ef | 313 | |
c2cdaffe | 314 | apollon_init_smc91x(); |
9b6553cd | 315 | apollon_led_init(); |
f0248408 KP |
316 | apollon_flash_init(); |
317 | apollon_usb_init(); | |
9b6553cd TL |
318 | |
319 | /* REVISIT: where's the correct place */ | |
f99bf16d | 320 | omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP); |
9b6553cd | 321 | |
18dbe6c5 TL |
322 | /* LCD PWR_EN */ |
323 | omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); | |
324 | ||
abc45e1d | 325 | /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */ |
44595982 PW |
326 | v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
327 | v |= (1 << 24); | |
328 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); | |
abc45e1d | 329 | |
9b6553cd TL |
330 | /* |
331 | * Make sure the serial ports are muxed on at this point. | |
332 | * You have to mux them off in device drivers later on | |
333 | * if not needed. | |
334 | */ | |
335 | platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices)); | |
9b6553cd | 336 | omap_serial_init(); |
a4ca9dbe | 337 | omap_sdrc_init(NULL, NULL); |
9b6553cd TL |
338 | } |
339 | ||
340 | static void __init omap_apollon_map_io(void) | |
341 | { | |
c8d2eb8e | 342 | omap2_set_globals_242x(); |
6fbd55d0 | 343 | omap242x_map_common_io(); |
9b6553cd TL |
344 | } |
345 | ||
346 | MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") | |
347 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ | |
9b6553cd | 348 | .boot_params = 0x80000100, |
71ee7dad | 349 | .reserve = omap_reserve, |
3dc3bad6 | 350 | .map_io = omap_apollon_map_io, |
8f5b5a41 | 351 | .init_early = omap2420_init_early, |
741e3a89 | 352 | .init_irq = omap2_init_irq, |
9b6553cd | 353 | .init_machine = omap_apollon_init, |
e74984e4 | 354 | .timer = &omap2_timer, |
9b6553cd | 355 | MACHINE_END |