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>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
30 #include <mach/board-zoom.h>
34 #include "common-board-devices.h"
36 #define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
37 #define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
39 #define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES)
41 /* Zoom2 has Qwerty keyboard*/
42 static uint32_t board_keymap
[] = {
48 KEY(0, 7, KEY_LEFTSHIFT
),
60 KEY(2, 7, KEY_CAPSLOCK
),
62 KEY(3, 1, KEY_KPPLUS
),
71 KEY(4, 4, KEY_VOLUMEUP
),
78 KEY(5, 4, KEY_UNKNOWN
),
79 KEY(5, 5, KEY_VOLUMEDOWN
),
85 KEY(6, 3, KEY_BACKSPACE
),
88 KEY(7, 0, KEY_PROG1
), /*MACRO 1 <User defined> */
89 KEY(7, 1, KEY_PROG2
), /*MACRO 2 <User defined> */
90 KEY(7, 2, KEY_PROG3
), /*MACRO 3 <User defined> */
91 KEY(7, 3, KEY_PROG4
), /*MACRO 4 <User defined> */
92 KEY(7, 6, KEY_SELECT
),
96 static struct matrix_keymap_data board_map_data
= {
97 .keymap
= board_keymap
,
98 .keymap_size
= ARRAY_SIZE(board_keymap
),
101 static struct twl4030_keypad_data zoom_kp_twl4030_data
= {
102 .keymap_data
= &board_map_data
,
108 static struct regulator_consumer_supply zoom_vmmc1_supply
[] = {
109 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
112 static struct regulator_consumer_supply zoom_vsim_supply
[] = {
113 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
116 static struct regulator_consumer_supply zoom_vmmc2_supply
[] = {
117 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
120 static struct regulator_consumer_supply zoom_vmmc3_supply
[] = {
121 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
124 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
125 static struct regulator_init_data zoom_vmmc1
= {
129 .valid_modes_mask
= REGULATOR_MODE_NORMAL
130 | REGULATOR_MODE_STANDBY
,
131 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
132 | REGULATOR_CHANGE_MODE
133 | REGULATOR_CHANGE_STATUS
,
135 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc1_supply
),
136 .consumer_supplies
= zoom_vmmc1_supply
,
139 /* VMMC2 for MMC2 card */
140 static struct regulator_init_data zoom_vmmc2
= {
145 .valid_modes_mask
= REGULATOR_MODE_NORMAL
146 | REGULATOR_MODE_STANDBY
,
147 .valid_ops_mask
= REGULATOR_CHANGE_MODE
148 | REGULATOR_CHANGE_STATUS
,
150 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc2_supply
),
151 .consumer_supplies
= zoom_vmmc2_supply
,
154 /* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
155 static struct regulator_init_data zoom_vsim
= {
159 .valid_modes_mask
= REGULATOR_MODE_NORMAL
160 | REGULATOR_MODE_STANDBY
,
161 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
162 | REGULATOR_CHANGE_MODE
163 | REGULATOR_CHANGE_STATUS
,
165 .num_consumer_supplies
= ARRAY_SIZE(zoom_vsim_supply
),
166 .consumer_supplies
= zoom_vsim_supply
,
169 static struct regulator_init_data zoom_vmmc3
= {
171 .valid_ops_mask
= REGULATOR_CHANGE_STATUS
,
173 .num_consumer_supplies
= ARRAY_SIZE(zoom_vmmc3_supply
),
174 .consumer_supplies
= zoom_vmmc3_supply
,
177 static struct fixed_voltage_config zoom_vwlan
= {
178 .supply_name
= "vwl1271",
179 .microvolts
= 1800000, /* 1.8V */
180 .gpio
= OMAP_ZOOM_WLAN_PMENA_GPIO
,
181 .startup_delay
= 70000, /* 70msec */
183 .enabled_at_boot
= 0,
184 .init_data
= &zoom_vmmc3
,
187 static struct platform_device omap_vwlan_device
= {
188 .name
= "reg-fixed-voltage",
191 .platform_data
= &zoom_vwlan
,
195 static struct wl12xx_platform_data omap_zoom_wlan_data __initdata
= {
196 .irq
= OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO
),
197 /* ZOOM ref clock is 26 MHz */
198 .board_ref_clock
= 1,
201 static struct omap2_hsmmc_info mmc
[] = {
205 .caps
= MMC_CAP_4_BIT_DATA
,
207 .power_saving
= true,
212 .caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_8_BIT_DATA
,
215 .nonremovable
= true,
216 .power_saving
= true,
221 .caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_POWER_OFF_CARD
,
224 .nonremovable
= true,
229 static int zoom_twl_gpio_setup(struct device
*dev
,
230 unsigned gpio
, unsigned ngpio
)
234 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
235 mmc
[0].gpio_cd
= gpio
+ 0;
236 omap2_hsmmc_init(mmc
);
238 ret
= gpio_request_one(LCD_PANEL_ENABLE_GPIO
, GPIOF_OUT_INIT_LOW
,
241 pr_err("Failed to get LCD_PANEL_ENABLE_GPIO (gpio%d).\n",
242 LCD_PANEL_ENABLE_GPIO
);
247 /* EXTMUTE callback function */
248 static void zoom2_set_hs_extmute(int mute
)
250 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO
, mute
);
253 static struct twl4030_gpio_platform_data zoom_gpio_data
= {
254 .gpio_base
= OMAP_MAX_GPIO_LINES
,
255 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
256 .irq_end
= TWL4030_GPIO_IRQ_END
,
257 .setup
= zoom_twl_gpio_setup
,
260 static struct twl4030_platform_data zoom_twldata
= {
261 /* platform_data for children goes here */
262 .gpio
= &zoom_gpio_data
,
263 .keypad
= &zoom_kp_twl4030_data
,
264 .vmmc1
= &zoom_vmmc1
,
265 .vmmc2
= &zoom_vmmc2
,
269 static int __init
omap_i2c_init(void)
271 omap3_pmic_get_config(&zoom_twldata
,
272 TWL_COMMON_PDATA_USB
| TWL_COMMON_PDATA_BCI
|
273 TWL_COMMON_PDATA_MADC
| TWL_COMMON_PDATA_AUDIO
,
274 TWL_COMMON_REGULATOR_VDAC
| TWL_COMMON_REGULATOR_VPLL2
);
276 if (machine_is_omap_zoom2()) {
277 struct twl4030_codec_data
*codec_data
;
278 codec_data
= zoom_twldata
.audio
->codec
;
280 codec_data
->ramp_delay_value
= 3; /* 161 ms */
281 codec_data
->hs_extmute
= 1;
282 codec_data
->set_hs_extmute
= zoom2_set_hs_extmute
;
284 omap_pmic_init(1, 2400, "twl5030", INT_34XX_SYS_NIRQ
, &zoom_twldata
);
285 omap_register_i2c_bus(2, 400, NULL
, 0);
286 omap_register_i2c_bus(3, 400, NULL
, 0);
290 static void enable_board_wakeup_source(void)
292 /* T2 interrupt line (keypad) */
293 omap_mux_init_signal("sys_nirq",
294 OMAP_WAKEUP_EN
| OMAP_PIN_INPUT_PULLUP
);
297 void __init
zoom_peripherals_init(void)
299 int ret
= wl12xx_set_platform_data(&omap_zoom_wlan_data
);
302 pr_err("error setting wl12xx data: %d\n", ret
);
305 platform_device_register(&omap_vwlan_device
);
307 enable_board_wakeup_source();