ab8500_btemp.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2012
  3. *
  4. * Battery temperature driver for AB8500
  5. *
  6. * License Terms: GNU General Public License v2
  7. * Author:
  8. * Johan Palsson <johan.palsson@stericsson.com>
  9. * Karl Komierowski <karl.komierowski@stericsson.com>
  10. * Arun R Murthy <arun.murthy@stericsson.com>
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/delay.h>
  17. #include <linux/slab.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/power_supply.h>
  20. #include <linux/completion.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/jiffies.h>
  23. #include <linux/of.h>
  24. #include <linux/mfd/core.h>
  25. #include <linux/mfd/abx500.h>
  26. #include <linux/mfd/abx500/ab8500.h>
  27. #include <linux/mfd/abx500/ab8500-bm.h>
  28. #include <linux/mfd/abx500/ab8500-gpadc.h>
  29. #define VTVOUT_V 1800
  30. #define BTEMP_THERMAL_LOW_LIMIT -10
  31. #define BTEMP_THERMAL_MED_LIMIT 0
  32. #define BTEMP_THERMAL_HIGH_LIMIT_52 52
  33. #define BTEMP_THERMAL_HIGH_LIMIT_57 57
  34. #define BTEMP_THERMAL_HIGH_LIMIT_62 62
  35. #define BTEMP_BATCTRL_CURR_SRC_7UA 7
  36. #define BTEMP_BATCTRL_CURR_SRC_20UA 20
  37. #define BTEMP_BATCTRL_CURR_SRC_16UA 16
  38. #define BTEMP_BATCTRL_CURR_SRC_18UA 18
  39. #define BTEMP_BATCTRL_CURR_SRC_60UA 60
  40. #define BTEMP_BATCTRL_CURR_SRC_120UA 120
  41. /**
  42. * struct ab8500_btemp_interrupts - ab8500 interrupts
  43. * @name: name of the interrupt
  44. * @isr function pointer to the isr
  45. */
  46. struct ab8500_btemp_interrupts {
  47. char *name;
  48. irqreturn_t (*isr)(int irq, void *data);
  49. };
  50. struct ab8500_btemp_events {
  51. bool batt_rem;
  52. bool btemp_high;
  53. bool btemp_medhigh;
  54. bool btemp_lowmed;
  55. bool btemp_low;
  56. bool ac_conn;
  57. bool usb_conn;
  58. };
  59. struct ab8500_btemp_ranges {
  60. int btemp_high_limit;
  61. int btemp_med_limit;
  62. int btemp_low_limit;
  63. };
  64. /**
  65. * struct ab8500_btemp - ab8500 BTEMP device information
  66. * @dev: Pointer to the structure device
  67. * @node: List of AB8500 BTEMPs, hence prepared for reentrance
  68. * @curr_source: What current source we use, in uA
  69. * @bat_temp: Dispatched battery temperature in degree Celsius
  70. * @prev_bat_temp Last measured battery temperature in degree Celsius
  71. * @parent: Pointer to the struct ab8500
  72. * @gpadc: Pointer to the struct gpadc
  73. * @fg: Pointer to the struct fg
  74. * @bm: Platform specific battery management information
  75. * @btemp_psy: Structure for BTEMP specific battery properties
  76. * @events: Structure for information about events triggered
  77. * @btemp_ranges: Battery temperature range structure
  78. * @btemp_wq: Work queue for measuring the temperature periodically
  79. * @btemp_periodic_work: Work for measuring the temperature periodically
  80. * @initialized: True if battery id read.
  81. */
  82. struct ab8500_btemp {
  83. struct device *dev;
  84. struct list_head node;
  85. int curr_source;
  86. int bat_temp;
  87. int prev_bat_temp;
  88. struct ab8500 *parent;
  89. struct ab8500_gpadc *gpadc;
  90. struct ab8500_fg *fg;
  91. struct abx500_bm_data *bm;
  92. struct power_supply *btemp_psy;
  93. struct ab8500_btemp_events events;
  94. struct ab8500_btemp_ranges btemp_ranges;
  95. struct workqueue_struct *btemp_wq;
  96. struct delayed_work btemp_periodic_work;
  97. bool initialized;
  98. };
  99. /* BTEMP power supply properties */
  100. static enum power_supply_property ab8500_btemp_props[] = {
  101. POWER_SUPPLY_PROP_PRESENT,
  102. POWER_SUPPLY_PROP_ONLINE,
  103. POWER_SUPPLY_PROP_TECHNOLOGY,
  104. POWER_SUPPLY_PROP_TEMP,
  105. };
  106. static LIST_HEAD(ab8500_btemp_list);
  107. /**
  108. * ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP
  109. * (i.e. the first BTEMP in the instance list)
  110. */
  111. struct ab8500_btemp *ab8500_btemp_get(void)
  112. {
  113. return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
  114. }
  115. EXPORT_SYMBOL(ab8500_btemp_get);
  116. /**
  117. * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance
  118. * @di: pointer to the ab8500_btemp structure
  119. * @v_batctrl: measured batctrl voltage
  120. * @inst_curr: measured instant current
  121. *
  122. * This function returns the battery resistance that is
  123. * derived from the BATCTRL voltage.
  124. * Returns value in Ohms.
  125. */
  126. static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di,
  127. int v_batctrl, int inst_curr)
  128. {
  129. int rbs;
  130. if (is_ab8500_1p1_or_earlier(di->parent)) {
  131. /*
  132. * For ABB cut1.0 and 1.1 BAT_CTRL is internally
  133. * connected to 1.8V through a 450k resistor
  134. */
  135. return (450000 * (v_batctrl)) / (1800 - v_batctrl);
  136. }
  137. if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL) {
  138. /*
  139. * If the battery has internal NTC, we use the current
  140. * source to calculate the resistance.
  141. */
  142. rbs = (v_batctrl * 1000
  143. - di->bm->gnd_lift_resistance * inst_curr)
  144. / di->curr_source;
  145. } else {
  146. /*
  147. * BAT_CTRL is internally
  148. * connected to 1.8V through a 80k resistor
  149. */
  150. rbs = (80000 * (v_batctrl)) / (1800 - v_batctrl);
  151. }
  152. return rbs;
  153. }
  154. /**
  155. * ab8500_btemp_read_batctrl_voltage() - measure batctrl voltage
  156. * @di: pointer to the ab8500_btemp structure
  157. *
  158. * This function returns the voltage on BATCTRL. Returns value in mV.
  159. */
  160. static int ab8500_btemp_read_batctrl_voltage(struct ab8500_btemp *di)
  161. {
  162. int vbtemp;
  163. static int prev;
  164. vbtemp = ab8500_gpadc_convert(di->gpadc, BAT_CTRL);
  165. if (vbtemp < 0) {
  166. dev_err(di->dev,
  167. "%s gpadc conversion failed, using previous value",
  168. __func__);
  169. return prev;
  170. }
  171. prev = vbtemp;
  172. return vbtemp;
  173. }
  174. /**
  175. * ab8500_btemp_curr_source_enable() - enable/disable batctrl current source
  176. * @di: pointer to the ab8500_btemp structure
  177. * @enable: enable or disable the current source
  178. *
  179. * Enable or disable the current sources for the BatCtrl AD channel
  180. */
  181. static int ab8500_btemp_curr_source_enable(struct ab8500_btemp *di,
  182. bool enable)
  183. {
  184. int curr;
  185. int ret = 0;
  186. /*
  187. * BATCTRL current sources are included on AB8500 cut2.0
  188. * and future versions
  189. */
  190. if (is_ab8500_1p1_or_earlier(di->parent))
  191. return 0;
  192. /* Only do this for batteries with internal NTC */
  193. if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && enable) {
  194. if (is_ab8540(di->parent)) {
  195. if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_60UA)
  196. curr = BAT_CTRL_60U_ENA;
  197. else
  198. curr = BAT_CTRL_120U_ENA;
  199. } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
  200. if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_16UA)
  201. curr = BAT_CTRL_16U_ENA;
  202. else
  203. curr = BAT_CTRL_18U_ENA;
  204. } else {
  205. if (di->curr_source == BTEMP_BATCTRL_CURR_SRC_7UA)
  206. curr = BAT_CTRL_7U_ENA;
  207. else
  208. curr = BAT_CTRL_20U_ENA;
  209. }
  210. dev_dbg(di->dev, "Set BATCTRL %duA\n", di->curr_source);
  211. ret = abx500_mask_and_set_register_interruptible(di->dev,
  212. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  213. FORCE_BAT_CTRL_CMP_HIGH, FORCE_BAT_CTRL_CMP_HIGH);
  214. if (ret) {
  215. dev_err(di->dev, "%s failed setting cmp_force\n",
  216. __func__);
  217. return ret;
  218. }
  219. /*
  220. * We have to wait one 32kHz cycle before enabling
  221. * the current source, since ForceBatCtrlCmpHigh needs
  222. * to be written in a separate cycle
  223. */
  224. udelay(32);
  225. ret = abx500_set_register_interruptible(di->dev,
  226. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  227. FORCE_BAT_CTRL_CMP_HIGH | curr);
  228. if (ret) {
  229. dev_err(di->dev, "%s failed enabling current source\n",
  230. __func__);
  231. goto disable_curr_source;
  232. }
  233. } else if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL && !enable) {
  234. dev_dbg(di->dev, "Disable BATCTRL curr source\n");
  235. if (is_ab8540(di->parent)) {
  236. /* Write 0 to the curr bits */
  237. ret = abx500_mask_and_set_register_interruptible(
  238. di->dev,
  239. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  240. BAT_CTRL_60U_ENA | BAT_CTRL_120U_ENA,
  241. ~(BAT_CTRL_60U_ENA | BAT_CTRL_120U_ENA));
  242. } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
  243. /* Write 0 to the curr bits */
  244. ret = abx500_mask_and_set_register_interruptible(
  245. di->dev,
  246. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  247. BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA,
  248. ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA));
  249. } else {
  250. /* Write 0 to the curr bits */
  251. ret = abx500_mask_and_set_register_interruptible(
  252. di->dev,
  253. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  254. BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA,
  255. ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA));
  256. }
  257. if (ret) {
  258. dev_err(di->dev, "%s failed disabling current source\n",
  259. __func__);
  260. goto disable_curr_source;
  261. }
  262. /* Enable Pull-Up and comparator */
  263. ret = abx500_mask_and_set_register_interruptible(di->dev,
  264. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  265. BAT_CTRL_PULL_UP_ENA | BAT_CTRL_CMP_ENA,
  266. BAT_CTRL_PULL_UP_ENA | BAT_CTRL_CMP_ENA);
  267. if (ret) {
  268. dev_err(di->dev, "%s failed enabling PU and comp\n",
  269. __func__);
  270. goto enable_pu_comp;
  271. }
  272. /*
  273. * We have to wait one 32kHz cycle before disabling
  274. * ForceBatCtrlCmpHigh since this needs to be written
  275. * in a separate cycle
  276. */
  277. udelay(32);
  278. /* Disable 'force comparator' */
  279. ret = abx500_mask_and_set_register_interruptible(di->dev,
  280. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  281. FORCE_BAT_CTRL_CMP_HIGH, ~FORCE_BAT_CTRL_CMP_HIGH);
  282. if (ret) {
  283. dev_err(di->dev, "%s failed disabling force comp\n",
  284. __func__);
  285. goto disable_force_comp;
  286. }
  287. }
  288. return ret;
  289. /*
  290. * We have to try unsetting FORCE_BAT_CTRL_CMP_HIGH one more time
  291. * if we got an error above
  292. */
  293. disable_curr_source:
  294. if (is_ab8540(di->parent)) {
  295. /* Write 0 to the curr bits */
  296. ret = abx500_mask_and_set_register_interruptible(di->dev,
  297. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  298. BAT_CTRL_60U_ENA | BAT_CTRL_120U_ENA,
  299. ~(BAT_CTRL_60U_ENA | BAT_CTRL_120U_ENA));
  300. } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
  301. /* Write 0 to the curr bits */
  302. ret = abx500_mask_and_set_register_interruptible(di->dev,
  303. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  304. BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA,
  305. ~(BAT_CTRL_16U_ENA | BAT_CTRL_18U_ENA));
  306. } else {
  307. /* Write 0 to the curr bits */
  308. ret = abx500_mask_and_set_register_interruptible(di->dev,
  309. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  310. BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA,
  311. ~(BAT_CTRL_7U_ENA | BAT_CTRL_20U_ENA));
  312. }
  313. if (ret) {
  314. dev_err(di->dev, "%s failed disabling current source\n",
  315. __func__);
  316. return ret;
  317. }
  318. enable_pu_comp:
  319. /* Enable Pull-Up and comparator */
  320. ret = abx500_mask_and_set_register_interruptible(di->dev,
  321. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  322. BAT_CTRL_PULL_UP_ENA | BAT_CTRL_CMP_ENA,
  323. BAT_CTRL_PULL_UP_ENA | BAT_CTRL_CMP_ENA);
  324. if (ret) {
  325. dev_err(di->dev, "%s failed enabling PU and comp\n",
  326. __func__);
  327. return ret;
  328. }
  329. disable_force_comp:
  330. /*
  331. * We have to wait one 32kHz cycle before disabling
  332. * ForceBatCtrlCmpHigh since this needs to be written
  333. * in a separate cycle
  334. */
  335. udelay(32);
  336. /* Disable 'force comparator' */
  337. ret = abx500_mask_and_set_register_interruptible(di->dev,
  338. AB8500_CHARGER, AB8500_BAT_CTRL_CURRENT_SOURCE,
  339. FORCE_BAT_CTRL_CMP_HIGH, ~FORCE_BAT_CTRL_CMP_HIGH);
  340. if (ret) {
  341. dev_err(di->dev, "%s failed disabling force comp\n",
  342. __func__);
  343. return ret;
  344. }
  345. return ret;
  346. }
  347. /**
  348. * ab8500_btemp_get_batctrl_res() - get battery resistance
  349. * @di: pointer to the ab8500_btemp structure
  350. *
  351. * This function returns the battery pack identification resistance.
  352. * Returns value in Ohms.
  353. */
  354. static int ab8500_btemp_get_batctrl_res(struct ab8500_btemp *di)
  355. {
  356. int ret;
  357. int batctrl = 0;
  358. int res;
  359. int inst_curr;
  360. int i;
  361. /*
  362. * BATCTRL current sources are included on AB8500 cut2.0
  363. * and future versions
  364. */
  365. ret = ab8500_btemp_curr_source_enable(di, true);
  366. if (ret) {
  367. dev_err(di->dev, "%s curr source enabled failed\n", __func__);
  368. return ret;
  369. }
  370. if (!di->fg)
  371. di->fg = ab8500_fg_get();
  372. if (!di->fg) {
  373. dev_err(di->dev, "No fg found\n");
  374. return -EINVAL;
  375. }
  376. ret = ab8500_fg_inst_curr_start(di->fg);
  377. if (ret) {
  378. dev_err(di->dev, "Failed to start current measurement\n");
  379. return ret;
  380. }
  381. do {
  382. msleep(20);
  383. } while (!ab8500_fg_inst_curr_started(di->fg));
  384. i = 0;
  385. do {
  386. batctrl += ab8500_btemp_read_batctrl_voltage(di);
  387. i++;
  388. msleep(20);
  389. } while (!ab8500_fg_inst_curr_done(di->fg));
  390. batctrl /= i;
  391. ret = ab8500_fg_inst_curr_finalize(di->fg, &inst_curr);
  392. if (ret) {
  393. dev_err(di->dev, "Failed to finalize current measurement\n");
  394. return ret;
  395. }
  396. res = ab8500_btemp_batctrl_volt_to_res(di, batctrl, inst_curr);
  397. ret = ab8500_btemp_curr_source_enable(di, false);
  398. if (ret) {
  399. dev_err(di->dev, "%s curr source disable failed\n", __func__);
  400. return ret;
  401. }
  402. dev_dbg(di->dev, "%s batctrl: %d res: %d inst_curr: %d samples: %d\n",
  403. __func__, batctrl, res, inst_curr, i);
  404. return res;
  405. }
  406. /**
  407. * ab8500_btemp_res_to_temp() - resistance to temperature
  408. * @di: pointer to the ab8500_btemp structure
  409. * @tbl: pointer to the resiatance to temperature table
  410. * @tbl_size: size of the resistance to temperature table
  411. * @res: resistance to calculate the temperature from
  412. *
  413. * This function returns the battery temperature in degrees Celsius
  414. * based on the NTC resistance.
  415. */
  416. static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di,
  417. const struct abx500_res_to_temp *tbl, int tbl_size, int res)
  418. {
  419. int i;
  420. /*
  421. * Calculate the formula for the straight line
  422. * Simple interpolation if we are within
  423. * the resistance table limits, extrapolate
  424. * if resistance is outside the limits.
  425. */
  426. if (res > tbl[0].resist)
  427. i = 0;
  428. else if (res <= tbl[tbl_size - 1].resist)
  429. i = tbl_size - 2;
  430. else {
  431. i = 0;
  432. while (!(res <= tbl[i].resist &&
  433. res > tbl[i + 1].resist))
  434. i++;
  435. }
  436. return tbl[i].temp + ((tbl[i + 1].temp - tbl[i].temp) *
  437. (res - tbl[i].resist)) / (tbl[i + 1].resist - tbl[i].resist);
  438. }
  439. /**
  440. * ab8500_btemp_measure_temp() - measure battery temperature
  441. * @di: pointer to the ab8500_btemp structure
  442. *
  443. * Returns battery temperature (on success) else the previous temperature
  444. */
  445. static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
  446. {
  447. int temp;
  448. static int prev;
  449. int rbat, rntc, vntc;
  450. u8 id;
  451. id = di->bm->batt_id;
  452. if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
  453. id != BATTERY_UNKNOWN) {
  454. rbat = ab8500_btemp_get_batctrl_res(di);
  455. if (rbat < 0) {
  456. dev_err(di->dev, "%s get batctrl res failed\n",
  457. __func__);
  458. /*
  459. * Return out-of-range temperature so that
  460. * charging is stopped
  461. */
  462. return BTEMP_THERMAL_LOW_LIMIT;
  463. }
  464. temp = ab8500_btemp_res_to_temp(di,
  465. di->bm->bat_type[id].r_to_t_tbl,
  466. di->bm->bat_type[id].n_temp_tbl_elements, rbat);
  467. } else {
  468. vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL);
  469. if (vntc < 0) {
  470. dev_err(di->dev,
  471. "%s gpadc conversion failed,"
  472. " using previous value\n", __func__);
  473. return prev;
  474. }
  475. /*
  476. * The PCB NTC is sourced from VTVOUT via a 230kOhm
  477. * resistor.
  478. */
  479. rntc = 230000 * vntc / (VTVOUT_V - vntc);
  480. temp = ab8500_btemp_res_to_temp(di,
  481. di->bm->bat_type[id].r_to_t_tbl,
  482. di->bm->bat_type[id].n_temp_tbl_elements, rntc);
  483. prev = temp;
  484. }
  485. dev_dbg(di->dev, "Battery temperature is %d\n", temp);
  486. return temp;
  487. }
  488. /**
  489. * ab8500_btemp_id() - Identify the connected battery
  490. * @di: pointer to the ab8500_btemp structure
  491. *
  492. * This function will try to identify the battery by reading the ID
  493. * resistor. Some brands use a combined ID resistor with a NTC resistor to
  494. * both be able to identify and to read the temperature of it.
  495. */
  496. static int ab8500_btemp_id(struct ab8500_btemp *di)
  497. {
  498. int res;
  499. u8 i;
  500. if (is_ab8540(di->parent))
  501. di->curr_source = BTEMP_BATCTRL_CURR_SRC_60UA;
  502. else if (is_ab9540(di->parent) || is_ab8505(di->parent))
  503. di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA;
  504. else
  505. di->curr_source = BTEMP_BATCTRL_CURR_SRC_7UA;
  506. di->bm->batt_id = BATTERY_UNKNOWN;
  507. res = ab8500_btemp_get_batctrl_res(di);
  508. if (res < 0) {
  509. dev_err(di->dev, "%s get batctrl res failed\n", __func__);
  510. return -ENXIO;
  511. }
  512. /* BATTERY_UNKNOWN is defined on position 0, skip it! */
  513. for (i = BATTERY_UNKNOWN + 1; i < di->bm->n_btypes; i++) {
  514. if ((res <= di->bm->bat_type[i].resis_high) &&
  515. (res >= di->bm->bat_type[i].resis_low)) {
  516. dev_dbg(di->dev, "Battery detected on %s"
  517. " low %d < res %d < high: %d"
  518. " index: %d\n",
  519. di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL ?
  520. "BATCTRL" : "BATTEMP",
  521. di->bm->bat_type[i].resis_low, res,
  522. di->bm->bat_type[i].resis_high, i);
  523. di->bm->batt_id = i;
  524. break;
  525. }
  526. }
  527. if (di->bm->batt_id == BATTERY_UNKNOWN) {
  528. dev_warn(di->dev, "Battery identified as unknown"
  529. ", resistance %d Ohm\n", res);
  530. return -ENXIO;
  531. }
  532. /*
  533. * We only have to change current source if the
  534. * detected type is Type 1.
  535. */
  536. if (di->bm->adc_therm == ABx500_ADC_THERM_BATCTRL &&
  537. di->bm->batt_id == 1) {
  538. if (is_ab8540(di->parent)) {
  539. dev_dbg(di->dev,
  540. "Set BATCTRL current source to 60uA\n");
  541. di->curr_source = BTEMP_BATCTRL_CURR_SRC_60UA;
  542. } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
  543. dev_dbg(di->dev,
  544. "Set BATCTRL current source to 16uA\n");
  545. di->curr_source = BTEMP_BATCTRL_CURR_SRC_16UA;
  546. } else {
  547. dev_dbg(di->dev, "Set BATCTRL current source to 20uA\n");
  548. di->curr_source = BTEMP_BATCTRL_CURR_SRC_20UA;
  549. }
  550. }
  551. return di->bm->batt_id;
  552. }
  553. /**
  554. * ab8500_btemp_periodic_work() - Measuring the temperature periodically
  555. * @work: pointer to the work_struct structure
  556. *
  557. * Work function for measuring the temperature periodically
  558. */
  559. static void ab8500_btemp_periodic_work(struct work_struct *work)
  560. {
  561. int interval;
  562. int bat_temp;
  563. struct ab8500_btemp *di = container_of(work,
  564. struct ab8500_btemp, btemp_periodic_work.work);
  565. if (!di->initialized) {
  566. /* Identify the battery */
  567. if (ab8500_btemp_id(di) < 0)
  568. dev_warn(di->dev, "failed to identify the battery\n");
  569. }
  570. bat_temp = ab8500_btemp_measure_temp(di);
  571. /*
  572. * Filter battery temperature.
  573. * Allow direct updates on temperature only if two samples result in
  574. * same temperature. Else only allow 1 degree change from previous
  575. * reported value in the direction of the new measurement.
  576. */
  577. if ((bat_temp == di->prev_bat_temp) || !di->initialized) {
  578. if ((di->bat_temp != di->prev_bat_temp) || !di->initialized) {
  579. di->initialized = true;
  580. di->bat_temp = bat_temp;
  581. power_supply_changed(di->btemp_psy);
  582. }
  583. } else if (bat_temp < di->prev_bat_temp) {
  584. di->bat_temp--;
  585. power_supply_changed(di->btemp_psy);
  586. } else if (bat_temp > di->prev_bat_temp) {
  587. di->bat_temp++;
  588. power_supply_changed(di->btemp_psy);
  589. }
  590. di->prev_bat_temp = bat_temp;
  591. if (di->events.ac_conn || di->events.usb_conn)
  592. interval = di->bm->temp_interval_chg;
  593. else
  594. interval = di->bm->temp_interval_nochg;
  595. /* Schedule a new measurement */
  596. queue_delayed_work(di->btemp_wq,
  597. &di->btemp_periodic_work,
  598. round_jiffies(interval * HZ));
  599. }
  600. /**
  601. * ab8500_btemp_batctrlindb_handler() - battery removal detected
  602. * @irq: interrupt number
  603. * @_di: void pointer that has to address of ab8500_btemp
  604. *
  605. * Returns IRQ status(IRQ_HANDLED)
  606. */
  607. static irqreturn_t ab8500_btemp_batctrlindb_handler(int irq, void *_di)
  608. {
  609. struct ab8500_btemp *di = _di;
  610. dev_err(di->dev, "Battery removal detected!\n");
  611. di->events.batt_rem = true;
  612. power_supply_changed(di->btemp_psy);
  613. return IRQ_HANDLED;
  614. }
  615. /**
  616. * ab8500_btemp_templow_handler() - battery temp lower than 10 degrees
  617. * @irq: interrupt number
  618. * @_di: void pointer that has to address of ab8500_btemp
  619. *
  620. * Returns IRQ status(IRQ_HANDLED)
  621. */
  622. static irqreturn_t ab8500_btemp_templow_handler(int irq, void *_di)
  623. {
  624. struct ab8500_btemp *di = _di;
  625. if (is_ab8500_3p3_or_earlier(di->parent)) {
  626. dev_dbg(di->dev, "Ignore false btemp low irq"
  627. " for ABB cut 1.0, 1.1, 2.0 and 3.3\n");
  628. } else {
  629. dev_crit(di->dev, "Battery temperature lower than -10deg c\n");
  630. di->events.btemp_low = true;
  631. di->events.btemp_high = false;
  632. di->events.btemp_medhigh = false;
  633. di->events.btemp_lowmed = false;
  634. power_supply_changed(di->btemp_psy);
  635. }
  636. return IRQ_HANDLED;
  637. }
  638. /**
  639. * ab8500_btemp_temphigh_handler() - battery temp higher than max temp
  640. * @irq: interrupt number
  641. * @_di: void pointer that has to address of ab8500_btemp
  642. *
  643. * Returns IRQ status(IRQ_HANDLED)
  644. */
  645. static irqreturn_t ab8500_btemp_temphigh_handler(int irq, void *_di)
  646. {
  647. struct ab8500_btemp *di = _di;
  648. dev_crit(di->dev, "Battery temperature is higher than MAX temp\n");
  649. di->events.btemp_high = true;
  650. di->events.btemp_medhigh = false;
  651. di->events.btemp_lowmed = false;
  652. di->events.btemp_low = false;
  653. power_supply_changed(di->btemp_psy);
  654. return IRQ_HANDLED;
  655. }
  656. /**
  657. * ab8500_btemp_lowmed_handler() - battery temp between low and medium
  658. * @irq: interrupt number
  659. * @_di: void pointer that has to address of ab8500_btemp
  660. *
  661. * Returns IRQ status(IRQ_HANDLED)
  662. */
  663. static irqreturn_t ab8500_btemp_lowmed_handler(int irq, void *_di)
  664. {
  665. struct ab8500_btemp *di = _di;
  666. dev_dbg(di->dev, "Battery temperature is between low and medium\n");
  667. di->events.btemp_lowmed = true;
  668. di->events.btemp_medhigh = false;
  669. di->events.btemp_high = false;
  670. di->events.btemp_low = false;
  671. power_supply_changed(di->btemp_psy);
  672. return IRQ_HANDLED;
  673. }
  674. /**
  675. * ab8500_btemp_medhigh_handler() - battery temp between medium and high
  676. * @irq: interrupt number
  677. * @_di: void pointer that has to address of ab8500_btemp
  678. *
  679. * Returns IRQ status(IRQ_HANDLED)
  680. */
  681. static irqreturn_t ab8500_btemp_medhigh_handler(int irq, void *_di)
  682. {
  683. struct ab8500_btemp *di = _di;
  684. dev_dbg(di->dev, "Battery temperature is between medium and high\n");
  685. di->events.btemp_medhigh = true;
  686. di->events.btemp_lowmed = false;
  687. di->events.btemp_high = false;
  688. di->events.btemp_low = false;
  689. power_supply_changed(di->btemp_psy);
  690. return IRQ_HANDLED;
  691. }
  692. /**
  693. * ab8500_btemp_periodic() - Periodic temperature measurements
  694. * @di: pointer to the ab8500_btemp structure
  695. * @enable: enable or disable periodic temperature measurements
  696. *
  697. * Starts of stops periodic temperature measurements. Periodic measurements
  698. * should only be done when a charger is connected.
  699. */
  700. static void ab8500_btemp_periodic(struct ab8500_btemp *di,
  701. bool enable)
  702. {
  703. dev_dbg(di->dev, "Enable periodic temperature measurements: %d\n",
  704. enable);
  705. /*
  706. * Make sure a new measurement is done directly by cancelling
  707. * any pending work
  708. */
  709. cancel_delayed_work_sync(&di->btemp_periodic_work);
  710. if (enable)
  711. queue_delayed_work(di->btemp_wq, &di->btemp_periodic_work, 0);
  712. }
  713. /**
  714. * ab8500_btemp_get_temp() - get battery temperature
  715. * @di: pointer to the ab8500_btemp structure
  716. *
  717. * Returns battery temperature
  718. */
  719. int ab8500_btemp_get_temp(struct ab8500_btemp *di)
  720. {
  721. int temp = 0;
  722. /*
  723. * The BTEMP events are not reliabe on AB8500 cut3.3
  724. * and prior versions
  725. */
  726. if (is_ab8500_3p3_or_earlier(di->parent)) {
  727. temp = di->bat_temp * 10;
  728. } else {
  729. if (di->events.btemp_low) {
  730. if (temp > di->btemp_ranges.btemp_low_limit)
  731. temp = di->btemp_ranges.btemp_low_limit * 10;
  732. else
  733. temp = di->bat_temp * 10;
  734. } else if (di->events.btemp_high) {
  735. if (temp < di->btemp_ranges.btemp_high_limit)
  736. temp = di->btemp_ranges.btemp_high_limit * 10;
  737. else
  738. temp = di->bat_temp * 10;
  739. } else if (di->events.btemp_lowmed) {
  740. if (temp > di->btemp_ranges.btemp_med_limit)
  741. temp = di->btemp_ranges.btemp_med_limit * 10;
  742. else
  743. temp = di->bat_temp * 10;
  744. } else if (di->events.btemp_medhigh) {
  745. if (temp < di->btemp_ranges.btemp_med_limit)
  746. temp = di->btemp_ranges.btemp_med_limit * 10;
  747. else
  748. temp = di->bat_temp * 10;
  749. } else
  750. temp = di->bat_temp * 10;
  751. }
  752. return temp;
  753. }
  754. EXPORT_SYMBOL(ab8500_btemp_get_temp);
  755. /**
  756. * ab8500_btemp_get_batctrl_temp() - get the temperature
  757. * @btemp: pointer to the btemp structure
  758. *
  759. * Returns the batctrl temperature in millidegrees
  760. */
  761. int ab8500_btemp_get_batctrl_temp(struct ab8500_btemp *btemp)
  762. {
  763. return btemp->bat_temp * 1000;
  764. }
  765. EXPORT_SYMBOL(ab8500_btemp_get_batctrl_temp);
  766. /**
  767. * ab8500_btemp_get_property() - get the btemp properties
  768. * @psy: pointer to the power_supply structure
  769. * @psp: pointer to the power_supply_property structure
  770. * @val: pointer to the power_supply_propval union
  771. *
  772. * This function gets called when an application tries to get the btemp
  773. * properties by reading the sysfs files.
  774. * online: presence of the battery
  775. * present: presence of the battery
  776. * technology: battery technology
  777. * temp: battery temperature
  778. * Returns error code in case of failure else 0(on success)
  779. */
  780. static int ab8500_btemp_get_property(struct power_supply *psy,
  781. enum power_supply_property psp,
  782. union power_supply_propval *val)
  783. {
  784. struct ab8500_btemp *di = power_supply_get_drvdata(psy);
  785. switch (psp) {
  786. case POWER_SUPPLY_PROP_PRESENT:
  787. case POWER_SUPPLY_PROP_ONLINE:
  788. if (di->events.batt_rem)
  789. val->intval = 0;
  790. else
  791. val->intval = 1;
  792. break;
  793. case POWER_SUPPLY_PROP_TECHNOLOGY:
  794. val->intval = di->bm->bat_type[di->bm->batt_id].name;
  795. break;
  796. case POWER_SUPPLY_PROP_TEMP:
  797. val->intval = ab8500_btemp_get_temp(di);
  798. break;
  799. default:
  800. return -EINVAL;
  801. }
  802. return 0;
  803. }
  804. static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
  805. {
  806. struct power_supply *psy;
  807. struct power_supply *ext = dev_get_drvdata(dev);
  808. const char **supplicants = (const char **)ext->supplied_to;
  809. struct ab8500_btemp *di;
  810. union power_supply_propval ret;
  811. int j;
  812. psy = (struct power_supply *)data;
  813. di = power_supply_get_drvdata(psy);
  814. /*
  815. * For all psy where the name of your driver
  816. * appears in any supplied_to
  817. */
  818. j = match_string(supplicants, ext->num_supplicants, psy->desc->name);
  819. if (j < 0)
  820. return 0;
  821. /* Go through all properties for the psy */
  822. for (j = 0; j < ext->desc->num_properties; j++) {
  823. enum power_supply_property prop;
  824. prop = ext->desc->properties[j];
  825. if (power_supply_get_property(ext, prop, &ret))
  826. continue;
  827. switch (prop) {
  828. case POWER_SUPPLY_PROP_PRESENT:
  829. switch (ext->desc->type) {
  830. case POWER_SUPPLY_TYPE_MAINS:
  831. /* AC disconnected */
  832. if (!ret.intval && di->events.ac_conn) {
  833. di->events.ac_conn = false;
  834. }
  835. /* AC connected */
  836. else if (ret.intval && !di->events.ac_conn) {
  837. di->events.ac_conn = true;
  838. if (!di->events.usb_conn)
  839. ab8500_btemp_periodic(di, true);
  840. }
  841. break;
  842. case POWER_SUPPLY_TYPE_USB:
  843. /* USB disconnected */
  844. if (!ret.intval && di->events.usb_conn) {
  845. di->events.usb_conn = false;
  846. }
  847. /* USB connected */
  848. else if (ret.intval && !di->events.usb_conn) {
  849. di->events.usb_conn = true;
  850. if (!di->events.ac_conn)
  851. ab8500_btemp_periodic(di, true);
  852. }
  853. break;
  854. default:
  855. break;
  856. }
  857. break;
  858. default:
  859. break;
  860. }
  861. }
  862. return 0;
  863. }
  864. /**
  865. * ab8500_btemp_external_power_changed() - callback for power supply changes
  866. * @psy: pointer to the structure power_supply
  867. *
  868. * This function is pointing to the function pointer external_power_changed
  869. * of the structure power_supply.
  870. * This function gets executed when there is a change in the external power
  871. * supply to the btemp.
  872. */
  873. static void ab8500_btemp_external_power_changed(struct power_supply *psy)
  874. {
  875. struct ab8500_btemp *di = power_supply_get_drvdata(psy);
  876. class_for_each_device(power_supply_class, NULL,
  877. di->btemp_psy, ab8500_btemp_get_ext_psy_data);
  878. }
  879. /* ab8500 btemp driver interrupts and their respective isr */
  880. static struct ab8500_btemp_interrupts ab8500_btemp_irq[] = {
  881. {"BAT_CTRL_INDB", ab8500_btemp_batctrlindb_handler},
  882. {"BTEMP_LOW", ab8500_btemp_templow_handler},
  883. {"BTEMP_HIGH", ab8500_btemp_temphigh_handler},
  884. {"BTEMP_LOW_MEDIUM", ab8500_btemp_lowmed_handler},
  885. {"BTEMP_MEDIUM_HIGH", ab8500_btemp_medhigh_handler},
  886. };
  887. #if defined(CONFIG_PM)
  888. static int ab8500_btemp_resume(struct platform_device *pdev)
  889. {
  890. struct ab8500_btemp *di = platform_get_drvdata(pdev);
  891. ab8500_btemp_periodic(di, true);
  892. return 0;
  893. }
  894. static int ab8500_btemp_suspend(struct platform_device *pdev,
  895. pm_message_t state)
  896. {
  897. struct ab8500_btemp *di = platform_get_drvdata(pdev);
  898. ab8500_btemp_periodic(di, false);
  899. return 0;
  900. }
  901. #else
  902. #define ab8500_btemp_suspend NULL
  903. #define ab8500_btemp_resume NULL
  904. #endif
  905. static int ab8500_btemp_remove(struct platform_device *pdev)
  906. {
  907. struct ab8500_btemp *di = platform_get_drvdata(pdev);
  908. int i, irq;
  909. /* Disable interrupts */
  910. for (i = 0; i < ARRAY_SIZE(ab8500_btemp_irq); i++) {
  911. irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name);
  912. free_irq(irq, di);
  913. }
  914. /* Delete the work queue */
  915. destroy_workqueue(di->btemp_wq);
  916. flush_scheduled_work();
  917. power_supply_unregister(di->btemp_psy);
  918. return 0;
  919. }
  920. static char *supply_interface[] = {
  921. "ab8500_chargalg",
  922. "ab8500_fg",
  923. };
  924. static const struct power_supply_desc ab8500_btemp_desc = {
  925. .name = "ab8500_btemp",
  926. .type = POWER_SUPPLY_TYPE_BATTERY,
  927. .properties = ab8500_btemp_props,
  928. .num_properties = ARRAY_SIZE(ab8500_btemp_props),
  929. .get_property = ab8500_btemp_get_property,
  930. .external_power_changed = ab8500_btemp_external_power_changed,
  931. };
  932. static int ab8500_btemp_probe(struct platform_device *pdev)
  933. {
  934. struct device_node *np = pdev->dev.of_node;
  935. struct abx500_bm_data *plat = pdev->dev.platform_data;
  936. struct power_supply_config psy_cfg = {};
  937. struct ab8500_btemp *di;
  938. int irq, i, ret = 0;
  939. u8 val;
  940. di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL);
  941. if (!di) {
  942. dev_err(&pdev->dev, "%s no mem for ab8500_btemp\n", __func__);
  943. return -ENOMEM;
  944. }
  945. if (!plat) {
  946. dev_err(&pdev->dev, "no battery management data supplied\n");
  947. return -EINVAL;
  948. }
  949. di->bm = plat;
  950. if (np) {
  951. ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm);
  952. if (ret) {
  953. dev_err(&pdev->dev, "failed to get battery information\n");
  954. return ret;
  955. }
  956. }
  957. /* get parent data */
  958. di->dev = &pdev->dev;
  959. di->parent = dev_get_drvdata(pdev->dev.parent);
  960. di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
  961. di->initialized = false;
  962. psy_cfg.supplied_to = supply_interface;
  963. psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
  964. psy_cfg.drv_data = di;
  965. /* Create a work queue for the btemp */
  966. di->btemp_wq =
  967. alloc_workqueue("ab8500_btemp_wq", WQ_MEM_RECLAIM, 0);
  968. if (di->btemp_wq == NULL) {
  969. dev_err(di->dev, "failed to create work queue\n");
  970. return -ENOMEM;
  971. }
  972. /* Init work for measuring temperature periodically */
  973. INIT_DEFERRABLE_WORK(&di->btemp_periodic_work,
  974. ab8500_btemp_periodic_work);
  975. /* Set BTEMP thermal limits. Low and Med are fixed */
  976. di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT;
  977. di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT;
  978. ret = abx500_get_register_interruptible(di->dev, AB8500_CHARGER,
  979. AB8500_BTEMP_HIGH_TH, &val);
  980. if (ret < 0) {
  981. dev_err(di->dev, "%s ab8500 read failed\n", __func__);
  982. goto free_btemp_wq;
  983. }
  984. switch (val) {
  985. case BTEMP_HIGH_TH_57_0:
  986. case BTEMP_HIGH_TH_57_1:
  987. di->btemp_ranges.btemp_high_limit =
  988. BTEMP_THERMAL_HIGH_LIMIT_57;
  989. break;
  990. case BTEMP_HIGH_TH_52:
  991. di->btemp_ranges.btemp_high_limit =
  992. BTEMP_THERMAL_HIGH_LIMIT_52;
  993. break;
  994. case BTEMP_HIGH_TH_62:
  995. di->btemp_ranges.btemp_high_limit =
  996. BTEMP_THERMAL_HIGH_LIMIT_62;
  997. break;
  998. }
  999. /* Register BTEMP power supply class */
  1000. di->btemp_psy = power_supply_register(di->dev, &ab8500_btemp_desc,
  1001. &psy_cfg);
  1002. if (IS_ERR(di->btemp_psy)) {
  1003. dev_err(di->dev, "failed to register BTEMP psy\n");
  1004. ret = PTR_ERR(di->btemp_psy);
  1005. goto free_btemp_wq;
  1006. }
  1007. /* Register interrupts */
  1008. for (i = 0; i < ARRAY_SIZE(ab8500_btemp_irq); i++) {
  1009. irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name);
  1010. ret = request_threaded_irq(irq, NULL, ab8500_btemp_irq[i].isr,
  1011. IRQF_SHARED | IRQF_NO_SUSPEND,
  1012. ab8500_btemp_irq[i].name, di);
  1013. if (ret) {
  1014. dev_err(di->dev, "failed to request %s IRQ %d: %d\n"
  1015. , ab8500_btemp_irq[i].name, irq, ret);
  1016. goto free_irq;
  1017. }
  1018. dev_dbg(di->dev, "Requested %s IRQ %d: %d\n",
  1019. ab8500_btemp_irq[i].name, irq, ret);
  1020. }
  1021. platform_set_drvdata(pdev, di);
  1022. /* Kick off periodic temperature measurements */
  1023. ab8500_btemp_periodic(di, true);
  1024. list_add_tail(&di->node, &ab8500_btemp_list);
  1025. return ret;
  1026. free_irq:
  1027. power_supply_unregister(di->btemp_psy);
  1028. /* We also have to free all successfully registered irqs */
  1029. for (i = i - 1; i >= 0; i--) {
  1030. irq = platform_get_irq_byname(pdev, ab8500_btemp_irq[i].name);
  1031. free_irq(irq, di);
  1032. }
  1033. free_btemp_wq:
  1034. destroy_workqueue(di->btemp_wq);
  1035. return ret;
  1036. }
  1037. static const struct of_device_id ab8500_btemp_match[] = {
  1038. { .compatible = "stericsson,ab8500-btemp", },
  1039. { },
  1040. };
  1041. static struct platform_driver ab8500_btemp_driver = {
  1042. .probe = ab8500_btemp_probe,
  1043. .remove = ab8500_btemp_remove,
  1044. .suspend = ab8500_btemp_suspend,
  1045. .resume = ab8500_btemp_resume,
  1046. .driver = {
  1047. .name = "ab8500-btemp",
  1048. .of_match_table = ab8500_btemp_match,
  1049. },
  1050. };
  1051. static int __init ab8500_btemp_init(void)
  1052. {
  1053. return platform_driver_register(&ab8500_btemp_driver);
  1054. }
  1055. static void __exit ab8500_btemp_exit(void)
  1056. {
  1057. platform_driver_unregister(&ab8500_btemp_driver);
  1058. }
  1059. device_initcall(ab8500_btemp_init);
  1060. module_exit(ab8500_btemp_exit);
  1061. MODULE_LICENSE("GPL v2");
  1062. MODULE_AUTHOR("Johan Palsson, Karl Komierowski, Arun R Murthy");
  1063. MODULE_ALIAS("platform:ab8500-btemp");
  1064. MODULE_DESCRIPTION("AB8500 battery temperature driver");