]>
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> |
a8f7445c | 31 | #include <linux/platform_data/leds-omap.h> |
9b6553cd | 32 | |
9b6553cd TL |
33 | #include <asm/mach-types.h> |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/flash.h> | |
36 | ||
4e65331c | 37 | #include "common.h" |
3ef5d007 | 38 | #include "gpmc.h" |
9b6553cd | 39 | |
da91e89f TV |
40 | #include <video/omapdss.h> |
41 | #include <video/omap-panel-generic-dpi.h> | |
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] = { | |
e7b3dc7e | 136 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
9b6553cd TL |
137 | }, |
138 | }; | |
139 | ||
140 | static struct platform_device apollon_smc91x_device = { | |
141 | .name = "smc91x", | |
142 | .id = -1, | |
3bc48014 LM |
143 | .dev = { |
144 | .platform_data = &appolon_smc91x_info, | |
145 | }, | |
9b6553cd TL |
146 | .num_resources = ARRAY_SIZE(apollon_smc91x_resources), |
147 | .resource = apollon_smc91x_resources, | |
148 | }; | |
149 | ||
f0248408 KP |
150 | static struct omap_led_config apollon_led_config[] = { |
151 | { | |
152 | .cdev = { | |
153 | .name = "apollon:led0", | |
154 | }, | |
155 | .gpio = LED0_GPIO13, | |
156 | }, | |
157 | { | |
158 | .cdev = { | |
159 | .name = "apollon:led1", | |
160 | }, | |
161 | .gpio = LED1_GPIO14, | |
162 | }, | |
163 | { | |
164 | .cdev = { | |
165 | .name = "apollon:led2", | |
166 | }, | |
167 | .gpio = LED2_GPIO15, | |
168 | }, | |
169 | }; | |
170 | ||
171 | static struct omap_led_platform_data apollon_led_data = { | |
172 | .nr_leds = ARRAY_SIZE(apollon_led_config), | |
173 | .leds = apollon_led_config, | |
174 | }; | |
175 | ||
176 | static struct platform_device apollon_led_device = { | |
177 | .name = "omap-led", | |
178 | .id = -1, | |
179 | .dev = { | |
180 | .platform_data = &apollon_led_data, | |
181 | }, | |
182 | }; | |
183 | ||
9b6553cd TL |
184 | static struct platform_device *apollon_devices[] __initdata = { |
185 | &apollon_onenand_device, | |
186 | &apollon_smc91x_device, | |
f0248408 | 187 | &apollon_led_device, |
9b6553cd TL |
188 | }; |
189 | ||
190 | static inline void __init apollon_init_smc91x(void) | |
191 | { | |
f0248408 KP |
192 | unsigned long base; |
193 | ||
44595982 PW |
194 | unsigned int rate; |
195 | struct clk *gpmc_fck; | |
196 | int eth_cs; | |
bc593f5d | 197 | int err; |
44595982 PW |
198 | |
199 | gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ | |
200 | if (IS_ERR(gpmc_fck)) { | |
201 | WARN_ON(1); | |
202 | return; | |
203 | } | |
204 | ||
4d7cb45e | 205 | clk_prepare_enable(gpmc_fck); |
44595982 PW |
206 | rate = clk_get_rate(gpmc_fck); |
207 | ||
208 | eth_cs = APOLLON_ETH_CS; | |
209 | ||
9b6553cd | 210 | /* Make sure CS1 timings are correct */ |
44595982 PW |
211 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200); |
212 | ||
213 | if (rate >= 160000000) { | |
214 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01); | |
215 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803); | |
216 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a); | |
217 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
218 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
219 | } else if (rate >= 130000000) { | |
220 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00); | |
221 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802); | |
222 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09); | |
223 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F); | |
224 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4); | |
225 | } else {/* rate = 100000000 */ | |
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, 0x031A1F1F); | |
230 | gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2); | |
231 | } | |
f0248408 KP |
232 | |
233 | if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) { | |
234 | printk(KERN_ERR "Failed to request GPMC CS for smc91x\n"); | |
44595982 | 235 | goto out; |
f0248408 KP |
236 | } |
237 | apollon_smc91x_resources[0].start = base + 0x300; | |
238 | apollon_smc91x_resources[0].end = base + 0x30f; | |
9b6553cd TL |
239 | udelay(100); |
240 | ||
bc593f5d IG |
241 | omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0); |
242 | err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq"); | |
243 | if (err) { | |
9b6553cd TL |
244 | printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n", |
245 | APOLLON_ETHR_GPIO_IRQ); | |
f0248408 | 246 | gpmc_cs_free(APOLLON_ETH_CS); |
9b6553cd | 247 | } |
44595982 | 248 | out: |
4d7cb45e | 249 | clk_disable_unprepare(gpmc_fck); |
44595982 | 250 | clk_put(gpmc_fck); |
9b6553cd TL |
251 | } |
252 | ||
da91e89f TV |
253 | static struct panel_generic_dpi_data apollon_panel_data = { |
254 | .name = "apollon", | |
9b6553cd TL |
255 | }; |
256 | ||
da91e89f TV |
257 | static struct omap_dss_device apollon_lcd_device = { |
258 | .name = "lcd", | |
259 | .driver_name = "generic_dpi_panel", | |
260 | .type = OMAP_DISPLAY_TYPE_DPI, | |
261 | .phy.dpi.data_lines = 18, | |
262 | .data = &apollon_panel_data, | |
263 | }; | |
264 | ||
265 | static struct omap_dss_device *apollon_dss_devices[] = { | |
266 | &apollon_lcd_device, | |
9b6553cd TL |
267 | }; |
268 | ||
da91e89f TV |
269 | static struct omap_dss_board_info apollon_dss_data = { |
270 | .num_devices = ARRAY_SIZE(apollon_dss_devices), | |
271 | .devices = apollon_dss_devices, | |
272 | .default_device = &apollon_lcd_device, | |
9b6553cd TL |
273 | }; |
274 | ||
bc593f5d IG |
275 | static struct gpio apollon_gpio_leds[] __initdata = { |
276 | { LED0_GPIO13, GPIOF_OUT_INIT_LOW, "LED0" }, /* LED0 - AA10 */ | |
277 | { LED1_GPIO14, GPIOF_OUT_INIT_LOW, "LED1" }, /* LED1 - AA6 */ | |
278 | { LED2_GPIO15, GPIOF_OUT_INIT_LOW, "LED2" }, /* LED2 - AA4 */ | |
279 | }; | |
280 | ||
9b6553cd TL |
281 | static void __init apollon_led_init(void) |
282 | { | |
f99bf16d | 283 | omap_mux_init_signal("vlynq_clk.gpio_13", 0); |
f99bf16d | 284 | omap_mux_init_signal("vlynq_rx1.gpio_14", 0); |
f99bf16d | 285 | omap_mux_init_signal("vlynq_rx0.gpio_15", 0); |
bc593f5d IG |
286 | |
287 | gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds)); | |
9b6553cd TL |
288 | } |
289 | ||
b52b14ef TL |
290 | #ifdef CONFIG_OMAP_MUX |
291 | static struct omap_board_mux board_mux[] __initdata = { | |
292 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
293 | }; | |
b52b14ef TL |
294 | #endif |
295 | ||
9b6553cd TL |
296 | static void __init omap_apollon_init(void) |
297 | { | |
44595982 PW |
298 | u32 v; |
299 | ||
b52b14ef TL |
300 | omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC); |
301 | ||
c2cdaffe | 302 | apollon_init_smc91x(); |
9b6553cd | 303 | apollon_led_init(); |
f0248408 | 304 | apollon_flash_init(); |
9b6553cd TL |
305 | |
306 | /* REVISIT: where's the correct place */ | |
f99bf16d | 307 | omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP); |
9b6553cd | 308 | |
18dbe6c5 TL |
309 | /* LCD PWR_EN */ |
310 | omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP); | |
311 | ||
260db902 | 312 | /* Use Internal loop-back in MMC/SDIO Module Input Clock selection */ |
44595982 PW |
313 | v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0); |
314 | v |= (1 << 24); | |
315 | omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0); | |
abc45e1d | 316 | |
9b6553cd TL |
317 | /* |
318 | * Make sure the serial ports are muxed on at this point. | |
319 | * You have to mux them off in device drivers later on | |
320 | * if not needed. | |
321 | */ | |
46a0a540 TKD |
322 | apollon_smc91x_resources[1].start = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ); |
323 | apollon_smc91x_resources[1].end = gpio_to_irq(APOLLON_ETHR_GPIO_IRQ); | |
9b6553cd | 324 | platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices)); |
9b6553cd | 325 | omap_serial_init(); |
a4ca9dbe | 326 | omap_sdrc_init(NULL, NULL); |
da91e89f | 327 | omap_display_init(&apollon_dss_data); |
9b6553cd TL |
328 | } |
329 | ||
9b6553cd TL |
330 | MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon") |
331 | /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */ | |
5e52b435 | 332 | .atag_offset = 0x100, |
71ee7dad | 333 | .reserve = omap_reserve, |
e990a406 | 334 | .map_io = omap242x_map_io, |
8f5b5a41 | 335 | .init_early = omap2420_init_early, |
741e3a89 | 336 | .init_irq = omap2_init_irq, |
6b2f55d7 | 337 | .handle_irq = omap2_intc_handle_irq, |
9b6553cd | 338 | .init_machine = omap_apollon_init, |
bbd707ac | 339 | .init_late = omap2420_init_late, |
6bb27d73 | 340 | .init_time = omap2_sync32k_timer_init, |
187e3e06 | 341 | .restart = omap2xxx_restart, |
9b6553cd | 342 | MACHINE_END |