Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 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/init.h> |
| 15 | #include <linux/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 18 | #include <linux/mfd/pm8xxx/pm8921.h> |
| 19 | #include <linux/leds.h> |
| 20 | #include <linux/leds-pm8xxx.h> |
Jay Chokshi | f3a9ea8 | 2012-01-12 16:34:43 -0800 | [diff] [blame] | 21 | #include <linux/mfd/pm8xxx/pm8xxx-adc.h> |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/mmc.h> |
| 24 | #include <mach/msm_bus_board.h> |
| 25 | #include <mach/board.h> |
| 26 | #include <mach/gpio.h> |
| 27 | #include <mach/gpiomux.h> |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 28 | #include <mach/restart.h> |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 29 | #include "devices.h" |
| 30 | #include "board-8064.h" |
| 31 | |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 32 | struct pm8xxx_gpio_init { |
| 33 | unsigned gpio; |
| 34 | struct pm_gpio config; |
| 35 | }; |
| 36 | |
| 37 | struct pm8xxx_mpp_init { |
| 38 | unsigned mpp; |
| 39 | struct pm8xxx_mpp_config_data config; |
| 40 | }; |
| 41 | |
| 42 | #define PM8921_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \ |
| 43 | _func, _inv, _disable) \ |
| 44 | { \ |
| 45 | .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \ |
| 46 | .config = { \ |
| 47 | .direction = _dir, \ |
| 48 | .output_buffer = _buf, \ |
| 49 | .output_value = _val, \ |
| 50 | .pull = _pull, \ |
| 51 | .vin_sel = _vin, \ |
| 52 | .out_strength = _out_strength, \ |
| 53 | .function = _func, \ |
| 54 | .inv_int_pol = _inv, \ |
| 55 | .disable_pin = _disable, \ |
| 56 | } \ |
| 57 | } |
| 58 | |
| 59 | #define PM8921_MPP_INIT(_mpp, _type, _level, _control) \ |
| 60 | { \ |
| 61 | .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \ |
| 62 | .config = { \ |
| 63 | .type = PM8XXX_MPP_TYPE_##_type, \ |
| 64 | .level = _level, \ |
| 65 | .control = PM8XXX_MPP_##_control, \ |
| 66 | } \ |
| 67 | } |
| 68 | |
| 69 | #define PM8821_MPP_INIT(_mpp, _type, _level, _control) \ |
| 70 | { \ |
| 71 | .mpp = PM8821_MPP_PM_TO_SYS(_mpp), \ |
| 72 | .config = { \ |
| 73 | .type = PM8XXX_MPP_TYPE_##_type, \ |
| 74 | .level = _level, \ |
| 75 | .control = PM8XXX_MPP_##_control, \ |
| 76 | } \ |
| 77 | } |
| 78 | |
| 79 | #define PM8921_GPIO_DISABLE(_gpio) \ |
| 80 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \ |
| 81 | 0, 0, 0, 1) |
| 82 | |
| 83 | #define PM8921_GPIO_OUTPUT(_gpio, _val, _strength) \ |
| 84 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 85 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 86 | PM_GPIO_STRENGTH_##_strength, \ |
| 87 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 88 | |
Jay Chokshi | 1de4f9d | 2012-02-07 16:11:31 -0800 | [diff] [blame] | 89 | #define PM8921_GPIO_OUTPUT_BUFCONF(_gpio, _val, _strength, _bufconf) \ |
| 90 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT,\ |
| 91 | PM_GPIO_OUT_BUF_##_bufconf, _val, \ |
| 92 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 93 | PM_GPIO_STRENGTH_##_strength, \ |
| 94 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 95 | |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 96 | #define PM8921_GPIO_INPUT(_gpio, _pull) \ |
| 97 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \ |
| 98 | _pull, PM_GPIO_VIN_S4, \ |
| 99 | PM_GPIO_STRENGTH_NO, \ |
| 100 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 101 | |
| 102 | #define PM8921_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \ |
| 103 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 104 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 105 | PM_GPIO_STRENGTH_HIGH, \ |
| 106 | _func, 0, 0) |
| 107 | |
| 108 | #define PM8921_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \ |
| 109 | PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 110 | PM_GPIO_PULL_NO, _vin, \ |
| 111 | PM_GPIO_STRENGTH_HIGH, \ |
| 112 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 113 | |
| 114 | /* Initial PM8921 GPIO configurations */ |
| 115 | static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = { |
David Collins | 390fc33 | 2012-02-07 14:38:16 -0800 | [diff] [blame] | 116 | PM8921_GPIO_OUTPUT(23, 0, HIGH), /* touchscreen power FET */ |
Jay Chokshi | 1de4f9d | 2012-02-07 16:11:31 -0800 | [diff] [blame] | 117 | PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */ |
| 118 | PM8921_GPIO_OUTPUT_FUNC(26, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */ |
| 119 | PM8921_GPIO_OUTPUT_BUFCONF(36, 1, LOW, OPEN_DRAIN), |
Amy Maloche | 70090f99 | 2012-02-16 16:35:26 -0800 | [diff] [blame] | 120 | PM8921_GPIO_OUTPUT_FUNC(44, 0, PM_GPIO_FUNC_2), |
| 121 | PM8921_GPIO_OUTPUT(33, 0, HIGH), |
| 122 | PM8921_GPIO_OUTPUT(20, 0, HIGH), |
Mohan Pallaka | 474b94b | 2012-01-25 12:59:58 +0530 | [diff] [blame] | 123 | PM8921_GPIO_INPUT(35, PM_GPIO_PULL_UP_1P5), |
| 124 | PM8921_GPIO_INPUT(38, PM_GPIO_PULL_UP_1P5), |
Shiv Maliyappanahalli | 7e0beff | 2012-02-06 15:56:39 -0800 | [diff] [blame] | 125 | /* TABLA CODEC RESET */ |
| 126 | PM8921_GPIO_OUTPUT(34, 1, MED), |
Mohan Pallaka | 474b94b | 2012-01-25 12:59:58 +0530 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | static struct pm8xxx_gpio_init pm8921_mtp_kp_gpios[] __initdata = { |
| 130 | PM8921_GPIO_INPUT(3, PM_GPIO_PULL_UP_1P5), |
| 131 | PM8921_GPIO_INPUT(4, PM_GPIO_PULL_UP_1P5), |
| 132 | }; |
| 133 | |
| 134 | static struct pm8xxx_gpio_init pm8921_cdp_kp_gpios[] __initdata = { |
| 135 | PM8921_GPIO_INPUT(37, PM_GPIO_PULL_UP_1P5), |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | /* Initial PM8XXX MPP configurations */ |
| 139 | static struct pm8xxx_mpp_init pm8xxx_mpps[] __initdata = { |
Jay Chokshi | 1de4f9d | 2012-02-07 16:11:31 -0800 | [diff] [blame] | 140 | PM8921_MPP_INIT(3, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_LOW), |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 141 | /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */ |
Jay Chokshi | 1de4f9d | 2012-02-07 16:11:31 -0800 | [diff] [blame] | 142 | PM8921_MPP_INIT(7, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_LOW), |
| 143 | PM8921_MPP_INIT(8, D_OUTPUT, PM8921_MPP_DIG_LEVEL_S4, DOUT_CTRL_LOW), |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | void __init apq8064_pm8xxx_gpio_mpp_init(void) |
| 147 | { |
| 148 | int i, rc; |
| 149 | |
| 150 | for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) { |
| 151 | rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio, |
| 152 | &pm8921_gpios[i].config); |
| 153 | if (rc) { |
| 154 | pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc); |
| 155 | break; |
| 156 | } |
| 157 | } |
| 158 | |
Mohan Pallaka | 474b94b | 2012-01-25 12:59:58 +0530 | [diff] [blame] | 159 | if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid()) |
| 160 | for (i = 0; i < ARRAY_SIZE(pm8921_cdp_kp_gpios); i++) { |
| 161 | rc = pm8xxx_gpio_config(pm8921_cdp_kp_gpios[i].gpio, |
| 162 | &pm8921_cdp_kp_gpios[i].config); |
| 163 | if (rc) { |
| 164 | pr_err("%s: pm8xxx_gpio_config: rc=%d\n", |
| 165 | __func__, rc); |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if (machine_is_apq8064_mtp()) |
| 171 | for (i = 0; i < ARRAY_SIZE(pm8921_mtp_kp_gpios); i++) { |
| 172 | rc = pm8xxx_gpio_config(pm8921_mtp_kp_gpios[i].gpio, |
| 173 | &pm8921_mtp_kp_gpios[i].config); |
| 174 | if (rc) { |
| 175 | pr_err("%s: pm8xxx_gpio_config: rc=%d\n", |
| 176 | __func__, rc); |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 181 | for (i = 0; i < ARRAY_SIZE(pm8xxx_mpps); i++) { |
| 182 | rc = pm8xxx_mpp_config(pm8xxx_mpps[i].mpp, |
| 183 | &pm8xxx_mpps[i].config); |
| 184 | if (rc) { |
| 185 | pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc); |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | static struct pm8xxx_pwrkey_platform_data apq8064_pm8921_pwrkey_pdata = { |
| 192 | .pull_up = 1, |
| 193 | .kpd_trigger_delay_us = 15625, |
| 194 | .wakeup = 1, |
| 195 | }; |
| 196 | |
| 197 | static struct pm8xxx_misc_platform_data apq8064_pm8921_misc_pdata = { |
| 198 | .priority = 0, |
| 199 | }; |
| 200 | |
| 201 | #define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */ |
| 202 | #define PM8921_LC_LED_LOW_CURRENT 1 /* I = 1mA */ |
| 203 | #define PM8XXX_LED_PWM_PERIOD 1000 |
| 204 | #define PM8XXX_LED_PWM_DUTY_MS 20 |
| 205 | /** |
| 206 | * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be |
| 207 | * driven using PWM feature. |
| 208 | */ |
| 209 | #define PM8XXX_PWM_CHANNEL_NONE -1 |
| 210 | |
| 211 | static struct led_info pm8921_led_info[] = { |
| 212 | [0] = { |
| 213 | .name = "led:red", |
| 214 | .default_trigger = "ac-online", |
| 215 | }, |
| 216 | }; |
| 217 | |
| 218 | static struct led_platform_data pm8921_led_core_pdata = { |
| 219 | .num_leds = ARRAY_SIZE(pm8921_led_info), |
| 220 | .leds = pm8921_led_info, |
| 221 | }; |
| 222 | |
| 223 | static int pm8921_led0_pwm_duty_pcts[56] = { |
| 224 | 1, 4, 8, 12, 16, 20, 24, 28, 32, 36, |
| 225 | 40, 44, 46, 52, 56, 60, 64, 68, 72, 76, |
| 226 | 80, 84, 88, 92, 96, 100, 100, 100, 98, 95, |
| 227 | 92, 88, 84, 82, 78, 74, 70, 66, 62, 58, |
| 228 | 58, 54, 50, 48, 42, 38, 34, 30, 26, 22, |
| 229 | 14, 10, 6, 4, 1 |
| 230 | }; |
| 231 | |
| 232 | static struct pm8xxx_pwm_duty_cycles pm8921_led0_pwm_duty_cycles = { |
| 233 | .duty_pcts = (int *)&pm8921_led0_pwm_duty_pcts, |
| 234 | .num_duty_pcts = ARRAY_SIZE(pm8921_led0_pwm_duty_pcts), |
| 235 | .duty_ms = PM8XXX_LED_PWM_DUTY_MS, |
| 236 | .start_idx = 0, |
| 237 | }; |
| 238 | |
| 239 | static struct pm8xxx_led_config pm8921_led_configs[] = { |
| 240 | [0] = { |
| 241 | .id = PM8XXX_ID_LED_0, |
| 242 | .mode = PM8XXX_LED_MODE_PWM2, |
| 243 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 244 | .pwm_channel = 5, |
| 245 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD, |
| 246 | .pwm_duty_cycles = &pm8921_led0_pwm_duty_cycles, |
| 247 | }, |
| 248 | }; |
| 249 | |
| 250 | static struct pm8xxx_led_platform_data apq8064_pm8921_leds_pdata = { |
| 251 | .led_core = &pm8921_led_core_pdata, |
| 252 | .configs = pm8921_led_configs, |
| 253 | .num_configs = ARRAY_SIZE(pm8921_led_configs), |
| 254 | }; |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 255 | |
Jay Chokshi | f3a9ea8 | 2012-01-12 16:34:43 -0800 | [diff] [blame] | 256 | static struct pm8xxx_adc_amux apq8064_pm8921_adc_channels_data[] = { |
| 257 | {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 258 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 259 | {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 260 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 261 | {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1, |
| 262 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 263 | {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 264 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 265 | {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 266 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 267 | {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 268 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 269 | {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2, |
| 270 | ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM}, |
| 271 | {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 272 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 273 | {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1, |
| 274 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 275 | {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 276 | ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM}, |
| 277 | {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 278 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 279 | {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 280 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 281 | {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 282 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 283 | {"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0, |
| 284 | ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM}, |
| 285 | }; |
| 286 | |
| 287 | static struct pm8xxx_adc_properties apq8064_pm8921_adc_data = { |
| 288 | .adc_vdd_reference = 1800, /* milli-voltage for this adc */ |
| 289 | .bitresolution = 15, |
| 290 | .bipolar = 0, |
| 291 | }; |
| 292 | |
| 293 | static struct pm8xxx_adc_platform_data apq8064_pm8921_adc_pdata = { |
| 294 | .adc_channel = apq8064_pm8921_adc_channels_data, |
| 295 | .adc_num_board_channel = ARRAY_SIZE(apq8064_pm8921_adc_channels_data), |
| 296 | .adc_prop = &apq8064_pm8921_adc_data, |
| 297 | .adc_mpp_base = PM8921_MPP_PM_TO_SYS(1), |
| 298 | }; |
| 299 | |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 300 | static struct pm8xxx_mpp_platform_data |
| 301 | apq8064_pm8921_mpp_pdata __devinitdata = { |
| 302 | .mpp_base = PM8921_MPP_PM_TO_SYS(1), |
| 303 | }; |
| 304 | |
| 305 | static struct pm8xxx_gpio_platform_data |
| 306 | apq8064_pm8921_gpio_pdata __devinitdata = { |
| 307 | .gpio_base = PM8921_GPIO_PM_TO_SYS(1), |
| 308 | }; |
| 309 | |
| 310 | static struct pm8xxx_irq_platform_data |
| 311 | apq8064_pm8921_irq_pdata __devinitdata = { |
| 312 | .irq_base = PM8921_IRQ_BASE, |
Jeffrey Chuang | a92c7ab | 2012-03-01 23:56:00 -0800 | [diff] [blame^] | 313 | .devirq = MSM_GPIO_TO_INT(74), |
| 314 | .irq_trigger_flag = IRQF_TRIGGER_LOW, |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 315 | .dev_id = 0, |
| 316 | }; |
| 317 | |
Ashay Jaiswal | 0b023dc | 2012-01-25 10:18:36 +0530 | [diff] [blame] | 318 | static struct pm8xxx_rtc_platform_data |
| 319 | apq8064_pm8921_rtc_pdata = { |
| 320 | .rtc_write_enable = false, |
| 321 | .rtc_alarm_powerup = false, |
| 322 | }; |
| 323 | |
Jay Chokshi | 42fe9f0 | 2012-02-01 20:52:08 -0800 | [diff] [blame] | 324 | static int apq8064_pm8921_therm_mitigation[] = { |
| 325 | 1100, |
| 326 | 700, |
| 327 | 600, |
| 328 | 325, |
| 329 | }; |
| 330 | |
| 331 | #define MAX_VOLTAGE_MV 4200 |
| 332 | static struct pm8921_charger_platform_data |
| 333 | apq8064_pm8921_chg_pdata __devinitdata = { |
| 334 | .safety_time = 180, |
| 335 | .update_time = 60000, |
| 336 | .max_voltage = MAX_VOLTAGE_MV, |
| 337 | .min_voltage = 3200, |
| 338 | .resume_voltage_delta = 100, |
| 339 | .term_current = 100, |
| 340 | .cool_temp = 10, |
| 341 | .warm_temp = 40, |
| 342 | .temp_check_period = 1, |
| 343 | .max_bat_chg_current = 1100, |
| 344 | .cool_bat_chg_current = 350, |
| 345 | .warm_bat_chg_current = 350, |
| 346 | .cool_bat_voltage = 4100, |
| 347 | .warm_bat_voltage = 4100, |
| 348 | .thermal_mitigation = apq8064_pm8921_therm_mitigation, |
| 349 | .thermal_levels = ARRAY_SIZE(apq8064_pm8921_therm_mitigation), |
| 350 | }; |
| 351 | |
| 352 | static struct pm8xxx_ccadc_platform_data |
| 353 | apq8064_pm8xxx_ccadc_pdata = { |
| 354 | .r_sense = 10, |
| 355 | }; |
| 356 | |
| 357 | static struct pm8921_bms_platform_data |
| 358 | apq8064_pm8921_bms_pdata __devinitdata = { |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 359 | .battery_type = BATT_UNKNOWN, |
Jay Chokshi | 42fe9f0 | 2012-02-01 20:52:08 -0800 | [diff] [blame] | 360 | .r_sense = 10, |
| 361 | .i_test = 2500, |
| 362 | .v_failure = 3000, |
| 363 | .calib_delay_ms = 600000, |
| 364 | .max_voltage_uv = MAX_VOLTAGE_MV * 1000, |
| 365 | }; |
| 366 | |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 367 | static struct pm8921_platform_data |
| 368 | apq8064_pm8921_platform_data __devinitdata = { |
| 369 | .regulator_pdatas = msm8064_pm8921_regulator_pdata, |
| 370 | .irq_pdata = &apq8064_pm8921_irq_pdata, |
| 371 | .gpio_pdata = &apq8064_pm8921_gpio_pdata, |
| 372 | .mpp_pdata = &apq8064_pm8921_mpp_pdata, |
Ashay Jaiswal | 0b023dc | 2012-01-25 10:18:36 +0530 | [diff] [blame] | 373 | .rtc_pdata = &apq8064_pm8921_rtc_pdata, |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 374 | .pwrkey_pdata = &apq8064_pm8921_pwrkey_pdata, |
| 375 | .misc_pdata = &apq8064_pm8921_misc_pdata, |
| 376 | .leds_pdata = &apq8064_pm8921_leds_pdata, |
Jay Chokshi | f3a9ea8 | 2012-01-12 16:34:43 -0800 | [diff] [blame] | 377 | .adc_pdata = &apq8064_pm8921_adc_pdata, |
Jay Chokshi | 42fe9f0 | 2012-02-01 20:52:08 -0800 | [diff] [blame] | 378 | .charger_pdata = &apq8064_pm8921_chg_pdata, |
| 379 | .bms_pdata = &apq8064_pm8921_bms_pdata, |
| 380 | .ccadc_pdata = &apq8064_pm8xxx_ccadc_pdata, |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | static struct pm8xxx_irq_platform_data |
| 384 | apq8064_pm8821_irq_pdata __devinitdata = { |
| 385 | .irq_base = PM8821_IRQ_BASE, |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 386 | .devirq = PM8821_SEC_IRQ_N, |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 387 | .irq_trigger_flag = IRQF_TRIGGER_HIGH, |
| 388 | .dev_id = 1, |
| 389 | }; |
| 390 | |
| 391 | static struct pm8xxx_mpp_platform_data |
| 392 | apq8064_pm8821_mpp_pdata __devinitdata = { |
| 393 | .mpp_base = PM8821_MPP_PM_TO_SYS(1), |
| 394 | }; |
| 395 | |
| 396 | static struct pm8821_platform_data |
| 397 | apq8064_pm8821_platform_data __devinitdata = { |
| 398 | .irq_pdata = &apq8064_pm8821_irq_pdata, |
| 399 | .mpp_pdata = &apq8064_pm8821_mpp_pdata, |
| 400 | }; |
| 401 | |
| 402 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = { |
| 403 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 404 | .slave = { |
| 405 | .name = "pm8921-core", |
| 406 | .platform_data = &apq8064_pm8921_platform_data, |
| 407 | }, |
| 408 | }; |
| 409 | |
| 410 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = { |
| 411 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 412 | .slave = { |
| 413 | .name = "pm8821-core", |
| 414 | .platform_data = &apq8064_pm8821_platform_data, |
| 415 | }, |
| 416 | }; |
| 417 | |
| 418 | void __init apq8064_init_pmic(void) |
| 419 | { |
Jay Chokshi | e874128 | 2012-01-25 15:22:55 -0800 | [diff] [blame] | 420 | pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ; |
| 421 | |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 422 | apq8064_device_ssbi_pmic1.dev.platform_data = |
| 423 | &apq8064_ssbi_pm8921_pdata; |
| 424 | apq8064_device_ssbi_pmic2.dev.platform_data = |
| 425 | &apq8064_ssbi_pm8821_pdata; |
| 426 | apq8064_pm8921_platform_data.num_regulators = |
| 427 | msm8064_pm8921_regulator_pdata_len; |
| 428 | |
| 429 | if (machine_is_apq8064_rumi3()) { |
| 430 | apq8064_pm8921_irq_pdata.devirq = 0; |
| 431 | apq8064_pm8821_irq_pdata.devirq = 0; |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 432 | } else if (machine_is_apq8064_mtp()) { |
| 433 | apq8064_pm8921_bms_pdata.battery_type = BATT_PALLADIUM; |
| 434 | } else if (machine_is_apq8064_liquid()) { |
| 435 | apq8064_pm8921_bms_pdata.battery_type = BATT_DESAY; |
Stepan Moskovchenko | c1074f0 | 2011-12-14 17:51:57 -0800 | [diff] [blame] | 436 | } |
| 437 | } |