tps65023-regulator.c 17 KB

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