Example #1
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);

	return 0;
}
Example #2
0
static int sta32x_probe(struct snd_soc_codec *codec)
{
	struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
	int i, ret = 0, thermal = 0;

	sta32x->codec = codec;
	sta32x->pdata = dev_get_platdata(codec->dev);

	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;
	}

	/* Chip documentation explicitly requires that the reset values
	 * of reserved register bits are left untouched.
	 * Write the register default value to cache for reserved registers,
	 * so the write to the these registers are suppressed by the cache
	 * restore code when it skips writes of default registers.
	 */
	regcache_cache_only(sta32x->regmap, true);
	snd_soc_write(codec, STA32X_CONFC, 0xc2);
	snd_soc_write(codec, STA32X_CONFE, 0xc2);
	snd_soc_write(codec, STA32X_CONFF, 0x5c);
	snd_soc_write(codec, STA32X_MMUTE, 0x10);
	snd_soc_write(codec, STA32X_AUTO1, 0x60);
	snd_soc_write(codec, STA32X_AUTO3, 0x00);
	snd_soc_write(codec, STA32X_C3CFG, 0x40);
	regcache_cache_only(sta32x->regmap, false);

	/* set thermal warning adjustment and recovery */
	if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_ADJUSTMENT_ENABLE))
		thermal |= STA32X_CONFA_TWAB;
	if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_RECOVERY_ENABLE))
		thermal |= STA32X_CONFA_TWRB;
	snd_soc_update_bits(codec, STA32X_CONFA,
			    STA32X_CONFA_TWAB | STA32X_CONFA_TWRB,
			    thermal);

	/* select output configuration  */
	snd_soc_update_bits(codec, STA32X_CONFF,
			    STA32X_CONFF_OCFG_MASK,
			    sta32x->pdata->output_conf
			    << STA32X_CONFF_OCFG_SHIFT);

	/* channel to output mapping */
	snd_soc_update_bits(codec, STA32X_C1CFG,
			    STA32X_CxCFG_OM_MASK,
			    sta32x->pdata->ch1_output_mapping
			    << STA32X_CxCFG_OM_SHIFT);
	snd_soc_update_bits(codec, STA32X_C2CFG,
			    STA32X_CxCFG_OM_MASK,
			    sta32x->pdata->ch2_output_mapping
			    << STA32X_CxCFG_OM_SHIFT);
	snd_soc_update_bits(codec, STA32X_C3CFG,
			    STA32X_CxCFG_OM_MASK,
			    sta32x->pdata->ch3_output_mapping
			    << STA32X_CxCFG_OM_SHIFT);

	/* initialize coefficient shadow RAM with reset values */
	for (i = 4; i <= 49; i += 5)
		sta32x->coef_shadow[i] = 0x400000;
	for (i = 50; i <= 54; i++)
		sta32x->coef_shadow[i] = 0x7fffff;
	sta32x->coef_shadow[55] = 0x5a9df7;
	sta32x->coef_shadow[56] = 0x7fffff;
	sta32x->coef_shadow[59] = 0x7fffff;
	sta32x->coef_shadow[60] = 0x400000;
	sta32x->coef_shadow[61] = 0x400000;

	if (sta32x->pdata->needs_esd_watchdog)
		INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog);

	sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
	/* Bias level configuration will have done an extra enable */
	regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

	return 0;
}
static int sta32x_resume(struct snd_soc_codec *codec)
{
	sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
	return 0;
}
static int sta32x_suspend(struct snd_soc_codec *codec)
{
	sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
	return 0;
}
Example #5
0
static int sta32x_probe(struct snd_soc_codec *codec)
{
    struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
    struct sta32x_platform_data *pdata = sta32x->pdata;
    int i, ret = 0, thermal = 0;
    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;
    }

    ret = sta32x_startup_sequence(sta32x);
    if (ret < 0) {
        dev_err(codec->dev, "Failed to startup device\n");
        return ret;
    }

    /* CONFA */
    if (!pdata->thermal_warning_recovery)
        thermal |= STA32X_CONFA_TWAB;
    if (!pdata->thermal_warning_adjustment)
        thermal |= STA32X_CONFA_TWRB;
    if (!pdata->fault_detect_recovery)
        thermal |= STA32X_CONFA_FDRB;
    regmap_update_bits(sta32x->regmap, STA32X_CONFA,
                       STA32X_CONFA_TWAB | STA32X_CONFA_TWRB |
                       STA32X_CONFA_FDRB,
                       thermal);

    /* CONFC */
    regmap_update_bits(sta32x->regmap, STA32X_CONFC,
                       STA32X_CONFC_CSZ_MASK,
                       pdata->drop_compensation_ns
                       << STA32X_CONFC_CSZ_SHIFT);

    /* CONFE */
    regmap_update_bits(sta32x->regmap, STA32X_CONFE,
                       STA32X_CONFE_MPCV,
                       pdata->max_power_use_mpcc ?
                       STA32X_CONFE_MPCV : 0);
    regmap_update_bits(sta32x->regmap, STA32X_CONFE,
                       STA32X_CONFE_MPC,
                       pdata->max_power_correction ?
                       STA32X_CONFE_MPC : 0);
    regmap_update_bits(sta32x->regmap, STA32X_CONFE,
                       STA32X_CONFE_AME,
                       pdata->am_reduction_mode ?
                       STA32X_CONFE_AME : 0);
    regmap_update_bits(sta32x->regmap, STA32X_CONFE,
                       STA32X_CONFE_PWMS,
                       pdata->odd_pwm_speed_mode ?
                       STA32X_CONFE_PWMS : 0);

    /*  CONFF */
    regmap_update_bits(sta32x->regmap, STA32X_CONFF,
                       STA32X_CONFF_IDE,
                       pdata->invalid_input_detect_mute ?
                       STA32X_CONFF_IDE : 0);

    /* select output configuration  */
    regmap_update_bits(sta32x->regmap, STA32X_CONFF,
                       STA32X_CONFF_OCFG_MASK,
                       pdata->output_conf
                       << STA32X_CONFF_OCFG_SHIFT);

    /* channel to output mapping */
    regmap_update_bits(sta32x->regmap, STA32X_C1CFG,
                       STA32X_CxCFG_OM_MASK,
                       pdata->ch1_output_mapping
                       << STA32X_CxCFG_OM_SHIFT);
    regmap_update_bits(sta32x->regmap, STA32X_C2CFG,
                       STA32X_CxCFG_OM_MASK,
                       pdata->ch2_output_mapping
                       << STA32X_CxCFG_OM_SHIFT);
    regmap_update_bits(sta32x->regmap, STA32X_C3CFG,
                       STA32X_CxCFG_OM_MASK,
                       pdata->ch3_output_mapping
                       << STA32X_CxCFG_OM_SHIFT);

    /* initialize coefficient shadow RAM with reset values */
    for (i = 4; i <= 49; i += 5)
        sta32x->coef_shadow[i] = 0x400000;
    for (i = 50; i <= 54; i++)
        sta32x->coef_shadow[i] = 0x7fffff;
    sta32x->coef_shadow[55] = 0x5a9df7;
    sta32x->coef_shadow[56] = 0x7fffff;
    sta32x->coef_shadow[59] = 0x7fffff;
    sta32x->coef_shadow[60] = 0x400000;
    sta32x->coef_shadow[61] = 0x400000;

    if (sta32x->pdata->needs_esd_watchdog)
        INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog);

    sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
    /* Bias level configuration will have done an extra enable */
    regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

    return 0;
}
Example #6
0
static int sta32x_probe(struct snd_soc_codec *codec)
{
	struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
	int i, ret = 0;

	sta32x->codec = codec;

	/* regulators */
	for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
		sta32x->supplies[i].supply = sta32x_supply_names[i];

	ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sta32x->supplies),
				 sta32x->supplies);
	if (ret != 0) {
		dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
		goto err;
	}

	ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies),
				    sta32x->supplies);
	if (ret != 0) {
		dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
		goto err_get;
	}

	/* Tell ASoC what kind of I/O to use to read the registers.  ASoC will
	 * then do the I2C transactions itself.
	 */
	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
	if (ret < 0) {
		dev_err(codec->dev, "failed to set cache I/O (ret=%i)\n", ret);
		return ret;
	}

	/* Chip documentation explicitly requires that the reset values
	 * of reserved register bits are left untouched.
	 * Write the register default value to cache for reserved registers,
	 * so the write to the these registers are suppressed by the cache
	 * restore code when it skips writes of default registers.
	 */
	snd_soc_cache_write(codec, STA32X_CONFC, 0xc2);
	snd_soc_cache_write(codec, STA32X_CONFE, 0xc2);
	snd_soc_cache_write(codec, STA32X_CONFF, 0x5c);
	snd_soc_cache_write(codec, STA32X_MMUTE, 0x10);
	snd_soc_cache_write(codec, STA32X_AUTO1, 0x60);
	snd_soc_cache_write(codec, STA32X_AUTO3, 0x00);
	snd_soc_cache_write(codec, STA32X_C3CFG, 0x40);

	/* FIXME enable thermal warning adjustment and recovery  */
	snd_soc_update_bits(codec, STA32X_CONFA,
			    STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, 0);

	/* FIXME select 2.1 mode  */
	snd_soc_update_bits(codec, STA32X_CONFF,
			    STA32X_CONFF_OCFG_MASK,
			    1 << STA32X_CONFF_OCFG_SHIFT);

	/* FIXME channel to output mapping */
	snd_soc_update_bits(codec, STA32X_C1CFG,
			    STA32X_CxCFG_OM_MASK,
			    0 << STA32X_CxCFG_OM_SHIFT);
	snd_soc_update_bits(codec, STA32X_C2CFG,
			    STA32X_CxCFG_OM_MASK,
			    1 << STA32X_CxCFG_OM_SHIFT);
	snd_soc_update_bits(codec, STA32X_C3CFG,
			    STA32X_CxCFG_OM_MASK,
			    2 << STA32X_CxCFG_OM_SHIFT);

	/* initialize coefficient shadow RAM with reset values */
	for (i = 4; i <= 49; i += 5)
		sta32x->coef_shadow[i] = 0x400000;
	for (i = 50; i <= 54; i++)
		sta32x->coef_shadow[i] = 0x7fffff;
	sta32x->coef_shadow[55] = 0x5a9df7;
	sta32x->coef_shadow[56] = 0x7fffff;
	sta32x->coef_shadow[59] = 0x7fffff;
	sta32x->coef_shadow[60] = 0x400000;
	sta32x->coef_shadow[61] = 0x400000;

	sta32x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
	/* Bias level configuration will have done an extra enable */
	regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

	return 0;

err_get:
	regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
err:
	return ret;
}