summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/tas2770.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/tas2770.c')
-rw-r--r--sound/soc/codecs/tas2770.c369
1 files changed, 147 insertions, 222 deletions
diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c
index 15cdd8b11a67..a91a0a31e74d 100644
--- a/sound/soc/codecs/tas2770.c
+++ b/sound/soc/codecs/tas2770.c
@@ -16,7 +16,6 @@
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
-#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/firmware.h>
#include <linux/regmap.h>
@@ -40,6 +39,7 @@ static void tas2770_reset(struct tas2770_priv *tas2770)
msleep(20);
gpiod_set_value_cansleep(tas2770->reset_gpio, 1);
}
+
snd_soc_component_write(tas2770->component, TAS2770_SW_RST,
TAS2770_RST);
}
@@ -52,27 +52,24 @@ static int tas2770_set_bias_level(struct snd_soc_component *component,
switch (level) {
case SND_SOC_BIAS_ON:
- snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_ACTIVE);
+ snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_ACTIVE);
break;
case SND_SOC_BIAS_STANDBY:
case SND_SOC_BIAS_PREPARE:
- snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK, TAS2770_PWR_CTRL_MUTE);
+ snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_MUTE);
break;
case SND_SOC_BIAS_OFF:
- snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_SHUTDOWN);
+ snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_SHUTDOWN);
break;
default:
- dev_err(tas2770->dev,
- "wrong power level setting %d\n", level);
+ dev_err(tas2770->dev, "wrong power level setting %d\n", level);
return -EINVAL;
}
@@ -82,32 +79,48 @@ static int tas2770_set_bias_level(struct snd_soc_component *component,
#ifdef CONFIG_PM
static int tas2770_codec_suspend(struct snd_soc_component *component)
{
- int ret;
+ struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component);
+ int ret = 0;
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_SHUTDOWN);
+ regcache_cache_only(tas2770->regmap, true);
+ regcache_mark_dirty(tas2770->regmap);
- if (ret < 0)
- return ret;
+ if (tas2770->sdz_gpio) {
+ gpiod_set_value_cansleep(tas2770->sdz_gpio, 0);
+ } else {
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_SHUTDOWN);
+ if (ret < 0) {
+ regcache_cache_only(tas2770->regmap, false);
+ regcache_sync(tas2770->regmap);
+ return ret;
+ }
- return 0;
+ ret = 0;
+ }
+
+ return ret;
}
static int tas2770_codec_resume(struct snd_soc_component *component)
{
- int ret;
+ struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component);
+ int ret = 0;
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_ACTIVE);
+ if (tas2770->sdz_gpio) {
+ gpiod_set_value_cansleep(tas2770->sdz_gpio, 1);
+ } else {
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_ACTIVE);
+ if (ret < 0)
+ return ret;
+ }
- if (ret < 0)
- return ret;
+ regcache_cache_only(tas2770->regmap, false);
- return 0;
+ return regcache_sync(tas2770->regmap);
}
#else
#define tas2770_codec_suspend NULL
@@ -136,16 +149,14 @@ static int tas2770_dac_event(struct snd_soc_dapm_widget *w,
switch (event) {
case SND_SOC_DAPM_POST_PMU:
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_MUTE);
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_MUTE);
break;
case SND_SOC_DAPM_PRE_PMD:
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_SHUTDOWN);
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_SHUTDOWN);
break;
default:
dev_err(tas2770->dev, "Not supported evevt\n");
@@ -165,14 +176,11 @@ static const struct snd_kcontrol_new vsense_switch =
static const struct snd_soc_dapm_widget tas2770_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("ASI1", "ASI1 Playback", 0, SND_SOC_NOPM, 0, 0),
- SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0,
- &tas2770_asi1_mux),
- SND_SOC_DAPM_SWITCH("ISENSE", TAS2770_PWR_CTRL, 3, 1,
- &isense_switch),
- SND_SOC_DAPM_SWITCH("VSENSE", TAS2770_PWR_CTRL, 2, 1,
- &vsense_switch),
+ SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas2770_asi1_mux),
+ SND_SOC_DAPM_SWITCH("ISENSE", TAS2770_PWR_CTRL, 3, 1, &isense_switch),
+ SND_SOC_DAPM_SWITCH("VSENSE", TAS2770_PWR_CTRL, 2, 1, &vsense_switch),
SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2770_dac_event,
- SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+ SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
SND_SOC_DAPM_OUTPUT("OUT"),
SND_SOC_DAPM_SIGGEN("VMON"),
SND_SOC_DAPM_SIGGEN("IMON")
@@ -195,15 +203,13 @@ static int tas2770_mute(struct snd_soc_dai *dai, int mute, int direction)
int ret;
if (mute)
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_MUTE);
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_MUTE);
else
- ret = snd_soc_component_update_bits(component,
- TAS2770_PWR_CTRL,
- TAS2770_PWR_CTRL_MASK,
- TAS2770_PWR_CTRL_ACTIVE);
+ ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
+ TAS2770_PWR_CTRL_MASK,
+ TAS2770_PWR_CTRL_ACTIVE);
if (ret < 0)
return ret;
@@ -218,24 +224,21 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
switch (bitwidth) {
case SNDRV_PCM_FORMAT_S16_LE:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXW_MASK,
- TAS2770_TDM_CFG_REG2_RXW_16BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXW_MASK,
+ TAS2770_TDM_CFG_REG2_RXW_16BITS);
tas2770->v_sense_slot = tas2770->i_sense_slot + 2;
break;
case SNDRV_PCM_FORMAT_S24_LE:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXW_MASK,
- TAS2770_TDM_CFG_REG2_RXW_24BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXW_MASK,
+ TAS2770_TDM_CFG_REG2_RXW_24BITS);
tas2770->v_sense_slot = tas2770->i_sense_slot + 4;
break;
case SNDRV_PCM_FORMAT_S32_LE:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXW_MASK,
- TAS2770_TDM_CFG_REG2_RXW_32BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXW_MASK,
+ TAS2770_TDM_CFG_REG2_RXW_32BITS);
tas2770->v_sense_slot = tas2770->i_sense_slot + 4;
break;
@@ -246,23 +249,19 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
if (ret < 0)
return ret;
- tas2770->channel_size = bitwidth;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG5,
- TAS2770_TDM_CFG_REG5_VSNS_MASK |
- TAS2770_TDM_CFG_REG5_50_MASK,
- TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG5,
+ TAS2770_TDM_CFG_REG5_VSNS_MASK |
+ TAS2770_TDM_CFG_REG5_50_MASK,
+ TAS2770_TDM_CFG_REG5_VSNS_ENABLE |
tas2770->v_sense_slot);
if (ret < 0)
return ret;
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG6,
- TAS2770_TDM_CFG_REG6_ISNS_MASK |
- TAS2770_TDM_CFG_REG6_50_MASK,
- TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
- tas2770->i_sense_slot);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG6,
+ TAS2770_TDM_CFG_REG6_ISNS_MASK |
+ TAS2770_TDM_CFG_REG6_50_MASK,
+ TAS2770_TDM_CFG_REG6_ISNS_ENABLE |
+ tas2770->i_sense_slot);
if (ret < 0)
return ret;
@@ -271,96 +270,46 @@ static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth)
static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate)
{
- int ret;
struct snd_soc_component *component = tas2770->component;
+ int ramp_rate_val;
+ int ret;
switch (samplerate) {
case 48000:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_48KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
+ TAS2770_TDM_CFG_REG0_31_44_1_48KHZ;
break;
case 44100:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_44_1_48KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
+ TAS2770_TDM_CFG_REG0_31_44_1_48KHZ;
break;
case 96000:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_48KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_88_2_96KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
+ TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
break;
case 88200:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_88_2_96KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
+ TAS2770_TDM_CFG_REG0_31_88_2_96KHZ;
break;
case 19200:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_48KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_176_4_192KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_48KHZ |
+ TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
break;
case 17640:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_SMP_MASK,
- TAS2770_TDM_CFG_REG0_SMP_44_1KHZ);
- if (ret < 0)
- return ret;
-
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG0,
- TAS2770_TDM_CFG_REG0_31_MASK,
- TAS2770_TDM_CFG_REG0_31_176_4_192KHZ);
+ ramp_rate_val = TAS2770_TDM_CFG_REG0_SMP_44_1KHZ |
+ TAS2770_TDM_CFG_REG0_31_176_4_192KHZ;
break;
default:
- ret = -EINVAL;
+ return -EINVAL;
}
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG0,
+ TAS2770_TDM_CFG_REG0_SMP_MASK |
+ TAS2770_TDM_CFG_REG0_31_MASK,
+ ramp_rate_val);
if (ret < 0)
return ret;
- tas2770->sampling_rate = samplerate;
return 0;
}
@@ -374,23 +323,19 @@ static int tas2770_hw_params(struct snd_pcm_substream *substream,
int ret;
ret = tas2770_set_bitwidth(tas2770, params_format(params));
- if (ret < 0)
- goto end;
-
-
- ret = tas2770_set_samplerate(tas2770, params_rate(params));
+ if (ret)
+ return ret;
-end:
- return ret;
+ return tas2770_set_samplerate(tas2770, params_rate(params));
}
static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
- u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
- int ret;
struct snd_soc_component *component = dai->component;
struct tas2770_priv *tas2770 =
snd_soc_component_get_drvdata(component);
+ u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
+ int ret;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
@@ -413,8 +358,8 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
}
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1,
- TAS2770_TDM_CFG_REG1_RX_MASK,
- asi_cfg_1);
+ TAS2770_TDM_CFG_REG1_RX_MASK,
+ asi_cfg_1);
if (ret < 0)
return ret;
@@ -438,13 +383,11 @@ static int tas2770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
}
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG1,
- TAS2770_TDM_CFG_REG1_MASK,
- (tdm_rx_start_slot << TAS2770_TDM_CFG_REG1_51_SHIFT));
+ TAS2770_TDM_CFG_REG1_MASK,
+ (tdm_rx_start_slot << TAS2770_TDM_CFG_REG1_51_SHIFT));
if (ret < 0)
return ret;
- tas2770->asi_format = fmt;
-
return 0;
}
@@ -454,8 +397,6 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
int slots, int slot_width)
{
struct snd_soc_component *component = dai->component;
- struct tas2770_priv *tas2770 =
- snd_soc_component_get_drvdata(component);
int left_slot, right_slot;
int ret;
@@ -465,6 +406,7 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
if (slots == 1) {
if (tx_mask != 1)
return -EINVAL;
+
left_slot = 0;
right_slot = 0;
} else {
@@ -482,43 +424,36 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
return -EINVAL;
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3,
- TAS2770_TDM_CFG_REG3_30_MASK,
- (left_slot << TAS2770_TDM_CFG_REG3_30_SHIFT));
+ TAS2770_TDM_CFG_REG3_30_MASK,
+ (left_slot << TAS2770_TDM_CFG_REG3_30_SHIFT));
if (ret < 0)
return ret;
ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG3,
- TAS2770_TDM_CFG_REG3_RXS_MASK,
- (right_slot << TAS2770_TDM_CFG_REG3_RXS_SHIFT));
+ TAS2770_TDM_CFG_REG3_RXS_MASK,
+ (right_slot << TAS2770_TDM_CFG_REG3_RXS_SHIFT));
if (ret < 0)
return ret;
switch (slot_width) {
case 16:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXS_MASK,
- TAS2770_TDM_CFG_REG2_RXS_16BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXS_MASK,
+ TAS2770_TDM_CFG_REG2_RXS_16BITS);
break;
-
case 24:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXS_MASK,
- TAS2770_TDM_CFG_REG2_RXS_24BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXS_MASK,
+ TAS2770_TDM_CFG_REG2_RXS_24BITS);
break;
-
case 32:
- ret = snd_soc_component_update_bits(component,
- TAS2770_TDM_CFG_REG2,
- TAS2770_TDM_CFG_REG2_RXS_MASK,
- TAS2770_TDM_CFG_REG2_RXS_32BITS);
+ ret = snd_soc_component_update_bits(component, TAS2770_TDM_CFG_REG2,
+ TAS2770_TDM_CFG_REG2_RXS_MASK,
+ TAS2770_TDM_CFG_REG2_RXS_32BITS);
break;
-
case 0:
/* Do not change slot width */
ret = 0;
break;
-
default:
ret = -EINVAL;
}
@@ -526,7 +461,6 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai,
if (ret < 0)
return ret;
- tas2770->slot_width = slot_width;
return 0;
}
@@ -576,6 +510,9 @@ static int tas2770_codec_probe(struct snd_soc_component *component)
tas2770->component = component;
+ if (tas2770->sdz_gpio)
+ gpiod_set_value_cansleep(tas2770->sdz_gpio, 1);
+
tas2770_reset(tas2770);
return 0;
@@ -586,11 +523,9 @@ static DECLARE_TLV_DB_SCALE(tas2770_playback_volume, -12750, 50, 0);
static const struct snd_kcontrol_new tas2770_snd_controls[] = {
SOC_SINGLE_TLV("Speaker Playback Volume", TAS2770_PLAY_CFG_REG2,
- 0, TAS2770_PLAY_CFG_REG2_VMAX, 1,
- tas2770_playback_volume),
- SOC_SINGLE_TLV("Amp Gain Volume", TAS2770_PLAY_CFG_REG0,
- 0, 0x14, 0,
- tas2770_digital_tlv),
+ 0, TAS2770_PLAY_CFG_REG2_VMAX, 1, tas2770_playback_volume),
+ SOC_SINGLE_TLV("Amp Gain Volume", TAS2770_PLAY_CFG_REG0, 0, 0x14, 0,
+ tas2770_digital_tlv),
};
static const struct snd_soc_component_driver soc_component_driver_tas2770 = {
@@ -651,6 +586,7 @@ static bool tas2770_volatile(struct device *dev, unsigned int reg)
case TAS2770_TEMP_LSB:
return true;
}
+
return false;
}
@@ -669,6 +605,7 @@ static bool tas2770_writeable(struct device *dev, unsigned int reg)
case TAS2770_REV_AND_GPID:
return false;
}
+
return true;
}
@@ -701,30 +638,32 @@ static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770)
{
int rc = 0;
- rc = fwnode_property_read_u32(dev->fwnode, "ti,asi-format",
- &tas2770->asi_format);
- if (rc) {
- dev_info(tas2770->dev, "Property %s is missing setting default slot\n",
- "ti,asi-format");
- tas2770->asi_format = 0;
- }
-
rc = fwnode_property_read_u32(dev->fwnode, "ti,imon-slot-no",
- &tas2770->i_sense_slot);
+ &tas2770->i_sense_slot);
if (rc) {
dev_info(tas2770->dev, "Property %s is missing setting default slot\n",
- "ti,imon-slot-no");
+ "ti,imon-slot-no");
+
tas2770->i_sense_slot = 0;
}
rc = fwnode_property_read_u32(dev->fwnode, "ti,vmon-slot-no",
- &tas2770->v_sense_slot);
+ &tas2770->v_sense_slot);
if (rc) {
dev_info(tas2770->dev, "Property %s is missing setting default slot\n",
- "ti,vmon-slot-no");
+ "ti,vmon-slot-no");
+
tas2770->v_sense_slot = 2;
}
+ tas2770->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH);
+ if (IS_ERR(tas2770->sdz_gpio)) {
+ if (PTR_ERR(tas2770->sdz_gpio) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
+ tas2770->sdz_gpio = NULL;
+ }
+
return 0;
}
@@ -734,22 +673,21 @@ static int tas2770_i2c_probe(struct i2c_client *client,
struct tas2770_priv *tas2770;
int result;
- tas2770 = devm_kzalloc(&client->dev,
- sizeof(struct tas2770_priv), GFP_KERNEL);
+ tas2770 = devm_kzalloc(&client->dev, sizeof(struct tas2770_priv),
+ GFP_KERNEL);
if (!tas2770)
return -ENOMEM;
- tas2770->dev = &client->dev;
+ tas2770->dev = &client->dev;
i2c_set_clientdata(client, tas2770);
dev_set_drvdata(&client->dev, tas2770);
- tas2770->power_state = TAS2770_POWER_SHUTDOWN;
tas2770->regmap = devm_regmap_init_i2c(client, &tas2770_i2c_regmap);
if (IS_ERR(tas2770->regmap)) {
result = PTR_ERR(tas2770->regmap);
dev_err(&client->dev, "Failed to allocate register map: %d\n",
- result);
- goto end;
+ result);
+ return result;
}
if (client->dev.of_node) {
@@ -757,7 +695,7 @@ static int tas2770_i2c_probe(struct i2c_client *client,
if (result) {
dev_err(tas2770->dev, "%s: Failed to parse devicetree\n",
__func__);
- goto end;
+ return result;
}
}
@@ -770,24 +708,13 @@ static int tas2770_i2c_probe(struct i2c_client *client,
}
}
- tas2770->channel_size = 0;
- tas2770->slot_width = 0;
-
result = tas2770_register_codec(tas2770);
if (result)
dev_err(tas2770->dev, "Register codec failed.\n");
-end:
return result;
}
-static int tas2770_i2c_remove(struct i2c_client *client)
-{
- pm_runtime_disable(&client->dev);
- return 0;
-}
-
-
static const struct i2c_device_id tas2770_i2c_id[] = {
{ "tas2770", 0},
{ }
@@ -808,10 +735,8 @@ static struct i2c_driver tas2770_i2c_driver = {
.of_match_table = of_match_ptr(tas2770_of_match),
},
.probe = tas2770_i2c_probe,
- .remove = tas2770_i2c_remove,
.id_table = tas2770_i2c_id,
};
-
module_i2c_driver(tas2770_i2c_driver);
MODULE_AUTHOR("Shi Fu <shifu0704@thundersoft.com>");