2 * linux/arch/arm/mach-omap2/board-2430sdp.c
4 * Copyright (C) 2006 Texas Instruments
6 * Modified from mach-omap2/board-generic.c
8 * Initial Code : Based on a patch from Komal Shah and Richard Woodruff
9 * Updated the Code for 2430 SDP : Syed Mohammed Khasim
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/delay.h>
22 #include <linux/input.h>
23 #include <linux/err.h>
24 #include <linux/clk.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/ads7846.h>
27 #include <linux/i2c/twl4030-rtc.h>
29 #include <asm/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/flash.h>
35 #include <asm/arch/gpio.h>
36 #include <asm/arch/mux.h>
37 #include <asm/arch/board.h>
38 #include <asm/arch/usb-musb.h>
39 #include <asm/arch/usb-ehci.h>
40 #include <asm/arch/hsmmc.h>
41 #include <asm/arch/common.h>
42 #include <asm/arch/keypad.h>
43 #include <asm/arch/gpmc.h>
44 #include <asm/arch/mcspi.h>
48 #define SDP2430_FLASH_CS 0
49 #define SDP2430_SMC91X_CS 5
51 /* GPIO used for TSC2046 (touchscreen)
53 * Also note that the tsc2046 is the same silicon as the ads7846, so
54 * that driver is used for the touchscreen. */
57 #define TWL4030_MSECURE_GPIO 118
58 #define SECONDARY_LCD_GPIO 147
60 static struct mtd_partition sdp2430_partitions[] = {
61 /* bootloader (U-Boot, etc) in first sector */
66 .mask_flags = MTD_WRITEABLE, /* force read-only */
68 /* bootloader params in the next sector */
71 .offset = MTDPART_OFS_APPEND,
78 .offset = MTDPART_OFS_APPEND,
85 .offset = MTDPART_OFS_APPEND,
86 .size = MTDPART_SIZ_FULL,
91 static struct flash_platform_data sdp2430_flash_data = {
92 .map_name = "cfi_probe",
94 .parts = sdp2430_partitions,
95 .nr_parts = ARRAY_SIZE(sdp2430_partitions),
98 static struct resource sdp2430_flash_resource = {
99 .start = SDP2430_CS0_BASE,
100 .end = SDP2430_CS0_BASE + SZ_64M - 1,
101 .flags = IORESOURCE_MEM,
104 static struct platform_device sdp2430_flash_device = {
108 .platform_data = &sdp2430_flash_data,
111 .resource = &sdp2430_flash_resource,
114 static struct resource sdp2430_smc91x_resources[] = {
116 .start = SDP2430_CS0_BASE,
117 .end = SDP2430_CS0_BASE + SZ_64M - 1,
118 .flags = IORESOURCE_MEM,
121 .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
122 .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
123 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
127 static struct platform_device sdp2430_lcd_device = {
128 .name = "sdp2430_lcd",
132 static struct platform_device sdp2430_smc91x_device = {
135 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
136 .resource = sdp2430_smc91x_resources,
140 * Key mapping for 2430 SDP board
143 static int sdp2430_keymap[] = {
145 KEY(0, 1, KEY_RIGHT),
154 KEY(2, 0, KEY_ENTER),
177 static struct omap_kp_platform_data sdp2430_kp_data = {
180 .keymap = sdp2430_keymap,
181 .keymapsize = ARRAY_SIZE(sdp2430_keymap),
185 static struct platform_device sdp2430_kp_device = {
186 .name = "omap_twl4030keypad",
189 .platform_data = &sdp2430_kp_data,
193 static int twl4030_rtc_init(void)
197 ret = omap_request_gpio(TWL4030_MSECURE_GPIO);
199 printk(KERN_ERR "twl4030_rtc_init: can't reserve GPIO:%d !\n",
200 TWL4030_MSECURE_GPIO);
204 * TWL4030 will be in secure mode if msecure line from OMAP is low.
205 * Make msecure line high in order to change the TWL4030 RTC time
206 * and calender registers.
208 omap_set_gpio_direction(TWL4030_MSECURE_GPIO, 0); /*dir out */
209 omap_set_gpio_dataout(TWL4030_MSECURE_GPIO, 1);
214 static void twl4030_rtc_exit(void)
216 omap_free_gpio(TWL4030_MSECURE_GPIO);
219 static struct twl4030rtc_platform_data sdp2430_twl4030rtc_data = {
220 .init = &twl4030_rtc_init,
221 .exit = &twl4030_rtc_exit,
224 static struct platform_device sdp2430_twl4030rtc_device = {
225 .name = "twl4030_rtc",
228 .platform_data = &sdp2430_twl4030rtc_data,
232 static struct platform_device *sdp2430_devices[] __initdata = {
233 &sdp2430_smc91x_device,
234 &sdp2430_flash_device,
237 &sdp2430_twl4030rtc_device,
240 static void ads7846_dev_init(void)
242 if (omap_request_gpio(TS_GPIO) < 0)
243 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
245 omap_set_gpio_direction(TS_GPIO, 1);
247 omap_set_gpio_debounce(TS_GPIO, 1);
248 omap_set_gpio_debounce_time(TS_GPIO, 0xa);
251 static int ads7846_get_pendown_state(void)
253 return !omap_get_gpio_datain(TS_GPIO);
256 static struct ads7846_platform_data tsc2046_config __initdata = {
257 .get_pendown_state = ads7846_get_pendown_state,
261 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
263 .single_channel = 0, /* 0: slave, 1: master */
266 static struct omap_lcd_config sdp2430_lcd_config __initdata = {
267 .ctrl_name = "internal",
270 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
273 * TSC2046 operates at a max freqency of 2MHz, so
274 * operate slightly below at 1.5MHz
276 .modalias = "ads7846",
279 .max_speed_hz = 1500000,
280 .controller_data = &tsc2046_mcspi_config,
281 .irq = OMAP_GPIO_IRQ(TS_GPIO),
282 .platform_data = &tsc2046_config,
286 static inline void __init sdp2430_init_smc91x(void)
289 unsigned long cs_mem_base;
291 struct clk *gpmc_fck;
293 eth_cs = SDP2430_SMC91X_CS;
295 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
296 if (IS_ERR(gpmc_fck)) {
301 clk_enable(gpmc_fck);
302 rate = clk_get_rate(gpmc_fck);
304 /* Make sure CS1 timings are correct, for 2430 always muxed */
305 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
307 if (rate >= 160000000) {
308 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
309 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
310 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
311 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
312 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
313 } else if (rate >= 130000000) {
314 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
315 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
316 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
317 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
318 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
319 } else { /* rate = 100000000 */
320 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
321 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
322 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
323 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
324 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
327 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
328 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
332 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
333 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
336 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
337 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
338 OMAP24XX_ETHR_GPIO_IRQ);
339 gpmc_cs_free(eth_cs);
342 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
345 clk_disable(gpmc_fck);
349 static void __init omap_2430sdp_init_irq(void)
351 omap2_init_common_hw();
354 sdp2430_init_smc91x();
357 static struct omap_uart_config sdp2430_uart_config __initdata = {
358 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
362 struct omap_serial_console_config sdp2430_serial_console_config __initdata = {
364 .console_speed = 115200,
367 static struct omap_mmc_config sdp2430_mmc_config __initdata = {
374 static struct omap_board_config_kernel sdp2430_config[] __initdata = {
375 {OMAP_TAG_UART, &sdp2430_uart_config},
376 {OMAP_TAG_LCD, &sdp2430_lcd_config},
377 {OMAP_TAG_SERIAL_CONSOLE, &sdp2430_serial_console_config},
378 {OMAP_TAG_MMC, &sdp2430_mmc_config},
381 static int __init omap2430_i2c_init(void)
383 omap_register_i2c_bus(1, 400, NULL, 0);
384 omap_register_i2c_bus(2, 2600, NULL, 0);
388 static void __init omap_2430sdp_init(void)
390 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
391 omap_board_config = sdp2430_config;
392 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
395 sdp2430_flash_init();
399 spi_register_board_info(sdp2430_spi_board_info,
400 ARRAY_SIZE(sdp2430_spi_board_info));
404 /* turn off secondary LCD backlight */
405 omap_set_gpio_direction(SECONDARY_LCD_GPIO, 0);
406 omap_set_gpio_dataout(SECONDARY_LCD_GPIO, 0);
409 static void __init omap_2430sdp_map_io(void)
411 omap2_set_globals_243x();
412 omap2_map_common_io();
415 arch_initcall(omap2430_i2c_init);
417 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
418 /* Maintainer: Syed Khasim - Texas Instruments Inc */
419 .phys_io = 0x48000000,
420 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
421 .boot_params = 0x80000100,
422 .map_io = omap_2430sdp_map_io,
423 .init_irq = omap_2430sdp_init_irq,
424 .init_machine = omap_2430sdp_init,
425 .timer = &omap_timer,