aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-10-06 11:54:34 -0400
committerTakashi Iwai <tiwai@suse.de>2008-10-12 20:17:10 -0400
commitdd0c0c805d932f34e87ee3c2db9eaee0974bfef8 (patch)
treebd7e40a000ee332903567c0fc794c0d5614b376b /sound
parentdf91ddf178481e68b8517bed0813d032d493efa0 (diff)
ALSA: ASoC: Add WM8753 SPI support
Implement SPI support for WM8753, cut'n'pasting from the support for WM8731 contributed by Cliff Cai and Alan Horstmann since the wire format is the same for both codecs. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm8753.c71
-rw-r--r--sound/soc/codecs/wm8753.h1
2 files changed, 70 insertions, 2 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 8c4df44f3345..83ba4199c9c3 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -40,6 +40,7 @@
40#include <linux/pm.h> 40#include <linux/pm.h>
41#include <linux/i2c.h> 41#include <linux/i2c.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/spi/spi.h>
43#include <sound/core.h> 44#include <sound/core.h>
44#include <sound/pcm.h> 45#include <sound/pcm.h>
45#include <sound/pcm_params.h> 46#include <sound/pcm_params.h>
@@ -1719,6 +1720,63 @@ err_driver:
1719} 1720}
1720#endif 1721#endif
1721 1722
1723#if defined(CONFIG_SPI_MASTER)
1724static int __devinit wm8753_spi_probe(struct spi_device *spi)
1725{
1726 struct snd_soc_device *socdev = wm8753_socdev;
1727 struct snd_soc_codec *codec = socdev->codec;
1728 int ret;
1729
1730 codec->control_data = spi;
1731
1732 ret = wm8753_init(socdev);
1733 if (ret < 0)
1734 dev_err(&spi->dev, "failed to initialise WM8753\n");
1735
1736 return ret;
1737}
1738
1739static int __devexit wm8753_spi_remove(struct spi_device *spi)
1740{
1741 return 0;
1742}
1743
1744static struct spi_driver wm8753_spi_driver = {
1745 .driver = {
1746 .name = "wm8753",
1747 .bus = &spi_bus_type,
1748 .owner = THIS_MODULE,
1749 },
1750 .probe = wm8753_spi_probe,
1751 .remove = __devexit_p(wm8753_spi_remove),
1752};
1753
1754static int wm8753_spi_write(struct spi_device *spi, const char *data, int len)
1755{
1756 struct spi_transfer t;
1757 struct spi_message m;
1758 u8 msg[2];
1759
1760 if (len <= 0)
1761 return 0;
1762
1763 msg[0] = data[0];
1764 msg[1] = data[1];
1765
1766 spi_message_init(&m);
1767 memset(&t, 0, (sizeof t));
1768
1769 t.tx_buf = &msg[0];
1770 t.len = len;
1771
1772 spi_message_add_tail(&t, &m);
1773 spi_sync(spi, &m);
1774
1775 return len;
1776}
1777#endif
1778
1779
1722static int wm8753_probe(struct platform_device *pdev) 1780static int wm8753_probe(struct platform_device *pdev)
1723{ 1781{
1724 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 1782 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -1753,8 +1811,14 @@ static int wm8753_probe(struct platform_device *pdev)
1753 codec->hw_write = (hw_write_t)i2c_master_send; 1811 codec->hw_write = (hw_write_t)i2c_master_send;
1754 ret = wm8753_add_i2c_device(pdev, setup); 1812 ret = wm8753_add_i2c_device(pdev, setup);
1755 } 1813 }
1756#else 1814#endif
1757 /* Add other interfaces here */ 1815#if defined(CONFIG_SPI_MASTER)
1816 if (setup->spi) {
1817 codec->hw_write = (hw_write_t)wm8753_spi_write;
1818 ret = spi_register_driver(&wm8753_spi_driver);
1819 if (ret != 0)
1820 printk(KERN_ERR "can't add spi driver");
1821 }
1758#endif 1822#endif
1759 1823
1760 if (ret != 0) { 1824 if (ret != 0) {
@@ -1798,6 +1862,9 @@ static int wm8753_remove(struct platform_device *pdev)
1798 i2c_unregister_device(codec->control_data); 1862 i2c_unregister_device(codec->control_data);
1799 i2c_del_driver(&wm8753_i2c_driver); 1863 i2c_del_driver(&wm8753_i2c_driver);
1800#endif 1864#endif
1865#if defined(CONFIG_SPI_MASTER)
1866 spi_unregister_driver(&wm8753_spi_driver);
1867#endif
1801 kfree(codec->private_data); 1868 kfree(codec->private_data);
1802 kfree(codec); 1869 kfree(codec);
1803 1870
diff --git a/sound/soc/codecs/wm8753.h b/sound/soc/codecs/wm8753.h
index 7defde069f1d..6678379c0a29 100644
--- a/sound/soc/codecs/wm8753.h
+++ b/sound/soc/codecs/wm8753.h
@@ -79,6 +79,7 @@
79#define WM8753_ADCTL2 0x3f 79#define WM8753_ADCTL2 0x3f
80 80
81struct wm8753_setup_data { 81struct wm8753_setup_data {
82 int spi;
82 int i2c_bus; 83 int i2c_bus;
83 unsigned short i2c_address; 84 unsigned short i2c_address;
84}; 85};