aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ssm2602.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-04-07 02:05:11 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-07 20:24:24 -0400
commitb39e285545a2bd7f331a53b32c8c40748fdd348e (patch)
tree32687fa861efc69b44bb316719d84d99dca3778d /sound/soc/codecs/ssm2602.c
parentb7af1dafdfaf8419065399d07fb7cbae14b286ef (diff)
ASoC: SSM2602: add SPI support
The ssm2602 codec has a SPI interface as well as I2C, so add the simple bit of glue to make it usable. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/ssm2602.c')
-rw-r--r--sound/soc/codecs/ssm2602.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index 8a2b52fa4a7e..7e2194975360 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/pm.h> 33#include <linux/pm.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/spi/spi.h>
35#include <linux/platform_device.h> 36#include <linux/platform_device.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
37#include <sound/core.h> 38#include <sound/core.h>
@@ -556,6 +557,43 @@ static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = {
556 .reg_cache_default = ssm2602_reg, 557 .reg_cache_default = ssm2602_reg,
557}; 558};
558 559
560#if defined(CONFIG_SPI_MASTER)
561static int __devinit ssm2602_spi_probe(struct spi_device *spi)
562{
563 struct ssm2602_priv *ssm2602;
564 int ret;
565
566 ssm2602 = kzalloc(sizeof(struct ssm2602_priv), GFP_KERNEL);
567 if (ssm2602 == NULL)
568 return -ENOMEM;
569
570 spi_set_drvdata(spi, ssm2602);
571 ssm2602->control_type = SND_SOC_SPI;
572
573 ret = snd_soc_register_codec(&spi->dev,
574 &soc_codec_dev_ssm2602, &ssm2602_dai, 1);
575 if (ret < 0)
576 kfree(ssm2602);
577 return ret;
578}
579
580static int __devexit ssm2602_spi_remove(struct spi_device *spi)
581{
582 snd_soc_unregister_codec(&spi->dev);
583 kfree(spi_get_drvdata(spi));
584 return 0;
585}
586
587static struct spi_driver ssm2602_spi_driver = {
588 .driver = {
589 .name = "ssm2602",
590 .owner = THIS_MODULE,
591 },
592 .probe = ssm2602_spi_probe,
593 .remove = __devexit_p(ssm2602_spi_remove),
594};
595#endif
596
559#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 597#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
560/* 598/*
561 * ssm2602 2 wire address is determined by GPIO5 599 * ssm2602 2 wire address is determined by GPIO5
@@ -612,19 +650,29 @@ static struct i2c_driver ssm2602_i2c_driver = {
612static int __init ssm2602_modinit(void) 650static int __init ssm2602_modinit(void)
613{ 651{
614 int ret = 0; 652 int ret = 0;
653
654#if defined(CONFIG_SPI_MASTER)
655 ret = spi_register_driver(&ssm2602_spi_driver);
656 if (ret)
657 return ret;
658#endif
659
615#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 660#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
616 ret = i2c_add_driver(&ssm2602_i2c_driver); 661 ret = i2c_add_driver(&ssm2602_i2c_driver);
617 if (ret != 0) { 662 if (ret)
618 printk(KERN_ERR "Failed to register SSM2602 I2C driver: %d\n", 663 return ret;
619 ret);
620 }
621#endif 664#endif
665
622 return ret; 666 return ret;
623} 667}
624module_init(ssm2602_modinit); 668module_init(ssm2602_modinit);
625 669
626static void __exit ssm2602_exit(void) 670static void __exit ssm2602_exit(void)
627{ 671{
672#if defined(CONFIG_SPI_MASTER)
673 spi_unregister_driver(&ssm2602_spi_driver);
674#endif
675
628#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 676#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
629 i2c_del_driver(&ssm2602_i2c_driver); 677 i2c_del_driver(&ssm2602_i2c_driver);
630#endif 678#endif