]>
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 TL |
44 | |
45 | /* LED & Switch macros */ | |
46 | #define LED0_GPIO13 13 | |
47 | #define LED1_GPIO14 14 | |
48 | #define LED2_GPIO15 15 | |
49 | #define SW_ENTER_GPIO16 16 | |
50 | #define SW_UP_GPIO17 17 | |
51 | #define SW_DOWN_GPIO58 58 | |
52 | ||
f0248408 KP |
53 | #define APOLLON_FLASH_CS 0 |
54 | #define APOLLON_ETH_CS 1 | |
70554775 | 55 | #define APOLLON_ETHR_GPIO_IRQ 74 |
f0248408 | 56 | |
9b6553cd TL |
57 | static struct mtd_partition apollon_partitions[] = { |
58 | { | |
59 | .name = "X-Loader + U-Boot", | |
60 | .offset = 0, | |
61 | .size = SZ_128K, | |
62 | .mask_flags = MTD_WRITEABLE, | |
63 | }, | |
64 | { | |
65 | .name = "params", | |
66 | .offset = MTDPART_OFS_APPEND, | |
67 | .size = SZ_128K, | |
68 | }, | |
69 | { | |
70 | .name = "kernel", | |
71 | .offset = MTDPART_OFS_APPEND, | |
72 | .size = SZ_2M, | |
73 | }, | |
74 | { | |
75 | .name = "rootfs", | |
76 | .offset = MTDPART_OFS_APPEND, | |
77 | .size = SZ_16M, | |
78 | }, | |
79 | { | |
80 | .name = "filesystem00", | |
81 | .offset = MTDPART_OFS_APPEND, | |
82 | .size = SZ_32M, | |
83 | }, | |
84 | { | |
85 | .name = "filesystem01", | |
86 | .offset = MTDPART_OFS_APPEND, | |
87 | .size = MTDPART_SIZ_FULL, | |
88 | }, | |
89 | }; | |
90 | ||
778dbcc1 | 91 | static struct onenand_platform_data apollon_flash_data = { |
9b6553cd TL |
92 | .parts = apollon_partitions, |
93 | .nr_parts = ARRAY_SIZE(apollon_partitions), | |
94 | }; | |
95 | ||
f0248408 KP |
96 | static struct resource apollon_flash_resource[] = { |
97 | [0] = { | |
98 | .flags = IORESOURCE_MEM, | |
99 | }, | |
9b6553cd TL |
100 | }; |
101 | ||
102 | static struct platform_device apollon_onenand_device = { | |
778dbcc1 | 103 | .name = "onenand-flash", |
9b6553cd TL |
104 | .id = -1, |
105 | .dev = { | |
106 | .platform_data = &apollon_flash_data, | |
107 | }, | |
f0248408 KP |
108 | .num_resources = ARRAY_SIZE(apollon_flash_resource), |
109 | .resource = apollon_flash_resource, | |
9b6553cd TL |
110 | }; |
111 | ||
f0248408 KP |
112 | static void __init apollon_flash_init(void) |
113 | { | |
114 | unsigned long base; | |
115 | ||
116 | if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) { | |
117 | printk(KERN_ERR "Cannot request OneNAND GPMC CS\n"); | |
118 | return; | |
119 | } | |
120 | apollon_flash_resource[0].start = base; | |
121 | apollon_flash_resource[0].end = base + SZ_128K - 1; | |
122 | } | |
123 | ||
3bc48014 LM |
124 | static struct smc91x_platdata appolon_smc91x_info = { |
125 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, | |
126 | .leda = RPC_LED_100_10, | |
127 | .ledb = RPC_LED_TX_RX, | |
128 | }; | |
129 | ||
9b6553cd TL |
130 | static struct resource apollon_smc91x_resources[] = { |
131 | [0] = { | |
9b6553cd TL |
132 | .flags = IORESOURCE_MEM, |
133 | }, | |
134 | [1] = { | |
135 | .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
136 | .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
e7b3dc7e | 137 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
9b6553cd TL |
138 | }, |
139 | }; | |
140 | ||
141 | static struct platform_device apollon_smc91x_device = { | |
142 | .name = "smc91x", | |
143 | .id = -1, | |
3bc48014 LM |
144 | .dev = { |
145 | .platform_data = &appolon_smc91x_info, | |
146 | }, | |
9b6553cd TL |
147 | .num_resources = ARRAY_SIZE(apollon_smc91x_resources), |
148 | .resource = apollon_smc91x_resources, | |
149 | }; | |
150 | ||
151 | static struct platform_device apollon_lcd_device = { | |
152 | .name = "apollon_lcd", | |
153 | .id = -1, | |
154 | }; | |
155 | ||
f0248408 KP |
156 | static struct omap_led_config apollon_led_config[] = { |
157 | { | |
158 | .cdev = { | |
159 | .name = "apollon:led0", | |
160 | }, | |
161 | .gpio = LED0_GPIO13, | |
162 | }, | |
163 | { | |
164 | .cdev = { | |
165 | .name = "apollon:led1", | |
166 | }, | |
167 | .gpio = LED1_GPIO14, | |
168 | }, | |
169 | { | |
170 | .cdev = { | |
171 | .name = "apollon:led2", | |
172 | }, | |
173 | .gpio = LED2_GPIO15, | |
174 | }, | |
175 | }; | |
176 | ||
177 | static struct omap_led_platform_data apollon_led_data = { | |
178 | .nr_leds = ARRAY_SIZE(apollon_led_config), | |
179 | .leds = apollon_led_config, | |
180 | }; | |
181 | ||
182 | static struct platform_device apollon_led_device = { | |
183 | .name = "omap-led", | |
184 | .id = -1, | |
185 | .dev = { | |
186 | .platform_data = &apollon_led_data, | |
187 | }, | |
188 | }; | |
189 | ||
9b6553cd TL |
190 | static struct platform_device *apollon_devices[] __initdata = { |
191 | &apollon_onenand_device, | |
192 | &apollon_smc91x_device, | |
193 | &apollon_lcd_device, | |
f0248408 | 194 | &apollon_led_device, |
9b6553cd TL |
195 | }; |
196 | ||
197 | static inline void __init apollon_init_smc91x(void) | |
198 | { | |
f0248408 KP |
199 | unsigned long base; |
200 | ||
44595982 PW |
201 | unsigned int rate; |
202 | struct clk *gpmc_fck; | |
203 | int eth_cs; | |
204 | ||
205 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
206 | if (IS_ERR(gpmc_fck)) { | |
207 | WARN_ON(1); | |
208 | return; | |
209 | } | |
210 | ||
211 | clk_enable(gpmc_fck); | |
212 | rate = clk_get_rate(gpmc_fck); | |
213 | ||
214 | eth_cs = APOLLON_ETH_CS; | |
215 | ||
9b6553cd | 216 | /* Make sure CS1 timings are correct */ |
44595982 PW |
217 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); |
218 | ||
219 | if (rate >= 160000000) { | |
220 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
221 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
222 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
223 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
224 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
225 | } else if (rate >= 130000000) { | |
226 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
227 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
228 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
229 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
230 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
231 | } else {/* rate = 100000000 */ | |
232 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
233 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
234 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
235 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | |
236 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
237 | } | |
f0248408 KP |
238 | |
239 | if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { | |
240 | printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); | |
44595982 | 241 | goto out; |
f0248408 KP |
242 | } |
243 | apollon_smc91x_resources[0].start = base + 0x300; | |
244 | apollon_smc91x_resources[0].end = base + 0x30f; | |
9b6553cd TL |
245 | udelay(100); |
246 | ||
247 | omap_cfg_reg(W4__24XX_GPIO74); | |
f2d18fea | 248 | if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) { |
9b6553cd TL |
249 | printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", |
250 | APOLLON_ETHR_GPIO_IRQ); | |
f0248408 | 251 | gpmc_cs_free(APOLLON_ETH_CS); |
44595982 | 252 | goto out; |
9b6553cd | 253 | } |
40e3925b | 254 | gpio_direction_input(APOLLON_ETHR_GPIO_IRQ); |
44595982 PW |
255 | |
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 | ||
272 | static struct omap_board_config_kernel apollon_config[] = { | |
9b6553cd TL |
273 | { OMAP_TAG_LCD, &apollon_lcd_config }, |
274 | }; | |
275 | ||
b3c6df3a PW |
276 | static void __init omap_apollon_init_irq(void) |
277 | { | |
278 | omap_board_config = apollon_config; | |
279 | omap_board_config_size = ARRAY_SIZE(apollon_config); | |
280 | omap2_init_common_hw(NULL, NULL); | |
281 | omap_init_irq(); | |
282 | omap_gpio_init(); | |
283 | apollon_init_smc91x(); | |
284 | } | |
285 | ||
9b6553cd TL |
286 | static void __init apollon_led_init(void) |
287 | { | |
288 | /* LED0 - AA10 */ | |
289 | omap_cfg_reg(AA10_242X_GPIO13); | |
73069e38 JN |
290 | gpio_request(LED0_GPIO13, "LED0"); |
291 | gpio_direction_output(LED0_GPIO13, 0); | |
9b6553cd TL |
292 | /* LED1 - AA6 */ |
293 | omap_cfg_reg(AA6_242X_GPIO14); | |
73069e38 JN |
294 | gpio_request(LED1_GPIO14, "LED1"); |
295 | gpio_direction_output(LED1_GPIO14, 0); | |
9b6553cd TL |
296 | /* LED2 - AA4 */ |
297 | omap_cfg_reg(AA4_242X_GPIO15); | |
73069e38 JN |
298 | gpio_request(LED2_GPIO15, "LED2"); |
299 | gpio_direction_output(LED2_GPIO15, 0); | |
9b6553cd TL |
300 | } |
301 | ||
f0248408 KP |
302 | static void __init apollon_usb_init(void) |
303 | { | |
304 | /* USB device */ | |
305 | /* DEVICE_SUSPEND */ | |
306 | omap_cfg_reg(P21_242X_GPIO12); | |
f2d18fea | 307 | gpio_request(12, "USB suspend"); |
e918edf7 | 308 | gpio_direction_output(12, 0); |
b5e8905b | 309 | omap2_usbfs_init(&apollon_usb_config); |
f0248408 KP |
310 | } |
311 | ||
9b6553cd TL |
312 | static void __init omap_apollon_init(void) |
313 | { | |
44595982 PW |
314 | u32 v; |
315 | ||
9b6553cd | 316 | apollon_led_init(); |
f0248408 KP |
317 | apollon_flash_init(); |
318 | apollon_usb_init(); | |
9b6553cd TL |
319 | |
320 | /* REVISIT: where's the correct place */ | |
321 | omap_cfg_reg(W19_24XX_SYS_NIRQ); | |
322 | ||
abc45e1d | 323 | /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */ |
44595982 PW |
324 | v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
325 | v |= (1 << 24); | |
326 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); | |
abc45e1d | 327 | |
9b6553cd TL |
328 | /* |
329 | * Make sure the serial ports are muxed on at this point. | |
330 | * You have to mux them off in device drivers later on | |
331 | * if not needed. | |
332 | */ | |
333 | platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices)); | |
9b6553cd TL |
334 | omap_serial_init(); |
335 | } | |
336 | ||
337 | static void __init omap_apollon_map_io(void) | |
338 | { | |
c8d2eb8e | 339 | omap2_set_globals_242x(); |
6fbd55d0 | 340 | omap242x_map_common_io(); |
9b6553cd TL |
341 | } |
342 | ||
343 | MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") | |
344 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ | |
345 | .phys_io = 0x48000000, | |
b4224b23 | 346 | .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, |
9b6553cd TL |
347 | .boot_params = 0x80000100, |
348 | .map_io = omap_apollon_map_io, | |
349 | .init_irq = omap_apollon_init_irq, | |
350 | .init_machine = omap_apollon_init, | |
351 | .timer = &omap_timer, | |
352 | MACHINE_END |