tps65023-regulator.c 17 KB

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