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 | |
| 389 | static struct matrix_keymap_data keymap_data_sim = { |
| 390 | .keymap_size = ARRAY_SIZE(keymap_sim), |
| 391 | .keymap = keymap_sim, |
| 392 | }; |
| 393 | |
| 394 | static struct pm8xxx_keypad_platform_data keypad_data_sim = { |
| 395 | .input_name = "keypad_8960", |
| 396 | .input_phys_device = "keypad_8960/input0", |
| 397 | .num_rows = 12, |
| 398 | .num_cols = 8, |
| 399 | .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9), |
| 400 | .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1), |
| 401 | .debounce_ms = 15, |
| 402 | .scan_delay_ms = 32, |
| 403 | .row_hold_ns = 91500, |
| 404 | .wakeup = 1, |
| 405 | .keymap_data = &keymap_data_sim, |
| 406 | }; |
| 407 | |
| 408 | static int pm8921_therm_mitigation[] = { |
| 409 | 1100, |
| 410 | 700, |
| 411 | 600, |
| 412 | 325, |
| 413 | }; |
| 414 | |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 415 | #define MAX_VOLTAGE_MV 4200 |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 416 | static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = { |
| 417 | .safety_time = 180, |
| 418 | .update_time = 60000, |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 419 | .max_voltage = MAX_VOLTAGE_MV, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 420 | .min_voltage = 3200, |
| 421 | .resume_voltage_delta = 100, |
| 422 | .term_current = 100, |
| 423 | .cool_temp = 10, |
| 424 | .warm_temp = 40, |
| 425 | .temp_check_period = 1, |
| 426 | .max_bat_chg_current = 1100, |
| 427 | .cool_bat_chg_current = 350, |
| 428 | .warm_bat_chg_current = 350, |
| 429 | .cool_bat_voltage = 4100, |
| 430 | .warm_bat_voltage = 4100, |
| 431 | .thermal_mitigation = pm8921_therm_mitigation, |
| 432 | .thermal_levels = ARRAY_SIZE(pm8921_therm_mitigation), |
Abhijeet Dharmapurikar | 40491ce | 2011-11-07 11:38:54 -0800 | [diff] [blame] | 433 | .rconn_mohm = 18, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 434 | }; |
| 435 | |
| 436 | static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = { |
| 437 | .priority = 0, |
| 438 | }; |
| 439 | |
| 440 | static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = { |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 441 | .battery_type = BATT_UNKNOWN, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 442 | .r_sense = 10, |
| 443 | .i_test = 2500, |
| 444 | .v_failure = 3000, |
| 445 | .calib_delay_ms = 600000, |
Abhijeet Dharmapurikar | a93ede8 | 2011-11-17 12:20:03 -0800 | [diff] [blame] | 446 | .max_voltage_uv = MAX_VOLTAGE_MV * 1000, |
Abhijeet Dharmapurikar | baffba4 | 2012-03-22 14:41:10 -0700 | [diff] [blame] | 447 | .rconn_mohm = 30, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 448 | }; |
| 449 | |
| 450 | #define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */ |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 451 | #define PM8921_LC_LED_LOW_CURRENT 1 /* I = 1mA */ |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 452 | #define PM8XXX_LED_PWM_PERIOD 1000 |
| 453 | #define PM8XXX_LED_PWM_DUTY_MS 20 |
| 454 | /** |
| 455 | * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be |
| 456 | * driven using PWM feature. |
| 457 | */ |
| 458 | #define PM8XXX_PWM_CHANNEL_NONE -1 |
| 459 | |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 460 | static struct led_info pm8921_led_info_liquid[] = { |
| 461 | { |
| 462 | .name = "led:red", |
| 463 | .flags = PM8XXX_ID_LED_0, |
Amy Maloche | 65a01a8 | 2012-01-30 12:36:42 -0800 | [diff] [blame] | 464 | .default_trigger = "battery-charging", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 465 | }, |
| 466 | { |
| 467 | .name = "led:green", |
| 468 | .flags = PM8XXX_ID_LED_0, |
Amy Maloche | 65a01a8 | 2012-01-30 12:36:42 -0800 | [diff] [blame] | 469 | .default_trigger = "battery-full", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 470 | }, |
| 471 | { |
| 472 | .name = "led:blue", |
| 473 | .flags = PM8XXX_ID_LED_2, |
Amy Maloche | 65a01a8 | 2012-01-30 12:36:42 -0800 | [diff] [blame] | 474 | .default_trigger = "dc-online", |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 475 | }, |
| 476 | }; |
| 477 | |
| 478 | static struct pm8xxx_led_config pm8921_led_configs_liquid[] = { |
| 479 | [0] = { |
| 480 | .id = PM8XXX_ID_LED_0, |
| 481 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 482 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 483 | }, |
| 484 | [1] = { |
| 485 | .id = PM8XXX_ID_LED_1, |
| 486 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 487 | .max_current = PM8921_LC_LED_LOW_CURRENT, |
| 488 | }, |
| 489 | [2] = { |
| 490 | .id = PM8XXX_ID_LED_2, |
| 491 | .mode = PM8XXX_LED_MODE_MANUAL, |
| 492 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 493 | }, |
| 494 | }; |
| 495 | |
| 496 | static struct led_platform_data pm8xxx_leds_core_liquid = { |
| 497 | .num_leds = ARRAY_SIZE(pm8921_led_info_liquid), |
| 498 | .leds = pm8921_led_info_liquid, |
| 499 | }; |
| 500 | |
| 501 | static struct pm8xxx_led_platform_data pm8xxx_leds_pdata_liquid = { |
| 502 | .led_core = &pm8xxx_leds_core_liquid, |
| 503 | .configs = pm8921_led_configs_liquid, |
| 504 | .num_configs = ARRAY_SIZE(pm8921_led_configs_liquid), |
| 505 | }; |
| 506 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 507 | static struct led_info pm8921_led_info[] = { |
| 508 | [0] = { |
| 509 | .name = "led:battery_charging", |
| 510 | .default_trigger = "battery-charging", |
| 511 | }, |
| 512 | [1] = { |
| 513 | .name = "led:battery_full", |
| 514 | .default_trigger = "battery-full", |
| 515 | }, |
| 516 | }; |
| 517 | |
| 518 | static struct led_platform_data pm8921_led_core_pdata = { |
| 519 | .num_leds = ARRAY_SIZE(pm8921_led_info), |
| 520 | .leds = pm8921_led_info, |
| 521 | }; |
| 522 | |
| 523 | static int pm8921_led0_pwm_duty_pcts[56] = { |
| 524 | 1, 4, 8, 12, 16, 20, 24, 28, 32, 36, |
| 525 | 40, 44, 46, 52, 56, 60, 64, 68, 72, 76, |
| 526 | 80, 84, 88, 92, 96, 100, 100, 100, 98, 95, |
| 527 | 92, 88, 84, 82, 78, 74, 70, 66, 62, 58, |
| 528 | 58, 54, 50, 48, 42, 38, 34, 30, 26, 22, |
| 529 | 14, 10, 6, 4, 1 |
| 530 | }; |
| 531 | |
| 532 | static struct pm8xxx_pwm_duty_cycles pm8921_led0_pwm_duty_cycles = { |
| 533 | .duty_pcts = (int *)&pm8921_led0_pwm_duty_pcts, |
| 534 | .num_duty_pcts = ARRAY_SIZE(pm8921_led0_pwm_duty_pcts), |
| 535 | .duty_ms = PM8XXX_LED_PWM_DUTY_MS, |
| 536 | .start_idx = 0, |
| 537 | }; |
| 538 | |
| 539 | static struct pm8xxx_led_config pm8921_led_configs[] = { |
| 540 | [0] = { |
| 541 | .id = PM8XXX_ID_LED_0, |
| 542 | .mode = PM8XXX_LED_MODE_PWM2, |
| 543 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 544 | .pwm_channel = 5, |
| 545 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD, |
| 546 | .pwm_duty_cycles = &pm8921_led0_pwm_duty_cycles, |
| 547 | }, |
| 548 | [1] = { |
| 549 | .id = PM8XXX_ID_LED_1, |
| 550 | .mode = PM8XXX_LED_MODE_PWM1, |
| 551 | .max_current = PM8921_LC_LED_MAX_CURRENT, |
| 552 | .pwm_channel = 4, |
| 553 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD, |
| 554 | }, |
| 555 | }; |
| 556 | |
| 557 | static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = { |
| 558 | .led_core = &pm8921_led_core_pdata, |
| 559 | .configs = pm8921_led_configs, |
| 560 | .num_configs = ARRAY_SIZE(pm8921_led_configs), |
| 561 | }; |
| 562 | |
| 563 | static struct pm8xxx_ccadc_platform_data pm8xxx_ccadc_pdata = { |
| 564 | .r_sense = 10, |
| 565 | }; |
| 566 | |
Jay Chokshi | 63c3bcc | 2012-02-27 18:54:37 -0800 | [diff] [blame] | 567 | /** |
| 568 | * PM8XXX_PWM_DTEST_CHANNEL_NONE shall be used when no LPG |
| 569 | * channel should be in DTEST mode. |
| 570 | */ |
| 571 | |
| 572 | #define PM8XXX_PWM_DTEST_CHANNEL_NONE (-1) |
| 573 | |
| 574 | static struct pm8xxx_pwm_platform_data pm8xxx_pwm_pdata = { |
| 575 | .dtest_channel = PM8XXX_PWM_DTEST_CHANNEL_NONE, |
| 576 | }; |
| 577 | |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 578 | static struct pm8921_platform_data pm8921_platform_data __devinitdata = { |
| 579 | .irq_pdata = &pm8xxx_irq_pdata, |
| 580 | .gpio_pdata = &pm8xxx_gpio_pdata, |
| 581 | .mpp_pdata = &pm8xxx_mpp_pdata, |
| 582 | .rtc_pdata = &pm8xxx_rtc_pdata, |
| 583 | .pwrkey_pdata = &pm8xxx_pwrkey_pdata, |
| 584 | .keypad_pdata = &keypad_data, |
| 585 | .misc_pdata = &pm8xxx_misc_pdata, |
| 586 | .regulator_pdatas = msm_pm8921_regulator_pdata, |
| 587 | .charger_pdata = &pm8921_chg_pdata, |
| 588 | .bms_pdata = &pm8921_bms_pdata, |
| 589 | .adc_pdata = &pm8xxx_adc_pdata, |
| 590 | .leds_pdata = &pm8xxx_leds_pdata, |
| 591 | .ccadc_pdata = &pm8xxx_ccadc_pdata, |
Jay Chokshi | 63c3bcc | 2012-02-27 18:54:37 -0800 | [diff] [blame] | 592 | .pwm_pdata = &pm8xxx_pwm_pdata, |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 593 | }; |
| 594 | |
| 595 | static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = { |
| 596 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 597 | .slave = { |
| 598 | .name = "pm8921-core", |
| 599 | .platform_data = &pm8921_platform_data, |
| 600 | }, |
| 601 | }; |
| 602 | |
| 603 | void __init msm8960_init_pmic(void) |
| 604 | { |
| 605 | pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ; |
Jay Chokshi | 33c044a | 2011-12-07 13:05:40 -0800 | [diff] [blame] | 606 | msm8960_device_ssbi_pmic.dev.platform_data = |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 607 | &msm8960_ssbi_pm8921_pdata; |
| 608 | pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len; |
| 609 | |
| 610 | /* Simulator supports a QWERTY keypad */ |
| 611 | if (machine_is_msm8960_sim()) |
| 612 | pm8921_platform_data.keypad_pdata = &keypad_data_sim; |
| 613 | |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 614 | if (machine_is_msm8960_liquid()) { |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 615 | pm8921_platform_data.keypad_pdata = &keypad_data_liquid; |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 616 | pm8921_platform_data.leds_pdata = &pm8xxx_leds_pdata_liquid; |
David Keitel | 35e1187 | 2012-02-17 17:40:42 -0800 | [diff] [blame] | 617 | pm8921_platform_data.bms_pdata->battery_type = BATT_DESAY; |
| 618 | } else if (machine_is_msm8960_mtp()) { |
| 619 | pm8921_platform_data.bms_pdata->battery_type = BATT_PALLADIUM; |
Amy Maloche | 38dd7a7 | 2011-12-06 09:51:41 -0800 | [diff] [blame] | 620 | } |
Abhijeet Dharmapurikar | baffba4 | 2012-03-22 14:41:10 -0700 | [diff] [blame] | 621 | |
| 622 | if (machine_is_msm8960_fluid()) |
| 623 | pm8921_bms_pdata.rconn_mohm = 20; |
Stepan Moskovchenko | ef1e0b6 | 2011-12-01 12:10:16 -0800 | [diff] [blame] | 624 | } |