Lines Matching full:sgtl5000
3 // sgtl5000.c -- SGTL5000 ALSA SoC Audio driver
29 #include "sgtl5000.h"
41 /* default value of sgtl5000 registers */
94 /* regulator supplies for sgtl5000, VDDD is an optional external supply */
140 /* sgtl5000 private structure in codec */
270 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in mic_bias_event() local
277 sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); in mic_bias_event()
307 struct sgtl5000_priv *sgtl5000 = in vag_and_mute_control() local
312 sgtl5000->mute_state[event_source] = in vag_and_mute_control()
318 sgtl5000->mute_state[event_source]); in vag_and_mute_control()
321 sgtl5000->mute_state[event_source] = in vag_and_mute_control()
327 sgtl5000->mute_state[event_source]); in vag_and_mute_control()
475 /* routes for sgtl5000 */
798 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_set_dai_fmt() local
801 sgtl5000->master = 0; in sgtl5000_set_dai_fmt()
813 sgtl5000->master = 1; in sgtl5000_set_dai_fmt()
843 sgtl5000->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in sgtl5000_set_dai_fmt()
866 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_set_dai_sysclk() local
870 sgtl5000->sysclk = freq; in sgtl5000_set_dai_sysclk()
881 * sgtl5000 provides 2 clock sources:
894 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_set_clock() local
957 switch (sgtl5000->sysclk / frame_rate) { in sgtl5000_set_clock()
972 if (sgtl5000->master) { in sgtl5000_set_clock()
980 sgtl5000->sysclk / frame_rate); in sgtl5000_set_clock()
992 if (sgtl5000->sysclk > 17000000) { in sgtl5000_set_clock()
994 in = sgtl5000->sysclk / 2; in sgtl5000_set_clock()
997 in = sgtl5000->sysclk; in sgtl5000_set_clock()
1052 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_pcm_hw_params() local
1059 if (!sgtl5000->sysclk) { in sgtl5000_pcm_hw_params()
1081 if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) in sgtl5000_pcm_hw_params()
1098 if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) in sgtl5000_pcm_hw_params()
1170 .name = "sgtl5000",
1279 * sgtl5000 has 3 internal power supplies:
1301 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_set_power_regs() local
1303 vdda = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer); in sgtl5000_set_power_regs()
1304 vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer); in sgtl5000_set_power_regs()
1305 vddd = (sgtl5000->num_supplies > VDDD) in sgtl5000_set_power_regs()
1306 ? regulator_get_voltage(sgtl5000->supplies[VDDD].consumer) in sgtl5000_set_power_regs()
1348 if (regulator_is_equal(sgtl5000->supplies[VDDA].consumer, in sgtl5000_set_power_regs()
1349 sgtl5000->supplies[VDDIO].consumer)) { in sgtl5000_set_power_regs()
1425 struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); in sgtl5000_enable_regulators() local
1427 for (i = 0; i < ARRAY_SIZE(sgtl5000->supplies); i++) in sgtl5000_enable_regulators()
1428 sgtl5000->supplies[i].supply = supply_names[i]; in sgtl5000_enable_regulators()
1440 sgtl5000->num_supplies = ARRAY_SIZE(sgtl5000->supplies) in sgtl5000_enable_regulators()
1442 ret = regulator_bulk_get(&client->dev, sgtl5000->num_supplies, in sgtl5000_enable_regulators()
1443 sgtl5000->supplies); in sgtl5000_enable_regulators()
1447 ret = regulator_bulk_enable(sgtl5000->num_supplies, in sgtl5000_enable_regulators()
1448 sgtl5000->supplies); in sgtl5000_enable_regulators()
1452 regulator_bulk_free(sgtl5000->num_supplies, in sgtl5000_enable_regulators()
1453 sgtl5000->supplies); in sgtl5000_enable_regulators()
1462 struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); in sgtl5000_probe() local
1465 /* power up sgtl5000 */ in sgtl5000_probe()
1486 reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | in sgtl5000_probe()
1487 (sgtl5000->sclk_strength) << SGTL5000_PAD_I2S_SCLK_SHIFT | in sgtl5000_probe()
1496 sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); in sgtl5000_probe()
1500 sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT); in sgtl5000_probe()
1557 * sgtl5000 registers, to make sure we always start with the sane registers
1560 * Since sgtl5000 does not have a reset line, nor a reset command in software,
1567 struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); in sgtl5000_fill_defaults() local
1573 ret = regmap_write(sgtl5000->regmap, index, val); in sgtl5000_fill_defaults()
1583 struct sgtl5000_priv *sgtl5000; in sgtl5000_i2c_probe() local
1589 sgtl5000 = devm_kzalloc(&client->dev, sizeof(*sgtl5000), GFP_KERNEL); in sgtl5000_i2c_probe()
1590 if (!sgtl5000) in sgtl5000_i2c_probe()
1593 i2c_set_clientdata(client, sgtl5000); in sgtl5000_i2c_probe()
1599 sgtl5000->regmap = devm_regmap_init_i2c(client, &sgtl5000_regmap); in sgtl5000_i2c_probe()
1600 if (IS_ERR(sgtl5000->regmap)) { in sgtl5000_i2c_probe()
1601 ret = PTR_ERR(sgtl5000->regmap); in sgtl5000_i2c_probe()
1606 sgtl5000->mclk = devm_clk_get(&client->dev, NULL); in sgtl5000_i2c_probe()
1607 if (IS_ERR(sgtl5000->mclk)) { in sgtl5000_i2c_probe()
1608 ret = PTR_ERR(sgtl5000->mclk); in sgtl5000_i2c_probe()
1618 ret = clk_prepare_enable(sgtl5000->mclk); in sgtl5000_i2c_probe()
1628 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, ®); in sgtl5000_i2c_probe()
1637 "Device with ID register %x is not a sgtl5000\n", reg); in sgtl5000_i2c_probe()
1643 dev_info(&client->dev, "sgtl5000 revision 0x%x\n", rev); in sgtl5000_i2c_probe()
1644 sgtl5000->revision = rev; in sgtl5000_i2c_probe()
1647 ret = regmap_write(sgtl5000->regmap, in sgtl5000_i2c_probe()
1655 ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_CTRL, in sgtl5000_i2c_probe()
1670 ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, &value); in sgtl5000_i2c_probe()
1676 ret = regmap_update_bits(sgtl5000->regmap, in sgtl5000_i2c_probe()
1690 if (sgtl5000->num_supplies <= VDDD) { in sgtl5000_i2c_probe()
1692 ret = regmap_update_bits(sgtl5000->regmap, in sgtl5000_i2c_probe()
1712 ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, ana_pwr); in sgtl5000_i2c_probe()
1723 sgtl5000->micbias_resistor = 0; in sgtl5000_i2c_probe()
1726 sgtl5000->micbias_resistor = 1; in sgtl5000_i2c_probe()
1729 sgtl5000->micbias_resistor = 2; in sgtl5000_i2c_probe()
1732 sgtl5000->micbias_resistor = 3; in sgtl5000_i2c_probe()
1735 sgtl5000->micbias_resistor = 2; in sgtl5000_i2c_probe()
1741 sgtl5000->micbias_resistor = 2; in sgtl5000_i2c_probe()
1748 sgtl5000->micbias_voltage = (value / 250) - 5; in sgtl5000_i2c_probe()
1750 sgtl5000->micbias_voltage = 0; in sgtl5000_i2c_probe()
1755 sgtl5000->micbias_voltage = 0; in sgtl5000_i2c_probe()
1759 sgtl5000->lrclk_strength = I2S_LRCLK_STRENGTH_LOW; in sgtl5000_i2c_probe()
1763 sgtl5000->lrclk_strength = value; in sgtl5000_i2c_probe()
1766 sgtl5000->sclk_strength = I2S_SCLK_STRENGTH_LOW; in sgtl5000_i2c_probe()
1770 sgtl5000->sclk_strength = value; in sgtl5000_i2c_probe()
1773 /* Ensure sgtl5000 will start with sane register values */ in sgtl5000_i2c_probe()
1784 clk_disable_unprepare(sgtl5000->mclk); in sgtl5000_i2c_probe()
1787 regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); in sgtl5000_i2c_probe()
1788 regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies); in sgtl5000_i2c_probe()
1795 struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); in sgtl5000_i2c_remove() local
1797 regmap_write(sgtl5000->regmap, SGTL5000_CHIP_CLK_CTRL, SGTL5000_CHIP_CLK_CTRL_DEFAULT); in sgtl5000_i2c_remove()
1798 regmap_write(sgtl5000->regmap, SGTL5000_CHIP_DIG_POWER, SGTL5000_DIG_POWER_DEFAULT); in sgtl5000_i2c_remove()
1799 regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, SGTL5000_ANA_POWER_DEFAULT); in sgtl5000_i2c_remove()
1801 clk_disable_unprepare(sgtl5000->mclk); in sgtl5000_i2c_remove()
1802 regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); in sgtl5000_i2c_remove()
1803 regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies); in sgtl5000_i2c_remove()
1812 {"sgtl5000"},
1819 { .compatible = "fsl,sgtl5000", },
1826 .name = "sgtl5000",
1837 MODULE_DESCRIPTION("Freescale SGTL5000 ALSA SoC Codec Driver");