2 * linux/arch/arm/mach-omap2/board-ldp.c
4 * Copyright (C) 2008 Texas Instruments Inc.
5 * Nishant Kamat <nskamat@ti.com>
7 * Modified from mach-omap2/board-3430sdp.c
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.
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>
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
31 #include <mach/board-ldp.h>
32 #include <mach/mcspi.h>
33 #include <mach/gpio.h>
34 #include <mach/board.h>
35 #include <mach/common.h>
36 #include <mach/gpmc.h>
37 #include <mach/hsmmc.h>
38 #include <mach/usb-musb.h>
41 #include <asm/delay.h>
42 #include <mach/control.h>
44 #define ENABLE_VAUX1_DEDICATED 0x03
45 #define ENABLE_VAUX1_DEV_GRP 0x20
47 #define TWL4030_MSECURE_GPIO 22
51 static int __init msecure_init(void)
55 #ifdef CONFIG_RTC_DRV_TWL4030
56 /* 3430ES2.0 doesn't have msecure/gpio-22 line connected to T2 */
57 if (omap_type() == OMAP2_DEVICE_TYPE_GP &&
58 system_rev < OMAP3430_REV_ES2_0) {
59 void __iomem *msecure_pad_config_reg =
60 omap_ctrl_base_get() + 0xA3C;
64 ret = gpio_request(TWL4030_MSECURE_GPIO, "msecure");
66 printk(KERN_ERR "msecure_init: can't"
67 "reserve GPIO:%d !\n", TWL4030_MSECURE_GPIO);
71 * TWL4030 will be in secure mode if msecure line from OMAP
72 * is low. Make msecure line high in order to change the
73 * TWL4030 RTC time and calender registers.
76 tmp = __raw_readw(msecure_pad_config_reg);
77 tmp &= 0xF8; /* To enable mux mode 03/04 = GPIO_RTC */
78 tmp |= mux_mask;/* To enable mux mode 03/04 = GPIO_RTC */
79 __raw_writew(tmp, msecure_pad_config_reg);
81 gpio_direction_output(TWL4030_MSECURE_GPIO, 1);
89 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
91 * @return - void. If request gpio fails then Flag KERN_ERR.
93 static void ads7846_dev_init(void)
95 if (omap_request_gpio(ts_gpio) < 0) {
96 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
100 omap_set_gpio_direction(ts_gpio, 1);
102 omap_set_gpio_debounce(ts_gpio, 1);
103 omap_set_gpio_debounce_time(ts_gpio, 0xa);
106 static int ads7846_get_pendown_state(void)
108 return !omap_get_gpio_datain(ts_gpio);
112 * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
114 static int ads7846_vaux_control(int vaux_cntrl)
118 #ifdef CONFIG_TWL4030_CORE
119 /* check for return value of ldo_use: if success it returns 0 */
120 if (vaux_cntrl == VAUX_ENABLE) {
121 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
122 ENABLE_VAUX1_DEDICATED, TWL4030_VAUX1_DEDICATED))
124 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
125 ENABLE_VAUX1_DEV_GRP, TWL4030_VAUX1_DEV_GRP))
127 } else if (vaux_cntrl == VAUX_DISABLE) {
128 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
129 0x00, TWL4030_VAUX1_DEDICATED))
131 if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
132 0x00, TWL4030_VAUX1_DEV_GRP))
141 static struct ads7846_platform_data tsc2046_config __initdata = {
142 .get_pendown_state = ads7846_get_pendown_state,
144 .vaux_control = ads7846_vaux_control,
148 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
150 .single_channel = 1, /* 0: slave, 1: master */
153 static struct spi_board_info ldp_spi_board_info[] __initdata = {
156 * TSC2046 operates at a max freqency of 2MHz, so
157 * operate slightly below at 1.5MHz
159 .modalias = "ads7846",
162 .max_speed_hz = 1500000,
163 .controller_data = &tsc2046_mcspi_config,
165 .platform_data = &tsc2046_config,
169 static struct platform_device *ldp_devices[] __initdata = {
172 static void __init omap_ldp_init_irq(void)
174 omap2_init_common_hw(NULL);
179 static struct omap_uart_config ldp_uart_config __initdata = {
180 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
183 static struct omap_board_config_kernel ldp_config[] __initdata = {
184 { OMAP_TAG_UART, &ldp_uart_config },
187 static int ldp_batt_table[] = {
189 30800, 29500, 28300, 27100,
190 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
191 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
192 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
193 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
194 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
195 4040, 3910, 3790, 3670, 3550
198 static struct twl4030_bci_platform_data ldp_bci_data = {
199 .battery_tmp_tbl = ldp_batt_table,
200 .tblsize = ARRAY_SIZE(ldp_batt_table),
203 static struct twl4030_usb_data ldp_usb_data = {
204 .usb_mode = T2_USB_MODE_ULPI,
207 static struct twl4030_gpio_platform_data ldp_gpio_data = {
208 .gpio_base = OMAP_MAX_GPIO_LINES,
209 .irq_base = TWL4030_GPIO_IRQ_BASE,
210 .irq_end = TWL4030_GPIO_IRQ_END,
213 static struct twl4030_madc_platform_data ldp_madc_data = {
217 static struct twl4030_platform_data ldp_twldata = {
218 .irq_base = TWL4030_IRQ_BASE,
219 .irq_end = TWL4030_IRQ_END,
221 /* platform_data for children goes here */
222 .bci = &ldp_bci_data,
223 .madc = &ldp_madc_data,
224 .usb = &ldp_usb_data,
225 .gpio = &ldp_gpio_data,
228 static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
230 I2C_BOARD_INFO("twl4030", 0x48),
231 .flags = I2C_CLIENT_WAKE,
232 .irq = INT_34XX_SYS_NIRQ,
233 .platform_data = &ldp_twldata,
237 static int __init omap_i2c_init(void)
239 omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
240 ARRAY_SIZE(ldp_i2c_boardinfo));
241 omap_register_i2c_bus(2, 400, NULL, 0);
242 omap_register_i2c_bus(3, 400, NULL, 0);
246 static void __init omap_ldp_init(void)
249 platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
250 omap_board_config = ldp_config;
251 omap_board_config_size = ARRAY_SIZE(ldp_config);
253 ldp_spi_board_info[0].irq = OMAP_GPIO_IRQ(ts_gpio);
254 spi_register_board_info(ldp_spi_board_info,
255 ARRAY_SIZE(ldp_spi_board_info));
263 static void __init omap_ldp_map_io(void)
265 omap2_set_globals_343x();
266 omap2_map_common_io();
269 MACHINE_START(OMAP_LDP, "OMAP LDP board")
270 .phys_io = 0x48000000,
271 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
272 .boot_params = 0x80000100,
273 .map_io = omap_ldp_map_io,
274 .init_irq = omap_ldp_init_irq,
275 .init_machine = omap_ldp_init,
276 .timer = &omap_timer,