diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-08-18 16:15:14 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-08-18 16:15:14 -0400 |
commit | 08aff8cd7a8568588d460c4bf8875a492d430314 (patch) | |
tree | 9cb49162abcbef3d0edd9c8a20ac29362501f45a /sound/soc/codecs/wm8711.c | |
parent | d97d2e35b903b11dc6f7f8fcbe9a82fd8929e234 (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.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index c7b1af89297b..1a7fca7d1ef9 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) | ||
539 | static 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 | |||
557 | static 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 | ||
567 | static int wm8711_spi_suspend(struct spi_device *spi, pm_message_t msg) | ||
568 | { | ||
569 | return snd_soc_suspend_device(&spi->dev); | ||
570 | } | ||
571 | |||
572 | static 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 | |||
581 | static 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) |
539 | static __devinit int wm8711_i2c_probe(struct i2c_client *i2c, | 595 | static __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 | } |
596 | module_init(wm8711_modinit); | 659 | module_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 | } |
604 | module_exit(wm8711_exit); | 670 | module_exit(wm8711_exit); |
605 | 671 | ||