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