]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-ldp.c
OMAP2 SDRC: add SDRAM timing parameter infrastructure
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-ldp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-ldp.c
3  *
4  * Copyright (C) 2008 Texas Instruments Inc.
5  * Nishant Kamat <nskamat@ti.com>
6  *
7  * Modified from mach-omap2/board-3430sdp.c
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/delay.h>
18 #include <linux/input.h>
19 #include <linux/workqueue.h>
20 #include <linux/err.h>
21 #include <linux/clk.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/ads7846.h>
24 #include <linux/i2c/twl4030.h>
25 #include <linux/i2c/twl4030-rtc.h>
26
27 #include <asm/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
32 #include <asm/arch/mcspi.h>
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/board.h>
35 #include <asm/arch/common.h>
36 #include <asm/arch/gpmc.h>
37 #include <asm/arch/hsmmc.h>
38 #include <asm/arch/usb-musb.h>
39
40 #include <asm/io.h>
41 #include <asm/delay.h>
42 #include <asm/arch/control.h>
43
44 #define ENABLE_VAUX1_DEDICATED  0x03
45 #define ENABLE_VAUX1_DEV_GRP    0x20
46
47 #define TWL4030_MSECURE_GPIO    22
48
49 static int ts_gpio;
50
51 #ifdef CONFIG_RTC_DRV_TWL4030
52 static int twl4030_rtc_init(void)
53 {
54         int ret = 0;
55
56         /* 3430ES2.0 doesn't have msecure/gpio-22 line connected to T2 */
57         if (is_device_type_gp() && is_sil_rev_less_than(OMAP3430_REV_ES2_0)) {
58                 u32 msecure_pad_config_reg = omap_ctrl_base_get() + 0xA3C;
59                 int mux_mask = 0x04;
60                 u16 tmp;
61
62                 ret = omap_request_gpio(TWL4030_MSECURE_GPIO);
63                 if (ret < 0) {
64                         printk(KERN_ERR "twl4030_rtc_init: can't"
65                                 "reserve GPIO:%d !\n", TWL4030_MSECURE_GPIO);
66                         goto out;
67                 }
68                 /*
69                  * TWL4030 will be in secure mode if msecure line from OMAP
70                  * is low. Make msecure line high in order to change the
71                  * TWL4030 RTC time and calender registers.
72                  */
73                 omap_set_gpio_direction(TWL4030_MSECURE_GPIO, 0);
74
75                 tmp = omap_readw(msecure_pad_config_reg);
76                 tmp &= 0xF8;    /* To enable mux mode 03/04 = GPIO_RTC */
77                 tmp |= mux_mask;/* To enable mux mode 03/04 = GPIO_RTC */
78                 omap_writew(tmp, msecure_pad_config_reg);
79
80                 omap_set_gpio_dataout(TWL4030_MSECURE_GPIO, 1);
81         }
82 out:
83         return ret;
84 }
85
86 static void twl4030_rtc_exit(void)
87 {
88         omap_free_gpio(TWL4030_MSECURE_GPIO);
89 }
90
91 static struct twl4030rtc_platform_data ldp_twl4030rtc_data = {
92         .init = &twl4030_rtc_init,
93         .exit = &twl4030_rtc_exit,
94 };
95
96 static struct platform_device ldp_twl4030rtc_device = {
97         .name           = "twl4030_rtc",
98         .id             = -1,
99         .dev            = {
100                 .platform_data  = &ldp_twl4030rtc_data,
101         },
102 };
103 #endif
104
105 /**
106  * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
107  *
108  * @return - void. If request gpio fails then Flag KERN_ERR.
109  */
110 static void ads7846_dev_init(void)
111 {
112         if (omap_request_gpio(ts_gpio) < 0) {
113                 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
114                 return;
115         }
116
117         omap_set_gpio_direction(ts_gpio, 1);
118
119         omap_set_gpio_debounce(ts_gpio, 1);
120         omap_set_gpio_debounce_time(ts_gpio, 0xa);
121 }
122
123 static int ads7846_get_pendown_state(void)
124 {
125         return !omap_get_gpio_datain(ts_gpio);
126 }
127
128 /*
129  * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
130  */
131 static int ads7846_vaux_control(int vaux_cntrl)
132 {
133         int ret = 0;
134
135 #ifdef CONFIG_TWL4030_CORE
136         /* check for return value of ldo_use: if success it returns 0 */
137         if (vaux_cntrl == VAUX_ENABLE) {
138                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
139                         ENABLE_VAUX1_DEDICATED, TWL4030_VAUX1_DEDICATED))
140                         return -EIO;
141                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
142                         ENABLE_VAUX1_DEV_GRP, TWL4030_VAUX1_DEV_GRP))
143                         return -EIO;
144         } else if (vaux_cntrl == VAUX_DISABLE) {
145                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
146                         0x00, TWL4030_VAUX1_DEDICATED))
147                         return -EIO;
148                 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
149                         0x00, TWL4030_VAUX1_DEV_GRP))
150                         return -EIO;
151         }
152 #else
153         ret = -EIO;
154 #endif
155         return ret;
156 }
157
158 static struct ads7846_platform_data tsc2046_config __initdata = {
159         .get_pendown_state      = ads7846_get_pendown_state,
160         .keep_vref_on           = 1,
161         .vaux_control           = ads7846_vaux_control,
162 };
163
164
165 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
166         .turbo_mode     = 0,
167         .single_channel = 1,  /* 0: slave, 1: master */
168 };
169
170 static struct spi_board_info ldp_spi_board_info[] __initdata = {
171         [0] = {
172                 /*
173                  * TSC2046 operates at a max freqency of 2MHz, so
174                  * operate slightly below at 1.5MHz
175                  */
176                 .modalias               = "ads7846",
177                 .bus_num                = 1,
178                 .chip_select            = 0,
179                 .max_speed_hz           = 1500000,
180                 .controller_data        = &tsc2046_mcspi_config,
181                 .irq                    = 0,
182                 .platform_data          = &tsc2046_config,
183         },
184 };
185
186 static struct platform_device *ldp_devices[] __initdata = {
187 #ifdef CONFIG_RTC_DRV_TWL4030
188         &ldp_twl4030rtc_device,
189 #endif
190 };
191
192 static void __init omap_ldp_init_irq(void)
193 {
194         omap2_init_common_hw(NULL);
195         omap_init_irq();
196         omap_gpio_init();
197 }
198
199 static struct omap_uart_config ldp_uart_config __initdata = {
200         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
201 };
202
203 static struct omap_mmc_config ldp_mmc_config __initdata = {
204         .mmc [0] = {
205                 .enabled        = 1,
206                 .wire4          = 1,
207         },
208 };
209
210 static struct omap_board_config_kernel ldp_config[] __initdata = {
211         { OMAP_TAG_UART,        &ldp_uart_config },
212         { OMAP_TAG_MMC,         &ldp_mmc_config },
213 };
214
215 static int __init omap_i2c_init(void)
216 {
217         omap_register_i2c_bus(1, 2600, NULL, 0);
218         omap_register_i2c_bus(2, 400, NULL, 0);
219         omap_register_i2c_bus(3, 400, NULL, 0);
220         return 0;
221 }
222
223 static void __init omap_ldp_init(void)
224 {
225         platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
226         omap_board_config = ldp_config;
227         omap_board_config_size = ARRAY_SIZE(ldp_config);
228         ts_gpio = 54;
229         ldp_spi_board_info[0].irq = OMAP_GPIO_IRQ(ts_gpio);
230         spi_register_board_info(ldp_spi_board_info,
231                                 ARRAY_SIZE(ldp_spi_board_info));
232         ads7846_dev_init();
233         omap_serial_init();
234         usb_musb_init();
235         hsmmc_init();
236 }
237
238 static void __init omap_ldp_map_io(void)
239 {
240         omap2_set_globals_343x();
241         omap2_map_common_io();
242 }
243 arch_initcall(omap_i2c_init);
244
245 MACHINE_START(OMAP_LDP, "OMAP LDP board")
246         .phys_io        = 0x48000000,
247         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
248         .boot_params    = 0x80000100,
249         .map_io         = omap_ldp_map_io,
250         .init_irq       = omap_ldp_init_irq,
251         .init_machine   = omap_ldp_init,
252         .timer          = &omap_timer,
253 MACHINE_END