ARM: OMAP: Remove unused old gpio-switch.h
[deliverable/linux.git] / arch / arm / mach-omap2 / board-zoom-peripherals.c
CommitLineData
479f12c9 1/*
2 * Copyright (C) 2009 Texas Instruments Inc.
3 *
4 * Modified from mach-omap2/board-zoom2.c
5 *
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.
9 */
10
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>
ebeb53e1 17#include <linux/i2c/twl.h>
479f12c9 18#include <linux/regulator/machine.h>
b642fde7 19#include <linux/regulator/fixed.h>
80b517f3 20#include <linux/wl12xx.h>
3a63833e 21#include <linux/mmc/host.h>
4b25408f 22#include <linux/platform_data/gpio-omap.h>
479f12c9 23
24#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26#include <asm/mach/map.h>
27
4e65331c 28#include "common.h"
479f12c9 29#include <plat/usb.h>
7d7e1eba 30#include <plat/serial.h>
479f12c9 31
4b285c3f
JN
32#include <mach/board-zoom.h>
33
a1e63642 34#include "mux.h"
d02a900b 35#include "hsmmc.h"
fbd8071c 36#include "common-board-devices.h"
479f12c9 37
b642fde7 38#define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
80b517f3 39#define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
b642fde7 40
a6490335
K
41#define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES)
42
479f12c9 43/* Zoom2 has Qwerty keyboard*/
bead4375 44static uint32_t board_keymap[] = {
479f12c9 45 KEY(0, 0, KEY_E),
46 KEY(0, 1, KEY_R),
47 KEY(0, 2, KEY_T),
48 KEY(0, 3, KEY_HOME),
49 KEY(0, 6, KEY_I),
50 KEY(0, 7, KEY_LEFTSHIFT),
51 KEY(1, 0, KEY_D),
52 KEY(1, 1, KEY_F),
53 KEY(1, 2, KEY_G),
54 KEY(1, 3, KEY_SEND),
55 KEY(1, 6, KEY_K),
56 KEY(1, 7, KEY_ENTER),
57 KEY(2, 0, KEY_X),
58 KEY(2, 1, KEY_C),
59 KEY(2, 2, KEY_V),
60 KEY(2, 3, KEY_END),
61 KEY(2, 6, KEY_DOT),
62 KEY(2, 7, KEY_CAPSLOCK),
63 KEY(3, 0, KEY_Z),
64 KEY(3, 1, KEY_KPPLUS),
65 KEY(3, 2, KEY_B),
66 KEY(3, 3, KEY_F1),
67 KEY(3, 6, KEY_O),
68 KEY(3, 7, KEY_SPACE),
69 KEY(4, 0, KEY_W),
70 KEY(4, 1, KEY_Y),
71 KEY(4, 2, KEY_U),
72 KEY(4, 3, KEY_F2),
73 KEY(4, 4, KEY_VOLUMEUP),
74 KEY(4, 6, KEY_L),
75 KEY(4, 7, KEY_LEFT),
76 KEY(5, 0, KEY_S),
77 KEY(5, 1, KEY_H),
78 KEY(5, 2, KEY_J),
79 KEY(5, 3, KEY_F3),
6b06ebdf 80 KEY(5, 4, KEY_UNKNOWN),
479f12c9 81 KEY(5, 5, KEY_VOLUMEDOWN),
82 KEY(5, 6, KEY_M),
6b06ebdf 83 KEY(5, 7, KEY_RIGHT),
479f12c9 84 KEY(6, 0, KEY_Q),
85 KEY(6, 1, KEY_A),
86 KEY(6, 2, KEY_N),
87 KEY(6, 3, KEY_BACKSPACE),
88 KEY(6, 6, KEY_P),
6b06ebdf 89 KEY(6, 7, KEY_UP),
479f12c9 90 KEY(7, 0, KEY_PROG1), /*MACRO 1 <User defined> */
91 KEY(7, 1, KEY_PROG2), /*MACRO 2 <User defined> */
92 KEY(7, 2, KEY_PROG3), /*MACRO 3 <User defined> */
93 KEY(7, 3, KEY_PROG4), /*MACRO 4 <User defined> */
6b06ebdf 94 KEY(7, 6, KEY_SELECT),
479f12c9 95 KEY(7, 7, KEY_DOWN)
96};
97
98static struct matrix_keymap_data board_map_data = {
99 .keymap = board_keymap,
100 .keymap_size = ARRAY_SIZE(board_keymap),
101};
102
62d0b336 103static struct twl4030_keypad_data zoom_kp_twl4030_data = {
479f12c9 104 .keymap_data = &board_map_data,
105 .rows = 8,
106 .cols = 8,
107 .rep = 1,
108};
109
786b01a8
OD
110static struct regulator_consumer_supply zoom_vmmc1_supply[] = {
111 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
479f12c9 112};
113
786b01a8
OD
114static struct regulator_consumer_supply zoom_vsim_supply[] = {
115 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
479f12c9 116};
117
786b01a8
OD
118static struct regulator_consumer_supply zoom_vmmc2_supply[] = {
119 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
479f12c9 120};
121
786b01a8
OD
122static struct regulator_consumer_supply zoom_vmmc3_supply[] = {
123 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
b642fde7
OBC
124};
125
479f12c9 126/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
62d0b336 127static struct regulator_init_data zoom_vmmc1 = {
479f12c9 128 .constraints = {
129 .min_uV = 1850000,
130 .max_uV = 3150000,
131 .valid_modes_mask = REGULATOR_MODE_NORMAL
132 | REGULATOR_MODE_STANDBY,
133 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
134 | REGULATOR_CHANGE_MODE
135 | REGULATOR_CHANGE_STATUS,
136 },
786b01a8
OD
137 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc1_supply),
138 .consumer_supplies = zoom_vmmc1_supply,
479f12c9 139};
140
141/* VMMC2 for MMC2 card */
62d0b336 142static struct regulator_init_data zoom_vmmc2 = {
479f12c9 143 .constraints = {
144 .min_uV = 1850000,
145 .max_uV = 1850000,
146 .apply_uV = true,
147 .valid_modes_mask = REGULATOR_MODE_NORMAL
148 | REGULATOR_MODE_STANDBY,
149 .valid_ops_mask = REGULATOR_CHANGE_MODE
150 | REGULATOR_CHANGE_STATUS,
151 },
786b01a8
OD
152 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc2_supply),
153 .consumer_supplies = zoom_vmmc2_supply,
479f12c9 154};
155
156/* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
62d0b336 157static struct regulator_init_data zoom_vsim = {
479f12c9 158 .constraints = {
159 .min_uV = 1800000,
160 .max_uV = 3000000,
161 .valid_modes_mask = REGULATOR_MODE_NORMAL
162 | REGULATOR_MODE_STANDBY,
163 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
164 | REGULATOR_CHANGE_MODE
165 | REGULATOR_CHANGE_STATUS,
166 },
786b01a8
OD
167 .num_consumer_supplies = ARRAY_SIZE(zoom_vsim_supply),
168 .consumer_supplies = zoom_vsim_supply,
479f12c9 169};
170
b642fde7
OBC
171static struct regulator_init_data zoom_vmmc3 = {
172 .constraints = {
173 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
174 },
786b01a8
OD
175 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc3_supply),
176 .consumer_supplies = zoom_vmmc3_supply,
b642fde7
OBC
177};
178
179static struct fixed_voltage_config zoom_vwlan = {
180 .supply_name = "vwl1271",
181 .microvolts = 1800000, /* 1.8V */
182 .gpio = OMAP_ZOOM_WLAN_PMENA_GPIO,
183 .startup_delay = 70000, /* 70msec */
184 .enable_high = 1,
185 .enabled_at_boot = 0,
186 .init_data = &zoom_vmmc3,
187};
188
189static struct platform_device omap_vwlan_device = {
190 .name = "reg-fixed-voltage",
191 .id = 1,
192 .dev = {
193 .platform_data = &zoom_vwlan,
194 },
195};
196
0ce3bb72 197static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
80b517f3
OBC
198 /* ZOOM ref clock is 26 MHz */
199 .board_ref_clock = 1,
200};
201
1a6b5923 202static struct omap2_hsmmc_info mmc[] = {
479f12c9 203 {
ed32350d 204 .name = "external",
479f12c9 205 .mmc = 1,
3a63833e 206 .caps = MMC_CAP_4_BIT_DATA,
479f12c9 207 .gpio_wp = -EINVAL,
ed32350d 208 .power_saving = true,
3b972bf0 209 .deferred = true,
479f12c9 210 },
211 {
ed32350d 212 .name = "internal",
479f12c9 213 .mmc = 2,
3a63833e 214 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
ed32350d 215 .gpio_cd = -EINVAL,
479f12c9 216 .gpio_wp = -EINVAL,
ed32350d
MC
217 .nonremovable = true,
218 .power_saving = true,
479f12c9 219 },
80b517f3
OBC
220 {
221 .name = "wl1271",
222 .mmc = 3,
f8110364 223 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
80b517f3
OBC
224 .gpio_wp = -EINVAL,
225 .gpio_cd = -EINVAL,
226 .nonremovable = true,
227 },
479f12c9 228 {} /* Terminator */
229};
230
62d0b336 231static int zoom_twl_gpio_setup(struct device *dev,
479f12c9 232 unsigned gpio, unsigned ngpio)
233{
a6490335
K
234 int ret;
235
ed32350d 236 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
479f12c9 237 mmc[0].gpio_cd = gpio + 0;
3b972bf0 238 omap_hsmmc_late_init(mmc);
479f12c9 239
bc593f5d
IG
240 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW,
241 "lcd enable");
242 if (ret)
a6490335
K
243 pr_err("Failed to get LCD_PANEL_ENABLE_GPIO (gpio%d).\n",
244 LCD_PANEL_ENABLE_GPIO);
a6490335
K
245
246 return ret;
479f12c9 247}
248
4b285c3f 249/* EXTMUTE callback function */
0ce3bb72 250static void zoom2_set_hs_extmute(int mute)
4b285c3f
JN
251{
252 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
253}
479f12c9 254
62d0b336 255static struct twl4030_gpio_platform_data zoom_gpio_data = {
62d0b336 256 .setup = zoom_twl_gpio_setup,
479f12c9 257};
258
62d0b336 259static struct twl4030_platform_data zoom_twldata = {
479f12c9 260 /* platform_data for children goes here */
62d0b336 261 .gpio = &zoom_gpio_data,
262 .keypad = &zoom_kp_twl4030_data,
aed79bce 263 .vmmc1 = &zoom_vmmc1,
62d0b336 264 .vmmc2 = &zoom_vmmc2,
265 .vsim = &zoom_vsim,
479f12c9 266};
267
479f12c9 268static int __init omap_i2c_init(void)
269{
827ed9ae 270 omap3_pmic_get_config(&zoom_twldata,
b252b0ef
PU
271 TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_BCI |
272 TWL_COMMON_PDATA_MADC | TWL_COMMON_PDATA_AUDIO,
273 TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
827ed9ae 274
4b285c3f 275 if (machine_is_omap_zoom2()) {
4ae6df5e
PU
276 struct twl4030_codec_data *codec_data;
277 codec_data = zoom_twldata.audio->codec;
827ed9ae 278
4ae6df5e
PU
279 codec_data->ramp_delay_value = 3; /* 161 ms */
280 codec_data->hs_extmute = 1;
281 codec_data->set_hs_extmute = zoom2_set_hs_extmute;
4b285c3f 282 }
7d7e1eba 283 omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START, &zoom_twldata);
479f12c9 284 omap_register_i2c_bus(2, 400, NULL, 0);
285 omap_register_i2c_bus(3, 400, NULL, 0);
286 return 0;
287}
288
a1e63642
L
289static void enable_board_wakeup_source(void)
290{
291 /* T2 interrupt line (keypad) */
292 omap_mux_init_signal("sys_nirq",
293 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
294}
295
479f12c9 296void __init zoom_peripherals_init(void)
297{
46a0a540
TKD
298 int ret;
299
300 omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
301 ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
70d669de
RK
302
303 if (ret)
304 pr_err("error setting wl12xx data: %d\n", ret);
80b517f3 305
3b972bf0 306 omap_hsmmc_init(mmc);
479f12c9 307 omap_i2c_init();
b642fde7 308 platform_device_register(&omap_vwlan_device);
9e18630b 309 usb_musb_init(NULL);
a1e63642 310 enable_board_wakeup_source();
257f23d8 311 omap_serial_init();
479f12c9 312}
This page took 0.169132 seconds and 5 git commands to generate.