blob: 2ab24975b6854339c103ea1d98b4ea63aa7627a7 [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>
Grazvydas Ignotas64f535a2009-05-28 14:04:04 -070026#include <linux/regulator/machine.h>
Grazvydas Ignotasda177242008-12-10 17:36:54 -080027#include <linux/i2c/twl4030.h>
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
33#include <mach/board.h>
34#include <mach/common.h>
35#include <mach/gpio.h>
36#include <mach/hardware.h>
37#include <mach/mcspi.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070038#include <mach/usb.h>
Grazvydas Ignotasda177242008-12-10 17:36:54 -080039
Paul Walmsley2e12bd72009-05-28 14:03:59 -070040#include "sdram-micron-mt46h32m32lf-6.h"
Tony Lindgren90c62bf2008-12-10 17:37:17 -080041#include "mmc-twl4030.h"
42
Grazvydas Ignotasda177242008-12-10 17:36:54 -080043#define OMAP3_PANDORA_TS_GPIO 94
44
Tony Lindgren90c62bf2008-12-10 17:37:17 -080045static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
46 {
47 .mmc = 1,
48 .wires = 4,
49 .gpio_cd = -EINVAL,
50 .gpio_wp = 126,
51 .ext_clock = 0,
52 },
53 {
54 .mmc = 2,
55 .wires = 4,
56 .gpio_cd = -EINVAL,
57 .gpio_wp = 127,
58 .ext_clock = 1,
David Brownell0329c372009-03-23 18:23:47 -070059 .transceiver = true,
Tony Lindgren90c62bf2008-12-10 17:37:17 -080060 },
Grazvydas Ignotas07d83cc2009-03-23 18:23:47 -070061 {
62 .mmc = 3,
63 .wires = 4,
64 .gpio_cd = -EINVAL,
65 .gpio_wp = -EINVAL,
66 },
Tony Lindgren90c62bf2008-12-10 17:37:17 -080067 {} /* Terminator */
68};
69
Grazvydas Ignotasda177242008-12-10 17:36:54 -080070static struct omap_uart_config omap3pandora_uart_config __initdata = {
71 .enabled_uarts = (1 << 2), /* UART3 */
72};
73
Grazvydas Ignotas64f535a2009-05-28 14:04:04 -070074static struct regulator_consumer_supply pandora_vmmc1_supply = {
75 .supply = "vmmc",
76};
77
78static struct regulator_consumer_supply pandora_vmmc2_supply = {
79 .supply = "vmmc",
80};
81
Tony Lindgren90c62bf2008-12-10 17:37:17 -080082static int omap3pandora_twl_gpio_setup(struct device *dev,
83 unsigned gpio, unsigned ngpio)
84{
85 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
86 omap3pandora_mmc[0].gpio_cd = gpio + 0;
87 omap3pandora_mmc[1].gpio_cd = gpio + 1;
88 twl4030_mmc_init(omap3pandora_mmc);
89
Grazvydas Ignotas64f535a2009-05-28 14:04:04 -070090 /* link regulators to MMC adapters */
91 pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev;
92 pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev;
93
Tony Lindgren90c62bf2008-12-10 17:37:17 -080094 return 0;
95}
96
Grazvydas Ignotasda177242008-12-10 17:36:54 -080097static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
98 .gpio_base = OMAP_MAX_GPIO_LINES,
99 .irq_base = TWL4030_GPIO_IRQ_BASE,
100 .irq_end = TWL4030_GPIO_IRQ_END,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800101 .setup = omap3pandora_twl_gpio_setup,
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800102};
103
Grazvydas Ignotas64f535a2009-05-28 14:04:04 -0700104/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
105static struct regulator_init_data pandora_vmmc1 = {
106 .constraints = {
107 .min_uV = 1850000,
108 .max_uV = 3150000,
109 .valid_modes_mask = REGULATOR_MODE_NORMAL
110 | REGULATOR_MODE_STANDBY,
111 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
112 | REGULATOR_CHANGE_MODE
113 | REGULATOR_CHANGE_STATUS,
114 },
115 .num_consumer_supplies = 1,
116 .consumer_supplies = &pandora_vmmc1_supply,
117};
118
119/* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
120static struct regulator_init_data pandora_vmmc2 = {
121 .constraints = {
122 .min_uV = 1850000,
123 .max_uV = 3150000,
124 .valid_modes_mask = REGULATOR_MODE_NORMAL
125 | REGULATOR_MODE_STANDBY,
126 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
127 | REGULATOR_CHANGE_MODE
128 | REGULATOR_CHANGE_STATUS,
129 },
130 .num_consumer_supplies = 1,
131 .consumer_supplies = &pandora_vmmc2_supply,
132};
133
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800134static struct twl4030_usb_data omap3pandora_usb_data = {
135 .usb_mode = T2_USB_MODE_ULPI,
136};
137
138static struct twl4030_platform_data omap3pandora_twldata = {
139 .irq_base = TWL4030_IRQ_BASE,
140 .irq_end = TWL4030_IRQ_END,
141 .gpio = &omap3pandora_gpio_data,
142 .usb = &omap3pandora_usb_data,
Grazvydas Ignotas64f535a2009-05-28 14:04:04 -0700143 .vmmc1 = &pandora_vmmc1,
144 .vmmc2 = &pandora_vmmc2,
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800145};
146
147static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
148 {
149 I2C_BOARD_INFO("tps65950", 0x48),
150 .flags = I2C_CLIENT_WAKE,
151 .irq = INT_34XX_SYS_NIRQ,
152 .platform_data = &omap3pandora_twldata,
153 },
154};
155
156static int __init omap3pandora_i2c_init(void)
157{
158 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
159 ARRAY_SIZE(omap3pandora_i2c_boardinfo));
160 /* i2c2 pins are not connected */
161 omap_register_i2c_bus(3, 400, NULL, 0);
162 return 0;
163}
164
165static void __init omap3pandora_init_irq(void)
166{
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700167 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800168 omap_init_irq();
169 omap_gpio_init();
170}
171
172static void __init omap3pandora_ads7846_init(void)
173{
174 int gpio = OMAP3_PANDORA_TS_GPIO;
175 int ret;
176
177 ret = gpio_request(gpio, "ads7846_pen_down");
178 if (ret < 0) {
179 printk(KERN_ERR "Failed to request GPIO %d for "
180 "ads7846 pen down IRQ\n", gpio);
181 return;
182 }
183
184 gpio_direction_input(gpio);
185}
186
187static int ads7846_get_pendown_state(void)
188{
189 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
190}
191
192static struct ads7846_platform_data ads7846_config = {
193 .x_max = 0x0fff,
194 .y_max = 0x0fff,
195 .x_plate_ohms = 180,
196 .pressure_max = 255,
197 .debounce_max = 10,
198 .debounce_tol = 3,
199 .debounce_rep = 1,
200 .get_pendown_state = ads7846_get_pendown_state,
201 .keep_vref_on = 1,
202};
203
204static struct omap2_mcspi_device_config ads7846_mcspi_config = {
205 .turbo_mode = 0,
206 .single_channel = 1, /* 0: slave, 1: master */
207};
208
209static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
210 {
211 .modalias = "ads7846",
212 .bus_num = 1,
213 .chip_select = 0,
214 .max_speed_hz = 1500000,
215 .controller_data = &ads7846_mcspi_config,
216 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
217 .platform_data = &ads7846_config,
218 }
219};
220
221static struct platform_device omap3pandora_lcd_device = {
222 .name = "pandora_lcd",
223 .id = -1,
224};
225
226static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
227 .ctrl_name = "internal",
228};
229
230static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
231 { OMAP_TAG_UART, &omap3pandora_uart_config },
232 { OMAP_TAG_LCD, &omap3pandora_lcd_config },
233};
234
235static struct platform_device *omap3pandora_devices[] __initdata = {
236 &omap3pandora_lcd_device,
237};
238
239static void __init omap3pandora_init(void)
240{
241 omap3pandora_i2c_init();
242 platform_add_devices(omap3pandora_devices,
243 ARRAY_SIZE(omap3pandora_devices));
244 omap_board_config = omap3pandora_config;
245 omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
246 omap_serial_init();
247 spi_register_board_info(omap3pandora_spi_board_info,
248 ARRAY_SIZE(omap3pandora_spi_board_info));
249 omap3pandora_ads7846_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700250 usb_musb_init();
Grazvydas Ignotasda177242008-12-10 17:36:54 -0800251}
252
253static void __init omap3pandora_map_io(void)
254{
255 omap2_set_globals_343x();
256 omap2_map_common_io();
257}
258
259MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
260 .phys_io = 0x48000000,
261 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
262 .boot_params = 0x80000100,
263 .map_io = omap3pandora_map_io,
264 .init_irq = omap3pandora_init_irq,
265 .init_machine = omap3pandora_init,
266 .timer = &omap_timer,
267MACHINE_END