aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-18 16:15:14 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-18 16:15:14 -0400
commit08aff8cd7a8568588d460c4bf8875a492d430314 (patch)
tree9cb49162abcbef3d0edd9c8a20ac29362501f45a /sound
parentd97d2e35b903b11dc6f7f8fcbe9a82fd8929e234 (diff)
ASoC: Add SPI support to WM8711
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/Kconfig2
-rw-r--r--sound/soc/codecs/wm8711.c66
2 files changed, 67 insertions, 1 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a5cfa78eb16..20ebf7437f9 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -35,7 +35,7 @@ config SND_SOC_ALL_CODECS
35 select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI 35 select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI
36 select SND_SOC_WM8523 if I2C 36 select SND_SOC_WM8523 if I2C
37 select SND_SOC_WM8580 if I2C 37 select SND_SOC_WM8580 if I2C
38 select SND_SOC_WM8711 if I2C 38 select SND_SOC_WM8711 if SND_SOC_I2C_AND_SPI
39 select SND_SOC_WM8728 if SND_SOC_I2C_AND_SPI 39 select SND_SOC_WM8728 if SND_SOC_I2C_AND_SPI
40 select SND_SOC_WM8731 if SND_SOC_I2C_AND_SPI 40 select SND_SOC_WM8731 if SND_SOC_I2C_AND_SPI
41 select SND_SOC_WM8750 if SND_SOC_I2C_AND_SPI 41 select SND_SOC_WM8750 if SND_SOC_I2C_AND_SPI
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)
535 wm8711_codec = NULL; 535 wm8711_codec = NULL;
536} 536}
537 537
538#if defined(CONFIG_SPI_MASTER)
539static int __devinit wm8711_spi_probe(struct spi_device *spi)
540{
541 struct snd_soc_codec *codec;
542 struct wm8711_priv *wm8711;
543
544 wm8711 = kzalloc(sizeof(struct wm8711_priv), GFP_KERNEL);
545 if (wm8711 == NULL)
546 return -ENOMEM;
547
548 codec = &wm8711->codec;
549 codec->control_data = spi;
550 codec->dev = &spi->dev;
551
552 dev_set_drvdata(&spi->dev, wm8711);
553
554 return wm8711_register(wm8711, SND_SOC_SPI);
555}
556
557static int __devexit wm8711_spi_remove(struct spi_device *spi)
558{
559 struct wm8711_priv *wm8711 = dev_get_drvdata(&spi->dev);
560
561 wm8711_unregister(wm8711);
562
563 return 0;
564}
565
566#ifdef CONFIG_PM
567static int wm8711_spi_suspend(struct spi_device *spi, pm_message_t msg)
568{
569 return snd_soc_suspend_device(&spi->dev);
570}
571
572static int wm8711_spi_resume(struct spi_device *spi)
573{
574 return snd_soc_resume_device(&spi->dev);
575}
576#else
577#define wm8711_spi_suspend NULL
578#define wm8711_spi_resume NULL
579#endif
580
581static struct spi_driver wm8711_spi_driver = {
582 .driver = {
583 .name = "wm8711",
584 .bus = &spi_bus_type,
585 .owner = THIS_MODULE,
586 },
587 .probe = wm8711_spi_probe,
588 .suspend = wm8711_spi_suspend,
589 .resume = wm8711_spi_resume,
590 .remove = __devexit_p(wm8711_spi_remove),
591};
592#endif /* CONFIG_SPI_MASTER */
593
538#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 594#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
539static __devinit int wm8711_i2c_probe(struct i2c_client *i2c, 595static __devinit int wm8711_i2c_probe(struct i2c_client *i2c,
540 const struct i2c_device_id *id) 596 const struct i2c_device_id *id)
@@ -591,6 +647,13 @@ static int __init wm8711_modinit(void)
591 ret); 647 ret);
592 } 648 }
593#endif 649#endif
650#if defined(CONFIG_SPI_MASTER)
651 ret = spi_register_driver(&wm8731_spi_driver);
652 if (ret != 0) {
653 printk(KERN_ERR "Failed to register WM8731 SPI driver: %d\n",
654 ret);
655 }
656#endif
594 return 0; 657 return 0;
595} 658}
596module_init(wm8711_modinit); 659module_init(wm8711_modinit);
@@ -600,6 +663,9 @@ static void __exit wm8711_exit(void)
600#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 663#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
601 i2c_del_driver(&wm8711_i2c_driver); 664 i2c_del_driver(&wm8711_i2c_driver);
602#endif 665#endif
666#if defined(CONFIG_SPI_MASTER)
667 spi_unregister_driver(&wm8731_spi_driver);
668#endif
603} 669}
604module_exit(wm8711_exit); 670module_exit(wm8711_exit);
605 671