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