tps6524x-regulator.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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 CMD_READ(reg) ((reg) << 6)
  102. #define CMD_WRITE(reg) (BIT(5) | (reg) << 6)
  103. #define STAT_CLK BIT(3)
  104. #define STAT_WRITE BIT(2)
  105. #define STAT_INVALID BIT(1)
  106. #define STAT_WP BIT(0)
  107. struct field {
  108. int reg;
  109. int shift;
  110. int mask;
  111. };
  112. struct supply_info {
  113. const char *name;
  114. int n_voltages;
  115. const unsigned int *voltages;
  116. int n_ilimsels;
  117. const unsigned int *ilimsels;
  118. struct field enable, voltage, ilimsel;
  119. };
  120. struct tps6524x {
  121. struct device *dev;
  122. struct spi_device *spi;
  123. struct mutex lock;
  124. struct regulator_desc desc[N_REGULATORS];
  125. };
  126. static int __read_reg(struct tps6524x *hw, int reg)
  127. {
  128. int error = 0;
  129. u16 cmd = CMD_READ(reg), in;
  130. u8 status;
  131. struct spi_message m;
  132. struct spi_transfer t[3];
  133. spi_message_init(&m);
  134. memset(t, 0, sizeof(t));
  135. t[0].tx_buf = &cmd;
  136. t[0].len = 2;
  137. t[0].bits_per_word = 12;
  138. spi_message_add_tail(&t[0], &m);
  139. t[1].rx_buf = &in;
  140. t[1].len = 2;
  141. t[1].bits_per_word = 16;
  142. spi_message_add_tail(&t[1], &m);
  143. t[2].rx_buf = &status;
  144. t[2].len = 1;
  145. t[2].bits_per_word = 4;
  146. spi_message_add_tail(&t[2], &m);
  147. error = spi_sync(hw->spi, &m);
  148. if (error < 0)
  149. return error;
  150. dev_dbg(hw->dev, "read reg %d, data %x, status %x\n",
  151. reg, in, status);
  152. if (!(status & STAT_CLK) || (status & STAT_WRITE))
  153. return -EIO;
  154. if (status & STAT_INVALID)
  155. return -EINVAL;
  156. return in;
  157. }
  158. static int read_reg(struct tps6524x *hw, int reg)
  159. {
  160. int ret;
  161. mutex_lock(&hw->lock);
  162. ret = __read_reg(hw, reg);
  163. mutex_unlock(&hw->lock);
  164. return ret;
  165. }
  166. static int __write_reg(struct tps6524x *hw, int reg, int val)
  167. {
  168. int error = 0;
  169. u16 cmd = CMD_WRITE(reg), out = val;
  170. u8 status;
  171. struct spi_message m;
  172. struct spi_transfer t[3];
  173. spi_message_init(&m);
  174. memset(t, 0, sizeof(t));
  175. t[0].tx_buf = &cmd;
  176. t[0].len = 2;
  177. t[0].bits_per_word = 12;
  178. spi_message_add_tail(&t[0], &m);
  179. t[1].tx_buf = &out;
  180. t[1].len = 2;
  181. t[1].bits_per_word = 16;
  182. spi_message_add_tail(&t[1], &m);
  183. t[2].rx_buf = &status;
  184. t[2].len = 1;
  185. t[2].bits_per_word = 4;
  186. spi_message_add_tail(&t[2], &m);
  187. error = spi_sync(hw->spi, &m);
  188. if (error < 0)
  189. return error;
  190. dev_dbg(hw->dev, "wrote reg %d, data %x, status %x\n",
  191. reg, out, status);
  192. if (!(status & STAT_CLK) || !(status & STAT_WRITE))
  193. return -EIO;
  194. if (status & (STAT_INVALID | STAT_WP))
  195. return -EINVAL;
  196. return error;
  197. }
  198. static int __rmw_reg(struct tps6524x *hw, int reg, int mask, int val)
  199. {
  200. int ret;
  201. ret = __read_reg(hw, reg);
  202. if (ret < 0)
  203. return ret;
  204. ret &= ~mask;
  205. ret |= val;
  206. ret = __write_reg(hw, reg, ret);
  207. return (ret < 0) ? ret : 0;
  208. }
  209. static int rmw_protect(struct tps6524x *hw, int reg, int mask, int val)
  210. {
  211. int ret;
  212. mutex_lock(&hw->lock);
  213. ret = __write_reg(hw, REG_WRITE_ENABLE, 1);
  214. if (ret) {
  215. dev_err(hw->dev, "failed to set write enable\n");
  216. goto error;
  217. }
  218. ret = __rmw_reg(hw, reg, mask, val);
  219. if (ret)
  220. dev_err(hw->dev, "failed to rmw register %d\n", reg);
  221. ret = __write_reg(hw, REG_WRITE_ENABLE, 0);
  222. if (ret) {
  223. dev_err(hw->dev, "failed to clear write enable\n");
  224. goto error;
  225. }
  226. error:
  227. mutex_unlock(&hw->lock);
  228. return ret;
  229. }
  230. static int read_field(struct tps6524x *hw, const struct field *field)
  231. {
  232. int tmp;
  233. tmp = read_reg(hw, field->reg);
  234. if (tmp < 0)
  235. return tmp;
  236. return (tmp >> field->shift) & field->mask;
  237. }
  238. static int write_field(struct tps6524x *hw, const struct field *field,
  239. int val)
  240. {
  241. if (val & ~field->mask)
  242. return -EOVERFLOW;
  243. return rmw_protect(hw, field->reg,
  244. field->mask << field->shift,
  245. val << field->shift);
  246. }
  247. static const unsigned int dcdc1_voltages[] = {
  248. 800000, 825000, 850000, 875000,
  249. 900000, 925000, 950000, 975000,
  250. 1000000, 1025000, 1050000, 1075000,
  251. 1100000, 1125000, 1150000, 1175000,
  252. 1200000, 1225000, 1250000, 1275000,
  253. 1300000, 1325000, 1350000, 1375000,
  254. 1400000, 1425000, 1450000, 1475000,
  255. 1500000, 1525000, 1550000, 1575000,
  256. };
  257. static const unsigned int dcdc2_voltages[] = {
  258. 1400000, 1450000, 1500000, 1550000,
  259. 1600000, 1650000, 1700000, 1750000,
  260. 1800000, 1850000, 1900000, 1950000,
  261. 2000000, 2050000, 2100000, 2150000,
  262. 2200000, 2250000, 2300000, 2350000,
  263. 2400000, 2450000, 2500000, 2550000,
  264. 2600000, 2650000, 2700000, 2750000,
  265. 2800000, 2850000, 2900000, 2950000,
  266. };
  267. static const unsigned int dcdc3_voltages[] = {
  268. 2400000, 2450000, 2500000, 2550000, 2600000,
  269. 2650000, 2700000, 2750000, 2800000, 2850000,
  270. 2900000, 2950000, 3000000, 3050000, 3100000,
  271. 3150000, 3200000, 3250000, 3300000, 3350000,
  272. 3400000, 3450000, 3500000, 3550000, 3600000,
  273. };
  274. static const unsigned int ldo1_voltages[] = {
  275. 4300000, 4350000, 4400000, 4450000,
  276. 4500000, 4550000, 4600000, 4650000,
  277. 4700000, 4750000, 4800000, 4850000,
  278. 4900000, 4950000, 5000000, 5050000,
  279. };
  280. static const unsigned int ldo2_voltages[] = {
  281. 1100000, 1150000, 1200000, 1250000,
  282. 1300000, 1700000, 1750000, 1800000,
  283. 1850000, 1900000, 3150000, 3200000,
  284. 3250000, 3300000, 3350000, 3400000,
  285. };
  286. static const unsigned int fixed_5000000_voltage[] = {
  287. 5000000
  288. };
  289. static const unsigned int ldo_ilimsel[] = {
  290. 400000, 1500000
  291. };
  292. static const unsigned int usb_ilimsel[] = {
  293. 200000, 400000, 800000, 1000000
  294. };
  295. static const unsigned int fixed_2400000_ilimsel[] = {
  296. 2400000
  297. };
  298. static const unsigned int fixed_1200000_ilimsel[] = {
  299. 1200000
  300. };
  301. static const unsigned int fixed_400000_ilimsel[] = {
  302. 400000
  303. };
  304. #define __MK_FIELD(_reg, _mask, _shift) \
  305. { .reg = (_reg), .mask = (_mask), .shift = (_shift), }
  306. static const struct supply_info supply_info[N_REGULATORS] = {
  307. {
  308. .name = "DCDC1",
  309. .n_voltages = ARRAY_SIZE(dcdc1_voltages),
  310. .voltages = dcdc1_voltages,
  311. .n_ilimsels = ARRAY_SIZE(fixed_2400000_ilimsel),
  312. .ilimsels = fixed_2400000_ilimsel,
  313. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  314. DCDCDCDC1_EN_SHIFT),
  315. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  316. DCDC_VDCDC1_SHIFT),
  317. },
  318. {
  319. .name = "DCDC2",
  320. .n_voltages = ARRAY_SIZE(dcdc2_voltages),
  321. .voltages = dcdc2_voltages,
  322. .n_ilimsels = ARRAY_SIZE(fixed_1200000_ilimsel),
  323. .ilimsels = fixed_1200000_ilimsel,
  324. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  325. DCDCDCDC2_EN_SHIFT),
  326. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  327. DCDC_VDCDC2_SHIFT),
  328. },
  329. {
  330. .name = "DCDC3",
  331. .n_voltages = ARRAY_SIZE(dcdc3_voltages),
  332. .voltages = dcdc3_voltages,
  333. .n_ilimsels = ARRAY_SIZE(fixed_1200000_ilimsel),
  334. .ilimsels = fixed_1200000_ilimsel,
  335. .enable = __MK_FIELD(REG_DCDC_EN, DCDCDCDC_EN_MASK,
  336. DCDCDCDC3_EN_SHIFT),
  337. .voltage = __MK_FIELD(REG_DCDC_SET, DCDC_VDCDC_MASK,
  338. DCDC_VDCDC3_SHIFT),
  339. },
  340. {
  341. .name = "LDO1",
  342. .n_voltages = ARRAY_SIZE(ldo1_voltages),
  343. .voltages = ldo1_voltages,
  344. .n_ilimsels = ARRAY_SIZE(ldo_ilimsel),
  345. .ilimsels = ldo_ilimsel,
  346. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  347. BLOCK_LDO1_SHIFT),
  348. .voltage = __MK_FIELD(REG_LDO_SET, LDO_VSEL_MASK,
  349. LDO1_VSEL_SHIFT),
  350. .ilimsel = __MK_FIELD(REG_LDO_SET, LDO_ILIM_MASK,
  351. LDO1_ILIM_SHIFT),
  352. },
  353. {
  354. .name = "LDO2",
  355. .n_voltages = ARRAY_SIZE(ldo2_voltages),
  356. .voltages = ldo2_voltages,
  357. .n_ilimsels = ARRAY_SIZE(ldo_ilimsel),
  358. .ilimsels = ldo_ilimsel,
  359. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  360. BLOCK_LDO2_SHIFT),
  361. .voltage = __MK_FIELD(REG_LDO_SET, LDO_VSEL_MASK,
  362. LDO2_VSEL_SHIFT),
  363. .ilimsel = __MK_FIELD(REG_LDO_SET, LDO_ILIM_MASK,
  364. LDO2_ILIM_SHIFT),
  365. },
  366. {
  367. .name = "USB",
  368. .n_voltages = ARRAY_SIZE(fixed_5000000_voltage),
  369. .voltages = fixed_5000000_voltage,
  370. .n_ilimsels = ARRAY_SIZE(usb_ilimsel),
  371. .ilimsels = usb_ilimsel,
  372. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  373. BLOCK_USB_SHIFT),
  374. .ilimsel = __MK_FIELD(REG_USB, USB_ILIM_MASK,
  375. USB_ILIM_SHIFT),
  376. },
  377. {
  378. .name = "LCD",
  379. .n_voltages = ARRAY_SIZE(fixed_5000000_voltage),
  380. .voltages = fixed_5000000_voltage,
  381. .n_ilimsels = ARRAY_SIZE(fixed_400000_ilimsel),
  382. .ilimsels = fixed_400000_ilimsel,
  383. .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK,
  384. BLOCK_LCD_SHIFT),
  385. },
  386. };
  387. static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
  388. {
  389. const struct supply_info *info;
  390. struct tps6524x *hw;
  391. hw = rdev_get_drvdata(rdev);
  392. info = &supply_info[rdev_get_id(rdev)];
  393. if (rdev->desc->n_voltages == 1)
  394. return -EINVAL;
  395. return write_field(hw, &info->voltage, selector);
  396. }
  397. static int get_voltage_sel(struct regulator_dev *rdev)
  398. {
  399. const struct supply_info *info;
  400. struct tps6524x *hw;
  401. int ret;
  402. hw = rdev_get_drvdata(rdev);
  403. info = &supply_info[rdev_get_id(rdev)];
  404. if (rdev->desc->n_voltages == 1)
  405. return 0;
  406. ret = read_field(hw, &info->voltage);
  407. if (ret < 0)
  408. return ret;
  409. if (WARN_ON(ret >= info->n_voltages))
  410. return -EIO;
  411. return ret;
  412. }
  413. static int set_current_limit(struct regulator_dev *rdev, int min_uA,
  414. int max_uA)
  415. {
  416. const struct supply_info *info;
  417. struct tps6524x *hw;
  418. int i;
  419. hw = rdev_get_drvdata(rdev);
  420. info = &supply_info[rdev_get_id(rdev)];
  421. if (info->n_ilimsels == 1)
  422. return -EINVAL;
  423. for (i = info->n_ilimsels - 1; i >= 0; i--) {
  424. if (min_uA <= info->ilimsels[i] &&
  425. max_uA >= info->ilimsels[i])
  426. return write_field(hw, &info->ilimsel, i);
  427. }
  428. return -EINVAL;
  429. }
  430. static int get_current_limit(struct regulator_dev *rdev)
  431. {
  432. const struct supply_info *info;
  433. struct tps6524x *hw;
  434. int ret;
  435. hw = rdev_get_drvdata(rdev);
  436. info = &supply_info[rdev_get_id(rdev)];
  437. if (info->n_ilimsels == 1)
  438. return info->ilimsels[0];
  439. ret = read_field(hw, &info->ilimsel);
  440. if (ret < 0)
  441. return ret;
  442. if (WARN_ON(ret >= info->n_ilimsels))
  443. return -EIO;
  444. return info->ilimsels[ret];
  445. }
  446. static int enable_supply(struct regulator_dev *rdev)
  447. {
  448. const struct supply_info *info;
  449. struct tps6524x *hw;
  450. hw = rdev_get_drvdata(rdev);
  451. info = &supply_info[rdev_get_id(rdev)];
  452. return write_field(hw, &info->enable, 1);
  453. }
  454. static int disable_supply(struct regulator_dev *rdev)
  455. {
  456. const struct supply_info *info;
  457. struct tps6524x *hw;
  458. hw = rdev_get_drvdata(rdev);
  459. info = &supply_info[rdev_get_id(rdev)];
  460. return write_field(hw, &info->enable, 0);
  461. }
  462. static int is_supply_enabled(struct regulator_dev *rdev)
  463. {
  464. const struct supply_info *info;
  465. struct tps6524x *hw;
  466. hw = rdev_get_drvdata(rdev);
  467. info = &supply_info[rdev_get_id(rdev)];
  468. return read_field(hw, &info->enable);
  469. }
  470. static const struct regulator_ops regulator_ops = {
  471. .is_enabled = is_supply_enabled,
  472. .enable = enable_supply,
  473. .disable = disable_supply,
  474. .get_voltage_sel = get_voltage_sel,
  475. .set_voltage_sel = set_voltage_sel,
  476. .list_voltage = regulator_list_voltage_table,
  477. .map_voltage = regulator_map_voltage_ascend,
  478. .set_current_limit = set_current_limit,
  479. .get_current_limit = get_current_limit,
  480. };
  481. static int pmic_probe(struct spi_device *spi)
  482. {
  483. struct tps6524x *hw;
  484. struct device *dev = &spi->dev;
  485. const struct supply_info *info = supply_info;
  486. struct regulator_init_data *init_data;
  487. struct regulator_config config = { };
  488. struct regulator_dev *rdev;
  489. int i;
  490. init_data = dev_get_platdata(dev);
  491. if (!init_data) {
  492. dev_err(dev, "could not find regulator platform data\n");
  493. return -EINVAL;
  494. }
  495. hw = devm_kzalloc(&spi->dev, sizeof(struct tps6524x), GFP_KERNEL);
  496. if (!hw)
  497. return -ENOMEM;
  498. spi_set_drvdata(spi, hw);
  499. memset(hw, 0, sizeof(struct tps6524x));
  500. hw->dev = dev;
  501. hw->spi = spi;
  502. mutex_init(&hw->lock);
  503. for (i = 0; i < N_REGULATORS; i++, info++, init_data++) {
  504. hw->desc[i].name = info->name;
  505. hw->desc[i].id = i;
  506. hw->desc[i].n_voltages = info->n_voltages;
  507. hw->desc[i].volt_table = info->voltages;
  508. hw->desc[i].ops = &regulator_ops;
  509. hw->desc[i].type = REGULATOR_VOLTAGE;
  510. hw->desc[i].owner = THIS_MODULE;
  511. config.dev = dev;
  512. config.init_data = init_data;
  513. config.driver_data = hw;
  514. rdev = devm_regulator_register(dev, &hw->desc[i], &config);
  515. if (IS_ERR(rdev))
  516. return PTR_ERR(rdev);
  517. }
  518. return 0;
  519. }
  520. static struct spi_driver pmic_driver = {
  521. .probe = pmic_probe,
  522. .driver = {
  523. .name = "tps6524x",
  524. },
  525. };
  526. module_spi_driver(pmic_driver);
  527. MODULE_DESCRIPTION("TPS6524X PMIC Driver");
  528. MODULE_AUTHOR("Cyril Chemparathy");
  529. MODULE_LICENSE("GPL");
  530. MODULE_ALIAS("spi:tps6524x");