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> | |
4e65331c | 40 | #include "common.h" |
ce491cf8 | 41 | #include <plat/gpmc.h> |
9b6553cd | 42 | |
da91e89f TV |
43 | #include <video/omapdss.h> |
44 | #include <video/omap-panel-generic-dpi.h> | |
45 | ||
b52b14ef | 46 | #include "mux.h" |
4814ced5 | 47 | #include "control.h" |
b52b14ef | 48 | |
9b6553cd TL |
49 | /* LED & Switch macros */ |
50 | #define LED0_GPIO13 13 | |
51 | #define LED1_GPIO14 14 | |
52 | #define LED2_GPIO15 15 | |
53 | #define SW_ENTER_GPIO16 16 | |
54 | #define SW_UP_GPIO17 17 | |
55 | #define SW_DOWN_GPIO58 58 | |
56 | ||
f0248408 KP |
57 | #define APOLLON_FLASH_CS 0 |
58 | #define APOLLON_ETH_CS 1 | |
70554775 | 59 | #define APOLLON_ETHR_GPIO_IRQ 74 |
f0248408 | 60 | |
9b6553cd TL |
61 | static struct mtd_partition apollon_partitions[] = { |
62 | { | |
63 | .name = "X-Loader + U-Boot", | |
64 | .offset = 0, | |
65 | .size = SZ_128K, | |
66 | .mask_flags = MTD_WRITEABLE, | |
67 | }, | |
68 | { | |
69 | .name = "params", | |
70 | .offset = MTDPART_OFS_APPEND, | |
71 | .size = SZ_128K, | |
72 | }, | |
73 | { | |
74 | .name = "kernel", | |
75 | .offset = MTDPART_OFS_APPEND, | |
76 | .size = SZ_2M, | |
77 | }, | |
78 | { | |
79 | .name = "rootfs", | |
80 | .offset = MTDPART_OFS_APPEND, | |
81 | .size = SZ_16M, | |
82 | }, | |
83 | { | |
84 | .name = "filesystem00", | |
85 | .offset = MTDPART_OFS_APPEND, | |
86 | .size = SZ_32M, | |
87 | }, | |
88 | { | |
89 | .name = "filesystem01", | |
90 | .offset = MTDPART_OFS_APPEND, | |
91 | .size = MTDPART_SIZ_FULL, | |
92 | }, | |
93 | }; | |
94 | ||
778dbcc1 | 95 | static struct onenand_platform_data apollon_flash_data = { |
9b6553cd TL |
96 | .parts = apollon_partitions, |
97 | .nr_parts = ARRAY_SIZE(apollon_partitions), | |
98 | }; | |
99 | ||
f0248408 KP |
100 | static struct resource apollon_flash_resource[] = { |
101 | [0] = { | |
102 | .flags = IORESOURCE_MEM, | |
103 | }, | |
9b6553cd TL |
104 | }; |
105 | ||
106 | static struct platform_device apollon_onenand_device = { | |
778dbcc1 | 107 | .name = "onenand-flash", |
9b6553cd TL |
108 | .id = -1, |
109 | .dev = { | |
110 | .platform_data = &apollon_flash_data, | |
111 | }, | |
f0248408 KP |
112 | .num_resources = ARRAY_SIZE(apollon_flash_resource), |
113 | .resource = apollon_flash_resource, | |
9b6553cd TL |
114 | }; |
115 | ||
f0248408 KP |
116 | static void __init apollon_flash_init(void) |
117 | { | |
118 | unsigned long base; | |
119 | ||
120 | if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) { | |
121 | printk(KERN_ERR "Cannot request OneNAND GPMC CS\n"); | |
122 | return; | |
123 | } | |
124 | apollon_flash_resource[0].start = base; | |
125 | apollon_flash_resource[0].end = base + SZ_128K - 1; | |
126 | } | |
127 | ||
3bc48014 LM |
128 | static struct smc91x_platdata appolon_smc91x_info = { |
129 | .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, | |
130 | .leda = RPC_LED_100_10, | |
131 | .ledb = RPC_LED_TX_RX, | |
132 | }; | |
133 | ||
9b6553cd TL |
134 | static struct resource apollon_smc91x_resources[] = { |
135 | [0] = { | |
9b6553cd TL |
136 | .flags = IORESOURCE_MEM, |
137 | }, | |
138 | [1] = { | |
139 | .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
140 | .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ), | |
e7b3dc7e | 141 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
9b6553cd TL |
142 | }, |
143 | }; | |
144 | ||
145 | static struct platform_device apollon_smc91x_device = { | |
146 | .name = "smc91x", | |
147 | .id = -1, | |
3bc48014 LM |
148 | .dev = { |
149 | .platform_data = &appolon_smc91x_info, | |
150 | }, | |
9b6553cd TL |
151 | .num_resources = ARRAY_SIZE(apollon_smc91x_resources), |
152 | .resource = apollon_smc91x_resources, | |
153 | }; | |
154 | ||
f0248408 KP |
155 | static struct omap_led_config apollon_led_config[] = { |
156 | { | |
157 | .cdev = { | |
158 | .name = "apollon:led0", | |
159 | }, | |
160 | .gpio = LED0_GPIO13, | |
161 | }, | |
162 | { | |
163 | .cdev = { | |
164 | .name = "apollon:led1", | |
165 | }, | |
166 | .gpio = LED1_GPIO14, | |
167 | }, | |
168 | { | |
169 | .cdev = { | |
170 | .name = "apollon:led2", | |
171 | }, | |
172 | .gpio = LED2_GPIO15, | |
173 | }, | |
174 | }; | |
175 | ||
176 | static struct omap_led_platform_data apollon_led_data = { | |
177 | .nr_leds = ARRAY_SIZE(apollon_led_config), | |
178 | .leds = apollon_led_config, | |
179 | }; | |
180 | ||
181 | static struct platform_device apollon_led_device = { | |
182 | .name = "omap-led", | |
183 | .id = -1, | |
184 | .dev = { | |
185 | .platform_data = &apollon_led_data, | |
186 | }, | |
187 | }; | |
188 | ||
9b6553cd TL |
189 | static struct platform_device *apollon_devices[] __initdata = { |
190 | &apollon_onenand_device, | |
191 | &apollon_smc91x_device, | |
f0248408 | 192 | &apollon_led_device, |
9b6553cd TL |
193 | }; |
194 | ||
195 | static inline void __init apollon_init_smc91x(void) | |
196 | { | |
f0248408 KP |
197 | unsigned long base; |
198 | ||
44595982 PW |
199 | unsigned int rate; |
200 | struct clk *gpmc_fck; | |
201 | int eth_cs; | |
bc593f5d | 202 | int err; |
44595982 PW |
203 | |
204 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
205 | if (IS_ERR(gpmc_fck)) { | |
206 | WARN_ON(1); | |
207 | return; | |
208 | } | |
209 | ||
210 | clk_enable(gpmc_fck); | |
211 | rate = clk_get_rate(gpmc_fck); | |
212 | ||
213 | eth_cs = APOLLON_ETH_CS; | |
214 | ||
9b6553cd | 215 | /* Make sure CS1 timings are correct */ |
44595982 PW |
216 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); |
217 | ||
218 | if (rate >= 160000000) { | |
219 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
220 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
221 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
222 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
223 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
224 | } else if (rate >= 130000000) { | |
225 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
226 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
227 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
228 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
229 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
230 | } else {/* rate = 100000000 */ | |
231 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
232 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
233 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
234 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F); | |
235 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
236 | } | |
f0248408 KP |
237 | |
238 | if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { | |
239 | printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); | |
44595982 | 240 | goto out; |
f0248408 KP |
241 | } |
242 | apollon_smc91x_resources[0].start = base + 0x300; | |
243 | apollon_smc91x_resources[0].end = base + 0x30f; | |
9b6553cd TL |
244 | udelay(100); |
245 | ||
bc593f5d IG |
246 | omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0); |
247 | err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq"); | |
248 | if (err) { | |
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); |
9b6553cd | 252 | } |
44595982 PW |
253 | out: |
254 | clk_disable(gpmc_fck); | |
255 | clk_put(gpmc_fck); | |
9b6553cd TL |
256 | } |
257 | ||
f0248408 KP |
258 | static struct omap_usb_config apollon_usb_config __initdata = { |
259 | .register_dev = 1, | |
260 | .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */ | |
261 | ||
262 | .pins[0] = 6, | |
263 | }; | |
264 | ||
da91e89f TV |
265 | static struct panel_generic_dpi_data apollon_panel_data = { |
266 | .name = "apollon", | |
9b6553cd TL |
267 | }; |
268 | ||
da91e89f TV |
269 | static struct omap_dss_device apollon_lcd_device = { |
270 | .name = "lcd", | |
271 | .driver_name = "generic_dpi_panel", | |
272 | .type = OMAP_DISPLAY_TYPE_DPI, | |
273 | .phy.dpi.data_lines = 18, | |
274 | .data = &apollon_panel_data, | |
275 | }; | |
276 | ||
277 | static struct omap_dss_device *apollon_dss_devices[] = { | |
278 | &apollon_lcd_device, | |
9b6553cd TL |
279 | }; |
280 | ||
da91e89f TV |
281 | static struct omap_dss_board_info apollon_dss_data = { |
282 | .num_devices = ARRAY_SIZE(apollon_dss_devices), | |
283 | .devices = apollon_dss_devices, | |
284 | .default_device = &apollon_lcd_device, | |
9b6553cd TL |
285 | }; |
286 | ||
bc593f5d IG |
287 | static struct gpio apollon_gpio_leds[] __initdata = { |
288 | { LED0_GPIO13, GPIOF_OUT_INIT_LOW, "LED0" }, /* LED0 - AA10 */ | |
289 | { LED1_GPIO14, GPIOF_OUT_INIT_LOW, "LED1" }, /* LED1 - AA6 */ | |
290 | { LED2_GPIO15, GPIOF_OUT_INIT_LOW, "LED2" }, /* LED2 - AA4 */ | |
291 | }; | |
292 | ||
9b6553cd TL |
293 | static void __init apollon_led_init(void) |
294 | { | |
f99bf16d | 295 | omap_mux_init_signal("vlynq_clk.gpio_13", 0); |
f99bf16d | 296 | omap_mux_init_signal("vlynq_rx1.gpio_14", 0); |
f99bf16d | 297 | omap_mux_init_signal("vlynq_rx0.gpio_15", 0); |
bc593f5d IG |
298 | |
299 | gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds)); | |
9b6553cd TL |
300 | } |
301 | ||
f0248408 KP |
302 | static void __init apollon_usb_init(void) |
303 | { | |
304 | /* USB device */ | |
305 | /* DEVICE_SUSPEND */ | |
f99bf16d | 306 | omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0); |
bc593f5d | 307 | gpio_request_one(12, GPIOF_OUT_INIT_LOW, "USB suspend"); |
b5e8905b | 308 | omap2_usbfs_init(&apollon_usb_config); |
f0248408 KP |
309 | } |
310 | ||
b52b14ef TL |
311 | #ifdef CONFIG_OMAP_MUX |
312 | static struct omap_board_mux board_mux[] __initdata = { | |
313 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
314 | }; | |
b52b14ef TL |
315 | #endif |
316 | ||
9b6553cd TL |
317 | static void __init omap_apollon_init(void) |
318 | { | |
44595982 PW |
319 | u32 v; |
320 | ||
b52b14ef TL |
321 | omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); |
322 | ||
c2cdaffe | 323 | apollon_init_smc91x(); |
9b6553cd | 324 | apollon_led_init(); |
f0248408 KP |
325 | apollon_flash_init(); |
326 | apollon_usb_init(); | |
9b6553cd TL |
327 | |
328 | /* REVISIT: where's the correct place */ | |
f99bf16d | 329 | omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP); |
9b6553cd | 330 | |
18dbe6c5 TL |
331 | /* LCD PWR_EN */ |
332 | omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); | |
333 | ||
abc45e1d | 334 | /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */ |
44595982 PW |
335 | v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
336 | v |= (1 << 24); | |
337 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); | |
abc45e1d | 338 | |
9b6553cd TL |
339 | /* |
340 | * Make sure the serial ports are muxed on at this point. | |
341 | * You have to mux them off in device drivers later on | |
342 | * if not needed. | |
343 | */ | |
344 | platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices)); | |
9b6553cd | 345 | omap_serial_init(); |
a4ca9dbe | 346 | omap_sdrc_init(NULL, NULL); |
da91e89f | 347 | omap_display_init(&apollon_dss_data); |
9b6553cd TL |
348 | } |
349 | ||
9b6553cd TL |
350 | MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") |
351 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ | |
5e52b435 | 352 | .atag_offset = 0x100, |
71ee7dad | 353 | .reserve = omap_reserve, |
e990a406 | 354 | .map_io = omap242x_map_io, |
8f5b5a41 | 355 | .init_early = omap2420_init_early, |
741e3a89 | 356 | .init_irq = omap2_init_irq, |
6b2f55d7 | 357 | .handle_irq = omap2_intc_handle_irq, |
9b6553cd | 358 | .init_machine = omap_apollon_init, |
e74984e4 | 359 | .timer = &omap2_timer, |
baa95883 | 360 | .restart = omap_prcm_restart, |
9b6553cd | 361 | MACHINE_END |