2 * board-omap3pandora.c (Pandora Handheld Console)
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.
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.
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
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
26 #include <linux/regulator/machine.h>
27 #include <linux/i2c/twl4030.h>
28 #include <linux/leds.h>
29 #include <linux/input.h>
30 #include <linux/gpio_keys.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <mach/board.h>
37 #include <mach/common.h>
38 #include <mach/gpio.h>
39 #include <mach/hardware.h>
40 #include <mach/mcspi.h>
42 #include <mach/keypad.h>
45 #include "sdram-micron-mt46h32m32lf-6.h"
46 #include "mmc-twl4030.h"
48 #define OMAP3_PANDORA_TS_GPIO 94
50 /* hardware debounce: (value + 1) * 31us */
51 #define GPIO_DEBOUNCE_TIME 127
53 static struct gpio_led pandora_gpio_leds
[] = {
55 .name
= "pandora::sd1",
56 .default_trigger
= "mmc0",
59 .name
= "pandora::sd2",
60 .default_trigger
= "mmc1",
63 .name
= "pandora::bluetooth",
66 .name
= "pandora::wifi",
71 static struct gpio_led_platform_data pandora_gpio_led_data
= {
72 .leds
= pandora_gpio_leds
,
73 .num_leds
= ARRAY_SIZE(pandora_gpio_leds
),
76 static struct platform_device pandora_leds_gpio
= {
80 .platform_data
= &pandora_gpio_led_data
,
84 #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
89 .active_low = act_low, \
90 .desc = "btn " descr, \
93 #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
94 GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
96 static struct gpio_keys_button pandora_gpio_keys
[] = {
97 GPIO_BUTTON_LOW(110, KEY_UP
, "up"),
98 GPIO_BUTTON_LOW(103, KEY_DOWN
, "down"),
99 GPIO_BUTTON_LOW(96, KEY_LEFT
, "left"),
100 GPIO_BUTTON_LOW(98, KEY_RIGHT
, "right"),
101 GPIO_BUTTON_LOW(111, BTN_A
, "a"),
102 GPIO_BUTTON_LOW(106, BTN_B
, "b"),
103 GPIO_BUTTON_LOW(109, BTN_X
, "x"),
104 GPIO_BUTTON_LOW(101, BTN_Y
, "y"),
105 GPIO_BUTTON_LOW(102, BTN_TL
, "l"),
106 GPIO_BUTTON_LOW(97, BTN_TL2
, "l2"),
107 GPIO_BUTTON_LOW(105, BTN_TR
, "r"),
108 GPIO_BUTTON_LOW(107, BTN_TR2
, "r2"),
109 GPIO_BUTTON_LOW(104, KEY_LEFTCTRL
, "ctrl"),
110 GPIO_BUTTON_LOW(99, KEY_MENU
, "menu"),
111 GPIO_BUTTON_LOW(176, KEY_COFFEE
, "hold"),
112 GPIO_BUTTON(100, EV_KEY
, KEY_LEFTALT
, 0, "alt"),
113 GPIO_BUTTON(108, EV_SW
, SW_LID
, 1, "lid"),
116 static struct gpio_keys_platform_data pandora_gpio_key_info
= {
117 .buttons
= pandora_gpio_keys
,
118 .nbuttons
= ARRAY_SIZE(pandora_gpio_keys
),
121 static struct platform_device pandora_keys_gpio
= {
125 .platform_data
= &pandora_gpio_key_info
,
129 static void __init
pandora_keys_gpio_init(void)
131 /* set debounce time for GPIO banks 4 and 6 */
132 omap_set_gpio_debounce_time(32 * 3, GPIO_DEBOUNCE_TIME
);
133 omap_set_gpio_debounce_time(32 * 5, GPIO_DEBOUNCE_TIME
);
136 static int pandora_keypad_map
[] = {
140 KEY(0, 2, KEY_BACKSPACE
),
145 KEY(0, 7, KEY_ENTER
),
169 KEY(3, 7, KEY_LEFTSHIFT
),
177 KEY(4, 7, KEY_COMMA
),
179 KEY(5, 1, KEY_SPACE
),
183 static struct twl4030_keypad_data pandora_kp_data
= {
186 .keymap
= pandora_keypad_map
,
187 .keymapsize
= ARRAY_SIZE(pandora_keypad_map
),
191 static struct twl4030_hsmmc_info omap3pandora_mmc
[] = {
216 static struct omap_uart_config omap3pandora_uart_config __initdata
= {
217 .enabled_uarts
= (1 << 2), /* UART3 */
220 static struct regulator_consumer_supply pandora_vmmc1_supply
= {
224 static struct regulator_consumer_supply pandora_vmmc2_supply
= {
228 static int omap3pandora_twl_gpio_setup(struct device
*dev
,
229 unsigned gpio
, unsigned ngpio
)
231 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
232 omap3pandora_mmc
[0].gpio_cd
= gpio
+ 0;
233 omap3pandora_mmc
[1].gpio_cd
= gpio
+ 1;
234 twl4030_mmc_init(omap3pandora_mmc
);
236 /* link regulators to MMC adapters */
237 pandora_vmmc1_supply
.dev
= omap3pandora_mmc
[0].dev
;
238 pandora_vmmc2_supply
.dev
= omap3pandora_mmc
[1].dev
;
243 static struct twl4030_gpio_platform_data omap3pandora_gpio_data
= {
244 .gpio_base
= OMAP_MAX_GPIO_LINES
,
245 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
246 .irq_end
= TWL4030_GPIO_IRQ_END
,
247 .setup
= omap3pandora_twl_gpio_setup
,
250 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
251 static struct regulator_init_data pandora_vmmc1
= {
255 .valid_modes_mask
= REGULATOR_MODE_NORMAL
256 | REGULATOR_MODE_STANDBY
,
257 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
258 | REGULATOR_CHANGE_MODE
259 | REGULATOR_CHANGE_STATUS
,
261 .num_consumer_supplies
= 1,
262 .consumer_supplies
= &pandora_vmmc1_supply
,
265 /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
266 static struct regulator_init_data pandora_vmmc2
= {
270 .valid_modes_mask
= REGULATOR_MODE_NORMAL
271 | REGULATOR_MODE_STANDBY
,
272 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
273 | REGULATOR_CHANGE_MODE
274 | REGULATOR_CHANGE_STATUS
,
276 .num_consumer_supplies
= 1,
277 .consumer_supplies
= &pandora_vmmc2_supply
,
280 static struct twl4030_usb_data omap3pandora_usb_data
= {
281 .usb_mode
= T2_USB_MODE_ULPI
,
284 static struct twl4030_platform_data omap3pandora_twldata
= {
285 .irq_base
= TWL4030_IRQ_BASE
,
286 .irq_end
= TWL4030_IRQ_END
,
287 .gpio
= &omap3pandora_gpio_data
,
288 .usb
= &omap3pandora_usb_data
,
289 .vmmc1
= &pandora_vmmc1
,
290 .vmmc2
= &pandora_vmmc2
,
291 .keypad
= &pandora_kp_data
,
294 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo
[] = {
296 I2C_BOARD_INFO("tps65950", 0x48),
297 .flags
= I2C_CLIENT_WAKE
,
298 .irq
= INT_34XX_SYS_NIRQ
,
299 .platform_data
= &omap3pandora_twldata
,
303 static int __init
omap3pandora_i2c_init(void)
305 omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo
,
306 ARRAY_SIZE(omap3pandora_i2c_boardinfo
));
307 /* i2c2 pins are not connected */
308 omap_register_i2c_bus(3, 400, NULL
, 0);
312 static void __init
omap3pandora_init_irq(void)
314 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
,
315 mt46h32m32lf6_sdrc_params
);
320 static void __init
omap3pandora_ads7846_init(void)
322 int gpio
= OMAP3_PANDORA_TS_GPIO
;
325 ret
= gpio_request(gpio
, "ads7846_pen_down");
327 printk(KERN_ERR
"Failed to request GPIO %d for "
328 "ads7846 pen down IRQ\n", gpio
);
332 gpio_direction_input(gpio
);
335 static int ads7846_get_pendown_state(void)
337 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO
);
340 static struct ads7846_platform_data ads7846_config
= {
348 .get_pendown_state
= ads7846_get_pendown_state
,
352 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
354 .single_channel
= 1, /* 0: slave, 1: master */
357 static struct spi_board_info omap3pandora_spi_board_info
[] __initdata
= {
359 .modalias
= "ads7846",
362 .max_speed_hz
= 1500000,
363 .controller_data
= &ads7846_mcspi_config
,
364 .irq
= OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO
),
365 .platform_data
= &ads7846_config
,
369 static struct platform_device omap3pandora_lcd_device
= {
370 .name
= "pandora_lcd",
374 static struct omap_lcd_config omap3pandora_lcd_config __initdata
= {
375 .ctrl_name
= "internal",
378 static struct omap_board_config_kernel omap3pandora_config
[] __initdata
= {
379 { OMAP_TAG_UART
, &omap3pandora_uart_config
},
380 { OMAP_TAG_LCD
, &omap3pandora_lcd_config
},
383 static struct platform_device
*omap3pandora_devices
[] __initdata
= {
384 &omap3pandora_lcd_device
,
389 static void __init
omap3pandora_init(void)
391 omap3pandora_i2c_init();
392 platform_add_devices(omap3pandora_devices
,
393 ARRAY_SIZE(omap3pandora_devices
));
394 omap_board_config
= omap3pandora_config
;
395 omap_board_config_size
= ARRAY_SIZE(omap3pandora_config
);
397 spi_register_board_info(omap3pandora_spi_board_info
,
398 ARRAY_SIZE(omap3pandora_spi_board_info
));
399 omap3pandora_ads7846_init();
400 pandora_keys_gpio_init();
403 /* Ensure SDRC pins are mux'd for self-refresh */
404 omap_cfg_reg(H16_34XX_SDRC_CKE0
);
405 omap_cfg_reg(H17_34XX_SDRC_CKE1
);
408 static void __init
omap3pandora_map_io(void)
410 omap2_set_globals_343x();
411 omap2_map_common_io();
414 MACHINE_START(OMAP3_PANDORA
, "Pandora Handheld Console")
415 .phys_io
= 0x48000000,
416 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
417 .boot_params
= 0x80000100,
418 .map_io
= omap3pandora_map_io
,
419 .init_irq
= omap3pandora_init_irq
,
420 .init_machine
= omap3pandora_init
,
421 .timer
= &omap_timer
,