aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-09-16 07:51:26 -0400
committerJaroslav Kysela <perex@perex.cz>2008-09-23 02:18:19 -0400
commit2f3dfaf5da3d43a1483b063e9d0692789241febb (patch)
treebe15fc2d8c63078c0d7aa23b073d3fbab9eeb216
parentccbc301e5346e115931ab052837d32778f8fd544 (diff)
sound: ASoC: Add WM8750 SPI support
Implement SPI support for WM8750, 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. Also fix a cut'n'pasted comment in the I2C side of the driver (which was clearly written in the same way) while we're at it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--sound/soc/codecs/wm8750.c70
-rw-r--r--sound/soc/codecs/wm8750.h1
2 files changed, 70 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 9847aa064d6b..4892e398a598 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -19,6 +19,7 @@
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/spi/spi.h>
22#include <sound/core.h> 23#include <sound/core.h>
23#include <sound/pcm.h> 24#include <sound/pcm.h>
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
@@ -841,7 +842,7 @@ static struct snd_soc_device *wm8750_socdev;
841#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 842#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
842 843
843/* 844/*
844 * WM8731 2 wire address is determined by GPIO5 845 * WM8750 2 wire address is determined by GPIO5
845 * state during powerup. 846 * state during powerup.
846 * low = 0x1a 847 * low = 0x1a
847 * high = 0x1b 848 * high = 0x1b
@@ -928,6 +929,62 @@ err_driver:
928} 929}
929#endif 930#endif
930 931
932#if defined(CONFIG_SPI_MASTER)
933static int __devinit wm8750_spi_probe(struct spi_device *spi)
934{
935 struct snd_soc_device *socdev = wm8750_socdev;
936 struct snd_soc_codec *codec = socdev->codec;
937 int ret;
938
939 codec->control_data = spi;
940
941 ret = wm8750_init(socdev);
942 if (ret < 0)
943 dev_err(&spi->dev, "failed to initialise WM8750\n");
944
945 return ret;
946}
947
948static int __devexit wm8750_spi_remove(struct spi_device *spi)
949{
950 return 0;
951}
952
953static struct spi_driver wm8750_spi_driver = {
954 .driver = {
955 .name = "wm8750",
956 .bus = &spi_bus_type,
957 .owner = THIS_MODULE,
958 },
959 .probe = wm8750_spi_probe,
960 .remove = __devexit_p(wm8750_spi_remove),
961};
962
963static int wm8750_spi_write(struct spi_device *spi, const char *data, int len)
964{
965 struct spi_transfer t;
966 struct spi_message m;
967 u8 msg[2];
968
969 if (len <= 0)
970 return 0;
971
972 msg[0] = data[0];
973 msg[1] = data[1];
974
975 spi_message_init(&m);
976 memset(&t, 0, (sizeof t));
977
978 t.tx_buf = &msg[0];
979 t.len = len;
980
981 spi_message_add_tail(&t, &m);
982 spi_sync(spi, &m);
983
984 return len;
985}
986#endif
987
931static int wm8750_probe(struct platform_device *pdev) 988static int wm8750_probe(struct platform_device *pdev)
932{ 989{
933 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 990 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -963,6 +1020,14 @@ static int wm8750_probe(struct platform_device *pdev)
963 ret = wm8750_add_i2c_device(pdev, setup); 1020 ret = wm8750_add_i2c_device(pdev, setup);
964 } 1021 }
965#endif 1022#endif
1023#if defined(CONFIG_SPI_MASTER)
1024 if (setup->spi) {
1025 codec->hw_write = (hw_write_t)wm8750_spi_write;
1026 ret = spi_register_driver(&wm8750_spi_driver);
1027 if (ret != 0)
1028 printk(KERN_ERR "can't add spi driver");
1029 }
1030#endif
966 1031
967 if (ret != 0) { 1032 if (ret != 0) {
968 kfree(codec->private_data); 1033 kfree(codec->private_data);
@@ -1005,6 +1070,9 @@ static int wm8750_remove(struct platform_device *pdev)
1005 i2c_unregister_device(codec->control_data); 1070 i2c_unregister_device(codec->control_data);
1006 i2c_del_driver(&wm8750_i2c_driver); 1071 i2c_del_driver(&wm8750_i2c_driver);
1007#endif 1072#endif
1073#if defined(CONFIG_SPI_MASTER)
1074 spi_unregister_driver(&wm8750_spi_driver);
1075#endif
1008 kfree(codec->private_data); 1076 kfree(codec->private_data);
1009 kfree(codec); 1077 kfree(codec);
1010 1078
diff --git a/sound/soc/codecs/wm8750.h b/sound/soc/codecs/wm8750.h
index fe6c80f7d9e2..1dc100e19cfe 100644
--- a/sound/soc/codecs/wm8750.h
+++ b/sound/soc/codecs/wm8750.h
@@ -58,6 +58,7 @@
58#define WM8750_SYSCLK 0 58#define WM8750_SYSCLK 0
59 59
60struct wm8750_setup_data { 60struct wm8750_setup_data {
61 int spi;
61 int i2c_bus; 62 int i2c_bus;
62 unsigned short i2c_address; 63 unsigned short i2c_address;
63}; 64};