max14577.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /*
  2. * max14577.c - mfd core driver for the Maxim 14577/77836
  3. *
  4. * Copyright (C) 2014 Samsung Electronics
  5. * Chanwoo Choi <cw00.choi@samsung.com>
  6. * Krzysztof Kozlowski <krzk@kernel.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * This driver is based on max8997.c
  19. */
  20. #include <linux/err.h>
  21. #include <linux/module.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/of_device.h>
  24. #include <linux/mfd/core.h>
  25. #include <linux/mfd/max14577.h>
  26. #include <linux/mfd/max14577-private.h>
  27. /*
  28. * Table of valid charger currents for different Maxim chipsets.
  29. * It is placed here because it is used by both charger and regulator driver.
  30. */
  31. const struct maxim_charger_current maxim_charger_currents[] = {
  32. [MAXIM_DEVICE_TYPE_UNKNOWN] = { 0, 0, 0, 0 },
  33. [MAXIM_DEVICE_TYPE_MAX14577] = {
  34. .min = MAX14577_CHARGER_CURRENT_LIMIT_MIN,
  35. .high_start = MAX14577_CHARGER_CURRENT_LIMIT_HIGH_START,
  36. .high_step = MAX14577_CHARGER_CURRENT_LIMIT_HIGH_STEP,
  37. .max = MAX14577_CHARGER_CURRENT_LIMIT_MAX,
  38. },
  39. [MAXIM_DEVICE_TYPE_MAX77836] = {
  40. .min = MAX77836_CHARGER_CURRENT_LIMIT_MIN,
  41. .high_start = MAX77836_CHARGER_CURRENT_LIMIT_HIGH_START,
  42. .high_step = MAX77836_CHARGER_CURRENT_LIMIT_HIGH_STEP,
  43. .max = MAX77836_CHARGER_CURRENT_LIMIT_MAX,
  44. },
  45. };
  46. EXPORT_SYMBOL_GPL(maxim_charger_currents);
  47. /*
  48. * maxim_charger_calc_reg_current - Calculate register value for current
  49. * @limits: constraints for charger, matching the MBCICHWRC register
  50. * @min_ua: minimal requested current, micro Amps
  51. * @max_ua: maximum requested current, micro Amps
  52. * @dst: destination to store calculated register value
  53. *
  54. * Calculates the value of MBCICHWRC (Fast Battery Charge Current) register
  55. * for given current and stores it under pointed 'dst'. The stored value
  56. * combines low bit (MBCICHWRCL) and high bits (MBCICHWRCH). It is also
  57. * properly shifted.
  58. *
  59. * The calculated register value matches the current which:
  60. * - is always between <limits.min, limits.max>;
  61. * - is always less or equal to max_ua;
  62. * - is the highest possible value;
  63. * - may be lower than min_ua.
  64. *
  65. * On success returns 0. On error returns -EINVAL (requested min/max current
  66. * is outside of given charger limits) and 'dst' is not set.
  67. */
  68. int maxim_charger_calc_reg_current(const struct maxim_charger_current *limits,
  69. unsigned int min_ua, unsigned int max_ua, u8 *dst)
  70. {
  71. unsigned int current_bits = 0xf;
  72. if (min_ua > max_ua)
  73. return -EINVAL;
  74. if (min_ua > limits->max || max_ua < limits->min)
  75. return -EINVAL;
  76. if (max_ua < limits->high_start) {
  77. /*
  78. * Less than high_start, so set the minimal current
  79. * (turn Low Bit off, 0 as high bits).
  80. */
  81. *dst = 0x0;
  82. return 0;
  83. }
  84. /* max_ua is in range: <high_start, infinite>, cut it to limits.max */
  85. max_ua = min(limits->max, max_ua);
  86. max_ua -= limits->high_start;
  87. /*
  88. * There is no risk of overflow 'max_ua' here because:
  89. * - max_ua >= limits.high_start
  90. * - BUILD_BUG checks that 'limits' are: max >= high_start + high_step
  91. */
  92. current_bits = max_ua / limits->high_step;
  93. /* Turn Low Bit on (use range <limits.high_start, limits.max>) ... */
  94. *dst = 0x1 << CHGCTRL4_MBCICHWRCL_SHIFT;
  95. /* and set proper High Bits */
  96. *dst |= current_bits << CHGCTRL4_MBCICHWRCH_SHIFT;
  97. return 0;
  98. }
  99. EXPORT_SYMBOL_GPL(maxim_charger_calc_reg_current);
  100. static const struct mfd_cell max14577_devs[] = {
  101. {
  102. .name = "max14577-muic",
  103. .of_compatible = "maxim,max14577-muic",
  104. },
  105. {
  106. .name = "max14577-regulator",
  107. .of_compatible = "maxim,max14577-regulator",
  108. },
  109. {
  110. .name = "max14577-charger",
  111. .of_compatible = "maxim,max14577-charger",
  112. },
  113. };
  114. static const struct mfd_cell max77836_devs[] = {
  115. {
  116. .name = "max77836-muic",
  117. .of_compatible = "maxim,max77836-muic",
  118. },
  119. {
  120. .name = "max77836-regulator",
  121. .of_compatible = "maxim,max77836-regulator",
  122. },
  123. {
  124. .name = "max77836-charger",
  125. .of_compatible = "maxim,max77836-charger",
  126. },
  127. {
  128. .name = "max77836-battery",
  129. .of_compatible = "maxim,max77836-battery",
  130. },
  131. };
  132. static const struct of_device_id max14577_dt_match[] = {
  133. {
  134. .compatible = "maxim,max14577",
  135. .data = (void *)MAXIM_DEVICE_TYPE_MAX14577,
  136. },
  137. {
  138. .compatible = "maxim,max77836",
  139. .data = (void *)MAXIM_DEVICE_TYPE_MAX77836,
  140. },
  141. {},
  142. };
  143. static bool max14577_muic_volatile_reg(struct device *dev, unsigned int reg)
  144. {
  145. switch (reg) {
  146. case MAX14577_REG_INT1 ... MAX14577_REG_STATUS3:
  147. return true;
  148. default:
  149. break;
  150. }
  151. return false;
  152. }
  153. static bool max77836_muic_volatile_reg(struct device *dev, unsigned int reg)
  154. {
  155. /* Any max14577 volatile registers are also max77836 volatile. */
  156. if (max14577_muic_volatile_reg(dev, reg))
  157. return true;
  158. switch (reg) {
  159. case MAX77836_FG_REG_VCELL_MSB ... MAX77836_FG_REG_SOC_LSB:
  160. case MAX77836_FG_REG_CRATE_MSB ... MAX77836_FG_REG_CRATE_LSB:
  161. case MAX77836_FG_REG_STATUS_H ... MAX77836_FG_REG_STATUS_L:
  162. case MAX77836_PMIC_REG_INTSRC:
  163. case MAX77836_PMIC_REG_TOPSYS_INT:
  164. case MAX77836_PMIC_REG_TOPSYS_STAT:
  165. return true;
  166. default:
  167. break;
  168. }
  169. return false;
  170. }
  171. static const struct regmap_config max14577_muic_regmap_config = {
  172. .reg_bits = 8,
  173. .val_bits = 8,
  174. .volatile_reg = max14577_muic_volatile_reg,
  175. .max_register = MAX14577_REG_END,
  176. };
  177. static const struct regmap_config max77836_pmic_regmap_config = {
  178. .reg_bits = 8,
  179. .val_bits = 8,
  180. .volatile_reg = max77836_muic_volatile_reg,
  181. .max_register = MAX77836_PMIC_REG_END,
  182. };
  183. static const struct regmap_irq max14577_irqs[] = {
  184. /* INT1 interrupts */
  185. { .reg_offset = 0, .mask = MAX14577_INT1_ADC_MASK, },
  186. { .reg_offset = 0, .mask = MAX14577_INT1_ADCLOW_MASK, },
  187. { .reg_offset = 0, .mask = MAX14577_INT1_ADCERR_MASK, },
  188. /* INT2 interrupts */
  189. { .reg_offset = 1, .mask = MAX14577_INT2_CHGTYP_MASK, },
  190. { .reg_offset = 1, .mask = MAX14577_INT2_CHGDETRUN_MASK, },
  191. { .reg_offset = 1, .mask = MAX14577_INT2_DCDTMR_MASK, },
  192. { .reg_offset = 1, .mask = MAX14577_INT2_DBCHG_MASK, },
  193. { .reg_offset = 1, .mask = MAX14577_INT2_VBVOLT_MASK, },
  194. /* INT3 interrupts */
  195. { .reg_offset = 2, .mask = MAX14577_INT3_EOC_MASK, },
  196. { .reg_offset = 2, .mask = MAX14577_INT3_CGMBC_MASK, },
  197. { .reg_offset = 2, .mask = MAX14577_INT3_OVP_MASK, },
  198. { .reg_offset = 2, .mask = MAX14577_INT3_MBCCHGERR_MASK, },
  199. };
  200. static const struct regmap_irq_chip max14577_irq_chip = {
  201. .name = "max14577",
  202. .status_base = MAX14577_REG_INT1,
  203. .mask_base = MAX14577_REG_INTMASK1,
  204. .mask_invert = true,
  205. .num_regs = 3,
  206. .irqs = max14577_irqs,
  207. .num_irqs = ARRAY_SIZE(max14577_irqs),
  208. };
  209. static const struct regmap_irq max77836_muic_irqs[] = {
  210. /* INT1 interrupts */
  211. { .reg_offset = 0, .mask = MAX14577_INT1_ADC_MASK, },
  212. { .reg_offset = 0, .mask = MAX14577_INT1_ADCLOW_MASK, },
  213. { .reg_offset = 0, .mask = MAX14577_INT1_ADCERR_MASK, },
  214. { .reg_offset = 0, .mask = MAX77836_INT1_ADC1K_MASK, },
  215. /* INT2 interrupts */
  216. { .reg_offset = 1, .mask = MAX14577_INT2_CHGTYP_MASK, },
  217. { .reg_offset = 1, .mask = MAX14577_INT2_CHGDETRUN_MASK, },
  218. { .reg_offset = 1, .mask = MAX14577_INT2_DCDTMR_MASK, },
  219. { .reg_offset = 1, .mask = MAX14577_INT2_DBCHG_MASK, },
  220. { .reg_offset = 1, .mask = MAX14577_INT2_VBVOLT_MASK, },
  221. { .reg_offset = 1, .mask = MAX77836_INT2_VIDRM_MASK, },
  222. /* INT3 interrupts */
  223. { .reg_offset = 2, .mask = MAX14577_INT3_EOC_MASK, },
  224. { .reg_offset = 2, .mask = MAX14577_INT3_CGMBC_MASK, },
  225. { .reg_offset = 2, .mask = MAX14577_INT3_OVP_MASK, },
  226. { .reg_offset = 2, .mask = MAX14577_INT3_MBCCHGERR_MASK, },
  227. };
  228. static const struct regmap_irq_chip max77836_muic_irq_chip = {
  229. .name = "max77836-muic",
  230. .status_base = MAX14577_REG_INT1,
  231. .mask_base = MAX14577_REG_INTMASK1,
  232. .mask_invert = true,
  233. .num_regs = 3,
  234. .irqs = max77836_muic_irqs,
  235. .num_irqs = ARRAY_SIZE(max77836_muic_irqs),
  236. };
  237. static const struct regmap_irq max77836_pmic_irqs[] = {
  238. { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T120C_MASK, },
  239. { .reg_offset = 0, .mask = MAX77836_TOPSYS_INT_T140C_MASK, },
  240. };
  241. static const struct regmap_irq_chip max77836_pmic_irq_chip = {
  242. .name = "max77836-pmic",
  243. .status_base = MAX77836_PMIC_REG_TOPSYS_INT,
  244. .mask_base = MAX77836_PMIC_REG_TOPSYS_INT_MASK,
  245. .mask_invert = false,
  246. .num_regs = 1,
  247. .irqs = max77836_pmic_irqs,
  248. .num_irqs = ARRAY_SIZE(max77836_pmic_irqs),
  249. };
  250. static void max14577_print_dev_type(struct max14577 *max14577)
  251. {
  252. u8 reg_data, vendor_id, device_id;
  253. int ret;
  254. ret = max14577_read_reg(max14577->regmap, MAX14577_REG_DEVICEID,
  255. &reg_data);
  256. if (ret) {
  257. dev_err(max14577->dev,
  258. "Failed to read DEVICEID register: %d\n", ret);
  259. return;
  260. }
  261. vendor_id = ((reg_data & DEVID_VENDORID_MASK) >>
  262. DEVID_VENDORID_SHIFT);
  263. device_id = ((reg_data & DEVID_DEVICEID_MASK) >>
  264. DEVID_DEVICEID_SHIFT);
  265. dev_info(max14577->dev, "Device type: %u (ID: 0x%x, vendor: 0x%x)\n",
  266. max14577->dev_type, device_id, vendor_id);
  267. }
  268. /*
  269. * Max77836 specific initialization code for driver probe.
  270. * Adds new I2C dummy device, regmap and regmap IRQ chip.
  271. * Unmasks Interrupt Source register.
  272. *
  273. * On success returns 0.
  274. * On failure returns errno and reverts any changes done so far (e.g. remove
  275. * I2C dummy device), except masking the INT SRC register.
  276. */
  277. static int max77836_init(struct max14577 *max14577)
  278. {
  279. int ret;
  280. u8 intsrc_mask;
  281. max14577->i2c_pmic = i2c_new_dummy(max14577->i2c->adapter,
  282. I2C_ADDR_PMIC);
  283. if (!max14577->i2c_pmic) {
  284. dev_err(max14577->dev, "Failed to register PMIC I2C device\n");
  285. return -ENODEV;
  286. }
  287. i2c_set_clientdata(max14577->i2c_pmic, max14577);
  288. max14577->regmap_pmic = devm_regmap_init_i2c(max14577->i2c_pmic,
  289. &max77836_pmic_regmap_config);
  290. if (IS_ERR(max14577->regmap_pmic)) {
  291. ret = PTR_ERR(max14577->regmap_pmic);
  292. dev_err(max14577->dev, "Failed to allocate PMIC register map: %d\n",
  293. ret);
  294. goto err;
  295. }
  296. /* Un-mask MAX77836 Interrupt Source register */
  297. ret = max14577_read_reg(max14577->regmap_pmic,
  298. MAX77836_PMIC_REG_INTSRC_MASK, &intsrc_mask);
  299. if (ret < 0) {
  300. dev_err(max14577->dev, "Failed to read PMIC register\n");
  301. goto err;
  302. }
  303. intsrc_mask &= ~(MAX77836_INTSRC_MASK_TOP_INT_MASK);
  304. intsrc_mask &= ~(MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK);
  305. ret = max14577_write_reg(max14577->regmap_pmic,
  306. MAX77836_PMIC_REG_INTSRC_MASK, intsrc_mask);
  307. if (ret < 0) {
  308. dev_err(max14577->dev, "Failed to write PMIC register\n");
  309. goto err;
  310. }
  311. ret = regmap_add_irq_chip(max14577->regmap_pmic, max14577->irq,
  312. IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED,
  313. 0, &max77836_pmic_irq_chip,
  314. &max14577->irq_data_pmic);
  315. if (ret != 0) {
  316. dev_err(max14577->dev, "Failed to request PMIC IRQ %d: %d\n",
  317. max14577->irq, ret);
  318. goto err;
  319. }
  320. return 0;
  321. err:
  322. i2c_unregister_device(max14577->i2c_pmic);
  323. return ret;
  324. }
  325. /*
  326. * Max77836 specific de-initialization code for driver remove.
  327. */
  328. static void max77836_remove(struct max14577 *max14577)
  329. {
  330. regmap_del_irq_chip(max14577->irq, max14577->irq_data_pmic);
  331. i2c_unregister_device(max14577->i2c_pmic);
  332. }
  333. static int max14577_i2c_probe(struct i2c_client *i2c,
  334. const struct i2c_device_id *id)
  335. {
  336. struct max14577 *max14577;
  337. struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev);
  338. struct device_node *np = i2c->dev.of_node;
  339. int ret = 0;
  340. const struct regmap_irq_chip *irq_chip;
  341. const struct mfd_cell *mfd_devs;
  342. unsigned int mfd_devs_size;
  343. int irq_flags;
  344. if (np) {
  345. pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
  346. if (!pdata)
  347. return -ENOMEM;
  348. i2c->dev.platform_data = pdata;
  349. }
  350. if (!pdata) {
  351. dev_err(&i2c->dev, "No platform data found.\n");
  352. return -EINVAL;
  353. }
  354. max14577 = devm_kzalloc(&i2c->dev, sizeof(*max14577), GFP_KERNEL);
  355. if (!max14577)
  356. return -ENOMEM;
  357. i2c_set_clientdata(i2c, max14577);
  358. max14577->dev = &i2c->dev;
  359. max14577->i2c = i2c;
  360. max14577->irq = i2c->irq;
  361. max14577->regmap = devm_regmap_init_i2c(i2c,
  362. &max14577_muic_regmap_config);
  363. if (IS_ERR(max14577->regmap)) {
  364. ret = PTR_ERR(max14577->regmap);
  365. dev_err(max14577->dev, "Failed to allocate register map: %d\n",
  366. ret);
  367. return ret;
  368. }
  369. if (np) {
  370. const struct of_device_id *of_id;
  371. of_id = of_match_device(max14577_dt_match, &i2c->dev);
  372. if (of_id)
  373. max14577->dev_type =
  374. (enum maxim_device_type)of_id->data;
  375. } else {
  376. max14577->dev_type = id->driver_data;
  377. }
  378. max14577_print_dev_type(max14577);
  379. switch (max14577->dev_type) {
  380. case MAXIM_DEVICE_TYPE_MAX77836:
  381. irq_chip = &max77836_muic_irq_chip;
  382. mfd_devs = max77836_devs;
  383. mfd_devs_size = ARRAY_SIZE(max77836_devs);
  384. irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED;
  385. break;
  386. case MAXIM_DEVICE_TYPE_MAX14577:
  387. default:
  388. irq_chip = &max14577_irq_chip;
  389. mfd_devs = max14577_devs;
  390. mfd_devs_size = ARRAY_SIZE(max14577_devs);
  391. irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT;
  392. break;
  393. }
  394. ret = regmap_add_irq_chip(max14577->regmap, max14577->irq,
  395. irq_flags, 0, irq_chip,
  396. &max14577->irq_data);
  397. if (ret != 0) {
  398. dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
  399. max14577->irq, ret);
  400. return ret;
  401. }
  402. /* Max77836 specific initialization code (additional regmap) */
  403. if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836) {
  404. ret = max77836_init(max14577);
  405. if (ret < 0)
  406. goto err_max77836;
  407. }
  408. ret = mfd_add_devices(max14577->dev, -1, mfd_devs,
  409. mfd_devs_size, NULL, 0, NULL);
  410. if (ret < 0)
  411. goto err_mfd;
  412. device_init_wakeup(max14577->dev, 1);
  413. return 0;
  414. err_mfd:
  415. if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
  416. max77836_remove(max14577);
  417. err_max77836:
  418. regmap_del_irq_chip(max14577->irq, max14577->irq_data);
  419. return ret;
  420. }
  421. static int max14577_i2c_remove(struct i2c_client *i2c)
  422. {
  423. struct max14577 *max14577 = i2c_get_clientdata(i2c);
  424. mfd_remove_devices(max14577->dev);
  425. regmap_del_irq_chip(max14577->irq, max14577->irq_data);
  426. if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
  427. max77836_remove(max14577);
  428. return 0;
  429. }
  430. static const struct i2c_device_id max14577_i2c_id[] = {
  431. { "max14577", MAXIM_DEVICE_TYPE_MAX14577, },
  432. { "max77836", MAXIM_DEVICE_TYPE_MAX77836, },
  433. { }
  434. };
  435. MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
  436. #ifdef CONFIG_PM_SLEEP
  437. static int max14577_suspend(struct device *dev)
  438. {
  439. struct i2c_client *i2c = to_i2c_client(dev);
  440. struct max14577 *max14577 = i2c_get_clientdata(i2c);
  441. if (device_may_wakeup(dev))
  442. enable_irq_wake(max14577->irq);
  443. /*
  444. * MUIC IRQ must be disabled during suspend because if it happens
  445. * while suspended it will be handled before resuming I2C.
  446. *
  447. * When device is woken up from suspend (e.g. by ADC change),
  448. * an interrupt occurs before resuming I2C bus controller.
  449. * Interrupt handler tries to read registers but this read
  450. * will fail because I2C is still suspended.
  451. */
  452. disable_irq(max14577->irq);
  453. return 0;
  454. }
  455. static int max14577_resume(struct device *dev)
  456. {
  457. struct i2c_client *i2c = to_i2c_client(dev);
  458. struct max14577 *max14577 = i2c_get_clientdata(i2c);
  459. if (device_may_wakeup(dev))
  460. disable_irq_wake(max14577->irq);
  461. enable_irq(max14577->irq);
  462. return 0;
  463. }
  464. #endif /* CONFIG_PM_SLEEP */
  465. static SIMPLE_DEV_PM_OPS(max14577_pm, max14577_suspend, max14577_resume);
  466. static struct i2c_driver max14577_i2c_driver = {
  467. .driver = {
  468. .name = "max14577",
  469. .pm = &max14577_pm,
  470. .of_match_table = max14577_dt_match,
  471. },
  472. .probe = max14577_i2c_probe,
  473. .remove = max14577_i2c_remove,
  474. .id_table = max14577_i2c_id,
  475. };
  476. static int __init max14577_i2c_init(void)
  477. {
  478. BUILD_BUG_ON(ARRAY_SIZE(max14577_i2c_id) != MAXIM_DEVICE_TYPE_NUM);
  479. BUILD_BUG_ON(ARRAY_SIZE(max14577_dt_match) != MAXIM_DEVICE_TYPE_NUM);
  480. /* Valid charger current values must be provided for each chipset */
  481. BUILD_BUG_ON(ARRAY_SIZE(maxim_charger_currents) != MAXIM_DEVICE_TYPE_NUM);
  482. /* Check for valid values for charger */
  483. BUILD_BUG_ON(MAX14577_CHARGER_CURRENT_LIMIT_HIGH_START +
  484. MAX14577_CHARGER_CURRENT_LIMIT_HIGH_STEP * 0xf !=
  485. MAX14577_CHARGER_CURRENT_LIMIT_MAX);
  486. BUILD_BUG_ON(MAX14577_CHARGER_CURRENT_LIMIT_HIGH_STEP == 0);
  487. BUILD_BUG_ON(MAX77836_CHARGER_CURRENT_LIMIT_HIGH_START +
  488. MAX77836_CHARGER_CURRENT_LIMIT_HIGH_STEP * 0xf !=
  489. MAX77836_CHARGER_CURRENT_LIMIT_MAX);
  490. BUILD_BUG_ON(MAX77836_CHARGER_CURRENT_LIMIT_HIGH_STEP == 0);
  491. return i2c_add_driver(&max14577_i2c_driver);
  492. }
  493. module_init(max14577_i2c_init);
  494. static void __exit max14577_i2c_exit(void)
  495. {
  496. i2c_del_driver(&max14577_i2c_driver);
  497. }
  498. module_exit(max14577_i2c_exit);
  499. MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <krzk@kernel.org>");
  500. MODULE_DESCRIPTION("Maxim 14577/77836 multi-function core driver");
  501. MODULE_LICENSE("GPL");