mt_bm_data.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607
  1. #include "mt_battery_custom_data.h"
  2. #include "mt_battery_meter.h"
  3. #include <linux/of.h>
  4. #include <linux/device.h>
  5. #define BAT_NTC_10 0
  6. #define BAT_NTC_47 1
  7. #define BAT_NTC_100 0
  8. /* ============================================================ */
  9. /* <DOD, Battery_Voltage> Table */
  10. /* ============================================================ */
  11. #if BAT_NTC_10
  12. static struct BATT_TEMPERATURE default_batt_temperature_table_10k[] = {
  13. {-20, 68237}
  14. ,
  15. {-15, 53650}
  16. ,
  17. {-10, 42506}
  18. ,
  19. {-5, 33892}
  20. ,
  21. {0, 27219}
  22. ,
  23. {5, 22021}
  24. ,
  25. {10, 17926}
  26. ,
  27. {15, 14674}
  28. ,
  29. {20, 12081}
  30. ,
  31. {25, 10000}
  32. ,
  33. {30, 8315}
  34. ,
  35. {35, 6948}
  36. ,
  37. {40, 5834}
  38. ,
  39. {45, 4917}
  40. ,
  41. {50, 4161}
  42. ,
  43. {55, 3535}
  44. ,
  45. {60, 3014}
  46. };
  47. #endif
  48. #if BAT_NTC_47
  49. static struct BATT_TEMPERATURE default_batt_temperature_table_47k[] = {
  50. {-20, 483954}
  51. ,
  52. {-15, 360850}
  53. ,
  54. {-10, 271697}
  55. ,
  56. {-5, 206463}
  57. ,
  58. {0, 158214}
  59. ,
  60. {5, 122259}
  61. ,
  62. {10, 95227}
  63. ,
  64. {15, 74730}
  65. ,
  66. {20, 59065}
  67. ,
  68. {25, 47000}
  69. ,
  70. {30, 37643}
  71. ,
  72. {35, 30334}
  73. ,
  74. {40, 24591}
  75. ,
  76. {45, 20048}
  77. ,
  78. {50, 16433}
  79. ,
  80. {55, 13539}
  81. ,
  82. {60, 11210}
  83. };
  84. #endif
  85. #if BAT_NTC_100
  86. static struct BATT_TEMPERATURE default_batt_temperature_table_100k[] = {
  87. {-20, 1151037}
  88. ,
  89. {-15, 846579}
  90. ,
  91. {-10, 628988}
  92. ,
  93. {-5, 471632}
  94. ,
  95. {0, 357012}
  96. ,
  97. {5, 272500}
  98. ,
  99. {10, 209710}
  100. ,
  101. {15, 162651}
  102. ,
  103. {20, 127080}
  104. ,
  105. {25, 100000}
  106. ,
  107. {30, 79222}
  108. ,
  109. {35, 63167}
  110. ,
  111. {40, 50677}
  112. ,
  113. {45, 40904}
  114. ,
  115. {50, 33195}
  116. ,
  117. {55, 27091}
  118. ,
  119. {60, 22224}
  120. };
  121. #endif
  122. /* T0 -10C */
  123. static struct BATTERY_PROFILE_STRUCT default_battery_profile_t0[] = {
  124. {0, 4180}
  125. ,
  126. {2, 4157}
  127. ,
  128. {4, 4139}
  129. ,
  130. {5, 4120}
  131. ,
  132. {7, 4105}
  133. ,
  134. {9, 4087}
  135. ,
  136. {11, 4072}
  137. ,
  138. {12, 4057}
  139. ,
  140. {14, 4043}
  141. ,
  142. {16, 4028}
  143. ,
  144. {18, 4013}
  145. ,
  146. {20, 4001}
  147. ,
  148. {21, 3989}
  149. ,
  150. {23, 3976}
  151. ,
  152. {25, 3964}
  153. ,
  154. {27, 3953}
  155. ,
  156. {28, 3942}
  157. ,
  158. {30, 3930}
  159. ,
  160. {32, 3920}
  161. ,
  162. {34, 3910}
  163. ,
  164. {36, 3898}
  165. ,
  166. {37, 3883}
  167. ,
  168. {39, 3865}
  169. ,
  170. {41, 3851}
  171. ,
  172. {43, 3840}
  173. ,
  174. {45, 3831}
  175. ,
  176. {46, 3824}
  177. ,
  178. {48, 3816}
  179. ,
  180. {50, 3811}
  181. ,
  182. {52, 3804}
  183. ,
  184. {53, 3800}
  185. ,
  186. {55, 3794}
  187. ,
  188. {57, 3790}
  189. ,
  190. {59, 3786}
  191. ,
  192. {61, 3784}
  193. ,
  194. {62, 3780}
  195. ,
  196. {64, 3778}
  197. ,
  198. {66, 3774}
  199. ,
  200. {68, 3772}
  201. ,
  202. {69, 3768}
  203. ,
  204. {71, 3765}
  205. ,
  206. {73, 3761}
  207. ,
  208. {75, 3755}
  209. ,
  210. {77, 3748}
  211. ,
  212. {78, 3741}
  213. ,
  214. {80, 3735}
  215. ,
  216. {82, 3725}
  217. ,
  218. {84, 3715}
  219. ,
  220. {86, 3704}
  221. ,
  222. {87, 3688}
  223. ,
  224. {89, 3679}
  225. ,
  226. {91, 3673}
  227. ,
  228. {93, 3666}
  229. ,
  230. {94, 3657}
  231. ,
  232. {96, 3632}
  233. ,
  234. {98, 3553}
  235. ,
  236. {100, 3426}
  237. ,
  238. {101, 3329}
  239. ,
  240. {101, 3306}
  241. ,
  242. {101, 3298}
  243. ,
  244. {101, 3294}
  245. ,
  246. {101, 3292}
  247. ,
  248. {101, 3291}
  249. ,
  250. {101, 3288}
  251. ,
  252. {101, 3286}
  253. ,
  254. {101, 3286}
  255. ,
  256. {101, 3286}
  257. ,
  258. {101, 3286}
  259. ,
  260. {101, 3286}
  261. ,
  262. {101, 3286}
  263. ,
  264. {101, 3286}
  265. ,
  266. {101, 3286}
  267. ,
  268. {101, 3286}
  269. ,
  270. {101, 3286}
  271. ,
  272. {101, 3286}
  273. };
  274. /* T1 0C */
  275. static struct BATTERY_PROFILE_STRUCT default_battery_profile_t1[] = {
  276. {0, 4180}
  277. ,
  278. {2, 4157}
  279. ,
  280. {4, 4139}
  281. ,
  282. {5, 4120}
  283. ,
  284. {7, 4105}
  285. ,
  286. {9, 4087}
  287. ,
  288. {11, 4072}
  289. ,
  290. {12, 4057}
  291. ,
  292. {14, 4043}
  293. ,
  294. {16, 4028}
  295. ,
  296. {18, 4013}
  297. ,
  298. {20, 4001}
  299. ,
  300. {21, 3989}
  301. ,
  302. {23, 3976}
  303. ,
  304. {25, 3964}
  305. ,
  306. {27, 3953}
  307. ,
  308. {28, 3942}
  309. ,
  310. {30, 3930}
  311. ,
  312. {32, 3920}
  313. ,
  314. {34, 3910}
  315. ,
  316. {36, 3898}
  317. ,
  318. {37, 3883}
  319. ,
  320. {39, 3865}
  321. ,
  322. {41, 3851}
  323. ,
  324. {43, 3840}
  325. ,
  326. {45, 3831}
  327. ,
  328. {46, 3824}
  329. ,
  330. {48, 3816}
  331. ,
  332. {50, 3811}
  333. ,
  334. {52, 3804}
  335. ,
  336. {53, 3800}
  337. ,
  338. {55, 3794}
  339. ,
  340. {57, 3790}
  341. ,
  342. {59, 3786}
  343. ,
  344. {61, 3784}
  345. ,
  346. {62, 3780}
  347. ,
  348. {64, 3778}
  349. ,
  350. {66, 3774}
  351. ,
  352. {68, 3772}
  353. ,
  354. {69, 3768}
  355. ,
  356. {71, 3765}
  357. ,
  358. {73, 3761}
  359. ,
  360. {75, 3755}
  361. ,
  362. {77, 3748}
  363. ,
  364. {78, 3741}
  365. ,
  366. {80, 3735}
  367. ,
  368. {82, 3725}
  369. ,
  370. {84, 3715}
  371. ,
  372. {86, 3704}
  373. ,
  374. {87, 3688}
  375. ,
  376. {89, 3679}
  377. ,
  378. {91, 3673}
  379. ,
  380. {93, 3666}
  381. ,
  382. {94, 3657}
  383. ,
  384. {96, 3632}
  385. ,
  386. {98, 3553}
  387. ,
  388. {100, 3426}
  389. ,
  390. {101, 3329}
  391. ,
  392. {101, 3306}
  393. ,
  394. {101, 3298}
  395. ,
  396. {101, 3294}
  397. ,
  398. {101, 3292}
  399. ,
  400. {101, 3291}
  401. ,
  402. {101, 3288}
  403. ,
  404. {101, 3286}
  405. ,
  406. {101, 3286}
  407. ,
  408. {101, 3286}
  409. ,
  410. {101, 3286}
  411. ,
  412. {101, 3286}
  413. ,
  414. {101, 3286}
  415. ,
  416. {101, 3286}
  417. ,
  418. {101, 3286}
  419. ,
  420. {101, 3286}
  421. ,
  422. {101, 3286}
  423. ,
  424. {101, 3286}
  425. };
  426. /* T2 25C */
  427. static struct BATTERY_PROFILE_STRUCT default_battery_profile_t2[] = {
  428. {0, 4180}
  429. ,
  430. {2, 4157}
  431. ,
  432. {4, 4139}
  433. ,
  434. {5, 4120}
  435. ,
  436. {7, 4105}
  437. ,
  438. {9, 4087}
  439. ,
  440. {11, 4072}
  441. ,
  442. {12, 4057}
  443. ,
  444. {14, 4043}
  445. ,
  446. {16, 4028}
  447. ,
  448. {18, 4013}
  449. ,
  450. {20, 4001}
  451. ,
  452. {21, 3989}
  453. ,
  454. {23, 3976}
  455. ,
  456. {25, 3964}
  457. ,
  458. {27, 3953}
  459. ,
  460. {28, 3942}
  461. ,
  462. {30, 3930}
  463. ,
  464. {32, 3920}
  465. ,
  466. {34, 3910}
  467. ,
  468. {36, 3898}
  469. ,
  470. {37, 3883}
  471. ,
  472. {39, 3865}
  473. ,
  474. {41, 3851}
  475. ,
  476. {43, 3840}
  477. ,
  478. {45, 3831}
  479. ,
  480. {46, 3824}
  481. ,
  482. {48, 3816}
  483. ,
  484. {50, 3811}
  485. ,
  486. {52, 3804}
  487. ,
  488. {53, 3800}
  489. ,
  490. {55, 3794}
  491. ,
  492. {57, 3790}
  493. ,
  494. {59, 3786}
  495. ,
  496. {61, 3784}
  497. ,
  498. {62, 3780}
  499. ,
  500. {64, 3778}
  501. ,
  502. {66, 3774}
  503. ,
  504. {68, 3772}
  505. ,
  506. {69, 3768}
  507. ,
  508. {71, 3765}
  509. ,
  510. {73, 3761}
  511. ,
  512. {75, 3755}
  513. ,
  514. {77, 3748}
  515. ,
  516. {78, 3741}
  517. ,
  518. {80, 3735}
  519. ,
  520. {82, 3725}
  521. ,
  522. {84, 3715}
  523. ,
  524. {86, 3704}
  525. ,
  526. {87, 3688}
  527. ,
  528. {89, 3679}
  529. ,
  530. {91, 3673}
  531. ,
  532. {93, 3666}
  533. ,
  534. {94, 3657}
  535. ,
  536. {96, 3632}
  537. ,
  538. {98, 3553}
  539. ,
  540. {100, 3426}
  541. ,
  542. {101, 3329}
  543. ,
  544. {101, 3306}
  545. ,
  546. {101, 3298}
  547. ,
  548. {101, 3294}
  549. ,
  550. {101, 3292}
  551. ,
  552. {101, 3291}
  553. ,
  554. {101, 3288}
  555. ,
  556. {101, 3286}
  557. ,
  558. {101, 3286}
  559. ,
  560. {101, 3286}
  561. ,
  562. {101, 3286}
  563. ,
  564. {101, 3286}
  565. ,
  566. {101, 3286}
  567. ,
  568. {101, 3286}
  569. ,
  570. {101, 3286}
  571. ,
  572. {101, 3286}
  573. ,
  574. {101, 3286}
  575. ,
  576. {101, 3286}
  577. };
  578. /* T3 50C */
  579. static struct BATTERY_PROFILE_STRUCT default_battery_profile_t3[] = {
  580. {0, 4180}
  581. ,
  582. {2, 4157}
  583. ,
  584. {4, 4139}
  585. ,
  586. {5, 4120}
  587. ,
  588. {7, 4105}
  589. ,
  590. {9, 4087}
  591. ,
  592. {11, 4072}
  593. ,
  594. {12, 4057}
  595. ,
  596. {14, 4043}
  597. ,
  598. {16, 4028}
  599. ,
  600. {18, 4013}
  601. ,
  602. {20, 4001}
  603. ,
  604. {21, 3989}
  605. ,
  606. {23, 3976}
  607. ,
  608. {25, 3964}
  609. ,
  610. {27, 3953}
  611. ,
  612. {28, 3942}
  613. ,
  614. {30, 3930}
  615. ,
  616. {32, 3920}
  617. ,
  618. {34, 3910}
  619. ,
  620. {36, 3898}
  621. ,
  622. {37, 3883}
  623. ,
  624. {39, 3865}
  625. ,
  626. {41, 3851}
  627. ,
  628. {43, 3840}
  629. ,
  630. {45, 3831}
  631. ,
  632. {46, 3824}
  633. ,
  634. {48, 3816}
  635. ,
  636. {50, 3811}
  637. ,
  638. {52, 3804}
  639. ,
  640. {53, 3800}
  641. ,
  642. {55, 3794}
  643. ,
  644. {57, 3790}
  645. ,
  646. {59, 3786}
  647. ,
  648. {61, 3784}
  649. ,
  650. {62, 3780}
  651. ,
  652. {64, 3778}
  653. ,
  654. {66, 3774}
  655. ,
  656. {68, 3772}
  657. ,
  658. {69, 3768}
  659. ,
  660. {71, 3765}
  661. ,
  662. {73, 3761}
  663. ,
  664. {75, 3755}
  665. ,
  666. {77, 3748}
  667. ,
  668. {78, 3741}
  669. ,
  670. {80, 3735}
  671. ,
  672. {82, 3725}
  673. ,
  674. {84, 3715}
  675. ,
  676. {86, 3704}
  677. ,
  678. {87, 3688}
  679. ,
  680. {89, 3679}
  681. ,
  682. {91, 3673}
  683. ,
  684. {93, 3666}
  685. ,
  686. {94, 3657}
  687. ,
  688. {96, 3632}
  689. ,
  690. {98, 3553}
  691. ,
  692. {100, 3426}
  693. ,
  694. {101, 3329}
  695. ,
  696. {101, 3306}
  697. ,
  698. {101, 3298}
  699. ,
  700. {101, 3294}
  701. ,
  702. {101, 3292}
  703. ,
  704. {101, 3291}
  705. ,
  706. {101, 3288}
  707. ,
  708. {101, 3286}
  709. ,
  710. {101, 3286}
  711. ,
  712. {101, 3286}
  713. ,
  714. {101, 3286}
  715. ,
  716. {101, 3286}
  717. ,
  718. {101, 3286}
  719. ,
  720. {101, 3286}
  721. ,
  722. {101, 3286}
  723. ,
  724. {101, 3286}
  725. ,
  726. {101, 3286}
  727. ,
  728. {101, 3286}
  729. };
  730. /* battery profile for actual temperature. The size should be the same as T1, T2 and T3 */
  731. static struct BATTERY_PROFILE_STRUCT default_battery_profile_temperature[] = {
  732. {0, 0}
  733. ,
  734. {0, 0}
  735. ,
  736. {0, 0}
  737. ,
  738. {0, 0}
  739. ,
  740. {0, 0}
  741. ,
  742. {0, 0}
  743. ,
  744. {0, 0}
  745. ,
  746. {0, 0}
  747. ,
  748. {0, 0}
  749. ,
  750. {0, 0}
  751. ,
  752. {0, 0}
  753. ,
  754. {0, 0}
  755. ,
  756. {0, 0}
  757. ,
  758. {0, 0}
  759. ,
  760. {0, 0}
  761. ,
  762. {0, 0}
  763. ,
  764. {0, 0}
  765. ,
  766. {0, 0}
  767. ,
  768. {0, 0}
  769. ,
  770. {0, 0}
  771. ,
  772. {0, 0}
  773. ,
  774. {0, 0}
  775. ,
  776. {0, 0}
  777. ,
  778. {0, 0}
  779. ,
  780. {0, 0}
  781. ,
  782. {0, 0}
  783. ,
  784. {0, 0}
  785. ,
  786. {0, 0}
  787. ,
  788. {0, 0}
  789. ,
  790. {0, 0}
  791. ,
  792. {0, 0}
  793. ,
  794. {0, 0}
  795. ,
  796. {0, 0}
  797. ,
  798. {0, 0}
  799. ,
  800. {0, 0}
  801. ,
  802. {0, 0}
  803. ,
  804. {0, 0}
  805. ,
  806. {0, 0}
  807. ,
  808. {0, 0}
  809. ,
  810. {0, 0}
  811. ,
  812. {0, 0}
  813. ,
  814. {0, 0}
  815. ,
  816. {0, 0}
  817. ,
  818. {0, 0}
  819. ,
  820. {0, 0}
  821. ,
  822. {0, 0}
  823. ,
  824. {0, 0}
  825. ,
  826. {0, 0}
  827. ,
  828. {0, 0}
  829. ,
  830. {0, 0}
  831. ,
  832. {0, 0}
  833. ,
  834. {0, 0}
  835. ,
  836. {0, 0}
  837. ,
  838. {0, 0}
  839. ,
  840. {0, 0}
  841. ,
  842. {0, 0}
  843. ,
  844. {0, 0}
  845. ,
  846. {0, 0}
  847. ,
  848. {0, 0}
  849. ,
  850. {0, 0}
  851. ,
  852. {0, 0}
  853. ,
  854. {0, 0}
  855. ,
  856. {0, 0}
  857. ,
  858. {0, 0}
  859. ,
  860. {0, 0}
  861. ,
  862. {0, 0}
  863. ,
  864. {0, 0}
  865. ,
  866. {0, 0}
  867. ,
  868. {0, 0}
  869. ,
  870. {0, 0}
  871. ,
  872. {0, 0}
  873. ,
  874. {0, 0}
  875. ,
  876. {0, 0}
  877. ,
  878. {0, 0}
  879. ,
  880. {0, 0}
  881. };
  882. /* ============================================================ */
  883. /* <Rbat, Battery_Voltage> Table */
  884. /* ============================================================ */
  885. /* BAT1 R profile */
  886. /* T0 -10C */
  887. static struct R_PROFILE_STRUCT default_r_profile_t0[] = {
  888. {113, 4180}
  889. ,
  890. {113, 4157}
  891. ,
  892. {117, 4139}
  893. ,
  894. {115, 4120}
  895. ,
  896. {122, 4105}
  897. ,
  898. {118, 4087}
  899. ,
  900. {123, 4072}
  901. ,
  902. {127, 4057}
  903. ,
  904. {130, 4043}
  905. ,
  906. {128, 4028}
  907. ,
  908. {130, 4013}
  909. ,
  910. {135, 4001}
  911. ,
  912. {140, 3989}
  913. ,
  914. {143, 3976}
  915. ,
  916. {145, 3964}
  917. ,
  918. {148, 3953}
  919. ,
  920. {150, 3942}
  921. ,
  922. {153, 3930}
  923. ,
  924. {155, 3920}
  925. ,
  926. {157, 3910}
  927. ,
  928. {153, 3898}
  929. ,
  930. {147, 3883}
  931. ,
  932. {133, 3865}
  933. ,
  934. {127, 3851}
  935. ,
  936. {120, 3840}
  937. ,
  938. {118, 3831}
  939. ,
  940. {118, 3824}
  941. ,
  942. {118, 3816}
  943. ,
  944. {123, 3811}
  945. ,
  946. {122, 3804}
  947. ,
  948. {123, 3800}
  949. ,
  950. {122, 3794}
  951. ,
  952. {125, 3790}
  953. ,
  954. {123, 3786}
  955. ,
  956. {128, 3784}
  957. ,
  958. {127, 3780}
  959. ,
  960. {128, 3778}
  961. ,
  962. {130, 3774}
  963. ,
  964. {130, 3772}
  965. ,
  966. {128, 3768}
  967. ,
  968. {128, 3765}
  969. ,
  970. {130, 3761}
  971. ,
  972. {128, 3755}
  973. ,
  974. {122, 3748}
  975. ,
  976. {122, 3741}
  977. ,
  978. {127, 3735}
  979. ,
  980. {125, 3725}
  981. ,
  982. {123, 3715}
  983. ,
  984. {127, 3704}
  985. ,
  986. {123, 3688}
  987. ,
  988. {127, 3679}
  989. ,
  990. {128, 3673}
  991. ,
  992. {135, 3666}
  993. ,
  994. {148, 3657}
  995. ,
  996. {160, 3632}
  997. ,
  998. {162, 3553}
  999. ,
  1000. {193, 3426}
  1001. ,
  1002. {217, 3329}
  1003. ,
  1004. {180, 3306}
  1005. ,
  1006. {167, 3298}
  1007. ,
  1008. {158, 3294}
  1009. ,
  1010. {155, 3292}
  1011. ,
  1012. {155, 3291}
  1013. ,
  1014. {150, 3288}
  1015. ,
  1016. {150, 3286}
  1017. ,
  1018. {148, 3286}
  1019. ,
  1020. {148, 3286}
  1021. ,
  1022. {148, 3286}
  1023. ,
  1024. {148, 3286}
  1025. ,
  1026. {148, 3286}
  1027. ,
  1028. {148, 3286}
  1029. ,
  1030. {148, 3286}
  1031. ,
  1032. {148, 3286}
  1033. ,
  1034. {148, 3286}
  1035. ,
  1036. {148, 3286}
  1037. };
  1038. /* T1 0C */
  1039. static struct R_PROFILE_STRUCT default_r_profile_t1[] = {
  1040. {113, 4180}
  1041. ,
  1042. {113, 4157}
  1043. ,
  1044. {117, 4139}
  1045. ,
  1046. {115, 4120}
  1047. ,
  1048. {122, 4105}
  1049. ,
  1050. {118, 4087}
  1051. ,
  1052. {123, 4072}
  1053. ,
  1054. {127, 4057}
  1055. ,
  1056. {130, 4043}
  1057. ,
  1058. {128, 4028}
  1059. ,
  1060. {130, 4013}
  1061. ,
  1062. {135, 4001}
  1063. ,
  1064. {140, 3989}
  1065. ,
  1066. {143, 3976}
  1067. ,
  1068. {145, 3964}
  1069. ,
  1070. {148, 3953}
  1071. ,
  1072. {150, 3942}
  1073. ,
  1074. {153, 3930}
  1075. ,
  1076. {155, 3920}
  1077. ,
  1078. {157, 3910}
  1079. ,
  1080. {153, 3898}
  1081. ,
  1082. {147, 3883}
  1083. ,
  1084. {133, 3865}
  1085. ,
  1086. {127, 3851}
  1087. ,
  1088. {120, 3840}
  1089. ,
  1090. {118, 3831}
  1091. ,
  1092. {118, 3824}
  1093. ,
  1094. {118, 3816}
  1095. ,
  1096. {123, 3811}
  1097. ,
  1098. {122, 3804}
  1099. ,
  1100. {123, 3800}
  1101. ,
  1102. {122, 3794}
  1103. ,
  1104. {125, 3790}
  1105. ,
  1106. {123, 3786}
  1107. ,
  1108. {128, 3784}
  1109. ,
  1110. {127, 3780}
  1111. ,
  1112. {128, 3778}
  1113. ,
  1114. {130, 3774}
  1115. ,
  1116. {130, 3772}
  1117. ,
  1118. {128, 3768}
  1119. ,
  1120. {128, 3765}
  1121. ,
  1122. {130, 3761}
  1123. ,
  1124. {128, 3755}
  1125. ,
  1126. {122, 3748}
  1127. ,
  1128. {122, 3741}
  1129. ,
  1130. {127, 3735}
  1131. ,
  1132. {125, 3725}
  1133. ,
  1134. {123, 3715}
  1135. ,
  1136. {127, 3704}
  1137. ,
  1138. {123, 3688}
  1139. ,
  1140. {127, 3679}
  1141. ,
  1142. {128, 3673}
  1143. ,
  1144. {135, 3666}
  1145. ,
  1146. {148, 3657}
  1147. ,
  1148. {160, 3632}
  1149. ,
  1150. {162, 3553}
  1151. ,
  1152. {193, 3426}
  1153. ,
  1154. {217, 3329}
  1155. ,
  1156. {180, 3306}
  1157. ,
  1158. {167, 3298}
  1159. ,
  1160. {158, 3294}
  1161. ,
  1162. {155, 3292}
  1163. ,
  1164. {155, 3291}
  1165. ,
  1166. {150, 3288}
  1167. ,
  1168. {150, 3286}
  1169. ,
  1170. {148, 3286}
  1171. ,
  1172. {148, 3286}
  1173. ,
  1174. {148, 3286}
  1175. ,
  1176. {148, 3286}
  1177. ,
  1178. {148, 3286}
  1179. ,
  1180. {148, 3286}
  1181. ,
  1182. {148, 3286}
  1183. ,
  1184. {148, 3286}
  1185. ,
  1186. {148, 3286}
  1187. ,
  1188. {148, 3286}
  1189. };
  1190. /* T2 25C */
  1191. static struct R_PROFILE_STRUCT default_r_profile_t2[] = {
  1192. {113, 4180}
  1193. ,
  1194. {113, 4157}
  1195. ,
  1196. {117, 4139}
  1197. ,
  1198. {115, 4120}
  1199. ,
  1200. {122, 4105}
  1201. ,
  1202. {118, 4087}
  1203. ,
  1204. {123, 4072}
  1205. ,
  1206. {127, 4057}
  1207. ,
  1208. {130, 4043}
  1209. ,
  1210. {128, 4028}
  1211. ,
  1212. {130, 4013}
  1213. ,
  1214. {135, 4001}
  1215. ,
  1216. {140, 3989}
  1217. ,
  1218. {143, 3976}
  1219. ,
  1220. {145, 3964}
  1221. ,
  1222. {148, 3953}
  1223. ,
  1224. {150, 3942}
  1225. ,
  1226. {153, 3930}
  1227. ,
  1228. {155, 3920}
  1229. ,
  1230. {157, 3910}
  1231. ,
  1232. {153, 3898}
  1233. ,
  1234. {147, 3883}
  1235. ,
  1236. {133, 3865}
  1237. ,
  1238. {127, 3851}
  1239. ,
  1240. {120, 3840}
  1241. ,
  1242. {118, 3831}
  1243. ,
  1244. {118, 3824}
  1245. ,
  1246. {118, 3816}
  1247. ,
  1248. {123, 3811}
  1249. ,
  1250. {122, 3804}
  1251. ,
  1252. {123, 3800}
  1253. ,
  1254. {122, 3794}
  1255. ,
  1256. {125, 3790}
  1257. ,
  1258. {123, 3786}
  1259. ,
  1260. {128, 3784}
  1261. ,
  1262. {127, 3780}
  1263. ,
  1264. {128, 3778}
  1265. ,
  1266. {130, 3774}
  1267. ,
  1268. {130, 3772}
  1269. ,
  1270. {128, 3768}
  1271. ,
  1272. {128, 3765}
  1273. ,
  1274. {130, 3761}
  1275. ,
  1276. {128, 3755}
  1277. ,
  1278. {122, 3748}
  1279. ,
  1280. {122, 3741}
  1281. ,
  1282. {127, 3735}
  1283. ,
  1284. {125, 3725}
  1285. ,
  1286. {123, 3715}
  1287. ,
  1288. {127, 3704}
  1289. ,
  1290. {123, 3688}
  1291. ,
  1292. {127, 3679}
  1293. ,
  1294. {128, 3673}
  1295. ,
  1296. {135, 3666}
  1297. ,
  1298. {148, 3657}
  1299. ,
  1300. {160, 3632}
  1301. ,
  1302. {162, 3553}
  1303. ,
  1304. {193, 3426}
  1305. ,
  1306. {217, 3329}
  1307. ,
  1308. {180, 3306}
  1309. ,
  1310. {167, 3298}
  1311. ,
  1312. {158, 3294}
  1313. ,
  1314. {155, 3292}
  1315. ,
  1316. {155, 3291}
  1317. ,
  1318. {150, 3288}
  1319. ,
  1320. {150, 3286}
  1321. ,
  1322. {148, 3286}
  1323. ,
  1324. {148, 3286}
  1325. ,
  1326. {148, 3286}
  1327. ,
  1328. {148, 3286}
  1329. ,
  1330. {148, 3286}
  1331. ,
  1332. {148, 3286}
  1333. ,
  1334. {148, 3286}
  1335. ,
  1336. {148, 3286}
  1337. ,
  1338. {148, 3286}
  1339. ,
  1340. {148, 3286}
  1341. };
  1342. /* T3 50C */
  1343. static struct R_PROFILE_STRUCT default_r_profile_t3[] = {
  1344. {113, 4180}
  1345. ,
  1346. {113, 4157}
  1347. ,
  1348. {117, 4139}
  1349. ,
  1350. {115, 4120}
  1351. ,
  1352. {122, 4105}
  1353. ,
  1354. {118, 4087}
  1355. ,
  1356. {123, 4072}
  1357. ,
  1358. {127, 4057}
  1359. ,
  1360. {130, 4043}
  1361. ,
  1362. {128, 4028}
  1363. ,
  1364. {130, 4013}
  1365. ,
  1366. {135, 4001}
  1367. ,
  1368. {140, 3989}
  1369. ,
  1370. {143, 3976}
  1371. ,
  1372. {145, 3964}
  1373. ,
  1374. {148, 3953}
  1375. ,
  1376. {150, 3942}
  1377. ,
  1378. {153, 3930}
  1379. ,
  1380. {155, 3920}
  1381. ,
  1382. {157, 3910}
  1383. ,
  1384. {153, 3898}
  1385. ,
  1386. {147, 3883}
  1387. ,
  1388. {133, 3865}
  1389. ,
  1390. {127, 3851}
  1391. ,
  1392. {120, 3840}
  1393. ,
  1394. {118, 3831}
  1395. ,
  1396. {118, 3824}
  1397. ,
  1398. {118, 3816}
  1399. ,
  1400. {123, 3811}
  1401. ,
  1402. {122, 3804}
  1403. ,
  1404. {123, 3800}
  1405. ,
  1406. {122, 3794}
  1407. ,
  1408. {125, 3790}
  1409. ,
  1410. {123, 3786}
  1411. ,
  1412. {128, 3784}
  1413. ,
  1414. {127, 3780}
  1415. ,
  1416. {128, 3778}
  1417. ,
  1418. {130, 3774}
  1419. ,
  1420. {130, 3772}
  1421. ,
  1422. {128, 3768}
  1423. ,
  1424. {128, 3765}
  1425. ,
  1426. {130, 3761}
  1427. ,
  1428. {128, 3755}
  1429. ,
  1430. {122, 3748}
  1431. ,
  1432. {122, 3741}
  1433. ,
  1434. {127, 3735}
  1435. ,
  1436. {125, 3725}
  1437. ,
  1438. {123, 3715}
  1439. ,
  1440. {127, 3704}
  1441. ,
  1442. {123, 3688}
  1443. ,
  1444. {127, 3679}
  1445. ,
  1446. {128, 3673}
  1447. ,
  1448. {135, 3666}
  1449. ,
  1450. {148, 3657}
  1451. ,
  1452. {160, 3632}
  1453. ,
  1454. {162, 3553}
  1455. ,
  1456. {193, 3426}
  1457. ,
  1458. {217, 3329}
  1459. ,
  1460. {180, 3306}
  1461. ,
  1462. {167, 3298}
  1463. ,
  1464. {158, 3294}
  1465. ,
  1466. {155, 3292}
  1467. ,
  1468. {155, 3291}
  1469. ,
  1470. {150, 3288}
  1471. ,
  1472. {150, 3286}
  1473. ,
  1474. {148, 3286}
  1475. ,
  1476. {148, 3286}
  1477. ,
  1478. {148, 3286}
  1479. ,
  1480. {148, 3286}
  1481. ,
  1482. {148, 3286}
  1483. ,
  1484. {148, 3286}
  1485. ,
  1486. {148, 3286}
  1487. ,
  1488. {148, 3286}
  1489. ,
  1490. {148, 3286}
  1491. ,
  1492. {148, 3286}
  1493. };
  1494. /* r-table profile for actual temperature. The size should be the same as T1, T2 and T3 */
  1495. static struct R_PROFILE_STRUCT default_r_profile_temperature[] = {
  1496. {0, 0}
  1497. ,
  1498. {0, 0}
  1499. ,
  1500. {0, 0}
  1501. ,
  1502. {0, 0}
  1503. ,
  1504. {0, 0}
  1505. ,
  1506. {0, 0}
  1507. ,
  1508. {0, 0}
  1509. ,
  1510. {0, 0}
  1511. ,
  1512. {0, 0}
  1513. ,
  1514. {0, 0}
  1515. ,
  1516. {0, 0}
  1517. ,
  1518. {0, 0}
  1519. ,
  1520. {0, 0}
  1521. ,
  1522. {0, 0}
  1523. ,
  1524. {0, 0}
  1525. ,
  1526. {0, 0}
  1527. ,
  1528. {0, 0}
  1529. ,
  1530. {0, 0}
  1531. ,
  1532. {0, 0}
  1533. ,
  1534. {0, 0}
  1535. ,
  1536. {0, 0}
  1537. ,
  1538. {0, 0}
  1539. ,
  1540. {0, 0}
  1541. ,
  1542. {0, 0}
  1543. ,
  1544. {0, 0}
  1545. ,
  1546. {0, 0}
  1547. ,
  1548. {0, 0}
  1549. ,
  1550. {0, 0}
  1551. ,
  1552. {0, 0}
  1553. ,
  1554. {0, 0}
  1555. ,
  1556. {0, 0}
  1557. ,
  1558. {0, 0}
  1559. ,
  1560. {0, 0}
  1561. ,
  1562. {0, 0}
  1563. ,
  1564. {0, 0}
  1565. ,
  1566. {0, 0}
  1567. ,
  1568. {0, 0}
  1569. ,
  1570. {0, 0}
  1571. ,
  1572. {0, 0}
  1573. ,
  1574. {0, 0}
  1575. ,
  1576. {0, 0}
  1577. ,
  1578. {0, 0}
  1579. ,
  1580. {0, 0}
  1581. ,
  1582. {0, 0}
  1583. ,
  1584. {0, 0}
  1585. ,
  1586. {0, 0}
  1587. ,
  1588. {0, 0}
  1589. ,
  1590. {0, 0}
  1591. ,
  1592. {0, 0}
  1593. ,
  1594. {0, 0}
  1595. ,
  1596. {0, 0}
  1597. ,
  1598. {0, 0}
  1599. ,
  1600. {0, 0}
  1601. ,
  1602. {0, 0}
  1603. ,
  1604. {0, 0}
  1605. ,
  1606. {0, 0}
  1607. ,
  1608. {0, 0}
  1609. ,
  1610. {0, 0}
  1611. ,
  1612. {0, 0}
  1613. ,
  1614. {0, 0}
  1615. ,
  1616. {0, 0}
  1617. ,
  1618. {0, 0}
  1619. ,
  1620. {0, 0}
  1621. ,
  1622. {0, 0}
  1623. ,
  1624. {0, 0}
  1625. ,
  1626. {0, 0}
  1627. ,
  1628. {0, 0}
  1629. ,
  1630. {0, 0}
  1631. ,
  1632. {0, 0}
  1633. ,
  1634. {0, 0}
  1635. ,
  1636. {0, 0}
  1637. ,
  1638. {0, 0}
  1639. ,
  1640. {0, 0}
  1641. ,
  1642. {0, 0}
  1643. ,
  1644. {0, 0}
  1645. };
  1646. static struct mt_battery_meter_custom_data default_bat_meter_data = {
  1647. .cust_tabt_number = 8,
  1648. #ifdef CONFIG_SWCHR_POWER_PATH
  1649. .vbat_channel_number = 1, /* w/ powerpath, battery voltage is ISENSE(1) */
  1650. .isense_channel_number = 0, /* w/ powerpath, system voltage is VSENSE(0) */
  1651. #else
  1652. .vbat_channel_number = 0,
  1653. .isense_channel_number = 1,
  1654. #endif
  1655. .vcharger_channel_number = 2,
  1656. .vbattemp_channel_number = 3,
  1657. /*ADC resistor */
  1658. .r_bat_sense = 4,
  1659. .r_i_sense = 4,
  1660. .r_charger_1 = 330,
  1661. .r_charger_2 = 39,
  1662. .temperature_t0 = 110,
  1663. .tempearture_t1 = 0,
  1664. .temperature_t2 = 25,
  1665. .temperature_t3 = 50,
  1666. .temperature_t = 255, /* This should be fixed, never change the value */
  1667. .fg_meter_resistance = 0,
  1668. .q_max_pos_50 = 3029,
  1669. .q_max_pos_25 = 3029,
  1670. .q_max_pos_0 = 3029,
  1671. .q_max_neg_10 = 3029,
  1672. .q_max_pos_50_h_current = 2989,
  1673. .q_max_pos_25_h_current = 2989,
  1674. .q_max_pos_0_h_current = 2989,
  1675. .q_max_neg_10_h_current = 2989,
  1676. /* Discharge Percentage */
  1677. .oam_d5 = 1, /* 1 : D5, 0: D2 */
  1678. .cust_tracking_point = 0,
  1679. .cust_r_sense = 68,
  1680. .cust_hw_cc = 0,
  1681. .aging_tuning_value = 100,
  1682. .cust_r_fg_offset = 0,
  1683. .ocv_board_compesate = 0, /* mV */
  1684. .r_fg_board_base = 1000,
  1685. .r_fg_board_slope = 1000,
  1686. .car_tune_value = 100,
  1687. /* HW Fuel gague */
  1688. .current_detect_r_fg = -1, /* turn off auto detect for auxadc gauge */
  1689. .min_error_offset = 1000,
  1690. .fg_vbat_average_size = 18,
  1691. .r_fg_value = 10, /* mOhm, base is 10 */
  1692. .poweron_delta_capacity_tolerance = 45,
  1693. .poweron_low_capacity_tolerance = 5,
  1694. .poweron_max_vbat_tolerance = 90,
  1695. .poweron_delta_vbat_tolerance = 30,
  1696. /* Dynamic change wake up period of battery thread when suspend */
  1697. .vbat_normal_wakeup = 3600, /* 3.6V */
  1698. .vbat_low_power_wakeup = 3500, /* 3.5V */
  1699. .normal_wakeup_period = 5400, /* 90 * 60 = 90 min */
  1700. .low_power_wakeup_period = 300, /* 5 * 60 = 5 min */
  1701. .close_poweroff_wakeup_period = 30, /* 30s */
  1702. /* meter table */
  1703. .rbat_pull_up_volt = 1200,
  1704. #if (BAT_NTC_10 == 1)
  1705. .rbat_pull_up_r = 16900,
  1706. .rbat_pull_down_r = 100000000,
  1707. .battery_ntc_table_saddles =
  1708. sizeof(default_batt_temperature_table_10k) / sizeof(struct BATT_TEMPERATURE),
  1709. .p_batt_temperature_table = default_batt_temperature_table_10k,
  1710. #elif (BAT_NTC_47 == 1)
  1711. .rbat_pull_up_r = 24000,
  1712. .rbat_pull_down_r = 100000000,
  1713. .battery_ntc_table_saddles =
  1714. sizeof(default_batt_temperature_table_47k) / sizeof(struct BATT_TEMPERATURE),
  1715. .p_batt_temperature_table = default_batt_temperature_table_47k,
  1716. #elif (BAT_NTC_100 == 1)
  1717. .rbat_pull_up_r = 24000,
  1718. .rbat_pull_down_r = 100000000,
  1719. .battery_ntc_table_saddles =
  1720. sizeof(default_batt_temperature_table_100k) / sizeof(struct BATT_TEMPERATURE),
  1721. .p_batt_temperature_table = default_batt_temperature_table_100k,
  1722. #endif
  1723. .battery_profile_saddles =
  1724. sizeof(default_battery_profile_temperature) / sizeof(struct BATTERY_PROFILE_STRUCT),
  1725. .battery_r_profile_saddles =
  1726. sizeof(default_r_profile_temperature) / sizeof(struct R_PROFILE_STRUCT),
  1727. .battery_aging_table_saddles = 0,
  1728. .p_battery_profile_t0 = default_battery_profile_t0,
  1729. .p_battery_profile_t1 = default_battery_profile_t1,
  1730. .p_battery_profile_t2 = default_battery_profile_t2,
  1731. .p_battery_profile_t3 = default_battery_profile_t3,
  1732. .p_r_profile_t0 = default_r_profile_t0,
  1733. .p_r_profile_t1 = default_r_profile_t1,
  1734. .p_r_profile_t2 = default_r_profile_t2,
  1735. .p_r_profile_t3 = default_r_profile_t3,
  1736. .p_battery_profile_temperature = default_battery_profile_temperature,
  1737. .p_r_profile_temperature = default_r_profile_temperature,
  1738. .p_battery_aging_table = NULL
  1739. };
  1740. /* T0 -10C */
  1741. static struct BATTERY_PROFILE_STRUCT p1v1_custom_battery_profile_t0[] = {
  1742. {0, 4082},
  1743. {2, 4062},
  1744. {5, 4050},
  1745. {7, 4036},
  1746. {10, 4024},
  1747. {12, 4013},
  1748. {15, 4001},
  1749. {17, 3990},
  1750. {20, 3977},
  1751. {22, 3949},
  1752. {25, 3893},
  1753. {27, 3875},
  1754. {30, 3862},
  1755. {32, 3850},
  1756. {35, 3840},
  1757. {37, 3829},
  1758. {39, 3820},
  1759. {42, 3815},
  1760. {44, 3809},
  1761. {47, 3804},
  1762. {49, 3799},
  1763. {52, 3795},
  1764. {54, 3792},
  1765. {57, 3788},
  1766. {59, 3787},
  1767. {62, 3784},
  1768. {64, 3778},
  1769. {67, 3773},
  1770. {69, 3768},
  1771. {72, 3761},
  1772. {74, 3753},
  1773. {77, 3743},
  1774. {79, 3732},
  1775. {81, 3721},
  1776. {84, 3712},
  1777. {86, 3705},
  1778. {88, 3701},
  1779. {89, 3698},
  1780. {90, 3695},
  1781. {91, 3691},
  1782. {92, 3688},
  1783. {93, 3687},
  1784. {94, 3685},
  1785. {94, 3681},
  1786. {95, 3678},
  1787. {96, 3674},
  1788. {96, 3669},
  1789. {97, 3666},
  1790. {97, 3662},
  1791. {97, 3657},
  1792. {98, 3652},
  1793. {98, 3647},
  1794. {98, 3643},
  1795. {98, 3639},
  1796. {99, 3634},
  1797. {99, 3630},
  1798. {99, 3628},
  1799. {99, 3624},
  1800. {99, 3622},
  1801. {99, 3621},
  1802. {99, 3619},
  1803. {99, 3617},
  1804. {99, 3616},
  1805. {99, 3613},
  1806. {99, 3612},
  1807. {99, 3612},
  1808. {100, 3610},
  1809. {100, 3610},
  1810. {100, 3607},
  1811. };
  1812. /* T1 0C */
  1813. static struct BATTERY_PROFILE_STRUCT p1v1_custom_battery_profile_t1[] = {
  1814. {0, 4167},
  1815. {2, 4142},
  1816. {3, 4089},
  1817. {5, 4062},
  1818. {7, 4046},
  1819. {9, 4030},
  1820. {10, 4016},
  1821. {12, 4004},
  1822. {14, 3995},
  1823. {16, 3984},
  1824. {17, 3975},
  1825. {19, 3964},
  1826. {21, 3954},
  1827. {23, 3944},
  1828. {24, 3934},
  1829. {26, 3924},
  1830. {28, 3912},
  1831. {29, 3901},
  1832. {31, 3888},
  1833. {33, 3877},
  1834. {35, 3865},
  1835. {36, 3854},
  1836. {38, 3845},
  1837. {40, 3838},
  1838. {42, 3830},
  1839. {43, 3824},
  1840. {45, 3819},
  1841. {47, 3813},
  1842. {48, 3809},
  1843. {50, 3804},
  1844. {52, 3798},
  1845. {54, 3796},
  1846. {55, 3792},
  1847. {57, 3787},
  1848. {59, 3785},
  1849. {61, 3783},
  1850. {62, 3780},
  1851. {64, 3779},
  1852. {66, 3776},
  1853. {68, 3773},
  1854. {69, 3770},
  1855. {71, 3768},
  1856. {73, 3764},
  1857. {74, 3760},
  1858. {76, 3754},
  1859. {78, 3747},
  1860. {80, 3741},
  1861. {81, 3732},
  1862. {83, 3722},
  1863. {85, 3711},
  1864. {87, 3700},
  1865. {88, 3693},
  1866. {90, 3688},
  1867. {92, 3683},
  1868. {94, 3676},
  1869. {95, 3659},
  1870. {97, 3629},
  1871. {97, 3602},
  1872. {98, 3580},
  1873. {98, 3563},
  1874. {99, 3550},
  1875. {99, 3539},
  1876. {99, 3529},
  1877. {99, 3520},
  1878. {99, 3513},
  1879. {99, 3507},
  1880. {99, 3502},
  1881. {99, 3498},
  1882. {100, 3494},
  1883. };
  1884. /* T2 25C */
  1885. static struct BATTERY_PROFILE_STRUCT p1v1_custom_battery_profile_t2[] = {
  1886. {0, 4176},
  1887. {2, 4158},
  1888. {3, 4142},
  1889. {5, 4127},
  1890. {6, 4113},
  1891. {8, 4098},
  1892. {9, 4087},
  1893. {11, 4072},
  1894. {12, 4060},
  1895. {14, 4048},
  1896. {15, 4035},
  1897. {17, 4022},
  1898. {19, 4013},
  1899. {20, 4000},
  1900. {22, 3990},
  1901. {23, 3980},
  1902. {25, 3970},
  1903. {26, 3960},
  1904. {28, 3951},
  1905. {29, 3942},
  1906. {31, 3934},
  1907. {32, 3926},
  1908. {34, 3916},
  1909. {35, 3906},
  1910. {37, 3897},
  1911. {39, 3885},
  1912. {40, 3873},
  1913. {42, 3860},
  1914. {43, 3849},
  1915. {45, 3839},
  1916. {46, 3832},
  1917. {48, 3825},
  1918. {49, 3820},
  1919. {51, 3814},
  1920. {52, 3809},
  1921. {54, 3804},
  1922. {56, 3800},
  1923. {57, 3795},
  1924. {59, 3791},
  1925. {60, 3789},
  1926. {62, 3785},
  1927. {63, 3782},
  1928. {65, 3778},
  1929. {66, 3776},
  1930. {68, 3773},
  1931. {69, 3772},
  1932. {71, 3768},
  1933. {73, 3765},
  1934. {74, 3762},
  1935. {76, 3756},
  1936. {77, 3751},
  1937. {79, 3746},
  1938. {80, 3741},
  1939. {82, 3734},
  1940. {83, 3724},
  1941. {85, 3715},
  1942. {86, 3704},
  1943. {88, 3691},
  1944. {89, 3687},
  1945. {91, 3684},
  1946. {93, 3683},
  1947. {94, 3678},
  1948. {96, 3665},
  1949. {97, 3610},
  1950. {99, 3523},
  1951. {100, 3378},
  1952. {101, 3324},
  1953. {101, 3311},
  1954. {101, 3306},
  1955. };
  1956. /* T3 50C */
  1957. static struct BATTERY_PROFILE_STRUCT p1v1_custom_battery_profile_t3[] = {
  1958. {0, 4184},
  1959. {2, 4167},
  1960. {3, 4154},
  1961. {5, 4137},
  1962. {6, 4124},
  1963. {8, 4111},
  1964. {9, 4097},
  1965. {11, 4084},
  1966. {12, 4071},
  1967. {14, 4057},
  1968. {15, 4046},
  1969. {17, 4033},
  1970. {18, 4020},
  1971. {20, 4009},
  1972. {21, 3998},
  1973. {23, 3988},
  1974. {24, 3976},
  1975. {26, 3967},
  1976. {27, 3958},
  1977. {29, 3947},
  1978. {31, 3937},
  1979. {32, 3930},
  1980. {34, 3921},
  1981. {35, 3910},
  1982. {37, 3903},
  1983. {38, 3894},
  1984. {40, 3883},
  1985. {41, 3869},
  1986. {43, 3856},
  1987. {44, 3844},
  1988. {46, 3836},
  1989. {47, 3830},
  1990. {49, 3823},
  1991. {50, 3817},
  1992. {52, 3811},
  1993. {53, 3807},
  1994. {55, 3802},
  1995. {57, 3797},
  1996. {58, 3793},
  1997. {60, 3789},
  1998. {61, 3785},
  1999. {63, 3782},
  2000. {64, 3779},
  2001. {66, 3775},
  2002. {67, 3772},
  2003. {69, 3768},
  2004. {70, 3763},
  2005. {72, 3755},
  2006. {73, 3749},
  2007. {75, 3744},
  2008. {76, 3739},
  2009. {78, 3733},
  2010. {79, 3727},
  2011. {81, 3721},
  2012. {83, 3715},
  2013. {84, 3703},
  2014. {86, 3695},
  2015. {87, 3683},
  2016. {89, 3674},
  2017. {90, 3671},
  2018. {92, 3669},
  2019. {93, 3666},
  2020. {95, 3661},
  2021. {96, 3634},
  2022. {98, 3570},
  2023. {99, 3472},
  2024. {101, 3311},
  2025. {101, 3289},
  2026. {101, 3282},
  2027. };
  2028. /* T0 -10C */
  2029. static struct R_PROFILE_STRUCT p1v1_custom_r_profile_t0[] = {
  2030. {345, 4082},
  2031. {345, 4062},
  2032. {367, 4050},
  2033. {367, 4036},
  2034. {377, 4024},
  2035. {378, 4013},
  2036. {388, 4001},
  2037. {398, 3990},
  2038. {420, 3977},
  2039. {453, 3949},
  2040. {637, 3893},
  2041. {690, 3875},
  2042. {698, 3862},
  2043. {698, 3850},
  2044. {697, 3840},
  2045. {705, 3829},
  2046. {695, 3820},
  2047. {705, 3815},
  2048. {702, 3809},
  2049. {708, 3804},
  2050. {710, 3799},
  2051. {715, 3795},
  2052. {720, 3792},
  2053. {725, 3788},
  2054. {732, 3787},
  2055. {743, 3784},
  2056. {743, 3778},
  2057. {753, 3773},
  2058. {757, 3768},
  2059. {770, 3761},
  2060. {782, 3753},
  2061. {792, 3743},
  2062. {805, 3732},
  2063. {812, 3721},
  2064. {835, 3712},
  2065. {842, 3705},
  2066. {837, 3701},
  2067. {832, 3698},
  2068. {825, 3695},
  2069. {820, 3691},
  2070. {815, 3688},
  2071. {812, 3687},
  2072. {810, 3685},
  2073. {803, 3681},
  2074. {798, 3678},
  2075. {792, 3674},
  2076. {782, 3669},
  2077. {777, 3666},
  2078. {770, 3662},
  2079. {768, 3657},
  2080. {755, 3652},
  2081. {747, 3647},
  2082. {740, 3643},
  2083. {733, 3639},
  2084. {728, 3634},
  2085. {720, 3630},
  2086. {713, 3628},
  2087. {708, 3624},
  2088. {705, 3622},
  2089. {705, 3621},
  2090. {702, 3619},
  2091. {697, 3617},
  2092. {693, 3616},
  2093. {692, 3613},
  2094. {688, 3612},
  2095. {687, 3612},
  2096. {687, 3610},
  2097. {685, 3610},
  2098. {682, 3607},
  2099. };
  2100. /* T1 0C */
  2101. struct R_PROFILE_STRUCT p1v1_custom_r_profile_t1[] = {
  2102. {235, 4167},
  2103. {235, 4142},
  2104. {252, 4089},
  2105. {343, 4062},
  2106. {357, 4046},
  2107. {362, 4030},
  2108. {363, 4016},
  2109. {368, 4004},
  2110. {377, 3995},
  2111. {377, 3984},
  2112. {385, 3975},
  2113. {382, 3964},
  2114. {387, 3954},
  2115. {390, 3944},
  2116. {388, 3934},
  2117. {395, 3924},
  2118. {388, 3912},
  2119. {392, 3901},
  2120. {383, 3888},
  2121. {385, 3877},
  2122. {378, 3865},
  2123. {377, 3854},
  2124. {375, 3845},
  2125. {378, 3838},
  2126. {382, 3830},
  2127. {380, 3824},
  2128. {383, 3819},
  2129. {387, 3813},
  2130. {390, 3809},
  2131. {388, 3804},
  2132. {393, 3798},
  2133. {393, 3796},
  2134. {397, 3792},
  2135. {400, 3787},
  2136. {398, 3785},
  2137. {408, 3783},
  2138. {407, 3780},
  2139. {417, 3779},
  2140. {415, 3776},
  2141. {420, 3773},
  2142. {423, 3770},
  2143. {433, 3768},
  2144. {435, 3764},
  2145. {447, 3760},
  2146. {453, 3754},
  2147. {457, 3747},
  2148. {477, 3741},
  2149. {480, 3732},
  2150. {492, 3722},
  2151. {503, 3711},
  2152. {520, 3700},
  2153. {537, 3693},
  2154. {565, 3688},
  2155. {608, 3683},
  2156. {652, 3676},
  2157. {697, 3659},
  2158. {715, 3629},
  2159. {672, 3602},
  2160. {637, 3580},
  2161. {607, 3563},
  2162. {585, 3550},
  2163. {567, 3539},
  2164. {548, 3529},
  2165. {533, 3520},
  2166. {523, 3513},
  2167. {515, 3507},
  2168. {507, 3502},
  2169. {498, 3498},
  2170. {495, 3494},
  2171. };
  2172. /* T2 25C */
  2173. static struct R_PROFILE_STRUCT p1v1_custom_r_profile_t2[] = {
  2174. {150, 4176},
  2175. {150, 4158},
  2176. {148, 4142},
  2177. {150, 4127},
  2178. {152, 4113},
  2179. {150, 4098},
  2180. {155, 4087},
  2181. {157, 4072},
  2182. {158, 4060},
  2183. {158, 4048},
  2184. {162, 4035},
  2185. {162, 4022},
  2186. {167, 4013},
  2187. {167, 4000},
  2188. {168, 3990},
  2189. {170, 3980},
  2190. {172, 3970},
  2191. {173, 3960},
  2192. {177, 3951},
  2193. {177, 3942},
  2194. {183, 3934},
  2195. {183, 3926},
  2196. {183, 3916},
  2197. {182, 3906},
  2198. {182, 3897},
  2199. {177, 3885},
  2200. {173, 3873},
  2201. {163, 3860},
  2202. {160, 3849},
  2203. {155, 3839},
  2204. {153, 3832},
  2205. {153, 3825},
  2206. {155, 3820},
  2207. {155, 3814},
  2208. {157, 3809},
  2209. {157, 3804},
  2210. {158, 3800},
  2211. {158, 3795},
  2212. {158, 3791},
  2213. {160, 3789},
  2214. {158, 3785},
  2215. {162, 3782},
  2216. {158, 3778},
  2217. {160, 3776},
  2218. {158, 3773},
  2219. {162, 3772},
  2220. {160, 3768},
  2221. {158, 3765},
  2222. {160, 3762},
  2223. {158, 3756},
  2224. {157, 3751},
  2225. {155, 3746},
  2226. {158, 3741},
  2227. {158, 3734},
  2228. {157, 3724},
  2229. {157, 3715},
  2230. {158, 3704},
  2231. {157, 3691},
  2232. {158, 3687},
  2233. {162, 3684},
  2234. {173, 3683},
  2235. {185, 3678},
  2236. {197, 3665},
  2237. {180, 3610},
  2238. {192, 3523},
  2239. {220, 3378},
  2240. {210, 3324},
  2241. {188, 3311},
  2242. {182, 3306},
  2243. };
  2244. /* T3 50C */
  2245. static struct R_PROFILE_STRUCT p1v1_custom_r_profile_t3[] = {
  2246. {120, 4184},
  2247. {120, 4167},
  2248. {123, 4154},
  2249. {118, 4137},
  2250. {123, 4124},
  2251. {125, 4111},
  2252. {125, 4097},
  2253. {125, 4084},
  2254. {127, 4071},
  2255. {127, 4057},
  2256. {130, 4046},
  2257. {127, 4033},
  2258. {127, 4020},
  2259. {128, 4009},
  2260. {130, 3998},
  2261. {132, 3988},
  2262. {132, 3976},
  2263. {135, 3967},
  2264. {138, 3958},
  2265. {138, 3947},
  2266. {135, 3937},
  2267. {142, 3930},
  2268. {143, 3921},
  2269. {142, 3910},
  2270. {148, 3903},
  2271. {147, 3894},
  2272. {145, 3883},
  2273. {138, 3869},
  2274. {132, 3856},
  2275. {127, 3844},
  2276. {123, 3836},
  2277. {123, 3830},
  2278. {123, 3823},
  2279. {123, 3817},
  2280. {125, 3811},
  2281. {127, 3807},
  2282. {127, 3802},
  2283. {127, 3797},
  2284. {127, 3793},
  2285. {128, 3789},
  2286. {130, 3785},
  2287. {130, 3782},
  2288. {133, 3779},
  2289. {130, 3775},
  2290. {133, 3772},
  2291. {132, 3768},
  2292. {130, 3763},
  2293. {123, 3755},
  2294. {125, 3749},
  2295. {127, 3744},
  2296. {128, 3739},
  2297. {125, 3733},
  2298. {127, 3727},
  2299. {125, 3721},
  2300. {128, 3715},
  2301. {122, 3703},
  2302. {128, 3695},
  2303. {123, 3683},
  2304. {123, 3674},
  2305. {125, 3671},
  2306. {130, 3669},
  2307. {135, 3666},
  2308. {142, 3661},
  2309. {135, 3634},
  2310. {140, 3570},
  2311. {148, 3472},
  2312. {180, 3311},
  2313. {148, 3289},
  2314. {138, 3282},
  2315. };
  2316. /* battery profile for actual temperature. The size should be the same as T1, T2 and T3 */
  2317. static struct BATTERY_PROFILE_STRUCT p1v1_custom_battery_profile_temperature[] = {
  2318. {0, 0},
  2319. {0, 0},
  2320. {0, 0},
  2321. {0, 0},
  2322. {0, 0},
  2323. {0, 0},
  2324. {0, 0},
  2325. {0, 0},
  2326. {0, 0},
  2327. {0, 0},
  2328. {0, 0},
  2329. {0, 0},
  2330. {0, 0},
  2331. {0, 0},
  2332. {0, 0},
  2333. {0, 0},
  2334. {0, 0},
  2335. {0, 0},
  2336. {0, 0},
  2337. {0, 0},
  2338. {0, 0},
  2339. {0, 0},
  2340. {0, 0},
  2341. {0, 0},
  2342. {0, 0},
  2343. {0, 0},
  2344. {0, 0},
  2345. {0, 0},
  2346. {0, 0},
  2347. {0, 0},
  2348. {0, 0},
  2349. {0, 0},
  2350. {0, 0},
  2351. {0, 0},
  2352. {0, 0},
  2353. {0, 0},
  2354. {0, 0},
  2355. {0, 0},
  2356. {0, 0},
  2357. {0, 0},
  2358. {0, 0},
  2359. {0, 0},
  2360. {0, 0},
  2361. {0, 0},
  2362. {0, 0},
  2363. {0, 0},
  2364. {0, 0},
  2365. {0, 0},
  2366. {0, 0},
  2367. {0, 0},
  2368. {0, 0},
  2369. {0, 0},
  2370. {0, 0},
  2371. {0, 0},
  2372. {0, 0},
  2373. {0, 0},
  2374. {0, 0},
  2375. {0, 0},
  2376. {0, 0},
  2377. {0, 0},
  2378. {0, 0},
  2379. {0, 0},
  2380. {0, 0},
  2381. {0, 0},
  2382. {0, 0},
  2383. {0, 0},
  2384. {0, 0},
  2385. {0, 0},
  2386. {0, 0},
  2387. };
  2388. /* r-table profile for actual temperature. The size should be the same as T1, T2 and T3 */
  2389. static struct R_PROFILE_STRUCT p1v1_custom_r_profile_temperature[] = {
  2390. {0, 0},
  2391. {0, 0},
  2392. {0, 0},
  2393. {0, 0},
  2394. {0, 0},
  2395. {0, 0},
  2396. {0, 0},
  2397. {0, 0},
  2398. {0, 0},
  2399. {0, 0},
  2400. {0, 0},
  2401. {0, 0},
  2402. {0, 0},
  2403. {0, 0},
  2404. {0, 0},
  2405. {0, 0},
  2406. {0, 0},
  2407. {0, 0},
  2408. {0, 0},
  2409. {0, 0},
  2410. {0, 0},
  2411. {0, 0},
  2412. {0, 0},
  2413. {0, 0},
  2414. {0, 0},
  2415. {0, 0},
  2416. {0, 0},
  2417. {0, 0},
  2418. {0, 0},
  2419. {0, 0},
  2420. {0, 0},
  2421. {0, 0},
  2422. {0, 0},
  2423. {0, 0},
  2424. {0, 0},
  2425. {0, 0},
  2426. {0, 0},
  2427. {0, 0},
  2428. {0, 0},
  2429. {0, 0},
  2430. {0, 0},
  2431. {0, 0},
  2432. {0, 0},
  2433. {0, 0},
  2434. {0, 0},
  2435. {0, 0},
  2436. {0, 0},
  2437. {0, 0},
  2438. {0, 0},
  2439. {0, 0},
  2440. {0, 0},
  2441. {0, 0},
  2442. {0, 0},
  2443. {0, 0},
  2444. {0, 0},
  2445. {0, 0},
  2446. {0, 0},
  2447. {0, 0},
  2448. {0, 0},
  2449. {0, 0},
  2450. {0, 0},
  2451. {0, 0},
  2452. {0, 0},
  2453. {0, 0},
  2454. {0, 0},
  2455. {0, 0},
  2456. {0, 0},
  2457. {0, 0},
  2458. {0, 0},
  2459. };
  2460. static struct BATT_TEMPERATURE p1v1_bat_temperature_table[] = {
  2461. {-20, 499900},
  2462. {-15, 371600},
  2463. {-10, 278700},
  2464. {-5, 210800},
  2465. {0, 160800},
  2466. {5, 123800},
  2467. {10, 96030},
  2468. {15, 75100},
  2469. {20, 59190},
  2470. {25, 47000},
  2471. {30, 37590},
  2472. {35, 30270},
  2473. {40, 24540},
  2474. {45, 20020},
  2475. {50, 16430},
  2476. {55, 13570},
  2477. {60, 11270},
  2478. {65, 9409},
  2479. {70, 7897}
  2480. };
  2481. void p1v1_custom_battery_init(struct mt_battery_meter_custom_data *p_meter_data)
  2482. {
  2483. p_meter_data->car_tune_value = 102;
  2484. /* NTC 47K */
  2485. p_meter_data->rbat_pull_up_r = 24000;
  2486. p_meter_data->rbat_pull_down_r = 100000000;
  2487. p_meter_data->cust_r_fg_offset = 0;
  2488. /* set low capacity tolerance to 2% due to flat curve of low battery area */
  2489. p_meter_data->poweron_low_capacity_tolerance = 2;
  2490. p_meter_data->p_batt_temperature_table = p1v1_bat_temperature_table;
  2491. p_meter_data->battery_ntc_table_saddles =
  2492. sizeof(p1v1_bat_temperature_table) / sizeof(struct BATT_TEMPERATURE);
  2493. /*
  2494. p_meter_data->q_max_pos_50 = 3535;
  2495. p_meter_data->q_max_pos_50_h_current = 3502;
  2496. p_meter_data->q_max_pos_25 = 3452;
  2497. p_meter_data->q_max_pos_25_h_current = 3409;
  2498. */
  2499. /* reserve 2% capacity for 25/50 degC */
  2500. p_meter_data->q_max_pos_50 = 3464;
  2501. p_meter_data->q_max_pos_50_h_current = 3431;
  2502. p_meter_data->q_max_pos_25 = 3383;
  2503. p_meter_data->q_max_pos_25_h_current = 3340;
  2504. p_meter_data->q_max_pos_0 = 2819;
  2505. p_meter_data->q_max_pos_0_h_current = 2370;
  2506. p_meter_data->q_max_neg_10 = 2183;
  2507. p_meter_data->q_max_neg_10_h_current = 876;
  2508. p_meter_data->battery_profile_saddles =
  2509. sizeof(p1v1_custom_battery_profile_temperature) / sizeof(struct BATTERY_PROFILE_STRUCT);
  2510. p_meter_data->battery_r_profile_saddles =
  2511. sizeof(p1v1_custom_r_profile_temperature) / sizeof(struct R_PROFILE_STRUCT);
  2512. p_meter_data->p_battery_profile_t0 = p1v1_custom_battery_profile_t0;
  2513. p_meter_data->p_battery_profile_t1 = p1v1_custom_battery_profile_t1;
  2514. p_meter_data->p_battery_profile_t2 = p1v1_custom_battery_profile_t2;
  2515. p_meter_data->p_battery_profile_t3 = p1v1_custom_battery_profile_t3;
  2516. p_meter_data->p_r_profile_t0 = p1v1_custom_r_profile_t0;
  2517. p_meter_data->p_r_profile_t1 = p1v1_custom_r_profile_t1;
  2518. p_meter_data->p_r_profile_t2 = p1v1_custom_r_profile_t2;
  2519. p_meter_data->p_r_profile_t3 = p1v1_custom_r_profile_t3;
  2520. p_meter_data->p_battery_profile_temperature = p1v1_custom_battery_profile_temperature;
  2521. p_meter_data->p_r_profile_temperature = p1v1_custom_r_profile_temperature;
  2522. }
  2523. struct mt_bm_item {
  2524. const char *battery_name;
  2525. void (*func)(struct mt_battery_meter_custom_data *p_meter_data);
  2526. };
  2527. static struct mt_bm_item mt_battery_profiles[] = {
  2528. {"p1v1_battery", p1v1_custom_battery_init}
  2529. };
  2530. int mt_bm_of_probe(struct device *dev, struct mt_battery_meter_custom_data **p_meter_data)
  2531. {
  2532. #ifdef CONFIG_OF
  2533. struct device_node *of_node = dev->of_node;
  2534. const char *bname;
  2535. int i;
  2536. if (*p_meter_data == NULL)
  2537. *p_meter_data = &default_bat_meter_data;
  2538. bname = of_get_property(of_node, "battery", NULL);
  2539. if (!bname) {
  2540. dev_warn(dev, "No custom battery profile. Use default setting.\n");
  2541. return 0;
  2542. }
  2543. for (i = 0; i < sizeof(mt_battery_profiles) / sizeof(struct mt_bm_item); i++) {
  2544. if (strcmp(bname, mt_battery_profiles[i].battery_name) == 0) {
  2545. dev_warn(dev, "match battery profile: %s\n", bname);
  2546. mt_battery_profiles[i].func(*p_meter_data);
  2547. break;
  2548. }
  2549. }
  2550. of_node_put(of_node);
  2551. #endif
  2552. return 0;
  2553. }