aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/codecs/wm8711.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-18 21:15:14 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-18 21:15:14 +0100
commit08aff8cd7a8568588d460c4bf8875a492d430314 (patch)
tree9cb49162abcbef3d0edd9c8a20ac29362501f45a /sound/soc/codecs/wm8711.c
parentd97d2e35b903b11dc6f7f8fcbe9a82fd8929e234 (diff)
ASoC: Add SPI support to WM8711
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8711.c')
-rw-r--r--sound/soc/codecs/wm8711.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c
index c7b1af89297..1a7fca7d1ef 100644
--- a/sound/soc/codecs/wm8711.c
+++ b/sound/soc/codecs/wm8711.c
@@ -535,6 +535,62 @@ static void wm8711_unregister(struct wm8711_priv *wm8711)
wm8711_codec = NULL;
}
+#if defined(CONFIG_SPI_MASTER)
+static int __devinit wm8711_spi_probe(struct spi_device *spi)
+{
+ struct snd_soc_codec *codec;
+ struct wm8711_priv *wm8711;
+
+ wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL);
+ if (wm8711 == NULL)
+ return -ENOMEM;
+
+ codec = &wm8711->codec;
+ codec->control_data = spi;
+ codec->dev = &spi->dev;
+
+ dev_set_drvdata(&spi->dev, wm8711);
+
+ return wm8711_register(wm8711, SND_SOC_SPI);
+}
+
+static int __devexit wm8711_spi_remove(struct spi_device *spi)
+{
+ struct wm8711_priv *wm8711 = dev_get_drvdata(&spi->dev);
+
+ wm8711_unregister(wm8711);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int wm8711_spi_suspend(struct spi_device *spi, pm_message_t msg)
+{
+ return snd_soc_suspend_device(&spi->dev);
+}
+
+static int wm8711_spi_resume(struct spi_device *spi)
+{
+ return snd_soc_resume_device(&spi->dev);
+}
+#else
+#define wm8711_spi_suspend NULL
+#define wm8711_spi_resume NULL
+#endif
+
+static struct spi_driver wm8711_spi_driver = {
+ .driver = {
+ .name = "wm8711",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+ },
+ .probe = wm8711_spi_probe,
+ .suspend = wm8711_spi_suspend,
+ .resume = wm8711_spi_resume,
+ .remove = __devexit_p(wm8711_spi_remove),
+};
+#endif /* CONFIG_SPI_MASTER */
+
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
static __devinit int wm8711_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
@@ -591,6 +647,13 @@ static int __init wm8711_modinit(void)
ret);
}
#endif
+#if defined(CONFIG_SPI_MASTER)
+ ret = spi_register_driver(&wm8731_spi_driver);
+ if (ret != 0) {
+ printk(KERN_ERR "Failed to register WM8731 SPI driver: %d\n",
+ ret);
+ }
+#endif
return 0;
}
module_init(wm8711_modinit);
@@ -600,6 +663,9 @@ static void __exit wm8711_exit(void)
#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
i2c_del_driver(&wm8711_i2c_driver);
#endif
+#if defined(CONFIG_SPI_MASTER)
+ spi_unregister_driver(&wm8731_spi_driver);
+#endif
}
module_exit(wm8711_exit);