diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm8510.c | 70 | ||||
-rw-r--r-- | sound/soc/codecs/wm8510.h | 1 |
2 files changed, 69 insertions, 2 deletions
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 9a37c8d95ed2..16768a5acc4c 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/pm.h> | 18 | #include <linux/pm.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/spi/spi.h> | ||
21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
23 | #include <sound/pcm_params.h> | 24 | #include <sound/pcm_params.h> |
@@ -747,6 +748,62 @@ err_driver: | |||
747 | } | 748 | } |
748 | #endif | 749 | #endif |
749 | 750 | ||
751 | #if defined(CONFIG_SPI_MASTER) | ||
752 | static int __devinit wm8510_spi_probe(struct spi_device *spi) | ||
753 | { | ||
754 | struct snd_soc_device *socdev = wm8510_socdev; | ||
755 | struct snd_soc_codec *codec = socdev->codec; | ||
756 | int ret; | ||
757 | |||
758 | codec->control_data = spi; | ||
759 | |||
760 | ret = wm8510_init(socdev); | ||
761 | if (ret < 0) | ||
762 | dev_err(&spi->dev, "failed to initialise WM8510\n"); | ||
763 | |||
764 | return ret; | ||
765 | } | ||
766 | |||
767 | static int __devexit wm8510_spi_remove(struct spi_device *spi) | ||
768 | { | ||
769 | return 0; | ||
770 | } | ||
771 | |||
772 | static struct spi_driver wm8510_spi_driver = { | ||
773 | .driver = { | ||
774 | .name = "wm8510", | ||
775 | .bus = &spi_bus_type, | ||
776 | .owner = THIS_MODULE, | ||
777 | }, | ||
778 | .probe = wm8510_spi_probe, | ||
779 | .remove = __devexit_p(wm8510_spi_remove), | ||
780 | }; | ||
781 | |||
782 | static int wm8510_spi_write(struct spi_device *spi, const char *data, int len) | ||
783 | { | ||
784 | struct spi_transfer t; | ||
785 | struct spi_message m; | ||
786 | u8 msg[2]; | ||
787 | |||
788 | if (len <= 0) | ||
789 | return 0; | ||
790 | |||
791 | msg[0] = data[0]; | ||
792 | msg[1] = data[1]; | ||
793 | |||
794 | spi_message_init(&m); | ||
795 | memset(&t, 0, (sizeof t)); | ||
796 | |||
797 | t.tx_buf = &msg[0]; | ||
798 | t.len = len; | ||
799 | |||
800 | spi_message_add_tail(&t, &m); | ||
801 | spi_sync(spi, &m); | ||
802 | |||
803 | return len; | ||
804 | } | ||
805 | #endif /* CONFIG_SPI_MASTER */ | ||
806 | |||
750 | static int wm8510_probe(struct platform_device *pdev) | 807 | static int wm8510_probe(struct platform_device *pdev) |
751 | { | 808 | { |
752 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 809 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
@@ -772,8 +829,14 @@ static int wm8510_probe(struct platform_device *pdev) | |||
772 | codec->hw_write = (hw_write_t)i2c_master_send; | 829 | codec->hw_write = (hw_write_t)i2c_master_send; |
773 | ret = wm8510_add_i2c_device(pdev, setup); | 830 | ret = wm8510_add_i2c_device(pdev, setup); |
774 | } | 831 | } |
775 | #else | 832 | #endif |
776 | /* Add other interfaces here */ | 833 | #if defined(CONFIG_SPI_MASTER) |
834 | if (setup->spi) { | ||
835 | codec->hw_write = (hw_write_t)wm8510_spi_write; | ||
836 | ret = spi_register_driver(&wm8510_spi_driver); | ||
837 | if (ret != 0) | ||
838 | printk(KERN_ERR "can't add spi driver"); | ||
839 | } | ||
777 | #endif | 840 | #endif |
778 | 841 | ||
779 | if (ret != 0) | 842 | if (ret != 0) |
@@ -796,6 +859,9 @@ static int wm8510_remove(struct platform_device *pdev) | |||
796 | i2c_unregister_device(codec->control_data); | 859 | i2c_unregister_device(codec->control_data); |
797 | i2c_del_driver(&wm8510_i2c_driver); | 860 | i2c_del_driver(&wm8510_i2c_driver); |
798 | #endif | 861 | #endif |
862 | #if defined(CONFIG_SPI_MASTER) | ||
863 | spi_unregister_driver(&wm8510_spi_driver); | ||
864 | #endif | ||
799 | kfree(codec); | 865 | kfree(codec); |
800 | 866 | ||
801 | return 0; | 867 | return 0; |
diff --git a/sound/soc/codecs/wm8510.h b/sound/soc/codecs/wm8510.h index c53683960456..bdefcf5c69ff 100644 --- a/sound/soc/codecs/wm8510.h +++ b/sound/soc/codecs/wm8510.h | |||
@@ -94,6 +94,7 @@ | |||
94 | #define WM8510_MCLKDIV_12 (7 << 5) | 94 | #define WM8510_MCLKDIV_12 (7 << 5) |
95 | 95 | ||
96 | struct wm8510_setup_data { | 96 | struct wm8510_setup_data { |
97 | int spi; | ||
97 | int i2c_bus; | 98 | int i2c_bus; |
98 | unsigned short i2c_address; | 99 | unsigned short i2c_address; |
99 | }; | 100 | }; |