Commit f516d322 authored by Jerome Brunet's avatar Jerome Brunet Committed by Mark Brown

ASoC: tas517x: add tas5707 support

Add support for the tas5707 audio power amplifier.
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 599eb906
...@@ -959,8 +959,11 @@ config SND_SOC_TAS5086 ...@@ -959,8 +959,11 @@ config SND_SOC_TAS5086
depends on I2C depends on I2C
config SND_SOC_TAS571X config SND_SOC_TAS571X
tristate "Texas Instruments TAS5711/TAS5717/TAS5719/TAS5721 power amplifiers" tristate "Texas Instruments TAS571x power amplifiers"
depends on I2C depends on I2C
help
Enable support for Texas Instruments TAS5707, TAS5711, TAS5717,
TAS5719 and TAS5721 power amplifiers
config SND_SOC_TAS5720 config SND_SOC_TAS5720
tristate "Texas Instruments TAS5720 Mono Audio amplifier" tristate "Texas Instruments TAS5720 Mono Audio amplifier"
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
* TAS5721 support: * TAS5721 support:
* Copyright (C) 2016 Petr Kulhavy, Barix AG <petr@barix.com> * Copyright (C) 2016 Petr Kulhavy, Barix AG <petr@barix.com>
* *
* TAS5707 support:
* Copyright (C) 2018 Jerome Brunet, Baylibre SAS <jbrunet@baylibre.com>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
...@@ -444,6 +447,111 @@ static const struct tas571x_chip tas5711_chip = { ...@@ -444,6 +447,111 @@ static const struct tas571x_chip tas5711_chip = {
.vol_reg_size = 1, .vol_reg_size = 1,
}; };
static const struct regmap_range tas5707_volatile_regs_range[] = {
regmap_reg_range(TAS571X_CLK_CTRL_REG, TAS571X_ERR_STATUS_REG),
regmap_reg_range(TAS571X_OSC_TRIM_REG, TAS571X_OSC_TRIM_REG),
regmap_reg_range(TAS5707_CH1_BQ0_REG, TAS5707_CH2_BQ6_REG),
};
static const struct regmap_access_table tas5707_volatile_regs = {
.yes_ranges = tas5707_volatile_regs_range,
.n_yes_ranges = ARRAY_SIZE(tas5707_volatile_regs_range),
};
static const DECLARE_TLV_DB_SCALE(tas5707_volume_tlv, -7900, 50, 1);
static const char * const tas5707_volume_slew_step_txt[] = {
"256", "512", "1024", "2048",
};
static const unsigned int tas5707_volume_slew_step_values[] = {
3, 0, 1, 2,
};
static SOC_VALUE_ENUM_SINGLE_DECL(tas5707_volume_slew_step_enum,
TAS571X_VOL_CFG_REG, 0, 0x3,
tas5707_volume_slew_step_txt,
tas5707_volume_slew_step_values);
static const struct snd_kcontrol_new tas5707_controls[] = {
SOC_SINGLE_TLV("Master Volume",
TAS571X_MVOL_REG,
0, 0xff, 1, tas5707_volume_tlv),
SOC_DOUBLE_R_TLV("Speaker Volume",
TAS571X_CH1_VOL_REG,
TAS571X_CH2_VOL_REG,
0, 0xff, 1, tas5707_volume_tlv),
SOC_DOUBLE("Speaker Switch",
TAS571X_SOFT_MUTE_REG,
TAS571X_SOFT_MUTE_CH1_SHIFT, TAS571X_SOFT_MUTE_CH2_SHIFT,
1, 1),
SOC_ENUM("Slew Rate Steps", tas5707_volume_slew_step_enum),
BIQUAD_COEFS("CH1 - Biquad 0", TAS5707_CH1_BQ0_REG),
BIQUAD_COEFS("CH1 - Biquad 1", TAS5707_CH1_BQ1_REG),
BIQUAD_COEFS("CH1 - Biquad 2", TAS5707_CH1_BQ2_REG),
BIQUAD_COEFS("CH1 - Biquad 3", TAS5707_CH1_BQ3_REG),
BIQUAD_COEFS("CH1 - Biquad 4", TAS5707_CH1_BQ4_REG),
BIQUAD_COEFS("CH1 - Biquad 5", TAS5707_CH1_BQ5_REG),
BIQUAD_COEFS("CH1 - Biquad 6", TAS5707_CH1_BQ6_REG),
BIQUAD_COEFS("CH2 - Biquad 0", TAS5707_CH2_BQ0_REG),
BIQUAD_COEFS("CH2 - Biquad 1", TAS5707_CH2_BQ1_REG),
BIQUAD_COEFS("CH2 - Biquad 2", TAS5707_CH2_BQ2_REG),
BIQUAD_COEFS("CH2 - Biquad 3", TAS5707_CH2_BQ3_REG),
BIQUAD_COEFS("CH2 - Biquad 4", TAS5707_CH2_BQ4_REG),
BIQUAD_COEFS("CH2 - Biquad 5", TAS5707_CH2_BQ5_REG),
BIQUAD_COEFS("CH2 - Biquad 6", TAS5707_CH2_BQ6_REG),
};
static const struct reg_default tas5707_reg_defaults[] = {
{TAS571X_CLK_CTRL_REG, 0x6c},
{TAS571X_DEV_ID_REG, 0x70},
{TAS571X_ERR_STATUS_REG, 0x00},
{TAS571X_SYS_CTRL_1_REG, 0xa0},
{TAS571X_SDI_REG, 0x05},
{TAS571X_SYS_CTRL_2_REG, 0x40},
{TAS571X_SOFT_MUTE_REG, 0x00},
{TAS571X_MVOL_REG, 0xff},
{TAS571X_CH1_VOL_REG, 0x30},
{TAS571X_CH2_VOL_REG, 0x30},
{TAS571X_VOL_CFG_REG, 0x91},
{TAS571X_MODULATION_LIMIT_REG, 0x02},
{TAS571X_IC_DELAY_CH1_REG, 0xac},
{TAS571X_IC_DELAY_CH2_REG, 0x54},
{TAS571X_IC_DELAY_CH3_REG, 0xac},
{TAS571X_IC_DELAY_CH4_REG, 0x54},
{TAS571X_START_STOP_PERIOD_REG, 0x0f},
{TAS571X_OSC_TRIM_REG, 0x82},
{TAS571X_BKND_ERR_REG, 0x02},
{TAS571X_INPUT_MUX_REG, 0x17772},
{TAS571X_PWM_MUX_REG, 0x1021345},
};
static const struct regmap_config tas5707_regmap_config = {
.reg_bits = 8,
.val_bits = 32,
.max_register = 0xff,
.reg_read = tas571x_reg_read,
.reg_write = tas571x_reg_write,
.reg_defaults = tas5707_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(tas5707_reg_defaults),
.cache_type = REGCACHE_RBTREE,
.wr_table = &tas571x_write_regs,
.volatile_table = &tas5707_volatile_regs,
};
static const struct tas571x_chip tas5707_chip = {
.supply_names = tas5711_supply_names,
.num_supply_names = ARRAY_SIZE(tas5711_supply_names),
.controls = tas5707_controls,
.num_controls = ARRAY_SIZE(tas5707_controls),
.regmap_config = &tas5707_regmap_config,
.vol_reg_size = 1,
};
static const char *const tas5717_supply_names[] = { static const char *const tas5717_supply_names[] = {
"AVDD", "AVDD",
"DVDD", "DVDD",
...@@ -775,6 +883,7 @@ static int tas571x_i2c_remove(struct i2c_client *client) ...@@ -775,6 +883,7 @@ static int tas571x_i2c_remove(struct i2c_client *client)
} }
static const struct of_device_id tas571x_of_match[] = { static const struct of_device_id tas571x_of_match[] = {
{ .compatible = "ti,tas5707", .data = &tas5707_chip, },
{ .compatible = "ti,tas5711", .data = &tas5711_chip, }, { .compatible = "ti,tas5711", .data = &tas5711_chip, },
{ .compatible = "ti,tas5717", .data = &tas5717_chip, }, { .compatible = "ti,tas5717", .data = &tas5717_chip, },
{ .compatible = "ti,tas5719", .data = &tas5717_chip, }, { .compatible = "ti,tas5719", .data = &tas5717_chip, },
...@@ -784,6 +893,7 @@ static const struct of_device_id tas571x_of_match[] = { ...@@ -784,6 +893,7 @@ static const struct of_device_id tas571x_of_match[] = {
MODULE_DEVICE_TABLE(of, tas571x_of_match); MODULE_DEVICE_TABLE(of, tas571x_of_match);
static const struct i2c_device_id tas571x_i2c_id[] = { static const struct i2c_device_id tas571x_i2c_id[] = {
{ "tas5707", (kernel_ulong_t) &tas5707_chip },
{ "tas5711", (kernel_ulong_t) &tas5711_chip }, { "tas5711", (kernel_ulong_t) &tas5711_chip },
{ "tas5717", (kernel_ulong_t) &tas5717_chip }, { "tas5717", (kernel_ulong_t) &tas5717_chip },
{ "tas5719", (kernel_ulong_t) &tas5717_chip }, { "tas5719", (kernel_ulong_t) &tas5717_chip },
......
...@@ -53,6 +53,22 @@ ...@@ -53,6 +53,22 @@
#define TAS571X_PWM_MUX_REG 0x25 #define TAS571X_PWM_MUX_REG 0x25
/* 20-byte biquad registers */ /* 20-byte biquad registers */
#define TAS5707_CH1_BQ0_REG 0x29
#define TAS5707_CH1_BQ1_REG 0x2a
#define TAS5707_CH1_BQ2_REG 0x2b
#define TAS5707_CH1_BQ3_REG 0x2c
#define TAS5707_CH1_BQ4_REG 0x2d
#define TAS5707_CH1_BQ5_REG 0x2e
#define TAS5707_CH1_BQ6_REG 0x2f
#define TAS5707_CH2_BQ0_REG 0x30
#define TAS5707_CH2_BQ1_REG 0x31
#define TAS5707_CH2_BQ2_REG 0x32
#define TAS5707_CH2_BQ3_REG 0x33
#define TAS5707_CH2_BQ4_REG 0x34
#define TAS5707_CH2_BQ5_REG 0x35
#define TAS5707_CH2_BQ6_REG 0x36
#define TAS5717_CH1_BQ0_REG 0x26 #define TAS5717_CH1_BQ0_REG 0x26
#define TAS5717_CH1_BQ1_REG 0x27 #define TAS5717_CH1_BQ1_REG 0x27
#define TAS5717_CH1_BQ2_REG 0x28 #define TAS5717_CH1_BQ2_REG 0x28
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment