ASoC: Remove cache default for volatile wm9081 reset register
Subsystems (3)
PATCH 1/8 ASoC: Remove cache default for volatile wm9081 reset register
Signed-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm9081.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
sound/soc/codecs/wm9081.c +0 -1
@@ -31,7 +31,6 @@#include "wm9081.h" static struct reg_default wm9081_reg[] = { - {0 ,0x9081 },/* R0 - Software Reset */ {2 ,0x00B9 },/* R2 - Analogue Lineout */ {3 ,0x00B9 },/* R3 - Analogue Speaker PGA */ {4 ,0x0001 },/* R4 - VMID Control */
Signature · 1 line
1.7.7.3
PATCH 2/8 ASoC: Use standard snd_soc_cache_sync() for WM9090
Signed-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm9090.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-)
sound/soc/codecs/wm9090.c +1 -12
@@ -513,18 +513,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,case SND_SOC_BIAS_STANDBY :if (codec->dapm.bias_level ==SND_SOC_BIAS_OFF ) {/* Restore the register cache */ -for (i =1 ; i < codec->driver->reg_cache_size; i++) { -if (reg_cache[i] == wm9090_reg_defaults[i]) -continue ; -if (wm9090_volatile (codec, i)) -continue ; - - ret =snd_soc_write (codec, i, reg_cache[i]); -if (ret !=0 ) -dev_warn (codec->dev, -"Failed to restore register %d: %d\n" , - i, ret); - } +snd_soc_cache_sync (codec); }/* We keep VMID off during standby since the combination of
Signature · 1 line
1.7.7.3
PATCH 3/8 ASoC: Convert WM9090 to use regmap directly
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm9090.c | 242 ++++++++++++++++++++++++--------------------- 1 files changed, 128 insertions(+), 114 deletions(-)
sound/soc/codecs/wm9090.c +128 -114
@@ -25,6 +25,7 @@#include <linux/device.h> #include <linux/i2c.h> #include <linux/delay.h> +#include <linux/regmap.h> #include <linux/slab.h> #include <sound/initval.h> #include <sound/soc.h>
@@ -33,116 +34,51 @@#include "wm9090.h" -static const u16 wm9090_reg_defaults[] = { -0x9093 ,/* R0 - Software Reset */ -0x0006 ,/* R1 - Power Management (1) */ -0x6000 ,/* R2 - Power Management (2) */ -0x0000 ,/* R3 - Power Management (3) */ -0x0000 ,/* R4 */ -0x0000 ,/* R5 */ -0x01C0 ,/* R6 - Clocking 1 */ -0x0000 ,/* R7 */ -0x0000 ,/* R8 */ -0x0000 ,/* R9 */ -0x0000 ,/* R10 */ -0x0000 ,/* R11 */ -0x0000 ,/* R12 */ -0x0000 ,/* R13 */ -0x0000 ,/* R14 */ -0x0000 ,/* R15 */ -0x0000 ,/* R16 */ -0x0000 ,/* R17 */ -0x0000 ,/* R18 */ -0x0000 ,/* R19 */ -0x0000 ,/* R20 */ -0x0000 ,/* R21 */ -0x0003 ,/* R22 - IN1 Line Control */ -0x0003 ,/* R23 - IN2 Line Control */ -0x0083 ,/* R24 - IN1 Line Input A Volume */ -0x0083 ,/* R25 - IN1 Line Input B Volume */ -0x0083 ,/* R26 - IN2 Line Input A Volume */ -0x0083 ,/* R27 - IN2 Line Input B Volume */ -0x002D ,/* R28 - Left Output Volume */ -0x002D ,/* R29 - Right Output Volume */ -0x0000 ,/* R30 */ -0x0000 ,/* R31 */ -0x0000 ,/* R32 */ -0x0000 ,/* R33 */ -0x0100 ,/* R34 - SPKMIXL Attenuation */ -0x0000 ,/* R35 */ -0x0010 ,/* R36 - SPKOUT Mixers */ -0x0140 ,/* R37 - ClassD3 */ -0x0039 ,/* R38 - Speaker Volume Left */ -0x0000 ,/* R39 */ -0x0000 ,/* R40 */ -0x0000 ,/* R41 */ -0x0000 ,/* R42 */ -0x0000 ,/* R43 */ -0x0000 ,/* R44 */ -0x0000 ,/* R45 - Output Mixer1 */ -0x0000 ,/* R46 - Output Mixer2 */ -0x0100 ,/* R47 - Output Mixer3 */ -0x0100 ,/* R48 - Output Mixer4 */ -0x0000 ,/* R49 */ -0x0000 ,/* R50 */ -0x0000 ,/* R51 */ -0x0000 ,/* R52 */ -0x0000 ,/* R53 */ -0x0000 ,/* R54 - Speaker Mixer */ -0x0000 ,/* R55 */ -0x0000 ,/* R56 */ -0x000D ,/* R57 - AntiPOP2 */ -0x0000 ,/* R58 */ -0x0000 ,/* R59 */ -0x0000 ,/* R60 */ -0x0000 ,/* R61 */ -0x0000 ,/* R62 */ -0x0000 ,/* R63 */ -0x0000 ,/* R64 */ -0x0000 ,/* R65 */ -0x0000 ,/* R66 */ -0x0000 ,/* R67 */ -0x0000 ,/* R68 */ -0x0000 ,/* R69 */ -0x0000 ,/* R70 - Write Sequencer 0 */ -0x0000 ,/* R71 - Write Sequencer 1 */ -0x0000 ,/* R72 - Write Sequencer 2 */ -0x0000 ,/* R73 - Write Sequencer 3 */ -0x0000 ,/* R74 - Write Sequencer 4 */ -0x0000 ,/* R75 - Write Sequencer 5 */ -0x1F25 ,/* R76 - Charge Pump 1 */ -0x0000 ,/* R77 */ -0x0000 ,/* R78 */ -0x0000 ,/* R79 */ -0x0000 ,/* R80 */ -0x0000 ,/* R81 */ -0x0000 ,/* R82 */ -0x0000 ,/* R83 */ -0x0000 ,/* R84 - DC Servo 0 */ -0x054A ,/* R85 - DC Servo 1 */ -0x0000 ,/* R86 */ -0x0000 ,/* R87 - DC Servo 3 */ -0x0000 ,/* R88 - DC Servo Readback 0 */ -0x0000 ,/* R89 - DC Servo Readback 1 */ -0x0000 ,/* R90 - DC Servo Readback 2 */ -0x0000 ,/* R91 */ -0x0000 ,/* R92 */ -0x0000 ,/* R93 */ -0x0000 ,/* R94 */ -0x0000 ,/* R95 */ -0x0100 ,/* R96 - Analogue HP 0 */ -0x0000 ,/* R97 */ -0x8640 ,/* R98 - AGC Control 0 */ -0xC000 ,/* R99 - AGC Control 1 */ -0x0200 ,/* R100 - AGC Control 2 */ +static const struct reg_default wm9090_reg_defaults[] = { + {1 ,0x0006 },/* R1 - Power Management (1) */ + {2 ,0x6000 },/* R2 - Power Management (2) */ + {3 ,0x0000 },/* R3 - Power Management (3) */ + {6 ,0x01C0 },/* R6 - Clocking 1 */ + {22 ,0x0003 },/* R22 - IN1 Line Control */ + {23 ,0x0003 },/* R23 - IN2 Line Control */ + {24 ,0x0083 },/* R24 - IN1 Line Input A Volume */ + {25 ,0x0083 },/* R25 - IN1 Line Input B Volume */ + {26 ,0x0083 },/* R26 - IN2 Line Input A Volume */ + {27 ,0x0083 },/* R27 - IN2 Line Input B Volume */ + {28 ,0x002D },/* R28 - Left Output Volume */ + {29 ,0x002D },/* R29 - Right Output Volume */ + {34 ,0x0100 },/* R34 - SPKMIXL Attenuation */ + {35 ,0x0010 },/* R36 - SPKOUT Mixers */ + {37 ,0x0140 },/* R37 - ClassD3 */ + {38 ,0x0039 },/* R38 - Speaker Volume Left */ + {45 ,0x0000 },/* R45 - Output Mixer1 */ + {46 ,0x0000 },/* R46 - Output Mixer2 */ + {47 ,0x0100 },/* R47 - Output Mixer3 */ + {48 ,0x0100 },/* R48 - Output Mixer4 */ + {54 ,0x0000 },/* R54 - Speaker Mixer */ + {57 ,0x000D },/* R57 - AntiPOP2 */ + {70 ,0x0000 },/* R70 - Write Sequencer 0 */ + {71 ,0x0000 },/* R71 - Write Sequencer 1 */ + {72 ,0x0000 },/* R72 - Write Sequencer 2 */ + {73 ,0x0000 },/* R73 - Write Sequencer 3 */ + {74 ,0x0000 },/* R74 - Write Sequencer 4 */ + {75 ,0x0000 },/* R75 - Write Sequencer 5 */ + {76 ,0x1F25 },/* R76 - Charge Pump 1 */ + {85 ,0x054A },/* R85 - DC Servo 1 */ + {87 ,0x0000 },/* R87 - DC Servo 3 */ + {96 ,0x0100 },/* R96 - Analogue HP 0 */ + {98 ,0x8640 },/* R98 - AGC Control 0 */ + {99 ,0xC000 },/* R99 - AGC Control 1 */ + {100 ,0x0200 },/* R100 - AGC Control 2 */ };/* This struct is used to save the context */ struct wm9090_priv {struct wm9090_platform_data pdata; +struct regmap *regmap; }; -static int wm9090_volatile (struct snd_soc_codec *codec,unsigned int reg) +static bool wm9090_volatile (struct device *dev,unsigned int reg) {switch (reg) {case WM9090_SOFTWARE_RESET :
@@ -150,10 +86,60 @@ static int wm9090_volatile(struct snd_soc_codec *codec, unsigned int reg)case WM9090_DC_SERVO_READBACK_0 :case WM9090_DC_SERVO_READBACK_1 :case WM9090_DC_SERVO_READBACK_2 : -return 1 ; +return true;default : -return 0 ; +return false; + } +} + +static bool wm9090_readable (struct device *dev,unsigned int reg) +{ +switch (reg) { +case WM9090_SOFTWARE_RESET : +case WM9090_POWER_MANAGEMENT_1 : +case WM9090_POWER_MANAGEMENT_2 : +case WM9090_POWER_MANAGEMENT_3 : +case WM9090_CLOCKING_1 : +case WM9090_IN1_LINE_CONTROL : +case WM9090_IN2_LINE_CONTROL : +case WM9090_IN1_LINE_INPUT_A_VOLUME : +case WM9090_IN1_LINE_INPUT_B_VOLUME : +case WM9090_IN2_LINE_INPUT_A_VOLUME : +case WM9090_IN2_LINE_INPUT_B_VOLUME : +case WM9090_LEFT_OUTPUT_VOLUME : +case WM9090_RIGHT_OUTPUT_VOLUME : +case WM9090_SPKMIXL_ATTENUATION : +case WM9090_SPKOUT_MIXERS : +case WM9090_CLASSD3 : +case WM9090_SPEAKER_VOLUME_LEFT : +case WM9090_OUTPUT_MIXER1 : +case WM9090_OUTPUT_MIXER2 : +case WM9090_OUTPUT_MIXER3 : +case WM9090_OUTPUT_MIXER4 : +case WM9090_SPEAKER_MIXER : +case WM9090_ANTIPOP2 : +case WM9090_WRITE_SEQUENCER_0 : +case WM9090_WRITE_SEQUENCER_1 : +case WM9090_WRITE_SEQUENCER_2 : +case WM9090_WRITE_SEQUENCER_3 : +case WM9090_WRITE_SEQUENCER_4 : +case WM9090_WRITE_SEQUENCER_5 : +case WM9090_CHARGE_PUMP_1 : +case WM9090_DC_SERVO_0 : +case WM9090_DC_SERVO_1 : +case WM9090_DC_SERVO_3 : +case WM9090_DC_SERVO_READBACK_0 : +case WM9090_DC_SERVO_READBACK_1 : +case WM9090_DC_SERVO_READBACK_2 : +case WM9090_ANALOGUE_HP_0 : +case WM9090_AGC_CONTROL_0 : +case WM9090_AGC_CONTROL_1 : +case WM9090_AGC_CONTROL_2 : +return true; + +default : +return false; } }
@@ -492,8 +478,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)static int wm9090_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) { -u16 *reg_cache = codec->reg_cache; -int i, ret; +struct wm9090_priv *wm9090 =snd_soc_codec_get_drvdata (codec);switch (level) {case SND_SOC_BIAS_ON :
@@ -513,7 +498,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,case SND_SOC_BIAS_STANDBY :if (codec->dapm.bias_level ==SND_SOC_BIAS_OFF ) {/* Restore the register cache */ -snd_soc_cache_sync (codec); +regcache_sync (wm9090->regmap); }/* We keep VMID off during standby since the combination of
@@ -537,9 +522,11 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,static int wm9090_probe (struct snd_soc_codec *codec) { +struct wm9090_priv *wm9090 =dev_get_drvdata (codec->dev);int ret; - ret =snd_soc_codec_set_cache_io (codec,8 ,16 ,SND_SOC_I2C ); + codec->control_data = wm9090->regmap; + ret =snd_soc_codec_set_cache_io (codec,8 ,16 ,SND_SOC_REGMAP );if (ret !=0 ) {dev_err (codec->dev,"Failed to set cache I/O: %d\n" , ret);return ret;
@@ -548,7 +535,7 @@ static int wm9090_probe(struct snd_soc_codec *codec) ret =snd_soc_read (codec,WM9090_SOFTWARE_RESET );if (ret <0 )return ret; -if (ret != wm9090_reg_defaults[WM9090_SOFTWARE_RESET ]) { +if (ret !=0x9093 ) {dev_err (codec->dev,"Device is not a WM9090, ID=%x\n" , ret);return -EINVAL ; }
@@ -624,12 +611,22 @@ static struct snd_soc_codec_driver soc_codec_dev_wm9090 = { .suspend = wm9090_suspend, .resume = wm9090_resume, .set_bias_level = wm9090_set_bias_level, - .reg_cache_size = (WM9090_MAX_REGISTER + 1), - .reg_word_size = sizeof(u16), - .reg_cache_default = wm9090_reg_defaults, - .volatile_register = wm9090_volatile, }; +static const struct regmap_config wm9090_regmap = { + .reg_bits =8 , + .val_bits =16 , + + .max_register =WM9090_MAX_REGISTER , + .volatile_reg = wm9090_volatile, + .readable_reg = wm9090_readable, + + .cache_type =REGCACHE_RBTREE , + .reg_defaults = wm9090_reg_defaults, + .num_reg_defaults =ARRAY_SIZE (wm9090_reg_defaults), +}; + +static int wm9090_i2c_probe (struct i2c_client *i2c,const struct i2c_device_id *id) {
@@ -642,6 +639,13 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,return -ENOMEM ; } + wm9090->regmap =regmap_init_i2c (i2c, &wm9090_regmap); +if (IS_ERR (wm9090->regmap)) { + ret =PTR_ERR (wm9090->regmap); +dev_err (&i2c->dev,"Failed to allocate regmap: %d\n" , ret); +return ret; + } +if (i2c->dev.platform_data)memcpy (&wm9090->pdata, i2c->dev.platform_data,sizeof (wm9090->pdata));
@@ -650,6 +654,15 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, ret =snd_soc_register_codec (&i2c->dev, &soc_codec_dev_wm9090,NULL ,0 ); +if (ret !=0 ) { +dev_err (&i2c->dev,"Failed to register CODEC: %d\n" , ret); + goto err; + } + +return 0 ; + +err: +regmap_exit (wm9090->regmap);return ret; }
@@ -658,6 +671,7 @@ static int __devexit wm9090_i2c_remove(struct i2c_client *i2c)struct wm9090_priv *wm9090 =i2c_get_clientdata (i2c);snd_soc_unregister_codec (&i2c->dev); +regmap_exit (wm9090->regmap);return 0 ; }
Signature · 1 line
1.7.7.3
PATCH 4/8 ASoC: Move WM9090 device identification and reset to I2C probe
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm9090.c | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-)
sound/soc/codecs/wm9090.c +14 -12
@@ -532,18 +532,6 @@ static int wm9090_probe(struct snd_soc_codec *codec)return ret; } - ret =snd_soc_read (codec,WM9090_SOFTWARE_RESET ); -if (ret <0 ) -return ret; -if (ret !=0x9093 ) { -dev_err (codec->dev,"Device is not a WM9090, ID=%x\n" , ret); -return -EINVAL ; - } - - ret =snd_soc_write (codec,WM9090_SOFTWARE_RESET ,0 ); -if (ret <0 ) -return ret; -/* Configure some defaults; they will be written out when we * bring the bias up. */
@@ -631,6 +619,7 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct wm9090_priv *wm9090; +unsigned int reg;int ret; wm9090 =devm_kzalloc (&i2c->dev,sizeof (*wm9090),GFP_KERNEL );
@@ -646,6 +635,19 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,return ret; } + ret =regmap_read (wm9090->regmap,WM9090_SOFTWARE_RESET , ®); +if (ret <0 ) + goto err; +if (reg !=0x9093 ) { +dev_err (&i2c->dev,"Device is not a WM9090, ID=%x\n" , ret); + ret = -ENODEV ; + goto err; + } + + ret =regmap_write (wm9090->regmap,WM9090_SOFTWARE_RESET ,0 ); +if (ret <0 ) + goto err; +if (i2c->dev.platform_data)memcpy (&wm9090->pdata, i2c->dev.platform_data,sizeof (wm9090->pdata));
Signature · 1 line
1.7.7.3
PATCH 5/8 ASoC: Convert wm8993 to devm_kzalloc()
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm8993.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
sound/soc/codecs/wm8993.c +2 -3
@@ -1613,7 +1613,8 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c,struct wm8993_priv *wm8993;int ret; - wm8993 =kzalloc (sizeof (struct wm8993_priv ),GFP_KERNEL ); + wm8993 =devm_kzalloc (&i2c-dev,sizeof (struct wm8993_priv ), +GFP_KERNEL );if (wm8993 ==NULL )return -ENOMEM ;
@@ -1621,8 +1622,6 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, ret =snd_soc_register_codec (&i2c->dev, &soc_codec_dev_wm8993, &wm8993_dai,1 ); -if (ret <0 ) -kfree (wm8993);return ret; }
Signature · 1 line
1.7.7.3
PATCH 6/8 ASoC: Use standard register cache sync in wm8993
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm8993.c | 24 +----------------------- 1 files changed, 1 insertions(+), 23 deletions(-)
sound/soc/codecs/wm8993.c +1 -23
@@ -934,28 +934,6 @@ static const struct snd_soc_dapm_route routes[] = { { "Right Headphone Mux", "DAC", "DACR" }, }; -static void wm8993_cache_restore (struct snd_soc_codec *codec) -{ -u16 *cache = codec->reg_cache; -int i; - -if (!codec->cache_sync) -return ; - -/* Reenable hardware writes */ - codec->cache_only =0 ; - -/* Restore the register settings */ -for (i =1 ; i <WM8993_MAX_REGISTER ; i++) { -if (cache[i] == wm8993_reg_defaults[i]) -continue ; -snd_soc_write (codec, i, cache[i]); - } - -/* We're in sync again */ - codec->cache_sync =0 ; -} -static int wm8993_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {
@@ -979,7 +957,7 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,if (ret !=0 )return ret; -wm8993_cache_restore (codec); +snd_soc_cache_sync (codec);/* Tune DC servo configuration */ snd_soc_write (codec,0x44 ,3 );
Signature · 1 line
1.7.7.3
PATCH 7/8 ASoC: Convert wm8993 to direct regmap API usage
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm8993.c | 422 +++++++++++++++++++++++++++++---------------- 1 files changed, 272 insertions(+), 150 deletions(-)
sound/soc/codecs/wm8993.c +272 -150
@@ -16,6 +16,7 @@#include <linux/delay.h> #include <linux/pm.h> #include <linux/i2c.h> +#include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/spi/spi.h> #include <linux/slab.h>
@@ -40,134 +41,112 @@ static const char *wm8993_supply_names[WM8993_NUM_SUPPLIES] = { "SPKVDD", }; -static u16 wm8993_reg_defaults[WM8993_REGISTER_COUNT ] = { -0x8993 ,/* R0 - Software Reset */ -0x0000 ,/* R1 - Power Management (1) */ -0x6000 ,/* R2 - Power Management (2) */ -0x0000 ,/* R3 - Power Management (3) */ -0x4050 ,/* R4 - Audio Interface (1) */ -0x4000 ,/* R5 - Audio Interface (2) */ -0x01C8 ,/* R6 - Clocking 1 */ -0x0000 ,/* R7 - Clocking 2 */ -0x0000 ,/* R8 - Audio Interface (3) */ -0x0040 ,/* R9 - Audio Interface (4) */ -0x0004 ,/* R10 - DAC CTRL */ -0x00C0 ,/* R11 - Left DAC Digital Volume */ -0x00C0 ,/* R12 - Right DAC Digital Volume */ -0x0000 ,/* R13 - Digital Side Tone */ -0x0300 ,/* R14 - ADC CTRL */ -0x00C0 ,/* R15 - Left ADC Digital Volume */ -0x00C0 ,/* R16 - Right ADC Digital Volume */ -0x0000 ,/* R17 */ -0x0000 ,/* R18 - GPIO CTRL 1 */ -0x0010 ,/* R19 - GPIO1 */ -0x0000 ,/* R20 - IRQ_DEBOUNCE */ -0x0000 ,/* R21 */ -0x8000 ,/* R22 - GPIOCTRL 2 */ -0x0800 ,/* R23 - GPIO_POL */ -0x008B ,/* R24 - Left Line Input 1&2 Volume */ -0x008B ,/* R25 - Left Line Input 3&4 Volume */ -0x008B ,/* R26 - Right Line Input 1&2 Volume */ -0x008B ,/* R27 - Right Line Input 3&4 Volume */ -0x006D ,/* R28 - Left Output Volume */ -0x006D ,/* R29 - Right Output Volume */ -0x0066 ,/* R30 - Line Outputs Volume */ -0x0020 ,/* R31 - HPOUT2 Volume */ -0x0079 ,/* R32 - Left OPGA Volume */ -0x0079 ,/* R33 - Right OPGA Volume */ -0x0003 ,/* R34 - SPKMIXL Attenuation */ -0x0003 ,/* R35 - SPKMIXR Attenuation */ -0x0011 ,/* R36 - SPKOUT Mixers */ -0x0100 ,/* R37 - SPKOUT Boost */ -0x0079 ,/* R38 - Speaker Volume Left */ -0x0079 ,/* R39 - Speaker Volume Right */ -0x0000 ,/* R40 - Input Mixer2 */ -0x0000 ,/* R41 - Input Mixer3 */ -0x0000 ,/* R42 - Input Mixer4 */ -0x0000 ,/* R43 - Input Mixer5 */ -0x0000 ,/* R44 - Input Mixer6 */ -0x0000 ,/* R45 - Output Mixer1 */ -0x0000 ,/* R46 - Output Mixer2 */ -0x0000 ,/* R47 - Output Mixer3 */ -0x0000 ,/* R48 - Output Mixer4 */ -0x0000 ,/* R49 - Output Mixer5 */ -0x0000 ,/* R50 - Output Mixer6 */ -0x0000 ,/* R51 - HPOUT2 Mixer */ -0x0000 ,/* R52 - Line Mixer1 */ -0x0000 ,/* R53 - Line Mixer2 */ -0x0000 ,/* R54 - Speaker Mixer */ -0x0000 ,/* R55 - Additional Control */ -0x0000 ,/* R56 - AntiPOP1 */ -0x0000 ,/* R57 - AntiPOP2 */ -0x0000 ,/* R58 - MICBIAS */ -0x0000 ,/* R59 */ -0x0000 ,/* R60 - FLL Control 1 */ -0x0000 ,/* R61 - FLL Control 2 */ -0x0000 ,/* R62 - FLL Control 3 */ -0x2EE0 ,/* R63 - FLL Control 4 */ -0x0002 ,/* R64 - FLL Control 5 */ -0x2287 ,/* R65 - Clocking 3 */ -0x025F ,/* R66 - Clocking 4 */ -0x0000 ,/* R67 - MW Slave Control */ -0x0000 ,/* R68 */ -0x0002 ,/* R69 - Bus Control 1 */ -0x0000 ,/* R70 - Write Sequencer 0 */ -0x0000 ,/* R71 - Write Sequencer 1 */ -0x0000 ,/* R72 - Write Sequencer 2 */ -0x0000 ,/* R73 - Write Sequencer 3 */ -0x0000 ,/* R74 - Write Sequencer 4 */ -0x0000 ,/* R75 - Write Sequencer 5 */ -0x1F25 ,/* R76 - Charge Pump 1 */ -0x0000 ,/* R77 */ -0x0000 ,/* R78 */ -0x0000 ,/* R79 */ -0x0000 ,/* R80 */ -0x0000 ,/* R81 - Class W 0 */ -0x0000 ,/* R82 */ -0x0000 ,/* R83 */ -0x0000 ,/* R84 - DC Servo 0 */ -0x054A ,/* R85 - DC Servo 1 */ -0x0000 ,/* R86 */ -0x0000 ,/* R87 - DC Servo 3 */ -0x0000 ,/* R88 - DC Servo Readback 0 */ -0x0000 ,/* R89 - DC Servo Readback 1 */ -0x0000 ,/* R90 - DC Servo Readback 2 */ -0x0000 ,/* R91 */ -0x0000 ,/* R92 */ -0x0000 ,/* R93 */ -0x0000 ,/* R94 */ -0x0000 ,/* R95 */ -0x0100 ,/* R96 - Analogue HP 0 */ -0x0000 ,/* R97 */ -0x0000 ,/* R98 - EQ1 */ -0x000C ,/* R99 - EQ2 */ -0x000C ,/* R100 - EQ3 */ -0x000C ,/* R101 - EQ4 */ -0x000C ,/* R102 - EQ5 */ -0x000C ,/* R103 - EQ6 */ -0x0FCA ,/* R104 - EQ7 */ -0x0400 ,/* R105 - EQ8 */ -0x00D8 ,/* R106 - EQ9 */ -0x1EB5 ,/* R107 - EQ10 */ -0xF145 ,/* R108 - EQ11 */ -0x0B75 ,/* R109 - EQ12 */ -0x01C5 ,/* R110 - EQ13 */ -0x1C58 ,/* R111 - EQ14 */ -0xF373 ,/* R112 - EQ15 */ -0x0A54 ,/* R113 - EQ16 */ -0x0558 ,/* R114 - EQ17 */ -0x168E ,/* R115 - EQ18 */ -0xF829 ,/* R116 - EQ19 */ -0x07AD ,/* R117 - EQ20 */ -0x1103 ,/* R118 - EQ21 */ -0x0564 ,/* R119 - EQ22 */ -0x0559 ,/* R120 - EQ23 */ -0x4000 ,/* R121 - EQ24 */ -0x0000 ,/* R122 - Digital Pulls */ -0x0F08 ,/* R123 - DRC Control 1 */ -0x0000 ,/* R124 - DRC Control 2 */ -0x0080 ,/* R125 - DRC Control 3 */ -0x0000 ,/* R126 - DRC Control 4 */ +static struct reg_default wm8993_reg_defaults[] = { + {1 ,0x0000 },/* R1 - Power Management (1) */ + {2 ,0x6000 },/* R2 - Power Management (2) */ + {3 ,0x0000 },/* R3 - Power Management (3) */ + {4 ,0x4050 },/* R4 - Audio Interface (1) */ + {5 ,0x4000 },/* R5 - Audio Interface (2) */ + {6 ,0x01C8 },/* R6 - Clocking 1 */ + {7 ,0x0000 },/* R7 - Clocking 2 */ + {8 ,0x0000 },/* R8 - Audio Interface (3) */ + {9 ,0x0040 },/* R9 - Audio Interface (4) */ + {10 ,0x0004 },/* R10 - DAC CTRL */ + {11 ,0x00C0 },/* R11 - Left DAC Digital Volume */ + {12 ,0x00C0 },/* R12 - Right DAC Digital Volume */ + {13 ,0x0000 },/* R13 - Digital Side Tone */ + {14 ,0x0300 },/* R14 - ADC CTRL */ + {15 ,0x00C0 },/* R15 - Left ADC Digital Volume */ + {16 ,0x00C0 },/* R16 - Right ADC Digital Volume */ + {18 ,0x0000 },/* R18 - GPIO CTRL 1 */ + {19 ,0x0010 },/* R19 - GPIO1 */ + {20 ,0x0000 },/* R20 - IRQ_DEBOUNCE */ + {21 ,0x8000 },/* R22 - GPIOCTRL 2 */ + {22 ,0x0800 },/* R23 - GPIO_POL */ + {24 ,0x008B },/* R24 - Left Line Input 1&2 Volume */ + {25 ,0x008B },/* R25 - Left Line Input 3&4 Volume */ + {26 ,0x008B },/* R26 - Right Line Input 1&2 Volume */ + {27 ,0x008B },/* R27 - Right Line Input 3&4 Volume */ + {28 ,0x006D },/* R28 - Left Output Volume */ + {29 ,0x006D },/* R29 - Right Output Volume */ + {30 ,0x0066 },/* R30 - Line Outputs Volume */ + {31 ,0x0020 },/* R31 - HPOUT2 Volume */ + {32 ,0x0079 },/* R32 - Left OPGA Volume */ + {33 ,0x0079 },/* R33 - Right OPGA Volume */ + {34 ,0x0003 },/* R34 - SPKMIXL Attenuation */ + {35 ,0x0003 },/* R35 - SPKMIXR Attenuation */ + {36 ,0x0011 },/* R36 - SPKOUT Mixers */ + {37 ,0x0100 },/* R37 - SPKOUT Boost */ + {38 ,0x0079 },/* R38 - Speaker Volume Left */ + {39 ,0x0079 },/* R39 - Speaker Volume Right */ + {40 ,0x0000 },/* R40 - Input Mixer2 */ + {41 ,0x0000 },/* R41 - Input Mixer3 */ + {42 ,0x0000 },/* R42 - Input Mixer4 */ + {43 ,0x0000 },/* R43 - Input Mixer5 */ + {44 ,0x0000 },/* R44 - Input Mixer6 */ + {45 ,0x0000 },/* R45 - Output Mixer1 */ + {46 ,0x0000 },/* R46 - Output Mixer2 */ + {47 ,0x0000 },/* R47 - Output Mixer3 */ + {48 ,0x0000 },/* R48 - Output Mixer4 */ + {49 ,0x0000 },/* R49 - Output Mixer5 */ + {50 ,0x0000 },/* R50 - Output Mixer6 */ + {51 ,0x0000 },/* R51 - HPOUT2 Mixer */ + {52 ,0x0000 },/* R52 - Line Mixer1 */ + {53 ,0x0000 },/* R53 - Line Mixer2 */ + {54 ,0x0000 },/* R54 - Speaker Mixer */ + {55 ,0x0000 },/* R55 - Additional Control */ + {56 ,0x0000 },/* R56 - AntiPOP1 */ + {57 ,0x0000 },/* R57 - AntiPOP2 */ + {58 ,0x0000 },/* R58 - MICBIAS */ + {60 ,0x0000 },/* R60 - FLL Control 1 */ + {61 ,0x0000 },/* R61 - FLL Control 2 */ + {62 ,0x0000 },/* R62 - FLL Control 3 */ + {63 ,0x2EE0 },/* R63 - FLL Control 4 */ + {64 ,0x0002 },/* R64 - FLL Control 5 */ + {65 ,0x2287 },/* R65 - Clocking 3 */ + {66 ,0x025F },/* R66 - Clocking 4 */ + {67 ,0x0000 },/* R67 - MW Slave Control */ + {69 ,0x0002 },/* R69 - Bus Control 1 */ + {70 ,0x0000 },/* R70 - Write Sequencer 0 */ + {71 ,0x0000 },/* R71 - Write Sequencer 1 */ + {72 ,0x0000 },/* R72 - Write Sequencer 2 */ + {73 ,0x0000 },/* R73 - Write Sequencer 3 */ + {74 ,0x0000 },/* R74 - Write Sequencer 4 */ + {75 ,0x0000 },/* R75 - Write Sequencer 5 */ + {76 ,0x1F25 },/* R76 - Charge Pump 1 */ + {81 ,0x0000 },/* R81 - Class W 0 */ + {85 ,0x054A },/* R85 - DC Servo 1 */ + {87 ,0x0000 },/* R87 - DC Servo 3 */ + {96 ,0x0100 },/* R96 - Analogue HP 0 */ + {98 ,0x0000 },/* R98 - EQ1 */ + {99 ,0x000C },/* R99 - EQ2 */ + {100 ,0x000C },/* R100 - EQ3 */ + {101 ,0x000C },/* R101 - EQ4 */ + {102 ,0x000C },/* R102 - EQ5 */ + {103 ,0x000C },/* R103 - EQ6 */ + {104 ,0x0FCA },/* R104 - EQ7 */ + {105 ,0x0400 },/* R105 - EQ8 */ + {106 ,0x00D8 },/* R106 - EQ9 */ + {107 ,0x1EB5 },/* R107 - EQ10 */ + {108 ,0xF145 },/* R108 - EQ11 */ + {109 ,0x0B75 },/* R109 - EQ12 */ + {110 ,0x01C5 },/* R110 - EQ13 */ + {111 ,0x1C58 },/* R111 - EQ14 */ + {112 ,0xF373 },/* R112 - EQ15 */ + {113 ,0x0A54 },/* R113 - EQ16 */ + {114 ,0x0558 },/* R114 - EQ17 */ + {115 ,0x168E },/* R115 - EQ18 */ + {116 ,0xF829 },/* R116 - EQ19 */ + {117 ,0x07AD },/* R117 - EQ20 */ + {118 ,0x1103 },/* R118 - EQ21 */ + {119 ,0x0564 },/* R119 - EQ22 */ + {120 ,0x0559 },/* R120 - EQ23 */ + {121 ,0x4000 },/* R121 - EQ24 */ + {122 ,0x0000 },/* R122 - Digital Pulls */ + {123 ,0x0F08 },/* R123 - DRC Control 1 */ + {124 ,0x0000 },/* R124 - DRC Control 2 */ + {125 ,0x0080 },/* R125 - DRC Control 3 */ + {126 ,0x0000 },/* R126 - DRC Control 4 */ }; static struct {
@@ -225,9 +204,9 @@ static struct {struct wm8993_priv {struct wm_hubs_data hubs_data; +struct regmap *regmap;struct regulator_bulk_data supplies[WM8993_NUM_SUPPLIES ];struct wm8993_platform_data pdata; -enum snd_soc_control_type control_type;int master;int sysclk_source;int tdm_slots;
@@ -242,7 +221,7 @@ struct wm8993_priv {int fll_src; }; -static int wm8993_volatile (struct snd_soc_codec *codec,unsigned int reg) +static bool wm8993_volatile (struct device *dev,unsigned int reg) {switch (reg) {case WM8993_SOFTWARE_RESET :
@@ -250,9 +229,128 @@ static int wm8993_volatile(struct snd_soc_codec *codec, unsigned int reg)case WM8993_DC_SERVO_READBACK_0 :case WM8993_DC_SERVO_READBACK_1 :case WM8993_DC_SERVO_READBACK_2 : -return 1 ; +return true;default : -return 0 ; +return false; + } +} + +static bool wm8993_readable (struct device *dev,unsigned int reg) +{ +switch (reg) { +case WM8993_SOFTWARE_RESET : +case WM8993_POWER_MANAGEMENT_1 : +case WM8993_POWER_MANAGEMENT_2 : +case WM8993_POWER_MANAGEMENT_3 : +case WM8993_AUDIO_INTERFACE_1 : +case WM8993_AUDIO_INTERFACE_2 : +case WM8993_CLOCKING_1 : +case WM8993_CLOCKING_2 : +case WM8993_AUDIO_INTERFACE_3 : +case WM8993_AUDIO_INTERFACE_4 : +case WM8993_DAC_CTRL : +case WM8993_LEFT_DAC_DIGITAL_VOLUME : +case WM8993_RIGHT_DAC_DIGITAL_VOLUME : +case WM8993_DIGITAL_SIDE_TONE : +case WM8993_ADC_CTRL : +case WM8993_LEFT_ADC_DIGITAL_VOLUME : +case WM8993_RIGHT_ADC_DIGITAL_VOLUME : +case WM8993_GPIO_CTRL_1 : +case WM8993_GPIO1 : +case WM8993_IRQ_DEBOUNCE : +case WM8993_GPIOCTRL_2 : +case WM8993_GPIO_POL : +case WM8993_LEFT_LINE_INPUT_1_2_VOLUME : +case WM8993_LEFT_LINE_INPUT_3_4_VOLUME : +case WM8993_RIGHT_LINE_INPUT_1_2_VOLUME : +case WM8993_RIGHT_LINE_INPUT_3_4_VOLUME : +case WM8993_LEFT_OUTPUT_VOLUME : +case WM8993_RIGHT_OUTPUT_VOLUME : +case WM8993_LINE_OUTPUTS_VOLUME : +case WM8993_HPOUT2_VOLUME : +case WM8993_LEFT_OPGA_VOLUME : +case WM8993_RIGHT_OPGA_VOLUME : +case WM8993_SPKMIXL_ATTENUATION : +case WM8993_SPKMIXR_ATTENUATION : +case WM8993_SPKOUT_MIXERS : +case WM8993_SPKOUT_BOOST : +case WM8993_SPEAKER_VOLUME_LEFT : +case WM8993_SPEAKER_VOLUME_RIGHT : +case WM8993_INPUT_MIXER2 : +case WM8993_INPUT_MIXER3 : +case WM8993_INPUT_MIXER4 : +case WM8993_INPUT_MIXER5 : +case WM8993_INPUT_MIXER6 : +case WM8993_OUTPUT_MIXER1 : +case WM8993_OUTPUT_MIXER2 : +case WM8993_OUTPUT_MIXER3 : +case WM8993_OUTPUT_MIXER4 : +case WM8993_OUTPUT_MIXER5 : +case WM8993_OUTPUT_MIXER6 : +case WM8993_HPOUT2_MIXER : +case WM8993_LINE_MIXER1 : +case WM8993_LINE_MIXER2 : +case WM8993_SPEAKER_MIXER : +case WM8993_ADDITIONAL_CONTROL : +case WM8993_ANTIPOP1 : +case WM8993_ANTIPOP2 : +case WM8993_MICBIAS : +case WM8993_FLL_CONTROL_1 : +case WM8993_FLL_CONTROL_2 : +case WM8993_FLL_CONTROL_3 : +case WM8993_FLL_CONTROL_4 : +case WM8993_FLL_CONTROL_5 : +case WM8993_CLOCKING_3 : +case WM8993_CLOCKING_4 : +case WM8993_MW_SLAVE_CONTROL : +case WM8993_BUS_CONTROL_1 : +case WM8993_WRITE_SEQUENCER_0 : +case WM8993_WRITE_SEQUENCER_1 : +case WM8993_WRITE_SEQUENCER_2 : +case WM8993_WRITE_SEQUENCER_3 : +case WM8993_WRITE_SEQUENCER_4 : +case WM8993_WRITE_SEQUENCER_5 : +case WM8993_CHARGE_PUMP_1 : +case WM8993_CLASS_W_0 : +case WM8993_DC_SERVO_0 : +case WM8993_DC_SERVO_1 : +case WM8993_DC_SERVO_3 : +case WM8993_DC_SERVO_READBACK_0 : +case WM8993_DC_SERVO_READBACK_1 : +case WM8993_DC_SERVO_READBACK_2 : +case WM8993_ANALOGUE_HP_0 : +case WM8993_EQ1 : +case WM8993_EQ2 : +case WM8993_EQ3 : +case WM8993_EQ4 : +case WM8993_EQ5 : +case WM8993_EQ6 : +case WM8993_EQ7 : +case WM8993_EQ8 : +case WM8993_EQ9 : +case WM8993_EQ10 : +case WM8993_EQ11 : +case WM8993_EQ12 : +case WM8993_EQ13 : +case WM8993_EQ14 : +case WM8993_EQ15 : +case WM8993_EQ16 : +case WM8993_EQ17 : +case WM8993_EQ18 : +case WM8993_EQ19 : +case WM8993_EQ20 : +case WM8993_EQ21 : +case WM8993_EQ22 : +case WM8993_EQ23 : +case WM8993_EQ24 : +case WM8993_DIGITAL_PULLS : +case WM8993_DRC_CONTROL_1 : +case WM8993_DRC_CONTROL_2 : +case WM8993_DRC_CONTROL_3 : +case WM8993_DRC_CONTROL_4 : +return true; +default : +return false; } }
@@ -957,7 +1055,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,if (ret !=0 )return ret; -snd_soc_cache_sync (codec); +regcache_cache_only (wm8993->regmap, false); +regcache_sync (wm8993->regmap);/* Tune DC servo configuration */ snd_soc_write (codec,0x44 ,3 );
@@ -1018,14 +1117,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,WM8993_VMID_RAMP_MASK | WM8993_BIAS_SRC, 0); -#ifdef CONFIG_REGULATOR -/* Post 2.6.34 we will be able to get a callback when -* the regulators are disabled which we can use but -* for now just assume that the power will be cut if -* the regulator API is in use. -*/ - codec->cache_sync =1 ; -#endif +regcache_cache_only (wm8993->regmap, true); +regcache_mark_dirty (wm8993->regmap);regulator_bulk_disable (ARRAY_SIZE (wm8993->supplies), wm8993->supplies);
@@ -1419,7 +1512,8 @@ static int wm8993_probe(struct snd_soc_codec *codec) wm8993->hubs_data.dcs_codes_r =-2 ; wm8993->hubs_data.series_startup =1 ; - ret =snd_soc_codec_set_cache_io (codec,8 ,16 ,SND_SOC_I2C ); + codec->control_data = wm8993->regmap; + ret =snd_soc_codec_set_cache_io (codec,8 ,16 ,SND_SOC_REGMAP );if (ret !=0 ) {dev_err (codec->dev,"Failed to set cache I/O: %d\n" , ret);return ret;
@@ -1443,7 +1537,7 @@ static int wm8993_probe(struct snd_soc_codec *codec) } val =snd_soc_read (codec,WM8993_SOFTWARE_RESET ); -if (val != wm8993_reg_defaults[WM8993_SOFTWARE_RESET ]) { +if (val !=0x8993 ) {dev_err (codec->dev,"Invalid ID register value %x\n" , val); ret = -EINVAL ; goto err_enable;
@@ -1453,7 +1547,7 @@ static int wm8993_probe(struct snd_soc_codec *codec)if (ret !=0 ) goto err_enable; - codec->cache_only =1 ; +regcache_cache_only (wm8993->regmap, true);/* By default we're using the output mixers */ wm8993->class_w_users =2 ;
@@ -1572,16 +1666,25 @@ static int wm8993_resume(struct snd_soc_codec *codec)#define wm8993_resume NULL#endif +static const struct regmap_config wm8993_regmap = { + .reg_bits =8 , + .val_bits =16 , + + .max_register =WM8993_MAX_REGISTER , + .volatile_reg = wm8993_volatile, + .readable_reg = wm8993_readable, + + .cache_type =REGCACHE_RBTREE , + .reg_defaults = wm8993_reg_defaults, + .num_reg_defaults =ARRAY_SIZE (wm8993_reg_defaults), +}; +static struct snd_soc_codec_driver soc_codec_dev_wm8993 = { .probe = wm8993_probe, .remove = wm8993_remove, .suspend = wm8993_suspend, .resume = wm8993_resume, .set_bias_level = wm8993_set_bias_level, - .reg_cache_size =ARRAY_SIZE (wm8993_reg_defaults), - .reg_word_size =sizeof (u16), - .reg_cache_default = wm8993_reg_defaults, - .volatile_register = wm8993_volatile, };#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE )
@@ -1591,22 +1694,41 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c,struct wm8993_priv *wm8993;int ret; - wm8993 =devm_kzalloc (&i2c-dev,sizeof (struct wm8993_priv ), + wm8993 =devm_kzalloc (&i2c->dev,sizeof (struct wm8993_priv ),GFP_KERNEL );if (wm8993 ==NULL )return -ENOMEM ; + wm8993->regmap =regmap_init_i2c (i2c, &wm8993_regmap); +if (IS_ERR (wm8993->regmap)) { + ret =PTR_ERR (wm8993->regmap); +dev_err (&i2c->dev,"Failed to allocate regmap: %d\n" , ret); +return ret; + } +i2c_set_clientdata (i2c, wm8993); ret =snd_soc_register_codec (&i2c->dev, &soc_codec_dev_wm8993, &wm8993_dai,1 ); +if (ret !=0 ) { +dev_err (&i2c->dev,"Failed to register CODEC: %d\n" , ret); + goto err; + } + +return ret; + +err: +regmap_exit (wm8993->regmap);return ret; } static __devexit int wm8993_i2c_remove(struct i2c_client *client) { +struct wm8993_priv *wm8993 =i2c_get_clientdata (client); +snd_soc_unregister_codec (&client->dev); -kfree (i2c_get_clientdata (client)); +regmap_exit (wm8993->regmap); +return 0 ; }
Signature · 1 line
1.7.7.3
PATCH 8/8 ASoC: Move WM8993 resource acquisition and device reset to bus probe
In reply to Mark BrownSigned-off-by Mark Brown <[email protected]>
--- sound/soc/codecs/wm8993.c | 89 +++++++++++++++++++++++++-------------------- 1 files changed, 49 insertions(+), 40 deletions(-)
sound/soc/codecs/wm8993.c +49 -40
@@ -1505,7 +1505,7 @@ static int wm8993_probe(struct snd_soc_codec *codec) {struct wm8993_priv *wm8993 =snd_soc_codec_get_drvdata (codec);struct snd_soc_dapm_context *dapm = &codec->dapm; -int ret, i, val; +int ret; wm8993->hubs_data.hp_startup_mode =1 ; wm8993->hubs_data.dcs_codes_l =-2 ;
@@ -1519,36 +1519,6 @@ static int wm8993_probe(struct snd_soc_codec *codec)return ret; } -for (i =0 ; i <ARRAY_SIZE (wm8993->supplies); i++) - wm8993->supplies[i].supply = wm8993_supply_names[i]; - - ret =regulator_bulk_get (codec->dev,ARRAY_SIZE (wm8993->supplies), - wm8993->supplies); -if (ret !=0 ) { -dev_err (codec->dev,"Failed to request supplies: %d\n" , ret); -return ret; - } - - ret =regulator_bulk_enable (ARRAY_SIZE (wm8993->supplies), - wm8993->supplies); -if (ret !=0 ) { -dev_err (codec->dev,"Failed to enable supplies: %d\n" , ret); - goto err_get; - } - - val =snd_soc_read (codec,WM8993_SOFTWARE_RESET ); -if (val !=0x8993 ) { -dev_err (codec->dev,"Invalid ID register value %x\n" , val); - ret = -EINVAL ; - goto err_enable; - } - - ret =snd_soc_write (codec,WM8993_SOFTWARE_RESET ,0xffff ); -if (ret !=0 ) - goto err_enable; - -regcache_cache_only (wm8993->regmap, true); -/* By default we're using the output mixers */ wm8993->class_w_users =2 ;
@@ -1577,7 +1547,7 @@ static int wm8993_probe(struct snd_soc_codec *codec) ret =wm8993_set_bias_level (codec,SND_SOC_BIAS_STANDBY );if (ret !=0 ) - goto err_enable; +return ret;snd_soc_add_controls (codec, wm8993_snd_controls,ARRAY_SIZE (wm8993_snd_controls));
@@ -1599,11 +1569,6 @@ static int wm8993_probe(struct snd_soc_codec *codec)return 0 ; -err_enable: -regulator_bulk_disable (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); -err_get: -regulator_bulk_free (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); -return ret; }static int wm8993_remove (struct snd_soc_codec *codec)
@@ -1692,7 +1657,8 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) {struct wm8993_priv *wm8993; -int ret; +unsigned int reg; +int ret, i; wm8993 =devm_kzalloc (&i2c->dev,sizeof (struct wm8993_priv ),GFP_KERNEL );
@@ -1708,15 +1674,56 @@ static __devinit int wm8993_i2c_probe(struct i2c_client *i2c,i2c_set_clientdata (i2c, wm8993); +for (i =0 ; i <ARRAY_SIZE (wm8993->supplies); i++) + wm8993->supplies[i].supply = wm8993_supply_names[i]; + + ret =regulator_bulk_get (&i2c->dev,ARRAY_SIZE (wm8993->supplies), + wm8993->supplies); +if (ret !=0 ) { +dev_err (&i2c->dev,"Failed to request supplies: %d\n" , ret); + goto err; + } + + ret =regulator_bulk_enable (ARRAY_SIZE (wm8993->supplies), + wm8993->supplies); +if (ret !=0 ) { +dev_err (&i2c->dev,"Failed to enable supplies: %d\n" , ret); + goto err_get; + } + + ret =regmap_read (wm8993->regmap,WM8993_SOFTWARE_RESET , ®); +if (ret !=0 ) { +dev_err (&i2c->dev,"Failed to read chip ID: %d\n" , ret); + goto err_enable; + } + +if (reg !=0x8993 ) { +dev_err (&i2c->dev,"Invalid ID register value %x\n" , reg); + ret = -EINVAL ; + goto err_enable; + } + + ret =regmap_write (wm8993->regmap,WM8993_SOFTWARE_RESET ,0xffff ); +if (ret !=0 ) + goto err_enable; + +regulator_bulk_disable (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); + +regcache_cache_only (wm8993->regmap, true); + ret =snd_soc_register_codec (&i2c->dev, &soc_codec_dev_wm8993, &wm8993_dai,1 );if (ret !=0 ) {dev_err (&i2c->dev,"Failed to register CODEC: %d\n" , ret); - goto err; + goto err_enable; } -return ret; +return 0 ; +err_enable: +regulator_bulk_disable (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); +err_get: +regulator_bulk_free (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); err:regmap_exit (wm8993->regmap);return ret;
@@ -1728,6 +1735,8 @@ static __devexit int wm8993_i2c_remove(struct i2c_client *client)snd_soc_unregister_codec (&client->dev);regmap_exit (wm8993->regmap); +regulator_bulk_disable (ARRAY_SIZE (wm8993->supplies), wm8993->supplies); +regulator_bulk_free (ARRAY_SIZE (wm8993->supplies), wm8993->supplies);return 0 ; }
Signature · 1 line
1.7.7.3