tps65023-regulator.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. /*
  2. * tps65023-regulator.c
  3. *
  4. * Supports TPS65023 Regulator
  5. *
  6. * Copyright (C) 2009 Texas Instrument Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation version 2.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  13. * whether express or implied; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/init.h>
  20. #include <linux/err.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/regulator/driver.h>
  23. #include <linux/regulator/machine.h>
  24. #include <linux/i2c.h>
  25. #include <linux/delay.h>
  26. #include <linux/slab.h>
  27. #include <linux/regmap.h>
  28. /* Register definitions */
  29. #define TPS65023_REG_VERSION 0
  30. #define TPS65023_REG_PGOODZ 1
  31. #define TPS65023_REG_MASK 2
  32. #define TPS65023_REG_REG_CTRL 3
  33. #define TPS65023_REG_CON_CTRL 4
  34. #define TPS65023_REG_CON_CTRL2 5
  35. #define TPS65023_REG_DEF_CORE 6
  36. #define TPS65023_REG_DEFSLEW 7
  37. #define TPS65023_REG_LDO_CTRL 8
  38. /* PGOODZ bitfields */
  39. #define TPS65023_PGOODZ_PWRFAILZ BIT(7)
  40. #define TPS65023_PGOODZ_LOWBATTZ BIT(6)
  41. #define TPS65023_PGOODZ_VDCDC1 BIT(5)
  42. #define TPS65023_PGOODZ_VDCDC2 BIT(4)
  43. #define TPS65023_PGOODZ_VDCDC3 BIT(3)
  44. #define TPS65023_PGOODZ_LDO2 BIT(2)
  45. #define TPS65023_PGOODZ_LDO1 BIT(1)
  46. /* MASK bitfields */
  47. #define TPS65023_MASK_PWRFAILZ BIT(7)
  48. #define TPS65023_MASK_LOWBATTZ BIT(6)
  49. #define TPS65023_MASK_VDCDC1 BIT(5)
  50. #define TPS65023_MASK_VDCDC2 BIT(4)
  51. #define TPS65023_MASK_VDCDC3 BIT(3)
  52. #define TPS65023_MASK_LDO2 BIT(2)
  53. #define TPS65023_MASK_LDO1 BIT(1)
  54. /* REG_CTRL bitfields */
  55. #define TPS65023_REG_CTRL_VDCDC1_EN BIT(5)
  56. #define TPS65023_REG_CTRL_VDCDC2_EN BIT(4)
  57. #define TPS65023_REG_CTRL_VDCDC3_EN BIT(3)
  58. #define TPS65023_REG_CTRL_LDO2_EN BIT(2)
  59. #define TPS65023_REG_CTRL_LDO1_EN BIT(1)
  60. /* REG_CTRL2 bitfields */
  61. #define TPS65023_REG_CTRL2_GO BIT(7)
  62. #define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
  63. #define TPS65023_REG_CTRL2_DCDC2 BIT(2)
  64. #define TPS65023_REG_CTRL2_DCDC1 BIT(2)
  65. #define TPS65023_REG_CTRL2_DCDC3 BIT(0)
  66. /* REG_CTRL2 bitfields */
  67. #define TPS65023_REG_CTRL2_GO BIT(7)
  68. #define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
  69. #define TPS65023_REG_CTRL2_DCDC2 BIT(2)
  70. #define TPS65023_REG_CTRL2_DCDC1 BIT(1)
  71. #define TPS65023_REG_CTRL2_DCDC3 BIT(0)
  72. /* LDO_CTRL bitfields */
  73. #define TPS65023_LDO_CTRL_LDOx_SHIFT(ldo_id) ((ldo_id)*4)
  74. #define TPS65023_LDO_CTRL_LDOx_MASK(ldo_id) (0xF0 >> ((ldo_id)*4))
  75. /* Number of step-down converters available */
  76. #define TPS65023_NUM_DCDC 3
  77. /* Number of LDO voltage regulators available */
  78. #define TPS65023_NUM_LDO 2
  79. /* Number of total regulators available */
  80. #define TPS65023_NUM_REGULATOR (TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
  81. /* DCDCs */
  82. #define TPS65023_DCDC_1 0
  83. #define TPS65023_DCDC_2 1
  84. #define TPS65023_DCDC_3 2
  85. /* LDOs */
  86. #define TPS65023_LDO_1 3
  87. #define TPS65023_LDO_2 4
  88. #define TPS65023_MAX_REG_ID TPS65023_LDO_2
  89. /* Supported voltage values for regulators */
  90. static const u16 VCORE_VSEL_table[] = {
  91. 800, 825, 850, 875,
  92. 900, 925, 950, 975,
  93. 1000, 1025, 1050, 1075,
  94. 1100, 1125, 1150, 1175,
  95. 1200, 1225, 1250, 1275,
  96. 1300, 1325, 1350, 1375,
  97. 1400, 1425, 1450, 1475,
  98. 1500, 1525, 1550, 1600,
  99. };
  100. /* Supported voltage values for LDO regulators
  101. * for tps65021 and tps65023 */
  102. static const u16 TPS65023_LDO1_VSEL_table[] = {
  103. 1000, 1100, 1300, 1800,
  104. 2200, 2600, 2800, 3150,
  105. };
  106. static const u16 TPS65023_LDO2_VSEL_table[] = {
  107. 1050, 1200, 1300, 1800,
  108. 2500, 2800, 3000, 3300,
  109. };
  110. /* Regulator specific details */
  111. struct tps_info {
  112. const char *name;
  113. unsigned min_uV;
  114. unsigned max_uV;
  115. bool fixed;
  116. u8 table_len;
  117. const u16 *table;
  118. };
  119. /* PMIC details */
  120. struct tps_pmic {
  121. struct regulator_desc desc[TPS65023_NUM_REGULATOR];
  122. struct i2c_client *client;
  123. struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
  124. const struct tps_info *info[TPS65023_NUM_REGULATOR];
  125. struct regmap *regmap;
  126. u8 core_regulator;
  127. };
  128. /* Struct passed as driver data */
  129. struct tps_driver_data {
  130. const struct tps_info *info;
  131. u8 core_regulator;
  132. };
  133. static int tps_65023_set_bits(struct tps_pmic *tps, u8 reg, u8 mask)
  134. {
  135. return regmap_update_bits(tps->regmap, reg, mask, mask);
  136. }
  137. static int tps_65023_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask)
  138. {
  139. return regmap_update_bits(tps->regmap, reg, mask, 0);
  140. }
  141. static int tps_65023_reg_read(struct tps_pmic *tps, u8 reg)
  142. {
  143. unsigned int val;
  144. int ret;
  145. ret = regmap_read(tps->regmap, reg, &val);
  146. if (ret != 0)
  147. return ret;
  148. else
  149. return val;
  150. }
  151. static int tps_65023_reg_write(struct tps_pmic *tps, u8 reg, u8 val)
  152. {
  153. return regmap_write(tps->regmap, reg, val);
  154. }
  155. static int tps65023_dcdc_is_enabled(struct regulator_dev *dev)
  156. {
  157. struct tps_pmic *tps = rdev_get_drvdata(dev);
  158. int data, dcdc = rdev_get_id(dev);
  159. u8 shift;
  160. if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
  161. return -EINVAL;
  162. shift = TPS65023_NUM_REGULATOR - dcdc;
  163. data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL);
  164. if (data < 0)
  165. return data;
  166. else
  167. return (data & 1<<shift) ? 1 : 0;
  168. }
  169. static int tps65023_ldo_is_enabled(struct regulator_dev *dev)
  170. {
  171. struct tps_pmic *tps = rdev_get_drvdata(dev);
  172. int data, ldo = rdev_get_id(dev);
  173. u8 shift;
  174. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  175. return -EINVAL;
  176. shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
  177. data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL);
  178. if (data < 0)
  179. return data;
  180. else
  181. return (data & 1<<shift) ? 1 : 0;
  182. }
  183. static int tps65023_dcdc_enable(struct regulator_dev *dev)
  184. {
  185. struct tps_pmic *tps = rdev_get_drvdata(dev);
  186. int dcdc = rdev_get_id(dev);
  187. u8 shift;
  188. if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
  189. return -EINVAL;
  190. shift = TPS65023_NUM_REGULATOR - dcdc;
  191. return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
  192. }
  193. static int tps65023_dcdc_disable(struct regulator_dev *dev)
  194. {
  195. struct tps_pmic *tps = rdev_get_drvdata(dev);
  196. int dcdc = rdev_get_id(dev);
  197. u8 shift;
  198. if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
  199. return -EINVAL;
  200. shift = TPS65023_NUM_REGULATOR - dcdc;
  201. return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
  202. }
  203. static int tps65023_ldo_enable(struct regulator_dev *dev)
  204. {
  205. struct tps_pmic *tps = rdev_get_drvdata(dev);
  206. int ldo = rdev_get_id(dev);
  207. u8 shift;
  208. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  209. return -EINVAL;
  210. shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
  211. return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
  212. }
  213. static int tps65023_ldo_disable(struct regulator_dev *dev)
  214. {
  215. struct tps_pmic *tps = rdev_get_drvdata(dev);
  216. int ldo = rdev_get_id(dev);
  217. u8 shift;
  218. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  219. return -EINVAL;
  220. shift = (ldo == TPS65023_LDO_1 ? 1 : 2);
  221. return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift);
  222. }
  223. static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
  224. {
  225. struct tps_pmic *tps = rdev_get_drvdata(dev);
  226. int data, dcdc = rdev_get_id(dev);
  227. if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
  228. return -EINVAL;
  229. if (dcdc == tps->core_regulator) {
  230. data = tps_65023_reg_read(tps, TPS65023_REG_DEF_CORE);
  231. if (data < 0)
  232. return data;
  233. data &= (tps->info[dcdc]->table_len - 1);
  234. return tps->info[dcdc]->table[data] * 1000;
  235. } else
  236. return tps->info[dcdc]->min_uV;
  237. }
  238. static int tps65023_dcdc_set_voltage(struct regulator_dev *dev,
  239. int min_uV, int max_uV,
  240. unsigned *selector)
  241. {
  242. struct tps_pmic *tps = rdev_get_drvdata(dev);
  243. int dcdc = rdev_get_id(dev);
  244. int vsel;
  245. int ret;
  246. if (dcdc != tps->core_regulator)
  247. return -EINVAL;
  248. if (min_uV < tps->info[dcdc]->min_uV
  249. || min_uV > tps->info[dcdc]->max_uV)
  250. return -EINVAL;
  251. if (max_uV < tps->info[dcdc]->min_uV
  252. || max_uV > tps->info[dcdc]->max_uV)
  253. return -EINVAL;
  254. for (vsel = 0; vsel < tps->info[dcdc]->table_len; vsel++) {
  255. int mV = tps->info[dcdc]->table[vsel];
  256. int uV = mV * 1000;
  257. /* Break at the first in-range value */
  258. if (min_uV <= uV && uV <= max_uV)
  259. break;
  260. }
  261. *selector = vsel;
  262. if (vsel == tps->info[dcdc]->table_len)
  263. goto failed;
  264. ret = tps_65023_reg_write(tps, TPS65023_REG_DEF_CORE, vsel);
  265. /* Tell the chip that we have changed the value in DEFCORE
  266. * and its time to update the core voltage
  267. */
  268. tps_65023_set_bits(tps, TPS65023_REG_CON_CTRL2,
  269. TPS65023_REG_CTRL2_GO);
  270. return ret;
  271. failed:
  272. return -EINVAL;
  273. }
  274. static int tps65023_ldo_get_voltage(struct regulator_dev *dev)
  275. {
  276. struct tps_pmic *tps = rdev_get_drvdata(dev);
  277. int data, ldo = rdev_get_id(dev);
  278. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  279. return -EINVAL;
  280. data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL);
  281. if (data < 0)
  282. return data;
  283. data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1));
  284. data &= (tps->info[ldo]->table_len - 1);
  285. return tps->info[ldo]->table[data] * 1000;
  286. }
  287. static int tps65023_ldo_set_voltage(struct regulator_dev *dev,
  288. int min_uV, int max_uV, unsigned *selector)
  289. {
  290. struct tps_pmic *tps = rdev_get_drvdata(dev);
  291. int data, vsel, ldo = rdev_get_id(dev);
  292. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  293. return -EINVAL;
  294. if (min_uV < tps->info[ldo]->min_uV || min_uV > tps->info[ldo]->max_uV)
  295. return -EINVAL;
  296. if (max_uV < tps->info[ldo]->min_uV || max_uV > tps->info[ldo]->max_uV)
  297. return -EINVAL;
  298. for (vsel = 0; vsel < tps->info[ldo]->table_len; vsel++) {
  299. int mV = tps->info[ldo]->table[vsel];
  300. int uV = mV * 1000;
  301. /* Break at the first in-range value */
  302. if (min_uV <= uV && uV <= max_uV)
  303. break;
  304. }
  305. if (vsel == tps->info[ldo]->table_len)
  306. return -EINVAL;
  307. *selector = vsel;
  308. data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL);
  309. if (data < 0)
  310. return data;
  311. data &= TPS65023_LDO_CTRL_LDOx_MASK(ldo - TPS65023_LDO_1);
  312. data |= (vsel << (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1)));
  313. return tps_65023_reg_write(tps, TPS65023_REG_LDO_CTRL, data);
  314. }
  315. static int tps65023_dcdc_list_voltage(struct regulator_dev *dev,
  316. unsigned selector)
  317. {
  318. struct tps_pmic *tps = rdev_get_drvdata(dev);
  319. int dcdc = rdev_get_id(dev);
  320. if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
  321. return -EINVAL;
  322. if (dcdc == tps->core_regulator) {
  323. if (selector >= tps->info[dcdc]->table_len)
  324. return -EINVAL;
  325. else
  326. return tps->info[dcdc]->table[selector] * 1000;
  327. } else
  328. return tps->info[dcdc]->min_uV;
  329. }
  330. static int tps65023_ldo_list_voltage(struct regulator_dev *dev,
  331. unsigned selector)
  332. {
  333. struct tps_pmic *tps = rdev_get_drvdata(dev);
  334. int ldo = rdev_get_id(dev);
  335. if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2)
  336. return -EINVAL;
  337. if (selector >= tps->info[ldo]->table_len)
  338. return -EINVAL;
  339. else
  340. return tps->info[ldo]->table[selector] * 1000;
  341. }
  342. /* Operations permitted on VDCDCx */
  343. static struct regulator_ops tps65023_dcdc_ops = {
  344. .is_enabled = tps65023_dcdc_is_enabled,
  345. .enable = tps65023_dcdc_enable,
  346. .disable = tps65023_dcdc_disable,
  347. .get_voltage = tps65023_dcdc_get_voltage,
  348. .set_voltage = tps65023_dcdc_set_voltage,
  349. .list_voltage = tps65023_dcdc_list_voltage,
  350. };
  351. /* Operations permitted on LDOx */
  352. static struct regulator_ops tps65023_ldo_ops = {
  353. .is_enabled = tps65023_ldo_is_enabled,
  354. .enable = tps65023_ldo_enable,
  355. .disable = tps65023_ldo_disable,
  356. .get_voltage = tps65023_ldo_get_voltage,
  357. .set_voltage = tps65023_ldo_set_voltage,
  358. .list_voltage = tps65023_ldo_list_voltage,
  359. };
  360. static struct regmap_config tps65023_regmap_config = {
  361. .reg_bits = 8,
  362. .val_bits = 8,
  363. };
  364. static int __devinit tps_65023_probe(struct i2c_client *client,
  365. const struct i2c_device_id *id)
  366. {
  367. const struct tps_driver_data *drv_data = (void *)id->driver_data;
  368. const struct tps_info *info = drv_data->info;
  369. struct regulator_init_data *init_data;
  370. struct regulator_dev *rdev;
  371. struct tps_pmic *tps;
  372. int i;
  373. int error;
  374. if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
  375. return -EIO;
  376. /**
  377. * init_data points to array of regulator_init structures
  378. * coming from the board-evm file.
  379. */
  380. init_data = client->dev.platform_data;
  381. if (!init_data)
  382. return -EIO;
  383. tps = kzalloc(sizeof(*tps), GFP_KERNEL);
  384. if (!tps)
  385. return -ENOMEM;
  386. tps->regmap = regmap_init_i2c(client, &tps65023_regmap_config);
  387. if (IS_ERR(tps->regmap)) {
  388. error = PTR_ERR(tps->regmap);
  389. dev_err(&client->dev, "Failed to allocate register map: %d\n",
  390. error);
  391. goto fail_alloc;
  392. }
  393. /* common for all regulators */
  394. tps->client = client;
  395. tps->core_regulator = drv_data->core_regulator;
  396. for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
  397. /* Store regulator specific information */
  398. tps->info[i] = info;
  399. tps->desc[i].name = info->name;
  400. tps->desc[i].id = i;
  401. tps->desc[i].n_voltages = info->table_len;
  402. tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
  403. &tps65023_ldo_ops : &tps65023_dcdc_ops);
  404. tps->desc[i].type = REGULATOR_VOLTAGE;
  405. tps->desc[i].owner = THIS_MODULE;
  406. /* Register the regulators */
  407. rdev = regulator_register(&tps->desc[i], &client->dev,
  408. init_data, tps);
  409. if (IS_ERR(rdev)) {
  410. dev_err(&client->dev, "failed to register %s\n",
  411. id->name);
  412. error = PTR_ERR(rdev);
  413. goto fail;
  414. }
  415. /* Save regulator for cleanup */
  416. tps->rdev[i] = rdev;
  417. }
  418. i2c_set_clientdata(client, tps);
  419. /* Enable setting output voltage by I2C */
  420. tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2,
  421. TPS65023_REG_CTRL2_CORE_ADJ);
  422. /* Enable setting output voltage by I2C */
  423. tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2,
  424. TPS65023_REG_CTRL2_CORE_ADJ);
  425. return 0;
  426. fail:
  427. while (--i >= 0)
  428. regulator_unregister(tps->rdev[i]);
  429. regmap_exit(tps->regmap);
  430. fail_alloc:
  431. kfree(tps);
  432. return error;
  433. }
  434. /**
  435. * tps_65023_remove - TPS65023 driver i2c remove handler
  436. * @client: i2c driver client device structure
  437. *
  438. * Unregister TPS driver as an i2c client device driver
  439. */
  440. static int __devexit tps_65023_remove(struct i2c_client *client)
  441. {
  442. struct tps_pmic *tps = i2c_get_clientdata(client);
  443. int i;
  444. for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
  445. regulator_unregister(tps->rdev[i]);
  446. regmap_exit(tps->regmap);
  447. kfree(tps);
  448. return 0;
  449. }
  450. static const struct tps_info tps65021_regs[] = {
  451. {
  452. .name = "VDCDC1",
  453. .min_uV = 3300000,
  454. .max_uV = 3300000,
  455. .fixed = 1,
  456. },
  457. {
  458. .name = "VDCDC2",
  459. .min_uV = 1800000,
  460. .max_uV = 1800000,
  461. .fixed = 1,
  462. },
  463. {
  464. .name = "VDCDC3",
  465. .min_uV = 800000,
  466. .max_uV = 1600000,
  467. .table_len = ARRAY_SIZE(VCORE_VSEL_table),
  468. .table = VCORE_VSEL_table,
  469. },
  470. {
  471. .name = "LDO1",
  472. .min_uV = 1000000,
  473. .max_uV = 3150000,
  474. .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
  475. .table = TPS65023_LDO1_VSEL_table,
  476. },
  477. {
  478. .name = "LDO2",
  479. .min_uV = 1050000,
  480. .max_uV = 3300000,
  481. .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
  482. .table = TPS65023_LDO2_VSEL_table,
  483. },
  484. };
  485. static const struct tps_info tps65023_regs[] = {
  486. {
  487. .name = "VDCDC1",
  488. .min_uV = 800000,
  489. .max_uV = 1600000,
  490. .table_len = ARRAY_SIZE(VCORE_VSEL_table),
  491. .table = VCORE_VSEL_table,
  492. },
  493. {
  494. .name = "VDCDC2",
  495. .min_uV = 3300000,
  496. .max_uV = 3300000,
  497. .fixed = 1,
  498. },
  499. {
  500. .name = "VDCDC3",
  501. .min_uV = 1800000,
  502. .max_uV = 1800000,
  503. .fixed = 1,
  504. },
  505. {
  506. .name = "LDO1",
  507. .min_uV = 1000000,
  508. .max_uV = 3150000,
  509. .table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
  510. .table = TPS65023_LDO1_VSEL_table,
  511. },
  512. {
  513. .name = "LDO2",
  514. .min_uV = 1050000,
  515. .max_uV = 3300000,
  516. .table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
  517. .table = TPS65023_LDO2_VSEL_table,
  518. },
  519. };
  520. static struct tps_driver_data tps65021_drv_data = {
  521. .info = tps65021_regs,
  522. .core_regulator = TPS65023_DCDC_3,
  523. };
  524. static struct tps_driver_data tps65023_drv_data = {
  525. .info = tps65023_regs,
  526. .core_regulator = TPS65023_DCDC_1,
  527. };
  528. static const struct i2c_device_id tps_65023_id[] = {
  529. {.name = "tps65023",
  530. .driver_data = (unsigned long) &tps65023_drv_data},
  531. {.name = "tps65021",
  532. .driver_data = (unsigned long) &tps65021_drv_data,},
  533. { },
  534. };
  535. MODULE_DEVICE_TABLE(i2c, tps_65023_id);
  536. static struct i2c_driver tps_65023_i2c_driver = {
  537. .driver = {
  538. .name = "tps65023",
  539. .owner = THIS_MODULE,
  540. },
  541. .probe = tps_65023_probe,
  542. .remove = __devexit_p(tps_65023_remove),
  543. .id_table = tps_65023_id,
  544. };
  545. /**
  546. * tps_65023_init
  547. *
  548. * Module init function
  549. */
  550. static int __init tps_65023_init(void)
  551. {
  552. return i2c_add_driver(&tps_65023_i2c_driver);
  553. }
  554. subsys_initcall(tps_65023_init);
  555. /**
  556. * tps_65023_cleanup
  557. *
  558. * Module exit function
  559. */
  560. static void __exit tps_65023_cleanup(void)
  561. {
  562. i2c_del_driver(&tps_65023_i2c_driver);
  563. }
  564. module_exit(tps_65023_cleanup);
  565. MODULE_AUTHOR("Texas Instruments");
  566. MODULE_DESCRIPTION("TPS65023 voltage regulator driver");
  567. MODULE_LICENSE("GPL v2");