mcp16502.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // MCP16502 PMIC driver
  4. //
  5. // Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries
  6. //
  7. // Author: Andrei Stefanescu <andrei.stefanescu@microchip.com>
  8. //
  9. // Inspired from tps65086-regulator.c
  10. #include <linux/i2c.h>
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/of.h>
  15. #include <linux/regmap.h>
  16. #include <linux/regulator/driver.h>
  17. #include <linux/suspend.h>
  18. #include <linux/gpio/consumer.h>
  19. #define VDD_LOW_SEL 0x0D
  20. #define VDD_HIGH_SEL 0x3F
  21. #define MCP16502_FLT BIT(7)
  22. #define MCP16502_DVSR GENMASK(3, 2)
  23. #define MCP16502_ENS BIT(0)
  24. /*
  25. * The PMIC has four sets of registers corresponding to four power modes:
  26. * Performance, Active, Low-power, Hibernate.
  27. *
  28. * Registers:
  29. * Each regulator has a register for each power mode. To access a register
  30. * for a specific regulator and mode BASE_* and OFFSET_* need to be added.
  31. *
  32. * Operating modes:
  33. * In order for the PMIC to transition to operating modes it has to be
  34. * controlled via GPIO lines called LPM and HPM.
  35. *
  36. * The registers are fully configurable such that you can put all regulators in
  37. * a low-power state while the PMIC is in Active mode. They are supposed to be
  38. * configured at startup and then simply transition to/from a global low-power
  39. * state by setting the GPIO lpm pin high/low.
  40. *
  41. * This driver keeps the PMIC in Active mode, Low-power state is set for the
  42. * regulators by enabling/disabling operating mode (FPWM or Auto PFM).
  43. *
  44. * The PMIC's Low-power and Hibernate modes are used during standby/suspend.
  45. * To enter standby/suspend the PMIC will go to Low-power mode. From there, it
  46. * will transition to Hibernate when the PWRHLD line is set to low by the MPU.
  47. */
  48. /*
  49. * This function is useful for iterating over all regulators and accessing their
  50. * registers in a generic way or accessing a regulator device by its id.
  51. */
  52. #define MCP16502_REG_BASE(i, r) ((((i) + 1) << 4) + MCP16502_REG_##r)
  53. #define MCP16502_STAT_BASE(i) ((i) + 5)
  54. #define MCP16502_OPMODE_ACTIVE REGULATOR_MODE_NORMAL
  55. #define MCP16502_OPMODE_LPM REGULATOR_MODE_IDLE
  56. #define MCP16502_OPMODE_HIB REGULATOR_MODE_STANDBY
  57. #define MCP16502_MODE_AUTO_PFM 0
  58. #define MCP16502_MODE_FPWM BIT(6)
  59. #define MCP16502_VSEL 0x3F
  60. #define MCP16502_EN BIT(7)
  61. #define MCP16502_MODE BIT(6)
  62. #define MCP16502_MIN_REG 0x0
  63. #define MCP16502_MAX_REG 0x65
  64. /**
  65. * enum mcp16502_reg - MCP16502 regulators's registers
  66. * @MCP16502_REG_A: active state register
  67. * @MCP16502_REG_LPM: low power mode state register
  68. * @MCP16502_REG_HIB: hibernate state register
  69. * @MCP16502_REG_HPM: high-performance mode register
  70. * @MCP16502_REG_SEQ: startup sequence register
  71. * @MCP16502_REG_CFG: configuration register
  72. */
  73. enum mcp16502_reg {
  74. MCP16502_REG_A,
  75. MCP16502_REG_LPM,
  76. MCP16502_REG_HIB,
  77. MCP16502_REG_HPM,
  78. MCP16502_REG_SEQ,
  79. MCP16502_REG_CFG,
  80. };
  81. /* Ramp delay (uV/us) for buck1, ldo1, ldo2. */
  82. static const unsigned int mcp16502_ramp_b1l12[] = {
  83. 6250, 3125, 2083, 1563
  84. };
  85. /* Ramp delay (uV/us) for buck2, buck3, buck4. */
  86. static const unsigned int mcp16502_ramp_b234[] = {
  87. 3125, 1563, 1042, 781
  88. };
  89. static unsigned int mcp16502_of_map_mode(unsigned int mode)
  90. {
  91. if (mode == REGULATOR_MODE_NORMAL || mode == REGULATOR_MODE_IDLE)
  92. return mode;
  93. return REGULATOR_MODE_INVALID;
  94. }
  95. #define MCP16502_REGULATOR(_name, _id, _sn, _ranges, _ops, _ramp_table) \
  96. [_id] = { \
  97. .name = _name, \
  98. .supply_name = #_sn, \
  99. .regulators_node = "regulators", \
  100. .id = _id, \
  101. .ops = &(_ops), \
  102. .type = REGULATOR_VOLTAGE, \
  103. .owner = THIS_MODULE, \
  104. .n_voltages = MCP16502_VSEL + 1, \
  105. .linear_ranges = _ranges, \
  106. .linear_min_sel = VDD_LOW_SEL, \
  107. .n_linear_ranges = ARRAY_SIZE(_ranges), \
  108. .of_match = _name, \
  109. .of_map_mode = mcp16502_of_map_mode, \
  110. .vsel_reg = (((_id) + 1) << 4), \
  111. .vsel_mask = MCP16502_VSEL, \
  112. .enable_reg = (((_id) + 1) << 4), \
  113. .enable_mask = MCP16502_EN, \
  114. .ramp_reg = MCP16502_REG_BASE(_id, CFG), \
  115. .ramp_mask = MCP16502_DVSR, \
  116. .ramp_delay_table = _ramp_table, \
  117. .n_ramp_values = ARRAY_SIZE(_ramp_table), \
  118. }
  119. enum {
  120. BUCK1 = 0,
  121. BUCK2,
  122. BUCK3,
  123. BUCK4,
  124. LDO1,
  125. LDO2,
  126. NUM_REGULATORS
  127. };
  128. /*
  129. * struct mcp16502 - PMIC representation
  130. * @lpm: LPM GPIO descriptor
  131. */
  132. struct mcp16502 {
  133. struct gpio_desc *lpm;
  134. };
  135. /*
  136. * mcp16502_gpio_set_mode() - set the GPIO corresponding value
  137. *
  138. * Used to prepare transitioning into hibernate or resuming from it.
  139. */
  140. static void mcp16502_gpio_set_mode(struct mcp16502 *mcp, int mode)
  141. {
  142. switch (mode) {
  143. case MCP16502_OPMODE_ACTIVE:
  144. gpiod_set_value(mcp->lpm, 0);
  145. break;
  146. case MCP16502_OPMODE_LPM:
  147. case MCP16502_OPMODE_HIB:
  148. gpiod_set_value(mcp->lpm, 1);
  149. break;
  150. default:
  151. pr_err("%s: %d invalid\n", __func__, mode);
  152. }
  153. }
  154. /*
  155. * mcp16502_get_reg() - get the PMIC's state configuration register for opmode
  156. *
  157. * @rdev: the regulator whose register we are searching
  158. * @opmode: the PMIC's operating mode ACTIVE, Low-power, Hibernate
  159. */
  160. static int mcp16502_get_state_reg(struct regulator_dev *rdev, int opmode)
  161. {
  162. switch (opmode) {
  163. case MCP16502_OPMODE_ACTIVE:
  164. return MCP16502_REG_BASE(rdev_get_id(rdev), A);
  165. case MCP16502_OPMODE_LPM:
  166. return MCP16502_REG_BASE(rdev_get_id(rdev), LPM);
  167. case MCP16502_OPMODE_HIB:
  168. return MCP16502_REG_BASE(rdev_get_id(rdev), HIB);
  169. default:
  170. return -EINVAL;
  171. }
  172. }
  173. /*
  174. * mcp16502_get_mode() - return the current operating mode of a regulator
  175. *
  176. * Note: all functions that are not part of entering/exiting standby/suspend
  177. * use the Active mode registers.
  178. *
  179. * Note: this is different from the PMIC's operatig mode, it is the
  180. * MODE bit from the regulator's register.
  181. */
  182. static unsigned int mcp16502_get_mode(struct regulator_dev *rdev)
  183. {
  184. unsigned int val;
  185. int ret, reg;
  186. reg = mcp16502_get_state_reg(rdev, MCP16502_OPMODE_ACTIVE);
  187. if (reg < 0)
  188. return reg;
  189. ret = regmap_read(rdev->regmap, reg, &val);
  190. if (ret)
  191. return ret;
  192. switch (val & MCP16502_MODE) {
  193. case MCP16502_MODE_FPWM:
  194. return REGULATOR_MODE_NORMAL;
  195. case MCP16502_MODE_AUTO_PFM:
  196. return REGULATOR_MODE_IDLE;
  197. default:
  198. return REGULATOR_MODE_INVALID;
  199. }
  200. }
  201. /*
  202. * _mcp16502_set_mode() - helper for set_mode and set_suspend_mode
  203. *
  204. * @rdev: the regulator for which we are setting the mode
  205. * @mode: the regulator's mode (the one from MODE bit)
  206. * @opmode: the PMIC's operating mode: Active/Low-power/Hibernate
  207. */
  208. static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode,
  209. unsigned int op_mode)
  210. {
  211. int val;
  212. int reg;
  213. reg = mcp16502_get_state_reg(rdev, op_mode);
  214. if (reg < 0)
  215. return reg;
  216. switch (mode) {
  217. case REGULATOR_MODE_NORMAL:
  218. val = MCP16502_MODE_FPWM;
  219. break;
  220. case REGULATOR_MODE_IDLE:
  221. val = MCP16502_MODE_AUTO_PFM;
  222. break;
  223. default:
  224. return -EINVAL;
  225. }
  226. reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val);
  227. return reg;
  228. }
  229. /*
  230. * mcp16502_set_mode() - regulator_ops set_mode
  231. */
  232. static int mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode)
  233. {
  234. return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_ACTIVE);
  235. }
  236. /*
  237. * mcp16502_get_status() - regulator_ops get_status
  238. */
  239. static int mcp16502_get_status(struct regulator_dev *rdev)
  240. {
  241. int ret;
  242. unsigned int val;
  243. ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
  244. &val);
  245. if (ret)
  246. return ret;
  247. if (val & MCP16502_FLT)
  248. return REGULATOR_STATUS_ERROR;
  249. else if (val & MCP16502_ENS)
  250. return REGULATOR_STATUS_ON;
  251. else if (!(val & MCP16502_ENS))
  252. return REGULATOR_STATUS_OFF;
  253. return REGULATOR_STATUS_UNDEFINED;
  254. }
  255. static int mcp16502_set_voltage_time_sel(struct regulator_dev *rdev,
  256. unsigned int old_sel,
  257. unsigned int new_sel)
  258. {
  259. static const u8 us_ramp[] = { 8, 16, 24, 32 };
  260. int id = rdev_get_id(rdev);
  261. unsigned int uV_delta, val;
  262. int ret;
  263. ret = regmap_read(rdev->regmap, MCP16502_REG_BASE(id, CFG), &val);
  264. if (ret)
  265. return ret;
  266. val = (val & MCP16502_DVSR) >> 2;
  267. uV_delta = abs(new_sel * rdev->desc->linear_ranges->step -
  268. old_sel * rdev->desc->linear_ranges->step);
  269. switch (id) {
  270. case BUCK1:
  271. case LDO1:
  272. case LDO2:
  273. ret = DIV_ROUND_CLOSEST(uV_delta * us_ramp[val],
  274. mcp16502_ramp_b1l12[val]);
  275. break;
  276. case BUCK2:
  277. case BUCK3:
  278. case BUCK4:
  279. ret = DIV_ROUND_CLOSEST(uV_delta * us_ramp[val],
  280. mcp16502_ramp_b234[val]);
  281. break;
  282. default:
  283. return -EINVAL;
  284. }
  285. return ret;
  286. }
  287. #ifdef CONFIG_SUSPEND
  288. /*
  289. * mcp16502_suspend_get_target_reg() - get the reg of the target suspend PMIC
  290. * mode
  291. */
  292. static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev)
  293. {
  294. switch (pm_suspend_target_state) {
  295. case PM_SUSPEND_STANDBY:
  296. return mcp16502_get_state_reg(rdev, MCP16502_OPMODE_LPM);
  297. case PM_SUSPEND_ON:
  298. case PM_SUSPEND_MEM:
  299. return mcp16502_get_state_reg(rdev, MCP16502_OPMODE_HIB);
  300. default:
  301. dev_err(&rdev->dev, "invalid suspend target: %d\n",
  302. pm_suspend_target_state);
  303. }
  304. return -EINVAL;
  305. }
  306. /*
  307. * mcp16502_set_suspend_voltage() - regulator_ops set_suspend_voltage
  308. */
  309. static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV)
  310. {
  311. int sel = regulator_map_voltage_linear_range(rdev, uV, uV);
  312. int reg = mcp16502_suspend_get_target_reg(rdev);
  313. if (sel < 0)
  314. return sel;
  315. if (reg < 0)
  316. return reg;
  317. return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel);
  318. }
  319. /*
  320. * mcp16502_set_suspend_mode() - regulator_ops set_suspend_mode
  321. */
  322. static int mcp16502_set_suspend_mode(struct regulator_dev *rdev,
  323. unsigned int mode)
  324. {
  325. switch (pm_suspend_target_state) {
  326. case PM_SUSPEND_STANDBY:
  327. return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_LPM);
  328. case PM_SUSPEND_ON:
  329. case PM_SUSPEND_MEM:
  330. return _mcp16502_set_mode(rdev, mode, MCP16502_OPMODE_HIB);
  331. default:
  332. dev_err(&rdev->dev, "invalid suspend target: %d\n",
  333. pm_suspend_target_state);
  334. }
  335. return -EINVAL;
  336. }
  337. /*
  338. * mcp16502_set_suspend_enable() - regulator_ops set_suspend_enable
  339. */
  340. static int mcp16502_set_suspend_enable(struct regulator_dev *rdev)
  341. {
  342. int reg = mcp16502_suspend_get_target_reg(rdev);
  343. if (reg < 0)
  344. return reg;
  345. return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN);
  346. }
  347. /*
  348. * mcp16502_set_suspend_disable() - regulator_ops set_suspend_disable
  349. */
  350. static int mcp16502_set_suspend_disable(struct regulator_dev *rdev)
  351. {
  352. int reg = mcp16502_suspend_get_target_reg(rdev);
  353. if (reg < 0)
  354. return reg;
  355. return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0);
  356. }
  357. #endif /* CONFIG_SUSPEND */
  358. static const struct regulator_ops mcp16502_buck_ops = {
  359. .list_voltage = regulator_list_voltage_linear_range,
  360. .map_voltage = regulator_map_voltage_linear_range,
  361. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  362. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  363. .enable = regulator_enable_regmap,
  364. .disable = regulator_disable_regmap,
  365. .is_enabled = regulator_is_enabled_regmap,
  366. .get_status = mcp16502_get_status,
  367. .set_voltage_time_sel = mcp16502_set_voltage_time_sel,
  368. .set_ramp_delay = regulator_set_ramp_delay_regmap,
  369. .set_mode = mcp16502_set_mode,
  370. .get_mode = mcp16502_get_mode,
  371. #ifdef CONFIG_SUSPEND
  372. .set_suspend_voltage = mcp16502_set_suspend_voltage,
  373. .set_suspend_mode = mcp16502_set_suspend_mode,
  374. .set_suspend_enable = mcp16502_set_suspend_enable,
  375. .set_suspend_disable = mcp16502_set_suspend_disable,
  376. #endif /* CONFIG_SUSPEND */
  377. };
  378. /*
  379. * LDOs cannot change operating modes.
  380. */
  381. static const struct regulator_ops mcp16502_ldo_ops = {
  382. .list_voltage = regulator_list_voltage_linear_range,
  383. .map_voltage = regulator_map_voltage_linear_range,
  384. .get_voltage_sel = regulator_get_voltage_sel_regmap,
  385. .set_voltage_sel = regulator_set_voltage_sel_regmap,
  386. .enable = regulator_enable_regmap,
  387. .disable = regulator_disable_regmap,
  388. .is_enabled = regulator_is_enabled_regmap,
  389. .get_status = mcp16502_get_status,
  390. .set_voltage_time_sel = mcp16502_set_voltage_time_sel,
  391. .set_ramp_delay = regulator_set_ramp_delay_regmap,
  392. #ifdef CONFIG_SUSPEND
  393. .set_suspend_voltage = mcp16502_set_suspend_voltage,
  394. .set_suspend_enable = mcp16502_set_suspend_enable,
  395. .set_suspend_disable = mcp16502_set_suspend_disable,
  396. #endif /* CONFIG_SUSPEND */
  397. };
  398. static const struct of_device_id mcp16502_ids[] = {
  399. { .compatible = "microchip,mcp16502", },
  400. {}
  401. };
  402. MODULE_DEVICE_TABLE(of, mcp16502_ids);
  403. static const struct linear_range b1l12_ranges[] = {
  404. REGULATOR_LINEAR_RANGE(1200000, VDD_LOW_SEL, VDD_HIGH_SEL, 50000),
  405. };
  406. static const struct linear_range b234_ranges[] = {
  407. REGULATOR_LINEAR_RANGE(600000, VDD_LOW_SEL, VDD_HIGH_SEL, 25000),
  408. };
  409. static const struct regulator_desc mcp16502_desc[] = {
  410. /* MCP16502_REGULATOR(_name, _id, _sn, _ranges, _ops, _ramp_table) */
  411. MCP16502_REGULATOR("VDD_IO", BUCK1, pvin1, b1l12_ranges, mcp16502_buck_ops,
  412. mcp16502_ramp_b1l12),
  413. MCP16502_REGULATOR("VDD_DDR", BUCK2, pvin2, b234_ranges, mcp16502_buck_ops,
  414. mcp16502_ramp_b234),
  415. MCP16502_REGULATOR("VDD_CORE", BUCK3, pvin3, b234_ranges, mcp16502_buck_ops,
  416. mcp16502_ramp_b234),
  417. MCP16502_REGULATOR("VDD_OTHER", BUCK4, pvin4, b234_ranges, mcp16502_buck_ops,
  418. mcp16502_ramp_b234),
  419. MCP16502_REGULATOR("LDO1", LDO1, lvin, b1l12_ranges, mcp16502_ldo_ops,
  420. mcp16502_ramp_b1l12),
  421. MCP16502_REGULATOR("LDO2", LDO2, lvin, b1l12_ranges, mcp16502_ldo_ops,
  422. mcp16502_ramp_b1l12)
  423. };
  424. static const struct regmap_range mcp16502_ranges[] = {
  425. regmap_reg_range(MCP16502_MIN_REG, MCP16502_MAX_REG)
  426. };
  427. static const struct regmap_access_table mcp16502_yes_reg_table = {
  428. .yes_ranges = mcp16502_ranges,
  429. .n_yes_ranges = ARRAY_SIZE(mcp16502_ranges),
  430. };
  431. static const struct regmap_config mcp16502_regmap_config = {
  432. .reg_bits = 8,
  433. .val_bits = 8,
  434. .max_register = MCP16502_MAX_REG,
  435. .cache_type = REGCACHE_NONE,
  436. .rd_table = &mcp16502_yes_reg_table,
  437. .wr_table = &mcp16502_yes_reg_table,
  438. };
  439. static int mcp16502_probe(struct i2c_client *client)
  440. {
  441. struct regulator_config config = { };
  442. struct regulator_dev *rdev;
  443. struct device *dev;
  444. struct mcp16502 *mcp;
  445. struct regmap *rmap;
  446. int i, ret;
  447. dev = &client->dev;
  448. config.dev = dev;
  449. mcp = devm_kzalloc(dev, sizeof(*mcp), GFP_KERNEL);
  450. if (!mcp)
  451. return -ENOMEM;
  452. rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
  453. if (IS_ERR(rmap)) {
  454. ret = PTR_ERR(rmap);
  455. dev_err(dev, "regmap init failed: %d\n", ret);
  456. return ret;
  457. }
  458. i2c_set_clientdata(client, mcp);
  459. config.regmap = rmap;
  460. config.driver_data = mcp;
  461. mcp->lpm = devm_gpiod_get_optional(dev, "lpm", GPIOD_OUT_LOW);
  462. if (IS_ERR(mcp->lpm)) {
  463. dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm));
  464. return PTR_ERR(mcp->lpm);
  465. }
  466. for (i = 0; i < NUM_REGULATORS; i++) {
  467. rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
  468. if (IS_ERR(rdev)) {
  469. dev_err(dev,
  470. "failed to register %s regulator %ld\n",
  471. mcp16502_desc[i].name, PTR_ERR(rdev));
  472. return PTR_ERR(rdev);
  473. }
  474. }
  475. mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
  476. return 0;
  477. }
  478. #ifdef CONFIG_PM_SLEEP
  479. static int mcp16502_suspend_noirq(struct device *dev)
  480. {
  481. struct i2c_client *client = to_i2c_client(dev);
  482. struct mcp16502 *mcp = i2c_get_clientdata(client);
  483. mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_LPM);
  484. return 0;
  485. }
  486. static int mcp16502_resume_noirq(struct device *dev)
  487. {
  488. struct i2c_client *client = to_i2c_client(dev);
  489. struct mcp16502 *mcp = i2c_get_clientdata(client);
  490. mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
  491. return 0;
  492. }
  493. #endif
  494. #ifdef CONFIG_PM
  495. static const struct dev_pm_ops mcp16502_pm_ops = {
  496. SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mcp16502_suspend_noirq,
  497. mcp16502_resume_noirq)
  498. };
  499. #endif
  500. static const struct i2c_device_id mcp16502_i2c_id[] = {
  501. { "mcp16502" },
  502. { }
  503. };
  504. MODULE_DEVICE_TABLE(i2c, mcp16502_i2c_id);
  505. static struct i2c_driver mcp16502_drv = {
  506. .probe = mcp16502_probe,
  507. .driver = {
  508. .name = "mcp16502-regulator",
  509. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  510. .of_match_table = mcp16502_ids,
  511. #ifdef CONFIG_PM
  512. .pm = &mcp16502_pm_ops,
  513. #endif
  514. },
  515. .id_table = mcp16502_i2c_id,
  516. };
  517. module_i2c_driver(mcp16502_drv);
  518. MODULE_LICENSE("GPL v2");
  519. MODULE_DESCRIPTION("MCP16502 PMIC driver");
  520. MODULE_AUTHOR("Andrei Stefanescu andrei.stefanescu@microchip.com");