ab8500_bmdata.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. #include <linux/export.h>
  2. #include <linux/power_supply.h>
  3. #include <linux/of.h>
  4. #include <linux/mfd/abx500.h>
  5. #include <linux/mfd/abx500/ab8500.h>
  6. #include <linux/mfd/abx500/ab8500-bm.h>
  7. /*
  8. * These are the defined batteries that uses a NTC and ID resistor placed
  9. * inside of the battery pack.
  10. * Note that the res_to_temp table must be strictly sorted by falling resistance
  11. * values to work.
  12. */
  13. const struct abx500_res_to_temp ab8500_temp_tbl_a_thermistor[] = {
  14. {-5, 53407},
  15. { 0, 48594},
  16. { 5, 43804},
  17. {10, 39188},
  18. {15, 34870},
  19. {20, 30933},
  20. {25, 27422},
  21. {30, 24347},
  22. {35, 21694},
  23. {40, 19431},
  24. {45, 17517},
  25. {50, 15908},
  26. {55, 14561},
  27. {60, 13437},
  28. {65, 12500},
  29. };
  30. EXPORT_SYMBOL(ab8500_temp_tbl_a_thermistor);
  31. const int ab8500_temp_tbl_a_size = ARRAY_SIZE(ab8500_temp_tbl_a_thermistor);
  32. EXPORT_SYMBOL(ab8500_temp_tbl_a_size);
  33. const struct abx500_res_to_temp ab8500_temp_tbl_b_thermistor[] = {
  34. {-5, 200000},
  35. { 0, 159024},
  36. { 5, 151921},
  37. {10, 144300},
  38. {15, 136424},
  39. {20, 128565},
  40. {25, 120978},
  41. {30, 113875},
  42. {35, 107397},
  43. {40, 101629},
  44. {45, 96592},
  45. {50, 92253},
  46. {55, 88569},
  47. {60, 85461},
  48. {65, 82869},
  49. };
  50. EXPORT_SYMBOL(ab8500_temp_tbl_b_thermistor);
  51. const int ab8500_temp_tbl_b_size = ARRAY_SIZE(ab8500_temp_tbl_b_thermistor);
  52. EXPORT_SYMBOL(ab8500_temp_tbl_b_size);
  53. static const struct abx500_v_to_cap cap_tbl_a_thermistor[] = {
  54. {4171, 100},
  55. {4114, 95},
  56. {4009, 83},
  57. {3947, 74},
  58. {3907, 67},
  59. {3863, 59},
  60. {3830, 56},
  61. {3813, 53},
  62. {3791, 46},
  63. {3771, 33},
  64. {3754, 25},
  65. {3735, 20},
  66. {3717, 17},
  67. {3681, 13},
  68. {3664, 8},
  69. {3651, 6},
  70. {3635, 5},
  71. {3560, 3},
  72. {3408, 1},
  73. {3247, 0},
  74. };
  75. static const struct abx500_v_to_cap cap_tbl_b_thermistor[] = {
  76. {4161, 100},
  77. {4124, 98},
  78. {4044, 90},
  79. {4003, 85},
  80. {3966, 80},
  81. {3933, 75},
  82. {3888, 67},
  83. {3849, 60},
  84. {3813, 55},
  85. {3787, 47},
  86. {3772, 30},
  87. {3751, 25},
  88. {3718, 20},
  89. {3681, 16},
  90. {3660, 14},
  91. {3589, 10},
  92. {3546, 7},
  93. {3495, 4},
  94. {3404, 2},
  95. {3250, 0},
  96. };
  97. static const struct abx500_v_to_cap cap_tbl[] = {
  98. {4186, 100},
  99. {4163, 99},
  100. {4114, 95},
  101. {4068, 90},
  102. {3990, 80},
  103. {3926, 70},
  104. {3898, 65},
  105. {3866, 60},
  106. {3833, 55},
  107. {3812, 50},
  108. {3787, 40},
  109. {3768, 30},
  110. {3747, 25},
  111. {3730, 20},
  112. {3705, 15},
  113. {3699, 14},
  114. {3684, 12},
  115. {3672, 9},
  116. {3657, 7},
  117. {3638, 6},
  118. {3556, 4},
  119. {3424, 2},
  120. {3317, 1},
  121. {3094, 0},
  122. };
  123. /*
  124. * Note that the res_to_temp table must be strictly sorted by falling
  125. * resistance values to work.
  126. */
  127. static const struct abx500_res_to_temp temp_tbl[] = {
  128. {-5, 214834},
  129. { 0, 162943},
  130. { 5, 124820},
  131. {10, 96520},
  132. {15, 75306},
  133. {20, 59254},
  134. {25, 47000},
  135. {30, 37566},
  136. {35, 30245},
  137. {40, 24520},
  138. {45, 20010},
  139. {50, 16432},
  140. {55, 13576},
  141. {60, 11280},
  142. {65, 9425},
  143. };
  144. /*
  145. * Note that the batres_vs_temp table must be strictly sorted by falling
  146. * temperature values to work.
  147. */
  148. static const struct batres_vs_temp temp_to_batres_tbl_thermistor[] = {
  149. { 40, 120},
  150. { 30, 135},
  151. { 20, 165},
  152. { 10, 230},
  153. { 00, 325},
  154. {-10, 445},
  155. {-20, 595},
  156. };
  157. /*
  158. * Note that the batres_vs_temp table must be strictly sorted by falling
  159. * temperature values to work.
  160. */
  161. static const struct batres_vs_temp temp_to_batres_tbl_ext_thermistor[] = {
  162. { 60, 300},
  163. { 30, 300},
  164. { 20, 300},
  165. { 10, 300},
  166. { 00, 300},
  167. {-10, 300},
  168. {-20, 300},
  169. };
  170. /* battery resistance table for LI ION 9100 battery */
  171. static const struct batres_vs_temp temp_to_batres_tbl_9100[] = {
  172. { 60, 180},
  173. { 30, 180},
  174. { 20, 180},
  175. { 10, 180},
  176. { 00, 180},
  177. {-10, 180},
  178. {-20, 180},
  179. };
  180. static struct abx500_battery_type bat_type_thermistor[] = {
  181. [BATTERY_UNKNOWN] = {
  182. /* First element always represent the UNKNOWN battery */
  183. .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN,
  184. .resis_high = 0,
  185. .resis_low = 0,
  186. .battery_resistance = 300,
  187. .charge_full_design = 612,
  188. .nominal_voltage = 3700,
  189. .termination_vol = 4050,
  190. .termination_curr = 200,
  191. .recharge_cap = 95,
  192. .normal_cur_lvl = 400,
  193. .normal_vol_lvl = 4100,
  194. .maint_a_cur_lvl = 400,
  195. .maint_a_vol_lvl = 4050,
  196. .maint_a_chg_timer_h = 60,
  197. .maint_b_cur_lvl = 400,
  198. .maint_b_vol_lvl = 4000,
  199. .maint_b_chg_timer_h = 200,
  200. .low_high_cur_lvl = 300,
  201. .low_high_vol_lvl = 4000,
  202. .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
  203. .r_to_t_tbl = temp_tbl,
  204. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
  205. .v_to_cap_tbl = cap_tbl,
  206. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  207. .batres_tbl = temp_to_batres_tbl_thermistor,
  208. },
  209. {
  210. .name = POWER_SUPPLY_TECHNOLOGY_LIPO,
  211. .resis_high = 53407,
  212. .resis_low = 12500,
  213. .battery_resistance = 300,
  214. .charge_full_design = 900,
  215. .nominal_voltage = 3600,
  216. .termination_vol = 4150,
  217. .termination_curr = 80,
  218. .recharge_cap = 95,
  219. .normal_cur_lvl = 700,
  220. .normal_vol_lvl = 4200,
  221. .maint_a_cur_lvl = 600,
  222. .maint_a_vol_lvl = 4150,
  223. .maint_a_chg_timer_h = 60,
  224. .maint_b_cur_lvl = 600,
  225. .maint_b_vol_lvl = 4100,
  226. .maint_b_chg_timer_h = 200,
  227. .low_high_cur_lvl = 300,
  228. .low_high_vol_lvl = 4000,
  229. .n_temp_tbl_elements = ARRAY_SIZE(ab8500_temp_tbl_a_thermistor),
  230. .r_to_t_tbl = ab8500_temp_tbl_a_thermistor,
  231. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_a_thermistor),
  232. .v_to_cap_tbl = cap_tbl_a_thermistor,
  233. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  234. .batres_tbl = temp_to_batres_tbl_thermistor,
  235. },
  236. {
  237. .name = POWER_SUPPLY_TECHNOLOGY_LIPO,
  238. .resis_high = 200000,
  239. .resis_low = 82869,
  240. .battery_resistance = 300,
  241. .charge_full_design = 900,
  242. .nominal_voltage = 3600,
  243. .termination_vol = 4150,
  244. .termination_curr = 80,
  245. .recharge_cap = 95,
  246. .normal_cur_lvl = 700,
  247. .normal_vol_lvl = 4200,
  248. .maint_a_cur_lvl = 600,
  249. .maint_a_vol_lvl = 4150,
  250. .maint_a_chg_timer_h = 60,
  251. .maint_b_cur_lvl = 600,
  252. .maint_b_vol_lvl = 4100,
  253. .maint_b_chg_timer_h = 200,
  254. .low_high_cur_lvl = 300,
  255. .low_high_vol_lvl = 4000,
  256. .n_temp_tbl_elements = ARRAY_SIZE(ab8500_temp_tbl_b_thermistor),
  257. .r_to_t_tbl = ab8500_temp_tbl_b_thermistor,
  258. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl_b_thermistor),
  259. .v_to_cap_tbl = cap_tbl_b_thermistor,
  260. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  261. .batres_tbl = temp_to_batres_tbl_thermistor,
  262. },
  263. };
  264. static struct abx500_battery_type bat_type_ext_thermistor[] = {
  265. [BATTERY_UNKNOWN] = {
  266. /* First element always represent the UNKNOWN battery */
  267. .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN,
  268. .resis_high = 0,
  269. .resis_low = 0,
  270. .battery_resistance = 300,
  271. .charge_full_design = 612,
  272. .nominal_voltage = 3700,
  273. .termination_vol = 4050,
  274. .termination_curr = 200,
  275. .recharge_cap = 95,
  276. .normal_cur_lvl = 400,
  277. .normal_vol_lvl = 4100,
  278. .maint_a_cur_lvl = 400,
  279. .maint_a_vol_lvl = 4050,
  280. .maint_a_chg_timer_h = 60,
  281. .maint_b_cur_lvl = 400,
  282. .maint_b_vol_lvl = 4000,
  283. .maint_b_chg_timer_h = 200,
  284. .low_high_cur_lvl = 300,
  285. .low_high_vol_lvl = 4000,
  286. .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
  287. .r_to_t_tbl = temp_tbl,
  288. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
  289. .v_to_cap_tbl = cap_tbl,
  290. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  291. .batres_tbl = temp_to_batres_tbl_thermistor,
  292. },
  293. /*
  294. * These are the batteries that doesn't have an internal NTC resistor to measure
  295. * its temperature. The temperature in this case is measure with a NTC placed
  296. * near the battery but on the PCB.
  297. */
  298. {
  299. .name = POWER_SUPPLY_TECHNOLOGY_LIPO,
  300. .resis_high = 76000,
  301. .resis_low = 53000,
  302. .battery_resistance = 300,
  303. .charge_full_design = 900,
  304. .nominal_voltage = 3700,
  305. .termination_vol = 4150,
  306. .termination_curr = 100,
  307. .recharge_cap = 95,
  308. .normal_cur_lvl = 700,
  309. .normal_vol_lvl = 4200,
  310. .maint_a_cur_lvl = 600,
  311. .maint_a_vol_lvl = 4150,
  312. .maint_a_chg_timer_h = 60,
  313. .maint_b_cur_lvl = 600,
  314. .maint_b_vol_lvl = 4100,
  315. .maint_b_chg_timer_h = 200,
  316. .low_high_cur_lvl = 300,
  317. .low_high_vol_lvl = 4000,
  318. .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
  319. .r_to_t_tbl = temp_tbl,
  320. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
  321. .v_to_cap_tbl = cap_tbl,
  322. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  323. .batres_tbl = temp_to_batres_tbl_thermistor,
  324. },
  325. {
  326. .name = POWER_SUPPLY_TECHNOLOGY_LION,
  327. .resis_high = 30000,
  328. .resis_low = 10000,
  329. .battery_resistance = 300,
  330. .charge_full_design = 950,
  331. .nominal_voltage = 3700,
  332. .termination_vol = 4150,
  333. .termination_curr = 100,
  334. .recharge_cap = 95,
  335. .normal_cur_lvl = 700,
  336. .normal_vol_lvl = 4200,
  337. .maint_a_cur_lvl = 600,
  338. .maint_a_vol_lvl = 4150,
  339. .maint_a_chg_timer_h = 60,
  340. .maint_b_cur_lvl = 600,
  341. .maint_b_vol_lvl = 4100,
  342. .maint_b_chg_timer_h = 200,
  343. .low_high_cur_lvl = 300,
  344. .low_high_vol_lvl = 4000,
  345. .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
  346. .r_to_t_tbl = temp_tbl,
  347. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
  348. .v_to_cap_tbl = cap_tbl,
  349. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  350. .batres_tbl = temp_to_batres_tbl_thermistor,
  351. },
  352. {
  353. .name = POWER_SUPPLY_TECHNOLOGY_LION,
  354. .resis_high = 95000,
  355. .resis_low = 76001,
  356. .battery_resistance = 300,
  357. .charge_full_design = 950,
  358. .nominal_voltage = 3700,
  359. .termination_vol = 4150,
  360. .termination_curr = 100,
  361. .recharge_cap = 95,
  362. .normal_cur_lvl = 700,
  363. .normal_vol_lvl = 4200,
  364. .maint_a_cur_lvl = 600,
  365. .maint_a_vol_lvl = 4150,
  366. .maint_a_chg_timer_h = 60,
  367. .maint_b_cur_lvl = 600,
  368. .maint_b_vol_lvl = 4100,
  369. .maint_b_chg_timer_h = 200,
  370. .low_high_cur_lvl = 300,
  371. .low_high_vol_lvl = 4000,
  372. .n_temp_tbl_elements = ARRAY_SIZE(temp_tbl),
  373. .r_to_t_tbl = temp_tbl,
  374. .n_v_cap_tbl_elements = ARRAY_SIZE(cap_tbl),
  375. .v_to_cap_tbl = cap_tbl,
  376. .n_batres_tbl_elements = ARRAY_SIZE(temp_to_batres_tbl_thermistor),
  377. .batres_tbl = temp_to_batres_tbl_thermistor,
  378. },
  379. };
  380. static const struct abx500_bm_capacity_levels cap_levels = {
  381. .critical = 2,
  382. .low = 10,
  383. .normal = 70,
  384. .high = 95,
  385. .full = 100,
  386. };
  387. static const struct abx500_fg_parameters fg = {
  388. .recovery_sleep_timer = 10,
  389. .recovery_total_time = 100,
  390. .init_timer = 1,
  391. .init_discard_time = 5,
  392. .init_total_time = 40,
  393. .high_curr_time = 60,
  394. .accu_charging = 30,
  395. .accu_high_curr = 30,
  396. .high_curr_threshold = 50,
  397. .lowbat_threshold = 3100,
  398. .battok_falling_th_sel0 = 2860,
  399. .battok_raising_th_sel1 = 2860,
  400. .maint_thres = 95,
  401. .user_cap_limit = 15,
  402. .pcut_enable = 1,
  403. .pcut_max_time = 127,
  404. .pcut_flag_time = 112,
  405. .pcut_max_restart = 15,
  406. .pcut_debounce_time = 2,
  407. };
  408. static const struct abx500_maxim_parameters ab8500_maxi_params = {
  409. .ena_maxi = true,
  410. .chg_curr = 910,
  411. .wait_cycles = 10,
  412. .charger_curr_step = 100,
  413. };
  414. static const struct abx500_maxim_parameters abx540_maxi_params = {
  415. .ena_maxi = true,
  416. .chg_curr = 3000,
  417. .wait_cycles = 10,
  418. .charger_curr_step = 200,
  419. };
  420. static const struct abx500_bm_charger_parameters chg = {
  421. .usb_volt_max = 5500,
  422. .usb_curr_max = 1500,
  423. .ac_volt_max = 7500,
  424. .ac_curr_max = 1500,
  425. };
  426. /*
  427. * This array maps the raw hex value to charger output current used by the
  428. * AB8500 values
  429. */
  430. static int ab8500_charge_output_curr_map[] = {
  431. 100, 200, 300, 400, 500, 600, 700, 800,
  432. 900, 1000, 1100, 1200, 1300, 1400, 1500, 1500,
  433. };
  434. static int ab8540_charge_output_curr_map[] = {
  435. 0, 0, 0, 75, 100, 125, 150, 175,
  436. 200, 225, 250, 275, 300, 325, 350, 375,
  437. 400, 425, 450, 475, 500, 525, 550, 575,
  438. 600, 625, 650, 675, 700, 725, 750, 775,
  439. 800, 825, 850, 875, 900, 925, 950, 975,
  440. 1000, 1025, 1050, 1075, 1100, 1125, 1150, 1175,
  441. 1200, 1225, 1250, 1275, 1300, 1325, 1350, 1375,
  442. 1400, 1425, 1450, 1500, 1600, 1700, 1900, 2000,
  443. };
  444. /*
  445. * This array maps the raw hex value to charger input current used by the
  446. * AB8500 values
  447. */
  448. static int ab8500_charge_input_curr_map[] = {
  449. 50, 98, 193, 290, 380, 450, 500, 600,
  450. 700, 800, 900, 1000, 1100, 1300, 1400, 1500,
  451. };
  452. static int ab8540_charge_input_curr_map[] = {
  453. 25, 50, 75, 100, 125, 150, 175, 200,
  454. 225, 250, 275, 300, 325, 350, 375, 400,
  455. 425, 450, 475, 500, 525, 550, 575, 600,
  456. 625, 650, 675, 700, 725, 750, 775, 800,
  457. 825, 850, 875, 900, 925, 950, 975, 1000,
  458. 1025, 1050, 1075, 1100, 1125, 1150, 1175, 1200,
  459. 1225, 1250, 1275, 1300, 1325, 1350, 1375, 1400,
  460. 1425, 1450, 1475, 1500, 1500, 1500, 1500, 1500,
  461. };
  462. struct abx500_bm_data ab8500_bm_data = {
  463. .temp_under = 3,
  464. .temp_low = 8,
  465. .temp_high = 43,
  466. .temp_over = 48,
  467. .main_safety_tmr_h = 4,
  468. .temp_interval_chg = 20,
  469. .temp_interval_nochg = 120,
  470. .usb_safety_tmr_h = 4,
  471. .bkup_bat_v = BUP_VCH_SEL_2P6V,
  472. .bkup_bat_i = BUP_ICH_SEL_150UA,
  473. .no_maintenance = false,
  474. .capacity_scaling = false,
  475. .adc_therm = ABx500_ADC_THERM_BATCTRL,
  476. .chg_unknown_bat = false,
  477. .enable_overshoot = false,
  478. .fg_res = 100,
  479. .cap_levels = &cap_levels,
  480. .bat_type = bat_type_thermistor,
  481. .n_btypes = ARRAY_SIZE(bat_type_thermistor),
  482. .batt_id = 0,
  483. .interval_charging = 5,
  484. .interval_not_charging = 120,
  485. .temp_hysteresis = 3,
  486. .gnd_lift_resistance = 34,
  487. .chg_output_curr = ab8500_charge_output_curr_map,
  488. .n_chg_out_curr = ARRAY_SIZE(ab8500_charge_output_curr_map),
  489. .maxi = &ab8500_maxi_params,
  490. .chg_params = &chg,
  491. .fg_params = &fg,
  492. .chg_input_curr = ab8500_charge_input_curr_map,
  493. .n_chg_in_curr = ARRAY_SIZE(ab8500_charge_input_curr_map),
  494. };
  495. struct abx500_bm_data ab8540_bm_data = {
  496. .temp_under = 3,
  497. .temp_low = 8,
  498. .temp_high = 43,
  499. .temp_over = 48,
  500. .main_safety_tmr_h = 4,
  501. .temp_interval_chg = 20,
  502. .temp_interval_nochg = 120,
  503. .usb_safety_tmr_h = 4,
  504. .bkup_bat_v = BUP_VCH_SEL_2P6V,
  505. .bkup_bat_i = BUP_ICH_SEL_150UA,
  506. .no_maintenance = false,
  507. .capacity_scaling = false,
  508. .adc_therm = ABx500_ADC_THERM_BATCTRL,
  509. .chg_unknown_bat = false,
  510. .enable_overshoot = false,
  511. .fg_res = 100,
  512. .cap_levels = &cap_levels,
  513. .bat_type = bat_type_thermistor,
  514. .n_btypes = ARRAY_SIZE(bat_type_thermistor),
  515. .batt_id = 0,
  516. .interval_charging = 5,
  517. .interval_not_charging = 120,
  518. .temp_hysteresis = 3,
  519. .gnd_lift_resistance = 0,
  520. .maxi = &abx540_maxi_params,
  521. .chg_params = &chg,
  522. .fg_params = &fg,
  523. .chg_output_curr = ab8540_charge_output_curr_map,
  524. .n_chg_out_curr = ARRAY_SIZE(ab8540_charge_output_curr_map),
  525. .chg_input_curr = ab8540_charge_input_curr_map,
  526. .n_chg_in_curr = ARRAY_SIZE(ab8540_charge_input_curr_map),
  527. };
  528. int ab8500_bm_of_probe(struct device *dev,
  529. struct device_node *np,
  530. struct abx500_bm_data *bm)
  531. {
  532. const struct batres_vs_temp *tmp_batres_tbl;
  533. struct device_node *battery_node;
  534. const char *btech;
  535. int i;
  536. /* get phandle to 'battery-info' node */
  537. battery_node = of_parse_phandle(np, "battery", 0);
  538. if (!battery_node) {
  539. dev_err(dev, "battery node or reference missing\n");
  540. return -EINVAL;
  541. }
  542. btech = of_get_property(battery_node, "stericsson,battery-type", NULL);
  543. if (!btech) {
  544. dev_warn(dev, "missing property battery-name/type\n");
  545. return -EINVAL;
  546. }
  547. if (strncmp(btech, "LION", 4) == 0) {
  548. bm->no_maintenance = true;
  549. bm->chg_unknown_bat = true;
  550. bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600;
  551. bm->bat_type[BATTERY_UNKNOWN].termination_vol = 4150;
  552. bm->bat_type[BATTERY_UNKNOWN].recharge_cap = 95;
  553. bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520;
  554. bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200;
  555. }
  556. if (of_property_read_bool(battery_node, "thermistor-on-batctrl")) {
  557. if (strncmp(btech, "LION", 4) == 0)
  558. tmp_batres_tbl = temp_to_batres_tbl_9100;
  559. else
  560. tmp_batres_tbl = temp_to_batres_tbl_thermistor;
  561. } else {
  562. bm->n_btypes = 4;
  563. bm->bat_type = bat_type_ext_thermistor;
  564. bm->adc_therm = ABx500_ADC_THERM_BATTEMP;
  565. tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor;
  566. }
  567. /* select the battery resolution table */
  568. for (i = 0; i < bm->n_btypes; ++i)
  569. bm->bat_type[i].batres_tbl = tmp_batres_tbl;
  570. of_node_put(battery_node);
  571. return 0;
  572. }