blob: 0745bd93f398daff6026a8b997c86eaa60626941 [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>
Tony Lindgren4b254082012-08-30 15:37:24 -070022#include <linux/platform_data/gpio-omap.h>
Peter Ujfalusic5913932012-12-05 15:39:35 +010023#include <linux/platform_data/omap-twl4030.h>
vikram pandita479f12c2009-11-22 10:11:30 -080024
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28
Tony Lindgren4e653312011-11-10 22:45:17 +010029#include "common.h"
vikram pandita479f12c2009-11-22 10:11:30 -080030
Tony Lindgren8599e7c2012-10-08 09:11:22 -070031#include "board-zoom.h"
Jarkko Nikula4b285c32010-09-23 19:11:54 +030032
Lesly A Ma1e63642010-02-15 10:03:35 -080033#include "mux.h"
Adrian Hunterd02a9002010-02-15 10:03:34 -080034#include "hsmmc.h"
Mike Rapoportfbd80712011-04-25 01:09:06 +030035#include "common-board-devices.h"
vikram pandita479f12c2009-11-22 10:11:30 -080036
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +020037#define OMAP_ZOOM_WLAN_PMENA_GPIO (101)
Peter Ujfalusi98b06062012-12-05 11:35:32 +010038#define OMAP_ZOOM_TSC2004_IRQ_GPIO (153)
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +020039#define OMAP_ZOOM_WLAN_IRQ_GPIO (162)
Ohad Ben-Cohenb642fde2010-09-16 01:32:09 +020040
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 = {
Vikram Narayanan224cd712012-09-26 22:12:22 +0530196 .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200197};
198
Bryan Wu1a6b5922010-12-08 02:41:25 +0000199static struct omap2_hsmmc_info mmc[] = {
vikram pandita479f12c2009-11-22 10:11:30 -0800200 {
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800201 .name = "external",
vikram pandita479f12c2009-11-22 10:11:30 -0800202 .mmc = 1,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000203 .caps = MMC_CAP_4_BIT_DATA,
vikram pandita479f12c2009-11-22 10:11:30 -0800204 .gpio_wp = -EINVAL,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800205 .power_saving = true,
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800206 .deferred = true,
vikram pandita479f12c2009-11-22 10:11:30 -0800207 },
208 {
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800209 .name = "internal",
vikram pandita479f12c2009-11-22 10:11:30 -0800210 .mmc = 2,
Sukumar Ghorai3a638332010-09-15 14:49:23 +0000211 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800212 .gpio_cd = -EINVAL,
vikram pandita479f12c2009-11-22 10:11:30 -0800213 .gpio_wp = -EINVAL,
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800214 .nonremovable = true,
215 .power_saving = true,
vikram pandita479f12c2009-11-22 10:11:30 -0800216 },
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200217 {
218 .name = "wl1271",
219 .mmc = 3,
Ohad Ben-Cohenf81103642010-11-26 23:59:24 +0000220 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200221 .gpio_wp = -EINVAL,
222 .gpio_cd = -EINVAL,
223 .nonremovable = true,
224 },
vikram pandita479f12c2009-11-22 10:11:30 -0800225 {} /* Terminator */
226};
227
Peter Ujfalusic5913932012-12-05 15:39:35 +0100228static struct omap_tw4030_pdata omap_twl4030_audio_data = {
229 .voice_connected = true,
230 .custom_routing = true,
231
232 .has_hs = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
233 .has_hf = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
234
235 .has_mainmic = true,
236 .has_submic = true,
237 .has_hsmic = true,
238 .has_linein = OMAP_TWL4030_LEFT | OMAP_TWL4030_RIGHT,
239};
240
vikram pandita62d0b3362009-11-22 10:11:31 -0800241static int zoom_twl_gpio_setup(struct device *dev,
vikram pandita479f12c2009-11-22 10:11:30 -0800242 unsigned gpio, unsigned ngpio)
243{
Madhusudhan Chikkatureed323502009-12-11 16:16:37 -0800244 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
vikram pandita479f12c2009-11-22 10:11:30 -0800245 mmc[0].gpio_cd = gpio + 0;
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800246 omap_hsmmc_late_init(mmc);
vikram pandita479f12c2009-11-22 10:11:30 -0800247
Peter Ujfalusic5913932012-12-05 15:39:35 +0100248 /* Audio setup */
249 omap_twl4030_audio_data.jack_detect = gpio + 2;
250 omap_twl4030_audio_init("Zoom2", &omap_twl4030_audio_data);
251
Peter Ujfalusie4f4e8b2012-11-30 14:40:51 +0100252 return 0;
vikram pandita479f12c2009-11-22 10:11:30 -0800253}
254
vikram pandita62d0b3362009-11-22 10:11:31 -0800255static struct twl4030_gpio_platform_data zoom_gpio_data = {
vikram pandita62d0b3362009-11-22 10:11:31 -0800256 .setup = zoom_twl_gpio_setup,
vikram pandita479f12c2009-11-22 10:11:30 -0800257};
258
vikram pandita62d0b3362009-11-22 10:11:31 -0800259static struct twl4030_platform_data zoom_twldata = {
vikram pandita479f12c2009-11-22 10:11:30 -0800260 /* platform_data for children goes here */
vikram pandita62d0b3362009-11-22 10:11:31 -0800261 .gpio = &zoom_gpio_data,
262 .keypad = &zoom_kp_twl4030_data,
Anand Gadiyaraed79bc2009-12-11 16:16:36 -0800263 .vmmc1 = &zoom_vmmc1,
vikram pandita62d0b3362009-11-22 10:11:31 -0800264 .vmmc2 = &zoom_vmmc2,
265 .vsim = &zoom_vsim,
vikram pandita479f12c2009-11-22 10:11:30 -0800266};
267
vikram pandita479f12c2009-11-22 10:11:30 -0800268static int __init omap_i2c_init(void)
269{
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300270 omap3_pmic_get_config(&zoom_twldata,
Peter Ujfalusib252b0e2011-06-07 11:38:24 +0300271 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);
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300274
Peter Ujfalusi98b06062012-12-05 11:35:32 +0100275 if (machine_is_omap_zoom2())
276 zoom_twldata.audio->codec->ramp_delay_value = 3; /* 161 ms */
Peter Ujfalusi827ed9a2011-06-07 10:28:54 +0300277
Tony Lindgren7d7e1eb2012-08-27 17:43:01 -0700278 omap_pmic_init(1, 2400, "twl5030", 7 + OMAP_INTC_START, &zoom_twldata);
vikram pandita479f12c2009-11-22 10:11:30 -0800279 omap_register_i2c_bus(2, 400, NULL, 0);
280 omap_register_i2c_bus(3, 400, NULL, 0);
281 return 0;
282}
283
Lesly A Ma1e63642010-02-15 10:03:35 -0800284static void enable_board_wakeup_source(void)
285{
286 /* T2 interrupt line (keypad) */
287 omap_mux_init_signal("sys_nirq",
288 OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
289}
290
vikram pandita479f12c2009-11-22 10:11:30 -0800291void __init zoom_peripherals_init(void)
292{
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -0700293 int ret;
294
295 omap_zoom_wlan_data.irq = gpio_to_irq(OMAP_ZOOM_WLAN_IRQ_GPIO);
296 ret = wl12xx_set_platform_data(&omap_zoom_wlan_data);
Russell King70d669d2012-02-07 11:03:23 +0000297
298 if (ret)
299 pr_err("error setting wl12xx data: %d\n", ret);
Ohad Ben-Cohen80b517f2010-09-16 01:32:30 +0200300
Tony Lindgren3b972bf2012-02-20 09:43:29 -0800301 omap_hsmmc_init(mmc);
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}