static int wm8770_probe(struct snd_soc_codec *codec) { struct wm8770_priv *wm8770; int ret; wm8770 = snd_soc_codec_get_drvdata(codec); wm8770->codec = codec; ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); if (ret < 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); return ret; } ret = wm8770_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } /* latch the volume update bits */ snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); /* mute all DACs */ snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); err_reg_enable: regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); return ret; }
static int wm8770_probe(struct snd_soc_codec *codec) { struct wm8770_priv *wm8770; int ret; int i; wm8770 = snd_soc_codec_get_drvdata(codec); wm8770->codec = codec; ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8770->control_type); if (ret < 0) { dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); return ret; } for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) wm8770->supplies[i].supply = wm8770_supply_names[i]; ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { dev_err(codec->dev, "Failed to request supplies: %d\n", ret); return ret; } wm8770->disable_nb[0].notifier_call = wm8770_regulator_event_0; wm8770->disable_nb[1].notifier_call = wm8770_regulator_event_1; wm8770->disable_nb[2].notifier_call = wm8770_regulator_event_2; /* This should really be moved into the regulator core */ for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) { ret = regulator_register_notifier(wm8770->supplies[i].consumer, &wm8770->disable_nb[i]); if (ret) { dev_err(codec->dev, "Failed to register regulator notifier: %d\n", ret); } } ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); goto err_reg_get; } ret = wm8770_reset(codec); if (ret < 0) { dev_err(codec->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } wm8770_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* latch the volume update bits */ snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); /* mute all DACs */ snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); snd_soc_add_codec_controls(codec, wm8770_snd_controls, ARRAY_SIZE(wm8770_snd_controls)); snd_soc_dapm_new_controls(&codec->dapm, wm8770_dapm_widgets, ARRAY_SIZE(wm8770_dapm_widgets)); snd_soc_dapm_add_routes(&codec->dapm, wm8770_intercon, ARRAY_SIZE(wm8770_intercon)); return 0; err_reg_enable: regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); err_reg_get: regulator_bulk_free(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); return ret; }