wm831x-core.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365
  1. /*
  2. * wm831x-core.c -- Device access for Wolfson WM831x PMICs
  3. *
  4. * Copyright 2009 Wolfson Microelectronics PLC.
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/i2c.h>
  17. #include <linux/mfd/core.h>
  18. #include <linux/mfd/wm831x/core.h>
  19. #include <linux/mfd/wm831x/pdata.h>
  20. #include <linux/mfd/wm831x/irq.h>
  21. enum wm831x_parent {
  22. WM8310 = 0,
  23. WM8311 = 1,
  24. WM8312 = 2,
  25. };
  26. static int wm831x_reg_locked(struct wm831x *wm831x, unsigned short reg)
  27. {
  28. if (!wm831x->locked)
  29. return 0;
  30. switch (reg) {
  31. case WM831X_WATCHDOG:
  32. case WM831X_DC4_CONTROL:
  33. case WM831X_ON_PIN_CONTROL:
  34. case WM831X_BACKUP_CHARGER_CONTROL:
  35. case WM831X_CHARGER_CONTROL_1:
  36. case WM831X_CHARGER_CONTROL_2:
  37. return 1;
  38. default:
  39. return 0;
  40. }
  41. }
  42. /**
  43. * wm831x_reg_unlock: Unlock user keyed registers
  44. *
  45. * The WM831x has a user key preventing writes to particularly
  46. * critical registers. This function locks those registers,
  47. * allowing writes to them.
  48. */
  49. void wm831x_reg_lock(struct wm831x *wm831x)
  50. {
  51. int ret;
  52. ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
  53. if (ret == 0) {
  54. dev_vdbg(wm831x->dev, "Registers locked\n");
  55. mutex_lock(&wm831x->io_lock);
  56. WARN_ON(wm831x->locked);
  57. wm831x->locked = 1;
  58. mutex_unlock(&wm831x->io_lock);
  59. } else {
  60. dev_err(wm831x->dev, "Failed to lock registers: %d\n", ret);
  61. }
  62. }
  63. EXPORT_SYMBOL_GPL(wm831x_reg_lock);
  64. /**
  65. * wm831x_reg_unlock: Unlock user keyed registers
  66. *
  67. * The WM831x has a user key preventing writes to particularly
  68. * critical registers. This function locks those registers,
  69. * preventing spurious writes.
  70. */
  71. int wm831x_reg_unlock(struct wm831x *wm831x)
  72. {
  73. int ret;
  74. /* 0x9716 is the value required to unlock the registers */
  75. ret = wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0x9716);
  76. if (ret == 0) {
  77. dev_vdbg(wm831x->dev, "Registers unlocked\n");
  78. mutex_lock(&wm831x->io_lock);
  79. WARN_ON(!wm831x->locked);
  80. wm831x->locked = 0;
  81. mutex_unlock(&wm831x->io_lock);
  82. }
  83. return ret;
  84. }
  85. EXPORT_SYMBOL_GPL(wm831x_reg_unlock);
  86. static int wm831x_read(struct wm831x *wm831x, unsigned short reg,
  87. int bytes, void *dest)
  88. {
  89. int ret, i;
  90. u16 *buf = dest;
  91. BUG_ON(bytes % 2);
  92. BUG_ON(bytes <= 0);
  93. ret = wm831x->read_dev(wm831x, reg, bytes, dest);
  94. if (ret < 0)
  95. return ret;
  96. for (i = 0; i < bytes / 2; i++) {
  97. buf[i] = be16_to_cpu(buf[i]);
  98. dev_vdbg(wm831x->dev, "Read %04x from R%d(0x%x)\n",
  99. buf[i], reg + i, reg + i);
  100. }
  101. return 0;
  102. }
  103. /**
  104. * wm831x_reg_read: Read a single WM831x register.
  105. *
  106. * @wm831x: Device to read from.
  107. * @reg: Register to read.
  108. */
  109. int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg)
  110. {
  111. unsigned short val;
  112. int ret;
  113. mutex_lock(&wm831x->io_lock);
  114. ret = wm831x_read(wm831x, reg, 2, &val);
  115. mutex_unlock(&wm831x->io_lock);
  116. if (ret < 0)
  117. return ret;
  118. else
  119. return val;
  120. }
  121. EXPORT_SYMBOL_GPL(wm831x_reg_read);
  122. /**
  123. * wm831x_bulk_read: Read multiple WM831x registers
  124. *
  125. * @wm831x: Device to read from
  126. * @reg: First register
  127. * @count: Number of registers
  128. * @buf: Buffer to fill.
  129. */
  130. int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
  131. int count, u16 *buf)
  132. {
  133. int ret;
  134. mutex_lock(&wm831x->io_lock);
  135. ret = wm831x_read(wm831x, reg, count * 2, buf);
  136. mutex_unlock(&wm831x->io_lock);
  137. return ret;
  138. }
  139. EXPORT_SYMBOL_GPL(wm831x_bulk_read);
  140. static int wm831x_write(struct wm831x *wm831x, unsigned short reg,
  141. int bytes, void *src)
  142. {
  143. u16 *buf = src;
  144. int i;
  145. BUG_ON(bytes % 2);
  146. BUG_ON(bytes <= 0);
  147. for (i = 0; i < bytes / 2; i++) {
  148. if (wm831x_reg_locked(wm831x, reg))
  149. return -EPERM;
  150. dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n",
  151. buf[i], reg + i, reg + i);
  152. buf[i] = cpu_to_be16(buf[i]);
  153. }
  154. return wm831x->write_dev(wm831x, reg, bytes, src);
  155. }
  156. /**
  157. * wm831x_reg_write: Write a single WM831x register.
  158. *
  159. * @wm831x: Device to write to.
  160. * @reg: Register to write to.
  161. * @val: Value to write.
  162. */
  163. int wm831x_reg_write(struct wm831x *wm831x, unsigned short reg,
  164. unsigned short val)
  165. {
  166. int ret;
  167. mutex_lock(&wm831x->io_lock);
  168. ret = wm831x_write(wm831x, reg, 2, &val);
  169. mutex_unlock(&wm831x->io_lock);
  170. return ret;
  171. }
  172. EXPORT_SYMBOL_GPL(wm831x_reg_write);
  173. /**
  174. * wm831x_set_bits: Set the value of a bitfield in a WM831x register
  175. *
  176. * @wm831x: Device to write to.
  177. * @reg: Register to write to.
  178. * @mask: Mask of bits to set.
  179. * @val: Value to set (unshifted)
  180. */
  181. int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
  182. unsigned short mask, unsigned short val)
  183. {
  184. int ret;
  185. u16 r;
  186. mutex_lock(&wm831x->io_lock);
  187. ret = wm831x_read(wm831x, reg, 2, &r);
  188. if (ret < 0)
  189. goto out;
  190. r &= ~mask;
  191. r |= val;
  192. ret = wm831x_write(wm831x, reg, 2, &r);
  193. out:
  194. mutex_unlock(&wm831x->io_lock);
  195. return ret;
  196. }
  197. EXPORT_SYMBOL_GPL(wm831x_set_bits);
  198. static struct resource wm831x_dcdc1_resources[] = {
  199. {
  200. .start = WM831X_DC1_CONTROL_1,
  201. .end = WM831X_DC1_DVS_CONTROL,
  202. .flags = IORESOURCE_IO,
  203. },
  204. {
  205. .name = "UV",
  206. .start = WM831X_IRQ_UV_DC1,
  207. .end = WM831X_IRQ_UV_DC1,
  208. .flags = IORESOURCE_IRQ,
  209. },
  210. {
  211. .name = "HC",
  212. .start = WM831X_IRQ_HC_DC1,
  213. .end = WM831X_IRQ_HC_DC1,
  214. .flags = IORESOURCE_IRQ,
  215. },
  216. };
  217. static struct resource wm831x_dcdc2_resources[] = {
  218. {
  219. .start = WM831X_DC2_CONTROL_1,
  220. .end = WM831X_DC2_DVS_CONTROL,
  221. .flags = IORESOURCE_IO,
  222. },
  223. {
  224. .name = "UV",
  225. .start = WM831X_IRQ_UV_DC2,
  226. .end = WM831X_IRQ_UV_DC2,
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. {
  230. .name = "HC",
  231. .start = WM831X_IRQ_HC_DC2,
  232. .end = WM831X_IRQ_HC_DC2,
  233. .flags = IORESOURCE_IRQ,
  234. },
  235. };
  236. static struct resource wm831x_dcdc3_resources[] = {
  237. {
  238. .start = WM831X_DC3_CONTROL_1,
  239. .end = WM831X_DC3_SLEEP_CONTROL,
  240. .flags = IORESOURCE_IO,
  241. },
  242. {
  243. .name = "UV",
  244. .start = WM831X_IRQ_UV_DC3,
  245. .end = WM831X_IRQ_UV_DC3,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. };
  249. static struct resource wm831x_dcdc4_resources[] = {
  250. {
  251. .start = WM831X_DC4_CONTROL,
  252. .end = WM831X_DC4_SLEEP_CONTROL,
  253. .flags = IORESOURCE_IO,
  254. },
  255. {
  256. .name = "UV",
  257. .start = WM831X_IRQ_UV_DC4,
  258. .end = WM831X_IRQ_UV_DC4,
  259. .flags = IORESOURCE_IRQ,
  260. },
  261. };
  262. static struct resource wm831x_gpio_resources[] = {
  263. {
  264. .start = WM831X_IRQ_GPIO_1,
  265. .end = WM831X_IRQ_GPIO_16,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. };
  269. static struct resource wm831x_isink1_resources[] = {
  270. {
  271. .start = WM831X_CURRENT_SINK_1,
  272. .end = WM831X_CURRENT_SINK_1,
  273. .flags = IORESOURCE_IO,
  274. },
  275. {
  276. .start = WM831X_IRQ_CS1,
  277. .end = WM831X_IRQ_CS1,
  278. .flags = IORESOURCE_IRQ,
  279. },
  280. };
  281. static struct resource wm831x_isink2_resources[] = {
  282. {
  283. .start = WM831X_CURRENT_SINK_2,
  284. .end = WM831X_CURRENT_SINK_2,
  285. .flags = IORESOURCE_IO,
  286. },
  287. {
  288. .start = WM831X_IRQ_CS2,
  289. .end = WM831X_IRQ_CS2,
  290. .flags = IORESOURCE_IRQ,
  291. },
  292. };
  293. static struct resource wm831x_ldo1_resources[] = {
  294. {
  295. .start = WM831X_LDO1_CONTROL,
  296. .end = WM831X_LDO1_SLEEP_CONTROL,
  297. .flags = IORESOURCE_IO,
  298. },
  299. {
  300. .name = "UV",
  301. .start = WM831X_IRQ_UV_LDO1,
  302. .end = WM831X_IRQ_UV_LDO1,
  303. .flags = IORESOURCE_IRQ,
  304. },
  305. };
  306. static struct resource wm831x_ldo2_resources[] = {
  307. {
  308. .start = WM831X_LDO2_CONTROL,
  309. .end = WM831X_LDO2_SLEEP_CONTROL,
  310. .flags = IORESOURCE_IO,
  311. },
  312. {
  313. .name = "UV",
  314. .start = WM831X_IRQ_UV_LDO2,
  315. .end = WM831X_IRQ_UV_LDO2,
  316. .flags = IORESOURCE_IRQ,
  317. },
  318. };
  319. static struct resource wm831x_ldo3_resources[] = {
  320. {
  321. .start = WM831X_LDO3_CONTROL,
  322. .end = WM831X_LDO3_SLEEP_CONTROL,
  323. .flags = IORESOURCE_IO,
  324. },
  325. {
  326. .name = "UV",
  327. .start = WM831X_IRQ_UV_LDO3,
  328. .end = WM831X_IRQ_UV_LDO3,
  329. .flags = IORESOURCE_IRQ,
  330. },
  331. };
  332. static struct resource wm831x_ldo4_resources[] = {
  333. {
  334. .start = WM831X_LDO4_CONTROL,
  335. .end = WM831X_LDO4_SLEEP_CONTROL,
  336. .flags = IORESOURCE_IO,
  337. },
  338. {
  339. .name = "UV",
  340. .start = WM831X_IRQ_UV_LDO4,
  341. .end = WM831X_IRQ_UV_LDO4,
  342. .flags = IORESOURCE_IRQ,
  343. },
  344. };
  345. static struct resource wm831x_ldo5_resources[] = {
  346. {
  347. .start = WM831X_LDO5_CONTROL,
  348. .end = WM831X_LDO5_SLEEP_CONTROL,
  349. .flags = IORESOURCE_IO,
  350. },
  351. {
  352. .name = "UV",
  353. .start = WM831X_IRQ_UV_LDO5,
  354. .end = WM831X_IRQ_UV_LDO5,
  355. .flags = IORESOURCE_IRQ,
  356. },
  357. };
  358. static struct resource wm831x_ldo6_resources[] = {
  359. {
  360. .start = WM831X_LDO6_CONTROL,
  361. .end = WM831X_LDO6_SLEEP_CONTROL,
  362. .flags = IORESOURCE_IO,
  363. },
  364. {
  365. .name = "UV",
  366. .start = WM831X_IRQ_UV_LDO6,
  367. .end = WM831X_IRQ_UV_LDO6,
  368. .flags = IORESOURCE_IRQ,
  369. },
  370. };
  371. static struct resource wm831x_ldo7_resources[] = {
  372. {
  373. .start = WM831X_LDO7_CONTROL,
  374. .end = WM831X_LDO7_SLEEP_CONTROL,
  375. .flags = IORESOURCE_IO,
  376. },
  377. {
  378. .name = "UV",
  379. .start = WM831X_IRQ_UV_LDO7,
  380. .end = WM831X_IRQ_UV_LDO7,
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. };
  384. static struct resource wm831x_ldo8_resources[] = {
  385. {
  386. .start = WM831X_LDO8_CONTROL,
  387. .end = WM831X_LDO8_SLEEP_CONTROL,
  388. .flags = IORESOURCE_IO,
  389. },
  390. {
  391. .name = "UV",
  392. .start = WM831X_IRQ_UV_LDO8,
  393. .end = WM831X_IRQ_UV_LDO8,
  394. .flags = IORESOURCE_IRQ,
  395. },
  396. };
  397. static struct resource wm831x_ldo9_resources[] = {
  398. {
  399. .start = WM831X_LDO9_CONTROL,
  400. .end = WM831X_LDO9_SLEEP_CONTROL,
  401. .flags = IORESOURCE_IO,
  402. },
  403. {
  404. .name = "UV",
  405. .start = WM831X_IRQ_UV_LDO9,
  406. .end = WM831X_IRQ_UV_LDO9,
  407. .flags = IORESOURCE_IRQ,
  408. },
  409. };
  410. static struct resource wm831x_ldo10_resources[] = {
  411. {
  412. .start = WM831X_LDO10_CONTROL,
  413. .end = WM831X_LDO10_SLEEP_CONTROL,
  414. .flags = IORESOURCE_IO,
  415. },
  416. {
  417. .name = "UV",
  418. .start = WM831X_IRQ_UV_LDO10,
  419. .end = WM831X_IRQ_UV_LDO10,
  420. .flags = IORESOURCE_IRQ,
  421. },
  422. };
  423. static struct resource wm831x_ldo11_resources[] = {
  424. {
  425. .start = WM831X_LDO11_ON_CONTROL,
  426. .end = WM831X_LDO11_SLEEP_CONTROL,
  427. .flags = IORESOURCE_IO,
  428. },
  429. };
  430. static struct resource wm831x_on_resources[] = {
  431. {
  432. .start = WM831X_IRQ_ON,
  433. .end = WM831X_IRQ_ON,
  434. .flags = IORESOURCE_IRQ,
  435. },
  436. };
  437. static struct resource wm831x_power_resources[] = {
  438. {
  439. .name = "SYSLO",
  440. .start = WM831X_IRQ_PPM_SYSLO,
  441. .end = WM831X_IRQ_PPM_SYSLO,
  442. .flags = IORESOURCE_IRQ,
  443. },
  444. {
  445. .name = "PWR SRC",
  446. .start = WM831X_IRQ_PPM_PWR_SRC,
  447. .end = WM831X_IRQ_PPM_PWR_SRC,
  448. .flags = IORESOURCE_IRQ,
  449. },
  450. {
  451. .name = "USB CURR",
  452. .start = WM831X_IRQ_PPM_USB_CURR,
  453. .end = WM831X_IRQ_PPM_USB_CURR,
  454. .flags = IORESOURCE_IRQ,
  455. },
  456. {
  457. .name = "BATT HOT",
  458. .start = WM831X_IRQ_CHG_BATT_HOT,
  459. .end = WM831X_IRQ_CHG_BATT_HOT,
  460. .flags = IORESOURCE_IRQ,
  461. },
  462. {
  463. .name = "BATT COLD",
  464. .start = WM831X_IRQ_CHG_BATT_COLD,
  465. .end = WM831X_IRQ_CHG_BATT_COLD,
  466. .flags = IORESOURCE_IRQ,
  467. },
  468. {
  469. .name = "BATT FAIL",
  470. .start = WM831X_IRQ_CHG_BATT_FAIL,
  471. .end = WM831X_IRQ_CHG_BATT_FAIL,
  472. .flags = IORESOURCE_IRQ,
  473. },
  474. {
  475. .name = "OV",
  476. .start = WM831X_IRQ_CHG_OV,
  477. .end = WM831X_IRQ_CHG_OV,
  478. .flags = IORESOURCE_IRQ,
  479. },
  480. {
  481. .name = "END",
  482. .start = WM831X_IRQ_CHG_END,
  483. .end = WM831X_IRQ_CHG_END,
  484. .flags = IORESOURCE_IRQ,
  485. },
  486. {
  487. .name = "TO",
  488. .start = WM831X_IRQ_CHG_TO,
  489. .end = WM831X_IRQ_CHG_TO,
  490. .flags = IORESOURCE_IRQ,
  491. },
  492. {
  493. .name = "MODE",
  494. .start = WM831X_IRQ_CHG_MODE,
  495. .end = WM831X_IRQ_CHG_MODE,
  496. .flags = IORESOURCE_IRQ,
  497. },
  498. {
  499. .name = "START",
  500. .start = WM831X_IRQ_CHG_START,
  501. .end = WM831X_IRQ_CHG_START,
  502. .flags = IORESOURCE_IRQ,
  503. },
  504. };
  505. static struct resource wm831x_rtc_resources[] = {
  506. {
  507. .name = "PER",
  508. .start = WM831X_IRQ_RTC_PER,
  509. .end = WM831X_IRQ_RTC_PER,
  510. .flags = IORESOURCE_IRQ,
  511. },
  512. {
  513. .name = "ALM",
  514. .start = WM831X_IRQ_RTC_ALM,
  515. .end = WM831X_IRQ_RTC_ALM,
  516. .flags = IORESOURCE_IRQ,
  517. },
  518. };
  519. static struct resource wm831x_status1_resources[] = {
  520. {
  521. .start = WM831X_STATUS_LED_1,
  522. .end = WM831X_STATUS_LED_1,
  523. .flags = IORESOURCE_IO,
  524. },
  525. };
  526. static struct resource wm831x_status2_resources[] = {
  527. {
  528. .start = WM831X_STATUS_LED_2,
  529. .end = WM831X_STATUS_LED_2,
  530. .flags = IORESOURCE_IO,
  531. },
  532. };
  533. static struct resource wm831x_touch_resources[] = {
  534. {
  535. .name = "TCHPD",
  536. .start = WM831X_IRQ_TCHPD,
  537. .end = WM831X_IRQ_TCHPD,
  538. .flags = IORESOURCE_IRQ,
  539. },
  540. {
  541. .name = "TCHDATA",
  542. .start = WM831X_IRQ_TCHDATA,
  543. .end = WM831X_IRQ_TCHDATA,
  544. .flags = IORESOURCE_IRQ,
  545. },
  546. };
  547. static struct resource wm831x_wdt_resources[] = {
  548. {
  549. .start = WM831X_IRQ_WDOG_TO,
  550. .end = WM831X_IRQ_WDOG_TO,
  551. .flags = IORESOURCE_IRQ,
  552. },
  553. };
  554. static struct mfd_cell wm8310_devs[] = {
  555. {
  556. .name = "wm831x-buckv",
  557. .id = 1,
  558. .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
  559. .resources = wm831x_dcdc1_resources,
  560. },
  561. {
  562. .name = "wm831x-buckv",
  563. .id = 2,
  564. .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
  565. .resources = wm831x_dcdc2_resources,
  566. },
  567. {
  568. .name = "wm831x-buckp",
  569. .id = 3,
  570. .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
  571. .resources = wm831x_dcdc3_resources,
  572. },
  573. {
  574. .name = "wm831x-boostp",
  575. .id = 4,
  576. .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
  577. .resources = wm831x_dcdc4_resources,
  578. },
  579. {
  580. .name = "wm831x-epe",
  581. .id = 1,
  582. },
  583. {
  584. .name = "wm831x-epe",
  585. .id = 2,
  586. },
  587. {
  588. .name = "wm831x-gpio",
  589. .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
  590. .resources = wm831x_gpio_resources,
  591. },
  592. {
  593. .name = "wm831x-hwmon",
  594. },
  595. {
  596. .name = "wm831x-isink",
  597. .id = 1,
  598. .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
  599. .resources = wm831x_isink1_resources,
  600. },
  601. {
  602. .name = "wm831x-isink",
  603. .id = 2,
  604. .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
  605. .resources = wm831x_isink2_resources,
  606. },
  607. {
  608. .name = "wm831x-ldo",
  609. .id = 1,
  610. .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
  611. .resources = wm831x_ldo1_resources,
  612. },
  613. {
  614. .name = "wm831x-ldo",
  615. .id = 2,
  616. .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
  617. .resources = wm831x_ldo2_resources,
  618. },
  619. {
  620. .name = "wm831x-ldo",
  621. .id = 3,
  622. .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
  623. .resources = wm831x_ldo3_resources,
  624. },
  625. {
  626. .name = "wm831x-ldo",
  627. .id = 4,
  628. .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
  629. .resources = wm831x_ldo4_resources,
  630. },
  631. {
  632. .name = "wm831x-ldo",
  633. .id = 5,
  634. .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
  635. .resources = wm831x_ldo5_resources,
  636. },
  637. {
  638. .name = "wm831x-ldo",
  639. .id = 6,
  640. .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
  641. .resources = wm831x_ldo6_resources,
  642. },
  643. {
  644. .name = "wm831x-aldo",
  645. .id = 7,
  646. .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
  647. .resources = wm831x_ldo7_resources,
  648. },
  649. {
  650. .name = "wm831x-aldo",
  651. .id = 8,
  652. .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
  653. .resources = wm831x_ldo8_resources,
  654. },
  655. {
  656. .name = "wm831x-aldo",
  657. .id = 9,
  658. .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
  659. .resources = wm831x_ldo9_resources,
  660. },
  661. {
  662. .name = "wm831x-aldo",
  663. .id = 10,
  664. .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
  665. .resources = wm831x_ldo10_resources,
  666. },
  667. {
  668. .name = "wm831x-alive-ldo",
  669. .id = 11,
  670. .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
  671. .resources = wm831x_ldo11_resources,
  672. },
  673. {
  674. .name = "wm831x-on",
  675. .num_resources = ARRAY_SIZE(wm831x_on_resources),
  676. .resources = wm831x_on_resources,
  677. },
  678. {
  679. .name = "wm831x-power",
  680. .num_resources = ARRAY_SIZE(wm831x_power_resources),
  681. .resources = wm831x_power_resources,
  682. },
  683. {
  684. .name = "wm831x-rtc",
  685. .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
  686. .resources = wm831x_rtc_resources,
  687. },
  688. {
  689. .name = "wm831x-status",
  690. .id = 1,
  691. .num_resources = ARRAY_SIZE(wm831x_status1_resources),
  692. .resources = wm831x_status1_resources,
  693. },
  694. {
  695. .name = "wm831x-status",
  696. .id = 2,
  697. .num_resources = ARRAY_SIZE(wm831x_status2_resources),
  698. .resources = wm831x_status2_resources,
  699. },
  700. {
  701. .name = "wm831x-watchdog",
  702. .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
  703. .resources = wm831x_wdt_resources,
  704. },
  705. };
  706. static struct mfd_cell wm8311_devs[] = {
  707. {
  708. .name = "wm831x-buckv",
  709. .id = 1,
  710. .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
  711. .resources = wm831x_dcdc1_resources,
  712. },
  713. {
  714. .name = "wm831x-buckv",
  715. .id = 2,
  716. .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
  717. .resources = wm831x_dcdc2_resources,
  718. },
  719. {
  720. .name = "wm831x-buckp",
  721. .id = 3,
  722. .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
  723. .resources = wm831x_dcdc3_resources,
  724. },
  725. {
  726. .name = "wm831x-boostp",
  727. .id = 4,
  728. .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
  729. .resources = wm831x_dcdc4_resources,
  730. },
  731. {
  732. .name = "wm831x-epe",
  733. .id = 1,
  734. },
  735. {
  736. .name = "wm831x-epe",
  737. .id = 2,
  738. },
  739. {
  740. .name = "wm831x-gpio",
  741. .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
  742. .resources = wm831x_gpio_resources,
  743. },
  744. {
  745. .name = "wm831x-hwmon",
  746. },
  747. {
  748. .name = "wm831x-isink",
  749. .id = 1,
  750. .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
  751. .resources = wm831x_isink1_resources,
  752. },
  753. {
  754. .name = "wm831x-isink",
  755. .id = 2,
  756. .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
  757. .resources = wm831x_isink2_resources,
  758. },
  759. {
  760. .name = "wm831x-ldo",
  761. .id = 1,
  762. .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
  763. .resources = wm831x_ldo1_resources,
  764. },
  765. {
  766. .name = "wm831x-ldo",
  767. .id = 2,
  768. .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
  769. .resources = wm831x_ldo2_resources,
  770. },
  771. {
  772. .name = "wm831x-ldo",
  773. .id = 3,
  774. .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
  775. .resources = wm831x_ldo3_resources,
  776. },
  777. {
  778. .name = "wm831x-ldo",
  779. .id = 4,
  780. .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
  781. .resources = wm831x_ldo4_resources,
  782. },
  783. {
  784. .name = "wm831x-ldo",
  785. .id = 5,
  786. .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
  787. .resources = wm831x_ldo5_resources,
  788. },
  789. {
  790. .name = "wm831x-aldo",
  791. .id = 7,
  792. .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
  793. .resources = wm831x_ldo7_resources,
  794. },
  795. {
  796. .name = "wm831x-alive-ldo",
  797. .id = 11,
  798. .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
  799. .resources = wm831x_ldo11_resources,
  800. },
  801. {
  802. .name = "wm831x-on",
  803. .num_resources = ARRAY_SIZE(wm831x_on_resources),
  804. .resources = wm831x_on_resources,
  805. },
  806. {
  807. .name = "wm831x-power",
  808. .num_resources = ARRAY_SIZE(wm831x_power_resources),
  809. .resources = wm831x_power_resources,
  810. },
  811. {
  812. .name = "wm831x-rtc",
  813. .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
  814. .resources = wm831x_rtc_resources,
  815. },
  816. {
  817. .name = "wm831x-status",
  818. .id = 1,
  819. .num_resources = ARRAY_SIZE(wm831x_status1_resources),
  820. .resources = wm831x_status1_resources,
  821. },
  822. {
  823. .name = "wm831x-status",
  824. .id = 2,
  825. .num_resources = ARRAY_SIZE(wm831x_status2_resources),
  826. .resources = wm831x_status2_resources,
  827. },
  828. {
  829. .name = "wm831x-touch",
  830. .num_resources = ARRAY_SIZE(wm831x_touch_resources),
  831. .resources = wm831x_touch_resources,
  832. },
  833. {
  834. .name = "wm831x-watchdog",
  835. .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
  836. .resources = wm831x_wdt_resources,
  837. },
  838. };
  839. static struct mfd_cell wm8312_devs[] = {
  840. {
  841. .name = "wm831x-buckv",
  842. .id = 1,
  843. .num_resources = ARRAY_SIZE(wm831x_dcdc1_resources),
  844. .resources = wm831x_dcdc1_resources,
  845. },
  846. {
  847. .name = "wm831x-buckv",
  848. .id = 2,
  849. .num_resources = ARRAY_SIZE(wm831x_dcdc2_resources),
  850. .resources = wm831x_dcdc2_resources,
  851. },
  852. {
  853. .name = "wm831x-buckp",
  854. .id = 3,
  855. .num_resources = ARRAY_SIZE(wm831x_dcdc3_resources),
  856. .resources = wm831x_dcdc3_resources,
  857. },
  858. {
  859. .name = "wm831x-boostp",
  860. .id = 4,
  861. .num_resources = ARRAY_SIZE(wm831x_dcdc4_resources),
  862. .resources = wm831x_dcdc4_resources,
  863. },
  864. {
  865. .name = "wm831x-epe",
  866. .id = 1,
  867. },
  868. {
  869. .name = "wm831x-epe",
  870. .id = 2,
  871. },
  872. {
  873. .name = "wm831x-gpio",
  874. .num_resources = ARRAY_SIZE(wm831x_gpio_resources),
  875. .resources = wm831x_gpio_resources,
  876. },
  877. {
  878. .name = "wm831x-hwmon",
  879. },
  880. {
  881. .name = "wm831x-isink",
  882. .id = 1,
  883. .num_resources = ARRAY_SIZE(wm831x_isink1_resources),
  884. .resources = wm831x_isink1_resources,
  885. },
  886. {
  887. .name = "wm831x-isink",
  888. .id = 2,
  889. .num_resources = ARRAY_SIZE(wm831x_isink2_resources),
  890. .resources = wm831x_isink2_resources,
  891. },
  892. {
  893. .name = "wm831x-ldo",
  894. .id = 1,
  895. .num_resources = ARRAY_SIZE(wm831x_ldo1_resources),
  896. .resources = wm831x_ldo1_resources,
  897. },
  898. {
  899. .name = "wm831x-ldo",
  900. .id = 2,
  901. .num_resources = ARRAY_SIZE(wm831x_ldo2_resources),
  902. .resources = wm831x_ldo2_resources,
  903. },
  904. {
  905. .name = "wm831x-ldo",
  906. .id = 3,
  907. .num_resources = ARRAY_SIZE(wm831x_ldo3_resources),
  908. .resources = wm831x_ldo3_resources,
  909. },
  910. {
  911. .name = "wm831x-ldo",
  912. .id = 4,
  913. .num_resources = ARRAY_SIZE(wm831x_ldo4_resources),
  914. .resources = wm831x_ldo4_resources,
  915. },
  916. {
  917. .name = "wm831x-ldo",
  918. .id = 5,
  919. .num_resources = ARRAY_SIZE(wm831x_ldo5_resources),
  920. .resources = wm831x_ldo5_resources,
  921. },
  922. {
  923. .name = "wm831x-ldo",
  924. .id = 6,
  925. .num_resources = ARRAY_SIZE(wm831x_ldo6_resources),
  926. .resources = wm831x_ldo6_resources,
  927. },
  928. {
  929. .name = "wm831x-aldo",
  930. .id = 7,
  931. .num_resources = ARRAY_SIZE(wm831x_ldo7_resources),
  932. .resources = wm831x_ldo7_resources,
  933. },
  934. {
  935. .name = "wm831x-aldo",
  936. .id = 8,
  937. .num_resources = ARRAY_SIZE(wm831x_ldo8_resources),
  938. .resources = wm831x_ldo8_resources,
  939. },
  940. {
  941. .name = "wm831x-aldo",
  942. .id = 9,
  943. .num_resources = ARRAY_SIZE(wm831x_ldo9_resources),
  944. .resources = wm831x_ldo9_resources,
  945. },
  946. {
  947. .name = "wm831x-aldo",
  948. .id = 10,
  949. .num_resources = ARRAY_SIZE(wm831x_ldo10_resources),
  950. .resources = wm831x_ldo10_resources,
  951. },
  952. {
  953. .name = "wm831x-alive-ldo",
  954. .id = 11,
  955. .num_resources = ARRAY_SIZE(wm831x_ldo11_resources),
  956. .resources = wm831x_ldo11_resources,
  957. },
  958. {
  959. .name = "wm831x-on",
  960. .num_resources = ARRAY_SIZE(wm831x_on_resources),
  961. .resources = wm831x_on_resources,
  962. },
  963. {
  964. .name = "wm831x-power",
  965. .num_resources = ARRAY_SIZE(wm831x_power_resources),
  966. .resources = wm831x_power_resources,
  967. },
  968. {
  969. .name = "wm831x-rtc",
  970. .num_resources = ARRAY_SIZE(wm831x_rtc_resources),
  971. .resources = wm831x_rtc_resources,
  972. },
  973. {
  974. .name = "wm831x-status",
  975. .id = 1,
  976. .num_resources = ARRAY_SIZE(wm831x_status1_resources),
  977. .resources = wm831x_status1_resources,
  978. },
  979. {
  980. .name = "wm831x-status",
  981. .id = 2,
  982. .num_resources = ARRAY_SIZE(wm831x_status2_resources),
  983. .resources = wm831x_status2_resources,
  984. },
  985. {
  986. .name = "wm831x-touch",
  987. .num_resources = ARRAY_SIZE(wm831x_touch_resources),
  988. .resources = wm831x_touch_resources,
  989. },
  990. {
  991. .name = "wm831x-watchdog",
  992. .num_resources = ARRAY_SIZE(wm831x_wdt_resources),
  993. .resources = wm831x_wdt_resources,
  994. },
  995. };
  996. /*
  997. * Instantiate the generic non-control parts of the device.
  998. */
  999. static int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
  1000. {
  1001. struct wm831x_pdata *pdata = wm831x->dev->platform_data;
  1002. int rev;
  1003. enum wm831x_parent parent;
  1004. int ret;
  1005. mutex_init(&wm831x->io_lock);
  1006. mutex_init(&wm831x->key_lock);
  1007. dev_set_drvdata(wm831x->dev, wm831x);
  1008. ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
  1009. if (ret < 0) {
  1010. dev_err(wm831x->dev, "Failed to read parent ID: %d\n", ret);
  1011. goto err;
  1012. }
  1013. if (ret != 0x6204) {
  1014. dev_err(wm831x->dev, "Device is not a WM831x: ID %x\n", ret);
  1015. ret = -EINVAL;
  1016. goto err;
  1017. }
  1018. ret = wm831x_reg_read(wm831x, WM831X_REVISION);
  1019. if (ret < 0) {
  1020. dev_err(wm831x->dev, "Failed to read revision: %d\n", ret);
  1021. goto err;
  1022. }
  1023. rev = (ret & WM831X_PARENT_REV_MASK) >> WM831X_PARENT_REV_SHIFT;
  1024. ret = wm831x_reg_read(wm831x, WM831X_RESET_ID);
  1025. if (ret < 0) {
  1026. dev_err(wm831x->dev, "Failed to read device ID: %d\n", ret);
  1027. goto err;
  1028. }
  1029. switch (ret) {
  1030. case 0x8310:
  1031. parent = WM8310;
  1032. switch (rev) {
  1033. case 0:
  1034. dev_info(wm831x->dev, "WM8310 revision %c\n",
  1035. 'A' + rev);
  1036. break;
  1037. }
  1038. break;
  1039. case 0x8311:
  1040. parent = WM8311;
  1041. switch (rev) {
  1042. case 0:
  1043. dev_info(wm831x->dev, "WM8311 revision %c\n",
  1044. 'A' + rev);
  1045. break;
  1046. }
  1047. break;
  1048. case 0x8312:
  1049. parent = WM8312;
  1050. switch (rev) {
  1051. case 0:
  1052. dev_info(wm831x->dev, "WM8312 revision %c\n",
  1053. 'A' + rev);
  1054. break;
  1055. }
  1056. break;
  1057. case 0:
  1058. /* Some engineering samples do not have the ID set,
  1059. * rely on the device being registered correctly.
  1060. * This will need revisiting for future devices with
  1061. * multiple dies.
  1062. */
  1063. parent = id;
  1064. switch (rev) {
  1065. case 0:
  1066. dev_info(wm831x->dev, "WM831%d ES revision %c\n",
  1067. parent, 'A' + rev);
  1068. break;
  1069. }
  1070. break;
  1071. default:
  1072. dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret);
  1073. ret = -EINVAL;
  1074. goto err;
  1075. }
  1076. /* This will need revisiting in future but is OK for all
  1077. * current parts.
  1078. */
  1079. if (parent != id)
  1080. dev_warn(wm831x->dev, "Device was registered as a WM831%lu\n",
  1081. id);
  1082. /* Bootstrap the user key */
  1083. ret = wm831x_reg_read(wm831x, WM831X_SECURITY_KEY);
  1084. if (ret < 0) {
  1085. dev_err(wm831x->dev, "Failed to read security key: %d\n", ret);
  1086. goto err;
  1087. }
  1088. if (ret != 0) {
  1089. dev_warn(wm831x->dev, "Security key had non-zero value %x\n",
  1090. ret);
  1091. wm831x_reg_write(wm831x, WM831X_SECURITY_KEY, 0);
  1092. }
  1093. wm831x->locked = 1;
  1094. if (pdata && pdata->pre_init) {
  1095. ret = pdata->pre_init(wm831x);
  1096. if (ret != 0) {
  1097. dev_err(wm831x->dev, "pre_init() failed: %d\n", ret);
  1098. goto err;
  1099. }
  1100. }
  1101. ret = wm831x_irq_init(wm831x, irq);
  1102. if (ret != 0)
  1103. goto err;
  1104. /* The core device is up, instantiate the subdevices. */
  1105. switch (parent) {
  1106. case WM8310:
  1107. ret = mfd_add_devices(wm831x->dev, -1,
  1108. wm8310_devs, ARRAY_SIZE(wm8310_devs),
  1109. NULL, 0);
  1110. break;
  1111. case WM8311:
  1112. ret = mfd_add_devices(wm831x->dev, -1,
  1113. wm8311_devs, ARRAY_SIZE(wm8311_devs),
  1114. NULL, 0);
  1115. break;
  1116. case WM8312:
  1117. ret = mfd_add_devices(wm831x->dev, -1,
  1118. wm8312_devs, ARRAY_SIZE(wm8312_devs),
  1119. NULL, 0);
  1120. break;
  1121. default:
  1122. /* If this happens the bus probe function is buggy */
  1123. BUG();
  1124. }
  1125. if (ret != 0) {
  1126. dev_err(wm831x->dev, "Failed to add children\n");
  1127. goto err_irq;
  1128. }
  1129. if (pdata && pdata->post_init) {
  1130. ret = pdata->post_init(wm831x);
  1131. if (ret != 0) {
  1132. dev_err(wm831x->dev, "post_init() failed: %d\n", ret);
  1133. goto err_irq;
  1134. }
  1135. }
  1136. return 0;
  1137. err_irq:
  1138. wm831x_irq_exit(wm831x);
  1139. err:
  1140. mfd_remove_devices(wm831x->dev);
  1141. kfree(wm831x);
  1142. return ret;
  1143. }
  1144. static void wm831x_device_exit(struct wm831x *wm831x)
  1145. {
  1146. mfd_remove_devices(wm831x->dev);
  1147. wm831x_irq_exit(wm831x);
  1148. kfree(wm831x);
  1149. }
  1150. static int wm831x_i2c_read_device(struct wm831x *wm831x, unsigned short reg,
  1151. int bytes, void *dest)
  1152. {
  1153. struct i2c_client *i2c = wm831x->control_data;
  1154. int ret;
  1155. u16 r = cpu_to_be16(reg);
  1156. ret = i2c_master_send(i2c, (unsigned char *)&r, 2);
  1157. if (ret < 0)
  1158. return ret;
  1159. if (ret != 2)
  1160. return -EIO;
  1161. ret = i2c_master_recv(i2c, dest, bytes);
  1162. if (ret < 0)
  1163. return ret;
  1164. if (ret != bytes)
  1165. return -EIO;
  1166. return 0;
  1167. }
  1168. /* Currently we allocate the write buffer on the stack; this is OK for
  1169. * small writes - if we need to do large writes this will need to be
  1170. * revised.
  1171. */
  1172. static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg,
  1173. int bytes, void *src)
  1174. {
  1175. struct i2c_client *i2c = wm831x->control_data;
  1176. unsigned char msg[bytes + 2];
  1177. int ret;
  1178. reg = cpu_to_be16(reg);
  1179. memcpy(&msg[0], &reg, 2);
  1180. memcpy(&msg[2], src, bytes);
  1181. ret = i2c_master_send(i2c, msg, bytes + 2);
  1182. if (ret < 0)
  1183. return ret;
  1184. if (ret < bytes + 2)
  1185. return -EIO;
  1186. return 0;
  1187. }
  1188. static int wm831x_i2c_probe(struct i2c_client *i2c,
  1189. const struct i2c_device_id *id)
  1190. {
  1191. struct wm831x *wm831x;
  1192. wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
  1193. if (wm831x == NULL) {
  1194. kfree(i2c);
  1195. return -ENOMEM;
  1196. }
  1197. i2c_set_clientdata(i2c, wm831x);
  1198. wm831x->dev = &i2c->dev;
  1199. wm831x->control_data = i2c;
  1200. wm831x->read_dev = wm831x_i2c_read_device;
  1201. wm831x->write_dev = wm831x_i2c_write_device;
  1202. return wm831x_device_init(wm831x, id->driver_data, i2c->irq);
  1203. }
  1204. static int wm831x_i2c_remove(struct i2c_client *i2c)
  1205. {
  1206. struct wm831x *wm831x = i2c_get_clientdata(i2c);
  1207. wm831x_device_exit(wm831x);
  1208. return 0;
  1209. }
  1210. static const struct i2c_device_id wm831x_i2c_id[] = {
  1211. { "wm8310", WM8310 },
  1212. { "wm8311", WM8311 },
  1213. { "wm8312", WM8312 },
  1214. { }
  1215. };
  1216. MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id);
  1217. static struct i2c_driver wm831x_i2c_driver = {
  1218. .driver = {
  1219. .name = "wm831x",
  1220. .owner = THIS_MODULE,
  1221. },
  1222. .probe = wm831x_i2c_probe,
  1223. .remove = wm831x_i2c_remove,
  1224. .id_table = wm831x_i2c_id,
  1225. };
  1226. static int __init wm831x_i2c_init(void)
  1227. {
  1228. int ret;
  1229. ret = i2c_add_driver(&wm831x_i2c_driver);
  1230. if (ret != 0)
  1231. pr_err("Failed to register wm831x I2C driver: %d\n", ret);
  1232. return ret;
  1233. }
  1234. subsys_initcall(wm831x_i2c_init);
  1235. static void __exit wm831x_i2c_exit(void)
  1236. {
  1237. i2c_del_driver(&wm831x_i2c_driver);
  1238. }
  1239. module_exit(wm831x_i2c_exit);
  1240. MODULE_DESCRIPTION("I2C support for the WM831X AudioPlus PMIC");
  1241. MODULE_LICENSE("GPL");
  1242. MODULE_AUTHOR("Mark Brown");