blob: fe2d2d2ed1e8da11302d6e8dd7176283ff00ca16 [file] [log] [blame]
Jay Chokshie8741282012-01-25 15:22:55 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -08002 *
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
14#include <linux/init.h>
15#include <linux/ioport.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070016#include <linux/gpio.h>
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -080017#include <linux/platform_device.h>
18#include <linux/bootmem.h>
Jay Chokshie8741282012-01-25 15:22:55 -080019#include <linux/mfd/pm8xxx/pm8921.h>
20#include <linux/leds.h>
21#include <linux/leds-pm8xxx.h>
Jay Chokshif3a9ea82012-01-12 16:34:43 -080022#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -080023#include <asm/mach-types.h>
24#include <asm/mach/mmc.h>
25#include <mach/msm_bus_board.h>
26#include <mach/board.h>
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -080027#include <mach/gpiomux.h>
Jay Chokshie8741282012-01-25 15:22:55 -080028#include <mach/restart.h>
David Collins793793b2012-08-21 15:43:02 -070029#include <mach/socinfo.h>
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -080030#include "devices.h"
31#include "board-8064.h"
32
Jay Chokshie8741282012-01-25 15:22:55 -080033struct pm8xxx_gpio_init {
34 unsigned gpio;
35 struct pm_gpio config;
36};
37
38struct pm8xxx_mpp_init {
39 unsigned mpp;
40 struct pm8xxx_mpp_config_data config;
41};
42
43#define PM8921_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
44 _func, _inv, _disable) \
45{ \
46 .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
47 .config = { \
48 .direction = _dir, \
49 .output_buffer = _buf, \
50 .output_value = _val, \
51 .pull = _pull, \
52 .vin_sel = _vin, \
53 .out_strength = _out_strength, \
54 .function = _func, \
55 .inv_int_pol = _inv, \
56 .disable_pin = _disable, \
57 } \
58}
59
60#define PM8921_MPP_INIT(_mpp, _type, _level, _control) \
61{ \
62 .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
63 .config = { \
64 .type = PM8XXX_MPP_TYPE_##_type, \
65 .level = _level, \
66 .control = PM8XXX_MPP_##_control, \
67 } \
68}
69
70#define PM8821_MPP_INIT(_mpp, _type, _level, _control) \
71{ \
72 .mpp = PM8821_MPP_PM_TO_SYS(_mpp), \
73 .config = { \
74 .type = PM8XXX_MPP_TYPE_##_type, \
75 .level = _level, \
76 .control = PM8XXX_MPP_##_control, \
77 } \
78}
79
80#define PM8921_GPIO_DISABLE(_gpio) \
81 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
82 0, 0, 0, 1)
83
84#define PM8921_GPIO_OUTPUT(_gpio, _val, _strength) \
85 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
86 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
87 PM_GPIO_STRENGTH_##_strength, \
88 PM_GPIO_FUNC_NORMAL, 0, 0)
89
Jay Chokshi1de4f9d2012-02-07 16:11:31 -080090#define PM8921_GPIO_OUTPUT_BUFCONF(_gpio, _val, _strength, _bufconf) \
91 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT,\
92 PM_GPIO_OUT_BUF_##_bufconf, _val, \
93 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
94 PM_GPIO_STRENGTH_##_strength, \
95 PM_GPIO_FUNC_NORMAL, 0, 0)
96
Jay Chokshie8741282012-01-25 15:22:55 -080097#define PM8921_GPIO_INPUT(_gpio, _pull) \
98 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
99 _pull, PM_GPIO_VIN_S4, \
100 PM_GPIO_STRENGTH_NO, \
101 PM_GPIO_FUNC_NORMAL, 0, 0)
102
103#define PM8921_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
104 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
105 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
106 PM_GPIO_STRENGTH_HIGH, \
107 _func, 0, 0)
108
109#define PM8921_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \
110 PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
111 PM_GPIO_PULL_NO, _vin, \
112 PM_GPIO_STRENGTH_HIGH, \
113 PM_GPIO_FUNC_NORMAL, 0, 0)
114
115/* Initial PM8921 GPIO configurations */
116static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
Aravind Venkateswaran0507c8c2012-02-16 17:16:05 -0800117 PM8921_GPIO_OUTPUT(14, 1, HIGH), /* HDMI Mux Selector */
Jay Chokshi1de4f9d2012-02-07 16:11:31 -0800118 PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */
119 PM8921_GPIO_OUTPUT_FUNC(26, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
David Keitel2f613d92012-02-15 11:29:16 -0800120 PM8921_GPIO_OUTPUT_VIN(30, 1, PM_GPIO_VIN_VPH), /* SMB349 susp line */
Jay Chokshi1de4f9d2012-02-07 16:11:31 -0800121 PM8921_GPIO_OUTPUT_BUFCONF(36, 1, LOW, OPEN_DRAIN),
Amy Maloche70090f992012-02-16 16:35:26 -0800122 PM8921_GPIO_OUTPUT_FUNC(44, 0, PM_GPIO_FUNC_2),
123 PM8921_GPIO_OUTPUT(33, 0, HIGH),
124 PM8921_GPIO_OUTPUT(20, 0, HIGH),
Anirudh Ghayal71478012012-03-08 17:54:23 -0800125 PM8921_GPIO_INPUT(35, PM_GPIO_PULL_UP_30),
126 PM8921_GPIO_INPUT(38, PM_GPIO_PULL_UP_30),
Shiv Maliyappanahalli7e0beff2012-02-06 15:56:39 -0800127 /* TABLA CODEC RESET */
Santosh Mardi0f81fcc2012-09-10 14:39:57 +0530128 PM8921_GPIO_OUTPUT(34, 1, HIGH),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600129 PM8921_GPIO_OUTPUT(13, 0, HIGH), /* PCIE_CLK_PWR_EN */
Niranjana Vishwanathapura459a27d2012-07-20 12:23:55 -0600130 PM8921_GPIO_INPUT(12, PM_GPIO_PULL_UP_30), /* PCIE_WAKE_N */
Mohan Pallaka474b94b2012-01-25 12:59:58 +0530131};
132
133static struct pm8xxx_gpio_init pm8921_mtp_kp_gpios[] __initdata = {
Anirudh Ghayal71478012012-03-08 17:54:23 -0800134 PM8921_GPIO_INPUT(3, PM_GPIO_PULL_UP_30),
135 PM8921_GPIO_INPUT(4, PM_GPIO_PULL_UP_30),
Mohan Pallaka474b94b2012-01-25 12:59:58 +0530136};
137
138static struct pm8xxx_gpio_init pm8921_cdp_kp_gpios[] __initdata = {
Anirudh Ghayal71478012012-03-08 17:54:23 -0800139 PM8921_GPIO_INPUT(27, PM_GPIO_PULL_UP_30),
140 PM8921_GPIO_INPUT(42, PM_GPIO_PULL_UP_30),
Oluwafemi Adeyemi48fc3262012-03-19 13:26:52 -0700141 PM8921_GPIO_INPUT(17, PM_GPIO_PULL_UP_1P5), /* SD_WP */
Jay Chokshie8741282012-01-25 15:22:55 -0800142};
143
Saket Saurabh54bd17a2012-09-11 17:00:46 +0530144static struct pm8xxx_gpio_init pm8921_mpq8064_hrd_gpios[] __initdata = {
145 PM8921_GPIO_OUTPUT(37, 0, LOW), /* MUX1_SEL */
Mohan Pallakab8aa8282012-10-04 14:26:21 +0530146 PM8921_GPIO_INPUT(40, PM_GPIO_PULL_UP_30), /* irq for sx150 exp2 */
Saket Saurabh54bd17a2012-09-11 17:00:46 +0530147};
148
David Collins03c16372012-10-04 15:57:28 -0700149static struct pm8xxx_gpio_init touchscreen_gpios[] __initdata = {
150 PM8921_GPIO_OUTPUT(23, 0, HIGH), /* touchscreen power FET */
151};
152
David Collinsd49a1c52012-08-22 13:18:06 -0700153/* Initial PM8917 GPIO configurations */
154static struct pm8xxx_gpio_init pm8917_gpios[] __initdata = {
155 PM8921_GPIO_OUTPUT(14, 1, HIGH), /* HDMI Mux Selector */
David Collinsd49a1c52012-08-22 13:18:06 -0700156 PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */
David Collinsd992d312012-08-22 13:59:23 -0700157 PM8921_GPIO_OUTPUT(26, 1, HIGH), /* Backlight: on */
David Collinsd49a1c52012-08-22 13:18:06 -0700158 PM8921_GPIO_OUTPUT_BUFCONF(36, 1, LOW, OPEN_DRAIN),
159 PM8921_GPIO_OUTPUT_FUNC(38, 0, PM_GPIO_FUNC_2),
160 PM8921_GPIO_OUTPUT(33, 0, HIGH),
161 PM8921_GPIO_OUTPUT(20, 0, HIGH),
162 PM8921_GPIO_INPUT(35, PM_GPIO_PULL_UP_30),
163 PM8921_GPIO_INPUT(30, PM_GPIO_PULL_UP_30),
164 /* TABLA CODEC RESET */
165 PM8921_GPIO_OUTPUT(34, 1, MED),
166 PM8921_GPIO_OUTPUT(13, 0, HIGH), /* PCIE_CLK_PWR_EN */
167 PM8921_GPIO_INPUT(12, PM_GPIO_PULL_UP_30), /* PCIE_WAKE_N */
168};
169
170/* PM8921 GPIO 42 remaps to PM8917 GPIO 8 */
171static struct pm8xxx_gpio_init pm8917_cdp_kp_gpios[] __initdata = {
172 PM8921_GPIO_INPUT(27, PM_GPIO_PULL_UP_30),
173 PM8921_GPIO_INPUT(8, PM_GPIO_PULL_UP_30),
174 PM8921_GPIO_INPUT(17, PM_GPIO_PULL_UP_1P5), /* SD_WP */
175};
176
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530177static struct pm8xxx_gpio_init pm8921_mpq_gpios[] __initdata = {
178 PM8921_GPIO_INIT(27, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0,
179 PM_GPIO_PULL_NO, PM_GPIO_VIN_VPH, PM_GPIO_STRENGTH_NO,
180 PM_GPIO_FUNC_NORMAL, 0, 0),
181};
182
Jay Chokshie8741282012-01-25 15:22:55 -0800183/* Initial PM8XXX MPP configurations */
184static struct pm8xxx_mpp_init pm8xxx_mpps[] __initdata = {
Jay Chokshi1de4f9d2012-02-07 16:11:31 -0800185 PM8921_MPP_INIT(3, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_LOW),
Jay Chokshi1de4f9d2012-02-07 16:11:31 -0800186 PM8921_MPP_INIT(8, D_OUTPUT, PM8921_MPP_DIG_LEVEL_S4, DOUT_CTRL_LOW),
Hemant Kumar56925352012-02-13 16:59:52 -0800187 /*MPP9 is used to detect docking station connection/removal on Liquid*/
188 PM8921_MPP_INIT(9, D_INPUT, PM8921_MPP_DIG_LEVEL_S4, DIN_TO_INT),
Niranjana Vishwanathapura06f89332012-05-03 17:11:13 -0600189 /* PCIE_RESET_N */
190 PM8921_MPP_INIT(1, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_HIGH),
Jay Chokshie8741282012-01-25 15:22:55 -0800191};
192
David Collinsd49a1c52012-08-22 13:18:06 -0700193
194void __init apq8064_configure_gpios(struct pm8xxx_gpio_init *data, int len)
195{
196 int i, rc;
197
198 for (i = 0; i < len; i++) {
199 rc = pm8xxx_gpio_config(data[i].gpio, &data[i].config);
200 if (rc)
201 pr_err("%s: pm8xxx_gpio_config(%u) failed: rc=%d\n",
202 __func__, data[i].gpio, rc);
203 }
204}
205
Jay Chokshie8741282012-01-25 15:22:55 -0800206void __init apq8064_pm8xxx_gpio_mpp_init(void)
207{
208 int i, rc;
209
David Collinsd49a1c52012-08-22 13:18:06 -0700210 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
211 apq8064_configure_gpios(pm8921_gpios, ARRAY_SIZE(pm8921_gpios));
212 else
213 apq8064_configure_gpios(pm8917_gpios, ARRAY_SIZE(pm8917_gpios));
214
215 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid()) {
David Collins03c16372012-10-04 15:57:28 -0700216 apq8064_configure_gpios(touchscreen_gpios,
217 ARRAY_SIZE(touchscreen_gpios));
David Collinsd49a1c52012-08-22 13:18:06 -0700218 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
219 apq8064_configure_gpios(pm8921_cdp_kp_gpios,
220 ARRAY_SIZE(pm8921_cdp_kp_gpios));
221 else
222 apq8064_configure_gpios(pm8917_cdp_kp_gpios,
223 ARRAY_SIZE(pm8917_cdp_kp_gpios));
Jay Chokshie8741282012-01-25 15:22:55 -0800224 }
225
Mohan Pallaka474b94b2012-01-25 12:59:58 +0530226 if (machine_is_apq8064_mtp())
David Collinsd49a1c52012-08-22 13:18:06 -0700227 apq8064_configure_gpios(pm8921_mtp_kp_gpios,
228 ARRAY_SIZE(pm8921_mtp_kp_gpios));
Mohan Pallaka474b94b2012-01-25 12:59:58 +0530229
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530230 if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd()
David Collinsd49a1c52012-08-22 13:18:06 -0700231 || machine_is_mpq8064_dtv())
232 apq8064_configure_gpios(pm8921_mpq_gpios,
233 ARRAY_SIZE(pm8921_mpq_gpios));
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530234
Saket Saurabh54bd17a2012-09-11 17:00:46 +0530235 if (machine_is_mpq8064_hrd())
236 apq8064_configure_gpios(pm8921_mpq8064_hrd_gpios,
237 ARRAY_SIZE(pm8921_mpq8064_hrd_gpios));
238
Jay Chokshie8741282012-01-25 15:22:55 -0800239 for (i = 0; i < ARRAY_SIZE(pm8xxx_mpps); i++) {
240 rc = pm8xxx_mpp_config(pm8xxx_mpps[i].mpp,
241 &pm8xxx_mpps[i].config);
242 if (rc) {
243 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
244 break;
245 }
246 }
247}
248
249static struct pm8xxx_pwrkey_platform_data apq8064_pm8921_pwrkey_pdata = {
250 .pull_up = 1,
251 .kpd_trigger_delay_us = 15625,
252 .wakeup = 1,
253};
254
255static struct pm8xxx_misc_platform_data apq8064_pm8921_misc_pdata = {
256 .priority = 0,
257};
258
259#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
260#define PM8921_LC_LED_LOW_CURRENT 1 /* I = 1mA */
261#define PM8XXX_LED_PWM_PERIOD 1000
262#define PM8XXX_LED_PWM_DUTY_MS 20
263/**
264 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
265 * driven using PWM feature.
266 */
267#define PM8XXX_PWM_CHANNEL_NONE -1
268
269static struct led_info pm8921_led_info[] = {
270 [0] = {
271 .name = "led:red",
272 .default_trigger = "ac-online",
273 },
274};
275
276static struct led_platform_data pm8921_led_core_pdata = {
277 .num_leds = ARRAY_SIZE(pm8921_led_info),
278 .leds = pm8921_led_info,
279};
280
281static int pm8921_led0_pwm_duty_pcts[56] = {
282 1, 4, 8, 12, 16, 20, 24, 28, 32, 36,
283 40, 44, 46, 52, 56, 60, 64, 68, 72, 76,
284 80, 84, 88, 92, 96, 100, 100, 100, 98, 95,
285 92, 88, 84, 82, 78, 74, 70, 66, 62, 58,
286 58, 54, 50, 48, 42, 38, 34, 30, 26, 22,
287 14, 10, 6, 4, 1
288};
289
Jay Chokshibe517232012-06-15 18:20:56 -0700290/*
291 * Note: There is a bug in LPG module that results in incorrect
292 * behavior of pattern when LUT index 0 is used. So effectively
293 * there are 63 usable LUT entries.
294 */
Jay Chokshie8741282012-01-25 15:22:55 -0800295static struct pm8xxx_pwm_duty_cycles pm8921_led0_pwm_duty_cycles = {
296 .duty_pcts = (int *)&pm8921_led0_pwm_duty_pcts,
297 .num_duty_pcts = ARRAY_SIZE(pm8921_led0_pwm_duty_pcts),
298 .duty_ms = PM8XXX_LED_PWM_DUTY_MS,
Jay Chokshibe517232012-06-15 18:20:56 -0700299 .start_idx = 1,
Jay Chokshie8741282012-01-25 15:22:55 -0800300};
301
302static struct pm8xxx_led_config pm8921_led_configs[] = {
303 [0] = {
304 .id = PM8XXX_ID_LED_0,
305 .mode = PM8XXX_LED_MODE_PWM2,
306 .max_current = PM8921_LC_LED_MAX_CURRENT,
307 .pwm_channel = 5,
308 .pwm_period_us = PM8XXX_LED_PWM_PERIOD,
309 .pwm_duty_cycles = &pm8921_led0_pwm_duty_cycles,
310 },
311};
312
313static struct pm8xxx_led_platform_data apq8064_pm8921_leds_pdata = {
314 .led_core = &pm8921_led_core_pdata,
315 .configs = pm8921_led_configs,
316 .num_configs = ARRAY_SIZE(pm8921_led_configs),
317};
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800318
Jay Chokshif3a9ea82012-01-12 16:34:43 -0800319static struct pm8xxx_adc_amux apq8064_pm8921_adc_channels_data[] = {
320 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
321 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
322 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
323 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
324 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
325 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
326 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
327 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
328 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
329 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
330 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
331 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
332 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
333 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
334 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
335 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
336 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
337 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
338 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
339 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
340 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
341 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
342 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
343 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
344 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
345 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
346 {"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0,
347 ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM},
348};
349
350static struct pm8xxx_adc_properties apq8064_pm8921_adc_data = {
351 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
352 .bitresolution = 15,
353 .bipolar = 0,
354};
355
356static struct pm8xxx_adc_platform_data apq8064_pm8921_adc_pdata = {
357 .adc_channel = apq8064_pm8921_adc_channels_data,
358 .adc_num_board_channel = ARRAY_SIZE(apq8064_pm8921_adc_channels_data),
359 .adc_prop = &apq8064_pm8921_adc_data,
360 .adc_mpp_base = PM8921_MPP_PM_TO_SYS(1),
361};
362
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800363static struct pm8xxx_mpp_platform_data
364apq8064_pm8921_mpp_pdata __devinitdata = {
365 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
366};
367
368static struct pm8xxx_gpio_platform_data
369apq8064_pm8921_gpio_pdata __devinitdata = {
370 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
371};
372
373static struct pm8xxx_irq_platform_data
374apq8064_pm8921_irq_pdata __devinitdata = {
375 .irq_base = PM8921_IRQ_BASE,
Jeffrey Chuanga92c7ab2012-03-01 23:56:00 -0800376 .devirq = MSM_GPIO_TO_INT(74),
377 .irq_trigger_flag = IRQF_TRIGGER_LOW,
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800378 .dev_id = 0,
379};
380
Ashay Jaiswal0b023dc2012-01-25 10:18:36 +0530381static struct pm8xxx_rtc_platform_data
382apq8064_pm8921_rtc_pdata = {
383 .rtc_write_enable = false,
384 .rtc_alarm_powerup = false,
385};
386
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800387static int apq8064_pm8921_therm_mitigation[] = {
388 1100,
389 700,
390 600,
391 325,
392};
393
394#define MAX_VOLTAGE_MV 4200
Abhijeet Dharmapurikard6d66c72012-08-06 14:02:51 -0700395#define CHG_TERM_MA 100
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800396static struct pm8921_charger_platform_data
397apq8064_pm8921_chg_pdata __devinitdata = {
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800398 .update_time = 60000,
399 .max_voltage = MAX_VOLTAGE_MV,
400 .min_voltage = 3200,
David Keitel0789fc62012-06-07 17:43:27 -0700401 .uvd_thresh_voltage = 4050,
David Keitel8b079fb2012-06-28 19:14:30 -0700402 .alarm_low_mv = 3400,
403 .alarm_high_mv = 4000,
Xiaozhe Shi14e8fa12012-10-11 15:49:58 -0700404 .resume_voltage_delta = 60,
405 .resume_charge_percent = 99,
Abhijeet Dharmapurikard6d66c72012-08-06 14:02:51 -0700406 .term_current = CHG_TERM_MA,
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800407 .cool_temp = 10,
408 .warm_temp = 40,
409 .temp_check_period = 1,
410 .max_bat_chg_current = 1100,
411 .cool_bat_chg_current = 350,
412 .warm_bat_chg_current = 350,
413 .cool_bat_voltage = 4100,
414 .warm_bat_voltage = 4100,
415 .thermal_mitigation = apq8064_pm8921_therm_mitigation,
416 .thermal_levels = ARRAY_SIZE(apq8064_pm8921_therm_mitigation),
Abhijeet Dharmapurikar499a36f2012-07-30 12:48:17 -0700417 .rconn_mohm = 18,
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800418};
419
420static struct pm8xxx_ccadc_platform_data
421apq8064_pm8xxx_ccadc_pdata = {
Xiaozhe Shid69c91e2012-11-06 10:00:38 -0800422 .r_sense_uohm = 10000,
David Keitel3c378822012-06-07 13:43:22 -0700423 .calib_delay_ms = 600000,
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800424};
425
426static struct pm8921_bms_platform_data
427apq8064_pm8921_bms_pdata __devinitdata = {
Abhijeet Dharmapurikard6d66c72012-08-06 14:02:51 -0700428 .battery_type = BATT_UNKNOWN,
Xiaozhe Shid69c91e2012-11-06 10:00:38 -0800429 .r_sense_uohm = 10000,
Abhijeet Dharmapurikard6d66c72012-08-06 14:02:51 -0700430 .v_cutoff = 3400,
431 .max_voltage_uv = MAX_VOLTAGE_MV * 1000,
432 .rconn_mohm = 18,
433 .shutdown_soc_valid_limit = 20,
434 .adjust_soc_low_threshold = 25,
435 .chg_term_ua = CHG_TERM_MA * 1000,
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800436};
437
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800438static struct pm8921_platform_data
439apq8064_pm8921_platform_data __devinitdata = {
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800440 .irq_pdata = &apq8064_pm8921_irq_pdata,
441 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
442 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Ashay Jaiswal0b023dc2012-01-25 10:18:36 +0530443 .rtc_pdata = &apq8064_pm8921_rtc_pdata,
Jay Chokshie8741282012-01-25 15:22:55 -0800444 .pwrkey_pdata = &apq8064_pm8921_pwrkey_pdata,
445 .misc_pdata = &apq8064_pm8921_misc_pdata,
446 .leds_pdata = &apq8064_pm8921_leds_pdata,
Jay Chokshif3a9ea82012-01-12 16:34:43 -0800447 .adc_pdata = &apq8064_pm8921_adc_pdata,
Jay Chokshi42fe9f02012-02-01 20:52:08 -0800448 .charger_pdata = &apq8064_pm8921_chg_pdata,
449 .bms_pdata = &apq8064_pm8921_bms_pdata,
450 .ccadc_pdata = &apq8064_pm8xxx_ccadc_pdata,
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800451};
452
453static struct pm8xxx_irq_platform_data
454apq8064_pm8821_irq_pdata __devinitdata = {
455 .irq_base = PM8821_IRQ_BASE,
Jay Chokshie8741282012-01-25 15:22:55 -0800456 .devirq = PM8821_SEC_IRQ_N,
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800457 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
458 .dev_id = 1,
459};
460
461static struct pm8xxx_mpp_platform_data
462apq8064_pm8821_mpp_pdata __devinitdata = {
463 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
464};
465
466static struct pm8821_platform_data
467apq8064_pm8821_platform_data __devinitdata = {
468 .irq_pdata = &apq8064_pm8821_irq_pdata,
469 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
470};
471
472static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
473 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
474 .slave = {
475 .name = "pm8921-core",
476 .platform_data = &apq8064_pm8921_platform_data,
477 },
478};
479
480static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
481 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
482 .slave = {
483 .name = "pm8821-core",
484 .platform_data = &apq8064_pm8821_platform_data,
485 },
486};
487
488void __init apq8064_init_pmic(void)
489{
Jay Chokshie8741282012-01-25 15:22:55 -0800490 pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ;
491
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800492 apq8064_device_ssbi_pmic1.dev.platform_data =
493 &apq8064_ssbi_pm8921_pdata;
494 apq8064_device_ssbi_pmic2.dev.platform_data =
495 &apq8064_ssbi_pm8821_pdata;
David Collins793793b2012-08-21 15:43:02 -0700496 if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
497 apq8064_pm8921_platform_data.regulator_pdatas
498 = msm8064_pm8921_regulator_pdata;
499 apq8064_pm8921_platform_data.num_regulators
500 = msm8064_pm8921_regulator_pdata_len;
501 } else {
502 apq8064_pm8921_platform_data.regulator_pdatas
503 = msm8064_pm8917_regulator_pdata;
504 apq8064_pm8921_platform_data.num_regulators
505 = msm8064_pm8917_regulator_pdata_len;
506 }
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800507
Jin Hongc5f5d542012-04-12 16:48:51 -0700508 if (machine_is_apq8064_mtp()) {
David Keitel35e11872012-02-17 17:40:42 -0800509 apq8064_pm8921_bms_pdata.battery_type = BATT_PALLADIUM;
510 } else if (machine_is_apq8064_liquid()) {
511 apq8064_pm8921_bms_pdata.battery_type = BATT_DESAY;
David Keitelb7bf2c92012-08-24 17:54:00 -0700512 } else if (machine_is_apq8064_cdp()) {
513 apq8064_pm8921_chg_pdata.has_dc_supply = true;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800514 }
Abhijeet Dharmapurikarbbaef592012-10-10 10:07:51 -0700515
516 if (!machine_is_apq8064_mtp() && !machine_is_apq8064_liquid())
517 apq8064_pm8921_chg_pdata.battery_less_hardware = 1;
Stepan Moskovchenkoc1074f02011-12-14 17:51:57 -0800518}