예제 #1
0
파일: sta32x.c 프로젝트: 383530895/linux
static int sta32x_remove(struct snd_soc_codec *codec)
{
	struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);

	sta32x_watchdog_stop(sta32x);
	regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

	return 0;
}
예제 #2
0
/**
 * sta32x_set_bias_level - DAPM callback
 * @codec: the codec device
 * @level: DAPM power level
 *
 * This is called by ALSA to put the codec into low power mode
 * or to wake it up.  If the codec is powered off completely
 * all registers must be restored after power on.
 */
static int sta32x_set_bias_level(struct snd_soc_codec *codec,
                                 enum snd_soc_bias_level level)
{
    int ret;
    struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);

    dev_dbg(codec->dev, "level = %d\n", level);
    switch (level) {
    case SND_SOC_BIAS_ON:
        break;

    case SND_SOC_BIAS_PREPARE:
        /* Full power on */
        regmap_update_bits(sta32x->regmap, STA32X_CONFF,
                           STA32X_CONFF_PWDN | STA32X_CONFF_EAPD,
                           STA32X_CONFF_PWDN | STA32X_CONFF_EAPD);
        break;

    case SND_SOC_BIAS_STANDBY:
        if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
            ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies),
                                        sta32x->supplies);
            if (ret != 0) {
                dev_err(codec->dev,
                        "Failed to enable supplies: %d\n", ret);
                return ret;
            }

            sta32x_startup_sequence(sta32x);
            sta32x_cache_sync(codec);
            sta32x_watchdog_start(sta32x);
        }

        /* Power down */
        regmap_update_bits(sta32x->regmap, STA32X_CONFF,
                           STA32X_CONFF_PWDN | STA32X_CONFF_EAPD,
                           0);

        break;

    case SND_SOC_BIAS_OFF:
        /* The chip runs through the power down sequence for us. */
        regmap_update_bits(sta32x->regmap, STA32X_CONFF,
                           STA32X_CONFF_PWDN | STA32X_CONFF_EAPD, 0);
        msleep(300);
        sta32x_watchdog_stop(sta32x);

        if (sta32x->gpiod_nreset)
            gpiod_set_value(sta32x->gpiod_nreset, 0);

        regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies),
                               sta32x->supplies);
        break;
    }
    codec->dapm.bias_level = level;
    return 0;
}
예제 #3
0
static int sta32x_remove(struct snd_soc_codec *codec)
{
	struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);

	sta32x_watchdog_stop(sta32x);
	sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
	regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
	regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

	return 0;
}