lp3972.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  2. * Regulator driver for National Semiconductors LP3972 PMIC chip
  3. *
  4. * Based on lp3971.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/bug.h>
  12. #include <linux/err.h>
  13. #include <linux/i2c.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/regulator/driver.h>
  17. #include <linux/regulator/lp3972.h>
  18. #include <linux/slab.h>
  19. struct lp3972 {
  20. struct device *dev;
  21. struct mutex io_lock;
  22. struct i2c_client *i2c;
  23. };
  24. /* LP3972 Control Registers */
  25. #define LP3972_SCR_REG 0x07
  26. #define LP3972_OVER1_REG 0x10
  27. #define LP3972_OVSR1_REG 0x11
  28. #define LP3972_OVER2_REG 0x12
  29. #define LP3972_OVSR2_REG 0x13
  30. #define LP3972_VCC1_REG 0x20
  31. #define LP3972_ADTV1_REG 0x23
  32. #define LP3972_ADTV2_REG 0x24
  33. #define LP3972_AVRC_REG 0x25
  34. #define LP3972_CDTC1_REG 0x26
  35. #define LP3972_CDTC2_REG 0x27
  36. #define LP3972_SDTV1_REG 0x29
  37. #define LP3972_SDTV2_REG 0x2A
  38. #define LP3972_MDTV1_REG 0x32
  39. #define LP3972_MDTV2_REG 0x33
  40. #define LP3972_L2VCR_REG 0x39
  41. #define LP3972_L34VCR_REG 0x3A
  42. #define LP3972_SCR1_REG 0x80
  43. #define LP3972_SCR2_REG 0x81
  44. #define LP3972_OEN3_REG 0x82
  45. #define LP3972_OSR3_REG 0x83
  46. #define LP3972_LOER4_REG 0x84
  47. #define LP3972_B2TV_REG 0x85
  48. #define LP3972_B3TV_REG 0x86
  49. #define LP3972_B32RC_REG 0x87
  50. #define LP3972_ISRA_REG 0x88
  51. #define LP3972_BCCR_REG 0x89
  52. #define LP3972_II1RR_REG 0x8E
  53. #define LP3972_II2RR_REG 0x8F
  54. #define LP3972_SYS_CONTROL1_REG LP3972_SCR1_REG
  55. /* System control register 1 initial value,
  56. * bits 5, 6 and 7 are EPROM programmable */
  57. #define SYS_CONTROL1_INIT_VAL 0x02
  58. #define SYS_CONTROL1_INIT_MASK 0x1F
  59. #define LP3972_VOL_CHANGE_REG LP3972_VCC1_REG
  60. #define LP3972_VOL_CHANGE_FLAG_GO 0x01
  61. #define LP3972_VOL_CHANGE_FLAG_MASK 0x03
  62. /* LDO output enable mask */
  63. #define LP3972_OEN3_L1EN BIT(0)
  64. #define LP3972_OVER2_LDO2_EN BIT(2)
  65. #define LP3972_OVER2_LDO3_EN BIT(3)
  66. #define LP3972_OVER2_LDO4_EN BIT(4)
  67. #define LP3972_OVER1_S_EN BIT(2)
  68. static const unsigned int ldo1_voltage_map[] = {
  69. 1700000, 1725000, 1750000, 1775000, 1800000, 1825000, 1850000, 1875000,
  70. 1900000, 1925000, 1950000, 1975000, 2000000,
  71. };
  72. static const unsigned int ldo23_voltage_map[] = {
  73. 1800000, 1900000, 2000000, 2100000, 2200000, 2300000, 2400000, 2500000,
  74. 2600000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000, 3300000,
  75. };
  76. static const unsigned int ldo4_voltage_map[] = {
  77. 1000000, 1050000, 1100000, 1150000, 1200000, 1250000, 1300000, 1350000,
  78. 1400000, 1500000, 1800000, 1900000, 2500000, 2800000, 3000000, 3300000,
  79. };
  80. static const unsigned int ldo5_voltage_map[] = {
  81. 0, 0, 0, 0, 0, 850000, 875000, 900000,
  82. 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
  83. 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
  84. 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,
  85. };
  86. static const unsigned int buck1_voltage_map[] = {
  87. 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000,
  88. 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000,
  89. 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000, 1300000,
  90. 1325000, 1350000, 1375000, 1400000, 1425000, 1450000, 1475000, 1500000,
  91. };
  92. static const unsigned int buck23_voltage_map[] = {
  93. 0, 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000,
  94. 1150000, 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000,
  95. 1550000, 1600000, 1650000, 1700000, 1800000, 1900000, 2500000, 2800000,
  96. 3000000, 3300000,
  97. };
  98. static const int ldo_output_enable_mask[] = {
  99. LP3972_OEN3_L1EN,
  100. LP3972_OVER2_LDO2_EN,
  101. LP3972_OVER2_LDO3_EN,
  102. LP3972_OVER2_LDO4_EN,
  103. LP3972_OVER1_S_EN,
  104. };
  105. static const int ldo_output_enable_addr[] = {
  106. LP3972_OEN3_REG,
  107. LP3972_OVER2_REG,
  108. LP3972_OVER2_REG,
  109. LP3972_OVER2_REG,
  110. LP3972_OVER1_REG,
  111. };
  112. static const int ldo_vol_ctl_addr[] = {
  113. LP3972_MDTV1_REG,
  114. LP3972_L2VCR_REG,
  115. LP3972_L34VCR_REG,
  116. LP3972_L34VCR_REG,
  117. LP3972_SDTV1_REG,
  118. };
  119. static const int buck_vol_enable_addr[] = {
  120. LP3972_OVER1_REG,
  121. LP3972_OEN3_REG,
  122. LP3972_OEN3_REG,
  123. };
  124. static const int buck_base_addr[] = {
  125. LP3972_ADTV1_REG,
  126. LP3972_B2TV_REG,
  127. LP3972_B3TV_REG,
  128. };
  129. #define LP3972_LDO_OUTPUT_ENABLE_MASK(x) (ldo_output_enable_mask[x])
  130. #define LP3972_LDO_OUTPUT_ENABLE_REG(x) (ldo_output_enable_addr[x])
  131. /* LDO voltage control registers shift:
  132. LP3972_LDO1 -> 0, LP3972_LDO2 -> 4
  133. LP3972_LDO3 -> 0, LP3972_LDO4 -> 4
  134. LP3972_LDO5 -> 0
  135. */
  136. #define LP3972_LDO_VOL_CONTR_SHIFT(x) (((x) & 1) << 2)
  137. #define LP3972_LDO_VOL_CONTR_REG(x) (ldo_vol_ctl_addr[x])
  138. #define LP3972_LDO_VOL_CHANGE_SHIFT(x) ((x) ? 4 : 6)
  139. #define LP3972_LDO_VOL_MASK(x) (((x) % 4) ? 0x0f : 0x1f)
  140. #define LP3972_LDO_VOL_MIN_IDX(x) (((x) == 4) ? 0x05 : 0x00)
  141. #define LP3972_LDO_VOL_MAX_IDX(x) ((x) ? (((x) == 4) ? 0x1f : 0x0f) : 0x0c)
  142. #define LP3972_BUCK_VOL_ENABLE_REG(x) (buck_vol_enable_addr[x])
  143. #define LP3972_BUCK_VOL1_REG(x) (buck_base_addr[x])
  144. #define LP3972_BUCK_VOL_MASK 0x1f
  145. static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count,
  146. u16 *dest)
  147. {
  148. int ret;
  149. if (count != 1)
  150. return -EIO;
  151. ret = i2c_smbus_read_byte_data(i2c, reg);
  152. if (ret < 0)
  153. return ret;
  154. *dest = ret;
  155. return 0;
  156. }
  157. static int lp3972_i2c_write(struct i2c_client *i2c, char reg, int count,
  158. const u16 *src)
  159. {
  160. if (count != 1)
  161. return -EIO;
  162. return i2c_smbus_write_byte_data(i2c, reg, *src);
  163. }
  164. static u8 lp3972_reg_read(struct lp3972 *lp3972, u8 reg)
  165. {
  166. u16 val = 0;
  167. mutex_lock(&lp3972->io_lock);
  168. lp3972_i2c_read(lp3972->i2c, reg, 1, &val);
  169. dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg,
  170. (unsigned)val & 0xff);
  171. mutex_unlock(&lp3972->io_lock);
  172. return val & 0xff;
  173. }
  174. static int lp3972_set_bits(struct lp3972 *lp3972, u8 reg, u16 mask, u16 val)
  175. {
  176. u16 tmp;
  177. int ret;
  178. mutex_lock(&lp3972->io_lock);
  179. ret = lp3972_i2c_read(lp3972->i2c, reg, 1, &tmp);
  180. if (ret == 0) {
  181. tmp = (tmp & ~mask) | val;
  182. ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp);
  183. dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg,
  184. (unsigned)val & 0xff);
  185. }
  186. mutex_unlock(&lp3972->io_lock);
  187. return ret;
  188. }
  189. static int lp3972_ldo_is_enabled(struct regulator_dev *dev)
  190. {
  191. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  192. int ldo = rdev_get_id(dev) - LP3972_LDO1;
  193. u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
  194. u16 val;
  195. val = lp3972_reg_read(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo));
  196. return !!(val & mask);
  197. }
  198. static int lp3972_ldo_enable(struct regulator_dev *dev)
  199. {
  200. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  201. int ldo = rdev_get_id(dev) - LP3972_LDO1;
  202. u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
  203. return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo),
  204. mask, mask);
  205. }
  206. static int lp3972_ldo_disable(struct regulator_dev *dev)
  207. {
  208. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  209. int ldo = rdev_get_id(dev) - LP3972_LDO1;
  210. u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
  211. return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo),
  212. mask, 0);
  213. }
  214. static int lp3972_ldo_get_voltage_sel(struct regulator_dev *dev)
  215. {
  216. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  217. int ldo = rdev_get_id(dev) - LP3972_LDO1;
  218. u16 mask = LP3972_LDO_VOL_MASK(ldo);
  219. u16 val, reg;
  220. reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo));
  221. val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask;
  222. return val;
  223. }
  224. static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev,
  225. unsigned int selector)
  226. {
  227. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  228. int ldo = rdev_get_id(dev) - LP3972_LDO1;
  229. int shift, ret;
  230. shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo);
  231. ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo),
  232. LP3972_LDO_VOL_MASK(ldo) << shift, selector << shift);
  233. if (ret)
  234. return ret;
  235. /*
  236. * LDO1 and LDO5 support voltage control by either target voltage1
  237. * or target voltage2 register.
  238. * We use target voltage1 register for LDO1 and LDO5 in this driver.
  239. * We need to update voltage change control register(0x20) to enable
  240. * LDO1 and LDO5 to change to their programmed target values.
  241. */
  242. switch (ldo) {
  243. case LP3972_LDO1:
  244. case LP3972_LDO5:
  245. shift = LP3972_LDO_VOL_CHANGE_SHIFT(ldo);
  246. ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
  247. LP3972_VOL_CHANGE_FLAG_MASK << shift,
  248. LP3972_VOL_CHANGE_FLAG_GO << shift);
  249. if (ret)
  250. return ret;
  251. ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
  252. LP3972_VOL_CHANGE_FLAG_MASK << shift, 0);
  253. break;
  254. }
  255. return ret;
  256. }
  257. static struct regulator_ops lp3972_ldo_ops = {
  258. .list_voltage = regulator_list_voltage_table,
  259. .map_voltage = regulator_map_voltage_ascend,
  260. .is_enabled = lp3972_ldo_is_enabled,
  261. .enable = lp3972_ldo_enable,
  262. .disable = lp3972_ldo_disable,
  263. .get_voltage_sel = lp3972_ldo_get_voltage_sel,
  264. .set_voltage_sel = lp3972_ldo_set_voltage_sel,
  265. };
  266. static int lp3972_dcdc_is_enabled(struct regulator_dev *dev)
  267. {
  268. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  269. int buck = rdev_get_id(dev) - LP3972_DCDC1;
  270. u16 mask = 1 << (buck * 2);
  271. u16 val;
  272. val = lp3972_reg_read(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck));
  273. return !!(val & mask);
  274. }
  275. static int lp3972_dcdc_enable(struct regulator_dev *dev)
  276. {
  277. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  278. int buck = rdev_get_id(dev) - LP3972_DCDC1;
  279. u16 mask = 1 << (buck * 2);
  280. u16 val;
  281. val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck),
  282. mask, mask);
  283. return val;
  284. }
  285. static int lp3972_dcdc_disable(struct regulator_dev *dev)
  286. {
  287. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  288. int buck = rdev_get_id(dev) - LP3972_DCDC1;
  289. u16 mask = 1 << (buck * 2);
  290. u16 val;
  291. val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck),
  292. mask, 0);
  293. return val;
  294. }
  295. static int lp3972_dcdc_get_voltage_sel(struct regulator_dev *dev)
  296. {
  297. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  298. int buck = rdev_get_id(dev) - LP3972_DCDC1;
  299. u16 reg;
  300. reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck));
  301. reg &= LP3972_BUCK_VOL_MASK;
  302. return reg;
  303. }
  304. static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev,
  305. unsigned int selector)
  306. {
  307. struct lp3972 *lp3972 = rdev_get_drvdata(dev);
  308. int buck = rdev_get_id(dev) - LP3972_DCDC1;
  309. int ret;
  310. ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck),
  311. LP3972_BUCK_VOL_MASK, selector);
  312. if (ret)
  313. return ret;
  314. if (buck != 0)
  315. return ret;
  316. ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
  317. LP3972_VOL_CHANGE_FLAG_MASK, LP3972_VOL_CHANGE_FLAG_GO);
  318. if (ret)
  319. return ret;
  320. return lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
  321. LP3972_VOL_CHANGE_FLAG_MASK, 0);
  322. }
  323. static struct regulator_ops lp3972_dcdc_ops = {
  324. .list_voltage = regulator_list_voltage_table,
  325. .map_voltage = regulator_map_voltage_ascend,
  326. .is_enabled = lp3972_dcdc_is_enabled,
  327. .enable = lp3972_dcdc_enable,
  328. .disable = lp3972_dcdc_disable,
  329. .get_voltage_sel = lp3972_dcdc_get_voltage_sel,
  330. .set_voltage_sel = lp3972_dcdc_set_voltage_sel,
  331. };
  332. static const struct regulator_desc regulators[] = {
  333. {
  334. .name = "LDO1",
  335. .id = LP3972_LDO1,
  336. .ops = &lp3972_ldo_ops,
  337. .n_voltages = ARRAY_SIZE(ldo1_voltage_map),
  338. .volt_table = ldo1_voltage_map,
  339. .type = REGULATOR_VOLTAGE,
  340. .owner = THIS_MODULE,
  341. },
  342. {
  343. .name = "LDO2",
  344. .id = LP3972_LDO2,
  345. .ops = &lp3972_ldo_ops,
  346. .n_voltages = ARRAY_SIZE(ldo23_voltage_map),
  347. .volt_table = ldo23_voltage_map,
  348. .type = REGULATOR_VOLTAGE,
  349. .owner = THIS_MODULE,
  350. },
  351. {
  352. .name = "LDO3",
  353. .id = LP3972_LDO3,
  354. .ops = &lp3972_ldo_ops,
  355. .n_voltages = ARRAY_SIZE(ldo23_voltage_map),
  356. .volt_table = ldo23_voltage_map,
  357. .type = REGULATOR_VOLTAGE,
  358. .owner = THIS_MODULE,
  359. },
  360. {
  361. .name = "LDO4",
  362. .id = LP3972_LDO4,
  363. .ops = &lp3972_ldo_ops,
  364. .n_voltages = ARRAY_SIZE(ldo4_voltage_map),
  365. .volt_table = ldo4_voltage_map,
  366. .type = REGULATOR_VOLTAGE,
  367. .owner = THIS_MODULE,
  368. },
  369. {
  370. .name = "LDO5",
  371. .id = LP3972_LDO5,
  372. .ops = &lp3972_ldo_ops,
  373. .n_voltages = ARRAY_SIZE(ldo5_voltage_map),
  374. .volt_table = ldo5_voltage_map,
  375. .type = REGULATOR_VOLTAGE,
  376. .owner = THIS_MODULE,
  377. },
  378. {
  379. .name = "DCDC1",
  380. .id = LP3972_DCDC1,
  381. .ops = &lp3972_dcdc_ops,
  382. .n_voltages = ARRAY_SIZE(buck1_voltage_map),
  383. .volt_table = buck1_voltage_map,
  384. .type = REGULATOR_VOLTAGE,
  385. .owner = THIS_MODULE,
  386. },
  387. {
  388. .name = "DCDC2",
  389. .id = LP3972_DCDC2,
  390. .ops = &lp3972_dcdc_ops,
  391. .n_voltages = ARRAY_SIZE(buck23_voltage_map),
  392. .volt_table = buck23_voltage_map,
  393. .type = REGULATOR_VOLTAGE,
  394. .owner = THIS_MODULE,
  395. },
  396. {
  397. .name = "DCDC3",
  398. .id = LP3972_DCDC3,
  399. .ops = &lp3972_dcdc_ops,
  400. .n_voltages = ARRAY_SIZE(buck23_voltage_map),
  401. .volt_table = buck23_voltage_map,
  402. .type = REGULATOR_VOLTAGE,
  403. .owner = THIS_MODULE,
  404. },
  405. };
  406. static int setup_regulators(struct lp3972 *lp3972,
  407. struct lp3972_platform_data *pdata)
  408. {
  409. int i, err;
  410. /* Instantiate the regulators */
  411. for (i = 0; i < pdata->num_regulators; i++) {
  412. struct lp3972_regulator_subdev *reg = &pdata->regulators[i];
  413. struct regulator_config config = { };
  414. struct regulator_dev *rdev;
  415. config.dev = lp3972->dev;
  416. config.init_data = reg->initdata;
  417. config.driver_data = lp3972;
  418. rdev = devm_regulator_register(lp3972->dev,
  419. &regulators[reg->id], &config);
  420. if (IS_ERR(rdev)) {
  421. err = PTR_ERR(rdev);
  422. dev_err(lp3972->dev, "regulator init failed: %d\n",
  423. err);
  424. return err;
  425. }
  426. }
  427. return 0;
  428. }
  429. static int lp3972_i2c_probe(struct i2c_client *i2c,
  430. const struct i2c_device_id *id)
  431. {
  432. struct lp3972 *lp3972;
  433. struct lp3972_platform_data *pdata = dev_get_platdata(&i2c->dev);
  434. int ret;
  435. u16 val;
  436. if (!pdata) {
  437. dev_dbg(&i2c->dev, "No platform init data supplied\n");
  438. return -ENODEV;
  439. }
  440. lp3972 = devm_kzalloc(&i2c->dev, sizeof(struct lp3972), GFP_KERNEL);
  441. if (!lp3972)
  442. return -ENOMEM;
  443. lp3972->i2c = i2c;
  444. lp3972->dev = &i2c->dev;
  445. mutex_init(&lp3972->io_lock);
  446. /* Detect LP3972 */
  447. ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val);
  448. if (ret == 0 &&
  449. (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL) {
  450. ret = -ENODEV;
  451. dev_err(&i2c->dev, "chip reported: val = 0x%x\n", val);
  452. }
  453. if (ret < 0) {
  454. dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret);
  455. return ret;
  456. }
  457. ret = setup_regulators(lp3972, pdata);
  458. if (ret < 0)
  459. return ret;
  460. i2c_set_clientdata(i2c, lp3972);
  461. return 0;
  462. }
  463. static const struct i2c_device_id lp3972_i2c_id[] = {
  464. { "lp3972", 0 },
  465. { }
  466. };
  467. MODULE_DEVICE_TABLE(i2c, lp3972_i2c_id);
  468. static struct i2c_driver lp3972_i2c_driver = {
  469. .driver = {
  470. .name = "lp3972",
  471. },
  472. .probe = lp3972_i2c_probe,
  473. .id_table = lp3972_i2c_id,
  474. };
  475. static int __init lp3972_module_init(void)
  476. {
  477. return i2c_add_driver(&lp3972_i2c_driver);
  478. }
  479. subsys_initcall(lp3972_module_init);
  480. static void __exit lp3972_module_exit(void)
  481. {
  482. i2c_del_driver(&lp3972_i2c_driver);
  483. }
  484. module_exit(lp3972_module_exit);
  485. MODULE_LICENSE("GPL");
  486. MODULE_AUTHOR("Axel Lin <[email protected]>");
  487. MODULE_DESCRIPTION("LP3972 PMIC driver");