diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-03 04:30:57 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-09 11:36:12 -0400 |
commit | 39e9b8d25d1c3a11e41e0044e010034a883f02ef (patch) | |
tree | badbebb99d9071054cbae4f02b83fedaa0f0bbe1 /sound/soc/codecs/wm8741.c | |
parent | 398575db00c17a2068a7e0c1c36d340445bc7d65 (diff) |
ASoC: Add SPI support for WM8741
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound/soc/codecs/wm8741.c')
-rw-r--r-- | sound/soc/codecs/wm8741.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index 00f80f7655cb..9f6e952da8ec 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/spi/spi.h> | ||
20 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
21 | #include <linux/regulator/consumer.h> | 22 | #include <linux/regulator/consumer.h> |
22 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
@@ -547,6 +548,43 @@ static struct i2c_driver wm8741_i2c_driver = { | |||
547 | }; | 548 | }; |
548 | #endif | 549 | #endif |
549 | 550 | ||
551 | #if defined(CONFIG_SPI_MASTER) | ||
552 | static int __devinit wm8741_spi_probe(struct spi_device *spi) | ||
553 | { | ||
554 | struct wm8741_priv *wm8741; | ||
555 | int ret; | ||
556 | |||
557 | wm8741 = kzalloc(sizeof(struct wm8741_priv), GFP_KERNEL); | ||
558 | if (wm8741 == NULL) | ||
559 | return -ENOMEM; | ||
560 | |||
561 | wm8741->control_type = SND_SOC_SPI; | ||
562 | spi_set_drvdata(spi, wm8741); | ||
563 | |||
564 | ret = snd_soc_register_codec(&spi->dev, | ||
565 | &soc_codec_dev_wm8741, &wm8741_dai, 1); | ||
566 | if (ret < 0) | ||
567 | kfree(wm8741); | ||
568 | return ret; | ||
569 | } | ||
570 | |||
571 | static int __devexit wm8741_spi_remove(struct spi_device *spi) | ||
572 | { | ||
573 | snd_soc_unregister_codec(&spi->dev); | ||
574 | kfree(spi_get_drvdata(spi)); | ||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | static struct spi_driver wm8741_spi_driver = { | ||
579 | .driver = { | ||
580 | .name = "wm8741", | ||
581 | .owner = THIS_MODULE, | ||
582 | }, | ||
583 | .probe = wm8741_spi_probe, | ||
584 | .remove = __devexit_p(wm8741_spi_remove), | ||
585 | }; | ||
586 | #endif /* CONFIG_SPI_MASTER */ | ||
587 | |||
550 | static int __init wm8741_modinit(void) | 588 | static int __init wm8741_modinit(void) |
551 | { | 589 | { |
552 | int ret = 0; | 590 | int ret = 0; |
@@ -556,6 +594,13 @@ static int __init wm8741_modinit(void) | |||
556 | if (ret != 0) | 594 | if (ret != 0) |
557 | pr_err("Failed to register WM8741 I2C driver: %d\n", ret); | 595 | pr_err("Failed to register WM8741 I2C driver: %d\n", ret); |
558 | #endif | 596 | #endif |
597 | #if defined(CONFIG_SPI_MASTER) | ||
598 | ret = spi_register_driver(&wm8741_spi_driver); | ||
599 | if (ret != 0) { | ||
600 | printk(KERN_ERR "Failed to register wm8741 SPI driver: %d\n", | ||
601 | ret); | ||
602 | } | ||
603 | #endif | ||
559 | 604 | ||
560 | return ret; | 605 | return ret; |
561 | } | 606 | } |
@@ -563,6 +608,9 @@ module_init(wm8741_modinit); | |||
563 | 608 | ||
564 | static void __exit wm8741_exit(void) | 609 | static void __exit wm8741_exit(void) |
565 | { | 610 | { |
611 | #if defined(CONFIG_SPI_MASTER) | ||
612 | spi_unregister_driver(&wm8741_spi_driver); | ||
613 | #endif | ||
566 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 614 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
567 | i2c_del_driver(&wm8741_i2c_driver); | 615 | i2c_del_driver(&wm8741_i2c_driver); |
568 | #endif | 616 | #endif |