PageRenderTime 78ms CodeModel.GetById 13ms app.highlight 59ms RepoModel.GetById 1ms app.codeStats 1ms

/arch/arm/mach-msm/board-8930-pmic.c

https://github.com/AICP/kernel_google_msm
C | 597 lines | 495 code | 61 blank | 41 comment | 17 complexity | 1a9607ac1c88620b062062b10ba31bb6 MD5 | raw file
  1/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2 *
  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/interrupt.h>
 15#include <linux/mfd/pm8xxx/pm8038.h>
 16#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
 17#include <linux/msm_ssbi.h>
 18#include <asm/mach-types.h>
 19#include <mach/msm_bus_board.h>
 20#include <mach/restart.h>
 21#include <mach/socinfo.h>
 22#include "devices.h"
 23#include "board-8930.h"
 24
 25struct pm8xxx_gpio_init {
 26	unsigned			gpio;
 27	struct pm_gpio			config;
 28};
 29
 30struct pm8xxx_mpp_init {
 31	unsigned			mpp;
 32	struct pm8xxx_mpp_config_data	config;
 33};
 34
 35#define PM8038_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
 36			_func, _inv, _disable) \
 37{ \
 38	.gpio	= PM8038_GPIO_PM_TO_SYS(_gpio), \
 39	.config	= { \
 40		.direction	= _dir, \
 41		.output_buffer	= _buf, \
 42		.output_value	= _val, \
 43		.pull		= _pull, \
 44		.vin_sel	= _vin, \
 45		.out_strength	= _out_strength, \
 46		.function	= _func, \
 47		.inv_int_pol	= _inv, \
 48		.disable_pin	= _disable, \
 49	} \
 50}
 51
 52#define PM8038_MPP_INIT(_mpp, _type, _level, _control) \
 53{ \
 54	.mpp	= PM8038_MPP_PM_TO_SYS(_mpp), \
 55	.config	= { \
 56		.type		= PM8XXX_MPP_TYPE_##_type, \
 57		.level		= _level, \
 58		.control	= PM8XXX_MPP_##_control, \
 59	} \
 60}
 61
 62#define PM8038_GPIO_DISABLE(_gpio) \
 63	PM8038_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM8038_GPIO_VIN_L11, \
 64			 0, 0, 0, 1)
 65
 66#define PM8038_GPIO_OUTPUT(_gpio, _val) \
 67	PM8038_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
 68			PM_GPIO_PULL_NO, PM8038_GPIO_VIN_L11, \
 69			PM_GPIO_STRENGTH_HIGH, \
 70			PM_GPIO_FUNC_NORMAL, 0, 0)
 71
 72#define PM8038_GPIO_INPUT(_gpio, _pull) \
 73	PM8038_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
 74			_pull, PM8038_GPIO_VIN_L11, \
 75			PM_GPIO_STRENGTH_NO, \
 76			PM_GPIO_FUNC_NORMAL, 0, 0)
 77
 78#define PM8038_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
 79	PM8038_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
 80			PM_GPIO_PULL_NO, PM8038_GPIO_VIN_L11, \
 81			PM_GPIO_STRENGTH_HIGH, \
 82			_func, 0, 0)
 83
 84#define PM8038_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \
 85	PM8038_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
 86			PM_GPIO_PULL_NO, _vin, \
 87			PM_GPIO_STRENGTH_HIGH, \
 88			PM_GPIO_FUNC_NORMAL, 0, 0)
 89
 90#define PM8917_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
 91			_func, _inv, _disable) \
 92{ \
 93	.gpio	= PM8917_GPIO_PM_TO_SYS(_gpio), \
 94	.config	= { \
 95		.direction	= _dir, \
 96		.output_buffer	= _buf, \
 97		.output_value	= _val, \
 98		.pull		= _pull, \
 99		.vin_sel	= _vin, \
100		.out_strength	= _out_strength, \
101		.function	= _func, \
102		.inv_int_pol	= _inv, \
103		.disable_pin	= _disable, \
104	} \
105}
106
107#define PM8917_MPP_INIT(_mpp, _type, _level, _control) \
108{ \
109	.mpp	= PM8917_MPP_PM_TO_SYS(_mpp), \
110	.config	= { \
111		.type		= PM8XXX_MPP_TYPE_##_type, \
112		.level		= _level, \
113		.control	= PM8XXX_MPP_##_control, \
114	} \
115}
116
117#define PM8917_GPIO_DISABLE(_gpio) \
118	PM8917_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
119			 0, 0, 0, 1)
120
121#define PM8917_GPIO_OUTPUT(_gpio, _val) \
122	PM8917_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
123			PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
124			PM_GPIO_STRENGTH_HIGH, \
125			PM_GPIO_FUNC_NORMAL, 0, 0)
126
127#define PM8917_GPIO_INPUT(_gpio, _pull) \
128	PM8917_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
129			_pull, PM_GPIO_VIN_S4, \
130			PM_GPIO_STRENGTH_NO, \
131			PM_GPIO_FUNC_NORMAL, 0, 0)
132
133#define PM8917_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
134	PM8917_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
135			PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
136			PM_GPIO_STRENGTH_HIGH, \
137			_func, 0, 0)
138
139#define PM8917_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \
140	PM8917_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
141			PM_GPIO_PULL_NO, _vin, \
142			PM_GPIO_STRENGTH_HIGH, \
143			PM_GPIO_FUNC_NORMAL, 0, 0)
144
145/* GPIO and MPP configurations for MSM8930 + PM8038 targets */
146
147/* Initial PM8038 GPIO configurations */
148static struct pm8xxx_gpio_init pm8038_gpios[] __initdata = {
149	/* keys GPIOs */
150	PM8038_GPIO_INPUT(3, PM_GPIO_PULL_UP_30),
151	PM8038_GPIO_INPUT(8, PM_GPIO_PULL_UP_30),
152	PM8038_GPIO_INPUT(10, PM_GPIO_PULL_UP_30),
153	PM8038_GPIO_INPUT(11, PM_GPIO_PULL_UP_30),
154	/* haptics gpio */
155	PM8038_GPIO_OUTPUT_FUNC(7, 0, PM_GPIO_FUNC_1),
156	/* MHL PWR EN */
157	PM8038_GPIO_OUTPUT_VIN(5, 1, PM8038_GPIO_VIN_VPH),
158};
159
160/* Initial PM8038 MPP configurations */
161static struct pm8xxx_mpp_init pm8038_mpps[] __initdata = {
162};
163
164/* GPIO and MPP configurations for MSM8930 + PM8917 targets */
165
166/* Initial PM8917 GPIO configurations */
167static struct pm8xxx_gpio_init pm8917_gpios[] __initdata = {
168	/* Backlight enable control */
169	PM8917_GPIO_OUTPUT(24, 1),
170	/* keys GPIOs */
171	PM8917_GPIO_INPUT(27, PM_GPIO_PULL_UP_30),
172	PM8917_GPIO_INPUT(28, PM_GPIO_PULL_UP_30),
173	PM8917_GPIO_INPUT(36, PM_GPIO_PULL_UP_30),
174	PM8917_GPIO_INPUT(37, PM_GPIO_PULL_UP_30),
175	/* haptics gpio */
176	PM8917_GPIO_OUTPUT_FUNC(38, 0, PM_GPIO_FUNC_2),
177	/* MHL PWR EN */
178	PM8917_GPIO_OUTPUT_VIN(25, 1, PM_GPIO_VIN_VPH),
179};
180
181/* Initial PM8917 MPP configurations */
182static struct pm8xxx_mpp_init pm8917_mpps[] __initdata = {
183	PM8917_MPP_INIT(PM8XXX_AMUX_MPP_3, A_INPUT,
184				PM8XXX_MPP_AIN_AMUX_CH8, DIN_TO_INT),
185	/* Configure MPP01 for USB ID detection */
186	PM8917_MPP_INIT(1, D_INPUT, PM8921_MPP_DIG_LEVEL_S4, DIN_TO_INT),
187};
188
189void __init msm8930_pm8038_gpio_mpp_init(void)
190{
191	int i, rc;
192
193	for (i = 0; i < ARRAY_SIZE(pm8038_gpios); i++) {
194		rc = pm8xxx_gpio_config(pm8038_gpios[i].gpio,
195					&pm8038_gpios[i].config);
196		if (rc) {
197			pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
198			break;
199		}
200	}
201
202	/* Initial MPP configuration. */
203	for (i = 0; i < ARRAY_SIZE(pm8038_mpps); i++) {
204		rc = pm8xxx_mpp_config(pm8038_mpps[i].mpp,
205					&pm8038_mpps[i].config);
206		if (rc) {
207			pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
208			break;
209		}
210	}
211}
212
213void __init msm8930_pm8917_gpio_mpp_init(void)
214{
215	int i, rc;
216
217	for (i = 0; i < ARRAY_SIZE(pm8917_gpios); i++) {
218		rc = pm8xxx_gpio_config(pm8917_gpios[i].gpio,
219					&pm8917_gpios[i].config);
220		if (rc) {
221			pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
222			break;
223		}
224	}
225
226	/* Initial MPP configuration. */
227	for (i = 0; i < ARRAY_SIZE(pm8917_mpps); i++) {
228		rc = pm8xxx_mpp_config(pm8917_mpps[i].mpp,
229					&pm8917_mpps[i].config);
230		if (rc) {
231			pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
232			break;
233		}
234	}
235}
236
237static struct pm8xxx_adc_amux pm8038_adc_channels_data[] = {
238	{"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
239		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
240	{"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
241		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
242	{"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
243		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
244	{"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
245		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
246	{"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
247		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
248	{"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
249		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
250	{"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
251		ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
252	{"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
253		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
254	{"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
255		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
256	{"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
257		ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
258	{"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
259		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
260	{"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
261		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
262	{"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
263		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
264	{"pa_therm1", ADC_MPP_1_AMUX4, CHAN_PATH_SCALING1, AMUX_RSV1,
265		ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
266	{"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0,
267		ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM},
268	{"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
269		ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
270};
271
272static struct pm8xxx_adc_properties pm8038_adc_data = {
273	.adc_vdd_reference	= 1800, /* milli-voltage for this adc */
274	.bitresolution		= 15,
275	.bipolar                = 0,
276};
277
278static struct pm8xxx_adc_platform_data pm8038_adc_pdata = {
279	.adc_channel            = pm8038_adc_channels_data,
280	.adc_num_board_channel  = ARRAY_SIZE(pm8038_adc_channels_data),
281	.adc_prop               = &pm8038_adc_data,
282	.adc_mpp_base		= PM8038_MPP_PM_TO_SYS(1),
283};
284
285static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
286	.irq_base		= PM8038_IRQ_BASE,
287	.devirq			= MSM_GPIO_TO_INT(104),
288	.irq_trigger_flag	= IRQF_TRIGGER_LOW,
289};
290
291static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
292	.gpio_base	= PM8038_GPIO_PM_TO_SYS(1),
293};
294
295static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
296	.mpp_base	= PM8038_MPP_PM_TO_SYS(1),
297};
298
299static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
300	.rtc_write_enable	= false,
301	.rtc_alarm_powerup	= false,
302};
303
304static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
305	.pull_up		= 1,
306	.kpd_trigger_delay_us	= 15625,
307	.wakeup			= 1,
308};
309
310static int pm8921_therm_mitigation[] = {
311	1100,
312	700,
313	600,
314	325,
315};
316
317#define MAX_VOLTAGE_MV		4200
318#define CHG_TERM_MA		100
319static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
320	.safety_time		= 180,
321	.update_time		= 60000,
322	.max_voltage		= MAX_VOLTAGE_MV,
323	.min_voltage		= 3200,
324	.uvd_thresh_voltage	= 4050,
325	.alarm_voltage          = 3400,
326	.resume_voltage_delta	= 100,
327	.term_current		= CHG_TERM_MA,
328	.cool_temp		= 10,
329	.warm_temp		= 40,
330	.temp_check_period	= 1,
331	.max_bat_chg_current	= 1100,
332	.cool_bat_chg_current	= 350,
333	.warm_bat_chg_current	= 350,
334	.cool_bat_voltage	= 4100,
335	.warm_bat_voltage	= 4100,
336	.thermal_mitigation	= pm8921_therm_mitigation,
337	.thermal_levels		= ARRAY_SIZE(pm8921_therm_mitigation),
338	.led_src_config		= LED_SRC_VPH_PWR,
339	.rconn_mohm		= 18,
340};
341
342#define PM8038_WLED_MAX_CURRENT		25
343#define PM8XXX_LED_PWM_PERIOD		1000
344#define PM8XXX_LED_PWM_DUTY_MS		20
345#define PM8038_RGB_LED_MAX_CURRENT	12
346
347static struct led_info pm8038_led_info[] = {
348	[0] = {
349		.name			= "wled",
350		.default_trigger	= "bkl_trigger",
351	},
352	[1] = {
353		.name			= "led:rgb_red",
354		.default_trigger	= "battery-charging",
355	},
356	[2] = {
357		.name			= "led:rgb_green",
358	},
359	[3] = {
360		.name			= "led:rgb_blue",
361	},
362};
363
364static struct led_platform_data pm8038_led_core_pdata = {
365	.num_leds = ARRAY_SIZE(pm8038_led_info),
366	.leds = pm8038_led_info,
367};
368
369static struct wled_config_data wled_cfg = {
370	.dig_mod_gen_en = true,
371	.cs_out_en = true,
372	.ctrl_delay_us = 0,
373	.op_fdbck = true,
374	.ovp_val = WLED_OVP_32V,
375	.boost_curr_lim = WLED_CURR_LIMIT_525mA,
376	.num_strings = 1,
377};
378
379static int pm8038_led0_pwm_duty_pcts[56] = {
380		1, 4, 8, 12, 16, 20, 24, 28, 32, 36,
381		40, 44, 46, 52, 56, 60, 64, 68, 72, 76,
382		80, 84, 88, 92, 96, 100, 100, 100, 98, 95,
383		92, 88, 84, 82, 78, 74, 70, 66, 62, 58,
384		58, 54, 50, 48, 42, 38, 34, 30, 26, 22,
385		14, 10, 6, 4, 1
386};
387
388/*
389 * Note: There is a bug in LPG module that results in incorrect
390 * behavior of pattern when LUT index 0 is used. So effectively
391 * there are 63 usable LUT entries.
392 */
393static struct pm8xxx_pwm_duty_cycles pm8038_led0_pwm_duty_cycles = {
394	.duty_pcts = (int *)&pm8038_led0_pwm_duty_pcts,
395	.num_duty_pcts = ARRAY_SIZE(pm8038_led0_pwm_duty_pcts),
396	.duty_ms = PM8XXX_LED_PWM_DUTY_MS,
397	.start_idx = 1,
398};
399
400static struct pm8xxx_led_config pm8038_led_configs[] = {
401	[0] = {
402		.id = PM8XXX_ID_WLED,
403		.mode = PM8XXX_LED_MODE_MANUAL,
404		.max_current = PM8038_WLED_MAX_CURRENT,
405		.default_state = 0,
406		.wled_cfg = &wled_cfg,
407	},
408	[1] = {
409		.id = PM8XXX_ID_RGB_LED_RED,
410		.mode = PM8XXX_LED_MODE_PWM1,
411		.max_current = PM8038_RGB_LED_MAX_CURRENT,
412		.pwm_channel = 5,
413		.pwm_period_us = PM8XXX_LED_PWM_PERIOD,
414		.pwm_duty_cycles = &pm8038_led0_pwm_duty_cycles,
415	},
416	[2] = {
417		.id = PM8XXX_ID_RGB_LED_GREEN,
418		.mode = PM8XXX_LED_MODE_PWM1,
419		.max_current = PM8038_RGB_LED_MAX_CURRENT,
420		.pwm_channel = 4,
421		.pwm_period_us = PM8XXX_LED_PWM_PERIOD,
422		.pwm_duty_cycles = &pm8038_led0_pwm_duty_cycles,
423	},
424	[3] = {
425		.id = PM8XXX_ID_RGB_LED_BLUE,
426		.mode = PM8XXX_LED_MODE_PWM1,
427		.max_current = PM8038_RGB_LED_MAX_CURRENT,
428		.pwm_channel = 3,
429		.pwm_period_us = PM8XXX_LED_PWM_PERIOD,
430		.pwm_duty_cycles = &pm8038_led0_pwm_duty_cycles,
431	},
432};
433
434static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
435	.led_core = &pm8038_led_core_pdata,
436	.configs = pm8038_led_configs,
437	.num_configs = ARRAY_SIZE(pm8038_led_configs),
438};
439
440static struct pm8xxx_ccadc_platform_data pm8xxx_ccadc_pdata = {
441	.r_sense		= 10,
442	.calib_delay_ms		= 600000,
443};
444
445static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
446	.priority		= 0,
447};
448
449/*
450 *	0x254=0xC8 (Threshold=110, preamp bias=01)
451 *	0x255=0xC1 (Hold=110, max attn=0000, mute=1)
452 *	0x256=0xB0 (decay=101, attack=10, delay=0)
453 */
454
455static struct pm8xxx_spk_platform_data pm8xxx_spk_pdata = {
456	.spk_add_enable		= false,
457	.cd_ng_threshold	= 0x6,
458	.cd_nf_preamp_bias	= 0x1,
459	.cd_ng_hold		= 0x6,
460	.cd_ng_max_atten	= 0x0,
461	.noise_mute		= 1,
462	.cd_ng_decay_rate	= 0x5,
463	.cd_ng_attack_rate	= 0x2,
464	.cd_delay		= 0x0,
465};
466
467static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
468	.battery_type			= BATT_UNKNOWN,
469	.r_sense			= 10,
470	.v_cutoff			= 3400,
471	.max_voltage_uv			= MAX_VOLTAGE_MV * 1000,
472	.shutdown_soc_valid_limit	= 20,
473	.adjust_soc_low_threshold	= 25,
474	.chg_term_ua			= CHG_TERM_MA * 1000,
475	.rconn_mohm			= 18,
476};
477
478static struct pm8038_platform_data pm8038_platform_data __devinitdata = {
479	.irq_pdata		= &pm8xxx_irq_pdata,
480	.gpio_pdata		= &pm8xxx_gpio_pdata,
481	.mpp_pdata		= &pm8xxx_mpp_pdata,
482	.rtc_pdata              = &pm8xxx_rtc_pdata,
483	.pwrkey_pdata		= &pm8xxx_pwrkey_pdata,
484	.misc_pdata		= &pm8xxx_misc_pdata,
485	.regulator_pdatas	= msm8930_pm8038_regulator_pdata,
486	.charger_pdata		= &pm8921_chg_pdata,
487	.bms_pdata		= &pm8921_bms_pdata,
488	.adc_pdata		= &pm8038_adc_pdata,
489	.leds_pdata		= &pm8xxx_leds_pdata,
490	.ccadc_pdata		= &pm8xxx_ccadc_pdata,
491	.spk_pdata		= &pm8xxx_spk_pdata,
492};
493
494static struct msm_ssbi_platform_data msm8930_ssbi_pm8038_pdata __devinitdata = {
495	.controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
496	.slave	= {
497		.name			= "pm8038-core",
498		.platform_data		= &pm8038_platform_data,
499	},
500};
501
502/* PM8917 platform data */
503
504static struct pm8xxx_adc_amux pm8917_adc_channels_data[] = {
505	{"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
506		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
507	{"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
508		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
509	{"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
510		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
511	{"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
512		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
513	{"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
514		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
515	{"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
516		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
517	{"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
518		ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
519	{"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
520		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
521	{"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
522		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
523	{"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
524		ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
525	{"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
526		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
527	{"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
528		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
529	{"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
530		ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
531	{"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0,
532		ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM},
533	{"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
534		ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
535};
536
537static struct pm8xxx_adc_properties pm8917_adc_data = {
538	.adc_vdd_reference	= 1800, /* milli-voltage for this adc */
539	.bitresolution		= 15,
540	.bipolar                = 0,
541};
542
543static struct pm8xxx_adc_platform_data pm8917_adc_pdata = {
544	.adc_channel            = pm8917_adc_channels_data,
545	.adc_num_board_channel  = ARRAY_SIZE(pm8917_adc_channels_data),
546	.adc_prop               = &pm8917_adc_data,
547	.adc_mpp_base		= PM8917_MPP_PM_TO_SYS(1),
548};
549
550static struct pm8921_platform_data pm8917_platform_data __devinitdata = {
551	.irq_pdata		= &pm8xxx_irq_pdata,
552	.gpio_pdata		= &pm8xxx_gpio_pdata,
553	.mpp_pdata		= &pm8xxx_mpp_pdata,
554	.rtc_pdata              = &pm8xxx_rtc_pdata,
555	.pwrkey_pdata		= &pm8xxx_pwrkey_pdata,
556	.misc_pdata		= &pm8xxx_misc_pdata,
557	.regulator_pdatas	= msm8930_pm8917_regulator_pdata,
558	.charger_pdata		= &pm8921_chg_pdata,
559	.bms_pdata		= &pm8921_bms_pdata,
560	.adc_pdata		= &pm8917_adc_pdata,
561	.ccadc_pdata		= &pm8xxx_ccadc_pdata,
562};
563
564static struct msm_ssbi_platform_data msm8930_ssbi_pm8917_pdata __devinitdata = {
565	.controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
566	.slave	= {
567		.name			= "pm8921-core",
568		.platform_data		= &pm8917_platform_data,
569	},
570};
571
572void __init msm8930_init_pmic(void)
573{
574	if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
575		/* PM8038 configuration */
576		pmic_reset_irq = PM8038_IRQ_BASE + PM8038_RESOUT_IRQ;
577		msm8960_device_ssbi_pmic.dev.platform_data =
578					&msm8930_ssbi_pm8038_pdata;
579		pm8038_platform_data.num_regulators
580			= msm8930_pm8038_regulator_pdata_len;
581		if (machine_is_msm8930_mtp())
582			pm8921_bms_pdata.battery_type = BATT_PALLADIUM;
583		else if (machine_is_msm8930_cdp())
584			pm8921_chg_pdata.has_dc_supply = true;
585	} else {
586		/* PM8917 configuration */
587		pmic_reset_irq = PM8917_IRQ_BASE + PM8921_RESOUT_IRQ;
588		msm8960_device_ssbi_pmic.dev.platform_data =
589					&msm8930_ssbi_pm8917_pdata;
590		pm8917_platform_data.num_regulators
591			= msm8930_pm8917_regulator_pdata_len;
592		if (machine_is_msm8930_mtp())
593			pm8921_bms_pdata.battery_type = BATT_PALLADIUM;
594		else if (machine_is_msm8930_cdp())
595			pm8921_chg_pdata.has_dc_supply = true;
596	}
597}