]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3evm.c
OMAP3 EVM: Add touchscreen support
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-omap3evm.c
1 /*
2  * linux/arch/arm/mach-omap2/board-omap3evm.c
3  *
4  * Copyright (C) 2008 Texas Instruments
5  *
6  * Modified from mach-omap2/board-3430sdp.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/ads7846.h>
24
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/board.h>
32 #include <asm/arch/hsmmc.h>
33 #include <asm/arch/usb-musb.h>
34 #include <asm/arch/usb-ehci.h>
35 #include <asm/arch/common.h>
36 #include <asm/arch/mcspi.h>
37
38 static struct omap_uart_config omap3_evm_uart_config __initdata = {
39         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
40 };
41
42 static int __init omap3_evm_i2c_init(void)
43 {
44         omap_register_i2c_bus(1, 2600, NULL, 0);
45         omap_register_i2c_bus(2, 400, NULL, 0);
46         omap_register_i2c_bus(3, 400, NULL, 0);
47         return 0;
48 }
49
50 static struct omap_mmc_config omap3_evm_mmc_config __initdata = {
51         .mmc [0] = {
52                 .enabled        = 1,
53                 .wire4          = 1,
54         },
55 };
56
57 static struct platform_device omap3_evm_lcd_device = {
58         .name           = "omap3evm_lcd",
59         .id             = -1,
60 };
61
62 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
63         .ctrl_name      = "internal",
64 };
65
66 static struct platform_device omap3_evm_twl4030rtc_device = {
67         .name           = "twl4030_rtc",
68         .id             = -1,
69 };
70
71 static void ads7846_dev_init(void)
72 {
73         if (omap_request_gpio(OMAP3_EVM_TS_GPIO) < 0)
74                 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
75
76         omap_set_gpio_direction(OMAP3_EVM_TS_GPIO, 1);
77
78         omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
79         omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
80 }
81
82 static int ads7846_get_pendown_state(void)
83 {
84         return !omap_get_gpio_datain(OMAP3_EVM_TS_GPIO);
85 }
86
87 struct ads7846_platform_data ads7846_config = {
88         .get_pendown_state      = ads7846_get_pendown_state,
89         .keep_vref_on           = 1,
90 };
91
92 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
93         .turbo_mode     = 0,
94         .single_channel = 1,  /* 0: slave, 1: master */
95 };
96
97 struct spi_board_info omap3evm_spi_board_info[] = {
98         [0] = {
99                 .modalias               = "ads7846",
100                 .bus_num                = 1,
101                 .chip_select            = 0,
102                 .max_speed_hz           = 1500000,
103                 .controller_data        = &ads7846_mcspi_config,
104                 .irq                    = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
105                 .platform_data          = &ads7846_config,
106         },
107 };
108
109 static void __init omap3_evm_init_irq(void)
110 {
111         omap2_init_common_hw();
112         omap_init_irq();
113         omap_gpio_init();
114 }
115
116 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
117         { OMAP_TAG_UART,        &omap3_evm_uart_config },
118         { OMAP_TAG_MMC,         &omap3_evm_mmc_config },
119         { OMAP_TAG_LCD,         &omap3_evm_lcd_config },
120 };
121
122 static struct platform_device *omap3_evm_devices[] __initdata = {
123         &omap3_evm_lcd_device,
124 #ifdef CONFIG_RTC_DRV_TWL4030
125         &omap3_evm_twl4030rtc_device,
126 #endif
127 };
128
129 static void __init omap3_evm_init(void)
130 {
131         platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
132         omap_board_config = omap3_evm_config;
133         omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
134
135         spi_register_board_info(omap3evm_spi_board_info,
136                                 ARRAY_SIZE(omap3evm_spi_board_info));
137
138         omap_serial_init();
139         hsmmc_init();
140         usb_musb_init();
141         usb_ehci_init();
142         omap3evm_flash_init();
143         ads7846_dev_init();
144 }
145
146 arch_initcall(omap3_evm_i2c_init);
147
148 static void __init omap3_evm_map_io(void)
149 {
150         omap2_set_globals_343x();
151         omap2_map_common_io();
152 }
153
154 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
155         /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
156         .phys_io        = 0x48000000,
157         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
158         .boot_params    = 0x80000100,
159         .map_io         = omap3_evm_map_io,
160         .init_irq       = omap3_evm_init_irq,
161         .init_machine   = omap3_evm_init,
162         .timer          = &omap_timer,
163 MACHINE_END