blob: a21abb8593684fe9fb446eedf047375ec9653923 [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/gpio_event.h>
Pankaj Kumar6f841742011-10-10 15:52:14 +053016#include <linux/usb/android.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053017#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/gpio.h>
20#include <linux/mtd/nand.h>
21#include <linux/mtd/partitions.h>
22#include <linux/i2c.h>
23#include <linux/android_pmem.h>
24#include <linux/bootmem.h>
25#include <linux/mfd/marimba.h>
26#include <linux/power_supply.h>
Taniya Dasda408822011-09-06 12:54:06 +053027#include <linux/input/rmi_platformdata.h>
28#include <linux/input/rmi_i2c.h>
Pankaj Kumar3cec0582011-11-18 11:13:29 +053029#include <linux/regulator/consumer.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053030#include <asm/mach/mmc.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <mach/board.h>
34#include <mach/msm_iomap.h>
35#include <mach/msm_hsusb.h>
36#include <mach/rpc_hsusb.h>
37#include <mach/rpc_pmapp.h>
38#include <mach/usbdiag.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053039#include <mach/msm_memtypes.h>
40#include <mach/msm_serial_hs.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053041#include <mach/pmic.h>
42#include <mach/socinfo.h>
43#include <mach/vreg.h>
44#include <mach/rpc_pmapp.h>
45#include <mach/msm_battery.h>
46#include <mach/rpc_server_handset.h>
47#include <mach/socinfo.h>
Pankaj Kumar27c02642011-09-22 15:55:55 +053048#include "board-msm7x27a-regulator.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053049#include "devices.h"
50#include "devices-msm7x2xa.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080051#include <mach/pm.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053052#include "timer.h"
Murali Nalajalaa1827842011-11-13 14:12:39 +053053#include "pm-boot.h"
Pankaj Kumar3cec0582011-11-18 11:13:29 +053054#include "board-msm7x27a-regulator.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053055#include "board-msm7627a.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053056
57#define PMEM_KERNEL_EBI1_SIZE 0x3A000
58#define MSM_PMEM_AUDIO_SIZE 0x5B000
Taniya Dasc98bfbc2011-08-23 09:58:55 +053059#define BAHAMA_SLAVE_ID_FM_REG 0x02
60#define FM_GPIO 83
Rahul Kashyap8b4a7862011-12-13 18:40:54 +053061#define BT_PCM_BCLK_MODE 0x88
62#define BT_PCM_DIN_MODE 0x89
63#define BT_PCM_DOUT_MODE 0x8A
64#define BT_PCM_SYNC_MODE 0x8B
65#define FM_I2S_SD_MODE 0x8E
66#define FM_I2S_WS_MODE 0x8F
67#define FM_I2S_SCK_MODE 0x90
68#define I2C_PIN_CTL 0x15
69#define I2C_NORMAL 0x40
Taniya Dasc98bfbc2011-08-23 09:58:55 +053070
Taniya Dasc98bfbc2011-08-23 09:58:55 +053071static struct platform_device msm_wlan_ar6000_pm_device = {
72 .name = "wlan_ar6000_pm_dev",
73 .id = -1,
74};
75
Taniya Dasc98bfbc2011-08-23 09:58:55 +053076static struct msm_gpio qup_i2c_gpios_io[] = {
77 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
78 "qup_scl" },
79 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
80 "qup_sda" },
81 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
82 "qup_scl" },
83 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
84 "qup_sda" },
85};
86
87static struct msm_gpio qup_i2c_gpios_hw[] = {
88 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
89 "qup_scl" },
90 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
91 "qup_sda" },
92 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
93 "qup_scl" },
94 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
95 "qup_sda" },
96};
97
98static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
99{
100 int rc;
101
102 if (adap_id < 0 || adap_id > 1)
103 return;
104
105 /* Each adapter gets 2 lines from the table */
106 if (config_type)
107 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
108 else
109 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
110 if (rc < 0)
111 pr_err("QUP GPIO request/enable failed: %d\n", rc);
112}
113
114static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
115 .clk_freq = 100000,
116 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
117};
118
119static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
120 .clk_freq = 100000,
121 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
122};
123
124#ifdef CONFIG_ARCH_MSM7X27A
125#define MSM_PMEM_MDP_SIZE 0x1DD1000
126#define MSM_PMEM_ADSP_SIZE 0x1000000
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530127#endif
128
Taniya Dasda408822011-09-06 12:54:06 +0530129#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
130defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
131
132#ifndef CLEARPAD3000_ATTEN_GPIO
133#define CLEARPAD3000_ATTEN_GPIO (48)
134#endif
135
136#ifndef CLEARPAD3000_RESET_GPIO
137#define CLEARPAD3000_RESET_GPIO (26)
138#endif
139
140static int synaptics_touchpad_setup(void);
141
142static struct msm_gpio clearpad3000_cfg_data[] = {
143 {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
144 GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
145 {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
146 GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
147};
148
149static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
150static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
151static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
152static struct rmi_f11_functiondata synaptics_f11_data = {
153 .swap_axes = false,
154 .flipX = false,
155 .flipY = false,
156 .offset = &rmi_offset,
157 .button_height = 113,
158 .clipX = &rmi_clipx,
159 .clipY = &rmi_clipy,
160};
161
162#define MAX_LEN 100
163
164static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
165 struct kobj_attribute *attr, char *buf)
166{
167 char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
168 ":60:830:120:60" ":" __stringify(EV_KEY) \
169 ":" __stringify(KEY_HOME) ":180:830:120:60" \
170 ":" __stringify(EV_KEY) ":" \
171 __stringify(KEY_SEARCH) ":300:830:120:60" \
172 ":" __stringify(EV_KEY) ":" \
173 __stringify(KEY_BACK) ":420:830:120:60" "\n";
174
175 return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
176 virtual_keys);
177}
178
179static struct kobj_attribute clearpad3000_virtual_keys_attr = {
180 .attr = {
181 .name = "virtualkeys.sensor00fn11",
182 .mode = S_IRUGO,
183 },
184 .show = &clearpad3000_virtual_keys_register,
185};
186
187static struct attribute *virtual_key_properties_attrs[] = {
188 &clearpad3000_virtual_keys_attr.attr,
189 NULL
190};
191
192static struct attribute_group virtual_key_properties_attr_group = {
193 .attrs = virtual_key_properties_attrs,
194};
195
196struct kobject *virtual_key_properties_kobj;
197
198static struct rmi_functiondata synaptics_functiondata[] = {
199 {
200 .function_index = RMI_F11_INDEX,
201 .data = &synaptics_f11_data,
202 },
203};
204
205static struct rmi_functiondata_list synaptics_perfunctiondata = {
206 .count = ARRAY_SIZE(synaptics_functiondata),
207 .functiondata = synaptics_functiondata,
208};
209
210static struct rmi_sensordata synaptics_sensordata = {
211 .perfunctiondata = &synaptics_perfunctiondata,
212 .rmi_sensor_setup = synaptics_touchpad_setup,
213};
214
215static struct rmi_i2c_platformdata synaptics_platformdata = {
216 .i2c_address = 0x2c,
217 .irq_type = IORESOURCE_IRQ_LOWLEVEL,
218 .sensordata = &synaptics_sensordata,
219};
220
221static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
222 {
223 I2C_BOARD_INFO("rmi4_ts", 0x2c),
224 .platform_data = &synaptics_platformdata,
225 },
226};
227
228static int synaptics_touchpad_setup(void)
229{
230 int retval = 0;
231
232 virtual_key_properties_kobj =
233 kobject_create_and_add("board_properties", NULL);
234 if (virtual_key_properties_kobj)
235 retval = sysfs_create_group(virtual_key_properties_kobj,
236 &virtual_key_properties_attr_group);
237 if (!virtual_key_properties_kobj || retval)
238 pr_err("failed to create ft5202 board_properties\n");
239
240 retval = msm_gpios_request_enable(clearpad3000_cfg_data,
241 sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
242 if (retval) {
243 pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
244 __func__, CLEARPAD3000_ATTEN_GPIO, retval);
245 retval = 0; /* ignore the err */
246 }
247 synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
248
249 gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
250 usleep(10000);
251 gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
252 usleep(50000);
253
254 return retval;
255}
256#endif
257
258
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530259static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +0530260 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530261};
262
263static struct platform_device android_usb_device = {
264 .name = "android_usb",
265 .id = -1,
266 .dev = {
267 .platform_data = &android_usb_pdata,
268 },
269};
270
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530271#ifdef CONFIG_USB_EHCI_MSM_72K
272static void msm_hsusb_vbus_power(unsigned phy_info, int on)
273{
274 int rc = 0;
275 unsigned gpio;
276
Chintan Pandya40762702011-12-06 13:47:06 +0530277 gpio = QRD_GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530278
279 rc = gpio_request(gpio, "i2c_host_vbus_en");
280 if (rc < 0) {
281 pr_err("failed to request %d GPIO\n", gpio);
282 return;
283 }
284 gpio_direction_output(gpio, !!on);
285 gpio_set_value_cansleep(gpio, !!on);
286 gpio_free(gpio);
287}
288
289static struct msm_usb_host_platform_data msm_usb_host_pdata = {
290 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
291};
292
293static void __init msm7627a_init_host(void)
294{
295 msm_add_host(0, &msm_usb_host_pdata);
296}
297#endif
298
299#ifdef CONFIG_USB_MSM_OTG_72K
300static int hsusb_rpc_connect(int connect)
301{
302 if (connect)
303 return msm_hsusb_rpc_connect();
304 else
305 return msm_hsusb_rpc_close();
306}
307
Pankaj Kumar27c02642011-09-22 15:55:55 +0530308static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530309static int msm_hsusb_ldo_init(int init)
310{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530311 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530312
Pankaj Kumar27c02642011-09-22 15:55:55 +0530313 if (init) {
314 reg_hsusb = regulator_get(NULL, "usb");
315 if (IS_ERR(reg_hsusb)) {
316 rc = PTR_ERR(reg_hsusb);
317 pr_err("%s: could not get regulator: %d\n",
318 __func__, rc);
319 goto out;
320 }
321
322 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
323 if (rc) {
324 pr_err("%s: could not set voltage: %d\n",
325 __func__, rc);
326 goto reg_free;
327 }
328
329 return 0;
330 }
331 /* else fall through */
332reg_free:
333 regulator_put(reg_hsusb);
334out:
335 reg_hsusb = NULL;
336 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530337}
338
339static int msm_hsusb_ldo_enable(int enable)
340{
341 static int ldo_status;
342
Pankaj Kumar27c02642011-09-22 15:55:55 +0530343 if (IS_ERR_OR_NULL(reg_hsusb))
344 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530345
346 if (ldo_status == enable)
347 return 0;
348
349 ldo_status = enable;
350
Pankaj Kumar27c02642011-09-22 15:55:55 +0530351 return enable ?
352 regulator_enable(reg_hsusb) :
353 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530354}
355
356#ifndef CONFIG_USB_EHCI_MSM_72K
357static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
358{
359 int ret = 0;
360
361 if (init)
362 ret = msm_pm_app_rpc_init(callback);
363 else
364 msm_pm_app_rpc_deinit(callback);
365
366 return ret;
367}
368#endif
369
370static struct msm_otg_platform_data msm_otg_pdata = {
371#ifndef CONFIG_USB_EHCI_MSM_72K
372 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
373#else
374 .vbus_power = msm_hsusb_vbus_power,
375#endif
376 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530377 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
378 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
379 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
380 .se1_gating = SE1_GATING_DISABLE,
381 .ldo_init = msm_hsusb_ldo_init,
382 .ldo_enable = msm_hsusb_ldo_enable,
383 .chg_init = hsusb_chg_init,
384 .chg_connected = hsusb_chg_connected,
385 .chg_vbus_draw = hsusb_chg_vbus_draw,
386};
387#endif
388
389static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
390 .is_phy_status_timer_on = 1,
391};
392
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530393#ifdef CONFIG_SERIAL_MSM_HS
394static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
395 .inject_rx_on_wakeup = 1,
396 .rx_to_inject = 0xFD,
397};
398#endif
399static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
400 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
401 .idle_supported = 1,
402 .suspend_supported = 1,
403 .idle_enabled = 1,
404 .suspend_enabled = 1,
405 .latency = 16000,
406 .residency = 20000,
407 },
408 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
409 .idle_supported = 1,
410 .suspend_supported = 1,
411 .idle_enabled = 1,
412 .suspend_enabled = 1,
413 .latency = 12000,
414 .residency = 20000,
415 },
416 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
417 .idle_supported = 1,
418 .suspend_supported = 1,
419 .idle_enabled = 0,
420 .suspend_enabled = 1,
421 .latency = 2000,
422 .residency = 0,
423 },
424 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
425 .idle_supported = 1,
426 .suspend_supported = 1,
427 .idle_enabled = 1,
428 .suspend_enabled = 1,
429 .latency = 2,
430 .residency = 0,
431 },
432};
433
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600434static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530435 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
436 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600437};
438
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530439static struct android_pmem_platform_data android_pmem_adsp_pdata = {
440 .name = "pmem_adsp",
441 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
442 .cached = 1,
443 .memory_type = MEMTYPE_EBI1,
444};
445
446static struct platform_device android_pmem_adsp_device = {
447 .name = "android_pmem",
448 .id = 1,
449 .dev = { .platform_data = &android_pmem_adsp_pdata },
450};
451
452static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
453static int __init pmem_mdp_size_setup(char *p)
454{
455 pmem_mdp_size = memparse(p, NULL);
456 return 0;
457}
458
459early_param("pmem_mdp_size", pmem_mdp_size_setup);
460
461static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
462static int __init pmem_adsp_size_setup(char *p)
463{
464 pmem_adsp_size = memparse(p, NULL);
465 return 0;
466}
467
468early_param("pmem_adsp_size", pmem_adsp_size_setup);
469
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530470#define SND(desc, num) { .name = #desc, .id = num }
471static struct snd_endpoint snd_endpoints_list[] = {
472 SND(HANDSET, 0),
473 SND(MONO_HEADSET, 2),
474 SND(HEADSET, 3),
475 SND(SPEAKER, 6),
476 SND(TTY_HEADSET, 8),
477 SND(TTY_VCO, 9),
478 SND(TTY_HCO, 10),
479 SND(BT, 12),
480 SND(IN_S_SADC_OUT_HANDSET, 16),
481 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
482 SND(FM_DIGITAL_STEREO_HEADSET, 26),
483 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
484 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530485 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +0530486 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530487 SND(FM_ANALOG_STEREO_HEADSET, 35),
488 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
489};
490#undef SND
491
492static struct msm_snd_endpoints msm_device_snd_endpoints = {
493 .endpoints = snd_endpoints_list,
494 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
495};
496
497static struct platform_device msm_device_snd = {
498 .name = "msm_snd",
499 .id = -1,
500 .dev = {
501 .platform_data = &msm_device_snd_endpoints
502 },
503};
504
505#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
506 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
507 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
508 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
509 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
510 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
511#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
512 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
513 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
514 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
515 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
516 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
517#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
518 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
519 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
520 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
521 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
522 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
523#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
524 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
525 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
526 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
527 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
528 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
529#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
530
531static unsigned int dec_concurrency_table[] = {
532 /* Audio LP */
533 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
534 0, 0, 0,
535
536 /* Concurrency 1 */
537 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
538 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
539 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
540 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
541 (DEC4_FORMAT),
542
543 /* Concurrency 2 */
544 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
545 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
546 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
547 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
548 (DEC4_FORMAT),
549
550 /* Concurrency 3 */
551 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
552 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
553 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
554 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
555 (DEC4_FORMAT),
556
557 /* Concurrency 4 */
558 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
559 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
560 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
561 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
562 (DEC4_FORMAT),
563
564 /* Concurrency 5 */
565 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
566 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
567 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
568 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
569 (DEC4_FORMAT),
570
571 /* Concurrency 6 */
572 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
573 0, 0, 0, 0,
574
575 /* Concurrency 7 */
576 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
577 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
578 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
579 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
580 (DEC4_FORMAT),
581};
582
583#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
584 .module_queueid = queueid, .module_decid = decid, \
585 .nr_codec_support = nr_codec}
586
587static struct msm_adspdec_info dec_info_list[] = {
588 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
589 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
590 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
591 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
592 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
593};
594
595static struct msm_adspdec_database msm_device_adspdec_database = {
596 .num_dec = ARRAY_SIZE(dec_info_list),
597 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
598 ARRAY_SIZE(dec_info_list)),
599 .dec_concurrency_table = dec_concurrency_table,
600 .dec_info_list = dec_info_list,
601};
602
603static struct platform_device msm_device_adspdec = {
604 .name = "msm_adspdec",
605 .id = -1,
606 .dev = {
607 .platform_data = &msm_device_adspdec_database
608 },
609};
610
611static struct android_pmem_platform_data android_pmem_audio_pdata = {
612 .name = "pmem_audio",
613 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
614 .cached = 0,
615 .memory_type = MEMTYPE_EBI1,
616};
617
618static struct platform_device android_pmem_audio_device = {
619 .name = "android_pmem",
620 .id = 2,
621 .dev = { .platform_data = &android_pmem_audio_pdata },
622};
623
624static struct android_pmem_platform_data android_pmem_pdata = {
625 .name = "pmem",
626 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
627 .cached = 1,
628 .memory_type = MEMTYPE_EBI1,
629};
630static struct platform_device android_pmem_device = {
631 .name = "android_pmem",
632 .id = 0,
633 .dev = { .platform_data = &android_pmem_pdata },
634};
635
636static u32 msm_calculate_batt_capacity(u32 current_voltage);
637
638static struct msm_psy_batt_pdata msm_psy_batt_data = {
639 .voltage_min_design = 2800,
640 .voltage_max_design = 4300,
641 .avail_chg_sources = AC_CHG | USB_CHG ,
642 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
643 .calculate_capacity = &msm_calculate_batt_capacity,
644};
645
646static u32 msm_calculate_batt_capacity(u32 current_voltage)
647{
648 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
649 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
650
651 return (current_voltage - low_voltage) * 100
652 / (high_voltage - low_voltage);
653}
654
655static struct platform_device msm_batt_device = {
656 .name = "msm-battery",
657 .id = -1,
658 .dev.platform_data = &msm_psy_batt_data,
659};
660
Taniya Dasc868a2e2012-01-03 10:18:47 +0530661static struct platform_device *qrd_common_devices[] __initdata = {
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530662 &msm_device_dmov,
663 &msm_device_smd,
664 &msm_device_uart1,
665 &msm_device_uart_dm1,
666 &msm_gsbi0_qup_i2c_device,
667 &msm_gsbi1_qup_i2c_device,
668 &msm_device_otg,
669 &msm_device_gadget_peripheral,
670 &android_usb_device,
671 &android_pmem_device,
672 &android_pmem_adsp_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530673 &android_pmem_audio_device,
674 &msm_device_snd,
675 &msm_device_adspdec,
676 &msm_batt_device,
677 &msm_kgsl_3d0,
678#ifdef CONFIG_BT
679 &msm_bt_power_device,
680#endif
681 &msm_wlan_ar6000_pm_device,
682 &asoc_msm_pcm,
683 &asoc_msm_dai0,
684 &asoc_msm_dai1,
685};
686
687static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
688static int __init pmem_kernel_ebi1_size_setup(char *p)
689{
690 pmem_kernel_ebi1_size = memparse(p, NULL);
691 return 0;
692}
693early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
694
695static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
696static int __init pmem_audio_size_setup(char *p)
697{
698 pmem_audio_size = memparse(p, NULL);
699 return 0;
700}
701early_param("pmem_audio_size", pmem_audio_size_setup);
702
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530703static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
704 [MEMTYPE_SMI] = {
705 },
706 [MEMTYPE_EBI0] = {
707 .flags = MEMTYPE_FLAGS_1M_ALIGN,
708 },
709 [MEMTYPE_EBI1] = {
710 .flags = MEMTYPE_FLAGS_1M_ALIGN,
711 },
712};
713
714static void __init size_pmem_devices(void)
715{
716#ifdef CONFIG_ANDROID_PMEM
717 android_pmem_adsp_pdata.size = pmem_adsp_size;
718 android_pmem_pdata.size = pmem_mdp_size;
719 android_pmem_audio_pdata.size = pmem_audio_size;
720#endif
721}
722
723static void __init reserve_memory_for(struct android_pmem_platform_data *p)
724{
725 msm7627a_reserve_table[p->memory_type].size += p->size;
726}
727
728static void __init reserve_pmem_memory(void)
729{
730#ifdef CONFIG_ANDROID_PMEM
731 reserve_memory_for(&android_pmem_adsp_pdata);
732 reserve_memory_for(&android_pmem_pdata);
733 reserve_memory_for(&android_pmem_audio_pdata);
734 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
735#endif
736}
737
738static void __init msm7627a_calculate_reserve_sizes(void)
739{
740 size_pmem_devices();
741 reserve_pmem_memory();
742}
743
744static int msm7627a_paddr_to_memtype(unsigned int paddr)
745{
746 return MEMTYPE_EBI1;
747}
748
749static struct reserve_info msm7627a_reserve_info __initdata = {
750 .memtype_reserve_table = msm7627a_reserve_table,
751 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
752 .paddr_to_memtype = msm7627a_paddr_to_memtype,
753};
754
755static void __init msm7627a_reserve(void)
756{
757 reserve_info = &msm7627a_reserve_info;
758 msm_reserve();
759}
760
761static void __init msm_device_i2c_init(void)
762{
763 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
764 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
765}
766
767static struct msm_handset_platform_data hs_platform_data = {
768 .hs_name = "7k_handset",
769 .pwr_key_delay_ms = 500, /* 0 will disable end key */
770};
771
772static struct platform_device hs_pdev = {
773 .name = "msm-handset",
774 .id = -1,
775 .dev = {
776 .platform_data = &hs_platform_data,
777 },
778};
779
Pankaj Kumar3cec0582011-11-18 11:13:29 +0530780static struct platform_device msm_proccomm_regulator_dev = {
781 .name = PROCCOMM_REGULATOR_DEV_NAME,
782 .id = -1,
783 .dev = {
784 .platform_data = &msm7x27a_proccomm_regulator_data
785 }
786};
787
788static void __init msm7627a_init_regulators(void)
789{
790 int rc = platform_device_register(&msm_proccomm_regulator_dev);
791 if (rc)
792 pr_err("%s: could not register regulator device: %d\n",
793 __func__, rc);
794}
795
Taniya Dasc868a2e2012-01-03 10:18:47 +0530796static void msm7627a_add_io_devices(void)
797{
798 if (machine_is_msm7627a_evb())
799 return;
800
801#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
802 defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
803 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
804 synaptic_i2c_clearpad3k,
805 ARRAY_SIZE(synaptic_i2c_clearpad3k));
806#endif
807 platform_device_register(&hs_pdev);
808
809#ifdef CONFIG_MSM_RPC_VIBRATOR
810 msm_init_pmic_vibrator();
811#endif
812
813}
814
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530815#define UART1DM_RX_GPIO 45
Taniya Dasc868a2e2012-01-03 10:18:47 +0530816static void __init msm_qrd_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530817{
818 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +0530819 msm7627a_init_regulators();
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530820 msm_device_i2c_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530821#ifdef CONFIG_SERIAL_MSM_HS
822 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
823 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
824#endif
825
826#ifdef CONFIG_USB_MSM_OTG_72K
827 msm_otg_pdata.swfi_latency = msm7627a_pm_data
828 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
829 msm_device_otg.dev.platform_data = &msm_otg_pdata;
830#endif
831 msm_device_gadget_peripheral.dev.platform_data =
Taniya Das7a22cdd2011-09-08 14:57:00 +0530832 &msm_gadget_pdata;
Taniya Dasc868a2e2012-01-03 10:18:47 +0530833
834 platform_add_devices(qrd_common_devices,
835 ARRAY_SIZE(qrd_common_devices));
836
Chintan Pandyacf467fc2011-12-01 17:11:11 +0530837 msm7627a_init_mmc();
838
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530839#ifdef CONFIG_USB_EHCI_MSM_72K
840 msm7627a_init_host();
841#endif
842 msm_pm_set_platform_data(msm7627a_pm_data,
843 ARRAY_SIZE(msm7627a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600844 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajalaa1827842011-11-13 14:12:39 +0530845
Taniya Das0a5303a2011-08-23 18:47:48 +0530846 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530847
848#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +0530849 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530850#endif
Taniya Dasda408822011-09-06 12:54:06 +0530851
Chintan Pandya40762702011-12-06 13:47:06 +0530852 msm7627a_camera_init();
Taniya Das7a22cdd2011-09-08 14:57:00 +0530853
Taniya Dasc868a2e2012-01-03 10:18:47 +0530854 msm7627a_add_io_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530855}
856
857static void __init qrd7627a_init_early(void)
858{
859 msm_msm7627a_allocate_memory_regions();
860}
861
862MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
863 .boot_params = PHYS_OFFSET + 0x100,
864 .map_io = msm_common_io_init,
865 .reserve = msm7627a_reserve,
866 .init_irq = msm_init_irq,
Taniya Dasc868a2e2012-01-03 10:18:47 +0530867 .init_machine = msm_qrd_init,
868 .timer = &msm_timer,
869 .init_early = qrd7627a_init_early,
870 .handle_irq = vic_handle_irq,
871MACHINE_END
872MACHINE_START(MSM7627A_EVB, "QRD MSM7627a EVB")
873 .boot_params = PHYS_OFFSET + 0x100,
874 .map_io = msm_common_io_init,
875 .reserve = msm7627a_reserve,
876 .init_irq = msm_init_irq,
877 .init_machine = msm_qrd_init,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530878 .timer = &msm_timer,
879 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +0530880 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530881MACHINE_END