blob: fbbd68d69cc8cc50d0f426bcc67db622f1bf5c16 [file] [log] [blame]
Tony Lindgren9b6553c2006-04-02 17:46:30 +01001/*
Uwe Zeisbergerf30c2262006-10-03 23:01:26 +02002 * linux/arch/arm/mach-omap2/board-apollon.c
Tony Lindgren9b6553c2006-04-02 17:46:30 +01003 *
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>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010025#include <linux/delay.h>
Kyungmin Parkf0248402006-12-06 17:13:53 -080026#include <linux/leds.h>
Paul Walmsley44595982008-03-18 10:04:51 +020027#include <linux/err.h>
28#include <linux/clk.h>
Ladislav Michl3bc48012009-12-11 16:16:33 -080029#include <linux/smc91x.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010030
Russell Kinga09e64f2008-08-05 16:14:15 +010031#include <mach/hardware.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010032#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/flash.h>
35
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/gpio.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070037#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>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010044
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
Kyungmin Parkf0248402006-12-06 17:13:53 -080053#define APOLLON_FLASH_CS 0
54#define APOLLON_ETH_CS 1
Tony Lindgren70554772009-03-23 18:07:35 -070055#define APOLLON_ETHR_GPIO_IRQ 74
Kyungmin Parkf0248402006-12-06 17:13:53 -080056
Tony Lindgren9b6553c2006-04-02 17:46:30 +010057static 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
Magnus Damm778dbcc2009-09-18 12:51:44 -070091static struct onenand_platform_data apollon_flash_data = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +010092 .parts = apollon_partitions,
93 .nr_parts = ARRAY_SIZE(apollon_partitions),
94};
95
Kyungmin Parkf0248402006-12-06 17:13:53 -080096static struct resource apollon_flash_resource[] = {
97 [0] = {
98 .flags = IORESOURCE_MEM,
99 },
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100100};
101
102static struct platform_device apollon_onenand_device = {
Magnus Damm778dbcc2009-09-18 12:51:44 -0700103 .name = "onenand-flash",
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100104 .id = -1,
105 .dev = {
106 .platform_data = &apollon_flash_data,
107 },
Kyungmin Parkf0248402006-12-06 17:13:53 -0800108 .num_resources = ARRAY_SIZE(apollon_flash_resource),
109 .resource = apollon_flash_resource,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100110};
111
Kyungmin Parkf0248402006-12-06 17:13:53 -0800112static 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
Ladislav Michl3bc48012009-12-11 16:16:33 -0800124static 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
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100130static struct resource apollon_smc91x_resources[] = {
131 [0] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100132 .flags = IORESOURCE_MEM,
133 },
134 [1] = {
135 .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
136 .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
Russell Kinge7b3dc72008-01-14 22:30:10 +0000137 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100138 },
139};
140
141static struct platform_device apollon_smc91x_device = {
142 .name = "smc91x",
143 .id = -1,
Ladislav Michl3bc48012009-12-11 16:16:33 -0800144 .dev = {
145 .platform_data = &appolon_smc91x_info,
146 },
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100147 .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
148 .resource = apollon_smc91x_resources,
149};
150
151static struct platform_device apollon_lcd_device = {
152 .name = "apollon_lcd",
153 .id = -1,
154};
155
Kyungmin Parkf0248402006-12-06 17:13:53 -0800156static 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
177static struct omap_led_platform_data apollon_led_data = {
178 .nr_leds = ARRAY_SIZE(apollon_led_config),
179 .leds = apollon_led_config,
180};
181
182static struct platform_device apollon_led_device = {
183 .name = "omap-led",
184 .id = -1,
185 .dev = {
186 .platform_data = &apollon_led_data,
187 },
188};
189
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100190static struct platform_device *apollon_devices[] __initdata = {
191 &apollon_onenand_device,
192 &apollon_smc91x_device,
193 &apollon_lcd_device,
Kyungmin Parkf0248402006-12-06 17:13:53 -0800194 &apollon_led_device,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100195};
196
197static inline void __init apollon_init_smc91x(void)
198{
Kyungmin Parkf0248402006-12-06 17:13:53 -0800199 unsigned long base;
200
Paul Walmsley44595982008-03-18 10:04:51 +0200201 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
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100216 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200217 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 }
Kyungmin Parkf0248402006-12-06 17:13:53 -0800238
239 if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
240 printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
Paul Walmsley44595982008-03-18 10:04:51 +0200241 goto out;
Kyungmin Parkf0248402006-12-06 17:13:53 -0800242 }
243 apollon_smc91x_resources[0].start = base + 0x300;
244 apollon_smc91x_resources[0].end = base + 0x30f;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100245 udelay(100);
246
247 omap_cfg_reg(W4__24XX_GPIO74);
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800248 if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100249 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
250 APOLLON_ETHR_GPIO_IRQ);
Kyungmin Parkf0248402006-12-06 17:13:53 -0800251 gpmc_cs_free(APOLLON_ETH_CS);
Paul Walmsley44595982008-03-18 10:04:51 +0200252 goto out;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100253 }
David Brownell40e39252008-12-10 17:35:26 -0800254 gpio_direction_input(APOLLON_ETHR_GPIO_IRQ);
Paul Walmsley44595982008-03-18 10:04:51 +0200255
256out:
257 clk_disable(gpmc_fck);
258 clk_put(gpmc_fck);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100259}
260
Kyungmin Parkf0248402006-12-06 17:13:53 -0800261static 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
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100268static struct omap_lcd_config apollon_lcd_config __initdata = {
269 .ctrl_name = "internal",
270};
271
272static struct omap_board_config_kernel apollon_config[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100273 { OMAP_TAG_LCD, &apollon_lcd_config },
274};
275
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300276static 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
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100286static void __init apollon_led_init(void)
287{
288 /* LED0 - AA10 */
289 omap_cfg_reg(AA10_242X_GPIO13);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200290 gpio_request(LED0_GPIO13, "LED0");
291 gpio_direction_output(LED0_GPIO13, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100292 /* LED1 - AA6 */
293 omap_cfg_reg(AA6_242X_GPIO14);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200294 gpio_request(LED1_GPIO14, "LED1");
295 gpio_direction_output(LED1_GPIO14, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100296 /* LED2 - AA4 */
297 omap_cfg_reg(AA4_242X_GPIO15);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200298 gpio_request(LED2_GPIO15, "LED2");
299 gpio_direction_output(LED2_GPIO15, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100300}
301
Kyungmin Parkf0248402006-12-06 17:13:53 -0800302static void __init apollon_usb_init(void)
303{
304 /* USB device */
305 /* DEVICE_SUSPEND */
306 omap_cfg_reg(P21_242X_GPIO12);
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800307 gpio_request(12, "USB suspend");
David Brownelle918edf2008-12-10 17:35:26 -0800308 gpio_direction_output(12, 0);
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700309 omap_usb_init(&apollon_usb_config);
Kyungmin Parkf0248402006-12-06 17:13:53 -0800310}
311
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100312static void __init omap_apollon_init(void)
313{
Paul Walmsley44595982008-03-18 10:04:51 +0200314 u32 v;
315
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100316 apollon_led_init();
Kyungmin Parkf0248402006-12-06 17:13:53 -0800317 apollon_flash_init();
318 apollon_usb_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100319
320 /* REVISIT: where's the correct place */
321 omap_cfg_reg(W19_24XX_SYS_NIRQ);
322
Kyungmin Parkabc45e12006-09-25 12:41:25 +0300323 /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
Paul Walmsley44595982008-03-18 10:04:51 +0200324 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
325 v |= (1 << 24);
326 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
Kyungmin Parkabc45e12006-09-25 12:41:25 +0300327
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100328 /*
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));
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100334 omap_serial_init();
335}
336
337static void __init omap_apollon_map_io(void)
338{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700339 omap2_set_globals_242x();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100340 omap2_map_common_io();
341}
342
343MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
344 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
345 .phys_io = 0x48000000,
Santosh Shilimkarb4224b22009-10-19 17:25:55 -0700346 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100347 .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,
352MACHINE_END