tps6507x-regulator.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /*
  2. * tps6507x-regulator.c
  3. *
  4. * Regulator driver for TPS65073 PMIC
  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/mfd/tps6507x.h>
  28. /* DCDC's */
  29. #define TPS6507X_DCDC_1 0
  30. #define TPS6507X_DCDC_2 1
  31. #define TPS6507X_DCDC_3 2
  32. /* LDOs */
  33. #define TPS6507X_LDO_1 3
  34. #define TPS6507X_LDO_2 4
  35. #define TPS6507X_MAX_REG_ID TPS6507X_LDO_2
  36. /* Number of step-down converters available */
  37. #define TPS6507X_NUM_DCDC 3
  38. /* Number of LDO voltage regulators available */
  39. #define TPS6507X_NUM_LDO 2
  40. /* Number of total regulators available */
  41. #define TPS6507X_NUM_REGULATOR (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO)
  42. /* Supported voltage values for regulators (in milliVolts) */
  43. static const u16 VDCDCx_VSEL_table[] = {
  44. 725, 750, 775, 800,
  45. 825, 850, 875, 900,
  46. 925, 950, 975, 1000,
  47. 1025, 1050, 1075, 1100,
  48. 1125, 1150, 1175, 1200,
  49. 1225, 1250, 1275, 1300,
  50. 1325, 1350, 1375, 1400,
  51. 1425, 1450, 1475, 1500,
  52. 1550, 1600, 1650, 1700,
  53. 1750, 1800, 1850, 1900,
  54. 1950, 2000, 2050, 2100,
  55. 2150, 2200, 2250, 2300,
  56. 2350, 2400, 2450, 2500,
  57. 2550, 2600, 2650, 2700,
  58. 2750, 2800, 2850, 2900,
  59. 3000, 3100, 3200, 3300,
  60. };
  61. static const u16 LDO1_VSEL_table[] = {
  62. 1000, 1100, 1200, 1250,
  63. 1300, 1350, 1400, 1500,
  64. 1600, 1800, 2500, 2750,
  65. 2800, 3000, 3100, 3300,
  66. };
  67. static const u16 LDO2_VSEL_table[] = {
  68. 725, 750, 775, 800,
  69. 825, 850, 875, 900,
  70. 925, 950, 975, 1000,
  71. 1025, 1050, 1075, 1100,
  72. 1125, 1150, 1175, 1200,
  73. 1225, 1250, 1275, 1300,
  74. 1325, 1350, 1375, 1400,
  75. 1425, 1450, 1475, 1500,
  76. 1550, 1600, 1650, 1700,
  77. 1750, 1800, 1850, 1900,
  78. 1950, 2000, 2050, 2100,
  79. 2150, 2200, 2250, 2300,
  80. 2350, 2400, 2450, 2500,
  81. 2550, 2600, 2650, 2700,
  82. 2750, 2800, 2850, 2900,
  83. 3000, 3100, 3200, 3300,
  84. };
  85. static unsigned int num_voltages[] = {ARRAY_SIZE(VDCDCx_VSEL_table),
  86. ARRAY_SIZE(VDCDCx_VSEL_table),
  87. ARRAY_SIZE(VDCDCx_VSEL_table),
  88. ARRAY_SIZE(LDO1_VSEL_table),
  89. ARRAY_SIZE(LDO2_VSEL_table)};
  90. struct tps_info {
  91. const char *name;
  92. unsigned min_uV;
  93. unsigned max_uV;
  94. u8 table_len;
  95. const u16 *table;
  96. };
  97. struct tps6507x_pmic {
  98. struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
  99. struct i2c_client *client;
  100. struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
  101. const struct tps_info *info[TPS6507X_NUM_REGULATOR];
  102. struct mutex io_lock;
  103. };
  104. static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg)
  105. {
  106. return i2c_smbus_read_byte_data(tps->client, reg);
  107. }
  108. static inline int tps6507x_pmic_write(struct tps6507x_pmic *tps, u8 reg, u8 val)
  109. {
  110. return i2c_smbus_write_byte_data(tps->client, reg, val);
  111. }
  112. static int tps6507x_pmic_set_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask)
  113. {
  114. int err, data;
  115. mutex_lock(&tps->io_lock);
  116. data = tps6507x_pmic_read(tps, reg);
  117. if (data < 0) {
  118. dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
  119. err = data;
  120. goto out;
  121. }
  122. data |= mask;
  123. err = tps6507x_pmic_write(tps, reg, data);
  124. if (err)
  125. dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
  126. out:
  127. mutex_unlock(&tps->io_lock);
  128. return err;
  129. }
  130. static int tps6507x_pmic_clear_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask)
  131. {
  132. int err, data;
  133. mutex_lock(&tps->io_lock);
  134. data = tps6507x_pmic_read(tps, reg);
  135. if (data < 0) {
  136. dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
  137. err = data;
  138. goto out;
  139. }
  140. data &= ~mask;
  141. err = tps6507x_pmic_write(tps, reg, data);
  142. if (err)
  143. dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
  144. out:
  145. mutex_unlock(&tps->io_lock);
  146. return err;
  147. }
  148. static int tps6507x_pmic_reg_read(struct tps6507x_pmic *tps, u8 reg)
  149. {
  150. int data;
  151. mutex_lock(&tps->io_lock);
  152. data = tps6507x_pmic_read(tps, reg);
  153. if (data < 0)
  154. dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg);
  155. mutex_unlock(&tps->io_lock);
  156. return data;
  157. }
  158. static int tps6507x_pmic_reg_write(struct tps6507x_pmic *tps, u8 reg, u8 val)
  159. {
  160. int err;
  161. mutex_lock(&tps->io_lock);
  162. err = tps6507x_pmic_write(tps, reg, val);
  163. if (err < 0)
  164. dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg);
  165. mutex_unlock(&tps->io_lock);
  166. return err;
  167. }
  168. static int tps6507x_pmic_dcdc_is_enabled(struct regulator_dev *dev)
  169. {
  170. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  171. int data, dcdc = rdev_get_id(dev);
  172. u8 shift;
  173. if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
  174. return -EINVAL;
  175. shift = TPS6507X_MAX_REG_ID - dcdc;
  176. data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1);
  177. if (data < 0)
  178. return data;
  179. else
  180. return (data & 1<<shift) ? 1 : 0;
  181. }
  182. static int tps6507x_pmic_ldo_is_enabled(struct regulator_dev *dev)
  183. {
  184. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  185. int data, ldo = rdev_get_id(dev);
  186. u8 shift;
  187. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  188. return -EINVAL;
  189. shift = TPS6507X_MAX_REG_ID - ldo;
  190. data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1);
  191. if (data < 0)
  192. return data;
  193. else
  194. return (data & 1<<shift) ? 1 : 0;
  195. }
  196. static int tps6507x_pmic_dcdc_enable(struct regulator_dev *dev)
  197. {
  198. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  199. int dcdc = rdev_get_id(dev);
  200. u8 shift;
  201. if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
  202. return -EINVAL;
  203. shift = TPS6507X_MAX_REG_ID - dcdc;
  204. return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
  205. }
  206. static int tps6507x_pmic_dcdc_disable(struct regulator_dev *dev)
  207. {
  208. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  209. int dcdc = rdev_get_id(dev);
  210. u8 shift;
  211. if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
  212. return -EINVAL;
  213. shift = TPS6507X_MAX_REG_ID - dcdc;
  214. return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1,
  215. 1 << shift);
  216. }
  217. static int tps6507x_pmic_ldo_enable(struct regulator_dev *dev)
  218. {
  219. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  220. int ldo = rdev_get_id(dev);
  221. u8 shift;
  222. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  223. return -EINVAL;
  224. shift = TPS6507X_MAX_REG_ID - ldo;
  225. return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
  226. }
  227. static int tps6507x_pmic_ldo_disable(struct regulator_dev *dev)
  228. {
  229. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  230. int ldo = rdev_get_id(dev);
  231. u8 shift;
  232. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  233. return -EINVAL;
  234. shift = TPS6507X_MAX_REG_ID - ldo;
  235. return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1,
  236. 1 << shift);
  237. }
  238. static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev)
  239. {
  240. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  241. int data, dcdc = rdev_get_id(dev);
  242. u8 reg;
  243. switch (dcdc) {
  244. case TPS6507X_DCDC_1:
  245. reg = TPS6507X_REG_DEFDCDC1;
  246. break;
  247. case TPS6507X_DCDC_2:
  248. reg = TPS6507X_REG_DEFDCDC2_LOW;
  249. break;
  250. case TPS6507X_DCDC_3:
  251. reg = TPS6507X_REG_DEFDCDC3_LOW;
  252. break;
  253. default:
  254. return -EINVAL;
  255. }
  256. data = tps6507x_pmic_reg_read(tps, reg);
  257. if (data < 0)
  258. return data;
  259. data &= TPS6507X_DEFDCDCX_DCDC_MASK;
  260. return tps->info[dcdc]->table[data] * 1000;
  261. }
  262. static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
  263. int min_uV, int max_uV)
  264. {
  265. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  266. int data, vsel, dcdc = rdev_get_id(dev);
  267. u8 reg;
  268. switch (dcdc) {
  269. case TPS6507X_DCDC_1:
  270. reg = TPS6507X_REG_DEFDCDC1;
  271. break;
  272. case TPS6507X_DCDC_2:
  273. reg = TPS6507X_REG_DEFDCDC2_LOW;
  274. break;
  275. case TPS6507X_DCDC_3:
  276. reg = TPS6507X_REG_DEFDCDC3_LOW;
  277. break;
  278. default:
  279. return -EINVAL;
  280. }
  281. if (min_uV < tps->info[dcdc]->min_uV
  282. || min_uV > tps->info[dcdc]->max_uV)
  283. return -EINVAL;
  284. if (max_uV < tps->info[dcdc]->min_uV
  285. || max_uV > tps->info[dcdc]->max_uV)
  286. return -EINVAL;
  287. for (vsel = 0; vsel < tps->info[dcdc]->table_len; vsel++) {
  288. int mV = tps->info[dcdc]->table[vsel];
  289. int uV = mV * 1000;
  290. /* Break at the first in-range value */
  291. if (min_uV <= uV && uV <= max_uV)
  292. break;
  293. }
  294. /* write to the register in case we found a match */
  295. if (vsel == tps->info[dcdc]->table_len)
  296. return -EINVAL;
  297. data = tps6507x_pmic_reg_read(tps, reg);
  298. if (data < 0)
  299. return data;
  300. data &= ~TPS6507X_DEFDCDCX_DCDC_MASK;
  301. data |= vsel;
  302. return tps6507x_pmic_reg_write(tps, reg, data);
  303. }
  304. static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev)
  305. {
  306. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  307. int data, ldo = rdev_get_id(dev);
  308. u8 reg, mask;
  309. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  310. return -EINVAL;
  311. else {
  312. reg = (ldo == TPS6507X_LDO_1 ?
  313. TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2);
  314. mask = (ldo == TPS6507X_LDO_1 ?
  315. TPS6507X_REG_LDO_CTRL1_LDO1_MASK :
  316. TPS6507X_REG_DEFLDO2_LDO2_MASK);
  317. }
  318. data = tps6507x_pmic_reg_read(tps, reg);
  319. if (data < 0)
  320. return data;
  321. data &= mask;
  322. return tps->info[ldo]->table[data] * 1000;
  323. }
  324. static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev,
  325. int min_uV, int max_uV)
  326. {
  327. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  328. int data, vsel, ldo = rdev_get_id(dev);
  329. u8 reg, mask;
  330. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  331. return -EINVAL;
  332. else {
  333. reg = (ldo == TPS6507X_LDO_1 ?
  334. TPS6507X_REG_LDO_CTRL1 : TPS6507X_REG_DEFLDO2);
  335. mask = (ldo == TPS6507X_LDO_1 ?
  336. TPS6507X_REG_LDO_CTRL1_LDO1_MASK :
  337. TPS6507X_REG_DEFLDO2_LDO2_MASK);
  338. }
  339. if (min_uV < tps->info[ldo]->min_uV || min_uV > tps->info[ldo]->max_uV)
  340. return -EINVAL;
  341. if (max_uV < tps->info[ldo]->min_uV || max_uV > tps->info[ldo]->max_uV)
  342. return -EINVAL;
  343. for (vsel = 0; vsel < tps->info[ldo]->table_len; vsel++) {
  344. int mV = tps->info[ldo]->table[vsel];
  345. int uV = mV * 1000;
  346. /* Break at the first in-range value */
  347. if (min_uV <= uV && uV <= max_uV)
  348. break;
  349. }
  350. if (vsel == tps->info[ldo]->table_len)
  351. return -EINVAL;
  352. data = tps6507x_pmic_reg_read(tps, reg);
  353. if (data < 0)
  354. return data;
  355. data &= ~mask;
  356. data |= vsel;
  357. return tps6507x_pmic_reg_write(tps, reg, data);
  358. }
  359. static int tps6507x_pmic_dcdc_list_voltage(struct regulator_dev *dev,
  360. unsigned selector)
  361. {
  362. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  363. int dcdc = rdev_get_id(dev);
  364. if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
  365. return -EINVAL;
  366. if (selector >= tps->info[dcdc]->table_len)
  367. return -EINVAL;
  368. else
  369. return tps->info[dcdc]->table[selector] * 1000;
  370. }
  371. static int tps6507x_pmic_ldo_list_voltage(struct regulator_dev *dev,
  372. unsigned selector)
  373. {
  374. struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
  375. int ldo = rdev_get_id(dev);
  376. if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
  377. return -EINVAL;
  378. if (selector >= tps->info[ldo]->table_len)
  379. return -EINVAL;
  380. else
  381. return tps->info[ldo]->table[selector] * 1000;
  382. }
  383. /* Operations permitted on VDCDCx */
  384. static struct regulator_ops tps6507x_pmic_dcdc_ops = {
  385. .is_enabled = tps6507x_pmic_dcdc_is_enabled,
  386. .enable = tps6507x_pmic_dcdc_enable,
  387. .disable = tps6507x_pmic_dcdc_disable,
  388. .get_voltage = tps6507x_pmic_dcdc_get_voltage,
  389. .set_voltage = tps6507x_pmic_dcdc_set_voltage,
  390. .list_voltage = tps6507x_pmic_dcdc_list_voltage,
  391. };
  392. /* Operations permitted on LDOx */
  393. static struct regulator_ops tps6507x_pmic_ldo_ops = {
  394. .is_enabled = tps6507x_pmic_ldo_is_enabled,
  395. .enable = tps6507x_pmic_ldo_enable,
  396. .disable = tps6507x_pmic_ldo_disable,
  397. .get_voltage = tps6507x_pmic_ldo_get_voltage,
  398. .set_voltage = tps6507x_pmic_ldo_set_voltage,
  399. .list_voltage = tps6507x_pmic_ldo_list_voltage,
  400. };
  401. static int __devinit tps6507x_pmic_probe(struct i2c_client *client,
  402. const struct i2c_device_id *id)
  403. {
  404. static int desc_id;
  405. const struct tps_info *info = (void *)id->driver_data;
  406. struct regulator_init_data *init_data;
  407. struct regulator_dev *rdev;
  408. struct tps6507x_pmic *tps;
  409. struct tps6507x_board *tps_board;
  410. int i;
  411. int error;
  412. if (!i2c_check_functionality(client->adapter,
  413. I2C_FUNC_SMBUS_BYTE_DATA))
  414. return -EIO;
  415. /**
  416. * tps_board points to pmic related constants
  417. * coming from the board-evm file.
  418. */
  419. tps_board = dev_get_platdata(&client->dev);
  420. if (!tps_board)
  421. return -EINVAL;
  422. /**
  423. * init_data points to array of regulator_init structures
  424. * coming from the board-evm file.
  425. */
  426. init_data = tps_board->tps6507x_pmic_init_data;
  427. if (!init_data)
  428. return -EINVAL;
  429. tps = kzalloc(sizeof(*tps), GFP_KERNEL);
  430. if (!tps)
  431. return -ENOMEM;
  432. mutex_init(&tps->io_lock);
  433. /* common for all regulators */
  434. tps->client = client;
  435. for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
  436. /* Register the regulators */
  437. tps->info[i] = info;
  438. tps->desc[i].name = info->name;
  439. tps->desc[i].id = desc_id++;
  440. tps->desc[i].n_voltages = num_voltages[i];
  441. tps->desc[i].ops = (i > TPS6507X_DCDC_3 ?
  442. &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops);
  443. tps->desc[i].type = REGULATOR_VOLTAGE;
  444. tps->desc[i].owner = THIS_MODULE;
  445. rdev = regulator_register(&tps->desc[i],
  446. &client->dev, init_data, tps);
  447. if (IS_ERR(rdev)) {
  448. dev_err(&client->dev, "failed to register %s\n",
  449. id->name);
  450. error = PTR_ERR(rdev);
  451. goto fail;
  452. }
  453. /* Save regulator for cleanup */
  454. tps->rdev[i] = rdev;
  455. }
  456. i2c_set_clientdata(client, tps);
  457. return 0;
  458. fail:
  459. while (--i >= 0)
  460. regulator_unregister(tps->rdev[i]);
  461. kfree(tps);
  462. return error;
  463. }
  464. /**
  465. * tps6507x_remove - TPS6507x driver i2c remove handler
  466. * @client: i2c driver client device structure
  467. *
  468. * Unregister TPS driver as an i2c client device driver
  469. */
  470. static int __devexit tps6507x_pmic_remove(struct i2c_client *client)
  471. {
  472. struct tps6507x_pmic *tps = i2c_get_clientdata(client);
  473. int i;
  474. /* clear the client data in i2c */
  475. i2c_set_clientdata(client, NULL);
  476. for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
  477. regulator_unregister(tps->rdev[i]);
  478. kfree(tps);
  479. return 0;
  480. }
  481. static const struct tps_info tps6507x_pmic_regs[] = {
  482. {
  483. .name = "VDCDC1",
  484. .min_uV = 725000,
  485. .max_uV = 3300000,
  486. .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
  487. .table = VDCDCx_VSEL_table,
  488. },
  489. {
  490. .name = "VDCDC2",
  491. .min_uV = 725000,
  492. .max_uV = 3300000,
  493. .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
  494. .table = VDCDCx_VSEL_table,
  495. },
  496. {
  497. .name = "VDCDC3",
  498. .min_uV = 725000,
  499. .max_uV = 3300000,
  500. .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
  501. .table = VDCDCx_VSEL_table,
  502. },
  503. {
  504. .name = "LDO1",
  505. .min_uV = 1000000,
  506. .max_uV = 3300000,
  507. .table_len = ARRAY_SIZE(LDO1_VSEL_table),
  508. .table = LDO1_VSEL_table,
  509. },
  510. {
  511. .name = "LDO2",
  512. .min_uV = 725000,
  513. .max_uV = 3300000,
  514. .table_len = ARRAY_SIZE(LDO2_VSEL_table),
  515. .table = LDO2_VSEL_table,
  516. },
  517. };
  518. static const struct i2c_device_id tps6507x_pmic_id[] = {
  519. {.name = "tps6507x",
  520. .driver_data = (unsigned long) tps6507x_pmic_regs,},
  521. { },
  522. };
  523. MODULE_DEVICE_TABLE(i2c, tps6507x_pmic_id);
  524. static struct i2c_driver tps6507x_i2c_driver = {
  525. .driver = {
  526. .name = "tps6507x",
  527. .owner = THIS_MODULE,
  528. },
  529. .probe = tps6507x_pmic_probe,
  530. .remove = __devexit_p(tps6507x_pmic_remove),
  531. .id_table = tps6507x_pmic_id,
  532. };
  533. /**
  534. * tps6507x_pmic_init
  535. *
  536. * Module init function
  537. */
  538. static int __init tps6507x_pmic_init(void)
  539. {
  540. return i2c_add_driver(&tps6507x_i2c_driver);
  541. }
  542. subsys_initcall(tps6507x_pmic_init);
  543. /**
  544. * tps6507x_pmic_cleanup
  545. *
  546. * Module exit function
  547. */
  548. static void __exit tps6507x_pmic_cleanup(void)
  549. {
  550. i2c_del_driver(&tps6507x_i2c_driver);
  551. }
  552. module_exit(tps6507x_pmic_cleanup);
  553. MODULE_AUTHOR("Texas Instruments");
  554. MODULE_DESCRIPTION("TPS6507x voltage regulator driver");
  555. MODULE_LICENSE("GPL v2");