Commit 341c9b84 authored by Joonyoung Shim's avatar Joonyoung Shim Committed by Mark Brown

ASoC: Factor out I2C 8 bit address 8 bit data I/O

This patch is for the AK4671 codec driver using this format.
Signed-off-by: default avatarJoonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 85488037
...@@ -77,6 +77,35 @@ static int snd_soc_7_9_spi_write(void *control_data, const char *data, ...@@ -77,6 +77,35 @@ static int snd_soc_7_9_spi_write(void *control_data, const char *data,
#define snd_soc_7_9_spi_write NULL #define snd_soc_7_9_spi_write NULL
#endif #endif
static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
u8 *cache = codec->reg_cache;
u8 data[2];
BUG_ON(codec->volatile_register);
data[0] = reg & 0xff;
data[1] = value & 0xff;
if (reg < codec->reg_cache_size)
cache[reg] = value;
if (codec->hw_write(codec->control_data, data, 2) == 2)
return 0;
else
return -EIO;
}
static unsigned int snd_soc_8_8_read(struct snd_soc_codec *codec,
unsigned int reg)
{
u8 *cache = codec->reg_cache;
if (reg >= codec->reg_cache_size)
return -1;
return cache[reg];
}
static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg, static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value) unsigned int value)
{ {
...@@ -151,6 +180,7 @@ static struct { ...@@ -151,6 +180,7 @@ static struct {
unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int); unsigned int (*i2c_read)(struct snd_soc_codec *, unsigned int);
} io_types[] = { } io_types[] = {
{ 7, 9, snd_soc_7_9_write, snd_soc_7_9_spi_write, snd_soc_7_9_read }, { 7, 9, snd_soc_7_9_write, snd_soc_7_9_spi_write, snd_soc_7_9_read },
{ 8, 8, snd_soc_8_8_write, NULL, snd_soc_8_8_read, NULL },
{ 8, 16, snd_soc_8_16_write, NULL, snd_soc_8_16_read, { 8, 16, snd_soc_8_16_write, NULL, snd_soc_8_16_read,
snd_soc_8_16_read_i2c }, snd_soc_8_16_read_i2c },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment