sec_board-msm8226.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  1. /*
  2. * sec_board-msm8226.c
  3. * Samsung Mobile Battery Driver
  4. *
  5. * Copyright (C) 2013 Samsung Electronics
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/battery/sec_battery.h>
  13. #include <linux/battery/sec_fuelgauge.h>
  14. #include <linux/battery/sec_charging_common.h>
  15. #include <linux/qpnp/pin.h>
  16. #include <linux/qpnp/qpnp-adc.h>
  17. #include <linux/regulator/machine.h>
  18. #include <linux/regulator/krait-regulator.h>
  19. #define SHORT_BATTERY_STANDARD 100
  20. #if defined(CONFIG_EXTCON)
  21. int current_cable_type = POWER_SUPPLY_TYPE_BATTERY;
  22. #else
  23. extern int current_cable_type;
  24. #endif
  25. extern unsigned int system_rev;
  26. extern int check_jig_state(void);
  27. extern int check_sm5502_jig_state(void);
  28. //static struct qpnp_vadc_chip *adc_client;
  29. static enum qpnp_vadc_channels temp_channel;
  30. static enum qpnp_vadc_channels chg_temp_channel;
  31. static struct sec_fuelgauge_info *sec_fuelgauge = NULL;
  32. #if defined(CONFIG_BATTERY_SAMSUNG_DATA)
  33. #include CONFIG_BATTERY_SAMSUNG_DATA_FILE
  34. #else //CONFIG_BATTERY_SAMSUNG_DATA
  35. #if defined(CONFIG_FUELGAUGE_MAX17048)
  36. static struct battery_data_t samsung_battery_data[] = {
  37. /* SDI battery data (High voltage 4.35V) */
  38. {
  39. #if defined(CONFIG_MACH_AFYONLTE_TMO) || defined(CONFIG_MACH_AFYONLTE_CAN) || defined(CONFIG_MACH_AFYONLTE_MTR)
  40. .RCOMP0 = 0x55,
  41. .RCOMP_charging = 0x55,
  42. .temp_cohot = -75,
  43. .temp_cocold = -4700,
  44. #elif defined(CONFIG_SEC_ATLANTICLTE_COMMON)
  45. .RCOMP0 = 0x60,
  46. .RCOMP_charging = 0x60,
  47. .temp_cohot = -1300,
  48. .temp_cocold = -7500,
  49. #elif defined(CONFIG_MACH_HESTIALTE_EUR)
  50. .RCOMP0 = 0x60,
  51. .RCOMP_charging = 0x60,
  52. .temp_cohot = -1300,
  53. .temp_cocold = -7500,
  54. #else
  55. .RCOMP0 = 0x74,
  56. .RCOMP_charging = 0x8D,
  57. .temp_cohot = -1000,
  58. .temp_cocold = -4350,
  59. #endif
  60. .is_using_model_data = true,
  61. .type_str = "SDI",
  62. }
  63. };
  64. #elif defined(CONFIG_FUELGAUGE_MAX17050)
  65. static struct battery_data_t samsung_battery_data[] = {
  66. /* SDI battery data (High voltage 4.35V) */
  67. {
  68. #if defined(CONFIG_SEC_MILLET_PROJECT)
  69. .Capacity = 0x2198, /* Millet : 4300mAh */
  70. #elif defined(CONFIG_SEC_MATISSE_PROJECT)
  71. .Capacity = 0x32CD, /* Matisse: 6502mAh */
  72. #elif defined(CONFIG_MACH_DEGASLTE_SPR)
  73. .Capacity = 0x1F1E, /* Degas*/
  74. #else
  75. .Capacity = 0x4A38, /* V1/V2: 9500mAh */
  76. #endif
  77. #if defined(CONFIG_SEC_MILLET_PROJECT)
  78. .low_battery_comp_voltage = 3450,
  79. .low_battery_table = {
  80. /* range, slope, offset */
  81. {-5000, 0, 0}, /* dummy for top limit */
  82. {-1250, 0, 3290},
  83. {-750, 97, 3400},
  84. {-100, 96, 3410},
  85. {0, 0, 3406},
  86. },
  87. #elif defined(CONFIG_MACH_DEGASLTE_SPR)
  88. .low_battery_comp_voltage = 3450,
  89. .low_battery_table = {
  90. /* range, slope, offset */
  91. {-5000, 0, 0}, /* dummy for top limit */
  92. {-1250, 0, 3290},
  93. {-750, 97, 3400},
  94. {-100, 96, 3410},
  95. {0, 0, 3406},
  96. },
  97. #else
  98. .low_battery_comp_voltage = 3500,
  99. .low_battery_table = {
  100. /* range, slope, offset */
  101. {-5000, 0, 0}, /* dummy for top limit */
  102. {-1250, 0, 3320},
  103. {-750, 97, 3451},
  104. {-100, 96, 3461},
  105. {0, 0, 3456},
  106. },
  107. #endif
  108. .temp_adjust_table = {
  109. /* range, slope, offset */
  110. {47000, 122, 8950},
  111. {60000, 200, 51000},
  112. {100000, 0, 0}, /* dummy for top limit */
  113. },
  114. .type_str = "SDI",
  115. }
  116. };
  117. #else
  118. static void * samsung_battery_data;
  119. #endif
  120. #define CAPACITY_MAX 1000
  121. #define CAPACITY_MAX_MARGIN 50
  122. #define CAPACITY_MIN 0
  123. #if defined(CONFIG_MACH_AFYONLTE_TMO) || defined(CONFIG_MACH_AFYONLTE_CAN) || defined(CONFIG_MACH_AFYONLTE_MTR)
  124. #define TEMP_HIGH_THRESHOLD_EVENT 635
  125. #define TEMP_HIGH_RECOVERY_EVENT 462
  126. #define TEMP_LOW_THRESHOLD_EVENT (-33)
  127. #define TEMP_LOW_RECOVERY_EVENT 10
  128. #define TEMP_HIGH_THRESHOLD_NORMAL 545
  129. #define TEMP_HIGH_RECOVERY_NORMAL 462
  130. #define TEMP_LOW_THRESHOLD_NORMAL (-45)
  131. #define TEMP_LOW_RECOVERY_NORMAL (-4)
  132. #define TEMP_HIGH_THRESHOLD_LPM 520
  133. #define TEMP_HIGH_RECOVERY_LPM 480
  134. #define TEMP_LOW_THRESHOLD_LPM (-40)
  135. #define TEMP_LOW_RECOVERY_LPM (-5)
  136. #elif defined(CONFIG_MACH_ATLANTICLTE_ATT)
  137. #define TEMP_HIGH_THRESHOLD_EVENT 640
  138. #define TEMP_HIGH_RECOVERY_EVENT 490
  139. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  140. #define TEMP_LOW_RECOVERY_EVENT (-10)
  141. #define TEMP_HIGH_THRESHOLD_NORMAL 525
  142. #define TEMP_HIGH_RECOVERY_NORMAL 470
  143. #define TEMP_LOW_THRESHOLD_NORMAL (-25)
  144. #define TEMP_LOW_RECOVERY_NORMAL (-10)
  145. #define TEMP_HIGH_THRESHOLD_LPM 520
  146. #define TEMP_HIGH_RECOVERY_LPM 470
  147. #define TEMP_LOW_THRESHOLD_LPM (-15)
  148. #define TEMP_LOW_RECOVERY_LPM (-10)
  149. #elif defined(CONFIG_MACH_ATLANTICLTE_VZW)
  150. #define TEMP_HIGH_THRESHOLD_EVENT 610
  151. #define TEMP_HIGH_RECOVERY_EVENT 490
  152. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  153. #define TEMP_LOW_RECOVERY_EVENT (-10)
  154. #define TEMP_HIGH_THRESHOLD_NORMAL 510
  155. #define TEMP_HIGH_RECOVERY_NORMAL 470
  156. #define TEMP_LOW_THRESHOLD_NORMAL (-25)
  157. #define TEMP_LOW_RECOVERY_NORMAL 0
  158. #define TEMP_HIGH_THRESHOLD_LPM 510
  159. #define TEMP_HIGH_RECOVERY_LPM 470
  160. #define TEMP_LOW_THRESHOLD_LPM (-15)
  161. #define TEMP_LOW_RECOVERY_LPM 5
  162. #elif defined(CONFIG_MACH_ATLANTICLTE_USC)
  163. #define TEMP_HIGH_THRESHOLD_EVENT 600
  164. #define TEMP_HIGH_RECOVERY_EVENT 490
  165. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  166. #define TEMP_LOW_RECOVERY_EVENT (-10)
  167. #define TEMP_HIGH_THRESHOLD_NORMAL 530
  168. #define TEMP_HIGH_RECOVERY_NORMAL 470
  169. #define TEMP_LOW_THRESHOLD_NORMAL (-25)
  170. #define TEMP_LOW_RECOVERY_NORMAL 0
  171. #define TEMP_HIGH_THRESHOLD_LPM 510
  172. #define TEMP_HIGH_RECOVERY_LPM 470
  173. #define TEMP_LOW_THRESHOLD_LPM (-15)
  174. #define TEMP_LOW_RECOVERY_LPM 5
  175. #elif defined(CONFIG_MACH_HESTIALTE_EUR)
  176. #define TEMP_HIGH_THRESHOLD_EVENT 640
  177. #define TEMP_HIGH_RECOVERY_EVENT 490
  178. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  179. #define TEMP_LOW_RECOVERY_EVENT (-10)
  180. #define TEMP_HIGH_THRESHOLD_NORMAL 525
  181. #define TEMP_HIGH_RECOVERY_NORMAL 470
  182. #define TEMP_LOW_THRESHOLD_NORMAL (-25)
  183. #define TEMP_LOW_RECOVERY_NORMAL (-10)
  184. #define TEMP_HIGH_THRESHOLD_LPM 520
  185. #define TEMP_HIGH_RECOVERY_LPM 470
  186. #define TEMP_LOW_THRESHOLD_LPM (-15)
  187. #define TEMP_LOW_RECOVERY_LPM (-10)
  188. #elif defined(CONFIG_MACH_DEGASLTE_SPR)
  189. #define TEMP_HIGH_THRESHOLD_EVENT 615
  190. #define TEMP_HIGH_RECOVERY_EVENT 480
  191. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  192. #define TEMP_LOW_RECOVERY_EVENT 0
  193. #define TEMP_HIGH_THRESHOLD_NORMAL 500
  194. #define TEMP_HIGH_RECOVERY_NORMAL 470
  195. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  196. #define TEMP_LOW_RECOVERY_NORMAL 0
  197. #define TEMP_HIGH_THRESHOLD_LPM 500
  198. #define TEMP_HIGH_RECOVERY_LPM 495
  199. #define TEMP_LOW_THRESHOLD_LPM (-30)
  200. #define TEMP_LOW_RECOVERY_LPM 20
  201. #elif defined(CONFIG_MACH_MATISSELTE_VZW)
  202. #define TEMP_HIGH_THRESHOLD_EVENT 590
  203. #define TEMP_HIGH_RECOVERY_EVENT 500
  204. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  205. #define TEMP_LOW_RECOVERY_EVENT 0
  206. #define TEMP_HIGH_THRESHOLD_NORMAL 545
  207. #define TEMP_HIGH_RECOVERY_NORMAL 475
  208. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  209. #define TEMP_LOW_RECOVERY_NORMAL 0
  210. #define TEMP_HIGH_THRESHOLD_LPM 510
  211. #define TEMP_HIGH_RECOVERY_LPM 500
  212. #define TEMP_LOW_THRESHOLD_LPM (-10)
  213. #define TEMP_LOW_RECOVERY_LPM 0
  214. #elif defined(CONFIG_MACH_MATISSELTE_USC)
  215. #define TEMP_HIGH_THRESHOLD_EVENT 535
  216. #define TEMP_HIGH_RECOVERY_EVENT 500
  217. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  218. #define TEMP_LOW_RECOVERY_EVENT 0
  219. #define TEMP_HIGH_THRESHOLD_NORMAL 545
  220. #define TEMP_HIGH_RECOVERY_NORMAL 475
  221. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  222. #define TEMP_LOW_RECOVERY_NORMAL 0
  223. #define TEMP_HIGH_THRESHOLD_LPM 510
  224. #define TEMP_HIGH_RECOVERY_LPM 500
  225. #define TEMP_LOW_THRESHOLD_LPM (-10)
  226. #define TEMP_LOW_RECOVERY_LPM 0
  227. #elif defined(CONFIG_MACH_MATISSELTE_ATT)
  228. #define TEMP_HIGH_THRESHOLD_EVENT 590
  229. #define TEMP_HIGH_RECOVERY_EVENT 500
  230. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  231. #define TEMP_LOW_RECOVERY_EVENT 0
  232. #define TEMP_HIGH_THRESHOLD_NORMAL 545
  233. #define TEMP_HIGH_RECOVERY_NORMAL 475
  234. #define TEMP_LOW_THRESHOLD_NORMAL (-40)
  235. #define TEMP_LOW_RECOVERY_NORMAL 0
  236. #define TEMP_HIGH_THRESHOLD_LPM 510
  237. #define TEMP_HIGH_RECOVERY_LPM 500
  238. #define TEMP_LOW_THRESHOLD_LPM (-10)
  239. #define TEMP_LOW_RECOVERY_LPM 0
  240. #elif defined(CONFIG_MACH_MATISSEWIFIUS_OPEN)
  241. #define TEMP_HIGH_THRESHOLD_EVENT 530
  242. #define TEMP_HIGH_RECOVERY_EVENT 460
  243. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  244. #define TEMP_LOW_RECOVERY_EVENT 0
  245. #define TEMP_HIGH_THRESHOLD_NORMAL 530
  246. #define TEMP_HIGH_RECOVERY_NORMAL 460
  247. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  248. #define TEMP_LOW_RECOVERY_NORMAL 0
  249. #define TEMP_HIGH_THRESHOLD_LPM 510
  250. #define TEMP_HIGH_RECOVERY_LPM 490
  251. #define TEMP_LOW_THRESHOLD_LPM 0
  252. #define TEMP_LOW_RECOVERY_LPM 5
  253. #elif defined(CONFIG_MACH_MILLETLTE_VZW)
  254. #define TEMP_HIGH_THRESHOLD_EVENT 645
  255. #define TEMP_HIGH_RECOVERY_EVENT 460
  256. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  257. #define TEMP_LOW_RECOVERY_EVENT 0
  258. #define TEMP_HIGH_THRESHOLD_NORMAL 555
  259. #define TEMP_HIGH_RECOVERY_NORMAL 460
  260. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  261. #define TEMP_LOW_RECOVERY_NORMAL 0
  262. #define TEMP_HIGH_THRESHOLD_LPM 510
  263. #define TEMP_HIGH_RECOVERY_LPM 460
  264. #define TEMP_LOW_THRESHOLD_LPM (-40)
  265. #define TEMP_LOW_RECOVERY_LPM 0
  266. #elif defined(CONFIG_MACH_MILLETLTE_ATT)
  267. #define TEMP_HIGH_THRESHOLD_EVENT 560
  268. #define TEMP_HIGH_RECOVERY_EVENT 475
  269. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  270. #define TEMP_LOW_RECOVERY_EVENT 10
  271. #define TEMP_HIGH_THRESHOLD_NORMAL 555
  272. #define TEMP_HIGH_RECOVERY_NORMAL 475
  273. #define TEMP_LOW_THRESHOLD_NORMAL (-40)
  274. #define TEMP_LOW_RECOVERY_NORMAL 10
  275. #define TEMP_HIGH_THRESHOLD_LPM 525
  276. #define TEMP_HIGH_RECOVERY_LPM 470
  277. #define TEMP_LOW_THRESHOLD_LPM (-25)
  278. #define TEMP_LOW_RECOVERY_LPM 10
  279. #elif defined(CONFIG_MACH_MILLETLTE_CAN) || defined(CONFIG_MACH_MILLETLTE_TMO)
  280. #define TEMP_HIGH_THRESHOLD_EVENT 645
  281. #define TEMP_HIGH_RECOVERY_EVENT 475
  282. #define TEMP_LOW_THRESHOLD_EVENT (-40)
  283. #define TEMP_LOW_RECOVERY_EVENT 10
  284. #define TEMP_HIGH_THRESHOLD_NORMAL 555
  285. #define TEMP_HIGH_RECOVERY_NORMAL 475
  286. #define TEMP_LOW_THRESHOLD_NORMAL (-40)
  287. #define TEMP_LOW_RECOVERY_NORMAL 10
  288. #define TEMP_HIGH_THRESHOLD_LPM 525
  289. #define TEMP_HIGH_RECOVERY_LPM 470
  290. #define TEMP_LOW_THRESHOLD_LPM (-25)
  291. #define TEMP_LOW_RECOVERY_LPM 10
  292. #elif defined(CONFIG_MACH_MILLETWIFIUS_OPEN)
  293. #define TEMP_HIGH_THRESHOLD_EVENT 610
  294. #define TEMP_HIGH_RECOVERY_EVENT 470
  295. #define TEMP_LOW_THRESHOLD_EVENT 0
  296. #define TEMP_LOW_RECOVERY_EVENT 30
  297. #define TEMP_HIGH_THRESHOLD_NORMAL 510
  298. #define TEMP_HIGH_RECOVERY_NORMAL 470
  299. #define TEMP_LOW_THRESHOLD_NORMAL 0
  300. #define TEMP_LOW_RECOVERY_NORMAL 30
  301. #define TEMP_HIGH_THRESHOLD_LPM 510
  302. #define TEMP_HIGH_RECOVERY_LPM 480
  303. #define TEMP_LOW_THRESHOLD_LPM 0
  304. #define TEMP_LOW_RECOVERY_LPM 30
  305. #elif defined(CONFIG_SEC_MATISSE_PROJECT)
  306. #define TEMP_HIGH_THRESHOLD_EVENT 540
  307. #define TEMP_HIGH_RECOVERY_EVENT 460
  308. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  309. #define TEMP_LOW_RECOVERY_EVENT 0
  310. #define TEMP_HIGH_THRESHOLD_NORMAL 540
  311. #define TEMP_HIGH_RECOVERY_NORMAL 460
  312. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  313. #define TEMP_LOW_RECOVERY_NORMAL 0
  314. #define TEMP_HIGH_THRESHOLD_LPM 510
  315. #define TEMP_HIGH_RECOVERY_LPM 490
  316. #define TEMP_LOW_THRESHOLD_LPM 0
  317. #define TEMP_LOW_RECOVERY_LPM 5
  318. #elif defined(CONFIG_MACH_MILLET3G_CHN_OPEN)
  319. #define TEMP_HIGH_THRESHOLD_EVENT 600
  320. #define TEMP_HIGH_RECOVERY_EVENT 460
  321. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  322. #define TEMP_LOW_RECOVERY_EVENT 0
  323. #define TEMP_HIGH_THRESHOLD_NORMAL 520
  324. #define TEMP_HIGH_RECOVERY_NORMAL 460
  325. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  326. #define TEMP_LOW_RECOVERY_NORMAL 0
  327. #define TEMP_HIGH_THRESHOLD_LPM 520
  328. #define TEMP_HIGH_RECOVERY_LPM 460
  329. #define TEMP_LOW_THRESHOLD_LPM (-50)
  330. #define TEMP_LOW_RECOVERY_LPM 0
  331. #elif defined(CONFIG_SEC_VICTOR_PROJECT)
  332. #define TEMP_HIGH_THRESHOLD_EVENT 600
  333. #define TEMP_HIGH_RECOVERY_EVENT 460
  334. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  335. #define TEMP_LOW_RECOVERY_EVENT 0
  336. #define TEMP_HIGH_THRESHOLD_NORMAL 600
  337. #define TEMP_HIGH_RECOVERY_NORMAL 460
  338. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  339. #define TEMP_LOW_RECOVERY_NORMAL 0
  340. #define TEMP_HIGH_THRESHOLD_LPM 600
  341. #define TEMP_HIGH_RECOVERY_LPM 460
  342. #define TEMP_LOW_THRESHOLD_LPM (-50)
  343. #define TEMP_LOW_RECOVERY_LPM 0
  344. #elif defined(CONFIG_SEC_ATLANTIC3G_COMMON)
  345. #define TEMP_HIGH_THRESHOLD_EVENT 600
  346. #define TEMP_HIGH_RECOVERY_EVENT 460
  347. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  348. #define TEMP_LOW_RECOVERY_EVENT 0
  349. #define TEMP_HIGH_THRESHOLD_NORMAL 600
  350. #define TEMP_HIGH_RECOVERY_NORMAL 460
  351. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  352. #define TEMP_LOW_RECOVERY_NORMAL 0
  353. #define TEMP_HIGH_THRESHOLD_LPM 600
  354. #define TEMP_HIGH_RECOVERY_LPM 460
  355. #define TEMP_LOW_THRESHOLD_LPM (-50)
  356. #define TEMP_LOW_RECOVERY_LPM 0
  357. #elif defined(CONFIG_SEC_MEGA2_PROJECT)
  358. #define TEMP_HIGH_THRESHOLD_EVENT 600
  359. #define TEMP_HIGH_RECOVERY_EVENT 460
  360. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  361. #define TEMP_LOW_RECOVERY_EVENT 0
  362. #define TEMP_HIGH_THRESHOLD_NORMAL 600
  363. #define TEMP_HIGH_RECOVERY_NORMAL 460
  364. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  365. #define TEMP_LOW_RECOVERY_NORMAL 0
  366. #define TEMP_HIGH_THRESHOLD_LPM 600
  367. #define TEMP_HIGH_RECOVERY_LPM 460
  368. #define TEMP_LOW_THRESHOLD_LPM (-50)
  369. #define TEMP_LOW_RECOVERY_LPM 0
  370. #else
  371. #define TEMP_HIGH_THRESHOLD_EVENT 520
  372. #define TEMP_HIGH_RECOVERY_EVENT 460
  373. #define TEMP_LOW_THRESHOLD_EVENT (-50)
  374. #define TEMP_LOW_RECOVERY_EVENT 0
  375. #define TEMP_HIGH_THRESHOLD_NORMAL 520
  376. #define TEMP_HIGH_RECOVERY_NORMAL 460
  377. #define TEMP_LOW_THRESHOLD_NORMAL (-50)
  378. #define TEMP_LOW_RECOVERY_NORMAL 0
  379. #define TEMP_HIGH_THRESHOLD_LPM 520
  380. #define TEMP_HIGH_RECOVERY_LPM 460
  381. #define TEMP_LOW_THRESHOLD_LPM (-50)
  382. #define TEMP_LOW_RECOVERY_LPM 0
  383. #endif
  384. #if defined(CONFIG_MACH_AFYONLTE_TMO) || defined(CONFIG_MACH_AFYONLTE_CAN) || defined(CONFIG_MACH_AFYONLTE_MTR)
  385. static sec_bat_adc_table_data_t temp_table[] = {
  386. {26390, 800},
  387. {26780, 750},
  388. {27182, 700},
  389. {27604, 650},
  390. {28080, 600},
  391. {28628, 550},
  392. {28858, 530},
  393. {29182, 510},
  394. {29306, 500},
  395. {29438, 490},
  396. {29627, 480},
  397. {30032, 450},
  398. {30879, 400},
  399. {31325, 380},
  400. {31772, 350},
  401. {32132, 330},
  402. {32825, 300},
  403. {33127, 280},
  404. {33825, 250},
  405. {34132, 230},
  406. {34843, 200},
  407. {35228, 180},
  408. {35911, 150},
  409. {36313, 130},
  410. {37021, 100},
  411. {37356, 80},
  412. {38034, 50},
  413. {38433, 30},
  414. {38716, 10},
  415. {38912, 0},
  416. {39120, -10},
  417. {39442, -30},
  418. {39855, -50},
  419. {40043, -70},
  420. {40580, -100},
  421. {41173, -150},
  422. {41667, -200},
  423. };
  424. #elif defined(CONFIG_MACH_ATLANTICLTE_ATT)
  425. static sec_bat_adc_table_data_t temp_table[] = {
  426. {26050, 900},
  427. {26273, 850},
  428. {26524, 800},
  429. {26847, 750},
  430. {27037, 700},
  431. {27456, 650},
  432. {27942, 600},
  433. {28513, 550},
  434. {28890, 520},
  435. {29150, 500},
  436. {29595, 470},
  437. {29903, 450},
  438. {30773, 400},
  439. {31738, 350},
  440. {32758, 300},
  441. {33836, 250},
  442. {34871, 200},
  443. {36007, 150},
  444. {37110, 100},
  445. {38207, 50},
  446. {39164, 0},
  447. {39558, -20},
  448. {40054, -50},
  449. {40696, -100},
  450. {41294, -150},
  451. {41828, -200},
  452. };
  453. #elif defined(CONFIG_MACH_ATLANTICLTE_USC) || defined(CONFIG_MACH_ATLANTICLTE_VZW)
  454. static sec_bat_adc_table_data_t temp_table[] = {
  455. {26050, 900},
  456. {26273, 850},
  457. {26524, 800},
  458. {26847, 750},
  459. {27037, 700},
  460. {27456, 650},
  461. {27942, 600},
  462. {28513, 550},
  463. {28890, 520},
  464. {29150, 500},
  465. {29595, 470},
  466. {29903, 450},
  467. {30773, 400},
  468. {31738, 350},
  469. {32758, 300},
  470. {33836, 250},
  471. {34871, 200},
  472. {36007, 150},
  473. {37110, 100},
  474. {38207, 50},
  475. {39164, 0},
  476. {39558, -20},
  477. {40054, -50},
  478. {40696, -100},
  479. {41294, -150},
  480. {41828, -200},
  481. };
  482. #elif defined(CONFIG_MACH_HESTIALTE_EUR)
  483. static sec_bat_adc_table_data_t temp_table[] = {
  484. {26050, 900},
  485. {26273, 850},
  486. {26524, 800},
  487. {26847, 750},
  488. {27037, 700},
  489. {27456, 650},
  490. {27942, 600},
  491. {28513, 550},
  492. {28890, 520},
  493. {29150, 500},
  494. {29595, 470},
  495. {29903, 450},
  496. {30773, 400},
  497. {31738, 350},
  498. {32758, 300},
  499. {33836, 250},
  500. {34871, 200},
  501. {36007, 150},
  502. {37110, 100},
  503. {38207, 50},
  504. {39164, 0},
  505. {39558, -20},
  506. {40054, -50},
  507. {40696, -100},
  508. {41294, -150},
  509. {41828, -200},
  510. };
  511. #elif defined(CONFIG_MACH_DEGASLTE_SPR)
  512. static sec_bat_adc_table_data_t temp_table[] = {
  513. {26800, 650},
  514. {27684, 620},
  515. {27838, 600},
  516. {28084, 580},
  517. {28200, 550},
  518. {28400, 530},
  519. {28710, 510},
  520. {28869, 500},
  521. {28980, 490},
  522. {29120, 480},
  523. {29354, 460},
  524. {29670, 440},
  525. {30841, 400},
  526. {31766, 350},
  527. {32700, 300},
  528. {33827, 250},
  529. {34936, 200},
  530. {35990, 150},
  531. {36558, 130},
  532. {36800, 100},
  533. {37020, 80},
  534. {37455, 50},
  535. {38020, 30},
  536. {38420, 10},
  537. {38639, 0},
  538. {38865, -10},
  539. {39321, -30},
  540. {39589, -50},
  541. {40281, -70},
  542. {40468, -100},
  543. {41039, -150},
  544. {41595, -200},
  545. };
  546. #elif defined(CONFIG_MACH_MILLETLTE_VZW)
  547. static sec_bat_adc_table_data_t temp_table[] = {
  548. {25950, 900},
  549. {26183, 850},
  550. {26397, 800},
  551. {26700, 750},
  552. {27061, 700},
  553. {27424, 650},
  554. {27873, 600},
  555. {28422, 550},
  556. {29065, 500},
  557. {29761, 450},
  558. {30819, 400},
  559. {31731, 350},
  560. {32633, 300},
  561. {33665, 250},
  562. {34711, 200},
  563. {35572, 150},
  564. {36680, 100},
  565. {37628, 50},
  566. {38706, 0},
  567. {39569, -50},
  568. {40286, -100},
  569. {40894, -150},
  570. {41448, -200},
  571. };
  572. #elif defined(CONFIG_MACH_MILLETLTE_ATT) || defined(CONFIG_MACH_MILLETLTE_CAN) || defined(CONFIG_MACH_MILLETLTE_TMO)
  573. static sec_bat_adc_table_data_t temp_table[] = {
  574. {26050, 900},
  575. {26283, 850},
  576. {26497, 800},
  577. {26800, 750},
  578. {27161, 700},
  579. {27524, 650},
  580. {27981, 600},
  581. {28527, 550},
  582. {28884, 520},
  583. {29173, 500},
  584. {29576, 470},
  585. {29864, 450},
  586. {30741, 400},
  587. {31677, 350},
  588. {32679, 300},
  589. {33743, 250},
  590. {34833, 200},
  591. {35940, 150},
  592. {37012, 100},
  593. {38083, 50},
  594. {39019, 0},
  595. {39360, -20},
  596. {39888, -50},
  597. {40495, -100},
  598. {41117, -150},
  599. {41671, -200},
  600. };
  601. #elif defined(CONFIG_MACH_MILLET3G_CHN_OPEN)
  602. static sec_bat_adc_table_data_t temp_table[] = {
  603. {26437, 900},
  604. {27225, 800},
  605. {28019, 700},
  606. {28531, 650},
  607. {28738, 620},
  608. {29025, 600},
  609. {29126, 580},
  610. {29570, 550},
  611. {30158, 500},
  612. {30420, 470},
  613. {30808, 450},
  614. {30953, 430},
  615. {31500, 400},
  616. {32149, 350},
  617. {32924, 300},
  618. {33849, 250},
  619. {34775, 200},
  620. {35694, 150},
  621. {36545, 100},
  622. {37402, 50},
  623. {37820, 20},
  624. {38215, 0},
  625. {38727, -30},
  626. {38957, -50},
  627. {39618, -100},
  628. {40303, -150},
  629. {40584, -200},
  630. };
  631. #elif defined(CONFIG_SEC_MILLET_PROJECT)
  632. static sec_bat_adc_table_data_t temp_table[] = {
  633. {26437, 900},
  634. {27225, 800},
  635. {28019, 700},
  636. {28378, 650},
  637. {28738, 620},
  638. {28917, 600},
  639. {29126, 580},
  640. {29576, 550},
  641. {30027, 500},
  642. {30420, 470},
  643. {30675, 450},
  644. {30953, 430},
  645. {31375, 400},
  646. {32149, 350},
  647. {32924, 300},
  648. {33849, 250},
  649. {34775, 200},
  650. {35694, 150},
  651. {36613, 100},
  652. {37216, 50},
  653. {37820, 20},
  654. {38170, 0},
  655. {38727, -30},
  656. {38878, -50},
  657. {39589, -100},
  658. {40303, -150},
  659. {40584, -200},
  660. };
  661. #elif defined(CONFIG_MACH_MATISSELTE_ATT)
  662. static sec_bat_adc_table_data_t temp_table[] = {
  663. {32938, 700},
  664. {32888, 650},
  665. {32938, 600},
  666. {32991, 550},
  667. {33122, 500},
  668. {33095, 470},
  669. {33131, 450},
  670. {33218, 400},
  671. {33332, 350},
  672. {33474, 300},
  673. {33606, 250},
  674. {33797, 200},
  675. {33983, 150},
  676. {34281, 100},
  677. {34581, 50},
  678. {34857, 10},
  679. {34937, 0},
  680. {35131, -30},
  681. {35326, -50},
  682. {35795, -100},
  683. {36419, -150},
  684. {37016, -200},
  685. {37687, -250},
  686. {38387, -300},
  687. };
  688. #elif defined(CONFIG_MACH_MATISSELTE_VZW) || defined(CONFIG_MACH_MATISSELTE_USC)
  689. static sec_bat_adc_table_data_t temp_table[] = {
  690. {32810, 750},
  691. {32848, 700},
  692. {32888, 650},
  693. {32938, 600},
  694. {32991, 550},
  695. {33055, 500},
  696. {33131, 450},
  697. {33218, 400},
  698. {33332, 350},
  699. {33474, 300},
  700. {33606, 250},
  701. {33797, 200},
  702. {33983, 150},
  703. {34281, 100},
  704. {34581, 50},
  705. {34937, 0},
  706. {35326, -50},
  707. {35795, -100},
  708. {36419, -150},
  709. {37016, -200},
  710. {37687, -250},
  711. {38387, -300},
  712. };
  713. #elif defined(CONFIG_SEC_MATISSE_PROJECT)
  714. static sec_bat_adc_table_data_t temp_table[] = {
  715. {24384, 900},
  716. {25129, 850},
  717. {25875, 800},
  718. {27567, 750},
  719. {27935, 700},
  720. {28388, 650},
  721. {28827, 600},
  722. {29363, 550},
  723. {29973, 500},
  724. {30585, 450},
  725. {31306, 400},
  726. {32056, 350},
  727. {32856, 300},
  728. {33728, 250},
  729. {34597, 200},
  730. {35633, 150},
  731. {36390, 100},
  732. {37252, 50},
  733. {38087, 0},
  734. {38867, -50},
  735. {39626, -100},
  736. {40212, -150},
  737. {40795, -200},
  738. };
  739. #elif defined(CONFIG_SEC_VICTOR_PROJECT)
  740. static sec_bat_adc_table_data_t temp_table[] = {
  741. {26500, 800},
  742. {26757, 750},
  743. {27122, 700},
  744. {27542, 650},
  745. {28028, 600},
  746. {28604, 550},
  747. {29290, 500},
  748. {29994, 450},
  749. {30854, 400},
  750. {31718, 350},
  751. {32748, 300},
  752. {33805, 250},
  753. {34969, 200},
  754. {36039, 150},
  755. {37081, 100},
  756. {38087, 50},
  757. {38997, 0},
  758. {39186, -10},
  759. {39353, -20},
  760. {39519, -30},
  761. {39828, -50},
  762. {40552, -100},
  763. {41143, -150},
  764. {41626, -200},
  765. };
  766. #elif defined(CONFIG_SEC_BERLUTI_PROJECT)
  767. static sec_bat_adc_table_data_t temp_table[] = {
  768. {25463, 900},
  769. {25933, 850},
  770. {26405, 800},
  771. {26735, 750},
  772. {27065, 700},
  773. {27545, 650},
  774. {28027, 600},
  775. {28549, 550},
  776. {29183, 500},
  777. {29932, 450},
  778. {30771, 400},
  779. {31735, 350},
  780. {32673, 300},
  781. {33748, 250},
  782. {34828, 200},
  783. {35928, 150},
  784. {37030, 100},
  785. {37990, 50},
  786. {38958, 0},
  787. {39807, -50},
  788. {40454, -100},
  789. {41034, -150},
  790. {41614, -200},
  791. };
  792. #elif defined(CONFIG_SEC_ATLANTIC3G_COMMON)
  793. static sec_bat_adc_table_data_t temp_table[] = {
  794. {26050, 920},
  795. {26273, 870},
  796. {26524, 820},
  797. {26847, 770},
  798. {27037, 720},
  799. {27456, 670},
  800. {27823, 620},
  801. {28400, 570},
  802. {28890, 540},
  803. {28976, 520},
  804. {29417, 490},
  805. {29704, 470},
  806. {30519, 420},
  807. {31368, 370},
  808. {32492, 320},
  809. {33460, 270},
  810. {34895, 220},
  811. {35670, 170},
  812. {36752, 120},
  813. {37724, 70},
  814. {38645, 2},
  815. {39005, 0},
  816. {39490, -30},
  817. {40696, -80},
  818. {41294, -130},
  819. {41828, -180},
  820. };
  821. #elif defined(CONFIG_SEC_MEGA2_PROJECT)
  822. static sec_bat_adc_table_data_t temp_table[] = {
  823. {25950, 900},
  824. {26173, 850},
  825. {26424, 800},
  826. {26727, 750},
  827. {27100, 700},
  828. {27625, 650},
  829. {28162, 600},
  830. {28705, 550},
  831. {29386, 500},
  832. {30071, 450},
  833. {30981, 400},
  834. {32025, 350},
  835. {33068, 300},
  836. {34106, 250},
  837. {35144, 200},
  838. {36227, 150},
  839. {37310, 100},
  840. {38273, 50},
  841. {39237, 0},
  842. {40041, -50},
  843. {40690, -100},
  844. {41420, -150},
  845. {42000, -200},
  846. };
  847. #else
  848. static sec_bat_adc_table_data_t temp_table[] = {
  849. {25950, 900},
  850. {26173, 850},
  851. {26424, 800},
  852. {26727, 750},
  853. {26884, 700},
  854. {27346, 650},
  855. {27750, 600},
  856. {28213, 550},
  857. {28760, 500},
  858. {29384, 450},
  859. {30180, 400},
  860. {31095, 350},
  861. {32085, 300},
  862. {33132, 250},
  863. {34242, 200},
  864. {35340, 150},
  865. {36430, 100},
  866. {37471, 50},
  867. {38406, 0},
  868. {39388, -50},
  869. {40184, -100},
  870. {40852, -150},
  871. {41420, -200},
  872. };
  873. #endif
  874. static sec_bat_adc_table_data_t chg_temp_table[] = {
  875. {0, 0},
  876. };
  877. #endif //CONFIG_BATTERY_SAMSUNG_DATA
  878. static void sec_bat_adc_ap_init(struct platform_device *pdev,
  879. struct sec_battery_info *battery)
  880. {
  881. temp_channel = LR_MUX1_BATT_THERM;
  882. pr_info("%s : temp_channel = %d\n", __func__,temp_channel);
  883. if (battery->pdata->chg_temp_check)
  884. chg_temp_channel = LR_MUX9_PU1_AMUX_THM5;
  885. }
  886. static int sec_bat_adc_ap_read(struct sec_battery_info *battery, int channel)
  887. {
  888. struct qpnp_vadc_result results;
  889. int rc = -1;
  890. int data = -1;
  891. switch (channel)
  892. {
  893. case SEC_BAT_ADC_CHANNEL_TEMP :
  894. rc = qpnp_vadc_read(NULL, temp_channel, &results);
  895. if (rc) {
  896. pr_err("%s: Unable to read batt temperature rc=%d\n",
  897. __func__, rc);
  898. return 0;
  899. }
  900. data = results.adc_code;
  901. break;
  902. case SEC_BAT_ADC_CHANNEL_TEMP_AMBIENT:
  903. data = 33000;
  904. break;
  905. case SEC_BAT_ADC_CHANNEL_BAT_CHECK:
  906. rc = qpnp_vadc_read(NULL, LR_MUX2_BAT_ID, &results);
  907. if (rc) {
  908. pr_err("%s: Unable to read BATT_ID ADC rc=%d\n",
  909. __func__, rc);
  910. return 0;
  911. }
  912. pr_debug("BAT_ID physical= %lld, raw = 0x%x\n", results.physical, results.adc_code);
  913. data = results.physical;
  914. break;
  915. case SEC_BAT_ADC_CHANNEL_CHG_TEMP:
  916. rc = qpnp_vadc_read(NULL, chg_temp_channel, &results);
  917. if (rc) {
  918. pr_err("%s: Unable to read chg temperature rc=%d\n",
  919. __func__, rc);
  920. return 33000;
  921. }
  922. data = results.adc_code;
  923. break;
  924. default :
  925. break;
  926. }
  927. pr_debug("%s: data(%d)\n", __func__, data);
  928. return data;
  929. }
  930. static void sec_bat_adc_ap_exit(void)
  931. {
  932. }
  933. static void sec_bat_adc_none_init(struct platform_device *pdev,
  934. struct sec_battery_info *battery)
  935. {
  936. }
  937. static int sec_bat_adc_none_read(struct sec_battery_info *battery, int channel)
  938. {
  939. return 0;
  940. }
  941. static void sec_bat_adc_none_exit(void)
  942. {
  943. }
  944. static void sec_bat_adc_ic_init(struct platform_device *pdev,
  945. struct sec_battery_info *battery)
  946. {
  947. }
  948. static int sec_bat_adc_ic_read(struct sec_battery_info *battery, int channel)
  949. {
  950. return 0;
  951. }
  952. static void sec_bat_adc_ic_exit(void)
  953. {
  954. }
  955. static int adc_read_type(struct sec_battery_info *battery, int channel)
  956. {
  957. int adc = 0;
  958. switch (battery->pdata->temp_adc_type)
  959. {
  960. case SEC_BATTERY_ADC_TYPE_NONE :
  961. adc = sec_bat_adc_none_read(battery, channel);
  962. break;
  963. case SEC_BATTERY_ADC_TYPE_AP :
  964. adc = sec_bat_adc_ap_read(battery, channel);
  965. break;
  966. case SEC_BATTERY_ADC_TYPE_IC :
  967. adc = sec_bat_adc_ic_read(battery, channel);
  968. break;
  969. case SEC_BATTERY_ADC_TYPE_NUM :
  970. break;
  971. default :
  972. break;
  973. }
  974. pr_debug("[%s] ADC = %d\n", __func__, adc);
  975. return adc;
  976. }
  977. static void adc_init_type(struct platform_device *pdev,
  978. struct sec_battery_info *battery)
  979. {
  980. switch (battery->pdata->temp_adc_type)
  981. {
  982. case SEC_BATTERY_ADC_TYPE_NONE :
  983. sec_bat_adc_none_init(pdev, battery);
  984. break;
  985. case SEC_BATTERY_ADC_TYPE_AP :
  986. sec_bat_adc_ap_init(pdev, battery);
  987. break;
  988. case SEC_BATTERY_ADC_TYPE_IC :
  989. sec_bat_adc_ic_init(pdev, battery);
  990. break;
  991. case SEC_BATTERY_ADC_TYPE_NUM :
  992. break;
  993. default :
  994. break;
  995. }
  996. }
  997. static void adc_exit_type(struct sec_battery_info *battery)
  998. {
  999. switch (battery->pdata->temp_adc_type)
  1000. {
  1001. case SEC_BATTERY_ADC_TYPE_NONE :
  1002. sec_bat_adc_none_exit();
  1003. break;
  1004. case SEC_BATTERY_ADC_TYPE_AP :
  1005. sec_bat_adc_ap_exit();
  1006. break;
  1007. case SEC_BATTERY_ADC_TYPE_IC :
  1008. sec_bat_adc_ic_exit();
  1009. break;
  1010. case SEC_BATTERY_ADC_TYPE_NUM :
  1011. break;
  1012. default :
  1013. break;
  1014. }
  1015. }
  1016. int adc_read(struct sec_battery_info *battery, int channel)
  1017. {
  1018. int adc = 0;
  1019. adc = adc_read_type(battery, channel);
  1020. pr_info("[%s]adc = %d\n", __func__, adc);
  1021. return adc;
  1022. }
  1023. void adc_exit(struct sec_battery_info *battery)
  1024. {
  1025. adc_exit_type(battery);
  1026. }
  1027. bool sec_bat_check_jig_status(void)
  1028. {
  1029. #if defined(CONFIG_MACH_AFYONLTE_TMO) || defined(CONFIG_MACH_AFYONLTE_CAN) || defined(CONFIG_MACH_AFYONLTE_MTR)
  1030. return check_jig_state();
  1031. #elif defined(CONFIG_SEC_MATISSE_PROJECT) || defined(CONFIG_SEC_MILLET_PROJECT)
  1032. return check_sm5502_jig_state();
  1033. #else
  1034. return false;
  1035. #endif
  1036. }
  1037. /* callback for battery check
  1038. * return : bool
  1039. * true - battery detected, false battery NOT detected
  1040. */
  1041. bool sec_bat_check_callback(struct sec_battery_info *battery)
  1042. {
  1043. return true;
  1044. }
  1045. void sec_bat_check_cable_result_callback(struct device *dev,
  1046. int cable_type)
  1047. {
  1048. }
  1049. int sec_bat_check_cable_callback(struct sec_battery_info *battery)
  1050. {
  1051. union power_supply_propval value;
  1052. if (battery->pdata->ta_irq_gpio == 0) {
  1053. pr_err("%s: ta_int_gpio is 0 or not assigned yet(cable_type(%d))\n",
  1054. __func__, current_cable_type);
  1055. } else {
  1056. if (battery->wire_status == POWER_SUPPLY_TYPE_BATTERY &&
  1057. !gpio_get_value_cansleep(battery->pdata->ta_irq_gpio)) {
  1058. pr_info("%s : VBUS IN\n", __func__);
  1059. value.intval = POWER_SUPPLY_TYPE_UARTOFF;
  1060. psy_do_property("battery", set, POWER_SUPPLY_PROP_ONLINE, value);
  1061. current_cable_type = POWER_SUPPLY_TYPE_UARTOFF;
  1062. return POWER_SUPPLY_TYPE_UARTOFF;
  1063. }
  1064. if ((battery->wire_status == POWER_SUPPLY_TYPE_UARTOFF ||
  1065. battery->wire_status == POWER_SUPPLY_TYPE_CARDOCK) &&
  1066. gpio_get_value_cansleep(battery->pdata->ta_irq_gpio)) {
  1067. pr_info("%s : VBUS OUT\n", __func__);
  1068. value.intval = POWER_SUPPLY_TYPE_BATTERY;
  1069. psy_do_property("battery", set, POWER_SUPPLY_PROP_ONLINE, value);
  1070. current_cable_type = POWER_SUPPLY_TYPE_BATTERY;
  1071. return POWER_SUPPLY_TYPE_BATTERY;
  1072. }
  1073. }
  1074. return current_cable_type;
  1075. }
  1076. void board_battery_init(struct platform_device *pdev, struct sec_battery_info *battery)
  1077. {
  1078. if ((!battery->pdata->temp_adc_table) &&
  1079. (battery->pdata->thermal_source == SEC_BATTERY_THERMAL_SOURCE_ADC)) {
  1080. pr_info("%s : assign temp adc table\n", __func__);
  1081. battery->pdata->temp_adc_table = temp_table;
  1082. battery->pdata->temp_amb_adc_table = temp_table;
  1083. battery->pdata->temp_adc_table_size = sizeof(temp_table)/sizeof(sec_bat_adc_table_data_t);
  1084. battery->pdata->temp_amb_adc_table_size = sizeof(temp_table)/sizeof(sec_bat_adc_table_data_t);
  1085. }
  1086. if ((!battery->pdata->chg_temp_adc_table) &&
  1087. (battery->pdata->chg_temp_check)) {
  1088. pr_info("%s : assign chg temp adc table\n", __func__);
  1089. battery->pdata->chg_temp_adc_table = chg_temp_table;
  1090. battery->pdata->chg_temp_adc_table_size = sizeof(chg_temp_table)/sizeof(sec_bat_adc_table_data_t);
  1091. }
  1092. battery->pdata->event_check = true;
  1093. battery->pdata->temp_high_threshold_event = TEMP_HIGH_THRESHOLD_EVENT;
  1094. battery->pdata->temp_high_recovery_event = TEMP_HIGH_RECOVERY_EVENT;
  1095. battery->pdata->temp_low_threshold_event = TEMP_LOW_THRESHOLD_EVENT;
  1096. battery->pdata->temp_low_recovery_event = TEMP_LOW_RECOVERY_EVENT;
  1097. battery->pdata->temp_high_threshold_normal = TEMP_HIGH_THRESHOLD_NORMAL;
  1098. battery->pdata->temp_high_recovery_normal = TEMP_HIGH_RECOVERY_NORMAL;
  1099. battery->pdata->temp_low_threshold_normal = TEMP_LOW_THRESHOLD_NORMAL;
  1100. battery->pdata->temp_low_recovery_normal = TEMP_LOW_RECOVERY_NORMAL;
  1101. battery->pdata->temp_high_threshold_lpm = TEMP_HIGH_THRESHOLD_LPM;
  1102. battery->pdata->temp_high_recovery_lpm = TEMP_HIGH_RECOVERY_LPM;
  1103. battery->pdata->temp_low_threshold_lpm = TEMP_LOW_THRESHOLD_LPM;
  1104. battery->pdata->temp_low_recovery_lpm = TEMP_LOW_RECOVERY_LPM;
  1105. #if defined(CONFIG_MACH_MATISSELTE_ATT) || defined(CONFIG_MACH_MATISSELTE_VZW) \
  1106. || defined(CONFIG_MACH_MILLETLTE_VZW) || defined(CONFIG_MACH_MATISSELTE_USC) || defined(CONFIG_MACH_MILLETLTE_ATT) || defined(CONFIG_MACH_MILLETLTE_CAN) || defined(CONFIG_MACH_MILLETLTE_TMO)
  1107. battery->pdata->fuelgauge_name = "sec-fuelgauge";
  1108. #endif
  1109. #if defined(CONFIG_MACH_MATISSELTE_ATT) || defined(CONFIG_MACH_MATISSELTE_VZW) || defined(CONFIG_MACH_MATISSELTE_USC)
  1110. battery->pdata->thermal_source = SEC_BATTERY_THERMAL_SOURCE_FG;
  1111. #endif
  1112. #if defined(CONFIG_MACH_MATISSELTE_ATT)
  1113. if(system_rev<=1)
  1114. battery->pdata->temp_check_type = SEC_BATTERY_TEMP_CHECK_NONE;
  1115. #endif
  1116. #if defined(CONFIG_BATTERY_SWELLING)
  1117. battery->pdata->swelling_high_temp_block = BATT_SWELLING_HIGH_TEMP_BLOCK;
  1118. battery->pdata->swelling_high_temp_recov = BATT_SWELLING_HIGH_TEMP_RECOV;
  1119. battery->pdata->swelling_low_temp_blck = BATT_SWELLING_LOW_TEMP_BLOCK;
  1120. battery->pdata->swelling_low_temp_recov = BATT_SWELLING_LOW_TEMP_RECOV;
  1121. battery->pdata->swelling_rechg_voltage = BATT_SWELLING_RECHG_VOLTAGE;
  1122. battery->pdata->swelling_block_time = BATT_SWELLING_BLOCK_TIME;
  1123. #endif
  1124. adc_init_type(pdev, battery);
  1125. }
  1126. void board_fuelgauge_init(struct sec_fuelgauge_info *fuelgauge)
  1127. {
  1128. sec_fuelgauge = fuelgauge;
  1129. if (!fuelgauge->pdata->battery_data) {
  1130. pr_info("%s : assign battery data\n", __func__);
  1131. fuelgauge->pdata->battery_data = (void *)samsung_battery_data;
  1132. }
  1133. fuelgauge->pdata->capacity_max = CAPACITY_MAX;
  1134. fuelgauge->pdata->capacity_max_margin = CAPACITY_MAX_MARGIN;
  1135. fuelgauge->pdata->capacity_min = CAPACITY_MIN;
  1136. #if defined(CONFIG_FUELGAUGE_MAX17048)
  1137. pr_info("%s: RCOMP0: 0x%x, RCOMP_charging: 0x%x, "
  1138. "temp_cohot: %d, temp_cocold: %d, "
  1139. "is_using_model_data: %d, type_str: %s, "
  1140. "capacity_max: %d, capacity_max_margin: %d, "
  1141. "capacity_min: %d, \n", __func__ ,
  1142. get_battery_data(fuelgauge).RCOMP0,
  1143. get_battery_data(fuelgauge).RCOMP_charging,
  1144. get_battery_data(fuelgauge).temp_cohot,
  1145. get_battery_data(fuelgauge).temp_cocold,
  1146. get_battery_data(fuelgauge).is_using_model_data,
  1147. get_battery_data(fuelgauge).type_str,
  1148. fuelgauge->pdata->capacity_max,
  1149. fuelgauge->pdata->capacity_max_margin,
  1150. fuelgauge->pdata->capacity_min
  1151. );
  1152. #endif
  1153. }
  1154. void cable_initial_check(struct sec_battery_info *battery)
  1155. {
  1156. union power_supply_propval value;
  1157. pr_info("%s : current_cable_type : (%d)\n", __func__, current_cable_type);
  1158. if (POWER_SUPPLY_TYPE_BATTERY != current_cable_type) {
  1159. value.intval = current_cable_type;
  1160. psy_do_property("battery", set,
  1161. POWER_SUPPLY_PROP_ONLINE, value);
  1162. } else {
  1163. psy_do_property(battery->pdata->charger_name, get,
  1164. POWER_SUPPLY_PROP_ONLINE, value);
  1165. if (value.intval == POWER_SUPPLY_TYPE_WIRELESS) {
  1166. value.intval = 1;
  1167. psy_do_property("wireless", set,
  1168. POWER_SUPPLY_PROP_ONLINE, value);
  1169. }
  1170. }
  1171. }