board-8064-pmic.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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. #include <linux/init.h>
  14. #include <linux/ioport.h>
  15. #include <linux/gpio.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/bootmem.h>
  18. #include <linux/mfd/pm8xxx/pm8921.h>
  19. #include <linux/leds.h>
  20. #include <linux/leds-pm8xxx.h>
  21. #include <linux/mfd/pm8xxx/pm8xxx-adc.h>
  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/gpiomux.h>
  27. #include <mach/restart.h>
  28. #include <mach/socinfo.h>
  29. #include "devices.h"
  30. #include "board-8064.h"
  31. struct pm8xxx_gpio_init {
  32. unsigned gpio;
  33. struct pm_gpio config;
  34. };
  35. struct pm8xxx_mpp_init {
  36. unsigned mpp;
  37. struct pm8xxx_mpp_config_data config;
  38. };
  39. #define PM8921_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
  40. _func, _inv, _disable) \
  41. { \
  42. .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
  43. .config = { \
  44. .direction = _dir, \
  45. .output_buffer = _buf, \
  46. .output_value = _val, \
  47. .pull = _pull, \
  48. .vin_sel = _vin, \
  49. .out_strength = _out_strength, \
  50. .function = _func, \
  51. .inv_int_pol = _inv, \
  52. .disable_pin = _disable, \
  53. } \
  54. }
  55. #define PM8921_MPP_INIT(_mpp, _type, _level, _control) \
  56. { \
  57. .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
  58. .config = { \
  59. .type = PM8XXX_MPP_TYPE_##_type, \
  60. .level = _level, \
  61. .control = PM8XXX_MPP_##_control, \
  62. } \
  63. }
  64. #define PM8821_MPP_INIT(_mpp, _type, _level, _control) \
  65. { \
  66. .mpp = PM8821_MPP_PM_TO_SYS(_mpp), \
  67. .config = { \
  68. .type = PM8XXX_MPP_TYPE_##_type, \
  69. .level = _level, \
  70. .control = PM8XXX_MPP_##_control, \
  71. } \
  72. }
  73. #define PM8921_GPIO_DISABLE(_gpio) \
  74. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
  75. 0, 0, 0, 1)
  76. #define PM8921_GPIO_OUTPUT(_gpio, _val, _strength) \
  77. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
  78. PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
  79. PM_GPIO_STRENGTH_##_strength, \
  80. PM_GPIO_FUNC_NORMAL, 0, 0)
  81. #define PM8921_GPIO_OUTPUT_BUFCONF(_gpio, _val, _strength, _bufconf) \
  82. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT,\
  83. PM_GPIO_OUT_BUF_##_bufconf, _val, \
  84. PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
  85. PM_GPIO_STRENGTH_##_strength, \
  86. PM_GPIO_FUNC_NORMAL, 0, 0)
  87. #define PM8921_GPIO_INPUT(_gpio, _pull) \
  88. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
  89. _pull, PM_GPIO_VIN_S4, \
  90. PM_GPIO_STRENGTH_NO, \
  91. PM_GPIO_FUNC_NORMAL, 0, 0)
  92. #define PM8921_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
  93. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
  94. PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
  95. PM_GPIO_STRENGTH_HIGH, \
  96. _func, 0, 0)
  97. #define PM8921_GPIO_OUTPUT_VIN(_gpio, _val, _vin) \
  98. PM8921_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
  99. PM_GPIO_PULL_NO, _vin, \
  100. PM_GPIO_STRENGTH_HIGH, \
  101. PM_GPIO_FUNC_NORMAL, 0, 0)
  102. /* Initial PM8921 GPIO configurations */
  103. static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
  104. PM8921_GPIO_OUTPUT(14, 1, HIGH), /* HDMI Mux Selector */
  105. PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */
  106. PM8921_GPIO_OUTPUT_FUNC(26, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
  107. PM8921_GPIO_OUTPUT_VIN(30, 1, PM_GPIO_VIN_VPH), /* SMB349 susp line */
  108. PM8921_GPIO_OUTPUT_BUFCONF(36, 1, LOW, OPEN_DRAIN),
  109. PM8921_GPIO_OUTPUT_FUNC(44, 0, PM_GPIO_FUNC_2),
  110. PM8921_GPIO_OUTPUT(33, 0, HIGH),
  111. PM8921_GPIO_OUTPUT(20, 0, HIGH),
  112. PM8921_GPIO_INPUT(35, PM_GPIO_PULL_UP_30),
  113. PM8921_GPIO_INPUT(38, PM_GPIO_PULL_UP_30),
  114. /* TABLA CODEC RESET */
  115. PM8921_GPIO_OUTPUT(34, 1, HIGH),
  116. PM8921_GPIO_OUTPUT(13, 0, HIGH), /* PCIE_CLK_PWR_EN */
  117. PM8921_GPIO_INPUT(12, PM_GPIO_PULL_UP_30), /* PCIE_WAKE_N */
  118. };
  119. static struct pm8xxx_gpio_init pm8921_fsm8064_ep_gpios[] __initdata = {
  120. PM8921_GPIO_OUTPUT_VIN(1, 1, PM_GPIO_VIN_VPH), /* 5V reg */
  121. PM8921_GPIO_OUTPUT_VIN(12, 1, PM_GPIO_VIN_VPH), /* 12V reg */
  122. /* De-assert CW_GPS_RST_N for CW GPS module to lock to GPS source */
  123. PM8921_GPIO_OUTPUT_VIN(14, 1, PM_GPIO_VIN_VPH),
  124. /* PPS_SRC_SEL_N, chooses between WGR7640 PPS source (high) or
  125. * CW GPS module PPS source (low) */
  126. PM8921_GPIO_OUTPUT_VIN(19, 0, PM_GPIO_VIN_VPH), /* PPS_SRC_SEL_N */
  127. PM8921_GPIO_OUTPUT_VIN(13, 1, PM_GPIO_VIN_VPH), /* PCIE_CLK_PWR_EN */
  128. PM8921_GPIO_OUTPUT_VIN(37, 1, PM_GPIO_VIN_VPH), /* PCIE_RST_N */
  129. PM8921_GPIO_INPUT(11, PM_GPIO_PULL_UP_30), /* PCIE_WAKE_N */
  130. PM8921_GPIO_OUTPUT_VIN(23, 1, PM_GPIO_VIN_VPH), /* USB2_HSIC_RST_N */
  131. PM8921_GPIO_OUTPUT_VIN(24, 1, PM_GPIO_VIN_VPH), /* USB3_RST_N */
  132. PM8921_GPIO_OUTPUT_VIN(34, 1, PM_GPIO_VIN_VPH), /* USB4_RST_N */
  133. };
  134. static struct pm8xxx_gpio_init pm8921_mtp_kp_gpios[] __initdata = {
  135. PM8921_GPIO_INPUT(3, PM_GPIO_PULL_UP_30),
  136. PM8921_GPIO_INPUT(4, PM_GPIO_PULL_UP_30),
  137. };
  138. static struct pm8xxx_gpio_init pm8921_cdp_kp_gpios[] __initdata = {
  139. PM8921_GPIO_INPUT(27, PM_GPIO_PULL_UP_30),
  140. PM8921_GPIO_INPUT(42, PM_GPIO_PULL_UP_30),
  141. PM8921_GPIO_INPUT(17, PM_GPIO_PULL_UP_1P5), /* SD_WP */
  142. };
  143. static struct pm8xxx_gpio_init pm8921_mpq8064_hrd_gpios[] __initdata = {
  144. PM8921_GPIO_OUTPUT(37, 0, LOW), /* MUX1_SEL */
  145. PM8921_GPIO_INPUT(40, PM_GPIO_PULL_UP_30), /* irq for sx150 exp2 */
  146. };
  147. static struct pm8xxx_gpio_init touchscreen_gpios[] __initdata = {
  148. PM8921_GPIO_OUTPUT(23, 0, HIGH), /* touchscreen power FET */
  149. };
  150. /* Initial PM8917 GPIO configurations */
  151. static struct pm8xxx_gpio_init pm8917_gpios[] __initdata = {
  152. PM8921_GPIO_OUTPUT(14, 1, HIGH), /* HDMI Mux Selector */
  153. PM8921_GPIO_OUTPUT_BUFCONF(25, 0, LOW, CMOS), /* DISP_RESET_N */
  154. PM8921_GPIO_OUTPUT(26, 1, HIGH), /* Backlight: on */
  155. PM8921_GPIO_OUTPUT_BUFCONF(36, 1, LOW, OPEN_DRAIN),
  156. PM8921_GPIO_OUTPUT_FUNC(38, 0, PM_GPIO_FUNC_2),
  157. PM8921_GPIO_OUTPUT(33, 0, HIGH),
  158. PM8921_GPIO_OUTPUT(20, 0, HIGH),
  159. PM8921_GPIO_INPUT(35, PM_GPIO_PULL_UP_30),
  160. PM8921_GPIO_INPUT(30, PM_GPIO_PULL_UP_30),
  161. /* TABLA CODEC RESET */
  162. PM8921_GPIO_OUTPUT(34, 1, MED),
  163. PM8921_GPIO_OUTPUT(13, 0, HIGH), /* PCIE_CLK_PWR_EN */
  164. PM8921_GPIO_INPUT(12, PM_GPIO_PULL_UP_30), /* PCIE_WAKE_N */
  165. };
  166. /* PM8921 GPIO 42 remaps to PM8917 GPIO 8 */
  167. static struct pm8xxx_gpio_init pm8917_cdp_kp_gpios[] __initdata = {
  168. PM8921_GPIO_INPUT(27, PM_GPIO_PULL_UP_30),
  169. PM8921_GPIO_INPUT(8, PM_GPIO_PULL_UP_30),
  170. PM8921_GPIO_INPUT(17, PM_GPIO_PULL_UP_1P5), /* SD_WP */
  171. };
  172. static struct pm8xxx_gpio_init pm8921_mpq_gpios[] __initdata = {
  173. PM8921_GPIO_INIT(27, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0,
  174. PM_GPIO_PULL_NO, PM_GPIO_VIN_VPH, PM_GPIO_STRENGTH_NO,
  175. PM_GPIO_FUNC_NORMAL, 0, 0),
  176. };
  177. /* Initial PM8XXX MPP configurations */
  178. static struct pm8xxx_mpp_init pm8xxx_mpps[] __initdata = {
  179. PM8921_MPP_INIT(3, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_LOW),
  180. /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */
  181. PM8921_MPP_INIT(7, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_LOW),
  182. PM8921_MPP_INIT(8, D_OUTPUT, PM8921_MPP_DIG_LEVEL_S4, DOUT_CTRL_LOW),
  183. /*MPP9 is used to detect docking station connection/removal on Liquid*/
  184. PM8921_MPP_INIT(9, D_INPUT, PM8921_MPP_DIG_LEVEL_S4, DIN_TO_INT),
  185. /* PCIE_RESET_N */
  186. PM8921_MPP_INIT(1, D_OUTPUT, PM8921_MPP_DIG_LEVEL_VPH, DOUT_CTRL_HIGH),
  187. };
  188. void __init apq8064_configure_gpios(struct pm8xxx_gpio_init *data, int len)
  189. {
  190. int i, rc;
  191. for (i = 0; i < len; i++) {
  192. rc = pm8xxx_gpio_config(data[i].gpio, &data[i].config);
  193. if (rc)
  194. pr_err("%s: pm8xxx_gpio_config(%u) failed: rc=%d\n",
  195. __func__, data[i].gpio, rc);
  196. }
  197. }
  198. void __init apq8064_pm8xxx_gpio_mpp_init(void)
  199. {
  200. int i, rc;
  201. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
  202. /* PCIE_CLK_PWR_EN is 23 and PCIE_WAKE_N is 22
  203. for MPQ8064 Hybrid */
  204. if (machine_is_mpq8064_hrd()) {
  205. int size = ARRAY_SIZE(pm8921_gpios);
  206. for (i = 0; i < size; i++)
  207. if (pm8921_gpios[i].gpio == 13)
  208. pm8921_gpios[i].gpio = 23;
  209. else if (pm8921_gpios[i].gpio == 12)
  210. pm8921_gpios[i].gpio = 22;
  211. }
  212. if (machine_is_fsm8064_ep())
  213. apq8064_configure_gpios(pm8921_fsm8064_ep_gpios,
  214. ARRAY_SIZE(pm8921_fsm8064_ep_gpios));
  215. else
  216. apq8064_configure_gpios(pm8921_gpios,
  217. ARRAY_SIZE(pm8921_gpios));
  218. } else {
  219. apq8064_configure_gpios(pm8917_gpios, ARRAY_SIZE(pm8917_gpios));
  220. }
  221. if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid()) {
  222. apq8064_configure_gpios(touchscreen_gpios,
  223. ARRAY_SIZE(touchscreen_gpios));
  224. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
  225. apq8064_configure_gpios(pm8921_cdp_kp_gpios,
  226. ARRAY_SIZE(pm8921_cdp_kp_gpios));
  227. else
  228. apq8064_configure_gpios(pm8917_cdp_kp_gpios,
  229. ARRAY_SIZE(pm8917_cdp_kp_gpios));
  230. }
  231. if (machine_is_apq8064_mtp())
  232. apq8064_configure_gpios(pm8921_mtp_kp_gpios,
  233. ARRAY_SIZE(pm8921_mtp_kp_gpios));
  234. if (machine_is_mpq8064_cdp() || machine_is_mpq8064_hrd()
  235. || machine_is_mpq8064_dtv())
  236. apq8064_configure_gpios(pm8921_mpq_gpios,
  237. ARRAY_SIZE(pm8921_mpq_gpios));
  238. if (machine_is_mpq8064_hrd())
  239. apq8064_configure_gpios(pm8921_mpq8064_hrd_gpios,
  240. ARRAY_SIZE(pm8921_mpq8064_hrd_gpios));
  241. for (i = 0; i < ARRAY_SIZE(pm8xxx_mpps); i++) {
  242. rc = pm8xxx_mpp_config(pm8xxx_mpps[i].mpp,
  243. &pm8xxx_mpps[i].config);
  244. if (rc) {
  245. pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
  246. break;
  247. }
  248. }
  249. }
  250. static struct pm8xxx_pwrkey_platform_data apq8064_pm8921_pwrkey_pdata = {
  251. .pull_up = 1,
  252. .kpd_trigger_delay_us = 15625,
  253. .wakeup = 1,
  254. };
  255. static struct pm8xxx_misc_platform_data apq8064_pm8921_misc_pdata = {
  256. .priority = 0,
  257. };
  258. #define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
  259. #define PM8921_LC_LED_LOW_CURRENT 1 /* I = 1mA */
  260. #define PM8XXX_LED_PWM_PERIOD 1000
  261. #define PM8XXX_LED_PWM_DUTY_MS 20
  262. /**
  263. * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
  264. * driven using PWM feature.
  265. */
  266. #define PM8XXX_PWM_CHANNEL_NONE -1
  267. static struct led_info pm8921_led_info[] = {
  268. [0] = {
  269. .name = "led:red",
  270. .default_trigger = "ac-online",
  271. },
  272. };
  273. static struct led_platform_data pm8921_led_core_pdata = {
  274. .num_leds = ARRAY_SIZE(pm8921_led_info),
  275. .leds = pm8921_led_info,
  276. };
  277. static int pm8921_led0_pwm_duty_pcts[56] = {
  278. 1, 4, 8, 12, 16, 20, 24, 28, 32, 36,
  279. 40, 44, 46, 52, 56, 60, 64, 68, 72, 76,
  280. 80, 84, 88, 92, 96, 100, 100, 100, 98, 95,
  281. 92, 88, 84, 82, 78, 74, 70, 66, 62, 58,
  282. 58, 54, 50, 48, 42, 38, 34, 30, 26, 22,
  283. 14, 10, 6, 4, 1
  284. };
  285. /*
  286. * Note: There is a bug in LPG module that results in incorrect
  287. * behavior of pattern when LUT index 0 is used. So effectively
  288. * there are 63 usable LUT entries.
  289. */
  290. static struct pm8xxx_pwm_duty_cycles pm8921_led0_pwm_duty_cycles = {
  291. .duty_pcts = (int *)&pm8921_led0_pwm_duty_pcts,
  292. .num_duty_pcts = ARRAY_SIZE(pm8921_led0_pwm_duty_pcts),
  293. .duty_ms = PM8XXX_LED_PWM_DUTY_MS,
  294. .start_idx = 1,
  295. };
  296. static struct pm8xxx_led_config pm8921_led_configs[] = {
  297. [0] = {
  298. .id = PM8XXX_ID_LED_0,
  299. .mode = PM8XXX_LED_MODE_PWM2,
  300. .max_current = PM8921_LC_LED_MAX_CURRENT,
  301. .pwm_channel = 5,
  302. .pwm_period_us = PM8XXX_LED_PWM_PERIOD,
  303. .pwm_duty_cycles = &pm8921_led0_pwm_duty_cycles,
  304. },
  305. };
  306. static struct pm8xxx_led_platform_data apq8064_pm8921_leds_pdata = {
  307. .led_core = &pm8921_led_core_pdata,
  308. .configs = pm8921_led_configs,
  309. .num_configs = ARRAY_SIZE(pm8921_led_configs),
  310. };
  311. static struct pm8xxx_adc_amux apq8064_pm8921_adc_channels_data[] = {
  312. {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
  313. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  314. {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
  315. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  316. {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
  317. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  318. {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
  319. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  320. {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
  321. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  322. {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
  323. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  324. {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
  325. ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
  326. {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
  327. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  328. {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
  329. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  330. {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
  331. ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
  332. {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
  333. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  334. {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
  335. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  336. {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
  337. ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
  338. {"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0,
  339. ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM},
  340. };
  341. static struct pm8xxx_adc_properties apq8064_pm8921_adc_data = {
  342. .adc_vdd_reference = 1800, /* milli-voltage for this adc */
  343. .bitresolution = 15,
  344. .bipolar = 0,
  345. };
  346. static struct pm8xxx_adc_platform_data apq8064_pm8921_adc_pdata = {
  347. .adc_channel = apq8064_pm8921_adc_channels_data,
  348. .adc_num_board_channel = ARRAY_SIZE(apq8064_pm8921_adc_channels_data),
  349. .adc_prop = &apq8064_pm8921_adc_data,
  350. .adc_mpp_base = PM8921_MPP_PM_TO_SYS(1),
  351. };
  352. static struct pm8xxx_mpp_platform_data
  353. apq8064_pm8921_mpp_pdata __devinitdata = {
  354. .mpp_base = PM8921_MPP_PM_TO_SYS(1),
  355. };
  356. static struct pm8xxx_gpio_platform_data
  357. apq8064_pm8921_gpio_pdata __devinitdata = {
  358. .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
  359. };
  360. static struct pm8xxx_irq_platform_data
  361. apq8064_pm8921_irq_pdata __devinitdata = {
  362. .irq_base = PM8921_IRQ_BASE,
  363. .devirq = MSM_GPIO_TO_INT(74),
  364. .irq_trigger_flag = IRQF_TRIGGER_LOW,
  365. .dev_id = 0,
  366. };
  367. static struct pm8xxx_rtc_platform_data
  368. apq8064_pm8921_rtc_pdata = {
  369. .rtc_write_enable = false,
  370. .rtc_alarm_powerup = false,
  371. };
  372. static int apq8064_pm8921_therm_mitigation[] = {
  373. 1100,
  374. 700,
  375. 600,
  376. 325,
  377. };
  378. #define MAX_VOLTAGE_MV 4200
  379. #define CHG_TERM_MA 100
  380. static struct pm8921_charger_platform_data
  381. apq8064_pm8921_chg_pdata __devinitdata = {
  382. .update_time = 60000,
  383. .max_voltage = MAX_VOLTAGE_MV,
  384. .min_voltage = 3200,
  385. .uvd_thresh_voltage = 4050,
  386. .alarm_low_mv = 3400,
  387. .alarm_high_mv = 4000,
  388. .resume_voltage_delta = 60,
  389. .resume_charge_percent = 99,
  390. .term_current = CHG_TERM_MA,
  391. .cool_temp = 10,
  392. .warm_temp = 45,
  393. .temp_check_period = 1,
  394. .max_bat_chg_current = 1100,
  395. .cool_bat_chg_current = 350,
  396. .warm_bat_chg_current = 350,
  397. .cool_bat_voltage = 4100,
  398. .warm_bat_voltage = 4100,
  399. .thermal_mitigation = apq8064_pm8921_therm_mitigation,
  400. .thermal_levels = ARRAY_SIZE(apq8064_pm8921_therm_mitigation),
  401. .rconn_mohm = 18,
  402. };
  403. static struct pm8xxx_ccadc_platform_data
  404. apq8064_pm8xxx_ccadc_pdata = {
  405. .r_sense_uohm = 10000,
  406. .calib_delay_ms = 600000,
  407. };
  408. static struct pm8921_bms_platform_data
  409. apq8064_pm8921_bms_pdata __devinitdata = {
  410. .battery_type = BATT_UNKNOWN,
  411. .r_sense_uohm = 10000,
  412. .v_cutoff = 3400,
  413. .max_voltage_uv = MAX_VOLTAGE_MV * 1000,
  414. .rconn_mohm = 18,
  415. .shutdown_soc_valid_limit = 20,
  416. .adjust_soc_low_threshold = 25,
  417. .chg_term_ua = CHG_TERM_MA * 1000,
  418. .normal_voltage_calc_ms = 20000,
  419. .low_voltage_calc_ms = 1000,
  420. .alarm_low_mv = 3400,
  421. .alarm_high_mv = 4000,
  422. .high_ocv_correction_limit_uv = 50,
  423. .low_ocv_correction_limit_uv = 100,
  424. .hold_soc_est = 3,
  425. .enable_fcc_learning = 1,
  426. .min_fcc_learning_soc = 20,
  427. .min_fcc_ocv_pc = 30,
  428. .min_fcc_learning_samples = 5,
  429. };
  430. static struct pm8921_platform_data
  431. apq8064_pm8921_platform_data __devinitdata = {
  432. .irq_pdata = &apq8064_pm8921_irq_pdata,
  433. .gpio_pdata = &apq8064_pm8921_gpio_pdata,
  434. .mpp_pdata = &apq8064_pm8921_mpp_pdata,
  435. .rtc_pdata = &apq8064_pm8921_rtc_pdata,
  436. .pwrkey_pdata = &apq8064_pm8921_pwrkey_pdata,
  437. .misc_pdata = &apq8064_pm8921_misc_pdata,
  438. .leds_pdata = &apq8064_pm8921_leds_pdata,
  439. .adc_pdata = &apq8064_pm8921_adc_pdata,
  440. .charger_pdata = &apq8064_pm8921_chg_pdata,
  441. .bms_pdata = &apq8064_pm8921_bms_pdata,
  442. .ccadc_pdata = &apq8064_pm8xxx_ccadc_pdata,
  443. };
  444. static struct pm8xxx_irq_platform_data
  445. apq8064_pm8821_irq_pdata __devinitdata = {
  446. .irq_base = PM8821_IRQ_BASE,
  447. .devirq = PM8821_SEC_IRQ_N,
  448. .irq_trigger_flag = IRQF_TRIGGER_HIGH,
  449. .dev_id = 1,
  450. };
  451. static struct pm8xxx_mpp_platform_data
  452. apq8064_pm8821_mpp_pdata __devinitdata = {
  453. .mpp_base = PM8821_MPP_PM_TO_SYS(1),
  454. };
  455. static struct pm8821_platform_data
  456. apq8064_pm8821_platform_data __devinitdata = {
  457. .irq_pdata = &apq8064_pm8821_irq_pdata,
  458. .mpp_pdata = &apq8064_pm8821_mpp_pdata,
  459. };
  460. static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
  461. .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
  462. .slave = {
  463. .name = "pm8921-core",
  464. .platform_data = &apq8064_pm8921_platform_data,
  465. },
  466. };
  467. static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
  468. .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
  469. .slave = {
  470. .name = "pm8821-core",
  471. .platform_data = &apq8064_pm8821_platform_data,
  472. },
  473. };
  474. void __init apq8064_init_pmic(void)
  475. {
  476. pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ;
  477. apq8064_device_ssbi_pmic1.dev.platform_data =
  478. &apq8064_ssbi_pm8921_pdata;
  479. apq8064_device_ssbi_pmic2.dev.platform_data =
  480. &apq8064_ssbi_pm8821_pdata;
  481. if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
  482. apq8064_pm8921_platform_data.regulator_pdatas
  483. = msm8064_pm8921_regulator_pdata;
  484. apq8064_pm8921_platform_data.num_regulators
  485. = msm8064_pm8921_regulator_pdata_len;
  486. } else {
  487. apq8064_pm8921_platform_data.regulator_pdatas
  488. = msm8064_pm8917_regulator_pdata;
  489. apq8064_pm8921_platform_data.num_regulators
  490. = msm8064_pm8917_regulator_pdata_len;
  491. }
  492. if (machine_is_apq8064_mtp()) {
  493. apq8064_pm8921_bms_pdata.battery_type = BATT_PALLADIUM;
  494. } else if (machine_is_apq8064_liquid()) {
  495. apq8064_pm8921_bms_pdata.battery_type = BATT_DESAY;
  496. } else if (machine_is_apq8064_cdp()) {
  497. apq8064_pm8921_chg_pdata.has_dc_supply = true;
  498. }
  499. if (!machine_is_apq8064_mtp() && !machine_is_apq8064_liquid())
  500. apq8064_pm8921_chg_pdata.battery_less_hardware = 1;
  501. if (machine_is_mpq8064_hrd())
  502. apq8064_pm8921_chg_pdata.disable_chg_rmvl_wrkarnd = 1;
  503. }