Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248262
b: refs/heads/master
c: b39e285
h: refs/heads/master
v: v3
  • Loading branch information
Mike Frysinger authored and Mark Brown committed Apr 8, 2011
1 parent 4f9ea06 commit db8f31a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b7af1dafdfaf8419065399d07fb7cbae14b286ef
refs/heads/master: b39e285545a2bd7f331a53b32c8c40748fdd348e
2 changes: 1 addition & 1 deletion trunk/sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_SGTL5000 if I2C
select SND_SOC_SN95031 if INTEL_SCU_IPC
select SND_SOC_SPDIF
select SND_SOC_SSM2602 if I2C
select SND_SOC_SSM2602 if SND_SOC_I2C_AND_SPI
select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
select SND_SOC_TLV320AIC23 if I2C
select SND_SOC_TLV320AIC26 if SPI_MASTER
Expand Down
56 changes: 52 additions & 4 deletions trunk/sound/soc/codecs/ssm2602.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/spi/spi.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <sound/core.h>
Expand Down Expand Up @@ -556,6 +557,43 @@ static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = {
.reg_cache_default = ssm2602_reg,
};

#if defined(CONFIG_SPI_MASTER)
static int __devinit ssm2602_spi_probe(struct spi_device *spi)
{
struct ssm2602_priv *ssm2602;
int ret;

ssm2602 = kzalloc(sizeof(struct ssm2602_priv), GFP_KERNEL);
if (ssm2602 == NULL)
return -ENOMEM;

spi_set_drvdata(spi, ssm2602);
ssm2602->control_type = SND_SOC_SPI;

ret = snd_soc_register_codec(&spi->dev,
&soc_codec_dev_ssm2602, &ssm2602_dai, 1);
if (ret < 0)
kfree(ssm2602);
return ret;
}

static int __devexit ssm2602_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
kfree(spi_get_drvdata(spi));
return 0;
}

static struct spi_driver ssm2602_spi_driver = {
.driver = {
.name = "ssm2602",
.owner = THIS_MODULE,
},
.probe = ssm2602_spi_probe,
.remove = __devexit_p(ssm2602_spi_remove),
};
#endif

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
/*
* ssm2602 2 wire address is determined by GPIO5
Expand Down Expand Up @@ -612,19 +650,29 @@ static struct i2c_driver ssm2602_i2c_driver = {
static int __init ssm2602_modinit(void)
{
int ret = 0;

#if defined(CONFIG_SPI_MASTER)
ret = spi_register_driver(&ssm2602_spi_driver);
if (ret)
return ret;
#endif

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
ret = i2c_add_driver(&ssm2602_i2c_driver);
if (ret != 0) {
printk(KERN_ERR "Failed to register SSM2602 I2C driver: %d\n",
ret);
}
if (ret)
return ret;
#endif

return ret;
}
module_init(ssm2602_modinit);

static void __exit ssm2602_exit(void)
{
#if defined(CONFIG_SPI_MASTER)
spi_unregister_driver(&ssm2602_spi_driver);
#endif

#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
i2c_del_driver(&ssm2602_i2c_driver);
#endif
Expand Down

0 comments on commit db8f31a

Please sign in to comment.