Commit 927073ee authored by Jack Yu's avatar Jack Yu Committed by Mark Brown

ASoC: rt715: Add software reset in io init

Add software reset before setting preset registers to make sure
all the registers are the default value before preset.
Signed-off-by: default avatarJack Yu <jack.yu@realtek.com>
Link: https://lore.kernel.org/r/4f405c7deb9642e1a8599c5f103b5759@realtek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6870f410
...@@ -52,6 +52,60 @@ static int rt715_index_write(struct regmap *regmap, unsigned int reg, ...@@ -52,6 +52,60 @@ static int rt715_index_write(struct regmap *regmap, unsigned int reg,
return ret; return ret;
} }
static int rt715_index_write_nid(struct regmap *regmap,
unsigned int nid, unsigned int reg, unsigned int value)
{
int ret;
unsigned int addr = ((RT715_PRIV_INDEX_W_H_2 | nid) << 8) | reg;
ret = regmap_write(regmap, addr, value);
if (ret < 0)
pr_err("Failed to set private value: %06x <= %04x ret=%d\n",
addr, value, ret);
return ret;
}
static int rt715_index_read_nid(struct regmap *regmap,
unsigned int nid, unsigned int reg, unsigned int *value)
{
int ret;
unsigned int addr = ((RT715_PRIV_INDEX_W_H_2 | nid) << 8) | reg;
*value = 0;
ret = regmap_read(regmap, addr, value);
if (ret < 0)
pr_err("Failed to get private value: %06x => %04x ret=%d\n",
addr, *value, ret);
return ret;
}
static int rt715_index_update_bits(struct regmap *regmap, unsigned int nid,
unsigned int reg, unsigned int mask, unsigned int val)
{
unsigned int tmp, orig;
int ret;
ret = rt715_index_read_nid(regmap, nid, reg, &orig);
if (ret < 0)
return ret;
tmp = orig & ~mask;
tmp |= val & mask;
return rt715_index_write_nid(regmap, nid, reg, tmp);
}
static void rt715_reset(struct regmap *regmap)
{
regmap_write(regmap, RT715_FUNC_RESET, 0);
rt715_index_update_bits(regmap, RT715_VENDOR_REGISTERS,
RT715_VD_CLEAR_CTRL, RT715_CLEAR_HIDDEN_REG,
RT715_CLEAR_HIDDEN_REG);
}
static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h, static void rt715_get_gain(struct rt715_priv *rt715, unsigned int addr_h,
unsigned int addr_l, unsigned int val_h, unsigned int addr_l, unsigned int val_h,
unsigned int *r_val, unsigned int *l_val) unsigned int *r_val, unsigned int *l_val)
...@@ -1040,6 +1094,8 @@ int rt715_io_init(struct device *dev, struct sdw_slave *slave) ...@@ -1040,6 +1094,8 @@ int rt715_io_init(struct device *dev, struct sdw_slave *slave)
pm_runtime_get_noresume(&slave->dev); pm_runtime_get_noresume(&slave->dev);
rt715_reset(rt715->regmap);
/* Mute nid=08h/09h */ /* Mute nid=08h/09h */
regmap_write(rt715->regmap, RT715_SET_GAIN_LINE_ADC_H, 0xb080); regmap_write(rt715->regmap, RT715_SET_GAIN_LINE_ADC_H, 0xb080);
regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC_H, 0xb080); regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC_H, 0xb080);
......
...@@ -48,6 +48,7 @@ struct rt715_priv { ...@@ -48,6 +48,7 @@ struct rt715_priv {
#define RT715_INLINE_CMD 0x55 #define RT715_INLINE_CMD 0x55
/* Index (NID:20h) */ /* Index (NID:20h) */
#define RT715_VD_CLEAR_CTRL 0x01
#define RT715_SDW_INPUT_SEL 0x39 #define RT715_SDW_INPUT_SEL 0x39
#define RT715_EXT_DMIC_CLK_CTRL2 0x54 #define RT715_EXT_DMIC_CLK_CTRL2 0x54
...@@ -71,6 +72,8 @@ struct rt715_priv { ...@@ -71,6 +72,8 @@ struct rt715_priv {
#define RT715_READ_HDA_0 0x2015 #define RT715_READ_HDA_0 0x2015
#define RT715_PRIV_INDEX_W_H 0x7520 #define RT715_PRIV_INDEX_W_H 0x7520
#define RT715_PRIV_INDEX_W_L 0x85a0 #define RT715_PRIV_INDEX_W_L 0x85a0
#define RT715_PRIV_INDEX_W_H_2 0x7500
#define RT715_PRIV_INDEX_W_L_2 0x8580
#define RT715_PRIV_DATA_W_H 0x7420 #define RT715_PRIV_DATA_W_H 0x7420
#define RT715_PRIV_DATA_W_L 0x84a0 #define RT715_PRIV_DATA_W_L 0x84a0
#define RT715_PRIV_INDEX_R_H 0x9d20 #define RT715_PRIV_INDEX_R_H 0x9d20
...@@ -198,6 +201,10 @@ struct rt715_priv { ...@@ -198,6 +201,10 @@ struct rt715_priv {
#define RT715_SET_DMIC4_CONFIG_DEFAULT4\ #define RT715_SET_DMIC4_CONFIG_DEFAULT4\
(RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC4) (RT715_VERB_SET_CONFIG_DEFAULT4 | RT715_DMIC4)
/* vendor register clear ctrl-1 (0x01)(NID:20h) */
#define RT715_CLEAR_HIDDEN_REG (0x1 << 15)
#define RT715_MUTE_SFT 7 #define RT715_MUTE_SFT 7
#define RT715_DIR_IN_SFT 6 #define RT715_DIR_IN_SFT 6
#define RT715_DIR_OUT_SFT 7 #define RT715_DIR_OUT_SFT 7
......
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