tps6524x-regulator.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * Regulator driver for TPS6524x PMIC
  3. *
  4. * Copyright (C) 2010 Texas Instruments
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation version 2.
  9. *
  10. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  11. * whether express or implied; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/module.h>
  17. #include <linux/err.h>
  18. #include <linux/errno.h>
  19. #include <linux/slab.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/regulator/driver.h>
  22. #include <linux/regulator/machine.h>
  23. #define REG_LDO_SET 0x0
  24. #define LDO_ILIM_MASK 1 /* 0 = 400-800, 1 = 900-1500 */
  25. #define LDO_VSEL_MASK 0x0f
  26. #define LDO2_ILIM_SHIFT 12
  27. #define LDO2_VSEL_SHIFT 4
  28. #define LDO1_ILIM_SHIFT 8
  29. #define LDO1_VSEL_SHIFT 0
  30. #define REG_BLOCK_EN 0x1
  31. #define BLOCK_MASK 1
  32. #define BLOCK_LDO1_SHIFT 0
  33. #define BLOCK_LDO2_SHIFT 1
  34. #define BLOCK_LCD_SHIFT 2
  35. #define BLOCK_USB_SHIFT 3
  36. #define REG_DCDC_SET 0x2
  37. #define DCDC_VDCDC_MASK 0x1f
  38. #define DCDC_VDCDC1_SHIFT 0
  39. #define DCDC_VDCDC2_SHIFT 5
  40. #define DCDC_VDCDC3_SHIFT 10
  41. #define REG_DCDC_EN 0x3
  42. #define DCDCDCDC_EN_MASK 0x1
  43. #define DCDCDCDC1_EN_SHIFT 0
  44. #define DCDCDCDC1_PG_MSK BIT(1)
  45. #define DCDCDCDC2_EN_SHIFT 2
  46. #define DCDCDCDC2_PG_MSK BIT(3)
  47. #define DCDCDCDC3_EN_SHIFT 4
  48. #define DCDCDCDC3_PG_MSK BIT(5)
  49. #define REG_USB 0x4
  50. #define USB_ILIM_SHIFT 0
  51. #define USB_ILIM_MASK 0x3
  52. #define USB_TSD_SHIFT 2
  53. #define USB_TSD_MASK 0x3
  54. #define USB_TWARN_SHIFT 4
  55. #define USB_TWARN_MASK 0x3
  56. #define USB_IWARN_SD BIT(6)
  57. #define USB_FAST_LOOP BIT(7)
  58. #define REG_ALARM 0x5
  59. #define ALARM_LDO1 BIT(0)
  60. #define ALARM_DCDC1 BIT(1)
  61. #define ALARM_DCDC2 BIT(2)
  62. #define ALARM_DCDC3 BIT(3)
  63. #define ALARM_LDO2 BIT(4)
  64. #define ALARM_USB_WARN BIT(5)
  65. #define ALARM_USB_ALARM BIT(6)
  66. #define ALARM_LCD BIT(9)
  67. #define ALARM_TEMP_WARM BIT(10)
  68. #define ALARM_TEMP_HOT BIT(11)
  69. #define ALARM_NRST BIT(14)
  70. #define ALARM_POWERUP BIT(15)
  71. #define REG_INT_ENABLE 0x6
  72. #define INT_LDO1 BIT(0)
  73. #define INT_DCDC1 BIT(1)
  74. #define INT_DCDC2 BIT(2)
  75. #define INT_DCDC3 BIT(3)
  76. #define INT_LDO2 BIT(4)
  77. #define INT_USB_WARN BIT(5)
  78. #define INT_USB_ALARM BIT(6)
  79. #define INT_LCD BIT(9)
  80. #define INT_TEMP_WARM BIT(10)
  81. #define INT_TEMP_HOT BIT(11)
  82. #define INT_GLOBAL_EN BIT(15)
  83. #define REG_INT_STATUS 0x7
  84. #define STATUS_LDO1 BIT(0)
  85. #define STATUS_DCDC1 BIT(1)
  86. #define STATUS_DCDC2 BIT(2)
  87. #define STATUS_DCDC3 BIT(3)
  88. #define STATUS_LDO2 BIT(4)
  89. #define STATUS_USB_WARN BIT(5)
  90. #define STATUS_USB_ALARM BIT(6)
  91. #define STATUS_LCD BIT(9)
  92. #define STATUS_TEMP_WARM BIT(10)
  93. #define STATUS_TEMP_HOT BIT(11)
  94. #define REG_SOFTWARE_RESET 0xb
  95. #define REG_WRITE_ENABLE 0xd
  96. #define REG_REV_ID 0xf
  97. #define N_DCDC 3
  98. #define N_LDO 2
  99. #define N_SWITCH 2
  100. #define N_REGULATORS (N_DCDC + N_LDO + N_SWITCH)
  101. #define FIXED_ILIMSEL BIT(0)
  102. #define CMD_READ(reg) ((reg) << 6)
  103. #define CMD_WRITE(reg) (BIT(5) | (reg) << 6)
  104. #define STAT_CLK BIT(3)
  105. #define STAT_WRITE BIT(2)
  106. #define STAT_INVALID BIT(1)
  107. #define STAT_WP BIT(0)
  108. struct field {
  109. int reg;
  110. int shift;
  111. int mask;
  112. };
  113. struct supply_info {
  114. const char *name;
  115. int n_voltages;
  116. const unsigned int *voltages;
  117. int n_ilimsels;
  118. const int *ilimsels;
  119. int fixed_ilimsel;
  120. int flags;
  121. struct field enable, voltage, ilimsel;
  122. };
  123. struct tps6524x {
  124. struct device *dev;
  125. struct spi_device *spi;
  126. struct mutex lock;
  127. struct regulator_desc desc[N_REGULATORS];
  128. struct regulator_dev *rdev[N_REGULATORS];
  129. };
  130. static int __read_reg(struct tps6524x *hw, int reg)
  131. {
  132. int error = 0;
  133. u16 cmd = CMD_READ(reg), in;
  134. u8 status;
  135. struct spi_message m;
  136. struct spi_transfer t[3];
  137. spi_message_init(&m);
  138. memset(t, 0, sizeof(t));
  139. t[0].tx_buf = &cmd;
  140. t[0].len = 2;
  141. t[0].bits_per_word = 12;
  142. spi_message_add_tail(&t[0], &m);
  143. t[1].rx_buf = &in;
  144. t[1].len = 2;
  145. t[1].bits_per_word = 16;
  146. spi_message_add_tail(&t[1], &m);
  147. t[2].rx_buf = &status;
  148. t[2].len = 1;
  149. t[2].bits_per_word = 4;
  150. spi_message_add_tail(&t[2], &m);
  151. error = spi_sync(hw->spi, &m);
  152. if (error < 0)
  153. return error;
  154. dev_dbg(hw->dev, "read reg %d, data %x, status %x\n",
  155. reg, in, status);
  156. if (!(status & STAT_CLK) || (status & STAT_WRITE))
  157. return -EIO;
  158. if (status & STAT_INVALID)
  159. return -EINVAL;
  160. return in;
  161. }
  162. static int read_reg(struct tps6524x *hw, int reg)
  163. {
  164. int ret;
  165. mutex_lock(&hw->lock);
  166. ret = __read_reg(hw, reg);
  167. mutex_unlock(&hw->lock);
  168. return ret;
  169. }
  170. static int __write_reg(struct tps6524x *hw, int reg, int val)
  171. {
  172. int error = 0;
  173. u16 cmd = CMD_WRITE(reg), out = val;
  174. u8 status;
  175. struct spi_message m;
  176. struct spi_transfer t[3];
  177. spi_message_init(&m);
  178. memset(t, 0, sizeof(t));
  179. t[0].tx_buf = &cmd;
  180. t[0].len = 2;
  181. t[0].bits_per_word = 12;
  182. spi_message_add_tail(&t[0], &m);
  183. t[1].tx_buf = &out;
  184. t[1].len = 2;
  185. t[1].bits_per_word = 16;
  186. spi_message_add_tail(&t[1], &m);
  187. t[2].rx_buf = &status;
  188. t[2].len = 1;
  189. t[2].bits_per_word = 4;
  190. spi_message_add_tail(&t[2], &m);
  191. error = spi_sync(hw->spi, &m);
  192. if (error < 0)
  193. return error;
  194. dev_dbg(hw->dev, "wrote reg %d, data %x, status %x\n",
  195. reg, out, status);
  196. if (!(status & STAT_CLK) || !(status & STAT_WRITE))
  197. return -EIO;
  198. if (status & (STAT_INVALID | STAT_WP))
  199. return -EINVAL;
  200. return error;
  201. }
  202. static int __rmw_reg(struct tps6524x *hw, int reg, int mask, int val)
  203. {
  204. int ret;
  205. ret = __read_reg(hw, reg);
  206. if (ret < 0)
  207. return ret;
  208. ret &= ~mask;
  209. ret |= val;
  210. ret = __write_reg(hw, reg, ret);
  211. return (ret < 0) ? ret : 0;
  212. }
  213. static int rmw_protect(struct tps6524x *hw, int reg, int mask, int val)
  214. {
  215. int ret;
  216. mutex_lock(&hw->lock);
  217. ret = __write_reg(hw, REG_WRITE_ENABLE, 1);
  218. if (ret) {
  219. dev_err(hw->dev, "failed to set write enable\n");
  220. goto error;
  221. }
  222. ret = __rmw_reg(hw, reg, mask, val);
  223. if (ret)
  224. dev_err(hw->dev, "failed to rmw register %d\n", reg);
  225. ret = __write_reg(hw, REG_WRITE_ENABLE, 0);
  226. if (ret) {
  227. dev_err(hw->dev, "failed to clear write enable\n");
  228. goto error;
  229. }
  230. error:
  231. mutex_unlock(&hw->lock);
  232. return ret;
  233. }
  234. static int read_field(struct tps6524x *hw, const struct field *field)
  235. {
  236. int tmp;
  237. tmp = read_reg(hw, field->reg);
  238. if (tmp < 0)
  239. return tmp;
  240. return (tmp >> field->shift) & field->mask;
  241. }
  242. static int write_field(struct tps6524x *hw, const struct field *field,
  243. int val)
  244. {
  245. if (val & ~field->mask)
  246. return -EOVERFLOW;
  247. return rmw_protect(hw, field->reg,
  248. field->mask << field->shift,
  249. val << field->shift);
  250. }
  251. static const unsigned int dcdc1_voltages[] = {
  252. 800000, 825000, 850000, 875000,
  253. 900000, 925000, 950000, 975000,
  254. 1000000, 1025000, 1050000, 1075000,
  255. 1100000, 1125000, 1150000, 1175000,
  256. 1200000, 1225000, 1250000, 1275000,
  257. 1300000, 1325000, 1350000, 1375000,
  258. 1400000, 1425000, 1450000, 1475000,
  259. 1500000, 1525000, 1550000, 1575000,
  260. };
  261. static const unsigned int dcdc2_voltages[] = {
  262. 1400000, 1450000, 1500000, 1550000,
  263. 1600000, 1650000, 1700000, 1750000,
  264. 1800000, 1850000, 1900000, 1950000,
  265. 2000000, 2050000, 2100000, 2150000,
  266. 2200000, 2250000, 2300000, 2350000,
  267. 2400000, 2450000, 2500000, 2550000,
  268. 2600000, 2650000, 2700000, 2750000,
  269. 2800000, 2850000, 2900000, 2950000,
  270. };
  271. static const unsigned int dcdc3_voltages[] = {
  272. 2400000, 2450000, 2500000, 2550000, 2600000,
  273. 2650000, 2700000, 2750000, 2800000, 2850000,
  274. 2900000, 2950000, 3000000, 3050000, 3100000,
  275. 3150000, 3200000, 3250000, 3300000, 3350000,
  276. 3400000, 3450000, 3500000, 3550000, 3600000,
  277. };
  278. static const unsigned int ldo1_voltages[] = {
  279. 4300000, 4350000, 4400000, 4450000,
  280. 4500000, 4550000, 4600000, 4650000,
  281. 4700000, 4750000, 4800000, 4850000,
  282. 4900000, 4950000, 5000000, 5050000,
  283. };
  284. static const unsigned int ldo2_voltages[] = {
  285. 1100000, 1150000, 1200000, 1250000,
  286. 1300000, 1700000, 1750000, 1800000,
  287. 1850000, 1900000, 3150000, 3200000,
  288. 3250000, 3300000, 3350000, 3400000,
  289. };
  290. static const unsigned int fixed_5000000_voltage[] = {
  291. 5000000
  292. };
  293. static const int ldo_ilimsel[] = {
  294. 400000, 1500000
  295. };
  296. static const int usb_ilimsel[] = {
  297. 200000, 400000, 800000, 1000000
  298. };
  299. #define __MK_FIELD(_reg, _mask, _shift) \
  300. { .reg = (_reg), .mask = (_mask), .shift = (_shift), }
  301. static const struct supply_info supply_info[N_REGULATORS] = {
  302. {
  303. .name = "DCDC1",
  304. .flags = FIXED_ILIMSEL,
  305. .n_voltages = ARRAY_SIZE(dcdc1_voltages),
  306. .voltages = dcdc1_voltages,
  307. .fixed_ilimsel = 2400000,
  308. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  309. DCDCDCDC1_EN_SHIFT),
  310. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  311. DCDC_VDCDC1_SHIFT),
  312. },
  313. {
  314. .name = "DCDC2",
  315. .flags = FIXED_ILIMSEL,
  316. .n_voltages = ARRAY_SIZE(dcdc2_voltages),
  317. .voltages = dcdc2_voltages,
  318. .fixed_ilimsel = 1200000,
  319. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  320. DCDCDCDC2_EN_SHIFT),
  321. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  322. DCDC_VDCDC2_SHIFT),
  323. },
  324. {
  325. .name = "DCDC3",
  326. .flags = FIXED_ILIMSEL,
  327. .n_voltages = ARRAY_SIZE(dcdc3_voltages),
  328. .voltages = dcdc3_voltages,
  329. .fixed_ilimsel = 1200000,
  330. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  331. DCDCDCDC3_EN_SHIFT),
  332. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  333. DCDC_VDCDC3_SHIFT),
  334. },
  335. {
  336. .name = "LDO1",
  337. .n_voltages = ARRAY_SIZE(ldo1_voltages),
  338. .voltages = ldo1_voltages,
  339. .n_ilimsels = ARRAY_SIZE(ldo_ilimsel),
  340. .ilimsels = ldo_ilimsel,
  341. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  342. BLOCK_LDO1_SHIFT),
  343. .voltage = __MK_FIELD(REG_LDO_SET, LDO_VSEL_MASK,
  344. LDO1_VSEL_SHIFT),
  345. .ilimsel = __MK_FIELD(REG_LDO_SET, LDO_ILIM_MASK,
  346. LDO1_ILIM_SHIFT),
  347. },
  348. {
  349. .name = "LDO2",
  350. .n_voltages = ARRAY_SIZE(ldo2_voltages),
  351. .voltages = ldo2_voltages,
  352. .n_ilimsels = ARRAY_SIZE(ldo_ilimsel),
  353. .ilimsels = ldo_ilimsel,
  354. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  355. BLOCK_LDO2_SHIFT),
  356. .voltage = __MK_FIELD(REG_LDO_SET, LDO_VSEL_MASK,
  357. LDO2_VSEL_SHIFT),
  358. .ilimsel = __MK_FIELD(REG_LDO_SET, LDO_ILIM_MASK,
  359. LDO2_ILIM_SHIFT),
  360. },
  361. {
  362. .name = "USB",
  363. .n_voltages = ARRAY_SIZE(fixed_5000000_voltage),
  364. .voltages = fixed_5000000_voltage,
  365. .n_ilimsels = ARRAY_SIZE(usb_ilimsel),
  366. .ilimsels = usb_ilimsel,
  367. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  368. BLOCK_USB_SHIFT),
  369. .ilimsel = __MK_FIELD(REG_USB, USB_ILIM_MASK,
  370. USB_ILIM_SHIFT),
  371. },
  372. {
  373. .name = "LCD",
  374. .n_voltages = ARRAY_SIZE(fixed_5000000_voltage),
  375. .voltages = fixed_5000000_voltage,
  376. .flags = FIXED_ILIMSEL,
  377. .fixed_ilimsel = 400000,
  378. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  379. BLOCK_LCD_SHIFT),
  380. },
  381. };
  382. static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
  383. {
  384. const struct supply_info *info;
  385. struct tps6524x *hw;
  386. hw = rdev_get_drvdata(rdev);
  387. info = &supply_info[rdev_get_id(rdev)];
  388. if (rdev->desc->n_voltages == 1)
  389. return -EINVAL;
  390. return write_field(hw, &info->voltage, selector);
  391. }
  392. static int get_voltage_sel(struct regulator_dev *rdev)
  393. {
  394. const struct supply_info *info;
  395. struct tps6524x *hw;
  396. int ret;
  397. hw = rdev_get_drvdata(rdev);
  398. info = &supply_info[rdev_get_id(rdev)];
  399. if (rdev->desc->n_voltages == 1)
  400. return 0;
  401. ret = read_field(hw, &info->voltage);
  402. if (ret < 0)
  403. return ret;
  404. if (WARN_ON(ret >= info->n_voltages))
  405. return -EIO;
  406. return ret;
  407. }
  408. static int set_current_limit(struct regulator_dev *rdev, int min_uA,
  409. int max_uA)
  410. {
  411. const struct supply_info *info;
  412. struct tps6524x *hw;
  413. int i;
  414. hw = rdev_get_drvdata(rdev);
  415. info = &supply_info[rdev_get_id(rdev)];
  416. if (info->flags & FIXED_ILIMSEL)
  417. return -EINVAL;
  418. for (i = 0; i < info->n_ilimsels; i++)
  419. if (min_uA <= info->ilimsels[i] &&
  420. max_uA >= info->ilimsels[i])
  421. break;
  422. if (i >= info->n_ilimsels)
  423. return -EINVAL;
  424. return write_field(hw, &info->ilimsel, i);
  425. }
  426. static int get_current_limit(struct regulator_dev *rdev)
  427. {
  428. const struct supply_info *info;
  429. struct tps6524x *hw;
  430. int ret;
  431. hw = rdev_get_drvdata(rdev);
  432. info = &supply_info[rdev_get_id(rdev)];
  433. if (info->flags & FIXED_ILIMSEL)
  434. return info->fixed_ilimsel;
  435. ret = read_field(hw, &info->ilimsel);
  436. if (ret < 0)
  437. return ret;
  438. if (WARN_ON(ret >= info->n_ilimsels))
  439. return -EIO;
  440. return info->ilimsels[ret];
  441. }
  442. static int enable_supply(struct regulator_dev *rdev)
  443. {
  444. const struct supply_info *info;
  445. struct tps6524x *hw;
  446. hw = rdev_get_drvdata(rdev);
  447. info = &supply_info[rdev_get_id(rdev)];
  448. return write_field(hw, &info->enable, 1);
  449. }
  450. static int disable_supply(struct regulator_dev *rdev)
  451. {
  452. const struct supply_info *info;
  453. struct tps6524x *hw;
  454. hw = rdev_get_drvdata(rdev);
  455. info = &supply_info[rdev_get_id(rdev)];
  456. return write_field(hw, &info->enable, 0);
  457. }
  458. static int is_supply_enabled(struct regulator_dev *rdev)
  459. {
  460. const struct supply_info *info;
  461. struct tps6524x *hw;
  462. hw = rdev_get_drvdata(rdev);
  463. info = &supply_info[rdev_get_id(rdev)];
  464. return read_field(hw, &info->enable);
  465. }
  466. static struct regulator_ops regulator_ops = {
  467. .is_enabled = is_supply_enabled,
  468. .enable = enable_supply,
  469. .disable = disable_supply,
  470. .get_voltage_sel = get_voltage_sel,
  471. .set_voltage_sel = set_voltage_sel,
  472. .list_voltage = regulator_list_voltage_table,
  473. .set_current_limit = set_current_limit,
  474. .get_current_limit = get_current_limit,
  475. };
  476. static int pmic_remove(struct spi_device *spi)
  477. {
  478. struct tps6524x *hw = spi_get_drvdata(spi);
  479. int i;
  480. if (!hw)
  481. return 0;
  482. for (i = 0; i < N_REGULATORS; i++) {
  483. if (hw->rdev[i])
  484. regulator_unregister(hw->rdev[i]);
  485. hw->rdev[i] = NULL;
  486. }
  487. spi_set_drvdata(spi, NULL);
  488. return 0;
  489. }
  490. static int __devinit pmic_probe(struct spi_device *spi)
  491. {
  492. struct tps6524x *hw;
  493. struct device *dev = &spi->dev;
  494. const struct supply_info *info = supply_info;
  495. struct regulator_init_data *init_data;
  496. struct regulator_config config = { };
  497. int ret = 0, i;
  498. init_data = dev->platform_data;
  499. if (!init_data) {
  500. dev_err(dev, "could not find regulator platform data\n");
  501. return -EINVAL;
  502. }
  503. hw = devm_kzalloc(&spi->dev, sizeof(struct tps6524x), GFP_KERNEL);
  504. if (!hw) {
  505. dev_err(dev, "cannot allocate regulator private data\n");
  506. return -ENOMEM;
  507. }
  508. spi_set_drvdata(spi, hw);
  509. memset(hw, 0, sizeof(struct tps6524x));
  510. hw->dev = dev;
  511. hw->spi = spi_dev_get(spi);
  512. mutex_init(&hw->lock);
  513. for (i = 0; i < N_REGULATORS; i++, info++, init_data++) {
  514. hw->desc[i].name = info->name;
  515. hw->desc[i].id = i;
  516. hw->desc[i].n_voltages = info->n_voltages;
  517. hw->desc[i].volt_table = info->voltages;
  518. hw->desc[i].ops = &regulator_ops;
  519. hw->desc[i].type = REGULATOR_VOLTAGE;
  520. hw->desc[i].owner = THIS_MODULE;
  521. config.dev = dev;
  522. config.init_data = init_data;
  523. config.driver_data = hw;
  524. hw->rdev[i] = regulator_register(&hw->desc[i], &config);
  525. if (IS_ERR(hw->rdev[i])) {
  526. ret = PTR_ERR(hw->rdev[i]);
  527. hw->rdev[i] = NULL;
  528. goto fail;
  529. }
  530. }
  531. return 0;
  532. fail:
  533. pmic_remove(spi);
  534. return ret;
  535. }
  536. static struct spi_driver pmic_driver = {
  537. .probe = pmic_probe,
  538. .remove = __devexit_p(pmic_remove),
  539. .driver = {
  540. .name = "tps6524x",
  541. .owner = THIS_MODULE,
  542. },
  543. };
  544. module_spi_driver(pmic_driver);
  545. MODULE_DESCRIPTION("TPS6524X PMIC Driver");
  546. MODULE_AUTHOR("Cyril Chemparathy");
  547. MODULE_LICENSE("GPL");
  548. MODULE_ALIAS("spi:tps6524x");