summaryrefslogtreecommitdiff
path: root/sound/soc/soc-cache.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-07-10 22:24:27 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-03 16:59:09 +0100
commit7084a42b965d972079201414d19a399e65b26099 (patch)
tree391a0ed913eb769013ca65e3c042ac043981dbfa /sound/soc/soc-cache.c
parent030c819e79e8ad0320486e9ccbe76d2f0870369f (diff)
ASoC: Add I/O control bus information to factored out cache setup
While writes tend to be able to use a fairly bus independant format to do the writes reads are all bus specific. To allow us to factor out this code include the bus type as a parameter when setting up the cache. Initially just use this to factor out hw_write_t for I2C. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-cache.c')
-rw-r--r--sound/soc/soc-cache.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 4eb4333a0efb..8b126682c843 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -11,6 +11,7 @@
* option) any later version.
*/
+#include <linux/i2c.h>
#include <sound/soc.h>
static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
@@ -62,6 +63,7 @@ static struct {
* @type: Type of cache.
* @addr_bits: Number of bits of register address data.
* @data_bits: Number of bits of data per register.
+ * @control: Control bus used.
*
* Register formats are frequently shared between many I2C and SPI
* devices. In order to promote code reuse the ASoC core provides
@@ -75,7 +77,8 @@ static struct {
* volatile registers.
*/
int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
- int addr_bits, int data_bits)
+ int addr_bits, int data_bits,
+ enum snd_soc_control_type control)
{
int i;
@@ -100,6 +103,20 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
codec->write = io_types[i].write;
codec->read = io_types[i].read;
+ switch (control) {
+ case SND_SOC_CUSTOM:
+ break;
+
+ case SND_SOC_I2C:
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+ codec->hw_write = (hw_write_t)i2c_master_send;
+#endif
+ break;
+
+ case SND_SOC_SPI:
+ break;
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io);