blob: 3571bb47ab86054e1184003581bf36ea30496a8b [file] [log] [blame]
Grazvydas Ignotasda177242008-12-10 17:36:54 -08001/*
2 * board-omap3pandora.c (Pandora Handheld Console)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 *
18 */
19
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/platform_device.h>
23
24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
26#include <linux/i2c/twl4030.h>
27
28#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31
32#include <mach/board.h>
33#include <mach/common.h>
34#include <mach/gpio.h>
35#include <mach/hardware.h>
36#include <mach/mcspi.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070037#include <mach/usb.h>
Grazvydas Ignotasda177242008-12-10 17:36:54 -080038
Paul Walmsley2e12bd72009-05-28 14:03:59 -070039#include "sdram-micron-mt46h32m32lf-6.h"
Tony Lindgren90c62bf2008-12-10 17:37:17 -080040#include "mmc-twl4030.h"
41
Grazvydas Ignotasda177242008-12-10 17:36:54 -080042#define OMAP3_PANDORA_TS_GPIO 94
43
Tony Lindgren90c62bf2008-12-10 17:37:17 -080044static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
45 {
46 .mmc = 1,
47 .wires = 4,
48 .gpio_cd = -EINVAL,
49 .gpio_wp = 126,
50 .ext_clock = 0,
51 },
52 {
53 .mmc = 2,
54 .wires = 4,
55 .gpio_cd = -EINVAL,
56 .gpio_wp = 127,
57 .ext_clock = 1,
David Brownell0329c372009-03-23 18:23:47 -070058 .transceiver = true,
Tony Lindgren90c62bf2008-12-10 17:37:17 -080059 },
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -070060 {
61 .mmc = 3,
62 .wires = 4,
63 .gpio_cd = -EINVAL,
64 .gpio_wp = -EINVAL,
65 },
Tony Lindgren90c62bf2008-12-10 17:37:17 -080066 {} /* Terminator */
67};
68
Grazvydas Ignotasda177242008-12-10 17:36:54 -080069static struct omap_uart_config omap3pandora_uart_config __initdata = {
70 .enabled_uarts = (1 << 2), /* UART3 */
71};
72
Tony Lindgren90c62bf2008-12-10 17:37:17 -080073static int omap3pandora_twl_gpio_setup(struct device *dev,
74 unsigned gpio, unsigned ngpio)
75{
76 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
77 omap3pandora_mmc[0].gpio_cd = gpio + 0;
78 omap3pandora_mmc[1].gpio_cd = gpio + 1;
79 twl4030_mmc_init(omap3pandora_mmc);
80
81 return 0;
82}
83
Grazvydas Ignotasda177242008-12-10 17:36:54 -080084static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
85 .gpio_base = OMAP_MAX_GPIO_LINES,
86 .irq_base = TWL4030_GPIO_IRQ_BASE,
87 .irq_end = TWL4030_GPIO_IRQ_END,
Tony Lindgren90c62bf2008-12-10 17:37:17 -080088 .setup = omap3pandora_twl_gpio_setup,
Grazvydas Ignotasda177242008-12-10 17:36:54 -080089};
90
91static struct twl4030_usb_data omap3pandora_usb_data = {
92 .usb_mode = T2_USB_MODE_ULPI,
93};
94
95static struct twl4030_platform_data omap3pandora_twldata = {
96 .irq_base = TWL4030_IRQ_BASE,
97 .irq_end = TWL4030_IRQ_END,
98 .gpio = &omap3pandora_gpio_data,
99 .usb = &omap3pandora_usb_data,
100};
101
102static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
103 {
104 I2C_BOARD_INFO("tps65950", 0x48),
105 .flags = I2C_CLIENT_WAKE,
106 .irq = INT_34XX_SYS_NIRQ,
107 .platform_data = &omap3pandora_twldata,
108 },
109};
110
111static int __init omap3pandora_i2c_init(void)
112{
113 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
114 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
115 /* i2c2 pins are not connected */
116 omap_register_i2c_bus(3, 400, NULL, 0);
117 return 0;
118}
119
120static void __init omap3pandora_init_irq(void)
121{
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700122 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800123 omap_init_irq();
124 omap_gpio_init();
125}
126
127static void __init omap3pandora_ads7846_init(void)
128{
129 int gpio = OMAP3_PANDORA_TS_GPIO;
130 int ret;
131
132 ret = gpio_request(gpio, "ads7846_pen_down");
133 if (ret < 0) {
134 printk(KERN_ERR "Failed to request GPIO %d for "
135 "ads7846 pen down IRQ\n", gpio);
136 return;
137 }
138
139 gpio_direction_input(gpio);
140}
141
142static int ads7846_get_pendown_state(void)
143{
144 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
145}
146
147static struct ads7846_platform_data ads7846_config = {
148 .x_max = 0x0fff,
149 .y_max = 0x0fff,
150 .x_plate_ohms = 180,
151 .pressure_max = 255,
152 .debounce_max = 10,
153 .debounce_tol = 3,
154 .debounce_rep = 1,
155 .get_pendown_state = ads7846_get_pendown_state,
156 .keep_vref_on = 1,
157};
158
159static struct omap2_mcspi_device_config ads7846_mcspi_config = {
160 .turbo_mode = 0,
161 .single_channel = 1, /* 0: slave, 1: master */
162};
163
164static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
165 {
166 .modalias = "ads7846",
167 .bus_num = 1,
168 .chip_select = 0,
169 .max_speed_hz = 1500000,
170 .controller_data = &ads7846_mcspi_config,
171 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
172 .platform_data = &ads7846_config,
173 }
174};
175
176static struct platform_device omap3pandora_lcd_device = {
177 .name = "pandora_lcd",
178 .id = -1,
179};
180
181static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
182 .ctrl_name = "internal",
183};
184
185static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
186 { OMAP_TAG_UART, &omap3pandora_uart_config },
187 { OMAP_TAG_LCD, &omap3pandora_lcd_config },
188};
189
190static struct platform_device *omap3pandora_devices[] __initdata = {
191 &omap3pandora_lcd_device,
192};
193
194static void __init omap3pandora_init(void)
195{
196 omap3pandora_i2c_init();
197 platform_add_devices(omap3pandora_devices,
198 ARRAY_SIZE(omap3pandora_devices));
199 omap_board_config = omap3pandora_config;
200 omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
201 omap_serial_init();
202 spi_register_board_info(omap3pandora_spi_board_info,
203 ARRAY_SIZE(omap3pandora_spi_board_info));
204 omap3pandora_ads7846_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700205 usb_musb_init();
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800206}
207
208static void __init omap3pandora_map_io(void)
209{
210 omap2_set_globals_343x();
211 omap2_map_common_io();
212}
213
214MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
215 .phys_io = 0x48000000,
216 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
217 .boot_params = 0x80000100,
218 .map_io = omap3pandora_map_io,
219 .init_irq = omap3pandora_init_irq,
220 .init_machine = omap3pandora_init,
221 .timer = &omap_timer,
222MACHINE_END