blob: b86a8790dd98979007865edb1a7541d73394fa6f [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
Tony Lindgrenb52b14e2010-07-05 16:31:37 +030045#include "mux.h"
46
Tony Lindgren9b6553c2006-04-02 17:46:30 +010047/* 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
Kyungmin Parkf0248402006-12-06 17:13:53 -080055#define APOLLON_FLASH_CS 0
56#define APOLLON_ETH_CS 1
Tony Lindgren70554772009-03-23 18:07:35 -070057#define APOLLON_ETHR_GPIO_IRQ 74
Kyungmin Parkf0248402006-12-06 17:13:53 -080058
Tony Lindgren9b6553c2006-04-02 17:46:30 +010059static 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
Magnus Damm778dbcc2009-09-18 12:51:44 -070093static struct onenand_platform_data apollon_flash_data = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +010094 .parts = apollon_partitions,
95 .nr_parts = ARRAY_SIZE(apollon_partitions),
96};
97
Kyungmin Parkf0248402006-12-06 17:13:53 -080098static struct resource apollon_flash_resource[] = {
99 [0] = {
100 .flags = IORESOURCE_MEM,
101 },
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100102};
103
104static struct platform_device apollon_onenand_device = {
Magnus Damm778dbcc2009-09-18 12:51:44 -0700105 .name = "onenand-flash",
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100106 .id = -1,
107 .dev = {
108 .platform_data = &apollon_flash_data,
109 },
Kyungmin Parkf0248402006-12-06 17:13:53 -0800110 .num_resources = ARRAY_SIZE(apollon_flash_resource),
111 .resource = apollon_flash_resource,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100112};
113
Kyungmin Parkf0248402006-12-06 17:13:53 -0800114static 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
Ladislav Michl3bc48012009-12-11 16:16:33 -0800126static 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
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100132static struct resource apollon_smc91x_resources[] = {
133 [0] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100134 .flags = IORESOURCE_MEM,
135 },
136 [1] = {
137 .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
138 .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
Russell Kinge7b3dc72008-01-14 22:30:10 +0000139 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100140 },
141};
142
143static struct platform_device apollon_smc91x_device = {
144 .name = "smc91x",
145 .id = -1,
Ladislav Michl3bc48012009-12-11 16:16:33 -0800146 .dev = {
147 .platform_data = &appolon_smc91x_info,
148 },
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100149 .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
150 .resource = apollon_smc91x_resources,
151};
152
153static struct platform_device apollon_lcd_device = {
154 .name = "apollon_lcd",
155 .id = -1,
156};
157
Kyungmin Parkf0248402006-12-06 17:13:53 -0800158static struct omap_led_config apollon_led_config[] = {
159 {
160 .cdev = {
161 .name = "apollon:led0",
162 },
163 .gpio = LED0_GPIO13,
164 },
165 {
166 .cdev = {
167 .name = "apollon:led1",
168 },
169 .gpio = LED1_GPIO14,
170 },
171 {
172 .cdev = {
173 .name = "apollon:led2",
174 },
175 .gpio = LED2_GPIO15,
176 },
177};
178
179static struct omap_led_platform_data apollon_led_data = {
180 .nr_leds = ARRAY_SIZE(apollon_led_config),
181 .leds = apollon_led_config,
182};
183
184static struct platform_device apollon_led_device = {
185 .name = "omap-led",
186 .id = -1,
187 .dev = {
188 .platform_data = &apollon_led_data,
189 },
190};
191
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100192static struct platform_device *apollon_devices[] __initdata = {
193 &apollon_onenand_device,
194 &apollon_smc91x_device,
195 &apollon_lcd_device,
Kyungmin Parkf0248402006-12-06 17:13:53 -0800196 &apollon_led_device,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100197};
198
199static inline void __init apollon_init_smc91x(void)
200{
Kyungmin Parkf0248402006-12-06 17:13:53 -0800201 unsigned long base;
202
Paul Walmsley44595982008-03-18 10:04:51 +0200203 unsigned int rate;
204 struct clk *gpmc_fck;
205 int eth_cs;
206
207 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
208 if (IS_ERR(gpmc_fck)) {
209 WARN_ON(1);
210 return;
211 }
212
213 clk_enable(gpmc_fck);
214 rate = clk_get_rate(gpmc_fck);
215
216 eth_cs = APOLLON_ETH_CS;
217
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100218 /* Make sure CS1 timings are correct */
Paul Walmsley44595982008-03-18 10:04:51 +0200219 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
220
221 if (rate >= 160000000) {
222 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
223 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
224 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
225 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
226 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
227 } else if (rate >= 130000000) {
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, 0x041f1F1F);
232 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
233 } else {/* rate = 100000000 */
234 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
235 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
236 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
237 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
238 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
239 }
Kyungmin Parkf0248402006-12-06 17:13:53 -0800240
241 if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
242 printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
Paul Walmsley44595982008-03-18 10:04:51 +0200243 goto out;
Kyungmin Parkf0248402006-12-06 17:13:53 -0800244 }
245 apollon_smc91x_resources[0].start = base + 0x300;
246 apollon_smc91x_resources[0].end = base + 0x30f;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100247 udelay(100);
248
249 omap_cfg_reg(W4__24XX_GPIO74);
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800250 if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100251 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
252 APOLLON_ETHR_GPIO_IRQ);
Kyungmin Parkf0248402006-12-06 17:13:53 -0800253 gpmc_cs_free(APOLLON_ETH_CS);
Paul Walmsley44595982008-03-18 10:04:51 +0200254 goto out;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100255 }
David Brownell40e39252008-12-10 17:35:26 -0800256 gpio_direction_input(APOLLON_ETHR_GPIO_IRQ);
Paul Walmsley44595982008-03-18 10:04:51 +0200257
258out:
259 clk_disable(gpmc_fck);
260 clk_put(gpmc_fck);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100261}
262
Kyungmin Parkf0248402006-12-06 17:13:53 -0800263static struct omap_usb_config apollon_usb_config __initdata = {
264 .register_dev = 1,
265 .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
266
267 .pins[0] = 6,
268};
269
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100270static struct omap_lcd_config apollon_lcd_config __initdata = {
271 .ctrl_name = "internal",
272};
273
274static struct omap_board_config_kernel apollon_config[] = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100275 { OMAP_TAG_LCD, &apollon_lcd_config },
276};
277
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300278static void __init omap_apollon_init_irq(void)
279{
280 omap_board_config = apollon_config;
281 omap_board_config_size = ARRAY_SIZE(apollon_config);
282 omap2_init_common_hw(NULL, NULL);
283 omap_init_irq();
284 omap_gpio_init();
285 apollon_init_smc91x();
286}
287
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100288static void __init apollon_led_init(void)
289{
290 /* LED0 - AA10 */
291 omap_cfg_reg(AA10_242X_GPIO13);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200292 gpio_request(LED0_GPIO13, "LED0");
293 gpio_direction_output(LED0_GPIO13, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100294 /* LED1 - AA6 */
295 omap_cfg_reg(AA6_242X_GPIO14);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200296 gpio_request(LED1_GPIO14, "LED1");
297 gpio_direction_output(LED1_GPIO14, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100298 /* LED2 - AA4 */
299 omap_cfg_reg(AA4_242X_GPIO15);
Jarkko Nikula73069e32009-01-15 13:09:52 +0200300 gpio_request(LED2_GPIO15, "LED2");
301 gpio_direction_output(LED2_GPIO15, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100302}
303
Kyungmin Parkf0248402006-12-06 17:13:53 -0800304static void __init apollon_usb_init(void)
305{
306 /* USB device */
307 /* DEVICE_SUSPEND */
308 omap_cfg_reg(P21_242X_GPIO12);
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800309 gpio_request(12, "USB suspend");
David Brownelle918edf2008-12-10 17:35:26 -0800310 gpio_direction_output(12, 0);
Tony Lindgrenb5e89052010-07-05 16:31:29 +0300311 omap2_usbfs_init(&apollon_usb_config);
Kyungmin Parkf0248402006-12-06 17:13:53 -0800312}
313
Tony Lindgrenb52b14e2010-07-05 16:31:37 +0300314#ifdef CONFIG_OMAP_MUX
315static struct omap_board_mux board_mux[] __initdata = {
316 { .reg_offset = OMAP_MUX_TERMINATOR },
317};
318#else
319#define board_mux NULL
320#endif
321
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100322static void __init omap_apollon_init(void)
323{
Paul Walmsley44595982008-03-18 10:04:51 +0200324 u32 v;
325
Tony Lindgrenb52b14e2010-07-05 16:31:37 +0300326 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
327
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100328 apollon_led_init();
Kyungmin Parkf0248402006-12-06 17:13:53 -0800329 apollon_flash_init();
330 apollon_usb_init();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100331
332 /* REVISIT: where's the correct place */
333 omap_cfg_reg(W19_24XX_SYS_NIRQ);
334
Kyungmin Parkabc45e12006-09-25 12:41:25 +0300335 /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
Paul Walmsley44595982008-03-18 10:04:51 +0200336 v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
337 v |= (1 << 24);
338 omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
Kyungmin Parkabc45e12006-09-25 12:41:25 +0300339
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100340 /*
341 * Make sure the serial ports are muxed on at this point.
342 * You have to mux them off in device drivers later on
343 * if not needed.
344 */
345 platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100346 omap_serial_init();
347}
348
349static void __init omap_apollon_map_io(void)
350{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700351 omap2_set_globals_242x();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800352 omap242x_map_common_io();
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100353}
354
355MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
356 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
357 .phys_io = 0x48000000,
Santosh Shilimkarb4224b22009-10-19 17:25:55 -0700358 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100359 .boot_params = 0x80000100,
360 .map_io = omap_apollon_map_io,
361 .init_irq = omap_apollon_init_irq,
362 .init_machine = omap_apollon_init,
363 .timer = &omap_timer,
364MACHINE_END