blob: 8d7ce11cfeaf14b34d18c5ac4945a855b51f0d2d [file] [log] [blame]
vikram pandita479f12c2009-11-22 10:11:30 -08001/*
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>
Balaji T Kebeb53e2009-12-15 20:09:02 +053017#include <linux/i2c/twl.h>
vikram pandita479f12c2009-11-22 10:11:30 -080018#include <linux/regulator/machine.h>
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +020019#include <linux/regulator/fixed.h>
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +020020#include <linux/wl12xx.h>
Sukumar Ghorai3a638332010-09-15 14:49:23 +000021#include <linux/mmc/host.h>
vikram pandita479f12c2009-11-22 10:11:30 -080022
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
26
Tony Lindgren4e653312011-11-10 22:45:17 +010027#include "common.h"
vikram pandita479f12c2009-11-22 10:11:30 -080028#include <plat/usb.h>
29
Jarkko Nikula4b285c32010-09-23 19:11:54 +030030#include <mach/board-zoom.h>
31
Lesly A Ma1e63642010-02-15 10:03:35 -080032#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080033#include "hsmmc.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030034#include "common-board-devices.h"
vikram pandita479f12c2009-11-22 10:11:30 -080035
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +020036#define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +020037#define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +020038
Kishore Ya6490332010-11-15 07:09:03 +010039#define LCD_PANEL_ENABLE_GPIO (7 + OMAP_MAX_GPIO_LINES)
40
vikram pandita479f12c2009-11-22 10:11:30 -080041/* Zoom2 has Qwerty keyboard*/
Manjunath Kondaiah Gbead4372010-10-08 10:01:13 -070042static uint32_t board_keymap[] = {
vikram pandita479f12c2009-11-22 10:11:30 -080043 KEY(0, 0, KEY_E),
44 KEY(0, 1, KEY_R),
45 KEY(0, 2, KEY_T),
46 KEY(0, 3, KEY_HOME),
47 KEY(0, 6, KEY_I),
48 KEY(0, 7, KEY_LEFTSHIFT),
49 KEY(1, 0, KEY_D),
50 KEY(1, 1, KEY_F),
51 KEY(1, 2, KEY_G),
52 KEY(1, 3, KEY_SEND),
53 KEY(1, 6, KEY_K),
54 KEY(1, 7, KEY_ENTER),
55 KEY(2, 0, KEY_X),
56 KEY(2, 1, KEY_C),
57 KEY(2, 2, KEY_V),
58 KEY(2, 3, KEY_END),
59 KEY(2, 6, KEY_DOT),
60 KEY(2, 7, KEY_CAPSLOCK),
61 KEY(3, 0, KEY_Z),
62 KEY(3, 1, KEY_KPPLUS),
63 KEY(3, 2, KEY_B),
64 KEY(3, 3, KEY_F1),
65 KEY(3, 6, KEY_O),
66 KEY(3, 7, KEY_SPACE),
67 KEY(4, 0, KEY_W),
68 KEY(4, 1, KEY_Y),
69 KEY(4, 2, KEY_U),
70 KEY(4, 3, KEY_F2),
71 KEY(4, 4, KEY_VOLUMEUP),
72 KEY(4, 6, KEY_L),
73 KEY(4, 7, KEY_LEFT),
74 KEY(5, 0, KEY_S),
75 KEY(5, 1, KEY_H),
76 KEY(5, 2, KEY_J),
77 KEY(5, 3, KEY_F3),
Vimal Singh6b06ebd2010-01-08 10:29:07 -080078 KEY(5, 4, KEY_UNKNOWN),
vikram pandita479f12c2009-11-22 10:11:30 -080079 KEY(5, 5, KEY_VOLUMEDOWN),
80 KEY(5, 6, KEY_M),
Vimal Singh6b06ebd2010-01-08 10:29:07 -080081 KEY(5, 7, KEY_RIGHT),
vikram pandita479f12c2009-11-22 10:11:30 -080082 KEY(6, 0, KEY_Q),
83 KEY(6, 1, KEY_A),
84 KEY(6, 2, KEY_N),
85 KEY(6, 3, KEY_BACKSPACE),
86 KEY(6, 6, KEY_P),
Vimal Singh6b06ebd2010-01-08 10:29:07 -080087 KEY(6, 7, KEY_UP),
vikram pandita479f12c2009-11-22 10:11:30 -080088 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> */
Vimal Singh6b06ebd2010-01-08 10:29:07 -080092 KEY(7, 6, KEY_SELECT),
vikram pandita479f12c2009-11-22 10:11:30 -080093 KEY(7, 7, KEY_DOWN)
94};
95
96static struct matrix_keymap_data board_map_data = {
97 .keymap = board_keymap,
98 .keymap_size = ARRAY_SIZE(board_keymap),
99};
100
vikram pandita62d0b3362009-11-22 10:11:31 -0800101static struct twl4030_keypad_data zoom_kp_twl4030_data = {
vikram pandita479f12c2009-11-22 10:11:30 -0800102 .keymap_data = &board_map_data,
103 .rows = 8,
104 .cols = 8,
105 .rep = 1,
106};
107
Oleg Drokin786b01a2011-06-06 18:57:07 +0000108static struct regulator_consumer_supply zoom_vmmc1_supply[] = {
109 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
vikram pandita479f12c2009-11-22 10:11:30 -0800110};
111
Oleg Drokin786b01a2011-06-06 18:57:07 +0000112static struct regulator_consumer_supply zoom_vsim_supply[] = {
113 REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
vikram pandita479f12c2009-11-22 10:11:30 -0800114};
115
Oleg Drokin786b01a2011-06-06 18:57:07 +0000116static struct regulator_consumer_supply zoom_vmmc2_supply[] = {
117 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
vikram pandita479f12c2009-11-22 10:11:30 -0800118};
119
Oleg Drokin786b01a2011-06-06 18:57:07 +0000120static struct regulator_consumer_supply zoom_vmmc3_supply[] = {
121 REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"),
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +0200122};
123
vikram pandita479f12c2009-11-22 10:11:30 -0800124/* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
vikram pandita62d0b3362009-11-22 10:11:31 -0800125static struct regulator_init_data zoom_vmmc1 = {
vikram pandita479f12c2009-11-22 10:11:30 -0800126 .constraints = {
127 .min_uV = 1850000,
128 .max_uV = 3150000,
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,
134 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000135 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc1_supply),
136 .consumer_supplies = zoom_vmmc1_supply,
vikram pandita479f12c2009-11-22 10:11:30 -0800137};
138
139/* VMMC2 for MMC2 card */
vikram pandita62d0b3362009-11-22 10:11:31 -0800140static struct regulator_init_data zoom_vmmc2 = {
vikram pandita479f12c2009-11-22 10:11:30 -0800141 .constraints = {
142 .min_uV = 1850000,
143 .max_uV = 1850000,
144 .apply_uV = true,
145 .valid_modes_mask = REGULATOR_MODE_NORMAL
146 | REGULATOR_MODE_STANDBY,
147 .valid_ops_mask = REGULATOR_CHANGE_MODE
148 | REGULATOR_CHANGE_STATUS,
149 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000150 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc2_supply),
151 .consumer_supplies = zoom_vmmc2_supply,
vikram pandita479f12c2009-11-22 10:11:30 -0800152};
153
154/* VSIM for OMAP VDD_MMC1A (i/o for DAT4..DAT7) */
vikram pandita62d0b3362009-11-22 10:11:31 -0800155static struct regulator_init_data zoom_vsim = {
vikram pandita479f12c2009-11-22 10:11:30 -0800156 .constraints = {
157 .min_uV = 1800000,
158 .max_uV = 3000000,
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,
164 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000165 .num_consumer_supplies = ARRAY_SIZE(zoom_vsim_supply),
166 .consumer_supplies = zoom_vsim_supply,
vikram pandita479f12c2009-11-22 10:11:30 -0800167};
168
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +0200169static struct regulator_init_data zoom_vmmc3 = {
170 .constraints = {
171 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
172 },
Oleg Drokin786b01a2011-06-06 18:57:07 +0000173 .num_consumer_supplies = ARRAY_SIZE(zoom_vmmc3_supply),
174 .consumer_supplies = zoom_vmmc3_supply,
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +0200175};
176
177static 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 */
182 .enable_high = 1,
183 .enabled_at_boot = 0,
184 .init_data = &zoom_vmmc3,
185};
186
187static struct platform_device omap_vwlan_device = {
188 .name = "reg-fixed-voltage",
189 .id = 1,
190 .dev = {
191 .platform_data = &zoom_vwlan,
192 },
193};
194
Nishanth Menon0ce3bb72011-01-06 19:49:29 -0800195static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200196 .irq = OMAP_GPIO_IRQ(OMAP_ZOOM_WLAN_IRQ_GPIO),
197 /* ZOOM ref clock is 26 MHz */
198 .board_ref_clock = 1,
199};
200
Bryan Wu1a6b5922010-12-08 02:41:25 +0000201static struct omap2_hsmmc_info mmc[] = {
vikram pandita479f12c2009-11-22 10:11:30 -0800202 {
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800203 .name = "external",
vikram pandita479f12c2009-11-22 10:11:30 -0800204 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000205 .caps = MMC_CAP_4_BIT_DATA,
vikram pandita479f12c2009-11-22 10:11:30 -0800206 .gpio_wp = -EINVAL,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800207 .power_saving = true,
vikram pandita479f12c2009-11-22 10:11:30 -0800208 },
209 {
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800210 .name = "internal",
vikram pandita479f12c2009-11-22 10:11:30 -0800211 .mmc = 2,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000212 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800213 .gpio_cd = -EINVAL,
vikram pandita479f12c2009-11-22 10:11:30 -0800214 .gpio_wp = -EINVAL,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800215 .nonremovable = true,
216 .power_saving = true,
vikram pandita479f12c2009-11-22 10:11:30 -0800217 },
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200218 {
219 .name = "wl1271",
220 .mmc = 3,
Ohad Ben-Cohenf81103642010-11-26 23:59:24 +0000221 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200222 .gpio_wp = -EINVAL,
223 .gpio_cd = -EINVAL,
224 .nonremovable = true,
225 },
vikram pandita479f12c2009-11-22 10:11:30 -0800226 {} /* Terminator */
227};
228
vikram pandita62d0b3362009-11-22 10:11:31 -0800229static int zoom_twl_gpio_setup(struct device *dev,
vikram pandita479f12c2009-11-22 10:11:30 -0800230 unsigned gpio, unsigned ngpio)
231{
Kishore Ya6490332010-11-15 07:09:03 +0100232 int ret;
233
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800234 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
vikram pandita479f12c2009-11-22 10:11:30 -0800235 mmc[0].gpio_cd = gpio + 0;
Adrian Hunter68ff0422010-02-15 10:03:34 -0800236 omap2_hsmmc_init(mmc);
vikram pandita479f12c2009-11-22 10:11:30 -0800237
Igor Grinbergbc593f52011-05-03 18:22:09 +0300238 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW,
239 "lcd enable");
240 if (ret)
Kishore Ya6490332010-11-15 07:09:03 +0100241 pr_err("Failed to get LCD_PANEL_ENABLE_GPIO (gpio%d).\n",
242 LCD_PANEL_ENABLE_GPIO);
Kishore Ya6490332010-11-15 07:09:03 +0100243
244 return ret;
vikram pandita479f12c2009-11-22 10:11:30 -0800245}
246
Jarkko Nikula4b285c32010-09-23 19:11:54 +0300247/* EXTMUTE callback function */
Nishanth Menon0ce3bb72011-01-06 19:49:29 -0800248static void zoom2_set_hs_extmute(int mute)
Jarkko Nikula4b285c32010-09-23 19:11:54 +0300249{
250 gpio_set_value(ZOOM2_HEADSET_EXTMUTE_GPIO, mute);
251}
vikram pandita479f12c2009-11-22 10:11:30 -0800252
vikram pandita62d0b3362009-11-22 10:11:31 -0800253static struct twl4030_gpio_platform_data zoom_gpio_data = {
vikram pandita479f12c2009-11-22 10:11:30 -0800254 .gpio_base = OMAP_MAX_GPIO_LINES,
255 .irq_base = TWL4030_GPIO_IRQ_BASE,
256 .irq_end = TWL4030_GPIO_IRQ_END,
vikram pandita62d0b3362009-11-22 10:11:31 -0800257 .setup = zoom_twl_gpio_setup,
vikram pandita479f12c2009-11-22 10:11:30 -0800258};
259
vikram pandita62d0b3362009-11-22 10:11:31 -0800260static struct twl4030_platform_data zoom_twldata = {
vikram pandita479f12c2009-11-22 10:11:30 -0800261 /* platform_data for children goes here */
vikram pandita62d0b3362009-11-22 10:11:31 -0800262 .gpio = &zoom_gpio_data,
263 .keypad = &zoom_kp_twl4030_data,
Anand Gadiyaraed79bc2009-12-11 16:16:36 -0800264 .vmmc1 = &zoom_vmmc1,
vikram pandita62d0b3362009-11-22 10:11:31 -0800265 .vmmc2 = &zoom_vmmc2,
266 .vsim = &zoom_vsim,
vikram pandita479f12c2009-11-22 10:11:30 -0800267};
268
vikram pandita479f12c2009-11-22 10:11:30 -0800269static int __init omap_i2c_init(void)
270{
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300271 omap3_pmic_get_config(&zoom_twldata,
Peter Ujfalusib252b0e2011-06-07 11:38:24 +0300272 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);
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300275
Jarkko Nikula4b285c32010-09-23 19:11:54 +0300276 if (machine_is_omap_zoom2()) {
Peter Ujfalusi4ae6df52011-05-31 15:21:13 +0300277 struct twl4030_codec_data *codec_data;
278 codec_data = zoom_twldata.audio->codec;
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300279
Peter Ujfalusi4ae6df52011-05-31 15:21:13 +0300280 codec_data->ramp_delay_value = 3; /* 161 ms */
281 codec_data->hs_extmute = 1;
282 codec_data->set_hs_extmute = zoom2_set_hs_extmute;
Jarkko Nikula4b285c32010-09-23 19:11:54 +0300283 }
Mike Rapoportfbd80712011-04-25 01:09:06 +0300284 omap_pmic_init(1, 2400, "twl5030", INT_34XX_SYS_NIRQ, &zoom_twldata);
vikram pandita479f12c2009-11-22 10:11:30 -0800285 omap_register_i2c_bus(2, 400, NULL, 0);
286 omap_register_i2c_bus(3, 400, NULL, 0);
287 return 0;
288}
289
Lesly A Ma1e63642010-02-15 10:03:35 -0800290static void enable_board_wakeup_source(void)
291{
292 /* T2 interrupt line (keypad) */
293 omap_mux_init_signal("sys_nirq",
294 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
295}
296
vikram pandita479f12c2009-11-22 10:11:30 -0800297void __init zoom_peripherals_init(void)
298{
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200299 if (wl12xx_set_platform_data(&omap_zoom_wlan_data))
300 pr_err("error setting wl12xx data\n");
301
vikram pandita479f12c2009-11-22 10:11:30 -0800302 omap_i2c_init();
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +0200303 platform_device_register(&omap_vwlan_device);
Mike Rapoport9e186302011-04-27 11:56:12 +0300304 usb_musb_init(NULL);
Lesly A Ma1e63642010-02-15 10:03:35 -0800305 enable_board_wakeup_source();
Govindraj.R257f23d2010-09-27 20:21:05 +0530306 omap_serial_init();
vikram pandita479f12c2009-11-22 10:11:30 -0800307}