2 * linux/arch/arm/mach-omap2/board-apollon.c
4 * Copyright (C) 2005,2006 Samsung Electronics
5 * Author: Kyungmin Park <kyungmin.park@samsung.com>
7 * Modified from mach-omap2/board-h4.c
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.
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.
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>
25 #include <linux/irq.h>
26 #include <linux/interrupt.h>
27 #include <linux/delay.h>
28 #include <linux/leds.h>
29 #include <linux/irq.h>
30 #include <linux/err.h>
31 #include <linux/clk.h>
33 #include <asm/hardware.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/flash.h>
38 #include <asm/arch/gpio.h>
39 #include <asm/arch/led.h>
40 #include <asm/arch/mux.h>
41 #include <asm/arch/usb.h>
42 #include <asm/arch/board.h>
43 #include <asm/arch/common.h>
44 #include <asm/arch/gpmc.h>
45 #include "prcm-regs.h"
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
55 #define APOLLON_FLASH_CS 0
56 #define APOLLON_ETH_CS 1
58 static struct mtd_partition apollon_partitions[] = {
60 .name = "X-Loader + U-Boot",
63 .mask_flags = MTD_WRITEABLE,
67 .offset = MTDPART_OFS_APPEND,
72 .offset = MTDPART_OFS_APPEND,
77 .offset = MTDPART_OFS_APPEND,
81 .name = "filesystem00",
82 .offset = MTDPART_OFS_APPEND,
86 .name = "filesystem01",
87 .offset = MTDPART_OFS_APPEND,
88 .size = MTDPART_SIZ_FULL,
92 static struct flash_platform_data apollon_flash_data = {
93 .parts = apollon_partitions,
94 .nr_parts = ARRAY_SIZE(apollon_partitions),
97 static struct resource apollon_flash_resource[] = {
99 .flags = IORESOURCE_MEM,
103 static struct platform_device apollon_onenand_device = {
107 .platform_data = &apollon_flash_data,
109 .num_resources = ARRAY_SIZE(apollon_flash_resource),
110 .resource = apollon_flash_resource,
113 static void __init apollon_flash_init(void)
117 if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
118 printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
121 apollon_flash_resource[0].start = base;
122 apollon_flash_resource[0].end = base + SZ_128K - 1;
125 static struct resource apollon_smc91x_resources[] = {
127 .flags = IORESOURCE_MEM,
130 .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
131 .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
132 .flags = IORESOURCE_IRQ,
136 static struct platform_device apollon_smc91x_device = {
139 .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
140 .resource = apollon_smc91x_resources,
143 static struct platform_device apollon_lcd_device = {
144 .name = "apollon_lcd",
148 static struct omap_led_config apollon_led_config[] = {
151 .name = "apollon:led0",
157 .name = "apollon:led1",
163 .name = "apollon:led2",
169 static struct omap_led_platform_data apollon_led_data = {
170 .nr_leds = ARRAY_SIZE(apollon_led_config),
171 .leds = apollon_led_config,
174 static struct platform_device apollon_led_device = {
178 .platform_data = &apollon_led_data,
182 static struct platform_device *apollon_devices[] __initdata = {
183 &apollon_onenand_device,
184 &apollon_smc91x_device,
189 static inline void __init apollon_init_smc91x(void)
196 l3ck = clk_get(NULL, "core_l3_ck");
200 rate = clk_get_rate(l3ck);
202 eth_cs = APOLLON_ETH_CS;
204 /* Make sure CS1 timings are correct */
205 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
207 if (rate >= 160000000) {
208 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
209 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
210 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
211 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
212 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
213 } else if (rate >= 130000000) {
214 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
215 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
216 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
217 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
218 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
219 } else {/* rate = 100000000 */
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, 0x031A1F1F);
224 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
227 if (gpmc_cs_request(eth_cs, SZ_16M, &base) < 0) {
228 printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
231 apollon_smc91x_resources[0].start = base + 0x300;
232 apollon_smc91x_resources[0].end = base + 0x30f;
235 omap_cfg_reg(W4__24XX_GPIO74);
236 if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) {
237 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
238 APOLLON_ETHR_GPIO_IRQ);
239 gpmc_cs_free(eth_cs);
242 omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1);
245 static void __init omap_apollon_init_irq(void)
247 omap2_init_common_hw();
250 apollon_init_smc91x();
253 static struct omap_uart_config apollon_uart_config __initdata = {
254 .enabled_uarts = (1 << 0) | (0 << 1) | (0 << 2),
257 static struct omap_mmc_config apollon_mmc_config __initdata = {
263 /* Note: If you want to detect card feature, please assign 37 */
268 static struct omap_usb_config apollon_usb_config __initdata = {
270 .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
275 static struct omap_lcd_config apollon_lcd_config __initdata = {
276 .ctrl_name = "internal",
279 static struct omap_board_config_kernel apollon_config[] = {
280 { OMAP_TAG_UART, &apollon_uart_config },
281 { OMAP_TAG_MMC, &apollon_mmc_config },
282 { OMAP_TAG_USB, &apollon_usb_config },
283 { OMAP_TAG_LCD, &apollon_lcd_config },
286 static void __init apollon_led_init(void)
289 omap_cfg_reg(AA10_242X_GPIO13);
290 omap_request_gpio(LED0_GPIO13);
291 omap_set_gpio_direction(LED0_GPIO13, 0);
292 omap_set_gpio_dataout(LED0_GPIO13, 0);
294 omap_cfg_reg(AA6_242X_GPIO14);
295 omap_request_gpio(LED1_GPIO14);
296 omap_set_gpio_direction(LED1_GPIO14, 0);
297 omap_set_gpio_dataout(LED1_GPIO14, 0);
299 omap_cfg_reg(AA4_242X_GPIO15);
300 omap_request_gpio(LED2_GPIO15);
301 omap_set_gpio_direction(LED2_GPIO15, 0);
302 omap_set_gpio_dataout(LED2_GPIO15, 0);
305 static irqreturn_t apollon_sw_interrupt(int irq, void *ignored)
307 static unsigned int led0, led1, led2;
309 if (irq == OMAP_GPIO_IRQ(SW_ENTER_GPIO16))
310 omap_set_gpio_dataout(LED0_GPIO13, led0 ^= 1);
311 else if (irq == OMAP_GPIO_IRQ(SW_UP_GPIO17))
312 omap_set_gpio_dataout(LED1_GPIO14, led1 ^= 1);
313 else if (irq == OMAP_GPIO_IRQ(SW_DOWN_GPIO58))
314 omap_set_gpio_dataout(LED2_GPIO15, led2 ^= 1);
319 static void __init apollon_sw_init(void)
322 omap_cfg_reg(Y11_242X_GPIO16);
323 omap_request_gpio(SW_ENTER_GPIO16);
324 omap_set_gpio_direction(SW_ENTER_GPIO16, 1);
326 omap_cfg_reg(AA12_242X_GPIO17);
327 omap_request_gpio(SW_UP_GPIO17);
328 omap_set_gpio_direction(SW_UP_GPIO17, 1);
330 omap_cfg_reg(AA8_242X_GPIO58);
331 omap_request_gpio(SW_DOWN_GPIO58);
332 omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
334 set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQT_RISING);
335 if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt,
336 IRQF_SHARED, "enter sw",
337 &apollon_sw_interrupt))
339 set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQT_RISING);
340 if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt,
341 IRQF_SHARED, "up sw",
342 &apollon_sw_interrupt))
344 set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQT_RISING);
345 if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt,
346 IRQF_SHARED, "down sw",
347 &apollon_sw_interrupt))
351 static void __init apollon_usb_init(void)
355 omap_cfg_reg(P21_242X_GPIO12);
356 omap_request_gpio(12);
357 omap_set_gpio_direction(12, 0); /* OUT */
358 omap_set_gpio_dataout(12, 0);
361 static void __init omap_apollon_init(void)
365 apollon_flash_init();
368 /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
369 CONTROL_DEVCONF |= (1 << 24);
372 * Make sure the serial ports are muxed on at this point.
373 * You have to mux them off in device drivers later on
376 platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
377 omap_board_config = apollon_config;
378 omap_board_config_size = ARRAY_SIZE(apollon_config);
382 static void __init omap_apollon_map_io(void)
384 omap2_map_common_io();
387 MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
388 /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
389 .phys_io = 0x48000000,
390 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
391 .boot_params = 0x80000100,
392 .map_io = omap_apollon_map_io,
393 .init_irq = omap_apollon_init_irq,
394 .init_machine = omap_apollon_init,
395 .timer = &omap_timer,