Amir Samuelov | 7f0cc07 | 2012-02-07 09:23:57 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -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/interrupt.h> |
| 15 | #include <linux/mfd/pm8xxx/pm8921.h> |
| 16 | #include <linux/mfd/pm8xxx/pm8xxx-adc.h> |
| 17 | #include <linux/leds.h> |
| 18 | #include <linux/leds-pm8xxx.h> |
| 19 | #include <linux/msm_ssbi.h> |
| 20 | #include <asm/mach-types.h> |
| 21 | #include <mach/msm_bus_board.h> |
| 22 | #include <mach/restart.h> |
| 23 | #include "devices.h" |
Stepan Moskovchenko | 5a83dba | 2011-12-05 17:30:17 -0800 | [diff] [blame] | 24 | #include "board-8960.h" |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 25 | |
| 26 | struct pm8xxx_gpio_init { |
| 27 | unsigned gpio; |
| 28 | struct pm_gpio config; |
| 29 | }; |
| 30 | |
| 31 | struct pm8xxx_mpp_init { |
| 32 | unsigned mpp; |
| 33 | struct pm8xxx_mpp_config_data config; |
| 34 | }; |
| 35 | |
| 36 | #define PM8XXX_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \ |
| 37 | _func, _inv, _disable) \ |
| 38 | { \ |
| 39 | .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \ |
| 40 | .config = { \ |
| 41 | .direction = _dir, \ |
| 42 | .output_buffer = _buf, \ |
| 43 | .output_value = _val, \ |
| 44 | .pull = _pull, \ |
| 45 | .vin_sel = _vin, \ |
| 46 | .out_strength = _out_strength, \ |
| 47 | .function = _func, \ |
| 48 | .inv_int_pol = _inv, \ |
| 49 | .disable_pin = _disable, \ |
| 50 | } \ |
| 51 | } |
| 52 | |
| 53 | #define PM8XXX_MPP_INIT(_mpp, _type, _level, _control) \ |
| 54 | { \ |
| 55 | .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \ |
| 56 | .config = { \ |
| 57 | .type = PM8XXX_MPP_TYPE_##_type, \ |
| 58 | .level = _level, \ |
| 59 | .control = PM8XXX_MPP_##_control, \ |
| 60 | } \ |
| 61 | } |
| 62 | |
| 63 | #define PM8XXX_GPIO_DISABLE(_gpio) \ |
| 64 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \ |
| 65 | 0, 0, 0, 1) |
| 66 | |
| 67 | #define PM8XXX_GPIO_OUTPUT(_gpio, _val) \ |
| 68 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 69 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 70 | PM_GPIO_STRENGTH_HIGH, \ |
| 71 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 72 | |
| 73 | #define PM8XXX_GPIO_INPUT(_gpio, _pull) \ |
| 74 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \ |
| 75 | _pull, PM_GPIO_VIN_S4, \ |
| 76 | PM_GPIO_STRENGTH_NO, \ |
| 77 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 78 | |
| 79 | #define PM8XXX_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \ |
| 80 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 81 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 82 | PM_GPIO_STRENGTH_HIGH, \ |
| 83 | _func, 0, 0) |
| 84 | |
| 85 | #define PM8XXX_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \ |
| 86 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 87 | PM_GPIO_PULL_NO, _vin, \ |
| 88 | PM_GPIO_STRENGTH_HIGH, \ |
| 89 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 90 | |
Shiv Maliyappanahalli | 7e0beff | 2012-02-06 15:56:39 -0800 | [diff] [blame] | 91 | #define PM8XXX_GPIO_OUTPUT_STRENGTH(_gpio, _val, _out_strength) \ |
| 92 | PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \ |
| 93 | PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \ |
| 94 | _out_strength, \ |
| 95 | PM_GPIO_FUNC_NORMAL, 0, 0) |
| 96 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 97 | /* Initial PM8921 GPIO configurations */ |
| 98 | static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = { |
Eugene Yasman | 97ee5c6 | 2011-12-20 16:20:42 +0200 | [diff] [blame] | 99 | PM8XXX_GPIO_OUTPUT_VIN(6, 1, PM_GPIO_VIN_VPH), /* MHL power EN_N */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 100 | PM8XXX_GPIO_DISABLE(7), /* Disable NFC */ |
| 101 | PM8XXX_GPIO_INPUT(16, PM_GPIO_PULL_UP_30), /* SD_CARD_WP */ |
| 102 | /* External regulator shared by display and touchscreen on LiQUID */ |
| 103 | PM8XXX_GPIO_OUTPUT(17, 0), /* DISP 3.3 V Boost */ |
Amir Samuelov | 99fe33c | 2012-03-27 09:41:49 +0200 | [diff] [blame] | 104 | PM8XXX_GPIO_OUTPUT(18, 0), /* TABLA SPKR_LEFT_EN=off */ |
| 105 | PM8XXX_GPIO_OUTPUT(19, 0), /* TABLA SPKR_RIGHT_EN=off */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 106 | PM8XXX_GPIO_DISABLE(22), /* Disable NFC */ |
Amir Samuelov | 7f0cc07 | 2012-02-07 09:23:57 +0200 | [diff] [blame] | 107 | PM8XXX_GPIO_OUTPUT_FUNC(25, 0, PM_GPIO_FUNC_2), /* TN_CLK */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 108 | PM8XXX_GPIO_INPUT(26, PM_GPIO_PULL_UP_30), /* SD_CARD_DET_N */ |
Chandan Uddaraju | 2679f09 | 2012-03-09 15:48:04 -0800 | [diff] [blame] | 109 | PM8XXX_GPIO_OUTPUT(43, 1), /* DISP_RESET_N */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 110 | PM8XXX_GPIO_OUTPUT(42, 0), /* USB 5V reg enable */ |
Shiv Maliyappanahalli | 7e0beff | 2012-02-06 15:56:39 -0800 | [diff] [blame] | 111 | /* TABLA CODEC RESET */ |
| 112 | PM8XXX_GPIO_OUTPUT_STRENGTH(34, 1, PM_GPIO_STRENGTH_MED) |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /* Initial PM8921 MPP configurations */ |
| 116 | static struct pm8xxx_mpp_init pm8921_mpps[] __initdata = { |
| 117 | /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */ |
| 118 | PM8XXX_MPP_INIT(7, D_INPUT, PM8921_MPP_DIG_LEVEL_VPH, DIN_TO_INT), |
| 119 | PM8XXX_MPP_INIT(PM8XXX_AMUX_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8, |
| 120 | DOUT_CTRL_LOW), |
| 121 | }; |
| 122 | |
| 123 | void __init msm8960_pm8921_gpio_mpp_init(void) |
| 124 | { |
| 125 | int i, rc; |
| 126 | |
| 127 | for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) { |
| 128 | rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio, |
| 129 | &pm8921_gpios[i].config); |
| 130 | if (rc) { |
| 131 | pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc); |
| 132 | break; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | for (i = 0; i < ARRAY_SIZE(pm8921_mpps); i++) { |
| 137 | rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp, |
| 138 | &pm8921_mpps[i].config); |
| 139 | if (rc) { |
| 140 | pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc); |
| 141 | break; |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | static struct pm8xxx_adc_amux pm8xxx_adc_channels_data[] = { |
| 147 | {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 148 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 149 | {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 150 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 151 | {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1, |
| 152 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 153 | {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 154 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 155 | {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 156 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 157 | {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 158 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 159 | {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2, |
| 160 | ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM}, |
| 161 | {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 162 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 163 | {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1, |
| 164 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 165 | {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 166 | ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM}, |
| 167 | {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 168 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 169 | {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 170 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 171 | {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 172 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 173 | {"pa_therm1", ADC_MPP_1_AMUX8, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 174 | ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM}, |
| 175 | {"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0, |
| 176 | ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM}, |
| 177 | {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 178 | ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM}, |
| 179 | }; |
| 180 | |
| 181 | static struct pm8xxx_adc_properties pm8xxx_adc_data = { |
| 182 | .adc_vdd_reference = 1800, /* milli-voltage for this adc */ |
| 183 | .bitresolution = 15, |
| 184 | .bipolar = 0, |
| 185 | }; |
| 186 | |
| 187 | static struct pm8xxx_adc_platform_data pm8xxx_adc_pdata = { |
| 188 | .adc_channel = pm8xxx_adc_channels_data, |
| 189 | .adc_num_board_channel = ARRAY_SIZE(pm8xxx_adc_channels_data), |
| 190 | .adc_prop = &pm8xxx_adc_data, |
| 191 | .adc_mpp_base = PM8921_MPP_PM_TO_SYS(1), |
| 192 | }; |
| 193 | |
| 194 | static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = { |
| 195 | .irq_base = PM8921_IRQ_BASE, |
| 196 | .devirq = MSM_GPIO_TO_INT(104), |
| 197 | .irq_trigger_flag = IRQF_TRIGGER_LOW, |
| 198 | }; |
| 199 | |
| 200 | static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = { |
| 201 | .gpio_base = PM8921_GPIO_PM_TO_SYS(1), |
| 202 | }; |
| 203 | |
| 204 | static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = { |
| 205 | .mpp_base = PM8921_MPP_PM_TO_SYS(1), |
| 206 | }; |
| 207 | |
| 208 | static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = { |
| 209 | .rtc_write_enable = false, |
| 210 | .rtc_alarm_powerup = false, |
| 211 | }; |
| 212 | |
| 213 | static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = { |
| 214 | .pull_up = 1, |
Jing Lin | eecdc06 | 2011-11-17 09:47:09 -0800 | [diff] [blame] | 215 | .kpd_trigger_delay_us = 15625, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 216 | .wakeup = 1, |
| 217 | }; |
| 218 | |
| 219 | /* Rotate lock key is not available so use F1 */ |
| 220 | #define KEY_ROTATE_LOCK KEY_F1 |
| 221 | |
| 222 | static const unsigned int keymap_liquid[] = { |
| 223 | KEY(0, 0, KEY_VOLUMEUP), |
| 224 | KEY(0, 1, KEY_VOLUMEDOWN), |
| 225 | KEY(1, 3, KEY_ROTATE_LOCK), |
| 226 | KEY(1, 4, KEY_HOME), |
| 227 | }; |
| 228 | |
| 229 | static struct matrix_keymap_data keymap_data_liquid = { |
| 230 | .keymap_size = ARRAY_SIZE(keymap_liquid), |
| 231 | .keymap = keymap_liquid, |
| 232 | }; |
| 233 | |
| 234 | static struct pm8xxx_keypad_platform_data keypad_data_liquid = { |
| 235 | .input_name = "keypad_8960_liquid", |
| 236 | .input_phys_device = "keypad_8960/input0", |
| 237 | .num_rows = 2, |
| 238 | .num_cols = 5, |
| 239 | .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9), |
| 240 | .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1), |
| 241 | .debounce_ms = 15, |
| 242 | .scan_delay_ms = 32, |
| 243 | .row_hold_ns = 91500, |
| 244 | .wakeup = 1, |
| 245 | .keymap_data = &keymap_data_liquid, |
| 246 | }; |
| 247 | |
| 248 | |
| 249 | static const unsigned int keymap[] = { |
| 250 | KEY(0, 0, KEY_VOLUMEUP), |
| 251 | KEY(0, 1, KEY_VOLUMEDOWN), |
| 252 | KEY(0, 2, KEY_CAMERA_SNAPSHOT), |
| 253 | KEY(0, 3, KEY_CAMERA_FOCUS), |
| 254 | }; |
| 255 | |
| 256 | static struct matrix_keymap_data keymap_data = { |
| 257 | .keymap_size = ARRAY_SIZE(keymap), |
| 258 | .keymap = keymap, |
| 259 | }; |
| 260 | |
| 261 | static struct pm8xxx_keypad_platform_data keypad_data = { |
| 262 | .input_name = "keypad_8960", |
| 263 | .input_phys_device = "keypad_8960/input0", |
| 264 | .num_rows = 1, |
| 265 | .num_cols = 5, |
| 266 | .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9), |
| 267 | .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1), |
| 268 | .debounce_ms = 15, |
| 269 | .scan_delay_ms = 32, |
| 270 | .row_hold_ns = 91500, |
| 271 | .wakeup = 1, |
| 272 | .keymap_data = &keymap_data, |
| 273 | }; |
| 274 | |
| 275 | static const unsigned int keymap_sim[] = { |
| 276 | KEY(0, 0, KEY_7), |
| 277 | KEY(0, 1, KEY_DOWN), |
| 278 | KEY(0, 2, KEY_UP), |
| 279 | KEY(0, 3, KEY_RIGHT), |
| 280 | KEY(0, 4, KEY_ENTER), |
| 281 | KEY(0, 5, KEY_L), |
| 282 | KEY(0, 6, KEY_BACK), |
| 283 | KEY(0, 7, KEY_M), |
| 284 | |
| 285 | KEY(1, 0, KEY_LEFT), |
| 286 | KEY(1, 1, KEY_SEND), |
| 287 | KEY(1, 2, KEY_1), |
| 288 | KEY(1, 3, KEY_4), |
| 289 | KEY(1, 4, KEY_CLEAR), |
| 290 | KEY(1, 5, KEY_MSDOS), |
| 291 | KEY(1, 6, KEY_SPACE), |
| 292 | KEY(1, 7, KEY_COMMA), |
| 293 | |
| 294 | KEY(2, 0, KEY_6), |
| 295 | KEY(2, 1, KEY_5), |
| 296 | KEY(2, 2, KEY_8), |
| 297 | KEY(2, 3, KEY_3), |
| 298 | KEY(2, 4, KEY_NUMERIC_STAR), |
| 299 | KEY(2, 5, KEY_UP), |
| 300 | KEY(2, 6, KEY_DOWN), |
| 301 | KEY(2, 7, KEY_LEFTSHIFT), |
| 302 | |
| 303 | KEY(3, 0, KEY_9), |
| 304 | KEY(3, 1, KEY_NUMERIC_POUND), |
| 305 | KEY(3, 2, KEY_0), |
| 306 | KEY(3, 3, KEY_2), |
| 307 | KEY(3, 4, KEY_SLEEP), |
| 308 | KEY(3, 5, KEY_F1), |
| 309 | KEY(3, 6, KEY_F2), |
| 310 | KEY(3, 7, KEY_F3), |
| 311 | |
| 312 | KEY(4, 0, KEY_BACK), |
| 313 | KEY(4, 1, KEY_HOME), |
| 314 | KEY(4, 2, KEY_MENU), |
| 315 | KEY(4, 3, KEY_VOLUMEUP), |
| 316 | KEY(4, 4, KEY_VOLUMEDOWN), |
| 317 | KEY(4, 5, KEY_F4), |
| 318 | KEY(4, 6, KEY_F5), |
| 319 | KEY(4, 7, KEY_F6), |
| 320 | |
| 321 | KEY(5, 0, KEY_R), |
| 322 | KEY(5, 1, KEY_T), |
| 323 | KEY(5, 2, KEY_Y), |
| 324 | KEY(5, 3, KEY_LEFTALT), |
| 325 | KEY(5, 4, KEY_KPENTER), |
| 326 | KEY(5, 5, KEY_Q), |
| 327 | KEY(5, 6, KEY_W), |
| 328 | KEY(5, 7, KEY_E), |
| 329 | |
| 330 | KEY(6, 0, KEY_F), |
| 331 | KEY(6, 1, KEY_G), |
| 332 | KEY(6, 2, KEY_H), |
| 333 | KEY(6, 3, KEY_CAPSLOCK), |
| 334 | KEY(6, 4, KEY_PAGEUP), |
| 335 | KEY(6, 5, KEY_A), |
| 336 | KEY(6, 6, KEY_S), |
| 337 | KEY(6, 7, KEY_D), |
| 338 | |
| 339 | KEY(7, 0, KEY_V), |
| 340 | KEY(7, 1, KEY_B), |
| 341 | KEY(7, 2, KEY_N), |
| 342 | KEY(7, 3, KEY_MENU), |
| 343 | KEY(7, 4, KEY_PAGEDOWN), |
| 344 | KEY(7, 5, KEY_Z), |
| 345 | KEY(7, 6, KEY_X), |
| 346 | KEY(7, 7, KEY_C), |
| 347 | |
| 348 | KEY(8, 0, KEY_P), |
| 349 | KEY(8, 1, KEY_J), |
| 350 | KEY(8, 2, KEY_K), |
| 351 | KEY(8, 3, KEY_INSERT), |
| 352 | KEY(8, 4, KEY_LINEFEED), |
| 353 | KEY(8, 5, KEY_U), |
| 354 | KEY(8, 6, KEY_I), |
| 355 | KEY(8, 7, KEY_O), |
| 356 | |
| 357 | KEY(9, 0, KEY_4), |
| 358 | KEY(9, 1, KEY_5), |
| 359 | KEY(9, 2, KEY_6), |
| 360 | KEY(9, 3, KEY_7), |
| 361 | KEY(9, 4, KEY_8), |
| 362 | KEY(9, 5, KEY_1), |
| 363 | KEY(9, 6, KEY_2), |
| 364 | KEY(9, 7, KEY_3), |
| 365 | |
| 366 | KEY(10, 0, KEY_F7), |
| 367 | KEY(10, 1, KEY_F8), |
| 368 | KEY(10, 2, KEY_F9), |
| 369 | KEY(10, 3, KEY_F10), |
| 370 | KEY(10, 4, KEY_FN), |
| 371 | KEY(10, 5, KEY_9), |
| 372 | KEY(10, 6, KEY_0), |
| 373 | KEY(10, 7, KEY_DOT), |
| 374 | |
| 375 | KEY(11, 0, KEY_LEFTCTRL), |
| 376 | KEY(11, 1, KEY_F11), |
| 377 | KEY(11, 2, KEY_ENTER), |
| 378 | KEY(11, 3, KEY_SEARCH), |
| 379 | KEY(11, 4, KEY_DELETE), |
| 380 | KEY(11, 5, KEY_RIGHT), |
| 381 | KEY(11, 6, KEY_LEFT), |
| 382 | KEY(11, 7, KEY_RIGHTSHIFT), |
| 383 | KEY(0, 0, KEY_VOLUMEUP), |
| 384 | KEY(0, 1, KEY_VOLUMEDOWN), |
| 385 | KEY(0, 2, KEY_CAMERA_SNAPSHOT), |
| 386 | KEY(0, 3, KEY_CAMERA_FOCUS), |
| 387 | }; |
| 388 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 389 | static int pm8921_therm_mitigation[] = { |
| 390 | 1100, |
| 391 | 700, |
| 392 | 600, |
| 393 | 325, |
| 394 | }; |
| 395 | |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 396 | #define MAX_VOLTAGE_MV 4200 |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 397 | static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = { |
| 398 | .safety_time = 180, |
| 399 | .update_time = 60000, |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 400 | .max_voltage = MAX_VOLTAGE_MV, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 401 | .min_voltage = 3200, |
David Keitel | 0789fc6 | 2012-06-07 17:43:27 -0700 | [diff] [blame] | 402 | .uvd_thresh_voltage = 4050, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 403 | .resume_voltage_delta = 100, |
| 404 | .term_current = 100, |
| 405 | .cool_temp = 10, |
| 406 | .warm_temp = 40, |
| 407 | .temp_check_period = 1, |
| 408 | .max_bat_chg_current = 1100, |
| 409 | .cool_bat_chg_current = 350, |
| 410 | .warm_bat_chg_current = 350, |
| 411 | .cool_bat_voltage = 4100, |
| 412 | .warm_bat_voltage = 4100, |
| 413 | .thermal_mitigation = pm8921_therm_mitigation, |
| 414 | .thermal_levels = ARRAY_SIZE(pm8921_therm_mitigation), |
Abhijeet Dharmapurikar | 40491ce | 2011-11-07 11:38:54 -0800 | [diff] [blame] | 415 | .rconn_mohm = 18, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 416 | }; |
| 417 | |
| 418 | static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = { |
| 419 | .priority = 0, |
| 420 | }; |
| 421 | |
| 422 | static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = { |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 423 | .battery_type = BATT_UNKNOWN, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 424 | .r_sense = 10, |
| 425 | .i_test = 2500, |
| 426 | .v_failure = 3000, |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 427 | .max_voltage_uv = MAX_VOLTAGE_MV * 1000, |
David Keitel | e643f16 | 2012-06-07 13:56:22 -0700 | [diff] [blame] | 428 | .rconn_mohm = 18, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 429 | }; |
| 430 | |
| 431 | #define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */ |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 432 | #define PM8921_LC_LED_LOW_CURRENT 1 /* I = 1mA */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 433 | #define PM8XXX_LED_PWM_PERIOD 1000 |
| 434 | #define PM8XXX_LED_PWM_DUTY_MS 20 |
| 435 | /** |
| 436 | * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be |
| 437 | * driven using PWM feature. |
| 438 | */ |
| 439 | #define PM8XXX_PWM_CHANNEL_NONE -1 |
| 440 | |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 441 | static struct led_info pm8921_led_info_liquid[] = { |
| 442 | { |
| 443 | .name = "led:red", |
| 444 | .flags = PM8XXX_ID_LED_0, |
Amy Maloche | 65a01a8 | 2012-01-30 12:36:42 -0800 | [diff] [blame] | 445 | .default_trigger = "battery-charging", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 446 | }, |
| 447 | { |
| 448 | .name = "led:green", |
| 449 | .flags = PM8XXX_ID_LED_0, |
Amy Maloche | 65a01a8 | 2012-01-30 12:36:42 -0800 | [diff] [blame] | 450 | .default_trigger = "battery-full", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 451 | }, |
| 452 | { |
| 453 | .name = "led:blue", |
| 454 | .flags = PM8XXX_ID_LED_2, |
Amir Samuelov | 4ffc8ec | 2012-05-16 09:38:43 +0300 | [diff] [blame] | 455 | .default_trigger = "notification", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 456 | }, |
| 457 | }; |
| 458 | |
| 459 | static struct pm8xxx_led_config pm8921_led_configs_liquid[] = { |
| 460 | [0] = { |
| 461 | .id = PM8XXX_ID_LED_0, |
| 462 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 463 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 464 | }, |
| 465 | [1] = { |
| 466 | .id = PM8XXX_ID_LED_1, |
| 467 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 468 | .max_current = PM8921_LC_LED_LOW_CURRENT, |
| 469 | }, |
| 470 | [2] = { |
| 471 | .id = PM8XXX_ID_LED_2, |
| 472 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 473 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 474 | }, |
| 475 | }; |
| 476 | |
| 477 | static struct led_platform_data pm8xxx_leds_core_liquid = { |
| 478 | .num_leds = ARRAY_SIZE(pm8921_led_info_liquid), |
| 479 | .leds = pm8921_led_info_liquid, |
| 480 | }; |
| 481 | |
| 482 | static struct pm8xxx_led_platform_data pm8xxx_leds_pdata_liquid = { |
| 483 | .led_core = &pm8xxx_leds_core_liquid, |
| 484 | .configs = pm8921_led_configs_liquid, |
| 485 | .num_configs = ARRAY_SIZE(pm8921_led_configs_liquid), |
| 486 | }; |
| 487 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 488 | static struct led_info pm8921_led_info[] = { |
| 489 | [0] = { |
| 490 | .name = "led:battery_charging", |
| 491 | .default_trigger = "battery-charging", |
| 492 | }, |
| 493 | [1] = { |
| 494 | .name = "led:battery_full", |
| 495 | .default_trigger = "battery-full", |
| 496 | }, |
| 497 | }; |
| 498 | |
| 499 | static struct led_platform_data pm8921_led_core_pdata = { |
| 500 | .num_leds = ARRAY_SIZE(pm8921_led_info), |
| 501 | .leds = pm8921_led_info, |
| 502 | }; |
| 503 | |
| 504 | static int pm8921_led0_pwm_duty_pcts[56] = { |
| 505 | 1, 4, 8, 12, 16, 20, 24, 28, 32, 36, |
| 506 | 40, 44, 46, 52, 56, 60, 64, 68, 72, 76, |
| 507 | 80, 84, 88, 92, 96, 100, 100, 100, 98, 95, |
| 508 | 92, 88, 84, 82, 78, 74, 70, 66, 62, 58, |
| 509 | 58, 54, 50, 48, 42, 38, 34, 30, 26, 22, |
| 510 | 14, 10, 6, 4, 1 |
| 511 | }; |
| 512 | |
Jay Chokshi | be51723 | 2012-06-15 18:20:56 -0700 | [diff] [blame] | 513 | /* |
| 514 | * Note: There is a bug in LPG module that results in incorrect |
| 515 | * behavior of pattern when LUT index 0 is used. So effectively |
| 516 | * there are 63 usable LUT entries. |
| 517 | */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 518 | static struct pm8xxx_pwm_duty_cycles pm8921_led0_pwm_duty_cycles = { |
| 519 | .duty_pcts = (int *)&pm8921_led0_pwm_duty_pcts, |
| 520 | .num_duty_pcts = ARRAY_SIZE(pm8921_led0_pwm_duty_pcts), |
| 521 | .duty_ms = PM8XXX_LED_PWM_DUTY_MS, |
Jay Chokshi | be51723 | 2012-06-15 18:20:56 -0700 | [diff] [blame] | 522 | .start_idx = 1, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 523 | }; |
| 524 | |
| 525 | static struct pm8xxx_led_config pm8921_led_configs[] = { |
| 526 | [0] = { |
| 527 | .id = PM8XXX_ID_LED_0, |
| 528 | .mode = PM8XXX_LED_MODE_PWM2, |
| 529 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 530 | .pwm_channel = 5, |
| 531 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD, |
| 532 | .pwm_duty_cycles = &pm8921_led0_pwm_duty_cycles, |
| 533 | }, |
| 534 | [1] = { |
| 535 | .id = PM8XXX_ID_LED_1, |
| 536 | .mode = PM8XXX_LED_MODE_PWM1, |
| 537 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 538 | .pwm_channel = 4, |
| 539 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD, |
| 540 | }, |
| 541 | }; |
| 542 | |
| 543 | static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = { |
| 544 | .led_core = &pm8921_led_core_pdata, |
| 545 | .configs = pm8921_led_configs, |
| 546 | .num_configs = ARRAY_SIZE(pm8921_led_configs), |
| 547 | }; |
| 548 | |
| 549 | static struct pm8xxx_ccadc_platform_data pm8xxx_ccadc_pdata = { |
| 550 | .r_sense = 10, |
David Keitel | 3c37882 | 2012-06-07 13:43:22 -0700 | [diff] [blame] | 551 | .calib_delay_ms = 600000, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 552 | }; |
| 553 | |
Jay Chokshi | 63c3bcc | 2012-02-27 18:54:37 -0800 | [diff] [blame] | 554 | /** |
| 555 | * PM8XXX_PWM_DTEST_CHANNEL_NONE shall be used when no LPG |
| 556 | * channel should be in DTEST mode. |
| 557 | */ |
| 558 | |
| 559 | #define PM8XXX_PWM_DTEST_CHANNEL_NONE (-1) |
| 560 | |
| 561 | static struct pm8xxx_pwm_platform_data pm8xxx_pwm_pdata = { |
| 562 | .dtest_channel = PM8XXX_PWM_DTEST_CHANNEL_NONE, |
| 563 | }; |
| 564 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 565 | static struct pm8921_platform_data pm8921_platform_data __devinitdata = { |
| 566 | .irq_pdata = &pm8xxx_irq_pdata, |
| 567 | .gpio_pdata = &pm8xxx_gpio_pdata, |
| 568 | .mpp_pdata = &pm8xxx_mpp_pdata, |
| 569 | .rtc_pdata = &pm8xxx_rtc_pdata, |
| 570 | .pwrkey_pdata = &pm8xxx_pwrkey_pdata, |
| 571 | .keypad_pdata = &keypad_data, |
| 572 | .misc_pdata = &pm8xxx_misc_pdata, |
| 573 | .regulator_pdatas = msm_pm8921_regulator_pdata, |
| 574 | .charger_pdata = &pm8921_chg_pdata, |
| 575 | .bms_pdata = &pm8921_bms_pdata, |
| 576 | .adc_pdata = &pm8xxx_adc_pdata, |
| 577 | .leds_pdata = &pm8xxx_leds_pdata, |
| 578 | .ccadc_pdata = &pm8xxx_ccadc_pdata, |
Jay Chokshi | 63c3bcc | 2012-02-27 18:54:37 -0800 | [diff] [blame] | 579 | .pwm_pdata = &pm8xxx_pwm_pdata, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 580 | }; |
| 581 | |
| 582 | static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = { |
| 583 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 584 | .slave = { |
| 585 | .name = "pm8921-core", |
| 586 | .platform_data = &pm8921_platform_data, |
| 587 | }, |
| 588 | }; |
| 589 | |
| 590 | void __init msm8960_init_pmic(void) |
| 591 | { |
| 592 | pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ; |
Jay Chokshi | 33c044a | 2011-12-07 13:05:40 -0800 | [diff] [blame] | 593 | msm8960_device_ssbi_pmic.dev.platform_data = |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 594 | &msm8960_ssbi_pm8921_pdata; |
| 595 | pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len; |
| 596 | |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 597 | if (machine_is_msm8960_liquid()) { |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 598 | pm8921_platform_data.keypad_pdata = &keypad_data_liquid; |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 599 | pm8921_platform_data.leds_pdata = &pm8xxx_leds_pdata_liquid; |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 600 | pm8921_platform_data.bms_pdata->battery_type = BATT_DESAY; |
| 601 | } else if (machine_is_msm8960_mtp()) { |
| 602 | pm8921_platform_data.bms_pdata->battery_type = BATT_PALLADIUM; |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 603 | } |
Abhijeet Dharmapurikar | baffba4 | 2012-03-22 14:41:10 -0700 | [diff] [blame] | 604 | |
| 605 | if (machine_is_msm8960_fluid()) |
| 606 | pm8921_bms_pdata.rconn_mohm = 20; |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 607 | } |