twl6040-core.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * MFD driver for TWL6040 audio device
  3. *
  4. * Authors: Misael Lopez Cruz <misael.lopez@ti.com>
  5. * Jorge Eduardo Candelaria <jorge.candelaria@ti.com>
  6. * Peter Ujfalusi <peter.ujfalusi@ti.com>
  7. *
  8. * Copyright: (C) 2011 Texas Instruments, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  22. * 02110-1301 USA
  23. *
  24. */
  25. #include <linux/module.h>
  26. #include <linux/types.h>
  27. #include <linux/slab.h>
  28. #include <linux/kernel.h>
  29. #include <linux/platform_device.h>
  30. #include <linux/gpio.h>
  31. #include <linux/delay.h>
  32. #include <linux/i2c/twl.h>
  33. #include <linux/mfd/core.h>
  34. #include <linux/mfd/twl6040.h>
  35. #define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1)
  36. int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
  37. {
  38. int ret;
  39. u8 val = 0;
  40. mutex_lock(&twl6040->io_mutex);
  41. /* Vibra control registers from cache */
  42. if (unlikely(reg == TWL6040_REG_VIBCTLL ||
  43. reg == TWL6040_REG_VIBCTLR)) {
  44. val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
  45. } else {
  46. ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
  47. if (ret < 0) {
  48. mutex_unlock(&twl6040->io_mutex);
  49. return ret;
  50. }
  51. }
  52. mutex_unlock(&twl6040->io_mutex);
  53. return val;
  54. }
  55. EXPORT_SYMBOL(twl6040_reg_read);
  56. int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val)
  57. {
  58. int ret;
  59. mutex_lock(&twl6040->io_mutex);
  60. ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
  61. /* Cache the vibra control registers */
  62. if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
  63. twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
  64. mutex_unlock(&twl6040->io_mutex);
  65. return ret;
  66. }
  67. EXPORT_SYMBOL(twl6040_reg_write);
  68. int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
  69. {
  70. int ret;
  71. u8 val;
  72. mutex_lock(&twl6040->io_mutex);
  73. ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
  74. if (ret)
  75. goto out;
  76. val |= mask;
  77. ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
  78. out:
  79. mutex_unlock(&twl6040->io_mutex);
  80. return ret;
  81. }
  82. EXPORT_SYMBOL(twl6040_set_bits);
  83. int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
  84. {
  85. int ret;
  86. u8 val;
  87. mutex_lock(&twl6040->io_mutex);
  88. ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
  89. if (ret)
  90. goto out;
  91. val &= ~mask;
  92. ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
  93. out:
  94. mutex_unlock(&twl6040->io_mutex);
  95. return ret;
  96. }
  97. EXPORT_SYMBOL(twl6040_clear_bits);
  98. /* twl6040 codec manual power-up sequence */
  99. static int twl6040_power_up(struct twl6040 *twl6040)
  100. {
  101. u8 ldoctl, ncpctl, lppllctl;
  102. int ret;
  103. /* enable high-side LDO, reference system and internal oscillator */
  104. ldoctl = TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA;
  105. ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  106. if (ret)
  107. return ret;
  108. usleep_range(10000, 10500);
  109. /* enable negative charge pump */
  110. ncpctl = TWL6040_NCPENA;
  111. ret = twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl);
  112. if (ret)
  113. goto ncp_err;
  114. usleep_range(1000, 1500);
  115. /* enable low-side LDO */
  116. ldoctl |= TWL6040_LSLDOENA;
  117. ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  118. if (ret)
  119. goto lsldo_err;
  120. usleep_range(1000, 1500);
  121. /* enable low-power PLL */
  122. lppllctl = TWL6040_LPLLENA;
  123. ret = twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  124. if (ret)
  125. goto lppll_err;
  126. usleep_range(5000, 5500);
  127. /* disable internal oscillator */
  128. ldoctl &= ~TWL6040_OSCENA;
  129. ret = twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  130. if (ret)
  131. goto osc_err;
  132. return 0;
  133. osc_err:
  134. lppllctl &= ~TWL6040_LPLLENA;
  135. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  136. lppll_err:
  137. ldoctl &= ~TWL6040_LSLDOENA;
  138. twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  139. lsldo_err:
  140. ncpctl &= ~TWL6040_NCPENA;
  141. twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl);
  142. ncp_err:
  143. ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA);
  144. twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  145. return ret;
  146. }
  147. /* twl6040 manual power-down sequence */
  148. static void twl6040_power_down(struct twl6040 *twl6040)
  149. {
  150. u8 ncpctl, ldoctl, lppllctl;
  151. ncpctl = twl6040_reg_read(twl6040, TWL6040_REG_NCPCTL);
  152. ldoctl = twl6040_reg_read(twl6040, TWL6040_REG_LDOCTL);
  153. lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL);
  154. /* enable internal oscillator */
  155. ldoctl |= TWL6040_OSCENA;
  156. twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  157. usleep_range(1000, 1500);
  158. /* disable low-power PLL */
  159. lppllctl &= ~TWL6040_LPLLENA;
  160. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  161. /* disable low-side LDO */
  162. ldoctl &= ~TWL6040_LSLDOENA;
  163. twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  164. /* disable negative charge pump */
  165. ncpctl &= ~TWL6040_NCPENA;
  166. twl6040_reg_write(twl6040, TWL6040_REG_NCPCTL, ncpctl);
  167. /* disable high-side LDO, reference system and internal oscillator */
  168. ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA);
  169. twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
  170. }
  171. static irqreturn_t twl6040_naudint_handler(int irq, void *data)
  172. {
  173. struct twl6040 *twl6040 = data;
  174. u8 intid, status;
  175. intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
  176. if (intid & TWL6040_READYINT)
  177. complete(&twl6040->ready);
  178. if (intid & TWL6040_THINT) {
  179. status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
  180. if (status & TWL6040_TSHUTDET) {
  181. dev_warn(twl6040->dev,
  182. "Thermal shutdown, powering-off");
  183. twl6040_power(twl6040, 0);
  184. } else {
  185. dev_warn(twl6040->dev,
  186. "Leaving thermal shutdown, powering-on");
  187. twl6040_power(twl6040, 1);
  188. }
  189. }
  190. return IRQ_HANDLED;
  191. }
  192. static int twl6040_power_up_completion(struct twl6040 *twl6040,
  193. int naudint)
  194. {
  195. int time_left;
  196. u8 intid;
  197. time_left = wait_for_completion_timeout(&twl6040->ready,
  198. msecs_to_jiffies(144));
  199. if (!time_left) {
  200. intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
  201. if (!(intid & TWL6040_READYINT)) {
  202. dev_err(twl6040->dev,
  203. "timeout waiting for READYINT\n");
  204. return -ETIMEDOUT;
  205. }
  206. }
  207. return 0;
  208. }
  209. int twl6040_power(struct twl6040 *twl6040, int on)
  210. {
  211. int audpwron = twl6040->audpwron;
  212. int naudint = twl6040->irq;
  213. int ret = 0;
  214. mutex_lock(&twl6040->mutex);
  215. if (on) {
  216. /* already powered-up */
  217. if (twl6040->power_count++)
  218. goto out;
  219. if (gpio_is_valid(audpwron)) {
  220. /* use AUDPWRON line */
  221. gpio_set_value(audpwron, 1);
  222. /* wait for power-up completion */
  223. ret = twl6040_power_up_completion(twl6040, naudint);
  224. if (ret) {
  225. dev_err(twl6040->dev,
  226. "automatic power-down failed\n");
  227. twl6040->power_count = 0;
  228. goto out;
  229. }
  230. } else {
  231. /* use manual power-up sequence */
  232. ret = twl6040_power_up(twl6040);
  233. if (ret) {
  234. dev_err(twl6040->dev,
  235. "manual power-up failed\n");
  236. twl6040->power_count = 0;
  237. goto out;
  238. }
  239. }
  240. /* Default PLL configuration after power up */
  241. twl6040->pll = TWL6040_SYSCLK_SEL_LPPLL;
  242. twl6040->sysclk = 19200000;
  243. } else {
  244. /* already powered-down */
  245. if (!twl6040->power_count) {
  246. dev_err(twl6040->dev,
  247. "device is already powered-off\n");
  248. ret = -EPERM;
  249. goto out;
  250. }
  251. if (--twl6040->power_count)
  252. goto out;
  253. if (gpio_is_valid(audpwron)) {
  254. /* use AUDPWRON line */
  255. gpio_set_value(audpwron, 0);
  256. /* power-down sequence latency */
  257. usleep_range(500, 700);
  258. } else {
  259. /* use manual power-down sequence */
  260. twl6040_power_down(twl6040);
  261. }
  262. twl6040->sysclk = 0;
  263. }
  264. out:
  265. mutex_unlock(&twl6040->mutex);
  266. return ret;
  267. }
  268. EXPORT_SYMBOL(twl6040_power);
  269. int twl6040_set_pll(struct twl6040 *twl6040, int pll_id,
  270. unsigned int freq_in, unsigned int freq_out)
  271. {
  272. u8 hppllctl, lppllctl;
  273. int ret = 0;
  274. mutex_lock(&twl6040->mutex);
  275. hppllctl = twl6040_reg_read(twl6040, TWL6040_REG_HPPLLCTL);
  276. lppllctl = twl6040_reg_read(twl6040, TWL6040_REG_LPPLLCTL);
  277. switch (pll_id) {
  278. case TWL6040_SYSCLK_SEL_LPPLL:
  279. /* low-power PLL divider */
  280. switch (freq_out) {
  281. case 17640000:
  282. lppllctl |= TWL6040_LPLLFIN;
  283. break;
  284. case 19200000:
  285. lppllctl &= ~TWL6040_LPLLFIN;
  286. break;
  287. default:
  288. dev_err(twl6040->dev,
  289. "freq_out %d not supported\n", freq_out);
  290. ret = -EINVAL;
  291. goto pll_out;
  292. }
  293. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  294. switch (freq_in) {
  295. case 32768:
  296. lppllctl |= TWL6040_LPLLENA;
  297. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL,
  298. lppllctl);
  299. mdelay(5);
  300. lppllctl &= ~TWL6040_HPLLSEL;
  301. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL,
  302. lppllctl);
  303. hppllctl &= ~TWL6040_HPLLENA;
  304. twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL,
  305. hppllctl);
  306. break;
  307. default:
  308. dev_err(twl6040->dev,
  309. "freq_in %d not supported\n", freq_in);
  310. ret = -EINVAL;
  311. goto pll_out;
  312. }
  313. break;
  314. case TWL6040_SYSCLK_SEL_HPPLL:
  315. /* high-performance PLL can provide only 19.2 MHz */
  316. if (freq_out != 19200000) {
  317. dev_err(twl6040->dev,
  318. "freq_out %d not supported\n", freq_out);
  319. ret = -EINVAL;
  320. goto pll_out;
  321. }
  322. hppllctl &= ~TWL6040_MCLK_MSK;
  323. switch (freq_in) {
  324. case 12000000:
  325. /* PLL enabled, active mode */
  326. hppllctl |= TWL6040_MCLK_12000KHZ |
  327. TWL6040_HPLLENA;
  328. break;
  329. case 19200000:
  330. /*
  331. * PLL disabled
  332. * (enable PLL if MCLK jitter quality
  333. * doesn't meet specification)
  334. */
  335. hppllctl |= TWL6040_MCLK_19200KHZ;
  336. break;
  337. case 26000000:
  338. /* PLL enabled, active mode */
  339. hppllctl |= TWL6040_MCLK_26000KHZ |
  340. TWL6040_HPLLENA;
  341. break;
  342. case 38400000:
  343. /* PLL enabled, active mode */
  344. hppllctl |= TWL6040_MCLK_38400KHZ |
  345. TWL6040_HPLLENA;
  346. break;
  347. default:
  348. dev_err(twl6040->dev,
  349. "freq_in %d not supported\n", freq_in);
  350. ret = -EINVAL;
  351. goto pll_out;
  352. }
  353. /* enable clock slicer to ensure input waveform is square */
  354. hppllctl |= TWL6040_HPLLSQRENA;
  355. twl6040_reg_write(twl6040, TWL6040_REG_HPPLLCTL, hppllctl);
  356. usleep_range(500, 700);
  357. lppllctl |= TWL6040_HPLLSEL;
  358. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  359. lppllctl &= ~TWL6040_LPLLENA;
  360. twl6040_reg_write(twl6040, TWL6040_REG_LPPLLCTL, lppllctl);
  361. break;
  362. default:
  363. dev_err(twl6040->dev, "unknown pll id %d\n", pll_id);
  364. ret = -EINVAL;
  365. goto pll_out;
  366. }
  367. twl6040->sysclk = freq_out;
  368. twl6040->pll = pll_id;
  369. pll_out:
  370. mutex_unlock(&twl6040->mutex);
  371. return ret;
  372. }
  373. EXPORT_SYMBOL(twl6040_set_pll);
  374. int twl6040_get_pll(struct twl6040 *twl6040)
  375. {
  376. if (twl6040->power_count)
  377. return twl6040->pll;
  378. else
  379. return -ENODEV;
  380. }
  381. EXPORT_SYMBOL(twl6040_get_pll);
  382. unsigned int twl6040_get_sysclk(struct twl6040 *twl6040)
  383. {
  384. return twl6040->sysclk;
  385. }
  386. EXPORT_SYMBOL(twl6040_get_sysclk);
  387. /* Get the combined status of the vibra control register */
  388. int twl6040_get_vibralr_status(struct twl6040 *twl6040)
  389. {
  390. u8 status;
  391. status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1];
  392. status &= (TWL6040_VIBENA | TWL6040_VIBSEL);
  393. return status;
  394. }
  395. EXPORT_SYMBOL(twl6040_get_vibralr_status);
  396. static struct resource twl6040_vibra_rsrc[] = {
  397. {
  398. .flags = IORESOURCE_IRQ,
  399. },
  400. };
  401. static struct resource twl6040_codec_rsrc[] = {
  402. {
  403. .flags = IORESOURCE_IRQ,
  404. },
  405. };
  406. static int __devinit twl6040_probe(struct platform_device *pdev)
  407. {
  408. struct twl4030_audio_data *pdata = pdev->dev.platform_data;
  409. struct twl6040 *twl6040;
  410. struct mfd_cell *cell = NULL;
  411. int ret, children = 0;
  412. if (!pdata) {
  413. dev_err(&pdev->dev, "Platform data is missing\n");
  414. return -EINVAL;
  415. }
  416. /* In order to operate correctly we need valid interrupt config */
  417. if (!pdata->naudint_irq || !pdata->irq_base) {
  418. dev_err(&pdev->dev, "Invalid IRQ configuration\n");
  419. return -EINVAL;
  420. }
  421. twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL);
  422. if (!twl6040)
  423. return -ENOMEM;
  424. platform_set_drvdata(pdev, twl6040);
  425. twl6040->dev = &pdev->dev;
  426. twl6040->irq = pdata->naudint_irq;
  427. twl6040->irq_base = pdata->irq_base;
  428. mutex_init(&twl6040->mutex);
  429. mutex_init(&twl6040->io_mutex);
  430. init_completion(&twl6040->ready);
  431. twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV);
  432. /* ERRATA: Automatic power-up is not possible in ES1.0 */
  433. if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0)
  434. twl6040->audpwron = pdata->audpwron_gpio;
  435. else
  436. twl6040->audpwron = -EINVAL;
  437. if (gpio_is_valid(twl6040->audpwron)) {
  438. ret = gpio_request(twl6040->audpwron, "audpwron");
  439. if (ret)
  440. goto gpio1_err;
  441. ret = gpio_direction_output(twl6040->audpwron, 0);
  442. if (ret)
  443. goto gpio2_err;
  444. }
  445. /* codec interrupt */
  446. ret = twl6040_irq_init(twl6040);
  447. if (ret)
  448. goto gpio2_err;
  449. ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
  450. NULL, twl6040_naudint_handler, 0,
  451. "twl6040_irq_ready", twl6040);
  452. if (ret) {
  453. dev_err(twl6040->dev, "READY IRQ request failed: %d\n",
  454. ret);
  455. goto irq_err;
  456. }
  457. /* dual-access registers controlled by I2C only */
  458. twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL);
  459. if (pdata->codec) {
  460. int irq = twl6040->irq_base + TWL6040_IRQ_PLUG;
  461. cell = &twl6040->cells[children];
  462. cell->name = "twl6040-codec";
  463. twl6040_codec_rsrc[0].start = irq;
  464. twl6040_codec_rsrc[0].end = irq;
  465. cell->resources = twl6040_codec_rsrc;
  466. cell->num_resources = ARRAY_SIZE(twl6040_codec_rsrc);
  467. cell->platform_data = pdata->codec;
  468. cell->pdata_size = sizeof(*pdata->codec);
  469. children++;
  470. }
  471. if (pdata->vibra) {
  472. int irq = twl6040->irq_base + TWL6040_IRQ_VIB;
  473. cell = &twl6040->cells[children];
  474. cell->name = "twl6040-vibra";
  475. twl6040_vibra_rsrc[0].start = irq;
  476. twl6040_vibra_rsrc[0].end = irq;
  477. cell->resources = twl6040_vibra_rsrc;
  478. cell->num_resources = ARRAY_SIZE(twl6040_vibra_rsrc);
  479. cell->platform_data = pdata->vibra;
  480. cell->pdata_size = sizeof(*pdata->vibra);
  481. children++;
  482. }
  483. if (children) {
  484. ret = mfd_add_devices(&pdev->dev, pdev->id, twl6040->cells,
  485. children, NULL, 0);
  486. if (ret)
  487. goto mfd_err;
  488. } else {
  489. dev_err(&pdev->dev, "No platform data found for children\n");
  490. ret = -ENODEV;
  491. goto mfd_err;
  492. }
  493. return 0;
  494. mfd_err:
  495. free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
  496. irq_err:
  497. twl6040_irq_exit(twl6040);
  498. gpio2_err:
  499. if (gpio_is_valid(twl6040->audpwron))
  500. gpio_free(twl6040->audpwron);
  501. gpio1_err:
  502. platform_set_drvdata(pdev, NULL);
  503. kfree(twl6040);
  504. return ret;
  505. }
  506. static int __devexit twl6040_remove(struct platform_device *pdev)
  507. {
  508. struct twl6040 *twl6040 = platform_get_drvdata(pdev);
  509. if (twl6040->power_count)
  510. twl6040_power(twl6040, 0);
  511. if (gpio_is_valid(twl6040->audpwron))
  512. gpio_free(twl6040->audpwron);
  513. free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
  514. twl6040_irq_exit(twl6040);
  515. mfd_remove_devices(&pdev->dev);
  516. platform_set_drvdata(pdev, NULL);
  517. kfree(twl6040);
  518. return 0;
  519. }
  520. static struct platform_driver twl6040_driver = {
  521. .probe = twl6040_probe,
  522. .remove = __devexit_p(twl6040_remove),
  523. .driver = {
  524. .owner = THIS_MODULE,
  525. .name = "twl6040",
  526. },
  527. };
  528. static int __devinit twl6040_init(void)
  529. {
  530. return platform_driver_register(&twl6040_driver);
  531. }
  532. module_init(twl6040_init);
  533. static void __devexit twl6040_exit(void)
  534. {
  535. platform_driver_unregister(&twl6040_driver);
  536. }
  537. module_exit(twl6040_exit);
  538. MODULE_DESCRIPTION("TWL6040 MFD");
  539. MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
  540. MODULE_AUTHOR("Jorge Eduardo Candelaria <jorge.candelaria@ti.com>");
  541. MODULE_LICENSE("GPL");
  542. MODULE_ALIAS("platform:twl6040");