2 * Copyright (C) 2009 Texas Instruments Inc.
4 * Modified from mach-omap2/board-zoom2.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/input.h>
15 #include <linux/input/matrix_keypad.h>
16 #include <linux/gpio.h>
17 #include <linux/i2c/twl.h>
18 #include <linux/regulator/machine.h>
19 #include <linux/regulator/fixed.h>
20 #include <linux/wl12xx.h>
21 #include <linux/mmc/host.h>
22 #include <linux/platform_data/gpio-omap.h>
23 #include <linux/platform_data/omap-twl4030.h>
24 #include <linux/usb/phy.h>
25 #include <linux/pwm.h>
26 #include <linux/leds_pwm.h>
27 #include <linux/pwm_backlight.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
35 #include "board-zoom.h"
39 #include "common-board-devices.h"
41 #define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
42 #define OMAP_ZOOM_TSC2004_IRQ_GPIO (153)
43 #define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
45 /* Zoom2 has Qwerty keyboard*/
46 static uint32_t board_keymap
[] = {
52 KEY(0, 7, KEY_LEFTSHIFT
),
64 KEY(2, 7, KEY_CAPSLOCK
),
66 KEY(3, 1, KEY_KPPLUS
),
75 KEY(4, 4, KEY_VOLUMEUP
),
82 KEY(5, 4, KEY_UNKNOWN
),
83 KEY(5, 5, KEY_VOLUMEDOWN
),
89 KEY(6, 3, KEY_BACKSPACE
),
92 KEY(7, 0, KEY_PROG1
), /*MACRO 1 <User defined> */
93 KEY(7, 1, KEY_PROG2
), /*MACRO 2 <User defined> */
94 KEY(7, 2, KEY_PROG3
), /*MACRO 3 <User defined> */
95 KEY(7, 3, KEY_PROG4
), /*MACRO 4 <User defined> */
96 KEY(7, 6, KEY_SELECT
),
100 static struct matrix_keymap_data board_map_data
= {
101 .keymap
= board_keymap
,
102 .keymap_size
= ARRAY_SIZE(board_keymap
),
105 static struct twl4030_keypad_data zoom_kp_twl4030_data
= {
106 .keymap_data
= &board_map_data
,
112 static struct regulator_consumer_supply zoom_vmmc1_supply
[] = {
113 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
116 static struct regulator_consumer_supply zoom_vsim_supply
[] = {
117 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
120 static struct regulator_consumer_supply zoom_vmmc2_supply
[] = {
121 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
124 static struct regulator_consumer_supply zoom_vmmc3_supply
[] = {
125 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
128 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
129 static struct regulator_init_data zoom_vmmc1
= {
133 .valid_modes_mask
= REGULATOR_MODE_NORMAL
134 | REGULATOR_MODE_STANDBY
,
135 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
136 | REGULATOR_CHANGE_MODE
137 | REGULATOR_CHANGE_STATUS
,
139 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc1_supply
),
140 .consumer_supplies
= zoom_vmmc1_supply
,
143 /* VMMC2 for MMC2 card */
144 static struct regulator_init_data zoom_vmmc2
= {
149 .valid_modes_mask
= REGULATOR_MODE_NORMAL
150 | REGULATOR_MODE_STANDBY
,
151 .valid_ops_mask
= REGULATOR_CHANGE_MODE
152 | REGULATOR_CHANGE_STATUS
,
154 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc2_supply
),
155 .consumer_supplies
= zoom_vmmc2_supply
,
158 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
159 static struct regulator_init_data zoom_vsim
= {
163 .valid_modes_mask
= REGULATOR_MODE_NORMAL
164 | REGULATOR_MODE_STANDBY
,
165 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
166 | REGULATOR_CHANGE_MODE
167 | REGULATOR_CHANGE_STATUS
,
169 .num_consumer_supplies
= ARRAY_SIZE(zoom_vsim_supply
),
170 .consumer_supplies
= zoom_vsim_supply
,
173 static struct regulator_init_data zoom_vmmc3
= {
175 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
177 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc3_supply
),
178 .consumer_supplies
= zoom_vmmc3_supply
,
181 static struct fixed_voltage_config zoom_vwlan
= {
182 .supply_name
= "vwl1271",
183 .microvolts
= 1800000, /* 1.8V */
184 .gpio
= OMAP_ZOOM_WLAN_PMENA_GPIO
,
185 .startup_delay
= 70000, /* 70msec */
187 .enabled_at_boot
= 0,
188 .init_data
= &zoom_vmmc3
,
191 static struct platform_device omap_vwlan_device
= {
192 .name
= "reg-fixed-voltage",
195 .platform_data
= &zoom_vwlan
,
199 static struct pwm_lookup zoom_pwm_lookup
[] = {
200 PWM_LOOKUP("twl-pwm", 0, "leds_pwm", "zoom::keypad"),
201 PWM_LOOKUP("twl-pwm", 1, "pwm-backlight", "backlight"),
204 static struct led_pwm zoom_pwm_leds
[] = {
206 .name
= "zoom::keypad",
207 .max_brightness
= 127,
208 .pwm_period_ns
= 7812500,
212 static struct led_pwm_platform_data zoom_pwm_data
= {
213 .num_leds
= ARRAY_SIZE(zoom_pwm_leds
),
214 .leds
= zoom_pwm_leds
,
217 static struct platform_device zoom_leds_pwm
= {
221 .platform_data
= &zoom_pwm_data
,
225 static struct platform_pwm_backlight_data zoom_backlight_data
= {
227 .max_brightness
= 127,
228 .dft_brightness
= 127,
229 .pwm_period_ns
= 7812500,
232 static struct platform_device zoom_backlight_pwm
= {
233 .name
= "pwm-backlight",
236 .platform_data
= &zoom_backlight_data
,
240 static struct platform_device
*zoom_devices
[] __initdata
= {
246 static struct wl12xx_platform_data omap_zoom_wlan_data __initdata
= {
247 .board_ref_clock
= WL12XX_REFCLOCK_26
, /* 26 MHz */
250 static struct omap2_hsmmc_info mmc
[] = {
254 .caps
= MMC_CAP_4_BIT_DATA
,
256 .power_saving
= true,
262 .caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_8_BIT_DATA
,
265 .nonremovable
= true,
266 .power_saving
= true,
271 .caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_POWER_OFF_CARD
,
274 .nonremovable
= true,
279 static struct omap_tw4030_pdata omap_twl4030_audio_data
= {
280 .voice_connected
= true,
281 .custom_routing
= true,
283 .has_hs
= OMAP_TWL4030_LEFT
| OMAP_TWL4030_RIGHT
,
284 .has_hf
= OMAP_TWL4030_LEFT
| OMAP_TWL4030_RIGHT
,
289 .has_linein
= OMAP_TWL4030_LEFT
| OMAP_TWL4030_RIGHT
,
292 static int zoom_twl_gpio_setup(struct device
*dev
,
293 unsigned gpio
, unsigned ngpio
)
295 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
296 mmc
[0].gpio_cd
= gpio
+ 0;
297 omap_hsmmc_late_init(mmc
);
300 omap_twl4030_audio_data
.jack_detect
= gpio
+ 2;
301 omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data
);
306 static struct twl4030_gpio_platform_data zoom_gpio_data
= {
307 .setup
= zoom_twl_gpio_setup
,
310 static struct twl4030_platform_data zoom_twldata
= {
311 /* platform_data for children goes here */
312 .gpio
= &zoom_gpio_data
,
313 .keypad
= &zoom_kp_twl4030_data
,
314 .vmmc1
= &zoom_vmmc1
,
315 .vmmc2
= &zoom_vmmc2
,
319 static int __init
omap_i2c_init(void)
321 omap3_pmic_get_config(&zoom_twldata
,
322 TWL_COMMON_PDATA_USB
| TWL_COMMON_PDATA_BCI
|
323 TWL_COMMON_PDATA_MADC
| TWL_COMMON_PDATA_AUDIO
,
324 TWL_COMMON_REGULATOR_VDAC
| TWL_COMMON_REGULATOR_VPLL2
);
326 if (machine_is_omap_zoom2())
327 zoom_twldata
.audio
->codec
->ramp_delay_value
= 3; /* 161 ms */
329 omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START
, &zoom_twldata
);
330 omap_register_i2c_bus(2, 400, NULL
, 0);
331 omap_register_i2c_bus(3, 400, NULL
, 0);
335 static void enable_board_wakeup_source(void)
337 /* T2 interrupt line (keypad) */
338 omap_mux_init_signal("sys_nirq",
339 OMAP_WAKEUP_EN
| OMAP_PIN_INPUT_PULLUP
);
342 void __init
zoom_peripherals_init(void)
346 omap_zoom_wlan_data
.irq
= gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO
);
347 ret
= wl12xx_set_platform_data(&omap_zoom_wlan_data
);
350 pr_err("error setting wl12xx data: %d\n", ret
);
352 omap_hsmmc_init(mmc
);
354 pwm_add_table(zoom_pwm_lookup
, ARRAY_SIZE(zoom_pwm_lookup
));
355 platform_add_devices(zoom_devices
, ARRAY_SIZE(zoom_devices
));
356 usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
358 enable_board_wakeup_source();