diff --git a/asoc/codecs/aqt1000/aqt1000-api.h b/asoc/codecs/aqt1000/aqt1000-api.h index 629e9d67bf..fc5d23a57e 100644 --- a/asoc/codecs/aqt1000/aqt1000-api.h +++ b/asoc/codecs/aqt1000/aqt1000-api.h @@ -10,11 +10,12 @@ #include #include -extern int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +extern int aqt_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int volt, int micb_num); -extern int aqt_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable); +extern int aqt_cdc_mclk_enable(struct snd_soc_component *component, + bool enable); extern int aqt_get_micb_vout_ctl_val(u32 micb_mv); -extern int aqt_micbias_control(struct snd_soc_codec *codec, int micb_num, - int req, bool is_dapm); +extern int aqt_micbias_control(struct snd_soc_component *component, + int micb_num, int req, bool is_dapm); #endif /* AQT1000_API_H */ diff --git a/asoc/codecs/aqt1000/aqt1000-clsh.c b/asoc/codecs/aqt1000/aqt1000-clsh.c index b8f403a4e8..218425b525 100644 --- a/asoc/codecs/aqt1000/aqt1000-clsh.c +++ b/asoc/codecs/aqt1000/aqt1000-clsh.c @@ -136,7 +136,7 @@ static const struct aqt_imped_val imped_index[] = { {13, 9}, }; -static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_codec *, +static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_component *, struct aqt_clsh_cdc_data *, u8 req_state, bool en, int mode); @@ -169,12 +169,13 @@ ret: /* * Function: aqt_clsh_imped_config - * Params: codec, imped, reset + * Params: component, imped, reset * Description: * This function updates HPHL and HPHR gain settings * according to the impedance value. */ -void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) +void aqt_clsh_imped_config(struct snd_soc_component *component, + int imped, bool reset) { int i; int index = 0; @@ -189,7 +190,7 @@ void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) /* reset = 1, which means request is to reset the register values */ if (reset) { for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, 0); return; @@ -205,7 +206,7 @@ void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) return; } for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, imped_table_ptr[index][i].val); @@ -242,22 +243,23 @@ static const char *const state_to_str[] = { }; static inline void -aqt_enable_clsh_block(struct snd_soc_codec *codec, +aqt_enable_clsh_block(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, bool enable) { if ((enable && ++clsh_d->clsh_users == 1) || (!enable && --clsh_d->clsh_users == 0)) - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_CRC, 0x01, - (u8) enable); + snd_soc_component_update_bits(component, AQT1000_CDC_CLSH_CRC, + 0x01, (u8) enable); if (clsh_d->clsh_users < 0) clsh_d->clsh_users = 0; - dev_dbg(codec->dev, "%s: clsh_users %d, enable %d", __func__, + dev_dbg(component->dev, "%s: clsh_users %d, enable %d", __func__, clsh_d->clsh_users, enable); } -static inline bool aqt_clsh_enable_status(struct snd_soc_codec *codec) +static inline bool aqt_clsh_enable_status(struct snd_soc_component *component) { - return snd_soc_read(codec, AQT1000_CDC_CLSH_CRC) & 0x01; + return snd_soc_component_read32( + component, AQT1000_CDC_CLSH_CRC) & 0x01; } static inline int aqt_clsh_get_int_mode(struct aqt_clsh_cdc_data *clsh_d, @@ -284,87 +286,106 @@ static inline void aqt_clsh_set_int_mode(struct aqt_clsh_cdc_data *clsh_d, clsh_d->interpolator_modes[ffs(clsh_state)] = mode; } -static inline void aqt_clsh_set_buck_mode(struct snd_soc_codec *codec, +static inline void aqt_clsh_set_buck_mode(struct snd_soc_component *component, int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x08, 0x08); /* set to HIFI */ + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x08, 0x08); /* set to HIFI */ else - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x08, 0x00); /* set to default */ + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x08, 0x00); /* set to default */ } -static inline void aqt_clsh_set_flyback_mode(struct snd_soc_codec *codec, - int mode) +static inline void aqt_clsh_set_flyback_mode( + struct snd_soc_component *component, int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x04, 0x04); /* set to HIFI */ + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x04, 0x04); /* set to HIFI */ else - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x04, 0x00); /* set to Default */ + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x04, 0x00); /* set to Default */ } -static inline void aqt_clsh_gm3_boost_disable(struct snd_soc_codec *codec, - int mode) +static inline void aqt_clsh_gm3_boost_disable( + struct snd_soc_component *component, int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) { - snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL, - 0x80, 0x0); /* disable GM3 Boost */ - snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x80); + snd_soc_component_update_bits(component, + AQT1000_HPH_CNP_WG_CTL, + 0x80, 0x0); /* disable GM3 Boost */ + snd_soc_component_update_bits(component, + AQT1000_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x80); } else { - snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL, - 0x80, 0x80); /* set to Default */ - snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x70); + snd_soc_component_update_bits(component, + AQT1000_HPH_CNP_WG_CTL, + 0x80, 0x80); /* set to Default */ + snd_soc_component_update_bits(component, + AQT1000_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x70); } } -static inline void aqt_clsh_flyback_dac_ctl(struct snd_soc_codec *codec, - int vref) +static inline void aqt_clsh_flyback_dac_ctl( + struct snd_soc_component *component, int vref) { - snd_soc_update_bits(codec, AQT1000_FLYBACK_VNEGDAC_CTRL_2, - 0xE0, (vref << 5)); + snd_soc_component_update_bits(component, + AQT1000_FLYBACK_VNEGDAC_CTRL_2, + 0xE0, (vref << 5)); } -static inline void aqt_clsh_mode_vref_ctl(struct snd_soc_codec *codec, - int vref_ctl) +static inline void aqt_clsh_mode_vref_ctl(struct snd_soc_component *component, + int vref_ctl) { if (vref_ctl == I2C) { - snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_3, 0x02, 0x02); - snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_2, 0xFF, 0x1C); + snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_3, + 0x02, 0x02); + snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_2, + 0xFF, 0x1C); } else { - snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_2, 0xFF, 0x3A); - snd_soc_update_bits(codec, AQT1000_CLASSH_MODE_3, 0x02, 0x00); + snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_2, + 0xFF, 0x3A); + snd_soc_component_update_bits(component, AQT1000_CLASSH_MODE_3, + 0x02, 0x00); } } -static inline void aqt_clsh_buck_current_bias_ctl(struct snd_soc_codec *codec, - bool enable) +static inline void aqt_clsh_buck_current_bias_ctl( + struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4, - 0x70, (I_2UA << 4)); - snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4, - 0x07, I_0P25UA); - snd_soc_update_bits(codec, AQT1000_BUCK_5V_CTRL_CCL_2, - 0x3F, 0x3F); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_IBIAS_CTL_4, + 0x70, (I_2UA << 4)); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_IBIAS_CTL_4, + 0x07, I_0P25UA); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_CTRL_CCL_2, + 0x3F, 0x3F); } else { - snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4, - 0x70, (I_1UA << 4)); - snd_soc_update_bits(codec, AQT1000_BUCK_5V_IBIAS_CTL_4, - 0x07, I_1UA); - snd_soc_update_bits(codec, AQT1000_BUCK_5V_CTRL_CCL_2, - 0x3F, 0x20); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_IBIAS_CTL_4, + 0x70, (I_1UA << 4)); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_IBIAS_CTL_4, + 0x07, I_1UA); + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_CTRL_CCL_2, + 0x3F, 0x20); } } -static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_codec *codec, +static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_component *component, u8 hd2_div_ctl, u8 state) { u16 reg = 0; @@ -374,34 +395,41 @@ static inline void aqt_clsh_rdac_hd2_ctl(struct snd_soc_codec *codec, else if (state == AQT_CLSH_STATE_HPHR) reg = AQT1000_HPH_NEW_INT_RDAC_HD2_CTL_R; else - dev_err(codec->dev, "%s: Invalid state: %d\n", + dev_err(component->dev, "%s: Invalid state: %d\n", __func__, state); if (!reg) - snd_soc_update_bits(codec, reg, 0x0F, hd2_div_ctl); + snd_soc_component_update_bits(component, reg, + 0x0F, hd2_div_ctl); } -static inline void aqt_clsh_force_iq_ctl(struct snd_soc_codec *codec, +static inline void aqt_clsh_force_iq_ctl(struct snd_soc_component *component, int mode) { if (mode == CLS_H_LOHIFI || mode == CLS_AB) { - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_PA_MISC2, - 0x20, 0x20); - snd_soc_update_bits(codec, AQT1000_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0xC0); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL1, - 0x0E, 0x02); + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_PA_MISC2, + 0x20, 0x20); + snd_soc_component_update_bits(component, + AQT1000_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0xC0); + snd_soc_component_update_bits(component, + AQT1000_HPH_PA_CTL1, + 0x0E, 0x02); } else { - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_PA_MISC2, - 0x20, 0x0); - snd_soc_update_bits(codec, AQT1000_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0x80); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL1, - 0x0E, 0x06); + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_PA_MISC2, + 0x20, 0x0); + snd_soc_component_update_bits(component, + AQT1000_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0x80); + snd_soc_component_update_bits(component, + AQT1000_HPH_PA_CTL1, + 0x0E, 0x06); } } -static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec, +static void aqt_clsh_buck_ctrl(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, int mode, bool enable) @@ -409,9 +437,10 @@ static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec, /* enable/disable buck */ if ((enable && (++clsh_d->buck_users == 1)) || (!enable && (--clsh_d->buck_users == 0))) - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - (1 << 7), (enable << 7)); - dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s", + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + (1 << 7), (enable << 7)); + dev_dbg(component->dev, "%s: buck_users %d, enable %d, mode: %s", __func__, clsh_d->buck_users, enable, mode_to_str(mode)); /* * 500us sleep is required after buck enable/disable @@ -420,7 +449,7 @@ static void aqt_clsh_buck_ctrl(struct snd_soc_codec *codec, usleep_range(500, 500 + AQT_USLEEP_RANGE); } -static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec, +static void aqt_clsh_flyback_ctrl(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, int mode, bool enable) @@ -428,12 +457,13 @@ static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec, /* enable/disable flyback */ if ((enable && (++clsh_d->flyback_users == 1)) || (!enable && (--clsh_d->flyback_users == 0))) { - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - (1 << 6), (enable << 6)); + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + (1 << 6), (enable << 6)); /* 100usec delay is needed as per HW requirement */ usleep_range(100, 110); } - dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s", + dev_dbg(component->dev, "%s: flyback_users %d, enable %d, mode: %s", __func__, clsh_d->flyback_users, enable, mode_to_str(mode)); /* * 500us sleep is required after flyback enable/disable @@ -442,7 +472,7 @@ static void aqt_clsh_flyback_ctrl(struct snd_soc_codec *codec, usleep_range(500, 500 + AQT_USLEEP_RANGE); } -static void aqt_clsh_set_hph_mode(struct snd_soc_codec *codec, +static void aqt_clsh_set_hph_mode(struct snd_soc_component *component, int mode) { u8 val = 0; @@ -487,21 +517,22 @@ static void aqt_clsh_set_hph_mode(struct snd_soc_codec *codec, if (mode == CLS_H_LOHIFI || mode == CLS_AB) val = 0x04; - snd_soc_update_bits(codec, AQT1000_ANA_HPH, 0x0C, val); + snd_soc_component_update_bits(component, AQT1000_ANA_HPH, 0x0C, val); } -static void aqt_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec, - int mode) +static void aqt_clsh_set_buck_regulator_mode( + struct snd_soc_component *component, int mode) { - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, + snd_soc_component_update_bits(component, AQT1000_ANA_RX_SUPPLIES, 0x02, 0x00); } -static void aqt_clsh_state_hph_st(struct snd_soc_codec *codec, +static void aqt_clsh_state_hph_st(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_AB || mode == CLS_AB_HIFI) @@ -509,158 +540,163 @@ static void aqt_clsh_state_hph_st(struct snd_soc_codec *codec, if (is_enable) { if (req_state == AQT_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CFG0, 0x40, 0x40); if (req_state == AQT_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); } else { if (req_state == AQT_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); if (req_state == AQT_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); } } -static void aqt_clsh_state_hph_r(struct snd_soc_codec *codec, +static void aqt_clsh_state_hph_r(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_err(codec->dev, "%s: Normal mode not applicable for hph_r\n", + dev_err(component->dev, "%s: Normal mode not applicable for hph_r\n", __func__); return; } if (is_enable) { if (mode != CLS_AB && mode != CLS_AB_HIFI) { - aqt_enable_clsh_block(codec, clsh_d, true); + aqt_enable_clsh_block(component, clsh_d, true); /* * These K1 values depend on the Headphone Impedance * For now it is assumed to be 16 ohm */ - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_MSB, - 0x0F, 0x00); - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_LSB, - 0xFF, 0xC0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, + AQT1000_CDC_CLSH_K1_MSB, + 0x0F, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_CLSH_K1_LSB, + 0xFF, 0xC0); + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); } - aqt_clsh_set_buck_regulator_mode(codec, mode); - aqt_clsh_set_flyback_mode(codec, mode); - aqt_clsh_gm3_boost_disable(codec, mode); - aqt_clsh_flyback_dac_ctl(codec, VREF_N0P9V); - aqt_clsh_mode_vref_ctl(codec, I2C); - aqt_clsh_force_iq_ctl(codec, mode); - aqt_clsh_rdac_hd2_ctl(codec, P82_0P77, req_state); - aqt_clsh_flyback_ctrl(codec, clsh_d, mode, true); - aqt_clsh_flyback_dac_ctl(codec, VREF_N1P827V); - aqt_clsh_set_buck_mode(codec, mode); - aqt_clsh_buck_ctrl(codec, clsh_d, mode, true); - aqt_clsh_mode_vref_ctl(codec, CONTROLLER); - aqt_clsh_buck_current_bias_ctl(codec, true); - aqt_clsh_set_hph_mode(codec, mode); + aqt_clsh_set_buck_regulator_mode(component, mode); + aqt_clsh_set_flyback_mode(component, mode); + aqt_clsh_gm3_boost_disable(component, mode); + aqt_clsh_flyback_dac_ctl(component, VREF_N0P9V); + aqt_clsh_mode_vref_ctl(component, I2C); + aqt_clsh_force_iq_ctl(component, mode); + aqt_clsh_rdac_hd2_ctl(component, P82_0P77, req_state); + aqt_clsh_flyback_ctrl(component, clsh_d, mode, true); + aqt_clsh_flyback_dac_ctl(component, VREF_N1P827V); + aqt_clsh_set_buck_mode(component, mode); + aqt_clsh_buck_ctrl(component, clsh_d, mode, true); + aqt_clsh_mode_vref_ctl(component, CONTROLLER); + aqt_clsh_buck_current_bias_ctl(component, true); + aqt_clsh_set_hph_mode(component, mode); } else { - aqt_clsh_set_hph_mode(codec, CLS_H_NORMAL); - aqt_clsh_buck_current_bias_ctl(codec, false); + aqt_clsh_set_hph_mode(component, CLS_H_NORMAL); + aqt_clsh_buck_current_bias_ctl(component, false); if (mode != CLS_AB && mode != CLS_AB_HIFI) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); - aqt_enable_clsh_block(codec, clsh_d, false); + aqt_enable_clsh_block(component, clsh_d, false); } /* buck and flyback set to default mode and disable */ - aqt_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - aqt_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - aqt_clsh_rdac_hd2_ctl(codec, P5_0P35, req_state); - aqt_clsh_force_iq_ctl(codec, CLS_H_NORMAL); - aqt_clsh_gm3_boost_disable(codec, CLS_H_NORMAL); - aqt_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - aqt_clsh_set_buck_mode(codec, CLS_H_NORMAL); - aqt_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL); + aqt_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + aqt_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + aqt_clsh_rdac_hd2_ctl(component, P5_0P35, req_state); + aqt_clsh_force_iq_ctl(component, CLS_H_NORMAL); + aqt_clsh_gm3_boost_disable(component, CLS_H_NORMAL); + aqt_clsh_set_flyback_mode(component, CLS_H_NORMAL); + aqt_clsh_set_buck_mode(component, CLS_H_NORMAL); + aqt_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL); } } -static void aqt_clsh_state_hph_l(struct snd_soc_codec *codec, +static void aqt_clsh_state_hph_l(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_err(codec->dev, "%s: Normal mode not applicable for hph_l\n", + dev_err(component->dev, "%s: Normal mode not applicable for hph_l\n", __func__); return; } if (is_enable) { if (mode != CLS_AB && mode != CLS_AB_HIFI) { - aqt_enable_clsh_block(codec, clsh_d, true); + aqt_enable_clsh_block(component, clsh_d, true); /* * These K1 values depend on the Headphone Impedance * For now it is assumed to be 16 ohm */ - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_MSB, - 0x0F, 0x00); - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_K1_LSB, - 0xFF, 0xC0); - snd_soc_update_bits(codec, - AQT1000_CDC_RX1_RX_PATH_CFG0, - 0x40, 0x40); + snd_soc_component_update_bits(component, + AQT1000_CDC_CLSH_K1_MSB, + 0x0F, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_CLSH_K1_LSB, + 0xFF, 0xC0); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CFG0, + 0x40, 0x40); } - aqt_clsh_set_buck_regulator_mode(codec, mode); - aqt_clsh_set_flyback_mode(codec, mode); - aqt_clsh_gm3_boost_disable(codec, mode); - aqt_clsh_flyback_dac_ctl(codec, VREF_N0P9V); - aqt_clsh_mode_vref_ctl(codec, I2C); - aqt_clsh_force_iq_ctl(codec, mode); - aqt_clsh_rdac_hd2_ctl(codec, P82_0P77, req_state); - aqt_clsh_flyback_ctrl(codec, clsh_d, mode, true); - aqt_clsh_flyback_dac_ctl(codec, VREF_N1P827V); - aqt_clsh_set_buck_mode(codec, mode); - aqt_clsh_buck_ctrl(codec, clsh_d, mode, true); - aqt_clsh_mode_vref_ctl(codec, CONTROLLER); - aqt_clsh_buck_current_bias_ctl(codec, true); - aqt_clsh_set_hph_mode(codec, mode); + aqt_clsh_set_buck_regulator_mode(component, mode); + aqt_clsh_set_flyback_mode(component, mode); + aqt_clsh_gm3_boost_disable(component, mode); + aqt_clsh_flyback_dac_ctl(component, VREF_N0P9V); + aqt_clsh_mode_vref_ctl(component, I2C); + aqt_clsh_force_iq_ctl(component, mode); + aqt_clsh_rdac_hd2_ctl(component, P82_0P77, req_state); + aqt_clsh_flyback_ctrl(component, clsh_d, mode, true); + aqt_clsh_flyback_dac_ctl(component, VREF_N1P827V); + aqt_clsh_set_buck_mode(component, mode); + aqt_clsh_buck_ctrl(component, clsh_d, mode, true); + aqt_clsh_mode_vref_ctl(component, CONTROLLER); + aqt_clsh_buck_current_bias_ctl(component, true); + aqt_clsh_set_hph_mode(component, mode); } else { - aqt_clsh_set_hph_mode(codec, CLS_H_NORMAL); - aqt_clsh_buck_current_bias_ctl(codec, false); + aqt_clsh_set_hph_mode(component, CLS_H_NORMAL); + aqt_clsh_buck_current_bias_ctl(component, false); if (mode != CLS_AB && mode != CLS_AB_HIFI) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); - aqt_enable_clsh_block(codec, clsh_d, false); + aqt_enable_clsh_block(component, clsh_d, false); } /* set buck and flyback to Default Mode */ - aqt_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - aqt_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - aqt_clsh_rdac_hd2_ctl(codec, P5_0P35, req_state); - aqt_clsh_force_iq_ctl(codec, CLS_H_NORMAL); - aqt_clsh_gm3_boost_disable(codec, CLS_H_NORMAL); - aqt_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - aqt_clsh_set_buck_mode(codec, CLS_H_NORMAL); - aqt_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL); + aqt_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + aqt_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + aqt_clsh_rdac_hd2_ctl(component, P5_0P35, req_state); + aqt_clsh_force_iq_ctl(component, CLS_H_NORMAL); + aqt_clsh_gm3_boost_disable(component, CLS_H_NORMAL); + aqt_clsh_set_flyback_mode(component, CLS_H_NORMAL); + aqt_clsh_set_buck_mode(component, CLS_H_NORMAL); + aqt_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL); } } -static void aqt_clsh_state_err(struct snd_soc_codec *codec, +static void aqt_clsh_state_err(struct snd_soc_component *component, struct aqt_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_err(codec->dev, + dev_err(component->dev, "%s Wrong request for class H state machine requested to %s %s", __func__, is_enable ? "enable" : "disable", state_to_str[req_state]); @@ -687,14 +723,14 @@ static bool aqt_clsh_is_state_valid(u8 state) /* * Function: aqt_clsh_fsm - * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event + * Params: component, cdc_clsh_d, req_state, req_type, clsh_event * Description: * This function handles PRE DAC and POST DAC conditions of different devices * and updates class H configuration of different combination of devices * based on validity of their states. cdc_clsh_d will contain current * class h state information */ -void aqt_clsh_fsm(struct snd_soc_codec *codec, +void aqt_clsh_fsm(struct snd_soc_component *component, struct aqt_clsh_cdc_data *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode) @@ -707,22 +743,22 @@ void aqt_clsh_fsm(struct snd_soc_codec *codec, new_state = old_state | req_state; if (!aqt_clsh_is_state_valid(new_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H not a valid new state: %s\n", __func__, state_to_str[new_state]); return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__, state_to_str[new_state]); return; } cdc_clsh_d->state = new_state; aqt_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode); - (*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state, + (*clsh_state_fp[new_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_ENABLE, int_mode); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str[old_state], state_to_str[cdc_clsh_d->state]); @@ -732,23 +768,23 @@ void aqt_clsh_fsm(struct snd_soc_codec *codec, new_state = old_state & (~req_state); if (new_state < NUM_CLSH_STATES) { if (!aqt_clsh_is_state_valid(old_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s:Invalid old state:%s\n", __func__, state_to_str[old_state]); return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__,state_to_str[new_state]); return; } - (*clsh_state_fp[old_state]) (codec, cdc_clsh_d, + (*clsh_state_fp[old_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_DISABLE, int_mode); cdc_clsh_d->state = new_state; aqt_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE); - dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n", + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str[old_state], state_to_str[cdc_clsh_d->state]); } diff --git a/asoc/codecs/aqt1000/aqt1000-clsh.h b/asoc/codecs/aqt1000/aqt1000-clsh.h index 04b8ca256d..7079450a73 100644 --- a/asoc/codecs/aqt1000/aqt1000-clsh.h +++ b/asoc/codecs/aqt1000/aqt1000-clsh.h @@ -94,14 +94,14 @@ struct aqt_reg_mask_val { u8 val; }; -extern void aqt_clsh_fsm(struct snd_soc_codec *codec, +extern void aqt_clsh_fsm(struct snd_soc_component *component, struct aqt_clsh_cdc_data *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode); extern void aqt_clsh_init(struct aqt_clsh_cdc_data *clsh); extern int aqt_clsh_get_clsh_state(struct aqt_clsh_cdc_data *clsh); -extern void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped, - bool reset); +extern void aqt_clsh_imped_config(struct snd_soc_component *component, + int imped, bool reset); #endif /* _AQT1000_CLSH_H */ diff --git a/asoc/codecs/aqt1000/aqt1000-irq.c b/asoc/codecs/aqt1000/aqt1000-irq.c index b4d2ef6fe3..5f715738aa 100644 --- a/asoc/codecs/aqt1000/aqt1000-irq.c +++ b/asoc/codecs/aqt1000/aqt1000-irq.c @@ -154,6 +154,7 @@ static struct irq_chip aqt_irq_chip = { }; static struct lock_class_key aqt_irq_lock_class; +static struct lock_class_key aqt_irq_lock_requested_class; static int aqt_irq_map(struct irq_domain *irqd, unsigned int virq, irq_hw_number_t hw) @@ -162,7 +163,8 @@ static int aqt_irq_map(struct irq_domain *irqd, unsigned int virq, irq_set_chip_data(virq, data); irq_set_chip_and_handler(virq, &aqt_irq_chip, handle_simple_irq); - irq_set_lockdep_class(virq, &aqt_irq_lock_class); + irq_set_lockdep_class(virq, &aqt_irq_lock_class, + &aqt_irq_lock_requested_class); irq_set_nested_thread(virq, 1); irq_set_noprobe(virq); diff --git a/asoc/codecs/aqt1000/aqt1000-mbhc.c b/asoc/codecs/aqt1000/aqt1000-mbhc.c index 0d96f71e95..4146c6bfbb 100644 --- a/asoc/codecs/aqt1000/aqt1000-mbhc.c +++ b/asoc/codecs/aqt1000/aqt1000-mbhc.c @@ -153,19 +153,19 @@ struct aqt_mbhc_zdet_param { u16 btn7; }; -static int aqt_mbhc_request_irq(struct snd_soc_codec *codec, +static int aqt_mbhc_request_irq(struct snd_soc_component *component, int irq, irq_handler_t handler, const char *name, void *data) { - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct aqt1000 *aqt = dev_get_drvdata(component->dev); return aqt_request_irq(aqt, irq, name, handler, data); } -static void aqt_mbhc_irq_control(struct snd_soc_codec *codec, +static void aqt_mbhc_irq_control(struct snd_soc_component *component, int irq, bool enable) { - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct aqt1000 *aqt = dev_get_drvdata(component->dev); if (enable) aqt_enable_irq(aqt, irq); @@ -173,44 +173,49 @@ static void aqt_mbhc_irq_control(struct snd_soc_codec *codec, aqt_disable_irq(aqt, irq); } -static int aqt_mbhc_free_irq(struct snd_soc_codec *codec, +static int aqt_mbhc_free_irq(struct snd_soc_component *component, int irq, void *data) { - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct aqt1000 *aqt = dev_get_drvdata(component->dev); aqt_free_irq(aqt, irq, data); return 0; } -static void aqt_mbhc_clk_setup(struct snd_soc_codec *codec, +static void aqt_mbhc_clk_setup(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_1, - 0x80, 0x80); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_CTL_1, + 0x80, 0x80); else - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_1, - 0x80, 0x00); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_CTL_1, + 0x80, 0x00); } -static int aqt_mbhc_btn_to_num(struct snd_soc_codec *codec) +static int aqt_mbhc_btn_to_num(struct snd_soc_component *component) { - return snd_soc_read(codec, AQT1000_ANA_MBHC_RESULT_3) & 0x7; + return snd_soc_component_read32(component, + AQT1000_ANA_MBHC_RESULT_3) & 0x7; } -static void aqt_mbhc_mbhc_bias_control(struct snd_soc_codec *codec, +static void aqt_mbhc_mbhc_bias_control(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_ELECT, - 0x01, 0x01); + snd_soc_component_update_bits(component, + AQT1000_ANA_MBHC_ELECT, + 0x01, 0x01); else - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_ELECT, - 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_MBHC_ELECT, + 0x01, 0x00); } -static void aqt_mbhc_program_btn_thr(struct snd_soc_codec *codec, +static void aqt_mbhc_program_btn_thr(struct snd_soc_component *component, s16 *btn_low, s16 *btn_high, int num_btn, bool is_micbias) { @@ -218,24 +223,25 @@ static void aqt_mbhc_program_btn_thr(struct snd_soc_codec *codec, int vth; if (num_btn > WCD_MBHC_DEF_BUTTONS) { - dev_err(codec->dev, "%s: invalid number of buttons: %d\n", + dev_err(component->dev, "%s: invalid number of buttons: %d\n", __func__, num_btn); return; } for (i = 0; i < num_btn; i++) { vth = ((btn_high[i] * 2) / 25) & 0x3F; - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN0 + i, - 0xFC, vth << 2); - dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n", + snd_soc_component_update_bits(component, + AQT1000_ANA_MBHC_BTN0 + i, + 0xFC, vth << 2); + dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n", __func__, i, btn_high[i], vth); } } static bool aqt_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock) { - struct snd_soc_codec *codec = mbhc->codec; - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = mbhc->component; + struct aqt1000 *aqt = dev_get_drvdata(component->dev); bool ret = 0; dev_dbg(aqt->dev, "%s: lock: %d\n", __func__, lock); @@ -264,7 +270,8 @@ static bool aqt_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) u8 val; if (micb_num == MIC_BIAS_1) { - val = ((snd_soc_read(mbhc->codec, AQT1000_ANA_MICB1) & 0xC0) + val = ((snd_soc_component_read32( + mbhc->component, AQT1000_ANA_MICB1) & 0xC0) >> 6); if (val == 0x01) return true; @@ -272,12 +279,13 @@ static bool aqt_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) return false; } -static bool aqt_mbhc_hph_pa_on_status(struct snd_soc_codec *codec) +static bool aqt_mbhc_hph_pa_on_status(struct snd_soc_component *component) { - return (snd_soc_read(codec, AQT1000_ANA_HPH) & 0xC0) ? true : false; + return (snd_soc_component_read32(component, AQT1000_ANA_HPH) & 0xC0) ? + true : false; } -static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec, +static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_component *component, int pull_up_cur) { /* Default pull up current to 2uA */ @@ -285,14 +293,15 @@ static void aqt_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec, pull_up_cur == HS_PULLUP_I_DEFAULT) pull_up_cur = HS_PULLUP_I_2P0_UA; - dev_dbg(codec->dev, "%s: HS pull up current:%d\n", + dev_dbg(component->dev, "%s: HS pull up current:%d\n", __func__, pull_up_cur); - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_INT_MECH_DET_CURRENT, - 0x1F, pull_up_cur); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_INT_MECH_DET_CURRENT, + 0x1F, pull_up_cur); } -static int aqt_mbhc_request_micbias(struct snd_soc_codec *codec, +static int aqt_mbhc_request_micbias(struct snd_soc_component *component, int micb_num, int req) { int ret = 0; @@ -302,33 +311,37 @@ static int aqt_mbhc_request_micbias(struct snd_soc_codec *codec, * is vote to enable mclk */ if (req == MICB_ENABLE) - aqt_cdc_mclk_enable(codec, true); + aqt_cdc_mclk_enable(component, true); - ret = aqt_micbias_control(codec, micb_num, req, false); + ret = aqt_micbias_control(component, micb_num, req, false); /* * Release vote for mclk while requesting for * micbias disable */ if (req == MICB_DISABLE) - aqt_cdc_mclk_enable(codec, false); + aqt_cdc_mclk_enable(component, false); return ret; } -static void aqt_mbhc_micb_ramp_control(struct snd_soc_codec *codec, +static void aqt_mbhc_micb_ramp_control(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP, - 0x1C, 0x0C); - snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP, - 0x80, 0x80); + snd_soc_component_update_bits(component, + AQT1000_ANA_MICB1_RAMP, + 0x1C, 0x0C); + snd_soc_component_update_bits(component, + AQT1000_ANA_MICB1_RAMP, + 0x80, 0x80); } else { - snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP, - 0x80, 0x00); - snd_soc_update_bits(codec, AQT1000_ANA_MICB1_RAMP, - 0x1C, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_MICB1_RAMP, + 0x80, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_MICB1_RAMP, + 0x1C, 0x00); } } @@ -337,26 +350,27 @@ static struct firmware_cal *aqt_get_hwdep_fw_cal(struct wcd_mbhc *mbhc, { struct aqt1000_mbhc *aqt_mbhc; struct firmware_cal *hwdep_cal; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; aqt_mbhc = container_of(mbhc, struct aqt1000_mbhc, wcd_mbhc); - if (!codec) { + if (!component) { pr_err("%s: NULL codec pointer\n", __func__); return NULL; } hwdep_cal = wcdcal_get_fw_cal(aqt_mbhc->fw_data, type); if (!hwdep_cal) - dev_err(codec->dev, "%s: cal not sent by %d\n", + dev_err(component->dev, "%s: cal not sent by %d\n", __func__, type); return hwdep_cal; } -static int aqt_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, - int micb_num, bool req_en) +static int aqt_mbhc_micb_ctrl_threshold_mic( + struct snd_soc_component *component, + int micb_num, bool req_en) { - struct aqt1000_pdata *pdata = dev_get_platdata(codec->dev); + struct aqt1000_pdata *pdata = dev_get_platdata(component->dev); int rc, micb_mv; if (micb_num != MIC_BIAS_1) @@ -372,7 +386,7 @@ static int aqt_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb1_mv; - rc = aqt_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_1); + rc = aqt_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_1); return rc; } @@ -433,25 +447,26 @@ ramp_down: } } -static void aqt_mbhc_zdet_ramp(struct snd_soc_codec *codec, +static void aqt_mbhc_zdet_ramp(struct snd_soc_component *component, struct aqt_mbhc_zdet_param *zdet_param, int32_t *zl, int32_t *zr, s16 *d1_a) { - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct aqt1000 *aqt = dev_get_drvdata(component->dev); int32_t zdet = 0; - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x70, - zdet_param->ldo_ctl << 4); - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN5, 0xFC, - zdet_param->btn5); - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN6, 0xFC, - zdet_param->btn6); - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_BTN7, 0xFC, - zdet_param->btn7); - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x0F, - zdet_param->noff); - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_ZDET_RAMP_CTL, 0x0F, - zdet_param->nshift); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_ZDET_ANA_CTL, 0x70, + zdet_param->ldo_ctl << 4); + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN5, + 0xFC, zdet_param->btn5); + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN6, + 0xFC, zdet_param->btn6); + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_BTN7, + 0xFC, zdet_param->btn7); + snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_ZDET_ANA_CTL, + 0x0F, zdet_param->noff); + snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_ZDET_RAMP_CTL, + 0x0F, zdet_param->nshift); if (!zl) goto z_right; @@ -481,17 +496,17 @@ z_right: *zr = zdet; } -static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, +static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_component *component, int32_t *z_val, int flag_l_r) { s16 q1; int q1_cal; if (*z_val < (AQT_ZDET_VAL_400/1000)) - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, AQT1000_CHIP_CFG0_EFUSE_VAL_OUT1 + (2 * flag_l_r)); else - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, AQT1000_CHIP_CFG0_EFUSE_VAL_OUT2 + (2 * flag_l_r)); if (q1 & 0x80) q1_cal = (10000 - ((q1 & 0x7F) * 25)); @@ -504,8 +519,8 @@ static inline void aqt_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { - struct snd_soc_codec *codec = mbhc->codec; - struct aqt1000 *aqt = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = mbhc->component; + struct aqt1000 *aqt = dev_get_drvdata(component->dev); s16 reg0, reg1, reg2, reg3, reg4; int32_t z1L, z1R, z1Ls; int zMono, z_diff1, z_diff2; @@ -527,13 +542,15 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); - reg0 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN5); - reg1 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN6); - reg2 = snd_soc_read(codec, AQT1000_ANA_MBHC_BTN7); - reg3 = snd_soc_read(codec, AQT1000_MBHC_CTL_CLK); - reg4 = snd_soc_read(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL); + reg0 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN5); + reg1 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN6); + reg2 = snd_soc_component_read32(component, AQT1000_ANA_MBHC_BTN7); + reg3 = snd_soc_component_read32(component, AQT1000_MBHC_CTL_CLK); + reg4 = snd_soc_component_read32(component, + AQT1000_MBHC_NEW_ZDET_ANA_CTL); - if (snd_soc_read(codec, AQT1000_ANA_MBHC_ELECT) & 0x80) { + if (snd_soc_component_read32(component, + AQT1000_ANA_MBHC_ELECT) & 0x80) { is_fsm_disable = true; regmap_update_bits(aqt->regmap, AQT1000_ANA_MBHC_ELECT, 0x80, 0x00); @@ -551,7 +568,7 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; - aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + aqt_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); if (!AQT_MBHC_IS_SECOND_RAMP_REQUIRED(z1L)) goto left_ch_impedance; @@ -567,7 +584,7 @@ static void aqt_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + aqt_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); left_ch_impedance: if ((z1L == AQT_ZDET_FLOATING_IMPEDANCE) || @@ -577,13 +594,13 @@ left_ch_impedance: d1 = d1_a[1]; } else { *zl = z1L/1000; - aqt_wcd_mbhc_qfuse_cal(codec, zl, 0); + aqt_wcd_mbhc_qfuse_cal(component, zl, 0); } - dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", __func__, *zl); /* Start of right impedance ramp and calculation */ - aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + aqt_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); if (AQT_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) { if (((z1R > AQT_ZDET_VAL_1200) && (zdet_param_ptr->noff == 0x6)) || @@ -601,7 +618,7 @@ left_ch_impedance: zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - aqt_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + aqt_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); } right_ch_impedance: if ((z1R == AQT_ZDET_FLOATING_IMPEDANCE) || @@ -609,15 +626,15 @@ right_ch_impedance: *zr = AQT_ZDET_FLOATING_IMPEDANCE; } else { *zr = z1R/1000; - aqt_wcd_mbhc_qfuse_cal(codec, zr, 1); + aqt_wcd_mbhc_qfuse_cal(component, zr, 1); } - dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", __func__, *zr); /* Mono/stereo detection */ if ((*zl == AQT_ZDET_FLOATING_IMPEDANCE) && (*zr == AQT_ZDET_FLOATING_IMPEDANCE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: plug type is invalid or extension cable\n", __func__); goto zdet_complete; @@ -626,40 +643,44 @@ right_ch_impedance: (*zr == AQT_ZDET_FLOATING_IMPEDANCE) || ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) || ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Mono plug type with one ch floating or shorted to GND\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; goto zdet_complete; } - snd_soc_update_bits(codec, AQT1000_HPH_R_ATEST, 0x02, 0x02); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, 0x40, 0x01); + snd_soc_component_update_bits(component, AQT1000_HPH_R_ATEST, + 0x02, 0x02); + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, + 0x40, 0x01); if (*zl < (AQT_ZDET_VAL_32/1000)) - aqt_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1); + aqt_mbhc_zdet_ramp(component, &zdet_param[0], &z1Ls, NULL, d1); else - aqt_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, AQT1000_HPH_R_ATEST, 0x02, 0x00); + aqt_mbhc_zdet_ramp(component, &zdet_param[1], &z1Ls, NULL, d1); + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, + 0x40, 0x00); + snd_soc_component_update_bits(component, AQT1000_HPH_R_ATEST, + 0x02, 0x00); z1Ls /= 1000; - aqt_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0); + aqt_wcd_mbhc_qfuse_cal(component, &z1Ls, 0); /* Parallel of left Z and 9 ohm pull down resistor */ zMono = ((*zl) * 9) / ((*zl) + 9); z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) { - dev_dbg(codec->dev, "%s: stereo plug type detected\n", + dev_dbg(component->dev, "%s: stereo plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_STEREO; } else { - dev_dbg(codec->dev, "%s: MONO plug type detected\n", + dev_dbg(component->dev, "%s: MONO plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; } zdet_complete: - snd_soc_write(codec, AQT1000_ANA_MBHC_BTN5, reg0); - snd_soc_write(codec, AQT1000_ANA_MBHC_BTN6, reg1); - snd_soc_write(codec, AQT1000_ANA_MBHC_BTN7, reg2); + snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN5, reg0); + snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN6, reg1); + snd_soc_component_write(component, AQT1000_ANA_MBHC_BTN7, reg2); /* Turn on 100k pull down on HPHL */ regmap_update_bits(aqt->regmap, AQT1000_ANA_MBHC_MECH, 0x01, 0x01); @@ -669,77 +690,83 @@ zdet_complete: regmap_update_bits(aqt->regmap, AQT1000_ANA_MBHC_MECH, 0x80, 0x80); - snd_soc_write(codec, AQT1000_MBHC_NEW_ZDET_ANA_CTL, reg4); - snd_soc_write(codec, AQT1000_MBHC_CTL_CLK, reg3); + snd_soc_component_write(component, AQT1000_MBHC_NEW_ZDET_ANA_CTL, + reg4); + snd_soc_component_write(component, AQT1000_MBHC_CTL_CLK, reg3); if (is_fsm_disable) regmap_update_bits(aqt->regmap, AQT1000_ANA_MBHC_ELECT, 0x80, 0x80); } -static void aqt_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable) +static void aqt_mbhc_gnd_det_ctrl(struct snd_soc_component *component, + bool enable) { if (enable) { - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH, 0x02, 0x02); - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH, 0x40, 0x40); } else { - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH, 0x40, 0x00); - snd_soc_update_bits(codec, AQT1000_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, AQT1000_ANA_MBHC_MECH, 0x02, 0x00); } } -static void aqt_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, +static void aqt_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, 0x40, 0x40); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, 0x10, 0x10); } else { - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, AQT1000_HPH_PA_CTL2, + snd_soc_component_update_bits(component, AQT1000_HPH_PA_CTL2, 0x10, 0x00); } } static void aqt_mbhc_moisture_config(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; if ((mbhc->moist_rref == R_OFF) || (mbhc->mbhc_cfg->enable_usbc_analog)) { - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2, - 0x0C, R_OFF << 2); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_CTL_2, + 0x0C, R_OFF << 2); return; } /* Do not enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { - dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", + dev_dbg(component->dev, "%s: disable moisture detection for NC\n", __func__); - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2, - 0x0C, R_OFF << 2); + snd_soc_component_update_bits(component, + AQT1000_MBHC_NEW_CTL_2, + 0x0C, R_OFF << 2); return; } - snd_soc_update_bits(codec, AQT1000_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, AQT1000_MBHC_NEW_CTL_2, 0x0C, mbhc->moist_rref << 2); } -static void aqt_update_anc_state(struct snd_soc_codec *codec, bool enable, - int anc_num) +static void aqt_update_anc_state(struct snd_soc_component *component, + bool enable, int anc_num) { if (enable) - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x10); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x10); else - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x00); } static bool aqt_is_anc_on(struct wcd_mbhc *mbhc) @@ -748,9 +775,11 @@ static bool aqt_is_anc_on(struct wcd_mbhc *mbhc) u16 ancl, ancr; ancl = - (snd_soc_read(mbhc->codec, AQT1000_CDC_RX1_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32(mbhc->component, + AQT1000_CDC_RX1_RX_PATH_CFG0)) & 0x10; ancr = - (snd_soc_read(mbhc->codec, AQT1000_CDC_RX2_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32(mbhc->component, + AQT1000_CDC_RX2_RX_PATH_CFG0)) & 0x10; anc_on = !!(ancl | ancr); @@ -785,20 +814,23 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int aqt_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); struct aqt1000_mbhc *aqt_mbhc = aqt->mbhc; struct wcd_mbhc *mbhc; if (!aqt_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mbhc = &aqt_mbhc->wcd_mbhc; ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; - dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); + dev_dbg(component->dev, "%s: hph_type = %u\n", __func__, + mbhc->hph_type); return 0; } @@ -809,19 +841,22 @@ static int aqt_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_multi_mixer_control *mc; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); struct aqt1000_mbhc *aqt_mbhc = aqt->mbhc; if (!aqt_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mc = (struct soc_multi_mixer_control *)(kcontrol->private_value); hphr = mc->shift; wcd_mbhc_get_impedance(&aqt_mbhc->wcd_mbhc, &zl, &zr); - dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); + dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, + zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; @@ -864,22 +899,22 @@ EXPORT_SYMBOL(aqt_mbhc_get_impedance); /* * aqt_mbhc_hs_detect: starts mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @mbhc_cfg: handle to mbhc configuration structure * return 0 if mbhc_start is success or error code in case of failure */ -int aqt_mbhc_hs_detect(struct snd_soc_codec *codec, +int aqt_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { struct aqt1000 *aqt; struct aqt1000_mbhc *aqt_mbhc; - if (!codec) { + if (!component) { pr_err("%s: codec is NULL\n", __func__); return -EINVAL; } - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); if (!aqt) { pr_err("%s: aqt is NULL\n", __func__); return -EINVAL; @@ -887,7 +922,8 @@ int aqt_mbhc_hs_detect(struct snd_soc_codec *codec, aqt_mbhc = aqt->mbhc; if (!aqt_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } @@ -897,19 +933,19 @@ EXPORT_SYMBOL(aqt_mbhc_hs_detect); /* * aqt_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component) { struct aqt1000 *aqt; struct aqt1000_mbhc *aqt_mbhc; - if (!codec) { + if (!component) { pr_err("%s: codec is NULL\n", __func__); return; } - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); if (!aqt) { pr_err("%s: aqt is NULL\n", __func__); return; @@ -917,7 +953,8 @@ void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec) aqt_mbhc = aqt->mbhc; if (!aqt_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return; } wcd_mbhc_stop(&aqt_mbhc->wcd_mbhc); @@ -927,17 +964,17 @@ EXPORT_SYMBOL(aqt_mbhc_hs_detect_exit); /* * aqt_mbhc_post_ssr_init: initialize mbhc for aqt post subsystem restart * @mbhc: poniter to aqt_mbhc structure - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * * return 0 if mbhc_init is success or error code in case of failure */ int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { int ret; struct wcd_mbhc *wcd_mbhc; - if (!mbhc || !codec) + if (!mbhc || !component) return -EINVAL; wcd_mbhc = &mbhc->wcd_mbhc; @@ -947,10 +984,10 @@ int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc, } wcd_mbhc_deinit(wcd_mbhc); - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, AQT_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto done; } @@ -963,29 +1000,30 @@ EXPORT_SYMBOL(aqt_mbhc_post_ssr_init); /* * aqt_mbhc_init: initialize mbhc for aqt * @mbhc: poniter to aqt_mbhc struct pointer to store the configs - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @fw_data: handle to firmware data * * return 0 if mbhc_init is success or error code in case of failure */ -int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, struct snd_soc_codec *codec, - struct fw_info *fw_data) +int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, + struct snd_soc_component *component, + struct fw_info *fw_data) { struct aqt1000_mbhc *aqt_mbhc; struct wcd_mbhc *wcd_mbhc; int ret; - if (!codec) { + if (!component) { pr_err("%s: codec is NULL\n", __func__); return -EINVAL; } - aqt_mbhc = devm_kzalloc(codec->dev, sizeof(struct aqt1000_mbhc), + aqt_mbhc = devm_kzalloc(component->dev, sizeof(struct aqt1000_mbhc), GFP_KERNEL); if (!aqt_mbhc) return -ENOMEM; - aqt_mbhc->aqt = dev_get_drvdata(codec->dev); + aqt_mbhc->aqt = dev_get_drvdata(component->dev); aqt_mbhc->fw_data = fw_data; BLOCKING_INIT_NOTIFIER_HEAD(&aqt_mbhc->notifier); wcd_mbhc = &aqt_mbhc->wcd_mbhc; @@ -999,43 +1037,43 @@ int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, struct snd_soc_codec *codec, /* Setting default mbhc detection logic to ADC */ wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC; - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, AQT_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto err; } (*mbhc) = aqt_mbhc; - snd_soc_add_codec_controls(codec, impedance_detect_controls, + snd_soc_add_component_controls(component, impedance_detect_controls, ARRAY_SIZE(impedance_detect_controls)); - snd_soc_add_codec_controls(codec, hph_type_detect_controls, + snd_soc_add_component_controls(component, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); return 0; err: - devm_kfree(codec->dev, aqt_mbhc); + devm_kfree(component->dev, aqt_mbhc); return ret; } EXPORT_SYMBOL(aqt_mbhc_init); /* * aqt_mbhc_deinit: deinitialize mbhc for aqt - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void aqt_mbhc_deinit(struct snd_soc_codec *codec) +void aqt_mbhc_deinit(struct snd_soc_component *component) { struct aqt1000 *aqt; struct aqt1000_mbhc *aqt_mbhc; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return; } - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); if (!aqt) { pr_err("%s: aqt is NULL\n", __func__); return; @@ -1044,7 +1082,7 @@ void aqt_mbhc_deinit(struct snd_soc_codec *codec) aqt_mbhc = aqt->mbhc; if (aqt_mbhc) { wcd_mbhc_deinit(&aqt_mbhc->wcd_mbhc); - devm_kfree(codec->dev, aqt_mbhc); + devm_kfree(component->dev, aqt_mbhc); } } EXPORT_SYMBOL(aqt_mbhc_deinit); diff --git a/asoc/codecs/aqt1000/aqt1000-mbhc.h b/asoc/codecs/aqt1000/aqt1000-mbhc.h index 1fad90a2fb..aea788cc5e 100644 --- a/asoc/codecs/aqt1000/aqt1000-mbhc.h +++ b/asoc/codecs/aqt1000/aqt1000-mbhc.h @@ -15,36 +15,36 @@ struct aqt1000_mbhc { #if IS_ENABLED(CONFIG_SND_SOC_AQT1000) extern int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data); -extern void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec); -extern int aqt_mbhc_hs_detect(struct snd_soc_codec *codec, +extern void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component); +extern int aqt_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); -extern void aqt_mbhc_deinit(struct snd_soc_codec *codec); +extern void aqt_mbhc_deinit(struct snd_soc_component *component); extern int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc, - struct snd_soc_codec *codec); + struct snd_soc_component *component); extern int aqt_mbhc_get_impedance(struct aqt1000_mbhc *aqt_mbhc, uint32_t *zl, uint32_t *zr); #else static inline int aqt_mbhc_init(struct aqt1000_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data) { return 0; } -static inline void aqt_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +static inline void aqt_mbhc_hs_detect_exit(struct snd_soc_component *component) { } -static inline int aqt_mbhc_hs_detect(struct snd_soc_codec *codec, +static inline int aqt_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { return 0; } -static inline void aqt_mbhc_deinit(struct snd_soc_codec *codec) +static inline void aqt_mbhc_deinit(struct snd_soc_component *component) { } static inline int aqt_mbhc_post_ssr_init(struct aqt1000_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } diff --git a/asoc/codecs/aqt1000/aqt1000.c b/asoc/codecs/aqt1000/aqt1000.c index 59a9d87266..ef0c265e0a 100644 --- a/asoc/codecs/aqt1000/aqt1000.c +++ b/asoc/codecs/aqt1000/aqt1000.c @@ -33,6 +33,8 @@ #include "../wcdcal-hwdep.h" #include "aqt1000-internal.h" +#define DRV_NAME "aqt_codec" + #define AQT1000_TX_UNMUTE_DELAY_MS 40 #define TX_HPF_CUT_OFF_FREQ_MASK 0x60 #define CF_MIN_3DB_4HZ 0x0 @@ -52,7 +54,7 @@ static int tx_unmute_delay = AQT1000_TX_UNMUTE_DELAY_MS; module_param(tx_unmute_delay, int, 0664); MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path"); -static void aqt_codec_set_tx_hold(struct snd_soc_codec *, u16, bool); +static void aqt_codec_set_tx_hold(struct snd_soc_component *, u16, bool); /* Cutoff frequency for high pass filter */ static const char * const cf_text[] = { @@ -91,8 +93,9 @@ static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0); static int aqt_get_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = aqt->anc_slot; return 0; @@ -101,8 +104,9 @@ static int aqt_get_anc_slot(struct snd_kcontrol *kcontrol, static int aqt_put_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); aqt->anc_slot = ucontrol->value.integer.value[0]; return 0; @@ -111,8 +115,9 @@ static int aqt_put_anc_slot(struct snd_kcontrol *kcontrol, static int aqt_get_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (aqt->anc_func == true ? 1 : 0); return 0; @@ -121,13 +126,15 @@ static int aqt_get_anc_func(struct snd_kcontrol *kcontrol, static int aqt_put_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); mutex_lock(&aqt->codec_mutex); aqt->anc_func = (!ucontrol->value.integer.value[0] ? false : true); - dev_dbg(codec->dev, "%s: anc_func %x", __func__, aqt->anc_func); + dev_dbg(component->dev, "%s: anc_func %x", __func__, aqt->anc_func); if (aqt->anc_func == true) { snd_soc_dapm_enable_pin(dapm, "ANC HPHL PA"); @@ -161,8 +168,9 @@ static const struct soc_enum aqt_anc_func_enum = static int aqt_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = aqt->hph_mode; return 0; @@ -171,16 +179,17 @@ static int aqt_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int aqt_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); u32 mode_val; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val); + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (mode_val == 0) { - dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H LOHiFi\n", + dev_warn(component->dev, "%s:Invalid HPH Mode, default to Cls-H LOHiFi\n", __func__); mode_val = CLS_H_LOHIFI; } @@ -200,15 +209,16 @@ static const struct soc_enum rx_hph_mode_mux_enum = static int aqt_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - ucontrol->value.integer.value[0] = (snd_soc_read(codec, + ucontrol->value.integer.value[0] = (snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_CTL) & (1 << band_idx)) != 0; - dev_dbg(codec->dev, "%s: IIR0 band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR0 band #%d enable %d\n", __func__, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; @@ -217,60 +227,64 @@ static int aqt_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, static int aqt_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; bool iir_band_en_status; int value = ucontrol->value.integer.value[0]; /* Mask first 5 bits, 6-8 are reserved */ - snd_soc_update_bits(codec, AQT1000_CDC_SIDETONE_IIR0_IIR_CTL, - (1 << band_idx), (value << band_idx)); + snd_soc_component_update_bits(component, + AQT1000_CDC_SIDETONE_IIR0_IIR_CTL, + (1 << band_idx), (value << band_idx)); - iir_band_en_status = ((snd_soc_read(codec, + iir_band_en_status = ((snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_CTL) & (1 << band_idx)) != 0); - dev_dbg(codec->dev, "%s: IIR0 band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR0 band #%d enable %d\n", __func__, band_idx, iir_band_en_status); return 0; } -static uint32_t aqt_get_iir_band_coeff(struct snd_soc_codec *codec, +static uint32_t aqt_get_iir_band_coeff(struct snd_soc_component *component, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL, ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); - value |= snd_soc_read(codec, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL); + value |= snd_soc_component_read32(component, + AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL); - snd_soc_write(codec, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL, + snd_soc_component_write(component, + AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL, ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); - value |= (snd_soc_read(codec, - AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL) << 8); + value |= (snd_soc_component_read32(component, + AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL) << 8); - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL, ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); - value |= (snd_soc_read(codec, - AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL) << 16); + value |= (snd_soc_component_read32(component, + AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL) << 16); - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL, ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ - value |= ((snd_soc_read(codec, + value |= ((snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL) & 0x3F) << 24); @@ -280,22 +294,23 @@ static uint32_t aqt_get_iir_band_coeff(struct snd_soc_codec *codec, static int aqt_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = - aqt_get_iir_band_coeff(codec, band_idx, 0); + aqt_get_iir_band_coeff(component, band_idx, 0); ucontrol->value.integer.value[1] = - aqt_get_iir_band_coeff(codec, band_idx, 1); + aqt_get_iir_band_coeff(component, band_idx, 1); ucontrol->value.integer.value[2] = - aqt_get_iir_band_coeff(codec, band_idx, 2); + aqt_get_iir_band_coeff(component, band_idx, 2); ucontrol->value.integer.value[3] = - aqt_get_iir_band_coeff(codec, band_idx, 3); + aqt_get_iir_band_coeff(component, band_idx, 3); ucontrol->value.integer.value[4] = - aqt_get_iir_band_coeff(codec, band_idx, 4); + aqt_get_iir_band_coeff(component, band_idx, 4); - dev_dbg(codec->dev, "%s: IIR band #%d b0 = 0x%x\n" + dev_dbg(component->dev, "%s: IIR band #%d b0 = 0x%x\n" "%s: IIR band #%d b1 = 0x%x\n" "%s: IIR band #%d b2 = 0x%x\n" "%s: IIR band #%d a1 = 0x%x\n" @@ -314,23 +329,23 @@ static int aqt_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, return 0; } -static void aqt_set_iir_band_coeff(struct snd_soc_codec *codec, +static void aqt_set_iir_band_coeff(struct snd_soc_component *component, int band_idx, uint32_t value) { - snd_soc_write(codec, + snd_soc_component_write(component, (AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL), (value & 0xFF)); - snd_soc_write(codec, + snd_soc_component_write(component, (AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL), (value >> 8) & 0xFF); - snd_soc_write(codec, + snd_soc_component_write(component, (AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ - snd_soc_write(codec, + snd_soc_component_write(component, (AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL), (value >> 24) & 0x3F); } @@ -338,7 +353,8 @@ static void aqt_set_iir_band_coeff(struct snd_soc_codec *codec, static int aqt_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int coeff_idx; @@ -347,31 +363,31 @@ static int aqt_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, * Mask top bit it is reserved * Updates addr automatically for each B2 write */ - snd_soc_write(codec, + snd_soc_component_write(component, (AQT1000_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); for (coeff_idx = 0; coeff_idx < AQT1000_CDC_SIDETONE_IIR_COEFF_MAX; coeff_idx++) { - aqt_set_iir_band_coeff(codec, band_idx, + aqt_set_iir_band_coeff(component, band_idx, ucontrol->value.integer.value[coeff_idx]); } - dev_dbg(codec->dev, "%s: IIR band #%d b0 = 0x%x\n" + dev_dbg(component->dev, "%s: IIR band #%d b0 = 0x%x\n" "%s: IIR band #%d b1 = 0x%x\n" "%s: IIR band #%d b2 = 0x%x\n" "%s: IIR band #%d a1 = 0x%x\n" "%s: IIR band #%d a2 = 0x%x\n", __func__, band_idx, - aqt_get_iir_band_coeff(codec, band_idx, 0), + aqt_get_iir_band_coeff(component, band_idx, 0), __func__, band_idx, - aqt_get_iir_band_coeff(codec, band_idx, 1), + aqt_get_iir_band_coeff(component, band_idx, 1), __func__, band_idx, - aqt_get_iir_band_coeff(codec, band_idx, 2), + aqt_get_iir_band_coeff(component, band_idx, 2), __func__, band_idx, - aqt_get_iir_band_coeff(codec, band_idx, 3), + aqt_get_iir_band_coeff(component, band_idx, 3), __func__, band_idx, - aqt_get_iir_band_coeff(codec, band_idx, 4)); + aqt_get_iir_band_coeff(component, band_idx, 4)); return 0; } @@ -380,10 +396,11 @@ static int aqt_compander_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = aqt->comp_enabled[comp]; return 0; @@ -392,13 +409,14 @@ static int aqt_compander_get(struct snd_kcontrol *kcontrol, static int aqt_compander_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Compander %d enable current %d, new %d\n", __func__, comp + 1, aqt->comp_enabled[comp], value); aqt->comp_enabled[comp] = value; @@ -406,12 +424,14 @@ static int aqt_compander_put(struct snd_kcontrol *kcontrol, switch (comp) { case COMPANDER_1: /* Set Gain Source Select based on compander enable/disable */ - snd_soc_update_bits(codec, AQT1000_HPH_L_EN, 0x20, - (value ? 0x00:0x20)); + snd_soc_component_update_bits(component, + AQT1000_HPH_L_EN, 0x20, + (value ? 0x00 : 0x20)); break; case COMPANDER_2: - snd_soc_update_bits(codec, AQT1000_HPH_R_EN, 0x20, - (value ? 0x00:0x20)); + snd_soc_component_update_bits(component, + AQT1000_HPH_R_EN, 0x20, + (value ? 0x00 : 0x20)); break; default: /* @@ -419,7 +439,7 @@ static int aqt_compander_put(struct snd_kcontrol *kcontrol, * it does not cause any audio failure, so do not * return error in this case, but just print a log */ - dev_warn(codec->dev, "%s: unknown compander: %d\n", + dev_warn(component->dev, "%s: unknown compander: %d\n", __func__, comp); }; return 0; @@ -428,8 +448,9 @@ static int aqt_compander_put(struct snd_kcontrol *kcontrol, static int aqt_hph_asrc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int index = -EINVAL; if (!strcmp(kcontrol->id.name, "AQT ASRC0 Output Mode")) @@ -447,8 +468,9 @@ static int aqt_hph_asrc_mode_put(struct snd_kcontrol *kcontrol, static int aqt_hph_asrc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int val = 0; int index = -EINVAL; @@ -473,8 +495,9 @@ static SOC_ENUM_SINGLE_EXT_DECL(asrc_mode_enum, asrc_mode_text); static int aqt_hph_idle_detect_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int val = 0; if (aqt) @@ -488,8 +511,9 @@ static int aqt_hph_idle_detect_get(struct snd_kcontrol *kcontrol, static int aqt_hph_idle_detect_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); if (aqt) aqt->idle_det_cfg.hph_idle_detect_en = @@ -507,7 +531,8 @@ static SOC_ENUM_SINGLE_EXT_DECL(hph_idle_detect_enum, hph_idle_detect_text); static int aqt_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u16 amic_reg = 0; if (!strcmp(kcontrol->id.name, "AQT AMIC_1_2 PWR MODE")) @@ -517,7 +542,7 @@ static int aqt_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, if (amic_reg) ucontrol->value.integer.value[0] = - (snd_soc_read(codec, amic_reg) & + (snd_soc_component_read32(component, amic_reg) & AQT1000_AMIC_PWR_LVL_MASK) >> AQT1000_AMIC_PWR_LVL_SHIFT; return 0; @@ -526,13 +551,14 @@ static int aqt_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, static int aqt_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u32 mode_val; u16 amic_reg = 0; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val); + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (!strcmp(kcontrol->id.name, "AQT AMIC_1_2 PWR MODE")) amic_reg = AQT1000_ANA_AMIC1; @@ -540,8 +566,9 @@ static int aqt_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, amic_reg = AQT1000_ANA_AMIC3; if (amic_reg) - snd_soc_update_bits(codec, amic_reg, AQT1000_AMIC_PWR_LVL_MASK, - mode_val << AQT1000_AMIC_PWR_LVL_SHIFT); + snd_soc_component_update_bits(component, amic_reg, + AQT1000_AMIC_PWR_LVL_MASK, + mode_val << AQT1000_AMIC_PWR_LVL_SHIFT); return 0; } @@ -651,41 +678,44 @@ static const struct snd_kcontrol_new aqt_snd_controls[] = { static int aqt_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: aqt->rx_bias_count++; if (aqt->rx_bias_count == 1) { - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x01, 0x01); + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x01, 0x01); } break; case SND_SOC_DAPM_POST_PMD: aqt->rx_bias_count--; if (!aqt->rx_bias_count) - snd_soc_update_bits(codec, AQT1000_ANA_RX_SUPPLIES, - 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_RX_SUPPLIES, + 0x01, 0x00); break; }; - dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__, - aqt->rx_bias_count); + dev_dbg(component->dev, "%s: Current RX BIAS user count: %d\n", + __func__, aqt->rx_bias_count); return 0; } /* * aqt_mbhc_micb_adjust_voltage: adjust specific micbias voltage - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @req_volt: micbias voltage to be set * @micb_num: micbias to be set, e.g. micbias1 or micbias2 * * return 0 if adjustment is success or error code in case of failure */ -int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +int aqt_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num) { struct aqt1000 *aqt; @@ -693,8 +723,8 @@ int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, int micb_reg, micb_val, micb_en; int ret = 0; - if (!codec) { - pr_err("%s: Invalid codec pointer\n", __func__); + if (!component) { + pr_err("%s: Invalid component pointer\n", __func__); return -EINVAL; } @@ -703,7 +733,7 @@ int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, else micb_reg = AQT1000_ANA_MICB1; - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); mutex_lock(&aqt->micb_lock); /* @@ -714,7 +744,7 @@ int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, * momentarily, change the micbias value and then re-enable * micbias. */ - micb_val = snd_soc_read(codec, micb_reg); + micb_val = snd_soc_component_read32(component, micb_reg); micb_en = (micb_val & 0xC0) >> 6; cur_vout_ctl = micb_val & 0x3F; @@ -728,17 +758,17 @@ int aqt_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, goto exit; } - dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", + dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", __func__, micb_num, AQT_VOUT_CTL_TO_MICB(cur_vout_ctl), req_volt, micb_en); if (micb_en == 0x1) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x80); - snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl); + snd_soc_component_update_bits(component, micb_reg, 0x3F, req_vout_ctl); if (micb_en == 0x1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x40); /* * Add 2ms delay as per HW requirement after enabling * micbias @@ -754,17 +784,17 @@ EXPORT_SYMBOL(aqt_mbhc_micb_adjust_voltage); /* * aqt_micbias_control: enable/disable micbias - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @micb_num: micbias to be enabled/disabled, e.g. micbias1 or micbias2 * @req: control requested, enable/disable or pullup enable/disable * @is_dapm: triggered by dapm or not * * return 0 if control is success or error code in case of failure */ -int aqt_micbias_control(struct snd_soc_codec *codec, +int aqt_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); u16 micb_reg; int pre_off_event = 0, post_off_event = 0; int post_on_event = 0, post_dapm_off = 0; @@ -781,7 +811,7 @@ int aqt_micbias_control(struct snd_soc_codec *codec, post_dapm_off = AQT_EVENT_POST_DAPM_MICBIAS_1_OFF; break; default: - dev_err(codec->dev, "%s: Invalid micbias number: %d\n", + dev_err(component->dev, "%s: Invalid micbias number: %d\n", __func__, micb_num); return -EINVAL; } @@ -792,19 +822,22 @@ int aqt_micbias_control(struct snd_soc_codec *codec, aqt->pullup_ref++; if ((aqt->pullup_ref == 1) && (aqt->micb_ref == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); break; case MICB_PULLUP_DISABLE: if (aqt->pullup_ref > 0) aqt->pullup_ref--; if ((aqt->pullup_ref == 0) && (aqt->micb_ref == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); break; case MICB_ENABLE: aqt->micb_ref++; if (aqt->micb_ref == 1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x40); if (post_on_event && aqt->mbhc) blocking_notifier_call_chain( &aqt->mbhc->notifier, @@ -820,7 +853,8 @@ int aqt_micbias_control(struct snd_soc_codec *codec, aqt->micb_ref--; if ((aqt->micb_ref == 0) && (aqt->pullup_ref > 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); else if ((aqt->micb_ref == 0) && (aqt->pullup_ref == 0)) { if (pre_off_event && aqt->mbhc) @@ -828,7 +862,8 @@ int aqt_micbias_control(struct snd_soc_codec *codec, &aqt->mbhc->notifier, pre_off_event, &aqt->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); if (post_off_event && aqt->mbhc) blocking_notifier_call_chain( &aqt->mbhc->notifier, @@ -840,14 +875,14 @@ int aqt_micbias_control(struct snd_soc_codec *codec, post_dapm_off, &aqt->mbhc->wcd_mbhc); break; default: - dev_err(codec->dev, "%s: Invalid micbias request: %d\n", + dev_err(component->dev, "%s: Invalid micbias request: %d\n", __func__, req); ret = -EINVAL; break; }; if (!ret) - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", __func__, micb_num, aqt->micb_ref, aqt->pullup_ref); @@ -860,10 +895,11 @@ EXPORT_SYMBOL(aqt_micbias_control); static int __aqt_codec_enable_micbias(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int micb_num; - dev_dbg(codec->dev, "%s: wname: %s, event: %d\n", + dev_dbg(component->dev, "%s: wname: %s, event: %d\n", __func__, w->name, event); if (strnstr(w->name, "AQT MIC BIAS1", sizeof("AQT MIC BIAS1"))) @@ -878,14 +914,14 @@ static int __aqt_codec_enable_micbias(struct snd_soc_dapm_widget *w, * so use ref count to handle micbias pullup * and enable requests */ - aqt_micbias_control(codec, micb_num, MICB_ENABLE, true); + aqt_micbias_control(component, micb_num, MICB_ENABLE, true); break; case SND_SOC_DAPM_POST_PMU: /* wait for cnp time */ usleep_range(1000, 1100); break; case SND_SOC_DAPM_POST_PMD: - aqt_micbias_control(codec, micb_num, MICB_DISABLE, true); + aqt_micbias_control(component, micb_num, MICB_DISABLE, true); break; }; @@ -898,28 +934,30 @@ static int aqt_codec_enable_micbias(struct snd_soc_dapm_widget *w, return __aqt_codec_enable_micbias(w, event); } -static int aqt_codec_enable_i2s_block(struct snd_soc_codec *codec) +static int aqt_codec_enable_i2s_block(struct snd_soc_component *component) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); mutex_lock(&aqt->i2s_lock); if (++aqt->i2s_users == 1) - snd_soc_update_bits(codec, AQT1000_I2S_I2S_0_CTL, 0x01, 0x01); + snd_soc_component_update_bits(component, AQT1000_I2S_I2S_0_CTL, + 0x01, 0x01); mutex_unlock(&aqt->i2s_lock); return 0; } -static int aqt_codec_disable_i2s_block(struct snd_soc_codec *codec) +static int aqt_codec_disable_i2s_block(struct snd_soc_component *component) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); mutex_lock(&aqt->i2s_lock); if (--aqt->i2s_users == 0) - snd_soc_update_bits(codec, AQT1000_I2S_I2S_0_CTL, 0x01, 0x00); + snd_soc_component_update_bits(component, AQT1000_I2S_I2S_0_CTL, + 0x01, 0x00); if (aqt->i2s_users < 0) - dev_warn(codec->dev, "%s: i2s_users count (%d) < 0\n", + dev_warn(component->dev, "%s: i2s_users count (%d) < 0\n", __func__, aqt->i2s_users); mutex_unlock(&aqt->i2s_lock); @@ -930,17 +968,18 @@ static int aqt_codec_enable_i2s_tx(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - aqt_codec_enable_i2s_block(codec); + aqt_codec_enable_i2s_block(component); break; case SND_SOC_DAPM_POST_PMD: - aqt_codec_disable_i2s_block(codec); + aqt_codec_disable_i2s_block(component); break; } - dev_dbg(codec->dev, "%s: event: %d\n", __func__, event); + dev_dbg(component->dev, "%s: event: %d\n", __func__, event); return 0; } @@ -949,17 +988,18 @@ static int aqt_codec_enable_i2s_rx(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - aqt_codec_enable_i2s_block(codec); + aqt_codec_enable_i2s_block(component); break; case SND_SOC_DAPM_POST_PMD: - aqt_codec_disable_i2s_block(codec); + aqt_codec_disable_i2s_block(component); break; } - dev_dbg(codec->dev, "%s: event: %d\n", __func__, event); + dev_dbg(component->dev, "%s: event: %d\n", __func__, event); return 0; } @@ -980,7 +1020,8 @@ AQT_DAPM_ENUM(tx_adc1, AQT1000_CDC_TX_INP_MUX_ADC_MUX1_CFG1, 0, AQT_DAPM_ENUM(tx_adc2, AQT1000_CDC_TX_INP_MUX_ADC_MUX2_CFG1, 0, tx_adc_mux_text); -static int aqt_find_amic_input(struct snd_soc_codec *codec, int adc_mux_n) +static int aqt_find_amic_input(struct snd_soc_component *component, + int adc_mux_n) { u8 mask; u16 adc_mux_in_reg = 0, amic_mux_sel_reg = 0; @@ -996,14 +1037,17 @@ static int aqt_find_amic_input(struct snd_soc_codec *codec, int adc_mux_n) amic_mux_sel_reg = AQT1000_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + 2 * adc_mux_n; } - is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask)) == 0); + is_amic = ( + ((snd_soc_component_read32(component, adc_mux_in_reg) + & mask)) == 0); if (!is_amic) return 0; - return snd_soc_read(codec, amic_mux_sel_reg) & 0x07; + return snd_soc_component_read32(component, amic_mux_sel_reg) & 0x07; } -static u16 aqt_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) +static u16 aqt_codec_get_amic_pwlvl_reg( + struct snd_soc_component *component, int amic) { u16 pwr_level_reg = 0; @@ -1016,7 +1060,7 @@ static u16 aqt_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) pwr_level_reg = AQT1000_ANA_AMIC3; break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic); break; } @@ -1029,7 +1073,7 @@ static void aqt_tx_hpf_corner_freq_callback(struct work_struct *work) struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct aqt1000 *aqt; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 dec_cfg_reg, amic_reg, go_bit_reg; u8 hpf_cut_off_freq; int amic_n; @@ -1037,26 +1081,27 @@ static void aqt_tx_hpf_corner_freq_callback(struct work_struct *work) hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); aqt = hpf_work->aqt; - codec = aqt->codec; + component = aqt->component; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = AQT1000_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator; go_bit_reg = dec_cfg_reg + 7; - dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", + dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); - amic_n = aqt_find_amic_input(codec, hpf_work->decimator); + amic_n = aqt_find_amic_input(component, hpf_work->decimator); if (amic_n) { amic_reg = AQT1000_ANA_AMIC1 + amic_n - 1; - aqt_codec_set_tx_hold(codec, amic_reg, false); + aqt_codec_set_tx_hold(component, amic_reg, false); } - snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, go_bit_reg, 0x02, 0x02); /* Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, go_bit_reg, 0x02, 0x00); } static void aqt_tx_mute_update_callback(struct work_struct *work) @@ -1064,26 +1109,27 @@ static void aqt_tx_mute_update_callback(struct work_struct *work) struct tx_mute_work *tx_mute_dwork; struct aqt1000 *aqt; struct delayed_work *delayed_work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 tx_vol_ctl_reg, hpf_gate_reg; delayed_work = to_delayed_work(work); tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork); aqt = tx_mute_dwork->aqt; - codec = aqt->codec; + component = aqt->component; tx_vol_ctl_reg = AQT1000_CDC_TX0_TX_PATH_CTL + 16 * tx_mute_dwork->decimator; hpf_gate_reg = AQT1000_CDC_TX0_TX_PATH_SEC2 + 16 * tx_mute_dwork->decimator; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00); } static int aqt_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); char *widget_name = NULL; char *dec = NULL; unsigned int decimator = 0; @@ -1093,14 +1139,14 @@ static int aqt_codec_enable_dec(struct snd_soc_dapm_widget *w, int ret = 0; u8 hpf_cut_off_freq; - dev_dbg(codec->dev, "%s: event: %d\n", __func__, event); + dev_dbg(component->dev, "%s: event: %d\n", __func__, event); widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) return -ENOMEM; dec = strpbrk(widget_name, "012"); if (!dec) { - dev_err(codec->dev, "%s: decimator index not found\n", + dev_err(component->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; @@ -1108,12 +1154,12 @@ static int aqt_codec_enable_dec(struct snd_soc_dapm_widget *w, ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid decimator = %s\n", + dev_err(component->dev, "%s: Invalid decimator = %s\n", __func__, widget_name); ret = -EINVAL; goto out; } - dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__, + dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__, w->name, decimator); tx_vol_ctl_reg = AQT1000_CDC_TX0_TX_PATH_CTL + 16 * decimator; @@ -1121,56 +1167,64 @@ static int aqt_codec_enable_dec(struct snd_soc_dapm_widget *w, dec_cfg_reg = AQT1000_CDC_TX0_TX_PATH_CFG0 + 16 * decimator; tx_gain_ctl_reg = AQT1000_CDC_TX0_TX_VOL_CTL + 16 * decimator; - amic_n = aqt_find_amic_input(codec, decimator); + amic_n = aqt_find_amic_input(component, decimator); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (amic_n) - pwr_level_reg = aqt_codec_get_amic_pwlvl_reg(codec, + pwr_level_reg = aqt_codec_get_amic_pwlvl_reg(component, amic_n); if (pwr_level_reg) { - switch ((snd_soc_read(codec, pwr_level_reg) & - AQT1000_AMIC_PWR_LVL_MASK) >> - AQT1000_AMIC_PWR_LVL_SHIFT) { + switch ((snd_soc_component_read32( + component, pwr_level_reg) & + AQT1000_AMIC_PWR_LVL_MASK) >> + AQT1000_AMIC_PWR_LVL_SHIFT) { case AQT1000_AMIC_PWR_LEVEL_LP: - snd_soc_update_bits(codec, dec_cfg_reg, - AQT1000_DEC_PWR_LVL_MASK, - AQT1000_DEC_PWR_LVL_LP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + AQT1000_DEC_PWR_LVL_MASK, + AQT1000_DEC_PWR_LVL_LP); break; case AQT1000_AMIC_PWR_LEVEL_HP: - snd_soc_update_bits(codec, dec_cfg_reg, - AQT1000_DEC_PWR_LVL_MASK, - AQT1000_DEC_PWR_LVL_HP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + AQT1000_DEC_PWR_LVL_MASK, + AQT1000_DEC_PWR_LVL_HP); break; case AQT1000_AMIC_PWR_LEVEL_DEFAULT: default: - snd_soc_update_bits(codec, dec_cfg_reg, - AQT1000_DEC_PWR_LVL_MASK, - AQT1000_DEC_PWR_LVL_DF); + snd_soc_component_update_bits( + component, dec_cfg_reg, + AQT1000_DEC_PWR_LVL_MASK, + AQT1000_DEC_PWR_LVL_DF); break; } } /* Enable TX PGA Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: - hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & - TX_HPF_CUT_OFF_FREQ_MASK) >> 5; + hpf_cut_off_freq = (snd_soc_component_read32( + component, dec_cfg_reg) & + TX_HPF_CUT_OFF_FREQ_MASK) >> 5; aqt->tx_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, hpf_gate_reg, + 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per * HW spec. */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, hpf_gate_reg, + 0x02, 0x00); } /* schedule work queue to Remove Mute */ schedule_delayed_work(&aqt->tx_mute_dwork[decimator].dwork, @@ -1181,36 +1235,42 @@ static int aqt_codec_enable_dec(struct snd_soc_dapm_widget *w, &aqt->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); /* apply gain after decimator is enabled */ - snd_soc_write(codec, tx_gain_ctl_reg, - snd_soc_read(codec, tx_gain_ctl_reg)); + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read32( + component, tx_gain_ctl_reg)); break; case SND_SOC_DAPM_PRE_PMD: hpf_cut_off_freq = aqt->tx_hpf_work[decimator].hpf_cut_off_freq; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); if (cancel_delayed_work_sync( &aqt->tx_hpf_work[decimator].dwork)) { if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x02); + snd_soc_component_update_bits( + component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits( + component, hpf_gate_reg, + 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per * HW spec. */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x00); + snd_soc_component_update_bits( + component, hpf_gate_reg, + 0x02, 0x00); } } cancel_delayed_work_sync( &aqt->tx_mute_dwork[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x00); + snd_soc_component_update_bits(component, dec_cfg_reg, AQT1000_DEC_PWR_LVL_MASK, AQT1000_DEC_PWR_LVL_DF); break; @@ -1240,11 +1300,12 @@ AQT_DAPM_ENUM(tx_amic13, AQT1000_CDC_TX_INP_MUX_ADC_MUX13_CFG0, 0, static int aqt_codec_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - aqt_codec_set_tx_hold(codec, w->reg, true); + aqt_codec_set_tx_hold(component, w->reg, true); break; default: break; @@ -1259,15 +1320,15 @@ static const struct snd_kcontrol_new anc_hphl_pa_switch = static const struct snd_kcontrol_new anc_hphr_pa_switch = SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0); -static int aqt_config_compander(struct snd_soc_codec *codec, int interp_n, - int event) +static int aqt_config_compander(struct snd_soc_component *component, + int interp_n, int event) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int comp; u16 comp_ctl0_reg, rx_path_cfg0_reg; comp = interp_n; - dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n", __func__, event, comp, aqt->comp_enabled[comp]); if (!aqt->comp_enabled[comp]) @@ -1278,29 +1339,39 @@ static int aqt_config_compander(struct snd_soc_codec *codec, int interp_n, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Compander Clock */ - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x01, 0x01); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x02, 0x02); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x02, 0x00); + snd_soc_component_update_bits( + component, rx_path_cfg0_reg, 0x02, 0x02); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00); + snd_soc_component_update_bits( + component, rx_path_cfg0_reg, 0x02, 0x00); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x04, 0x04); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x02, 0x02); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x02, 0x00); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x01, 0x00); + snd_soc_component_update_bits( + component, comp_ctl0_reg, 0x04, 0x00); } return 0; } -static void aqt_codec_idle_detect_control(struct snd_soc_codec *codec, +static void aqt_codec_idle_detect_control(struct snd_soc_component *component, int interp, int event) { int reg = 0, mask, val; - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); if (!aqt->idle_det_cfg.hph_idle_detect_en) return; @@ -1317,19 +1388,20 @@ static void aqt_codec_idle_detect_control(struct snd_soc_codec *codec, } if (reg && SND_SOC_DAPM_EVENT_ON(event)) - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); if (reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, reg, mask, 0x00); + snd_soc_component_update_bits(component, reg, mask, 0x00); aqt->idle_det_cfg.hph_idle_thr = 0; - snd_soc_write(codec, AQT1000_CDC_RX_IDLE_DET_CFG3, 0x0); + snd_soc_component_write(component, + AQT1000_CDC_RX_IDLE_DET_CFG3, 0x0); } } -static void aqt_codec_hphdelay_lutbypass(struct snd_soc_codec *codec, +static void aqt_codec_hphdelay_lutbypass(struct snd_soc_component *component, u16 interp_idx, int event) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); u8 hph_dly_mask; u16 hph_lut_bypass_reg = 0; u16 hph_comp_ctrl7 = 0; @@ -1351,48 +1423,55 @@ static void aqt_codec_hphdelay_lutbypass(struct snd_soc_codec *codec, } if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_TEST0, - hph_dly_mask, 0x0); - snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x80); + snd_soc_component_update_bits(component, AQT1000_CDC_CLSH_TEST0, + hph_dly_mask, 0x0); + snd_soc_component_update_bits(component, hph_lut_bypass_reg, + 0x80, 0x80); if (aqt->hph_mode == CLS_H_ULP) - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x20); + snd_soc_component_update_bits(component, hph_comp_ctrl7, + 0x20, 0x20); } if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, AQT1000_CDC_CLSH_TEST0, - hph_dly_mask, hph_dly_mask); - snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x00); - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x0); + snd_soc_component_update_bits(component, AQT1000_CDC_CLSH_TEST0, + hph_dly_mask, hph_dly_mask); + snd_soc_component_update_bits(component, hph_lut_bypass_reg, + 0x80, 0x00); + snd_soc_component_update_bits(component, hph_comp_ctrl7, + 0x20, 0x0); } } -static int aqt_codec_enable_interp_clk(struct snd_soc_codec *codec, +static int aqt_codec_enable_interp_clk(struct snd_soc_component *component, int event, int interp_idx) { struct aqt1000 *aqt; u16 main_reg, dsm_reg; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return -EINVAL; } - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); main_reg = AQT1000_CDC_RX1_RX_PATH_CTL + (interp_idx * 20); dsm_reg = AQT1000_CDC_RX1_RX_PATH_DSMDEM_CTL + (interp_idx * 20); if (SND_SOC_DAPM_EVENT_ON(event)) { if (aqt->main_clk_users[interp_idx] == 0) { /* Main path PGA mute enable */ - snd_soc_update_bits(codec, main_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, main_reg, + 0x10, 0x10); /* Clk enable */ - snd_soc_update_bits(codec, dsm_reg, 0x01, 0x01); - snd_soc_update_bits(codec, main_reg, 0x20, 0x20); - aqt_codec_idle_detect_control(codec, interp_idx, + snd_soc_component_update_bits(component, dsm_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x20); + aqt_codec_idle_detect_control(component, interp_idx, event); - aqt_codec_hphdelay_lutbypass(codec, interp_idx, + aqt_codec_hphdelay_lutbypass(component, interp_idx, event); - aqt_config_compander(codec, interp_idx, event); + aqt_config_compander(component, interp_idx, event); } aqt->main_clk_users[interp_idx]++; } @@ -1401,23 +1480,28 @@ static int aqt_codec_enable_interp_clk(struct snd_soc_codec *codec, aqt->main_clk_users[interp_idx]--; if (aqt->main_clk_users[interp_idx] <= 0) { aqt->main_clk_users[interp_idx] = 0; - aqt_config_compander(codec, interp_idx, event); - aqt_codec_hphdelay_lutbypass(codec, interp_idx, + aqt_config_compander(component, interp_idx, event); + aqt_codec_hphdelay_lutbypass(component, interp_idx, event); - aqt_codec_idle_detect_control(codec, interp_idx, + aqt_codec_idle_detect_control(component, interp_idx, event); /* Clk Disable */ - snd_soc_update_bits(codec, main_reg, 0x20, 0x00); - snd_soc_update_bits(codec, dsm_reg, 0x01, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x00); + snd_soc_component_update_bits(component, dsm_reg, + 0x01, 0x00); /* Reset enable and disable */ - snd_soc_update_bits(codec, main_reg, 0x40, 0x40); - snd_soc_update_bits(codec, main_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x40); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x00); /* Reset rate to 48K*/ - snd_soc_update_bits(codec, main_reg, 0x0F, 0x04); + snd_soc_component_update_bits(component, main_reg, + 0x0F, 0x04); } } - dev_dbg(codec->dev, "%s event %d main_clk_users %d\n", + dev_dbg(component->dev, "%s event %d main_clk_users %d\n", __func__, event, aqt->main_clk_users[interp_idx]); return aqt->main_clk_users[interp_idx]; @@ -1426,9 +1510,10 @@ static int aqt_codec_enable_interp_clk(struct snd_soc_codec *codec, static int aqt_anc_out_switch_cb(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - aqt_codec_enable_interp_clk(codec, event, w->shift); + aqt_codec_enable_interp_clk(component, event, w->shift); return 0; } @@ -1473,14 +1558,14 @@ AQT_DAPM_ENUM(rx_int2_1, AQT1000_CDC_RX_INP_MUX_RX_INT2_CFG0, 0, AQT_DAPM_ENUM(rx_int2_2, AQT1000_CDC_RX_INP_MUX_RX_INT2_CFG1, 0, rx_int2_2_mux_text); -static int aqt_codec_set_idle_detect_thr(struct snd_soc_codec *codec, +static int aqt_codec_set_idle_detect_thr(struct snd_soc_component *component, int interp, int path_type) { int port_id[4] = { 0, 0, 0, 0 }; int *port_ptr, num_ports; int bit_width = 0; int mux_reg = 0, mux_reg_val = 0; - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int idle_thr; if ((interp != INTERP_HPHL) && (interp != INTERP_HPHR)) @@ -1505,12 +1590,13 @@ static int aqt_codec_set_idle_detect_thr(struct snd_soc_codec *codec, else mux_reg = AQT1000_CDC_RX_INP_MUX_RX_INT2_CFG0; } - mux_reg_val = snd_soc_read(codec, mux_reg); + mux_reg_val = snd_soc_component_read32(component, mux_reg); /* Read bit width from I2S reg if mux is set to I2S0_L or I2S0_R */ if (mux_reg_val == 0x02 || mux_reg_val == 0x03) - bit_width = ((snd_soc_read(codec, AQT1000_I2S_I2S_0_CTL) & - 0x40) >> 6); + bit_width = ((snd_soc_component_read32( + component, AQT1000_I2S_I2S_0_CTL) & + 0x40) >> 6); switch (bit_width) { case 1: /* 16 bit */ @@ -1522,12 +1608,13 @@ static int aqt_codec_set_idle_detect_thr(struct snd_soc_codec *codec, break; } - dev_dbg(codec->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", + dev_dbg(component->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", __func__, idle_thr, aqt->idle_det_cfg.hph_idle_thr); if ((aqt->idle_det_cfg.hph_idle_thr == 0) || (idle_thr < aqt->idle_det_cfg.hph_idle_thr)) { - snd_soc_write(codec, AQT1000_CDC_RX_IDLE_DET_CFG3, idle_thr); + snd_soc_component_write(component, AQT1000_CDC_RX_IDLE_DET_CFG3, + idle_thr); aqt->idle_det_cfg.hph_idle_thr = idle_thr; } @@ -1538,14 +1625,15 @@ static int aqt_codec_enable_main_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg = 0; int val = 0; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); if (w->shift >= AQT1000_NUM_INTERPOLATORS) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; }; @@ -1555,17 +1643,17 @@ static int aqt_codec_enable_main_path(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - aqt_codec_enable_interp_clk(codec, event, w->shift); + aqt_codec_enable_interp_clk(component, event, w->shift); break; case SND_SOC_DAPM_POST_PMU: - aqt_codec_set_idle_detect_thr(codec, w->shift, + aqt_codec_set_idle_detect_thr(component, w->shift, INTERP_MAIN_PATH); /* apply gain after int clk is enabled */ - val = snd_soc_read(codec, gain_reg); - snd_soc_write(codec, gain_reg, val); + val = snd_soc_component_read32(component, gain_reg); + snd_soc_component_write(component, gain_reg, val); break; case SND_SOC_DAPM_POST_PMD: - aqt_codec_enable_interp_clk(codec, event, w->shift); + aqt_codec_enable_interp_clk(component, event, w->shift); break; }; @@ -1576,12 +1664,13 @@ static int aqt_codec_enable_mix_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg = 0; u16 mix_reg = 0; if (w->shift >= AQT1000_NUM_INTERPOLATORS) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; }; @@ -1592,25 +1681,26 @@ static int aqt_codec_enable_mix_path(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - aqt_codec_enable_interp_clk(codec, event, w->shift); + aqt_codec_enable_interp_clk(component, event, w->shift); /* Clk enable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x20); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x20); break; case SND_SOC_DAPM_POST_PMU: - aqt_codec_set_idle_detect_thr(codec, w->shift, + aqt_codec_set_idle_detect_thr(component, w->shift, INTERP_MIX_PATH); break; case SND_SOC_DAPM_POST_PMD: /* Clk Disable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x00); - aqt_codec_enable_interp_clk(codec, event, w->shift); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x00); + aqt_codec_enable_interp_clk(component, event, w->shift); /* Reset enable and disable */ - snd_soc_update_bits(codec, mix_reg, 0x40, 0x40); - snd_soc_update_bits(codec, mix_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x40); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x00); break; }; - dev_dbg(codec->dev, "%s event %d name %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s event %d name %s\n", __func__, + event, w->name); return 0; } @@ -1693,8 +1783,9 @@ static int aqt_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int asrc = 0, ret = 0; u8 cfg; u16 cfg_reg = 0; @@ -1705,9 +1796,10 @@ static int aqt_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, u16 paired_reg = 0; u8 main_sr, mix_sr, asrc_mode = 0; - cfg = snd_soc_read(codec, AQT1000_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0); + cfg = snd_soc_component_read32(component, + AQT1000_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0); if (!(cfg & 0xFF)) { - dev_err(codec->dev, "%s: ASRC%u input not selected\n", + dev_err(component->dev, "%s: ASRC%u input not selected\n", __func__, w->shift); return -EINVAL; } @@ -1732,7 +1824,7 @@ static int aqt_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, } break; default: - dev_err(codec->dev, "%s: Invalid asrc:%u\n", __func__, + dev_err(component->dev, "%s: Invalid asrc:%u\n", __func__, w->shift); ret = -EINVAL; break; @@ -1744,26 +1836,30 @@ static int aqt_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - if ((snd_soc_read(codec, clk_reg) & 0x02) || - (snd_soc_read(codec, paired_reg) & 0x02)) { - snd_soc_update_bits(codec, clk_reg, 0x02, 0x00); - snd_soc_update_bits(codec, paired_reg, 0x02, 0x00); + if ((snd_soc_component_read32(component, clk_reg) & 0x02) || + (snd_soc_component_read32(component, paired_reg) & 0x02)) { + snd_soc_component_update_bits(component, clk_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, paired_reg, + 0x02, 0x00); } - snd_soc_update_bits(codec, cfg_reg, 0x80, 0x80); - snd_soc_update_bits(codec, clk_reg, 0x01, 0x01); - main_sr = snd_soc_read(codec, ctl_reg) & 0x0F; + snd_soc_component_update_bits(component, cfg_reg, 0x80, 0x80); + snd_soc_component_update_bits(component, clk_reg, 0x01, 0x01); + main_sr = snd_soc_component_read32(component, ctl_reg) & 0x0F; mix_ctl_reg = ctl_reg + 5; - mix_sr = snd_soc_read(codec, mix_ctl_reg) & 0x0F; + mix_sr = snd_soc_component_read32( + component, mix_ctl_reg) & 0x0F; asrc_mode = aqt_get_asrc_mode(aqt, asrc, main_sr, mix_sr); - dev_dbg(codec->dev, "%s: main_sr:%d mix_sr:%d asrc_mode %d\n", + dev_dbg(component->dev, "%s: main_sr:%d mix_sr:%d asrc_mode %d\n", __func__, main_sr, mix_sr, asrc_mode); - snd_soc_update_bits(codec, asrc_ctl, 0x07, asrc_mode); + snd_soc_component_update_bits( + component, asrc_ctl, 0x07, asrc_mode); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, asrc_ctl, 0x07, 0x00); - snd_soc_update_bits(codec, cfg_reg, 0x80, 0x00); - snd_soc_update_bits(codec, clk_reg, 0x03, 0x02); + snd_soc_component_update_bits(component, asrc_ctl, 0x07, 0x00); + snd_soc_component_update_bits(component, cfg_reg, 0x80, 0x00); + snd_soc_component_update_bits(component, clk_reg, 0x03, 0x02); break; }; @@ -1774,8 +1870,9 @@ done: static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); const char *filename; const struct firmware *fw; int i; @@ -1801,28 +1898,28 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration, cal_size %zd", + dev_dbg(component->dev, "%s: using hwdep calibration, cal_size %zd", __func__, cal_size); } else { filename = "AQT1000/AQT1000_anc.bin"; - ret = request_firmware(&fw, filename, codec->dev); + ret = request_firmware(&fw, filename, component->dev); if (ret < 0) { - dev_err(codec->dev, "%s: Failed to acquire ANC data: %d\n", + dev_err(component->dev, "%s: Failed to acquire ANC data: %d\n", __func__, ret); return ret; } if (!fw) { - dev_err(codec->dev, "%s: Failed to get anc fw\n", + dev_err(component->dev, "%s: Failed to get anc fw\n", __func__); return -ENODEV; } data = fw->data; cal_size = fw->size; - dev_dbg(codec->dev, "%s: using request_firmware calibration\n", + dev_dbg(component->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(struct aqt1000_anc_header)) { - dev_err(codec->dev, "%s: Invalid cal_size %zd\n", + dev_err(component->dev, "%s: Invalid cal_size %zd\n", __func__, cal_size); ret = -EINVAL; goto err; @@ -1835,14 +1932,14 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, num_anc_slots = anc_head->num_anc_slots; if (aqt->anc_slot >= num_anc_slots) { - dev_err(codec->dev, "%s: Invalid ANC slot selected\n", + dev_err(component->dev, "%s: Invalid ANC slot selected\n", __func__); ret = -EINVAL; goto err; } for (i = 0; i < num_anc_slots; i++) { if (anc_size_remaining < AQT1000_PACKED_REG_SIZE) { - dev_err(codec->dev, "%s: Invalid register format\n", + dev_err(component->dev, "%s: Invalid register format\n", __func__); ret = -EINVAL; goto err; @@ -1853,7 +1950,7 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, if ((anc_writes_size * AQT1000_PACKED_REG_SIZE) > anc_size_remaining) { - dev_err(codec->dev, "%s: Invalid register format\n", + dev_err(component->dev, "%s: Invalid register format\n", __func__); ret = -EINVAL; goto err; @@ -1867,7 +1964,7 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, anc_ptr += anc_writes_size; } if (i == num_anc_slots) { - dev_err(codec->dev, "%s: Selected ANC slot not present\n", + dev_err(component->dev, "%s: Selected ANC slot not present\n", __func__); ret = -EINVAL; goto err; @@ -1877,36 +1974,36 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, anc_cal_size = anc_writes_size; /* Rate converter clk enable and set bypass mode */ if (!strcmp(w->name, "AQT RX INT1 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC0_RC_COMMON_CTL, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC0_FIFO_COMMON_CTL, 0x66, 0x66); anc_writes_size = anc_cal_size / 2; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39); } else if (!strcmp(w->name, "AQT RX INT2 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC1_RC_COMMON_CTL, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC1_FIFO_COMMON_CTL, 0x66, 0x66); i = anc_cal_size / 2; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39); } for (; i < anc_writes_size; i++) { AQT1000_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val); - snd_soc_write(codec, reg, (val & mask)); + snd_soc_component_write(component, reg, (val & mask)); } if (!strcmp(w->name, "AQT RX INT1 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08); else if (!strcmp(w->name, "AQT RX INT2 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08); if (!hwdep_cal) @@ -1915,53 +2012,58 @@ static int aqt_codec_enable_anc(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: /* Remove ANC Rx from reset */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, AQT1000_CDC_ANC0_RC_COMMON_CTL, - 0x05, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_RC_COMMON_CTL, + 0x05, 0x00); if (!strcmp(w->name, "AQT ANC HPHL PA")) { - snd_soc_update_bits(codec, AQT1000_CDC_ANC0_MODE_1_CTL, - 0x30, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_MODE_1_CTL, + 0x30, 0x00); /* 50 msec sleep is needed to avoid click and pop as * per HW requirement */ msleep(50); - snd_soc_update_bits(codec, AQT1000_CDC_ANC0_MODE_1_CTL, - 0x01, 0x00); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC0_CLK_RESET_CTL, - 0x38, 0x38); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC0_CLK_RESET_CTL, - 0x07, 0x00); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC0_CLK_RESET_CTL, - 0x38, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_MODE_1_CTL, + 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_CLK_RESET_CTL, + 0x38, 0x38); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_CLK_RESET_CTL, + 0x07, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC0_CLK_RESET_CTL, + 0x38, 0x00); } else if (!strcmp(w->name, "AQT ANC HPHR PA")) { - snd_soc_update_bits(codec, AQT1000_CDC_ANC1_MODE_1_CTL, - 0x30, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC1_MODE_1_CTL, + 0x30, 0x00); /* 50 msec sleep is needed to avoid click and pop as * per HW requirement */ msleep(50); - snd_soc_update_bits(codec, AQT1000_CDC_ANC1_MODE_1_CTL, - 0x01, 0x00); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC1_CLK_RESET_CTL, - 0x38, 0x38); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC1_CLK_RESET_CTL, - 0x07, 0x00); - snd_soc_update_bits(codec, - AQT1000_CDC_ANC1_CLK_RESET_CTL, - 0x38, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC1_MODE_1_CTL, + 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC1_CLK_RESET_CTL, + 0x38, 0x38); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC1_CLK_RESET_CTL, + 0x07, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_ANC1_CLK_RESET_CTL, + 0x38, 0x00); } break; } @@ -1973,25 +2075,25 @@ err: return ret; } -static void aqt_codec_override(struct snd_soc_codec *codec, int mode, +static void aqt_codec_override(struct snd_soc_component *component, int mode, int event) { if (mode == CLS_AB || mode == CLS_AB_HIFI) { switch (event) { case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_ANA_RX_SUPPLIES, 0x02, 0x02); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_ANA_RX_SUPPLIES, 0x02, 0x00); break; } } } -static void aqt_codec_set_tx_hold(struct snd_soc_codec *codec, +static void aqt_codec_set_tx_hold(struct snd_soc_component *component, u16 amic_reg, bool set) { u8 mask = 0x20; @@ -2006,13 +2108,15 @@ static void aqt_codec_set_tx_hold(struct snd_soc_codec *codec, switch (amic_reg) { case AQT1000_ANA_AMIC1: case AQT1000_ANA_AMIC2: - snd_soc_update_bits(codec, AQT1000_ANA_AMIC2, mask, val); + snd_soc_component_update_bits(component, AQT1000_ANA_AMIC2, + mask, val); break; case AQT1000_ANA_AMIC3: - snd_soc_update_bits(codec, AQT1000_ANA_AMIC3_HPF, mask, val); + snd_soc_component_update_bits(component, AQT1000_ANA_AMIC3_HPF, + mask, val); break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic_reg); break; } @@ -2021,11 +2125,11 @@ static void aqt_codec_set_tx_hold(struct snd_soc_codec *codec, static void aqt_codec_clear_anc_tx_hold(struct aqt1000 *aqt) { if (test_and_clear_bit(ANC_MIC_AMIC1, &aqt->status_mask)) - aqt_codec_set_tx_hold(aqt->codec, AQT1000_ANA_AMIC1, false); + aqt_codec_set_tx_hold(aqt->component, AQT1000_ANA_AMIC1, false); if (test_and_clear_bit(ANC_MIC_AMIC2, &aqt->status_mask)) - aqt_codec_set_tx_hold(aqt->codec, AQT1000_ANA_AMIC2, false); + aqt_codec_set_tx_hold(aqt->component, AQT1000_ANA_AMIC2, false); if (test_and_clear_bit(ANC_MIC_AMIC3, &aqt->status_mask)) - aqt_codec_set_tx_hold(aqt->codec, AQT1000_ANA_AMIC3, false); + aqt_codec_set_tx_hold(aqt->component, AQT1000_ANA_AMIC3, false); } static const char * const rx_int_dem_inp_mux_text[] = { @@ -2037,7 +2141,8 @@ static int aqt_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; unsigned short look_ahead_dly_reg = AQT1000_CDC_RX1_RX_PATH_CFG0; @@ -2046,7 +2151,7 @@ static int aqt_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, if (val >= e->items) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); if (e->reg == AQT1000_CDC_RX1_RX_PATH_SEC0) @@ -2055,7 +2160,7 @@ static int aqt_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, look_ahead_dly_reg = AQT1000_CDC_RX2_RX_PATH_CFG0; /* Set Look Ahead Delay */ - snd_soc_update_bits(codec, look_ahead_dly_reg, + snd_soc_component_update_bits(component, look_ahead_dly_reg, 0x08, (val ? 0x08 : 0x00)); /* Set DEM INP Select */ return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -2072,16 +2177,17 @@ static int aqt_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int hph_mode = aqt->hph_mode; u8 dem_inp; int ret = 0; uint32_t impedl = 0; uint32_t impedr = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2091,35 +2197,37 @@ static int aqt_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, msleep(40); } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, AQT1000_CDC_RX1_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32( + component, AQT1000_CDC_RX1_RX_PATH_SEC0) & + 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } /* Disable AutoChop timer during power up */ - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x00); - aqt_clsh_fsm(codec, &aqt->clsh_d, + aqt_clsh_fsm(component, &aqt->clsh_d, AQT_CLSH_EVENT_PRE_DAC, AQT_CLSH_STATE_HPHL, hph_mode); if (aqt->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10); ret = aqt_mbhc_get_impedance(aqt->mbhc, &impedl, &impedr); if (!ret) { - aqt_clsh_imped_config(codec, impedl, false); + aqt_clsh_imped_config(component, impedl, false); set_bit(CLSH_Z_CONFIG, &aqt->status_mask); } else { - dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n", + dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n", __func__, ret); ret = 0; } @@ -2127,12 +2235,12 @@ static int aqt_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: /* 1000us required as per HW requirement */ usleep_range(1000, 1100); - aqt_clsh_fsm(codec, &aqt->clsh_d, + aqt_clsh_fsm(component, &aqt->clsh_d, AQT_CLSH_EVENT_POST_PA, AQT_CLSH_STATE_HPHL, hph_mode); if (test_bit(CLSH_Z_CONFIG, &aqt->status_mask)) { - aqt_clsh_imped_config(codec, impedl, true); + aqt_clsh_imped_config(component, impedl, true); clear_bit(CLSH_Z_CONFIG, &aqt->status_mask); } break; @@ -2147,14 +2255,15 @@ static int aqt_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int hph_mode = aqt->hph_mode; u8 dem_inp; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2164,30 +2273,32 @@ static int aqt_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, msleep(40); } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, AQT1000_CDC_RX2_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32( + component, AQT1000_CDC_RX2_RX_PATH_SEC0) & + 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } /* Disable AutoChop timer during power up */ - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); - aqt_clsh_fsm(codec, &aqt->clsh_d, + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x00); + aqt_clsh_fsm(component, &aqt->clsh_d, AQT_CLSH_EVENT_PRE_DAC, AQT_CLSH_STATE_HPHR, hph_mode); if (aqt->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: /* 1000us required as per HW requirement */ usleep_range(1000, 1100); - aqt_clsh_fsm(codec, &aqt->clsh_d, + aqt_clsh_fsm(component, &aqt->clsh_d, AQT_CLSH_EVENT_POST_PA, AQT_CLSH_STATE_HPHR, hph_mode); @@ -2203,23 +2314,26 @@ static int aqt_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if ((!(strcmp(w->name, "AQT ANC HPHR PA"))) && (test_bit(HPH_PA_DELAY, &aqt->status_mask))) - snd_soc_update_bits(codec, AQT1000_ANA_HPH, 0xC0, 0xC0); + snd_soc_component_update_bits(component, + AQT1000_ANA_HPH, 0xC0, 0xC0); set_bit(HPH_PA_DELAY, &aqt->status_mask); break; case SND_SOC_DAPM_POST_PMU: if ((!(strcmp(w->name, "AQT ANC HPHR PA")))) { - if ((snd_soc_read(codec, AQT1000_ANA_HPH) & 0xC0) + if ((snd_soc_component_read32( + component, AQT1000_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC case) @@ -2242,64 +2356,76 @@ static int aqt_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, } if (aqt->anc_func) { /* Clear Tx FE HOLD if both PAs are enabled */ - if ((snd_soc_read(aqt->codec, AQT1000_ANA_HPH) & + if ((snd_soc_component_read32( + aqt->component, AQT1000_ANA_HPH) & 0xC0) == 0xC0) aqt_codec_clear_anc_tx_hold(aqt); } - snd_soc_update_bits(codec, AQT1000_HPH_R_TEST, 0x01, 0x01); + snd_soc_component_update_bits( + component, AQT1000_HPH_R_TEST, 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits( + component, AQT1000_CDC_RX2_RX_PATH_CTL, + 0x10, 0x00); /* Enable GM3 boost */ - snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL, - 0x80, 0x80); + snd_soc_component_update_bits( + component, AQT1000_HPH_CNP_WG_CTL, + 0x80, 0x80); /* Enable AutoChop timer at the end of power up */ - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, AQT1000_CDC_RX2_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, AQT1000_CDC_RX2_RX_PATH_MIX_CTL)) & + 0x10) + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); if (!(strcmp(w->name, "AQT ANC HPHR PA"))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s:Do everything needed for left channel\n", __func__); /* Do everything needed for left channel */ - snd_soc_update_bits(codec, AQT1000_HPH_L_TEST, - 0x01, 0x01); + snd_soc_component_update_bits( + component, AQT1000_HPH_L_TEST, + 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, AQT1000_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); /* Remove ANC Rx from reset */ ret = aqt_codec_enable_anc(w, kcontrol, event); } - aqt_codec_override(codec, aqt->hph_mode, event); + aqt_codec_override(component, aqt->hph_mode, event); break; case SND_SOC_DAPM_PRE_PMD: blocking_notifier_call_chain(&aqt->mbhc->notifier, AQT_EVENT_PRE_HPHR_PA_OFF, &aqt->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, AQT1000_HPH_R_TEST, 0x01, 0x00); - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_CTL, - 0x10, 0x10); - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_MIX_CTL, - 0x10, 0x10); + snd_soc_component_update_bits(component, + AQT1000_HPH_R_TEST, 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX2_RX_PATH_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX2_RX_PATH_MIX_CTL, + 0x10, 0x10); if (!(strcmp(w->name, "AQT ANC HPHR PA"))) - snd_soc_update_bits(codec, AQT1000_ANA_HPH, 0x40, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_HPH, 0x40, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* @@ -2310,13 +2436,13 @@ static int aqt_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, usleep_range(20000, 20100); else usleep_range(5000, 5100); - aqt_codec_override(codec, aqt->hph_mode, event); + aqt_codec_override(component, aqt->hph_mode, event); blocking_notifier_call_chain(&aqt->mbhc->notifier, AQT_EVENT_POST_HPHR_PA_OFF, &aqt->mbhc->wcd_mbhc); if (!(strcmp(w->name, "AQT ANC HPHR PA"))) { ret = aqt_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00); } @@ -2330,23 +2456,26 @@ static int aqt_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if ((!(strcmp(w->name, "AQT ANC HPHL PA"))) && (test_bit(HPH_PA_DELAY, &aqt->status_mask))) - snd_soc_update_bits(codec, AQT1000_ANA_HPH, - 0xC0, 0xC0); + snd_soc_component_update_bits(component, + AQT1000_ANA_HPH, + 0xC0, 0xC0); set_bit(HPH_PA_DELAY, &aqt->status_mask); break; case SND_SOC_DAPM_POST_PMU: if (!(strcmp(w->name, "AQT ANC HPHL PA"))) { - if ((snd_soc_read(codec, AQT1000_ANA_HPH) & 0xC0) + if ((snd_soc_component_read32( + component, AQT1000_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC @@ -2369,64 +2498,73 @@ static int aqt_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, } if (aqt->anc_func) { /* Clear Tx FE HOLD if both PAs are enabled */ - if ((snd_soc_read(aqt->codec, AQT1000_ANA_HPH) & + if ((snd_soc_component_read32( + aqt->component, AQT1000_ANA_HPH) & 0xC0) == 0xC0) aqt_codec_clear_anc_tx_hold(aqt); } - snd_soc_update_bits(codec, AQT1000_HPH_L_TEST, 0x01, 0x01); + snd_soc_component_update_bits(component, + AQT1000_HPH_L_TEST, 0x01, 0x01); /* Remove Mute on primary path */ - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Enable GM3 boost */ - snd_soc_update_bits(codec, AQT1000_HPH_CNP_WG_CTL, - 0x80, 0x80); + snd_soc_component_update_bits(component, + AQT1000_HPH_CNP_WG_CTL, + 0x80, 0x80); /* Enable AutoChop timer at the end of power up */ - snd_soc_update_bits(codec, AQT1000_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + AQT1000_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, AQT1000_CDC_RX1_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32(component, + AQT1000_CDC_RX1_RX_PATH_MIX_CTL)) & + 0x10) + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); if (!(strcmp(w->name, "AQT ANC HPHL PA"))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s:Do everything needed for right channel\n", __func__); /* Do everything needed for right channel */ - snd_soc_update_bits(codec, AQT1000_HPH_R_TEST, - 0x01, 0x01); + snd_soc_component_update_bits(component, + AQT1000_HPH_R_TEST, + 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_CTL, + snd_soc_component_update_bits(component, + AQT1000_CDC_RX2_RX_PATH_CTL, 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, AQT1000_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); /* Remove ANC Rx from reset */ ret = aqt_codec_enable_anc(w, kcontrol, event); } - aqt_codec_override(codec, aqt->hph_mode, event); + aqt_codec_override(component, aqt->hph_mode, event); break; case SND_SOC_DAPM_PRE_PMD: blocking_notifier_call_chain(&aqt->mbhc->notifier, AQT_EVENT_PRE_HPHL_PA_OFF, &aqt->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, AQT1000_HPH_L_TEST, 0x01, 0x00); - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CTL, - 0x10, 0x10); - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_MIX_CTL, - 0x10, 0x10); + snd_soc_component_update_bits(component, + AQT1000_HPH_L_TEST, 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_CTL, 0x10, 0x10); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x10); if (!(strcmp(w->name, "AQT ANC HPHL PA"))) - snd_soc_update_bits(codec, AQT1000_ANA_HPH, - 0x80, 0x00); + snd_soc_component_update_bits(component, + AQT1000_ANA_HPH, 0x80, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* @@ -2437,13 +2575,13 @@ static int aqt_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, usleep_range(20000, 20100); else usleep_range(5000, 5100); - aqt_codec_override(codec, aqt->hph_mode, event); + aqt_codec_override(component, aqt->hph_mode, event); blocking_notifier_call_chain(&aqt->mbhc->notifier, AQT_EVENT_POST_HPHL_PA_OFF, &aqt->mbhc->wcd_mbhc); if (!(strcmp(w->name, "AQT ANC HPHL PA"))) { ret = aqt_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00); } break; @@ -2455,29 +2593,30 @@ static int aqt_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, static int aqt_codec_set_iir_gain(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: /* fall through */ case SND_SOC_DAPM_PRE_PMD: if (strnstr(w->name, "AQT IIR0", sizeof("AQT IIR0"))) { - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, AQT1000_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL)); } break; @@ -2488,20 +2627,22 @@ static int aqt_codec_set_iir_gain(struct snd_soc_dapm_widget *w, static int aqt_enable_native_supply(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (++aqt->native_clk_users == 1) { - snd_soc_update_bits(codec, AQT1000_CLK_SYS_PLL_ENABLES, - 0x01, 0x01); + snd_soc_component_update_bits(component, + AQT1000_CLK_SYS_PLL_ENABLES, + 0x01, 0x01); /* 100usec is needed as per HW requirement */ usleep_range(100, 120); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x02); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x10, 0x10); } @@ -2509,19 +2650,20 @@ static int aqt_enable_native_supply(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: if (aqt->native_clk_users && (--aqt->native_clk_users == 0)) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x00); - snd_soc_update_bits(codec, AQT1000_CLK_SYS_PLL_ENABLES, - 0x01, 0x00); + snd_soc_component_update_bits(component, + AQT1000_CLK_SYS_PLL_ENABLES, + 0x01, 0x00); } break; } - dev_dbg(codec->dev, "%s: native_clk_users: %d, event: %d\n", + dev_dbg(component->dev, "%s: native_clk_users: %d, event: %d\n", __func__, aqt->native_clk_users, event); return 0; @@ -2537,17 +2679,18 @@ AQT_DAPM_ENUM(int2_1_native, SND_SOC_NOPM, 0, native_mux_text); static int aqt_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; - dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - ret = aqt_cdc_mclk_enable(codec, true); + ret = aqt_cdc_mclk_enable(component, true); break; case SND_SOC_DAPM_POST_PMD: - ret = aqt_cdc_mclk_enable(codec, false); + ret = aqt_cdc_mclk_enable(component, false); break; } @@ -2766,7 +2909,7 @@ static void aqt_shutdown(struct snd_pcm_substream *substream, static int aqt_set_decimator_rate(struct snd_soc_dai *dai, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 tx_fs_rate = 0; u8 tx_mux_sel = 0, tx0_mux_sel = 0, tx1_mux_sel = 0; u16 tx_path_ctl_reg = 0; @@ -2791,27 +2934,30 @@ static int aqt_set_decimator_rate(struct snd_soc_dai *dai, tx_fs_rate = 6; break; default: - dev_err(codec->dev, "%s: Invalid TX sample rate: %d\n", + dev_err(component->dev, "%s: Invalid TX sample rate: %d\n", __func__, sample_rate); return -EINVAL; }; /* Find which decimator path is enabled */ - tx_mux_sel = snd_soc_read(codec, AQT1000_CDC_IF_ROUTER_TX_MUX_CFG0); + tx_mux_sel = snd_soc_component_read32(component, + AQT1000_CDC_IF_ROUTER_TX_MUX_CFG0); tx0_mux_sel = (tx_mux_sel & 0x03); tx1_mux_sel = (tx_mux_sel & 0xC0); if (tx0_mux_sel) { tx_path_ctl_reg = AQT1000_CDC_TX0_TX_PATH_CTL + ((tx0_mux_sel - 1) * 16); - snd_soc_update_bits(codec, tx_path_ctl_reg, 0x0F, tx_fs_rate); + snd_soc_component_update_bits(component, tx_path_ctl_reg, + 0x0F, tx_fs_rate); } if (tx1_mux_sel) { tx_path_ctl_reg = AQT1000_CDC_TX0_TX_PATH_CTL + ((tx1_mux_sel - 1) * 16); - snd_soc_update_bits(codec, tx_path_ctl_reg, 0x0F, tx_fs_rate); + snd_soc_component_update_bits(component, tx_path_ctl_reg, + 0x0F, tx_fs_rate); } return 0; @@ -2820,7 +2966,7 @@ static int aqt_set_decimator_rate(struct snd_soc_dai *dai, static int aqt_set_interpolator_rate(struct snd_soc_dai *dai, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int rate_val = 0; int i; @@ -2831,23 +2977,25 @@ static int aqt_set_interpolator_rate(struct snd_soc_dai *dai, } } if ((i == ARRAY_SIZE(sr_val_tbl)) || (rate_val < 0)) { - dev_err(codec->dev, "%s: Unsupported sample rate: %d\n", + dev_err(component->dev, "%s: Unsupported sample rate: %d\n", __func__, sample_rate); return -EINVAL; } /* TODO - Set the rate only to enabled path */ /* Set Primary interpolator rate */ - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_CTL, + snd_soc_component_update_bits(component, AQT1000_CDC_RX1_RX_PATH_CTL, 0x0F, (u8)rate_val); - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_CTL, + snd_soc_component_update_bits(component, AQT1000_CDC_RX2_RX_PATH_CTL, 0x0F, (u8)rate_val); /* Set mixing path interpolator rate */ - snd_soc_update_bits(codec, AQT1000_CDC_RX1_RX_PATH_MIX_CTL, - 0x0F, (u8)rate_val); - snd_soc_update_bits(codec, AQT1000_CDC_RX2_RX_PATH_MIX_CTL, - 0x0F, (u8)rate_val); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX1_RX_PATH_MIX_CTL, + 0x0F, (u8)rate_val); + snd_soc_component_update_bits(component, + AQT1000_CDC_RX2_RX_PATH_MIX_CTL, + 0x0F, (u8)rate_val); return 0; } @@ -2864,7 +3012,7 @@ static int aqt_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(dai->codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(dai->component); int ret = 0; dev_dbg(aqt->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", @@ -2965,7 +3113,7 @@ struct snd_soc_dai_driver aqt_dai[] = { static int aqt_enable_mclk(struct aqt1000 *aqt) { - struct snd_soc_codec *codec = aqt->codec; + struct snd_soc_component *component = aqt->component; /* Enable mclk requires master bias to be enabled first */ if (aqt->master_bias_users <= 0) { @@ -2977,14 +3125,14 @@ static int aqt_enable_mclk(struct aqt1000 *aqt) if (++aqt->mclk_users == 1) { /* Set clock div 2 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CLK_SYS_MCLK1_PRG, 0x0C, 0x04); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CLK_SYS_MCLK1_PRG, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x01, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x01, 0x01); /* @@ -3001,7 +3149,7 @@ static int aqt_enable_mclk(struct aqt1000 *aqt) static int aqt_disable_mclk(struct aqt1000 *aqt) { - struct snd_soc_codec *codec = aqt->codec; + struct snd_soc_component *component = aqt->component; if (aqt->mclk_users <= 0) { dev_err(aqt->dev, "%s: No mclk users, cannot disable mclk\n", @@ -3010,37 +3158,41 @@ static int aqt_disable_mclk(struct aqt1000 *aqt) } if (--aqt->mclk_users == 0) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AQT1000_CLK_SYS_MCLK1_PRG, 0x10, 0x00); } - dev_dbg(codec->dev, "%s: mclk_users: %d\n", __func__, aqt->mclk_users); + dev_dbg(component->dev, "%s: mclk_users: %d\n", __func__, + aqt->mclk_users); return 0; } static int aqt_enable_master_bias(struct aqt1000 *aqt) { - struct snd_soc_codec *codec = aqt->codec; + struct snd_soc_component *component = aqt->component; mutex_lock(&aqt->master_bias_lock); aqt->master_bias_users++; if (aqt->master_bias_users == 1) { - snd_soc_update_bits(codec, AQT1000_ANA_BIAS, 0x80, 0x80); - snd_soc_update_bits(codec, AQT1000_ANA_BIAS, 0x40, 0x40); + snd_soc_component_update_bits(component, AQT1000_ANA_BIAS, + 0x80, 0x80); + snd_soc_component_update_bits(component, AQT1000_ANA_BIAS, + 0x40, 0x40); /* * 1ms delay is required after pre-charge is enabled * as per HW requirement */ usleep_range(1000, 1100); - snd_soc_update_bits(codec, AQT1000_ANA_BIAS, 0x40, 0x00); + snd_soc_component_update_bits(component, AQT1000_ANA_BIAS, + 0x40, 0x00); } mutex_unlock(&aqt->master_bias_lock); @@ -3050,7 +3202,7 @@ static int aqt_enable_master_bias(struct aqt1000 *aqt) static int aqt_disable_master_bias(struct aqt1000 *aqt) { - struct snd_soc_codec *codec = aqt->codec; + struct snd_soc_component *component = aqt->component; mutex_lock(&aqt->master_bias_lock); if (aqt->master_bias_users <= 0) { @@ -3060,7 +3212,8 @@ static int aqt_disable_master_bias(struct aqt1000 *aqt) aqt->master_bias_users--; if (aqt->master_bias_users == 0) - snd_soc_update_bits(codec, AQT1000_ANA_BIAS, 0x80, 0x00); + snd_soc_component_update_bits(component, AQT1000_ANA_BIAS, + 0x80, 0x00); mutex_unlock(&aqt->master_bias_lock); return 0; @@ -3126,14 +3279,14 @@ static int __aqt_cdc_mclk_enable(struct aqt1000 *aqt, /** * aqt_cdc_mclk_enable - Enable/disable codec mclk * - * @codec: codec instance + * @component: codec component instance * @enable: Indicates clk enable or disable * * Returns 0 on Success and error on failure */ -int aqt_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable) +int aqt_cdc_mclk_enable(struct snd_soc_component *component, bool enable) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); return __aqt_cdc_mclk_enable(aqt, enable); } @@ -3160,11 +3313,11 @@ EXPORT_SYMBOL(aqt_get_micb_vout_ctl_val); static int aqt_set_micbias(struct aqt1000 *aqt, struct aqt1000_pdata *pdata) { - struct snd_soc_codec *codec = aqt->codec; + struct snd_soc_component *component = aqt->component; int vout_ctl_1; if (!pdata) { - dev_err(codec->dev, "%s: NULL pdata\n", __func__); + dev_err(component->dev, "%s: NULL pdata\n", __func__); return -ENODEV; } @@ -3173,7 +3326,8 @@ static int aqt_set_micbias(struct aqt1000 *aqt, if (vout_ctl_1 < 0) return -EINVAL; - snd_soc_update_bits(codec, AQT1000_ANA_MICB1, 0x3F, vout_ctl_1); + snd_soc_component_update_bits(component, AQT1000_ANA_MICB1, + 0x3F, vout_ctl_1); return 0; } @@ -3199,7 +3353,7 @@ static struct snd_info_entry_ops aqt_codec_info_ops = { /* * aqt_codec_info_create_codec_entry - creates aqt1000 module * @codec_root: The parent directory - * @codec: Codec instance + * @component: Codec component instance * * Creates aqt1000 module and version entry under the given * parent directory. @@ -3207,25 +3361,25 @@ static struct snd_info_entry_ops aqt_codec_info_ops = { * Return: 0 on success or negative error code on failure. */ int aqt_codec_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct aqt1000 *aqt; struct snd_soc_card *card; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - aqt = snd_soc_codec_get_drvdata(codec); + aqt = snd_soc_component_get_drvdata(component); if (!aqt) { - dev_dbg(codec->dev, "%s: aqt is NULL\n", __func__); + dev_dbg(component->dev, "%s: aqt is NULL\n", __func__); return -EINVAL; } - card = codec->component.card; + card = component->card; aqt->entry = snd_info_create_subdir(codec_root->module, "aqt1000", codec_root); if (!aqt->entry) { - dev_dbg(codec->dev, "%s: failed to create aqt1000 entry\n", + dev_dbg(component->dev, "%s: failed to create aqt1000 entry\n", __func__); return -ENOMEM; } @@ -3234,7 +3388,7 @@ int aqt_codec_info_create_codec_entry(struct snd_info_entry *codec_root, "version", aqt->entry); if (!version_entry) { - dev_dbg(codec->dev, "%s: failed to create aqt1000 version entry\n", + dev_dbg(component->dev, "%s: failed to create aqt1000 version entry\n", __func__); return -ENOMEM; } @@ -3271,11 +3425,11 @@ static const struct aqt_reg_mask_val aqt_codec_reg_update[] = { static void aqt_codec_init_reg(struct aqt1000 *priv) { - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 i; for (i = 0; i < ARRAY_SIZE(aqt_codec_reg_init); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, aqt_codec_reg_init[i].reg, aqt_codec_reg_init[i].mask, aqt_codec_reg_init[i].val); @@ -3283,26 +3437,29 @@ static void aqt_codec_init_reg(struct aqt1000 *priv) static void aqt_codec_update_reg(struct aqt1000 *priv) { - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 i; for (i = 0; i < ARRAY_SIZE(aqt_codec_reg_update); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, aqt_codec_reg_update[i].reg, aqt_codec_reg_update[i].mask, aqt_codec_reg_update[i].val); } -static int aqt_soc_codec_probe(struct snd_soc_codec *codec) +static int aqt_soc_codec_probe(struct snd_soc_component *component) { struct aqt1000 *aqt; struct aqt1000_pdata *pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int i, ret = 0; - dev_dbg(codec->dev, "%s()\n", __func__); - aqt = snd_soc_codec_get_drvdata(codec); + dev_dbg(component->dev, "%s()\n", __func__); + aqt = snd_soc_component_get_drvdata(component); + + snd_soc_component_init_regmap(component, aqt->regmap); mutex_init(&aqt->codec_mutex); mutex_init(&aqt->i2s_lock); @@ -3311,7 +3468,7 @@ static int aqt_soc_codec_probe(struct snd_soc_codec *codec) /* Default HPH Mode to Class-H Low HiFi */ aqt->hph_mode = CLS_H_LOHIFI; - aqt->fw_data = devm_kzalloc(codec->dev, sizeof(*(aqt->fw_data)), + aqt->fw_data = devm_kzalloc(component->dev, sizeof(*(aqt->fw_data)), GFP_KERNEL); if (!aqt->fw_data) goto err; @@ -3328,39 +3485,40 @@ static int aqt_soc_codec_probe(struct snd_soc_codec *codec) } ret = wcd_cal_create_hwdep(aqt->fw_data, - AQT1000_CODEC_HWDEP_NODE, codec); + AQT1000_CODEC_HWDEP_NODE, component); if (ret < 0) { - dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret); + dev_err(component->dev, "%s hwdep failed %d\n", __func__, ret); goto err_hwdep; } /* Initialize MBHC module */ - ret = aqt_mbhc_init(&aqt->mbhc, codec, aqt->fw_data); + ret = aqt_mbhc_init(&aqt->mbhc, component, aqt->fw_data); if (ret) { pr_err("%s: mbhc initialization failed\n", __func__); goto err_hwdep; } - aqt->codec = codec; + aqt->component = component; for (i = 0; i < COMPANDER_MAX; i++) aqt->comp_enabled[i] = 0; - aqt_cdc_mclk_enable(codec, true); + aqt_cdc_mclk_enable(component, true); aqt_codec_init_reg(aqt); - aqt_cdc_mclk_enable(codec, false); + aqt_cdc_mclk_enable(component, false); /* Add 100usec delay as per HW requirement */ usleep_range(100, 110); aqt_codec_update_reg(aqt); - pdata = dev_get_platdata(codec->dev); + pdata = dev_get_platdata(component->dev); /* If 1.8v is supplied externally, then disable internal 1.8v supply */ for (i = 0; i < pdata->num_supplies; i++) { if (!strcmp(pdata->regulator->name, "aqt_vdd1p8")) { - snd_soc_update_bits(codec, AQT1000_BUCK_5V_EN_CTL, - 0x03, 0x00); - dev_dbg(codec->dev, "%s: Disabled internal supply\n", + snd_soc_component_update_bits(component, + AQT1000_BUCK_5V_EN_CTL, + 0x03, 0x00); + dev_dbg(component->dev, "%s: Disabled internal supply\n", __func__); break; } @@ -3405,7 +3563,7 @@ static int aqt_soc_codec_probe(struct snd_soc_codec *codec) err_hwdep: clk_put(aqt->ext_clk); err_clk: - devm_kfree(codec->dev, aqt->fw_data); + devm_kfree(component->dev, aqt->fw_data); aqt->fw_data = NULL; err: mutex_destroy(&aqt->i2s_lock); @@ -3413,39 +3571,30 @@ err: return ret; } -static int aqt_soc_codec_remove(struct snd_soc_codec *codec) +static void aqt_soc_codec_remove(struct snd_soc_component *component) { - struct aqt1000 *aqt = snd_soc_codec_get_drvdata(codec); + struct aqt1000 *aqt = snd_soc_component_get_drvdata(component); /* Deinitialize MBHC module */ - aqt_mbhc_deinit(codec); + aqt_mbhc_deinit(component); aqt->mbhc = NULL; mutex_destroy(&aqt->i2s_lock); mutex_destroy(&aqt->codec_mutex); clk_put(aqt->ext_clk); - return 0; + return; } -static struct regmap *aqt_get_regmap(struct device *dev) -{ - struct aqt1000 *control = dev_get_drvdata(dev); - - return control->regmap; -} - -struct snd_soc_codec_driver snd_cdc_dev_aqt = { +static const struct snd_soc_component_driver snd_cdc_dev_aqt = { + .name = DRV_NAME, .probe = aqt_soc_codec_probe, .remove = aqt_soc_codec_remove, - .get_regmap = aqt_get_regmap, - .component_driver = { - .controls = aqt_snd_controls, - .num_controls = ARRAY_SIZE(aqt_snd_controls), - .dapm_widgets = aqt_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(aqt_dapm_widgets), - .dapm_routes = aqt_audio_map, - .num_dapm_routes = ARRAY_SIZE(aqt_audio_map), - }, + .controls = aqt_snd_controls, + .num_controls = ARRAY_SIZE(aqt_snd_controls), + .dapm_widgets = aqt_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aqt_dapm_widgets), + .dapm_routes = aqt_audio_map, + .num_dapm_routes = ARRAY_SIZE(aqt_audio_map), }; /* @@ -3456,7 +3605,7 @@ struct snd_soc_codec_driver snd_cdc_dev_aqt = { */ int aqt_register_codec(struct device *dev) { - return snd_soc_register_codec(dev, &snd_cdc_dev_aqt, aqt_dai, + return snd_soc_register_component(dev, &snd_cdc_dev_aqt, aqt_dai, ARRAY_SIZE(aqt_dai)); } EXPORT_SYMBOL(aqt_register_codec); diff --git a/asoc/codecs/aqt1000/aqt1000.h b/asoc/codecs/aqt1000/aqt1000.h index 88fdc90d2c..6148213f65 100644 --- a/asoc/codecs/aqt1000/aqt1000.h +++ b/asoc/codecs/aqt1000/aqt1000.h @@ -145,7 +145,7 @@ struct aqt1000 { u32 mclk_rate; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; bool dev_up; bool prev_pg_valid; u8 prev_pg; diff --git a/asoc/codecs/audio-ext-clk-up.c b/asoc/codecs/audio-ext-clk-up.c index 2bbbc9e95a..74ab9e243a 100644 --- a/asoc/codecs/audio-ext-clk-up.c +++ b/asoc/codecs/audio-ext-clk-up.c @@ -10,6 +10,7 @@ #include #include #include "../../../drivers/clk/qcom/common.h" +#include #include #include #include diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c index 430a0b3e5e..2d63c431cf 100644 --- a/asoc/codecs/bolero/bolero-cdc.c +++ b/asoc/codecs/bolero/bolero-cdc.c @@ -16,13 +16,15 @@ #include "bolero-cdc.h" #include "internal.h" +#define DRV_NAME "bolero_codec" + #define BOLERO_VERSION_1_0 0x0001 #define BOLERO_VERSION_1_1 0x0002 #define BOLERO_VERSION_1_2 0x0003 #define BOLERO_VERSION_ENTRY_SIZE 32 #define BOLERO_CDC_STRING_LEN 80 -static struct snd_soc_codec_driver bolero; +static const struct snd_soc_component_driver bolero; /* pm runtime auto suspend timer in msecs */ #define BOLERO_AUTO_SUSPEND_DELAY 100 /* delay in msec */ @@ -145,17 +147,20 @@ static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data) switch (event) { case WCD_BOLERO_EVT_RX_MUTE: if (priv->macro_params[RX_MACRO].event_handler) - priv->macro_params[RX_MACRO].event_handler(priv->codec, + priv->macro_params[RX_MACRO].event_handler( + priv->component, BOLERO_MACRO_EVT_RX_MUTE, data); break; case WCD_BOLERO_EVT_IMPED_TRUE: if (priv->macro_params[RX_MACRO].event_handler) - priv->macro_params[RX_MACRO].event_handler(priv->codec, + priv->macro_params[RX_MACRO].event_handler( + priv->component, BOLERO_MACRO_EVT_IMPED_TRUE, data); break; case WCD_BOLERO_EVT_IMPED_FALSE: if (priv->macro_params[RX_MACRO].event_handler) - priv->macro_params[RX_MACRO].event_handler(priv->codec, + priv->macro_params[RX_MACRO].event_handler( + priv->component, BOLERO_MACRO_EVT_IMPED_FALSE, data); break; default: @@ -367,7 +372,7 @@ int bolero_register_macro(struct device *dev, u16 macro_id, bolero_mclk_mux_tbl[VA_MACRO][MCLK_MUX0] = VA_MACRO; priv->current_mclk_mux_macro[VA_MACRO] = VA_MACRO; } - ret = snd_soc_register_codec(dev->parent, &bolero, + ret = snd_soc_register_component(dev->parent, &bolero, priv->bolero_dais, priv->num_dais); if (ret < 0) { dev_err(dev, "%s: register codec failed\n", __func__); @@ -418,7 +423,7 @@ void bolero_unregister_macro(struct device *dev, u16 macro_id) /* UNREGISTER CODEC HERE */ if (priv->num_macros - 1 == priv->num_macros_registered) - snd_soc_unregister_codec(dev->parent); + snd_soc_unregister_component(dev->parent); } EXPORT_SYMBOL(bolero_unregister_macro); @@ -568,7 +573,8 @@ static int bolero_ssr_enable(struct device *dev, void *data) } if (priv->macro_params[VA_MACRO].event_handler) - priv->macro_params[VA_MACRO].event_handler(priv->codec, + priv->macro_params[VA_MACRO].event_handler( + priv->component, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0); regcache_cache_only(priv->regmap, false); @@ -576,7 +582,8 @@ static int bolero_ssr_enable(struct device *dev, void *data) for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; - priv->macro_params[macro_idx].event_handler(priv->codec, + priv->macro_params[macro_idx].event_handler( + priv->component, BOLERO_MACRO_EVT_SSR_UP, 0x0); } mutex_lock(&priv->clk_lock); @@ -601,7 +608,8 @@ static void bolero_ssr_disable(struct device *dev, void *data) for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; - priv->macro_params[macro_idx].event_handler(priv->codec, + priv->macro_params[macro_idx].event_handler( + priv->component, BOLERO_MACRO_EVT_SSR_DOWN, 0x0); } bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_DOWN); @@ -619,7 +627,7 @@ static const struct snd_event_ops bolero_ssr_ops = { /* * bolero_info_create_codec_entry - creates bolero module * @codec_root: The parent directory - * @codec: Codec instance + * @component: Codec component instance * * Creates bolero module and version entry under the given * parent directory. @@ -627,26 +635,26 @@ static const struct snd_event_ops bolero_ssr_ops = { * Return: 0 on success or negative error code on failure. */ int bolero_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct bolero_priv *priv; struct snd_soc_card *card; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - priv = snd_soc_codec_get_drvdata(codec); + priv = snd_soc_component_get_drvdata(component); if (priv->entry) { dev_dbg(priv->dev, "%s:bolero module already created\n", __func__); return 0; } - card = codec->component.card; + card = component->card; priv->entry = snd_info_create_subdir(codec_root->module, "bolero", codec_root); if (!priv->entry) { - dev_dbg(codec->dev, "%s: failed to create bolero entry\n", + dev_dbg(component->dev, "%s: failed to create bolero entry\n", __func__); return -ENOMEM; } @@ -654,7 +662,7 @@ int bolero_info_create_codec_entry(struct snd_info_entry *codec_root, "version", priv->entry); if (!version_entry) { - dev_err(codec->dev, "%s: failed to create bolero version entry\n", + dev_err(component->dev, "%s: failed to create bolero version entry\n", __func__); return -ENOMEM; } @@ -677,52 +685,56 @@ EXPORT_SYMBOL(bolero_info_create_codec_entry); /** * bolero_register_wake_irq - Register wake irq of Tx macro * - * @codec: codec ptr. + * @component: codec component ptr. * @ipc_wakeup: bool to identify ipc_wakeup to be used or HW interrupt line. * * Return: 0 on success or negative error code on failure. */ -int bolero_register_wake_irq(struct snd_soc_codec *codec, u32 ipc_wakeup) +int bolero_register_wake_irq(struct snd_soc_component *component, + u32 ipc_wakeup) { struct bolero_priv *priv = NULL; - if (!codec) + if (!component) return -EINVAL; - priv = snd_soc_codec_get_drvdata(codec); + priv = snd_soc_component_get_drvdata(component); if (!priv) return -EINVAL; if (!bolero_is_valid_codec_dev(priv->dev)) { - dev_err(codec->dev, "%s: invalid codec\n", __func__); + dev_err(component->dev, "%s: invalid codec\n", __func__); return -EINVAL; } if (priv->macro_params[TX_MACRO].reg_wake_irq) - priv->macro_params[TX_MACRO].reg_wake_irq(codec, ipc_wakeup); + priv->macro_params[TX_MACRO].reg_wake_irq( + component, ipc_wakeup); return 0; } EXPORT_SYMBOL(bolero_register_wake_irq); -static int bolero_soc_codec_probe(struct snd_soc_codec *codec) +static int bolero_soc_codec_probe(struct snd_soc_component *component) { - struct bolero_priv *priv = dev_get_drvdata(codec->dev); + struct bolero_priv *priv = dev_get_drvdata(component->dev); int macro_idx, ret = 0; + snd_soc_component_init_regmap(component, priv->regmap); + /* call init for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (priv->macro_params[macro_idx].init) { - ret = priv->macro_params[macro_idx].init(codec); + ret = priv->macro_params[macro_idx].init(component); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: init for macro %d failed\n", __func__, macro_idx); goto err; } } } - priv->codec = codec; + priv->component = component; /* * In order for the ADIE RTC to differentiate between targets * version info is used. @@ -741,42 +753,36 @@ static int bolero_soc_codec_probe(struct snd_soc_codec *codec) if (!ret) { snd_event_notify(priv->dev, SND_EVENT_UP); } else { - dev_err(codec->dev, + dev_err(component->dev, "%s: Registration with SND event FWK failed ret = %d\n", __func__, ret); goto err; } - dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__); + dev_dbg(component->dev, "%s: bolero soc codec probe success\n", + __func__); err: return ret; } -static int bolero_soc_codec_remove(struct snd_soc_codec *codec) +static void bolero_soc_codec_remove(struct snd_soc_component *component) { - struct bolero_priv *priv = dev_get_drvdata(codec->dev); + struct bolero_priv *priv = dev_get_drvdata(component->dev); int macro_idx; snd_event_client_deregister(priv->dev); /* call exit for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) if (priv->macro_params[macro_idx].exit) - priv->macro_params[macro_idx].exit(codec); + priv->macro_params[macro_idx].exit(component); - return 0; + return; } -static struct regmap *bolero_get_regmap(struct device *dev) -{ - struct bolero_priv *priv = dev_get_drvdata(dev); - - return priv->regmap; -} - -static struct snd_soc_codec_driver bolero = { +static const struct snd_soc_component_driver bolero = { + .name = DRV_NAME, .probe = bolero_soc_codec_probe, .remove = bolero_soc_codec_remove, - .get_regmap = bolero_get_regmap, }; static void bolero_add_child_devices(struct work_struct *work) diff --git a/asoc/codecs/bolero/bolero-cdc.h b/asoc/codecs/bolero/bolero-cdc.h index 7193a8ccf1..386fa628bf 100644 --- a/asoc/codecs/bolero/bolero-cdc.h +++ b/asoc/codecs/bolero/bolero-cdc.h @@ -42,15 +42,15 @@ enum { }; struct macro_ops { - int (*init)(struct snd_soc_codec *codec); - int (*exit)(struct snd_soc_codec *codec); + int (*init)(struct snd_soc_component *component); + int (*exit)(struct snd_soc_component *component); u16 num_dais; struct device *dev; struct snd_soc_dai_driver *dai_ptr; int (*mclk_fn)(struct device *dev, bool enable); - int (*event_handler)(struct snd_soc_codec *codec, u16 event, + int (*event_handler)(struct snd_soc_component *component, u16 event, u32 data); - int (*reg_wake_irq)(struct snd_soc_codec *codec, u32 data); + int (*reg_wake_irq)(struct snd_soc_component *component, u32 data); char __iomem *io_base; }; @@ -64,8 +64,8 @@ int bolero_request_clock(struct device *dev, u16 macro_id, bool enable); int bolero_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec); -int bolero_register_wake_irq(struct snd_soc_codec *codec, u32 data); + struct snd_soc_component *component); +int bolero_register_wake_irq(struct snd_soc_component *component, u32 data); void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n); int bolero_runtime_resume(struct device *dev); int bolero_runtime_suspend(struct device *dev); @@ -96,7 +96,7 @@ static inline int bolero_request_clock(struct device *dev, u16 macro_id, static int bolero_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } @@ -105,7 +105,7 @@ static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n) { } -static inline int bolero_register_wake_irq(struct snd_soc_codec *codec, +static inline int bolero_register_wake_irq(struct snd_soc_component *component, u32 data) static inline int bolero_runtime_resume(struct device *dev) { diff --git a/asoc/codecs/bolero/internal.h b/asoc/codecs/bolero/internal.h index 8b7c0923cb..be00482a3e 100644 --- a/asoc/codecs/bolero/internal.h +++ b/asoc/codecs/bolero/internal.h @@ -41,7 +41,7 @@ struct wcd_ctrl_platform_data { struct bolero_priv { struct device *dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; struct mutex io_lock; struct mutex clk_lock; diff --git a/asoc/codecs/bolero/rx-macro.c b/asoc/codecs/bolero/rx-macro.c index aa49e898bc..75a3a0a15d 100644 --- a/asoc/codecs/bolero/rx-macro.c +++ b/asoc/codecs/bolero/rx-macro.c @@ -271,7 +271,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -static int rx_macro_enable_interp_clk(struct snd_soc_codec *codec, +static int rx_macro_enable_interp_clk(struct snd_soc_component *component, int event, int interp_idx); /* Hold instance to soundwire platform device */ @@ -320,7 +320,7 @@ enum { * @rx_swr_gpio_p: used by pinctrl API * @rx_core_clk: MCLK for rx macro * @rx_npl_clk: NPL clock for RX soundwire - * @codec: codec handle + * @component: codec handle */ struct rx_macro_priv { struct device *dev; @@ -347,7 +347,7 @@ struct rx_macro_priv { struct device_node *rx_swr_gpio_p; struct clk *rx_core_clk; struct clk *rx_npl_clk; - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned long active_ch_mask[RX_MACRO_MAX_DAIS]; unsigned long active_ch_cnt[RX_MACRO_MAX_DAIS]; u16 bit_width[RX_MACRO_MAX_DAIS]; @@ -631,11 +631,11 @@ ret: * This function updates HPHL and HPHR gain settings * according to the impedance value. * - * @codec: codec pointer handle + * @component: codec pointer handle * @imped: impedance value of HPHL/R * @reset: bool variable to reset registers when teardown */ -static void rx_macro_wcd_clsh_imped_config(struct snd_soc_codec *codec, +static void rx_macro_wcd_clsh_imped_config(struct snd_soc_component *component, int imped, bool reset) { int i; @@ -650,7 +650,7 @@ static void rx_macro_wcd_clsh_imped_config(struct snd_soc_codec *codec, /* reset = 1, which means request is to reset the register values */ if (reset) { for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, 0); return; @@ -666,34 +666,34 @@ static void rx_macro_wcd_clsh_imped_config(struct snd_soc_codec *codec, return; } for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, imped_table_ptr[index][i].val); } -static bool rx_macro_get_data(struct snd_soc_codec *codec, +static bool rx_macro_get_data(struct snd_soc_component *component, struct device **rx_dev, struct rx_macro_priv **rx_priv, const char *func_name) { - *rx_dev = bolero_get_device_ptr(codec->dev, RX_MACRO); + *rx_dev = bolero_get_device_ptr(component->dev, RX_MACRO); if (!(*rx_dev)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", func_name); return false; } *rx_priv = dev_get_drvdata((*rx_dev)); if (!(*rx_priv)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", func_name); return false; } - if (!(*rx_priv)->codec) { - dev_err(codec->dev, + if (!(*rx_priv)->component) { + dev_err(component->dev, "%s: tx_priv codec is not initialized!\n", func_name); return false; } @@ -706,7 +706,8 @@ static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = 0; unsigned short look_ahead_dly_reg = @@ -716,7 +717,7 @@ static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, if (val >= e->items) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); if (e->reg == BOLERO_CDC_RX_RX0_RX_PATH_CFG1) @@ -725,7 +726,7 @@ static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, look_ahead_dly_reg = BOLERO_CDC_RX_RX1_RX_PATH_CFG0; /* Set Look Ahead Delay */ - snd_soc_update_bits(codec, look_ahead_dly_reg, + snd_soc_component_update_bits(component, look_ahead_dly_reg, 0x08, (val ? 0x08 : 0x00)); /* Set DEM INP Select */ return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -741,11 +742,11 @@ static int rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, u16 int_fs_reg = 0; u8 int_mux_cfg0_val = 0, int_mux_cfg1_val = 0; u8 inp0_sel = 0, inp1_sel = 0, inp2_sel = 0; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; for_each_set_bit(port, &rx_priv->active_ch_mask[dai->id], @@ -768,8 +769,10 @@ static int rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, for (j = 0; j < INTERP_MAX; j++) { int_mux_cfg1 = int_mux_cfg0 + 4; - int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1); + int_mux_cfg0_val = snd_soc_component_read32( + component, int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read32( + component, int_mux_cfg1); inp0_sel = int_mux_cfg0_val & 0x07; inp1_sel = (int_mux_cfg0_val >> 4) & 0x038; inp2_sel = (int_mux_cfg1_val >> 4) & 0x038; @@ -783,7 +786,8 @@ static int rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, pr_debug("%s: set INT%u_1 sample rate to %u\n", __func__, j, sample_rate); /* sample_rate is in Hz */ - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits(component, + int_fs_reg, 0x0F, rate_reg_val); } int_mux_cfg0 += 8; @@ -801,11 +805,11 @@ static int rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, u32 j = 0, port = 0; u16 int_mux_cfg1 = 0, int_fs_reg = 0; u8 int_mux_cfg1_val = 0; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; for_each_set_bit(port, &rx_priv->active_ch_mask[dai->id], @@ -820,7 +824,8 @@ static int rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_mux_cfg1 = BOLERO_CDC_RX_INP_MUX_RX_INT0_CFG1; for (j = 0; j < INTERP_MAX; j++) { - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) & + int_mux_cfg1_val = snd_soc_component_read32( + component, int_mux_cfg1) & 0x07; if (int_mux_cfg1_val == int_2_inp) { int_fs_reg = BOLERO_CDC_RX_RX0_RX_PATH_MIX_CTL + @@ -829,7 +834,8 @@ static int rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, __func__, dai->id, j); pr_debug("%s: set INT%u_2 sample rate to %u\n", __func__, j, sample_rate); - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits( + component, int_fs_reg, 0x0F, rate_reg_val); } int_mux_cfg1 += 8; @@ -855,13 +861,13 @@ static bool rx_macro_is_fractional_sample_rate(u32 sample_rate) static int rx_macro_set_interpolator_rate(struct snd_soc_dai *dai, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int rate_val = 0; int i = 0, ret = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; @@ -876,7 +882,7 @@ static int rx_macro_set_interpolator_rate(struct snd_soc_dai *dai, } } if ((i == ARRAY_SIZE(sr_val_tbl)) || (rate_val < 0)) { - dev_err(codec->dev, "%s: Unsupported sample rate: %d\n", + dev_err(component->dev, "%s: Unsupported sample rate: %d\n", __func__, sample_rate); return -EINVAL; } @@ -895,15 +901,15 @@ static int rx_macro_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int ret = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), params_channels(params)); @@ -929,13 +935,13 @@ static int rx_macro_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; unsigned int temp = 0, ch_mask = 0; u16 i = 0; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; switch (dai->id) { @@ -1031,13 +1037,14 @@ exit: static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; int mclk_freq = MCLK_FREQ; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; dev_dbg(rx_dev, "%s: event = %d\n", __func__, event); @@ -1111,14 +1118,14 @@ static int rx_macro_mclk_ctrl(struct device *dev, bool enable) return 0; } -static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, - u32 data) +static int rx_macro_event_handler(struct snd_soc_component *component, + u16 event, u32 data) { u16 reg = 0, reg_mix = 0, rx_idx = 0, mute = 0x0, val = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; switch (event) { @@ -1130,14 +1137,16 @@ static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, RX_MACRO_RX_PATH_OFFSET); reg_mix = BOLERO_CDC_RX_RX0_RX_PATH_MIX_CTL + (rx_idx * RX_MACRO_RX_PATH_OFFSET); - snd_soc_update_bits(codec, reg, 0x10, val); - snd_soc_update_bits(codec, reg_mix, 0x10, val); + snd_soc_component_update_bits(component, reg, + 0x10, val); + snd_soc_component_update_bits(component, reg_mix, + 0x10, val); break; case BOLERO_MACRO_EVT_IMPED_TRUE: - rx_macro_wcd_clsh_imped_config(codec, data, true); + rx_macro_wcd_clsh_imped_config(component, data, true); break; case BOLERO_MACRO_EVT_IMPED_FALSE: - rx_macro_wcd_clsh_imped_config(codec, data, false); + rx_macro_wcd_clsh_imped_config(component, data, false); break; case BOLERO_MACRO_EVT_SSR_DOWN: rx_priv->dev_up = false; @@ -1176,7 +1185,7 @@ static int rx_macro_find_playback_dai_id_for_port(int port_id, return -EINVAL; } -static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, +static int rx_macro_set_idle_detect_thr(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, int interp, int path_type) { @@ -1204,7 +1213,8 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, if (path_type == INTERP_MIX_PATH) { mux_reg = BOLERO_CDC_RX_INP_MUX_RX_INT0_CFG1 + 2 * interp; - mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f; + mux_reg_val = snd_soc_component_read32(component, mux_reg) & + 0x0f; if ((mux_reg_val >= INTn_2_INP_SEL_RX0) && (mux_reg_val <= INTn_2_INP_SEL_RX5)) { @@ -1216,7 +1226,8 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, if (path_type == INTERP_MAIN_PATH) { mux_reg = BOLERO_CDC_RX_INP_MUX_RX_INT1_CFG0 + 2 * (interp - 1); - mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f; + mux_reg_val = snd_soc_component_read32(component, mux_reg) & + 0x0f; i = RX_MACRO_INTERP_MUX_NUM_INPUTS; while (i) { @@ -1226,14 +1237,15 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, INTn_1_INP_SEL_RX0; num_ports++; } - mux_reg_val = (snd_soc_read(codec, mux_reg) & - 0xf0) >> 4; + mux_reg_val = + (snd_soc_component_read32(component, mux_reg) & + 0xf0) >> 4; mux_reg += 1; i--; } } - dev_dbg(codec->dev, "%s: num_ports: %d, ports[%d %d %d %d]\n", + dev_dbg(component->dev, "%s: num_ports: %d, ports[%d %d %d %d]\n", __func__, num_ports, port_id[0], port_id[1], port_id[2], port_id[3]); @@ -1243,7 +1255,7 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, rx_priv); if ((dai_id >= 0) && (dai_id < RX_MACRO_MAX_DAIS)) { - dev_dbg(codec->dev, "%s: dai_id: %d bit_width: %d\n", + dev_dbg(component->dev, "%s: dai_id: %d bit_width: %d\n", __func__, dai_id, rx_priv->bit_width[dai_id]); @@ -1266,12 +1278,13 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, break; } - dev_dbg(codec->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", + dev_dbg(component->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", __func__, idle_thr, rx_priv->idle_det_cfg.hph_idle_thr); if ((rx_priv->idle_det_cfg.hph_idle_thr == 0) || (idle_thr < rx_priv->idle_det_cfg.hph_idle_thr)) { - snd_soc_write(codec, BOLERO_CDC_RX_IDLE_DETECT_CFG3, idle_thr); + snd_soc_component_write(component, + BOLERO_CDC_RX_IDLE_DETECT_CFG3, idle_thr); rx_priv->idle_det_cfg.hph_idle_thr = idle_thr; } @@ -1281,16 +1294,17 @@ static int rx_macro_set_idle_detect_thr(struct snd_soc_codec *codec, static int rx_macro_enable_mix_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg = 0, mix_reg = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; if (w->shift >= INTERP_MAX) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; } @@ -1300,27 +1314,27 @@ static int rx_macro_enable_mix_path(struct snd_soc_dapm_widget *w, mix_reg = BOLERO_CDC_RX_RX0_RX_PATH_MIX_CTL + (w->shift * RX_MACRO_RX_PATH_OFFSET); - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); switch (event) { case SND_SOC_DAPM_PRE_PMU: - rx_macro_set_idle_detect_thr(codec, rx_priv, w->shift, + rx_macro_set_idle_detect_thr(component, rx_priv, w->shift, INTERP_MIX_PATH); - rx_macro_enable_interp_clk(codec, event, w->shift); + rx_macro_enable_interp_clk(component, event, w->shift); /* Clk enable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x20); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x20); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, gain_reg, - snd_soc_read(codec, gain_reg)); + snd_soc_component_write(component, gain_reg, + snd_soc_component_read32(component, gain_reg)); break; case SND_SOC_DAPM_POST_PMD: /* Clk Disable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x00); - rx_macro_enable_interp_clk(codec, event, w->shift); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x00); + rx_macro_enable_interp_clk(component, event, w->shift); /* Reset enable and disable */ - snd_soc_update_bits(codec, mix_reg, 0x40, 0x40); - snd_soc_update_bits(codec, mix_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x40); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x00); break; } @@ -1331,19 +1345,20 @@ static int rx_macro_enable_main_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg = 0; u16 reg = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); if (w->shift >= INTERP_MAX) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; } @@ -1355,23 +1370,23 @@ static int rx_macro_enable_main_path(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - rx_macro_set_idle_detect_thr(codec, rx_priv, w->shift, + rx_macro_set_idle_detect_thr(component, rx_priv, w->shift, INTERP_MAIN_PATH); - rx_macro_enable_interp_clk(codec, event, w->shift); + rx_macro_enable_interp_clk(component, event, w->shift); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, gain_reg, - snd_soc_read(codec, gain_reg)); + snd_soc_component_write(component, gain_reg, + snd_soc_component_read32(component, gain_reg)); break; case SND_SOC_DAPM_POST_PMD: - rx_macro_enable_interp_clk(codec, event, w->shift); + rx_macro_enable_interp_clk(component, event, w->shift); break; } return 0; } -static int rx_macro_config_compander(struct snd_soc_codec *codec, +static int rx_macro_config_compander(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, int interp_n, int event) { @@ -1383,7 +1398,7 @@ static int rx_macro_config_compander(struct snd_soc_codec *codec, return 0; comp = interp_n; - dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n", __func__, event, comp + 1, rx_priv->comp_enabled[comp]); if (!rx_priv->comp_enabled[comp]) @@ -1396,46 +1411,54 @@ static int rx_macro_config_compander(struct snd_soc_codec *codec, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Compander Clock */ - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x02); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x04); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x00); } return 0; } -static void rx_macro_enable_softclip_clk(struct snd_soc_codec *codec, +static void rx_macro_enable_softclip_clk(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, bool enable) { if (enable) { if (rx_priv->softclip_clk_users == 0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_SOFTCLIP_CRC, 0x01, 0x01); rx_priv->softclip_clk_users++; } else { rx_priv->softclip_clk_users--; if (rx_priv->softclip_clk_users == 0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_SOFTCLIP_CRC, 0x01, 0x00); } } -static int rx_macro_config_softclip(struct snd_soc_codec *codec, +static int rx_macro_config_softclip(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, int event) { - dev_dbg(codec->dev, "%s: event %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d, enabled %d\n", __func__, event, rx_priv->is_softclip_on); if (!rx_priv->is_softclip_on) @@ -1443,16 +1466,16 @@ static int rx_macro_config_softclip(struct snd_soc_codec *codec, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Softclip clock */ - rx_macro_enable_softclip_clk(codec, rx_priv, true); + rx_macro_enable_softclip_clk(component, rx_priv, true); /* Enable Softclip control */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 0x01, 0x01); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 0x01, 0x00); - rx_macro_enable_softclip_clk(codec, rx_priv, false); + rx_macro_enable_softclip_clk(component, rx_priv, false); } return 0; @@ -1463,7 +1486,7 @@ rx_macro_enable_clsh_block(struct rx_macro_priv *rx_priv, bool enable) { if ((enable && ++rx_priv->clsh_users == 1) || (!enable && --rx_priv->clsh_users == 0)) - snd_soc_update_bits(rx_priv->codec, + snd_soc_component_update_bits(rx_priv->component, BOLERO_CDC_RX_CLSH_CRC, 0x01, (u8) enable); if (rx_priv->clsh_users < 0) @@ -1472,7 +1495,7 @@ rx_macro_enable_clsh_block(struct rx_macro_priv *rx_priv, bool enable) rx_priv->clsh_users, enable); } -static int rx_macro_config_classh(struct snd_soc_codec *codec, +static int rx_macro_config_classh(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, int interp_n, int event) { @@ -1491,36 +1514,44 @@ static int rx_macro_config_classh(struct snd_soc_codec *codec, * These K1 values depend on the Headphone Impedance * For now it is assumed to be 16 ohm */ - snd_soc_update_bits(codec, BOLERO_CDC_RX_CLSH_K1_LSB, - 0xFF, 0xC0); - snd_soc_update_bits(codec, BOLERO_CDC_RX_CLSH_K1_MSB, - 0x0F, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_CLSH_K1_LSB, + 0xFF, 0xC0); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_CLSH_K1_MSB, + 0x0F, 0x00); } switch (interp_n) { case INTERP_HPHL: if (rx_priv->is_ear_mode_on) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_CLSH_HPH_V_PA, 0x3F, 0x39); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_CLSH_HPH_V_PA, 0x3F, 0x1C); - snd_soc_update_bits(codec, BOLERO_CDC_RX_CLSH_DECAY_CTRL, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_CLSH_DECAY_CTRL, 0x07, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX0_RX_PATH_CFG0, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX0_RX_PATH_CFG0, 0x40, 0x40); break; case INTERP_HPHR: - snd_soc_update_bits(codec, BOLERO_CDC_RX_CLSH_HPH_V_PA, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_CLSH_HPH_V_PA, 0x3F, 0x1C); - snd_soc_update_bits(codec, BOLERO_CDC_RX_CLSH_DECAY_CTRL, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_CLSH_DECAY_CTRL, 0x07, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX1_RX_PATH_CFG0, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX1_RX_PATH_CFG0, 0x40, 0x40); break; case INTERP_AUX: - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG0, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_CFG0, 0x10, 0x10); break; } @@ -1528,7 +1559,7 @@ static int rx_macro_config_classh(struct snd_soc_codec *codec, return 0; } -static void rx_macro_hd2_control(struct snd_soc_codec *codec, +static void rx_macro_hd2_control(struct snd_soc_component *component, u16 interp_idx, int event) { u16 hd2_scale_reg = 0; @@ -1546,26 +1577,31 @@ static void rx_macro_hd2_control(struct snd_soc_codec *codec, } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x14); - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x14); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x04); } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x00); } } static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = rx_priv->comp_enabled[comp]; @@ -1575,17 +1611,18 @@ static int rx_macro_get_compander(struct snd_kcontrol *kcontrol, static int rx_macro_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Compander %d enable current %d, new %d\n", __func__, comp + 1, rx_priv->comp_enabled[comp], value); rx_priv->comp_enabled[comp] = value; @@ -1597,11 +1634,12 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = @@ -1614,7 +1652,8 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; u32 rx_port_value = ucontrol->value.integer.value[0]; @@ -1622,7 +1661,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; aif_rst = rx_priv->rx_port_value[widget->shift]; @@ -1649,7 +1688,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol, rx_priv->active_ch_cnt[rx_port_value]++; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s:Invalid AIF_ID for RX_MACRO MUX\n", __func__); goto err; } @@ -1664,11 +1703,12 @@ err: static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = rx_priv->is_ear_mode_on; @@ -1678,11 +1718,12 @@ static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; rx_priv->is_ear_mode_on = @@ -1693,11 +1734,12 @@ static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = rx_priv->hph_hd2_mode; @@ -1707,11 +1749,12 @@ static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; rx_priv->hph_hd2_mode = ucontrol->value.integer.value[0]; @@ -1721,11 +1764,12 @@ static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol, static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = rx_priv->hph_pwr_mode; @@ -1735,11 +1779,12 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; rx_priv->hph_pwr_mode = ucontrol->value.integer.value[0]; @@ -1749,13 +1794,15 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol, static int rx_macro_vbat_bcl_gsm_mode_func_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); ucontrol->value.integer.value[0] = - ((snd_soc_read(codec, BOLERO_CDC_RX_BCL_VBAT_CFG) & 0x04) ? + ((snd_soc_component_read32( + component, BOLERO_CDC_RX_BCL_VBAT_CFG) & 0x04) ? 1 : 0); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1764,18 +1811,21 @@ static int rx_macro_vbat_bcl_gsm_mode_func_get(struct snd_kcontrol *kcontrol, static int rx_macro_vbat_bcl_gsm_mode_func_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); /* Set Vbat register configuration for GSM mode bit based on value */ if (ucontrol->value.integer.value[0]) - snd_soc_update_bits(codec, BOLERO_CDC_RX_BCL_VBAT_CFG, - 0x04, 0x04); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_BCL_VBAT_CFG, + 0x04, 0x04); else - snd_soc_update_bits(codec, BOLERO_CDC_RX_BCL_VBAT_CFG, - 0x04, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_BCL_VBAT_CFG, + 0x04, 0x00); return 0; } @@ -1783,16 +1833,17 @@ static int rx_macro_vbat_bcl_gsm_mode_func_put(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = rx_priv->is_softclip_on; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1801,16 +1852,17 @@ static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; - rx_priv->is_softclip_on = ucontrol->value.integer.value[0]; + rx_priv->is_softclip_on = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: soft clip enable = %d\n", __func__, + dev_dbg(component->dev, "%s: soft clip enable = %d\n", __func__, rx_priv->is_softclip_on); return 0; @@ -1820,108 +1872,113 @@ static int rx_macro_enable_vbat(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable clock for VBAT block */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_PATH_CTL, 0x10, 0x10); /* Enable VBAT block */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_CFG, 0x01, 0x01); /* Update interpolator with 384K path */ - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG1, - 0x80, 0x80); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_CFG1, 0x80, 0x80); /* Update DSM FS rate */ - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_SEC7, - 0x02, 0x02); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_SEC7, 0x02, 0x02); /* Use attenuation mode */ - snd_soc_update_bits(codec, BOLERO_CDC_RX_BCL_VBAT_CFG, - 0x02, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_BCL_VBAT_CFG, 0x02, 0x00); /* BCL block needs softclip clock to be enabled */ - rx_macro_enable_softclip_clk(codec, rx_priv, true); + rx_macro_enable_softclip_clk(component, rx_priv, true); /* Enable VBAT at channel level */ - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_CFG1, 0x02, 0x02); /* Set the ATTK1 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD1, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD2, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD3, 0xFF, 0x00); /* Set the ATTK2 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD4, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD5, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD6, 0xFF, 0x00); /* Set the ATTK3 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD7, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD8, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD9, 0xFF, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG1, - 0x80, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_SEC7, - 0x02, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_RX_BCL_VBAT_CFG, - 0x02, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG1, - 0x02, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_CFG1, + 0x80, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_SEC7, + 0x02, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_BCL_VBAT_CFG, + 0x02, 0x02); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_CFG1, + 0x02, 0x00); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD1, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD2, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD3, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD4, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD5, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD6, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD7, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD8, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_BCL_GAIN_UPD9, 0xFF, 0x00); - rx_macro_enable_softclip_clk(codec, rx_priv, false); - snd_soc_update_bits(codec, + rx_macro_enable_softclip_clk(component, rx_priv, false); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_CFG, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_PATH_CTL, 0x10, 0x00); break; default: @@ -1931,7 +1988,7 @@ static int rx_macro_enable_vbat(struct snd_soc_dapm_widget *w, return 0; } -static void rx_macro_idle_detect_control(struct snd_soc_codec *codec, +static void rx_macro_idle_detect_control(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, int interp, int event) { @@ -1952,16 +2009,17 @@ static void rx_macro_idle_detect_control(struct snd_soc_codec *codec, } if (reg && SND_SOC_DAPM_EVENT_ON(event)) - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); if (reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, reg, mask, 0x00); + snd_soc_component_update_bits(component, reg, mask, 0x00); rx_priv->idle_det_cfg.hph_idle_thr = 0; - snd_soc_write(codec, BOLERO_CDC_RX_IDLE_DETECT_CFG3, 0x0); + snd_soc_component_write(component, + BOLERO_CDC_RX_IDLE_DETECT_CFG3, 0x0); } } -static void rx_macro_hphdelay_lutbypass(struct snd_soc_codec *codec, +static void rx_macro_hphdelay_lutbypass(struct snd_soc_component *component, struct rx_macro_priv *rx_priv, u16 interp_idx, int event) { @@ -1984,43 +2042,48 @@ static void rx_macro_hphdelay_lutbypass(struct snd_soc_codec *codec, if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) { if (interp_idx == INTERP_HPHL) { if (rx_priv->is_ear_mode_on) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX0_RX_PATH_CFG1, 0x02, 0x02); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, hph_lut_bypass_reg, 0x80, 0x80); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, hph_lut_bypass_reg, 0x80, 0x80); } if (rx_priv->hph_pwr_mode) - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x00); + snd_soc_component_update_bits(component, + hph_comp_ctrl7, + 0x20, 0x00); } if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX0_RX_PATH_CFG1, + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX0_RX_PATH_CFG1, 0x02, 0x00); - snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x00); - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x20); + snd_soc_component_update_bits(component, hph_lut_bypass_reg, + 0x80, 0x00); + snd_soc_component_update_bits(component, hph_comp_ctrl7, + 0x20, 0x0); } } -static int rx_macro_enable_interp_clk(struct snd_soc_codec *codec, +static int rx_macro_enable_interp_clk(struct snd_soc_component *component, int event, int interp_idx) { u16 main_reg = 0, dsm_reg = 0, rx_cfg2_reg = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return -EINVAL; } - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; main_reg = BOLERO_CDC_RX_RX0_RX_PATH_CTL + @@ -2032,24 +2095,29 @@ static int rx_macro_enable_interp_clk(struct snd_soc_codec *codec, if (SND_SOC_DAPM_EVENT_ON(event)) { if (rx_priv->main_clk_users[interp_idx] == 0) { - snd_soc_update_bits(codec, dsm_reg, 0x01, 0x01); + snd_soc_component_update_bits(component, dsm_reg, + 0x01, 0x01); /* Main path PGA mute enable */ - snd_soc_update_bits(codec, main_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, main_reg, + 0x10, 0x10); /* Clk enable */ - snd_soc_update_bits(codec, main_reg, 0x20, 0x20); - snd_soc_update_bits(codec, rx_cfg2_reg, 0x03, 0x03); - rx_macro_idle_detect_control(codec, rx_priv, + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x20); + snd_soc_component_update_bits(component, rx_cfg2_reg, + 0x03, 0x03); + rx_macro_idle_detect_control(component, rx_priv, interp_idx, event); if (rx_priv->hph_hd2_mode) - rx_macro_hd2_control(codec, interp_idx, event); - rx_macro_hphdelay_lutbypass(codec, rx_priv, interp_idx, - event); - rx_macro_config_compander(codec, rx_priv, + rx_macro_hd2_control( + component, interp_idx, event); + rx_macro_hphdelay_lutbypass(component, rx_priv, + interp_idx, event); + rx_macro_config_compander(component, rx_priv, interp_idx, event); if (interp_idx == INTERP_AUX) - rx_macro_config_softclip(codec, rx_priv, + rx_macro_config_softclip(component, rx_priv, event); - rx_macro_config_classh(codec, rx_priv, + rx_macro_config_classh(component, rx_priv, interp_idx, event); } rx_priv->main_clk_users[interp_idx]++; @@ -2060,31 +2128,38 @@ static int rx_macro_enable_interp_clk(struct snd_soc_codec *codec, if (rx_priv->main_clk_users[interp_idx] <= 0) { rx_priv->main_clk_users[interp_idx] = 0; /* Clk Disable */ - snd_soc_update_bits(codec, dsm_reg, 0x01, 0x00); - snd_soc_update_bits(codec, main_reg, 0x20, 0x00); + snd_soc_component_update_bits(component, dsm_reg, + 0x01, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x00); /* Reset enable and disable */ - snd_soc_update_bits(codec, main_reg, 0x40, 0x40); - snd_soc_update_bits(codec, main_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x40); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x00); /* Reset rate to 48K*/ - snd_soc_update_bits(codec, main_reg, 0x0F, 0x04); - snd_soc_update_bits(codec, rx_cfg2_reg, 0x03, 0x00); - rx_macro_config_classh(codec, rx_priv, + snd_soc_component_update_bits(component, main_reg, + 0x0F, 0x04); + snd_soc_component_update_bits(component, rx_cfg2_reg, + 0x03, 0x00); + rx_macro_config_classh(component, rx_priv, interp_idx, event); - rx_macro_config_compander(codec, rx_priv, + rx_macro_config_compander(component, rx_priv, interp_idx, event); if (interp_idx == INTERP_AUX) - rx_macro_config_softclip(codec, rx_priv, + rx_macro_config_softclip(component, rx_priv, event); - rx_macro_hphdelay_lutbypass(codec, rx_priv, interp_idx, - event); + rx_macro_hphdelay_lutbypass(component, rx_priv, + interp_idx, event); if (rx_priv->hph_hd2_mode) - rx_macro_hd2_control(codec, interp_idx, event); - rx_macro_idle_detect_control(codec, rx_priv, + rx_macro_hd2_control(component, interp_idx, + event); + rx_macro_idle_detect_control(component, rx_priv, interp_idx, event); } } - dev_dbg(codec->dev, "%s event %d main_clk_users %d\n", + dev_dbg(component->dev, "%s event %d main_clk_users %d\n", __func__, event, rx_priv->main_clk_users[interp_idx]); return rx_priv->main_clk_users[interp_idx]; @@ -2093,21 +2168,24 @@ static int rx_macro_enable_interp_clk(struct snd_soc_codec *codec, static int rx_macro_enable_rx_path_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 sidetone_reg = 0; - dev_dbg(codec->dev, "%s %d %d\n", __func__, event, w->shift); + dev_dbg(component->dev, "%s %d %d\n", __func__, event, w->shift); sidetone_reg = BOLERO_CDC_RX_RX0_RX_PATH_CFG1 + RX_MACRO_RX_PATH_OFFSET * (w->shift); switch (event) { case SND_SOC_DAPM_PRE_PMU: - rx_macro_enable_interp_clk(codec, event, w->shift); - snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x10); + rx_macro_enable_interp_clk(component, event, w->shift); + snd_soc_component_update_bits(component, sidetone_reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x00); - rx_macro_enable_interp_clk(codec, event, w->shift); + snd_soc_component_update_bits(component, sidetone_reg, + 0x10, 0x00); + rx_macro_enable_interp_clk(component, event, w->shift); break; default: break; @@ -2150,7 +2228,8 @@ static void rx_macro_restore_iir_coeff(struct rx_macro_priv *rx_priv, int iir_id static int rx_macro_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -2158,10 +2237,11 @@ static int rx_macro_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, /* IIR filter band registers are at integer multiples of 0x80 */ u16 iir_reg = BOLERO_CDC_RX_SIDETONE_IIR0_IIR_CTL + 0x80 * iir_idx; - ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) & - (1 << band_idx)) != 0; + ucontrol->value.integer.value[0] = ( + snd_soc_component_read32(component, iir_reg) & + (1 << band_idx)) != 0; - dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; @@ -2170,7 +2250,8 @@ static int rx_macro_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, static int rx_macro_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -2181,62 +2262,62 @@ static int rx_macro_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol, struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; rx_macro_restore_iir_coeff(rx_priv, iir_idx, band_idx); /* Mask first 5 bits, 6-8 are reserved */ - snd_soc_update_bits(codec, iir_reg, (1 << band_idx), + snd_soc_component_update_bits(component, iir_reg, (1 << band_idx), (value << band_idx)); - iir_band_en_status = ((snd_soc_read(codec, iir_reg) & + iir_band_en_status = ((snd_soc_component_read32(component, iir_reg) & (1 << band_idx)) != 0); - dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, iir_band_en_status); return 0; } -static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, +static uint32_t get_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); - value |= snd_soc_read(codec, + value |= snd_soc_component_read32(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx)); - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx)) << 8); - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx)) << 16); - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ - value |= ((snd_soc_read(codec, + value |= ((snd_soc_component_read32(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24); @@ -2246,24 +2327,25 @@ static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, static int rx_macro_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = - get_iir_band_coeff(codec, iir_idx, band_idx, 0); + get_iir_band_coeff(component, iir_idx, band_idx, 0); ucontrol->value.integer.value[1] = - get_iir_band_coeff(codec, iir_idx, band_idx, 1); + get_iir_band_coeff(component, iir_idx, band_idx, 1); ucontrol->value.integer.value[2] = - get_iir_band_coeff(codec, iir_idx, band_idx, 2); + get_iir_band_coeff(component, iir_idx, band_idx, 2); ucontrol->value.integer.value[3] = - get_iir_band_coeff(codec, iir_idx, band_idx, 3); + get_iir_band_coeff(component, iir_idx, band_idx, 3); ucontrol->value.integer.value[4] = - get_iir_band_coeff(codec, iir_idx, band_idx, 4); + get_iir_band_coeff(component, iir_idx, band_idx, 4); - dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" + dev_dbg(component->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" @@ -2281,24 +2363,24 @@ static int rx_macro_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, return 0; } -static void set_iir_band_coeff(struct snd_soc_codec *codec, +static void set_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, uint32_t value) { - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx), (value & 0xFF)); - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx), (value >> 8) & 0xFF); - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 0x80 * iir_idx), (value >> 24) & 0x3F); } @@ -2306,7 +2388,8 @@ static void set_iir_band_coeff(struct snd_soc_codec *codec, static int rx_macro_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -2315,14 +2398,14 @@ static int rx_macro_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; /* * Mask top bit it is reserved * Updates addr automatically for each B2 write */ - snd_soc_write(codec, + snd_soc_component_write(component, (BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); @@ -2331,7 +2414,7 @@ static int rx_macro_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, coeff_idx++) { uint32_t value = ucontrol->value.integer.value[coeff_idx]; - set_iir_band_coeff(codec, iir_idx, band_idx, value); + set_iir_band_coeff(component, iir_idx, band_idx, value); /* Four 8 bit values(one 32 bit) per coefficient */ rx_priv->sidetone_coeff_array[iir_idx][band_idx][idx++] = @@ -2350,61 +2433,62 @@ static int rx_macro_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 0), + get_iir_band_coeff(component, iir_idx, band_idx, 0), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 1), + get_iir_band_coeff(component, iir_idx, band_idx, 1), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 2), + get_iir_band_coeff(component, iir_idx, band_idx, 2), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 3), + get_iir_band_coeff(component, iir_idx, band_idx, 3), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 4)); + get_iir_band_coeff(component, iir_idx, band_idx, 4)); return 0; } static int rx_macro_set_iir_gain(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: /* fall through */ case SND_SOC_DAPM_PRE_PMD: if (strnstr(w->name, "IIR0", sizeof("IIR0"))) { - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL)); } else { - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, BOLERO_CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL)); } break; @@ -3018,43 +3102,43 @@ exit: return ret; } -static void rx_macro_init_bcl_pmic_reg(struct snd_soc_codec *codec) +static void rx_macro_init_bcl_pmic_reg(struct snd_soc_component *component) { struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!codec) { - pr_err("%s: NULL codec pointer!\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer!\n", __func__); return; } - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return; switch (rx_priv->bcl_pmic_params.id) { case 0: /* Enable ID0 to listen to respective PMIC group interrupts */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CTL1, 0x02, 0x02); /* Update MC_SID0 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CFG1, 0x0F, rx_priv->bcl_pmic_params.sid); /* Update MC_PPID0 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CFG2, 0xFF, rx_priv->bcl_pmic_params.ppid); break; case 1: /* Enable ID1 to listen to respective PMIC group interrupts */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CTL1, 0x01, 0x01); /* Update MC_SID1 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CFG3, 0x0F, rx_priv->bcl_pmic_params.sid); /* Update MC_PPID1 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_RX_BCL_VBAT_DECODE_CFG1, 0xFF, rx_priv->bcl_pmic_params.ppid); break; @@ -3065,22 +3149,23 @@ static void rx_macro_init_bcl_pmic_reg(struct snd_soc_codec *codec) } } -static int rx_macro_init(struct snd_soc_codec *codec) +static int rx_macro_init(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int ret = 0; struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - rx_dev = bolero_get_device_ptr(codec->dev, RX_MACRO); + rx_dev = bolero_get_device_ptr(component->dev, RX_MACRO); if (!rx_dev) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", __func__); return -EINVAL; } rx_priv = dev_get_drvdata(rx_dev); if (!rx_priv) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", __func__); return -EINVAL; } @@ -3102,7 +3187,7 @@ static int rx_macro_init(struct snd_soc_codec *codec) dev_err(rx_dev, "%s: failed to add widgets\n", __func__); return ret; } - ret = snd_soc_add_codec_controls(codec, rx_macro_snd_controls, + ret = snd_soc_add_component_controls(component, rx_macro_snd_controls, ARRAY_SIZE(rx_macro_snd_controls)); if (ret < 0) { dev_err(rx_dev, "%s: failed to add snd_ctls\n", __func__); @@ -3122,31 +3207,44 @@ static int rx_macro_init(struct snd_soc_codec *codec) snd_soc_dapm_ignore_suspend(dapm, "RX_TX DEC3_INP"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX0_RX_PATH_DSM_CTL, 0x01, 0x01); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX1_RX_PATH_DSM_CTL, 0x01, 0x01); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_DSM_CTL, 0x01, 0x01); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX0_RX_PATH_SEC7, 0x07, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX1_RX_PATH_SEC7, 0x07, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_SEC7, 0x07, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX0_RX_PATH_CFG3, 0x03, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX1_RX_PATH_CFG3, 0x03, 0x02); - snd_soc_update_bits(codec, BOLERO_CDC_RX_RX2_RX_PATH_CFG3, 0x03, 0x02); - rx_macro_init_bcl_pmic_reg(codec); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX0_RX_PATH_DSM_CTL, + 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX1_RX_PATH_DSM_CTL, + 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_RX_RX2_RX_PATH_DSM_CTL, + 0x01, 0x01); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX0_RX_PATH_SEC7, + 0x07, 0x02); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX1_RX_PATH_SEC7, + 0x07, 0x02); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX2_RX_PATH_SEC7, + 0x07, 0x02); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX0_RX_PATH_CFG3, + 0x03, 0x02); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX1_RX_PATH_CFG3, + 0x03, 0x02); + snd_soc_component_update_bits(component, BOLERO_CDC_RX_RX2_RX_PATH_CFG3, + 0x03, 0x02); - rx_priv->codec = codec; + rx_macro_init_bcl_pmic_reg(component); + + rx_priv->component = component; return 0; } -static int rx_macro_deinit(struct snd_soc_codec *codec) +static int rx_macro_deinit(struct snd_soc_component *component) { struct device *rx_dev = NULL; struct rx_macro_priv *rx_priv = NULL; - if (!rx_macro_get_data(codec, &rx_dev, &rx_priv, __func__)) + if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__)) return -EINVAL; - rx_priv->codec = NULL; + rx_priv->component = NULL; return 0; } diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index 2051e5f4e8..96182d3c86 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -130,7 +130,7 @@ struct tx_macro_priv { struct clk *tx_npl_clk; struct mutex mclk_lock; struct mutex swr_clk_lock; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct device_node *tx_swr_gpio_p; struct tx_macro_swr_ctrl_data *swr_ctrl_data; struct tx_macro_swr_ctrl_platform_data swr_plat_data; @@ -150,28 +150,28 @@ struct tx_macro_priv { int child_count; }; -static bool tx_macro_get_data(struct snd_soc_codec *codec, +static bool tx_macro_get_data(struct snd_soc_component *component, struct device **tx_dev, struct tx_macro_priv **tx_priv, const char *func_name) { - *tx_dev = bolero_get_device_ptr(codec->dev, TX_MACRO); + *tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO); if (!(*tx_dev)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", func_name); return false; } *tx_priv = dev_get_drvdata((*tx_dev)); if (!(*tx_priv)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", func_name); return false; } - if (!(*tx_priv)->codec) { - dev_err(codec->dev, - "%s: tx_priv->codec not initialized!\n", func_name); + if (!(*tx_priv)->component) { + dev_err(component->dev, + "%s: tx_priv->component not initialized!\n", func_name); return false; } @@ -245,12 +245,13 @@ exit: static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; dev_dbg(tx_dev, "%s: event = %d\n", __func__, event); @@ -296,13 +297,13 @@ exit: return ret; } -static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, - u32 data) +static int tx_macro_event_handler(struct snd_soc_component *component, + u16 event, u32 data) { struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; switch (event) { @@ -323,7 +324,7 @@ static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, return 0; } -static int tx_macro_reg_wake_irq(struct snd_soc_codec *codec, +static int tx_macro_reg_wake_irq(struct snd_soc_component *component, u32 data) { struct device *tx_dev = NULL; @@ -331,7 +332,7 @@ static int tx_macro_reg_wake_irq(struct snd_soc_codec *codec, u32 ipc_wakeup = data; int ret = 0; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; ret = swrm_wcd_notify( @@ -346,7 +347,7 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) struct delayed_work *hpf_delayed_work = NULL; struct hpf_work *hpf_work = NULL; struct tx_macro_priv *tx_priv = NULL; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; u16 dec_cfg_reg = 0, hpf_gate_reg = 0; u8 hpf_cut_off_freq = 0; u16 adc_mux_reg = 0, adc_n = 0, adc_reg = 0; @@ -354,7 +355,7 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tx_priv = hpf_work->tx_priv; - codec = tx_priv->codec; + component = tx_priv->component; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 + @@ -362,34 +363,35 @@ static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 + TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator; - dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", + dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 + TX_MACRO_ADC_MUX_CFG_OFFSET * hpf_work->decimator; - if (snd_soc_read(codec, adc_mux_reg) & SWR_MIC) { + if (snd_soc_component_read32(component, adc_mux_reg) & SWR_MIC) { adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + TX_MACRO_ADC_MUX_CFG_OFFSET * hpf_work->decimator; - adc_n = snd_soc_read(codec, adc_reg) & + adc_n = snd_soc_component_read32(component, adc_reg) & TX_MACRO_SWR_MIC_MUX_SEL_MASK; if (adc_n >= BOLERO_ADC_MAX) goto tx_hpf_set; /* analog mic clear TX hold */ - bolero_clear_amic_tx_hold(codec->dev, adc_n); + bolero_clear_amic_tx_hold(component->dev, adc_n); } tx_hpf_set: - snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x02); + snd_soc_component_update_bits(component, + dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x02); /* Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x01); + snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x01); } static void tx_macro_mute_update_callback(struct work_struct *work) { struct tx_mute_work *tx_mute_dwork = NULL; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; struct tx_macro_priv *tx_priv = NULL; struct delayed_work *delayed_work = NULL; u16 tx_vol_ctl_reg = 0; @@ -398,13 +400,13 @@ static void tx_macro_mute_update_callback(struct work_struct *work) delayed_work = to_delayed_work(work); tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork); tx_priv = tx_mute_dwork->tx_priv; - codec = tx_priv->codec; + component = tx_priv->component; decimator = tx_mute_dwork->decimator; tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL + TX_MACRO_TX_PATH_OFFSET * decimator; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00); dev_dbg(tx_priv->dev, "%s: decimator %u unmute\n", __func__, decimator); } @@ -414,7 +416,8 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = 0; u16 mic_sel_reg = 0; @@ -423,7 +426,7 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, if (val > e->items - 1) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); switch (e->reg) { @@ -452,23 +455,26 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, mic_sel_reg = BOLERO_CDC_TX7_TX_PATH_CFG0; break; default: - dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n", + dev_err(component->dev, "%s: e->reg: 0x%x not expected\n", __func__, e->reg); return -EINVAL; } if (strnstr(widget->name, "SMIC", strlen(widget->name))) { if (val != 0) { if (val < 5) - snd_soc_update_bits(codec, mic_sel_reg, + snd_soc_component_update_bits(component, + mic_sel_reg, 1 << 7, 0x0 << 7); else - snd_soc_update_bits(codec, mic_sel_reg, + snd_soc_component_update_bits(component, + mic_sel_reg, 1 << 7, 0x1 << 7); } } else { /* DMIC selected */ if (val != 0) - snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, 1 << 7); + snd_soc_component_update_bits(component, mic_sel_reg, + 1 << 7, 1 << 7); } return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -479,7 +485,8 @@ static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); u32 dai_id = widget->shift; @@ -487,7 +494,7 @@ static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id])) @@ -502,7 +509,8 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct snd_soc_dapm_update *update = NULL; struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); @@ -512,7 +520,7 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; if (enable) { @@ -530,7 +538,8 @@ static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u8 dmic_clk_en = 0x01; u16 dmic_clk_reg = 0; s32 *dmic_clk_cnt = NULL; @@ -540,18 +549,18 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w, struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; wname = strpbrk(w->name, "01234567"); if (!wname) { - dev_err(codec->dev, "%s: widget not found\n", __func__); + dev_err(component->dev, "%s: widget not found\n", __func__); return -EINVAL; } ret = kstrtouint(wname, 10, &dmic); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n", + dev_err(component->dev, "%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } @@ -578,30 +587,31 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w, dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC3_CTL; break; default: - dev_err(codec->dev, "%s: Invalid DMIC Selection\n", + dev_err(component->dev, "%s: Invalid DMIC Selection\n", __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", + dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); switch (event) { case SND_SOC_DAPM_PRE_PMU: (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) { - snd_soc_update_bits(codec, BOLERO_CDC_VA_TOP_CSR_DMIC_CFG, + snd_soc_component_update_bits(component, + BOLERO_CDC_VA_TOP_CSR_DMIC_CFG, 0x80, 0x00); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, 0x0E, tx_priv->dmic_clk_div << 0x1); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, dmic_clk_en); } break; case SND_SOC_DAPM_POST_PMD: (*dmic_clk_cnt)--; if (*dmic_clk_cnt == 0) - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, 0); break; } @@ -612,7 +622,8 @@ static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w, static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); unsigned int decimator = 0; u16 tx_vol_ctl_reg = 0; u16 dec_cfg_reg = 0; @@ -622,12 +633,12 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; decimator = w->shift; - dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__, + dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__, w->name, decimator); tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL + @@ -642,21 +653,27 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable TX PGA Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, + tx_vol_ctl_reg, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x20); - snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00); + snd_soc_component_update_bits(component, + tx_vol_ctl_reg, 0x20, 0x20); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x01, 0x00); + + hpf_cut_off_freq = ( + snd_soc_component_read32(component, dec_cfg_reg) & + TX_HPF_CUT_OFF_FREQ_MASK) >> 5; - hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & - TX_HPF_CUT_OFF_FREQ_MASK) >> 5; tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq = - hpf_cut_off_freq; + hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - CF_MIN_3DB_150HZ << 5); + snd_soc_component_update_bits(component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + CF_MIN_3DB_150HZ << 5); + /* schedule work queue to Remove Mute */ schedule_delayed_work(&tx_priv->tx_mute_dwork[decimator].dwork, msecs_to_jiffies(tx_unmute_delay)); @@ -665,35 +682,42 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, schedule_delayed_work( &tx_priv->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x00); } /* apply gain after decimator is enabled */ - snd_soc_write(codec, tx_gain_ctl_reg, - snd_soc_read(codec, tx_gain_ctl_reg)); + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read32(component, + tx_gain_ctl_reg)); break; case SND_SOC_DAPM_PRE_PMD: hpf_cut_off_freq = tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, + tx_vol_ctl_reg, 0x10, 0x10); if (cancel_delayed_work_sync( &tx_priv->tx_hpf_work[decimator].dwork)) { if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, + snd_soc_component_update_bits( + component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x02); /* * Minimum 1 clk cycle delay is required * as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x00); } } @@ -701,8 +725,10 @@ static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w, &tx_priv->tx_mute_dwork[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x00); - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x20, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x00); break; } return 0; @@ -719,14 +745,14 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int tx_fs_rate = -EINVAL; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u32 decimator = 0; u32 sample_rate = 0; u16 tx_fs_reg = 0; struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, @@ -757,7 +783,7 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream, tx_fs_rate = 7; break; default: - dev_err(codec->dev, "%s: Invalid TX sample rate: %d\n", + dev_err(component->dev, "%s: Invalid TX sample rate: %d\n", __func__, params_rate(params)); return -EINVAL; } @@ -766,12 +792,12 @@ static int tx_macro_hw_params(struct snd_pcm_substream *substream, if (decimator >= 0) { tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL + TX_MACRO_TX_PATH_OFFSET * decimator; - dev_dbg(codec->dev, "%s: set DEC%u rate to %u\n", + dev_dbg(component->dev, "%s: set DEC%u rate to %u\n", __func__, decimator, sample_rate); - snd_soc_update_bits(codec, tx_fs_reg, 0x0F, - tx_fs_rate); + snd_soc_component_update_bits(component, tx_fs_reg, + 0x0F, tx_fs_rate); } else { - dev_err(codec->dev, + dev_err(component->dev, "%s: ERROR: Invalid decimator: %d\n", __func__, decimator); return -EINVAL; @@ -784,11 +810,11 @@ static int tx_macro_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; switch (dai->id) { @@ -1483,22 +1509,23 @@ undefined_rate: return dmic_sample_rate; } -static int tx_macro_init(struct snd_soc_codec *codec) +static int tx_macro_init(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int ret = 0, i = 0; struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - tx_dev = bolero_get_device_ptr(codec->dev, TX_MACRO); + tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO); if (!tx_dev) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", __func__); return -EINVAL; } tx_priv = dev_get_drvdata(tx_dev); if (!tx_priv) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", __func__); return -EINVAL; } @@ -1522,7 +1549,7 @@ static int tx_macro_init(struct snd_soc_codec *codec) return ret; } - ret = snd_soc_add_codec_controls(codec, tx_macro_snd_controls, + ret = snd_soc_add_component_controls(component, tx_macro_snd_controls, ARRAY_SIZE(tx_macro_snd_controls)); if (ret < 0) { dev_err(tx_dev, "%s: Failed to add snd_ctls\n", __func__); @@ -1558,20 +1585,20 @@ static int tx_macro_init(struct snd_soc_codec *codec) INIT_DELAYED_WORK(&tx_priv->tx_mute_dwork[i].dwork, tx_macro_mute_update_callback); } - tx_priv->codec = codec; + tx_priv->component = component; return 0; } -static int tx_macro_deinit(struct snd_soc_codec *codec) +static int tx_macro_deinit(struct snd_soc_component *component) { struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; - if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) + if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__)) return -EINVAL; - tx_priv->codec = NULL; + tx_priv->component = NULL; return 0; } diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c index ed052ae58a..985424a5b6 100644 --- a/asoc/codecs/bolero/va-macro.c +++ b/asoc/codecs/bolero/va-macro.c @@ -95,7 +95,7 @@ struct va_macro_priv { bool va_without_decimation; struct clk *va_core_clk; struct mutex mclk_lock; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct hpf_work va_hpf_work[VA_MACRO_NUM_DECIMATORS]; struct va_mute_work va_mute_dwork[VA_MACRO_NUM_DECIMATORS]; unsigned long active_ch_mask[VA_MACRO_MAX_DAIS]; @@ -113,20 +113,20 @@ struct va_macro_priv { int micb_users; }; -static bool va_macro_get_data(struct snd_soc_codec *codec, +static bool va_macro_get_data(struct snd_soc_component *component, struct device **va_dev, struct va_macro_priv **va_priv, const char *func_name) { - *va_dev = bolero_get_device_ptr(codec->dev, VA_MACRO); + *va_dev = bolero_get_device_ptr(component->dev, VA_MACRO); if (!(*va_dev)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", func_name); return false; } *va_priv = dev_get_drvdata((*va_dev)); - if (!(*va_priv) || !(*va_priv)->codec) { - dev_err(codec->dev, + if (!(*va_priv) || !(*va_priv)->component) { + dev_err(component->dev, "%s: priv is null for macro!\n", func_name); return false; } @@ -200,14 +200,14 @@ exit: return ret; } -static int va_macro_event_handler(struct snd_soc_codec *codec, u16 event, - u32 data) +static int va_macro_event_handler(struct snd_soc_component *component, + u16 event, u32 data) { struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; int retry_cnt = MAX_RETRY_ATTEMPTS; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; switch (event) { @@ -237,12 +237,13 @@ static int va_macro_event_handler(struct snd_soc_codec *codec, u16 event, static int va_macro_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; dev_dbg(va_dev, "%s: event = %d\n", __func__, event); @@ -285,14 +286,14 @@ static void va_macro_tx_hpf_corner_freq_callback(struct work_struct *work) struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct va_macro_priv *va_priv; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 dec_cfg_reg, hpf_gate_reg; u8 hpf_cut_off_freq; hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); va_priv = hpf_work->va_priv; - codec = va_priv->codec; + component = va_priv->component; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = BOLERO_CDC_VA_TX0_TX_PATH_CFG0 + @@ -303,18 +304,19 @@ static void va_macro_tx_hpf_corner_freq_callback(struct work_struct *work) dev_dbg(va_priv->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); - snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x02); + snd_soc_component_update_bits(component, + dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x02); /* Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x03, 0x01); + snd_soc_component_update_bits(component, hpf_gate_reg, 0x03, 0x01); } static void va_macro_mute_update_callback(struct work_struct *work) { struct va_mute_work *va_mute_dwork; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; struct va_macro_priv *va_priv; struct delayed_work *delayed_work; u16 tx_vol_ctl_reg, decimator; @@ -322,13 +324,13 @@ static void va_macro_mute_update_callback(struct work_struct *work) delayed_work = to_delayed_work(work); va_mute_dwork = container_of(delayed_work, struct va_mute_work, dwork); va_priv = va_mute_dwork->va_priv; - codec = va_priv->codec; + component = va_priv->component; decimator = va_mute_dwork->decimator; tx_vol_ctl_reg = BOLERO_CDC_VA_TX0_TX_PATH_CTL + VA_MACRO_TX_PATH_OFFSET * decimator; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00); dev_dbg(va_priv->dev, "%s: decimator %u unmute\n", __func__, decimator); } @@ -338,7 +340,8 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; u16 mic_sel_reg; @@ -347,7 +350,7 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, if (val > e->items - 1) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); switch (e->reg) { @@ -376,13 +379,14 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol, mic_sel_reg = BOLERO_CDC_VA_TX7_TX_PATH_CFG0; break; default: - dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n", + dev_err(component->dev, "%s: e->reg: 0x%x not expected\n", __func__, e->reg); return -EINVAL; } /* DMIC selected */ if (val != 0) - snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, 1 << 7); + snd_soc_component_update_bits(component, mic_sel_reg, + 1 << 7, 1 << 7); return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); } @@ -392,7 +396,8 @@ static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); u32 dai_id = widget->shift; @@ -400,7 +405,7 @@ static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol, struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; if (test_bit(dec_id, &va_priv->active_ch_mask[dai_id])) @@ -415,7 +420,8 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct snd_soc_dapm_update *update = NULL; struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); @@ -425,7 +431,7 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; if (enable) { @@ -444,7 +450,8 @@ static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol, static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u8 dmic_clk_en = 0x01; u16 dmic_clk_reg; s32 *dmic_clk_cnt; @@ -454,7 +461,7 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w, struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; wname = strpbrk(w->name, "01234567"); @@ -503,21 +510,21 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_VA_TOP_CSR_DMIC_CFG, 0x80, 0x00); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, VA_MACRO_TX_DMIC_CLK_DIV_MASK, va_priv->dmic_clk_div << VA_MACRO_TX_DMIC_CLK_DIV_SHFT); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, dmic_clk_en); } break; case SND_SOC_DAPM_POST_PMD: (*dmic_clk_cnt)--; if (*dmic_clk_cnt == 0) { - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, 0); } break; @@ -529,7 +536,8 @@ static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w, static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); unsigned int decimator; u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg; u16 tx_gain_ctl_reg; @@ -537,7 +545,7 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; decimator = w->shift; @@ -557,28 +565,34 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable TX PGA Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, + tx_vol_ctl_reg, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: /* Enable TX CLK */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x20); - snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00); + snd_soc_component_update_bits(component, + tx_vol_ctl_reg, 0x20, 0x20); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x01, 0x00); - hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & + hpf_cut_off_freq = (snd_soc_component_read32( + component, dec_cfg_reg) & TX_HPF_CUT_OFF_FREQ_MASK) >> 5; va_priv->va_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, + hpf_gate_reg, 0x02, 0x00); } /* schedule work queue to Remove Mute */ schedule_delayed_work(&va_priv->va_mute_dwork[decimator].dwork, @@ -589,28 +603,32 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, &va_priv->va_hpf_work[decimator].dwork, msecs_to_jiffies(300)); /* apply gain after decimator is enabled */ - snd_soc_write(codec, tx_gain_ctl_reg, - snd_soc_read(codec, tx_gain_ctl_reg)); + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read32(component, tx_gain_ctl_reg)); break; case SND_SOC_DAPM_PRE_PMD: hpf_cut_off_freq = va_priv->va_hpf_work[decimator].hpf_cut_off_freq; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); if (cancel_delayed_work_sync( &va_priv->va_hpf_work[decimator].dwork)) { if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x02); + snd_soc_component_update_bits(component, + dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, + hpf_gate_reg, + 0x02, 0x02); /* * Minimum 1 clk cycle delay is required * as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x00); + snd_soc_component_update_bits(component, + hpf_gate_reg, + 0x02, 0x00); } } cancel_delayed_work_sync( @@ -618,8 +636,10 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: /* Disable TX CLK */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x20, 0x00); - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x20, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x00); break; } return 0; @@ -628,12 +648,13 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w, static int va_macro_enable_micbias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; int ret = 0; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; if (!va_priv->micb_supply) { @@ -695,13 +716,13 @@ static int va_macro_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int tx_fs_rate = -EINVAL; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u32 decimator, sample_rate; u16 tx_fs_reg = 0; struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; dev_dbg(va_dev, @@ -744,8 +765,8 @@ static int va_macro_hw_params(struct snd_pcm_substream *substream, VA_MACRO_TX_PATH_OFFSET * decimator; dev_dbg(va_dev, "%s: set DEC%u rate to %u\n", __func__, decimator, sample_rate); - snd_soc_update_bits(codec, tx_fs_reg, 0x0F, - tx_fs_rate); + snd_soc_component_update_bits(component, tx_fs_reg, + 0x0F, tx_fs_rate); } else { dev_err(va_dev, "%s: ERROR: Invalid decimator: %d\n", @@ -760,11 +781,11 @@ static int va_macro_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; switch (dai->id) { @@ -1393,22 +1414,23 @@ undefined_rate: return dmic_sample_rate; } -static int va_macro_init(struct snd_soc_codec *codec) +static int va_macro_init(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int ret, i; struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - va_dev = bolero_get_device_ptr(codec->dev, VA_MACRO); + va_dev = bolero_get_device_ptr(component->dev, VA_MACRO); if (!va_dev) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", __func__); return -EINVAL; } va_priv = dev_get_drvdata(va_dev); if (!va_priv) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", __func__); return -EINVAL; } @@ -1422,7 +1444,7 @@ static int va_macro_init(struct snd_soc_codec *codec) __func__); return ret; } - va_priv->codec = codec; + va_priv->component = component; return 0; } @@ -1445,7 +1467,7 @@ static int va_macro_init(struct snd_soc_codec *codec) dev_err(va_dev, "%s: Failed to add widgets\n", __func__); return ret; } - ret = snd_soc_add_codec_controls(codec, va_macro_snd_controls, + ret = snd_soc_add_component_controls(component, va_macro_snd_controls, ARRAY_SIZE(va_macro_snd_controls)); if (ret < 0) { dev_err(va_dev, "%s: Failed to add snd_ctls\n", __func__); @@ -1481,20 +1503,20 @@ static int va_macro_init(struct snd_soc_codec *codec) INIT_DELAYED_WORK(&va_priv->va_mute_dwork[i].dwork, va_macro_mute_update_callback); } - va_priv->codec = codec; + va_priv->component = component; return 0; } -static int va_macro_deinit(struct snd_soc_codec *codec) +static int va_macro_deinit(struct snd_soc_component *component) { struct device *va_dev = NULL; struct va_macro_priv *va_priv = NULL; - if (!va_macro_get_data(codec, &va_dev, &va_priv, __func__)) + if (!va_macro_get_data(component, &va_dev, &va_priv, __func__)) return -EINVAL; - va_priv->codec = NULL; + va_priv->component = NULL; return 0; } diff --git a/asoc/codecs/bolero/wsa-macro.c b/asoc/codecs/bolero/wsa-macro.c index 823954e410..9586770f77 100644 --- a/asoc/codecs/bolero/wsa-macro.c +++ b/asoc/codecs/bolero/wsa-macro.c @@ -173,7 +173,7 @@ enum { * @wsa_swr_gpio_p: used by pinctrl API * @wsa_core_clk: MCLK for wsa macro * @wsa_npl_clk: NPL clock for WSA soundwire - * @codec: codec handle + * @component: codec handle * @rx_0_count: RX0 interpolation users * @rx_1_count: RX1 interpolation users * @active_ch_mask: channel mask for all AIF DAIs @@ -197,7 +197,7 @@ struct wsa_macro_priv { struct device_node *wsa_swr_gpio_p; struct clk *wsa_core_clk; struct clk *wsa_npl_clk; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int rx_0_count; int rx_1_count; unsigned long active_ch_mask[WSA_MACRO_MAX_DAIS]; @@ -215,7 +215,7 @@ struct wsa_macro_priv { struct wsa_macro_bcl_pmic_params bcl_pmic_params; }; -static int wsa_macro_config_ear_spkr_gain(struct snd_soc_codec *codec, +static int wsa_macro_config_ear_spkr_gain(struct snd_soc_component *component, struct wsa_macro_priv *wsa_priv, int event, int gain_reg); static struct snd_soc_dai_driver wsa_macro_dai[]; @@ -429,20 +429,20 @@ static const struct wsa_macro_reg_mask_val wsa_macro_spkr_mode1[] = { {BOLERO_CDC_WSA_BOOST1_BOOST_CTL, 0x7C, 0x44}, }; -static bool wsa_macro_get_data(struct snd_soc_codec *codec, +static bool wsa_macro_get_data(struct snd_soc_component *component, struct device **wsa_dev, struct wsa_macro_priv **wsa_priv, const char *func_name) { - *wsa_dev = bolero_get_device_ptr(codec->dev, WSA_MACRO); + *wsa_dev = bolero_get_device_ptr(component->dev, WSA_MACRO); if (!(*wsa_dev)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", func_name); return false; } *wsa_priv = dev_get_drvdata((*wsa_dev)); - if (!(*wsa_priv) || !(*wsa_priv)->codec) { - dev_err(codec->dev, + if (!(*wsa_priv) || !(*wsa_priv)->component) { + dev_err(component->dev, "%s: priv is null for macro!\n", func_name); return false; } @@ -453,22 +453,23 @@ static bool wsa_macro_get_data(struct snd_soc_codec *codec, * wsa_macro_set_spkr_gain_offset - offset the speaker path * gain with the given offset value. * - * @codec: codec instance + * @component: codec instance * @offset: Indicates speaker path gain offset value. * * Returns 0 on success or -EINVAL on error. */ -int wsa_macro_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset) +int wsa_macro_set_spkr_gain_offset(struct snd_soc_component *component, + int offset) { struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!codec) { - pr_err("%s: NULL codec pointer!\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer!\n", __func__); return -EINVAL; } - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; wsa_priv->spkr_gain_offset = offset; @@ -480,12 +481,12 @@ EXPORT_SYMBOL(wsa_macro_set_spkr_gain_offset); * wsa_macro_set_spkr_mode - Configures speaker compander and smartboost * settings based on speaker mode. * - * @codec: codec instance + * @component: codec instance * @mode: Indicates speaker configuration mode. * * Returns 0 on success or -EINVAL on error. */ -int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode) +int wsa_macro_set_spkr_mode(struct snd_soc_component *component, int mode) { int i; const struct wsa_macro_reg_mask_val *regs; @@ -493,12 +494,12 @@ int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode) struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!codec) { + if (!component) { pr_err("%s: NULL codec pointer!\n", __func__); return -EINVAL; } - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; switch (mode) { @@ -514,7 +515,7 @@ int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode) wsa_priv->spkr_mode = mode; for (i = 0; i < size; i++) - snd_soc_update_bits(codec, regs[i].reg, + snd_soc_component_update_bits(component, regs[i].reg, regs[i].mask, regs[i].val); return 0; } @@ -530,11 +531,11 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, u16 int_fs_reg; u8 int_mux_cfg0_val, int_mux_cfg1_val; u8 inp0_sel, inp1_sel, inp2_sel; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; for_each_set_bit(port, &wsa_priv->active_ch_mask[dai->id], @@ -558,8 +559,10 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, for (j = 0; j < NUM_INTERPOLATORS; j++) { int_mux_cfg1 = int_mux_cfg0 + WSA_MACRO_MUX_CFG1_OFFSET; - int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1); + int_mux_cfg0_val = snd_soc_component_read32(component, + int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read32(component, + int_mux_cfg1); inp0_sel = int_mux_cfg0_val & WSA_MACRO_MUX_INP_MASK1; inp1_sel = (int_mux_cfg0_val >> WSA_MACRO_MUX_INP_SHFT) & @@ -579,7 +582,8 @@ static int wsa_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai, "%s: set INT%u_1 sample rate to %u\n", __func__, j, sample_rate); /* sample_rate is in Hz */ - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits(component, + int_fs_reg, WSA_MACRO_FS_RATE_MASK, int_prim_fs_rate_reg_val); } @@ -598,11 +602,11 @@ static int wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, u32 j, port; u16 int_mux_cfg1, int_fs_reg; u8 int_mux_cfg1_val; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; @@ -619,7 +623,8 @@ static int wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_mux_cfg1 = BOLERO_CDC_WSA_RX_INP_MUX_RX_INT0_CFG1; for (j = 0; j < NUM_INTERPOLATORS; j++) { - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) & + int_mux_cfg1_val = snd_soc_component_read32(component, + int_mux_cfg1) & WSA_MACRO_MUX_INP_MASK1; if (int_mux_cfg1_val == int_2_inp) { int_fs_reg = @@ -632,7 +637,8 @@ static int wsa_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai, dev_dbg(wsa_dev, "%s: set INT%u_2 sample rate to %u\n", __func__, j, sample_rate); - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits(component, + int_fs_reg, WSA_MACRO_FS_RATE_MASK, int_mix_fs_rate_reg_val); } @@ -684,10 +690,10 @@ static int wsa_macro_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int ret; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), params_channels(params)); @@ -696,7 +702,7 @@ static int wsa_macro_hw_params(struct snd_pcm_substream *substream, case SNDRV_PCM_STREAM_PLAYBACK: ret = wsa_macro_set_interpolator_rate(dai, params_rate(params)); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "%s: cannot set sample rate: %u\n", __func__, params_rate(params)); return ret; @@ -713,11 +719,11 @@ static int wsa_macro_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; wsa_priv = dev_get_drvdata(wsa_dev); @@ -809,12 +815,13 @@ exit: static int wsa_macro_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; dev_dbg(wsa_dev, "%s: event = %d\n", __func__, event); @@ -862,13 +869,13 @@ exit: return ret; } -static int wsa_macro_event_handler(struct snd_soc_codec *codec, u16 event, - u32 data) +static int wsa_macro_event_handler(struct snd_soc_component *component, + u16 event, u32 data) { struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; switch (event) { @@ -893,11 +900,12 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; switch (event) { @@ -906,28 +914,28 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, &wsa_priv->active_ch_mask[WSA_MACRO_AIF_VI])) { dev_dbg(wsa_dev, "%s: spkr1 enabled\n", __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x20, 0x00); } @@ -935,28 +943,28 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, &wsa_priv->active_ch_mask[WSA_MACRO_AIF_VI])) { dev_dbg(wsa_dev, "%s: spkr2 enabled\n", __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x20, 0x00); } @@ -965,17 +973,17 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, if (test_bit(WSA_MACRO_TX0, &wsa_priv->active_ch_mask[WSA_MACRO_AIF_VI])) { /* Disable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x20, 0x20); dev_dbg(wsa_dev, "%s: spkr1 disabled\n", __func__); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX0_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX1_SPKR_PROT_PATH_CTL, 0x10, 0x00); } @@ -983,16 +991,16 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, &wsa_priv->active_ch_mask[WSA_MACRO_AIF_VI])) { /* Disable V&I sensing */ dev_dbg(wsa_dev, "%s: spkr2 disabled\n", __func__); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX2_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_TX3_SPKR_PROT_PATH_CTL, 0x10, 0x00); } @@ -1005,12 +1013,13 @@ static int wsa_macro_enable_vi_feedback(struct snd_soc_dapm_widget *w, static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg; int offset_val = 0; int val = 0; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); switch (w->reg) { case BOLERO_CDC_WSA_RX0_RX_PATH_MIX_CTL: @@ -1020,16 +1029,16 @@ static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w, gain_reg = BOLERO_CDC_WSA_RX1_RX_VOL_MIX_CTL; break; default: - dev_err(codec->dev, "%s: No gain register avail for %s\n", + dev_err(component->dev, "%s: No gain register avail for %s\n", __func__, w->name); return 0; } switch (event) { case SND_SOC_DAPM_POST_PMU: - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); break; case SND_SOC_DAPM_POST_PMD: break; @@ -1038,7 +1047,7 @@ static int wsa_macro_enable_mix_path(struct snd_soc_dapm_widget *w, return 0; } -static void wsa_macro_hd2_control(struct snd_soc_codec *codec, +static void wsa_macro_hd2_control(struct snd_soc_component *component, u16 reg, int event) { u16 hd2_scale_reg; @@ -1054,27 +1063,34 @@ static void wsa_macro_hd2_control(struct snd_soc_codec *codec, } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10); - snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01); - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x10); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x03, 0x01); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x04); } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x03, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x00); } } static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ch_cnt; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; switch (event) { @@ -1114,17 +1130,17 @@ static int wsa_macro_enable_swr(struct snd_soc_dapm_widget *w, return 0; } -static int wsa_macro_config_compander(struct snd_soc_codec *codec, +static int wsa_macro_config_compander(struct snd_soc_component *component, int comp, int event) { u16 comp_ctl0_reg, rx_path_cfg0_reg; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n", __func__, event, comp + 1, wsa_priv->comp_enabled[comp]); if (!wsa_priv->comp_enabled[comp]) @@ -1137,25 +1153,35 @@ static int wsa_macro_config_compander(struct snd_soc_codec *codec, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Compander Clock */ - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x02); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x04); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x00); } return 0; } -static void wsa_macro_enable_softclip_clk(struct snd_soc_codec *codec, +static void wsa_macro_enable_softclip_clk(struct snd_soc_component *component, struct wsa_macro_priv *wsa_priv, int path, bool enable) @@ -1165,13 +1191,13 @@ static void wsa_macro_enable_softclip_clk(struct snd_soc_codec *codec, u8 softclip_mux_mask = (1 << path); u8 softclip_mux_value = (1 << path); - dev_dbg(codec->dev, "%s: path %d, enable %d\n", + dev_dbg(component->dev, "%s: path %d, enable %d\n", __func__, path, enable); if (enable) { if (wsa_priv->softclip_clk_users[path] == 0) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, softclip_clk_reg, 0x01, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_RX_INP_MUX_SOFTCLIP_CFG0, softclip_mux_mask, softclip_mux_value); } @@ -1179,16 +1205,16 @@ static void wsa_macro_enable_softclip_clk(struct snd_soc_codec *codec, } else { wsa_priv->softclip_clk_users[path]--; if (wsa_priv->softclip_clk_users[path] == 0) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, softclip_clk_reg, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_RX_INP_MUX_SOFTCLIP_CFG0, softclip_mux_mask, 0x00); } } } -static int wsa_macro_config_softclip(struct snd_soc_codec *codec, +static int wsa_macro_config_softclip(struct snd_soc_component *component, int path, int event) { u16 softclip_ctrl_reg = 0; @@ -1196,7 +1222,7 @@ static int wsa_macro_config_softclip(struct snd_soc_codec *codec, struct wsa_macro_priv *wsa_priv = NULL; int softclip_path = 0; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; if (path == WSA_MACRO_COMP1) @@ -1204,7 +1230,7 @@ static int wsa_macro_config_softclip(struct snd_soc_codec *codec, else if (path == WSA_MACRO_COMP2) softclip_path = WSA_MACRO_SOFTCLIP1; - dev_dbg(codec->dev, "%s: event %d path %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d path %d, enabled %d\n", __func__, event, softclip_path, wsa_priv->is_softclip_on[softclip_path]); @@ -1216,16 +1242,18 @@ static int wsa_macro_config_softclip(struct snd_soc_codec *codec, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Softclip clock and mux */ - wsa_macro_enable_softclip_clk(codec, wsa_priv, softclip_path, - true); + wsa_macro_enable_softclip_clk(component, wsa_priv, + softclip_path, true); /* Enable Softclip control */ - snd_soc_update_bits(codec, softclip_ctrl_reg, 0x01, 0x01); + snd_soc_component_update_bits(component, softclip_ctrl_reg, + 0x01, 0x01); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, softclip_ctrl_reg, 0x01, 0x00); - wsa_macro_enable_softclip_clk(codec, wsa_priv, softclip_path, - false); + snd_soc_component_update_bits(component, softclip_ctrl_reg, + 0x01, 0x00); + wsa_macro_enable_softclip_clk(component, wsa_priv, + softclip_path, false); } return 0; @@ -1252,7 +1280,7 @@ static int wsa_macro_interp_get_primary_reg(u16 reg, u16 *ind) } static int wsa_macro_enable_prim_interpolator( - struct snd_soc_codec *codec, + struct snd_soc_component *component, u16 reg, int event) { u16 prim_int_reg; @@ -1260,7 +1288,7 @@ static int wsa_macro_enable_prim_interpolator( struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; prim_int_reg = wsa_macro_interp_get_primary_reg(reg, &ind); @@ -1269,37 +1297,39 @@ static int wsa_macro_enable_prim_interpolator( case SND_SOC_DAPM_PRE_PMU: wsa_priv->prim_int_users[ind]++; if (wsa_priv->prim_int_users[ind] == 1) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, prim_int_reg + WSA_MACRO_RX_PATH_CFG3_OFFSET, 0x03, 0x03); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x10, 0x10); - wsa_macro_hd2_control(codec, prim_int_reg, event); - snd_soc_update_bits(codec, + wsa_macro_hd2_control(component, prim_int_reg, event); + snd_soc_component_update_bits(component, prim_int_reg + WSA_MACRO_RX_PATH_DSMDEM_OFFSET, 0x1, 0x1); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 1 << 0x5, 1 << 0x5); } if ((reg != prim_int_reg) && - ((snd_soc_read(codec, prim_int_reg)) & 0x10)) - snd_soc_update_bits(codec, reg, 0x10, 0x10); + ((snd_soc_component_read32( + component, prim_int_reg)) & 0x10)) + snd_soc_component_update_bits(component, reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: wsa_priv->prim_int_users[ind]--; if (wsa_priv->prim_int_users[ind] == 0) { - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 1 << 0x5, 0 << 0x5); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x40, 0x40); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x40, 0x00); - wsa_macro_hd2_control(codec, prim_int_reg, event); + wsa_macro_hd2_control(component, prim_int_reg, event); } break; } - dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n", + dev_dbg(component->dev, "%s: primary interpolator: INT%d, users: %d\n", __func__, ind, wsa_priv->prim_int_users[ind]); return 0; } @@ -1308,7 +1338,8 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 gain_reg; u16 reg; int val; @@ -1316,10 +1347,10 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); if (!(strcmp(w->name, "WSA_RX INT0 INTERP"))) { reg = BOLERO_CDC_WSA_RX0_RX_PATH_CTL; @@ -1328,7 +1359,7 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, reg = BOLERO_CDC_WSA_RX1_RX_PATH_CTL; gain_reg = BOLERO_CDC_WSA_RX1_RX_VOL_CTL; } else { - dev_err(codec->dev, "%s: Interpolator reg not found\n", + dev_err(component->dev, "%s: Interpolator reg not found\n", __func__); return -EINVAL; } @@ -1336,11 +1367,11 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Reset if needed */ - wsa_macro_enable_prim_interpolator(codec, reg, event); + wsa_macro_enable_prim_interpolator(component, reg, event); break; case SND_SOC_DAPM_POST_PMU: - wsa_macro_config_compander(codec, w->shift, event); - wsa_macro_config_softclip(codec, w->shift, event); + wsa_macro_config_compander(component, w->shift, event); + wsa_macro_config_softclip(component, w->shift, event); /* apply gain after int clk is enabled */ if ((wsa_priv->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && @@ -1348,50 +1379,54 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, wsa_priv->comp_enabled[WSA_MACRO_COMP2]) && (gain_reg == BOLERO_CDC_WSA_RX0_RX_VOL_CTL || gain_reg == BOLERO_CDC_WSA_RX1_RX_VOL_CTL)) { - snd_soc_update_bits(codec, BOLERO_CDC_WSA_RX0_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - BOLERO_CDC_WSA_RX0_RX_PATH_MIX_SEC0, - 0x01, 0x01); - snd_soc_update_bits(codec, BOLERO_CDC_WSA_RX1_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - BOLERO_CDC_WSA_RX1_RX_PATH_MIX_SEC0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX0_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX0_RX_PATH_MIX_SEC0, + 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX1_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX1_RX_PATH_MIX_SEC0, + 0x01, 0x01); offset_val = -2; } - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); - wsa_macro_config_ear_spkr_gain(codec, wsa_priv, + snd_soc_component_write(component, gain_reg, val); + wsa_macro_config_ear_spkr_gain(component, wsa_priv, event, gain_reg); break; case SND_SOC_DAPM_POST_PMD: - wsa_macro_config_compander(codec, w->shift, event); - wsa_macro_config_softclip(codec, w->shift, event); - wsa_macro_enable_prim_interpolator(codec, reg, event); + wsa_macro_config_compander(component, w->shift, event); + wsa_macro_config_softclip(component, w->shift, event); + wsa_macro_enable_prim_interpolator(component, reg, event); if ((wsa_priv->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && (wsa_priv->comp_enabled[WSA_MACRO_COMP1] || wsa_priv->comp_enabled[WSA_MACRO_COMP2]) && (gain_reg == BOLERO_CDC_WSA_RX0_RX_VOL_CTL || gain_reg == BOLERO_CDC_WSA_RX1_RX_VOL_CTL)) { - snd_soc_update_bits(codec, BOLERO_CDC_WSA_RX0_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - BOLERO_CDC_WSA_RX0_RX_PATH_MIX_SEC0, - 0x01, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_WSA_RX1_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - BOLERO_CDC_WSA_RX1_RX_PATH_MIX_SEC0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX0_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX0_RX_PATH_MIX_SEC0, + 0x01, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX1_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_RX1_RX_PATH_MIX_SEC0, + 0x01, 0x00); offset_val = 2; - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); } - wsa_macro_config_ear_spkr_gain(codec, wsa_priv, + wsa_macro_config_ear_spkr_gain(component, wsa_priv, event, gain_reg); break; } @@ -1399,7 +1434,7 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w, return 0; } -static int wsa_macro_config_ear_spkr_gain(struct snd_soc_codec *codec, +static int wsa_macro_config_ear_spkr_gain(struct snd_soc_component *component, struct wsa_macro_priv *wsa_priv, int event, int gain_reg) { @@ -1424,7 +1459,7 @@ static int wsa_macro_config_ear_spkr_gain(struct snd_soc_codec *codec, (wsa_priv->ear_spkr_gain != 0)) { /* For example, val is -8(-12+5-1) for 4dB of gain */ val = comp_gain_offset + wsa_priv->ear_spkr_gain - 1; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); dev_dbg(wsa_priv->dev, "%s: RX0 Volume %d dB\n", __func__, val); @@ -1438,7 +1473,7 @@ static int wsa_macro_config_ear_spkr_gain(struct snd_soc_codec *codec, if (wsa_priv->comp_enabled[WSA_MACRO_COMP1] && (gain_reg == BOLERO_CDC_WSA_RX0_RX_VOL_CTL) && (wsa_priv->ear_spkr_gain != 0)) { - snd_soc_write(codec, gain_reg, 0x0); + snd_soc_component_write(component, gain_reg, 0x0); dev_dbg(wsa_priv->dev, "%s: Reset RX0 Volume to 0 dB\n", __func__); @@ -1453,11 +1488,12 @@ static int wsa_macro_spk_boost_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 boost_path_ctl, boost_path_cfg1; u16 reg, reg_mix; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (!strcmp(w->name, "WSA_RX INT0 CHAIN")) { boost_path_ctl = BOLERO_CDC_WSA_BOOST0_BOOST_PATH_CTL; @@ -1470,24 +1506,29 @@ static int wsa_macro_spk_boost_event(struct snd_soc_dapm_widget *w, reg = BOLERO_CDC_WSA_RX1_RX_PATH_CTL; reg_mix = BOLERO_CDC_WSA_RX1_RX_PATH_MIX_CTL; } else { - dev_err(codec->dev, "%s: unknown widget: %s\n", + dev_err(component->dev, "%s: unknown widget: %s\n", __func__, w->name); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01); - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10); - if ((snd_soc_read(codec, reg_mix)) & 0x10) - snd_soc_update_bits(codec, reg_mix, 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x01); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x10); + if ((snd_soc_component_read32(component, reg_mix)) & 0x10) + snd_soc_component_update_bits(component, reg_mix, + 0x10, 0x00); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, reg, 0x10, 0x00); + snd_soc_component_update_bits(component, reg, 0x10, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00); - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x00); break; } @@ -1499,16 +1540,17 @@ static int wsa_macro_enable_vbat(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; u16 vbat_path_cfg = 0; int softclip_path = 0; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (!strcmp(w->name, "WSA_RX INT0 VBAT")) { vbat_path_cfg = BOLERO_CDC_WSA_RX0_RX_PATH_CFG1; softclip_path = WSA_MACRO_SOFTCLIP0; @@ -1520,92 +1562,97 @@ static int wsa_macro_enable_vbat(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable clock for VBAT block */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_PATH_CTL, 0x10, 0x10); /* Enable VBAT block */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, 0x01, 0x01); /* Update interpolator with 384K path */ - snd_soc_update_bits(codec, vbat_path_cfg, 0x80, 0x80); + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x80, 0x80); /* Use attenuation mode */ - snd_soc_update_bits(codec, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, - 0x02, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, 0x02, 0x00); /* * BCL block needs softclip clock and mux config to be enabled */ - wsa_macro_enable_softclip_clk(codec, wsa_priv, softclip_path, - true); + wsa_macro_enable_softclip_clk(component, wsa_priv, + softclip_path, true); /* Enable VBAT at channel level */ - snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02); + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x02, 0x02); /* Set the ATTK1 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD1, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD2, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD3, 0xFF, 0x00); /* Set the ATTK2 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD4, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD5, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD6, 0xFF, 0x00); /* Set the ATTK3 gain */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD7, 0xFF, 0xFF); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD8, 0xFF, 0x03); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD9, 0xFF, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, vbat_path_cfg, 0x80, 0x00); - snd_soc_update_bits(codec, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, - 0x02, 0x02); - snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x80, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, + 0x02, 0x02); + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x02, 0x00); + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD1, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD2, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD3, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD4, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD5, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD6, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD7, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD8, 0xFF, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_BCL_GAIN_UPD9, 0xFF, 0x00); - wsa_macro_enable_softclip_clk(codec, wsa_priv, softclip_path, - false); - snd_soc_update_bits(codec, + wsa_macro_enable_softclip_clk(component, wsa_priv, + softclip_path, false); + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_PATH_CTL, 0x10, 0x00); break; default: @@ -1619,17 +1666,19 @@ static int wsa_macro_enable_echo(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; u16 val, ec_tx = 0, ec_hq_reg; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; dev_dbg(wsa_dev, "%s %d %s\n", __func__, event, w->name); - val = snd_soc_read(codec, BOLERO_CDC_WSA_RX_INP_MUX_RX_MIX_CFG0); + val = snd_soc_component_read32(component, + BOLERO_CDC_WSA_RX_INP_MUX_RX_MIX_CFG0); if (!(strcmp(w->name, "WSA RX_MIX EC0_MUX"))) ec_tx = (val & 0x07) - 1; else @@ -1641,16 +1690,16 @@ static int wsa_macro_enable_echo(struct snd_soc_dapm_widget *w, return -EINVAL; } if (wsa_priv->ec_hq[ec_tx]) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_RX_INP_MUX_RX_MIX_CFG0, 0x1 << ec_tx, 0x1 << ec_tx); ec_hq_reg = BOLERO_CDC_WSA_EC_HQ0_EC_REF_HQ_PATH_CTL + 0x20 * ec_tx; - snd_soc_update_bits(codec, ec_hq_reg, 0x01, 0x01); + snd_soc_component_update_bits(component, ec_hq_reg, 0x01, 0x01); ec_hq_reg = BOLERO_CDC_WSA_EC_HQ0_EC_REF_HQ_CFG0 + 0x20 * ec_tx; /* default set to 48k */ - snd_soc_update_bits(codec, ec_hq_reg, 0x1E, 0x08); + snd_soc_component_update_bits(component, ec_hq_reg, 0x1E, 0x08); } return 0; @@ -1660,13 +1709,14 @@ static int wsa_macro_get_ec_hq(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int ec_tx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = wsa_priv->ec_hq[ec_tx]; @@ -1676,14 +1726,15 @@ static int wsa_macro_get_ec_hq(struct snd_kcontrol *kcontrol, static int wsa_macro_set_ec_hq(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int ec_tx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; dev_dbg(wsa_dev, "%s: enable current %d, new %d\n", @@ -1697,13 +1748,14 @@ static int wsa_macro_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = wsa_priv->comp_enabled[comp]; @@ -1713,17 +1765,18 @@ static int wsa_macro_get_compander(struct snd_kcontrol *kcontrol, static int wsa_macro_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; - dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Compander %d enable current %d, new %d\n", __func__, comp + 1, wsa_priv->comp_enabled[comp], value); wsa_priv->comp_enabled[comp] = value; @@ -1733,16 +1786,17 @@ static int wsa_macro_set_compander(struct snd_kcontrol *kcontrol, static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = wsa_priv->ear_spkr_gain; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1751,16 +1805,17 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; wsa_priv->ear_spkr_gain = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: gain = %d\n", __func__, + dev_dbg(component->dev, "%s: gain = %d\n", __func__, wsa_priv->ear_spkr_gain); return 0; @@ -1770,12 +1825,14 @@ static int wsa_macro_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, BOLERO_CDC_WSA_BOOST0_BOOST_CTL); + bst_state_max = snd_soc_component_read32(component, + BOLERO_CDC_WSA_BOOST0_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1785,13 +1842,15 @@ static int wsa_macro_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, BOLERO_CDC_WSA_BOOST0_BOOST_CTL, - 0x0c, bst_state_max); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_BOOST0_BOOST_CTL, + 0x0c, bst_state_max); return 0; } @@ -1800,12 +1859,14 @@ static int wsa_macro_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, BOLERO_CDC_WSA_BOOST1_BOOST_CTL); + bst_state_max = snd_soc_component_read32(component, + BOLERO_CDC_WSA_BOOST1_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1815,13 +1876,15 @@ static int wsa_macro_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, BOLERO_CDC_WSA_BOOST1_BOOST_CTL, - 0x0c, bst_state_max); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_BOOST1_BOOST_CTL, + 0x0c, bst_state_max); return 0; } @@ -1831,11 +1894,12 @@ static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = @@ -1848,7 +1912,8 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; u32 rx_port_value = ucontrol->value.integer.value[0]; @@ -1857,7 +1922,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; aif_rst = wsa_priv->rx_port_value[widget->shift]; @@ -1899,13 +1964,15 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol, static int wsa_macro_vbat_bcl_gsm_mode_func_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); ucontrol->value.integer.value[0] = - ((snd_soc_read(codec, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG) & 0x04) ? + ((snd_soc_component_read32( + component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG) & 0x04) ? 1 : 0); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1914,18 +1981,21 @@ static int wsa_macro_vbat_bcl_gsm_mode_func_get(struct snd_kcontrol *kcontrol, static int wsa_macro_vbat_bcl_gsm_mode_func_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); /* Set Vbat register configuration for GSM mode bit based on value */ if (ucontrol->value.integer.value[0]) - snd_soc_update_bits(codec, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, - 0x04, 0x04); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, + 0x04, 0x04); else - snd_soc_update_bits(codec, BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, - 0x04, 0x00); + snd_soc_component_update_bits(component, + BOLERO_CDC_WSA_VBAT_BCL_VBAT_CFG, + 0x04, 0x00); return 0; } @@ -1933,18 +2003,19 @@ static int wsa_macro_vbat_bcl_gsm_mode_func_put(struct snd_kcontrol *kcontrol, static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; int path = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; ucontrol->value.integer.value[0] = wsa_priv->is_softclip_on[path]; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -1953,18 +2024,19 @@ static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol, static int wsa_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; int path = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; wsa_priv->is_softclip_on[path] = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: soft clip enable for %d: %d\n", __func__, + dev_dbg(component->dev, "%s: soft clip enable for %d: %d\n", __func__, path, wsa_priv->is_softclip_on[path]); return 0; @@ -2028,7 +2100,8 @@ static int wsa_macro_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); u32 dai_id = widget->shift; @@ -2036,7 +2109,7 @@ static int wsa_macro_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; if (test_bit(spk_tx_id, &wsa_priv->active_ch_mask[dai_id])) @@ -2052,7 +2125,8 @@ static int wsa_macro_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); u32 spk_tx_id = mixer->shift; @@ -2060,7 +2134,7 @@ static int wsa_macro_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; wsa_priv->vi_feed_value = ucontrol->value.integer.value[0]; @@ -2369,43 +2443,43 @@ static const struct wsa_macro_reg_mask_val wsa_macro_reg_init[] = { {BOLERO_CDC_WSA_RX1_RX_PATH_MIX_CFG, 0x01, 0x01}, }; -static void wsa_macro_init_bcl_pmic_reg(struct snd_soc_codec *codec) +static void wsa_macro_init_bcl_pmic_reg(struct snd_soc_component *component) { struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!codec) { - pr_err("%s: NULL codec pointer!\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer!\n", __func__); return; } - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return; switch (wsa_priv->bcl_pmic_params.id) { case 0: /* Enable ID0 to listen to respective PMIC group interrupts */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CTL1, 0x02, 0x02); /* Update MC_SID0 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CFG1, 0x0F, wsa_priv->bcl_pmic_params.sid); /* Update MC_PPID0 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CFG2, 0xFF, wsa_priv->bcl_pmic_params.ppid); break; case 1: /* Enable ID1 to listen to respective PMIC group interrupts */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CTL1, 0x01, 0x01); /* Update MC_SID1 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CFG3, 0x0F, wsa_priv->bcl_pmic_params.sid); /* Update MC_PPID1 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, BOLERO_CDC_WSA_VBAT_BCL_VBAT_DECODE_CFG4, 0xFF, wsa_priv->bcl_pmic_params.ppid); break; @@ -2416,17 +2490,17 @@ static void wsa_macro_init_bcl_pmic_reg(struct snd_soc_codec *codec) } } -static void wsa_macro_init_reg(struct snd_soc_codec *codec) +static void wsa_macro_init_reg(struct snd_soc_component *component) { int i; for (i = 0; i < ARRAY_SIZE(wsa_macro_reg_init); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, wsa_macro_reg_init[i].reg, wsa_macro_reg_init[i].mask, wsa_macro_reg_init[i].val); - wsa_macro_init_bcl_pmic_reg(codec); + wsa_macro_init_bcl_pmic_reg(component); } static int wsa_swrm_clock(void *handle, bool enable) @@ -2487,22 +2561,23 @@ exit: return ret; } -static int wsa_macro_init(struct snd_soc_codec *codec) +static int wsa_macro_init(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int ret; struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - wsa_dev = bolero_get_device_ptr(codec->dev, WSA_MACRO); + wsa_dev = bolero_get_device_ptr(component->dev, WSA_MACRO); if (!wsa_dev) { - dev_err(codec->dev, + dev_err(component->dev, "%s: null device for macro!\n", __func__); return -EINVAL; } wsa_priv = dev_get_drvdata(wsa_dev); if (!wsa_priv) { - dev_err(codec->dev, + dev_err(component->dev, "%s: priv is null for macro!\n", __func__); return -EINVAL; } @@ -2527,7 +2602,7 @@ static int wsa_macro_init(struct snd_soc_codec *codec) return ret; } - ret = snd_soc_add_codec_controls(codec, wsa_macro_snd_controls, + ret = snd_soc_add_component_controls(component, wsa_macro_snd_controls, ARRAY_SIZE(wsa_macro_snd_controls)); if (ret < 0) { dev_err(wsa_dev, "%s: Failed to add snd_ctls\n", __func__); @@ -2545,22 +2620,22 @@ static int wsa_macro_init(struct snd_soc_codec *codec) snd_soc_dapm_ignore_suspend(dapm, "WSA_TX DEC1_INP"); snd_soc_dapm_sync(dapm); - wsa_priv->codec = codec; + wsa_priv->component = component; wsa_priv->spkr_gain_offset = WSA_MACRO_GAIN_OFFSET_0_DB; - wsa_macro_init_reg(codec); + wsa_macro_init_reg(component); return 0; } -static int wsa_macro_deinit(struct snd_soc_codec *codec) +static int wsa_macro_deinit(struct snd_soc_component *component) { struct device *wsa_dev = NULL; struct wsa_macro_priv *wsa_priv = NULL; - if (!wsa_macro_get_data(codec, &wsa_dev, &wsa_priv, __func__)) + if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__)) return -EINVAL; - wsa_priv->codec = NULL; + wsa_priv->component = NULL; return 0; } diff --git a/asoc/codecs/bolero/wsa-macro.h b/asoc/codecs/bolero/wsa-macro.h index ec8f5249b2..f2553c02d3 100644 --- a/asoc/codecs/bolero/wsa-macro.h +++ b/asoc/codecs/bolero/wsa-macro.h @@ -21,16 +21,19 @@ enum { #if IS_ENABLED(CONFIG_WSA_MACRO) -extern int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode); -extern int wsa_macro_set_spkr_gain_offset(struct snd_soc_codec *codec, +extern int wsa_macro_set_spkr_mode(struct snd_soc_component *component, + int mode); +extern int wsa_macro_set_spkr_gain_offset(struct snd_soc_component *component, int offset); #else /* CONFIG_WSA_MACRO */ -static inline int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode) +static inline int wsa_macro_set_spkr_mode(struct snd_soc_component *component, + int mode) { return 0; } -static inline int wsa_macro_set_spkr_gain_offset(struct snd_soc_codec *codec, - int offset); +static inline int wsa_macro_set_spkr_gain_offset( + struct snd_soc_component *component, + int offset); { return 0; } diff --git a/asoc/codecs/cpe_core.h b/asoc/codecs/cpe_core.h index 989c4a9d1d..7cfbd43302 100644 --- a/asoc/codecs/cpe_core.h +++ b/asoc/codecs/cpe_core.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. */ #ifndef __CPE_CORE_H__ @@ -107,35 +107,37 @@ struct wcd_cpe_lsm_ops { u8 size, u8 *payload)); int (*lsm_dealloc_session) - (void *core_handle, struct cpe_lsm_session *); + (void *core_handle, struct cpe_lsm_session *session); int (*lsm_open_tx)(void *core_handle, - struct cpe_lsm_session *, u16, u16); + struct cpe_lsm_session *session, u16 app_id, + u16 sample_rate); int (*lsm_close_tx)(void *core_handle, - struct cpe_lsm_session *); + struct cpe_lsm_session *session); int (*lsm_shmem_alloc)(void *core_handle, - struct cpe_lsm_session *, u32 size); + struct cpe_lsm_session *session, u32 size); int (*lsm_shmem_dealloc)(void *core_handle, - struct cpe_lsm_session *); + struct cpe_lsm_session *session); int (*lsm_register_snd_model)(void *core_handle, - struct cpe_lsm_session *, - enum lsm_detection_mode, bool); + struct cpe_lsm_session *session, + enum lsm_detection_mode, + bool detect_failure); int (*lsm_deregister_snd_model)(void *core_handle, - struct cpe_lsm_session *); + struct cpe_lsm_session *session); int (*lsm_get_afe_out_port_id)(void *core_handle, struct cpe_lsm_session *session); int (*lsm_start)(void *core_handle, - struct cpe_lsm_session *); + struct cpe_lsm_session *session); int (*lsm_stop)(void *core_handle, - struct cpe_lsm_session *); + struct cpe_lsm_session *session); int (*lsm_lab_control)(void *core_handle, struct cpe_lsm_session *session, @@ -156,7 +158,7 @@ struct wcd_cpe_lsm_ops { struct lsm_params_info *p_info, void *data, uint32_t param_type); void (*lsm_get_snd_model_offset) - (void *core_handle, struct cpe_lsm_session *, + (void *core_handle, struct cpe_lsm_session *session, size_t *offset); int (*lsm_set_media_fmt_params)(void *core_handle, struct cpe_lsm_session *session, @@ -168,7 +170,7 @@ struct wcd_cpe_lsm_ops { #if IS_ENABLED(CONFIG_SND_SOC_WCD_CPE) int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops); int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops); -void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec); +void *wcd_cpe_get_core_handle(struct snd_soc_component *component); #else /* CONFIG_SND_SOC_WCD_CPE */ static inline int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops) { @@ -178,7 +180,7 @@ static inline int wcd_cpe_get_afe_ops(struct wcd_cpe_afe_ops *afe_ops) { return 0; } -static inline void *wcd_cpe_get_core_handle(struct snd_soc_codec *codec) +static inline void *wcd_cpe_get_core_handle(struct snd_soc_component *component) { return NULL; } diff --git a/asoc/codecs/csra66x0/csra66x0.c b/asoc/codecs/csra66x0/csra66x0.c index 97041a19d8..33e53340f2 100644 --- a/asoc/codecs/csra66x0/csra66x0.c +++ b/asoc/codecs/csra66x0/csra66x0.c @@ -19,6 +19,8 @@ #include #include "csra66x0.h" +#define DRV_NAME "csra66x0_codec" + /* CSRA66X0 register default values */ static struct reg_default csra66x0_reg_defaults[] = { {CSRA66X0_AUDIO_IF_RX_CONFIG1, 0x00}, @@ -247,7 +249,7 @@ static bool csra66x0_readable_registers(struct device *dev, unsigned int reg) /* codec private data */ struct csra66x0_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int spk_volume_ch1; int spk_volume_ch2; int irq; @@ -312,7 +314,7 @@ static ssize_t debugfs_codec_write_op(struct file *filp, { struct csra66x0_priv *csra66x0 = (struct csra66x0_priv *) filp->private_data; - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; char lbuf[32]; int rc; u32 param[2]; @@ -328,46 +330,47 @@ static ssize_t debugfs_codec_write_op(struct file *filp, rc = debugfs_get_parameters(lbuf, param, 2); if ((param[0] < CSRA66X0_AUDIO_IF_RX_CONFIG1) || (param[0] > CSRA66X0_MAX_REGISTER_ADDR)) { - dev_err(codec->dev, "%s: register address 0x%04X out of range\n", + dev_err(component->dev, "%s: register address 0x%04X out of range\n", __func__, param[0]); return -EINVAL; } if ((param[1] < 0) || (param[1] > 255)) { - dev_err(codec->dev, "%s: register data 0x%02X out of range\n", + dev_err(component->dev, "%s: register data 0x%02X out of range\n", __func__, param[1]); return -EINVAL; } if (rc == 0) { rc = cnt; - dev_info(codec->dev, "%s: reg[0x%04X]=0x%02X\n", + dev_info(component->dev, "%s: reg[0x%04X]=0x%02X\n", __func__, param[0], param[1]); - snd_soc_write(codec, param[0], param[1]); + snd_soc_component_write(component, param[0], param[1]); } else { - dev_err(codec->dev, "%s: write to register addr=0x%04X failed\n", + dev_err(component->dev, "%s: write to register addr=0x%04X failed\n", __func__, param[0]); } return rc; } -static ssize_t debugfs_csra66x0_reg_show(struct snd_soc_codec *codec, +static ssize_t debugfs_csra66x0_reg_show(struct snd_soc_component *component, char __user *ubuf, size_t count, loff_t *ppos) { int i, reg_val, len; ssize_t total = 0; char tmp_buf[20]; - if (!ubuf || !ppos || !codec || *ppos < 0) + if (!ubuf || !ppos || !component || *ppos < 0) return -EINVAL; for (i = ((int) *ppos + CSRA66X0_BASE); i <= CSRA66X0_MAX_REGISTER_ADDR; i++) { - reg_val = snd_soc_read(codec, i); + reg_val = snd_soc_component_read32(component, i); len = snprintf(tmp_buf, 20, "0x%04X: 0x%02X\n", i, (reg_val & 0xFF)); if ((total + len) >= count - 1) break; if (copy_to_user((ubuf + total), tmp_buf, len)) { - dev_err(codec->dev, "%s: fail to copy reg dump\n", __func__); + dev_err(component->dev, "%s: fail to copy reg dump\n", + __func__); total = -EFAULT; goto copy_err; } @@ -384,12 +387,12 @@ static ssize_t debugfs_codec_read_op(struct file *filp, { struct csra66x0_priv *csra66x0 = (struct csra66x0_priv *) filp->private_data; - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; ssize_t ret_cnt; if (!filp || !ppos || !ubuf || *ppos < 0) return -EINVAL; - ret_cnt = debugfs_csra66x0_reg_show(codec, ubuf, cnt, ppos); + ret_cnt = debugfs_csra66x0_reg_show(component, ubuf, cnt, ppos); return ret_cnt; } @@ -415,16 +418,17 @@ static int csra66x0_get_volume(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); unsigned int reg_l = mc->reg; unsigned int reg_r = mc->rreg; unsigned int val_l, val_r; - val_l = (snd_soc_read(codec, reg_l) & 0xff) | - ((snd_soc_read(codec, + val_l = (snd_soc_component_read32(component, reg_l) & 0xff) | + ((snd_soc_component_read32(component, CSRA66X0_CH1_VOLUME_1_FA) & (0x01)) << 8); - val_r = (snd_soc_read(codec, reg_r) & 0xff) | - ((snd_soc_read(codec, + val_r = (snd_soc_component_read32(component, reg_r) & 0xff) | + ((snd_soc_component_read32(component, CSRA66X0_CH2_VOLUME_1_FA) & (0x01)) << 8); ucontrol->value.integer.value[0] = val_l; ucontrol->value.integer.value[1] = val_r; @@ -436,8 +440,10 @@ static int csra66x0_set_volume(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct csra66x0_priv *csra66x0 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct csra66x0_priv *csra66x0 = + snd_soc_component_get_drvdata(component); unsigned int reg_l = mc->reg; unsigned int reg_r = mc->rreg; unsigned int val_l[2]; @@ -449,10 +455,10 @@ static int csra66x0_set_volume(struct snd_kcontrol *kcontrol, val_l[1] = (csra66x0->spk_volume_ch1 & SPK_VOLUME_MSB_MSK) ? 1 : 0; val_r[0] = csra66x0->spk_volume_ch2 & SPK_VOLUME_LSB_MSK; val_r[1] = (csra66x0->spk_volume_ch2 & SPK_VOLUME_MSB_MSK) ? 1 : 0; - snd_soc_write(codec, reg_l, val_l[0]); - snd_soc_write(codec, reg_r, val_r[0]); - snd_soc_write(codec, CSRA66X0_CH1_VOLUME_1_FA, val_l[1]); - snd_soc_write(codec, CSRA66X0_CH2_VOLUME_1_FA, val_r[1]); + snd_soc_component_write(component, reg_l, val_l[0]); + snd_soc_component_write(component, reg_r, val_r[0]); + snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_1_FA, val_l[1]); + snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_1_FA, val_r[1]); return 0; } @@ -526,51 +532,66 @@ static const struct snd_soc_dapm_route csra66x0_dapm_routes[] = { static int csra66x0_init(struct csra66x0_priv *csra66x0) { - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; - dev_dbg(codec->dev, "%s: initialize %s\n", - __func__, codec->component.name); + dev_dbg(component->dev, "%s: initialize %s\n", + __func__, component->name); /* config */ - snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, CONFIG_STATE); + snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA, + CONFIG_STATE); /* settle time in HW is min. 500ms before proceeding */ msleep(500); /* setup */ - snd_soc_write(codec, CSRA66X0_MISC_CONTROL_STATUS_0, 0x09); - snd_soc_write(codec, CSRA66X0_TEMP_PROT_BACKOFF, 0x0C); - snd_soc_write(codec, CSRA66X0_EXT_PA_PROTECT_POLARITY, 0x03); - snd_soc_write(codec, CSRA66X0_PWM_OUTPUT_CONFIG, 0xC8); + snd_soc_component_write(component, CSRA66X0_MISC_CONTROL_STATUS_0, + 0x09); + snd_soc_component_write(component, CSRA66X0_TEMP_PROT_BACKOFF, 0x0C); + snd_soc_component_write(component, CSRA66X0_EXT_PA_PROTECT_POLARITY, + 0x03); + snd_soc_component_write(component, CSRA66X0_PWM_OUTPUT_CONFIG, 0xC8); csra66x0->spk_volume_ch1 = SPK_VOLUME_M20DB; csra66x0->spk_volume_ch2 = SPK_VOLUME_M20DB; - snd_soc_write(codec, CSRA66X0_CH1_VOLUME_0_FA, SPK_VOLUME_M20DB_LSB); - snd_soc_write(codec, CSRA66X0_CH2_VOLUME_0_FA, SPK_VOLUME_M20DB_LSB); - snd_soc_write(codec, CSRA66X0_CH1_VOLUME_1_FA, SPK_VOLUME_M20DB_MSB); - snd_soc_write(codec, CSRA66X0_CH2_VOLUME_1_FA, SPK_VOLUME_M20DB_MSB); + snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_0_FA, + SPK_VOLUME_M20DB_LSB); + snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_0_FA, + SPK_VOLUME_M20DB_LSB); + snd_soc_component_write(component, CSRA66X0_CH1_VOLUME_1_FA, + SPK_VOLUME_M20DB_MSB); + snd_soc_component_write(component, CSRA66X0_CH2_VOLUME_1_FA, + SPK_VOLUME_M20DB_MSB); - snd_soc_write(codec, CSRA66X0_DEAD_TIME_CTRL, 0x0); - snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_0, 0xE7); - snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_1, 0x26); - snd_soc_write(codec, CSRA66X0_DEAD_TIME_THRESHOLD_2, 0x40); + snd_soc_component_write(component, CSRA66X0_DEAD_TIME_CTRL, 0x0); + snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_0, + 0xE7); + snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_1, + 0x26); + snd_soc_component_write(component, CSRA66X0_DEAD_TIME_THRESHOLD_2, + 0x40); - snd_soc_write(codec, CSRA66X0_MIN_MODULATION_PULSE_WIDTH, 0x7A); - snd_soc_write(codec, CSRA66X0_CH1_HARD_CLIP_THRESH, 0x00); - snd_soc_write(codec, CSRA66X0_CH2_HARD_CLIP_THRESH, 0x00); + snd_soc_component_write(component, CSRA66X0_MIN_MODULATION_PULSE_WIDTH, + 0x7A); + snd_soc_component_write(component, CSRA66X0_CH1_HARD_CLIP_THRESH, 0x00); + snd_soc_component_write(component, CSRA66X0_CH2_HARD_CLIP_THRESH, 0x00); - snd_soc_write(codec, CSRA66X0_CH1_DCA_THRESH, 0x40); - snd_soc_write(codec, CSRA66X0_CH2_DCA_THRESH, 0x40); - snd_soc_write(codec, CSRA66X0_DCA_ATTACK_RATE, 0x00); - snd_soc_write(codec, CSRA66X0_DCA_RELEASE_RATE, 0x00); + snd_soc_component_write(component, CSRA66X0_CH1_DCA_THRESH, 0x40); + snd_soc_component_write(component, CSRA66X0_CH2_DCA_THRESH, 0x40); + snd_soc_component_write(component, CSRA66X0_DCA_ATTACK_RATE, 0x00); + snd_soc_component_write(component, CSRA66X0_DCA_RELEASE_RATE, 0x00); if (csra66x0->irq) { - snd_soc_write(codec, CSRA66X0_PIO0_SELECT, 0x1); + snd_soc_component_write(component, CSRA66X0_PIO0_SELECT, 0x1); if (csra66x0->irq_active_low) - snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_POLARITY, 0x0); + snd_soc_component_write(component, + CSRA66X0_IRQ_OUTPUT_POLARITY, 0x0); else - snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_POLARITY, 0x1); + snd_soc_component_write(component, + CSRA66X0_IRQ_OUTPUT_POLARITY, 0x1); - snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_ENABLE, 0x01); + snd_soc_component_write(component, + CSRA66X0_IRQ_OUTPUT_ENABLE, 0x01); } else { - snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_ENABLE, 0x00); + snd_soc_component_write(component, + CSRA66X0_IRQ_OUTPUT_ENABLE, 0x00); } /* settle time in HW is min. 500ms before slave initializing */ msleep(500); @@ -579,37 +600,39 @@ static int csra66x0_init(struct csra66x0_priv *csra66x0) static int csra66x0_reset(struct csra66x0_priv *csra66x0) { - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; u16 val; - val = snd_soc_read(codec, CSRA66X0_FAULT_STATUS_FA); + val = snd_soc_component_read32(component, CSRA66X0_FAULT_STATUS_FA); if (val & FAULT_STATUS_INTERNAL) - dev_dbg(codec->dev, "%s: FAULT_STATUS_INTERNAL 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_INTERNAL 0x%X\n", __func__, val); if (val & FAULT_STATUS_OTP_INTEGRITY) - dev_dbg(codec->dev, "%s: FAULT_STATUS_OTP_INTEGRITY 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_OTP_INTEGRITY 0x%X\n", __func__, val); if (val & FAULT_STATUS_PADS2) - dev_dbg(codec->dev, "%s: FAULT_STATUS_PADS2 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_PADS2 0x%X\n", __func__, val); if (val & FAULT_STATUS_SMPS) - dev_dbg(codec->dev, "%s: FAULT_STATUS_SMPS 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_SMPS 0x%X\n", __func__, val); if (val & FAULT_STATUS_TEMP) - dev_dbg(codec->dev, "%s: FAULT_STATUS_TEMP 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_TEMP 0x%X\n", __func__, val); if (val & FAULT_STATUS_PROTECT) - dev_dbg(codec->dev, "%s: FAULT_STATUS_PROTECT 0x%X\n", + dev_dbg(component->dev, "%s: FAULT_STATUS_PROTECT 0x%X\n", __func__, val); - dev_dbg(codec->dev, "%s: reset %s\n", - __func__, codec->component.name); + dev_dbg(component->dev, "%s: reset %s\n", + __func__, component->name); /* clear fault state and re-init */ - snd_soc_write(codec, CSRA66X0_FAULT_STATUS_FA, 0x00); - snd_soc_write(codec, CSRA66X0_IRQ_OUTPUT_STATUS_FA, 0x00); + snd_soc_component_write(component, CSRA66X0_FAULT_STATUS_FA, 0x00); + snd_soc_component_write(component, CSRA66X0_IRQ_OUTPUT_STATUS_FA, 0x00); /* apply reset to CSRA66X0 */ - val = snd_soc_read(codec, CSRA66X0_MISC_CONTROL_STATUS_1_FA); - snd_soc_write(codec, CSRA66X0_MISC_CONTROL_STATUS_1_FA, val | 0x08); + val = snd_soc_component_read32(component, + CSRA66X0_MISC_CONTROL_STATUS_1_FA); + snd_soc_component_write(component, CSRA66X0_MISC_CONTROL_STATUS_1_FA, + val | 0x08); /* wait 500ms after reset to recover CSRA66X0 */ msleep(500); return 0; @@ -617,51 +640,58 @@ static int csra66x0_reset(struct csra66x0_priv *csra66x0) static int csra66x0_msconfig(struct csra66x0_priv *csra66x0) { - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; - dev_dbg(codec->dev, "%s: configure %s\n", - __func__, codec->component.name); + dev_dbg(component->dev, "%s: configure %s\n", + __func__, component->name); /* config */ - snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, + snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA, CONFIG_STATE); /* settle time in HW is min. 500ms before proceeding */ msleep(500); - snd_soc_write(codec, CSRA66X0_PIO7_SELECT, 0x04); - snd_soc_write(codec, CSRA66X0_PIO8_SELECT, 0x04); + snd_soc_component_write(component, CSRA66X0_PIO7_SELECT, 0x04); + snd_soc_component_write(component, CSRA66X0_PIO8_SELECT, 0x04); if (csra66x0->is_master) { /* Master specific config */ - snd_soc_write(codec, CSRA66X0_PIO_PULL_EN0, 0xFF); - snd_soc_write(codec, CSRA66X0_PIO_PULL_DIR0, 0x80); - snd_soc_write(codec, CSRA66X0_PIO_PULL_EN1, 0x01); - snd_soc_write(codec, CSRA66X0_PIO_PULL_DIR1, 0x01); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_EN0, 0xFF); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_DIR0, 0x80); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_EN1, 0x01); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_DIR1, 0x01); } else { /* Slave specific config */ - snd_soc_write(codec, CSRA66X0_PIO_PULL_EN0, 0x7F); - snd_soc_write(codec, CSRA66X0_PIO_PULL_EN1, 0x00); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_EN0, 0x7F); + snd_soc_component_write(component, + CSRA66X0_PIO_PULL_EN1, 0x00); } - snd_soc_write(codec, CSRA66X0_DCA_CTRL, 0x05); + snd_soc_component_write(component, CSRA66X0_DCA_CTRL, 0x05); return 0; } -static int csra66x0_soc_probe(struct snd_soc_codec *codec) +static int csra66x0_soc_probe(struct snd_soc_component *component) { - struct csra66x0_priv *csra66x0 = snd_soc_codec_get_drvdata(codec); + struct csra66x0_priv *csra66x0 = + snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm; char name[50]; unsigned int i, max_num_cluster_devices; - csra66x0->codec = codec; + csra66x0->component = component; if (csra66x0->in_cluster) { - dapm = snd_soc_codec_get_dapm(codec); - dev_dbg(codec->dev, "%s: assign prefix %s to codec device %s\n", - __func__, codec->component.name_prefix, - codec->component.name); + dapm = snd_soc_component_get_dapm(component); + dev_dbg(component->dev, "%s: assign prefix %s to codec device %s\n", + __func__, component->name_prefix, + component->name); /* add device to cluster table */ max_num_cluster_devices = sizeof(csra_clust_dev_tbl)/ sizeof(csra_clust_dev_tbl[0]); for (i = 0; i < max_num_cluster_devices; i++) { - if (!strncmp(codec->component.name_prefix, + if (!strncmp(component->name_prefix, csra_clust_dev_tbl[i].csra66x0_prefix, strlen( csra_clust_dev_tbl[i].csra66x0_prefix))) { @@ -669,21 +699,21 @@ static int csra66x0_soc_probe(struct snd_soc_codec *codec) break; } if (i == max_num_cluster_devices-1) - dev_warn(codec->dev, + dev_warn(component->dev, "%s: Unknown prefix %s of cluster device %s\n", - __func__, codec->component.name_prefix, - codec->component.name); + __func__, component->name_prefix, + component->name); } /* master slave config */ csra66x0_msconfig(csra66x0); if (dapm->component) { strlcpy(name, dapm->component->name_prefix, - sizeof(name)); + sizeof(name)); strlcat(name, " IN", sizeof(name)); snd_soc_dapm_ignore_suspend(dapm, name); strlcpy(name, dapm->component->name_prefix, - sizeof(name)); + sizeof(name)); strlcat(name, " SPKR", sizeof(name)); snd_soc_dapm_ignore_suspend(dapm, name); } @@ -694,53 +724,45 @@ static int csra66x0_soc_probe(struct snd_soc_codec *codec) return 0; } -static int csra66x0_soc_remove(struct snd_soc_codec *codec) +static void csra66x0_soc_remove(struct snd_soc_component *component) { - snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, STDBY_STATE); + snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA, + STDBY_STATE); + return; +} + +static int csra66x0_soc_suspend(struct snd_soc_component *component) +{ + u16 state_reg = snd_soc_component_read32(component, + CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC; + + snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA, + state_reg | STDBY_STATE); return 0; } -static int csra66x0_soc_suspend(struct snd_soc_codec *codec) +static int csra66x0_soc_resume(struct snd_soc_component *component) { - u16 state_reg = snd_soc_read(codec, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC; + u16 state_reg = snd_soc_component_read32( + component, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC; - snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, state_reg | - STDBY_STATE); + snd_soc_component_write(component, CSRA66X0_CHIP_STATE_CTRL_FA, + state_reg | RUN_STATE); return 0; } -static int csra66x0_soc_resume(struct snd_soc_codec *codec) -{ - u16 state_reg = snd_soc_read(codec, CSRA66X0_CHIP_STATE_CTRL_FA) & 0xFC; - - snd_soc_write(codec, CSRA66X0_CHIP_STATE_CTRL_FA, state_reg | - RUN_STATE); - return 0; -} - -static struct regmap *csra66x0_get_regmap(struct device *dev) -{ - struct csra66x0_priv *csra66x0_ctrl = dev_get_drvdata(dev); - - if (!csra66x0_ctrl) - return NULL; - return csra66x0_ctrl->regmap; -} - -static struct snd_soc_codec_driver soc_codec_drv_csra66x0 = { +static const struct snd_soc_component_driver soc_codec_drv_csra66x0 = { + .name = DRV_NAME, .probe = csra66x0_soc_probe, .remove = csra66x0_soc_remove, .suspend = csra66x0_soc_suspend, .resume = csra66x0_soc_resume, - .get_regmap = csra66x0_get_regmap, - .component_driver = { - .controls = csra66x0_snd_controls, - .num_controls = ARRAY_SIZE(csra66x0_snd_controls), - .dapm_widgets = csra66x0_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(csra66x0_dapm_widgets), - .dapm_routes = csra66x0_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(csra66x0_dapm_routes), - }, + .controls = csra66x0_snd_controls, + .num_controls = ARRAY_SIZE(csra66x0_snd_controls), + .dapm_widgets = csra66x0_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(csra66x0_dapm_widgets), + .dapm_routes = csra66x0_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(csra66x0_dapm_routes), }; static struct regmap_config csra66x0_regmap_config = { @@ -758,19 +780,20 @@ static struct regmap_config csra66x0_regmap_config = { static irqreturn_t csra66x0_irq(int irq, void *data) { struct csra66x0_priv *csra66x0 = (struct csra66x0_priv *) data; - struct snd_soc_codec *codec = csra66x0->codec; + struct snd_soc_component *component = csra66x0->component; u16 val; unsigned int i, max_num_cluster_devices; - /* Treat interrupt before codec is initialized as spurious */ - if (codec == NULL) + /* Treat interrupt before component is initialized as spurious */ + if (component == NULL) return IRQ_NONE; - dev_dbg(codec->dev, "%s: csra66x0_interrupt triggered by %s\n", - __func__, codec->component.name); + dev_dbg(component->dev, "%s: csra66x0_interrupt triggered by %s\n", + __func__, component->name); /* fault indication */ - val = snd_soc_read(codec, CSRA66X0_IRQ_OUTPUT_STATUS_FA) & 0x1; + val = snd_soc_component_read32(component, CSRA66X0_IRQ_OUTPUT_STATUS_FA) + & 0x1; if (!val) return IRQ_HANDLED; @@ -780,7 +803,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data) sizeof(csra_clust_dev_tbl) / sizeof(csra_clust_dev_tbl[0]); for (i = 0; i < max_num_cluster_devices; i++) { - if (i >= codec->component.card->num_aux_devs) + if (i >= component->card->num_aux_devs) break; if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL) continue; @@ -790,7 +813,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data) } /* reset all master codecs */ for (i = 0; i < max_num_cluster_devices; i++) { - if (i >= codec->component.card->num_aux_devs) + if (i >= component->card->num_aux_devs) break; if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL) continue; @@ -800,7 +823,7 @@ static irqreturn_t csra66x0_irq(int irq, void *data) } /* recover all codecs */ for (i = 0; i < max_num_cluster_devices; i++) { - if (i >= codec->component.card->num_aux_devs) + if (i >= component->card->num_aux_devs) break; if (csra_clust_dev_tbl[i].csra66x0_ptr == NULL) continue; @@ -958,7 +981,7 @@ static int csra66x0_i2c_probe(struct i2c_client *client_i2c, #endif /* CONFIG_DEBUG_FS */ /* register codec */ - ret = snd_soc_register_codec(&client_i2c->dev, + ret = snd_soc_register_component(&client_i2c->dev, &soc_codec_drv_csra66x0, NULL, 0); if (ret != 0) { dev_err(&client_i2c->dev, "%s %d: Failed to register codec: %d\n", @@ -985,7 +1008,7 @@ static int csra66x0_i2c_remove(struct i2c_client *i2c_client) debugfs_remove_recursive(csra66x0->debugfs_dir); #endif } - snd_soc_unregister_codec(&i2c_client->dev); + snd_soc_unregister_component(&i2c_client->dev); return 0; } diff --git a/asoc/codecs/ep92/ep92.c b/asoc/codecs/ep92/ep92.c index cdcd7ab98f..81ff656b92 100644 --- a/asoc/codecs/ep92/ep92.c +++ b/asoc/codecs/ep92/ep92.c @@ -21,6 +21,8 @@ #include #include "ep92.h" +#define DRV_NAME "ep92_codec" + #define EP92_POLL_INTERVAL_OFF_MSEC 200 #define EP92_POLL_INTERVAL_ON_MSEC 20 #define EP92_SYSFS_ENTRY_MAX_LEN 64 @@ -91,7 +93,7 @@ static bool ep92_readable_registers(struct device *dev, unsigned int reg) /* codec private data */ struct ep92_pdata { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct timer_list timer; struct work_struct read_status_worker; int irq; @@ -169,7 +171,7 @@ static ssize_t debugfs_codec_write_op(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { struct ep92_pdata *ep92 = (struct ep92_pdata *) filp->private_data; - struct snd_soc_codec *codec = ep92->codec; + struct snd_soc_component *component = ep92->component; char lbuf[32]; int rc; u32 param[2]; @@ -185,45 +187,45 @@ static ssize_t debugfs_codec_write_op(struct file *filp, rc = debugfs_get_parameters(lbuf, param, 2); if ((param[0] < EP92_ISP_MODE_ENTER_ISP) || (param[0] > EP92_GENERAL_CONTROL_4)) { - dev_err(codec->dev, "%s: reg address 0x%02X out of range\n", + dev_err(component->dev, "%s: reg address 0x%02X out of range\n", __func__, param[0]); return -EINVAL; } if ((param[1] < 0) || (param[1] > 255)) { - dev_err(codec->dev, "%s: reg data 0x%02X out of range\n", + dev_err(component->dev, "%s: reg data 0x%02X out of range\n", __func__, param[1]); return -EINVAL; } if (rc == 0) { rc = cnt; - dev_info(codec->dev, "%s: reg[0x%02X]=0x%02X\n", + dev_info(component->dev, "%s: reg[0x%02X]=0x%02X\n", __func__, param[0], param[1]); - snd_soc_write(codec, param[0], param[1]); + snd_soc_component_write(component, param[0], param[1]); } else { - dev_err(codec->dev, "%s: write to register addr=0x%02X failed\n", + dev_err(component->dev, "%s: write to register addr=0x%02X failed\n", __func__, param[0]); } return rc; } -static ssize_t debugfs_ep92_reg_show(struct snd_soc_codec *codec, +static ssize_t debugfs_ep92_reg_show(struct snd_soc_component *component, char __user *ubuf, size_t count, loff_t *ppos) { int i, reg_val, len; ssize_t total = 0; char tmp_buf[20]; - if (!ubuf || !ppos || !codec || *ppos < 0) + if (!ubuf || !ppos || !component || *ppos < 0) return -EINVAL; for (i = (int) *ppos / 11; i <= EP92_MAX_REGISTER_ADDR; i++) { - reg_val = snd_soc_read(codec, i); + reg_val = snd_soc_component_read32(component, i); len = snprintf(tmp_buf, 20, "0x%02X: 0x%02X\n", i, (reg_val & 0xFF)); if ((total + len) > count) break; if (copy_to_user((ubuf + total), tmp_buf, len)) { - dev_err(codec->dev, "%s: fail to copy reg dump\n", + dev_err(component->dev, "%s: fail to copy reg dump\n", __func__); total = -EFAULT; goto copy_err; @@ -240,12 +242,12 @@ static ssize_t debugfs_codec_read_op(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) { struct ep92_pdata *ep92 = (struct ep92_pdata *) filp->private_data; - struct snd_soc_codec *codec = ep92->codec; + struct snd_soc_component *component = ep92->component; ssize_t ret_cnt; if (!filp || !ppos || !ubuf || *ppos < 0) return -EINVAL; - ret_cnt = debugfs_ep92_reg_show(codec, ubuf, cnt, ppos); + ret_cnt = debugfs_ep92_reg_show(component, ubuf, cnt, ppos); return ret_cnt; } @@ -263,7 +265,8 @@ static int ep92_send_uevent(struct ep92_pdata *ep92, char *event) if (!event || !ep92) return -EINVAL; - return kobject_uevent_env(&ep92->codec->dev->kobj, KOBJ_CHANGE, env); + return kobject_uevent_env(&ep92->component->dev->kobj, + KOBJ_CHANGE, env); } static int ep92_startup(struct snd_pcm_substream *substream, @@ -320,14 +323,15 @@ static struct snd_soc_dai_driver ep92_dai[] = { }, }; -static void ep92_read_general_control(struct snd_soc_codec *codec, +static void ep92_read_general_control(struct snd_soc_component *component, struct ep92_pdata *ep92) { u8 old, change; int val; old = ep92->gi.tx_info; - ep92->gi.tx_info = snd_soc_read(codec, EP92_BI_GENERAL_INFO_0); + ep92->gi.tx_info = snd_soc_component_read32(component, + EP92_BI_GENERAL_INFO_0); if (ep92->gi.tx_info == 0xff) { pr_debug("ep92 EP92_BI_GENERAL_INFO_0 read 0xff\n"); ep92->gi.tx_info = old; @@ -358,7 +362,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } old = ep92->gi.video_latency; - ep92->gi.video_latency = snd_soc_read(codec, EP92_BI_GENERAL_INFO_4); + ep92->gi.video_latency = snd_soc_component_read32(component, + EP92_BI_GENERAL_INFO_4); if (ep92->gi.video_latency == 0xff) { pr_debug("ep92 EP92_BI_GENERAL_INFO_4 read 0xff\n"); ep92->gi.video_latency = old; @@ -373,7 +378,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } old = ep92->gc.ctl; - ep92->gc.ctl = snd_soc_read(codec, EP92_GENERAL_CONTROL_0); + ep92->gc.ctl = snd_soc_component_read32(component, + EP92_GENERAL_CONTROL_0); if (ep92->gc.ctl == 0xff) { pr_debug("ep92 EP92_GENERAL_CONTROL_0 read 0xff\n"); ep92->gc.ctl = old; @@ -416,7 +422,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } old = ep92->gc.rx_sel; - ep92->gc.rx_sel = snd_soc_read(codec, EP92_GENERAL_CONTROL_1); + ep92->gc.rx_sel = snd_soc_component_read32(component, + EP92_GENERAL_CONTROL_1); if (ep92->gc.rx_sel == 0xff) { pr_debug("ep92 EP92_GENERAL_CONTROL_1 read 0xff\n"); ep92->gc.rx_sel = old; @@ -429,7 +436,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } old = ep92->gc.cec_volume; - ep92->gc.cec_volume = snd_soc_read(codec, EP92_GENERAL_CONTROL_3); + ep92->gc.cec_volume = snd_soc_component_read32(component, + EP92_GENERAL_CONTROL_3); if (ep92->gc.cec_volume == 0xff) { pr_debug("ep92 EP92_GENERAL_CONTROL_3 read 0xff\n"); ep92->gc.cec_volume = old; @@ -442,7 +450,8 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } old = ep92->gc.link; - ep92->gc.link = snd_soc_read(codec, EP92_GENERAL_CONTROL_4); + ep92->gc.link = snd_soc_component_read32(component, + EP92_GENERAL_CONTROL_4); if (ep92->gc.link == 0xff) { pr_debug("ep92 EP92_GENERAL_CONTROL_4 read 0xff\n"); ep92->gc.link = old; @@ -524,7 +533,7 @@ static void ep92_read_general_control(struct snd_soc_codec *codec, } } -static void ep92_read_audio_info(struct snd_soc_codec *codec, +static void ep92_read_audio_info(struct snd_soc_component *component, struct ep92_pdata *ep92) { u8 old, change; @@ -532,7 +541,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, bool send_uevent = false; old = ep92->ai.system_status_0; - ep92->ai.system_status_0 = snd_soc_read(codec, + ep92->ai.system_status_0 = snd_soc_component_read32(component, EP92_AUDIO_INFO_SYSTEM_STATUS_0); if (ep92->ai.system_status_0 == 0xff) { pr_debug("ep92 EP92_AUDIO_INFO_SYSTEM_STATUS_0 read 0xff\n"); @@ -558,7 +567,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, } old = ep92->ai.audio_status; - ep92->ai.audio_status = snd_soc_read(codec, + ep92->ai.audio_status = snd_soc_component_read32(component, EP92_AUDIO_INFO_AUDIO_STATUS); if (ep92->ai.audio_status == 0xff) { pr_debug("ep92 EP92_AUDIO_INFO_AUDIO_STATUS read 0xff\n"); @@ -575,7 +584,7 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, new_mode = ep92->old_mode; if (ep92->ai.audio_status & EP92_AI_STD_ADO_MASK) { old = ep92->ai.cs[0]; - ep92->ai.cs[0] = snd_soc_read(codec, + ep92->ai.cs[0] = snd_soc_component_read32(component, EP92_AUDIO_INFO_CHANNEL_STATUS_0); if (ep92->ai.cs[0] == 0xff) { pr_debug("ep92 EP92_AUDIO_INFO_CHANNEL_STATUS_0 read 0xff\n"); @@ -595,7 +604,8 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, ep92->old_mode = new_mode; old = ep92->ai.cc; - ep92->ai.cc = snd_soc_read(codec, EP92_AUDIO_INFO_ADO_INFO_FRAME_1); + ep92->ai.cc = snd_soc_component_read32(component, + EP92_AUDIO_INFO_ADO_INFO_FRAME_1); if (ep92->ai.cc == 0xff) { pr_debug("ep92 EP92_AUDIO_INFO_ADO_INFO_FRAME_1 read 0xff\n"); ep92->ai.cc = old; @@ -610,7 +620,8 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, } old = ep92->ai.ca; - ep92->ai.ca = snd_soc_read(codec, EP92_AUDIO_INFO_ADO_INFO_FRAME_4); + ep92->ai.ca = snd_soc_component_read32(component, + EP92_AUDIO_INFO_ADO_INFO_FRAME_4); if (ep92->ai.ca == 0xff) { pr_debug("ep92 EP92_AUDIO_INFO_ADO_INFO_FRAME_4 read 0xff\n"); ep92->ai.ca = old; @@ -626,42 +637,33 @@ static void ep92_read_audio_info(struct snd_soc_codec *codec, ep92_send_uevent(ep92, "EP92EVT_AUDIO=MEDIA_CONFIG_CHANGE"); } -static void ep92_init(struct snd_soc_codec *codec, struct ep92_pdata *ep92) +static void ep92_init(struct snd_soc_component *component, + struct ep92_pdata *ep92) { /* update the format information in mixer controls */ - ep92_read_general_control(codec, ep92); - ep92_read_audio_info(codec, ep92); + ep92_read_general_control(component, ep92); + ep92_read_audio_info(component, ep92); } -static int ep92_probe(struct snd_soc_codec *codec) +static int ep92_probe(struct snd_soc_component *component) { - struct ep92_pdata *ep92 = snd_soc_codec_get_drvdata(codec); + struct ep92_pdata *ep92 = snd_soc_component_get_drvdata(component); - ep92->codec = codec; - ep92_init(codec, ep92); + ep92->component = component; + ep92_init(component, ep92); return 0; } -static int ep92_remove(struct snd_soc_codec *codec) +static void ep92_remove(struct snd_soc_component *component) { - return 0; + return; } -static struct regmap *ep92_get_regmap(struct device *dev) -{ - struct ep92_pdata *ep92_ctrl = dev_get_drvdata(dev); - - if (!ep92_ctrl) - return NULL; - - return ep92_ctrl->regmap; -} - -static struct snd_soc_codec_driver soc_codec_drv_ep92 = { +static const struct snd_soc_component_driver soc_codec_drv_ep92 = { + .name = DRV_NAME, .probe = ep92_probe, .remove = ep92_remove, - .get_regmap = ep92_get_regmap, }; static struct regmap_config ep92_regmap_config = { @@ -680,18 +682,19 @@ void ep92_read_status(struct work_struct *work) { struct ep92_pdata *ep92 = container_of(work, struct ep92_pdata, read_status_worker); - struct snd_soc_codec *codec = ep92->codec; + struct snd_soc_component *component = ep92->component; u8 val; /* No polling before codec is initialized */ - if (codec == NULL) + if (component == NULL) return; /* check ADO_CHF that is set when audio format has changed */ - val = snd_soc_read(codec, EP92_BI_GENERAL_INFO_1); + val = snd_soc_component_read32(component, EP92_BI_GENERAL_INFO_1); if (val == 0xff) { /* workaround for Nak'ed first read */ - val = snd_soc_read(codec, EP92_BI_GENERAL_INFO_1); + val = snd_soc_component_read32(component, + EP92_BI_GENERAL_INFO_1); if (val == 0xff) return; /* assume device not present */ } @@ -703,22 +706,22 @@ void ep92_read_status(struct work_struct *work) pr_debug("ep92 CEC change trigger.\n"); /* check for general control changes */ - ep92_read_general_control(codec, ep92); + ep92_read_general_control(component, ep92); /* update the format information in mixer controls */ - ep92_read_audio_info(codec, ep92); + ep92_read_audio_info(component, ep92); } static irqreturn_t ep92_irq(int irq, void *data) { struct ep92_pdata *ep92 = data; - struct snd_soc_codec *codec = ep92->codec; + struct snd_soc_component *component = ep92->component; /* Treat interrupt before codec is initialized as spurious */ - if (codec == NULL) + if (component == NULL) return IRQ_NONE; - dev_dbg(codec->dev, "ep92_interrupt\n"); + dev_dbg(component->dev, "ep92_interrupt\n"); schedule_work(&ep92->read_status_worker); @@ -1038,10 +1041,11 @@ static ssize_t ep92_sysfs_wta_arc_disable(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_2); + reg = snd_soc_component_read32(ep92->component, + EP92_GENERAL_CONTROL_2); reg &= ~EP92_GC_ARC_DIS_MASK; reg |= ((val << EP92_GC_ARC_DIS_SHIFT) & EP92_GC_ARC_DIS_MASK); - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_2, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_2, reg); ep92->gc.ctl2 &= ~EP92_GC_ARC_DIS_MASK; ep92->gc.ctl2 |= (val << EP92_GC_ARC_DIS_SHIFT) & EP92_GC_ARC_DIS_MASK; @@ -1092,10 +1096,10 @@ static ssize_t ep92_sysfs_wta_power(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0); + reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0); reg &= ~EP92_GC_POWER_MASK; reg |= (val << EP92_GC_POWER_SHIFT) & EP92_GC_POWER_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg); ep92->gc.ctl &= ~EP92_GC_POWER_MASK; ep92->gc.ctl |= (val << EP92_GC_POWER_SHIFT) & EP92_GC_POWER_MASK; @@ -1146,10 +1150,11 @@ static ssize_t ep92_sysfs_wta_audio_path(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0); + reg = snd_soc_component_read32(ep92->component, + EP92_GENERAL_CONTROL_0); reg &= ~EP92_GC_AUDIO_PATH_MASK; reg |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg); ep92->gc.ctl &= ~EP92_GC_AUDIO_PATH_MASK; ep92->gc.ctl |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK; @@ -1201,10 +1206,11 @@ static ssize_t ep92_sysfs_wta_src_sel(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_1); + reg = snd_soc_component_read32(ep92->component, + EP92_GENERAL_CONTROL_1); reg &= ~EP92_GC_RX_SEL_MASK; reg |= (val << EP92_GC_RX_SEL_SHIFT) & EP92_GC_RX_SEL_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_1, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_1, reg); ep92->gc.rx_sel &= ~EP92_GC_RX_SEL_MASK; ep92->gc.rx_sel |= (val << EP92_GC_RX_SEL_SHIFT) & EP92_GC_RX_SEL_MASK; @@ -1255,10 +1261,10 @@ static ssize_t ep92_sysfs_wta_arc_enable(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0); + reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0); reg &= ~EP92_GC_AUDIO_PATH_MASK; reg |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg); ep92->gc.ctl &= ~EP92_GC_AUDIO_PATH_MASK; ep92->gc.ctl |= (val << EP92_GC_AUDIO_PATH_SHIFT) & EP92_GC_AUDIO_PATH_MASK; @@ -1310,10 +1316,10 @@ static ssize_t ep92_sysfs_wta_cec_mute(struct device *dev, goto end; } - reg = snd_soc_read(ep92->codec, EP92_GENERAL_CONTROL_0); + reg = snd_soc_component_read32(ep92->component, EP92_GENERAL_CONTROL_0); reg &= ~EP92_GC_CEC_MUTE_MASK; reg |= (val << EP92_GC_CEC_MUTE_SHIFT) & EP92_GC_CEC_MUTE_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_0, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_0, reg); ep92->gc.ctl &= ~EP92_GC_CEC_MUTE_MASK; ep92->gc.ctl |= (val << EP92_GC_CEC_MUTE_SHIFT) & EP92_GC_CEC_MUTE_MASK; @@ -1367,7 +1373,7 @@ static ssize_t ep92_sysfs_wta_cec_volume(struct device *dev, } reg = val & EP92_GC_CEC_VOLUME_MASK; - snd_soc_write(ep92->codec, EP92_GENERAL_CONTROL_3, reg); + snd_soc_component_write(ep92->component, EP92_GENERAL_CONTROL_3, reg); ep92->gc.cec_volume = val & EP92_GC_CEC_VOLUME_MASK; rc = strnlen(buf, EP92_SYSFS_ENTRY_MAX_LEN); @@ -1524,7 +1530,7 @@ static int ep92_i2c_probe(struct i2c_client *client, #endif /* CONFIG_DEBUG_FS */ /* register codec */ - ret = snd_soc_register_codec(&client->dev, &soc_codec_drv_ep92, + ret = snd_soc_register_component(&client->dev, &soc_codec_drv_ep92, ep92_dai, ARRAY_SIZE(ep92_dai)); if (ret) { dev_err(&client->dev, @@ -1542,7 +1548,7 @@ static int ep92_i2c_probe(struct i2c_client *client, return 0; err_sysfs: - snd_soc_unregister_codec(&client->dev); + snd_soc_unregister_component(&client->dev); err_reg: if (ep92->irq == 0) del_timer(&ep92->timer); @@ -1563,7 +1569,7 @@ static int ep92_i2c_remove(struct i2c_client *client) debugfs_remove_recursive(ep92->debugfs_dir); #endif } - snd_soc_unregister_codec(&client->dev); + snd_soc_unregister_component(&client->dev); ep92_sysfs_remove(client, ep92); diff --git a/asoc/codecs/msm_hdmi_codec_rx.c b/asoc/codecs/msm_hdmi_codec_rx.c index 3e4c2d5ca6..95bb26d027 100644 --- a/asoc/codecs/msm_hdmi_codec_rx.c +++ b/asoc/codecs/msm_hdmi_codec_rx.c @@ -11,6 +11,8 @@ #include #include +#define DRV_NAME "HDMI_codec" + #define MSM_EXT_DISP_PCM_RATES SNDRV_PCM_RATE_48000 #define AUD_EXT_DISP_ACK_DISCONNECT (AUDIO_ACK_CONNECT ^ AUDIO_ACK_CONNECT) #define AUD_EXT_DISP_ACK_CONNECT (AUDIO_ACK_CONNECT) @@ -64,29 +66,30 @@ struct msm_ext_disp_audio_codec_rx_data { static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct msm_ext_disp_audio_codec_rx_data *codec_data; struct msm_ext_disp_audio_edid_blk edid_blk; int rc = 0; struct msm_ext_disp_codec_id codec_info; int dai_id = kcontrol->private_value; - codec_data = snd_soc_codec_get_drvdata(codec); + codec_data = snd_soc_component_get_drvdata(component); if (!codec_data) { - dev_err(codec->dev, "%s: codec_data is NULL\n", __func__); + dev_err(component->dev, "%s: codec_data is NULL\n", __func__); return -EINVAL; } if (!codec_data->ext_disp_ops.get_audio_edid_blk) { - dev_dbg(codec->dev, "%s: get_audio_edid_blk() is NULL\n", + dev_dbg(component->dev, "%s: get_audio_edid_blk() is NULL\n", __func__); uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = 0; return 0; } - dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__, codec_data->ctl[dai_id], codec_data->stream[dai_id]); mutex_lock(&codec_data->dp_ops_lock); @@ -100,28 +103,29 @@ static int msm_ext_disp_edid_ctl_info(struct snd_kcontrol *kcontrol, edid_blk.spk_alloc_data_blk_size; } - dev_dbg(codec->dev, "%s: count: %d\n", __func__, uinfo->count); + dev_dbg(component->dev, "%s: count: %d\n", __func__, uinfo->count); return rc; } static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct msm_ext_disp_audio_codec_rx_data *codec_data; struct msm_ext_disp_audio_edid_blk edid_blk; struct msm_ext_disp_codec_id codec_info; int rc = 0; int dai_id = kcontrol->private_value; - codec_data = snd_soc_codec_get_drvdata(codec); + codec_data = snd_soc_component_get_drvdata(component); if (!codec_data || !codec_data->ext_disp_ops.get_audio_edid_blk) { - dev_err(codec->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n", + dev_err(component->dev, "%s: codec_data or get_audio_edid_blk() is NULL\n", __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__, codec_data->ctl[dai_id], codec_data->stream[dai_id]); mutex_lock(&codec_data->dp_ops_lock); @@ -133,7 +137,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol, if (sizeof(ucontrol->value.bytes.data) < (edid_blk.audio_data_blk_size + edid_blk.spk_alloc_data_blk_size)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Not enough memory to copy EDID data\n", __func__); return -ENOMEM; @@ -147,7 +151,7 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol, edid_blk.spk_alloc_data_blk, edid_blk.spk_alloc_data_blk_size); - dev_dbg(codec->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n", + dev_dbg(component->dev, "%s: data_blk_size:%d, spk_alloc_data_blk_size:%d\n", __func__, edid_blk.audio_data_blk_size, edid_blk.spk_alloc_data_blk_size); } @@ -158,7 +162,8 @@ static int msm_ext_disp_edid_get(struct snd_kcontrol *kcontrol, static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct msm_ext_disp_audio_codec_rx_data *codec_data; enum msm_ext_disp_cable_state cable_state; enum msm_ext_disp_type disp_type; @@ -166,16 +171,16 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol, int rc = 0; int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l; - codec_data = snd_soc_codec_get_drvdata(codec); + codec_data = snd_soc_component_get_drvdata(component); if (!codec_data || !codec_data->ext_disp_ops.get_audio_edid_blk || !codec_data->ext_disp_ops.get_intf_id) { - dev_err(codec->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n", + dev_err(component->dev, "%s: codec_data, get_audio_edid_blk() or get_intf_id is NULL\n", __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__, codec_data->ctl[dai_id], codec_data->stream[dai_id]); mutex_lock(&codec_data->dp_ops_lock); @@ -183,7 +188,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol, cable_state = codec_data->ext_disp_ops.cable_status( codec_data->ext_disp_core_pdev, 1); if (cable_state < 0) { - dev_err(codec->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n", + dev_err(component->dev, "%s: Error retrieving cable state from ext_disp, err:%d\n", __func__, cable_state); rc = cable_state; goto cable_err; @@ -191,7 +196,7 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol, codec_data->cable_status = cable_state; if (cable_state == EXT_DISPLAY_CABLE_DISCONNECT) { - dev_err(codec->dev, "%s: Display cable disconnected\n", + dev_err(component->dev, "%s: Display cable disconnected\n", __func__); ucontrol->value.integer.value[0] = 0; rc = 0; @@ -213,14 +218,14 @@ static int msm_ext_disp_audio_type_get(struct snd_kcontrol *kcontrol, break; default: rc = -EINVAL; - dev_err(codec->dev, "%s: Invalid disp_type:%d\n", + dev_err(component->dev, "%s: Invalid disp_type:%d\n", __func__, disp_type); goto done; } - dev_dbg(codec->dev, "%s: Display type: %d\n", + dev_dbg(component->dev, "%s: Display type: %d\n", __func__, disp_type); } else { - dev_err(codec->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n", + dev_err(component->dev, "%s: Error retrieving disp_type from ext_disp, err:%d\n", __func__, disp_type); rc = disp_type; } @@ -235,24 +240,25 @@ done: static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct msm_ext_disp_audio_codec_rx_data *codec_data; u32 ack_state = 0; struct msm_ext_disp_codec_id codec_info; int rc = 0; int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l; - codec_data = snd_soc_codec_get_drvdata(codec); + codec_data = snd_soc_component_get_drvdata(component); if (!codec_data || !codec_data->ext_disp_ops.acknowledge) { - dev_err(codec->dev, + dev_err(component->dev, "%s: codec_data or ops acknowledge() is NULL\n", __func__); rc = -EINVAL; goto done; } - dev_dbg(codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(component->dev, "%s: DP ctl id %d Stream id %d\n", __func__, codec_data->ctl[dai_id], codec_data->stream[dai_id]); switch (ucontrol->value.enumerated.item[0]) { @@ -267,12 +273,12 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol, break; default: rc = -EINVAL; - dev_err(codec->dev, + dev_err(component->dev, "%s: invalid value %d for mixer ctl\n", __func__, ucontrol->value.enumerated.item[0]); goto done; } - dev_dbg(codec->dev, "%s: control %d, ack set value 0x%x\n", + dev_dbg(component->dev, "%s: control %d, ack set value 0x%x\n", __func__, ucontrol->value.enumerated.item[0], ack_state); mutex_lock(&codec_data->dp_ops_lock); @@ -281,7 +287,7 @@ static int msm_ext_disp_audio_ack_set(struct snd_kcontrol *kcontrol, codec_data->ext_disp_core_pdev, ack_state); mutex_unlock(&codec_data->dp_ops_lock); if (rc < 0) { - dev_err(codec->dev, "%s: error from acknowledge(), err:%d\n", + dev_err(component->dev, "%s: error from acknowledge(), err:%d\n", __func__, rc); } @@ -292,14 +298,15 @@ done: static int msm_ext_disp_audio_device_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); struct msm_ext_disp_audio_codec_rx_data *codec_data; int rc = 0; int dai_id = ((struct soc_enum *) kcontrol->private_value)->shift_l; - codec_data = snd_soc_codec_get_drvdata(codec); + codec_data = snd_soc_component_get_drvdata(component); if (!codec_data) { - dev_err(codec->dev, + dev_err(component->dev, "%s: codec_data or ops acknowledge() is NULL\n", __func__); rc = -EINVAL; @@ -371,7 +378,7 @@ static int msm_ext_disp_audio_codec_rx_dai_startup( int ret = 0; struct msm_ext_disp_codec_id codec_info; struct msm_ext_disp_audio_codec_rx_data *codec_data = - dev_get_drvdata(dai->codec->dev); + dev_get_drvdata(dai->component->dev); if (!codec_data || !codec_data->ext_disp_ops.cable_status) { dev_err(dai->dev, "%s() codec_data or cable_status is null\n", @@ -379,7 +386,8 @@ static int msm_ext_disp_audio_codec_rx_dai_startup( return -EINVAL; } - dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n", + __func__, codec_data->ctl[dai->id], codec_data->stream[dai->id]); mutex_lock(&codec_data->dp_ops_lock); @@ -417,7 +425,7 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params( struct msm_ext_disp_audio_setup_params audio_setup_params = {0}; struct msm_ext_disp_audio_codec_rx_data *codec_data = - dev_get_drvdata(dai->codec->dev); + dev_get_drvdata(dai->component->dev); if (!codec_data || !codec_data->ext_disp_ops.audio_info_setup) { dev_err(dai->dev, "%s: codec_data or audio_info_setup is null\n", @@ -425,7 +433,8 @@ static int msm_ext_disp_audio_codec_rx_dai_hw_params( return -EINVAL; } - dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n", + __func__, codec_data->ctl[dai->id], codec_data->stream[dai->id]); if (codec_data->cable_status < 0) { @@ -507,7 +516,7 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown( struct msm_ext_disp_codec_id codec_info; struct msm_ext_disp_audio_codec_rx_data *codec_data = - dev_get_drvdata(dai->codec->dev); + dev_get_drvdata(dai->component->dev); if (!codec_data || !codec_data->ext_disp_ops.teardown_done || !codec_data->ext_disp_ops.cable_status) { @@ -516,7 +525,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown( return; } - dev_dbg(dai->codec->dev, "%s: DP ctl id %d Stream id %d\n", __func__, + dev_dbg(dai->component->dev, "%s: DP ctl id %d Stream id %d\n", + __func__, codec_data->ctl[dai->id], codec_data->stream[dai->id]); mutex_lock(&codec_data->dp_ops_lock); @@ -534,7 +544,8 @@ static void msm_ext_disp_audio_codec_rx_dai_shutdown( mutex_unlock(&codec_data->dp_ops_lock); } -static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec) +static int msm_ext_disp_audio_codec_rx_probe( + struct snd_soc_component *component) { struct msm_ext_disp_audio_codec_rx_data *codec_data; struct device_node *of_node_parent = NULL; @@ -543,14 +554,14 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec) GFP_KERNEL); if (!codec_data) { - dev_err(codec->dev, "%s(): fail to allocate dai data\n", + dev_err(component->dev, "%s(): fail to allocate dai data\n", __func__); return -ENOMEM; } - of_node_parent = of_get_parent(codec->dev->of_node); + of_node_parent = of_get_parent(component->dev->of_node); if (!of_node_parent) { - dev_err(codec->dev, "%s(): Parent device tree node not found\n", + dev_err(component->dev, "%s(): Parent device tree node not found\n", __func__); kfree(codec_data); return -ENODEV; @@ -558,37 +569,39 @@ static int msm_ext_disp_audio_codec_rx_probe(struct snd_soc_codec *codec) codec_data->ext_disp_core_pdev = of_find_device_by_node(of_node_parent); if (!codec_data->ext_disp_core_pdev) { - dev_err(codec->dev, "%s(): can't get parent pdev\n", __func__); + dev_err(component->dev, "%s(): can't get parent pdev\n", + __func__); kfree(codec_data); return -ENODEV; } if (msm_ext_disp_register_audio_codec(codec_data->ext_disp_core_pdev, &codec_data->ext_disp_ops)) { - dev_err(codec->dev, "%s(): can't register with ext disp core", + dev_err(component->dev, "%s(): can't register with ext disp core", __func__); kfree(codec_data); return -ENODEV; } mutex_init(&codec_data->dp_ops_lock); - dev_set_drvdata(codec->dev, codec_data); + dev_set_drvdata(component->dev, codec_data); - dev_dbg(codec->dev, "%s(): registered %s with ext disp core\n", - __func__, codec->component.name); + dev_dbg(component->dev, "%s(): registered %s with ext disp core\n", + __func__, component->name); return 0; } -static int msm_ext_disp_audio_codec_rx_remove(struct snd_soc_codec *codec) +static void msm_ext_disp_audio_codec_rx_remove( + struct snd_soc_component *component) { struct msm_ext_disp_audio_codec_rx_data *codec_data; - codec_data = dev_get_drvdata(codec->dev); + codec_data = dev_get_drvdata(component->dev); mutex_destroy(&codec_data->dp_ops_lock); kfree(codec_data); - return 0; + return; } static struct snd_soc_dai_ops msm_ext_disp_audio_codec_rx_dai_ops = { @@ -648,13 +661,12 @@ static struct snd_soc_dai_driver msm_ext_disp_audio_codec_rx_dais[] = { }, }; -static struct snd_soc_codec_driver msm_ext_disp_audio_codec_rx_soc_driver = { +static const struct snd_soc_component_driver msm_ext_disp_codec_rx_driver = { + .name = DRV_NAME, .probe = msm_ext_disp_audio_codec_rx_probe, .remove = msm_ext_disp_audio_codec_rx_remove, - .component_driver = { - .controls = msm_ext_disp_codec_rx_controls, - .num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls), - }, + .controls = msm_ext_disp_codec_rx_controls, + .num_controls = ARRAY_SIZE(msm_ext_disp_codec_rx_controls), }; static int msm_ext_disp_audio_codec_rx_plat_probe( @@ -663,8 +675,8 @@ static int msm_ext_disp_audio_codec_rx_plat_probe( dev_dbg(&pdev->dev, "%s(): dev name %s\n", __func__, dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, - &msm_ext_disp_audio_codec_rx_soc_driver, + return snd_soc_register_component(&pdev->dev, + &msm_ext_disp_codec_rx_driver, msm_ext_disp_audio_codec_rx_dais, ARRAY_SIZE(msm_ext_disp_audio_codec_rx_dais)); } @@ -672,7 +684,7 @@ static int msm_ext_disp_audio_codec_rx_plat_probe( static int msm_ext_disp_audio_codec_rx_plat_remove( struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); return 0; } static const struct of_device_id msm_ext_disp_audio_codec_rx_dt_match[] = { diff --git a/asoc/codecs/msm_stub.c b/asoc/codecs/msm_stub.c index 5bfaa49526..a27111aeac 100644 --- a/asoc/codecs/msm_stub.c +++ b/asoc/codecs/msm_stub.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2011-2014, 2017 The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2014, 2017-2018 The Linux Foundation. All rights reserved. */ #include @@ -10,6 +10,8 @@ #include #include +#define DRV_NAME "msm-stub-codec" + /* A dummy driver useful only to advertise hardware parameters */ static struct snd_soc_dai_driver msm_stub_dais[] = { { @@ -35,19 +37,21 @@ static struct snd_soc_dai_driver msm_stub_dais[] = { }, }; -static struct snd_soc_codec_driver soc_msm_stub = {}; +static const struct snd_soc_component_driver soc_msm_stub = { + .name = DRV_NAME, +}; static int msm_stub_dev_probe(struct platform_device *pdev) { dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev)); - return snd_soc_register_codec(&pdev->dev, + return snd_soc_register_component(&pdev->dev, &soc_msm_stub, msm_stub_dais, ARRAY_SIZE(msm_stub_dais)); } static int msm_stub_dev_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); return 0; } static const struct of_device_id msm_stub_codec_dt_match[] = { diff --git a/asoc/codecs/wcd-clsh.c b/asoc/codecs/wcd-clsh.c index 8c2ae68931..7aec959474 100644 --- a/asoc/codecs/wcd-clsh.c +++ b/asoc/codecs/wcd-clsh.c @@ -13,7 +13,7 @@ #define WCD_USLEEP_RANGE 50 -static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_codec *, +static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_component *, struct wcd_clsh_cdc_info *, u8 req_state, bool en, int mode); @@ -103,66 +103,82 @@ static inline void wcd_clsh_set_int_mode(struct wcd_clsh_cdc_info *clsh_d, clsh_d->interpolator_modes[ffs(clsh_state)] = mode; } -static inline void wcd_clsh_set_buck_mode(struct snd_soc_codec *codec, +static inline void wcd_clsh_set_buck_mode(struct snd_soc_component *component, int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI) - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - 0x08, 0x08); /* set to HIFI */ + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + 0x08, 0x08); /* set to HIFI */ else - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - 0x08, 0x00); /* set to default */ + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + 0x08, 0x00); /* set to default */ } -static inline void wcd_clsh_set_flyback_mode(struct snd_soc_codec *codec, - int mode) +static inline void wcd_clsh_set_flyback_mode( + struct snd_soc_component *component, + int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI) { - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x80); + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x80); } else { - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - 0x04, 0x00); /* set to Default */ - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x70); + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + 0x04, 0x00); /* set to Default */ + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x70); } } -static inline void wcd_clsh_force_iq_ctl(struct snd_soc_codec *codec, +static inline void wcd_clsh_force_iq_ctl(struct snd_soc_component *component, int mode, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, - 0xE0, 0xA0); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, + 0xE0, 0xA0); /* 100usec delay is needed as per HW requirement */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_3, - 0x02, 0x02); - snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_2, - 0xFF, 0x1C); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_MODE_3, + 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_MODE_2, + 0xFF, 0x1C); if (mode == CLS_H_LOHIFI) { - snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2, - 0x20, 0x20); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0xC0); - snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1, - 0x0E, 0x02); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_NEW_INT_PA_MISC2, + 0x20, 0x20); + snd_soc_component_update_bits(component, + WCD9XXX_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0xC0); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_PA_CTL1, + 0x0E, 0x02); } } else { - snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2, - 0x20, 0x00); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0x80); - snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1, - 0x0E, 0x06); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_NEW_INT_PA_MISC2, + 0x20, 0x00); + snd_soc_component_update_bits(component, + WCD9XXX_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0x80); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_PA_CTL1, + 0x0E, 0x06); } } -static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, +static void wcd_clsh_buck_ctrl(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, int mode, bool enable) @@ -170,8 +186,9 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, /* enable/disable buck */ if ((enable && (++clsh_d->buck_users == 1)) || (!enable && (--clsh_d->buck_users == 0))) { - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - (1 << 7), (enable << 7)); + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + (1 << 7), (enable << 7)); /* * 500us sleep is required after buck enable/disable * as per HW requirement @@ -179,18 +196,21 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, usleep_range(500, 510); if (mode == CLS_H_LOHIFI || mode == CLS_H_ULP || mode == CLS_H_HIFI || mode == CLS_H_LP) - snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_3, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_MODE_3, + 0x02, 0x00); - snd_soc_update_bits(codec, WCD9XXX_CLASSH_MODE_2, 0xFF, 0x3A); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_MODE_2, + 0xFF, 0x3A); /* 500usec delay is needed as per HW requirement */ usleep_range(500, 500 + WCD_USLEEP_RANGE); } - dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s\n", + dev_dbg(component->dev, "%s: buck_users %d, enable %d, mode: %s\n", __func__, clsh_d->buck_users, enable, mode_to_str(mode)); } -static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec, +static void wcd_clsh_flyback_ctrl(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, int mode, bool enable) @@ -198,23 +218,25 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec, /* enable/disable flyback */ if ((enable && (++clsh_d->flyback_users == 1)) || (!enable && (--clsh_d->flyback_users == 0))) { - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, - (1 << 6), (enable << 6)); + snd_soc_component_update_bits(component, + WCD9XXX_ANA_RX_SUPPLIES, + (1 << 6), (enable << 6)); /* * 100us sleep is required after flyback enable/disable * as per HW requirement */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, - 0xE0, 0xE0); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, + 0xE0, 0xE0); /* 500usec delay is needed as per HW requirement */ usleep_range(500, 500 + WCD_USLEEP_RANGE); } - dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s\n", + dev_dbg(component->dev, "%s: flyback_users %d, enable %d, mode: %s\n", __func__, clsh_d->flyback_users, enable, mode_to_str(mode)); } -static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec, +static void wcd_clsh_set_hph_mode(struct snd_soc_component *component, int mode) { u8 val = 0; @@ -236,185 +258,189 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec, val = 0x04; break; default: - dev_err(codec->dev, "%s:Invalid mode %d\n", __func__, mode); + dev_err(component->dev, "%s:Invalid mode %d\n", __func__, mode); return; }; - snd_soc_update_bits(codec, WCD9XXX_ANA_HPH, 0x0C, val); + snd_soc_component_update_bits(component, WCD9XXX_ANA_HPH, 0x0C, val); } -static void wcd_clsh_set_flyback_current(struct snd_soc_codec *codec, int mode) +static void wcd_clsh_set_flyback_current(struct snd_soc_component *component, + int mode) { - - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0x0F, 0x0A); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0xF0, 0xA0); + snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF, + 0x0F, 0x0A); + snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF, + 0xF0, 0xA0); /* Sleep needed to avoid click and pop as per HW requirement */ usleep_range(100, 110); } -static void wcd_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec, - int mode) +static void wcd_clsh_set_buck_regulator_mode( + struct snd_soc_component *component, + int mode) { - snd_soc_update_bits(codec, WCD9XXX_ANA_RX_SUPPLIES, + snd_soc_component_update_bits(component, WCD9XXX_ANA_RX_SUPPLIES, 0x02, 0x00); } -static void wcd_clsh_state_ear_aux(struct snd_soc_codec *codec, +static void wcd_clsh_state_ear_aux(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); } -static void wcd_clsh_state_hph_aux(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_aux(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); } -static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_ear(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); } -static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_st(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); } -static void wcd_clsh_state_hph_r(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_r(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_dbg(codec->dev, "%s: Normal mode not applicable for hph_r\n", + dev_dbg(component->dev, "%s: Normal mode not applicable for hph_r\n", __func__); return; } if (is_enable) { - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_force_iq_ctl(codec, mode, true); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_hph_mode(codec, mode); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_force_iq_ctl(component, mode, true); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_hph_mode(component, mode); } else { - wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_hph_mode(component, CLS_H_NORMAL); /* buck and flyback set to default mode and disable */ - wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_hph_l(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_l(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_dbg(codec->dev, "%s: Normal mode not applicable for hph_l\n", + dev_dbg(component->dev, "%s: Normal mode not applicable for hph_l\n", __func__); return; } if (is_enable) { - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_force_iq_ctl(codec, mode, true); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_hph_mode(codec, mode); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_force_iq_ctl(component, mode, true); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_hph_mode(component, mode); } else { - wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_hph_mode(component, CLS_H_NORMAL); /* set buck and flyback to Default Mode */ - wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_aux(struct snd_soc_codec *codec, +static void wcd_clsh_state_aux(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), - is_enable ? "enable" : "disable"); + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (is_enable) { - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); } else { - wcd_clsh_buck_ctrl(codec, clsh_d, mode, false); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_clsh_buck_ctrl(component, clsh_d, mode, false); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_ear(struct snd_soc_codec *codec, +static void wcd_clsh_state_ear(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (is_enable) { - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_force_iq_ctl(codec, mode, true); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_hph_mode(codec, mode); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_force_iq_ctl(component, mode, true); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_hph_mode(component, mode); } else { - wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_hph_mode(component, CLS_H_NORMAL); /* set buck and flyback to Default Mode */ - wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_err(struct snd_soc_codec *codec, +static void wcd_clsh_state_err(struct snd_soc_component *component, struct wcd_clsh_cdc_info *clsh_d, u8 req_state, bool is_enable, int mode) { char msg[128]; - dev_err(codec->dev, + dev_err(component->dev, "%s Wrong request for class H state machine requested to %s %s\n", __func__, is_enable ? "enable" : "disable", state_to_str(req_state, msg, sizeof(msg))); @@ -447,14 +473,14 @@ static bool wcd_clsh_is_state_valid(u8 state) /* * Function: wcd_cls_h_fsm - * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event + * Params: component, cdc_clsh_d, req_state, req_type, clsh_event * Description: * This function handles PRE DAC and POST DAC conditions of different devices * and updates class H configuration of different combination of devices * based on validity of their states. cdc_clsh_d will contain current * class h state information */ -void wcd_cls_h_fsm(struct snd_soc_codec *codec, +void wcd_cls_h_fsm(struct snd_soc_component *component, struct wcd_clsh_cdc_info *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode) @@ -468,14 +494,14 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec, new_state = old_state | req_state; if (!wcd_clsh_is_state_valid(new_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H not a valid new state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); @@ -483,9 +509,9 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec, } cdc_clsh_d->state = new_state; wcd_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode); - (*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state, + (*clsh_state_fp[new_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_ENABLE, int_mode); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str(old_state, msg0, sizeof(msg0)), state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1))); @@ -495,7 +521,7 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec, new_state = old_state & (~req_state); if (new_state < NUM_CLSH_STATES) { if (!wcd_clsh_is_state_valid(old_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s:Invalid old state:%s\n", __func__, state_to_str(old_state, msg0, @@ -503,19 +529,19 @@ void wcd_cls_h_fsm(struct snd_soc_codec *codec, return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); return; } - (*clsh_state_fp[old_state]) (codec, cdc_clsh_d, + (*clsh_state_fp[old_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_DISABLE, int_mode); cdc_clsh_d->state = new_state; wcd_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE); - dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n", + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str(old_state, msg0, sizeof(msg0)), state_to_str(cdc_clsh_d->state, msg1, diff --git a/asoc/codecs/wcd-clsh.h b/asoc/codecs/wcd-clsh.h index 29e5da5a68..1a7759ef0e 100644 --- a/asoc/codecs/wcd-clsh.h +++ b/asoc/codecs/wcd-clsh.h @@ -74,14 +74,14 @@ struct wcd_clsh_cdc_info { }; #ifdef CONFIG_SND_SOC_WCD9XXX_V2 -extern void wcd_cls_h_fsm(struct snd_soc_codec *codec, +extern void wcd_cls_h_fsm(struct snd_soc_component *component, struct wcd_clsh_cdc_info *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode); extern void wcd_cls_h_init(struct wcd_clsh_cdc_info *clsh); #else -extern void wcd_cls_h_fsm(struct snd_soc_codec *codec, +extern void wcd_cls_h_fsm(struct snd_soc_component *component, struct wcd_clsh_cdc_info *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode) diff --git a/asoc/codecs/wcd-irq.c b/asoc/codecs/wcd-irq.c index 37ed566979..d294d40f59 100644 --- a/asoc/codecs/wcd-irq.c +++ b/asoc/codecs/wcd-irq.c @@ -112,12 +112,14 @@ static struct irq_chip wcd_irq_chip = { }; static struct lock_class_key wcd_irq_lock_class; +static struct lock_class_key wcd_irq_lock_requested_class; static int wcd_irq_chip_map(struct irq_domain *irqd, unsigned int virq, irq_hw_number_t hw) { irq_set_chip_and_handler(virq, &wcd_irq_chip, handle_simple_irq); - irq_set_lockdep_class(virq, &wcd_irq_lock_class); + irq_set_lockdep_class(virq, &wcd_irq_lock_class, + &wcd_irq_lock_requested_class); irq_set_nested_thread(virq, 1); irq_set_noprobe(virq); diff --git a/asoc/codecs/wcd-mbhc-adc.c b/asoc/codecs/wcd-mbhc-adc.c index 2170869342..c7882d6cb3 100644 --- a/asoc/codecs/wcd-mbhc-adc.c +++ b/asoc/codecs/wcd-mbhc-adc.c @@ -193,7 +193,7 @@ static bool wcd_mbhc_adc_detect_anc_plug_type(struct wcd_mbhc *mbhc) wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false); WCD_MBHC_REG_READ(WCD_MBHC_FSM_EN, fsm_en); - mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec, + mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component, mbhc->mbhc_cfg->anc_micbias, MICB_ENABLE); @@ -254,7 +254,7 @@ done: /* Restore electrical detection */ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, elect_ctl); - mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec, + mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component, mbhc->mbhc_cfg->anc_micbias, MICB_DISABLE); pr_debug("%s: anc mic %sfound\n", __func__, @@ -283,7 +283,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc) /* If PA is enabled, dont check for cross-connection */ if (mbhc->mbhc_cb->hph_pa_on_status) - if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) + if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) return -EINVAL; /* Read legacy electircal detection and disable */ @@ -349,15 +349,15 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, bool spl_hs = false; int output_mv = 0; int adc_threshold = 0, adc_hph_threshold = 0; - struct snd_soc_codec *codec = mbhc->codec; - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct snd_soc_component *component = mbhc->component; + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); pr_debug("%s: enter\n", __func__); if (!mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) goto exit; /* Bump up MB2 to 2.7V */ - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, mbhc->mbhc_cfg->mbhc_micbias, true); usleep_range(10000, 10100); @@ -391,7 +391,7 @@ static bool wcd_mbhc_adc_check_for_spl_headset(struct wcd_mbhc *mbhc, /* MB2 back to 1.8v if the type is not special headset */ if (spl_hs_cnt && (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT)) { - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, mbhc->mbhc_cfg->mbhc_micbias, false); /* Add 10ms delay for micbias to settle */ usleep_range(10000, 10100); @@ -412,8 +412,8 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) bool is_spl_hs = false; int output_mv = 0; int adc_threshold = 0; - struct snd_soc_codec *codec = mbhc->codec; - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct snd_soc_component *component = mbhc->component; + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); /* * Increase micbias to 2.7V to detect headsets with @@ -425,7 +425,7 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) __func__); return false; } else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) { - ret = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, + ret = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, MIC_BIAS_2, true); if (ret) { pr_err("%s: mbhc_micb_ctrl_thr_mic failed, ret: %d\n", @@ -470,7 +470,8 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) } if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic && !mbhc->micbias_enable) - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, + MIC_BIAS_2, false); pr_debug("%s: leave, micb_enable: %d\n", __func__, mbhc->micbias_enable); @@ -530,18 +531,18 @@ static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc, /* called under codec_resource_lock acquisition */ static void wcd_mbhc_adc_detect_plug_type(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; pr_debug("%s: enter\n", __func__); WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); if (mbhc->mbhc_cb->hph_pull_down_ctrl) - mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false); + mbhc->mbhc_cb->hph_pull_down_ctrl(component, false); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_DETECTION_DONE, 0); if (mbhc->mbhc_cb->mbhc_micbias_control) { - mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2, MICB_ENABLE); } else { pr_err("%s: Mic Bias is not enabled\n", __func__); @@ -558,10 +559,10 @@ static void wcd_micbias_disable(struct wcd_mbhc *mbhc) { if (mbhc->micbias_enable) { mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - mbhc->codec, MIC_BIAS_2, false); + mbhc->component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) mbhc->mbhc_cb->set_micbias_value( - mbhc->codec); + mbhc->component); mbhc->micbias_enable = false; } } @@ -596,7 +597,7 @@ static int wcd_mbhc_get_plug_from_adc(struct wcd_mbhc *mbhc, int adc_result) static void wcd_correct_swch_plug(struct work_struct *work) { struct wcd_mbhc *mbhc; - struct snd_soc_codec *codec; + struct snd_soc_component *component; enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID; unsigned long timeout; bool wrk_complete = false; @@ -612,7 +613,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) pr_debug("%s: enter\n", __func__); mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch); - codec = mbhc->codec; + component = mbhc->component; WCD_MBHC_RSC_LOCK(mbhc); /* Mask ADC COMPLETE interrupt */ @@ -703,7 +704,8 @@ correct_plug_type: } if (mbhc->mbhc_cb->hph_pa_on_status) - is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec); + is_pa_on = mbhc->mbhc_cb->hph_pa_on_status( + mbhc->component); if ((output_mv <= WCD_MBHC_ADC_HS_THRESHOLD_MV) && (!is_pa_on)) { @@ -750,7 +752,7 @@ correct_plug_type: * otherwise report unsupported plug */ if (mbhc->mbhc_cfg->swap_gnd_mic && - mbhc->mbhc_cfg->swap_gnd_mic(codec, + mbhc->mbhc_cfg->swap_gnd_mic(component, true)) { pr_debug("%s: US_EU gpio present,flip switch\n" , __func__); @@ -858,7 +860,7 @@ enable_supply: exit: if (mbhc->mbhc_cb->mbhc_micbias_control && !mbhc->micbias_enable) - mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2, MICB_DISABLE); /* @@ -870,14 +872,14 @@ exit: mbhc->micbias_enable) { if (mbhc->mbhc_cb->mbhc_micbias_control) mbhc->mbhc_cb->mbhc_micbias_control( - codec, MIC_BIAS_2, + component, MIC_BIAS_2, MICB_DISABLE); if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - codec, + component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) { - mbhc->mbhc_cb->set_micbias_value(codec); + mbhc->mbhc_cb->set_micbias_value(component); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0); } mbhc->micbias_enable = false; @@ -905,7 +907,7 @@ exit: } if (mbhc->mbhc_cb->hph_pull_down_ctrl) - mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true); + mbhc->mbhc_cb->hph_pull_down_ctrl(component, true); mbhc->mbhc_cb->lock_sleep(mbhc, false); pr_debug("%s: leave\n", __func__); @@ -953,7 +955,7 @@ static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data) if (mbhc->mbhc_cfg->moisture_en) { if (mbhc->mbhc_cb->hph_pa_on_status) - if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) { + if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) { hphpa_on = true; WCD_MBHC_REG_UPDATE_BITS( WCD_MBHC_HPHL_PA_EN, 0); diff --git a/asoc/codecs/wcd-mbhc-legacy.c b/asoc/codecs/wcd-mbhc-legacy.c index e4196b1035..4b8917d156 100644 --- a/asoc/codecs/wcd-mbhc-legacy.c +++ b/asoc/codecs/wcd-mbhc-legacy.c @@ -48,7 +48,7 @@ static bool wcd_mbhc_detect_anc_plug_type(struct wcd_mbhc *mbhc) if (val) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0); - mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec, + mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component, mbhc->mbhc_cfg->anc_micbias, MICB_ENABLE); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x2); @@ -103,7 +103,7 @@ exit: WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ANC_DET_EN, 0); - mbhc->mbhc_cb->mbhc_micbias_control(mbhc->codec, + mbhc->mbhc_cb->mbhc_micbias_control(mbhc->component, mbhc->mbhc_cfg->anc_micbias, MICB_DISABLE); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MUX_CTL, 0x0); @@ -127,7 +127,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc) /* If PA is enabled, dont check for cross-connection */ if (mbhc->mbhc_cb->hph_pa_on_status) - if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) + if (mbhc->mbhc_cb->hph_pa_on_status(mbhc->component)) return false; WCD_MBHC_REG_READ(WCD_MBHC_ELECT_SCHMT_ISRC, reg1); @@ -168,7 +168,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc) static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; int delay = 0, rc; bool ret = false; u16 hs_comp_res; @@ -184,7 +184,7 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) __func__); return false; } else if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) { - rc = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec, + rc = mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(component, MIC_BIAS_2, true); if (rc) { pr_err("%s: Micbias control for thr mic failed, rc: %d\n", @@ -206,17 +206,17 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) } delay = delay + 50; if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) { - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_PRECHARGE, true); - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_SET_VAL, true); } /* Wait for 50msec for MICBIAS to settle down */ msleep(50); if (mbhc->mbhc_cb->set_auto_zeroing) - mbhc->mbhc_cb->set_auto_zeroing(codec, true); + mbhc->mbhc_cb->set_auto_zeroing(component, true); /* Wait for 50msec for FSM to update result values */ msleep(50); WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res); @@ -237,17 +237,17 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc) ret = true; } if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_PRECHARGE, false); if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable) - mbhc->mbhc_cb->set_micbias_value(codec); + mbhc->mbhc_cb->set_micbias_value(component); if (mbhc->mbhc_cb->set_auto_zeroing) - mbhc->mbhc_cb->set_auto_zeroing(codec, false); + mbhc->mbhc_cb->set_auto_zeroing(component, false); if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic && !mbhc->micbias_enable) - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(component, MIC_BIAS_2, false); pr_debug("%s: leave, micb_enable: %d\n", __func__, @@ -282,7 +282,7 @@ static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc, enum wcd_mbhc_plug_type plug_type) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; /* * Do not disable micbias if recording is going on or @@ -294,7 +294,7 @@ static void wcd_enable_mbhc_supply(struct wcd_mbhc *mbhc, */ if (det_extn_cable_en && mbhc->is_extn_cable && mbhc->mbhc_cb && mbhc->mbhc_cb->extn_use_mb && - mbhc->mbhc_cb->extn_use_mb(codec)) { + mbhc->mbhc_cb->extn_use_mb(component)) { if (plug_type == MBHC_PLUG_TYPE_HEADPHONE || plug_type == MBHC_PLUG_TYPE_HEADSET) wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB); @@ -340,7 +340,7 @@ static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc, } /* Bump up MB2 to 2.7v */ - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, mbhc->mbhc_cfg->mbhc_micbias, true); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1); @@ -356,7 +356,7 @@ static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc, /* MB2 back to 1.8v */ if (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT) { - mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec, + mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->component, mbhc->mbhc_cfg->mbhc_micbias, false); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 1); @@ -399,24 +399,24 @@ static void wcd_cancel_hs_detect_plug(struct wcd_mbhc *mbhc, /* called under codec_resource_lock acquisition */ static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; bool micbias1 = false; pr_debug("%s: enter\n", __func__); WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); if (mbhc->mbhc_cb->hph_pull_down_ctrl) - mbhc->mbhc_cb->hph_pull_down_ctrl(codec, false); + mbhc->mbhc_cb->hph_pull_down_ctrl(component, false); if (mbhc->mbhc_cb->micbias_enable_status) micbias1 = mbhc->mbhc_cb->micbias_enable_status(mbhc, MIC_BIAS_1); if (mbhc->mbhc_cb->set_cap_mode) - mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true); + mbhc->mbhc_cb->set_cap_mode(component, micbias1, true); if (mbhc->mbhc_cb->mbhc_micbias_control) - mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2, MICB_ENABLE); else wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_MB); @@ -430,7 +430,7 @@ static void wcd_mbhc_detect_plug_type(struct wcd_mbhc *mbhc) static void wcd_correct_swch_plug(struct work_struct *work) { struct wcd_mbhc *mbhc; - struct snd_soc_codec *codec; + struct snd_soc_component *component; enum wcd_mbhc_plug_type plug_type = MBHC_PLUG_TYPE_INVALID; unsigned long timeout; u16 hs_comp_res = 0, hphl_sch = 0, mic_sch = 0, btn_result = 0; @@ -448,7 +448,7 @@ static void wcd_correct_swch_plug(struct work_struct *work) pr_debug("%s: enter\n", __func__); mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch); - codec = mbhc->codec; + component = mbhc->component; /* * Enable micbias/pullup for detection in correct work. @@ -528,10 +528,10 @@ correct_plug_type: if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic && mbhc->micbias_enable) { mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - mbhc->codec, MIC_BIAS_2, false); + mbhc->component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) mbhc->mbhc_cb->set_micbias_value( - mbhc->codec); + mbhc->component); mbhc->micbias_enable = false; } goto exit; @@ -554,10 +554,10 @@ correct_plug_type: if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic && mbhc->micbias_enable) { mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - mbhc->codec, MIC_BIAS_2, false); + mbhc->component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) mbhc->mbhc_cb->set_micbias_value( - mbhc->codec); + mbhc->component); mbhc->micbias_enable = false; } goto exit; @@ -566,7 +566,7 @@ correct_plug_type: pr_debug("%s: hs_comp_res: %x\n", __func__, hs_comp_res); if (mbhc->mbhc_cb->hph_pa_on_status) - is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec); + is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(component); /* * instead of hogging system by contineous polling, wait for @@ -627,7 +627,7 @@ correct_plug_type: * otherwise report unsupported plug */ if (mbhc->mbhc_cfg->swap_gnd_mic && - mbhc->mbhc_cfg->swap_gnd_mic(codec, + mbhc->mbhc_cfg->swap_gnd_mic(component, true)) { pr_debug("%s: US_EU gpio present,flip switch\n" , __func__); @@ -733,7 +733,7 @@ enable_supply: exit: if (mbhc->mbhc_cb->mbhc_micbias_control && !mbhc->micbias_enable) - mbhc->mbhc_cb->mbhc_micbias_control(codec, MIC_BIAS_2, + mbhc->mbhc_cb->mbhc_micbias_control(component, MIC_BIAS_2, MICB_DISABLE); /* @@ -745,14 +745,14 @@ exit: mbhc->micbias_enable) { if (mbhc->mbhc_cb->mbhc_micbias_control) mbhc->mbhc_cb->mbhc_micbias_control( - codec, MIC_BIAS_2, + component, MIC_BIAS_2, MICB_DISABLE); if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - codec, + component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) { - mbhc->mbhc_cb->set_micbias_value(codec); + mbhc->mbhc_cb->set_micbias_value(component); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0); } mbhc->micbias_enable = false; @@ -774,10 +774,10 @@ exit: WCD_MBHC_RSC_UNLOCK(mbhc); } if (mbhc->mbhc_cb->set_cap_mode) - mbhc->mbhc_cb->set_cap_mode(codec, micbias1, micbias2); + mbhc->mbhc_cb->set_cap_mode(component, micbias1, micbias2); if (mbhc->mbhc_cb->hph_pull_down_ctrl) - mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true); + mbhc->mbhc_cb->hph_pull_down_ctrl(component, true); mbhc->mbhc_cb->lock_sleep(mbhc, false); pr_debug("%s: leave\n", __func__); @@ -833,7 +833,8 @@ static irqreturn_t wcd_mbhc_hs_rem_irq(int irq, void *data) if (mbhc->mbhc_cfg->moisture_en) { if (mbhc->mbhc_cb->hph_pa_on_status) if ( - mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec)) { + mbhc->mbhc_cb->hph_pa_on_status( + mbhc->component)) { hphpa_on = true; WCD_MBHC_REG_UPDATE_BITS( WCD_MBHC_HPHL_PA_EN, 0); diff --git a/asoc/codecs/wcd-mbhc-v2-api.h b/asoc/codecs/wcd-mbhc-v2-api.h index d89da4caa8..fc00e14174 100644 --- a/asoc/codecs/wcd-mbhc-v2-api.h +++ b/asoc/codecs/wcd-mbhc-v2-api.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD_MBHC_V2_API_H__ #define __WCD_MBHC_V2_API_H__ @@ -10,7 +10,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg); void wcd_mbhc_stop(struct wcd_mbhc *mbhc); -int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, +int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component, const struct wcd_mbhc_cb *mbhc_cb, const struct wcd_mbhc_intr *mbhc_cdc_intr_ids, struct wcd_mbhc_register *wcd_mbhc_regs, @@ -23,7 +23,7 @@ void wcd_mbhc_deinit(struct wcd_mbhc *mbhc); static inline void wcd_mbhc_stop(struct wcd_mbhc *mbhc) { } -int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, +int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component, const struct wcd_mbhc_cb *mbhc_cb, const struct wcd_mbhc_intr *mbhc_cdc_intr_ids, struct wcd_mbhc_register *wcd_mbhc_regs, diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c index 79944b5884..971cf519ba 100644 --- a/asoc/codecs/wcd-mbhc-v2.c +++ b/asoc/codecs/wcd-mbhc-v2.c @@ -36,9 +36,9 @@ EXPORT_SYMBOL(wcd_mbhc_jack_report); static void __hphocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status, int irq) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; - dev_dbg(codec->dev, "%s: clear ocp status %x\n", + dev_dbg(component->dev, "%s: clear ocp status %x\n", __func__, jack_status); if (mbhc->hph_status & jack_status) { @@ -55,7 +55,7 @@ static void __hphocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status, mbhc->hphlocp_cnt = 0; else mbhc->hphrocp_cnt = 0; - mbhc->mbhc_cb->irq_control(codec, irq, true); + mbhc->mbhc_cb->irq_control(component, irq, true); } } @@ -74,21 +74,21 @@ static void hphlocp_off_report(struct wcd_mbhc *mbhc, u32 jack_status) static void wcd_program_hs_vref(struct wcd_mbhc *mbhc) { struct wcd_mbhc_plug_type_cfg *plug_type_cfg; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; u32 reg_val; plug_type_cfg = WCD_MBHC_CAL_PLUG_TYPE_PTR(mbhc->mbhc_cfg->calibration); reg_val = ((plug_type_cfg->v_hs_max - HS_VREF_MIN_VAL) / 100); - dev_dbg(codec->dev, "%s: reg_val = %x\n", __func__, reg_val); + dev_dbg(component->dev, "%s: reg_val = %x\n", __func__, reg_val); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_VREF, reg_val); } static void wcd_program_btn_threshold(const struct wcd_mbhc *mbhc, bool micbias) { struct wcd_mbhc_btn_detect_cfg *btn_det; - struct snd_soc_codec *codec = mbhc->codec; - struct snd_soc_card *card = codec->component.card; + struct snd_soc_component *component = mbhc->component; + struct snd_soc_card *card = component->card; s16 *btn_low, *btn_high; if (mbhc->mbhc_cfg->calibration == NULL) { @@ -101,8 +101,8 @@ static void wcd_program_btn_threshold(const struct wcd_mbhc *mbhc, bool micbias) btn_high = ((void *)&btn_det->_v_btn_low) + (sizeof(btn_det->_v_btn_low[0]) * btn_det->num_btn); - mbhc->mbhc_cb->set_btn_thr(codec, btn_low, btn_high, btn_det->num_btn, - micbias); + mbhc->mbhc_cb->set_btn_thr(component, btn_low, btn_high, + btn_det->num_btn, micbias); } void wcd_enable_curr_micbias(const struct wcd_mbhc *mbhc, @@ -203,7 +203,7 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val, { struct wcd_mbhc *mbhc = (struct wcd_mbhc *)data; enum wcd_notify_event event = (enum wcd_notify_event)val; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; bool micbias2 = false; bool micbias1 = false; u8 fsm_en = 0; @@ -227,10 +227,10 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val, if (!mbhc->micbias_enable) goto out_micb_en; if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) { - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_PRECHARGE, true); - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_SET_VAL, true); /* @@ -240,9 +240,9 @@ static int wcd_event_notify(struct notifier_block *self, unsigned long val, msleep(50); } if (mbhc->mbhc_cb->set_auto_zeroing) - mbhc->mbhc_cb->set_auto_zeroing(codec, true); + mbhc->mbhc_cb->set_auto_zeroing(component, true); if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_PRECHARGE, false); out_micb_en: @@ -258,7 +258,7 @@ out_micb_en: } /* configure cap settings properly when micbias is enabled */ if (mbhc->mbhc_cb->set_cap_mode) - mbhc->mbhc_cb->set_cap_mode(codec, micbias1, true); + mbhc->mbhc_cb->set_cap_mode(component, micbias1, true); break; case WCD_EVENT_PRE_MICBIAS_2_OFF: /* @@ -289,9 +289,9 @@ out_micb_en: } if (mbhc->mbhc_cb->set_auto_zeroing) - mbhc->mbhc_cb->set_auto_zeroing(codec, false); + mbhc->mbhc_cb->set_auto_zeroing(component, false); if (mbhc->mbhc_cb->set_micbias_value && !mbhc->micbias_enable) - mbhc->mbhc_cb->set_micbias_value(codec); + mbhc->mbhc_cb->set_micbias_value(component); /* Enable PULL UP if PA's are enabled */ if ((test_bit(WCD_MBHC_EVENT_PA_HPHL, &mbhc->event_state)) || (test_bit(WCD_MBHC_EVENT_PA_HPHR, @@ -304,7 +304,7 @@ out_micb_en: /* configure cap settings properly when micbias is disabled */ if (mbhc->mbhc_cb->set_cap_mode) - mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false); + mbhc->mbhc_cb->set_cap_mode(component, micbias1, false); break; case WCD_EVENT_PRE_HPHL_PA_OFF: mutex_lock(&mbhc->hphl_pa_lock); @@ -363,12 +363,12 @@ out_micb_en: wcd_enable_curr_micbias(mbhc, WCD_MBHC_EN_PULLUP); break; case WCD_EVENT_OCP_OFF: - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_left_ocp, false); break; case WCD_EVENT_OCP_ON: - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_left_ocp, true); break; @@ -441,7 +441,8 @@ static void wcd_mbhc_clr_and_turnon_hph_padac(struct wcd_mbhc *mbhc) pr_debug("%s: HPHL ANC clear flag and enable ANC_EN\n", __func__); if (mbhc->mbhc_cb->update_anc_state) - mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 0); + mbhc->mbhc_cb->update_anc_state(mbhc->component, + true, 0); } if (test_and_clear_bit(WCD_MBHC_ANC1_OFF_ACK, @@ -450,7 +451,8 @@ static void wcd_mbhc_clr_and_turnon_hph_padac(struct wcd_mbhc *mbhc) pr_debug("%s: HPHR ANC clear flag and enable ANC_EN\n", __func__); if (mbhc->mbhc_cb->update_anc_state) - mbhc->mbhc_cb->update_anc_state(mbhc->codec, true, 1); + mbhc->mbhc_cb->update_anc_state(mbhc->component, + true, 1); } } @@ -493,8 +495,10 @@ static void wcd_mbhc_set_and_turnoff_hph_padac(struct wcd_mbhc *mbhc) set_bit(WCD_MBHC_ANC0_OFF_ACK, &mbhc->hph_anc_state); set_bit(WCD_MBHC_ANC1_OFF_ACK, &mbhc->hph_anc_state); if (mbhc->mbhc_cb->update_anc_state) { - mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 0); - mbhc->mbhc_cb->update_anc_state(mbhc->codec, false, 1); + mbhc->mbhc_cb->update_anc_state(mbhc->component, + false, 0); + mbhc->mbhc_cb->update_anc_state(mbhc->component, + false, 1); } else { pr_debug("%s ANC is off\n", __func__); } @@ -534,7 +538,7 @@ void wcd_mbhc_hs_elec_irq(struct wcd_mbhc *mbhc, int irq_type, pr_debug("%s: irq: %d, enable: %d, intr_status:%lu\n", __func__, irq, enable, mbhc->intr_status); if ((test_bit(irq_type, &mbhc->intr_status)) != enable) { - mbhc->mbhc_cb->irq_control(mbhc->codec, irq, enable); + mbhc->mbhc_cb->irq_control(mbhc->component, irq, enable); if (enable) set_bit(irq_type, &mbhc->intr_status); else @@ -546,7 +550,7 @@ EXPORT_SYMBOL(wcd_mbhc_hs_elec_irq); void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, enum snd_jack_types jack_type) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; bool is_pa_on = false; u8 fsm_en = 0; @@ -575,14 +579,14 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, if (mbhc->micbias_enable) { if (mbhc->mbhc_cb->mbhc_micbias_control) mbhc->mbhc_cb->mbhc_micbias_control( - codec, MIC_BIAS_2, + component, MIC_BIAS_2, MICB_DISABLE); if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - codec, + component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) { - mbhc->mbhc_cb->set_micbias_value(codec); + mbhc->mbhc_cb->set_micbias_value(component); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0); } mbhc->micbias_enable = false; @@ -614,15 +618,15 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, mbhc->hph_status == SND_JACK_HEADSET) { if (mbhc->mbhc_cb->mbhc_micbias_control) mbhc->mbhc_cb->mbhc_micbias_control( - codec, MIC_BIAS_2, + component, MIC_BIAS_2, MICB_DISABLE); if (mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic) mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic( - codec, + component, MIC_BIAS_2, false); if (mbhc->mbhc_cb->set_micbias_value) { mbhc->mbhc_cb->set_micbias_value( - codec); + component); WCD_MBHC_REG_UPDATE_BITS( WCD_MBHC_MICB_CTRL, 0); } @@ -672,7 +676,7 @@ void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion, mbhc->current_plug = MBHC_PLUG_TYPE_ANC_HEADPHONE; if (mbhc->mbhc_cb->hph_pa_on_status) - is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(codec); + is_pa_on = mbhc->mbhc_cb->hph_pa_on_status(component); if (mbhc->impedance_detect && mbhc->mbhc_cb->compute_impedance && @@ -876,10 +880,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) { bool detection_type = 0; bool micbias1 = false; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; enum snd_jack_types jack_type; - dev_dbg(codec->dev, "%s: enter\n", __func__); + dev_dbg(component->dev, "%s: enter\n", __func__); WCD_MBHC_RSC_LOCK(mbhc); mbhc->in_swch_irq_handler = true; @@ -915,10 +919,10 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) goto done; /* Make sure MASTER_BIAS_CTL is enabled */ - mbhc->mbhc_cb->mbhc_bias(codec, true); + mbhc->mbhc_cb->mbhc_bias(component, true); if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_TAIL_CURR, true); if (!mbhc->mbhc_cfg->hs_ext_micbias && @@ -927,13 +931,13 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) * Enable Tx2 RBias if the headset * is using internal micbias */ - mbhc->mbhc_cb->micb_internal(codec, 1, true); + mbhc->mbhc_cb->micb_internal(component, 1, true); /* Remove micbias pulldown */ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 0); /* Apply trim if needed on the device */ if (mbhc->mbhc_cb->trim_btn_reg) - mbhc->mbhc_cb->trim_btn_reg(codec); + mbhc->mbhc_cb->trim_btn_reg(component); /* Enable external voltage source to micbias if present */ if (mbhc->mbhc_cb->enable_mb_source) mbhc->mbhc_cb->enable_mb_source(mbhc, true); @@ -950,11 +954,11 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_ISRC_CTL, 0); if (mbhc->mbhc_cb->mbhc_common_micb_ctrl) - mbhc->mbhc_cb->mbhc_common_micb_ctrl(codec, + mbhc->mbhc_cb->mbhc_common_micb_ctrl(component, MBHC_COMMON_MICB_TAIL_CURR, false); if (mbhc->mbhc_cb->set_cap_mode) - mbhc->mbhc_cb->set_cap_mode(codec, micbias1, false); + mbhc->mbhc_cb->set_cap_mode(component, micbias1, false); mbhc->btn_press_intr = false; mbhc->is_btn_press = false; @@ -968,7 +972,8 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) case MBHC_PLUG_TYPE_HEADSET: /* make sure to turn off Rbias */ if (mbhc->mbhc_cb->micb_internal) - mbhc->mbhc_cb->micb_internal(codec, 1, false); + mbhc->mbhc_cb->micb_internal(component, + 1, false); /* Pulldown micbias */ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_PULLDOWN_CTRL, 1); jack_type = SND_JACK_HEADSET; @@ -998,7 +1003,8 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc) if (mbhc->mbhc_cfg->enable_usbc_analog) { WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 0); if (mbhc->mbhc_cb->clk_setup) - mbhc->mbhc_cb->clk_setup(mbhc->codec, false); + mbhc->mbhc_cb->clk_setup( + mbhc->component, false); } if (mbhc->mbhc_cfg->moisture_en && @@ -1050,7 +1056,7 @@ int wcd_mbhc_get_button_mask(struct wcd_mbhc *mbhc) int mask = 0; int btn; - btn = mbhc->mbhc_cb->map_btn_code_to_num(mbhc->codec); + btn = mbhc->mbhc_cb->map_btn_code_to_num(mbhc->component); switch (btn) { case 0: @@ -1265,7 +1271,7 @@ static irqreturn_t wcd_mbhc_hphl_ocp_irq(int irq, void *data) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1); } else { - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_left_ocp, false); mbhc->hph_status |= SND_JACK_OC_HPHL; @@ -1308,7 +1314,7 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 0); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_OCP_FSM_EN, 1); } else { - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_right_ocp, false); mbhc->hph_status |= SND_JACK_OC_HPHR; @@ -1322,17 +1328,17 @@ done: static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) { int ret = 0; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; pr_debug("%s: enter\n", __func__); WCD_MBHC_RSC_LOCK(mbhc); /* enable HS detection */ if (mbhc->mbhc_cb->hph_pull_up_control_v2) - mbhc->mbhc_cb->hph_pull_up_control_v2(codec, + mbhc->mbhc_cb->hph_pull_up_control_v2(component, HS_PULLUP_I_DEFAULT); else if (mbhc->mbhc_cb->hph_pull_up_control) - mbhc->mbhc_cb->hph_pull_up_control(codec, I_DEFAULT); + mbhc->mbhc_cb->hph_pull_up_control(component, I_DEFAULT); else WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 3); @@ -1350,10 +1356,10 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) mbhc->gnd_swh = 0; if (mbhc->mbhc_cb->hph_pull_up_control_v2) - mbhc->mbhc_cb->hph_pull_up_control_v2(codec, + mbhc->mbhc_cb->hph_pull_up_control_v2(component, HS_PULLUP_I_OFF); else if (mbhc->mbhc_cb->hph_pull_up_control) - mbhc->mbhc_cb->hph_pull_up_control(codec, I_OFF); + mbhc->mbhc_cb->hph_pull_up_control(component, I_OFF); else WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_CTRL, 0); @@ -1363,7 +1369,7 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_GND_PLUG_TYPE, mbhc->gnd_swh); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_SW_HPH_LP_100K_TO_GND, 1); if (mbhc->mbhc_cfg->gnd_det_en && mbhc->mbhc_cb->mbhc_gnd_det_ctrl) - mbhc->mbhc_cb->mbhc_gnd_det_ctrl(codec, true); + mbhc->mbhc_cb->mbhc_gnd_det_ctrl(component, true); WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1); /* @@ -1389,15 +1395,15 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) /* Enable micbias ramp */ if (mbhc->mbhc_cb->mbhc_micb_ramp_control) - mbhc->mbhc_cb->mbhc_micb_ramp_control(codec, true); + mbhc->mbhc_cb->mbhc_micb_ramp_control(component, true); /* enable bias */ - mbhc->mbhc_cb->mbhc_bias(codec, true); + mbhc->mbhc_cb->mbhc_bias(component, true); /* enable MBHC clock */ if (mbhc->mbhc_cb->clk_setup) { if (mbhc->mbhc_cfg->enable_usbc_analog) - mbhc->mbhc_cb->clk_setup(codec, false); + mbhc->mbhc_cb->clk_setup(component, false); else - mbhc->mbhc_cb->clk_setup(codec, true); + mbhc->mbhc_cb->clk_setup(component, true); } /* program HS_VREF value */ @@ -1417,7 +1423,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work) { struct delayed_work *dwork; struct wcd_mbhc *mbhc; - struct snd_soc_codec *codec; + struct snd_soc_component *component; const struct firmware *fw; struct firmware_cal *fw_data = NULL; int ret = -1, retry = 0; @@ -1425,7 +1431,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work) dwork = to_delayed_work(work); mbhc = container_of(dwork, struct wcd_mbhc, mbhc_firmware_dwork); - codec = mbhc->codec; + component = mbhc->component; while (retry < FW_READ_ATTEMPTS) { retry++; @@ -1436,7 +1442,7 @@ static void wcd_mbhc_fw_read(struct work_struct *work) WCD9XXX_MBHC_CAL); if (!fw_data) ret = request_firmware(&fw, "wcd9320/wcd9320_mbhc.bin", - codec->dev); + component->dev); /* * if request_firmware and hwdep cal both fail then * sleep for 4sec for the userspace to send data to kernel @@ -1557,11 +1563,11 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb, if (!mbhc) return -EINVAL; - dev_dbg(mbhc->codec->dev, "%s: mode = %lu\n", __func__, mode); + dev_dbg(mbhc->component->dev, "%s: mode = %lu\n", __func__, mode); if (mode == POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) { if (mbhc->mbhc_cb->clk_setup) - mbhc->mbhc_cb->clk_setup(mbhc->codec, true); + mbhc->mbhc_cb->clk_setup(mbhc->component, true); /* insertion detected, enable L_DET_EN */ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1); } @@ -1571,20 +1577,20 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb, int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg) { int rc = 0; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct snd_soc_card *card; const char *usb_c_dt = "qcom,msm-mbhc-usbc-audio-supported"; if (!mbhc || !mbhc_cfg) return -EINVAL; - codec = mbhc->codec; - card = codec->component.card; + component = mbhc->component; + card = component->card; /* update the mbhc config */ mbhc->mbhc_cfg = mbhc_cfg; - dev_dbg(mbhc->codec->dev, "%s: enter\n", __func__); + dev_dbg(mbhc->component->dev, "%s: enter\n", __func__); /* check if USB C analog is defined on device tree */ mbhc_cfg->enable_usbc_analog = 0; @@ -1602,7 +1608,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg) /* Parse fsa switch handle */ if (mbhc_cfg->enable_usbc_analog) { - dev_dbg(mbhc->codec->dev, "%s: usbc analog enabled\n", + dev_dbg(mbhc->component->dev, "%s: usbc analog enabled\n", __func__); mbhc->swap_thr = GND_MIC_USBC_SWAP_THRESHOLD; mbhc->fsa_np = of_parse_phandle(card->dev->of_node, @@ -1645,7 +1651,7 @@ int wcd_mbhc_start(struct wcd_mbhc *mbhc, struct wcd_mbhc_config *mbhc_cfg) return rc; err: - dev_dbg(mbhc->codec->dev, "%s: leave %d\n", __func__, rc); + dev_dbg(mbhc->component->dev, "%s: leave %d\n", __func__, rc); return rc; } EXPORT_SYMBOL(wcd_mbhc_start); @@ -1656,15 +1662,15 @@ void wcd_mbhc_stop(struct wcd_mbhc *mbhc) if (mbhc->current_plug != MBHC_PLUG_TYPE_NONE) { if (mbhc->mbhc_cb && mbhc->mbhc_cb->skip_imped_detect) - mbhc->mbhc_cb->skip_imped_detect(mbhc->codec); + mbhc->mbhc_cb->skip_imped_detect(mbhc->component); } mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->hph_status = 0; if (mbhc->mbhc_cb && mbhc->mbhc_cb->irq_control) { - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_left_ocp, false); - mbhc->mbhc_cb->irq_control(mbhc->codec, + mbhc->mbhc_cb->irq_control(mbhc->component, mbhc->intr_ids->hph_right_ocp, false); } @@ -1688,7 +1694,7 @@ EXPORT_SYMBOL(wcd_mbhc_stop); * * NOTE: mbhc->mbhc_cfg is not YET configure so shouldn't be used */ -int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, +int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_component *component, const struct wcd_mbhc_cb *mbhc_cb, const struct wcd_mbhc_intr *mbhc_cdc_intr_ids, struct wcd_mbhc_register *wcd_mbhc_regs, @@ -1698,7 +1704,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, int hph_swh = 0; int gnd_swh = 0; u32 hph_moist_config[3]; - struct snd_soc_card *card = codec->component.card; + struct snd_soc_card *card = component->card; const char *hph_switch = "qcom,msm-mbhc-hphl-swh"; const char *gnd_switch = "qcom,msm-mbhc-gnd-swh"; const char *hs_thre = "qcom,msm-mbhc-hs-mic-max-threshold-mv"; @@ -1750,7 +1756,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, mbhc->in_swch_irq_handler = false; mbhc->current_plug = MBHC_PLUG_TYPE_NONE; mbhc->is_btn_press = false; - mbhc->codec = codec; + mbhc->component = component; mbhc->intr_ids = mbhc_cdc_intr_ids; mbhc->impedance_detect = impedance_det_en; mbhc->hphl_swh = hph_swh; @@ -1770,7 +1776,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, return -EINVAL; } if (!mbhc->wcd_mbhc_regs) { - dev_err(codec->dev, "%s: mbhc registers are not defined\n", + dev_err(component->dev, "%s: mbhc registers are not defined\n", __func__); return -EINVAL; } @@ -1780,14 +1786,14 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, !mbhc_cb->free_irq || !mbhc_cb->map_btn_code_to_num || !mbhc_cb->lock_sleep || !mbhc_cb->mbhc_bias || !mbhc_cb->set_btn_thr) { - dev_err(codec->dev, "%s: required mbhc callbacks are not defined\n", + dev_err(component->dev, "%s: required mbhc callbacks are not defined\n", __func__); return -EINVAL; } /* No need to create new sound card jacks if is is already created */ if (mbhc->headset_jack.jack == NULL) { - ret = snd_soc_card_jack_new(codec->component.card, + ret = snd_soc_card_jack_new(component->card, "Headset Jack", WCD_MBHC_JACK_MASK, &mbhc->headset_jack, NULL, 0); if (ret) { @@ -1795,7 +1801,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, return ret; } - ret = snd_soc_card_jack_new(codec->component.card, + ret = snd_soc_card_jack_new(component->card, "Button Jack", WCD_MBHC_JACK_BUTTON_MASK, &mbhc->button_jack, NULL, 0); @@ -1857,16 +1863,17 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, pr_err("%s: mbhc function pointer is NULL\n", __func__); goto err_mbhc_sw_irq; } - ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->mbhc_sw_intr, - wcd_mbhc_mech_plug_detect_irq, - "mbhc sw intr", mbhc); + ret = mbhc->mbhc_cb->request_irq(component, + mbhc->intr_ids->mbhc_sw_intr, + wcd_mbhc_mech_plug_detect_irq, + "mbhc sw intr", mbhc); if (ret) { pr_err("%s: Failed to request irq %d, ret = %d\n", __func__, mbhc->intr_ids->mbhc_sw_intr, ret); goto err_mbhc_sw_irq; } - ret = mbhc->mbhc_cb->request_irq(codec, + ret = mbhc->mbhc_cb->request_irq(component, mbhc->intr_ids->mbhc_btn_press_intr, wcd_mbhc_btn_press_handler, "Button Press detect", mbhc); @@ -1876,7 +1883,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, goto err_btn_press_irq; } - ret = mbhc->mbhc_cb->request_irq(codec, + ret = mbhc->mbhc_cb->request_irq(component, mbhc->intr_ids->mbhc_btn_release_intr, wcd_mbhc_release_handler, "Button Release detect", mbhc); @@ -1886,7 +1893,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, goto err_btn_release_irq; } - ret = mbhc->mbhc_cb->request_irq(codec, + ret = mbhc->mbhc_cb->request_irq(component, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc->mbhc_fn->wcd_mbhc_hs_ins_irq, "Elect Insert", mbhc); @@ -1895,11 +1902,11 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, mbhc->intr_ids->mbhc_hs_ins_intr); goto err_mbhc_hs_ins_irq; } - mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_ins_intr, + mbhc->mbhc_cb->irq_control(component, mbhc->intr_ids->mbhc_hs_ins_intr, false); clear_bit(WCD_MBHC_ELEC_HS_INS, &mbhc->intr_status); - ret = mbhc->mbhc_cb->request_irq(codec, + ret = mbhc->mbhc_cb->request_irq(component, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc->mbhc_fn->wcd_mbhc_hs_rem_irq, "Elect Remove", mbhc); @@ -1908,22 +1915,24 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, mbhc->intr_ids->mbhc_hs_rem_intr); goto err_mbhc_hs_rem_irq; } - mbhc->mbhc_cb->irq_control(codec, mbhc->intr_ids->mbhc_hs_rem_intr, + mbhc->mbhc_cb->irq_control(component, mbhc->intr_ids->mbhc_hs_rem_intr, false); clear_bit(WCD_MBHC_ELEC_HS_REM, &mbhc->intr_status); - ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_left_ocp, - wcd_mbhc_hphl_ocp_irq, "HPH_L OCP detect", - mbhc); + ret = mbhc->mbhc_cb->request_irq(component, + mbhc->intr_ids->hph_left_ocp, + wcd_mbhc_hphl_ocp_irq, "HPH_L OCP detect", + mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->hph_left_ocp); goto err_hphl_ocp_irq; } - ret = mbhc->mbhc_cb->request_irq(codec, mbhc->intr_ids->hph_right_ocp, - wcd_mbhc_hphr_ocp_irq, "HPH_R OCP detect", - mbhc); + ret = mbhc->mbhc_cb->request_irq(component, + mbhc->intr_ids->hph_right_ocp, + wcd_mbhc_hphr_ocp_irq, "HPH_R OCP detect", + mbhc); if (ret) { pr_err("%s: Failed to request irq %d\n", __func__, mbhc->intr_ids->hph_right_ocp); @@ -1935,19 +1944,22 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec, return ret; err_hphr_ocp_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_left_ocp, mbhc); err_hphl_ocp_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_rem_intr, + mbhc); err_mbhc_hs_rem_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_ins_intr, + mbhc); err_mbhc_hs_ins_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr, + mbhc->mbhc_cb->free_irq(component, + mbhc->intr_ids->mbhc_btn_release_intr, mbhc); err_btn_release_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr, + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_btn_press_intr, mbhc); err_btn_press_irq: - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_sw_intr, mbhc); err_mbhc_sw_irq: if (mbhc->mbhc_cb->register_notifier) mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false); @@ -1960,17 +1972,20 @@ EXPORT_SYMBOL(wcd_mbhc_init); void wcd_mbhc_deinit(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_sw_intr, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_press_intr, + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_sw_intr, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_btn_press_intr, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_btn_release_intr, + mbhc->mbhc_cb->free_irq(component, + mbhc->intr_ids->mbhc_btn_release_intr, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_ins_intr, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->mbhc_hs_rem_intr, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_left_ocp, mbhc); - mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_right_ocp, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_ins_intr, + mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->mbhc_hs_rem_intr, + mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_left_ocp, mbhc); + mbhc->mbhc_cb->free_irq(component, mbhc->intr_ids->hph_right_ocp, mbhc); if (mbhc->mbhc_cb && mbhc->mbhc_cb->register_notifier) mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false); if (mbhc->mbhc_fn->wcd_cancel_hs_detect_plug) { diff --git a/asoc/codecs/wcd-mbhc-v2.h b/asoc/codecs/wcd-mbhc-v2.h index 6915344ae0..451ca91cd8 100644 --- a/asoc/codecs/wcd-mbhc-v2.h +++ b/asoc/codecs/wcd-mbhc-v2.h @@ -51,7 +51,7 @@ #define WCD_MBHC_REG_UPDATE_BITS(function, val) \ do { \ if (mbhc->wcd_mbhc_regs[function].reg) { \ - snd_soc_update_bits(mbhc->codec, \ + snd_soc_component_update_bits(mbhc->component, \ mbhc->wcd_mbhc_regs[function].reg, \ mbhc->wcd_mbhc_regs[function].mask, \ val << (mbhc->wcd_mbhc_regs[function].offset)); \ @@ -61,7 +61,7 @@ do { \ #define WCD_MBHC_REG_READ(function, val) \ do { \ if (mbhc->wcd_mbhc_regs[function].reg) { \ - val = (((snd_soc_read(mbhc->codec, \ + val = (((snd_soc_component_read32(mbhc->component, \ mbhc->wcd_mbhc_regs[function].reg)) & \ (mbhc->wcd_mbhc_regs[function].mask)) >> \ (mbhc->wcd_mbhc_regs[function].offset)); \ @@ -420,7 +420,7 @@ struct wcd_mbhc_config { void *calibration; bool detect_extn_cable; bool mono_stero_detection; - bool (*swap_gnd_mic)(struct snd_soc_codec *codec, bool active); + bool (*swap_gnd_mic)(struct snd_soc_component *component, bool active); bool hs_ext_micbias; bool gnd_det_en; int key_code[WCD_MBHC_KEYCODE_NUM]; @@ -452,53 +452,64 @@ struct wcd_mbhc_register { }; struct wcd_mbhc_cb { - int (*enable_mb_source)(struct wcd_mbhc *, bool); - void (*trim_btn_reg)(struct snd_soc_codec *); - void (*compute_impedance)(struct wcd_mbhc *, uint32_t *, uint32_t *); - void (*set_micbias_value)(struct snd_soc_codec *); - void (*set_auto_zeroing)(struct snd_soc_codec *, bool); - struct firmware_cal * (*get_hwdep_fw_cal)(struct wcd_mbhc *, + int (*enable_mb_source)(struct wcd_mbhc *mbhc, bool turn_on); + void (*trim_btn_reg)(struct snd_soc_component *component); + void (*compute_impedance)(struct wcd_mbhc *mbhc, + uint32_t *zl, uint32_t *zr); + void (*set_micbias_value)(struct snd_soc_component *component); + void (*set_auto_zeroing)(struct snd_soc_component *component, + bool enable); + struct firmware_cal * (*get_hwdep_fw_cal)(struct wcd_mbhc *mbhc, enum wcd_cal_type); - void (*set_cap_mode)(struct snd_soc_codec *, bool, bool); - int (*register_notifier)(struct wcd_mbhc *, + void (*set_cap_mode)(struct snd_soc_component *component, + bool micbias1, bool micbias2); + int (*register_notifier)(struct wcd_mbhc *mbhc, struct notifier_block *nblock, bool enable); - int (*request_irq)(struct snd_soc_codec *, - int, irq_handler_t, const char *, void *); - void (*irq_control)(struct snd_soc_codec *, + int (*request_irq)(struct snd_soc_component *component, + int irq, irq_handler_t handler, + const char *name, void *data); + void (*irq_control)(struct snd_soc_component *component, int irq, bool enable); - int (*free_irq)(struct snd_soc_codec *, - int irq, void *); - void (*clk_setup)(struct snd_soc_codec *, bool); - int (*map_btn_code_to_num)(struct snd_soc_codec *); - bool (*lock_sleep)(struct wcd_mbhc *, bool); - bool (*micbias_enable_status)(struct wcd_mbhc *, int); - void (*mbhc_bias)(struct snd_soc_codec *, bool); - void (*mbhc_common_micb_ctrl)(struct snd_soc_codec *, - int event, bool); - void (*micb_internal)(struct snd_soc_codec *, - int micb_num, bool); - bool (*hph_pa_on_status)(struct snd_soc_codec *); - void (*set_btn_thr)(struct snd_soc_codec *, s16 *, s16 *, - int num_btn, bool); - void (*hph_pull_up_control)(struct snd_soc_codec *, + int (*free_irq)(struct snd_soc_component *component, + int irq, void *data); + void (*clk_setup)(struct snd_soc_component *component, bool enable); + int (*map_btn_code_to_num)(struct snd_soc_component *component); + bool (*lock_sleep)(struct wcd_mbhc *mbhc, bool lock); + bool (*micbias_enable_status)(struct wcd_mbhc *mbhc, int micb_num); + void (*mbhc_bias)(struct snd_soc_component *component, bool enable); + void (*mbhc_common_micb_ctrl)(struct snd_soc_component *component, + int event, bool enable); + void (*micb_internal)(struct snd_soc_component *component, + int micb_num, bool enable); + bool (*hph_pa_on_status)(struct snd_soc_component *component); + void (*set_btn_thr)(struct snd_soc_component *component, + s16 *btn_low, s16 *btn_high, + int num_btn, bool is_micbias); + void (*hph_pull_up_control)(struct snd_soc_component *component, enum mbhc_hs_pullup_iref); - int (*mbhc_micbias_control)(struct snd_soc_codec *, int, int req); - void (*mbhc_micb_ramp_control)(struct snd_soc_codec *, bool); - void (*skip_imped_detect)(struct snd_soc_codec *); - bool (*extn_use_mb)(struct snd_soc_codec *); - int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_codec *, int, bool); - void (*mbhc_gnd_det_ctrl)(struct snd_soc_codec *, bool); - void (*hph_pull_down_ctrl)(struct snd_soc_codec *, bool); - void (*mbhc_moisture_config)(struct wcd_mbhc *); - bool (*hph_register_recovery)(struct wcd_mbhc *); - void (*update_anc_state)(struct snd_soc_codec *codec, - bool enable, int anc_num); + int (*mbhc_micbias_control)(struct snd_soc_component *component, + int micb_num, int req); + void (*mbhc_micb_ramp_control)(struct snd_soc_component *component, + bool enable); + void (*skip_imped_detect)(struct snd_soc_component *component); + bool (*extn_use_mb)(struct snd_soc_component *component); + int (*mbhc_micb_ctrl_thr_mic)(struct snd_soc_component *component, + int micb_num, bool req_en); + void (*mbhc_gnd_det_ctrl)(struct snd_soc_component *component, + bool enable); + void (*hph_pull_down_ctrl)(struct snd_soc_component *component, + bool enable); + void (*mbhc_moisture_config)(struct wcd_mbhc *mbhc); + bool (*hph_register_recovery)(struct wcd_mbhc *mbhc); + void (*update_anc_state)(struct snd_soc_component *component, + bool enable, int anc_num); bool (*is_anc_on)(struct wcd_mbhc *mbhc); - void (*hph_pull_up_control_v2)(struct snd_soc_codec *, int); - bool (*mbhc_get_moisture_status)(struct wcd_mbhc *); - void (*mbhc_moisture_polling_ctrl)(struct wcd_mbhc *, bool); - void (*mbhc_moisture_detect_en)(struct wcd_mbhc *, bool); + void (*hph_pull_up_control_v2)(struct snd_soc_component *component, + int pull_up_cur); + bool (*mbhc_get_moisture_status)(struct wcd_mbhc *mbhc); + void (*mbhc_moisture_polling_ctrl)(struct wcd_mbhc *mbhc, bool enable); + void (*mbhc_moisture_detect_en)(struct wcd_mbhc *mbhc, bool enable); }; struct wcd_mbhc_fn { @@ -544,7 +555,7 @@ struct wcd_mbhc { bool is_btn_already_regd; bool extn_cable_hph_rem; - struct snd_soc_codec *codec; + struct snd_soc_component *component; /* Work to perform MBHC Firmware Read */ struct delayed_work mbhc_firmware_dwork; const struct firmware *mbhc_fw; diff --git a/asoc/codecs/wcd9335.c b/asoc/codecs/wcd9335.c index afd8c5d62e..740f232b70 100644 --- a/asoc/codecs/wcd9335.c +++ b/asoc/codecs/wcd9335.c @@ -41,6 +41,8 @@ #include "wcdcal-hwdep.h" #include "wcd-mbhc-v2-api.h" +#define DRV_NAME "tasha_codec" + #define TASHA_RX_PORT_START_NUMBER 16 #define WCD9335_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ @@ -547,9 +549,9 @@ static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1); static struct snd_soc_dai_driver tasha_dai[]; static int wcd9335_get_micb_vout_ctl_val(u32 micb_mv); -static int tasha_config_compander(struct snd_soc_codec *, int, int); -static void tasha_codec_set_tx_hold(struct snd_soc_codec *, u16, bool); -static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec, +static int tasha_config_compander(struct snd_soc_component *, int, int); +static void tasha_codec_set_tx_hold(struct snd_soc_component *, u16, bool); +static int tasha_codec_internal_rco_ctrl(struct snd_soc_component *component, bool enable); /* Hold instance to soundwire platform device */ @@ -699,7 +701,7 @@ struct tasha_priv { struct device *dev; struct wcd9xxx *wcd9xxx; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u32 adc_count; u32 rx_bias_count; s32 dmic_0_1_clk_cnt; @@ -797,7 +799,7 @@ struct tasha_priv { struct mutex swr_clk_lock; int swr_clk_users; int native_clk_users; - int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high); + int (*zdet_gpio_cb)(struct snd_soc_component *component, bool high); struct snd_info_entry *entry; struct snd_info_entry *version_entry; @@ -805,7 +807,7 @@ struct tasha_priv { struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX]; - int (*machine_codec_event_cb)(struct snd_soc_codec *codec, + int (*machine_codec_event_cb)(struct snd_soc_component *component, enum wcd9335_codec_event); int spkr_gain_offset; int spkr_mode; @@ -832,7 +834,7 @@ struct tasha_priv { int child_count; }; -static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, +static int tasha_codec_vote_max_bw(struct snd_soc_component *component, bool vote); static const struct tasha_reg_mask_val tasha_spkr_default[] = { @@ -857,14 +859,14 @@ static const struct tasha_reg_mask_val tasha_spkr_mode1[] = { * tasha_set_spkr_gain_offset - offset the speaker path * gain with the given offset value. * - * @codec: codec instance + * @component: codec component instance * @offset: Indicates speaker path gain offset value. * * Returns 0 on success or -EINVAL on error. */ -int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset) +int tasha_set_spkr_gain_offset(struct snd_soc_component *component, int offset) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); if (!priv) return -EINVAL; @@ -878,14 +880,14 @@ EXPORT_SYMBOL(tasha_set_spkr_gain_offset); * tasha_set_spkr_mode - Configures speaker compander and smartboost * settings based on speaker mode. * - * @codec: codec instance + * @component: codec component instance * @mode: Indicates speaker configuration mode. * * Returns 0 on success or -EINVAL on error. */ -int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode) +int tasha_set_spkr_mode(struct snd_soc_component *component, int mode) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); int i; const struct tasha_reg_mask_val *regs; int size; @@ -906,21 +908,23 @@ int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode) priv->spkr_mode = mode; for (i = 0; i < size; i++) - snd_soc_update_bits(codec, regs[i].reg, + snd_soc_component_update_bits(component, regs[i].reg, regs[i].mask, regs[i].val); return 0; } EXPORT_SYMBOL(tasha_set_spkr_mode); -static void tasha_enable_sido_buck(struct snd_soc_codec *codec) +static void tasha_enable_sido_buck(struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - snd_soc_update_bits(codec, WCD9335_ANA_RCO, 0x80, 0x80); - snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x02, 0x02); + snd_soc_component_update_bits(component, WCD9335_ANA_RCO, 0x80, 0x80); + snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL, + 0x02, 0x02); /* 100us sleep needed after IREF settings */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x04, 0x04); + snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL, + 0x04, 0x04); /* 100us sleep needed after VREF settings */ usleep_range(100, 110); tasha->resmgr->sido_input_src = SIDO_SOURCE_RCO_BG; @@ -928,30 +932,30 @@ static void tasha_enable_sido_buck(struct snd_soc_codec *codec) static void tasha_cdc_sido_ccl_enable(struct tasha_priv *tasha, bool ccl_flag) { - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; - if (!codec) + if (!component) return; if (!TASHA_IS_2_0(tasha->wcd9xxx)) { - dev_dbg(codec->dev, "%s: tasha version < 2p0, return\n", + dev_dbg(component->dev, "%s: tasha version < 2p0, return\n", __func__); return; } - dev_dbg(codec->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n", + dev_dbg(component->dev, "%s: sido_ccl_cnt=%d, ccl_flag:%d\n", __func__, tasha->sido_ccl_cnt, ccl_flag); if (ccl_flag) { if (++tasha->sido_ccl_cnt == 1) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x6E); } else { if (tasha->sido_ccl_cnt == 0) { - dev_dbg(codec->dev, "%s: sido_ccl already disabled\n", + dev_dbg(component->dev, "%s: sido_ccl already disabled\n", __func__); return; } if (--tasha->sido_ccl_cnt == 0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_SIDO_SIDO_CCL_10, 0xFF, 0x02); } } @@ -1010,10 +1014,10 @@ static void tasha_codec_apply_sido_voltage( enum tasha_sido_voltage req_mv) { u32 vout_d_val; - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; int ret; - if (!codec) + if (!component) return; if (!tasha_cdc_is_svs_enabled(tasha)) @@ -1025,19 +1029,19 @@ static void tasha_codec_apply_sido_voltage( ret = tasha_cdc_check_sido_value(req_mv); if (ret < 0) { - dev_dbg(codec->dev, "%s: requested mv=%d not in range\n", + dev_dbg(component->dev, "%s: requested mv=%d not in range\n", __func__, req_mv); return; } if (req_mv == tasha->sido_voltage) { - dev_dbg(codec->dev, "%s: Already at requested mv=%d\n", + dev_dbg(component->dev, "%s: Already at requested mv=%d\n", __func__, req_mv); return; } if (req_mv == sido_buck_svs_voltage) { if (test_bit(AUDIO_NOMINAL, &tasha->status_mask) || test_bit(CPE_NOMINAL, &tasha->status_mask)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: nominal client running, status_mask=%lu\n", __func__, tasha->status_mask); return; @@ -1045,17 +1049,19 @@ static void tasha_codec_apply_sido_voltage( } /* compute the vout_d step value */ vout_d_val = CALCULATE_VOUT_D(req_mv); - snd_soc_write(codec, WCD9335_ANA_BUCK_VOUT_D, vout_d_val & 0xFF); - snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, 0x80, 0x80); + snd_soc_component_write(component, WCD9335_ANA_BUCK_VOUT_D, + vout_d_val & 0xFF); + snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL, + 0x80, 0x80); /* 1 msec sleep required after SIDO Vout_D voltage change */ usleep_range(1000, 1100); tasha->sido_voltage = req_mv; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: updated SIDO buck Vout_D to %d, vout_d step = %u\n", __func__, tasha->sido_voltage, vout_d_val); - snd_soc_update_bits(codec, WCD9335_ANA_BUCK_CTL, + snd_soc_component_update_bits(component, WCD9335_ANA_BUCK_CTL, 0x80, 0x00); } @@ -1084,43 +1090,47 @@ err: return ret; } -int tasha_enable_efuse_sensing(struct snd_soc_codec *codec) +int tasha_enable_efuse_sensing(struct snd_soc_component *component) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); - tasha_cdc_mclk_enable(codec, true, false); + tasha_cdc_mclk_enable(component, true, false); if (!TASHA_IS_2_0(priv->wcd9xxx)) - snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, - 0x1E, 0x02); - snd_soc_update_bits(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, + 0x1E, 0x02); + snd_soc_component_update_bits(component, + WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, + 0x01, 0x01); /* * 5ms sleep required after enabling efuse control * before checking the status. */ usleep_range(5000, 5500); - if (!(snd_soc_read(codec, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01)) + if (!(snd_soc_component_read32( + component, WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01)) WARN(1, "%s: Efuse sense is not complete\n", __func__); if (TASHA_IS_2_0(priv->wcd9xxx)) { - if (!(snd_soc_read(codec, + if (!(snd_soc_component_read32(component, WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT0) & 0x40)) - snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, - 0x04, 0x00); - tasha_enable_sido_buck(codec); + snd_soc_component_update_bits(component, + WCD9335_HPH_R_ATEST, + 0x04, 0x00); + tasha_enable_sido_buck(component); } - tasha_cdc_mclk_enable(codec, false, false); + tasha_cdc_mclk_enable(component, false, false); return 0; } EXPORT_SYMBOL(tasha_enable_efuse_sensing); -void *tasha_get_afe_config(struct snd_soc_codec *codec, +void *tasha_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); switch (config_type) { case AFE_SLIMBUS_SLAVE_CONFIG: @@ -1138,7 +1148,7 @@ void *tasha_get_afe_config(struct snd_soc_codec *codec, case AFE_CDC_REGISTER_PAGE_CONFIG: return &tasha_cdc_reg_page_cfg; default: - dev_err(codec->dev, "%s: Unknown config_type 0x%x\n", + dev_err(component->dev, "%s: Unknown config_type 0x%x\n", __func__, config_type); return NULL; } @@ -1152,29 +1162,30 @@ EXPORT_SYMBOL(tasha_get_afe_config); * codec driver once codec comes out of reset after ADSP SSR. * * @machine_event_cb: callback function from machine driver - * @codec: Codec instance + * @component: Codec component instance * * Return: none */ void tasha_event_register( - int (*machine_event_cb)(struct snd_soc_codec *codec, + int (*machine_event_cb)(struct snd_soc_component *component, enum wcd9335_codec_event), - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (tasha) tasha->machine_codec_event_cb = machine_event_cb; else - dev_dbg(codec->dev, "%s: Invalid tasha_priv data\n", __func__); + dev_dbg(component->dev, "%s: Invalid tasha_priv data\n", + __func__); } EXPORT_SYMBOL(tasha_event_register); -static int tasha_mbhc_request_irq(struct snd_soc_codec *codec, +static int tasha_mbhc_request_irq(struct snd_soc_component *component, int irq, irq_handler_t handler, const char *name, void *data) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -1182,10 +1193,10 @@ static int tasha_mbhc_request_irq(struct snd_soc_codec *codec, return wcd9xxx_request_irq(core_res, irq, handler, name, data); } -static void tasha_mbhc_irq_control(struct snd_soc_codec *codec, +static void tasha_mbhc_irq_control(struct snd_soc_component *component, int irq, bool enable) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -1195,10 +1206,10 @@ static void tasha_mbhc_irq_control(struct snd_soc_codec *codec, wcd9xxx_disable_irq(core_res, irq); } -static int tasha_mbhc_free_irq(struct snd_soc_codec *codec, +static int tasha_mbhc_free_irq(struct snd_soc_component *component, int irq, void *data) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -1207,34 +1218,35 @@ static int tasha_mbhc_free_irq(struct snd_soc_codec *codec, return 0; } -static void tasha_mbhc_clk_setup(struct snd_soc_codec *codec, +static void tasha_mbhc_clk_setup(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, + snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1, 0x80, 0x80); else - snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, + snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1, 0x80, 0x00); } -static int tasha_mbhc_btn_to_num(struct snd_soc_codec *codec) +static int tasha_mbhc_btn_to_num(struct snd_soc_component *component) { - return snd_soc_read(codec, WCD9335_ANA_MBHC_RESULT_3) & 0x7; + return snd_soc_component_read32( + component, WCD9335_ANA_MBHC_RESULT_3) & 0x7; } -static void tasha_mbhc_mbhc_bias_control(struct snd_soc_codec *codec, +static void tasha_mbhc_mbhc_bias_control(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_ELECT, 0x01, 0x01); else - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_ELECT, 0x01, 0x00); } -static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec, +static void tasha_mbhc_program_btn_thr(struct snd_soc_component *component, s16 *btn_low, s16 *btn_high, int num_btn, bool is_micbias) { @@ -1242,7 +1254,7 @@ static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec, int vth; if (num_btn > WCD_MBHC_DEF_BUTTONS) { - dev_err(codec->dev, "%s: invalid number of buttons: %d\n", + dev_err(component->dev, "%s: invalid number of buttons: %d\n", __func__, num_btn); return; } @@ -1254,17 +1266,18 @@ static void tasha_mbhc_program_btn_thr(struct snd_soc_codec *codec, */ for (i = 0; i < num_btn; i++) { vth = ((btn_high[i] * 2) / 25) & 0x3F; - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN0 + i, - 0xFC, vth << 2); - dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n", + snd_soc_component_update_bits( + component, WCD9335_ANA_MBHC_BTN0 + i, + 0xFC, vth << 2); + dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n", __func__, i, btn_high[i], vth); } } static bool tasha_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock) { - struct snd_soc_codec *codec = mbhc->codec; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = mbhc->component; + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -1280,8 +1293,8 @@ static int tasha_mbhc_register_notifier(struct wcd_mbhc *mbhc, struct notifier_block *nblock, bool enable) { - struct snd_soc_codec *codec = mbhc->codec; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = mbhc->component; + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (enable) return blocking_notifier_chain_register(&tasha->notifier, @@ -1296,22 +1309,25 @@ static bool tasha_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) u8 val; if (micb_num == MIC_BIAS_2) { - val = (snd_soc_read(mbhc->codec, WCD9335_ANA_MICB2) >> 6); + val = (snd_soc_component_read32( + mbhc->component, WCD9335_ANA_MICB2) >> 6); if (val == 0x01) return true; } return false; } -static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_codec *codec) +static bool tasha_mbhc_hph_pa_on_status(struct snd_soc_component *component) { - return (snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) ? true : false; + return (snd_soc_component_read32(component, WCD9335_ANA_HPH) & 0xC0) ? + true : false; } -static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec, - enum mbhc_hs_pullup_iref pull_up_cur) +static void tasha_mbhc_hph_l_pull_up_control( + struct snd_soc_component *component, + enum mbhc_hs_pullup_iref pull_up_cur) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (!tasha) return; @@ -1321,22 +1337,24 @@ static void tasha_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec, pull_up_cur == I_DEFAULT) pull_up_cur = I_2P0_UA; - dev_dbg(codec->dev, "%s: HS pull up current:%d\n", + dev_dbg(component->dev, "%s: HS pull up current:%d\n", __func__, pull_up_cur); if (TASHA_IS_2_0(tasha->wcd9xxx)) - snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL, - 0xC0, pull_up_cur << 6); + snd_soc_component_update_bits(component, + WCD9335_MBHC_PLUG_DETECT_CTL, + 0xC0, pull_up_cur << 6); else - snd_soc_update_bits(codec, WCD9335_MBHC_PLUG_DETECT_CTL, - 0xC0, 0x40); + snd_soc_component_update_bits(component, + WCD9335_MBHC_PLUG_DETECT_CTL, + 0xC0, 0x40); } static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc, bool turn_on) { - struct snd_soc_codec *codec = mbhc->codec; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = mbhc->component; + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; struct on_demand_supply *supply; @@ -1345,20 +1363,21 @@ static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc, supply = &tasha->on_demand_list[ON_DEMAND_MICBIAS]; if (!supply->supply) { - dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n", + dev_dbg(component->dev, "%s: warning supply not present ond for %s\n", __func__, "onDemand Micbias"); return ret; } - dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on, + dev_dbg(component->dev, "%s turn_on: %d count: %d\n", __func__, turn_on, supply->ondemand_supply_count); if (turn_on) { if (!(supply->ondemand_supply_count)) { ret = snd_soc_dapm_force_enable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), "MICBIAS_REGULATOR"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync( + snd_soc_component_get_dapm(component)); } supply->ondemand_supply_count++; } else { @@ -1366,27 +1385,27 @@ static int tasha_enable_ext_mb_source(struct wcd_mbhc *mbhc, supply->ondemand_supply_count--; if (!(supply->ondemand_supply_count)) { ret = snd_soc_dapm_disable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), "MICBIAS_REGULATOR"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); } } if (ret) - dev_err(codec->dev, "%s: Failed to %s external micbias source\n", + dev_err(component->dev, "%s: Failed to %s external micbias source\n", __func__, turn_on ? "enable" : "disabled"); else - dev_dbg(codec->dev, "%s: %s external micbias source\n", + dev_dbg(component->dev, "%s: %s external micbias source\n", __func__, turn_on ? "Enabled" : "Disabled"); return ret; } -static int tasha_micbias_control(struct snd_soc_codec *codec, +static int tasha_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int micb_index = micb_num - 1; u16 micb_reg; int pre_off_event = 0, post_off_event = 0; @@ -1394,7 +1413,7 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, int post_dapm_on = 0; if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) { - dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n", + dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n", __func__, micb_index); return -EINVAL; } @@ -1417,7 +1436,7 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, micb_reg = WCD9335_ANA_MICB4; break; default: - dev_err(codec->dev, "%s: Invalid micbias number: %d\n", + dev_err(component->dev, "%s: Invalid micbias number: %d\n", __func__, micb_num); return -EINVAL; } @@ -1428,19 +1447,22 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, tasha->pullup_ref[micb_index]++; if ((tasha->pullup_ref[micb_index] == 1) && (tasha->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); break; case MICB_PULLUP_DISABLE: if (tasha->pullup_ref[micb_index] > 0) tasha->pullup_ref[micb_index]--; if ((tasha->pullup_ref[micb_index] == 0) && (tasha->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); break; case MICB_ENABLE: tasha->micb_ref[micb_index]++; if (tasha->micb_ref[micb_index] == 1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x40); if (post_on_event) blocking_notifier_call_chain(&tasha->notifier, post_on_event, &tasha->mbhc); @@ -1454,13 +1476,15 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, tasha->micb_ref[micb_index]--; if ((tasha->micb_ref[micb_index] == 0) && (tasha->pullup_ref[micb_index] > 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); else if ((tasha->micb_ref[micb_index] == 0) && (tasha->pullup_ref[micb_index] == 0)) { if (pre_off_event) blocking_notifier_call_chain(&tasha->notifier, pre_off_event, &tasha->mbhc); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); if (post_off_event) blocking_notifier_call_chain(&tasha->notifier, post_off_event, &tasha->mbhc); @@ -1471,7 +1495,7 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, break; }; - dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", + dev_dbg(component->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", __func__, micb_num, tasha->micb_ref[micb_index], tasha->pullup_ref[micb_index]); @@ -1480,7 +1504,7 @@ static int tasha_micbias_control(struct snd_soc_codec *codec, return 0; } -static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec, +static int tasha_mbhc_request_micbias(struct snd_soc_component *component, int micb_num, int req) { int ret; @@ -1490,32 +1514,32 @@ static int tasha_mbhc_request_micbias(struct snd_soc_codec *codec, * is vote to enable mclk */ if (req == MICB_ENABLE) - tasha_cdc_mclk_enable(codec, true, false); + tasha_cdc_mclk_enable(component, true, false); - ret = tasha_micbias_control(codec, micb_num, req, false); + ret = tasha_micbias_control(component, micb_num, req, false); /* * Release vote for mclk while requesting for * micbias disable */ if (req == MICB_DISABLE) - tasha_cdc_mclk_enable(codec, false, false); + tasha_cdc_mclk_enable(component, false, false); return ret; } -static void tasha_mbhc_micb_ramp_control(struct snd_soc_codec *codec, +static void tasha_mbhc_micb_ramp_control(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP, 0x1C, 0x0C); - snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP, 0x80, 0x80); } else { - snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP, 0x80, 0x00); - snd_soc_update_bits(codec, WCD9335_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD9335_ANA_MICB2_RAMP, 0x1C, 0x00); } } @@ -1525,22 +1549,22 @@ static struct firmware_cal *tasha_get_hwdep_fw_cal(struct wcd_mbhc *mbhc, { struct tasha_priv *tasha; struct firmware_cal *hwdep_cal; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; - if (!codec) { - pr_err("%s: NULL codec pointer\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer\n", __func__); return NULL; } - tasha = snd_soc_codec_get_drvdata(codec); + tasha = snd_soc_component_get_drvdata(component); hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, type); if (!hwdep_cal) - dev_err(codec->dev, "%s: cal not sent by %d\n", + dev_err(component->dev, "%s: cal not sent by %d\n", __func__, type); return hwdep_cal; } -static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num) { @@ -1572,7 +1596,7 @@ static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, * momentarily, change the micbias value and then re-enable * micbias. */ - micb_val = snd_soc_read(codec, micb_reg); + micb_val = snd_soc_component_read32(component, micb_reg); micb_en = (micb_val & 0xC0) >> 6; cur_vout_ctl = micb_val & 0x3F; @@ -1582,17 +1606,17 @@ static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, if (cur_vout_ctl == req_vout_ctl) return 0; - dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", + dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl), req_volt, micb_en); if (micb_en == 0x1) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x80); - snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl); + snd_soc_component_update_bits(component, micb_reg, 0x3F, req_vout_ctl); if (micb_en == 0x1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x40); /* * Add 2ms delay as per HW requirement after enabling * micbias @@ -1603,11 +1627,12 @@ static int tasha_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, return 0; } -static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, - int micb_num, bool req_en) +static int tasha_mbhc_micb_ctrl_threshold_mic( + struct snd_soc_component *component, + int micb_num, bool req_en) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); int rc, micb_mv; if (micb_num != MIC_BIAS_2) @@ -1624,7 +1649,7 @@ static int tasha_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv; mutex_lock(&tasha->micb_lock); - rc = tasha_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2); + rc = tasha_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); mutex_unlock(&tasha->micb_lock); return rc; @@ -1694,39 +1719,40 @@ ramp_down: * to make the switch open. * * @zdet_gpio_cb: callback function from machine driver - * @codec: Codec instance + * @component: Codec instance * * Return: none */ void tasha_mbhc_zdet_gpio_ctrl( - int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high), - struct snd_soc_codec *codec) + int (*zdet_gpio_cb)( + struct snd_soc_component *component, bool high), + struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); tasha->zdet_gpio_cb = zdet_gpio_cb; } EXPORT_SYMBOL(tasha_mbhc_zdet_gpio_ctrl); -static void tasha_mbhc_zdet_ramp(struct snd_soc_codec *codec, +static void tasha_mbhc_zdet_ramp(struct snd_soc_component *component, struct tasha_mbhc_zdet_param *zdet_param, int32_t *zl, int32_t *zr, s16 *d1_a) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); int32_t zdet = 0; - snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x70, - zdet_param->ldo_ctl << 4); - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN5, 0xFC, - zdet_param->btn5); - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN6, 0xFC, - zdet_param->btn6); - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_BTN7, 0xFC, - zdet_param->btn7); - snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_ANA_CTL, 0x0F, - zdet_param->noff); - snd_soc_update_bits(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x0F, - zdet_param->nshift); + snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_ANA_CTL, + 0x70, zdet_param->ldo_ctl << 4); + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN5, 0xFC, + zdet_param->btn5); + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN6, 0xFC, + zdet_param->btn6); + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_BTN7, 0xFC, + zdet_param->btn7); + snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_ANA_CTL, + 0x0F, zdet_param->noff); + snd_soc_component_update_bits(component, WCD9335_MBHC_ZDET_RAMP_CTL, + 0x0F, zdet_param->nshift); if (!zl) goto z_right; @@ -1756,17 +1782,17 @@ z_right: *zr = zdet; } -static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, +static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_component *component, int32_t *z_val, int flag_l_r) { s16 q1; int q1_cal; if (*z_val < (TASHA_ZDET_VAL_400/1000)) - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r)); else - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r)); if (q1 & 0x80) q1_cal = (10000 - ((q1 & 0x7F) * 25)); @@ -1779,8 +1805,8 @@ static inline void tasha_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { - struct snd_soc_codec *codec = mbhc->codec; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = mbhc->component; + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; s16 reg0, reg1, reg2, reg3, reg4; int32_t z1L, z1R, z1Ls; @@ -1803,7 +1829,7 @@ static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, s16 *d1 = NULL; if (!TASHA_IS_2_0(wcd9xxx)) { - dev_dbg(codec->dev, "%s: Z-det is not supported for this codec version\n", + dev_dbg(component->dev, "%s: Z-det is not supported for this codec version\n", __func__); *zl = 0; *zr = 0; @@ -1812,15 +1838,16 @@ static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); if (tasha->zdet_gpio_cb) - is_change = tasha->zdet_gpio_cb(codec, true); + is_change = tasha->zdet_gpio_cb(component, true); - reg0 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN5); - reg1 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN6); - reg2 = snd_soc_read(codec, WCD9335_ANA_MBHC_BTN7); - reg3 = snd_soc_read(codec, WCD9335_MBHC_CTL_1); - reg4 = snd_soc_read(codec, WCD9335_MBHC_ZDET_ANA_CTL); + reg0 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN5); + reg1 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN6); + reg2 = snd_soc_component_read32(component, WCD9335_ANA_MBHC_BTN7); + reg3 = snd_soc_component_read32(component, WCD9335_MBHC_CTL_1); + reg4 = snd_soc_component_read32(component, WCD9335_MBHC_ZDET_ANA_CTL); - if (snd_soc_read(codec, WCD9335_ANA_MBHC_ELECT) & 0x80) { + if (snd_soc_component_read32( + component, WCD9335_ANA_MBHC_ELECT) & 0x80) { is_fsm_disable = true; regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ELECT, 0x80, 0x00); @@ -1832,7 +1859,8 @@ static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, WCD9335_ANA_MBHC_MECH, 0x80, 0x00); /* Enable AZ */ - snd_soc_update_bits(codec, WCD9335_MBHC_CTL_1, 0x0C, 0x04); + snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_1, + 0x0C, 0x04); /* Turn off 100k pull down on HPHL */ regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_MECH, 0x01, 0x00); @@ -1840,7 +1868,7 @@ static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; - tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + tasha_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); if (!TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1L)) goto left_ch_impedance; @@ -1856,7 +1884,7 @@ static void tasha_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + tasha_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); left_ch_impedance: if ((z1L == TASHA_ZDET_FLOATING_IMPEDANCE) || @@ -1866,13 +1894,13 @@ left_ch_impedance: d1 = d1_a[1]; } else { *zl = z1L/1000; - tasha_wcd_mbhc_qfuse_cal(codec, zl, 0); + tasha_wcd_mbhc_qfuse_cal(component, zl, 0); } - dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", __func__, *zl); /* start of right impedance ramp and calculation */ - tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + tasha_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); if (TASHA_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) { if (((z1R > TASHA_ZDET_VAL_1200) && (zdet_param_ptr->noff == 0x6)) || @@ -1890,7 +1918,7 @@ left_ch_impedance: zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - tasha_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + tasha_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); } right_ch_impedance: if ((z1R == TASHA_ZDET_FLOATING_IMPEDANCE) || @@ -1898,15 +1926,15 @@ right_ch_impedance: *zr = TASHA_ZDET_FLOATING_IMPEDANCE; } else { *zr = z1R/1000; - tasha_wcd_mbhc_qfuse_cal(codec, zr, 1); + tasha_wcd_mbhc_qfuse_cal(component, zr, 1); } - dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", __func__, *zr); /* mono/stereo detection */ if ((*zl == TASHA_ZDET_FLOATING_IMPEDANCE) && (*zr == TASHA_ZDET_FLOATING_IMPEDANCE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: plug type is invalid or extension cable\n", __func__); goto zdet_complete; @@ -1915,40 +1943,46 @@ right_ch_impedance: (*zr == TASHA_ZDET_FLOATING_IMPEDANCE) || ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) || ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Mono plug type with one ch floating or shorted to GND\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; goto zdet_complete; } - snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x02); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x01); + snd_soc_component_update_bits(component, WCD9335_HPH_R_ATEST, + 0x02, 0x02); + snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2, + 0x40, 0x01); if (*zl < (TASHA_ZDET_VAL_32/1000)) - tasha_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1); + tasha_mbhc_zdet_ramp(component, &zdet_param[0], + &z1Ls, NULL, d1); else - tasha_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_R_ATEST, 0x02, 0x00); + tasha_mbhc_zdet_ramp(component, &zdet_param[1], + &z1Ls, NULL, d1); + snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2, + 0x40, 0x00); + snd_soc_component_update_bits(component, WCD9335_HPH_R_ATEST, + 0x02, 0x00); z1Ls /= 1000; - tasha_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0); + tasha_wcd_mbhc_qfuse_cal(component, &z1Ls, 0); /* parallel of left Z and 9 ohm pull down resistor */ zMono = ((*zl) * 9) / ((*zl) + 9); z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) { - dev_dbg(codec->dev, "%s: stereo plug type detected\n", + dev_dbg(component->dev, "%s: stereo plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_STEREO; } else { - dev_dbg(codec->dev, "%s: MONO plug type detected\n", + dev_dbg(component->dev, "%s: MONO plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; } zdet_complete: - snd_soc_write(codec, WCD9335_ANA_MBHC_BTN5, reg0); - snd_soc_write(codec, WCD9335_ANA_MBHC_BTN6, reg1); - snd_soc_write(codec, WCD9335_ANA_MBHC_BTN7, reg2); + snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN5, reg0); + snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN6, reg1); + snd_soc_component_write(component, WCD9335_ANA_MBHC_BTN7, reg2); /* Turn on 100k pull down on HPHL */ regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_MECH, 0x01, 0x01); @@ -1958,78 +1992,83 @@ zdet_complete: regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_MECH, 0x80, 0x80); - snd_soc_write(codec, WCD9335_MBHC_ZDET_ANA_CTL, reg4); - snd_soc_write(codec, WCD9335_MBHC_CTL_1, reg3); + snd_soc_component_write(component, WCD9335_MBHC_ZDET_ANA_CTL, reg4); + snd_soc_component_write(component, WCD9335_MBHC_CTL_1, reg3); if (is_fsm_disable) regmap_update_bits(wcd9xxx->regmap, WCD9335_ANA_MBHC_ELECT, 0x80, 0x80); if (tasha->zdet_gpio_cb && is_change) - tasha->zdet_gpio_cb(codec, false); + tasha->zdet_gpio_cb(component, false); } -static void tasha_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable) +static void tasha_mbhc_gnd_det_ctrl( + struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH, 0x02, 0x02); - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH, 0x40, 0x40); } else { - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH, 0x40, 0x00); - snd_soc_update_bits(codec, WCD9335_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD9335_ANA_MBHC_MECH, 0x02, 0x00); } } -static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, +static void tasha_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component, bool enable) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (enable) { - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2, 0x40, 0x40); if (TASHA_IS_2_0(tasha->wcd9xxx)) - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, - 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, + 0x10, 0x10); } else { - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, - 0x40, 0x00); + snd_soc_component_update_bits(component, WCD9335_HPH_PA_CTL2, + 0x40, 0x00); if (TASHA_IS_2_0(tasha->wcd9xxx)) - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, + 0x10, 0x00); } } static void tasha_mbhc_moisture_config(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; if (mbhc->moist_vref == V_OFF) return; /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { - dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", + dev_dbg(component->dev, "%s: disable moisture detection for NC\n", __func__); return; } - snd_soc_update_bits(codec, WCD9335_MBHC_CTL_2, + snd_soc_component_update_bits(component, WCD9335_MBHC_CTL_2, 0x0C, mbhc->moist_vref << 2); - tasha_mbhc_hph_l_pull_up_control(codec, mbhc->moist_iref); + tasha_mbhc_hph_l_pull_up_control(component, mbhc->moist_iref); } -static void tasha_update_anc_state(struct snd_soc_codec *codec, bool enable, - int anc_num) +static void tasha_update_anc_state(struct snd_soc_component *component, + bool enable, int anc_num) { if (enable) - snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x10); else - snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x00); } static bool tasha_is_anc_on(struct wcd_mbhc *mbhc) @@ -2038,9 +2077,11 @@ static bool tasha_is_anc_on(struct wcd_mbhc *mbhc) u16 ancl, ancr; ancl = - (snd_soc_read(mbhc->codec, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32( + mbhc->component, WCD9335_CDC_RX1_RX_PATH_CFG0)) & 0x10; ancr = - (snd_soc_read(mbhc->codec, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32( + mbhc->component, WCD9335_CDC_RX2_RX_PATH_CFG0)) & 0x10; anc_on = !!(ancl | ancr); @@ -2076,8 +2117,9 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha->anc_slot; return 0; @@ -2086,8 +2128,9 @@ static int tasha_get_anc_slot(struct snd_kcontrol *kcontrol, static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); tasha->anc_slot = ucontrol->value.integer.value[0]; return 0; @@ -2096,8 +2139,9 @@ static int tasha_put_anc_slot(struct snd_kcontrol *kcontrol, static int tasha_get_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (tasha->anc_func == true ? 1 : 0); return 0; @@ -2106,14 +2150,16 @@ static int tasha_get_anc_func(struct snd_kcontrol *kcontrol, static int tasha_put_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); mutex_lock(&tasha->codec_mutex); tasha->anc_func = (!ucontrol->value.integer.value[0] ? false : true); - dev_dbg(codec->dev, "%s: anc_func %x", __func__, tasha->anc_func); + dev_dbg(component->dev, "%s: anc_func %x", __func__, tasha->anc_func); if (tasha->anc_func == true) { snd_soc_dapm_enable_pin(dapm, "ANC LINEOUT2 PA"); @@ -2168,11 +2214,13 @@ static int tasha_put_anc_func(struct snd_kcontrol *kcontrol, static int tasha_get_clkmode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = tasha->clk_mode; - dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode); + dev_dbg(component->dev, "%s: clk_mode: %d\n", __func__, + tasha->clk_mode); return 0; } @@ -2180,11 +2228,13 @@ static int tasha_get_clkmode(struct snd_kcontrol *kcontrol, static int tasha_put_clkmode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); tasha->clk_mode = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: clk_mode: %d\n", __func__, tasha->clk_mode); + dev_dbg(component->dev, "%s: clk_mode: %d\n", __func__, + tasha->clk_mode); return 0; } @@ -2193,7 +2243,8 @@ static int tasha_get_iir_enable_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -2201,10 +2252,11 @@ static int tasha_get_iir_enable_audio_mixer( /* IIR filter band registers are at integer multiples of 16 */ u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx; - ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) & - (1 << band_idx)) != 0; + ucontrol->value.integer.value[0] = ( + snd_soc_component_read32(component, iir_reg) & + (1 << band_idx)) != 0; - dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; @@ -2216,13 +2268,15 @@ static int tasha_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_multi_mixer_control *mc; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); mc = (struct soc_multi_mixer_control *)(kcontrol->private_value); hphr = mc->shift; wcd_mbhc_get_impedance(&priv->mbhc, &zl, &zr); - dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); + dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, + zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; @@ -2238,24 +2292,26 @@ static const struct snd_kcontrol_new impedance_detect_controls[] = { static int tasha_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); struct wcd_mbhc *mbhc; if (!priv) { - dev_dbg(codec->dev, "%s: wcd9335 private data is NULL\n", + dev_dbg(component->dev, "%s: wcd9335 private data is NULL\n", __func__); return 0; } mbhc = &priv->mbhc; if (!mbhc) { - dev_dbg(codec->dev, "%s: mbhc not initialized\n", __func__); + dev_dbg(component->dev, "%s: mbhc not initialized\n", __func__); return 0; } ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; - dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); + dev_dbg(component->dev, "%s: hph_type = %u\n", __func__, + mbhc->hph_type); return 0; } @@ -2269,9 +2325,10 @@ static int tasha_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha_p->vi_feed_value; @@ -2282,9 +2339,10 @@ static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); struct wcd9xxx *core = tasha_p->wcd9xxx; struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); @@ -2292,7 +2350,7 @@ static int tasha_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, u32 port_id = mixer->shift; u32 enable = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n", + dev_dbg(component->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n", __func__, enable, port_id, dai_id); tasha_p->vi_feed_value = ucontrol->value.integer.value[0]; @@ -2335,8 +2393,9 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha_p->tx_port_value; return 0; @@ -2346,10 +2405,11 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); + struct wcd9xxx *core = dev_get_drvdata(component->dev->parent); struct snd_soc_dapm_update *update = NULL; struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); @@ -2359,7 +2419,7 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, u32 vtable; - dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", + dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, tasha_p->tx_port_value, widget->shift, ucontrol->value.integer.value[0]); @@ -2367,16 +2427,16 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, mutex_lock(&tasha_p->codec_mutex); if (tasha_p->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - if (dai_id >= ARRAY_SIZE(vport_slim_check_table)) { - dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n", - __func__, dai_id); + if (dai_id != AIF1_CAP) { + dev_err(component->dev, "%s: invalid AIF for I2C mode\n", + __func__); mutex_unlock(&tasha_p->codec_mutex); return -EINVAL; } vtable = vport_slim_check_table[dai_id]; } else { if (dai_id >= ARRAY_SIZE(vport_i2s_check_table)) { - dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n", + dev_err(component->dev, "%s: dai_id: %d, out of bounds\n", __func__, dai_id); return -EINVAL; } @@ -2391,7 +2451,7 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_tx_vport_validation(vtable, port_id, tasha_p->dai, NUM_CODEC_DAIS)) { - dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", + dev_dbg(component->dev, "%s: TX%u is used by other virtual port\n", __func__, port_id); mutex_unlock(&tasha_p->codec_mutex); return 0; @@ -2406,11 +2466,11 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, list_del_init(&core->tx_chs[port_id].list); } else { if (enable) - dev_dbg(codec->dev, "%s: TX%u port is used by\n" + dev_dbg(component->dev, "%s: TX%u port is used by\n" "this virtual port\n", __func__, port_id); else - dev_dbg(codec->dev, "%s: TX%u port is not used by\n" + dev_dbg(component->dev, "%s: TX%u port is not used by\n" "this virtual port\n", __func__, port_id); /* avoid update power function */ @@ -2441,8 +2501,9 @@ static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = tasha_p->rx_port_value[widget->shift]; @@ -2458,9 +2519,10 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); + struct wcd9xxx *core = dev_get_drvdata(component->dev->parent); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; unsigned int rx_port_value; @@ -2477,7 +2539,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { if (rx_port_value > 2) { - dev_err(codec->dev, "%s: invalid AIF for I2C mode\n", + dev_err(component->dev, "%s: invalid AIF for I2C mode\n", __func__); goto err; } @@ -2491,7 +2553,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + TASHA_RX_PORT_START_NUMBER, &tasha_p->dai[AIF1_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -2502,7 +2564,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + TASHA_RX_PORT_START_NUMBER, &tasha_p->dai[AIF2_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -2513,7 +2575,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + TASHA_RX_PORT_START_NUMBER, &tasha_p->dai[AIF3_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -2524,7 +2586,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + TASHA_RX_PORT_START_NUMBER, &tasha_p->dai[AIF4_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -2535,7 +2597,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + TASHA_RX_PORT_START_NUMBER, &tasha_p->dai[AIF_MIX1_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -2741,7 +2803,8 @@ static int tasha_put_iir_enable_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -2751,56 +2814,56 @@ static int tasha_put_iir_enable_audio_mixer( u16 iir_reg = WCD9335_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx; /* Mask first 5 bits, 6-8 are reserved */ - snd_soc_update_bits(codec, iir_reg, (1 << band_idx), + snd_soc_component_update_bits(component, iir_reg, (1 << band_idx), (value << band_idx)); - iir_band_en_status = ((snd_soc_read(codec, iir_reg) & + iir_band_en_status = ((snd_soc_component_read32(component, iir_reg) & (1 << band_idx)) != 0); pr_debug("%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, iir_band_en_status); return 0; } -static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, +static uint32_t get_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); - value |= snd_soc_read(codec, + value |= snd_soc_component_read32(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) << 8); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) << 16); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ - value |= ((snd_soc_read(codec, + value |= ((snd_soc_component_read32(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24); @@ -2811,22 +2874,23 @@ static int tasha_get_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = - get_iir_band_coeff(codec, iir_idx, band_idx, 0); + get_iir_band_coeff(component, iir_idx, band_idx, 0); ucontrol->value.integer.value[1] = - get_iir_band_coeff(codec, iir_idx, band_idx, 1); + get_iir_band_coeff(component, iir_idx, band_idx, 1); ucontrol->value.integer.value[2] = - get_iir_band_coeff(codec, iir_idx, band_idx, 2); + get_iir_band_coeff(component, iir_idx, band_idx, 2); ucontrol->value.integer.value[3] = - get_iir_band_coeff(codec, iir_idx, band_idx, 3); + get_iir_band_coeff(component, iir_idx, band_idx, 3); ucontrol->value.integer.value[4] = - get_iir_band_coeff(codec, iir_idx, band_idx, 4); + get_iir_band_coeff(component, iir_idx, band_idx, 4); pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" @@ -2846,30 +2910,30 @@ static int tasha_get_iir_band_audio_mixer( return 0; } -static void set_iir_band_coeff(struct snd_soc_codec *codec, +static void set_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, uint32_t value) { - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value & 0xFF)); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 8) & 0xFF); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 24) & 0x3F); } static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct wcd9xxx_ch *ch; int port_num = 0; @@ -2877,12 +2941,12 @@ static void tasha_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai, u8 val = 0; struct tasha_priv *tasha_p; - if (!dai || !codec) { + if (!dai || !component) { pr_err("%s: Invalid params\n", __func__); return; } - tasha_p = snd_soc_codec_get_drvdata(codec); + tasha_p = snd_soc_component_get_drvdata(component); list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { if (ch->port >= TASHA_RX_PORT_START_NUMBER) { port_num = ch->port - TASHA_RX_PORT_START_NUMBER; @@ -2949,48 +3013,49 @@ static int tasha_codec_enable_slimrx(struct snd_soc_dapm_widget *w, int event) { struct wcd9xxx *core; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); int ret = 0; struct wcd9xxx_codec_dai_data *dai; - core = dev_get_drvdata(codec->dev->parent); + core = dev_get_drvdata(component->dev->parent); - dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n" + dev_dbg(component->dev, "%s: event called! component name %s num_dai %d\n" "stream name %s event %d\n", - __func__, codec->component.name, - codec->component.num_dai, w->sname, event); + __func__, component->name, + component->num_dai, w->sname, event); /* Execute the callback only if interface type is slimbus */ if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) return 0; dai = &tasha_p->dai[w->shift]; - dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n", + dev_dbg(component->dev, "%s: w->name %s w->shift %d event %d\n", __func__, w->name, w->shift, event); switch (event) { case SND_SOC_DAPM_POST_PMU: dai->bus_down_in_recovery = false; - tasha_codec_enable_int_port(dai, codec); + tasha_codec_enable_int_port(dai, component); (void) tasha_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, &dai->grph); break; case SND_SOC_DAPM_PRE_PMD: - tasha_codec_vote_max_bw(codec, true); + tasha_codec_vote_max_bw(component, true); break; case SND_SOC_DAPM_POST_PMD: ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list, dai->grph); - dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n", + dev_dbg(component->dev, "%s: Disconnect RX port, ret = %d\n", __func__, ret); if (!dai->bus_down_in_recovery) ret = tasha_codec_enable_slim_chmask(dai, false); else - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: bus in recovery skip enable slim_chmask", __func__); ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list, @@ -3005,7 +3070,7 @@ static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, int event) { struct wcd9xxx *core = NULL; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; struct tasha_priv *tasha_p = NULL; int ret = 0; struct wcd9xxx_codec_dai_data *dai = NULL; @@ -3014,20 +3079,21 @@ static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, pr_err("%s invalid params\n", __func__); return -EINVAL; } - codec = snd_soc_dapm_to_codec(w->dapm); - tasha_p = snd_soc_codec_get_drvdata(codec); + component = snd_soc_dapm_to_component(w->dapm); + tasha_p = snd_soc_component_get_drvdata(component); core = tasha_p->wcd9xxx; - dev_dbg(codec->dev, "%s: num_dai %d stream name %s\n", - __func__, codec->component.num_dai, w->sname); + dev_dbg(component->dev, "%s: num_dai %d stream name %s\n", + __func__, component->num_dai, w->sname); /* Execute the callback only if interface type is slimbus */ if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) { - dev_err(codec->dev, "%s Interface is not correct", __func__); + dev_err(component->dev, "%s Interface is not correct", + __func__); return 0; } - dev_dbg(codec->dev, "%s(): w->name %s event %d w->shift %d\n", + dev_dbg(component->dev, "%s(): w->name %s event %d w->shift %d\n", __func__, w->name, event, w->shift); if (w->shift != AIF4_VIFEED) { pr_err("%s Error in enabling the tx path\n", __func__); @@ -3038,59 +3104,60 @@ static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) { - dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__); + dev_dbg(component->dev, "%s: spkr1 enabled\n", + __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x00); } if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) { pr_debug("%s: spkr2 enabled\n", __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x00); } dai->bus_down_in_recovery = false; - tasha_codec_enable_int_port(dai, codec); + tasha_codec_enable_int_port(dai, component); (void) tasha_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, @@ -3100,7 +3167,7 @@ static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->grph); if (ret) - dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n", + dev_err(component->dev, "%s error in close_slim_sch_tx %d\n", __func__, ret); if (!dai->bus_down_in_recovery) ret = tasha_codec_enable_slim_chmask(dai, false); @@ -3108,36 +3175,38 @@ static int tasha_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list, dai->grph); - dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n", + dev_dbg(component->dev, "%s: Disconnect TX port, ret = %d\n", __func__, ret); } if (test_bit(VI_SENSE_1, &tasha_p->status_mask)) { /* Disable V&I sensing */ - dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__); - snd_soc_update_bits(codec, + dev_dbg(component->dev, "%s: spkr1 disabled\n", + __func__); + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10, 0x00); } if (test_bit(VI_SENSE_2, &tasha_p->status_mask)) { /* Disable V&I sensing */ - dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__); - snd_soc_update_bits(codec, + dev_dbg(component->dev, "%s: spkr2 disabled\n", + __func__); + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10, 0x00); } @@ -3150,29 +3219,29 @@ out_vi: /* * __tasha_codec_enable_slimtx: Enable the slimbus slave port * for TX path - * @codec: Handle to the codec for which the slave port is to be + * @component: Handle to the codec for which the slave port is to be * enabled. * @dai_data: The dai specific data for dai which is enabled. */ -static int __tasha_codec_enable_slimtx(struct snd_soc_codec *codec, +static int __tasha_codec_enable_slimtx(struct snd_soc_component *component, int event, struct wcd9xxx_codec_dai_data *dai) { struct wcd9xxx *core; - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); int ret = 0; /* Execute the callback only if interface type is slimbus */ if (tasha_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS) return 0; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); - core = dev_get_drvdata(codec->dev->parent); + core = dev_get_drvdata(component->dev->parent); switch (event) { case SND_SOC_DAPM_POST_PMU: dai->bus_down_in_recovery = false; - tasha_codec_enable_int_port(dai, codec); + tasha_codec_enable_int_port(dai, component); (void) tasha_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, @@ -3201,22 +3270,24 @@ static int tasha_codec_enable_slimtx(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n", __func__, w->name, w->shift, - codec->component.num_dai, w->sname); + component->num_dai, w->sname); dai = &tasha_p->dai[w->shift]; - return __tasha_codec_enable_slimtx(codec, event, dai); + return __tasha_codec_enable_slimtx(component, event, dai); } -static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event) +static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_component *component, + int event) { - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; u8 bit_width, rate, buf_period; @@ -3238,8 +3309,8 @@ static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event) bit_width = 0x0; break; } - snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x0F, - bit_width); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_TX_PP_CFG, 0x0F, bit_width); switch (dai->rate) { case 384000: @@ -3256,19 +3327,23 @@ static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event) rate = 0x00; break; } - snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x70, - rate); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_TX_PP_CFG, 0x70, rate); buf_period = (dai->rate * (dai->bit_width/8)) / (16*1000); - snd_soc_update_bits(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, - 0xFF, buf_period); - dev_dbg(codec->dev, "%s: PP buffer period= 0x%x\n", + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, + 0xFF, buf_period); + dev_dbg(component->dev, "%s: PP buffer period= 0x%x\n", __func__, buf_period); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_CFG, 0x3C); - snd_soc_write(codec, WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, 0x60); + snd_soc_component_write(component, WCD9335_CPE_SS_TX_PP_CFG, + 0x3C); + snd_soc_component_write(component, + WCD9335_CPE_SS_TX_PP_BUF_INT_PERIOD, + 0x60); break; default: @@ -3279,20 +3354,20 @@ static void tasha_codec_cpe_pp_set_cfg(struct snd_soc_codec *codec, int event) /* * tasha_codec_get_mad_port_id: Callback function that will be invoked * to get the port ID for MAD. - * @codec: Handle to the codec + * @component: Handle to the codec * @port_id: cpe port_id needs to enable */ -static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec, +static int tasha_codec_get_mad_port_id(struct snd_soc_component *component, u16 *port_id) { struct tasha_priv *tasha_p; struct wcd9xxx_codec_dai_data *dai; struct wcd9xxx_ch *ch; - if (!port_id || !codec) + if (!port_id || !component) return -EINVAL; - tasha_p = snd_soc_codec_get_drvdata(codec); + tasha_p = snd_soc_component_get_drvdata(component); if (!tasha_p) return -EINVAL; @@ -3303,12 +3378,12 @@ static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec, else if (ch->port == TASHA_TX13) *port_id = WCD_CPE_AFE_OUT_PORT_4; else { - dev_err(codec->dev, "%s: invalid mad_port = %d\n", + dev_err(component->dev, "%s: invalid mad_port = %d\n", __func__, ch->port); return -EINVAL; } } - dev_dbg(codec->dev, "%s: port_id = %d\n", __func__, *port_id); + dev_dbg(component->dev, "%s: port_id = %d\n", __func__, *port_id); return 0; } @@ -3316,13 +3391,13 @@ static int tasha_codec_get_mad_port_id(struct snd_soc_codec *codec, /* * tasha_codec_enable_slimtx_mad: Callback function that will be invoked * to setup the slave port for MAD. - * @codec: Handle to the codec + * @component: Handle to the codec * @event: Indicates whether to enable or disable the slave port */ -static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec, +static int tasha_codec_enable_slimtx_mad(struct snd_soc_component *component, u8 event) { - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; struct wcd9xxx_ch *ch; int dapm_event = SND_SOC_DAPM_POST_PMU; @@ -3334,43 +3409,45 @@ static int tasha_codec_enable_slimtx_mad(struct snd_soc_codec *codec, if (event == 0) dapm_event = SND_SOC_DAPM_POST_PMD; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: mad_channel, event = 0x%x\n", __func__, event); list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { - dev_dbg(codec->dev, "%s: mad_port = %d, event = 0x%x\n", + dev_dbg(component->dev, "%s: mad_port = %d, event = 0x%x\n", __func__, ch->port, event); if (ch->port == TASHA_TX13) { - tasha_codec_cpe_pp_set_cfg(codec, dapm_event); + tasha_codec_cpe_pp_set_cfg(component, dapm_event); port = TASHA_TX13; break; } } - ret = __tasha_codec_enable_slimtx(codec, dapm_event, dai); + ret = __tasha_codec_enable_slimtx(component, dapm_event, dai); if (port == TASHA_TX13) { switch (dapm_event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0x03, 0x02); - snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, - 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_CFG, + 0x80, 0x80); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_PWR_CPE_DRAM1_SHUTDOWN, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_SB_TX13_INP_CFG, 0x03, 0x00); - snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_CFG, + 0x80, 0x00); break; } } @@ -3382,7 +3459,8 @@ static int tasha_put_iir_band_audio_mixer( struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -3392,19 +3470,19 @@ static int tasha_put_iir_band_audio_mixer( * Mask top bit it is reserved * Updates addr automatically for each B2 write */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD9335_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); - set_iir_band_coeff(codec, iir_idx, band_idx, + set_iir_band_coeff(component, iir_idx, band_idx, ucontrol->value.integer.value[0]); - set_iir_band_coeff(codec, iir_idx, band_idx, + set_iir_band_coeff(component, iir_idx, band_idx, ucontrol->value.integer.value[1]); - set_iir_band_coeff(codec, iir_idx, band_idx, + set_iir_band_coeff(component, iir_idx, band_idx, ucontrol->value.integer.value[2]); - set_iir_band_coeff(codec, iir_idx, band_idx, + set_iir_band_coeff(component, iir_idx, band_idx, ucontrol->value.integer.value[3]); - set_iir_band_coeff(codec, iir_idx, band_idx, + set_iir_band_coeff(component, iir_idx, band_idx, ucontrol->value.integer.value[4]); pr_debug("%s: IIR #%d band #%d b0 = 0x%x\n" @@ -3413,15 +3491,15 @@ static int tasha_put_iir_band_audio_mixer( "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 0), + get_iir_band_coeff(component, iir_idx, band_idx, 0), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 1), + get_iir_band_coeff(component, iir_idx, band_idx, 1), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 2), + get_iir_band_coeff(component, iir_idx, band_idx, 2), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 3), + get_iir_band_coeff(component, iir_idx, band_idx, 3), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 4)); + get_iir_band_coeff(component, iir_idx, band_idx, 4)); return 0; } @@ -3429,10 +3507,11 @@ static int tasha_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha->comp_enabled[comp]; return 0; @@ -3441,8 +3520,9 @@ static int tasha_get_compander(struct snd_kcontrol *kcontrol, static int tasha_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; @@ -3455,11 +3535,11 @@ static int tasha_set_compander(struct snd_kcontrol *kcontrol, switch (comp) { case COMPANDER_1: /* Set Gain Source Select based on compander enable/disable */ - snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0x20, + snd_soc_component_update_bits(component, WCD9335_HPH_L_EN, 0x20, (value ? 0x00:0x20)); break; case COMPANDER_2: - snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0x20, + snd_soc_component_update_bits(component, WCD9335_HPH_R_EN, 0x20, (value ? 0x00:0x20)); break; case COMPANDER_3: @@ -3467,12 +3547,12 @@ static int tasha_set_compander(struct snd_kcontrol *kcontrol, case COMPANDER_4: break; case COMPANDER_5: - snd_soc_update_bits(codec, WCD9335_SE_LO_LO3_GAIN, 0x20, - (value ? 0x00:0x20)); + snd_soc_component_update_bits(component, WCD9335_SE_LO_LO3_GAIN, + 0x20, (value ? 0x00:0x20)); break; case COMPANDER_6: - snd_soc_update_bits(codec, WCD9335_SE_LO_LO4_GAIN, 0x20, - (value ? 0x00:0x20)); + snd_soc_component_update_bits(component, WCD9335_SE_LO_LO4_GAIN, + 0x20, (value ? 0x00:0x20)); break; case COMPANDER_7: break; @@ -3484,85 +3564,90 @@ static int tasha_set_compander(struct snd_kcontrol *kcontrol, * it does not cause any audio failure, so do not * return error in this case, but just print a log */ - dev_warn(codec->dev, "%s: unknown compander: %d\n", + dev_warn(component->dev, "%s: unknown compander: %d\n", __func__, comp); }; return 0; } -static void tasha_codec_init_flyback(struct snd_soc_codec *codec) +static void tasha_codec_init_flyback(struct snd_soc_component *component) { - snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x00); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0x0F, 0x00); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_FLYB_BUFF, 0xF0, 0x00); + snd_soc_component_update_bits(component, WCD9335_HPH_L_EN, 0xC0, 0x00); + snd_soc_component_update_bits(component, WCD9335_HPH_R_EN, 0xC0, 0x00); + snd_soc_component_update_bits(component, WCD9335_RX_BIAS_FLYB_BUFF, + 0x0F, 0x00); + snd_soc_component_update_bits(component, WCD9335_RX_BIAS_FLYB_BUFF, + 0xF0, 0x00); } static int tasha_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: tasha->rx_bias_count++; if (tasha->rx_bias_count == 1) { if (TASHA_IS_2_0(tasha->wcd9xxx)) - tasha_codec_init_flyback(codec); - snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES, - 0x01, 0x01); + tasha_codec_init_flyback(component); + snd_soc_component_update_bits(component, + WCD9335_ANA_RX_SUPPLIES, + 0x01, 0x01); } break; case SND_SOC_DAPM_POST_PMD: tasha->rx_bias_count--; if (!tasha->rx_bias_count) - snd_soc_update_bits(codec, WCD9335_ANA_RX_SUPPLIES, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_ANA_RX_SUPPLIES, + 0x01, 0x00); break; }; - dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__, - tasha->rx_bias_count); + dev_dbg(component->dev, "%s: Current RX BIAS user count: %d\n", + __func__, tasha->rx_bias_count); return 0; } -static void tasha_realign_anc_coeff(struct snd_soc_codec *codec, +static void tasha_realign_anc_coeff(struct snd_soc_component *component, u16 reg1, u16 reg2) { u8 val1, val2, tmpval1, tmpval2; - snd_soc_write(codec, reg1, 0x00); - tmpval1 = snd_soc_read(codec, reg2); - tmpval2 = snd_soc_read(codec, reg2); - snd_soc_write(codec, reg1, 0x00); - snd_soc_write(codec, reg2, 0xFF); - snd_soc_write(codec, reg1, 0x01); - snd_soc_write(codec, reg2, 0xFF); + snd_soc_component_write(component, reg1, 0x00); + tmpval1 = snd_soc_component_read32(component, reg2); + tmpval2 = snd_soc_component_read32(component, reg2); + snd_soc_component_write(component, reg1, 0x00); + snd_soc_component_write(component, reg2, 0xFF); + snd_soc_component_write(component, reg1, 0x01); + snd_soc_component_write(component, reg2, 0xFF); - snd_soc_write(codec, reg1, 0x00); - val1 = snd_soc_read(codec, reg2); - val2 = snd_soc_read(codec, reg2); + snd_soc_component_write(component, reg1, 0x00); + val1 = snd_soc_component_read32(component, reg2); + val2 = snd_soc_component_read32(component, reg2); if (val1 == 0x0F && val2 == 0xFF) { - dev_dbg(codec->dev, "%s: ANC0 co-eff index re-aligned\n", + dev_dbg(component->dev, "%s: ANC0 co-eff index re-aligned\n", __func__); - snd_soc_read(codec, reg2); - snd_soc_write(codec, reg1, 0x00); - snd_soc_write(codec, reg2, tmpval2); - snd_soc_write(codec, reg1, 0x01); - snd_soc_write(codec, reg2, tmpval1); + snd_soc_component_read32(component, reg2); + snd_soc_component_write(component, reg1, 0x00); + snd_soc_component_write(component, reg2, tmpval2); + snd_soc_component_write(component, reg1, 0x01); + snd_soc_component_write(component, reg2, tmpval1); } else if (val1 == 0xFF && val2 == 0x0F) { - dev_dbg(codec->dev, "%s: ANC1 co-eff index already aligned\n", + dev_dbg(component->dev, "%s: ANC1 co-eff index already aligned\n", __func__); - snd_soc_write(codec, reg1, 0x00); - snd_soc_write(codec, reg2, tmpval1); - snd_soc_write(codec, reg1, 0x01); - snd_soc_write(codec, reg2, tmpval2); + snd_soc_component_write(component, reg1, 0x00); + snd_soc_component_write(component, reg2, tmpval1); + snd_soc_component_write(component, reg1, 0x01); + snd_soc_component_write(component, reg2, tmpval2); } else { - dev_err(codec->dev, "%s: ANC0 co-eff index not aligned\n", + dev_err(component->dev, "%s: ANC0 co-eff index not aligned\n", __func__); } } @@ -3570,8 +3655,9 @@ static void tasha_realign_anc_coeff(struct snd_soc_codec *codec, static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); const char *filename; const struct firmware *fw; int i; @@ -3597,27 +3683,27 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration\n", + dev_dbg(component->dev, "%s: using hwdep calibration\n", __func__); } else { filename = "wcd9335/wcd9335_anc.bin"; - ret = request_firmware(&fw, filename, codec->dev); + ret = request_firmware(&fw, filename, component->dev); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to acquire ANC data: %d\n", ret); return -ENODEV; } if (!fw) { - dev_err(codec->dev, "failed to get anc fw"); + dev_err(component->dev, "failed to get anc fw"); return -ENODEV; } data = fw->data; cal_size = fw->size; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(struct wcd9xxx_anc_header)) { - dev_err(codec->dev, "Not enough data\n"); + dev_err(component->dev, "Not enough data\n"); ret = -ENOMEM; goto err; } @@ -3630,13 +3716,13 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, num_anc_slots = anc_head->num_anc_slots; if (tasha->anc_slot >= num_anc_slots) { - dev_err(codec->dev, "Invalid ANC slot selected\n"); + dev_err(component->dev, "Invalid ANC slot selected\n"); ret = -EINVAL; goto err; } for (i = 0; i < num_anc_slots; i++) { if (anc_size_remaining < TASHA_PACKED_REG_SIZE) { - dev_err(codec->dev, + dev_err(component->dev, "Invalid register format\n"); ret = -EINVAL; goto err; @@ -3647,7 +3733,7 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, if (anc_writes_size * TASHA_PACKED_REG_SIZE > anc_size_remaining) { - dev_err(codec->dev, + dev_err(component->dev, "Invalid register format\n"); ret = -EINVAL; goto err; @@ -3661,7 +3747,7 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, anc_ptr += anc_writes_size; } if (i == num_anc_slots) { - dev_err(codec->dev, "Selected ANC slot not present\n"); + dev_err(component->dev, "Selected ANC slot not present\n"); ret = -EINVAL; goto err; } @@ -3671,39 +3757,39 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, if (!strcmp(w->name, "RX INT0 DAC") || !strcmp(w->name, "ANC SPK1 PA")) - tasha_realign_anc_coeff(codec, + tasha_realign_anc_coeff(component, WCD9335_CDC_ANC0_IIR_COEFF_1_CTL, WCD9335_CDC_ANC0_IIR_COEFF_2_CTL); if (!strcmp(w->name, "RX INT1 DAC") || !strcmp(w->name, "RX INT3 DAC")) { - tasha_realign_anc_coeff(codec, + tasha_realign_anc_coeff(component, WCD9335_CDC_ANC0_IIR_COEFF_1_CTL, WCD9335_CDC_ANC0_IIR_COEFF_2_CTL); anc_writes_size = anc_cal_size / 2; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x39, 0x39); } else if (!strcmp(w->name, "RX INT2 DAC") || !strcmp(w->name, "RX INT4 DAC")) { - tasha_realign_anc_coeff(codec, + tasha_realign_anc_coeff(component, WCD9335_CDC_ANC1_IIR_COEFF_1_CTL, WCD9335_CDC_ANC1_IIR_COEFF_2_CTL); i = anc_cal_size / 2; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x39, 0x39); } for (; i < anc_writes_size; i++) { TASHA_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val); - snd_soc_write(codec, reg, (val & mask)); + snd_soc_component_write(component, reg, (val & mask)); } if (!strcmp(w->name, "RX INT1 DAC") || !strcmp(w->name, "RX INT3 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08); } else if (!strcmp(w->name, "RX INT2 DAC") || !strcmp(w->name, "RX INT4 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08); } @@ -3712,39 +3798,41 @@ static int tasha_codec_enable_anc(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: /* Remove ANC Rx from reset */ - snd_soc_update_bits(codec, WCD9335_CDC_ANC0_CLK_RESET_CTL, - 0x08, 0x00); - snd_soc_update_bits(codec, WCD9335_CDC_ANC1_CLK_RESET_CTL, - 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_ANC0_CLK_RESET_CTL, + 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_ANC1_CLK_RESET_CTL, + 0x08, 0x00); break; case SND_SOC_DAPM_POST_PMD: if (!strcmp(w->name, "ANC HPHL PA") || !strcmp(w->name, "ANC EAR PA") || !strcmp(w->name, "ANC SPK1 PA") || !strcmp(w->name, "ANC LINEOUT1 PA")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_1_CTL, 0x30, 0x00); msleep(50); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_1_CTL, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x38); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x07, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_CLK_RESET_CTL, 0x38, 0x00); } else if (!strcmp(w->name, "ANC HPHR PA") || !strcmp(w->name, "ANC LINEOUT2 PA")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_1_CTL, 0x30, 0x00); msleep(50); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_1_CTL, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x38); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x07, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_CLK_RESET_CTL, 0x38, 0x00); } break; @@ -3760,17 +3848,23 @@ err: static void tasha_codec_clear_anc_tx_hold(struct tasha_priv *tasha) { if (test_and_clear_bit(ANC_MIC_AMIC1, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC1, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC1, false); if (test_and_clear_bit(ANC_MIC_AMIC2, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC2, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC2, false); if (test_and_clear_bit(ANC_MIC_AMIC3, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC3, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC3, false); if (test_and_clear_bit(ANC_MIC_AMIC4, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC4, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC4, false); if (test_and_clear_bit(ANC_MIC_AMIC5, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC5, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC5, false); if (test_and_clear_bit(ANC_MIC_AMIC6, &tasha->status_mask)) - tasha_codec_set_tx_hold(tasha->codec, WCD9335_ANA_AMIC6, false); + tasha_codec_set_tx_hold(tasha->component, + WCD9335_ANA_AMIC6, false); } static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha, @@ -3793,8 +3887,9 @@ static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha, } if (tasha->anc_func) { /* Clear Tx FE HOLD if both PAs are enabled */ - if ((snd_soc_read(tasha->codec, WCD9335_ANA_HPH) & - 0xC0) == 0xC0) { + if ((snd_soc_component_read32( + tasha->component, WCD9335_ANA_HPH) & + 0xC0) == 0xC0) { tasha_codec_clear_anc_tx_hold(tasha); } } @@ -3805,46 +3900,53 @@ static void tasha_codec_hph_post_pa_config(struct tasha_priv *tasha, } if (scale_val) - snd_soc_update_bits(tasha->codec, WCD9335_HPH_PA_CTL1, 0x0E, - scale_val << 1); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_PA_CTL1, 0x0E, + scale_val << 1); if (SND_SOC_DAPM_EVENT_ON(event)) { if (tasha->comp_enabled[COMPANDER_1] || tasha->comp_enabled[COMPANDER_2]) { - snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, - 0x20, 0x00); - snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, - 0x20, 0x00); - snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, - 0x20, 0x20); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_L_EN, + 0x20, 0x00); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_R_EN, + 0x20, 0x00); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_AUTO_CHOP, + 0x20, 0x20); } - snd_soc_update_bits(tasha->codec, WCD9335_HPH_L_EN, 0x1F, - tasha->hph_l_gain); - snd_soc_update_bits(tasha->codec, WCD9335_HPH_R_EN, 0x1F, - tasha->hph_r_gain); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_L_EN, 0x1F, + tasha->hph_l_gain); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_R_EN, 0x1F, + tasha->hph_r_gain); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(tasha->codec, WCD9335_HPH_AUTO_CHOP, 0x20, - 0x00); + snd_soc_component_update_bits(tasha->component, + WCD9335_HPH_AUTO_CHOP, 0x20, + 0x00); } } -static void tasha_codec_override(struct snd_soc_codec *codec, +static void tasha_codec_override(struct snd_soc_component *component, int mode, int event) { if (mode == CLS_AB) { switch (event) { case SND_SOC_DAPM_POST_PMU: - if (!(snd_soc_read(codec, + if (!(snd_soc_component_read32(component, WCD9335_CDC_RX2_RX_PATH_CTL) & 0x10) && - (!(snd_soc_read(codec, + (!(snd_soc_component_read32(component, WCD9335_CDC_RX1_RX_PATH_CTL) & 0x10))) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00); break; } @@ -3855,27 +3957,30 @@ static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int hph_mode = tasha->hph_mode; int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if ((!(strcmp(w->name, "ANC HPHR PA"))) && (test_bit(HPH_PA_DELAY, &tasha->status_mask))) { - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0); + snd_soc_component_update_bits( + component, WCD9335_ANA_HPH, 0xC0, 0xC0); } set_bit(HPH_PA_DELAY, &tasha->status_mask); if (!(strcmp(w->name, "HPHR PA"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x40); + snd_soc_component_update_bits( + component, WCD9335_ANA_HPH, 0x40, 0x40); break; case SND_SOC_DAPM_POST_PMU: if (!(strcmp(w->name, "ANC HPHR PA"))) { - if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) - != 0xC0) + if ((snd_soc_component_read32( + component, WCD9335_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC case) * then do nothing for POST_PMU and let left @@ -3892,30 +3997,32 @@ static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, clear_bit(HPH_PA_DELAY, &tasha->status_mask); } tasha_codec_hph_post_pa_config(tasha, hph_mode, event); - snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX2_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(component, WCD9335_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); if (!(strcmp(w->name, "ANC HPHR PA"))) { /* Do everything needed for left channel */ - snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); /* Remove ANC Rx from reset */ ret = tasha_codec_enable_anc(w, kcontrol, event); } - tasha_codec_override(codec, hph_mode, event); + tasha_codec_override(component, hph_mode, event); break; case SND_SOC_DAPM_PRE_PMD: @@ -3925,21 +4032,22 @@ static int tasha_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, tasha_codec_hph_post_pa_config(tasha, hph_mode, event); if (!(strcmp(w->name, "ANC HPHR PA")) || !(strcmp(w->name, "HPHR PA"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x40, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* 5ms sleep is required after PA is disabled as per * HW requirement */ usleep_range(5000, 5500); - tasha_codec_override(codec, hph_mode, event); + tasha_codec_override(component, hph_mode, event); blocking_notifier_call_chain(&tasha->notifier, WCD_EVENT_POST_HPHR_PA_OFF, &tasha->mbhc); if (!(strcmp(w->name, "ANC HPHR PA"))) { ret = tasha_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x00); } break; @@ -3952,27 +4060,30 @@ static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int hph_mode = tasha->hph_mode; int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if ((!(strcmp(w->name, "ANC HPHL PA"))) && (test_bit(HPH_PA_DELAY, &tasha->status_mask))) { - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0xC0, 0xC0); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0xC0, 0xC0); } if (!(strcmp(w->name, "HPHL PA"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x80, 0x80); set_bit(HPH_PA_DELAY, &tasha->status_mask); break; case SND_SOC_DAPM_POST_PMU: if (!(strcmp(w->name, "ANC HPHL PA"))) { - if ((snd_soc_read(codec, WCD9335_ANA_HPH) & 0xC0) - != 0xC0) + if ((snd_soc_component_read32( + component, WCD9335_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC case) * then do nothing for POST_PMU and let right @@ -3990,31 +4101,33 @@ static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, } tasha_codec_hph_post_pa_config(tasha, hph_mode, event); - snd_soc_update_bits(codec, WCD9335_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, WCD9335_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(component, WCD9335_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); if (!(strcmp(w->name, "ANC HPHL PA"))) { /* Do everything needed for right channel */ - snd_soc_update_bits(codec, WCD9335_CDC_RX2_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX2_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, WCD9335_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); /* Remove ANC Rx from reset */ ret = tasha_codec_enable_anc(w, kcontrol, event); } - tasha_codec_override(codec, hph_mode, event); + tasha_codec_override(component, hph_mode, event); break; case SND_SOC_DAPM_PRE_PMD: blocking_notifier_call_chain(&tasha->notifier, @@ -4023,21 +4136,22 @@ static int tasha_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, tasha_codec_hph_post_pa_config(tasha, hph_mode, event); if (!(strcmp(w->name, "ANC HPHL PA")) || !(strcmp(w->name, "HPHL PA"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x80, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* 5ms sleep is required after PA is disabled as per * HW requirement */ usleep_range(5000, 5500); - tasha_codec_override(codec, hph_mode, event); + tasha_codec_override(component, hph_mode, event); blocking_notifier_call_chain(&tasha->notifier, WCD_EVENT_POST_HPHL_PA_OFF, &tasha->mbhc); if (!(strcmp(w->name, "ANC HPHL PA"))) { ret = tasha_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00); } break; @@ -4050,11 +4164,12 @@ static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0; int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (w->reg == WCD9335_ANA_LO_1_2) { if (w->shift == 7) { @@ -4073,7 +4188,7 @@ static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, lineout_mix_vol_reg = WCD9335_CDC_RX6_RX_PATH_MIX_CTL; } } else { - dev_err(codec->dev, "%s: Error enabling lineout PA\n", + dev_err(component->dev, "%s: Error enabling lineout PA\n", __func__); return -EINVAL; } @@ -4084,32 +4199,33 @@ static int tasha_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, * HW requirement */ usleep_range(5000, 5500); - snd_soc_update_bits(codec, lineout_vol_reg, + snd_soc_component_update_bits(component, lineout_vol_reg, 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, lineout_mix_vol_reg)) & 0x10) + snd_soc_component_update_bits(component, lineout_mix_vol_reg, 0x10, 0x00); if (!(strcmp(w->name, "ANC LINEOUT1 PA")) || !(strcmp(w->name, "ANC LINEOUT2 PA"))) ret = tasha_codec_enable_anc(w, kcontrol, event); - tasha_codec_override(codec, CLS_AB, event); + tasha_codec_override(component, CLS_AB, event); break; case SND_SOC_DAPM_POST_PMD: /* 5ms sleep is required after PA is disabled as per * HW requirement */ usleep_range(5000, 5500); - tasha_codec_override(codec, CLS_AB, event); + tasha_codec_override(component, CLS_AB, event); if (!(strcmp(w->name, "ANC LINEOUT1 PA")) || !(strcmp(w->name, "ANC LINEOUT2 PA"))) { ret = tasha_codec_enable_anc(w, kcontrol, event); if (!(strcmp(w->name, "ANC LINEOUT1 PA"))) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10); } break; @@ -4123,14 +4239,15 @@ static void tasha_spk_anc_update_callback(struct work_struct *work) struct spk_anc_work *spk_anc_dwork; struct tasha_priv *tasha; struct delayed_work *delayed_work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; delayed_work = to_delayed_work(work); spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork); tasha = spk_anc_dwork->tasha; - codec = tasha->codec; + component = tasha->component; - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10); + snd_soc_component_update_bits(component, WCD9335_CDC_RX7_RX_PATH_CFG0, + 0x10, 0x10); } static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w, @@ -4138,10 +4255,11 @@ static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d %d\n", __func__, w->name, event, + dev_dbg(component->dev, "%s %s %d %d\n", __func__, w->name, event, tasha->anc_func); if (!tasha->anc_func) @@ -4155,8 +4273,9 @@ static int tasha_codec_enable_spk_anc(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: cancel_delayed_work_sync(&tasha->spk_anc_dwork.dwork); - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_CFG0, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_CFG0, + 0x10, 0x00); ret = tasha_codec_enable_anc(w, kcontrol, event); break; } @@ -4167,10 +4286,11 @@ static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -4178,12 +4298,13 @@ static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, * HW requirement */ usleep_range(5000, 5500); - snd_soc_update_bits(codec, WCD9335_CDC_RX0_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX0_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, WCD9335_CDC_RX0_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(component, WCD9335_CDC_RX0_RX_PATH_MIX_CTL, 0x10, 0x00); break; @@ -4195,7 +4316,7 @@ static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, if (!(strcmp(w->name, "ANC EAR PA"))) { ret = tasha_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x00); } break; @@ -4204,21 +4325,21 @@ static int tasha_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, return ret; } -static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec, +static void tasha_codec_hph_mode_gain_opt(struct snd_soc_component *component, u8 gain) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u8 hph_l_en, hph_r_en; u8 l_val, r_val; u8 hph_pa_status; bool is_hphl_pa, is_hphr_pa; - hph_pa_status = snd_soc_read(codec, WCD9335_ANA_HPH); + hph_pa_status = snd_soc_component_read32(component, WCD9335_ANA_HPH); is_hphl_pa = hph_pa_status >> 7; is_hphr_pa = (hph_pa_status & 0x40) >> 6; - hph_l_en = snd_soc_read(codec, WCD9335_HPH_L_EN); - hph_r_en = snd_soc_read(codec, WCD9335_HPH_R_EN); + hph_l_en = snd_soc_component_read32(component, WCD9335_HPH_L_EN); + hph_r_en = snd_soc_component_read32(component, WCD9335_HPH_R_EN); l_val = (hph_l_en & 0xC0) | 0x20 | gain; r_val = (hph_r_en & 0xC0) | 0x20 | gain; @@ -4230,102 +4351,135 @@ static void tasha_codec_hph_mode_gain_opt(struct snd_soc_codec *codec, * PA gains to be applied after PAs are enabled */ if ((l_val != hph_l_en) && !is_hphl_pa) { - snd_soc_write(codec, WCD9335_HPH_L_EN, l_val); + snd_soc_component_write(component, WCD9335_HPH_L_EN, l_val); tasha->hph_l_gain = hph_l_en & 0x1F; } if ((r_val != hph_r_en) && !is_hphr_pa) { - snd_soc_write(codec, WCD9335_HPH_R_EN, r_val); + snd_soc_component_write(component, WCD9335_HPH_R_EN, r_val); tasha->hph_r_gain = hph_r_en & 0x1F; } } -static void tasha_codec_hph_lohifi_config(struct snd_soc_codec *codec, +static void tasha_codec_hph_lohifi_config(struct snd_soc_component *component, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x06); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, - 0xF0, 0x40); - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C); - tasha_codec_hph_mode_gain_opt(codec, 0x11); + snd_soc_component_update_bits(component, + WCD9335_RX_BIAS_HPH_PA, + 0x0F, 0x06); + snd_soc_component_update_bits(component, + WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, + 0xF0, 0x40); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, + 0x07, 0x03); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, + 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL1, + 0x0E, 0x0C); + tasha_codec_hph_mode_gain_opt(component, 0x11); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); - snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_PA, 0x0F, 0x0A); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, + 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); + snd_soc_component_write(component, + WCD9335_RX_BIAS_HPH_RDACBUFF_CNP2, 0x8A); + snd_soc_component_update_bits(component, + WCD9335_RX_BIAS_HPH_PA, + 0x0F, 0x0A); } } -static void tasha_codec_hph_lp_config(struct snd_soc_codec *codec, +static void tasha_codec_hph_lp_config(struct snd_soc_component *component, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C); - tasha_codec_hph_mode_gain_opt(codec, 0x10); - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x04); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x20); - snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x07, - 0x01); - snd_soc_update_bits(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x70, - 0x10); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, - 0x0F, 0x01); - snd_soc_update_bits(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, - 0xF0, 0x10); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL1, 0x0E, 0x0C); + tasha_codec_hph_mode_gain_opt(component, 0x10); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x20, 0x20); + snd_soc_component_update_bits(component, + WCD9335_HPH_RDAC_LDO_CTL, 0x07, 0x01); + snd_soc_component_update_bits(component, + WCD9335_HPH_RDAC_LDO_CTL, 0x70, 0x10); + snd_soc_component_update_bits(component, + WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x0F, 0x01); + snd_soc_component_update_bits(component, + WCD9335_RX_BIAS_HPH_RDAC_LDO, 0xF0, 0x10); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_write(codec, WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88); - snd_soc_write(codec, WCD9335_HPH_RDAC_LDO_CTL, 0x33); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x20, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x04, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); - snd_soc_update_bits(codec, WCD9335_HPH_R_EN, 0xC0, 0x80); - snd_soc_update_bits(codec, WCD9335_HPH_L_EN, 0xC0, 0x80); + snd_soc_component_write(component, + WCD9335_RX_BIAS_HPH_RDAC_LDO, 0x88); + snd_soc_component_write(component, + WCD9335_HPH_RDAC_LDO_CTL, 0x33); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x20, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x04, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); + snd_soc_component_update_bits(component, + WCD9335_HPH_R_EN, 0xC0, 0x80); + snd_soc_component_update_bits(component, + WCD9335_HPH_L_EN, 0xC0, 0x80); } } -static void tasha_codec_hph_hifi_config(struct snd_soc_codec *codec, +static void tasha_codec_hph_hifi_config(struct snd_soc_component *component, int event) { if (SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x08); - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL1, 0x0E, 0x0C); - tasha_codec_hph_mode_gain_opt(codec, 0x11); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, 0x07, 0x03); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL1, 0x0E, 0x0C); + tasha_codec_hph_mode_gain_opt(component, 0x11); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, WCD9335_HPH_PA_CTL2, 0x08, 0x00); - snd_soc_update_bits(codec, WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); + snd_soc_component_update_bits(component, + WCD9335_HPH_PA_CTL2, 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_CNP_WG_CTL, 0x07, 0x02); } } -static void tasha_codec_hph_mode_config(struct snd_soc_codec *codec, +static void tasha_codec_hph_mode_config(struct snd_soc_component *component, int event, int mode) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (!TASHA_IS_2_0(tasha->wcd9xxx)) return; switch (mode) { case CLS_H_LP: - tasha_codec_hph_lp_config(codec, event); + tasha_codec_hph_lp_config(component, event); break; case CLS_H_LOHIFI: - tasha_codec_hph_lohifi_config(codec, event); + tasha_codec_hph_lohifi_config(component, event); break; case CLS_H_HIFI: - tasha_codec_hph_hifi_config(codec, event); + tasha_codec_hph_hifi_config(component, event); break; } } @@ -4334,15 +4488,16 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); int hph_mode = tasha->hph_mode; u8 dem_inp; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -4353,27 +4508,29 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, WCD9335_CDC_RX2_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32( + component, WCD9335_CDC_RX2_RX_PATH_SEC0) & + 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHR, ((hph_mode == CLS_H_LOHIFI) ? CLS_H_HIFI : hph_mode)); if (!(strcmp(w->name, "RX INT2 DAC"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x10, 0x10); - tasha_codec_hph_mode_config(codec, event, hph_mode); + tasha_codec_hph_mode_config(component, event, hph_mode); if (tasha->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10); break; @@ -4382,18 +4539,20 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, usleep_range(1000, 1100); if ((hph_mode == CLS_H_LP) && (TASHA_IS_1_1(wcd9xxx))) { - snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL, - 0x03, 0x03); + snd_soc_component_update_bits(component, + WCD9335_HPH_L_DAC_CTL, 0x03, 0x03); } break; case SND_SOC_DAPM_PRE_PMD: if ((hph_mode == CLS_H_LP) && (TASHA_IS_1_1(wcd9xxx))) { - snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_L_DAC_CTL, + 0x03, 0x00); } if (!(strcmp(w->name, "RX INT2 DAC"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x10, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* 1000us required as per HW requirement */ @@ -4401,9 +4560,9 @@ static int tasha_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) & WCD_CLSH_STATE_HPHL)) - tasha_codec_hph_mode_config(codec, event, hph_mode); + tasha_codec_hph_mode_config(component, event, hph_mode); - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHR, ((hph_mode == CLS_H_LOHIFI) ? @@ -4418,16 +4577,17 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); int hph_mode = tasha->hph_mode; u8 dem_inp; int ret = 0; uint32_t impedl = 0, impedr = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -4438,36 +4598,38 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, WCD9335_CDC_RX1_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32( + component, WCD9335_CDC_RX1_RX_PATH_SEC0) & + 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHL, ((hph_mode == CLS_H_LOHIFI) ? CLS_H_HIFI : hph_mode)); if (!(strcmp(w->name, "RX INT1 DAC"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x20); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x20, 0x20); - tasha_codec_hph_mode_config(codec, event, hph_mode); + tasha_codec_hph_mode_config(component, event, hph_mode); if (tasha->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10); ret = wcd_mbhc_get_impedance(&tasha->mbhc, &impedl, &impedr); if (!ret) { - wcd_clsh_imped_config(codec, impedl, false); + wcd_clsh_imped_config(component, impedl, false); set_bit(CLASSH_CONFIG, &tasha->status_mask); } else { - dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n", + dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n", __func__, ret); ret = 0; } @@ -4479,17 +4641,20 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, usleep_range(1000, 1100); if ((hph_mode == CLS_H_LP) && (TASHA_IS_1_1(wcd9xxx))) { - snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL, - 0x03, 0x03); + snd_soc_component_update_bits(component, + WCD9335_HPH_L_DAC_CTL, + 0x03, 0x03); } break; case SND_SOC_DAPM_PRE_PMD: if (!(strcmp(w->name, "RX INT1 DAC"))) - snd_soc_update_bits(codec, WCD9335_ANA_HPH, 0x20, 0x00); + snd_soc_component_update_bits(component, + WCD9335_ANA_HPH, 0x20, 0x00); if ((hph_mode == CLS_H_LP) && (TASHA_IS_1_1(wcd9xxx))) { - snd_soc_update_bits(codec, WCD9335_HPH_L_DAC_CTL, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD9335_HPH_L_DAC_CTL, + 0x03, 0x00); } break; case SND_SOC_DAPM_POST_PMD: @@ -4498,18 +4663,18 @@ static int tasha_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, if (!(wcd_clsh_get_clsh_state(&tasha->clsh_d) & WCD_CLSH_STATE_HPHR)) - tasha_codec_hph_mode_config(codec, event, hph_mode); - wcd_clsh_fsm(codec, &tasha->clsh_d, + tasha_codec_hph_mode_config(component, event, hph_mode); + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHL, ((hph_mode == CLS_H_LOHIFI) ? CLS_H_HIFI : hph_mode)); if (test_bit(CLASSH_CONFIG, &tasha->status_mask)) { - wcd_clsh_imped_config(codec, impedl, true); + wcd_clsh_imped_config(component, impedl, true); clear_bit(CLASSH_CONFIG, &tasha->status_mask); } else - dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n", + dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n", __func__, ret); @@ -4523,11 +4688,12 @@ static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -4536,22 +4702,22 @@ static int tasha_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, !strcmp(w->name, "RX INT4 DAC"))) ret = tasha_codec_enable_anc(w, kcontrol, event); - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_LO, CLS_AB); if (tasha->anc_func) { if (!strcmp(w->name, "RX INT3 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX3_RX_PATH_CFG0, 0x10, 0x10); else if (!strcmp(w->name, "RX INT4 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX4_RX_PATH_CFG0, 0x10, 0x10); } break; case SND_SOC_DAPM_POST_PMD: - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_LO, CLS_AB); @@ -4572,23 +4738,24 @@ static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (tasha->anc_func) ret = tasha_codec_enable_anc(w, kcontrol, event); - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_EAR, CLS_H_NORMAL); if (tasha->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10); break; @@ -4597,7 +4764,7 @@ static int tasha_codec_ear_dac_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: break; case SND_SOC_DAPM_POST_PMD: - wcd_clsh_fsm(codec, &tasha->clsh_d, + wcd_clsh_fsm(component, &tasha->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_EAR, CLS_H_NORMAL); @@ -4611,11 +4778,12 @@ static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 boost_path_ctl, boost_path_cfg1; u16 reg, reg_mix; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (!strcmp(w->name, "RX INT7 CHAIN")) { boost_path_ctl = WCD9335_CDC_BOOST0_BOOST_PATH_CTL; @@ -4628,22 +4796,27 @@ static int tasha_codec_spk_boost_event(struct snd_soc_dapm_widget *w, reg = WCD9335_CDC_RX8_RX_PATH_CTL; reg_mix = WCD9335_CDC_RX8_RX_PATH_MIX_CTL; } else { - dev_err(codec->dev, "%s: unknown widget: %s\n", + dev_err(component->dev, "%s: unknown widget: %s\n", __func__, w->name); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10); - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01); - snd_soc_update_bits(codec, reg, 0x10, 0x00); - if ((snd_soc_read(codec, reg_mix)) & 0x10) - snd_soc_update_bits(codec, reg_mix, 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x10); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x01); + snd_soc_component_update_bits(component, reg, 0x10, 0x00); + if ((snd_soc_component_read32(component, reg_mix)) & 0x10) + snd_soc_component_update_bits(component, reg_mix, + 0x10, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00); - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x00); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x00); break; }; @@ -4705,10 +4878,10 @@ static u16 tasha_interp_get_primary_reg(u16 reg, u16 *ind) return prim_int_reg; } -static void tasha_codec_hd2_control(struct snd_soc_codec *codec, +static void tasha_codec_hd2_control(struct snd_soc_component *component, u16 prim_int_reg, int event) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 hd2_scale_reg; u16 hd2_enable_reg = 0; @@ -4725,23 +4898,29 @@ static void tasha_codec_hd2_control(struct snd_soc_codec *codec, } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x10); - snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x01); - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x10); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x03, 0x01); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x04); } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x03, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x03, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x00); } } static int tasha_codec_enable_prim_interpolator( - struct snd_soc_codec *codec, + struct snd_soc_component *component, u16 reg, int event) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 prim_int_reg; u16 ind = 0; @@ -4751,36 +4930,38 @@ static int tasha_codec_enable_prim_interpolator( case SND_SOC_DAPM_PRE_PMU: tasha->prim_int_users[ind]++; if (tasha->prim_int_users[ind] == 1) { - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x10, 0x10); - tasha_codec_hd2_control(codec, prim_int_reg, event); - snd_soc_update_bits(codec, prim_int_reg, + tasha_codec_hd2_control(component, prim_int_reg, event); + snd_soc_component_update_bits(component, prim_int_reg, 1 << 0x5, 1 << 0x5); } if ((reg != prim_int_reg) && - ((snd_soc_read(codec, prim_int_reg)) & 0x10)) - snd_soc_update_bits(codec, reg, 0x10, 0x10); + ((snd_soc_component_read32( + component, prim_int_reg)) & 0x10)) + snd_soc_component_update_bits(component, reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: tasha->prim_int_users[ind]--; if (tasha->prim_int_users[ind] == 0) { - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 1 << 0x5, 0 << 0x5); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x40, 0x40); - snd_soc_update_bits(codec, prim_int_reg, + snd_soc_component_update_bits(component, prim_int_reg, 0x40, 0x00); - tasha_codec_hd2_control(codec, prim_int_reg, event); + tasha_codec_hd2_control(component, prim_int_reg, event); } break; }; - dev_dbg(codec->dev, "%s: primary interpolator: INT%d, users: %d\n", + dev_dbg(component->dev, "%s: primary interpolator: INT%d, users: %d\n", __func__, ind, tasha->prim_int_users[ind]); return 0; } -static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec, +static int tasha_codec_enable_spline_src(struct snd_soc_component *component, int src_num, int event) { @@ -4791,7 +4972,7 @@ static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec, int *src_users, count, spl_src = SPLINE_SRC0; u16 src_clk_reg = WCD9335_SPLINE_SRC0_CLK_RST_CTL_0; - tasha = snd_soc_codec_get_drvdata(codec); + tasha = snd_soc_component_get_drvdata(component); switch (src_num) { case SRC_IN_HPHL: @@ -4859,16 +5040,19 @@ static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec, count = *src_users; count++; if (count == 1) { - if ((snd_soc_read(codec, src_clk_reg) & 0x02) || - (snd_soc_read(codec, src_paired_reg) & 0x02)) { - snd_soc_update_bits(codec, src_clk_reg, 0x02, - 0x00); - snd_soc_update_bits(codec, src_paired_reg, - 0x02, 0x00); + if ((snd_soc_component_read32( + component, src_clk_reg) & 0x02) || + (snd_soc_component_read32( + component, src_paired_reg) & 0x02)) { + snd_soc_component_update_bits(component, + src_clk_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, + src_paired_reg, 0x02, 0x00); } - snd_soc_update_bits(codec, src_clk_reg, 0x01, 0x01); - snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80, - 0x80); + snd_soc_component_update_bits(component, src_clk_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, + rx_path_cfg_reg, 0x80, 0x80); } *src_users = count; break; @@ -4876,18 +5060,19 @@ static int tasha_codec_enable_spline_src(struct snd_soc_codec *codec, count = *src_users; count--; if (count == 0) { - snd_soc_update_bits(codec, rx_path_cfg_reg, 0x80, - 0x00); - snd_soc_update_bits(codec, src_clk_reg, 0x03, 0x02); + snd_soc_component_update_bits(component, + rx_path_cfg_reg, 0x80, 0x00); + snd_soc_component_update_bits(component, + src_clk_reg, 0x03, 0x02); /* default sample rate */ - snd_soc_update_bits(codec, rx_path_ctl_reg, 0x0f, - 0x04); + snd_soc_component_update_bits(component, + rx_path_ctl_reg, 0x0f, 0x04); } *src_users = count; break; }; - dev_dbg(codec->dev, "%s: Spline SRC%d, users: %d\n", + dev_dbg(component->dev, "%s: Spline SRC%d, users: %d\n", __func__, spl_src, *src_users); return 0; } @@ -4896,40 +5081,42 @@ static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; u8 src_in; - src_in = snd_soc_read(codec, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0); + src_in = snd_soc_component_read32( + component, WCD9335_CDC_RX_INP_MUX_SPLINE_SRC_CFG0); if (!(src_in & 0xFF)) { - dev_err(codec->dev, "%s: Spline SRC%u input not selected\n", + dev_err(component->dev, "%s: Spline SRC%u input not selected\n", __func__, w->shift); return -EINVAL; } switch (w->shift) { case SPLINE_SRC0: - ret = tasha_codec_enable_spline_src(codec, + ret = tasha_codec_enable_spline_src(component, ((src_in & 0x03) == 1) ? SRC_IN_HPHL : SRC_IN_LO1, event); break; case SPLINE_SRC1: - ret = tasha_codec_enable_spline_src(codec, + ret = tasha_codec_enable_spline_src(component, ((src_in & 0x0C) == 4) ? SRC_IN_HPHR : SRC_IN_LO2, event); break; case SPLINE_SRC2: - ret = tasha_codec_enable_spline_src(codec, + ret = tasha_codec_enable_spline_src(component, ((src_in & 0x30) == 0x10) ? SRC_IN_LO3 : SRC_IN_SPKRL, event); break; case SPLINE_SRC3: - ret = tasha_codec_enable_spline_src(codec, + ret = tasha_codec_enable_spline_src(component, ((src_in & 0xC0) == 0x40) ? SRC_IN_LO4 : SRC_IN_SPKRR, event); break; default: - dev_err(codec->dev, "%s: Invalid spline src:%u\n", __func__, + dev_err(component->dev, "%s: Invalid spline src:%u\n", __func__, w->shift); ret = -EINVAL; }; @@ -4940,11 +5127,12 @@ static int tasha_codec_enable_spline_resampler(struct snd_soc_dapm_widget *w, static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct tasha_priv *tasha; int i, ch_cnt; - tasha = snd_soc_codec_get_drvdata(codec); + tasha = snd_soc_component_get_drvdata(component); if (!tasha->nr) return 0; @@ -4987,11 +5175,11 @@ static int tasha_codec_enable_swr(struct snd_soc_dapm_widget *w, return 0; } -static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, +static int tasha_codec_config_ear_spkr_gain(struct snd_soc_component *component, int event, int gain_reg) { int comp_gain_offset, val; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); switch (tasha->spkr_mode) { /* Compander gain in SPKR_MODE1 case is 12 dB */ @@ -5013,9 +5201,9 @@ static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, (tasha->ear_spkr_gain != 0)) { /* For example, val is -8(-12+5-1) for 4dB of gain */ val = comp_gain_offset + tasha->ear_spkr_gain - 1; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); - dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n", + dev_dbg(component->dev, "%s: RX7 Volume %d dB\n", __func__, val); } break; @@ -5028,9 +5216,9 @@ static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL || gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL) && (tasha->ear_spkr_gain != 0)) { - snd_soc_write(codec, gain_reg, 0x0); + snd_soc_component_write(component, gain_reg, 0x0); - dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n", + dev_dbg(component->dev, "%s: Reset RX7 Volume to 0 dB\n", __func__); } break; @@ -5042,13 +5230,14 @@ static int tasha_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 gain_reg; int offset_val = 0; int val = 0; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); switch (w->reg) { case WCD9335_CDC_RX0_RX_PATH_MIX_CTL: @@ -5079,7 +5268,7 @@ static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w, gain_reg = WCD9335_CDC_RX8_RX_VOL_MIX_CTL; break; default: - dev_err(codec->dev, "%s: No gain register avail for %s\n", + dev_err(component->dev, "%s: No gain register avail for %s\n", __func__, w->name); return 0; }; @@ -5091,22 +5280,24 @@ static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w, tasha->comp_enabled[COMPANDER_8]) && (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL || gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) { - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x01); offset_val = -2; } - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); - tasha_codec_config_ear_spkr_gain(codec, event, gain_reg); + snd_soc_component_write(component, gain_reg, val); + tasha_codec_config_ear_spkr_gain(component, event, gain_reg); break; case SND_SOC_DAPM_POST_PMD: if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) && @@ -5114,22 +5305,24 @@ static int tasha_codec_enable_mix_path(struct snd_soc_dapm_widget *w, tasha->comp_enabled[COMPANDER_8]) && (gain_reg == WCD9335_CDC_RX7_RX_VOL_MIX_CTL || gain_reg == WCD9335_CDC_RX8_RX_VOL_MIX_CTL)) { - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x00); offset_val = 2; - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); } - tasha_codec_config_ear_spkr_gain(codec, event, gain_reg); + tasha_codec_config_ear_spkr_gain(component, event, gain_reg); break; }; @@ -5140,14 +5333,16 @@ static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha, bool enable) { int ret = 0; - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; if (!tasha->wcd_native_clk) { - dev_err(tasha->dev, "%s: wcd native clock is NULL\n", __func__); + dev_err(tasha->dev, "%s: wcd native clock is NULL\n", + __func__); return -EINVAL; } - dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", __func__, enable); + dev_dbg(tasha->dev, "%s: native_clk_enable = %u\n", + __func__, enable); if (enable) { ret = clk_prepare_enable(tasha->wcd_native_clk); @@ -5157,40 +5352,47 @@ static int __tasha_cdc_native_clk_enable(struct tasha_priv *tasha, goto err; } if (++tasha->native_clk_users == 1) { - snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL, - 0x10, 0x10); - snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL, - 0x80, 0x80); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE, - 0x04, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, + WCD9335_CLOCK_TEST_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_CLOCK_TEST_CTL, + 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_GATE, + 0x04, 0x00); + snd_soc_component_update_bits(component, WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x02); } } else { if (tasha->native_clk_users && (--tasha->native_clk_users == 0)) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x00); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_GATE, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL, - 0x80, 0x00); - snd_soc_update_bits(codec, WCD9335_CLOCK_TEST_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_GATE, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD9335_CLOCK_TEST_CTL, + 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CLOCK_TEST_CTL, + 0x10, 0x00); } clk_disable_unprepare(tasha->wcd_native_clk); } - dev_dbg(codec->dev, "%s: native_clk_users: %d\n", __func__, + dev_dbg(component->dev, "%s: native_clk_users: %d\n", __func__, tasha->native_clk_users); err: return ret; } -static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec, - int interp_n) +static int tasha_codec_get_native_fifo_sync_mask( + struct snd_soc_component *component, + int interp_n) { int mask = 0; u16 reg; @@ -5199,8 +5401,8 @@ static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec, reg = WCD9335_CDC_RX_INP_MUX_RX_INT1_CFG0 + (2 * interp_n) - 2; - val1 = snd_soc_read(codec, reg); - val2 = snd_soc_read(codec, reg + 1); + val1 = snd_soc_component_read32(component, reg); + val2 = snd_soc_component_read32(component, reg + 1); inp0 = val1 & 0x0F; inp1 = (val1 >> 4) & 0x0F; @@ -5213,9 +5415,9 @@ static int tasha_codec_get_native_fifo_sync_mask(struct snd_soc_codec *codec, if (IS_VALID_NATIVE_FIFO_PORT(inp2)) mask |= (1 << (inp2 - 5)); - dev_dbg(codec->dev, "%s: native fifo mask: 0x%x\n", __func__, mask); + dev_dbg(component->dev, "%s: native fifo mask: 0x%x\n", __func__, mask); if (!mask) - dev_err(codec->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n", + dev_err(component->dev, "native fifo err,int:%d,inp0:%d,inp1:%d,inp2:%d\n", interp_n, inp0, inp1, inp2); return mask; } @@ -5224,11 +5426,12 @@ static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int mask; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 interp_reg; - dev_dbg(codec->dev, "%s: event: %d, shift:%d\n", __func__, event, + dev_dbg(component->dev, "%s: event: %d, shift:%d\n", __func__, event, w->shift); if (w->shift < INTERP_HPHL || w->shift > INTERP_LO2) @@ -5236,24 +5439,28 @@ static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w, interp_reg = WCD9335_CDC_RX1_RX_PATH_CTL + 20 * (w->shift - 1); - mask = tasha_codec_get_native_fifo_sync_mask(codec, w->shift); + mask = tasha_codec_get_native_fifo_sync_mask(component, w->shift); if (!mask) return -EINVAL; switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Adjust interpolator rate to 44P1_NATIVE */ - snd_soc_update_bits(codec, interp_reg, 0x0F, 0x09); + snd_soc_component_update_bits(component, interp_reg, + 0x0F, 0x09); __tasha_cdc_native_clk_enable(tasha, true); - snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC, - mask, mask); + snd_soc_component_update_bits(component, + WCD9335_DATA_HUB_NATIVE_FIFO_SYNC, + mask, mask); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WCD9335_DATA_HUB_NATIVE_FIFO_SYNC, - mask, 0x0); + snd_soc_component_update_bits(component, + WCD9335_DATA_HUB_NATIVE_FIFO_SYNC, + mask, 0x0); __tasha_cdc_native_clk_enable(tasha, false); /* Adjust interpolator rate to default */ - snd_soc_update_bits(codec, interp_reg, 0x0F, 0x04); + snd_soc_component_update_bits(component, interp_reg, + 0x0F, 0x04); break; } @@ -5263,14 +5470,15 @@ static int tasha_enable_native_supply(struct snd_soc_dapm_widget *w, static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 gain_reg; u16 reg; int val; int offset_val = 0; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); if (!(strcmp(w->name, "RX INT0 INTERP"))) { reg = WCD9335_CDC_RX0_RX_PATH_CTL; @@ -5300,66 +5508,70 @@ static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w, reg = WCD9335_CDC_RX8_RX_PATH_CTL; gain_reg = WCD9335_CDC_RX8_RX_VOL_CTL; } else { - dev_err(codec->dev, "%s: Interpolator reg not found\n", + dev_err(component->dev, "%s: Interpolator reg not found\n", __func__); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - tasha_codec_vote_max_bw(codec, true); + tasha_codec_vote_max_bw(component, true); /* Reset if needed */ - tasha_codec_enable_prim_interpolator(codec, reg, event); + tasha_codec_enable_prim_interpolator(component, reg, event); break; case SND_SOC_DAPM_POST_PMU: - tasha_config_compander(codec, w->shift, event); + tasha_config_compander(component, w->shift, event); /* apply gain after int clk is enabled */ if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) && (tasha->comp_enabled[COMPANDER_7] || tasha->comp_enabled[COMPANDER_8]) && (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL || gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) { - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x01); offset_val = -2; } - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); - tasha_codec_config_ear_spkr_gain(codec, event, gain_reg); + snd_soc_component_write(component, gain_reg, val); + tasha_codec_config_ear_spkr_gain(component, event, gain_reg); break; case SND_SOC_DAPM_POST_PMD: - tasha_config_compander(codec, w->shift, event); - tasha_codec_enable_prim_interpolator(codec, reg, event); + tasha_config_compander(component, w->shift, event); + tasha_codec_enable_prim_interpolator(component, reg, event); if ((tasha->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) && (tasha->comp_enabled[COMPANDER_7] || tasha->comp_enabled[COMPANDER_8]) && (gain_reg == WCD9335_CDC_RX7_RX_VOL_CTL || gain_reg == WCD9335_CDC_RX8_RX_VOL_CTL)) { - snd_soc_update_bits(codec, WCD9335_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD9335_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x00); offset_val = 2; - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); } - tasha_codec_config_ear_spkr_gain(codec, event, gain_reg); + tasha_codec_config_ear_spkr_gain(component, event, gain_reg); break; }; @@ -5369,42 +5581,43 @@ static int tasha_codec_enable_interpolator(struct snd_soc_dapm_widget *w, static int tasha_codec_set_iir_gain(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: /* fall through */ case SND_SOC_DAPM_PRE_PMD: if (strnstr(w->name, "IIR0", sizeof("IIR0"))) { - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL)); } else { - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD9335_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL)); } break; @@ -5417,25 +5630,26 @@ static int tasha_codec_enable_on_demand_supply( struct snd_kcontrol *kcontrol, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct on_demand_supply *supply; if (w->shift >= ON_DEMAND_SUPPLIES_MAX) { - dev_err(codec->dev, "%s: error index > MAX Demand supplies", + dev_err(component->dev, "%s: error index > MAX Demand supplies", __func__); ret = -EINVAL; goto out; } - dev_dbg(codec->dev, "%s: supply: %s event: %d\n", + dev_dbg(component->dev, "%s: supply: %s event: %d\n", __func__, on_demand_supply_name[w->shift], event); supply = &tasha->on_demand_list[w->shift]; WARN_ONCE(!supply->supply, "%s isn't defined\n", on_demand_supply_name[w->shift]); if (!supply->supply) { - dev_err(codec->dev, "%s: err supply not present ond for %d", + dev_err(component->dev, "%s: err supply not present ond for %d", __func__, w->shift); goto out; } @@ -5444,14 +5658,14 @@ static int tasha_codec_enable_on_demand_supply( case SND_SOC_DAPM_PRE_PMU: ret = regulator_enable(supply->supply); if (ret) - dev_err(codec->dev, "%s: Failed to enable %s\n", + dev_err(component->dev, "%s: Failed to enable %s\n", __func__, on_demand_supply_name[w->shift]); break; case SND_SOC_DAPM_POST_PMD: ret = regulator_disable(supply->supply); if (ret) - dev_err(codec->dev, "%s: Failed to disable %s\n", + dev_err(component->dev, "%s: Failed to disable %s\n", __func__, on_demand_supply_name[w->shift]); break; @@ -5463,7 +5677,7 @@ out: return ret; } -static int tasha_codec_find_amic_input(struct snd_soc_codec *codec, +static int tasha_codec_find_amic_input(struct snd_soc_component *component, int adc_mux_n) { u16 mask, shift, adc_mux_in_reg; @@ -5489,15 +5703,15 @@ static int tasha_codec_find_amic_input(struct snd_soc_codec *codec, mask = 0xC0; shift = 6; } - is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift) - == 1); + is_amic = (((snd_soc_component_read32( + component, adc_mux_in_reg) & mask) >> shift) == 1); if (!is_amic) return 0; - return snd_soc_read(codec, amic_mux_sel_reg) & 0x07; + return snd_soc_component_read32(component, amic_mux_sel_reg) & 0x07; } -static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec, +static void tasha_codec_set_tx_hold(struct snd_soc_component *component, u16 amic_reg, bool set) { u8 mask = 0x20; @@ -5513,18 +5727,21 @@ static void tasha_codec_set_tx_hold(struct snd_soc_codec *codec, switch (amic_reg) { case WCD9335_ANA_AMIC1: case WCD9335_ANA_AMIC2: - snd_soc_update_bits(codec, WCD9335_ANA_AMIC2, mask, val); + snd_soc_component_update_bits(component, WCD9335_ANA_AMIC2, + mask, val); break; case WCD9335_ANA_AMIC3: case WCD9335_ANA_AMIC4: - snd_soc_update_bits(codec, WCD9335_ANA_AMIC4, mask, val); + snd_soc_component_update_bits(component, WCD9335_ANA_AMIC4, + mask, val); break; case WCD9335_ANA_AMIC5: case WCD9335_ANA_AMIC6: - snd_soc_update_bits(codec, WCD9335_ANA_AMIC6, mask, val); + snd_soc_component_update_bits(component, WCD9335_ANA_AMIC6, + mask, val); break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic_reg); break; } @@ -5534,15 +5751,16 @@ static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int adc_mux_n = w->shift; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int amic_n; - dev_dbg(codec->dev, "%s: event: %d\n", __func__, event); + dev_dbg(component->dev, "%s: event: %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: - amic_n = tasha_codec_find_amic_input(codec, adc_mux_n); + amic_n = tasha_codec_find_amic_input(component, adc_mux_n); if (amic_n) { /* * Prevent ANC Rx pop by leaving Tx FE in HOLD @@ -5560,7 +5778,8 @@ static int tasha_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w, return 0; } -static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) +static u16 tasha_codec_get_amic_pwlvl_reg( + struct snd_soc_component *component, int amic) { u16 pwr_level_reg = 0; @@ -5580,7 +5799,7 @@ static u16 tasha_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) pwr_level_reg = WCD9335_ANA_AMIC5; break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic); break; } @@ -5598,7 +5817,7 @@ static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work) struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tasha_priv *tasha; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 dec_cfg_reg, amic_reg; u8 hpf_cut_off_freq; int amic_n; @@ -5606,23 +5825,24 @@ static void tasha_tx_hpf_corner_freq_callback(struct work_struct *work) hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tasha = hpf_work->tasha; - codec = tasha->codec; + component = tasha->component; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = WCD9335_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator; - dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", + dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); - amic_n = tasha_codec_find_amic_input(codec, hpf_work->decimator); + amic_n = tasha_codec_find_amic_input(component, hpf_work->decimator); if (amic_n) { amic_reg = WCD9335_ANA_AMIC1 + amic_n - 1; - tasha_codec_set_tx_hold(codec, amic_reg, false); + tasha_codec_set_tx_hold(component, amic_reg, false); } - tasha_codec_vote_max_bw(codec, true); - snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - tasha_codec_vote_max_bw(codec, false); + tasha_codec_vote_max_bw(component, true); + snd_soc_component_update_bits(component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + tasha_codec_vote_max_bw(component, false); } static void tasha_tx_mute_update_callback(struct work_struct *work) @@ -5630,26 +5850,27 @@ static void tasha_tx_mute_update_callback(struct work_struct *work) struct tx_mute_work *tx_mute_dwork; struct tasha_priv *tasha; struct delayed_work *delayed_work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 tx_vol_ctl_reg, hpf_gate_reg; delayed_work = to_delayed_work(work); tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork); tasha = tx_mute_dwork->tasha; - codec = tasha->codec; + component = tasha->component; tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * tx_mute_dwork->decimator; hpf_gate_reg = WCD9335_CDC_TX0_TX_PATH_SEC2 + 16 * tx_mute_dwork->decimator; - snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x01); - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, hpf_gate_reg, 0x01, 0x01); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00); } static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; @@ -5659,9 +5880,9 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, u16 tx_gain_ctl_reg; char *dec; u8 hpf_cut_off_freq; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %d\n", __func__, event); + dev_dbg(component->dev, "%s %d\n", __func__, event); widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) @@ -5670,7 +5891,7 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, wname = widget_name; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { - dev_err(codec->dev, "%s: Invalid decimator = %s\n", + dev_err(component->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; @@ -5679,7 +5900,7 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, dec = strpbrk(dec_adc_mux_name, "012345678"); if (!dec) { - dev_err(codec->dev, "%s: decimator index not found\n", + dev_err(component->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; @@ -5687,13 +5908,13 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid decimator = %s\n", + dev_err(component->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; } - dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__, + dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__, w->name, decimator); tx_vol_ctl_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator; @@ -5703,54 +5924,65 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - amic_n = tasha_codec_find_amic_input(codec, decimator); + amic_n = tasha_codec_find_amic_input(component, decimator); if (amic_n) - pwr_level_reg = tasha_codec_get_amic_pwlvl_reg(codec, - amic_n); + pwr_level_reg = tasha_codec_get_amic_pwlvl_reg( + component, amic_n); if (pwr_level_reg) { - switch ((snd_soc_read(codec, pwr_level_reg) & + switch ( + (snd_soc_component_read32(component, pwr_level_reg) & WCD9335_AMIC_PWR_LVL_MASK) >> WCD9335_AMIC_PWR_LVL_SHIFT) { case WCD9335_AMIC_PWR_LEVEL_LP: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD9335_DEC_PWR_LVL_MASK, - WCD9335_DEC_PWR_LVL_LP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD9335_DEC_PWR_LVL_MASK, + WCD9335_DEC_PWR_LVL_LP); break; case WCD9335_AMIC_PWR_LEVEL_HP: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD9335_DEC_PWR_LVL_MASK, - WCD9335_DEC_PWR_LVL_HP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD9335_DEC_PWR_LVL_MASK, + WCD9335_DEC_PWR_LVL_HP); break; case WCD9335_AMIC_PWR_LEVEL_DEFAULT: default: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD9335_DEC_PWR_LVL_MASK, - WCD9335_DEC_PWR_LVL_DF); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD9335_DEC_PWR_LVL_MASK, + WCD9335_DEC_PWR_LVL_DF); break; } } - hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & + hpf_cut_off_freq = ( + snd_soc_component_read32(component, dec_cfg_reg) & TX_HPF_CUT_OFF_FREQ_MASK) >> 5; tasha->tx_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); /* Enable TX PGA Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, hpf_gate_reg, 0x01, 0x00); + snd_soc_component_update_bits(component, hpf_gate_reg, + 0x01, 0x00); if (decimator == 0) { - snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83); - snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3); - snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x83); - snd_soc_write(codec, WCD9335_MBHC_ZDET_RAMP_CTL, 0x03); + snd_soc_component_write(component, + WCD9335_MBHC_ZDET_RAMP_CTL, 0x83); + snd_soc_component_write(component, + WCD9335_MBHC_ZDET_RAMP_CTL, 0xA3); + snd_soc_component_write(component, + WCD9335_MBHC_ZDET_RAMP_CTL, 0x83); + snd_soc_component_write(component, + WCD9335_MBHC_ZDET_RAMP_CTL, 0x03); } /* schedule work queue to Remove Mute */ schedule_delayed_work(&tasha->tx_mute_dwork[decimator].dwork, @@ -5761,28 +5993,32 @@ static int tasha_codec_enable_dec(struct snd_soc_dapm_widget *w, &tasha->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); /* apply gain after decimator is enabled */ - snd_soc_write(codec, tx_gain_ctl_reg, - snd_soc_read(codec, tx_gain_ctl_reg)); + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read32( + component, tx_gain_ctl_reg)); break; case SND_SOC_DAPM_PRE_PMD: hpf_cut_off_freq = tasha->tx_hpf_work[decimator].hpf_cut_off_freq; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); if (cancel_delayed_work_sync( &tasha->tx_hpf_work[decimator].dwork)) { if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - tasha_codec_vote_max_bw(codec, true); - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - tasha_codec_vote_max_bw(codec, false); + tasha_codec_vote_max_bw(component, true); + snd_soc_component_update_bits(component, + dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + tasha_codec_vote_max_bw(component, false); } } cancel_delayed_work_sync( &tasha->tx_mute_dwork[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x00); break; }; out: @@ -5790,7 +6026,7 @@ out: return ret; } -static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec, +static u32 tasha_get_dmic_sample_rate(struct snd_soc_component *component, unsigned int dmic, struct wcd9xxx_pdata *pdata) { u8 tx_stream_fs; @@ -5803,13 +6039,13 @@ static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec, if (adc_mux_index < 4) { adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX0_CFG0 + (adc_mux_index * 2); - adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) & - 0x78) >> 3) - 1; + adc_mux_sel = ((snd_soc_component_read32(component, + adc_mux_ctl_reg) & 0x78) >> 3) - 1; } else if (adc_mux_index < 9) { adc_mux_ctl_reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + ((adc_mux_index - 4) * 1); - adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) & - 0x38) >> 3) - 1; + adc_mux_sel = ((snd_soc_component_read32( + component, adc_mux_ctl_reg) & 0x38) >> 3) - 1; } else if (adc_mux_index == 9) { ++adc_mux_index; continue; @@ -5822,7 +6058,8 @@ static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec, if (dec_found == true && adc_mux_index <= 8) { tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index); - tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F; + tx_stream_fs = + snd_soc_component_read32(component, tx_fs_reg) & 0x0F; dmic_fs = tx_stream_fs <= 4 ? WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ : WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ; @@ -5831,10 +6068,12 @@ static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec, * any other audio path to apply ECPP DMIC sample rate */ if ((adc_mux_index == 1) && - ((snd_soc_read(codec, WCD9335_CPE_SS_US_EC_MUX_CFG) - & 0x0F) == 0x0A) && - ((snd_soc_read(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0) - & 0x0C) == 0x00)) { + ((snd_soc_component_read32( + component, WCD9335_CPE_SS_US_EC_MUX_CFG) + & 0x0F) == 0x0A) && + ((snd_soc_component_read32( + component, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0) + & 0x0C) == 0x00)) { dmic_fs = pdata->ecpp_dmic_sample_rate; } } else { @@ -5844,13 +6083,13 @@ static u32 tasha_get_dmic_sample_rate(struct snd_soc_codec *codec, return dmic_fs; } -static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec, +static u8 tasha_get_dmic_clk_val(struct snd_soc_component *component, u32 mclk_rate, u32 dmic_clk_rate) { u32 div_factor; u8 dmic_ctl_val; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: mclk_rate = %d, dmic_sample_rate = %d\n", __func__, mclk_rate, dmic_clk_rate); @@ -5861,7 +6100,7 @@ static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec, dmic_ctl_val = WCD9335_DMIC_CLK_DIV_3; if (dmic_clk_rate == 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: dmic_sample_rate cannot be 0\n", __func__); goto done; @@ -5888,7 +6127,7 @@ static u8 tasha_get_dmic_clk_val(struct snd_soc_codec *codec, dmic_ctl_val = WCD9335_DMIC_CLK_DIV_16; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n", __func__, div_factor, mclk_rate, dmic_clk_rate); break; @@ -5901,13 +6140,14 @@ done: static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event:%d\n", __func__, event); + dev_dbg(component->dev, "%s: event:%d\n", __func__, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - tasha_codec_set_tx_hold(codec, w->reg, true); + tasha_codec_set_tx_hold(component, w->reg, true); break; default: break; @@ -5919,9 +6159,10 @@ static int tasha_codec_enable_adc(struct snd_soc_dapm_widget *w, static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); u8 dmic_clk_en = 0x01; u16 dmic_clk_reg; s32 *dmic_clk_cnt; @@ -5933,13 +6174,13 @@ static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w, wname = strpbrk(w->name, "012345"); if (!wname) { - dev_err(codec->dev, "%s: widget not found\n", __func__); + dev_err(component->dev, "%s: widget not found\n", __func__); return -EINVAL; } ret = kstrtouint(wname, 10, &dmic); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n", + dev_err(component->dev, "%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } @@ -5961,42 +6202,42 @@ static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w, dmic_clk_reg = WCD9335_CPE_SS_DMIC2_CTL; break; default: - dev_err(codec->dev, "%s: Invalid DMIC Selection\n", + dev_err(component->dev, "%s: Invalid DMIC Selection\n", __func__); return -EINVAL; }; - dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", + dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); switch (event) { case SND_SOC_DAPM_PRE_PMU: - dmic_sample_rate = tasha_get_dmic_sample_rate(codec, dmic, + dmic_sample_rate = tasha_get_dmic_sample_rate(component, dmic, pdata); dmic_rate_val = - tasha_get_dmic_clk_val(codec, + tasha_get_dmic_clk_val(component, pdata->mclk_rate, dmic_sample_rate); (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) { - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, dmic_clk_en); } break; case SND_SOC_DAPM_POST_PMD: dmic_rate_val = - tasha_get_dmic_clk_val(codec, + tasha_get_dmic_clk_val(component, pdata->mclk_rate, pdata->mad_dmic_sample_rate); (*dmic_clk_cnt)--; if (*dmic_clk_cnt == 0) { - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, 0); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); } @@ -6009,10 +6250,11 @@ static int tasha_codec_enable_dmic(struct snd_soc_dapm_widget *w, static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int micb_num; - dev_dbg(codec->dev, "%s: wname: %s, event: %d\n", + dev_dbg(component->dev, "%s: wname: %s, event: %d\n", __func__, w->name, event); if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) @@ -6033,14 +6275,14 @@ static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w, * so use ref count to handle micbias pullup * and enable requests */ - tasha_micbias_control(codec, micb_num, MICB_ENABLE, true); + tasha_micbias_control(component, micb_num, MICB_ENABLE, true); break; case SND_SOC_DAPM_POST_PMU: /* wait for cnp time */ usleep_range(1000, 1100); break; case SND_SOC_DAPM_POST_PMD: - tasha_micbias_control(codec, micb_num, MICB_DISABLE, true); + tasha_micbias_control(component, micb_num, MICB_DISABLE, true); break; }; @@ -6050,15 +6292,17 @@ static int __tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w, static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (SND_SOC_DAPM_EVENT_ON(event)) { tasha->ldo_h_users++; if (tasha->ldo_h_users == 1) - snd_soc_update_bits(codec, WCD9335_LDOH_MODE, - 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD9335_LDOH_MODE, + 0x80, 0x80); } if (SND_SOC_DAPM_EVENT_OFF(event)) { @@ -6068,8 +6312,9 @@ static int tasha_codec_ldo_h_control(struct snd_soc_dapm_widget *w, tasha->ldo_h_users = 0; if (tasha->ldo_h_users == 0) - snd_soc_update_bits(codec, WCD9335_LDOH_MODE, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD9335_LDOH_MODE, + 0x80, 0x00); } return 0; @@ -6079,8 +6324,9 @@ static int tasha_codec_force_enable_ldo_h(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -6101,17 +6347,18 @@ static int tasha_codec_force_enable_micbias(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: wcd_resmgr_enable_master_bias(tasha->resmgr); - tasha_cdc_mclk_enable(codec, true, true); + tasha_cdc_mclk_enable(component, true, true); ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU); /* Wait for 1ms for better cnp */ usleep_range(1000, 1100); - tasha_cdc_mclk_enable(codec, false, true); + tasha_cdc_mclk_enable(component, false, true); break; case SND_SOC_DAPM_POST_PMD: ret = __tasha_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD); @@ -6128,24 +6375,25 @@ static int tasha_codec_enable_micbias(struct snd_soc_dapm_widget *w, return __tasha_codec_enable_micbias(w, event); } -static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec, - bool enable) +static int tasha_codec_enable_standalone_ldo_h( + struct snd_soc_component *component, + bool enable) { int rc; if (enable) rc = snd_soc_dapm_force_enable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), DAPM_LDO_H_STANDALONE); else rc = snd_soc_dapm_disable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), DAPM_LDO_H_STANDALONE); if (!rc) - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); else - dev_err(codec->dev, "%s: ldo_h force %s pin failed\n", + dev_err(component->dev, "%s: ldo_h force %s pin failed\n", __func__, (enable ? "enable" : "disable")); return rc; @@ -6153,7 +6401,7 @@ static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec, /* * tasha_codec_enable_standalone_micbias - enable micbias standalone - * @codec: pointer to codec instance + * @component: pointer to codec instance * @micb_num: number of micbias to be enabled * @enable: true to enable micbias or false to disable * @@ -6162,7 +6410,7 @@ static int tasha_codec_enable_standalone_ldo_h(struct snd_soc_codec *codec, * * Return: error code in case of failure or 0 for success */ -int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec, +int tasha_codec_enable_standalone_micbias(struct snd_soc_component *component, int micb_num, bool enable) { @@ -6173,29 +6421,30 @@ int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec, int micb_index = micb_num - 1; int rc; - if (!codec) { - pr_err("%s: Codec memory is NULL\n", __func__); + if (!component) { + pr_err("%s: Component memory is NULL\n", __func__); return -EINVAL; } if ((micb_index < 0) || (micb_index > TASHA_MAX_MICBIAS - 1)) { - dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n", + dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n", __func__, micb_index); return -EINVAL; } if (enable) rc = snd_soc_dapm_force_enable_pin( - snd_soc_codec_get_dapm(codec), - micb_names[micb_index]); + snd_soc_component_get_dapm(component), + micb_names[micb_index]); else - rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec), - micb_names[micb_index]); + rc = snd_soc_dapm_disable_pin( + snd_soc_component_get_dapm(component), + micb_names[micb_index]); if (!rc) - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); else - dev_err(codec->dev, "%s: micbias%d force %s pin failed\n", + dev_err(component->dev, "%s: micbias%d force %s pin failed\n", __func__, micb_num, (enable ? "enable" : "disable")); return rc; @@ -7622,7 +7871,8 @@ static const struct snd_soc_dapm_route audio_map[] = { static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u16 amic_reg; if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE")) @@ -7633,8 +7883,9 @@ static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, amic_reg = WCD9335_ANA_AMIC5; ucontrol->value.integer.value[0] = - (snd_soc_read(codec, amic_reg) & WCD9335_AMIC_PWR_LVL_MASK) >> - WCD9335_AMIC_PWR_LVL_SHIFT; + (snd_soc_component_read32(component, amic_reg) & + WCD9335_AMIC_PWR_LVL_MASK) >> + WCD9335_AMIC_PWR_LVL_SHIFT; return 0; } @@ -7642,13 +7893,14 @@ static int tasha_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u32 mode_val; u16 amic_reg; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE")) @@ -7658,8 +7910,9 @@ static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, if (!strcmp(kcontrol->id.name, "AMIC_5_6 PWR MODE")) amic_reg = WCD9335_ANA_AMIC5; - snd_soc_update_bits(codec, amic_reg, WCD9335_AMIC_PWR_LVL_MASK, - mode_val << WCD9335_AMIC_PWR_LVL_SHIFT); + snd_soc_component_update_bits(component, amic_reg, + WCD9335_AMIC_PWR_LVL_MASK, + mode_val << WCD9335_AMIC_PWR_LVL_SHIFT); return 0; } @@ -7667,8 +7920,9 @@ static int tasha_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha->hph_mode; return 0; @@ -7677,17 +7931,18 @@ static int tasha_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int tasha_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u32 mode_val; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (mode_val == 0) { - dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n", + dev_warn(component->dev, "%s:Invalid HPH Mode, default to Cls-H HiFi\n", __func__); mode_val = CLS_H_HIFI; } @@ -7708,11 +7963,13 @@ static const struct soc_enum tasha_conn_mad_enum = static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u8 val = 0; - if (codec) - val = snd_soc_read(codec, WCD9335_LDOH_MODE) & 0x80; + if (component) + val = snd_soc_component_read32(component, WCD9335_LDOH_MODE) & + 0x80; ucontrol->value.integer.value[0] = !!val; @@ -7722,13 +7979,14 @@ static int tasha_enable_ldo_h_get(struct snd_kcontrol *kcontrol, static int tasha_enable_ldo_h_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int value = ucontrol->value.integer.value[0]; bool enable; enable = !!value; - if (codec) - tasha_codec_enable_standalone_ldo_h(codec, enable); + if (component) + tasha_codec_enable_standalone_ldo_h(component, enable); return 0; } @@ -7737,13 +7995,14 @@ static int tasha_mad_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 tasha_mad_input; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - tasha_mad_input = snd_soc_read(codec, + tasha_mad_input = snd_soc_component_read32(component, WCD9335_SOC_MAD_INP_SEL) & 0x0F; ucontrol->value.integer.value[0] = tasha_mad_input; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: tasha_mad_input = %s\n", __func__, tasha_conn_mad_text[tasha_mad_input]); return 0; @@ -7753,8 +8012,9 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 tasha_mad_input; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_card *card = codec->component.card; + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct snd_soc_card *card = component->card; char mad_amic_input_widget[6]; const char *mad_input_widget; const char *source_widget = NULL; @@ -7765,7 +8025,7 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, tasha_mad_input = ucontrol->value.integer.value[0]; if (tasha_mad_input >= ARRAY_SIZE(tasha_conn_mad_text)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: tasha_mad_input = %d out of bounds\n", __func__, tasha_mad_input); return -EINVAL; @@ -7775,7 +8035,7 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED2") || !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED3") || !strcmp(tasha_conn_mad_text[tasha_mad_input], "NOTUSED4")) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Unsupported tasha_mad_input = %s\n", __func__, tasha_conn_mad_text[tasha_mad_input]); return -EINVAL; @@ -7786,14 +8046,14 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, mad_input = strpbrk(tasha_conn_mad_text[tasha_mad_input], "123456"); if (!mad_input) { - dev_err(codec->dev, "%s: Invalid MAD input %s\n", + dev_err(component->dev, "%s: Invalid MAD input %s\n", __func__, tasha_conn_mad_text[tasha_mad_input]); return -EINVAL; } ret = kstrtouint(mad_input, 10, &adc); if ((ret < 0) || (adc > 6)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid ADC = %s\n", __func__, tasha_conn_mad_text[tasha_mad_input]); ret = -EINVAL; @@ -7807,7 +8067,7 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, mad_input_widget = tasha_conn_mad_text[tasha_mad_input]; } - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: tasha input widget = %s\n", __func__, mad_input_widget); @@ -7815,7 +8075,7 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) { source_widget = card->of_dapm_routes[i].source; if (!source_widget) { - dev_err(codec->dev, + dev_err(component->dev, "%s: invalid source widget\n", __func__); return -EINVAL; @@ -7842,19 +8102,19 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, } if (!mic_bias_found) { - dev_err(codec->dev, + dev_err(component->dev, "%s: mic bias source not found for input = %s\n", __func__, mad_input_widget); return -EINVAL; } - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: mic_bias found = %d\n", __func__, mic_bias_found); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_INP_SEL, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_INP_SEL, 0x0F, tasha_mad_input); - snd_soc_update_bits(codec, WCD9335_ANA_MAD_SETUP, + snd_soc_component_update_bits(component, WCD9335_ANA_MAD_SETUP, 0x07, mic_bias_found); return 0; @@ -7863,7 +8123,8 @@ static int tasha_mad_input_put(struct snd_kcontrol *kcontrol, static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u16 ctl_reg; u8 reg_val, pinctl_position; @@ -7883,12 +8144,12 @@ static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol, ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3; break; default: - dev_err(codec->dev, "%s: Invalid pinctl position = %d\n", + dev_err(component->dev, "%s: Invalid pinctl position = %d\n", __func__, pinctl_position); return -EINVAL; } - reg_val = snd_soc_read(codec, ctl_reg); + reg_val = snd_soc_component_read32(component, ctl_reg); reg_val = (reg_val >> (pinctl_position & 0x07)) & 0x1; ucontrol->value.integer.value[0] = reg_val; @@ -7898,8 +8159,9 @@ static int tasha_pinctl_mode_get(struct snd_kcontrol *kcontrol, static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 ctl_reg, cfg_reg; u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask; @@ -7922,14 +8184,14 @@ static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol, ctl_reg = WCD9335_TEST_DEBUG_PIN_CTL_OE_3; break; default: - dev_err(codec->dev, "%s: Invalid pinctl position = %d\n", + dev_err(component->dev, "%s: Invalid pinctl position = %d\n", __func__, pinctl_position); return -EINVAL; } ctl_val = pinctl_mode << (pinctl_position & 0x07); mask = 1 << (pinctl_position & 0x07); - snd_soc_update_bits(codec, ctl_reg, mask, ctl_val); + snd_soc_component_update_bits(component, ctl_reg, mask, ctl_val); cfg_reg = WCD9335_TLMM_BIST_MODE_PINCFG + pinctl_position; if (!pinctl_mode) { @@ -7940,16 +8202,16 @@ static int tasha_pinctl_mode_put(struct snd_kcontrol *kcontrol, } else { cfg_val = 0; } - snd_soc_update_bits(codec, cfg_reg, 0x07, cfg_val); + snd_soc_component_update_bits(component, cfg_reg, 0x07, cfg_val); - dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n", + dev_dbg(component->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n", __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val); return 0; } static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { u8 val1, val2; @@ -7957,51 +8219,65 @@ static void wcd_vbat_adc_out_config_2_0(struct wcd_vbat *vbat, * Measure dcp1 by using "ALT" branch of band gap * voltage(Vbg) and use it in FAST mode */ - snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x82, 0x82); - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x01); - snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x80); - snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x00); - - snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x20); + snd_soc_component_update_bits(component, WCD9335_BIAS_CTL, + 0x82, 0x82); + snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, + 0x01, 0x01); + snd_soc_component_update_bits(component, WCD9335_ANA_VBADC, + 0x80, 0x80); + snd_soc_component_update_bits(component, WCD9335_VBADC_SUBBLOCK_EN, + 0x20, 0x00); + snd_soc_component_update_bits(component, WCD9335_VBADC_FE_CTRL, + 0x20, 0x20); /* Wait 100 usec after calibration select as Vbg */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40); - val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB); - val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB); - snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00); + snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO, + 0x40, 0x40); + val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB); + val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB); + snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO, + 0x40, 0x00); vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07)); - snd_soc_update_bits(codec, WCD9335_BIAS_CTL, 0x40, 0x40); + snd_soc_component_update_bits(component, WCD9335_BIAS_CTL, 0x40, 0x40); /* Wait 100 usec after selecting Vbg as 1.05V */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x40); - val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB); - val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB); - snd_soc_update_bits(codec, WCD9335_VBADC_ADC_IO, 0x40, 0x00); + snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO, + 0x40, 0x40); + val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB); + val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB); + snd_soc_component_update_bits(component, WCD9335_VBADC_ADC_IO, + 0x40, 0x00); vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07)); - dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n", + dev_dbg(component->dev, "%s: dcp1:0x%x, dcp2:0x%x\n", __func__, vbat->dcp1, vbat->dcp2); - snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28); + snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28); /* Wait 100 usec after selecting Vbg as 0.85V */ usleep_range(100, 110); - snd_soc_update_bits(codec, WCD9335_VBADC_FE_CTRL, 0x20, 0x00); - snd_soc_update_bits(codec, WCD9335_VBADC_SUBBLOCK_EN, 0x20, 0x20); - snd_soc_update_bits(codec, WCD9335_ANA_VBADC, 0x80, 0x00); + snd_soc_component_update_bits(component, WCD9335_VBADC_FE_CTRL, + 0x20, 0x00); + snd_soc_component_update_bits(component, WCD9335_VBADC_SUBBLOCK_EN, + 0x20, 0x20); + snd_soc_component_update_bits(component, WCD9335_ANA_VBADC, + 0x80, 0x00); - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01, 0x00); + snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL, + 0x10, 0x00); + snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, + 0x01, 0x00); } static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { u8 val1, val2; @@ -8009,29 +8285,30 @@ static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat, * Measure dcp1 by applying band gap voltage(Vbg) * of 0.85V */ - snd_soc_write(codec, WCD9335_ANA_BIAS, 0x20); - snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28); - snd_soc_write(codec, WCD9335_BIAS_VBG_FINE_ADJ, 0x05); - snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x20); + snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28); + snd_soc_component_write(component, WCD9335_BIAS_VBG_FINE_ADJ, 0x05); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xA0); /* Wait 2 sec after enabling band gap bias */ usleep_range(2000000, 2000100); - snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x82); - snd_soc_write(codec, WCD9335_ANA_CLK_TOP, 0x87); - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x10, 0x10); - snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D); - snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01); + snd_soc_component_write(component, WCD9335_ANA_CLK_TOP, 0x82); + snd_soc_component_write(component, WCD9335_ANA_CLK_TOP, 0x87); + snd_soc_component_update_bits(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL, + 0x10, 0x10); + snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_CFG, 0x0D); + snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x01); - snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80); - snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xDE); - snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x3C); + snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x80); + snd_soc_component_write(component, WCD9335_VBADC_SUBBLOCK_EN, 0xDE); + snd_soc_component_write(component, WCD9335_VBADC_FE_CTRL, 0x3C); /* Wait 1 msec after calibration select as Vbg */ usleep_range(1000, 1100); - snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0); - val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB); - val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB); - snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80); + snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0xC0); + val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB); + val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB); + snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80); vbat->dcp1 = (((val1 & 0xFF) << 3) | (val2 & 0x07)); @@ -8039,69 +8316,70 @@ static void wcd_vbat_adc_out_config_1_x(struct wcd_vbat *vbat, * Measure dcp2 by applying band gap voltage(Vbg) * of 1.05V */ - snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80); - snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0); - snd_soc_write(codec, WCD9335_BIAS_CTL, 0x68); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xC0); + snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x68); /* Wait 2 msec after selecting Vbg as 1.05V */ usleep_range(2000, 2100); - snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80); /* Wait 1 sec after enabling band gap bias */ usleep_range(1000000, 1000100); - snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0xC0); - val1 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTMSB); - val2 = snd_soc_read(codec, WCD9335_VBADC_ADC_DOUTLSB); - snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80); + snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0xC0); + val1 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTMSB); + val2 = snd_soc_component_read32(component, WCD9335_VBADC_ADC_DOUTLSB); + snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80); vbat->dcp2 = (((val1 & 0xFF) << 3) | (val2 & 0x07)); - dev_dbg(codec->dev, "%s: dcp1:0x%x, dcp2:0x%x\n", + dev_dbg(component->dev, "%s: dcp1:0x%x, dcp2:0x%x\n", __func__, vbat->dcp1, vbat->dcp2); /* Reset the Vbat ADC configuration */ - snd_soc_write(codec, WCD9335_ANA_BIAS, 0x80); - snd_soc_write(codec, WCD9335_ANA_BIAS, 0xC0); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0x80); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xC0); - snd_soc_write(codec, WCD9335_BIAS_CTL, 0x28); + snd_soc_component_write(component, WCD9335_BIAS_CTL, 0x28); /* Wait 2 msec after selecting Vbg as 0.85V */ usleep_range(2000, 2100); - snd_soc_write(codec, WCD9335_ANA_BIAS, 0xA0); + snd_soc_component_write(component, WCD9335_ANA_BIAS, 0xA0); /* Wait 1 sec after enabling band gap bias */ usleep_range(1000000, 1000100); - snd_soc_write(codec, WCD9335_VBADC_FE_CTRL, 0x1C); - snd_soc_write(codec, WCD9335_VBADC_SUBBLOCK_EN, 0xFE); - snd_soc_write(codec, WCD9335_VBADC_ADC_IO, 0x80); - snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00); + snd_soc_component_write(component, WCD9335_VBADC_FE_CTRL, 0x1C); + snd_soc_component_write(component, WCD9335_VBADC_SUBBLOCK_EN, 0xFE); + snd_soc_component_write(component, WCD9335_VBADC_ADC_IO, 0x80); + snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x00); - snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00); - snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_PATH_CTL, 0x00); - snd_soc_write(codec, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A); + snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_DEBUG1, 0x00); + snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_PATH_CTL, + 0x00); + snd_soc_component_write(component, WCD9335_CDC_VBAT_VBAT_CFG, 0x0A); } static void wcd_vbat_adc_out_config(struct wcd_vbat *vbat, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!vbat->adc_config) { - tasha_cdc_mclk_enable(codec, true, false); + tasha_cdc_mclk_enable(component, true, false); if (TASHA_IS_2_0(wcd9xxx)) - wcd_vbat_adc_out_config_2_0(vbat, codec); + wcd_vbat_adc_out_config_2_0(vbat, component); else - wcd_vbat_adc_out_config_1_x(vbat, codec); + wcd_vbat_adc_out_config_1_x(vbat, component); - tasha_cdc_mclk_enable(codec, false, false); + tasha_cdc_mclk_enable(component, false, false); vbat->adc_config = true; } } -static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec) +static int tasha_update_vbat_reg_config(struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct firmware_cal *hwdep_cal = NULL; struct vbat_monitor_reg *vbat_reg_ptr = NULL; const void *data; @@ -8115,17 +8393,17 @@ static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec) if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration\n", + dev_dbg(component->dev, "%s: using hwdep calibration\n", __func__); } else { - dev_err(codec->dev, "%s: Vbat cal not received\n", + dev_err(component->dev, "%s: Vbat cal not received\n", __func__); ret = -EINVAL; goto done; } if (cal_size < sizeof(*vbat_reg_ptr)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Incorrect size %zd for Vbat Cal, expected %zd\n", __func__, cal_size, sizeof(*vbat_reg_ptr)); ret = -EINVAL; @@ -8135,7 +8413,7 @@ static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec) vbat_reg_ptr = (struct vbat_monitor_reg *) (data); if (!vbat_reg_ptr) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid calibration data for Vbat\n", __func__); ret = -EINVAL; @@ -8144,7 +8422,7 @@ static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec) vbat_writes_size = vbat_reg_ptr->size; vbat_size_remaining = cal_size - sizeof(u32); - dev_dbg(codec->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n", + dev_dbg(component->dev, "%s: vbat_writes_sz: %d, vbat_sz_remaining: %zd\n", __func__, vbat_writes_size, vbat_size_remaining); if ((vbat_writes_size * TASHA_PACKED_REG_SIZE) @@ -8157,8 +8435,9 @@ static int tasha_update_vbat_reg_config(struct snd_soc_codec *codec) for (i = 0 ; i < vbat_writes_size; i++) { TASHA_CODEC_UNPACK_ENTRY(vbat_reg_ptr->writes[i], reg, mask, val); - old_val = snd_soc_read(codec, reg); - snd_soc_write(codec, reg, (old_val & ~mask) | (val & mask)); + old_val = snd_soc_component_read32(component, reg); + snd_soc_component_write(component, reg, (old_val & ~mask) | + (val & mask)); } done: @@ -8168,15 +8447,16 @@ done: static int tasha_vbat_adc_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - wcd_vbat_adc_out_config(&tasha->vbat, codec); + wcd_vbat_adc_out_config(&tasha->vbat, component); ucontrol->value.integer.value[0] = tasha->vbat.dcp1; ucontrol->value.integer.value[1] = tasha->vbat.dcp2; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Vbat ADC output values, Dcp1 : %lu, Dcp2: %lu\n", __func__, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1]); @@ -8193,13 +8473,14 @@ static const struct soc_enum tasha_vbat_gsm_mode_enum = static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); ucontrol->value.integer.value[0] = - ((snd_soc_read(codec, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ? - 1 : 0); + ((snd_soc_component_read32( + component, WCD9335_CDC_VBAT_VBAT_CFG) & 0x04) ? 1 : 0); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -8208,18 +8489,21 @@ static int tasha_vbat_gsm_mode_func_get(struct snd_kcontrol *kcontrol, static int tasha_vbat_gsm_mode_func_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: value: %lu\n", __func__, + dev_dbg(component->dev, "%s: value: %lu\n", __func__, ucontrol->value.integer.value[0]); /* Set Vbat register configuration for GSM mode bit based on value */ if (ucontrol->value.integer.value[0]) - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG, - 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD9335_CDC_VBAT_VBAT_CFG, + 0x04, 0x04); else - snd_soc_update_bits(codec, WCD9335_CDC_VBAT_VBAT_CFG, - 0x04, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_VBAT_VBAT_CFG, + 0x04, 0x00); return 0; } @@ -8229,8 +8513,9 @@ static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u16 vbat_path_ctl, vbat_cfg, vbat_path_cfg; vbat_path_ctl = WCD9335_CDC_VBAT_VBAT_PATH_CTL; @@ -8248,25 +8533,31 @@ static int tasha_codec_vbat_enable_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - ret = tasha_update_vbat_reg_config(codec); + ret = tasha_update_vbat_reg_config(component); if (ret) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s : VBAT isn't calibrated, So not enabling it\n", __func__); return 0; } - snd_soc_write(codec, WCD9335_ANA_VBADC, 0x80); - snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x02); - snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x10); - snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x01); + snd_soc_component_write(component, WCD9335_ANA_VBADC, 0x80); + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x02, 0x02); + snd_soc_component_update_bits(component, vbat_path_ctl, + 0x10, 0x10); + snd_soc_component_update_bits(component, vbat_cfg, 0x01, 0x01); tasha->vbat.is_enabled = true; break; case SND_SOC_DAPM_POST_PMD: if (tasha->vbat.is_enabled) { - snd_soc_update_bits(codec, vbat_cfg, 0x01, 0x00); - snd_soc_update_bits(codec, vbat_path_ctl, 0x10, 0x00); - snd_soc_update_bits(codec, vbat_path_cfg, 0x02, 0x00); - snd_soc_write(codec, WCD9335_ANA_VBADC, 0x00); + snd_soc_component_update_bits(component, vbat_cfg, + 0x01, 0x00); + snd_soc_component_update_bits(component, vbat_path_ctl, + 0x10, 0x00); + snd_soc_component_update_bits(component, vbat_path_cfg, + 0x02, 0x00); + snd_soc_component_write(component, WCD9335_ANA_VBADC, + 0x00); tasha->vbat.is_enabled = false; } break; @@ -8523,8 +8814,9 @@ static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; u16 mic_sel_reg; @@ -8534,7 +8826,7 @@ static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol, if (val > e->items - 1) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); switch (e->reg) { @@ -8566,14 +8858,15 @@ static int tasha_put_dec_enum(struct snd_kcontrol *kcontrol, mic_sel_reg = WCD9335_CDC_TX8_TX_PATH_CFG0; break; default: - dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n", + dev_err(component->dev, "%s: e->reg: 0x%x not expected\n", __func__, e->reg); return -EINVAL; } /* ADC: 0, DMIC: 1 */ mic_sel = val ? 0x0 : 0x1; - snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7); + snd_soc_component_update_bits(component, mic_sel_reg, + 1 << 7, mic_sel << 7); return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); } @@ -8582,8 +8875,9 @@ static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; unsigned short look_ahead_dly_reg = WCD9335_CDC_RX0_RX_PATH_CFG0; @@ -8592,7 +8886,7 @@ static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, if (val >= e->items) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0) @@ -8603,7 +8897,7 @@ static int tasha_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, look_ahead_dly_reg = WCD9335_CDC_RX2_RX_PATH_CFG0; /* Set Look Ahead Delay */ - snd_soc_update_bits(codec, look_ahead_dly_reg, + snd_soc_component_update_bits(component, look_ahead_dly_reg, 0x08, (val ? 0x08 : 0x00)); /* Set DEM INP Select */ return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -8613,15 +8907,16 @@ static int tasha_ear_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - ear_pa_gain = snd_soc_read(codec, WCD9335_ANA_EAR); + ear_pa_gain = snd_soc_component_read32(component, WCD9335_ANA_EAR); ear_pa_gain = (ear_pa_gain & 0x70) >> 4; ucontrol->value.integer.value[0] = ear_pa_gain; - dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__, + dev_dbg(component->dev, "%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); return 0; @@ -8631,26 +8926,29 @@ static int tasha_ear_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); ear_pa_gain = ucontrol->value.integer.value[0] << 4; - snd_soc_update_bits(codec, WCD9335_ANA_EAR, 0x70, ear_pa_gain); + snd_soc_component_update_bits(component, WCD9335_ANA_EAR, + 0x70, ear_pa_gain); return 0; } static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tasha->ear_spkr_gain; - dev_dbg(codec->dev, "%s: ear_spkr_gain = %ld\n", __func__, + dev_dbg(component->dev, "%s: ear_spkr_gain = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -8659,10 +8957,11 @@ static int tasha_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, static int tasha_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); tasha->ear_spkr_gain = ucontrol->value.integer.value[0]; @@ -8674,12 +8973,14 @@ static int tasha_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST0_BOOST_CTL); + bst_state_max = snd_soc_component_read32( + component, WCD9335_CDC_BOOST0_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -8689,12 +8990,13 @@ static int tasha_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, WCD9335_CDC_BOOST0_BOOST_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_BOOST0_BOOST_CTL, 0x0c, bst_state_max); return 0; @@ -8704,12 +9006,14 @@ static int tasha_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, WCD9335_CDC_BOOST1_BOOST_CTL); + bst_state_max = snd_soc_component_read32( + component, WCD9335_CDC_BOOST1_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -8719,21 +9023,22 @@ static int tasha_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, WCD9335_CDC_BOOST1_BOOST_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_BOOST1_BOOST_CTL, 0x0c, bst_state_max); return 0; } -static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n, - int event) +static int tasha_config_compander(struct snd_soc_component *component, + int interp_n, int event) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int comp; u16 comp_ctl0_reg, rx_path_cfg0_reg; @@ -8742,7 +9047,7 @@ static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n, return 0; comp = interp_n - 1; - dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n", __func__, event, comp + 1, tasha->comp_enabled[comp]); if (!tasha->comp_enabled[comp]) @@ -8753,25 +9058,35 @@ static int tasha_config_compander(struct snd_soc_codec *codec, int interp_n, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Compander Clock */ - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x02); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x04); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x00); } return 0; } -static int tasha_codec_config_mad(struct snd_soc_codec *codec) +static int tasha_codec_config_mad(struct snd_soc_component *component) { int ret = 0; int idx; @@ -8780,31 +9095,31 @@ static int tasha_codec_config_mad(struct snd_soc_codec *codec) struct wcd_mad_audio_cal *mad_cal = NULL; const void *data; const char *filename = TASHA_MAD_AUDIO_FIRMWARE_PATH; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); size_t cal_size; hwdep_cal = wcdcal_get_fw_cal(tasha->fw_data, WCD9XXX_MAD_CAL); if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration\n", + dev_dbg(component->dev, "%s: using hwdep calibration\n", __func__); } else { - ret = request_firmware(&fw, filename, codec->dev); + ret = request_firmware(&fw, filename, component->dev); if (ret || !fw) { - dev_err(codec->dev, + dev_err(component->dev, "%s: MAD firmware acquire failed, err = %d\n", __func__, ret); return -ENODEV; } data = fw->data; cal_size = fw->size; - dev_dbg(codec->dev, "%s: using request_firmware calibration\n", + dev_dbg(component->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(*mad_cal)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Incorrect size %zd for MAD Cal, expected %zd\n", __func__, cal_size, sizeof(*mad_cal)); ret = -ENOMEM; @@ -8813,80 +9128,86 @@ static int tasha_codec_config_mad(struct snd_soc_codec *codec) mad_cal = (struct wcd_mad_audio_cal *) (data); if (!mad_cal) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid calibration data\n", __func__); ret = -EINVAL; goto done; } - snd_soc_write(codec, WCD9335_SOC_MAD_MAIN_CTL_2, + snd_soc_component_write(component, WCD9335_SOC_MAD_MAIN_CTL_2, mad_cal->microphone_info.cycle_time); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_MAIN_CTL_1, 0xFF << 3, - ((uint16_t)mad_cal->microphone_info.settle_time) - << 3); + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_MAIN_CTL_1, + 0xFF << 3, + ((uint16_t)mad_cal->microphone_info.settle_time) << 3); /* Audio */ - snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_8, + snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_8, mad_cal->audio_info.rms_omit_samples); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_1, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_AUDIO_CTL_1, 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_CTL_2, 0x03 << 2, - mad_cal->audio_info.detection_mechanism << 2); - snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_7, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_AUDIO_CTL_2, + 0x03 << 2, + mad_cal->audio_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_7, mad_cal->audio_info.rms_diff_threshold & 0x3F); - snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_5, + snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_5, mad_cal->audio_info.rms_threshold_lsb); - snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_CTL_6, + snd_soc_component_write(component, WCD9335_SOC_MAD_AUDIO_CTL_6, mad_cal->audio_info.rms_threshold_msb); for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients); idx++) { - snd_soc_update_bits(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR, - 0x3F, idx); - snd_soc_write(codec, WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL, - mad_cal->audio_info.iir_coefficients[idx]); - dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x", + snd_soc_component_update_bits(component, + WCD9335_SOC_MAD_AUDIO_IIR_CTL_PTR, 0x3F, idx); + snd_soc_component_write(component, + WCD9335_SOC_MAD_AUDIO_IIR_CTL_VAL, + mad_cal->audio_info.iir_coefficients[idx]); + dev_dbg(component->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x", __func__, idx, mad_cal->audio_info.iir_coefficients[idx]); } /* Beacon */ - snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_8, + snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_8, mad_cal->beacon_info.rms_omit_samples); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_1, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_BEACON_CTL_1, 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_CTL_2, 0x03 << 2, - mad_cal->beacon_info.detection_mechanism << 2); - snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_7, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_BEACON_CTL_2, + 0x03 << 2, + mad_cal->beacon_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_7, mad_cal->beacon_info.rms_diff_threshold & 0x1F); - snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_5, + snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_5, mad_cal->beacon_info.rms_threshold_lsb); - snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_CTL_6, + snd_soc_component_write(component, WCD9335_SOC_MAD_BEACON_CTL_6, mad_cal->beacon_info.rms_threshold_msb); for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients); idx++) { - snd_soc_update_bits(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR, - 0x3F, idx); - snd_soc_write(codec, WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL, - mad_cal->beacon_info.iir_coefficients[idx]); - dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x", + snd_soc_component_update_bits(component, + WCD9335_SOC_MAD_BEACON_IIR_CTL_PTR, + 0x3F, idx); + snd_soc_component_write(component, + WCD9335_SOC_MAD_BEACON_IIR_CTL_VAL, + mad_cal->beacon_info.iir_coefficients[idx]); + dev_dbg(component->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x", __func__, idx, mad_cal->beacon_info.iir_coefficients[idx]); } /* Ultrasound */ - snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_1, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_ULTR_CTL_1, 0x07 << 4, mad_cal->ultrasound_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD9335_SOC_MAD_ULTR_CTL_2, 0x03 << 2, - mad_cal->ultrasound_info.detection_mechanism << 2); - snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_7, + snd_soc_component_update_bits(component, WCD9335_SOC_MAD_ULTR_CTL_2, + 0x03 << 2, + mad_cal->ultrasound_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_7, mad_cal->ultrasound_info.rms_diff_threshold & 0x1F); - snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_5, + snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_5, mad_cal->ultrasound_info.rms_threshold_lsb); - snd_soc_write(codec, WCD9335_SOC_MAD_ULTR_CTL_6, + snd_soc_component_write(component, WCD9335_SOC_MAD_ULTR_CTL_6, mad_cal->ultrasound_info.rms_threshold_msb); done: @@ -8899,38 +9220,39 @@ done: static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); /* Return if CPE INPUT is DEC1 */ - if (snd_soc_read(codec, WCD9335_CPE_SS_SVA_CFG) & 0x01) + if (snd_soc_component_read32(component, WCD9335_CPE_SS_SVA_CFG) & 0x01) return ret; switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Turn on MAD clk */ - snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL, 0x01, 0x01); /* Undo reset for MAD */ - snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL, 0x02, 0x00); - ret = tasha_codec_config_mad(codec); + ret = tasha_codec_config_mad(component); if (ret) - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to config MAD, err = %d\n", __func__, ret); break; case SND_SOC_DAPM_POST_PMD: /* Reset the MAD block */ - snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL, 0x02, 0x02); /* Turn off MAD clk */ - snd_soc_update_bits(codec, WCD9335_CPE_SS_MAD_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_MAD_CTL, 0x01, 0x00); break; } @@ -8941,27 +9263,30 @@ static int tasha_codec_enable_mad(struct snd_soc_dapm_widget *w, static int tasha_codec_configure_cpe_input(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Configure CPE input as DEC1 */ - snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG, - 0x01, 0x01); + snd_soc_component_update_bits(component, WCD9335_CPE_SS_SVA_CFG, + 0x01, 0x01); /* Configure DEC1 Tx out with sample rate as 16K */ - snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL, - 0x0F, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CDC_TX1_TX_PATH_CTL, + 0x0F, 0x01); break; case SND_SOC_DAPM_POST_PMD: /* Reset DEC1 Tx out sample rate */ - snd_soc_update_bits(codec, WCD9335_CDC_TX1_TX_PATH_CTL, - 0x0F, 0x04); - snd_soc_update_bits(codec, WCD9335_CPE_SS_SVA_CFG, + snd_soc_component_update_bits(component, + WCD9335_CDC_TX1_TX_PATH_CTL, + 0x0F, 0x04); + snd_soc_component_update_bits(component, WCD9335_CPE_SS_SVA_CFG, 0x01, 0x00); break; @@ -8976,15 +9301,16 @@ static int tasha_codec_aif4_mixer_switch_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); if (test_bit(AIF4_SWITCH_VALUE, &tasha_p->status_mask)) ucontrol->value.integer.value[0] = 1; else ucontrol->value.integer.value[0] = 0; - dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n", + dev_dbg(component->dev, "%s: AIF4 switch value = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; } @@ -8995,10 +9321,11 @@ static int tasha_codec_aif4_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); struct snd_soc_dapm_update *update = NULL; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tasha_priv *tasha_p = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: AIF4 switch value = %ld\n", + dev_dbg(component->dev, "%s: AIF4 switch value = %ld\n", __func__, ucontrol->value.integer.value[0]); if (ucontrol->value.integer.value[0]) { @@ -10306,23 +10633,29 @@ static int tasha_codec_ec_buf_mux_enable(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event = %d name = %s\n", + dev_dbg(component->dev, "%s: event = %d name = %s\n", __func__, event, w->name); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B); - snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x08); - snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, - 0x08, 0x08); + snd_soc_component_write(component, + WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x3B); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_CFG, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, 0x08, 0x08); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, - 0x08, 0x00); - snd_soc_update_bits(codec, WCD9335_CPE_SS_CFG, 0x08, 0x00); - snd_soc_write(codec, WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CDC_IF_ROUTER_TX_MUX_CFG0, + 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CPE_SS_CFG, 0x08, 0x00); + snd_soc_component_write(component, + WCD9335_CPE_SS_EC_BUF_INT_PERIOD, 0x00); break; } @@ -11128,7 +11461,8 @@ static int tasha_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct tasha_priv *tasha_p = snd_soc_codec_get_drvdata(dai->codec); + struct tasha_priv *tasha_p = + snd_soc_component_get_drvdata(dai->component); u32 i = 0; struct wcd9xxx_ch *ch; @@ -11192,8 +11526,8 @@ static int tasha_set_channel_map(struct snd_soc_dai *dai, pr_err("%s: dai is empty\n", __func__); return -EINVAL; } - tasha = snd_soc_codec_get_drvdata(dai->codec); - core = dev_get_drvdata(dai->codec->dev->parent); + tasha = snd_soc_component_get_drvdata(dai->component); + core = dev_get_drvdata(dai->component->dev->parent); if (!tx_slot || !rx_slot) { pr_err("%s: Invalid tx_slot=%pK, rx_slot=%pK\n", @@ -11234,7 +11568,8 @@ static int tasha_startup(struct snd_pcm_substream *substream, static void tasha_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec); + struct tasha_priv *tasha = + snd_soc_component_get_drvdata(dai->component); pr_debug("%s(): substream = %s stream = %d\n", __func__, substream->name, substream->stream); @@ -11243,15 +11578,15 @@ static void tasha_shutdown(struct snd_pcm_substream *substream, return; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - tasha_codec_vote_max_bw(dai->codec, false); + tasha_codec_vote_max_bw(dai->component, false); } static int tasha_set_decimator_rate(struct snd_soc_dai *dai, u8 tx_fs_rate_reg_val, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u32 tx_port = 0; u8 shift = 0, shift_val = 0, tx_mux_sel = 0; int decimator = -1; @@ -11259,11 +11594,11 @@ static int tasha_set_decimator_rate(struct snd_soc_dai *dai, list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) { tx_port = ch->port; - dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d", + dev_dbg(component->dev, "%s: dai->id = %d, tx_port = %d", __func__, dai->id, tx_port); if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) { - dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n", + dev_err(component->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n", __func__, tx_port, dai->id); return -EINVAL; } @@ -11289,7 +11624,7 @@ static int tasha_set_decimator_rate(struct snd_soc_dai *dai, shift = 4; shift_val = 0x03; } - tx_mux_sel = snd_soc_read(codec, tx_port_reg) & + tx_mux_sel = snd_soc_component_read32(component, tx_port_reg) & (shift_val << shift); tx_mux_sel = tx_mux_sel >> shift; @@ -11310,16 +11645,16 @@ static int tasha_set_decimator_rate(struct snd_soc_dai *dai, if (decimator >= 0) { tx_fs_reg = WCD9335_CDC_TX0_TX_PATH_CTL + 16 * decimator; - dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", + dev_dbg(component->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", __func__, decimator, tx_port, sample_rate); - snd_soc_update_bits(codec, tx_fs_reg, 0x0F, - tx_fs_rate_reg_val); + snd_soc_component_update_bits(component, tx_fs_reg, + 0x0F, tx_fs_rate_reg_val); } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) { /* Check if the TX Mux input is RX MIX TXn */ - dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n", + dev_dbg(component->dev, "%s: RX_MIX_TX%u going to SLIM TX%u\n", __func__, tx_port, tx_port); } else { - dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n", + dev_err(component->dev, "%s: ERROR: Invalid decimator: %d\n", __func__, decimator); return -EINVAL; } @@ -11335,9 +11670,9 @@ static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai, u32 j; u16 int_mux_cfg1, int_fs_reg; u8 int_mux_cfg1_val; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) { int_2_inp = ch->port + INTn_2_INP_SEL_RX0 - @@ -11353,7 +11688,8 @@ static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_mux_cfg1 = WCD9335_CDC_RX_INP_MUX_RX_INT0_CFG1; for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) { - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) & + int_mux_cfg1_val = snd_soc_component_read32( + component, int_mux_cfg1) & 0x0F; if (int_mux_cfg1_val == int_2_inp) { int_fs_reg = WCD9335_CDC_RX0_RX_PATH_MIX_CTL + @@ -11362,7 +11698,8 @@ static int tasha_set_mix_interpolator_rate(struct snd_soc_dai *dai, __func__, dai->id, j); pr_debug("%s: set INT%u_2 sample rate to %u\n", __func__, j, sample_rate); - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits(component, + int_fs_reg, 0x0F, int_mix_fs_rate_reg_val); } int_mux_cfg1 += 2; @@ -11381,9 +11718,9 @@ static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai, u16 int_fs_reg; u8 int_mux_cfg0_val, int_mux_cfg1_val; u8 inp0_sel, inp1_sel, inp2_sel; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); list_for_each_entry(ch, &tasha->dai[dai->id].wcd9xxx_ch_list, list) { int_1_mix1_inp = ch->port + INTn_1_MIX_INP_SEL_RX0 - @@ -11407,8 +11744,10 @@ static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai, for (j = 0; j < TASHA_NUM_INTERPOLATORS; j++) { int_mux_cfg1 = int_mux_cfg0 + 1; - int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1); + int_mux_cfg0_val = snd_soc_component_read32(component, + int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read32(component, + int_mux_cfg1); inp0_sel = int_mux_cfg0_val & 0x0F; inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F; inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F; @@ -11426,7 +11765,8 @@ static int tasha_set_prim_interpolator_rate(struct snd_soc_dai *dai, pr_info("%s: Cannot set 44.1KHz on INT0\n", __func__); } else - snd_soc_update_bits(codec, int_fs_reg, + snd_soc_component_update_bits( + component, int_fs_reg, 0x0F, int_prim_fs_rate_reg_val); } int_mux_cfg0 += 2; @@ -11482,7 +11822,7 @@ static int tasha_prepare(struct snd_pcm_substream *substream, substream->name, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - tasha_codec_vote_max_bw(dai->codec, false); + tasha_codec_vote_max_bw(dai->component, false); return 0; } @@ -11490,12 +11830,13 @@ static int tasha_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec); + struct tasha_priv *tasha = + snd_soc_component_get_drvdata(dai->component); int ret; int tx_fs_rate = -EINVAL; int rx_fs_rate = -EINVAL; int i2s_bit_mode; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), @@ -11548,10 +11889,10 @@ static int tasha_hw_params(struct snd_pcm_substream *substream, __func__, params_rate(params)); return -EINVAL; }; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL, 0x20, i2s_bit_mode << 5); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL, 0x1c, (rx_fs_rate << 2)); } @@ -11615,27 +11956,27 @@ static int tasha_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }; if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL, 0x20, i2s_bit_mode << 5); if (tx_fs_rate > 1) tx_fs_rate--; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL, 0x1c, tx_fs_rate << 2); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_L_CFG, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD0_R_CFG, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_L_CFG, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_SD1_R_CFG, 0x05, 0x05); } @@ -11653,18 +11994,19 @@ static int tasha_hw_params(struct snd_pcm_substream *substream, static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(dai->codec); + struct tasha_priv *tasha = + snd_soc_component_get_drvdata(dai->component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* CPU is master */ if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { if (dai->id == AIF1_CAP) - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL, 0x2, 0); else if (dai->id == AIF1_PB) - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL, 0x2, 0); } @@ -11673,11 +12015,11 @@ static int tasha_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) /* CPU is slave */ if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { if (dai->id == AIF1_CAP) - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, WCD9335_DATA_HUB_DATA_HUB_TX_I2S_CTL, 0x2, 0x2); else if (dai->id == AIF1_PB) - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, WCD9335_DATA_HUB_DATA_HUB_RX_I2S_CTL, 0x2, 0x2); } @@ -11939,13 +12281,13 @@ static struct snd_soc_dai_driver tasha_i2s_dai[] = { static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha) { - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; - if (!codec) + if (!component) return; mutex_lock(&tasha->power_lock); - dev_dbg(codec->dev, "%s: Entering power gating function, %d\n", + dev_dbg(component->dev, "%s: Entering power gating function, %d\n", __func__, tasha->power_active_ref); if (tasha->power_active_ref > 0) @@ -11954,18 +12296,21 @@ static void tasha_codec_power_gate_digital_core(struct tasha_priv *tasha) wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_COLLAPSE_BEGIN, WCD9XXX_DIG_CORE_REGION_1); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x04, 0x04); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x01, 0x00); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x02, 0x00); clear_bit(AUDIO_NOMINAL, &tasha->status_mask); tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage); wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_DOWN, WCD9XXX_DIG_CORE_REGION_1); exit: - dev_dbg(codec->dev, "%s: Exiting power gating function, %d\n", + dev_dbg(component->dev, "%s: Exiting power gating function, %d\n", __func__, tasha->power_active_ref); mutex_unlock(&tasha->power_lock); } @@ -11974,37 +12319,43 @@ static void tasha_codec_power_gate_work(struct work_struct *work) { struct tasha_priv *tasha; struct delayed_work *dwork; - struct snd_soc_codec *codec; + struct snd_soc_component *component; dwork = to_delayed_work(work); tasha = container_of(dwork, struct tasha_priv, power_gate_work); - codec = tasha->codec; + component = tasha->component; - if (!codec) + if (!component) return; tasha_codec_power_gate_digital_core(tasha); } /* called under power_lock acquisition */ -static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec) +static int tasha_dig_core_remove_power_collapse( + struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); - tasha_codec_vote_max_bw(codec, true); - snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5); - snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7); - snd_soc_write(codec, WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x00); - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_RST_CTL, 0x02, 0x02); + tasha_codec_vote_max_bw(component, true); + snd_soc_component_write(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x5); + snd_soc_component_write(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x7); + snd_soc_component_write(component, + WCD9335_CODEC_RPM_PWR_CDC_DIG_HM_CTL, 0x3); + snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_RST_CTL, + 0x02, 0x00); + snd_soc_component_update_bits(component, WCD9335_CODEC_RPM_RST_CTL, + 0x02, 0x02); wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_COLLAPSE_REMOVE, WCD9XXX_DIG_CORE_REGION_1); - regcache_mark_dirty(codec->component.regmap); - regcache_sync_region(codec->component.regmap, + regcache_mark_dirty(component->regmap); + regcache_sync_region(component->regmap, TASHA_DIG_CORE_REG_MIN, TASHA_DIG_CORE_REG_MAX); - tasha_codec_vote_max_bw(codec, false); + tasha_codec_vote_max_bw(component, false); return 0; } @@ -12012,7 +12363,7 @@ static int tasha_dig_core_remove_power_collapse(struct snd_soc_codec *codec) static int tasha_dig_core_power_collapse(struct tasha_priv *tasha, int req_state) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int cur_state; /* Exit if feature is disabled */ @@ -12033,8 +12384,8 @@ static int tasha_dig_core_power_collapse(struct tasha_priv *tasha, goto unlock_mutex; } - codec = tasha->codec; - if (!codec) + component = tasha->component; + if (!component) goto unlock_mutex; if (req_state == POWER_COLLAPSE) { @@ -12054,7 +12405,7 @@ static int tasha_dig_core_power_collapse(struct tasha_priv *tasha, tasha->wcd9xxx, WCD9XXX_DIG_CORE_REGION_1); if (cur_state == WCD_REGION_POWER_DOWN) - tasha_dig_core_remove_power_collapse(codec); + tasha_dig_core_remove_power_collapse(component); else { mutex_unlock(&tasha->power_lock); cancel_delayed_work_sync( @@ -12117,17 +12468,19 @@ static int __tasha_cdc_mclk_enable(struct tasha_priv *tasha, return ret; } -int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, bool dapm) +int tasha_cdc_mclk_enable(struct snd_soc_component *component, + int enable, bool dapm) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); return __tasha_cdc_mclk_enable(tasha, enable); } EXPORT_SYMBOL(tasha_cdc_mclk_enable); -int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm) +int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component, + int enable, bool dapm) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; dev_dbg(tasha->dev, "%s: clk_mode: %d, enable: %d, clk_internal: %d\n", @@ -12137,10 +12490,10 @@ int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, bool dapm) tasha_cdc_sido_ccl_enable(tasha, true); wcd_resmgr_enable_master_bias(tasha->resmgr); tasha_dig_core_power_collapse(tasha, POWER_RESUME); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x01, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x01, 0x01); set_bit(CPE_NOMINAL, &tasha->status_mask); @@ -12202,7 +12555,7 @@ static struct snd_info_entry_ops tasha_codec_info_ops = { /* * tasha_codec_info_create_codec_entry - creates wcd9335 module * @codec_root: The parent directory - * @codec: Codec instance + * @component: Codec instance * * Creates wcd9335 module and version entry under the given * parent directory. @@ -12210,21 +12563,21 @@ static struct snd_info_entry_ops tasha_codec_info_ops = { * Return: 0 on success or negative error code on failure. */ int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct tasha_priv *tasha; struct snd_soc_card *card; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - tasha = snd_soc_codec_get_drvdata(codec); - card = codec->component.card; + tasha = snd_soc_component_get_drvdata(component); + card = component->card; tasha->entry = snd_info_create_subdir(codec_root->module, "tasha", codec_root); if (!tasha->entry) { - dev_dbg(codec->dev, "%s: failed to create wcd9335 entry\n", + dev_dbg(component->dev, "%s: failed to create wcd9335 entry\n", __func__); return -ENOMEM; } @@ -12233,7 +12586,7 @@ int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root, "version", tasha->entry); if (!version_entry) { - dev_dbg(codec->dev, "%s: failed to create wcd9335 version entry\n", + dev_dbg(component->dev, "%s: failed to create wcd9335 version entry\n", __func__); return -ENOMEM; } @@ -12254,9 +12607,9 @@ int tasha_codec_info_create_codec_entry(struct snd_info_entry *codec_root, EXPORT_SYMBOL(tasha_codec_info_create_codec_entry); static int __tasha_codec_internal_rco_ctrl( - struct snd_soc_codec *codec, bool enable) + struct snd_soc_component *component, bool enable) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; if (enable) { @@ -12279,7 +12632,7 @@ static int __tasha_codec_internal_rco_ctrl( } if (ret) { - dev_err(codec->dev, "%s: Error in %s RCO\n", + dev_err(component->dev, "%s: Error in %s RCO\n", __func__, (enable ? "enabling" : "disabling")); ret = -EINVAL; } @@ -12292,28 +12645,28 @@ static int __tasha_codec_internal_rco_ctrl( * Make sure that the caller does not acquire * BG_CLK_LOCK. */ -static int tasha_codec_internal_rco_ctrl(struct snd_soc_codec *codec, +static int tasha_codec_internal_rco_ctrl(struct snd_soc_component *component, bool enable) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); int ret = 0; WCD9XXX_V2_BG_CLK_LOCK(tasha->resmgr); - ret = __tasha_codec_internal_rco_ctrl(codec, enable); + ret = __tasha_codec_internal_rco_ctrl(component, enable); WCD9XXX_V2_BG_CLK_UNLOCK(tasha->resmgr); return ret; } /* * tasha_mbhc_hs_detect: starts mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @mbhc_cfg: handle to mbhc configuration structure * return 0 if mbhc_start is success or error code in case of failure */ -int tasha_mbhc_hs_detect(struct snd_soc_codec *codec, +int tasha_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); return wcd_mbhc_start(&tasha->mbhc, mbhc_cfg); } @@ -12321,11 +12674,11 @@ EXPORT_SYMBOL(tasha_mbhc_hs_detect); /* * tasha_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +void tasha_mbhc_hs_detect_exit(struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); wcd_mbhc_stop(&tasha->mbhc); } @@ -12519,27 +12872,27 @@ static const struct tasha_reg_mask_val tasha_codec_reg_init_1_x_val[] = { {WCD9335_DIFF_LO_COM_PA_FREQ, 0x70, 0x40}, }; -static void tasha_update_reg_reset_values(struct snd_soc_codec *codec) +static void tasha_update_reg_reset_values(struct snd_soc_component *component) { u32 i; - struct wcd9xxx *tasha_core = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *tasha_core = dev_get_drvdata(component->dev->parent); if (TASHA_IS_1_1(tasha_core)) { for (i = 0; i < ARRAY_SIZE(tasha_reg_update_reset_val_1_1); i++) - snd_soc_write(codec, + snd_soc_component_write(component, tasha_reg_update_reset_val_1_1[i].reg, tasha_reg_update_reset_val_1_1[i].val); } } -static void tasha_codec_init_reg(struct snd_soc_codec *codec) +static void tasha_codec_init_reg(struct snd_soc_component *component) { u32 i; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_common_val); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tasha_codec_reg_init_common_val[i].reg, tasha_codec_reg_init_common_val[i].mask, tasha_codec_reg_init_common_val[i].val); @@ -12547,26 +12900,26 @@ static void tasha_codec_init_reg(struct snd_soc_codec *codec) if (TASHA_IS_1_1(wcd9xxx) || TASHA_IS_1_0(wcd9xxx)) for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_1_x_val); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tasha_codec_reg_init_1_x_val[i].reg, tasha_codec_reg_init_1_x_val[i].mask, tasha_codec_reg_init_1_x_val[i].val); if (TASHA_IS_1_1(wcd9xxx)) { for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_1); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tasha_codec_reg_init_val_1_1[i].reg, tasha_codec_reg_init_val_1_1[i].mask, tasha_codec_reg_init_val_1_1[i].val); } else if (TASHA_IS_1_0(wcd9xxx)) { for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_1_0); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tasha_codec_reg_init_val_1_0[i].reg, tasha_codec_reg_init_val_1_0[i].mask, tasha_codec_reg_init_val_1_0[i].val); } else if (TASHA_IS_2_0(wcd9xxx)) { for (i = 0; i < ARRAY_SIZE(tasha_codec_reg_init_val_2_0); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tasha_codec_reg_init_val_2_0[i].reg, tasha_codec_reg_init_val_2_0[i].mask, tasha_codec_reg_init_val_2_0[i].val); @@ -12595,10 +12948,10 @@ static void tasha_update_reg_defaults(struct tasha_priv *tasha) } -static void tasha_slim_interface_init_reg(struct snd_soc_codec *codec) +static void tasha_slim_interface_init_reg(struct snd_soc_component *component) { int i; - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++) wcd9xxx_interface_reg_write(priv->wcd9xxx, @@ -12707,7 +13060,7 @@ static irqreturn_t tasha_slimbus_irq(int irq, void *data) static int tasha_setup_irqs(struct tasha_priv *tasha) { int ret = 0; - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -12718,14 +13071,14 @@ static int tasha_setup_irqs(struct tasha_priv *tasha) pr_err("%s: Failed to request irq %d\n", __func__, WCD9XXX_IRQ_SLIMBUS); else - tasha_slim_interface_init_reg(codec); + tasha_slim_interface_init_reg(component); return ret; } -static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec) +static void tasha_init_slim_slave_cfg(struct snd_soc_component *component) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); struct afe_param_cdc_slimbus_slave_cfg *cfg; struct wcd9xxx *wcd9xxx = priv->wcd9xxx; uint64_t eaddr = 0; @@ -12740,7 +13093,7 @@ static void tasha_init_slim_slave_cfg(struct snd_soc_codec *codec) cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF; cfg->device_enum_addr_msw = eaddr >> 32; - dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n", + dev_dbg(component->dev, "%s: slimbus logical address 0x%llx\n", __func__, eaddr); } @@ -12756,7 +13109,7 @@ static void tasha_cleanup_irqs(struct tasha_priv *tasha) static int tasha_handle_pdata(struct tasha_priv *tasha, struct wcd9xxx_pdata *pdata) { - struct snd_soc_codec *codec = tasha->codec; + struct snd_soc_component *component = tasha->component; u8 dmic_ctl_val, mad_dmic_ctl_val; u8 anc_ctl_value; u32 def_dmic_rate, dmic_clk_drv; @@ -12764,7 +13117,7 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, int rc = 0; if (!pdata) { - dev_err(codec->dev, "%s: NULL pdata\n", __func__); + dev_err(component->dev, "%s: NULL pdata\n", __func__); return -ENODEV; } @@ -12778,10 +13131,14 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, rc = -EINVAL; goto done; } - snd_soc_update_bits(codec, WCD9335_ANA_MICB1, 0x3F, vout_ctl_1); - snd_soc_update_bits(codec, WCD9335_ANA_MICB2, 0x3F, vout_ctl_2); - snd_soc_update_bits(codec, WCD9335_ANA_MICB3, 0x3F, vout_ctl_3); - snd_soc_update_bits(codec, WCD9335_ANA_MICB4, 0x3F, vout_ctl_4); + snd_soc_component_update_bits(component, WCD9335_ANA_MICB1, + 0x3F, vout_ctl_1); + snd_soc_component_update_bits(component, WCD9335_ANA_MICB2, + 0x3F, vout_ctl_2); + snd_soc_component_update_bits(component, WCD9335_ANA_MICB3, + 0x3F, vout_ctl_3); + snd_soc_component_update_bits(component, WCD9335_ANA_MICB4, + 0x3F, vout_ctl_4); /* Set the DMIC sample rate */ switch (pdata->mclk_rate) { @@ -12793,7 +13150,7 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, break; default: /* should never happen */ - dev_err(codec->dev, "%s: Invalid mclk_rate %d\n", + dev_err(component->dev, "%s: Invalid mclk_rate %d\n", __func__, pdata->mclk_rate); rc = -EINVAL; goto done; @@ -12801,13 +13158,13 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, if (pdata->dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) { - dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n", + dev_info(component->dev, "%s: dmic_rate invalid default = %d\n", __func__, def_dmic_rate); pdata->dmic_sample_rate = def_dmic_rate; } if (pdata->mad_dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) { - dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n", + dev_info(component->dev, "%s: mad_dmic_rate invalid default = %d\n", __func__, def_dmic_rate); /* * use dmic_sample_rate as the default for MAD @@ -12817,7 +13174,7 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, } if (pdata->ecpp_dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) { - dev_info(codec->dev, + dev_info(component->dev, "%s: ecpp_dmic_rate invalid default = %d\n", __func__, def_dmic_rate); /* @@ -12830,7 +13187,7 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, if (pdata->dmic_clk_drv == WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) { pdata->dmic_clk_drv = WCD9335_DMIC_CLK_DRIVE_DEFAULT; - dev_info(codec->dev, + dev_info(component->dev, "%s: dmic_clk_strength invalid, default = %d\n", __func__, pdata->dmic_clk_drv); } @@ -12849,14 +13206,14 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, dmic_clk_drv = 3; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: invalid dmic_clk_drv %d, using default\n", __func__, pdata->dmic_clk_drv); dmic_clk_drv = 0; break; } - snd_soc_update_bits(codec, WCD9335_TEST_DEBUG_PAD_DRVCTL, + snd_soc_component_update_bits(component, WCD9335_TEST_DEBUG_PAD_DRVCTL, 0x0C, dmic_clk_drv << 2); /* @@ -12864,17 +13221,17 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, * whereas, the anc/txfe dmic rates to dmic_sample_rate * since the anc/txfe are independent of mad block. */ - mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec, + mad_dmic_ctl_val = tasha_get_dmic_clk_val(tasha->component, pdata->mclk_rate, pdata->mad_dmic_sample_rate); - snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC0_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC0_CTL, 0x0E, mad_dmic_ctl_val << 1); - snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC1_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC1_CTL, 0x0E, mad_dmic_ctl_val << 1); - snd_soc_update_bits(codec, WCD9335_CPE_SS_DMIC2_CTL, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_DMIC2_CTL, 0x0E, mad_dmic_ctl_val << 1); - dmic_ctl_val = tasha_get_dmic_clk_val(tasha->codec, + dmic_ctl_val = tasha_get_dmic_clk_val(tasha->component, pdata->mclk_rate, pdata->dmic_sample_rate); @@ -12883,38 +13240,38 @@ static int tasha_handle_pdata(struct tasha_priv *tasha, else anc_ctl_value = WCD9335_ANC_DMIC_X2_HALF_RATE; - snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_2_CTL, 0x40, anc_ctl_value << 6); - snd_soc_update_bits(codec, WCD9335_CDC_ANC0_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC0_MODE_2_CTL, 0x20, anc_ctl_value << 5); - snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_2_CTL, 0x40, anc_ctl_value << 6); - snd_soc_update_bits(codec, WCD9335_CDC_ANC1_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD9335_CDC_ANC1_MODE_2_CTL, 0x20, anc_ctl_value << 5); done: return rc; } static struct wcd_cpe_core *tasha_codec_get_cpe_core( - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct tasha_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *priv = snd_soc_component_get_drvdata(component); return priv->cpe_core; } static int tasha_codec_cpe_fll_update_divider( - struct snd_soc_codec *codec, u32 cpe_fll_rate) + struct snd_soc_component *component, u32 cpe_fll_rate) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u32 div_val = 0, l_val = 0; u32 computed_cpe_fll; if (cpe_fll_rate != CPE_FLL_CLK_75MHZ && cpe_fll_rate != CPE_FLL_CLK_150MHZ) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid CPE fll rate request %u\n", __func__, cpe_fll_rate); return -EINVAL; @@ -12922,18 +13279,20 @@ static int tasha_codec_cpe_fll_update_divider( if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) { /* update divider to 10 and enable 5x divider */ - snd_soc_write(codec, WCD9335_CPE_FLL_USER_CTL_1, + snd_soc_component_write(component, WCD9335_CPE_FLL_USER_CTL_1, 0x55); div_val = 10; } else if (wcd9xxx->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) { /* update divider to 8 and enable 2x divider */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0, - 0x7C, 0x70); - snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_1, - 0xE0, 0x20); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_USER_CTL_0, + 0x7C, 0x70); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_USER_CTL_1, + 0xE0, 0x20); div_val = 8; } else { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid MCLK rate %u\n", __func__, wcd9xxx->mclk_rate); return -EINVAL; @@ -12949,102 +13308,106 @@ static int tasha_codec_cpe_fll_update_divider( /* update L value LSB and MSB */ - snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_0, + snd_soc_component_write(component, WCD9335_CPE_FLL_L_VAL_CTL_0, (l_val & 0xFF)); - snd_soc_write(codec, WCD9335_CPE_FLL_L_VAL_CTL_1, + snd_soc_component_write(component, WCD9335_CPE_FLL_L_VAL_CTL_1, ((l_val >> 8) & 0xFF)); tasha->current_cpe_clk_freq = cpe_fll_rate; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: updated l_val to %u for cpe_clk %u and mclk %u\n", __func__, l_val, cpe_fll_rate, wcd9xxx->mclk_rate); return 0; } -static int __tasha_cdc_change_cpe_clk(struct snd_soc_codec *codec, +static int __tasha_cdc_change_cpe_clk(struct snd_soc_component *component, u32 clk_freq) { int ret = 0; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (!tasha_cdc_is_svs_enabled(tasha)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: SVS not enabled or tasha is not 2p0, return\n", __func__); return 0; } - dev_dbg(codec->dev, "%s: clk_freq = %u\n", __func__, clk_freq); + dev_dbg(component->dev, "%s: clk_freq = %u\n", __func__, clk_freq); if (clk_freq == CPE_FLL_CLK_75MHZ) { /* Change to SVS */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x08, 0x08); - if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) { + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x08, 0x08); + if (tasha_codec_cpe_fll_update_divider(component, clk_freq)) { ret = -EINVAL; goto done; } - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x10, 0x10); clear_bit(CPE_NOMINAL, &tasha->status_mask); tasha_codec_update_sido_voltage(tasha, sido_buck_svs_voltage); } else if (clk_freq == CPE_FLL_CLK_150MHZ) { /* change to nominal */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x08, 0x08); set_bit(CPE_NOMINAL, &tasha->status_mask); tasha_codec_update_sido_voltage(tasha, SIDO_VOLTAGE_NOMINAL_MV); - if (tasha_codec_cpe_fll_update_divider(codec, clk_freq)) { + if (tasha_codec_cpe_fll_update_divider(component, clk_freq)) { ret = -EINVAL; goto done; } - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x10, 0x10); } else { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid clk_freq request %d for CPE FLL\n", __func__, clk_freq); ret = -EINVAL; } done: - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x10, 0x00); - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x08, 0x00); + snd_soc_component_update_bits(component, WCD9335_CPE_FLL_FLL_MODE, + 0x10, 0x00); + snd_soc_component_update_bits(component, WCD9335_CPE_FLL_FLL_MODE, + 0x08, 0x00); return ret; } -static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec, +static int tasha_codec_cpe_fll_enable(struct snd_soc_component *component, bool enable) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u8 clk_sel_reg_val = 0x00; - dev_dbg(codec->dev, "%s: enable = %s\n", + dev_dbg(component->dev, "%s: enable = %s\n", __func__, enable ? "true" : "false"); if (enable) { if (tasha_cdc_is_svs_enabled(tasha)) { /* FLL enable is always at SVS */ - if (__tasha_cdc_change_cpe_clk(codec, + if (__tasha_cdc_change_cpe_clk(component, CPE_FLL_CLK_75MHZ)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: clk change to %d failed\n", __func__, CPE_FLL_CLK_75MHZ); return -EINVAL; } } else { - if (tasha_codec_cpe_fll_update_divider(codec, + if (tasha_codec_cpe_fll_update_divider(component, CPE_FLL_CLK_75MHZ)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: clk change to %d failed\n", __func__, CPE_FLL_CLK_75MHZ); return -EINVAL; @@ -13052,53 +13415,61 @@ static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec, } if (TASHA_IS_1_0(wcd9xxx)) { - tasha_cdc_mclk_enable(codec, true, false); + tasha_cdc_mclk_enable(component, true, false); clk_sel_reg_val = 0x02; } /* Setup CPE reference clk */ - snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP, - 0x02, clk_sel_reg_val); + snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP, + 0x02, clk_sel_reg_val); /* enable CPE FLL reference clk */ - snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP, - 0x01, 0x01); + snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP, + 0x01, 0x01); /* program the PLL */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_USER_CTL_0, + 0x01, 0x01); /* TEST clk setting */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0, - 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_TEST_CTL_0, + 0x80, 0x80); /* set FLL mode to HW controlled */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x60, 0x00); - snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x80); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x60, 0x00); + snd_soc_component_write(component, WCD9335_CPE_FLL_FLL_MODE, + 0x80); } else { /* disable CPE FLL reference clk */ - snd_soc_update_bits(codec, WCD9335_ANA_CLK_TOP, - 0x01, 0x00); + snd_soc_component_update_bits(component, WCD9335_ANA_CLK_TOP, + 0x01, 0x00); /* undo TEST clk setting */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_TEST_CTL_0, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_TEST_CTL_0, + 0x80, 0x00); /* undo FLL mode to HW control */ - snd_soc_write(codec, WCD9335_CPE_FLL_FLL_MODE, 0x00); - snd_soc_update_bits(codec, WCD9335_CPE_FLL_FLL_MODE, - 0x60, 0x20); + snd_soc_component_write(component, + WCD9335_CPE_FLL_FLL_MODE, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_FLL_MODE, + 0x60, 0x20); /* undo the PLL */ - snd_soc_update_bits(codec, WCD9335_CPE_FLL_USER_CTL_0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CPE_FLL_USER_CTL_0, + 0x01, 0x00); if (TASHA_IS_1_0(wcd9xxx)) - tasha_cdc_mclk_enable(codec, false, false); + tasha_cdc_mclk_enable(component, false, false); /* * FLL could get disabled while at nominal, * scale it back to SVS */ if (tasha_cdc_is_svs_enabled(tasha)) - __tasha_cdc_change_cpe_clk(codec, + __tasha_cdc_change_cpe_clk(component, CPE_FLL_CLK_75MHZ); } @@ -13109,20 +13480,20 @@ static int tasha_codec_cpe_fll_enable(struct snd_soc_codec *codec, static void tasha_cdc_query_cpe_clk_plan(void *data, struct cpe_svc_cfg_clk_plan *clk_freq) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; struct tasha_priv *tasha; u32 cpe_clk_khz; - if (!codec) { - pr_err("%s: Invalid codec handle\n", + if (!component) { + pr_err("%s: Invalid component handle\n", __func__); return; } - tasha = snd_soc_codec_get_drvdata(codec); + tasha = snd_soc_component_get_drvdata(component); cpe_clk_khz = tasha->current_cpe_clk_freq / 1000; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: current_clk_freq = %u\n", __func__, tasha->current_cpe_clk_freq); @@ -13141,17 +13512,17 @@ static void tasha_cdc_query_cpe_clk_plan(void *data, static void tasha_cdc_change_cpe_clk(void *data, u32 clk_freq) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; struct tasha_priv *tasha; u32 cpe_clk_khz, req_freq = 0; - if (!codec) { + if (!component) { pr_err("%s: Invalid codec handle\n", __func__); return; } - tasha = snd_soc_codec_get_drvdata(codec); + tasha = snd_soc_component_get_drvdata(component); cpe_clk_khz = tasha->current_cpe_clk_freq / 1000; if (tasha_cdc_is_svs_enabled(tasha)) { @@ -13161,34 +13532,34 @@ static void tasha_cdc_change_cpe_clk(void *data, req_freq = CPE_FLL_CLK_150MHZ; } - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: requested clk_freq = %u, current clk_freq = %u\n", __func__, clk_freq * 1000, tasha->current_cpe_clk_freq); if (tasha_cdc_is_svs_enabled(tasha)) { - if (__tasha_cdc_change_cpe_clk(codec, req_freq)) - dev_err(codec->dev, + if (__tasha_cdc_change_cpe_clk(component, req_freq)) + dev_err(component->dev, "%s: clock/voltage scaling failed\n", __func__); } } -static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec, +static int tasha_codec_slim_reserve_bw(struct snd_soc_component *component, u32 bw_ops, bool commit) { struct wcd9xxx *wcd9xxx; - if (!codec) { + if (!component) { pr_err("%s: Invalid handle to codec\n", __func__); return -EINVAL; } - wcd9xxx = dev_get_drvdata(codec->dev->parent); + wcd9xxx = dev_get_drvdata(component->dev->parent); if (!wcd9xxx) { - dev_err(codec->dev, "%s: Invalid parent drv_data\n", + dev_err(component->dev, "%s: Invalid parent drv_data\n", __func__); return -EINVAL; } @@ -13196,11 +13567,11 @@ static int tasha_codec_slim_reserve_bw(struct snd_soc_codec *codec, return wcd9xxx_slim_reserve_bw(wcd9xxx, bw_ops, commit); } -static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, +static int tasha_codec_vote_max_bw(struct snd_soc_component *component, bool vote) { u32 bw_ops; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) return 0; @@ -13210,19 +13581,19 @@ static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, tasha->ref_count++; if (tasha->ref_count == 1) { bw_ops = SLIM_BW_CLK_GEAR_9; - tasha_codec_slim_reserve_bw(codec, + tasha_codec_slim_reserve_bw(component, bw_ops, true); } } else if (!vote && tasha->ref_count > 0) { tasha->ref_count--; if (tasha->ref_count == 0) { bw_ops = SLIM_BW_UNVOTE; - tasha_codec_slim_reserve_bw(codec, + tasha_codec_slim_reserve_bw(component, bw_ops, true); } }; - dev_dbg(codec->dev, "%s Value of counter after vote or un-vote is %d\n", + dev_dbg(component->dev, "%s Value of counter after vote or un-vote is %d\n", __func__, tasha->ref_count); mutex_unlock(&tasha->sb_clk_gear_lock); @@ -13230,10 +13601,10 @@ static int tasha_codec_vote_max_bw(struct snd_soc_codec *codec, return 0; } -static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec, +static int tasha_cpe_err_irq_control(struct snd_soc_component *component, enum cpe_err_irq_cntl_type cntl_type, u8 *status) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); u8 irq_bits; if (TASHA_IS_2_0(tasha->wcd9xxx)) @@ -13246,24 +13617,25 @@ static int tasha_cpe_err_irq_control(struct snd_soc_codec *codec, switch (cntl_type) { case CPE_ERR_IRQ_MASK: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_SS_ERROR_INT_MASK, irq_bits, irq_bits); break; case CPE_ERR_IRQ_UNMASK: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9335_CPE_SS_SS_ERROR_INT_MASK, irq_bits, 0x00); break; case CPE_ERR_IRQ_CLEAR: - snd_soc_write(codec, WCD9335_CPE_SS_SS_ERROR_INT_CLEAR, - irq_bits); + snd_soc_component_write(component, + WCD9335_CPE_SS_SS_ERROR_INT_CLEAR, + irq_bits); break; case CPE_ERR_IRQ_STATUS: if (!status) return -EINVAL; - *status = snd_soc_read(codec, - WCD9335_CPE_SS_SS_ERROR_INT_STATUS); + *status = snd_soc_component_read32(component, + WCD9335_CPE_SS_SS_ERROR_INT_STATUS); break; } @@ -13286,14 +13658,14 @@ static struct cpe_svc_init_param cpe_svc_params = { .change_freq_plan_cb = tasha_cdc_change_cpe_clk, }; -static int tasha_cpe_initialize(struct snd_soc_codec *codec) +static int tasha_cpe_initialize(struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd_cpe_params cpe_params; memset(&cpe_params, 0, sizeof(struct wcd_cpe_params)); - cpe_params.codec = codec; + cpe_params.component = component; cpe_params.get_cpe_core = tasha_codec_get_cpe_core; cpe_params.cdc_cb = &cpe_cb; cpe_params.dbg_mode = cpe_debug_mode; @@ -13308,13 +13680,13 @@ static int tasha_cpe_initialize(struct snd_soc_codec *codec) cpe_params.cdc_irq_info.cpe_fatal_irqs = TASHA_CPE_FATAL_IRQS; - cpe_svc_params.context = codec; + cpe_svc_params.context = component; cpe_params.cpe_svc_params = &cpe_svc_params; - tasha->cpe_core = wcd_cpe_init("cpe_9335", codec, + tasha->cpe_core = wcd_cpe_init("cpe_9335", component, &cpe_params); if (IS_ERR_OR_NULL(tasha->cpe_core)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to enable CPE\n", __func__); return -EINVAL; @@ -13329,18 +13701,18 @@ static const struct wcd_resmgr_cb tasha_resmgr_cb = { static int tasha_device_down(struct wcd9xxx *wcd9xxx) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct tasha_priv *priv; int count; int i = 0; - codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); - priv = snd_soc_codec_get_drvdata(codec); + component = (struct snd_soc_component *)(wcd9xxx->ssr_priv); + priv = snd_soc_component_get_drvdata(component); wcd_cpe_ssr_event(priv->cpe_core, WCD_CPE_BUS_DOWN_EVENT); for (i = 0; i < priv->nr; i++) swrm_wcd_notify(priv->swr_ctrl_data[i].swr_pdev, SWR_DEVICE_DOWN, NULL); - snd_soc_card_change_online_state(codec->component.card, 0); + snd_soc_card_change_online_state(component->card, 0); for (count = 0; count < NUM_CODEC_DAIS; count++) priv->dai[count].bus_down_in_recovery = true; @@ -13353,13 +13725,13 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx) { int i, ret = 0; struct wcd9xxx *control; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct tasha_priv *tasha; struct wcd9xxx_pdata *pdata; - codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); - tasha = snd_soc_codec_get_drvdata(codec); - control = dev_get_drvdata(codec->dev->parent); + component = (struct snd_soc_component *)(wcd9xxx->ssr_priv); + tasha = snd_soc_component_get_drvdata(component); + control = dev_get_drvdata(component->dev->parent); wcd9xxx_set_power_state(tasha->wcd9xxx, WCD_REGION_POWER_COLLAPSE_REMOVE, @@ -13371,11 +13743,11 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx) control->slim_slave->laddr; tasha_slimbus_slave_port_cfg.slave_dev_pgd_la = control->slim->laddr; - tasha_init_slim_slave_cfg(codec); + tasha_init_slim_slave_cfg(component); if (tasha->machine_codec_event_cb) - tasha->machine_codec_event_cb(codec, + tasha->machine_codec_event_cb(component, WCD9335_CODEC_EVENT_CODEC_UP); - snd_soc_card_change_online_state(codec->component.card, 1); + snd_soc_card_change_online_state(component->card, 1); /* Class-H Init*/ wcd_clsh_init(&tasha->clsh_d); @@ -13385,30 +13757,32 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx) tasha_update_reg_defaults(tasha); - tasha->codec = codec; + tasha->component = component; - dev_dbg(codec->dev, "%s: MCLK Rate = %x\n", + dev_dbg(component->dev, "%s: MCLK Rate = %x\n", __func__, control->mclk_rate); if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x00); else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x01); - tasha_codec_init_reg(codec); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x01); + tasha_codec_init_reg(component); wcd_resmgr_post_ssr_v2(tasha->resmgr); - tasha_enable_efuse_sensing(codec); + tasha_enable_efuse_sensing(component); - regcache_mark_dirty(codec->component.regmap); - regcache_sync(codec->component.regmap); + regcache_mark_dirty(component->regmap); + regcache_sync(component->regmap); - pdata = dev_get_platdata(codec->dev->parent); + pdata = dev_get_platdata(component->dev->parent); ret = tasha_handle_pdata(tasha, pdata); if (ret < 0) - dev_err(codec->dev, "%s: invalid pdata\n", __func__); + dev_err(component->dev, "%s: invalid pdata\n", __func__); /* Reset reference counter for voting for max bw */ tasha->ref_count = 0; @@ -13417,23 +13791,23 @@ static int tasha_post_reset_cb(struct wcd9xxx *wcd9xxx) tasha->mbhc_started = false; /* Initialize MBHC module */ - ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids, + ret = wcd_mbhc_init(&tasha->mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, TASHA_ZDET_SUPPORTED); if (ret) - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); else - tasha_mbhc_hs_detect(codec, tasha->mbhc.mbhc_cfg); + tasha_mbhc_hs_detect(component, tasha->mbhc.mbhc_cfg); tasha_cleanup_irqs(tasha); ret = tasha_setup_irqs(tasha); if (ret) { - dev_err(codec->dev, "%s: tasha irq setup failed %d\n", + dev_err(component->dev, "%s: tasha irq setup failed %d\n", __func__, ret); goto err; } - tasha_set_spkr_mode(codec, tasha->spkr_mode); + tasha_set_spkr_mode(component, tasha->spkr_mode); wcd_cpe_ssr_event(tasha->cpe_core, WCD_CPE_BUS_UP_EVENT); err: @@ -13442,12 +13816,12 @@ err: } static struct regulator *tasha_codec_find_ondemand_regulator( - struct snd_soc_codec *codec, const char *name) + struct snd_soc_component *component, const char *name) { int i; - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *wcd9xxx = tasha->wcd9xxx; - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); for (i = 0; i < wcd9xxx->num_of_supplies; ++i) { if (pdata->regulator[i].ondemand && @@ -13461,32 +13835,35 @@ static struct regulator *tasha_codec_find_ondemand_regulator( return NULL; } -static int tasha_codec_probe(struct snd_soc_codec *codec) +static int tasha_codec_probe(struct snd_soc_component *component) { struct wcd9xxx *control; struct tasha_priv *tasha; struct wcd9xxx_pdata *pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int i, ret; void *ptr = NULL; struct regulator *supply; - control = dev_get_drvdata(codec->dev->parent); + control = dev_get_drvdata(component->dev->parent); - dev_info(codec->dev, "%s()\n", __func__); - tasha = snd_soc_codec_get_drvdata(codec); + snd_soc_component_init_regmap(component, control->regmap); + + dev_info(component->dev, "%s()\n", __func__); + tasha = snd_soc_component_get_drvdata(component); tasha->intf_type = wcd9xxx_get_intf_type(); if (tasha->intf_type == WCD9XXX_INTERFACE_TYPE_SLIMBUS) { control->dev_down = tasha_device_down; control->post_reset = tasha_post_reset_cb; - control->ssr_priv = (void *)codec; + control->ssr_priv = (void *)component; } /* Resource Manager post Init */ - ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, codec); + ret = wcd_resmgr_post_init(tasha->resmgr, &tasha_resmgr_cb, component); if (ret) { - dev_err(codec->dev, "%s: wcd resmgr post init failed\n", + dev_err(component->dev, "%s: wcd resmgr post init failed\n", __func__); goto err; } @@ -13495,32 +13872,34 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) /* Default HPH Mode to Class-H HiFi */ tasha->hph_mode = CLS_H_HIFI; - tasha->codec = codec; + tasha->component = component; for (i = 0; i < COMPANDER_MAX; i++) tasha->comp_enabled[i] = 0; tasha->spkr_gain_offset = RX_GAIN_OFFSET_0_DB; tasha->intf_type = wcd9xxx_get_intf_type(); - tasha_update_reg_reset_values(codec); + tasha_update_reg_reset_values(component); pr_debug("%s: MCLK Rate = %x\n", __func__, control->mclk_rate); if (control->mclk_rate == TASHA_MCLK_CLK_12P288MHZ) - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x00); else if (control->mclk_rate == TASHA_MCLK_CLK_9P6MHZ) - snd_soc_update_bits(codec, WCD9335_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x01); - tasha_codec_init_reg(codec); + snd_soc_component_update_bits(component, + WCD9335_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x01); + tasha_codec_init_reg(component); - tasha_enable_efuse_sensing(codec); + tasha_enable_efuse_sensing(component); - pdata = dev_get_platdata(codec->dev->parent); + pdata = dev_get_platdata(component->dev->parent); ret = tasha_handle_pdata(tasha, pdata); if (ret < 0) { pr_err("%s: bad pdata\n", __func__); goto err; } - supply = tasha_codec_find_ondemand_regulator(codec, + supply = tasha_codec_find_ondemand_regulator(component, on_demand_supply_name[ON_DEMAND_MICBIAS]); if (supply) { tasha->on_demand_list[ON_DEMAND_MICBIAS].supply = supply; @@ -13528,7 +13907,7 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) 0; } - tasha->fw_data = devm_kzalloc(codec->dev, + tasha->fw_data = devm_kzalloc(component->dev, sizeof(*(tasha->fw_data)), GFP_KERNEL); if (!tasha->fw_data) goto err; @@ -13538,9 +13917,9 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) set_bit(WCD9XXX_VBAT_CAL, tasha->fw_data->cal_bit); ret = wcd_cal_create_hwdep(tasha->fw_data, - WCD9XXX_CODEC_HWDEP_NODE, codec); + WCD9XXX_CODEC_HWDEP_NODE, component); if (ret < 0) { - dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret); + dev_err(component->dev, "%s hwdep failed %d\n", __func__, ret); goto err_hwdep; } @@ -13550,14 +13929,14 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) WCD9335_MBHC_FSM_STATUS; wcd_mbhc_registers[WCD_MBHC_FSM_STATUS].mask = 0x01; } - ret = wcd_mbhc_init(&tasha->mbhc, codec, &mbhc_cb, &intr_ids, + ret = wcd_mbhc_init(&tasha->mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, TASHA_ZDET_SUPPORTED); if (ret) { pr_err("%s: mbhc initialization failed\n", __func__); goto err_hwdep; } - ptr = devm_kzalloc(codec->dev, (sizeof(tasha_rx_chs) + + ptr = devm_kzalloc(component->dev, (sizeof(tasha_rx_chs) + sizeof(tasha_tx_chs)), GFP_KERNEL); if (!ptr) { ret = -ENOMEM; @@ -13584,19 +13963,19 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) control->slim->laddr; tasha_slimbus_slave_port_cfg.slave_port_mapping[0] = TASHA_TX13; - tasha_init_slim_slave_cfg(codec); + tasha_init_slim_slave_cfg(component); } - snd_soc_add_codec_controls(codec, impedance_detect_controls, + snd_soc_add_component_controls(component, impedance_detect_controls, ARRAY_SIZE(impedance_detect_controls)); - snd_soc_add_codec_controls(codec, hph_type_detect_controls, + snd_soc_add_component_controls(component, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, tasha_analog_gain_controls, ARRAY_SIZE(tasha_analog_gain_controls)); if (tasha->is_wsa_attach) - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, tasha_spkr_wsa_controls, ARRAY_SIZE(tasha_spkr_wsa_controls)); control->num_rx_port = TASHA_RX_MAX; @@ -13629,9 +14008,9 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) goto err_pdata; } - ret = tasha_cpe_initialize(codec); + ret = tasha_cpe_initialize(component); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "%s: cpe initialization failed, err = %d\n", __func__, ret); /* Do not fail probe if CPE failed */ @@ -13674,22 +14053,22 @@ static int tasha_codec_probe(struct snd_soc_codec *codec) return ret; err_pdata: - devm_kfree(codec->dev, ptr); + devm_kfree(component->dev, ptr); control->rx_chs = NULL; control->tx_chs = NULL; err_hwdep: - devm_kfree(codec->dev, tasha->fw_data); + devm_kfree(component->dev, tasha->fw_data); tasha->fw_data = NULL; err: return ret; } -static int tasha_codec_remove(struct snd_soc_codec *codec) +static void tasha_codec_remove(struct snd_soc_component *component) { - struct tasha_priv *tasha = snd_soc_codec_get_drvdata(codec); + struct tasha_priv *tasha = snd_soc_component_get_drvdata(component); struct wcd9xxx *control; - control = dev_get_drvdata(codec->dev->parent); + control = dev_get_drvdata(component->dev->parent); control->num_rx_port = 0; control->num_tx_port = 0; control->rx_chs = NULL; @@ -13700,28 +14079,19 @@ static int tasha_codec_remove(struct snd_soc_codec *codec) wcd_mbhc_deinit(&tasha->mbhc); /* Cleanup resmgr */ - return 0; + return; } -static struct regmap *tasha_get_regmap(struct device *dev) -{ - struct wcd9xxx *control = dev_get_drvdata(dev->parent); - - return control->regmap; -} - -static struct snd_soc_codec_driver soc_codec_dev_tasha = { +static const struct snd_soc_component_driver soc_codec_dev_tasha = { + .name = DRV_NAME, .probe = tasha_codec_probe, .remove = tasha_codec_remove, - .get_regmap = tasha_get_regmap, - .component_driver = { - .controls = tasha_snd_controls, - .num_controls = ARRAY_SIZE(tasha_snd_controls), - .dapm_widgets = tasha_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets), - .dapm_routes = audio_map, - .num_dapm_routes = ARRAY_SIZE(audio_map), - }, + .controls = tasha_snd_controls, + .num_controls = ARRAY_SIZE(tasha_snd_controls), + .dapm_widgets = tasha_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tasha_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), }; #ifdef CONFIG_PM @@ -14115,7 +14485,7 @@ err: /* * tasha_codec_ver: to get tasha codec version - * @codec: handle to snd_soc_codec * + * @codec: handle to snd_soc_component * * return enum codec_variant - version */ enum codec_variant tasha_codec_ver(void) @@ -14265,12 +14635,14 @@ static int tasha_probe(struct platform_device *pdev) tasha->wcd_native_clk = wcd_native_clk; if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_SLIMBUS) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha, - tasha_dai, ARRAY_SIZE(tasha_dai)); + ret = snd_soc_register_component(&pdev->dev, + &soc_codec_dev_tasha, + tasha_dai, ARRAY_SIZE(tasha_dai)); else if (wcd9xxx_get_intf_type() == WCD9XXX_INTERFACE_TYPE_I2C) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tasha, - tasha_i2s_dai, - ARRAY_SIZE(tasha_i2s_dai)); + ret = snd_soc_register_component(&pdev->dev, + &soc_codec_dev_tasha, + tasha_i2s_dai, + ARRAY_SIZE(tasha_i2s_dai)); else ret = -EINVAL; if (ret) { @@ -14320,7 +14692,7 @@ static int tasha_remove(struct platform_device *pdev) clk_put(tasha->wcd_native_clk); mutex_destroy(&tasha->mclk_lock); mutex_destroy(&tasha->sb_clk_gear_lock); - snd_soc_unregister_codec(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); devm_kfree(&pdev->dev, tasha); return 0; } diff --git a/asoc/codecs/wcd9335.h b/asoc/codecs/wcd9335.h index 105fc2eca5..203c6de0aa 100644 --- a/asoc/codecs/wcd9335.h +++ b/asoc/codecs/wcd9335.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ #ifndef WCD9335_H #define WCD9335_H @@ -130,95 +130,102 @@ enum { }; #if IS_ENABLED(CONFIG_SND_SOC_WCD9335) -extern void *tasha_get_afe_config(struct snd_soc_codec *codec, +extern void *tasha_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type); -extern int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, int enable, - bool dapm); -extern int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, int enable, - bool dapm); -extern int tasha_enable_efuse_sensing(struct snd_soc_codec *codec); -extern int tasha_mbhc_hs_detect(struct snd_soc_codec *codec, +extern int tasha_cdc_mclk_enable(struct snd_soc_component *component, + int enable, bool dapm); +extern int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component, + int enable, bool dapm); +extern int tasha_enable_efuse_sensing(struct snd_soc_component *component); +extern int tasha_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); -extern void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec); +extern void tasha_mbhc_hs_detect_exit(struct snd_soc_component *component); extern void tasha_mbhc_zdet_gpio_ctrl( - int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high), - struct snd_soc_codec *codec); + int (*zdet_gpio_cb)(struct snd_soc_component *component, + bool high), struct snd_soc_component *component); extern int tasha_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec); + struct snd_soc_component *component); extern void tasha_event_register( - int (*machine_event_cb)(struct snd_soc_codec *codec, + int (*machine_event_cb)(struct snd_soc_component *component, enum wcd9335_codec_event), - struct snd_soc_codec *codec); -extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec, - int micb_num, - bool enable); -extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode); -extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset); + struct snd_soc_component *component); +extern int tasha_codec_enable_standalone_micbias( + struct snd_soc_component *component, + int micb_num, + bool enable); +extern int tasha_set_spkr_mode(struct snd_soc_component *component, int mode); +extern int tasha_set_spkr_gain_offset(struct snd_soc_component *component, + int offset); extern enum codec_variant tasha_codec_ver(void); #else /* CONFIG_SND_SOC_WCD9335 */ -static inline void *tasha_get_afe_config(struct snd_soc_codec *codec, +static inline void *tasha_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type) { return NULL; } -static inline int tasha_cdc_mclk_enable(struct snd_soc_codec *codec, +static inline int tasha_cdc_mclk_enable(struct snd_soc_component *component, int enable, bool dapm) { return 0; } -static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_codec *codec, +static inline int tasha_cdc_mclk_tx_enable(struct snd_soc_component *component, int enable, bool dapm) { return 0; } -static inline int tasha_enable_efuse_sensing(struct snd_soc_codec *codec) +static inline int tasha_enable_efuse_sensing( + struct snd_soc_component *component) { return 0; } -static inline int tasha_mbhc_hs_detect(struct snd_soc_codec *codec, +static inline int tasha_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { return 0; } -static inline void tasha_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +static inline void tasha_mbhc_hs_detect_exit( + struct snd_soc_component *component) { } static inline void tasha_mbhc_zdet_gpio_ctrl( - int (*zdet_gpio_cb)(struct snd_soc_codec *codec, bool high), - struct snd_soc_codec *codec) + int (*zdet_gpio_cb)(struct snd_soc_component *component, + bool high), + struct snd_soc_component *component) { } static inline int tasha_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } static inline void tasha_event_register( - int (*machine_event_cb)(struct snd_soc_codec *codec, + int (*machine_event_cb)(struct snd_soc_component *component, enum wcd9335_codec_event), - struct snd_soc_codec *codec) + struct snd_soc_component *component) { } static inline int tasha_codec_enable_standalone_micbias( - struct snd_soc_codec *codec, + struct snd_soc_component *component, int micb_num, bool enable) { return 0; } -static inline int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode) +static inline int tasha_set_spkr_mode(struct snd_soc_component *component, + int mode) { return 0; } -static inline int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, - int offset) +static inline int tasha_set_spkr_gain_offset( + struct snd_soc_component *component, + int offset) { return 0; } diff --git a/asoc/codecs/wcd934x/wcd934x-dsd.c b/asoc/codecs/wcd934x/wcd934x-dsd.c index 2069c8d14d..0a9c55696c 100644 --- a/asoc/codecs/wcd934x/wcd934x-dsd.c +++ b/asoc/codecs/wcd934x/wcd934x-dsd.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ #include @@ -162,15 +162,15 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf, int interp_num) { unsigned int reg, val; - struct snd_soc_codec *codec; + struct snd_soc_component *component; - if (!dsd_conf || !dsd_conf->codec) + if (!dsd_conf || !dsd_conf->component) return -EINVAL; - codec = dsd_conf->codec; + component = dsd_conf->component; if (!is_valid_dsd_interpolator(interp_num)) { - dev_err(codec->dev, "%s: Invalid Interpolator: %d for DSD\n", + dev_err(component->dev, "%s: Invalid Interpolator: %d for DSD\n", __func__, interp_num); return -EINVAL; } @@ -196,7 +196,7 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf, return -EINVAL; } - snd_soc_update_bits(codec, reg, 0x02, val); + snd_soc_component_update_bits(component, reg, 0x02, val); return 0; } @@ -210,17 +210,21 @@ EXPORT_SYMBOL(tavil_dsd_set_out_select); */ void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf) { - if (!dsd_conf || !dsd_conf->codec) + if (!dsd_conf || !dsd_conf->component) return; - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x02, 0x02); - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x01, 0x00); - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x02, 0x02); - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x01, 0x00); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x01, 0x00); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x01, 0x00); } EXPORT_SYMBOL(tavil_dsd_reset); @@ -240,17 +244,17 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port, u8 val0, val1; u8 dsd0_out_sel, dsd1_out_sel; u16 int_fs_reg, interp_num = 0; - struct snd_soc_codec *codec; + struct snd_soc_component *component; - if (!dsd_conf || !dsd_conf->codec) + if (!dsd_conf || !dsd_conf->component) return; - codec = dsd_conf->codec; + component = dsd_conf->component; dsd_inp_sel = DSD_INP_SEL_RX0 + rx_port - WCD934X_RX_PORT_START_NUMBER; - val0 = snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0); - val1 = snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0); + val0 = snd_soc_component_read32(component, WCD934X_CDC_DSD0_CFG0); + val1 = snd_soc_component_read32(component, WCD934X_CDC_DSD1_CFG0); dsd0_inp = (val0 & 0x3C) >> 2; dsd1_inp = (val1 & 0x3C) >> 2; dsd0_out_sel = (val0 & 0x02) >> 1; @@ -270,23 +274,24 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port, if (interp_num) { int_fs_reg = WCD934X_CDC_RX0_RX_PATH_CTL + 20 * interp_num; - if ((snd_soc_read(codec, int_fs_reg) & 0x0f) < 0x09) { - dev_dbg(codec->dev, "%s: Set Interp %d to sample_rate val 0x%x\n", + if ((snd_soc_component_read32(component, int_fs_reg) & 0x0f) < + 0x09) { + dev_dbg(component->dev, "%s: Set Interp %d to sample_rate val 0x%x\n", __func__, interp_num, sample_rate_val); - snd_soc_update_bits(codec, int_fs_reg, 0x0F, - sample_rate_val); + snd_soc_component_update_bits(component, int_fs_reg, + 0x0F, sample_rate_val); } } } EXPORT_SYMBOL(tavil_dsd_set_interp_rate); -static int tavil_set_dsd_mode(struct snd_soc_codec *codec, int dsd_num, +static int tavil_set_dsd_mode(struct snd_soc_component *component, int dsd_num, u8 *pcm_rate_val) { unsigned int dsd_out_sel_reg; u8 dsd_mode; u32 sample_rate; - struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec); + struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component); if (!dsd_conf) return -EINVAL; @@ -307,17 +312,19 @@ static int tavil_set_dsd_mode(struct snd_soc_codec *codec, int dsd_num, *pcm_rate_val = 0xc; break; default: - dev_err(codec->dev, "%s: Invalid DSD rate: %d\n", + dev_err(component->dev, "%s: Invalid DSD rate: %d\n", __func__, sample_rate); return -EINVAL; } - snd_soc_update_bits(codec, dsd_out_sel_reg, 0x01, dsd_mode); + snd_soc_component_update_bits(component, dsd_out_sel_reg, + 0x01, dsd_mode); return 0; } -static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num, +static void tavil_dsd_data_pull(struct snd_soc_component *component, + int dsd_num, u8 pcm_rate_val, bool enable) { u8 clk_en, mute_en; @@ -332,37 +339,41 @@ static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num, } if (dsd_num & 0x01) { - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_MIX_CTL, - 0x20, clk_en); - dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_MIX_CTL, + 0x20, clk_en); + dsd_inp_sel = (snd_soc_component_read32( + component, WCD934X_CDC_DSD0_CFG0) & 0x3C) >> 2; dsd_inp_sel = (enable) ? dsd_inp_sel : 0; if (dsd_inp_sel < 9) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX_INP_MUX_RX_INT7_CFG1, 0x0F, dsd_inp_sel); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX7_RX_PATH_MIX_CTL, 0x0F, pcm_rate_val); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX7_RX_PATH_MIX_CTL, 0x10, mute_en); } } if (dsd_num & 0x02) { - snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_MIX_CTL, - 0x20, clk_en); - dsd_inp_sel = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_MIX_CTL, + 0x20, clk_en); + dsd_inp_sel = (snd_soc_component_read32( + component, WCD934X_CDC_DSD1_CFG0) & 0x3C) >> 2; dsd_inp_sel = (enable) ? dsd_inp_sel : 0; if (dsd_inp_sel < 9) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX_INP_MUX_RX_INT8_CFG1, 0x0F, dsd_inp_sel); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX8_RX_PATH_MIX_CTL, 0x0F, pcm_rate_val); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX8_RX_PATH_MIX_CTL, 0x10, mute_en); } @@ -371,85 +382,99 @@ static void tavil_dsd_data_pull(struct snd_soc_codec *codec, int dsd_num, static void tavil_dsd_update_volume(struct tavil_dsd_config *dsd_conf) { - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0, - 0x01, 0x01); - snd_soc_update_bits(dsd_conf->codec, WCD934X_CDC_TOP_TOP_CFG0, - 0x01, 0x00); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_TOP_TOP_CFG0, + 0x01, 0x01); + snd_soc_component_update_bits(dsd_conf->component, + WCD934X_CDC_TOP_TOP_CFG0, + 0x01, 0x00); } static int tavil_enable_dsd(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component); int rc, clk_users; int interp_idx; u8 pcm_rate_val; if (!dsd_conf) { - dev_err(codec->dev, "%s: null dsd_config pointer\n", __func__); + dev_err(component->dev, "%s: null dsd_config pointer\n", + __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s: DSD%d, event: %d\n", __func__, + dev_dbg(component->dev, "%s: DSD%d, event: %d\n", __func__, w->shift, event); if (w->shift == DSD0) { /* Read out select */ - if (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & 0x02) + if (snd_soc_component_read32( + component, WCD934X_CDC_DSD0_CFG0) & 0x02) interp_idx = INTERP_LO1; else interp_idx = INTERP_HPHL; } else if (w->shift == DSD1) { /* Read out select */ - if (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & 0x02) + if (snd_soc_component_read32( + component, WCD934X_CDC_DSD1_CFG0) & 0x02) interp_idx = INTERP_LO2; else interp_idx = INTERP_HPHR; } else { - dev_err(codec->dev, "%s: Unsupported DSD:%d\n", + dev_err(component->dev, "%s: Unsupported DSD:%d\n", __func__, w->shift); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - clk_users = tavil_codec_enable_interp_clk(codec, event, + clk_users = tavil_codec_enable_interp_clk(component, event, interp_idx); - rc = tavil_set_dsd_mode(codec, w->shift, &pcm_rate_val); + rc = tavil_set_dsd_mode(component, w->shift, &pcm_rate_val); if (rc) return rc; - tavil_dsd_data_pull(codec, (1 << w->shift), pcm_rate_val, + tavil_dsd_data_pull(component, (1 << w->shift), pcm_rate_val, true); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL, 0x01, 0x01); if (w->shift == DSD0) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x02, 0x02); - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x01, 0x01); /* Apply Gain */ - snd_soc_write(codec, WCD934X_CDC_DSD0_CFG1, - dsd_conf->volume[DSD0]); + snd_soc_component_write(component, + WCD934X_CDC_DSD0_CFG1, + dsd_conf->volume[DSD0]); if (dsd_conf->version == TAVIL_VERSION_1_1) tavil_dsd_update_volume(dsd_conf); } else if (w->shift == DSD1) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x02, 0x02); - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x01, 0x01); /* Apply Gain */ - snd_soc_write(codec, WCD934X_CDC_DSD1_CFG1, - dsd_conf->volume[DSD1]); + snd_soc_component_write(component, + WCD934X_CDC_DSD1_CFG1, + dsd_conf->volume[DSD1]); if (dsd_conf->version == TAVIL_VERSION_1_1) tavil_dsd_update_volume(dsd_conf); } @@ -457,14 +482,15 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w, usleep_range(10000, 10100); if (clk_users > 1) { - snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_ANA_RX_SUPPLIES, + 0x02, 0x02); if (w->shift == DSD0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2, 0x04, 0x00); if (w->shift == DSD1) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2, 0x04, 0x00); @@ -472,25 +498,31 @@ static int tavil_enable_dsd(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: if (w->shift == DSD0) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_PATH_CTL, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_PATH_CTL, + 0x01, 0x00); } else if (w->shift == DSD1) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_PATH_CTL, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_PATH_CTL, + 0x01, 0x00); } - tavil_codec_enable_interp_clk(codec, event, interp_idx); + tavil_codec_enable_interp_clk(component, event, interp_idx); - if (!(snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01) && - !(snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) { - snd_soc_update_bits(codec, + if (!(snd_soc_component_read32( + component, WCD934X_CDC_DSD0_PATH_CTL) & 0x01) && + !(snd_soc_component_read32( + component, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) { + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_DSD_CONTROL, 0x01, 0x00); - tavil_dsd_data_pull(codec, 0x03, 0x04, false); + tavil_dsd_data_pull(component, 0x03, 0x04, false); tavil_dsd_reset(dsd_conf); } break; @@ -513,8 +545,9 @@ static int tavil_dsd_vol_info(struct snd_kcontrol *kcontrol, static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component); int nv[DSD_MAX], cv[DSD_MAX]; int step_size, nv1; int i, dsd_idx; @@ -537,7 +570,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol, if (cv[dsd_idx] == nv[dsd_idx]) continue; - dev_dbg(codec->dev, "%s: DSD%d cur.vol: %d, new vol: %d\n", + dev_dbg(component->dev, "%s: DSD%d cur.vol: %d, new vol: %d\n", __func__, dsd_idx, cv[dsd_idx], nv[dsd_idx]); step_size = (nv[dsd_idx] - cv[dsd_idx]) / @@ -547,7 +580,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol, for (i = 0; i < DSD_VOLUME_STEPS; i++) { nv1 += step_size; - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx, nv1); if (dsd_conf->version == TAVIL_VERSION_1_1) @@ -559,7 +592,7 @@ static int tavil_dsd_vol_put(struct snd_kcontrol *kcontrol, DSD_VOLUME_USLEEP_MARGIN_US)); } if (nv1 != nv[dsd_idx]) { - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_DSD0_CFG1 + 16 * dsd_idx, nv[dsd_idx]); @@ -579,8 +612,9 @@ done: static int tavil_dsd_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_dsd_config *dsd_conf = tavil_get_dsd_config(component); if (dsd_conf) { ucontrol->value.integer.value[0] = dsd_conf->volume[DSD0]; @@ -618,45 +652,63 @@ static const struct snd_soc_dapm_widget tavil_dsd_widgets[] = { /** * tavil_dsd_post_ssr_init - DSD intialization after subsystem restart * - * @codec: pointer to snd_soc_codec + * @component: pointer to snd_soc_component * * Returns 0 on success or error on failure */ int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_conf) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; - if (!dsd_conf || !dsd_conf->codec) + if (!dsd_conf || !dsd_conf->component) return -EINVAL; - codec = dsd_conf->codec; + component = dsd_conf->component; /* Disable DSD Interrupts */ - snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD934X_INTR_CODEC_MISC_MASK, + 0x08, 0x08); /* DSD registers init */ if (dsd_conf->version == TAVIL_VERSION_1_0) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, + 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, + 0x02, 0x00); } /* DSD0: Mute EN */ - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, + 0x04, 0x04); /* DSD1: Mute EN */ - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10, - 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10, - 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E, - 0x0A); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E, - 0x0A); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07, - 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07, - 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, + 0x0E, 0x0A); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, + 0x0E, 0x0A); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, + 0x07, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, + 0x07, 0x04); /* Enable DSD Interrupts */ - snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD934X_INTR_CODEC_MISC_MASK, + 0x08, 0x00); return 0; } @@ -665,60 +717,71 @@ EXPORT_SYMBOL(tavil_dsd_post_ssr_init); /** * tavil_dsd_init - DSD intialization * - * @codec: pointer to snd_soc_codec + * @component: pointer to snd_soc_component * * Returns pointer to tavil_dsd_config for success or NULL for failure */ -struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec) +struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm; struct tavil_dsd_config *dsd_conf; u8 val; - if (!codec) + if (!component) return NULL; - dapm = snd_soc_codec_get_dapm(codec); + dapm = snd_soc_component_get_dapm(component); /* Read efuse register to check if DSD is supported */ - val = snd_soc_read(codec, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14); + val = snd_soc_component_read32(component, + WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT14); if (val & 0x80) { - dev_info(codec->dev, "%s: DSD unsupported for this codec version\n", + dev_info(component->dev, "%s: DSD unsupported for this codec version\n", __func__); return NULL; } - dsd_conf = devm_kzalloc(codec->dev, sizeof(struct tavil_dsd_config), + dsd_conf = devm_kzalloc(component->dev, sizeof(struct tavil_dsd_config), GFP_KERNEL); if (!dsd_conf) return NULL; - dsd_conf->codec = codec; + dsd_conf->component = component; /* Read version */ - dsd_conf->version = snd_soc_read(codec, + dsd_conf->version = snd_soc_component_read32(component, WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0); /* DSD registers init */ if (dsd_conf->version == TAVIL_VERSION_1_0) { - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x02, 0x00); + snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2, + 0x02, 0x00); + snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2, + 0x02, 0x00); } /* DSD0: Mute EN */ - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, 0x04, 0x04); + snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2, + 0x04, 0x04); /* DSD1: Mute EN */ - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, 0x10, - 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, 0x10, - 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, 0x0E, - 0x0A); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, 0x0E, - 0x0A); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, 0x07, - 0x04); - snd_soc_update_bits(codec, WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, 0x07, - 0x04); + snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG3, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG3, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG0, + 0x0E, 0x0A); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG0, + 0x0E, 0x0A); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD0_DEBUG_CFG1, + 0x07, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DEBUG_DSD1_DEBUG_CFG1, + 0x07, 0x04); snd_soc_dapm_new_controls(dapm, tavil_dsd_widgets, ARRAY_SIZE(tavil_dsd_widgets)); @@ -730,11 +793,12 @@ struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec) dsd_conf->volume[DSD0] = DSD_VOLUME_MAX_0dB; dsd_conf->volume[DSD1] = DSD_VOLUME_MAX_0dB; - snd_soc_add_codec_controls(codec, tavil_dsd_vol_controls, + snd_soc_add_component_controls(component, tavil_dsd_vol_controls, ARRAY_SIZE(tavil_dsd_vol_controls)); /* Enable DSD Interrupts */ - snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00); + snd_soc_component_update_bits(component, + WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x00); return dsd_conf; } @@ -747,18 +811,19 @@ EXPORT_SYMBOL(tavil_dsd_init); */ void tavil_dsd_deinit(struct tavil_dsd_config *dsd_conf) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; if (!dsd_conf) return; - codec = dsd_conf->codec; + component = dsd_conf->component; mutex_destroy(&dsd_conf->vol_mutex); /* Disable DSD Interrupts */ - snd_soc_update_bits(codec, WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD934X_INTR_CODEC_MISC_MASK, 0x08, 0x08); - devm_kfree(codec->dev, dsd_conf); + devm_kfree(component->dev, dsd_conf); } EXPORT_SYMBOL(tavil_dsd_deinit); diff --git a/asoc/codecs/wcd934x/wcd934x-dsd.h b/asoc/codecs/wcd934x/wcd934x-dsd.h index cd6b57924f..e078c077f8 100644 --- a/asoc/codecs/wcd934x/wcd934x-dsd.h +++ b/asoc/codecs/wcd934x/wcd934x-dsd.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD934X_DSD_H__ @@ -27,7 +27,7 @@ enum { }; struct tavil_dsd_config { - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int dsd_interp_mixer[INTERP_MAX]; u32 base_sample_rate[DSD_MAX]; int volume[DSD_MAX]; @@ -45,7 +45,7 @@ int tavil_dsd_set_out_select(struct tavil_dsd_config *dsd_conf, void tavil_dsd_reset(struct tavil_dsd_config *dsd_conf); void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port, u32 sample_rate, u8 sample_rate_val); -struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec); +struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component); void tavil_dsd_deinit(struct tavil_dsd_config *dsd_config); int tavil_dsd_post_ssr_init(struct tavil_dsd_config *dsd_config); #else @@ -74,7 +74,7 @@ void tavil_dsd_set_interp_rate(struct tavil_dsd_config *dsd_conf, u16 rx_port, u32 sample_rate, u8 sample_rate_val) { } -struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_codec *codec) +struct tavil_dsd_config *tavil_dsd_init(struct snd_soc_component *component) { return NULL; } diff --git a/asoc/codecs/wcd934x/wcd934x-dsp-cntl.c b/asoc/codecs/wcd934x/wcd934x-dsp-cntl.c index a7a836faef..e64b1588a8 100644 --- a/asoc/codecs/wcd934x/wcd934x-dsp-cntl.c +++ b/asoc/codecs/wcd934x/wcd934x-dsp-cntl.c @@ -25,16 +25,16 @@ #define WCD_934X_RAMDUMP_SIZE ((1024 * 1024) - 128) #define WCD_MISCDEV_CMD_MAX_LEN 11 -#define WCD_CNTL_MUTEX_LOCK(codec, lock) \ +#define WCD_CNTL_MUTEX_LOCK(component, lock) \ { \ - dev_dbg(codec->dev, "%s: mutex_lock(%s)\n", \ + dev_dbg(component->dev, "%s: mutex_lock(%s)\n", \ __func__, __stringify_1(lock)); \ mutex_lock(&lock); \ } -#define WCD_CNTL_MUTEX_UNLOCK(codec, lock) \ +#define WCD_CNTL_MUTEX_UNLOCK(component, lock) \ { \ - dev_dbg(codec->dev, "%s: mutex_unlock(%s)\n", \ + dev_dbg(component->dev, "%s: mutex_unlock(%s)\n", \ __func__, __stringify_1(lock)); \ mutex_unlock(&lock); \ } @@ -109,7 +109,7 @@ static u16 wdsp_reg_for_debug_dump[] = { static void wcd_cntl_collect_debug_dumps(struct wcd_dsp_cntl *cntl, bool internal) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; struct wdsp_err_signal_arg arg; enum wdsp_signal signal; int i; @@ -120,21 +120,22 @@ static void wcd_cntl_collect_debug_dumps(struct wcd_dsp_cntl *cntl, return; /* Mask all error interrupts */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, 0xFF); /* Collect important WDSP registers dump for debug use */ pr_err("%s: Dump the WDSP registers for debug use\n", __func__); for (i = 0; i < sizeof(wdsp_reg_for_debug_dump)/sizeof(u16); i++) { - val = snd_soc_read(codec, wdsp_reg_for_debug_dump[i]); + val = snd_soc_component_read32(component, + wdsp_reg_for_debug_dump[i]); pr_err("%s: reg = 0x%x, val = 0x%x\n", __func__, wdsp_reg_for_debug_dump[i], val); } /* Trigger NMI in WDSP to sync and update the memory */ - snd_soc_write(codec, WCD934X_CPE_SS_BACKUP_INT, 0x02); + snd_soc_component_write(component, WCD934X_CPE_SS_BACKUP_INT, 0x02); /* Collect WDSP ramdump for debug use */ if (cntl->m_dev && cntl->m_ops && cntl->m_ops->signal_handler) { @@ -146,9 +147,9 @@ static void wcd_cntl_collect_debug_dumps(struct wcd_dsp_cntl *cntl, } /* Unmask the fatal irqs */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, ~(cntl->irqs.fatal_irqs & 0xFF)); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, ~((cntl->irqs.fatal_irqs >> 8) & 0xFF)); WCD_CNTL_CLR_ERR_IRQ_FLAG(cntl); @@ -177,7 +178,7 @@ static ssize_t wdsp_boot_store(struct wcd_dsp_cntl *cntl, ret = kstrtou32(buf, 10, &val); if (ret) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: Invalid entry, ret = %d\n", __func__, ret); return -EINVAL; } @@ -197,7 +198,7 @@ static ssize_t wdsp_boot_store(struct wcd_dsp_cntl *cntl, ret = -EINVAL; if (ret < 0) - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: failed to %s dsp\n", __func__, vote ? "enable" : "disable"); return count; @@ -247,17 +248,17 @@ static void wcd_cntl_change_online_state(struct wcd_dsp_cntl *cntl, struct wdsp_ssr_entry *ssr_entry = &cntl->ssr_entry; unsigned long ret; - WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_LOCK(cntl->component, cntl->ssr_mutex); ssr_entry->offline = !online; /* Make sure the write is complete */ wmb(); ret = xchg(&ssr_entry->offline_change, 1); wake_up_interruptible(&ssr_entry->offline_poll_wait); - dev_dbg(cntl->codec->dev, + dev_dbg(cntl->component->dev, "%s: requested %u, offline %u offline_change %u, ret = %ldn", __func__, online, ssr_entry->offline, ssr_entry->offline_change, ret); - WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_UNLOCK(cntl->component, cntl->ssr_mutex); } static ssize_t wdsp_ssr_entry_read(struct snd_info_entry *entry, @@ -280,16 +281,16 @@ static ssize_t wdsp_ssr_entry_read(struct snd_info_entry *entry, ssr_entry = &cntl->ssr_entry; - WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_LOCK(cntl->component, cntl->ssr_mutex); offline = ssr_entry->offline; /* Make sure the read is complete */ rmb(); - dev_dbg(cntl->codec->dev, "%s: offline = %s\n", __func__, + dev_dbg(cntl->component->dev, "%s: offline = %s\n", __func__, offline ? "true" : "false"); len = snprintf(buffer, sizeof(buffer), "%s\n", offline ? "OFFLINE" : "ONLINE"); ret = simple_read_from_buffer(buf, count, &pos, buffer, len); - WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_UNLOCK(cntl->component, cntl->ssr_mutex); return ret; } @@ -311,18 +312,18 @@ static unsigned int wdsp_ssr_entry_poll(struct snd_info_entry *entry, cntl = (struct wcd_dsp_cntl *) entry->private_data; ssr_entry = &cntl->ssr_entry; - dev_dbg(cntl->codec->dev, "%s: Poll wait, offline = %u\n", + dev_dbg(cntl->component->dev, "%s: Poll wait, offline = %u\n", __func__, ssr_entry->offline); poll_wait(file, &ssr_entry->offline_poll_wait, wait); - dev_dbg(cntl->codec->dev, "%s: Woken up Poll wait, offline = %u\n", + dev_dbg(cntl->component->dev, "%s: Woken up Poll wait, offline = %u\n", __func__, ssr_entry->offline); - WCD_CNTL_MUTEX_LOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_LOCK(cntl->component, cntl->ssr_mutex); if (xchg(&ssr_entry->offline_change, 0)) ret = POLLIN | POLLPRI | POLLRDNORM; - dev_dbg(cntl->codec->dev, "%s: ret (%d) from poll_wait\n", + dev_dbg(cntl->component->dev, "%s: ret (%d) from poll_wait\n", __func__, ret); - WCD_CNTL_MUTEX_UNLOCK(cntl->codec, cntl->ssr_mutex); + WCD_CNTL_MUTEX_UNLOCK(cntl->component, cntl->ssr_mutex); return ret; } @@ -334,25 +335,25 @@ static struct snd_info_entry_ops wdsp_ssr_entry_ops = { static int wcd_cntl_cpe_fll_calibrate(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0, retry = 0; u8 cal_lsb, cal_msb; u8 lock_det; /* Make sure clocks are gated */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPE_CTL, 0x05, 0x00); /* Enable CPE FLL reference clock */ - snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1, + snd_soc_component_update_bits(component, WCD934X_CLK_SYS_MCLK2_PRG1, 0x80, 0x80); - snd_soc_update_bits(codec, WCD934X_CPE_FLL_USER_CTL_5, + snd_soc_component_update_bits(component, WCD934X_CPE_FLL_USER_CTL_5, 0xF3, 0x13); - snd_soc_write(codec, WCD934X_CPE_FLL_L_VAL_CTL_0, 0x50); + snd_soc_component_write(component, WCD934X_CPE_FLL_L_VAL_CTL_0, 0x50); /* Disable CPAR reset and Enable CPAR clk */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CTL, 0x02, 0x02); /* Write calibration l-value based on cdc clk rate */ @@ -363,56 +364,57 @@ static int wcd_cntl_cpe_fll_calibrate(struct wcd_dsp_cntl *cntl) cal_lsb = 0x56; cal_msb = 0x00; } - snd_soc_write(codec, WCD934X_CPE_FLL_USER_CTL_6, cal_lsb); - snd_soc_write(codec, WCD934X_CPE_FLL_USER_CTL_7, cal_msb); + snd_soc_component_write(component, WCD934X_CPE_FLL_USER_CTL_6, cal_lsb); + snd_soc_component_write(component, WCD934X_CPE_FLL_USER_CTL_7, cal_msb); /* FLL mode to follow power up sequence */ - snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE, + snd_soc_component_update_bits(component, WCD934X_CPE_FLL_FLL_MODE, 0x60, 0x00); /* HW controlled CPE FLL */ - snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE, + snd_soc_component_update_bits(component, WCD934X_CPE_FLL_FLL_MODE, 0x80, 0x80); /* Force on CPE FLL */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CFG, 0x04, 0x04); do { /* Time for FLL calibration to complete */ usleep_range(1000, 1100); - lock_det = snd_soc_read(codec, WCD934X_CPE_FLL_STATUS_3); + lock_det = snd_soc_component_read32( + component, WCD934X_CPE_FLL_STATUS_3); retry++; } while (!(lock_det & 0x01) && retry <= WCD_CPE_FLL_MAX_RETRIES); if (!(lock_det & 0x01)) { - dev_err(codec->dev, "%s: lock detect not set, 0x%02x\n", + dev_err(component->dev, "%s: lock detect not set, 0x%02x\n", __func__, lock_det); ret = -EIO; goto err_lock_det; } - snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE, + snd_soc_component_update_bits(component, WCD934X_CPE_FLL_FLL_MODE, 0x60, 0x20); - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CFG, 0x04, 0x00); return ret; err_lock_det: /* Undo the register settings */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CFG, 0x04, 0x00); - snd_soc_update_bits(codec, WCD934X_CPE_FLL_FLL_MODE, + snd_soc_component_update_bits(component, WCD934X_CPE_FLL_FLL_MODE, 0x80, 0x00); - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CTL, 0x02, 0x00); return ret; } static void wcd_cntl_config_cpar(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; u8 nom_lo, nom_hi, svs2_lo, svs2_hi; /* Configure CPAR */ @@ -425,25 +427,30 @@ static void wcd_cntl_config_cpar(struct wcd_dsp_cntl *cntl) svs2_lo = 0x3e; } - snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_NOM_LOW, nom_lo); - snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_NOM_HIGH, nom_hi); - snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW, svs2_lo); - snd_soc_write(codec, WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH, svs2_hi); + snd_soc_component_write(component, WCD934X_TEST_DEBUG_LVAL_NOM_LOW, + nom_lo); + snd_soc_component_write(component, WCD934X_TEST_DEBUG_LVAL_NOM_HIGH, + nom_hi); + snd_soc_component_write(component, WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_LOW, + svs2_lo); + snd_soc_component_write(component, + WCD934X_TEST_DEBUG_LVAL_SVS_SVS2_HIGH, + svs2_hi); - snd_soc_update_bits(codec, WCD934X_CPE_SS_PWR_CPEFLL_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_PWR_CPEFLL_CTL, 0x03, 0x03); } static int wcd_cntl_cpe_fll_ctrl(struct wcd_dsp_cntl *cntl, bool enable) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0; if (enable) { ret = wcd_cntl_cpe_fll_calibrate(cntl); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: cpe_fll_cal failed, err = %d\n", __func__, ret); goto done; @@ -452,18 +459,21 @@ static int wcd_cntl_cpe_fll_ctrl(struct wcd_dsp_cntl *cntl, wcd_cntl_config_cpar(cntl); /* Enable AHB CLK and CPE CLK*/ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPE_CTL, 0x05, 0x05); } else { /* Disable AHB CLK and CPE CLK */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPE_CTL, 0x05, 0x00); /* Reset the CPAR mode for CPE FLL */ - snd_soc_write(codec, WCD934X_CPE_FLL_FLL_MODE, 0x20); - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CFG, - 0x04, 0x00); - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, - 0x02, 0x00); + snd_soc_component_write(component, WCD934X_CPE_FLL_FLL_MODE, + 0x20); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_CPAR_CFG, + 0x04, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_CPAR_CTL, + 0x02, 0x00); } done: return ret; @@ -471,29 +481,30 @@ done: static int wcd_cntl_clocks_enable(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret; - WCD_CNTL_MUTEX_LOCK(codec, cntl->clk_mutex); + WCD_CNTL_MUTEX_LOCK(component, cntl->clk_mutex); /* Enable codec clock */ if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en) - ret = cntl->cdc_cb->cdc_clk_en(codec, true); + ret = cntl->cdc_cb->cdc_clk_en(component, true); else ret = -EINVAL; if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to enable cdc clk, err = %d\n", __func__, ret); goto done; } /* Pull CPAR out of reset */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x00); + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CTL, + 0x04, 0x00); /* Configure and Enable CPE FLL clock */ ret = wcd_cntl_cpe_fll_ctrl(cntl, true); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to enable cpe clk, err = %d\n", __func__, ret); goto err_cpe_clk; @@ -501,39 +512,42 @@ static int wcd_cntl_clocks_enable(struct wcd_dsp_cntl *cntl) cntl->is_clk_enabled = true; /* Ungate the CPR clock */ - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, 0x10, 0x00); + snd_soc_component_update_bits(component, WCD934X_CODEC_RPM_CLK_GATE, + 0x10, 0x00); done: - WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex); + WCD_CNTL_MUTEX_UNLOCK(component, cntl->clk_mutex); return ret; err_cpe_clk: if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en) - cntl->cdc_cb->cdc_clk_en(codec, false); + cntl->cdc_cb->cdc_clk_en(component, false); - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x04); - WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex); + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CTL, + 0x04, 0x04); + WCD_CNTL_MUTEX_UNLOCK(component, cntl->clk_mutex); return ret; } static int wcd_cntl_clocks_disable(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0; - WCD_CNTL_MUTEX_LOCK(codec, cntl->clk_mutex); + WCD_CNTL_MUTEX_LOCK(component, cntl->clk_mutex); if (!cntl->is_clk_enabled) { - dev_info(codec->dev, "%s: clocks already disabled\n", + dev_info(component->dev, "%s: clocks already disabled\n", __func__); goto done; } /* Gate the CPR clock */ - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, 0x10, 0x10); + snd_soc_component_update_bits(component, WCD934X_CODEC_RPM_CLK_GATE, + 0x10, 0x10); /* Disable CPE FLL clock */ ret = wcd_cntl_cpe_fll_ctrl(cntl, false); if (ret < 0) - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to disable cpe clk, err = %d\n", __func__, ret); @@ -542,35 +556,38 @@ static int wcd_cntl_clocks_disable(struct wcd_dsp_cntl *cntl) * the codec clock */ if (cntl->cdc_cb && cntl->cdc_cb->cdc_clk_en) - ret = cntl->cdc_cb->cdc_clk_en(codec, false); + ret = cntl->cdc_cb->cdc_clk_en(component, false); else ret = -EINVAL; cntl->is_clk_enabled = false; /* Put CPAR in reset */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x04, 0x04); + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPAR_CTL, + 0x04, 0x04); done: - WCD_CNTL_MUTEX_UNLOCK(codec, cntl->clk_mutex); + WCD_CNTL_MUTEX_UNLOCK(component, cntl->clk_mutex); return ret; } static void wcd_cntl_cpar_ctrl(struct wcd_dsp_cntl *cntl, bool enable) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; if (enable) - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x03); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x03); else - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_CPAR_CTL, 0x03, 0x00); } static int wcd_cntl_enable_memory(struct wcd_dsp_cntl *cntl, enum wcd_mem_type mem_type) { - struct snd_soc_codec *codec = cntl->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = cntl->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); int loop_cnt = 0; u8 status; int ret = 0; @@ -593,23 +610,26 @@ static int wcd_cntl_enable_memory(struct wcd_dsp_cntl *cntl, case WCD_MEM_TYPE_SWITCHABLE: - snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, - 0x04, 0x00); - snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_MEM_CTRL, - 0x80, 0x80); - snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, + 0x04, 0x00); + snd_soc_component_update_bits(component, + WCD934X_TEST_DEBUG_MEM_CTRL, + 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, + 0x01, 0x01); do { loop_cnt++; /* Time to enable the power domain for memory */ usleep_range(100, 150); - status = snd_soc_read(codec, + status = snd_soc_component_read32(component, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL); } while ((status & 0x02) != 0x02 && loop_cnt != WCD_MEM_ENABLE_MAX_RETRIES); if ((status & 0x02) != 0x02) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: power domain not enabled, status = 0x%02x\n", __func__, status); ret = -EIO; @@ -626,20 +646,23 @@ static int wcd_cntl_enable_memory(struct wcd_dsp_cntl *cntl, ARRAY_SIZE(mem_enable_values), mem_enable_values); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN, - 0x05); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN, + 0x05); break; default: - dev_err(cntl->codec->dev, "%s: Invalid mem_type %d\n", + dev_err(cntl->component->dev, "%s: Invalid mem_type %d\n", __func__, mem_type); ret = -EINVAL; break; } done: /* Make sure Deep sleep of memories is enabled for all banks */ - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F); return ret; } @@ -647,66 +670,76 @@ done: static void wcd_cntl_disable_memory(struct wcd_dsp_cntl *cntl, enum wcd_mem_type mem_type) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; u8 val; switch (mem_type) { case WCD_MEM_TYPE_ALWAYS_ON: - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1, - 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0, - 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_1, + 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_0, + 0xFF); break; case WCD_MEM_TYPE_SWITCHABLE: - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3, - 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2, - 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN, - 0x07); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_3, + 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_SHUTDOWN_2, + 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_DRAM1_SHUTDOWN, + 0x07); - snd_soc_update_bits(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, - 0x01, 0x00); - val = snd_soc_read(codec, WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL, + 0x01, 0x00); + val = snd_soc_component_read32(component, + WCD934X_CPE_SS_SOC_SW_COLLAPSE_CTL); if (val & 0x02) - dev_err(codec->dev, + dev_err(component->dev, "%s: Disable switchable failed, val = 0x%02x", __func__, val); - snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_MEM_CTRL, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD934X_TEST_DEBUG_MEM_CTRL, + 0x80, 0x00); break; default: - dev_err(cntl->codec->dev, "%s: Invalid mem_type %d\n", + dev_err(cntl->component->dev, "%s: Invalid mem_type %d\n", __func__, mem_type); break; } - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_0, 0xFF); + snd_soc_component_write(component, + WCD934X_CPE_SS_PWR_CPE_SYSMEM_DEEPSLP_1, 0x0F); } static void wcd_cntl_do_shutdown(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; /* Disable WDOG */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_WDOG_CFG, 0x3F, 0x01); /* Put WDSP in reset state */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPE_CTL, 0x02, 0x00); /* If DSP transitions from boot to shutdown, then vote for SVS */ if (cntl->is_wdsp_booted) - cntl->cdc_cb->cdc_vote_svs(codec, true); + cntl->cdc_cb->cdc_vote_svs(component, true); cntl->is_wdsp_booted = false; } static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0; /* @@ -715,21 +748,25 @@ static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl) * will be required for debugging the DSP firmware. */ if (cntl->debug_mode) { - snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG, - 0x3F, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_WDOG_CFG, + 0x3F, 0x01); } else { - snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG, - 0x3F, 0x21); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_WDOG_CFG, + 0x3F, 0x21); } /* Make sure all the error interrupts are cleared */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B, 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0A, + 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_CLEAR_0B, + 0xFF); reinit_completion(&cntl->boot_complete); /* Remove WDSP out of reset */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_CPE_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_CPE_CTL, 0x02, 0x02); /* @@ -738,7 +775,8 @@ static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl) */ if (cntl->debug_mode) { wait_for_completion(&cntl->boot_complete); - dev_dbg(codec->dev, "%s: WDSP booted in dbg mode\n", __func__); + dev_dbg(component->dev, "%s: WDSP booted in dbg mode\n", + __func__); cntl->is_wdsp_booted = true; goto done; } @@ -747,7 +785,7 @@ static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl) ret = wait_for_completion_timeout(&cntl->boot_complete, msecs_to_jiffies(WCD_DSP_BOOT_TIMEOUT_MS)); if (!ret) { - dev_err(codec->dev, "%s: WDSP boot timed out\n", + dev_err(component->dev, "%s: WDSP boot timed out\n", __func__); if (cntl->dbg_dmp_enable) wcd_cntl_collect_debug_dumps(cntl, true); @@ -761,16 +799,16 @@ static int wcd_cntl_do_boot(struct wcd_dsp_cntl *cntl) ret = 0; } - dev_dbg(codec->dev, "%s: WDSP booted in normal mode\n", __func__); + dev_dbg(component->dev, "%s: WDSP booted in normal mode\n", __func__); cntl->is_wdsp_booted = true; /* Enable WDOG */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_WDOG_CFG, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_WDOG_CFG, 0x10, 0x10); done: /* If dsp booted up, then remove vote on SVS */ if (cntl->is_wdsp_booted) - cntl->cdc_cb->cdc_vote_svs(codec, false); + cntl->cdc_cb->cdc_vote_svs(component, false); return ret; err_boot: @@ -794,7 +832,7 @@ static irqreturn_t wcd_cntl_ipc_irq(int irq, void *data) ret = -EINVAL; if (ret < 0) - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: Failed to handle irq %d\n", __func__, irq); return IRQ_HANDLED; @@ -803,19 +841,21 @@ static irqreturn_t wcd_cntl_ipc_irq(int irq, void *data) static irqreturn_t wcd_cntl_err_irq(int irq, void *data) { struct wcd_dsp_cntl *cntl = data; - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; struct wdsp_err_signal_arg arg; u16 status = 0; u8 reg_val; int rc, ret = 0; - reg_val = snd_soc_read(codec, WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A); + reg_val = snd_soc_component_read32(component, + WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0A); status = status | reg_val; - reg_val = snd_soc_read(codec, WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B); + reg_val = snd_soc_component_read32(component, + WCD934X_CPE_SS_SS_ERROR_INT_STATUS_0B); status = status | (reg_val << 8); - dev_info(codec->dev, "%s: error interrupt status = 0x%x\n", + dev_info(component->dev, "%s: error interrupt status = 0x%x\n", __func__, status); if ((status & cntl->irqs.fatal_irqs) && @@ -832,14 +872,14 @@ static irqreturn_t wcd_cntl_err_irq(int irq, void *data) ret = cntl->m_ops->signal_handler(cntl->m_dev, WDSP_ERR_INTR, &arg); if (ret < 0) - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: Failed to handle fatal irq 0x%x\n", __func__, status & cntl->irqs.fatal_irqs); wcd_cntl_change_online_state(cntl, 0); if (rc == 0) WCD_CNTL_CLR_ERR_IRQ_FLAG(cntl); } else { - dev_err(cntl->codec->dev, "%s: Invalid signal_handler\n", + dev_err(cntl->component->dev, "%s: Invalid signal_handler\n", __func__); } @@ -850,7 +890,7 @@ static int wcd_control_handler(struct device *dev, void *priv_data, enum wdsp_event_type event, void *data) { struct wcd_dsp_cntl *cntl = priv_data; - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0; switch (event) { @@ -864,7 +904,7 @@ static int wcd_control_handler(struct device *dev, void *priv_data, /* Disable all the clocks */ ret = wcd_cntl_clocks_disable(cntl); if (ret < 0) - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to disable clocks, err = %d\n", __func__, ret); @@ -879,7 +919,7 @@ static int wcd_control_handler(struct device *dev, void *priv_data, /* Enable all the clocks */ ret = wcd_cntl_clocks_enable(cntl); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to enable clocks, err = %d\n", __func__, ret); goto done; @@ -898,7 +938,7 @@ static int wcd_control_handler(struct device *dev, void *priv_data, ret = wcd_cntl_do_boot(cntl); if (ret < 0) - dev_err(codec->dev, + dev_err(component->dev, "%s: WDSP boot failed, err = %d\n", __func__, ret); break; @@ -910,7 +950,7 @@ static int wcd_control_handler(struct device *dev, void *priv_data, break; default: - dev_dbg(codec->dev, "%s: unhandled event %d\n", + dev_dbg(component->dev, "%s: unhandled event %d\n", __func__, event); } @@ -920,13 +960,13 @@ done: static int wcd_cntl_sysfs_init(char *dir, struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; int ret = 0; ret = kobject_init_and_add(&cntl->wcd_kobj, &wcd_cntl_ktype, kernel_kobj, dir); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to add kobject %s, err = %d\n", __func__, dir, ret); goto done; @@ -934,7 +974,7 @@ static int wcd_cntl_sysfs_init(char *dir, struct wcd_dsp_cntl *cntl) ret = sysfs_create_file(&cntl->wcd_kobj, &cntl_attr_boot.attr); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to add wdsp_boot sysfs entry to %s\n", __func__, dir); goto fail_create_file; @@ -956,11 +996,11 @@ static void wcd_cntl_sysfs_remove(struct wcd_dsp_cntl *cntl) static void wcd_cntl_debugfs_init(char *dir, struct wcd_dsp_cntl *cntl) { - struct snd_soc_codec *codec = cntl->codec; + struct snd_soc_component *component = cntl->component; cntl->entry = debugfs_create_dir(dir, NULL); if (IS_ERR_OR_NULL(dir)) { - dev_err(codec->dev, "%s debugfs_create_dir failed for %s\n", + dev_err(component->dev, "%s debugfs_create_dir failed for %s\n", __func__, dir); goto done; } @@ -987,7 +1027,7 @@ static int wcd_miscdev_release(struct inode *inode, struct file *filep) struct wcd_dsp_cntl, miscdev); if (!cntl->m_dev || !cntl->m_ops || !cntl->m_ops->vote_for_dsp) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: DSP not ready to boot\n", __func__); return -EINVAL; } @@ -1020,7 +1060,7 @@ static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf, ret = copy_from_user(val, ubuf, count); if (ret < 0) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: copy_from_user failed, err = %d\n", __func__, ret); ret = -EFAULT; @@ -1032,7 +1072,7 @@ static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf, vote = true; } else if (val[0] == '0') { if (cntl->boot_reqs == 0) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: WDSP already disabled\n", __func__); ret = -EINVAL; @@ -1042,7 +1082,7 @@ static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf, vote = false; } else if (!strcmp(val, "DEBUG_DUMP")) { if (cntl->dbg_dmp_enable) { - dev_dbg(cntl->codec->dev, + dev_dbg(cntl->component->dev, "%s: Collect dumps for debug use\n", __func__); wcd_cntl_collect_debug_dumps(cntl, false); } @@ -1052,13 +1092,13 @@ static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf, */ goto done; } else { - dev_err(cntl->codec->dev, "%s: Invalid value %s\n", + dev_err(cntl->component->dev, "%s: Invalid value %s\n", __func__, val); ret = -EINVAL; goto done; } - dev_dbg(cntl->codec->dev, + dev_dbg(cntl->component->dev, "%s: booted = %s, ref_cnt = %d, vote = %s\n", __func__, cntl->is_wdsp_booted ? "true" : "false", cntl->boot_reqs, vote ? "true" : "false"); @@ -1087,7 +1127,7 @@ static int wcd_cntl_miscdev_create(struct wcd_dsp_cntl *cntl) cntl->miscdev.minor = MISC_DYNAMIC_MINOR; cntl->miscdev.name = cntl->miscdev_name; cntl->miscdev.fops = &wcd_miscdev_fops; - cntl->miscdev.parent = cntl->codec->dev; + cntl->miscdev.parent = cntl->component->dev; return misc_register(&cntl->miscdev); } @@ -1100,8 +1140,8 @@ static void wcd_cntl_miscdev_destroy(struct wcd_dsp_cntl *cntl) static int wcd_control_init(struct device *dev, void *priv_data) { struct wcd_dsp_cntl *cntl = priv_data; - struct snd_soc_codec *codec = cntl->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = cntl->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; int ret; bool err_irq_requested = false; @@ -1111,16 +1151,16 @@ static int wcd_control_init(struct device *dev, void *priv_data) wcd_cntl_ipc_irq, "CPE IPC1", cntl); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to request cpe ipc irq, err = %d\n", __func__, ret); goto done; } /* Unmask the fatal irqs */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, ~(cntl->irqs.fatal_irqs & 0xFF)); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, ~((cntl->irqs.fatal_irqs >> 8) & 0xFF)); /* @@ -1130,7 +1170,7 @@ static int wcd_control_init(struct device *dev, void *priv_data) */ if (wcd9xxx_request_irq(core_res, cntl->irqs.cpe_err_irq, wcd_cntl_err_irq, "CPE ERR", cntl)) - dev_info(codec->dev, "%s: Failed request_irq(cpe_err_irq)", + dev_info(component->dev, "%s: Failed request_irq(cpe_err_irq)", __func__); else err_irq_requested = true; @@ -1139,7 +1179,7 @@ static int wcd_control_init(struct device *dev, void *priv_data) /* Enable all the clocks */ ret = wcd_cntl_clocks_enable(cntl); if (ret < 0) { - dev_err(codec->dev, "%s: Failed to enable clocks, err = %d\n", + dev_err(component->dev, "%s: Failed to enable clocks, err = %d\n", __func__, ret); goto err_clk_enable; } @@ -1149,8 +1189,10 @@ static int wcd_control_init(struct device *dev, void *priv_data) err_clk_enable: /* Mask all error interrupts */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, + 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, + 0xFF); /* Free the irq's requested */ wcd9xxx_free_irq(core_res, cntl->irqs.cpe_ipc1_irq, cntl); @@ -1164,16 +1206,18 @@ done: static int wcd_control_deinit(struct device *dev, void *priv_data) { struct wcd_dsp_cntl *cntl = priv_data; - struct snd_soc_codec *codec = cntl->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = cntl->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; wcd_cntl_clocks_disable(cntl); wcd_cntl_cpar_ctrl(cntl, false); /* Mask all error interrupts */ - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, 0xFF); - snd_soc_write(codec, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0A, + 0xFF); + snd_soc_component_write(component, WCD934X_CPE_SS_SS_ERROR_INT_MASK_0B, + 0xFF); /* Free the irq's requested */ wcd9xxx_free_irq(core_res, cntl->irqs.cpe_err_irq, cntl); @@ -1193,7 +1237,7 @@ static int wcd_ctrl_component_bind(struct device *dev, void *data) { struct wcd_dsp_cntl *cntl; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct snd_card *card; struct snd_info_entry *entry; char proc_name[WCD_PROCFS_ENTRY_MAX_LEN]; @@ -1247,8 +1291,8 @@ static int wcd_ctrl_component_bind(struct device *dev, wcd_cntl_debugfs_init(wcd_cntl_dir_name, cntl); - codec = cntl->codec; - card = codec->component.card->snd_card; + component = cntl->component; + card = component->card->snd_card; snprintf(proc_name, WCD_PROCFS_ENTRY_MAX_LEN, "%s%d%s", "cpe", cntl->dsp_instance, "_state"); entry = snd_info_create_card_entry(card, proc_name, card->proc_root); @@ -1335,7 +1379,7 @@ int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event) } if (!cntl->m_dev || !cntl->m_ops || !cntl->m_ops->signal_handler) { - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: Invalid signal_handler callback\n", __func__); return -EINVAL; } @@ -1346,7 +1390,7 @@ int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event) WDSP_CDC_DOWN_SIGNAL, NULL); if (ret < 0) - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: WDSP_CDC_DOWN_SIGNAL failed, err = %d\n", __func__, ret); wcd_cntl_change_online_state(cntl, 0); @@ -1356,12 +1400,12 @@ int wcd_dsp_ssr_event(struct wcd_dsp_cntl *cntl, enum cdc_ssr_event event) WDSP_CDC_UP_SIGNAL, NULL); if (ret < 0) - dev_err(cntl->codec->dev, + dev_err(cntl->component->dev, "%s: WDSP_CDC_UP_SIGNAL failed, err = %d\n", __func__, ret); break; default: - dev_err(cntl->codec->dev, "%s: Invalid event %d\n", + dev_err(cntl->component->dev, "%s: Invalid event %d\n", __func__, event); ret = -EINVAL; break; @@ -1373,23 +1417,23 @@ EXPORT_SYMBOL(wcd_dsp_ssr_event); /* * wcd_dsp_cntl_init: Initialize the wcd-dsp control - * @codec: pointer to the codec handle + * @component: pointer to the codec component handle * @params: Parameters required to initialize wcd-dsp control * * This API is expected to be invoked by the codec driver and * provide information essential for the wcd dsp control to * configure and initialize the dsp */ -void wcd_dsp_cntl_init(struct snd_soc_codec *codec, +void wcd_dsp_cntl_init(struct snd_soc_component *component, struct wcd_dsp_params *params, struct wcd_dsp_cntl **cntl) { struct wcd_dsp_cntl *control; int ret; - if (!codec || !params) { + if (!component || !params) { pr_err("%s: Invalid handle to %s\n", __func__, - (!codec) ? "codec" : "params"); + (!component) ? "component" : "params"); *cntl = NULL; return; } @@ -1402,7 +1446,7 @@ void wcd_dsp_cntl_init(struct snd_soc_codec *codec, if (!params->cb || !params->cb->cdc_clk_en || !params->cb->cdc_vote_svs) { - dev_err(codec->dev, + dev_err(component->dev, "%s: clk_en and vote_svs callbacks must be provided\n", __func__); return; @@ -1412,7 +1456,7 @@ void wcd_dsp_cntl_init(struct snd_soc_codec *codec, if (!(control)) return; - control->codec = codec; + control->component = component; control->clk_rate = params->clk_rate; control->cdc_cb = params->cb; control->dsp_instance = params->dsp_instance; @@ -1428,7 +1472,7 @@ void wcd_dsp_cntl_init(struct snd_soc_codec *codec, * Vote for SVS now, the vote will be removed only * after DSP is booted up. */ - control->cdc_cb->cdc_vote_svs(codec, true); + control->cdc_cb->cdc_vote_svs(component, true); /* * If this is the last component needed by master to be ready, @@ -1437,9 +1481,9 @@ void wcd_dsp_cntl_init(struct snd_soc_codec *codec, * so that we can access it during this component's bind call. */ *cntl = control; - ret = component_add(codec->dev, &wcd_ctrl_component_ops); + ret = component_add(component->dev, &wcd_ctrl_component_ops); if (ret) { - dev_err(codec->dev, "%s: component_add failed, err = %d\n", + dev_err(component->dev, "%s: component_add failed, err = %d\n", __func__, ret); kfree(*cntl); *cntl = NULL; @@ -1457,12 +1501,12 @@ EXPORT_SYMBOL(wcd_dsp_cntl_init); void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl) { struct wcd_dsp_cntl *control = *cntl; - struct snd_soc_codec *codec; + struct snd_soc_component *component; /* If control is NULL, there is nothing to de-initialize */ if (!control) return; - codec = control->codec; + component = control->component; /* * Calling shutdown will cleanup all register states, @@ -1472,7 +1516,7 @@ void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl) wcd_cntl_disable_memory(control, WCD_MEM_TYPE_SWITCHABLE); wcd_cntl_disable_memory(control, WCD_MEM_TYPE_ALWAYS_ON); - component_del(codec->dev, &wcd_ctrl_component_ops); + component_del(component->dev, &wcd_ctrl_component_ops); mutex_destroy(&control->clk_mutex); mutex_destroy(&control->ssr_mutex); diff --git a/asoc/codecs/wcd934x/wcd934x-dsp-cntl.h b/asoc/codecs/wcd934x/wcd934x-dsp-cntl.h index 8035176fe1..a4b18a3cba 100644 --- a/asoc/codecs/wcd934x/wcd934x-dsp-cntl.h +++ b/asoc/codecs/wcd934x/wcd934x-dsp-cntl.h @@ -17,9 +17,9 @@ enum cdc_ssr_event { struct wcd_dsp_cdc_cb { /* Callback to enable codec clock */ - int (*cdc_clk_en)(struct snd_soc_codec *, bool); + int (*cdc_clk_en)(struct snd_soc_component *component, bool enable); /* Callback to vote and unvote for SVS2 mode */ - void (*cdc_vote_svs)(struct snd_soc_codec *, bool); + void (*cdc_vote_svs)(struct snd_soc_component *component, bool enable); }; struct wcd_dsp_irq_info { @@ -61,7 +61,7 @@ struct wdsp_ssr_entry { struct wcd_dsp_cntl { /* Handle to codec */ - struct snd_soc_codec *codec; + struct snd_soc_component *component; /* Clk rate of the codec clock */ u32 clk_rate; @@ -109,7 +109,7 @@ struct wcd_dsp_cntl { #endif }; -void wcd_dsp_cntl_init(struct snd_soc_codec *codec, +void wcd_dsp_cntl_init(struct snd_soc_component *component, struct wcd_dsp_params *params, struct wcd_dsp_cntl **cntl); void wcd_dsp_cntl_deinit(struct wcd_dsp_cntl **cntl); diff --git a/asoc/codecs/wcd934x/wcd934x-mbhc.c b/asoc/codecs/wcd934x/wcd934x-mbhc.c index f23dcf1e46..7a91bf3482 100644 --- a/asoc/codecs/wcd934x/wcd934x-mbhc.c +++ b/asoc/codecs/wcd934x/wcd934x-mbhc.c @@ -169,21 +169,21 @@ struct tavil_mbhc_zdet_param { u16 btn7; }; -static int tavil_mbhc_request_irq(struct snd_soc_codec *codec, +static int tavil_mbhc_request_irq(struct snd_soc_component *component, int irq, irq_handler_t handler, const char *name, void *data) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; return wcd9xxx_request_irq(core_res, irq, handler, name, data); } -static void tavil_mbhc_irq_control(struct snd_soc_codec *codec, +static void tavil_mbhc_irq_control(struct snd_soc_component *component, int irq, bool enable) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; if (enable) @@ -192,10 +192,10 @@ static void tavil_mbhc_irq_control(struct snd_soc_codec *codec, wcd9xxx_disable_irq(core_res, irq); } -static int tavil_mbhc_free_irq(struct snd_soc_codec *codec, +static int tavil_mbhc_free_irq(struct snd_soc_component *component, int irq, void *data) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -203,27 +203,28 @@ static int tavil_mbhc_free_irq(struct snd_soc_codec *codec, return 0; } -static void tavil_mbhc_clk_setup(struct snd_soc_codec *codec, +static void tavil_mbhc_clk_setup(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1, 0x80, 0x80); else - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1, 0x80, 0x00); } -static int tavil_mbhc_btn_to_num(struct snd_soc_codec *codec) +static int tavil_mbhc_btn_to_num(struct snd_soc_component *component) { - return snd_soc_read(codec, WCD934X_ANA_MBHC_RESULT_3) & 0x7; + return snd_soc_component_read32(component, WCD934X_ANA_MBHC_RESULT_3) & + 0x7; } static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc, bool turn_on) { struct wcd934x_mbhc *wcd934x_mbhc; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; struct wcd934x_on_demand_supply *supply; int ret = 0; @@ -231,20 +232,21 @@ static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc, supply = &wcd934x_mbhc->on_demand_list[WCD934X_ON_DEMAND_MICBIAS]; if (!supply->supply) { - dev_dbg(codec->dev, "%s: warning supply not present ond for %s\n", + dev_dbg(component->dev, "%s: warning supply not present ond for %s\n", __func__, "onDemand Micbias"); return ret; } - dev_dbg(codec->dev, "%s turn_on: %d count: %d\n", __func__, turn_on, + dev_dbg(component->dev, "%s turn_on: %d count: %d\n", __func__, turn_on, supply->ondemand_supply_count); if (turn_on) { if (!(supply->ondemand_supply_count)) { ret = snd_soc_dapm_force_enable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), "MICBIAS_REGULATOR"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync( + snd_soc_component_get_dapm(component)); } supply->ondemand_supply_count++; } else { @@ -252,34 +254,34 @@ static int tavil_enable_ext_mb_source(struct wcd_mbhc *mbhc, supply->ondemand_supply_count--; if (!(supply->ondemand_supply_count)) { ret = snd_soc_dapm_disable_pin( - snd_soc_codec_get_dapm(codec), + snd_soc_component_get_dapm(component), "MICBIAS_REGULATOR"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); } } if (ret) - dev_err(codec->dev, "%s: Failed to %s external micbias source\n", + dev_err(component->dev, "%s: Failed to %s external micbias source\n", __func__, turn_on ? "enable" : "disabled"); else - dev_dbg(codec->dev, "%s: %s external micbias source\n", + dev_dbg(component->dev, "%s: %s external micbias source\n", __func__, turn_on ? "Enabled" : "Disabled"); return ret; } -static void tavil_mbhc_mbhc_bias_control(struct snd_soc_codec *codec, +static void tavil_mbhc_mbhc_bias_control(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_ELECT, 0x01, 0x01); else - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_ELECT, 0x01, 0x00); } -static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec, +static void tavil_mbhc_program_btn_thr(struct snd_soc_component *component, s16 *btn_low, s16 *btn_high, int num_btn, bool is_micbias) { @@ -287,7 +289,7 @@ static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec, int vth; if (num_btn > WCD_MBHC_DEF_BUTTONS) { - dev_err(codec->dev, "%s: invalid number of buttons: %d\n", + dev_err(component->dev, "%s: invalid number of buttons: %d\n", __func__, num_btn); return; } @@ -299,17 +301,18 @@ static void tavil_mbhc_program_btn_thr(struct snd_soc_codec *codec, */ for (i = 0; i < num_btn; i++) { vth = ((btn_high[i] * 2) / 25) & 0x3F; - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN0 + i, - 0xFC, vth << 2); - dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n", + snd_soc_component_update_bits(component, + WCD934X_ANA_MBHC_BTN0 + i, + 0xFC, vth << 2); + dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n", __func__, i, btn_high[i], vth); } } static bool tavil_mbhc_lock_sleep(struct wcd_mbhc *mbhc, bool lock) { - struct snd_soc_codec *codec = mbhc->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = mbhc->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; bool ret = 0; @@ -343,20 +346,22 @@ static bool tavil_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) u8 val; if (micb_num == MIC_BIAS_2) { - val = (snd_soc_read(mbhc->codec, WCD934X_ANA_MICB2) >> 6); + val = (snd_soc_component_read32( + mbhc->component, WCD934X_ANA_MICB2) >> 6); if (val == 0x01) return true; } return false; } -static bool tavil_mbhc_hph_pa_on_status(struct snd_soc_codec *codec) +static bool tavil_mbhc_hph_pa_on_status(struct snd_soc_component *component) { - return (snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0) ? true : false; + return (snd_soc_component_read32(component, WCD934X_ANA_HPH) & 0xC0) ? + true : false; } static void tavil_mbhc_hph_l_pull_up_control( - struct snd_soc_codec *codec, + struct snd_soc_component *component, enum mbhc_hs_pullup_iref pull_up_cur) { /* Default pull up current to 2uA */ @@ -364,14 +369,15 @@ static void tavil_mbhc_hph_l_pull_up_control( pull_up_cur == I_DEFAULT) pull_up_cur = I_2P0_UA; - dev_dbg(codec->dev, "%s: HS pull up current:%d\n", + dev_dbg(component->dev, "%s: HS pull up current:%d\n", __func__, pull_up_cur); - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_PLUG_DETECT_CTL, - 0xC0, pull_up_cur << 6); + snd_soc_component_update_bits(component, + WCD934X_MBHC_NEW_PLUG_DETECT_CTL, + 0xC0, pull_up_cur << 6); } -static int tavil_mbhc_request_micbias(struct snd_soc_codec *codec, +static int tavil_mbhc_request_micbias(struct snd_soc_component *component, int micb_num, int req) { int ret; @@ -381,32 +387,32 @@ static int tavil_mbhc_request_micbias(struct snd_soc_codec *codec, * is vote to enable mclk */ if (req == MICB_ENABLE) - tavil_cdc_mclk_enable(codec, true); + tavil_cdc_mclk_enable(component, true); - ret = tavil_micbias_control(codec, micb_num, req, false); + ret = tavil_micbias_control(component, micb_num, req, false); /* * Release vote for mclk while requesting for * micbias disable */ if (req == MICB_DISABLE) - tavil_cdc_mclk_enable(codec, false); + tavil_cdc_mclk_enable(component, false); return ret; } -static void tavil_mbhc_micb_ramp_control(struct snd_soc_codec *codec, +static void tavil_mbhc_micb_ramp_control(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP, 0x1C, 0x0C); - snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP, 0x80, 0x80); } else { - snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP, 0x80, 0x00); - snd_soc_update_bits(codec, WCD934X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD934X_ANA_MICB2_RAMP, 0x1C, 0x00); } } @@ -416,26 +422,27 @@ static struct firmware_cal *tavil_get_hwdep_fw_cal(struct wcd_mbhc *mbhc, { struct wcd934x_mbhc *wcd934x_mbhc; struct firmware_cal *hwdep_cal; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; wcd934x_mbhc = container_of(mbhc, struct wcd934x_mbhc, wcd_mbhc); - if (!codec) { - pr_err("%s: NULL codec pointer\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer\n", __func__); return NULL; } hwdep_cal = wcdcal_get_fw_cal(wcd934x_mbhc->fw_data, type); if (!hwdep_cal) - dev_err(codec->dev, "%s: cal not sent by %d\n", + dev_err(component->dev, "%s: cal not sent by %d\n", __func__, type); return hwdep_cal; } -static int tavil_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, - int micb_num, bool req_en) +static int tavil_mbhc_micb_ctrl_threshold_mic( + struct snd_soc_component *component, + int micb_num, bool req_en) { - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); int rc, micb_mv; if (micb_num != MIC_BIAS_2) @@ -451,7 +458,7 @@ static int tavil_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv; - rc = tavil_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2); + rc = tavil_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); return rc; } @@ -512,25 +519,25 @@ ramp_down: } } -static void tavil_mbhc_zdet_ramp(struct snd_soc_codec *codec, +static void tavil_mbhc_zdet_ramp(struct snd_soc_component *component, struct tavil_mbhc_zdet_param *zdet_param, int32_t *zl, int32_t *zr, s16 *d1_a) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); int32_t zdet = 0; - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x70, - zdet_param->ldo_ctl << 4); - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN5, 0xFC, - zdet_param->btn5); - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN6, 0xFC, - zdet_param->btn6); - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_BTN7, 0xFC, - zdet_param->btn7); - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, 0x0F, - zdet_param->noff); - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_ZDET_RAMP_CTL, 0x0F, - zdet_param->nshift); + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL, + 0x70, zdet_param->ldo_ctl << 4); + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN5, 0xFC, + zdet_param->btn5); + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN6, 0xFC, + zdet_param->btn6); + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_BTN7, 0xFC, + zdet_param->btn7); + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL, + 0x0F, zdet_param->noff); + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_ZDET_RAMP_CTL, + 0x0F, zdet_param->nshift); if (!zl) goto z_right; @@ -560,17 +567,17 @@ z_right: *zr = zdet; } -static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, +static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_component *component, int32_t *z_val, int flag_l_r) { s16 q1; int q1_cal; if (*z_val < (TAVIL_ZDET_VAL_400/1000)) - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT1 + (2 * flag_l_r)); else - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD934X_CHIP_TIER_CTRL_EFUSE_VAL_OUT2 + (2 * flag_l_r)); if (q1 & 0x80) q1_cal = (10000 - ((q1 & 0x7F) * 25)); @@ -583,8 +590,8 @@ static inline void tavil_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { - struct snd_soc_codec *codec = mbhc->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = mbhc->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); s16 reg0, reg1, reg2, reg3, reg4; int32_t z1L, z1R, z1Ls; int zMono, z_diff1, z_diff2; @@ -606,13 +613,15 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); - reg0 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN5); - reg1 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN6); - reg2 = snd_soc_read(codec, WCD934X_ANA_MBHC_BTN7); - reg3 = snd_soc_read(codec, WCD934X_MBHC_CTL_CLK); - reg4 = snd_soc_read(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL); + reg0 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN5); + reg1 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN6); + reg2 = snd_soc_component_read32(component, WCD934X_ANA_MBHC_BTN7); + reg3 = snd_soc_component_read32(component, WCD934X_MBHC_CTL_CLK); + reg4 = snd_soc_component_read32(component, + WCD934X_MBHC_NEW_ZDET_ANA_CTL); - if (snd_soc_read(codec, WCD934X_ANA_MBHC_ELECT) & 0x80) { + if (snd_soc_component_read32(component, WCD934X_ANA_MBHC_ELECT) & + 0x80) { is_fsm_disable = true; regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x00); @@ -630,7 +639,7 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; - tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + tavil_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); if (!TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1L)) goto left_ch_impedance; @@ -646,7 +655,7 @@ static void tavil_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + tavil_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); left_ch_impedance: if ((z1L == TAVIL_ZDET_FLOATING_IMPEDANCE) || @@ -656,13 +665,13 @@ left_ch_impedance: d1 = d1_a[1]; } else { *zl = z1L/1000; - tavil_wcd_mbhc_qfuse_cal(codec, zl, 0); + tavil_wcd_mbhc_qfuse_cal(component, zl, 0); } - dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", __func__, *zl); /* Start of right impedance ramp and calculation */ - tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + tavil_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); if (TAVIL_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) { if (((z1R > TAVIL_ZDET_VAL_1200) && (zdet_param_ptr->noff == 0x6)) || @@ -680,7 +689,7 @@ left_ch_impedance: zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - tavil_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + tavil_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); } right_ch_impedance: if ((z1R == TAVIL_ZDET_FLOATING_IMPEDANCE) || @@ -688,15 +697,15 @@ right_ch_impedance: *zr = TAVIL_ZDET_FLOATING_IMPEDANCE; } else { *zr = z1R/1000; - tavil_wcd_mbhc_qfuse_cal(codec, zr, 1); + tavil_wcd_mbhc_qfuse_cal(component, zr, 1); } - dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", __func__, *zr); /* Mono/stereo detection */ if ((*zl == TAVIL_ZDET_FLOATING_IMPEDANCE) && (*zr == TAVIL_ZDET_FLOATING_IMPEDANCE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: plug type is invalid or extension cable\n", __func__); goto zdet_complete; @@ -705,40 +714,46 @@ right_ch_impedance: (*zr == TAVIL_ZDET_FLOATING_IMPEDANCE) || ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) || ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Mono plug type with one ch floating or shorted to GND\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; goto zdet_complete; } - snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x02); - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x01); + snd_soc_component_update_bits(component, WCD934X_HPH_R_ATEST, + 0x02, 0x02); + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, + 0x40, 0x01); if (*zl < (TAVIL_ZDET_VAL_32/1000)) - tavil_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1); + tavil_mbhc_zdet_ramp(component, &zdet_param[0], + &z1Ls, NULL, d1); else - tavil_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1); - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD934X_HPH_R_ATEST, 0x02, 0x00); + tavil_mbhc_zdet_ramp(component, &zdet_param[1], + &z1Ls, NULL, d1); + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, + 0x40, 0x00); + snd_soc_component_update_bits(component, WCD934X_HPH_R_ATEST, + 0x02, 0x00); z1Ls /= 1000; - tavil_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0); + tavil_wcd_mbhc_qfuse_cal(component, &z1Ls, 0); /* Parallel of left Z and 9 ohm pull down resistor */ zMono = ((*zl) * 9) / ((*zl) + 9); z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) { - dev_dbg(codec->dev, "%s: stereo plug type detected\n", + dev_dbg(component->dev, "%s: stereo plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_STEREO; } else { - dev_dbg(codec->dev, "%s: MONO plug type detected\n", + dev_dbg(component->dev, "%s: MONO plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; } zdet_complete: - snd_soc_write(codec, WCD934X_ANA_MBHC_BTN5, reg0); - snd_soc_write(codec, WCD934X_ANA_MBHC_BTN6, reg1); - snd_soc_write(codec, WCD934X_ANA_MBHC_BTN7, reg2); + snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN5, reg0); + snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN6, reg1); + snd_soc_component_write(component, WCD934X_ANA_MBHC_BTN7, reg2); /* Turn on 100k pull down on HPHL */ regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_MECH, 0x01, 0x01); @@ -748,96 +763,99 @@ zdet_complete: regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_MECH, 0x80, 0x80); - snd_soc_write(codec, WCD934X_MBHC_NEW_ZDET_ANA_CTL, reg4); - snd_soc_write(codec, WCD934X_MBHC_CTL_CLK, reg3); + snd_soc_component_write(component, WCD934X_MBHC_NEW_ZDET_ANA_CTL, reg4); + snd_soc_component_write(component, WCD934X_MBHC_CTL_CLK, reg3); if (is_fsm_disable) regmap_update_bits(wcd9xxx->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x80); } -static void tavil_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable) +static void tavil_mbhc_gnd_det_ctrl(struct snd_soc_component *component, + bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH, 0x02, 0x02); - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH, 0x40, 0x40); } else { - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH, 0x40, 0x00); - snd_soc_update_bits(codec, WCD934X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD934X_ANA_MBHC_MECH, 0x02, 0x00); } } -static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, +static void tavil_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, 0x40, 0x40); - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, 0x10, 0x10); } else { - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD934X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD934X_HPH_PA_CTL2, 0x10, 0x00); } } static void tavil_mbhc_moisture_config(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; if ((mbhc->moist_rref == R_OFF) || (mbhc->mbhc_cfg->enable_usbc_analog)) { - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); return; } /* Donot enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { - dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", + dev_dbg(component->dev, "%s: disable moisture detection for NC\n", __func__); - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); return; } - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_2, 0x0C, mbhc->moist_rref << 2); } static bool tavil_hph_register_recovery(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct snd_soc_component *component = mbhc->component; + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); if (!wcd934x_mbhc) return false; wcd934x_mbhc->is_hph_recover = false; - snd_soc_dapm_force_enable_pin(snd_soc_codec_get_dapm(codec), + snd_soc_dapm_force_enable_pin(snd_soc_component_get_dapm(component), "RESET_HPH_REGISTERS"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); - snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec), + snd_soc_dapm_disable_pin(snd_soc_component_get_dapm(component), "RESET_HPH_REGISTERS"); - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); return wcd934x_mbhc->is_hph_recover; } -static void tavil_update_anc_state(struct snd_soc_codec *codec, bool enable, - int anc_num) +static void tavil_update_anc_state(struct snd_soc_component *component, + bool enable, int anc_num) { if (enable) - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x10); else - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CFG0 + - (20 * anc_num), 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_CFG0 + (20 * anc_num), + 0x10, 0x00); } static bool tavil_is_anc_on(struct wcd_mbhc *mbhc) @@ -846,9 +864,11 @@ static bool tavil_is_anc_on(struct wcd_mbhc *mbhc) u16 ancl, ancr; ancl = - (snd_soc_read(mbhc->codec, WCD934X_CDC_RX1_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32( + mbhc->component, WCD934X_CDC_RX1_RX_PATH_CFG0)) & 0x10; ancr = - (snd_soc_read(mbhc->codec, WCD934X_CDC_RX2_RX_PATH_CFG0)) & 0x10; + (snd_soc_component_read32( + mbhc->component, WCD934X_CDC_RX2_RX_PATH_CFG0)) & 0x10; anc_on = !!(ancl | ancr); @@ -883,11 +903,11 @@ static const struct wcd_mbhc_cb mbhc_cb = { }; static struct regulator *tavil_codec_find_ondemand_regulator( - struct snd_soc_codec *codec, const char *name) + struct snd_soc_component *component, const char *name) { int i; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); for (i = 0; i < wcd9xxx->num_of_supplies; ++i) { if (pdata->regulator[i].ondemand && @@ -896,7 +916,7 @@ static struct regulator *tavil_codec_find_ondemand_regulator( return wcd9xxx->supplies[i].consumer; } - dev_dbg(codec->dev, "Warning: regulator not found:%s\n", + dev_dbg(component->dev, "Warning: regulator not found:%s\n", name); return NULL; } @@ -904,19 +924,22 @@ static struct regulator *tavil_codec_find_ondemand_regulator( static int tavil_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); struct wcd_mbhc *mbhc; if (!wcd934x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mbhc = &wcd934x_mbhc->wcd_mbhc; ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; - dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); + dev_dbg(component->dev, "%s: hph_type = %u\n", __func__, + mbhc->hph_type); return 0; } @@ -927,18 +950,21 @@ static int tavil_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_multi_mixer_control *mc; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); if (!wcd934x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mc = (struct soc_multi_mixer_control *)(kcontrol->private_value); hphr = mc->shift; wcd_mbhc_get_impedance(&wcd934x_mbhc->wcd_mbhc, &zl, &zr); - dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); + dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, + zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; @@ -981,17 +1007,18 @@ EXPORT_SYMBOL(tavil_mbhc_get_impedance); /* * tavil_mbhc_hs_detect: starts mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @mbhc_cfg: handle to mbhc configuration structure * return 0 if mbhc_start is success or error code in case of failure */ -int tavil_mbhc_hs_detect(struct snd_soc_codec *codec, +int tavil_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); if (!wcd934x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } @@ -1001,14 +1028,15 @@ EXPORT_SYMBOL(tavil_mbhc_hs_detect); /* * tavil_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +void tavil_mbhc_hs_detect_exit(struct snd_soc_component *component) { - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); if (!wcd934x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return; } wcd_mbhc_stop(&wcd934x_mbhc->wcd_mbhc); @@ -1018,17 +1046,17 @@ EXPORT_SYMBOL(tavil_mbhc_hs_detect_exit); /* * tavil_mbhc_post_ssr_init: initialize mbhc for tavil post subsystem restart * @mbhc: poniter to wcd934x_mbhc structure - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * * return 0 if mbhc_init is success or error code in case of failure */ int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { int ret; struct wcd_mbhc *wcd_mbhc; - if (!mbhc || !codec) + if (!mbhc || !component) return -EINVAL; wcd_mbhc = &mbhc->wcd_mbhc; @@ -1037,18 +1065,20 @@ int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc, return -EINVAL; } - tavil_mbhc_hs_detect_exit(codec); + tavil_mbhc_hs_detect_exit(component); wcd_mbhc_deinit(wcd_mbhc); - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, TAVIL_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto done; } if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) { - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01); + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1, + 0x04, 0x04); + snd_soc_component_update_bits(component, WCD934X_MBHC_CTL_BCS, + 0x01, 0x01); } done: @@ -1059,12 +1089,13 @@ EXPORT_SYMBOL(tavil_mbhc_post_ssr_init); /* * tavil_mbhc_init: initialize mbhc for tavil * @mbhc: poniter to wcd934x_mbhc struct pointer to store the configs - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @fw_data: handle to firmware data * * return 0 if mbhc_init is success or error code in case of failure */ -int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, +int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, + struct snd_soc_component *component, struct fw_info *fw_data) { struct regulator *supply; @@ -1072,12 +1103,12 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, struct wcd_mbhc *wcd_mbhc; int ret; - wcd934x_mbhc = devm_kzalloc(codec->dev, sizeof(struct wcd934x_mbhc), + wcd934x_mbhc = devm_kzalloc(component->dev, sizeof(struct wcd934x_mbhc), GFP_KERNEL); if (!wcd934x_mbhc) return -ENOMEM; - wcd934x_mbhc->wcd9xxx = dev_get_drvdata(codec->dev->parent); + wcd934x_mbhc->wcd9xxx = dev_get_drvdata(component->dev->parent); wcd934x_mbhc->fw_data = fw_data; BLOCKING_INIT_NOTIFIER_HEAD(&wcd934x_mbhc->notifier); wcd_mbhc = &wcd934x_mbhc->wcd_mbhc; @@ -1091,16 +1122,16 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, /* Setting default mbhc detection logic to ADC for Tavil */ wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC; - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, TAVIL_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto err; } - supply = tavil_codec_find_ondemand_regulator(codec, + supply = tavil_codec_find_ondemand_regulator(component, on_demand_supply_name[WCD934X_ON_DEMAND_MICBIAS]); if (supply) { wcd934x_mbhc->on_demand_list[ @@ -1112,34 +1143,36 @@ int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, struct snd_soc_codec *codec, } (*mbhc) = wcd934x_mbhc; - snd_soc_add_codec_controls(codec, impedance_detect_controls, + snd_soc_add_component_controls(component, impedance_detect_controls, ARRAY_SIZE(impedance_detect_controls)); - snd_soc_add_codec_controls(codec, hph_type_detect_controls, + snd_soc_add_component_controls(component, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); if (wcd_mbhc->mbhc_detection_logic == WCD_DETECTION_LEGACY) { - snd_soc_update_bits(codec, WCD934X_MBHC_NEW_CTL_1, 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_MBHC_CTL_BCS, 0x01, 0x01); + snd_soc_component_update_bits(component, WCD934X_MBHC_NEW_CTL_1, + 0x04, 0x04); + snd_soc_component_update_bits(component, WCD934X_MBHC_CTL_BCS, + 0x01, 0x01); } return 0; err: - devm_kfree(codec->dev, wcd934x_mbhc); + devm_kfree(component->dev, wcd934x_mbhc); return ret; } EXPORT_SYMBOL(tavil_mbhc_init); /* * tavil_mbhc_deinit: deinitialize mbhc for tavil - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void tavil_mbhc_deinit(struct snd_soc_codec *codec) +void tavil_mbhc_deinit(struct snd_soc_component *component) { - struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(codec); + struct wcd934x_mbhc *wcd934x_mbhc = tavil_soc_get_mbhc(component); if (wcd934x_mbhc) { wcd_mbhc_deinit(&wcd934x_mbhc->wcd_mbhc); - devm_kfree(codec->dev, wcd934x_mbhc); + devm_kfree(component->dev, wcd934x_mbhc); } } EXPORT_SYMBOL(tavil_mbhc_deinit); diff --git a/asoc/codecs/wcd934x/wcd934x-mbhc.h b/asoc/codecs/wcd934x/wcd934x-mbhc.h index 07e6207d74..69cd460336 100644 --- a/asoc/codecs/wcd934x/wcd934x-mbhc.h +++ b/asoc/codecs/wcd934x/wcd934x-mbhc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD934X_MBHC_H__ #define __WCD934X_MBHC_H__ @@ -29,36 +29,37 @@ struct wcd934x_mbhc { #if IS_ENABLED(CONFIG_SND_SOC_WCD934X_MBHC) extern int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data); -extern void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec); -extern int tavil_mbhc_hs_detect(struct snd_soc_codec *codec, +extern void tavil_mbhc_hs_detect_exit(struct snd_soc_component *component); +extern int tavil_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); -extern void tavil_mbhc_deinit(struct snd_soc_codec *codec); +extern void tavil_mbhc_deinit(struct snd_soc_component *component); extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc, - struct snd_soc_codec *codec); + struct snd_soc_component *component); extern int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc, uint32_t *zl, uint32_t *zr); #else static inline int tavil_mbhc_init(struct wcd934x_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data) { return 0; } -static inline void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +static inline void tavil_mbhc_hs_detect_exit( + struct snd_soc_component *component) { } -static inline int tavil_mbhc_hs_detect(struct snd_soc_codec *codec, +static inline int tavil_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { return 0; } -static inline void tavil_mbhc_deinit(struct snd_soc_codec *codec) +static inline void tavil_mbhc_deinit(struct snd_soc_component *component) { } static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } diff --git a/asoc/codecs/wcd934x/wcd934x.c b/asoc/codecs/wcd934x/wcd934x.c index 71a680622e..d930ec83ad 100644 --- a/asoc/codecs/wcd934x/wcd934x.c +++ b/asoc/codecs/wcd934x/wcd934x.c @@ -43,6 +43,8 @@ #include "../wcdcal-hwdep.h" #include "wcd934x-dsd.h" +#define DRV_NAME "tavil_codec" + #define WCD934X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\ SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\ @@ -485,7 +487,7 @@ static int tx_unmute_delay = WCD934X_TX_UNMUTE_DELAY_MS; module_param(tx_unmute_delay, int, 0664); MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path"); -static void tavil_codec_set_tx_hold(struct snd_soc_codec *, u16, bool); +static void tavil_codec_set_tx_hold(struct snd_soc_component *, u16, bool); /* Hold instance to soundwire platform device */ struct tavil_swr_ctrl_data { @@ -543,7 +545,7 @@ struct hpf_work { struct tavil_priv { struct device *dev; struct wcd9xxx *wcd9xxx; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u32 rx_bias_count; s32 dmic_0_1_clk_cnt; s32 dmic_2_3_clk_cnt; @@ -661,14 +663,14 @@ static int __tavil_enable_efuse_sensing(struct tavil_priv *tavil); * tavil_set_spkr_gain_offset - offset the speaker path * gain with the given offset value. * - * @codec: codec instance + * @component: codec component instance * @offset: Indicates speaker path gain offset value. * * Returns 0 on success or -EINVAL on error. */ -int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset) +int tavil_set_spkr_gain_offset(struct snd_soc_component *component, int offset) { - struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *priv = snd_soc_component_get_drvdata(component); if (!priv) return -EINVAL; @@ -682,14 +684,14 @@ EXPORT_SYMBOL(tavil_set_spkr_gain_offset); * tavil_set_spkr_mode - Configures speaker compander and smartboost * settings based on speaker mode. * - * @codec: codec instance + * @component: codec component instance * @mode: Indicates speaker configuration mode. * * Returns 0 on success or -EINVAL on error. */ -int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode) +int tavil_set_spkr_mode(struct snd_soc_component *component, int mode) { - struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *priv = snd_soc_component_get_drvdata(component); int i; const struct tavil_reg_mask_val *regs; int size; @@ -710,7 +712,7 @@ int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode) priv->swr.spkr_mode = mode; for (i = 0; i < size; i++) - snd_soc_update_bits(codec, regs[i].reg, + snd_soc_component_update_bits(component, regs[i].reg, regs[i].mask, regs[i].val); return 0; } @@ -719,13 +721,13 @@ EXPORT_SYMBOL(tavil_set_spkr_mode); /** * tavil_get_afe_config - returns specific codec configuration to afe to write * - * @codec: codec instance + * @component: codec component instance * @config_type: Indicates type of configuration to write. */ -void *tavil_get_afe_config(struct snd_soc_codec *codec, +void *tavil_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type) { - struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *priv = snd_soc_component_get_drvdata(component); switch (config_type) { case AFE_SLIMBUS_SLAVE_CONFIG: @@ -739,7 +741,7 @@ void *tavil_get_afe_config(struct snd_soc_codec *codec, case AFE_CDC_REGISTER_PAGE_CONFIG: return &tavil_cdc_reg_page_cfg; default: - dev_info(codec->dev, "%s: Unknown config_type 0x%x\n", + dev_info(component->dev, "%s: Unknown config_type 0x%x\n", __func__, config_type); return NULL; } @@ -810,8 +812,9 @@ done: static int tavil_get_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil->anc_slot; return 0; @@ -820,8 +823,9 @@ static int tavil_get_anc_slot(struct snd_kcontrol *kcontrol, static int tavil_put_anc_slot(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); tavil->anc_slot = ucontrol->value.integer.value[0]; return 0; @@ -830,8 +834,9 @@ static int tavil_put_anc_slot(struct snd_kcontrol *kcontrol, static int tavil_get_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = (tavil->anc_func == true ? 1 : 0); return 0; @@ -840,13 +845,15 @@ static int tavil_get_anc_func(struct snd_kcontrol *kcontrol, static int tavil_put_anc_func(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); mutex_lock(&tavil->codec_mutex); tavil->anc_func = (!ucontrol->value.integer.value[0] ? false : true); - dev_dbg(codec->dev, "%s: anc_func %x", __func__, tavil->anc_func); + dev_dbg(component->dev, "%s: anc_func %x", __func__, tavil->anc_func); if (tavil->anc_func == true) { snd_soc_dapm_enable_pin(dapm, "ANC EAR PA"); @@ -886,8 +893,9 @@ static int tavil_put_anc_func(struct snd_kcontrol *kcontrol, static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); const char *filename; const struct firmware *fw; int i; @@ -912,28 +920,28 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration, cal_size %zd", + dev_dbg(component->dev, "%s: using hwdep calibration, cal_size %zd", __func__, cal_size); } else { filename = "WCD934X/WCD934X_anc.bin"; - ret = request_firmware(&fw, filename, codec->dev); + ret = request_firmware(&fw, filename, component->dev); if (ret < 0) { - dev_err(codec->dev, "%s: Failed to acquire ANC data: %d\n", + dev_err(component->dev, "%s: Failed to acquire ANC data: %d\n", __func__, ret); return ret; } if (!fw) { - dev_err(codec->dev, "%s: Failed to get anc fw\n", + dev_err(component->dev, "%s: Failed to get anc fw\n", __func__); return -ENODEV; } data = fw->data; cal_size = fw->size; - dev_dbg(codec->dev, "%s: using request_firmware calibration\n", + dev_dbg(component->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(struct wcd9xxx_anc_header)) { - dev_err(codec->dev, "%s: Invalid cal_size %zd\n", + dev_err(component->dev, "%s: Invalid cal_size %zd\n", __func__, cal_size); ret = -EINVAL; goto err; @@ -946,14 +954,14 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, num_anc_slots = anc_head->num_anc_slots; if (tavil->anc_slot >= num_anc_slots) { - dev_err(codec->dev, "%s: Invalid ANC slot selected\n", + dev_err(component->dev, "%s: Invalid ANC slot selected\n", __func__); ret = -EINVAL; goto err; } for (i = 0; i < num_anc_slots; i++) { if (anc_size_remaining < WCD934X_PACKED_REG_SIZE) { - dev_err(codec->dev, "%s: Invalid register format\n", + dev_err(component->dev, "%s: Invalid register format\n", __func__); ret = -EINVAL; goto err; @@ -964,7 +972,7 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, if ((anc_writes_size * WCD934X_PACKED_REG_SIZE) > anc_size_remaining) { - dev_err(codec->dev, "%s: Invalid register format\n", + dev_err(component->dev, "%s: Invalid register format\n", __func__); ret = -EINVAL; goto err; @@ -978,7 +986,7 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, anc_ptr += anc_writes_size; } if (i == num_anc_slots) { - dev_err(codec->dev, "%s: Selected ANC slot not present\n", + dev_err(component->dev, "%s: Selected ANC slot not present\n", __func__); ret = -EINVAL; goto err; @@ -995,34 +1003,34 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, for (; i < anc_writes_size; i++) { WCD934X_CODEC_UNPACK_ENTRY(anc_ptr[i], reg, mask, val); - snd_soc_write(codec, reg, (val & mask)); + snd_soc_component_write(component, reg, (val & mask)); } /* Rate converter clk enable and set bypass mode */ if (!strcmp(w->name, "RX INT0 DAC") || !strcmp(w->name, "RX INT1 DAC") || !strcmp(w->name, "ANC SPK1 PA")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_RC_COMMON_CTL, 0x05, 0x05); if (!strcmp(w->name, "RX INT1 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_FIFO_COMMON_CTL, 0x66, 0x66); } } else if (!strcmp(w->name, "RX INT2 DAC")) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_RC_COMMON_CTL, 0x05, 0x05); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_FIFO_COMMON_CTL, 0x66, 0x66); } if (!strcmp(w->name, "RX INT1 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x08); else if (!strcmp(w->name, "RX INT2 DAC")) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x08); if (!hwdep_cal) @@ -1033,10 +1041,10 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, if (!strcmp(w->name, "ANC HPHL PA") || !strcmp(w->name, "ANC HPHR PA")) { /* Remove ANC Rx from reset */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_CLK_RESET_CTL, 0x08, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_CLK_RESET_CTL, 0x08, 0x00); } @@ -1044,40 +1052,45 @@ static int tavil_codec_enable_anc(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WCD934X_CDC_ANC0_RC_COMMON_CTL, - 0x05, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_RC_COMMON_CTL, + 0x05, 0x00); if (!strcmp(w->name, "ANC EAR PA") || !strcmp(w->name, "ANC SPK1 PA") || !strcmp(w->name, "ANC HPHL PA")) { - snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_1_CTL, - 0x30, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_MODE_1_CTL, + 0x30, 0x00); msleep(50); - snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_1_CTL, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC0_CLK_RESET_CTL, - 0x38, 0x38); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC0_CLK_RESET_CTL, - 0x07, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC0_CLK_RESET_CTL, - 0x38, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_MODE_1_CTL, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_CLK_RESET_CTL, + 0x38, 0x38); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_CLK_RESET_CTL, + 0x07, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC0_CLK_RESET_CTL, + 0x38, 0x00); } else if (!strcmp(w->name, "ANC HPHR PA")) { - snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_1_CTL, - 0x30, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC1_MODE_1_CTL, + 0x30, 0x00); msleep(50); - snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_1_CTL, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC1_CLK_RESET_CTL, - 0x38, 0x38); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC1_CLK_RESET_CTL, - 0x07, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_ANC1_CLK_RESET_CTL, - 0x38, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC1_MODE_1_CTL, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC1_CLK_RESET_CTL, + 0x38, 0x38); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC1_CLK_RESET_CTL, + 0x07, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_ANC1_CLK_RESET_CTL, + 0x38, 0x00); } break; } @@ -1092,15 +1105,16 @@ err: static int tavil_get_clkmode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); if (test_bit(CLK_MODE, &tavil_p->status_mask)) ucontrol->value.enumerated.item[0] = 1; else ucontrol->value.enumerated.item[0] = 0; - dev_dbg(codec->dev, "%s: is_low_power_clock: %s\n", __func__, + dev_dbg(component->dev, "%s: is_low_power_clock: %s\n", __func__, test_bit(CLK_MODE, &tavil_p->status_mask) ? "true" : "false"); return 0; @@ -1109,15 +1123,16 @@ static int tavil_get_clkmode(struct snd_kcontrol *kcontrol, static int tavil_put_clkmode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); if (ucontrol->value.enumerated.item[0]) set_bit(CLK_MODE, &tavil_p->status_mask); else clear_bit(CLK_MODE, &tavil_p->status_mask); - dev_dbg(codec->dev, "%s: is_low_power_clock: %s\n", __func__, + dev_dbg(component->dev, "%s: is_low_power_clock: %s\n", __func__, test_bit(CLK_MODE, &tavil_p->status_mask) ? "true" : "false"); return 0; @@ -1128,8 +1143,9 @@ static int tavil_vi_feed_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil_p->vi_feed_value; @@ -1141,16 +1157,17 @@ static int tavil_vi_feed_mixer_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); + struct wcd9xxx *core = dev_get_drvdata(component->dev->parent); struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); u32 dai_id = widget->shift; u32 port_id = mixer->shift; u32 enable = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n", + dev_dbg(component->dev, "%s: enable: %d, port_id:%d, dai_id: %d\n", __func__, enable, port_id, dai_id); tavil_p->vi_feed_value = ucontrol->value.integer.value[0]; @@ -1191,9 +1208,10 @@ static int slim_tx_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil_p->tx_port_value; return 0; @@ -1203,10 +1221,11 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); + struct wcd9xxx *core = dev_get_drvdata(component->dev->parent); struct snd_soc_dapm_update *update = NULL; struct soc_multi_mixer_control *mixer = ((struct soc_multi_mixer_control *)kcontrol->private_value); @@ -1215,14 +1234,14 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, u32 enable = ucontrol->value.integer.value[0]; u32 vtable; - dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", + dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, tavil_p->tx_port_value, widget->shift, ucontrol->value.integer.value[0]); mutex_lock(&tavil_p->codec_mutex); if (dai_id >= ARRAY_SIZE(vport_slim_check_table)) { - dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n", + dev_err(component->dev, "%s: dai_id: %d, out of bounds\n", __func__, dai_id); mutex_unlock(&tavil_p->codec_mutex); return -EINVAL; @@ -1237,7 +1256,7 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, if (enable && !(tavil_p->tx_port_value & 1 << port_id)) { if (wcd9xxx_tx_vport_validation(vtable, port_id, tavil_p->dai, NUM_CODEC_DAIS)) { - dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", + dev_dbg(component->dev, "%s: TX%u is used by other virtual port\n", __func__, port_id); mutex_unlock(&tavil_p->codec_mutex); return 0; @@ -1251,11 +1270,11 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, list_del_init(&core->tx_chs[port_id].list); } else { if (enable) - dev_dbg(codec->dev, "%s: TX%u port is used by\n" + dev_dbg(component->dev, "%s: TX%u port is used by\n" "this virtual port\n", __func__, port_id); else - dev_dbg(codec->dev, "%s: TX%u port is not used by\n" + dev_dbg(component->dev, "%s: TX%u port is not used by\n" "this virtual port\n", __func__, port_id); /* avoid update power function */ @@ -1266,11 +1285,11 @@ static int slim_tx_mixer_put(struct snd_kcontrol *kcontrol, case AIF4_MAD_TX: break; default: - dev_err(codec->dev, "Unknown AIF %d\n", dai_id); + dev_err(component->dev, "Unknown AIF %d\n", dai_id); mutex_unlock(&tavil_p->codec_mutex); return -EINVAL; } - dev_dbg(codec->dev, "%s: name %s sname %s updated value %u shift %d\n", + dev_dbg(component->dev, "%s: name %s sname %s updated value %u shift %d\n", __func__, widget->name, widget->sname, tavil_p->tx_port_value, widget->shift); @@ -1285,8 +1304,9 @@ static int i2s_tx_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil_p->tx_port_value; return 0; @@ -1297,8 +1317,9 @@ static int i2s_tx_mixer_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_update *update = NULL; struct soc_multi_mixer_control *mixer = (struct soc_multi_mixer_control *)kcontrol->private_value; @@ -1307,14 +1328,14 @@ static int i2s_tx_mixer_put(struct snd_kcontrol *kcontrol, u32 enable = ucontrol->value.integer.value[0]; u32 vtable; - dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", + dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, tavil_p->tx_port_value, widget->shift, ucontrol->value.integer.value[0]); mutex_lock(&tavil_p->codec_mutex); if (dai_id >= ARRAY_SIZE(vport_slim_check_table)) { - dev_err(codec->dev, "%s: dai_id: %d, out of bounds\n", + dev_err(component->dev, "%s: dai_id: %d, out of bounds\n", __func__, dai_id); mutex_unlock(&tavil_p->codec_mutex); return -EINVAL; @@ -1329,7 +1350,7 @@ static int i2s_tx_mixer_put(struct snd_kcontrol *kcontrol, if (enable && !(tavil_p->tx_port_value & 1 << port_id)) { if (wcd9xxx_tx_vport_validation(vtable, port_id, tavil_p->dai, NUM_CODEC_DAIS)) { - dev_dbg(codec->dev, "%s: TX%u is used by other virtual port\n", + dev_dbg(component->dev, "%s: TX%u is used by other virtual port\n", __func__, port_id); mutex_unlock(&tavil_p->codec_mutex); return 0; @@ -1340,11 +1361,11 @@ static int i2s_tx_mixer_put(struct snd_kcontrol *kcontrol, tavil_p->tx_port_value &= ~(1 << port_id); } else { if (enable) - dev_dbg(codec->dev, "%s: TX%u port is used by\n" + dev_dbg(component->dev, "%s: TX%u port is used by\n" "this virtual port\n", __func__, port_id); else - dev_dbg(codec->dev, "%s: TX%u port is not used by\n" + dev_dbg(component->dev, "%s: TX%u port is not used by\n" "this virtual port\n", __func__, port_id); /* avoid update power function */ @@ -1353,11 +1374,11 @@ static int i2s_tx_mixer_put(struct snd_kcontrol *kcontrol, } break; default: - dev_err(codec->dev, "Unknown AIF %d\n", dai_id); + dev_err(component->dev, "Unknown AIF %d\n", dai_id); mutex_unlock(&tavil_p->codec_mutex); return -EINVAL; } - dev_dbg(codec->dev, "%s: name %s sname %s updated value %u shift %d\n", + dev_dbg(component->dev, "%s: name %s sname %s updated value %u shift %d\n", __func__, widget->name, widget->sname, tavil_p->tx_port_value, widget->shift); @@ -1372,8 +1393,9 @@ static int slim_rx_mux_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = tavil_p->rx_port_value[widget->shift]; @@ -1385,9 +1407,10 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *core = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); + struct wcd9xxx *core = dev_get_drvdata(component->dev->parent); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; unsigned int rx_port_value; @@ -1397,7 +1420,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, rx_port_value = tavil_p->rx_port_value[port_id]; mutex_lock(&tavil_p->codec_mutex); - dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", + dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, rx_port_value, widget->shift, ucontrol->value.integer.value[0]); @@ -1411,7 +1434,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + WCD934X_RX_PORT_START_NUMBER, &tavil_p->dai[AIF1_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -1422,7 +1445,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + WCD934X_RX_PORT_START_NUMBER, &tavil_p->dai[AIF2_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -1433,7 +1456,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + WCD934X_RX_PORT_START_NUMBER, &tavil_p->dai[AIF3_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -1444,7 +1467,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, if (wcd9xxx_rx_vport_validation(port_id + WCD934X_RX_PORT_START_NUMBER, &tavil_p->dai[AIF4_PB].wcd9xxx_ch_list)) { - dev_dbg(codec->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", + dev_dbg(component->dev, "%s: RX%u is used by current requesting AIF_PB itself\n", __func__, port_id); goto rtn; } @@ -1452,7 +1475,7 @@ static int slim_rx_mux_put(struct snd_kcontrol *kcontrol, &tavil_p->dai[AIF4_PB].wcd9xxx_ch_list); break; default: - dev_err(codec->dev, "Unknown AIF %d\n", rx_port_value); + dev_err(component->dev, "Unknown AIF %d\n", rx_port_value); goto err; } rtn: @@ -1468,7 +1491,7 @@ err: static void tavil_codec_enable_slim_port_intr( struct wcd9xxx_codec_dai_data *dai, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct wcd9xxx_ch *ch; int port_num = 0; @@ -1476,12 +1499,12 @@ static void tavil_codec_enable_slim_port_intr( u8 val = 0; struct tavil_priv *tavil_p; - if (!dai || !codec) { + if (!dai || !component) { pr_err("%s: Invalid params\n", __func__); return; } - tavil_p = snd_soc_codec_get_drvdata(codec); + tavil_p = snd_soc_component_get_drvdata(component); list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) { if (ch->port >= WCD934X_RX_PORT_START_NUMBER) { port_num = ch->port - WCD934X_RX_PORT_START_NUMBER; @@ -1543,7 +1566,7 @@ static int tavil_codec_enable_slim_chmask(struct wcd9xxx_codec_dai_data *dai, return ret; } -static void tavil_codec_mute_dsd(struct snd_soc_codec *codec, +static void tavil_codec_mute_dsd(struct snd_soc_component *component, struct list_head *ch_list) { u8 dsd0_in; @@ -1551,8 +1574,10 @@ static void tavil_codec_mute_dsd(struct snd_soc_codec *codec, struct wcd9xxx_ch *ch; /* Read DSD Input Ports */ - dsd0_in = (snd_soc_read(codec, WCD934X_CDC_DSD0_CFG0) & 0x3C) >> 2; - dsd1_in = (snd_soc_read(codec, WCD934X_CDC_DSD1_CFG0) & 0x3C) >> 2; + dsd0_in = (snd_soc_component_read32( + component, WCD934X_CDC_DSD0_CFG0) & 0x3C) >> 2; + dsd1_in = (snd_soc_component_read32( + component, WCD934X_CDC_DSD1_CFG0) & 0x3C) >> 2; if ((dsd0_in == 0) && (dsd1_in == 0)) return; @@ -1563,11 +1588,13 @@ static void tavil_codec_mute_dsd(struct snd_soc_codec *codec, */ list_for_each_entry(ch, ch_list, list) { if (ch->port == (dsd0_in + WCD934X_RX_PORT_START_NUMBER - 1)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, - 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, + 0x04, 0x04); if (ch->port == (dsd1_in + WCD934X_RX_PORT_START_NUMBER - 1)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, - 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, + 0x04, 0x04); } } @@ -1576,8 +1603,9 @@ static int tavil_codec_set_i2s_rx_ch(struct snd_soc_dapm_widget *w, { int rx_fs_rate = -EINVAL; int i2s_bit_mode; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; dai = &tavil_p->dai[w->shift]; @@ -1616,14 +1644,14 @@ static int tavil_codec_set_i2s_rx_ch(struct snd_soc_dapm_widget *w, __func__, dai->rate); return -EINVAL; }; - snd_soc_update_bits(codec, i2s_reg, + snd_soc_component_update_bits(component, i2s_reg, 0x40, i2s_bit_mode << 6); - snd_soc_update_bits(codec, i2s_reg, + snd_soc_component_update_bits(component, i2s_reg, 0x3c, (rx_fs_rate << 2)); } else { - snd_soc_update_bits(codec, i2s_reg, + snd_soc_component_update_bits(component, i2s_reg, 0x40, 0x00); - snd_soc_update_bits(codec, i2s_reg, + snd_soc_component_update_bits(component, i2s_reg, 0x3c, 0x00); } return 0; @@ -1634,8 +1662,9 @@ static int tavil_codec_set_i2s_tx_ch(struct snd_soc_dapm_widget *w, { int tx_fs_rate = -EINVAL; int i2s_bit_mode; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; dai = &tavil_p->dai[w->shift]; @@ -1645,7 +1674,8 @@ static int tavil_codec_set_i2s_tx_ch(struct snd_soc_dapm_widget *w, else i2s_bit_mode = 0x00; - snd_soc_update_bits(codec, i2s_reg, 0x40, i2s_bit_mode << 6); + snd_soc_component_update_bits( + component, i2s_reg, 0x40, i2s_bit_mode << 6); switch (dai->rate) { case 8000: @@ -1675,40 +1705,41 @@ static int tavil_codec_set_i2s_tx_ch(struct snd_soc_dapm_widget *w, return -EINVAL; }; - snd_soc_update_bits(codec, i2s_reg, 0x3c, tx_fs_rate << 2); + snd_soc_component_update_bits( + component, i2s_reg, 0x3c, tx_fs_rate << 2); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX0_CFG, 0x03, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX0_CFG, 0x0C, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX1_0_CFG, 0x03, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX1_1_CFG, 0x05, 0x05); } else { - snd_soc_update_bits(codec, i2s_reg, 0x40, 0x00); - snd_soc_update_bits(codec, i2s_reg, 0x3c, 0x00); + snd_soc_component_update_bits(component, i2s_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, i2s_reg, 0x3c, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX0_CFG, 0x03, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX0_CFG, 0x0C, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX1_0_CFG, 0x03, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_DATA_HUB_I2S_TX1_1_CFG, 0x05, 0x00); } @@ -1719,8 +1750,9 @@ static int tavil_codec_enable_rx_i2c(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); int ret = -EINVAL; u32 i2s_reg; @@ -1738,7 +1770,7 @@ static int tavil_codec_enable_rx_i2c(struct snd_soc_dapm_widget *w, i2s_reg = WCD934X_DATA_HUB_I2S_2_CTL; break; default: - dev_err(codec->dev, "%s Invalid i2s Id received", __func__); + dev_err(component->dev, "%s Invalid i2s Id received", __func__); return -EINVAL; } @@ -1759,21 +1791,22 @@ static int tavil_codec_enable_rx(struct snd_soc_dapm_widget *w, int event) { struct wcd9xxx *core; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); int ret = 0; struct wcd9xxx_codec_dai_data *dai; struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config; - core = dev_get_drvdata(codec->dev->parent); + core = dev_get_drvdata(component->dev->parent); - dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d\n" + dev_dbg(component->dev, "%s: event called! codec name %s num_dai %d\n" "stream name %s event %d\n", - __func__, codec->component.name, - codec->component.num_dai, w->sname, event); + __func__, component->name, + component->num_dai, w->sname, event); dai = &tavil_p->dai[w->shift]; - dev_dbg(codec->dev, "%s: w->name %s w->shift %d event %d\n", + dev_dbg(component->dev, "%s: w->name %s w->shift %d event %d\n", __func__, w->name, w->shift, event); if (tavil_p->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { @@ -1784,7 +1817,7 @@ static int tavil_codec_enable_rx(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: dai->bus_down_in_recovery = false; - tavil_codec_enable_slim_port_intr(dai, codec); + tavil_codec_enable_slim_port_intr(dai, component); (void) tavil_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, @@ -1792,17 +1825,17 @@ static int tavil_codec_enable_rx(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: if (dsd_conf) - tavil_codec_mute_dsd(codec, &dai->wcd9xxx_ch_list); + tavil_codec_mute_dsd(component, &dai->wcd9xxx_ch_list); ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list, dai->grph); - dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n", + dev_dbg(component->dev, "%s: Disconnect RX port, ret = %d\n", __func__, ret); if (!dai->bus_down_in_recovery) ret = tavil_codec_enable_slim_chmask(dai, false); else - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: bus in recovery skip enable slim_chmask", __func__); ret = wcd9xxx_close_slim_sch_rx(core, &dai->wcd9xxx_ch_list, @@ -1816,8 +1849,9 @@ static int tavil_codec_enable_tx_i2c(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); int ret = -EINVAL; u32 i2s_reg; @@ -1835,7 +1869,7 @@ static int tavil_codec_enable_tx_i2c(struct snd_soc_dapm_widget *w, i2s_reg = WCD934X_DATA_HUB_I2S_2_CTL; break; default: - dev_err(codec->dev, "%s Invalid i2s Id received", __func__); + dev_err(component->dev, "%s Invalid i2s Id received", __func__); return -EINVAL; } @@ -1855,19 +1889,20 @@ static int tavil_codec_enable_tx(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct wcd9xxx_codec_dai_data *dai; struct wcd9xxx *core; int ret = 0; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: w->name %s, w->shift = %d, num_dai %d stream name %s\n", __func__, w->name, w->shift, - codec->component.num_dai, w->sname); + component->num_dai, w->sname); dai = &tavil_p->dai[w->shift]; - core = dev_get_drvdata(codec->dev->parent); + core = dev_get_drvdata(component->dev->parent); if (tavil_p->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) { ret = tavil_codec_enable_tx_i2c(w, kcontrol, event); @@ -1877,7 +1912,7 @@ static int tavil_codec_enable_tx(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: dai->bus_down_in_recovery = false; - tavil_codec_enable_slim_port_intr(dai, codec); + tavil_codec_enable_slim_port_intr(dai, component); (void) tavil_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, @@ -1892,7 +1927,7 @@ static int tavil_codec_enable_tx(struct snd_soc_dapm_widget *w, ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list, dai->grph); - dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n", + dev_dbg(component->dev, "%s: Disconnect RX port, ret = %d\n", __func__, ret); } break; @@ -1905,18 +1940,18 @@ static int tavil_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, int event) { struct wcd9xxx *core = NULL; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; struct tavil_priv *tavil_p = NULL; int ret = 0; struct wcd9xxx_codec_dai_data *dai = NULL; - codec = snd_soc_dapm_to_codec(w->dapm); - tavil_p = snd_soc_codec_get_drvdata(codec); - core = dev_get_drvdata(codec->dev->parent); + component = snd_soc_dapm_to_component(w->dapm); + tavil_p = snd_soc_component_get_drvdata(component); + core = dev_get_drvdata(component->dev->parent); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: num_dai %d stream name %s w->name %s event %d shift %d\n", - __func__, codec->component.num_dai, w->sname, + __func__, component->num_dai, w->sname, w->name, event, w->shift); if (w->shift != AIF4_VIFEED) { @@ -1928,59 +1963,60 @@ static int tavil_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: if (test_bit(VI_SENSE_1, &tavil_p->status_mask)) { - dev_dbg(codec->dev, "%s: spkr1 enabled\n", __func__); + dev_dbg(component->dev, "%s: spkr1 enabled\n", + __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x00); } if (test_bit(VI_SENSE_2, &tavil_p->status_mask)) { pr_debug("%s: spkr2 enabled\n", __func__); /* Enable V&I sensing */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x00); } dai->bus_down_in_recovery = false; - tavil_codec_enable_slim_port_intr(dai, codec); + tavil_codec_enable_slim_port_intr(dai, component); (void) tavil_codec_enable_slim_chmask(dai, true); ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->rate, dai->bit_width, @@ -1990,7 +2026,7 @@ static int tavil_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list, dai->grph); if (ret) - dev_err(codec->dev, "%s error in close_slim_sch_tx %d\n", + dev_err(component->dev, "%s error in close_slim_sch_tx %d\n", __func__, ret); if (!dai->bus_down_in_recovery) ret = tavil_codec_enable_slim_chmask(dai, false); @@ -1998,36 +2034,38 @@ static int tavil_codec_enable_slimvi_feedback(struct snd_soc_dapm_widget *w, ret = wcd9xxx_disconnect_port(core, &dai->wcd9xxx_ch_list, dai->grph); - dev_dbg(codec->dev, "%s: Disconnect TX port, ret = %d\n", + dev_dbg(component->dev, "%s: Disconnect TX port, ret = %d\n", __func__, ret); } if (test_bit(VI_SENSE_1, &tavil_p->status_mask)) { /* Disable V&I sensing */ - dev_dbg(codec->dev, "%s: spkr1 disabled\n", __func__); - snd_soc_update_bits(codec, + dev_dbg(component->dev, "%s: spkr1 disabled\n", + __func__); + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX9_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX10_SPKR_PROT_PATH_CTL, 0x10, 0x00); } if (test_bit(VI_SENSE_2, &tavil_p->status_mask)) { /* Disable V&I sensing */ - dev_dbg(codec->dev, "%s: spkr2 disabled\n", __func__); - snd_soc_update_bits(codec, + dev_dbg(component->dev, "%s: spkr2 disabled\n", + __func__); + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x20, 0x20); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX11_SPKR_PROT_PATH_CTL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_TX12_SPKR_PROT_PATH_CTL, 0x10, 0x00); } @@ -2040,28 +2078,31 @@ done: static int tavil_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: tavil->rx_bias_count++; if (tavil->rx_bias_count == 1) { - snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_ANA_RX_SUPPLIES, + 0x01, 0x01); } break; case SND_SOC_DAPM_POST_PMD: tavil->rx_bias_count--; if (!tavil->rx_bias_count) - snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_ANA_RX_SUPPLIES, + 0x01, 0x00); break; }; - dev_dbg(codec->dev, "%s: Current RX BIAS user count: %d\n", __func__, - tavil->rx_bias_count); + dev_dbg(component->dev, "%s: Current RX BIAS user count: %d\n", + __func__, tavil->rx_bias_count); return 0; } @@ -2071,14 +2112,15 @@ static void tavil_spk_anc_update_callback(struct work_struct *work) struct spk_anc_work *spk_anc_dwork; struct tavil_priv *tavil; struct delayed_work *delayed_work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; delayed_work = to_delayed_work(work); spk_anc_dwork = container_of(delayed_work, struct spk_anc_work, dwork); tavil = spk_anc_dwork->tavil; - codec = tavil->codec; + component = tavil->component; - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_CFG0, 0x10, 0x10); + snd_soc_component_update_bits(component, WCD934X_CDC_RX7_RX_PATH_CFG0, + 0x10, 0x10); } static int tavil_codec_enable_spkr_anc(struct snd_soc_dapm_widget *w, @@ -2086,13 +2128,14 @@ static int tavil_codec_enable_spkr_anc(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); if (!tavil->anc_func) return 0; - dev_dbg(codec->dev, "%s: w: %s event: %d anc: %d\n", __func__, + dev_dbg(component->dev, "%s: w: %s event: %d anc: %d\n", __func__, w->name, event, tavil->anc_func); switch (event) { @@ -2103,8 +2146,9 @@ static int tavil_codec_enable_spkr_anc(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: cancel_delayed_work_sync(&tavil->spk_anc_dwork.dwork); - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_CFG0, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_CFG0, + 0x10, 0x00); ret = tavil_codec_enable_anc(w, kcontrol, event); break; } @@ -2116,9 +2160,10 @@ static int tavil_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -2127,12 +2172,14 @@ static int tavil_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, * HW requirement */ usleep_range(5000, 5500); - snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX0_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD934X_CDC_RX0_RX_PATH_MIX_CTL)) & + if ((snd_soc_component_read32(component, + WCD934X_CDC_RX0_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX0_RX_PATH_MIX_CTL, 0x10, 0x00); break; @@ -2145,8 +2192,9 @@ static int tavil_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, if (!(strcmp(w->name, "ANC EAR PA"))) { ret = tavil_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CFG0, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX0_RX_PATH_CFG0, + 0x10, 0x00); } break; }; @@ -2154,18 +2202,18 @@ static int tavil_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, return ret; } -static void tavil_codec_override(struct snd_soc_codec *codec, int mode, +static void tavil_codec_override(struct snd_soc_component *component, int mode, int event) { if (mode == CLS_AB || mode == CLS_AB_HIFI) { switch (event) { case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x02); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00); break; } @@ -2175,24 +2223,32 @@ static void tavil_codec_override(struct snd_soc_codec *codec, int mode, static void tavil_codec_clear_anc_tx_hold(struct tavil_priv *tavil) { if (test_and_clear_bit(ANC_MIC_AMIC1, &tavil->status_mask)) - tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC1, false); + tavil_codec_set_tx_hold(tavil->component, + WCD934X_ANA_AMIC1, false); if (test_and_clear_bit(ANC_MIC_AMIC2, &tavil->status_mask)) - tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC2, false); + tavil_codec_set_tx_hold(tavil->component, + WCD934X_ANA_AMIC2, false); if (test_and_clear_bit(ANC_MIC_AMIC3, &tavil->status_mask)) - tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC3, false); + tavil_codec_set_tx_hold(tavil->component, + WCD934X_ANA_AMIC3, false); if (test_and_clear_bit(ANC_MIC_AMIC4, &tavil->status_mask)) - tavil_codec_set_tx_hold(tavil->codec, WCD934X_ANA_AMIC4, false); + tavil_codec_set_tx_hold(tavil->component, + WCD934X_ANA_AMIC4, false); } -static void tavil_ocp_control(struct snd_soc_codec *codec, bool enable) +static void tavil_ocp_control(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD934X_HPH_OCP_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, WCD934X_RX_OCP_CTL, 0x0F, 0x02); + snd_soc_component_update_bits(component, WCD934X_HPH_OCP_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, WCD934X_RX_OCP_CTL, + 0x0F, 0x02); } else { - snd_soc_update_bits(codec, WCD934X_RX_OCP_CTL, 0x0F, 0x0F); - snd_soc_update_bits(codec, WCD934X_HPH_OCP_CTL, 0x10, 0x00); + snd_soc_component_update_bits(component, WCD934X_RX_OCP_CTL, + 0x0F, 0x0F); + snd_soc_component_update_bits(component, WCD934X_HPH_OCP_CTL, + 0x10, 0x00); } } @@ -2200,36 +2256,41 @@ static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); struct tavil_dsd_config *dsd_conf = tavil->dsd_config; int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_ocp_control(codec, false); + tavil_ocp_control(component, false); if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL, - 0x06, (0x03 << 1)); + snd_soc_component_update_bits(component, + WCD934X_HPH_REFBUFF_LP_CTL, + 0x06, (0x03 << 1)); if ((!(strcmp(w->name, "ANC HPHR PA"))) && (test_bit(HPH_PA_DELAY, &tavil->status_mask))) - snd_soc_update_bits(codec, WCD934X_ANA_HPH, 0xC0, 0xC0); + snd_soc_component_update_bits(component, + WCD934X_ANA_HPH, 0xC0, 0xC0); set_bit(HPH_PA_DELAY, &tavil->status_mask); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) { + (snd_soc_component_read32(component, + WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) { /* Set regulator mode to AB if DSD is enabled */ - snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_ANA_RX_SUPPLIES, + 0x02, 0x02); } break; case SND_SOC_DAPM_POST_PMU: if ((!(strcmp(w->name, "ANC HPHR PA")))) { - if ((snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0) - != 0xC0) + if ((snd_soc_component_read32(component, + WCD934X_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC case) * then do nothing for POST_PMU and let left @@ -2251,80 +2312,92 @@ static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, } if (tavil->anc_func) { /* Clear Tx FE HOLD if both PAs are enabled */ - if ((snd_soc_read(tavil->codec, WCD934X_ANA_HPH) & - 0xC0) == 0xC0) + if ((snd_soc_component_read32(tavil->component, + WCD934X_ANA_HPH) & 0xC0) == 0xC0) tavil_codec_clear_anc_tx_hold(tavil); } - snd_soc_update_bits(codec, WCD934X_HPH_R_TEST, 0x01, 0x01); + snd_soc_component_update_bits(component, WCD934X_HPH_R_TEST, + 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX2_RX_PATH_CTL, + 0x10, 0x00); /* Enable GM3 boost */ - snd_soc_update_bits(codec, WCD934X_HPH_CNP_WG_CTL, - 0x80, 0x80); + snd_soc_component_update_bits(component, WCD934X_HPH_CNP_WG_CTL, + 0x80, 0x80); /* Enable AutoChop timer at the end of power up */ - snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32(component, + WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(component, WCD934X_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, - 0x04, 0x00); + (snd_soc_component_read32( + component, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, 0x04, 0x00); if (!(strcmp(w->name, "ANC HPHR PA"))) { pr_debug("%s:Do everything needed for left channel\n", __func__); /* Do everything needed for left channel */ - snd_soc_update_bits(codec, WCD934X_HPH_L_TEST, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_HPH_L_TEST, + 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, WCD934X_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); - if (dsd_conf && (snd_soc_read(codec, + if (dsd_conf && (snd_soc_component_read32(component, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_DSD0_CFG2, 0x04, 0x00); /* Remove ANC Rx from reset */ ret = tavil_codec_enable_anc(w, kcontrol, event); } - tavil_codec_override(codec, tavil->hph_mode, event); - tavil_ocp_control(codec, true); + tavil_codec_override(component, tavil->hph_mode, event); + tavil_ocp_control(component, true); break; case SND_SOC_DAPM_PRE_PMD: - tavil_ocp_control(codec, false); + tavil_ocp_control(component, false); blocking_notifier_call_chain(&tavil->mbhc->notifier, WCD_EVENT_PRE_HPHR_PA_OFF, &tavil->mbhc->wcd_mbhc); /* Enable DSD Mute before PA disable */ if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD1_CFG2, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_HPH_R_TEST, 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL, - 0x10, 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_MIX_CTL, - 0x10, 0x10); + (snd_soc_component_read32(component, + WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD1_CFG2, + 0x04, 0x04); + snd_soc_component_update_bits(component, WCD934X_HPH_R_TEST, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX2_RX_PATH_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX2_RX_PATH_MIX_CTL, + 0x10, 0x10); if (!(strcmp(w->name, "ANC HPHR PA"))) - snd_soc_update_bits(codec, WCD934X_ANA_HPH, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD934X_ANA_HPH, 0x40, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* @@ -2335,20 +2408,21 @@ static int tavil_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, usleep_range(20000, 20100); else usleep_range(5000, 5100); - tavil_codec_override(codec, tavil->hph_mode, event); + tavil_codec_override(component, tavil->hph_mode, event); blocking_notifier_call_chain(&tavil->mbhc->notifier, WCD_EVENT_POST_HPHR_PA_OFF, &tavil->mbhc->wcd_mbhc); if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL, - 0x06, 0x0); + snd_soc_component_update_bits(component, + WCD934X_HPH_REFBUFF_LP_CTL, + 0x06, 0x0); if (!(strcmp(w->name, "ANC HPHR PA"))) { ret = tavil_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, - WCD934X_CDC_RX2_RX_PATH_CFG0, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX2_RX_PATH_CFG0, + 0x10, 0x00); } - tavil_ocp_control(codec, true); + tavil_ocp_control(component, true); break; }; @@ -2359,35 +2433,40 @@ static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); struct tavil_dsd_config *dsd_conf = tavil->dsd_config; int ret = 0; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_ocp_control(codec, false); + tavil_ocp_control(component, false); if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL, - 0x06, (0x03 << 1)); + snd_soc_component_update_bits(component, + WCD934X_HPH_REFBUFF_LP_CTL, + 0x06, (0x03 << 1)); if ((!(strcmp(w->name, "ANC HPHL PA"))) && (test_bit(HPH_PA_DELAY, &tavil->status_mask))) - snd_soc_update_bits(codec, WCD934X_ANA_HPH, - 0xC0, 0xC0); + snd_soc_component_update_bits(component, + WCD934X_ANA_HPH, + 0xC0, 0xC0); set_bit(HPH_PA_DELAY, &tavil->status_mask); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) { + (snd_soc_component_read32(component, + WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) { /* Set regulator mode to AB if DSD is enabled */ - snd_soc_update_bits(codec, WCD934X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_ANA_RX_SUPPLIES, + 0x02, 0x02); } break; case SND_SOC_DAPM_POST_PMU: if (!(strcmp(w->name, "ANC HPHL PA"))) { - if ((snd_soc_read(codec, WCD934X_ANA_HPH) & 0xC0) - != 0xC0) + if ((snd_soc_component_read32( + component, WCD934X_ANA_HPH) & 0xC0) != 0xC0) /* * If PA_EN is not set (potentially in ANC * case) then do nothing for POST_PMU and @@ -2409,80 +2488,95 @@ static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, } if (tavil->anc_func) { /* Clear Tx FE HOLD if both PAs are enabled */ - if ((snd_soc_read(tavil->codec, WCD934X_ANA_HPH) & - 0xC0) == 0xC0) + if ((snd_soc_component_read32( + tavil->component, WCD934X_ANA_HPH) & 0xC0) == + 0xC0) tavil_codec_clear_anc_tx_hold(tavil); } - snd_soc_update_bits(codec, WCD934X_HPH_L_TEST, 0x01, 0x01); + snd_soc_component_update_bits(component, WCD934X_HPH_L_TEST, + 0x01, 0x01); /* Remove Mute on primary path */ - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_CTL, + 0x10, 0x00); /* Enable GM3 boost */ - snd_soc_update_bits(codec, WCD934X_HPH_CNP_WG_CTL, - 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD934X_HPH_CNP_WG_CTL, + 0x80, 0x80); /* Enable AutoChop timer at the end of power up */ - snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, WCD934X_CDC_RX1_RX_PATH_MIX_CTL)) & - 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32(component, + WCD934X_CDC_RX1_RX_PATH_MIX_CTL)) & 0x10) + snd_soc_component_update_bits(component, WCD934X_CDC_RX1_RX_PATH_MIX_CTL, 0x10, 0x00); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, - 0x04, 0x00); + (snd_soc_component_read32( + component, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, + 0x04, 0x00); if (!(strcmp(w->name, "ANC HPHL PA"))) { pr_debug("%s:Do everything needed for right channel\n", __func__); /* Do everything needed for right channel */ - snd_soc_update_bits(codec, WCD934X_HPH_R_TEST, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_HPH_R_TEST, + 0x01, 0x01); /* Remove mute */ - snd_soc_update_bits(codec, WCD934X_CDC_RX2_RX_PATH_CTL, - 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX2_RX_PATH_CTL, + 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, + if ((snd_soc_component_read32(component, WCD934X_CDC_RX2_RX_PATH_MIX_CTL)) & 0x10) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX2_RX_PATH_MIX_CTL, 0x10, 0x00); - if (dsd_conf && (snd_soc_read(codec, + if (dsd_conf && (snd_soc_component_read32(component, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_DSD1_CFG2, 0x04, 0x00); /* Remove ANC Rx from reset */ ret = tavil_codec_enable_anc(w, kcontrol, event); } - tavil_codec_override(codec, tavil->hph_mode, event); - tavil_ocp_control(codec, true); + tavil_codec_override(component, tavil->hph_mode, event); + tavil_ocp_control(component, true); break; case SND_SOC_DAPM_PRE_PMD: - tavil_ocp_control(codec, false); + tavil_ocp_control(component, false); blocking_notifier_call_chain(&tavil->mbhc->notifier, WCD_EVENT_PRE_HPHL_PA_OFF, &tavil->mbhc->wcd_mbhc); /* Enable DSD Mute before PA disable */ if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) - snd_soc_update_bits(codec, WCD934X_CDC_DSD0_CFG2, + (snd_soc_component_read32(component, + WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) + snd_soc_component_update_bits(component, + WCD934X_CDC_DSD0_CFG2, 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_HPH_L_TEST, 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_CTL, - 0x10, 0x10); - snd_soc_update_bits(codec, WCD934X_CDC_RX1_RX_PATH_MIX_CTL, - 0x10, 0x10); + snd_soc_component_update_bits(component, WCD934X_HPH_L_TEST, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_CTL, + 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX1_RX_PATH_MIX_CTL, + 0x10, 0x10); if (!(strcmp(w->name, "ANC HPHL PA"))) - snd_soc_update_bits(codec, WCD934X_ANA_HPH, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD934X_ANA_HPH, + 0x80, 0x00); break; case SND_SOC_DAPM_POST_PMD: /* @@ -2493,19 +2587,20 @@ static int tavil_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, usleep_range(20000, 20100); else usleep_range(5000, 5100); - tavil_codec_override(codec, tavil->hph_mode, event); + tavil_codec_override(component, tavil->hph_mode, event); blocking_notifier_call_chain(&tavil->mbhc->notifier, WCD_EVENT_POST_HPHL_PA_OFF, &tavil->mbhc->wcd_mbhc); if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, WCD934X_HPH_REFBUFF_LP_CTL, - 0x06, 0x0); + snd_soc_component_update_bits(component, + WCD934X_HPH_REFBUFF_LP_CTL, + 0x06, 0x0); if (!(strcmp(w->name, "ANC HPHL PA"))) { ret = tavil_codec_enable_anc(w, kcontrol, event); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX1_RX_PATH_CFG0, 0x10, 0x00); } - tavil_ocp_control(codec, true); + tavil_ocp_control(component, true); break; }; @@ -2516,13 +2611,14 @@ static int tavil_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 lineout_vol_reg = 0, lineout_mix_vol_reg = 0; u16 dsd_mute_reg = 0, dsd_clk_reg = 0; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); struct tavil_dsd_config *dsd_conf = tavil->dsd_config; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (w->reg == WCD934X_ANA_LO_1_2) { if (w->shift == 7) { @@ -2537,14 +2633,14 @@ static int tavil_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, dsd_clk_reg = WCD934X_CDC_DSD1_PATH_CTL; } } else { - dev_err(codec->dev, "%s: Error enabling lineout PA\n", + dev_err(component->dev, "%s: Error enabling lineout PA\n", __func__); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_codec_override(codec, CLS_AB, event); + tavil_codec_override(component, CLS_AB, event); break; case SND_SOC_DAPM_POST_PMU: /* @@ -2552,19 +2648,24 @@ static int tavil_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, * HW requirement */ usleep_range(5000, 5500); - snd_soc_update_bits(codec, lineout_vol_reg, + snd_soc_component_update_bits(component, lineout_vol_reg, 0x10, 0x00); /* Remove mix path mute if it is enabled */ - if ((snd_soc_read(codec, lineout_mix_vol_reg)) & 0x10) - snd_soc_update_bits(codec, + if ((snd_soc_component_read32( + component, lineout_mix_vol_reg)) & 0x10) + snd_soc_component_update_bits(component, lineout_mix_vol_reg, 0x10, 0x00); - if (dsd_conf && (snd_soc_read(codec, dsd_clk_reg) & 0x01)) - snd_soc_update_bits(codec, dsd_mute_reg, 0x04, 0x00); + if (dsd_conf && (snd_soc_component_read32( + component, dsd_clk_reg) & 0x01)) + snd_soc_component_update_bits(component, dsd_mute_reg, + 0x04, 0x00); break; case SND_SOC_DAPM_PRE_PMD: - if (dsd_conf && (snd_soc_read(codec, dsd_clk_reg) & 0x01)) - snd_soc_update_bits(codec, dsd_mute_reg, 0x04, 0x04); + if (dsd_conf && (snd_soc_component_read32( + component, dsd_clk_reg) & 0x01)) + snd_soc_component_update_bits(component, dsd_mute_reg, + 0x04, 0x04); break; case SND_SOC_DAPM_POST_PMD: /* @@ -2572,7 +2673,7 @@ static int tavil_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, * HW requirement */ usleep_range(5000, 5500); - tavil_codec_override(codec, CLS_AB, event); + tavil_codec_override(component, CLS_AB, event); default: break; }; @@ -2585,8 +2686,9 @@ static int i2s_rx_mux_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = tavil_p->rx_port_value[widget->shift]; @@ -2598,8 +2700,9 @@ static int i2s_rx_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update *update = NULL; unsigned int rx_port_value; @@ -2608,7 +2711,7 @@ static int i2s_rx_mux_put(struct snd_kcontrol *kcontrol, tavil_p->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; rx_port_value = tavil_p->rx_port_value[port_id]; - dev_dbg(codec->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", + dev_dbg(component->dev, "%s: wname %s cname %s value %u shift %d item %ld\n", __func__, widget->name, ucontrol->id.name, rx_port_value, widget->shift, ucontrol->value.integer.value[0]); @@ -2624,8 +2727,9 @@ static int tavil_codec_enable_i2s_path(struct snd_soc_dapm_widget *w, { int ret = 0; u32 i2s_reg; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); switch (tavil_p->rx_port_value[w->shift]) { case AIF1_PB: @@ -2641,16 +2745,18 @@ static int tavil_codec_enable_i2s_path(struct snd_soc_dapm_widget *w, i2s_reg = WCD934X_DATA_HUB_I2S_2_CTL; break; default: - dev_err(codec->dev, "%s Invalid i2s Id received", __func__); + dev_err(component->dev, "%s Invalid i2s Id received", __func__); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - ret = snd_soc_update_bits(codec, i2s_reg, 0x01, 0x01); + ret = snd_soc_component_update_bits(component, i2s_reg, + 0x01, 0x01); break; case SND_SOC_DAPM_POST_PMD: - ret = snd_soc_update_bits(codec, i2s_reg, 0x01, 0x00); + ret = snd_soc_component_update_bits(component, i2s_reg, + 0x01, 0x00); break; } @@ -2662,30 +2768,33 @@ static int tavil_codec_ear_dac_event(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Disable AutoChop timer during power up */ - snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x00); if (tavil->anc_func) ret = tavil_codec_enable_anc(w, kcontrol, event); - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_EAR, CLS_H_NORMAL); if (tavil->anc_func) - snd_soc_update_bits(codec, WCD934X_CDC_RX0_RX_PATH_CFG0, + snd_soc_component_update_bits(component, + WCD934X_CDC_RX0_RX_PATH_CFG0, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_EAR, CLS_H_NORMAL); @@ -2701,15 +2810,16 @@ static int tavil_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int hph_mode = tavil->hph_mode; u8 dem_inp; struct tavil_dsd_config *dsd_conf = tavil->dsd_config; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2719,55 +2829,57 @@ static int tavil_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, msleep(40); } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, WCD934X_CDC_RX2_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32(component, + WCD934X_CDC_RX2_RX_PATH_SEC0) & 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP)) /* Ripple freq control enable */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_SIDO_NEW_VOUT_D_FREQ2, 0x01, 0x01); /* Disable AutoChop timer during power up */ - snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x00); /* Set RDAC gain */ if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0xF0, 0x40); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) + (snd_soc_component_read32(component, + WCD934X_CDC_DSD1_PATH_CTL) & 0x01)) hph_mode = CLS_H_HIFI; - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHR, hph_mode); if (tavil->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX2_RX_PATH_CFG0, 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: /* 1000us required as per HW requirement */ usleep_range(1000, 1100); - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHR, hph_mode); if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP)) /* Ripple freq control disable */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_SIDO_NEW_VOUT_D_FREQ2, 0x01, 0x0); /* Re-set RDAC gain */ if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0xF0, 0x0); break; @@ -2782,16 +2894,17 @@ static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int hph_mode = tavil->hph_mode; u8 dem_inp; int ret = 0; struct tavil_dsd_config *dsd_conf = tavil->dsd_config; uint32_t impedl = 0, impedr = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d hph_mode: %d\n", __func__, - w->name, event, hph_mode); + dev_dbg(component->dev, "%s wname: %s event: %d hph_mode: %d\n", + __func__, w->name, event, hph_mode); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2801,48 +2914,50 @@ static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, msleep(40); } /* Read DEM INP Select */ - dem_inp = snd_soc_read(codec, WCD934X_CDC_RX1_RX_PATH_SEC0) & - 0x03; + dem_inp = snd_soc_component_read32(component, + WCD934X_CDC_RX1_RX_PATH_SEC0) & 0x03; if (((hph_mode == CLS_H_HIFI) || (hph_mode == CLS_H_LOHIFI) || (hph_mode == CLS_H_LP)) && (dem_inp != 0x01)) { - dev_err(codec->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", + dev_err(component->dev, "%s: DEM Input not set correctly, hph_mode: %d\n", __func__, hph_mode); return -EINVAL; } if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP)) /* Ripple freq control enable */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_SIDO_NEW_VOUT_D_FREQ2, 0x01, 0x01); /* Disable AutoChop timer during power up */ - snd_soc_update_bits(codec, WCD934X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x00); /* Set RDAC gain */ if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, - WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, - 0xF0, 0x40); + snd_soc_component_update_bits(component, + WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, + 0xF0, 0x40); if (dsd_conf && - (snd_soc_read(codec, WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) + (snd_soc_component_read32(component, + WCD934X_CDC_DSD0_PATH_CTL) & 0x01)) hph_mode = CLS_H_HIFI; - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHL, hph_mode); if (tavil->anc_func) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_RX1_RX_PATH_CFG0, 0x10, 0x10); ret = tavil_mbhc_get_impedance(tavil->mbhc, &impedl, &impedr); if (!ret) { - wcd_clsh_imped_config(codec, impedl, false); + wcd_clsh_imped_config(component, impedl, false); set_bit(CLSH_Z_CONFIG, &tavil->status_mask); } else { - dev_dbg(codec->dev, "%s: Failed to get mbhc impedance %d\n", + dev_dbg(component->dev, "%s: Failed to get mbhc impedance %d\n", __func__, ret); ret = 0; } @@ -2851,23 +2966,23 @@ static int tavil_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: /* 1000us required as per HW requirement */ usleep_range(1000, 1100); - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHL, hph_mode); if ((hph_mode != CLS_H_LP) && (hph_mode != CLS_H_ULP)) /* Ripple freq control disable */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_SIDO_NEW_VOUT_D_FREQ2, 0x01, 0x0); /* Re-set RDAC gain */ if (TAVIL_IS_1_0(tavil->wcd9xxx)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0xF0, 0x0); if (test_bit(CLSH_Z_CONFIG, &tavil->status_mask)) { - wcd_clsh_imped_config(codec, impedl, true); + wcd_clsh_imped_config(component, impedl, true); clear_bit(CLSH_Z_CONFIG, &tavil->status_mask); } break; @@ -2882,20 +2997,21 @@ static int tavil_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_LO, CLS_AB); break; case SND_SOC_DAPM_POST_PMD: - wcd_clsh_fsm(codec, &tavil->clsh_d, + wcd_clsh_fsm(component, &tavil->clsh_d, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_LO, CLS_AB); @@ -2909,11 +3025,12 @@ static int tavil_codec_spk_boost_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 boost_path_ctl, boost_path_cfg1; u16 reg, reg_mix; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s %s %d\n", __func__, w->name, event); if (!strcmp(w->name, "RX INT7 CHAIN")) { boost_path_ctl = WCD934X_CDC_BOOST0_BOOST_PATH_CTL; @@ -2926,22 +3043,27 @@ static int tavil_codec_spk_boost_event(struct snd_soc_dapm_widget *w, reg = WCD934X_CDC_RX8_RX_PATH_CTL; reg_mix = WCD934X_CDC_RX8_RX_PATH_MIX_CTL; } else { - dev_err(codec->dev, "%s: unknown widget: %s\n", + dev_err(component->dev, "%s: unknown widget: %s\n", __func__, w->name); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x01); - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x10); - snd_soc_update_bits(codec, reg, 0x10, 0x00); - if ((snd_soc_read(codec, reg_mix)) & 0x10) - snd_soc_update_bits(codec, reg_mix, 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x01); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x10); + snd_soc_component_update_bits(component, reg, 0x10, 0x00); + if ((snd_soc_component_read32(component, reg_mix)) & 0x10) + snd_soc_component_update_bits(component, reg_mix, + 0x10, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, boost_path_ctl, 0x10, 0x00); - snd_soc_update_bits(codec, boost_path_cfg1, 0x01, 0x00); + snd_soc_component_update_bits(component, boost_path_ctl, + 0x10, 0x00); + snd_soc_component_update_bits(component, boost_path_cfg1, + 0x01, 0x00); break; }; @@ -2950,11 +3072,12 @@ static int tavil_codec_spk_boost_event(struct snd_soc_dapm_widget *w, static int __tavil_codec_enable_swr(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); struct tavil_priv *tavil; int ch_cnt = 0; - tavil = snd_soc_codec_get_drvdata(codec); + tavil = snd_soc_component_get_drvdata(component); if (!tavil->swr.ctrl_data) return -EINVAL; @@ -3010,7 +3133,7 @@ static int tavil_codec_enable_swr(struct snd_soc_dapm_widget *w, return __tavil_codec_enable_swr(w, event); } -static int tavil_codec_config_mad(struct snd_soc_codec *codec) +static int tavil_codec_config_mad(struct snd_soc_component *component) { int ret = 0; int idx; @@ -3019,31 +3142,31 @@ static int tavil_codec_config_mad(struct snd_soc_codec *codec) struct wcd_mad_audio_cal *mad_cal = NULL; const void *data; const char *filename = WCD934X_MAD_AUDIO_FIRMWARE_PATH; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); size_t cal_size; hwdep_cal = wcdcal_get_fw_cal(tavil->fw_data, WCD9XXX_MAD_CAL); if (hwdep_cal) { data = hwdep_cal->data; cal_size = hwdep_cal->size; - dev_dbg(codec->dev, "%s: using hwdep calibration\n", + dev_dbg(component->dev, "%s: using hwdep calibration\n", __func__); } else { - ret = request_firmware(&fw, filename, codec->dev); + ret = request_firmware(&fw, filename, component->dev); if (ret || !fw) { - dev_err(codec->dev, + dev_err(component->dev, "%s: MAD firmware acquire failed, err = %d\n", __func__, ret); return -ENODEV; } data = fw->data; cal_size = fw->size; - dev_dbg(codec->dev, "%s: using request_firmware calibration\n", + dev_dbg(component->dev, "%s: using request_firmware calibration\n", __func__); } if (cal_size < sizeof(*mad_cal)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Incorrect size %zd for MAD Cal, expected %zd\n", __func__, cal_size, sizeof(*mad_cal)); ret = -ENOMEM; @@ -3052,80 +3175,87 @@ static int tavil_codec_config_mad(struct snd_soc_codec *codec) mad_cal = (struct wcd_mad_audio_cal *) (data); if (!mad_cal) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid calibration data\n", __func__); ret = -EINVAL; goto done; } - snd_soc_write(codec, WCD934X_SOC_MAD_MAIN_CTL_2, + snd_soc_component_write(component, WCD934X_SOC_MAD_MAIN_CTL_2, mad_cal->microphone_info.cycle_time); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_MAIN_CTL_1, 0xFF << 3, - ((uint16_t)mad_cal->microphone_info.settle_time) - << 3); + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_MAIN_CTL_1, + 0xFF << 3, + ((uint16_t)mad_cal->microphone_info.settle_time) << 3); /* Audio */ - snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_8, + snd_soc_component_write(component, WCD934X_SOC_MAD_AUDIO_CTL_8, mad_cal->audio_info.rms_omit_samples); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_1, + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_AUDIO_CTL_1, 0x07 << 4, mad_cal->audio_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2, 0x03 << 2, - mad_cal->audio_info.detection_mechanism << 2); - snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_7, - mad_cal->audio_info.rms_diff_threshold & 0x3F); - snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_5, - mad_cal->audio_info.rms_threshold_lsb); - snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_CTL_6, - mad_cal->audio_info.rms_threshold_msb); + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_AUDIO_CTL_2, + 0x03 << 2, + mad_cal->audio_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD934X_SOC_MAD_AUDIO_CTL_7, + mad_cal->audio_info.rms_diff_threshold & 0x3F); + snd_soc_component_write(component, WCD934X_SOC_MAD_AUDIO_CTL_5, + mad_cal->audio_info.rms_threshold_lsb); + snd_soc_component_write(component, WCD934X_SOC_MAD_AUDIO_CTL_6, + mad_cal->audio_info.rms_threshold_msb); for (idx = 0; idx < ARRAY_SIZE(mad_cal->audio_info.iir_coefficients); idx++) { - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR, + snd_soc_component_update_bits(component, + WCD934X_SOC_MAD_AUDIO_IIR_CTL_PTR, 0x3F, idx); - snd_soc_write(codec, WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL, - mad_cal->audio_info.iir_coefficients[idx]); - dev_dbg(codec->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x", + snd_soc_component_write(component, + WCD934X_SOC_MAD_AUDIO_IIR_CTL_VAL, + mad_cal->audio_info.iir_coefficients[idx]); + dev_dbg(component->dev, "%s:MAD Audio IIR Coef[%d] = 0X%x", __func__, idx, mad_cal->audio_info.iir_coefficients[idx]); } /* Beacon */ - snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_8, - mad_cal->beacon_info.rms_omit_samples); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_CTL_1, - 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_CTL_2, 0x03 << 2, - mad_cal->beacon_info.detection_mechanism << 2); - snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_7, - mad_cal->beacon_info.rms_diff_threshold & 0x1F); - snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_5, - mad_cal->beacon_info.rms_threshold_lsb); - snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_CTL_6, - mad_cal->beacon_info.rms_threshold_msb); + snd_soc_component_write(component, WCD934X_SOC_MAD_BEACON_CTL_8, + mad_cal->beacon_info.rms_omit_samples); + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_BEACON_CTL_1, + 0x07 << 4, mad_cal->beacon_info.rms_comp_time << 4); + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_BEACON_CTL_2, + 0x03 << 2, + mad_cal->beacon_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD934X_SOC_MAD_BEACON_CTL_7, + mad_cal->beacon_info.rms_diff_threshold & 0x1F); + snd_soc_component_write(component, WCD934X_SOC_MAD_BEACON_CTL_5, + mad_cal->beacon_info.rms_threshold_lsb); + snd_soc_component_write(component, WCD934X_SOC_MAD_BEACON_CTL_6, + mad_cal->beacon_info.rms_threshold_msb); for (idx = 0; idx < ARRAY_SIZE(mad_cal->beacon_info.iir_coefficients); idx++) { - snd_soc_update_bits(codec, WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR, - 0x3F, idx); - snd_soc_write(codec, WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL, - mad_cal->beacon_info.iir_coefficients[idx]); - dev_dbg(codec->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x", + snd_soc_component_update_bits(component, + WCD934X_SOC_MAD_BEACON_IIR_CTL_PTR, + 0x3F, idx); + snd_soc_component_write(component, + WCD934X_SOC_MAD_BEACON_IIR_CTL_VAL, + mad_cal->beacon_info.iir_coefficients[idx]); + dev_dbg(component->dev, "%s:MAD Beacon IIR Coef[%d] = 0X%x", __func__, idx, mad_cal->beacon_info.iir_coefficients[idx]); } /* Ultrasound */ - snd_soc_update_bits(codec, WCD934X_SOC_MAD_ULTR_CTL_1, - 0x07 << 4, - mad_cal->ultrasound_info.rms_comp_time << 4); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_ULTR_CTL_2, 0x03 << 2, - mad_cal->ultrasound_info.detection_mechanism << 2); - snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_7, - mad_cal->ultrasound_info.rms_diff_threshold & 0x1F); - snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_5, + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_ULTR_CTL_1, + 0x07 << 4, + mad_cal->ultrasound_info.rms_comp_time << 4); + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_ULTR_CTL_2, + 0x03 << 2, + mad_cal->ultrasound_info.detection_mechanism << 2); + snd_soc_component_write(component, WCD934X_SOC_MAD_ULTR_CTL_7, + mad_cal->ultrasound_info.rms_diff_threshold & 0x1F); + snd_soc_component_write(component, WCD934X_SOC_MAD_ULTR_CTL_5, mad_cal->ultrasound_info.rms_threshold_lsb); - snd_soc_write(codec, WCD934X_SOC_MAD_ULTR_CTL_6, + snd_soc_component_write(component, WCD934X_SOC_MAD_ULTR_CTL_6, mad_cal->ultrasound_info.rms_threshold_msb); done: @@ -3135,46 +3265,54 @@ done: return ret; } -static int __tavil_codec_enable_mad(struct snd_soc_codec *codec, bool enable) +static int __tavil_codec_enable_mad(struct snd_soc_component *component, + bool enable) { int rc = 0; /* Return if CPE INPUT is DEC1 */ - if (snd_soc_read(codec, WCD934X_CPE_SS_SVA_CFG) & 0x04) { - dev_dbg(codec->dev, "%s: MAD is bypassed, skip mad %s\n", + if (snd_soc_component_read32( + component, WCD934X_CPE_SS_SVA_CFG) & 0x04) { + dev_dbg(component->dev, "%s: MAD is bypassed, skip mad %s\n", __func__, enable ? "enable" : "disable"); return rc; } - dev_dbg(codec->dev, "%s: enable = %s\n", __func__, + dev_dbg(component->dev, "%s: enable = %s\n", __func__, enable ? "enable" : "disable"); if (enable) { - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2, - 0x03, 0x03); - rc = tavil_codec_config_mad(codec); + snd_soc_component_update_bits(component, + WCD934X_SOC_MAD_AUDIO_CTL_2, + 0x03, 0x03); + rc = tavil_codec_config_mad(component); if (rc < 0) { - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD934X_SOC_MAD_AUDIO_CTL_2, + 0x03, 0x00); goto done; } /* Turn on MAD clk */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_MAD_CTL, + 0x01, 0x01); /* Undo reset for MAD */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_MAD_CTL, + 0x02, 0x00); } else { - snd_soc_update_bits(codec, WCD934X_SOC_MAD_AUDIO_CTL_2, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD934X_SOC_MAD_AUDIO_CTL_2, + 0x03, 0x00); /* Reset the MAD block */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL, - 0x02, 0x02); - /* Turn off MAD clk */ - snd_soc_update_bits(codec, WCD934X_CPE_SS_MAD_CTL, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_MAD_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_MAD_CTL, + 0x01, 0x00); } done: return rc; @@ -3184,18 +3322,21 @@ static int tavil_codec_ape_enable_mad(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int rc = 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x40, 0x40); - rc = __tavil_codec_enable_mad(codec, true); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_SVA_CFG, 0x40, 0x40); + rc = __tavil_codec_enable_mad(component, true); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x40, 0x00); - __tavil_codec_enable_mad(codec, false); + snd_soc_component_update_bits(component, + WCD934X_CPE_SS_SVA_CFG, 0x40, 0x00); + __tavil_codec_enable_mad(component, false); break; } @@ -3206,8 +3347,9 @@ static int tavil_codec_ape_enable_mad(struct snd_soc_dapm_widget *w, static int tavil_codec_cpe_mad_ctl(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int rc = 0; switch (event) { @@ -3216,8 +3358,9 @@ static int tavil_codec_cpe_mad_ctl(struct snd_soc_dapm_widget *w, if (tavil->mad_switch_cnt != 1) goto done; - snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x20, 0x20); - rc = __tavil_codec_enable_mad(codec, true); + snd_soc_component_update_bits(component, WCD934X_CPE_SS_SVA_CFG, + 0x20, 0x20); + rc = __tavil_codec_enable_mad(component, true); if (rc < 0) { tavil->mad_switch_cnt--; goto done; @@ -3229,8 +3372,9 @@ static int tavil_codec_cpe_mad_ctl(struct snd_soc_dapm_widget *w, if (tavil->mad_switch_cnt != 0) goto done; - snd_soc_update_bits(codec, WCD934X_CPE_SS_SVA_CFG, 0x20, 0x00); - __tavil_codec_enable_mad(codec, false); + snd_soc_component_update_bits(component, WCD934X_CPE_SS_SVA_CFG, + 0x20, 0x00); + __tavil_codec_enable_mad(component, false); break; } done: @@ -3281,24 +3425,25 @@ static int tavil_get_asrc_mode(struct tavil_priv *tavil, int asrc, static int tavil_codec_wdma3_ctl(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Fix to 16KHz */ - snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3, + snd_soc_component_update_bits(component, WCD934X_DMA_WDMA_CTL_3, 0xF0, 0x10); /* Select mclk_1 */ - snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3, + snd_soc_component_update_bits(component, WCD934X_DMA_WDMA_CTL_3, 0x02, 0x00); /* Enable DMA */ - snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3, + snd_soc_component_update_bits(component, WCD934X_DMA_WDMA_CTL_3, 0x01, 0x01); break; case SND_SOC_DAPM_POST_PMD: /* Disable DMA */ - snd_soc_update_bits(codec, WCD934X_DMA_WDMA_CTL_3, + snd_soc_component_update_bits(component, WCD934X_DMA_WDMA_CTL_3, 0x01, 0x00); break; @@ -3307,10 +3452,10 @@ static int tavil_codec_wdma3_ctl(struct snd_soc_dapm_widget *w, return 0; } -static int tavil_codec_enable_asrc(struct snd_soc_codec *codec, +static int tavil_codec_enable_asrc(struct snd_soc_component *component, int asrc_in, int event) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u16 cfg_reg, ctl_reg, clk_reg, asrc_ctl, mix_ctl_reg, paired_reg; int asrc, ret = 0; u8 main_sr, mix_sr, asrc_mode = 0; @@ -3365,8 +3510,8 @@ static int tavil_codec_enable_asrc(struct snd_soc_codec *codec, asrc = ASRC3; break; default: - dev_err(codec->dev, "%s: Invalid asrc input :%d\n", __func__, - asrc_in); + dev_err(component->dev, "%s: Invalid asrc input :%d\n", + __func__, asrc_in); ret = -EINVAL; goto done; }; @@ -3374,23 +3519,30 @@ static int tavil_codec_enable_asrc(struct snd_soc_codec *codec, switch (event) { case SND_SOC_DAPM_PRE_PMU: if (tavil->asrc_users[asrc] == 0) { - if ((snd_soc_read(codec, clk_reg) & 0x02) || - (snd_soc_read(codec, paired_reg) & 0x02)) { - snd_soc_update_bits(codec, clk_reg, - 0x02, 0x00); - snd_soc_update_bits(codec, paired_reg, - 0x02, 0x00); + if ((snd_soc_component_read32( + component, clk_reg) & 0x02) || + (snd_soc_component_read32( + component, paired_reg) & 0x02)) { + snd_soc_component_update_bits( + component, clk_reg, 0x02, 0x00); + snd_soc_component_update_bits( + component, paired_reg, 0x02, 0x00); } - snd_soc_update_bits(codec, cfg_reg, 0x80, 0x80); - snd_soc_update_bits(codec, clk_reg, 0x01, 0x01); - main_sr = snd_soc_read(codec, ctl_reg) & 0x0F; + snd_soc_component_update_bits( + component, cfg_reg, 0x80, 0x80); + snd_soc_component_update_bits( + component, clk_reg, 0x01, 0x01); + main_sr = snd_soc_component_read32( + component, ctl_reg) & 0x0F; mix_ctl_reg = ctl_reg + 5; - mix_sr = snd_soc_read(codec, mix_ctl_reg) & 0x0F; + mix_sr = snd_soc_component_read32( + component, mix_ctl_reg) & 0x0F; asrc_mode = tavil_get_asrc_mode(tavil, asrc, main_sr, mix_sr); - dev_dbg(codec->dev, "%s: main_sr:%d mix_sr:%d asrc_mode %d\n", + dev_dbg(component->dev, "%s: main_sr:%d mix_sr:%d asrc_mode %d\n", __func__, main_sr, mix_sr, asrc_mode); - snd_soc_update_bits(codec, asrc_ctl, 0x07, asrc_mode); + snd_soc_component_update_bits(component, asrc_ctl, + 0x07, asrc_mode); } tavil->asrc_users[asrc]++; break; @@ -3398,14 +3550,17 @@ static int tavil_codec_enable_asrc(struct snd_soc_codec *codec, tavil->asrc_users[asrc]--; if (tavil->asrc_users[asrc] <= 0) { tavil->asrc_users[asrc] = 0; - snd_soc_update_bits(codec, asrc_ctl, 0x07, 0x00); - snd_soc_update_bits(codec, cfg_reg, 0x80, 0x00); - snd_soc_update_bits(codec, clk_reg, 0x03, 0x02); + snd_soc_component_update_bits(component, asrc_ctl, + 0x07, 0x00); + snd_soc_component_update_bits(component, cfg_reg, + 0x80, 0x00); + snd_soc_component_update_bits(component, clk_reg, + 0x03, 0x02); } break; }; - dev_dbg(codec->dev, "%s: ASRC%d, users: %d\n", + dev_dbg(component->dev, "%s: ASRC%d, users: %d\n", __func__, asrc, tavil->asrc_users[asrc]); done: @@ -3416,13 +3571,15 @@ static int tavil_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int ret = 0; u8 cfg, asrc_in; - cfg = snd_soc_read(codec, WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0); + cfg = snd_soc_component_read32(component, + WCD934X_CDC_RX_INP_MUX_SPLINE_ASRC_CFG0); if (!(cfg & 0xFF)) { - dev_err(codec->dev, "%s: ASRC%u input not selected\n", + dev_err(component->dev, "%s: ASRC%u input not selected\n", __func__, w->shift); return -EINVAL; } @@ -3430,22 +3587,22 @@ static int tavil_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, switch (w->shift) { case ASRC0: asrc_in = ((cfg & 0x03) == 1) ? ASRC_IN_HPHL : ASRC_IN_LO1; - ret = tavil_codec_enable_asrc(codec, asrc_in, event); + ret = tavil_codec_enable_asrc(component, asrc_in, event); break; case ASRC1: asrc_in = ((cfg & 0x0C) == 4) ? ASRC_IN_HPHR : ASRC_IN_LO2; - ret = tavil_codec_enable_asrc(codec, asrc_in, event); + ret = tavil_codec_enable_asrc(component, asrc_in, event); break; case ASRC2: asrc_in = ((cfg & 0x30) == 0x20) ? ASRC_IN_SPKR1 : ASRC_INVALID; - ret = tavil_codec_enable_asrc(codec, asrc_in, event); + ret = tavil_codec_enable_asrc(component, asrc_in, event); break; case ASRC3: asrc_in = ((cfg & 0xC0) == 0x80) ? ASRC_IN_SPKR2 : ASRC_INVALID; - ret = tavil_codec_enable_asrc(codec, asrc_in, event); + ret = tavil_codec_enable_asrc(component, asrc_in, event); break; default: - dev_err(codec->dev, "%s: Invalid asrc:%u\n", __func__, + dev_err(component->dev, "%s: Invalid asrc:%u\n", __func__, w->shift); ret = -EINVAL; break; @@ -3457,26 +3614,31 @@ static int tavil_codec_enable_asrc_resampler(struct snd_soc_dapm_widget *w, static int tavil_enable_native_supply(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (++tavil->native_clk_users == 1) { - snd_soc_update_bits(codec, WCD934X_CLK_SYS_PLL_ENABLES, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_PLL_ENABLES, + 0x01, 0x01); usleep_range(100, 120); - snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1, - 0x06, 0x02); - snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, - 0x04, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_MCLK2_PRG1, + 0x06, 0x02); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_MCLK2_PRG1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CODEC_RPM_CLK_GATE, + 0x04, 0x00); usleep_range(30, 50); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x02); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x10, 0x10); } @@ -3484,39 +3646,42 @@ static int tavil_enable_native_supply(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: if (tavil->native_clk_users && (--tavil->native_clk_users == 0)) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_FS_CNT_CONTROL, 0x10, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD934X_CDC_CLK_RST_CTRL_MCLK_CONTROL, 0x02, 0x00); - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_GATE, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CLK_SYS_MCLK2_PRG1, - 0x06, 0x00); - snd_soc_update_bits(codec, WCD934X_CLK_SYS_PLL_ENABLES, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CODEC_RPM_CLK_GATE, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_MCLK2_PRG1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_MCLK2_PRG1, + 0x06, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CLK_SYS_PLL_ENABLES, + 0x01, 0x00); } break; } - dev_dbg(codec->dev, "%s: native_clk_users: %d, event: %d\n", + dev_dbg(component->dev, "%s: native_clk_users: %d, event: %d\n", __func__, tavil->native_clk_users, event); return 0; } -static void tavil_codec_hphdelay_lutbypass(struct snd_soc_codec *codec, +static void tavil_codec_hphdelay_lutbypass(struct snd_soc_component *component, u16 interp_idx, int event) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u8 hph_dly_mask; u16 hph_lut_bypass_reg = 0; u16 hph_comp_ctrl7 = 0; - switch (interp_idx) { case INTERP_HPHL: hph_dly_mask = 1; @@ -3533,18 +3698,22 @@ static void tavil_codec_hphdelay_lutbypass(struct snd_soc_codec *codec, } if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, WCD934X_CDC_CLSH_TEST0, + snd_soc_component_update_bits(component, WCD934X_CDC_CLSH_TEST0, hph_dly_mask, 0x0); - snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x80); + snd_soc_component_update_bits(component, hph_lut_bypass_reg, + 0x80, 0x80); if (tavil->hph_mode == CLS_H_ULP) - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x20); + snd_soc_component_update_bits(component, hph_comp_ctrl7, + 0x20, 0x20); } if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, WCD934X_CDC_CLSH_TEST0, + snd_soc_component_update_bits(component, WCD934X_CDC_CLSH_TEST0, hph_dly_mask, hph_dly_mask); - snd_soc_update_bits(codec, hph_lut_bypass_reg, 0x80, 0x00); - snd_soc_update_bits(codec, hph_comp_ctrl7, 0x20, 0x0); + snd_soc_component_update_bits(component, hph_lut_bypass_reg, + 0x80, 0x00); + snd_soc_component_update_bits(component, hph_comp_ctrl7, + 0x20, 0x0); } } @@ -3553,7 +3722,7 @@ static void tavil_codec_hd2_control(struct tavil_priv *priv, { u16 hd2_scale_reg; u16 hd2_enable_reg = 0; - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; if (TAVIL_IS_1_1(priv->wcd9xxx)) return; @@ -3570,21 +3739,25 @@ static void tavil_codec_hd2_control(struct tavil_priv *priv, } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) { - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x14); - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x04); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x14); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x04); } if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, hd2_enable_reg, 0x04, 0x00); - snd_soc_update_bits(codec, hd2_scale_reg, 0x3C, 0x00); + snd_soc_component_update_bits(component, hd2_enable_reg, + 0x04, 0x00); + snd_soc_component_update_bits(component, hd2_scale_reg, + 0x3C, 0x00); } } -static int tavil_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, +static int tavil_codec_config_ear_spkr_gain(struct snd_soc_component *component, int event, int gain_reg) { int comp_gain_offset, val; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); switch (tavil->swr.spkr_mode) { /* Compander gain in SPKR_MODE1 case is 12 dB */ @@ -3606,9 +3779,9 @@ static int tavil_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, (tavil->ear_spkr_gain != 0)) { /* For example, val is -8(-12+5-1) for 4dB of gain */ val = comp_gain_offset + tavil->ear_spkr_gain - 1; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); - dev_dbg(codec->dev, "%s: RX7 Volume %d dB\n", + dev_dbg(component->dev, "%s: RX7 Volume %d dB\n", __func__, val); } break; @@ -3621,9 +3794,9 @@ static int tavil_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL || gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL) && (tavil->ear_spkr_gain != 0)) { - snd_soc_write(codec, gain_reg, 0x0); + snd_soc_component_write(component, gain_reg, 0x0); - dev_dbg(codec->dev, "%s: Reset RX7 Volume to 0 dB\n", + dev_dbg(component->dev, "%s: Reset RX7 Volume to 0 dB\n", __func__); } break; @@ -3632,10 +3805,10 @@ static int tavil_codec_config_ear_spkr_gain(struct snd_soc_codec *codec, return 0; } -static int tavil_config_compander(struct snd_soc_codec *codec, int interp_n, - int event) +static int tavil_config_compander(struct snd_soc_component *component, + int interp_n, int event) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int comp; u16 comp_ctl0_reg, rx_path_cfg0_reg; @@ -3644,7 +3817,7 @@ static int tavil_config_compander(struct snd_soc_codec *codec, int interp_n, return 0; comp = interp_n - 1; - dev_dbg(codec->dev, "%s: event %d compander %d, enabled %d\n", + dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n", __func__, event, comp + 1, tavil->comp_enabled[comp]); if (!tavil->comp_enabled[comp]) @@ -3655,29 +3828,39 @@ static int tavil_config_compander(struct snd_soc_codec *codec, int interp_n, if (SND_SOC_DAPM_EVENT_ON(event)) { /* Enable Compander Clock */ - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x01); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x01); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x02); } if (SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, rx_path_cfg0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x04); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x02); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x02, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x01, 0x00); - snd_soc_update_bits(codec, comp_ctl0_reg, 0x04, 0x00); + snd_soc_component_update_bits(component, rx_path_cfg0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x04); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x02); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x02, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x01, 0x00); + snd_soc_component_update_bits(component, comp_ctl0_reg, + 0x04, 0x00); } return 0; } -static void tavil_codec_idle_detect_control(struct snd_soc_codec *codec, +static void tavil_codec_idle_detect_control(struct snd_soc_component *component, int interp, int event) { int reg = 0, mask, val; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); if (!tavil->idle_det_cfg.hph_idle_detect_en) return; @@ -3694,12 +3877,13 @@ static void tavil_codec_idle_detect_control(struct snd_soc_codec *codec, } if (reg && SND_SOC_DAPM_EVENT_ON(event)) - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); if (reg && SND_SOC_DAPM_EVENT_OFF(event)) { - snd_soc_update_bits(codec, reg, mask, 0x00); + snd_soc_component_update_bits(component, reg, mask, 0x00); tavil->idle_det_cfg.hph_idle_thr = 0; - snd_soc_write(codec, WCD934X_CDC_RX_IDLE_DET_CFG3, 0x0); + snd_soc_component_write(component, WCD934X_CDC_RX_IDLE_DET_CFG3, + 0x0); } } @@ -3707,37 +3891,39 @@ static void tavil_codec_idle_detect_control(struct snd_soc_codec *codec, * tavil_codec_enable_interp_clk - Enable main path Interpolator * clock. * - * @codec: Codec instance + * @component: Codec component instance * @event: Indicates speaker path gain offset value * @intp_idx: Interpolator index * Returns number of main clock users */ -int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec, +int tavil_codec_enable_interp_clk(struct snd_soc_component *component, int event, int interp_idx) { struct tavil_priv *tavil; u16 main_reg; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return -EINVAL; } - tavil = snd_soc_codec_get_drvdata(codec); + tavil = snd_soc_component_get_drvdata(component); main_reg = WCD934X_CDC_RX0_RX_PATH_CTL + (interp_idx * 20); if (SND_SOC_DAPM_EVENT_ON(event)) { if (tavil->main_clk_users[interp_idx] == 0) { /* Main path PGA mute enable */ - snd_soc_update_bits(codec, main_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, main_reg, + 0x10, 0x10); /* Clk enable */ - snd_soc_update_bits(codec, main_reg, 0x20, 0x20); - tavil_codec_idle_detect_control(codec, interp_idx, + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x20); + tavil_codec_idle_detect_control(component, interp_idx, event); tavil_codec_hd2_control(tavil, interp_idx, event); - tavil_codec_hphdelay_lutbypass(codec, interp_idx, + tavil_codec_hphdelay_lutbypass(component, interp_idx, event); - tavil_config_compander(codec, interp_idx, event); + tavil_config_compander(component, interp_idx, event); } tavil->main_clk_users[interp_idx]++; } @@ -3746,23 +3932,27 @@ int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec, tavil->main_clk_users[interp_idx]--; if (tavil->main_clk_users[interp_idx] <= 0) { tavil->main_clk_users[interp_idx] = 0; - tavil_config_compander(codec, interp_idx, event); - tavil_codec_hphdelay_lutbypass(codec, interp_idx, + tavil_config_compander(component, interp_idx, event); + tavil_codec_hphdelay_lutbypass(component, interp_idx, event); tavil_codec_hd2_control(tavil, interp_idx, event); - tavil_codec_idle_detect_control(codec, interp_idx, + tavil_codec_idle_detect_control(component, interp_idx, event); /* Clk Disable */ - snd_soc_update_bits(codec, main_reg, 0x20, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x20, 0x00); /* Reset enable and disable */ - snd_soc_update_bits(codec, main_reg, 0x40, 0x40); - snd_soc_update_bits(codec, main_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x40); + snd_soc_component_update_bits(component, main_reg, + 0x40, 0x00); /* Reset rate to 48K*/ - snd_soc_update_bits(codec, main_reg, 0x0F, 0x04); + snd_soc_component_update_bits(component, main_reg, + 0x0F, 0x04); } } - dev_dbg(codec->dev, "%s event %d main_clk_users %d\n", + dev_dbg(component->dev, "%s event %d main_clk_users %d\n", __func__, event, tavil->main_clk_users[interp_idx]); return tavil->main_clk_users[interp_idx]; @@ -3772,20 +3962,21 @@ EXPORT_SYMBOL(tavil_codec_enable_interp_clk); static int tavil_anc_out_switch_cb(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - tavil_codec_enable_interp_clk(codec, event, w->shift); + tavil_codec_enable_interp_clk(component, event, w->shift); return 0; } -static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, +static int tavil_codec_set_idle_detect_thr(struct snd_soc_component *component, int interp, int path_type) { int port_id[4] = { 0, 0, 0, 0 }; int *port_ptr, num_ports; int bit_width = 0, i; int mux_reg, mux_reg_val; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int dai_id, idle_thr; if ((interp != INTERP_HPHL) && (interp != INTERP_HPHR)) @@ -3805,7 +3996,8 @@ static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, if (path_type == INTERP_MIX_PATH) { mux_reg = WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG1 + 2 * (interp - 1); - mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f; + mux_reg_val = snd_soc_component_read32(component, mux_reg) & + 0x0f; if ((mux_reg_val >= INTn_2_INP_SEL_RX0) && (mux_reg_val < INTn_2_INP_SEL_PROXIMITY)) { @@ -3818,7 +4010,8 @@ static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, if (path_type == INTERP_MAIN_PATH) { mux_reg = WCD934X_CDC_RX_INP_MUX_RX_INT1_CFG0 + 2 * (interp - 1); - mux_reg_val = snd_soc_read(codec, mux_reg) & 0x0f; + mux_reg_val = snd_soc_component_read32(component, mux_reg) & + 0x0f; i = WCD934X_INTERP_MUX_NUM_INPUTS; while (i) { @@ -3829,14 +4022,14 @@ static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, INTn_1_INP_SEL_RX0; num_ports++; } - mux_reg_val = (snd_soc_read(codec, mux_reg) & - 0xf0) >> 4; + mux_reg_val = (snd_soc_component_read32( + component, mux_reg) & 0xf0) >> 4; mux_reg += 1; i--; } } - dev_dbg(codec->dev, "%s: num_ports: %d, ports[%d %d %d %d]\n", + dev_dbg(component->dev, "%s: num_ports: %d, ports[%d %d %d %d]\n", __func__, num_ports, port_id[0], port_id[1], port_id[2], port_id[3]); @@ -3846,7 +4039,7 @@ static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, tavil); if ((dai_id >= 0) && (dai_id < NUM_CODEC_DAIS)) { - dev_dbg(codec->dev, "%s: dai_id: %d bit_width: %d\n", + dev_dbg(component->dev, "%s: dai_id: %d bit_width: %d\n", __func__, dai_id, tavil->dai[dai_id].bit_width); @@ -3870,12 +4063,13 @@ static int tavil_codec_set_idle_detect_thr(struct snd_soc_codec *codec, break; } - dev_dbg(codec->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", + dev_dbg(component->dev, "%s: (new) idle_thr: %d, (cur) idle_thr: %d\n", __func__, idle_thr, tavil->idle_det_cfg.hph_idle_thr); if ((tavil->idle_det_cfg.hph_idle_thr == 0) || (idle_thr < tavil->idle_det_cfg.hph_idle_thr)) { - snd_soc_write(codec, WCD934X_CDC_RX_IDLE_DET_CFG3, idle_thr); + snd_soc_component_write(component, WCD934X_CDC_RX_IDLE_DET_CFG3, + idle_thr); tavil->idle_det_cfg.hph_idle_thr = idle_thr; } @@ -3886,15 +4080,16 @@ static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u16 gain_reg, mix_reg; int offset_val = 0; int val = 0; if (w->shift >= WCD934X_NUM_INTERPOLATORS || w->shift == INTERP_LO3_NA || w->shift == INTERP_LO4_NA) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; }; @@ -3909,11 +4104,11 @@ static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_codec_set_idle_detect_thr(codec, w->shift, + tavil_codec_set_idle_detect_thr(component, w->shift, INTERP_MIX_PATH); - tavil_codec_enable_interp_clk(codec, event, w->shift); + tavil_codec_enable_interp_clk(component, event, w->shift); /* Clk enable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x20); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x20); break; case SND_SOC_DAPM_POST_PMU: if ((tavil->swr.spkr_gain_offset == @@ -3922,30 +4117,32 @@ static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w, tavil->comp_enabled[COMPANDER_8]) && (gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL || gain_reg == WCD934X_CDC_RX8_RX_VOL_MIX_CTL)) { - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x01); offset_val = -2; } - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); - tavil_codec_config_ear_spkr_gain(codec, event, gain_reg); + snd_soc_component_write(component, gain_reg, val); + tavil_codec_config_ear_spkr_gain(component, event, gain_reg); break; case SND_SOC_DAPM_POST_PMD: /* Clk Disable */ - snd_soc_update_bits(codec, mix_reg, 0x20, 0x00); - tavil_codec_enable_interp_clk(codec, event, w->shift); + snd_soc_component_update_bits(component, mix_reg, 0x20, 0x00); + tavil_codec_enable_interp_clk(component, event, w->shift); /* Reset enable and disable */ - snd_soc_update_bits(codec, mix_reg, 0x40, 0x40); - snd_soc_update_bits(codec, mix_reg, 0x40, 0x00); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x40); + snd_soc_component_update_bits(component, mix_reg, 0x40, 0x00); if ((tavil->swr.spkr_gain_offset == WCD934X_RX_GAIN_OFFSET_M1P5_DB) && @@ -3953,25 +4150,28 @@ static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w, tavil->comp_enabled[COMPANDER_8]) && (gain_reg == WCD934X_CDC_RX7_RX_VOL_MIX_CTL || gain_reg == WCD934X_CDC_RX8_RX_VOL_MIX_CTL)) { - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x00); offset_val = 2; - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); } - tavil_codec_config_ear_spkr_gain(codec, event, gain_reg); + tavil_codec_config_ear_spkr_gain(component, event, gain_reg); break; }; - dev_dbg(codec->dev, "%s event %d name %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s event %d name %s\n", __func__, + event, w->name); return 0; } @@ -3979,18 +4179,19 @@ static int tavil_codec_enable_mix_path(struct snd_soc_dapm_widget *w, /** * tavil_get_dsd_config - Get pointer to dsd config structure * - * @codec: pointer to snd_soc_codec structure + * @component: pointer to snd_soc_component structure * * Returns pointer to tavil_dsd_config structure */ -struct tavil_dsd_config *tavil_get_dsd_config(struct snd_soc_codec *codec) +struct tavil_dsd_config *tavil_get_dsd_config( + struct snd_soc_component *component) { struct tavil_priv *tavil; - if (!codec) + if (!component) return NULL; - tavil = snd_soc_codec_get_drvdata(codec); + tavil = snd_soc_component_get_drvdata(component); if (!tavil) return NULL; @@ -4003,18 +4204,19 @@ static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u16 gain_reg; u16 reg; int val; int offset_val = 0; - dev_dbg(codec->dev, "%s %d %s\n", __func__, event, w->name); + dev_dbg(component->dev, "%s %d %s\n", __func__, event, w->name); if (w->shift >= WCD934X_NUM_INTERPOLATORS || w->shift == INTERP_LO3_NA || w->shift == INTERP_LO4_NA) { - dev_err(codec->dev, "%s: Invalid Interpolator value %d for name %s\n", + dev_err(component->dev, "%s: Invalid Interpolator value %d for name %s\n", __func__, w->shift, w->name); return -EINVAL; }; @@ -4026,9 +4228,9 @@ static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_codec_set_idle_detect_thr(codec, w->shift, + tavil_codec_set_idle_detect_thr(component, w->shift, INTERP_MAIN_PATH); - tavil_codec_enable_interp_clk(codec, event, w->shift); + tavil_codec_enable_interp_clk(component, event, w->shift); break; case SND_SOC_DAPM_POST_PMU: /* apply gain after int clk is enabled */ @@ -4038,25 +4240,27 @@ static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w, tavil->comp_enabled[COMPANDER_8]) && (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL || gain_reg == WCD934X_CDC_RX8_RX_VOL_CTL)) { - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x01); - snd_soc_update_bits(codec, - WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x01); offset_val = -2; } - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); - tavil_codec_config_ear_spkr_gain(codec, event, gain_reg); + snd_soc_component_write(component, gain_reg, val); + tavil_codec_config_ear_spkr_gain(component, event, gain_reg); break; case SND_SOC_DAPM_POST_PMD: - tavil_codec_enable_interp_clk(codec, event, w->shift); + tavil_codec_enable_interp_clk(component, event, w->shift); if ((tavil->swr.spkr_gain_offset == WCD934X_RX_GAIN_OFFSET_M1P5_DB) && @@ -4064,22 +4268,24 @@ static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w, tavil->comp_enabled[COMPANDER_8]) && (gain_reg == WCD934X_CDC_RX7_RX_VOL_CTL || gain_reg == WCD934X_CDC_RX8_RX_VOL_CTL)) { - snd_soc_update_bits(codec, WCD934X_CDC_RX7_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, - 0x01, 0x00); - snd_soc_update_bits(codec, WCD934X_CDC_RX8_RX_PATH_SEC1, - 0x01, 0x00); - snd_soc_update_bits(codec, - WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX7_RX_PATH_MIX_SEC0, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_SEC1, + 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CDC_RX8_RX_PATH_MIX_SEC0, + 0x01, 0x00); offset_val = 2; - val = snd_soc_read(codec, gain_reg); + val = snd_soc_component_read32(component, gain_reg); val += offset_val; - snd_soc_write(codec, gain_reg, val); + snd_soc_component_write(component, gain_reg, val); } - tavil_codec_config_ear_spkr_gain(codec, event, gain_reg); + tavil_codec_config_ear_spkr_gain(component, event, gain_reg); break; }; @@ -4089,42 +4295,43 @@ static int tavil_codec_enable_main_path(struct snd_soc_dapm_widget *w, static int tavil_codec_set_iir_gain(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event = %d\n", __func__, event); + dev_dbg(component->dev, "%s: event = %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: /* fall through */ case SND_SOC_DAPM_PRE_PMD: if (strnstr(w->name, "IIR0", sizeof("IIR0"))) { - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL)); } else { - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL)); - snd_soc_write(codec, + snd_soc_component_write(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, - snd_soc_read(codec, + snd_soc_component_read32(component, WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL)); } break; @@ -4132,7 +4339,7 @@ static int tavil_codec_set_iir_gain(struct snd_soc_dapm_widget *w, return 0; } -static int tavil_codec_find_amic_input(struct snd_soc_codec *codec, +static int tavil_codec_find_amic_input(struct snd_soc_component *component, int adc_mux_n) { u16 mask, shift, adc_mux_in_reg; @@ -4192,15 +4399,16 @@ static int tavil_codec_find_amic_input(struct snd_soc_codec *codec, adc_mux_n - 5; } - is_amic = (((snd_soc_read(codec, adc_mux_in_reg) & mask) >> shift) + is_amic = (((snd_soc_component_read32(component, adc_mux_in_reg) & + mask) >> shift) == 1); if (!is_amic) return 0; - return snd_soc_read(codec, amic_mux_sel_reg) & 0x07; + return snd_soc_component_read32(component, amic_mux_sel_reg) & 0x07; } -static void tavil_codec_set_tx_hold(struct snd_soc_codec *codec, +static void tavil_codec_set_tx_hold(struct snd_soc_component *component, u16 amic_reg, bool set) { u8 mask = 0x20; @@ -4215,14 +4423,16 @@ static void tavil_codec_set_tx_hold(struct snd_soc_codec *codec, switch (amic_reg) { case WCD934X_ANA_AMIC1: case WCD934X_ANA_AMIC2: - snd_soc_update_bits(codec, WCD934X_ANA_AMIC2, mask, val); + snd_soc_component_update_bits(component, WCD934X_ANA_AMIC2, + mask, val); break; case WCD934X_ANA_AMIC3: case WCD934X_ANA_AMIC4: - snd_soc_update_bits(codec, WCD934X_ANA_AMIC4, mask, val); + snd_soc_component_update_bits(component, WCD934X_ANA_AMIC4, + mask, val); break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic_reg); break; } @@ -4232,15 +4442,16 @@ static int tavil_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { int adc_mux_n = w->shift; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int amic_n; - dev_dbg(codec->dev, "%s: event: %d\n", __func__, event); + dev_dbg(component->dev, "%s: event: %d\n", __func__, event); switch (event) { case SND_SOC_DAPM_POST_PMU: - amic_n = tavil_codec_find_amic_input(codec, adc_mux_n); + amic_n = tavil_codec_find_amic_input(component, adc_mux_n); if (amic_n) { /* * Prevent ANC Rx pop by leaving Tx FE in HOLD @@ -4258,7 +4469,8 @@ static int tavil_codec_tx_adc_cfg(struct snd_soc_dapm_widget *w, return 0; } -static u16 tavil_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) +static u16 tavil_codec_get_amic_pwlvl_reg(struct snd_soc_component *component, + int amic) { u16 pwr_level_reg = 0; @@ -4273,7 +4485,7 @@ static u16 tavil_codec_get_amic_pwlvl_reg(struct snd_soc_codec *codec, int amic) pwr_level_reg = WCD934X_ANA_AMIC3; break; default: - dev_dbg(codec->dev, "%s: invalid amic: %d\n", + dev_dbg(component->dev, "%s: invalid amic: %d\n", __func__, amic); break; } @@ -4291,7 +4503,7 @@ static void tavil_tx_hpf_corner_freq_callback(struct work_struct *work) struct delayed_work *hpf_delayed_work; struct hpf_work *hpf_work; struct tavil_priv *tavil; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 dec_cfg_reg, amic_reg, go_bit_reg; u8 hpf_cut_off_freq; int amic_n; @@ -4299,26 +4511,27 @@ static void tavil_tx_hpf_corner_freq_callback(struct work_struct *work) hpf_delayed_work = to_delayed_work(work); hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork); tavil = hpf_work->tavil; - codec = tavil->codec; + component = tavil->component; hpf_cut_off_freq = hpf_work->hpf_cut_off_freq; dec_cfg_reg = WCD934X_CDC_TX0_TX_PATH_CFG0 + 16 * hpf_work->decimator; go_bit_reg = dec_cfg_reg + 7; - dev_dbg(codec->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", + dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n", __func__, hpf_work->decimator, hpf_cut_off_freq); - amic_n = tavil_codec_find_amic_input(codec, hpf_work->decimator); + amic_n = tavil_codec_find_amic_input(component, hpf_work->decimator); if (amic_n) { amic_reg = WCD934X_ANA_AMIC1 + amic_n - 1; - tavil_codec_set_tx_hold(codec, amic_reg, false); + tavil_codec_set_tx_hold(component, amic_reg, false); } - snd_soc_update_bits(codec, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, go_bit_reg, 0x02, 0x02); /* Minimum 1 clk cycle delay is required as per HW spec */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, go_bit_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, go_bit_reg, 0x02, 0x00); } static void tavil_tx_mute_update_callback(struct work_struct *work) @@ -4326,40 +4539,43 @@ static void tavil_tx_mute_update_callback(struct work_struct *work) struct tx_mute_work *tx_mute_dwork; struct tavil_priv *tavil; struct delayed_work *delayed_work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 tx_vol_ctl_reg, hpf_gate_reg; delayed_work = to_delayed_work(work); tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork); tavil = tx_mute_dwork->tavil; - codec = tavil->codec; + component = tavil->component; tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * tx_mute_dwork->decimator; hpf_gate_reg = WCD934X_CDC_TX0_TX_PATH_SEC2 + 16 * tx_mute_dwork->decimator; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00); } static int tavil_codec_enable_rx_path_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); u16 sidetone_reg; - dev_dbg(codec->dev, "%s %d %d\n", __func__, event, w->shift); + dev_dbg(component->dev, "%s %d %d\n", __func__, event, w->shift); sidetone_reg = WCD934X_CDC_RX0_RX_PATH_CFG1 + 0x14*(w->shift); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (!strcmp(w->name, "RX INT7 MIX2 INP")) __tavil_codec_enable_swr(w, event); - tavil_codec_enable_interp_clk(codec, event, w->shift); - snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x10); + tavil_codec_enable_interp_clk(component, event, w->shift); + snd_soc_component_update_bits(component, sidetone_reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, sidetone_reg, 0x10, 0x00); - tavil_codec_enable_interp_clk(codec, event, w->shift); + snd_soc_component_update_bits(component, sidetone_reg, + 0x10, 0x00); + tavil_codec_enable_interp_clk(component, event, w->shift); if (!strcmp(w->name, "RX INT7 MIX2 INP")) __tavil_codec_enable_swr(w, event); break; @@ -4372,8 +4588,9 @@ static int tavil_codec_enable_rx_path_clk(struct snd_soc_dapm_widget *w, static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); unsigned int decimator; char *dec_adc_mux_name = NULL; char *widget_name = NULL; @@ -4384,7 +4601,7 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, char *dec; u8 hpf_cut_off_freq; - dev_dbg(codec->dev, "%s %d\n", __func__, event); + dev_dbg(component->dev, "%s %d\n", __func__, event); widget_name = kstrndup(w->name, 15, GFP_KERNEL); if (!widget_name) @@ -4393,7 +4610,7 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, wname = widget_name; dec_adc_mux_name = strsep(&widget_name, " "); if (!dec_adc_mux_name) { - dev_err(codec->dev, "%s: Invalid decimator = %s\n", + dev_err(component->dev, "%s: Invalid decimator = %s\n", __func__, w->name); ret = -EINVAL; goto out; @@ -4402,7 +4619,7 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, dec = strpbrk(dec_adc_mux_name, "012345678"); if (!dec) { - dev_err(codec->dev, "%s: decimator index not found\n", + dev_err(component->dev, "%s: decimator index not found\n", __func__); ret = -EINVAL; goto out; @@ -4410,13 +4627,13 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, ret = kstrtouint(dec, 10, &decimator); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid decimator = %s\n", + dev_err(component->dev, "%s: Invalid decimator = %s\n", __func__, wname); ret = -EINVAL; goto out; } - dev_dbg(codec->dev, "%s(): widget = %s decimator = %u\n", __func__, + dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__, w->name, decimator); tx_vol_ctl_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; @@ -4426,55 +4643,63 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - amic_n = tavil_codec_find_amic_input(codec, decimator); + amic_n = tavil_codec_find_amic_input(component, decimator); if (amic_n) - pwr_level_reg = tavil_codec_get_amic_pwlvl_reg(codec, - amic_n); + pwr_level_reg = tavil_codec_get_amic_pwlvl_reg( + component, amic_n); if (pwr_level_reg) { - switch ((snd_soc_read(codec, pwr_level_reg) & - WCD934X_AMIC_PWR_LVL_MASK) >> - WCD934X_AMIC_PWR_LVL_SHIFT) { + switch ((snd_soc_component_read32( + component, pwr_level_reg) & + WCD934X_AMIC_PWR_LVL_MASK) >> + WCD934X_AMIC_PWR_LVL_SHIFT) { case WCD934X_AMIC_PWR_LEVEL_LP: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD934X_DEC_PWR_LVL_MASK, - WCD934X_DEC_PWR_LVL_LP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_LP); break; case WCD934X_AMIC_PWR_LEVEL_HP: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD934X_DEC_PWR_LVL_MASK, - WCD934X_DEC_PWR_LVL_HP); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_HP); break; case WCD934X_AMIC_PWR_LEVEL_DEFAULT: case WCD934X_AMIC_PWR_LEVEL_HYBRID: default: - snd_soc_update_bits(codec, dec_cfg_reg, - WCD934X_DEC_PWR_LVL_MASK, - WCD934X_DEC_PWR_LVL_DF); + snd_soc_component_update_bits( + component, dec_cfg_reg, + WCD934X_DEC_PWR_LVL_MASK, + WCD934X_DEC_PWR_LVL_DF); break; } } /* Enable TX PGA Mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); break; case SND_SOC_DAPM_POST_PMU: - hpf_cut_off_freq = (snd_soc_read(codec, dec_cfg_reg) & - TX_HPF_CUT_OFF_FREQ_MASK) >> 5; + hpf_cut_off_freq = (snd_soc_component_read32( + component, dec_cfg_reg) & + TX_HPF_CUT_OFF_FREQ_MASK) >> 5; tavil->tx_hpf_work[decimator].hpf_cut_off_freq = hpf_cut_off_freq; if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK, CF_MIN_3DB_150HZ << 5); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x02); + snd_soc_component_update_bits(component, hpf_gate_reg, + 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per * HW spec. */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, 0x02, 0x00); + snd_soc_component_update_bits(component, hpf_gate_reg, + 0x02, 0x00); } /* schedule work queue to Remove Mute */ schedule_delayed_work(&tavil->tx_mute_dwork[decimator].dwork, @@ -4485,36 +4710,42 @@ static int tavil_codec_enable_dec(struct snd_soc_dapm_widget *w, &tavil->tx_hpf_work[decimator].dwork, msecs_to_jiffies(300)); /* apply gain after decimator is enabled */ - snd_soc_write(codec, tx_gain_ctl_reg, - snd_soc_read(codec, tx_gain_ctl_reg)); + snd_soc_component_write(component, tx_gain_ctl_reg, + snd_soc_component_read32( + component, tx_gain_ctl_reg)); break; case SND_SOC_DAPM_PRE_PMD: hpf_cut_off_freq = tavil->tx_hpf_work[decimator].hpf_cut_off_freq; - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x10); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x10); if (cancel_delayed_work_sync( &tavil->tx_hpf_work[decimator].dwork)) { if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) { - snd_soc_update_bits(codec, dec_cfg_reg, - TX_HPF_CUT_OFF_FREQ_MASK, - hpf_cut_off_freq << 5); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x02); + snd_soc_component_update_bits(component, + dec_cfg_reg, + TX_HPF_CUT_OFF_FREQ_MASK, + hpf_cut_off_freq << 5); + snd_soc_component_update_bits(component, + hpf_gate_reg, + 0x02, 0x02); /* * Minimum 1 clk cycle delay is required as per * HW spec. */ usleep_range(1000, 1010); - snd_soc_update_bits(codec, hpf_gate_reg, - 0x02, 0x00); + snd_soc_component_update_bits(component, + hpf_gate_reg, + 0x02, 0x00); } } cancel_delayed_work_sync( &tavil->tx_mute_dwork[decimator].dwork); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, tx_vol_ctl_reg, 0x10, 0x00); - snd_soc_update_bits(codec, dec_cfg_reg, + snd_soc_component_update_bits(component, tx_vol_ctl_reg, + 0x10, 0x00); + snd_soc_component_update_bits(component, dec_cfg_reg, WCD934X_DEC_PWR_LVL_MASK, WCD934X_DEC_PWR_LVL_DF); break; @@ -4524,7 +4755,7 @@ out: return ret; } -static u32 tavil_get_dmic_sample_rate(struct snd_soc_codec *codec, +static u32 tavil_get_dmic_sample_rate(struct snd_soc_component *component, unsigned int dmic, struct wcd9xxx_pdata *pdata) { @@ -4545,7 +4776,8 @@ static u32 tavil_get_dmic_sample_rate(struct snd_soc_codec *codec, ++adc_mux_index; continue; } - adc_mux_sel = ((snd_soc_read(codec, adc_mux_ctl_reg) & + adc_mux_sel = ((snd_soc_component_read32( + component, adc_mux_ctl_reg) & 0xF8) >> 3) - 1; if (adc_mux_sel == dmic) { @@ -4558,7 +4790,8 @@ static u32 tavil_get_dmic_sample_rate(struct snd_soc_codec *codec, if (dec_found && adc_mux_index <= 8) { tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL + (16 * adc_mux_index); - tx_stream_fs = snd_soc_read(codec, tx_fs_reg) & 0x0F; + tx_stream_fs = snd_soc_component_read32( + component, tx_fs_reg) & 0x0F; if (tx_stream_fs <= 4) { if (pdata->dmic_sample_rate <= WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ) @@ -4574,13 +4807,13 @@ static u32 tavil_get_dmic_sample_rate(struct snd_soc_codec *codec, return dmic_fs; } -static u8 tavil_get_dmic_clk_val(struct snd_soc_codec *codec, +static u8 tavil_get_dmic_clk_val(struct snd_soc_component *component, u32 mclk_rate, u32 dmic_clk_rate) { u32 div_factor; u8 dmic_ctl_val; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: mclk_rate = %d, dmic_sample_rate = %d\n", __func__, mclk_rate, dmic_clk_rate); @@ -4591,7 +4824,7 @@ static u8 tavil_get_dmic_clk_val(struct snd_soc_codec *codec, dmic_ctl_val = WCD934X_DMIC_CLK_DIV_3; if (dmic_clk_rate == 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: dmic_sample_rate cannot be 0\n", __func__); goto done; @@ -4618,7 +4851,7 @@ static u8 tavil_get_dmic_clk_val(struct snd_soc_codec *codec, dmic_ctl_val = WCD934X_DMIC_CLK_DIV_16; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid div_factor %u, clk_rate(%u), dmic_rate(%u)\n", __func__, div_factor, mclk_rate, dmic_clk_rate); break; @@ -4631,13 +4864,14 @@ done: static int tavil_codec_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s: event:%d\n", __func__, event); + dev_dbg(component->dev, "%s: event:%d\n", __func__, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - tavil_codec_set_tx_hold(codec, w->reg, true); + tavil_codec_set_tx_hold(component, w->reg, true); break; default: break; @@ -4649,9 +4883,10 @@ static int tavil_codec_enable_adc(struct snd_soc_dapm_widget *w, static int tavil_codec_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx_pdata *pdata = dev_get_platdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); + struct wcd9xxx_pdata *pdata = dev_get_platdata(component->dev->parent); u8 dmic_clk_en = 0x01; u16 dmic_clk_reg; s32 *dmic_clk_cnt; @@ -4663,13 +4898,13 @@ static int tavil_codec_enable_dmic(struct snd_soc_dapm_widget *w, wname = strpbrk(w->name, "012345"); if (!wname) { - dev_err(codec->dev, "%s: widget not found\n", __func__); + dev_err(component->dev, "%s: widget not found\n", __func__); return -EINVAL; } ret = kstrtouint(wname, 10, &dmic); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n", + dev_err(component->dev, "%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } @@ -4691,42 +4926,42 @@ static int tavil_codec_enable_dmic(struct snd_soc_dapm_widget *w, dmic_clk_reg = WCD934X_CPE_SS_DMIC2_CTL; break; default: - dev_err(codec->dev, "%s: Invalid DMIC Selection\n", + dev_err(component->dev, "%s: Invalid DMIC Selection\n", __func__); return -EINVAL; }; - dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", + dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); switch (event) { case SND_SOC_DAPM_PRE_PMU: - dmic_sample_rate = tavil_get_dmic_sample_rate(codec, dmic, + dmic_sample_rate = tavil_get_dmic_sample_rate(component, dmic, pdata); dmic_rate_val = - tavil_get_dmic_clk_val(codec, + tavil_get_dmic_clk_val(component, pdata->mclk_rate, dmic_sample_rate); (*dmic_clk_cnt)++; if (*dmic_clk_cnt == 1) { - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, dmic_clk_en); } break; case SND_SOC_DAPM_POST_PMD: dmic_rate_val = - tavil_get_dmic_clk_val(codec, + tavil_get_dmic_clk_val(component, pdata->mclk_rate, pdata->mad_dmic_sample_rate); (*dmic_clk_cnt)--; if (*dmic_clk_cnt == 0) { - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, dmic_clk_en, 0); - snd_soc_update_bits(codec, dmic_clk_reg, + snd_soc_component_update_bits(component, dmic_clk_reg, 0x07 << dmic_rate_shift, dmic_rate_val << dmic_rate_shift); } @@ -4738,16 +4973,16 @@ static int tavil_codec_enable_dmic(struct snd_soc_dapm_widget *w, /* * tavil_mbhc_micb_adjust_voltage: adjust specific micbias voltage - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @req_volt: micbias voltage to be set * @micb_num: micbias to be set, e.g. micbias1 or micbias2 * * return 0 if adjustment is success or error code in case of failure */ -int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +int tavil_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int cur_vout_ctl, req_vout_ctl; int micb_reg, micb_val, micb_en; int ret = 0; @@ -4778,7 +5013,7 @@ int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, * momentarily, change the micbias value and then re-enable * micbias. */ - micb_val = snd_soc_read(codec, micb_reg); + micb_val = snd_soc_component_read32(component, micb_reg); micb_en = (micb_val & 0xC0) >> 6; cur_vout_ctl = micb_val & 0x3F; @@ -4792,17 +5027,17 @@ int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, goto exit; } - dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", + dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl), req_volt, micb_en); if (micb_en == 0x1) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x80); - snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl); + snd_soc_component_update_bits(component, micb_reg, 0x3F, req_vout_ctl); if (micb_en == 0x1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x40); /* * Add 2ms delay as per HW requirement after enabling * micbias @@ -4817,17 +5052,17 @@ EXPORT_SYMBOL(tavil_mbhc_micb_adjust_voltage); /* * tavil_micbias_control: enable/disable micbias - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @micb_num: micbias to be enabled/disabled, e.g. micbias1 or micbias2 * @req: control requested, enable/disable or pullup enable/disable * @is_dapm: triggered by dapm or not * * return 0 if control is success or error code in case of failure */ -int tavil_micbias_control(struct snd_soc_codec *codec, +int tavil_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int micb_index = micb_num - 1; u16 micb_reg; int pre_off_event = 0, post_off_event = 0; @@ -4835,7 +5070,7 @@ int tavil_micbias_control(struct snd_soc_codec *codec, int post_dapm_on = 0; if ((micb_index < 0) || (micb_index > TAVIL_MAX_MICBIAS - 1)) { - dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n", + dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n", __func__, micb_index); return -EINVAL; } @@ -4859,7 +5094,7 @@ int tavil_micbias_control(struct snd_soc_codec *codec, micb_reg = WCD934X_ANA_MICB4; break; default: - dev_err(codec->dev, "%s: Invalid micbias number: %d\n", + dev_err(component->dev, "%s: Invalid micbias number: %d\n", __func__, micb_num); return -EINVAL; } @@ -4870,14 +5105,16 @@ int tavil_micbias_control(struct snd_soc_codec *codec, tavil->pullup_ref[micb_index]++; if ((tavil->pullup_ref[micb_index] == 1) && (tavil->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); break; case MICB_PULLUP_DISABLE: if (tavil->pullup_ref[micb_index] > 0) tavil->pullup_ref[micb_index]--; if ((tavil->pullup_ref[micb_index] == 0) && (tavil->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); break; case MICB_ENABLE: tavil->micb_ref[micb_index]++; @@ -4885,7 +5122,8 @@ int tavil_micbias_control(struct snd_soc_codec *codec, if (tavil->micb_load) regulator_set_load(tavil->micb_load, tavil->micb_load_high); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x40); if (post_on_event && tavil->mbhc) blocking_notifier_call_chain( &tavil->mbhc->notifier, @@ -4901,7 +5139,8 @@ int tavil_micbias_control(struct snd_soc_codec *codec, tavil->micb_ref[micb_index]--; if ((tavil->micb_ref[micb_index] == 0) && (tavil->pullup_ref[micb_index] > 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); else if ((tavil->micb_ref[micb_index] == 0) && (tavil->pullup_ref[micb_index] == 0)) { if (pre_off_event && tavil->mbhc) @@ -4909,7 +5148,8 @@ int tavil_micbias_control(struct snd_soc_codec *codec, &tavil->mbhc->notifier, pre_off_event, &tavil->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); if (post_off_event && tavil->mbhc) blocking_notifier_call_chain( &tavil->mbhc->notifier, @@ -4925,7 +5165,7 @@ int tavil_micbias_control(struct snd_soc_codec *codec, break; }; - dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", + dev_dbg(component->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", __func__, micb_num, tavil->micb_ref[micb_index], tavil->pullup_ref[micb_index]); @@ -4938,10 +5178,11 @@ EXPORT_SYMBOL(tavil_micbias_control); static int __tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int micb_num; - dev_dbg(codec->dev, "%s: wname: %s, event: %d\n", + dev_dbg(component->dev, "%s: wname: %s, event: %d\n", __func__, w->name, event); if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) @@ -4962,14 +5203,14 @@ static int __tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w, * so use ref count to handle micbias pullup * and enable requests */ - tavil_micbias_control(codec, micb_num, MICB_ENABLE, true); + tavil_micbias_control(component, micb_num, MICB_ENABLE, true); break; case SND_SOC_DAPM_POST_PMU: /* wait for cnp time */ usleep_range(1000, 1100); break; case SND_SOC_DAPM_POST_PMD: - tavil_micbias_control(codec, micb_num, MICB_DISABLE, true); + tavil_micbias_control(component, micb_num, MICB_DISABLE, true); break; }; @@ -4978,7 +5219,7 @@ static int __tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w, /* * tavil_codec_enable_standalone_micbias - enable micbias standalone - * @codec: pointer to codec instance + * @component: pointer to codec component instance * @micb_num: number of micbias to be enabled * @enable: true to enable micbias or false to disable * @@ -4987,7 +5228,7 @@ static int __tavil_codec_enable_micbias(struct snd_soc_dapm_widget *w, * * Return: error code in case of failure or 0 for success */ -int tavil_codec_enable_standalone_micbias(struct snd_soc_codec *codec, +int tavil_codec_enable_standalone_micbias(struct snd_soc_component *component, int micb_num, bool enable) { @@ -4998,29 +5239,30 @@ int tavil_codec_enable_standalone_micbias(struct snd_soc_codec *codec, int micb_index = micb_num - 1; int rc; - if (!codec) { - pr_err("%s: Codec memory is NULL\n", __func__); + if (!component) { + pr_err("%s: Component memory is NULL\n", __func__); return -EINVAL; } if ((micb_index < 0) || (micb_index > TAVIL_MAX_MICBIAS - 1)) { - dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n", + dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n", __func__, micb_index); return -EINVAL; } if (enable) rc = snd_soc_dapm_force_enable_pin( - snd_soc_codec_get_dapm(codec), - micb_names[micb_index]); + snd_soc_component_get_dapm(component), + micb_names[micb_index]); else - rc = snd_soc_dapm_disable_pin(snd_soc_codec_get_dapm(codec), - micb_names[micb_index]); + rc = snd_soc_dapm_disable_pin( + snd_soc_component_get_dapm(component), + micb_names[micb_index]); if (!rc) - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); else - dev_err(codec->dev, "%s: micbias%d force %s pin failed\n", + dev_err(component->dev, "%s: micbias%d force %s pin failed\n", __func__, micb_num, (enable ? "enable" : "disable")); return rc; @@ -5032,17 +5274,18 @@ static int tavil_codec_force_enable_micbias(struct snd_soc_dapm_widget *w, int event) { int ret = 0; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: wcd_resmgr_enable_master_bias(tavil->resmgr); - tavil_cdc_mclk_enable(codec, true); + tavil_cdc_mclk_enable(component, true); ret = __tavil_codec_enable_micbias(w, SND_SOC_DAPM_PRE_PMU); /* Wait for 1ms for better cnp */ usleep_range(1000, 1100); - tavil_cdc_mclk_enable(codec, false); + tavil_cdc_mclk_enable(component, false); break; case SND_SOC_DAPM_POST_PMD: ret = __tavil_codec_enable_micbias(w, SND_SOC_DAPM_POST_PMD); @@ -5318,9 +5561,10 @@ static int tavil_codec_reset_hph_registers(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); u8 cache_val[TAVIL_HPH_TOTAL_REG]; u8 hw_val[TAVIL_HPH_TOTAL_REG]; int pa_status; @@ -5347,12 +5591,12 @@ static int tavil_codec_reset_hph_registers(struct snd_soc_dapm_widget *w, /* If both the values are same, it means no corruption */ if (ret) { - dev_dbg(codec->dev, "%s: cache and hw reg are not same\n", + dev_dbg(component->dev, "%s: cache and hw reg are not same\n", __func__); tavil_codec_hph_reg_recover(tavil, wcd9xxx->regmap, pa_status); } else { - dev_dbg(codec->dev, "%s: cache and hw reg are same\n", + dev_dbg(component->dev, "%s: cache and hw reg are same\n", __func__); tavil->mbhc->is_hph_recover = false; } @@ -5397,7 +5641,8 @@ static void tavil_restore_iir_coeff(struct tavil_priv *tavil, int iir_idx, static int tavil_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -5405,10 +5650,11 @@ static int tavil_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, /* IIR filter band registers are at integer multiples of 16 */ u16 iir_reg = WCD934X_CDC_SIDETONE_IIR0_IIR_CTL + 16 * iir_idx; - ucontrol->value.integer.value[0] = (snd_soc_read(codec, iir_reg) & - (1 << band_idx)) != 0; + ucontrol->value.integer.value[0] = + (snd_soc_component_read32(component, iir_reg) & + (1 << band_idx)) != 0; - dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, (uint32_t)ucontrol->value.integer.value[0]); return 0; @@ -5417,8 +5663,9 @@ static int tavil_iir_enable_audio_mixer_get(struct snd_kcontrol *kcontrol, static int tavil_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -5430,56 +5677,56 @@ static int tavil_iir_enable_audio_mixer_put(struct snd_kcontrol *kcontrol, tavil_restore_iir_coeff(tavil, iir_idx, band_idx); /* Mask first 5 bits, 6-8 are reserved */ - snd_soc_update_bits(codec, iir_reg, (1 << band_idx), + snd_soc_component_update_bits(component, iir_reg, (1 << band_idx), (value << band_idx)); - iir_band_en_status = ((snd_soc_read(codec, iir_reg) & + iir_band_en_status = ((snd_soc_component_read32(component, iir_reg) & (1 << band_idx)) != 0); - dev_dbg(codec->dev, "%s: IIR #%d band #%d enable %d\n", __func__, + dev_dbg(component->dev, "%s: IIR #%d band #%d enable %d\n", __func__, iir_idx, band_idx, iir_band_en_status); return 0; } -static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, +static uint32_t get_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, int coeff_idx) { uint32_t value = 0; /* Address does not automatically update if reading */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t)) & 0x7F); - value |= snd_soc_read(codec, + value |= snd_soc_component_read32(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 1) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) << 8); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 2) & 0x7F); - value |= (snd_soc_read(codec, + value |= (snd_soc_component_read32(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) << 16); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), ((band_idx * BAND_MAX + coeff_idx) * sizeof(uint32_t) + 3) & 0x7F); /* Mask bits top 2 bits since they are reserved */ - value |= ((snd_soc_read(codec, + value |= ((snd_soc_component_read32(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx)) & 0x3F) << 24); @@ -5489,24 +5736,25 @@ static uint32_t get_iir_band_coeff(struct snd_soc_codec *codec, static int tavil_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; ucontrol->value.integer.value[0] = - get_iir_band_coeff(codec, iir_idx, band_idx, 0); + get_iir_band_coeff(component, iir_idx, band_idx, 0); ucontrol->value.integer.value[1] = - get_iir_band_coeff(codec, iir_idx, band_idx, 1); + get_iir_band_coeff(component, iir_idx, band_idx, 1); ucontrol->value.integer.value[2] = - get_iir_band_coeff(codec, iir_idx, band_idx, 2); + get_iir_band_coeff(component, iir_idx, band_idx, 2); ucontrol->value.integer.value[3] = - get_iir_band_coeff(codec, iir_idx, band_idx, 3); + get_iir_band_coeff(component, iir_idx, band_idx, 3); ucontrol->value.integer.value[4] = - get_iir_band_coeff(codec, iir_idx, band_idx, 4); + get_iir_band_coeff(component, iir_idx, band_idx, 4); - dev_dbg(codec->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" + dev_dbg(component->dev, "%s: IIR #%d band #%d b0 = 0x%x\n" "%s: IIR #%d band #%d b1 = 0x%x\n" "%s: IIR #%d band #%d b2 = 0x%x\n" "%s: IIR #%d band #%d a1 = 0x%x\n" @@ -5524,24 +5772,24 @@ static int tavil_iir_band_audio_mixer_get(struct snd_kcontrol *kcontrol, return 0; } -static void set_iir_band_coeff(struct snd_soc_codec *codec, +static void set_iir_band_coeff(struct snd_soc_component *component, int iir_idx, int band_idx, uint32_t value) { - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value & 0xFF)); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 8) & 0xFF); - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 16) & 0xFF); /* Mask top 2 bits, 7-8 are reserved */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx), (value >> 24) & 0x3F); } @@ -5549,8 +5797,9 @@ static void set_iir_band_coeff(struct snd_soc_codec *codec, static int tavil_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int iir_idx = ((struct soc_multi_mixer_control *) kcontrol->private_value)->reg; int band_idx = ((struct soc_multi_mixer_control *) @@ -5561,7 +5810,7 @@ static int tavil_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, * Mask top bit it is reserved * Updates addr automatically for each B2 write */ - snd_soc_write(codec, + snd_soc_component_write(component, (WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx), (band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F); @@ -5570,7 +5819,7 @@ static int tavil_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, coeff_idx++) { uint32_t value = ucontrol->value.integer.value[coeff_idx]; - set_iir_band_coeff(codec, iir_idx, band_idx, value); + set_iir_band_coeff(component, iir_idx, band_idx, value); /* Four 8 bit values(one 32 bit) per coefficient */ tavil->sidetone_coeff_array[iir_idx][band_idx][idx++] = @@ -5589,15 +5838,15 @@ static int tavil_iir_band_audio_mixer_put(struct snd_kcontrol *kcontrol, "%s: IIR #%d band #%d a1 = 0x%x\n" "%s: IIR #%d band #%d a2 = 0x%x\n", __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 0), + get_iir_band_coeff(component, iir_idx, band_idx, 0), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 1), + get_iir_band_coeff(component, iir_idx, band_idx, 1), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 2), + get_iir_band_coeff(component, iir_idx, band_idx, 2), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 3), + get_iir_band_coeff(component, iir_idx, band_idx, 3), __func__, iir_idx, band_idx, - get_iir_band_coeff(codec, iir_idx, band_idx, 4)); + get_iir_band_coeff(component, iir_idx, band_idx, 4)); return 0; } @@ -5605,10 +5854,11 @@ static int tavil_compander_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil->comp_enabled[comp]; return 0; @@ -5617,13 +5867,14 @@ static int tavil_compander_get(struct snd_kcontrol *kcontrol, static int tavil_compander_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int comp = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: Compander %d enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Compander %d enable current %d, new %d\n", __func__, comp + 1, tavil->comp_enabled[comp], value); tavil->comp_enabled[comp] = value; @@ -5631,11 +5882,11 @@ static int tavil_compander_put(struct snd_kcontrol *kcontrol, switch (comp) { case COMPANDER_1: /* Set Gain Source Select based on compander enable/disable */ - snd_soc_update_bits(codec, WCD934X_HPH_L_EN, 0x20, + snd_soc_component_update_bits(component, WCD934X_HPH_L_EN, 0x20, (value ? 0x00:0x20)); break; case COMPANDER_2: - snd_soc_update_bits(codec, WCD934X_HPH_R_EN, 0x20, + snd_soc_component_update_bits(component, WCD934X_HPH_R_EN, 0x20, (value ? 0x00:0x20)); break; case COMPANDER_3: @@ -5649,7 +5900,7 @@ static int tavil_compander_put(struct snd_kcontrol *kcontrol, * it does not cause any audio failure, so do not * return error in this case, but just print a log */ - dev_warn(codec->dev, "%s: unknown compander: %d\n", + dev_warn(component->dev, "%s: unknown compander: %d\n", __func__, comp); }; return 0; @@ -5658,8 +5909,9 @@ static int tavil_compander_put(struct snd_kcontrol *kcontrol, static int tavil_hph_asrc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int index = -EINVAL; if (!strcmp(kcontrol->id.name, "ASRC0 Output Mode")) @@ -5677,8 +5929,9 @@ static int tavil_hph_asrc_mode_put(struct snd_kcontrol *kcontrol, static int tavil_hph_asrc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int val = 0; int index = -EINVAL; @@ -5698,8 +5951,9 @@ static int tavil_hph_asrc_mode_get(struct snd_kcontrol *kcontrol, static int tavil_hph_idle_detect_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int val = 0; if (tavil) @@ -5713,8 +5967,9 @@ static int tavil_hph_idle_detect_get(struct snd_kcontrol *kcontrol, static int tavil_hph_idle_detect_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); if (tavil) tavil->idle_det_cfg.hph_idle_detect_en = @@ -5726,7 +5981,8 @@ static int tavil_hph_idle_detect_put(struct snd_kcontrol *kcontrol, static int tavil_dmic_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u16 dmic_pin; u8 reg_val, pinctl_position; @@ -5734,7 +5990,7 @@ static int tavil_dmic_pin_mode_get(struct snd_kcontrol *kcontrol, kcontrol->private_value)->shift; dmic_pin = pinctl_position & 0x07; - reg_val = snd_soc_read(codec, + reg_val = snd_soc_component_read32(component, WCD934X_TLMM_DMIC1_CLK_PINCFG + dmic_pin - 1); ucontrol->value.integer.value[0] = !!reg_val; @@ -5745,8 +6001,9 @@ static int tavil_dmic_pin_mode_get(struct snd_kcontrol *kcontrol, static int tavil_dmic_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u16 ctl_reg, cfg_reg, dmic_pin; u8 ctl_val, cfg_val, pinctl_position, pinctl_mode, mask; @@ -5769,14 +6026,14 @@ static int tavil_dmic_pin_mode_put(struct snd_kcontrol *kcontrol, ctl_reg = WCD934X_TEST_DEBUG_PIN_CTL_OE_3; break; default: - dev_err(codec->dev, "%s: Invalid pinctl position = %d\n", + dev_err(component->dev, "%s: Invalid pinctl position = %d\n", __func__, pinctl_position); return -EINVAL; } ctl_val = ~(pinctl_mode << (pinctl_position & 0x07)); mask = 1 << (pinctl_position & 0x07); - snd_soc_update_bits(codec, ctl_reg, mask, ctl_val); + snd_soc_component_update_bits(component, ctl_reg, mask, ctl_val); dmic_pin = pinctl_position & 0x07; cfg_reg = WCD934X_TLMM_DMIC1_CLK_PINCFG + dmic_pin - 1; @@ -5787,9 +6044,9 @@ static int tavil_dmic_pin_mode_put(struct snd_kcontrol *kcontrol, cfg_val = 0xD; } else cfg_val = 0; - snd_soc_update_bits(codec, cfg_reg, 0x1F, cfg_val); + snd_soc_component_update_bits(component, cfg_reg, 0x1F, cfg_val); - dev_dbg(codec->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n", + dev_dbg(component->dev, "%s: reg=0x%x mask=0x%x val=%d reg=0x%x val=%d\n", __func__, ctl_reg, mask, ctl_val, cfg_reg, cfg_val); return 0; @@ -5798,7 +6055,8 @@ static int tavil_dmic_pin_mode_put(struct snd_kcontrol *kcontrol, static int tavil_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u16 amic_reg = 0; if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE")) @@ -5808,7 +6066,7 @@ static int tavil_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, if (amic_reg) ucontrol->value.integer.value[0] = - (snd_soc_read(codec, amic_reg) & + (snd_soc_component_read32(component, amic_reg) & WCD934X_AMIC_PWR_LVL_MASK) >> WCD934X_AMIC_PWR_LVL_SHIFT; return 0; @@ -5817,13 +6075,14 @@ static int tavil_amic_pwr_lvl_get(struct snd_kcontrol *kcontrol, static int tavil_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u32 mode_val; u16 amic_reg = 0; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val); + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (!strcmp(kcontrol->id.name, "AMIC_1_2 PWR MODE")) amic_reg = WCD934X_ANA_AMIC1; @@ -5831,8 +6090,9 @@ static int tavil_amic_pwr_lvl_put(struct snd_kcontrol *kcontrol, amic_reg = WCD934X_ANA_AMIC3; if (amic_reg) - snd_soc_update_bits(codec, amic_reg, WCD934X_AMIC_PWR_LVL_MASK, - mode_val << WCD934X_AMIC_PWR_LVL_SHIFT); + snd_soc_component_update_bits(component, amic_reg, + WCD934X_AMIC_PWR_LVL_MASK, + mode_val << WCD934X_AMIC_PWR_LVL_SHIFT); return 0; } @@ -5849,13 +6109,15 @@ static const struct soc_enum tavil_conn_mad_enum = static int tavil_mad_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u8 tavil_mad_input; - tavil_mad_input = snd_soc_read(codec, WCD934X_SOC_MAD_INP_SEL) & 0x0F; + tavil_mad_input = snd_soc_component_read32( + component, WCD934X_SOC_MAD_INP_SEL) & 0x0F; ucontrol->value.integer.value[0] = tavil_mad_input; - dev_dbg(codec->dev, "%s: tavil_mad_input = %s\n", __func__, + dev_dbg(component->dev, "%s: tavil_mad_input = %s\n", __func__, tavil_conn_mad_text[tavil_mad_input]); return 0; @@ -5864,8 +6126,9 @@ static int tavil_mad_input_get(struct snd_kcontrol *kcontrol, static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_card *card = codec->component.card; + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct snd_soc_card *card = component->card; u8 tavil_mad_input; char mad_amic_input_widget[6]; const char *mad_input_widget; @@ -5879,7 +6142,7 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, if (tavil_mad_input >= sizeof(tavil_conn_mad_text)/ sizeof(tavil_conn_mad_text[0])) { - dev_err(codec->dev, + dev_err(component->dev, "%s: tavil_mad_input = %d out of bounds\n", __func__, tavil_mad_input); return -EINVAL; @@ -5887,11 +6150,11 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, if (strnstr(tavil_conn_mad_text[tavil_mad_input], "NOTUSED", sizeof("NOTUSED"))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Unsupported tavil_mad_input = %s\n", __func__, tavil_conn_mad_text[tavil_mad_input]); /* Make sure the MAD register is updated */ - snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP, + snd_soc_component_update_bits(component, WCD934X_ANA_MAD_SETUP, 0x88, 0x00); return -EINVAL; } @@ -5901,21 +6164,23 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, mad_input = strpbrk(tavil_conn_mad_text[tavil_mad_input], "1234"); if (!mad_input) { - dev_err(codec->dev, "%s: Invalid MAD input %s\n", + dev_err(component->dev, "%s: Invalid MAD input %s\n", __func__, tavil_conn_mad_text[tavil_mad_input]); return -EINVAL; } ret = kstrtouint(mad_input, 10, &adc); if ((ret < 0) || (adc > 4)) { - dev_err(codec->dev, "%s: Invalid ADC = %s\n", __func__, + dev_err(component->dev, "%s: Invalid ADC = %s\n", + __func__, tavil_conn_mad_text[tavil_mad_input]); return -EINVAL; } /*AMIC4 and AMIC5 share ADC4*/ if ((adc == 4) && - (snd_soc_read(codec, WCD934X_TX_NEW_AMIC_4_5_SEL) & 0x10)) + (snd_soc_component_read32( + component, WCD934X_TX_NEW_AMIC_4_5_SEL) & 0x10)) adc = 5; snprintf(mad_amic_input_widget, 6, "%s%u", "AMIC", adc); @@ -5927,7 +6192,7 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, mad_input_widget = tavil_conn_mad_text[tavil_mad_input]; } - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: tavil input widget = %s, adc_input = %s\n", __func__, mad_input_widget, is_adc_input ? "true" : "false"); @@ -5935,7 +6200,7 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, if (!strcmp(card->of_dapm_routes[i].sink, mad_input_widget)) { source_widget = card->of_dapm_routes[i].source; if (!source_widget) { - dev_err(codec->dev, + dev_err(component->dev, "%s: invalid source widget\n", __func__); return -EINVAL; @@ -5962,24 +6227,24 @@ static int tavil_mad_input_put(struct snd_kcontrol *kcontrol, } if (!mic_bias_found) { - dev_err(codec->dev, "%s: mic bias not found for input %s\n", + dev_err(component->dev, "%s: mic bias not found for input %s\n", __func__, mad_input_widget); return -EINVAL; } - dev_dbg(codec->dev, "%s: mic_bias found = %d\n", __func__, + dev_dbg(component->dev, "%s: mic_bias found = %d\n", __func__, mic_bias_found); - snd_soc_update_bits(codec, WCD934X_SOC_MAD_INP_SEL, + snd_soc_component_update_bits(component, WCD934X_SOC_MAD_INP_SEL, 0x0F, tavil_mad_input); - snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP, + snd_soc_component_update_bits(component, WCD934X_ANA_MAD_SETUP, 0x07, mic_bias_found); /* for all adc inputs, mad should be in micbias mode with BG enabled */ if (is_adc_input) - snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP, + snd_soc_component_update_bits(component, WCD934X_ANA_MAD_SETUP, 0x88, 0x88); else - snd_soc_update_bits(codec, WCD934X_ANA_MAD_SETUP, + snd_soc_component_update_bits(component, WCD934X_ANA_MAD_SETUP, 0x88, 0x00); return 0; } @@ -5988,15 +6253,16 @@ static int tavil_ear_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - ear_pa_gain = snd_soc_read(codec, WCD934X_ANA_EAR); + ear_pa_gain = snd_soc_component_read32(component, WCD934X_ANA_EAR); ear_pa_gain = (ear_pa_gain & 0x70) >> 4; ucontrol->value.integer.value[0] = ear_pa_gain; - dev_dbg(codec->dev, "%s: ear_pa_gain = 0x%x\n", __func__, + dev_dbg(component->dev, "%s: ear_pa_gain = 0x%x\n", __func__, ear_pa_gain); return 0; @@ -6006,26 +6272,29 @@ static int tavil_ear_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 ear_pa_gain; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); ear_pa_gain = ucontrol->value.integer.value[0] << 4; - snd_soc_update_bits(codec, WCD934X_ANA_EAR, 0x70, ear_pa_gain); + snd_soc_component_update_bits(component, WCD934X_ANA_EAR, + 0x70, ear_pa_gain); return 0; } static int tavil_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil->ear_spkr_gain; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -6034,12 +6303,14 @@ static int tavil_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol, static int tavil_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); tavil->ear_spkr_gain = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: gain = %d\n", __func__, tavil->ear_spkr_gain); + dev_dbg(component->dev, "%s: gain = %d\n", __func__, + tavil->ear_spkr_gain); return 0; } @@ -6048,12 +6319,14 @@ static int tavil_spkr_left_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, WCD934X_CDC_BOOST0_BOOST_CTL); + bst_state_max = snd_soc_component_read32( + component, WCD934X_CDC_BOOST0_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -6063,12 +6336,13 @@ static int tavil_spkr_left_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, WCD934X_CDC_BOOST0_BOOST_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_BOOST0_BOOST_CTL, 0x0c, bst_state_max); return 0; @@ -6078,12 +6352,14 @@ static int tavil_spkr_right_boost_stage_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max = 0; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - bst_state_max = snd_soc_read(codec, WCD934X_CDC_BOOST1_BOOST_CTL); + bst_state_max = snd_soc_component_read32(component, + WCD934X_CDC_BOOST1_BOOST_CTL); bst_state_max = (bst_state_max & 0x0c) >> 2; ucontrol->value.integer.value[0] = bst_state_max; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); return 0; @@ -6093,12 +6369,13 @@ static int tavil_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { u8 bst_state_max; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); bst_state_max = ucontrol->value.integer.value[0] << 2; - snd_soc_update_bits(codec, WCD934X_CDC_BOOST1_BOOST_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_BOOST1_BOOST_CTL, 0x0c, bst_state_max); return 0; @@ -6107,8 +6384,9 @@ static int tavil_spkr_right_boost_stage_put(struct snd_kcontrol *kcontrol, static int tavil_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = tavil->hph_mode; return 0; @@ -6117,16 +6395,17 @@ static int tavil_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int tavil_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); u32 mode_val; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val); + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (mode_val == 0) { - dev_warn(codec->dev, "%s:Invalid HPH Mode, default to Cls-H LOHiFi\n", + dev_warn(component->dev, "%s:Invalid HPH Mode, default to Cls-H LOHiFi\n", __func__); mode_val = CLS_H_LOHIFI; } @@ -6477,8 +6756,9 @@ static int tavil_dec_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_widget *widget = - snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + snd_soc_dapm_kcontrol_widget(kcontrol); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; u16 mic_sel_reg = 0; @@ -6488,7 +6768,7 @@ static int tavil_dec_enum_put(struct snd_kcontrol *kcontrol, if (val > e->items - 1) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); switch (e->reg) { @@ -6519,7 +6799,7 @@ static int tavil_dec_enum_put(struct snd_kcontrol *kcontrol, mic_sel_reg = WCD934X_CDC_TX7_TX_PATH_CFG0; break; default: - dev_err(codec->dev, "%s: e->reg: 0x%x not expected\n", + dev_err(component->dev, "%s: e->reg: 0x%x not expected\n", __func__, e->reg); return -EINVAL; } @@ -6527,7 +6807,8 @@ static int tavil_dec_enum_put(struct snd_kcontrol *kcontrol, /* ADC: 0, DMIC: 1 */ mic_sel = val ? 0x0 : 0x1; if (mic_sel_reg) - snd_soc_update_bits(codec, mic_sel_reg, 1 << 7, mic_sel << 7); + snd_soc_component_update_bits(component, mic_sel_reg, 1 << 7, + mic_sel << 7); return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); } @@ -6537,7 +6818,8 @@ static int tavil_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(widget->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(widget->dapm); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; unsigned short look_ahead_dly_reg = WCD934X_CDC_RX0_RX_PATH_CFG0; @@ -6546,7 +6828,7 @@ static int tavil_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, if (val >= e->items) return -EINVAL; - dev_dbg(codec->dev, "%s: wname: %s, val: 0x%x\n", __func__, + dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__, widget->name, val); if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0) @@ -6557,7 +6839,7 @@ static int tavil_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol, look_ahead_dly_reg = WCD934X_CDC_RX2_RX_PATH_CFG0; /* Set Look Ahead Delay */ - snd_soc_update_bits(codec, look_ahead_dly_reg, + snd_soc_component_update_bits(component, look_ahead_dly_reg, 0x08, (val ? 0x08 : 0x00)); /* Set DEM INP Select */ return snd_soc_dapm_put_enum_double(kcontrol, ucontrol); @@ -7454,8 +7736,9 @@ static int tavil_dsd_mixer_get(struct snd_kcontrol *kcontrol, { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config; @@ -7475,8 +7758,8 @@ static int tavil_dsd_mixer_put(struct snd_kcontrol *kcontrol, (struct soc_mixer_control *)kcontrol->private_value; struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct tavil_priv *tavil_p = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct tavil_priv *tavil_p = snd_soc_component_get_drvdata(component); unsigned int wval = ucontrol->value.integer.value[0]; struct tavil_dsd_config *dsd_conf = tavil_p->dsd_config; @@ -8168,7 +8451,8 @@ static int tavil_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, unsigned int *rx_num, unsigned int *rx_slot) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec); + struct tavil_priv *tavil = + snd_soc_component_get_drvdata(dai->component); u32 i = 0; struct wcd9xxx_ch *ch; int ret = 0; @@ -8243,8 +8527,8 @@ static int tavil_set_channel_map(struct snd_soc_dai *dai, struct wcd9xxx *core; struct wcd9xxx_codec_dai_data *dai_data = NULL; - tavil = snd_soc_codec_get_drvdata(dai->codec); - core = dev_get_drvdata(dai->codec->dev->parent); + tavil = snd_soc_component_get_drvdata(dai->component); + core = dev_get_drvdata(dai->component->dev->parent); if (!tx_slot || !rx_slot) { dev_err(tavil->dev, "%s: Invalid tx_slot 0x%pK, rx_slot 0x%pK\n", @@ -8284,9 +8568,10 @@ static void tavil_shutdown(struct snd_pcm_substream *substream, static int tavil_set_decimator_rate(struct snd_soc_dai *dai, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = + snd_soc_component_get_drvdata(component); u32 tx_port = 0, tx_fs_rate = 0; u8 shift = 0, shift_val = 0, tx_mux_sel = 0; int decimator = -1; @@ -8320,11 +8605,11 @@ static int tavil_set_decimator_rate(struct snd_soc_dai *dai, list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) { tx_port = ch->port; - dev_dbg(codec->dev, "%s: dai->id = %d, tx_port = %d", + dev_dbg(component->dev, "%s: dai->id = %d, tx_port = %d", __func__, dai->id, tx_port); if ((tx_port < 0) || (tx_port == 12) || (tx_port >= 14)) { - dev_err(codec->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n", + dev_err(component->dev, "%s: Invalid SLIM TX%u port. DAI ID: %d\n", __func__, tx_port, dai->id); return -EINVAL; } @@ -8350,7 +8635,7 @@ static int tavil_set_decimator_rate(struct snd_soc_dai *dai, shift = 4; shift_val = 0x03; } - tx_mux_sel = snd_soc_read(codec, tx_port_reg) & + tx_mux_sel = snd_soc_component_read32(component, tx_port_reg) & (shift_val << shift); tx_mux_sel = tx_mux_sel >> shift; @@ -8371,15 +8656,16 @@ static int tavil_set_decimator_rate(struct snd_soc_dai *dai, if (decimator >= 0) { tx_fs_reg = WCD934X_CDC_TX0_TX_PATH_CTL + 16 * decimator; - dev_dbg(codec->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", + dev_dbg(component->dev, "%s: set DEC%u (-> SLIM_TX%u) rate to %u\n", __func__, decimator, tx_port, sample_rate); - snd_soc_update_bits(codec, tx_fs_reg, 0x0F, tx_fs_rate); + snd_soc_component_update_bits(component, tx_fs_reg, + 0x0F, tx_fs_rate); } else if ((tx_port <= 8) && (tx_mux_sel == 0x01)) { /* Check if the TX Mux input is RX MIX TXn */ - dev_dbg(codec->dev, "%s: RX_MIX_TX%u going to CDC_IF TX%u\n", + dev_dbg(component->dev, "%s: RX_MIX_TX%u going to CDC_IF TX%u\n", __func__, tx_port, tx_port); } else { - dev_err(codec->dev, "%s: ERROR: Invalid decimator: %d\n", + dev_err(component->dev, "%s: ERROR: Invalid decimator: %d\n", __func__, decimator); return -EINVAL; } @@ -8395,16 +8681,16 @@ static int tavil_set_mix_interpolator_rate(struct snd_soc_dai *dai, u32 j; u16 int_mux_cfg1, int_fs_reg; u8 int_mux_cfg1_val; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) { int_2_inp = INTn_2_INP_SEL_RX0 + ch->port - WCD934X_RX_PORT_START_NUMBER; if ((int_2_inp < INTn_2_INP_SEL_RX0) || (int_2_inp > INTn_2_INP_SEL_RX7)) { - dev_err(codec->dev, "%s: Invalid RX%u port, Dai ID is %d\n", + dev_err(component->dev, "%s: Invalid RX%u port, Dai ID is %d\n", __func__, (ch->port - WCD934X_RX_PORT_START_NUMBER), dai->id); @@ -8418,8 +8704,8 @@ static int tavil_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_mux_cfg1 += 2; continue; } - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1) & - 0x0F; + int_mux_cfg1_val = snd_soc_component_read32(component, + int_mux_cfg1) & 0x0F; if (int_mux_cfg1_val == int_2_inp) { /* * Ear mix path supports only 48, 96, 192, @@ -8428,7 +8714,7 @@ static int tavil_set_mix_interpolator_rate(struct snd_soc_dai *dai, if ((j == INTERP_EAR) && (rate_reg_val < 0x4 || rate_reg_val > 0x7)) { - dev_err_ratelimited(codec->dev, + dev_err_ratelimited(component->dev, "%s: Invalid rate for AIF_PB DAI(%d)\n", __func__, dai->id); return -EINVAL; @@ -8436,12 +8722,12 @@ static int tavil_set_mix_interpolator_rate(struct snd_soc_dai *dai, int_fs_reg = WCD934X_CDC_RX0_RX_PATH_MIX_CTL + 20 * j; - dev_dbg(codec->dev, "%s: AIF_PB DAI(%d) connected to INT%u_2\n", + dev_dbg(component->dev, "%s: AIF_PB DAI(%d) connected to INT%u_2\n", __func__, dai->id, j); - dev_dbg(codec->dev, "%s: set INT%u_2 sample rate to %u\n", + dev_dbg(component->dev, "%s: set INT%u_2 sample rate to %u\n", __func__, j, sample_rate); - snd_soc_update_bits(codec, int_fs_reg, 0x0F, - rate_reg_val); + snd_soc_component_update_bits(component, + int_fs_reg, 0x0F, rate_reg_val); } int_mux_cfg1 += 2; } @@ -8459,9 +8745,9 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, u16 int_fs_reg; u8 int_mux_cfg0_val, int_mux_cfg1_val; u8 inp0_sel, inp1_sel, inp2_sel; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct wcd9xxx_ch *ch; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); struct tavil_dsd_config *dsd_conf = tavil->dsd_config; list_for_each_entry(ch, &tavil->dai[dai->id].wcd9xxx_ch_list, list) { @@ -8469,7 +8755,7 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, WCD934X_RX_PORT_START_NUMBER; if ((int_1_mix1_inp < INTn_1_INP_SEL_RX0) || (int_1_mix1_inp > INTn_1_INP_SEL_RX7)) { - dev_err(codec->dev, "%s: Invalid RX%u port, Dai ID is %d\n", + dev_err(component->dev, "%s: Invalid RX%u port, Dai ID is %d\n", __func__, (ch->port - WCD934X_RX_PORT_START_NUMBER), dai->id); @@ -8491,8 +8777,10 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, } int_mux_cfg1 = int_mux_cfg0 + 1; - int_mux_cfg0_val = snd_soc_read(codec, int_mux_cfg0); - int_mux_cfg1_val = snd_soc_read(codec, int_mux_cfg1); + int_mux_cfg0_val = snd_soc_component_read32( + component, int_mux_cfg0); + int_mux_cfg1_val = snd_soc_component_read32( + component, int_mux_cfg1); inp0_sel = int_mux_cfg0_val & 0x0F; inp1_sel = (int_mux_cfg0_val >> 4) & 0x0F; inp2_sel = (int_mux_cfg1_val >> 4) & 0x0F; @@ -8506,7 +8794,7 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, if ((j == INTERP_EAR || j == INTERP_SPKR1 || j == INTERP_SPKR2) && (rate_reg_val > 0x7)) { - dev_err_ratelimited(codec->dev, + dev_err_ratelimited(component->dev, "%s: Invalid rate for AIF_PB DAI(%d)\n", __func__, dai->id); return -EINVAL; @@ -8514,14 +8802,14 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, int_fs_reg = WCD934X_CDC_RX0_RX_PATH_CTL + 20 * j; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: AIF_PB DAI(%d) connected to INT%u_1\n", __func__, dai->id, j); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: set INT%u_1 sample rate to %u\n", __func__, j, sample_rate); - snd_soc_update_bits(codec, int_fs_reg, 0x0F, - rate_reg_val); + snd_soc_component_update_bits(component, + int_fs_reg, 0x0F, rate_reg_val); } int_mux_cfg0 += 2; } @@ -8537,7 +8825,7 @@ static int tavil_set_prim_interpolator_rate(struct snd_soc_dai *dai, static int tavil_set_interpolator_rate(struct snd_soc_dai *dai, u32 sample_rate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int rate_val = 0; int i, ret; @@ -8548,7 +8836,7 @@ static int tavil_set_interpolator_rate(struct snd_soc_dai *dai, } } if ((i == ARRAY_SIZE(sr_val_tbl)) || (rate_val < 0)) { - dev_err(codec->dev, "%s: Unsupported sample rate: %d\n", + dev_err(component->dev, "%s: Unsupported sample rate: %d\n", __func__, sample_rate); return -EINVAL; } @@ -8575,7 +8863,8 @@ static int tavil_vi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec); + struct tavil_priv *tavil = + snd_soc_component_get_drvdata(dai->component); dev_dbg(tavil->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__, dai->name, dai->id, params_rate(params), @@ -8591,7 +8880,8 @@ static int tavil_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(dai->codec); + struct tavil_priv *tavil = + snd_soc_component_get_drvdata(dai->component); int ret = 0; dev_dbg(tavil->dev, "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", @@ -8671,18 +8961,20 @@ static int tavil_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) i2s_reg = WCD934X_DATA_HUB_I2S_2_CTL; break; default: - dev_err(dai->codec->dev, "%s Invalid i2s Id", __func__); + dev_err(dai->component->dev, "%s Invalid i2s Id", __func__); return -EINVAL; } switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* CPU is master */ - snd_soc_update_bits(dai->codec, i2s_reg, 0x2, 0x0); + snd_soc_component_update_bits(dai->component, i2s_reg, + 0x2, 0x0); break; case SND_SOC_DAIFMT_CBM_CFM: /* CPU is slave */ - snd_soc_update_bits(dai->codec, i2s_reg, 0x2, 0x2); + snd_soc_component_update_bits(dai->component, i2s_reg, + 0x2, 0x2); break; default: return -EINVAL; @@ -9168,7 +9460,7 @@ static struct snd_info_entry_ops tavil_codec_info_ops = { /* * tavil_codec_info_create_codec_entry - creates wcd934x module * @codec_root: The parent directory - * @codec: Codec instance + * @component: Codec component instance * * Creates wcd934x module and version entry under the given * parent directory. @@ -9176,21 +9468,21 @@ static struct snd_info_entry_ops tavil_codec_info_ops = { * Return: 0 on success or negative error code on failure. */ int tavil_codec_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct tavil_priv *tavil; struct snd_soc_card *card; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - tavil = snd_soc_codec_get_drvdata(codec); - card = codec->component.card; + tavil = snd_soc_component_get_drvdata(component); + card = component->card; tavil->entry = snd_info_create_subdir(codec_root->module, "tavil", codec_root); if (!tavil->entry) { - dev_dbg(codec->dev, "%s: failed to create wcd934x entry\n", + dev_dbg(component->dev, "%s: failed to create wcd934x entry\n", __func__); return -ENOMEM; } @@ -9199,7 +9491,7 @@ int tavil_codec_info_create_codec_entry(struct snd_info_entry *codec_root, "version", tavil->entry); if (!version_entry) { - dev_dbg(codec->dev, "%s: failed to create wcd934x version entry\n", + dev_dbg(component->dev, "%s: failed to create wcd934x version entry\n", __func__); return -ENOMEM; } @@ -9222,23 +9514,23 @@ EXPORT_SYMBOL(tavil_codec_info_create_codec_entry); /** * tavil_cdc_mclk_enable - Enable/disable codec mclk * - * @codec: codec instance + * @component: codec component instance * @enable: Indicates clk enable or disable * * Returns 0 on Success and error on failure */ -int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable) +int tavil_cdc_mclk_enable(struct snd_soc_component *component, bool enable) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); return __tavil_cdc_mclk_enable(tavil, enable); } EXPORT_SYMBOL(tavil_cdc_mclk_enable); -static int __tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec, +static int __tavil_codec_internal_rco_ctrl(struct snd_soc_component *component, bool enable) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int ret = 0; if (enable) { @@ -9249,7 +9541,7 @@ static int __tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec, } else { ret = tavil_cdc_req_mclk_enable(tavil, true); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "%s: mclk_enable failed, err = %d\n", __func__, ret); goto done; @@ -9267,7 +9559,7 @@ static int __tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec, } if (ret) { - dev_err(codec->dev, "%s: Error in %s RCO\n", + dev_err(component->dev, "%s: Error in %s RCO\n", __func__, (enable ? "enabling" : "disabling")); ret = -EINVAL; } @@ -9278,41 +9570,41 @@ done: /* * tavil_codec_internal_rco_ctrl: Enable/Disable codec's RCO clock - * @codec: Handle to the codec + * @component: Handle to the codec * @enable: Indicates whether clock should be enabled or disabled */ -static int tavil_codec_internal_rco_ctrl(struct snd_soc_codec *codec, +static int tavil_codec_internal_rco_ctrl(struct snd_soc_component *component, bool enable) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); int ret = 0; WCD9XXX_V2_BG_CLK_LOCK(tavil->resmgr); - ret = __tavil_codec_internal_rco_ctrl(codec, enable); + ret = __tavil_codec_internal_rco_ctrl(component, enable); WCD9XXX_V2_BG_CLK_UNLOCK(tavil->resmgr); return ret; } /* * tavil_cdc_mclk_tx_enable: Enable/Disable codec's clock for TX path - * @codec: Handle to codec + * @component: Handle to codec * @enable: Indicates whether clock should be enabled or disabled */ -int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable) +int tavil_cdc_mclk_tx_enable(struct snd_soc_component *component, bool enable) { struct tavil_priv *tavil_p; int ret = 0; bool clk_mode; bool clk_internal; - if (!codec) + if (!component) return -EINVAL; - tavil_p = snd_soc_codec_get_drvdata(codec); + tavil_p = snd_soc_component_get_drvdata(component); clk_mode = test_bit(CLK_MODE, &tavil_p->status_mask); clk_internal = test_bit(CLK_INTERNAL, &tavil_p->status_mask); - dev_dbg(codec->dev, "%s: clkmode: %d, enable: %d, clk_internal: %d\n", + dev_dbg(component->dev, "%s: clkmode: %d, enable: %d, clk_internal: %d\n", __func__, clk_mode, enable, clk_internal); if (clk_mode || clk_internal) { @@ -9320,11 +9612,11 @@ int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable) wcd_resmgr_enable_master_bias(tavil_p->resmgr); tavil_dig_core_power_collapse(tavil_p, POWER_RESUME); tavil_vote_svs(tavil_p, true); - ret = tavil_codec_internal_rco_ctrl(codec, enable); + ret = tavil_codec_internal_rco_ctrl(component, enable); set_bit(CLK_INTERNAL, &tavil_p->status_mask); } else { clear_bit(CLK_INTERNAL, &tavil_p->status_mask); - tavil_codec_internal_rco_ctrl(codec, enable); + tavil_codec_internal_rco_ctrl(component, enable); tavil_vote_svs(tavil_p, false); tavil_dig_core_power_collapse(tavil_p, POWER_COLLAPSE); wcd_resmgr_disable_master_bias(tavil_p->resmgr); @@ -9470,18 +9762,18 @@ static const struct tavil_reg_mask_val tavil_codec_reg_init_common_val[] = { static void tavil_codec_init_reg(struct tavil_priv *priv) { - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 i; for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_common_val); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tavil_codec_reg_init_common_val[i].reg, tavil_codec_reg_init_common_val[i].mask, tavil_codec_reg_init_common_val[i].val); if (TAVIL_IS_1_1(priv->wcd9xxx)) { for (i = 0; i < ARRAY_SIZE(tavil_codec_reg_init_1_1_val); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tavil_codec_reg_init_1_1_val[i].reg, tavil_codec_reg_init_1_1_val[i].mask, tavil_codec_reg_init_1_1_val[i].val); @@ -9553,10 +9845,10 @@ static void tavil_update_cpr_defaults(struct tavil_priv *tavil) __tavil_cdc_mclk_enable(tavil, false); } -static void tavil_slim_interface_init_reg(struct snd_soc_codec *codec) +static void tavil_slim_interface_init_reg(struct snd_soc_component *component) { int i; - struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *priv = snd_soc_component_get_drvdata(component); for (i = 0; i < WCD9XXX_SLIM_NUM_PORT_REG; i++) wcd9xxx_interface_reg_write(priv->wcd9xxx, @@ -9690,7 +9982,7 @@ static irqreturn_t tavil_slimbus_irq(int irq, void *data) static int tavil_setup_irqs(struct tavil_priv *tavil) { int ret = 0; - struct snd_soc_codec *codec = tavil->codec; + struct snd_soc_component *component = tavil->component; struct wcd9xxx *wcd9xxx = tavil->wcd9xxx; struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; @@ -9698,24 +9990,24 @@ static int tavil_setup_irqs(struct tavil_priv *tavil) ret = wcd9xxx_request_irq(core_res, WCD9XXX_IRQ_SLIMBUS, tavil_slimbus_irq, "SLIMBUS Slave", tavil); if (ret) - dev_err(codec->dev, "%s: Failed to request irq %d\n", __func__, - WCD9XXX_IRQ_SLIMBUS); + dev_err(component->dev, "%s: Failed to request irq %d\n", + __func__, WCD9XXX_IRQ_SLIMBUS); else - tavil_slim_interface_init_reg(codec); + tavil_slim_interface_init_reg(component); /* Register for misc interrupts as well */ ret = wcd9xxx_request_irq(core_res, WCD934X_IRQ_MISC, tavil_misc_irq, "CDC MISC Irq", tavil); if (ret) - dev_err(codec->dev, "%s: Failed to request cdc misc irq\n", + dev_err(component->dev, "%s: Failed to request cdc misc irq\n", __func__); return ret; } -static void tavil_init_slim_slave_cfg(struct snd_soc_codec *codec) +static void tavil_init_slim_slave_cfg(struct snd_soc_component *component) { - struct tavil_priv *priv = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *priv = snd_soc_component_get_drvdata(component); struct afe_param_cdc_slimbus_slave_cfg *cfg; struct wcd9xxx *wcd9xxx = priv->wcd9xxx; uint64_t eaddr = 0; @@ -9730,7 +10022,7 @@ static void tavil_init_slim_slave_cfg(struct snd_soc_codec *codec) cfg->device_enum_addr_lsw = eaddr & 0xFFFFFFFF; cfg->device_enum_addr_msw = eaddr >> 32; - dev_dbg(codec->dev, "%s: slimbus logical address 0x%llx\n", + dev_dbg(component->dev, "%s: slimbus logical address 0x%llx\n", __func__, eaddr); } @@ -9765,7 +10057,7 @@ EXPORT_SYMBOL(wcd934x_get_micb_vout_ctl_val); static int tavil_handle_pdata(struct tavil_priv *tavil, struct wcd9xxx_pdata *pdata) { - struct snd_soc_codec *codec = tavil->codec; + struct snd_soc_component *component = tavil->component; u8 mad_dmic_ctl_val; u8 anc_ctl_value; u32 def_dmic_rate, dmic_clk_drv; @@ -9773,7 +10065,7 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, int rc = 0; if (!pdata) { - dev_err(codec->dev, "%s: NULL pdata\n", __func__); + dev_err(component->dev, "%s: NULL pdata\n", __func__); return -ENODEV; } @@ -9787,10 +10079,14 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, rc = -EINVAL; goto done; } - snd_soc_update_bits(codec, WCD934X_ANA_MICB1, 0x3F, vout_ctl_1); - snd_soc_update_bits(codec, WCD934X_ANA_MICB2, 0x3F, vout_ctl_2); - snd_soc_update_bits(codec, WCD934X_ANA_MICB3, 0x3F, vout_ctl_3); - snd_soc_update_bits(codec, WCD934X_ANA_MICB4, 0x3F, vout_ctl_4); + snd_soc_component_update_bits(component, WCD934X_ANA_MICB1, + 0x3F, vout_ctl_1); + snd_soc_component_update_bits(component, WCD934X_ANA_MICB2, + 0x3F, vout_ctl_2); + snd_soc_component_update_bits(component, WCD934X_ANA_MICB3, + 0x3F, vout_ctl_3); + snd_soc_component_update_bits(component, WCD934X_ANA_MICB4, + 0x3F, vout_ctl_4); /* Set the DMIC sample rate */ switch (pdata->mclk_rate) { @@ -9802,7 +10098,7 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, break; default: /* should never happen */ - dev_err(codec->dev, "%s: Invalid mclk_rate %d\n", + dev_err(component->dev, "%s: Invalid mclk_rate %d\n", __func__, pdata->mclk_rate); rc = -EINVAL; goto done; @@ -9810,13 +10106,13 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, if (pdata->dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) { - dev_info(codec->dev, "%s: dmic_rate invalid default = %d\n", + dev_info(component->dev, "%s: dmic_rate invalid default = %d\n", __func__, def_dmic_rate); pdata->dmic_sample_rate = def_dmic_rate; } if (pdata->mad_dmic_sample_rate == WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED) { - dev_info(codec->dev, "%s: mad_dmic_rate invalid default = %d\n", + dev_info(component->dev, "%s: mad_dmic_rate invalid default = %d\n", __func__, def_dmic_rate); /* * use dmic_sample_rate as the default for MAD @@ -9828,7 +10124,7 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, if (pdata->dmic_clk_drv == WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED) { pdata->dmic_clk_drv = WCD934X_DMIC_CLK_DRIVE_DEFAULT; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: dmic_clk_strength invalid, default = %d\n", __func__, pdata->dmic_clk_drv); } @@ -9847,29 +10143,30 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, dmic_clk_drv = 3; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: invalid dmic_clk_drv %d, using default\n", __func__, pdata->dmic_clk_drv); dmic_clk_drv = 0; break; } - snd_soc_update_bits(codec, WCD934X_TEST_DEBUG_PAD_DRVCTL_0, - 0x0C, dmic_clk_drv << 2); + snd_soc_component_update_bits(component, + WCD934X_TEST_DEBUG_PAD_DRVCTL_0, + 0x0C, dmic_clk_drv << 2); /* * Default the DMIC clk rates to mad_dmic_sample_rate, * whereas, the anc/txfe dmic rates to dmic_sample_rate * since the anc/txfe are independent of mad block. */ - mad_dmic_ctl_val = tavil_get_dmic_clk_val(tavil->codec, + mad_dmic_ctl_val = tavil_get_dmic_clk_val(tavil->component, pdata->mclk_rate, pdata->mad_dmic_sample_rate); - snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC0_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_DMIC0_CTL, 0x0E, mad_dmic_ctl_val << 1); - snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC1_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_DMIC1_CTL, 0x0E, mad_dmic_ctl_val << 1); - snd_soc_update_bits(codec, WCD934X_CPE_SS_DMIC2_CTL, + snd_soc_component_update_bits(component, WCD934X_CPE_SS_DMIC2_CTL, 0x0E, mad_dmic_ctl_val << 1); if (dmic_clk_drv == WCD934X_DMIC_CLK_DIV_2) @@ -9877,22 +10174,22 @@ static int tavil_handle_pdata(struct tavil_priv *tavil, else anc_ctl_value = WCD934X_ANC_DMIC_X2_HALF_RATE; - snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_MODE_2_CTL, 0x40, anc_ctl_value << 6); - snd_soc_update_bits(codec, WCD934X_CDC_ANC0_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC0_MODE_2_CTL, 0x20, anc_ctl_value << 5); - snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_MODE_2_CTL, 0x40, anc_ctl_value << 6); - snd_soc_update_bits(codec, WCD934X_CDC_ANC1_MODE_2_CTL, + snd_soc_component_update_bits(component, WCD934X_CDC_ANC1_MODE_2_CTL, 0x20, anc_ctl_value << 5); done: return rc; } -static void tavil_cdc_vote_svs(struct snd_soc_codec *codec, bool vote) +static void tavil_cdc_vote_svs(struct snd_soc_component *component, bool vote) { - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); return tavil_vote_svs(tavil, vote); } @@ -9902,15 +10199,15 @@ static struct wcd_dsp_cdc_cb cdc_cb = { .cdc_vote_svs = tavil_cdc_vote_svs, }; -static int tavil_wdsp_initialize(struct snd_soc_codec *codec) +static int tavil_wdsp_initialize(struct snd_soc_component *component) { struct wcd9xxx *control; struct tavil_priv *tavil; struct wcd_dsp_params params; int ret = 0; - control = dev_get_drvdata(codec->dev->parent); - tavil = snd_soc_codec_get_drvdata(codec); + control = dev_get_drvdata(component->dev->parent); + tavil = snd_soc_component_get_drvdata(component); params.cb = &cdc_cb; params.irqs.cpe_ipc1_irq = WCD934X_IRQ_CPE1_INTR; @@ -9919,7 +10216,7 @@ static int tavil_wdsp_initialize(struct snd_soc_codec *codec) params.clk_rate = control->mclk_rate; params.dsp_instance = 0; - wcd_dsp_cntl_init(codec, ¶ms, &tavil->wdsp_cntl); + wcd_dsp_cntl_init(component, ¶ms, &tavil->wdsp_cntl); if (!tavil->wdsp_cntl) { dev_err(tavil->dev, "%s: wcd-dsp-control init failed\n", __func__); @@ -9931,19 +10228,19 @@ static int tavil_wdsp_initialize(struct snd_soc_codec *codec) /* * tavil_soc_get_mbhc: get wcd934x_mbhc handle of corresponding codec - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * * return wcd934x_mbhc handle or error code in case of failure */ -struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec) +struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_component *component) { struct tavil_priv *tavil; - if (!codec) { + if (!component) { pr_err("%s: Invalid params, NULL codec\n", __func__); return NULL; } - tavil = snd_soc_codec_get_drvdata(codec); + tavil = snd_soc_component_get_drvdata(component); if (!tavil) { pr_err("%s: Invalid params, NULL tavil\n", __func__); @@ -9957,12 +10254,12 @@ EXPORT_SYMBOL(tavil_soc_get_mbhc); static void tavil_mclk2_reg_defaults(struct tavil_priv *tavil) { int i; - struct snd_soc_codec *codec = tavil->codec; + struct snd_soc_component *component = tavil->component; if (TAVIL_IS_1_0(tavil->wcd9xxx)) { /* MCLK2 configuration */ for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_0_defaults); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tavil_codec_mclk2_1_0_defaults[i].reg, tavil_codec_mclk2_1_0_defaults[i].mask, tavil_codec_mclk2_1_0_defaults[i].val); @@ -9970,7 +10267,7 @@ static void tavil_mclk2_reg_defaults(struct tavil_priv *tavil) if (TAVIL_IS_1_1(tavil->wcd9xxx)) { /* MCLK2 configuration */ for (i = 0; i < ARRAY_SIZE(tavil_codec_mclk2_1_1_defaults); i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, tavil_codec_mclk2_1_1_defaults[i].reg, tavil_codec_mclk2_1_1_defaults[i].mask, tavil_codec_mclk2_1_1_defaults[i].val); @@ -9979,20 +10276,20 @@ static void tavil_mclk2_reg_defaults(struct tavil_priv *tavil) static int tavil_device_down(struct wcd9xxx *wcd9xxx) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct tavil_priv *priv; int count; int decimator; int ret; - codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); - if (!codec->component.card) { - dev_err(codec->dev, "%s: sound card is not enumerated.\n", + component = (struct snd_soc_component *)(wcd9xxx->ssr_priv); + if (!component->card) { + dev_err(component->dev, "%s: sound card is not enumerated.\n", __func__); return -EINVAL; } - priv = snd_soc_codec_get_drvdata(codec); + priv = snd_soc_component_get_drvdata(component); for (count = 0; count < NUM_CODEC_DAIS; count++) priv->dai[count].bus_down_in_recovery = true; snd_event_notify(priv->dev->parent, SND_EVENT_DOWN); @@ -10028,7 +10325,7 @@ static int tavil_device_down(struct wcd9xxx *wcd9xxx) } tavil_dsd_reset(priv->dsd_config); if (!is_snd_event_fwk_enabled()) - snd_soc_card_change_online_state(codec->component.card, 0); + snd_soc_card_change_online_state(component->card, 0); wcd_dsp_ssr_event(priv->wdsp_cntl, WCD_CDC_DOWN_EVENT); wcd_resmgr_set_sido_input_src_locked(priv->resmgr, SIDO_SOURCE_INTERNAL); @@ -10040,19 +10337,19 @@ static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx) { int i, ret = 0; struct wcd9xxx *control; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct tavil_priv *tavil; struct wcd9xxx_pdata *pdata; struct wcd_mbhc *mbhc; - codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); - if (!codec->component.card) { + component = (struct snd_soc_component *)(wcd9xxx->ssr_priv); + if (!component->card) { dev_err(codec->dev, "%s: sound card is not enumerated.\n", __func__); return -EINVAL; } - tavil = snd_soc_codec_get_drvdata(codec); - control = dev_get_drvdata(codec->dev->parent); + tavil = snd_soc_component_get_drvdata(component); + control = dev_get_drvdata(component->dev->parent); wcd9xxx_set_power_state(tavil->wcd9xxx, WCD_REGION_POWER_COLLAPSE_REMOVE, @@ -10065,22 +10362,24 @@ static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx) control->slim_slave->laddr; tavil_slimbus_slave_port_cfg.slave_dev_pgd_la = control->slim->laddr; - tavil_init_slim_slave_cfg(codec); + tavil_init_slim_slave_cfg(component); if (!is_snd_event_fwk_enabled()) - snd_soc_card_change_online_state(codec->component.card, 1); + snd_soc_card_change_online_state(component->card, 1); for (i = 0; i < TAVIL_MAX_MICBIAS; i++) tavil->micb_ref[i] = 0; - dev_dbg(codec->dev, "%s: MCLK Rate = %x\n", + dev_dbg(component->dev, "%s: MCLK Rate = %x\n", __func__, control->mclk_rate); if (control->mclk_rate == WCD934X_MCLK_CLK_12P288MHZ) - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x00); + snd_soc_component_update_bits(component, + WCD934X_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x00); else if (control->mclk_rate == WCD934X_MCLK_CLK_9P6MHZ) - snd_soc_update_bits(codec, WCD934X_CODEC_RPM_CLK_MCLK_CFG, - 0x03, 0x01); + snd_soc_component_update_bits(component, + WCD934X_CODEC_RPM_CLK_MCLK_CFG, + 0x03, 0x01); tavil_update_reg_defaults(tavil); wcd_resmgr_post_ssr_v2(tavil->resmgr); tavil_codec_init_reg(tavil); @@ -10088,26 +10387,26 @@ static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx) tavil_mclk2_reg_defaults(tavil); __tavil_cdc_mclk_enable(tavil, true); - regcache_mark_dirty(codec->component.regmap); - regcache_sync(codec->component.regmap); + regcache_mark_dirty(component->regmap); + regcache_sync(component->regmap); __tavil_cdc_mclk_enable(tavil, false); tavil_update_cpr_defaults(tavil); - pdata = dev_get_platdata(codec->dev->parent); + pdata = dev_get_platdata(component->dev->parent); ret = tavil_handle_pdata(tavil, pdata); if (ret < 0) - dev_err(codec->dev, "%s: invalid pdata\n", __func__); + dev_err(component->dev, "%s: invalid pdata\n", __func__); /* Initialize MBHC module */ mbhc = &tavil->mbhc->wcd_mbhc; - ret = tavil_mbhc_post_ssr_init(tavil->mbhc, codec); + ret = tavil_mbhc_post_ssr_init(tavil->mbhc, component); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto done; } else { - tavil_mbhc_hs_detect(codec, mbhc->mbhc_cfg); + tavil_mbhc_hs_detect(component, mbhc->mbhc_cfg); } /* DSD initialization */ @@ -10118,7 +10417,7 @@ static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx) tavil_cleanup_irqs(tavil); ret = tavil_setup_irqs(tavil); if (ret) { - dev_err(codec->dev, "%s: tavil irq setup failed %d\n", + dev_err(component->dev, "%s: tavil irq setup failed %d\n", __func__, ret); goto done; } @@ -10126,7 +10425,7 @@ static int tavil_post_reset_cb(struct wcd9xxx *wcd9xxx) if (tavil->swr.ctrl_data && is_snd_event_fwk_enabled()) swrm_wcd_notify(tavil->swr.ctrl_data[0].swr_pdev, SWR_DEVICE_SSR_UP, NULL); - tavil_set_spkr_mode(codec, tavil->swr.spkr_mode); + tavil_set_spkr_mode(component, tavil->swr.spkr_mode); /* * Once the codec initialization is completed, the svs vote * can be released allowing the codec to go to SVS2. @@ -10140,29 +10439,32 @@ done: return ret; } -static int tavil_soc_codec_probe(struct snd_soc_codec *codec) +static int tavil_soc_codec_probe(struct snd_soc_component *component) { struct wcd9xxx *control; struct tavil_priv *tavil; struct wcd9xxx_pdata *pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int i, ret; void *ptr = NULL; - control = dev_get_drvdata(codec->dev->parent); + control = dev_get_drvdata(component->dev->parent); - dev_info(codec->dev, "%s()\n", __func__); - tavil = snd_soc_codec_get_drvdata(codec); + snd_soc_component_init_regmap(component, control->regmap); + + dev_info(component->dev, "%s()\n", __func__); + tavil = snd_soc_component_get_drvdata(component); tavil->intf_type = wcd9xxx_get_intf_type(); control->dev_down = tavil_device_down; control->post_reset = tavil_post_reset_cb; - control->ssr_priv = (void *)codec; + control->ssr_priv = (void *)component; /* Resource Manager post Init */ - ret = wcd_resmgr_post_init(tavil->resmgr, &tavil_resmgr_cb, codec); + ret = wcd_resmgr_post_init(tavil->resmgr, &tavil_resmgr_cb, component); if (ret) { - dev_err(codec->dev, "%s: wcd resmgr post init failed\n", + dev_err(component->dev, "%s: wcd resmgr post init failed\n", __func__); goto err; } @@ -10171,7 +10473,7 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) /* Default HPH Mode to Class-H Low HiFi */ tavil->hph_mode = CLS_H_LOHIFI; - tavil->fw_data = devm_kzalloc(codec->dev, sizeof(*(tavil->fw_data)), + tavil->fw_data = devm_kzalloc(component->dev, sizeof(*(tavil->fw_data)), GFP_KERNEL); if (!tavil->fw_data) goto err; @@ -10182,33 +10484,33 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) set_bit(WCD9XXX_VBAT_CAL, tavil->fw_data->cal_bit); ret = wcd_cal_create_hwdep(tavil->fw_data, - WCD9XXX_CODEC_HWDEP_NODE, codec); + WCD9XXX_CODEC_HWDEP_NODE, component); if (ret < 0) { - dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret); + dev_err(component->dev, "%s hwdep failed %d\n", __func__, ret); goto err_hwdep; } /* Initialize MBHC module */ - ret = tavil_mbhc_init(&tavil->mbhc, codec, tavil->fw_data); + ret = tavil_mbhc_init(&tavil->mbhc, component, tavil->fw_data); if (ret) { pr_err("%s: mbhc initialization failed\n", __func__); goto err_hwdep; } - tavil->codec = codec; + tavil->component = component; for (i = 0; i < COMPANDER_MAX; i++) tavil->comp_enabled[i] = 0; tavil_codec_init_reg(tavil); - pdata = dev_get_platdata(codec->dev->parent); + pdata = dev_get_platdata(component->dev->parent); ret = tavil_handle_pdata(tavil, pdata); if (ret < 0) { - dev_err(codec->dev, "%s: bad pdata\n", __func__); + dev_err(component->dev, "%s: bad pdata\n", __func__); goto err_hwdep; } - ptr = devm_kzalloc(codec->dev, (sizeof(tavil_rx_chs) + + ptr = devm_kzalloc(component->dev, (sizeof(tavil_rx_chs) + sizeof(tavil_tx_chs)), GFP_KERNEL); if (!ptr) { ret = -ENOMEM; @@ -10231,7 +10533,7 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) control->slim->laddr; tavil_slimbus_slave_port_cfg.slave_port_mapping[0] = WCD934X_TX13; - tavil_init_slim_slave_cfg(codec); + tavil_init_slim_slave_cfg(component); } else { snd_soc_dapm_new_controls(dapm, tavil_dapm_i2s_widgets, ARRAY_SIZE(tavil_dapm_i2s_widgets)); @@ -10272,7 +10574,7 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) tavil_mclk2_reg_defaults(tavil); /* DSD initialization */ - tavil->dsd_config = tavil_dsd_init(codec); + tavil->dsd_config = tavil_dsd_init(component); if (IS_ERR_OR_NULL(tavil->dsd_config)) dev_dbg(tavil->dev, "%s: DSD init failed\n", __func__); @@ -10302,7 +10604,7 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) snd_soc_dapm_sync(dapm); - tavil_wdsp_initialize(codec); + tavil_wdsp_initialize(component); /* * Once the codec initialization is completed, the svs vote @@ -10313,23 +10615,23 @@ static int tavil_soc_codec_probe(struct snd_soc_codec *codec) return ret; err_pdata: - devm_kfree(codec->dev, ptr); + devm_kfree(component->dev, ptr); control->rx_chs = NULL; control->tx_chs = NULL; err_hwdep: - devm_kfree(codec->dev, tavil->fw_data); + devm_kfree(component->dev, tavil->fw_data); tavil->fw_data = NULL; err: return ret; } -static int tavil_soc_codec_remove(struct snd_soc_codec *codec) +static void tavil_soc_codec_remove(struct snd_soc_component *component) { struct wcd9xxx *control; - struct tavil_priv *tavil = snd_soc_codec_get_drvdata(codec); + struct tavil_priv *tavil = snd_soc_component_get_drvdata(component); - control = dev_get_drvdata(codec->dev->parent); - devm_kfree(codec->dev, control->rx_chs); + control = dev_get_drvdata(component->dev->parent); + devm_kfree(component->dev, control->rx_chs); /* slimslave deinit in wcd core looks for this value */ control->num_rx_port = 0; control->num_tx_port = 0; @@ -10341,31 +10643,22 @@ static int tavil_soc_codec_remove(struct snd_soc_codec *codec) wcd_dsp_cntl_deinit(&tavil->wdsp_cntl); /* Deinitialize MBHC module */ - tavil_mbhc_deinit(codec); + tavil_mbhc_deinit(component); tavil->mbhc = NULL; - return 0; + return; } -static struct regmap *tavil_get_regmap(struct device *dev) -{ - struct wcd9xxx *control = dev_get_drvdata(dev->parent); - - return control->regmap; -} - -static struct snd_soc_codec_driver soc_codec_dev_tavil = { +static const struct snd_soc_component_driver soc_codec_dev_tavil = { + .name = DRV_NAME, .probe = tavil_soc_codec_probe, .remove = tavil_soc_codec_remove, - .get_regmap = tavil_get_regmap, - .component_driver = { - .controls = tavil_snd_controls, - .num_controls = ARRAY_SIZE(tavil_snd_controls), - .dapm_widgets = tavil_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tavil_dapm_widgets), - .dapm_routes = tavil_audio_map, - .num_dapm_routes = ARRAY_SIZE(tavil_audio_map), - }, + .controls = tavil_snd_controls, + .num_controls = ARRAY_SIZE(tavil_snd_controls), + .dapm_widgets = tavil_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tavil_dapm_widgets), + .dapm_routes = tavil_audio_map, + .num_dapm_routes = ARRAY_SIZE(tavil_audio_map), }; #ifdef CONFIG_PM @@ -10938,15 +11231,15 @@ static void wcd934x_ssr_disable(struct device *dev, void *data) { struct wcd9xxx *wcd9xxx = dev_get_drvdata(dev); struct tavil_priv *tavil; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int count = 0; if (!wcd9xxx) { dev_dbg(dev, "%s: wcd9xxx pointer NULL.\n", __func__); return; } - codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv); - tavil = snd_soc_codec_get_drvdata(codec); + component = (struct snd_soc_component *)(wcd9xxx->ssr_priv); + tavil = snd_soc_component_get_drvdata(component); for (count = 0; count < NUM_CODEC_DAIS; count++) tavil->dai[count].bus_down_in_recovery = true; @@ -11066,13 +11359,15 @@ static int tavil_probe(struct platform_device *pdev) /* Register with soc framework */ if (tavil->intf_type == WCD9XXX_INTERFACE_TYPE_I2C) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tavil, - tavil_i2s_dai, - ARRAY_SIZE(tavil_i2s_dai)); + ret = snd_soc_register_component(&pdev->dev, + &soc_codec_dev_tavil, + tavil_i2s_dai, + ARRAY_SIZE(tavil_i2s_dai)); else - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_tavil, - tavil_slim_dai, - ARRAY_SIZE(tavil_slim_dai)); + ret = snd_soc_register_component(&pdev->dev, + &soc_codec_dev_tavil, + tavil_slim_dai, + ARRAY_SIZE(tavil_slim_dai)); if (ret) { dev_err(&pdev->dev, "%s: Codec registration failed\n", @@ -11081,7 +11376,8 @@ static int tavil_probe(struct platform_device *pdev) } schedule_work(&tavil->tavil_add_child_devices_work); - ret = snd_event_client_register(pdev->dev.parent, &wcd934x_ssr_ops, NULL); + ret = snd_event_client_register(pdev->dev.parent, + &wcd934x_ssr_ops, NULL); if (!ret) { snd_event_notify(pdev->dev.parent, SND_EVENT_UP); } else { @@ -11161,7 +11457,7 @@ static int tavil_remove(struct platform_device *pdev) mutex_destroy(&tavil->swr.write_mutex); mutex_destroy(&tavil->swr.clk_mutex); - snd_soc_unregister_codec(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); clk_put(tavil->wcd_ext_clk); wcd_resmgr_remove(tavil->resmgr); devm_kfree(&pdev->dev, tavil); diff --git a/asoc/codecs/wcd934x/wcd934x.h b/asoc/codecs/wcd934x/wcd934x.h index c0aec9efc0..a14e6eb050 100644 --- a/asoc/codecs/wcd934x/wcd934x.h +++ b/asoc/codecs/wcd934x/wcd934x.h @@ -127,47 +127,54 @@ struct tavil_reg_mask_val { }; #if IS_ENABLED(CONFIG_SND_SOC_WCD934X) -extern void *tavil_get_afe_config(struct snd_soc_codec *codec, +extern void *tavil_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type); -extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable); -extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable); -extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode); -extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset); +extern int tavil_cdc_mclk_enable(struct snd_soc_component *component, + bool enable); +extern int tavil_cdc_mclk_tx_enable(struct snd_soc_component *component, + bool enable); +extern int tavil_set_spkr_mode(struct snd_soc_component *component, int mode); +extern int tavil_set_spkr_gain_offset(struct snd_soc_component *component, + int offset); extern struct wcd_dsp_cntl *tavil_get_wcd_dsp_cntl(struct device *dev); extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv); -extern int tavil_micbias_control(struct snd_soc_codec *codec, +extern int tavil_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm); -extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num); -extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec); -extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec, +extern struct wcd934x_mbhc *tavil_soc_get_mbhc( + struct snd_soc_component *component); +extern int tavil_codec_enable_interp_clk(struct snd_soc_component *component, int event, int intp_idx); extern struct tavil_dsd_config *tavil_get_dsd_config( - struct snd_soc_codec *codec); + struct snd_soc_component *component); extern int tavil_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec); + struct snd_soc_component *component); #else -extern void *tavil_get_afe_config(struct snd_soc_codec *codec, +extern void *tavil_get_afe_config(struct snd_soc_component *component, enum afe_config_type config_type) { return NULL; } -extern int tavil_cdc_mclk_enable(struct snd_soc_codec *codec, bool enable) +extern int tavil_cdc_mclk_enable(struct snd_soc_component *component, + bool enable) { return 0; } -extern int tavil_cdc_mclk_tx_enable(struct snd_soc_codec *codec, bool enable) +extern int tavil_cdc_mclk_tx_enable(struct snd_soc_component *component, + bool enable) { return 0; } -extern int tavil_set_spkr_mode(struct snd_soc_codec *codec, int mode) +extern int tavil_set_spkr_mode(struct snd_soc_component *component, int mode) { return 0; } -extern int tavil_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset) +extern int tavil_set_spkr_gain_offset(struct snd_soc_component *component, + int offset) { return 0; } @@ -179,35 +186,36 @@ extern int wcd934x_get_micb_vout_ctl_val(u32 micb_mv) { return 0; } -extern int tavil_micbias_control(struct snd_soc_codec *codec, +extern int tavil_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm) { return 0; } -extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +extern int tavil_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num) { return 0; } -extern struct wcd934x_mbhc *tavil_soc_get_mbhc(struct snd_soc_codec *codec) +extern struct wcd934x_mbhc *tavil_soc_get_mbhc( + struct snd_soc_component *component) { return NULL; } -extern int tavil_codec_enable_interp_clk(struct snd_soc_codec *codec, +extern int tavil_codec_enable_interp_clk(struct snd_soc_component *component, int event, int intp_idx) { return 0; } extern struct tavil_dsd_config *tavil_get_dsd_config( - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return NULL; } extern int tavil_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } diff --git a/asoc/codecs/wcd937x/internal.h b/asoc/codecs/wcd937x/internal.h index 46c0c022b8..b4165115b8 100644 --- a/asoc/codecs/wcd937x/internal.h +++ b/asoc/codecs/wcd937x/internal.h @@ -30,7 +30,7 @@ struct wcd937x_priv { struct device *dev; int variant; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct device_node *rst_np; struct regmap *regmap; @@ -160,10 +160,11 @@ enum { WCD937X_NUM_IRQS, }; -extern struct wcd937x_mbhc *wcd937x_soc_get_mbhc(struct snd_soc_codec *codec); -extern int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +extern struct wcd937x_mbhc *wcd937x_soc_get_mbhc( + struct snd_soc_component *component); +extern int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int volt, int micb_num); extern int wcd937x_get_micb_vout_ctl_val(u32 micb_mv); -extern int wcd937x_micbias_control(struct snd_soc_codec *codec, int micb_num, - int req, bool is_dapm); +extern int wcd937x_micbias_control(struct snd_soc_component *component, + int micb_num, int req, bool is_dapm); #endif diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.c b/asoc/codecs/wcd937x/wcd937x-mbhc.c index 1e0fcf8082..543897628a 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.c +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.c @@ -157,19 +157,19 @@ struct wcd937x_mbhc_zdet_param { u16 btn7; }; -static int wcd937x_mbhc_request_irq(struct snd_soc_codec *codec, +static int wcd937x_mbhc_request_irq(struct snd_soc_component *component, int irq, irq_handler_t handler, const char *name, void *data) { - struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev); + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); return wcd_request_irq(&wcd937x->irq_info, irq, name, handler, data); } -static void wcd937x_mbhc_irq_control(struct snd_soc_codec *codec, +static void wcd937x_mbhc_irq_control(struct snd_soc_component *component, int irq, bool enable) { - struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev); + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); if (enable) wcd_enable_irq(&wcd937x->irq_info, irq); @@ -177,44 +177,45 @@ static void wcd937x_mbhc_irq_control(struct snd_soc_codec *codec, wcd_disable_irq(&wcd937x->irq_info, irq); } -static int wcd937x_mbhc_free_irq(struct snd_soc_codec *codec, +static int wcd937x_mbhc_free_irq(struct snd_soc_component *component, int irq, void *data) { - struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev); + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); wcd_free_irq(&wcd937x->irq_info, irq, data); return 0; } -static void wcd937x_mbhc_clk_setup(struct snd_soc_codec *codec, +static void wcd937x_mbhc_clk_setup(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_1, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_1, 0x80, 0x80); else - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_1, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_1, 0x80, 0x00); } -static int wcd937x_mbhc_btn_to_num(struct snd_soc_codec *codec) +static int wcd937x_mbhc_btn_to_num(struct snd_soc_component *component) { - return snd_soc_read(codec, WCD937X_ANA_MBHC_RESULT_3) & 0x7; + return snd_soc_component_read32(component, WCD937X_ANA_MBHC_RESULT_3) & + 0x7; } -static void wcd937x_mbhc_mbhc_bias_control(struct snd_soc_codec *codec, +static void wcd937x_mbhc_mbhc_bias_control(struct snd_soc_component *component, bool enable) { if (enable) - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_ELECT, 0x01, 0x01); else - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_ELECT, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_ELECT, 0x01, 0x00); } -static void wcd937x_mbhc_program_btn_thr(struct snd_soc_codec *codec, +static void wcd937x_mbhc_program_btn_thr(struct snd_soc_component *component, s16 *btn_low, s16 *btn_high, int num_btn, bool is_micbias) { @@ -222,16 +223,17 @@ static void wcd937x_mbhc_program_btn_thr(struct snd_soc_codec *codec, int vth; if (num_btn > WCD_MBHC_DEF_BUTTONS) { - dev_err(codec->dev, "%s: invalid number of buttons: %d\n", + dev_err(component->dev, "%s: invalid number of buttons: %d\n", __func__, num_btn); return; } for (i = 0; i < num_btn; i++) { vth = ((btn_high[i] * 2) / 25) & 0x3F; - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN0 + i, - 0xFC, vth << 2); - dev_dbg(codec->dev, "%s: btn_high[%d]: %d, vth: %d\n", + snd_soc_component_update_bits(component, + WCD937X_ANA_MBHC_BTN0 + i, + 0xFC, vth << 2); + dev_dbg(component->dev, "%s: btn_high[%d]: %d, vth: %d\n", __func__, i, btn_high[i], vth); } } @@ -262,7 +264,8 @@ static bool wcd937x_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) u8 val = 0; if (micb_num == MIC_BIAS_2) { - val = ((snd_soc_read(mbhc->codec, WCD937X_ANA_MICB2) & 0xC0) + val = ((snd_soc_component_read32(mbhc->component, + WCD937X_ANA_MICB2) & 0xC0) >> 6); if (val == 0x01) return true; @@ -270,48 +273,51 @@ static bool wcd937x_mbhc_micb_en_status(struct wcd_mbhc *mbhc, int micb_num) return false; } -static bool wcd937x_mbhc_hph_pa_on_status(struct snd_soc_codec *codec) +static bool wcd937x_mbhc_hph_pa_on_status(struct snd_soc_component *component) { - return (snd_soc_read(codec, WCD937X_ANA_HPH) & 0xC0) ? true : false; + return (snd_soc_component_read32(component, WCD937X_ANA_HPH) & 0xC0) ? + true : false; } -static void wcd937x_mbhc_hph_l_pull_up_control(struct snd_soc_codec *codec, - int pull_up_cur) +static void wcd937x_mbhc_hph_l_pull_up_control( + struct snd_soc_component *component, + int pull_up_cur) { /* Default pull up current to 2uA */ if (pull_up_cur > HS_PULLUP_I_OFF || pull_up_cur < HS_PULLUP_I_3P0_UA || pull_up_cur == HS_PULLUP_I_DEFAULT) pull_up_cur = HS_PULLUP_I_2P0_UA; - dev_dbg(codec->dev, "%s: HS pull up current:%d\n", + dev_dbg(component->dev, "%s: HS pull up current:%d\n", __func__, pull_up_cur); - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_INT_MECH_DET_CURRENT, - 0x1F, pull_up_cur); + snd_soc_component_update_bits(component, + WCD937X_MBHC_NEW_INT_MECH_DET_CURRENT, + 0x1F, pull_up_cur); } -static int wcd937x_mbhc_request_micbias(struct snd_soc_codec *codec, +static int wcd937x_mbhc_request_micbias(struct snd_soc_component *component, int micb_num, int req) { int ret = 0; - ret = wcd937x_micbias_control(codec, micb_num, req, false); + ret = wcd937x_micbias_control(component, micb_num, req, false); return ret; } -static void wcd937x_mbhc_micb_ramp_control(struct snd_soc_codec *codec, +static void wcd937x_mbhc_micb_ramp_control(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP, 0x1C, 0x0C); - snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP, 0x80, 0x80); } else { - snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP, 0x80, 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_MICB2_RAMP, + snd_soc_component_update_bits(component, WCD937X_ANA_MICB2_RAMP, 0x1C, 0x00); } } @@ -321,26 +327,27 @@ static struct firmware_cal *wcd937x_get_hwdep_fw_cal(struct wcd_mbhc *mbhc, { struct wcd937x_mbhc *wcd937x_mbhc; struct firmware_cal *hwdep_cal; - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; wcd937x_mbhc = container_of(mbhc, struct wcd937x_mbhc, wcd_mbhc); - if (!codec) { - pr_err("%s: NULL codec pointer\n", __func__); + if (!component) { + pr_err("%s: NULL component pointer\n", __func__); return NULL; } hwdep_cal = wcdcal_get_fw_cal(wcd937x_mbhc->fw_data, type); if (!hwdep_cal) - dev_err(codec->dev, "%s: cal not sent by %d\n", + dev_err(component->dev, "%s: cal not sent by %d\n", __func__, type); return hwdep_cal; } -static int wcd937x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, - int micb_num, bool req_en) +static int wcd937x_mbhc_micb_ctrl_threshold_mic( + struct snd_soc_component *component, + int micb_num, bool req_en) { - struct wcd937x_pdata *pdata = dev_get_platdata(codec->dev); + struct wcd937x_pdata *pdata = dev_get_platdata(component->dev); int rc, micb_mv; if (micb_num != MIC_BIAS_2) @@ -355,7 +362,7 @@ static int wcd937x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_codec *codec, micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : pdata->micbias.micb2_mv; - rc = wcd937x_mbhc_micb_adjust_voltage(codec, micb_mv, MIC_BIAS_2); + rc = wcd937x_mbhc_micb_adjust_voltage(component, micb_mv, MIC_BIAS_2); return rc; } @@ -418,25 +425,25 @@ ramp_down: } } -static void wcd937x_mbhc_zdet_ramp(struct snd_soc_codec *codec, +static void wcd937x_mbhc_zdet_ramp(struct snd_soc_component *component, struct wcd937x_mbhc_zdet_param *zdet_param, int32_t *zl, int32_t *zr, s16 *d1_a) { - struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev); + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); int32_t zdet = 0; - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, 0x70, - zdet_param->ldo_ctl << 4); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN5, 0xFC, - zdet_param->btn5); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN6, 0xFC, - zdet_param->btn6); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_BTN7, 0xFC, - zdet_param->btn7); - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, 0x0F, - zdet_param->noff); - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_ZDET_RAMP_CTL, 0x0F, - zdet_param->nshift); + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL, + 0x70, zdet_param->ldo_ctl << 4); + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN5, 0xFC, + zdet_param->btn5); + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN6, 0xFC, + zdet_param->btn6); + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_BTN7, 0xFC, + zdet_param->btn7); + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL, + 0x0F, zdet_param->noff); + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_ZDET_RAMP_CTL, + 0x0F, zdet_param->nshift); if (!zl) goto z_right; @@ -466,17 +473,18 @@ z_right: *zr = zdet; } -static inline void wcd937x_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, - int32_t *z_val, int flag_l_r) +static inline void wcd937x_wcd_mbhc_qfuse_cal( + struct snd_soc_component *component, + int32_t *z_val, int flag_l_r) { s16 q1; int q1_cal; if (*z_val < (WCD937X_ZDET_VAL_400/1000)) - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_23 + (2 * flag_l_r)); else - q1 = snd_soc_read(codec, + q1 = snd_soc_component_read32(component, WCD937X_DIGITAL_EFUSE_REG_24 + (2 * flag_l_r)); if (q1 & 0x80) q1_cal = (10000 - ((q1 & 0x7F) * 25)); @@ -489,8 +497,8 @@ static inline void wcd937x_wcd_mbhc_qfuse_cal(struct snd_soc_codec *codec, static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, uint32_t *zr) { - struct snd_soc_codec *codec = mbhc->codec; - struct wcd937x_priv *wcd937x = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = mbhc->component; + struct wcd937x_priv *wcd937x = dev_get_drvdata(component->dev); s16 reg0, reg1, reg2, reg3, reg4; int32_t z1L, z1R, z1Ls; int zMono, z_diff1, z_diff2; @@ -512,13 +520,15 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, WCD_MBHC_RSC_ASSERT_LOCKED(mbhc); - reg0 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN5); - reg1 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN6); - reg2 = snd_soc_read(codec, WCD937X_ANA_MBHC_BTN7); - reg3 = snd_soc_read(codec, WCD937X_MBHC_CTL_CLK); - reg4 = snd_soc_read(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL); + reg0 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN5); + reg1 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN6); + reg2 = snd_soc_component_read32(component, WCD937X_ANA_MBHC_BTN7); + reg3 = snd_soc_component_read32(component, WCD937X_MBHC_CTL_CLK); + reg4 = snd_soc_component_read32(component, + WCD937X_MBHC_NEW_ZDET_ANA_CTL); - if (snd_soc_read(codec, WCD937X_ANA_MBHC_ELECT) & 0x80) { + if (snd_soc_component_read32(component, WCD937X_ANA_MBHC_ELECT) & + 0x80) { is_fsm_disable = true; regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MBHC_ELECT, 0x80, 0x00); @@ -536,7 +546,7 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, /* First get impedance on Left */ d1 = d1_a[1]; zdet_param_ptr = &zdet_param[1]; - wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); if (!WCD937X_MBHC_IS_SECOND_RAMP_REQUIRED(z1L)) goto left_ch_impedance; @@ -553,7 +563,7 @@ static void wcd937x_wcd_mbhc_calc_impedance(struct wcd_mbhc *mbhc, uint32_t *zl, zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, &z1L, NULL, d1); + wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, &z1L, NULL, d1); left_ch_impedance: if ((z1L == WCD937X_ZDET_FLOATING_IMPEDANCE) || @@ -563,13 +573,13 @@ left_ch_impedance: d1 = d1_a[1]; } else { *zl = z1L/1000; - wcd937x_wcd_mbhc_qfuse_cal(codec, zl, 0); + wcd937x_wcd_mbhc_qfuse_cal(component, zl, 0); } - dev_dbg(codec->dev, "%s: impedance on HPH_L = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", __func__, *zl); /* Start of right impedance ramp and calculation */ - wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, &z1R, d1); if (WCD937X_MBHC_IS_SECOND_RAMP_REQUIRED(z1R)) { if (((z1R > WCD937X_ZDET_VAL_1200) && (zdet_param_ptr->noff == 0x6)) || @@ -587,7 +597,8 @@ left_ch_impedance: zdet_param_ptr = &zdet_param[3]; d1 = d1_a[3]; } - wcd937x_mbhc_zdet_ramp(codec, zdet_param_ptr, NULL, &z1R, d1); + wcd937x_mbhc_zdet_ramp(component, zdet_param_ptr, NULL, + &z1R, d1); } right_ch_impedance: if ((z1R == WCD937X_ZDET_FLOATING_IMPEDANCE) || @@ -595,15 +606,15 @@ right_ch_impedance: *zr = WCD937X_ZDET_FLOATING_IMPEDANCE; } else { *zr = z1R/1000; - wcd937x_wcd_mbhc_qfuse_cal(codec, zr, 1); + wcd937x_wcd_mbhc_qfuse_cal(component, zr, 1); } - dev_dbg(codec->dev, "%s: impedance on HPH_R = %d(ohms)\n", + dev_dbg(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", __func__, *zr); /* Mono/stereo detection */ if ((*zl == WCD937X_ZDET_FLOATING_IMPEDANCE) && (*zr == WCD937X_ZDET_FLOATING_IMPEDANCE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: plug type is invalid or extension cable\n", __func__); goto zdet_complete; @@ -612,40 +623,46 @@ right_ch_impedance: (*zr == WCD937X_ZDET_FLOATING_IMPEDANCE) || ((*zl < WCD_MONO_HS_MIN_THR) && (*zr > WCD_MONO_HS_MIN_THR)) || ((*zl > WCD_MONO_HS_MIN_THR) && (*zr < WCD_MONO_HS_MIN_THR))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: Mono plug type with one ch floating or shorted to GND\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; goto zdet_complete; } - snd_soc_update_bits(codec, WCD937X_HPH_R_ATEST, 0x02, 0x02); - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, 0x40, 0x01); + snd_soc_component_update_bits(component, WCD937X_HPH_R_ATEST, + 0x02, 0x02); + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, + 0x40, 0x01); if (*zl < (WCD937X_ZDET_VAL_32/1000)) - wcd937x_mbhc_zdet_ramp(codec, &zdet_param[0], &z1Ls, NULL, d1); + wcd937x_mbhc_zdet_ramp(component, &zdet_param[0], &z1Ls, + NULL, d1); else - wcd937x_mbhc_zdet_ramp(codec, &zdet_param[1], &z1Ls, NULL, d1); - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_HPH_R_ATEST, 0x02, 0x00); + wcd937x_mbhc_zdet_ramp(component, &zdet_param[1], &z1Ls, + NULL, d1); + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, + 0x40, 0x00); + snd_soc_component_update_bits(component, WCD937X_HPH_R_ATEST, + 0x02, 0x00); z1Ls /= 1000; - wcd937x_wcd_mbhc_qfuse_cal(codec, &z1Ls, 0); + wcd937x_wcd_mbhc_qfuse_cal(component, &z1Ls, 0); /* Parallel of left Z and 9 ohm pull down resistor */ zMono = ((*zl) * 9) / ((*zl) + 9); z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); if ((z_diff1 * (*zl + z1Ls)) > (z_diff2 * (z1Ls + zMono))) { - dev_dbg(codec->dev, "%s: stereo plug type detected\n", + dev_dbg(component->dev, "%s: stereo plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_STEREO; } else { - dev_dbg(codec->dev, "%s: MONO plug type detected\n", + dev_dbg(component->dev, "%s: MONO plug type detected\n", __func__); mbhc->hph_type = WCD_MBHC_HPH_MONO; } zdet_complete: - snd_soc_write(codec, WCD937X_ANA_MBHC_BTN5, reg0); - snd_soc_write(codec, WCD937X_ANA_MBHC_BTN6, reg1); - snd_soc_write(codec, WCD937X_ANA_MBHC_BTN7, reg2); + snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN5, reg0); + snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN6, reg1); + snd_soc_component_write(component, WCD937X_ANA_MBHC_BTN7, reg2); /* Turn on 100k pull down on HPHL */ regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MBHC_MECH, 0x01, 0x01); @@ -655,97 +672,98 @@ zdet_complete: regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MBHC_MECH, 0x80, 0x80); - snd_soc_write(codec, WCD937X_MBHC_NEW_ZDET_ANA_CTL, reg4); - snd_soc_write(codec, WCD937X_MBHC_CTL_CLK, reg3); + snd_soc_component_write(component, WCD937X_MBHC_NEW_ZDET_ANA_CTL, reg4); + snd_soc_component_write(component, WCD937X_MBHC_CTL_CLK, reg3); if (is_fsm_disable) regmap_update_bits(wcd937x->regmap, WCD937X_ANA_MBHC_ELECT, 0x80, 0x80); } -static void wcd937x_mbhc_gnd_det_ctrl(struct snd_soc_codec *codec, bool enable) +static void wcd937x_mbhc_gnd_det_ctrl(struct snd_soc_component *component, + bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x02, 0x02); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x40, 0x40); } else { - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x02, 0x00); } } -static void wcd937x_mbhc_hph_pull_down_ctrl(struct snd_soc_codec *codec, +static void wcd937x_mbhc_hph_pull_down_ctrl(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, 0x40, 0x40); - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, 0x10, 0x10); } else { - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_HPH_PA_CTL2, + snd_soc_component_update_bits(component, WCD937X_HPH_PA_CTL2, 0x10, 0x00); } } static void wcd937x_mbhc_moisture_config(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; if ((mbhc->moist_rref == R_OFF) || (mbhc->mbhc_cfg->enable_usbc_analog)) { - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); return; } /* Do not enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { - dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", + dev_dbg(component->dev, "%s: disable moisture detection for NC\n", __func__); - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); return; } - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, mbhc->moist_rref << 2); } static void wcd937x_mbhc_moisture_detect_en(struct wcd_mbhc *mbhc, bool enable) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; if (enable) - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, mbhc->moist_rref << 2); else - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); } static bool wcd937x_mbhc_get_moisture_status(struct wcd_mbhc *mbhc) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; bool ret = false; if ((mbhc->moist_rref == R_OFF) || (mbhc->mbhc_cfg->enable_usbc_analog)) { - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); goto done; } /* Do not enable moisture detection if jack type is NC */ if (!mbhc->hphl_swh) { - dev_dbg(codec->dev, "%s: disable moisture detection for NC\n", + dev_dbg(component->dev, "%s: disable moisture detection for NC\n", __func__); - snd_soc_update_bits(codec, WCD937X_MBHC_NEW_CTL_2, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_CTL_2, 0x0C, R_OFF << 2); goto done; } @@ -753,12 +771,13 @@ static bool wcd937x_mbhc_get_moisture_status(struct wcd_mbhc *mbhc) /* If moisture_en is already enabled, then skip to plug type * detection. */ - if ((snd_soc_read(codec, WCD937X_MBHC_NEW_CTL_2) & 0x0C)) + if ((snd_soc_component_read32(component, WCD937X_MBHC_NEW_CTL_2) & + 0x0C)) goto done; wcd937x_mbhc_moisture_detect_en(mbhc, true); /* Read moisture comparator status */ - ret = ((snd_soc_read(codec, WCD937X_MBHC_NEW_FSM_STATUS) + ret = ((snd_soc_component_read32(component, WCD937X_MBHC_NEW_FSM_STATUS) & 0x20) ? 0 : 1); done: @@ -769,9 +788,9 @@ done: static void wcd937x_mbhc_moisture_polling_ctrl(struct wcd_mbhc *mbhc, bool enable) { - struct snd_soc_codec *codec = mbhc->codec; + struct snd_soc_component *component = mbhc->component; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_MBHC_NEW_INT_MOISTURE_DET_POLLING_CTRL, 0x04, (enable << 2)); } @@ -805,19 +824,22 @@ static const struct wcd_mbhc_cb mbhc_cb = { static int wcd937x_get_hph_type(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(component); struct wcd_mbhc *mbhc; if (!wcd937x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mbhc = &wcd937x_mbhc->wcd_mbhc; ucontrol->value.integer.value[0] = (u32) mbhc->hph_type; - dev_dbg(codec->dev, "%s: hph_type = %u\n", __func__, mbhc->hph_type); + dev_dbg(component->dev, "%s: hph_type = %u\n", __func__, + mbhc->hph_type); return 0; } @@ -828,18 +850,21 @@ static int wcd937x_hph_impedance_get(struct snd_kcontrol *kcontrol, uint32_t zl, zr; bool hphr; struct soc_multi_mixer_control *mc; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_mbhc *wcd937x_mbhc = wcd937x_soc_get_mbhc(component); if (!wcd937x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } mc = (struct soc_multi_mixer_control *)(kcontrol->private_value); hphr = mc->shift; wcd_mbhc_get_impedance(&wcd937x_mbhc->wcd_mbhc, &zl, &zr); - dev_dbg(codec->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); + dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, + zl, zr); ucontrol->value.integer.value[0] = hphr ? zr : zl; return 0; @@ -883,22 +908,22 @@ EXPORT_SYMBOL(wcd937x_mbhc_get_impedance); /* * wcd937x_mbhc_hs_detect: starts mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @mbhc_cfg: handle to mbhc configuration structure * return 0 if mbhc_start is success or error code in case of failure */ -int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec, +int wcd937x_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { struct wcd937x_priv *wcd937x = NULL; struct wcd937x_mbhc *wcd937x_mbhc = NULL; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return -EINVAL; } - wcd937x = snd_soc_codec_get_drvdata(codec); + wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) { pr_err("%s: wcd937x is NULL\n", __func__); return -EINVAL; @@ -906,7 +931,8 @@ int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec, wcd937x_mbhc = wcd937x->mbhc; if (!wcd937x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return -EINVAL; } @@ -916,19 +942,19 @@ EXPORT_SYMBOL(wcd937x_mbhc_hs_detect); /* * wcd937x_mbhc_hs_detect_exit: stop mbhc insertion/removal functionality - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component) { struct wcd937x_priv *wcd937x = NULL; struct wcd937x_mbhc *wcd937x_mbhc = NULL; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return; } - wcd937x = snd_soc_codec_get_drvdata(codec); + wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) { pr_err("%s: wcd937x is NULL\n", __func__); return; @@ -936,7 +962,8 @@ void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec) wcd937x_mbhc = wcd937x->mbhc; if (!wcd937x_mbhc) { - dev_err(codec->dev, "%s: mbhc not initialized!\n", __func__); + dev_err(component->dev, "%s: mbhc not initialized!\n", + __func__); return; } wcd_mbhc_stop(&wcd937x_mbhc->wcd_mbhc); @@ -947,17 +974,17 @@ EXPORT_SYMBOL(wcd937x_mbhc_hs_detect_exit); * wcd937x_mbhc_post_ssr_init: initialize mbhc for * wcd937x post subsystem restart * @mbhc: poniter to wcd937x_mbhc structure - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * * return 0 if mbhc_init is success or error code in case of failure */ int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { int ret = 0; struct wcd_mbhc *wcd_mbhc = NULL; - if (!mbhc || !codec) + if (!mbhc || !component) return -EINVAL; wcd_mbhc = &mbhc->wcd_mbhc; @@ -966,14 +993,14 @@ int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, return -EINVAL; } - wcd937x_mbhc_hs_detect_exit(codec); + wcd937x_mbhc_hs_detect_exit(component); wcd_mbhc_deinit(wcd_mbhc); - snd_soc_update_bits(codec, WCD937X_ANA_MBHC_MECH, + snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x20, 0x20); - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, &intr_ids, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, WCD937X_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto done; } @@ -986,24 +1013,25 @@ EXPORT_SYMBOL(wcd937x_mbhc_post_ssr_init); /* * wcd937x_mbhc_init: initialize mbhc for wcd937x * @mbhc: poniter to wcd937x_mbhc struct pointer to store the configs - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @fw_data: handle to firmware data * * return 0 if mbhc_init is success or error code in case of failure */ -int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, struct snd_soc_codec *codec, - struct fw_info *fw_data) +int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, + struct snd_soc_component *component, + struct fw_info *fw_data) { struct wcd937x_mbhc *wcd937x_mbhc = NULL; struct wcd_mbhc *wcd_mbhc = NULL; int ret = 0; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return -EINVAL; } - wcd937x_mbhc = devm_kzalloc(codec->dev, sizeof(struct wcd937x_mbhc), + wcd937x_mbhc = devm_kzalloc(component->dev, sizeof(struct wcd937x_mbhc), GFP_KERNEL); if (!wcd937x_mbhc) return -ENOMEM; @@ -1021,43 +1049,43 @@ int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, struct snd_soc_codec *codec, /* Setting default mbhc detection logic to ADC */ wcd_mbhc->mbhc_detection_logic = WCD_DETECTION_ADC; - ret = wcd_mbhc_init(wcd_mbhc, codec, &mbhc_cb, + ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, WCD937X_ZDET_SUPPORTED); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); goto err; } (*mbhc) = wcd937x_mbhc; - snd_soc_add_codec_controls(codec, impedance_detect_controls, + snd_soc_add_component_controls(component, impedance_detect_controls, ARRAY_SIZE(impedance_detect_controls)); - snd_soc_add_codec_controls(codec, hph_type_detect_controls, + snd_soc_add_component_controls(component, hph_type_detect_controls, ARRAY_SIZE(hph_type_detect_controls)); return 0; err: - devm_kfree(codec->dev, wcd937x_mbhc); + devm_kfree(component->dev, wcd937x_mbhc); return ret; } EXPORT_SYMBOL(wcd937x_mbhc_init); /* * wcd937x_mbhc_deinit: deinitialize mbhc for wcd937x - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * */ -void wcd937x_mbhc_deinit(struct snd_soc_codec *codec) +void wcd937x_mbhc_deinit(struct snd_soc_component *component) { struct wcd937x_priv *wcd937x; struct wcd937x_mbhc *wcd937x_mbhc; - if (!codec) { - pr_err("%s: codec is NULL\n", __func__); + if (!component) { + pr_err("%s: component is NULL\n", __func__); return; } - wcd937x = snd_soc_codec_get_drvdata(codec); + wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) { pr_err("%s: wcd937x is NULL\n", __func__); return; @@ -1066,7 +1094,7 @@ void wcd937x_mbhc_deinit(struct snd_soc_codec *codec) wcd937x_mbhc = wcd937x->mbhc; if (wcd937x_mbhc) { wcd_mbhc_deinit(&wcd937x_mbhc->wcd_mbhc); - devm_kfree(codec->dev, wcd937x_mbhc); + devm_kfree(component->dev, wcd937x_mbhc); } } EXPORT_SYMBOL(wcd937x_mbhc_deinit); diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.h b/asoc/codecs/wcd937x/wcd937x-mbhc.h index c0689e4bf0..d7bfb16954 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.h +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.h @@ -13,36 +13,37 @@ struct wcd937x_mbhc { #if IS_ENABLED(CONFIG_SND_SOC_WCD937X) extern int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data); -extern void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec); -extern int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec, +extern void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component); +extern int wcd937x_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); -extern void wcd937x_mbhc_deinit(struct snd_soc_codec *codec); +extern void wcd937x_mbhc_deinit(struct snd_soc_component *component); extern int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, - struct snd_soc_codec *codec); + struct snd_soc_component *component); extern int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc, uint32_t *zl, uint32_t *zr); #else static inline int wcd937x_mbhc_init(struct wcd937x_mbhc **mbhc, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct fw_info *fw_data) { return 0; } -static inline void wcd937x_mbhc_hs_detect_exit(struct snd_soc_codec *codec) +static inline void wcd937x_mbhc_hs_detect_exit( + struct snd_soc_component *component) { } -static inline int wcd937x_mbhc_hs_detect(struct snd_soc_codec *codec, +static inline int wcd937x_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg) { return 0; } -static inline void wcd937x_mbhc_deinit(struct snd_soc_codec *codec) +static inline void wcd937x_mbhc_deinit(struct snd_soc_component *component) { } static inline int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index ea0e2ee9e6..fbd553a841 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.c @@ -25,6 +25,8 @@ #include #include "../msm-cdc-supply.h" +#define DRV_NAME "wcd937x_codec" + #define WCD9370_VARIANT 0 #define WCD9375_VARIANT 5 @@ -83,7 +85,6 @@ static struct regmap_irq_chip wcd937x_regmap_irq_chip = { .mask_base = WCD937X_DIGITAL_INTR_MASK_0, .ack_base = WCD937X_DIGITAL_INTR_CLEAR_0, .use_ack = 1, - .clear_ack = 1, .type_base = WCD937X_DIGITAL_INTR_LEVEL_0, .runtime_pm = false, .handle_post_irq = wcd937x_handle_post_irq, @@ -104,35 +105,48 @@ static int wcd937x_handle_post_irq(void *data) return IRQ_HANDLED; } -static int wcd937x_init_reg(struct snd_soc_codec *codec) +static int wcd937x_init_reg(struct snd_soc_component *component) { - snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x0E, 0x0E); - snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x80, 0x80); + snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, + 0x0E, 0x0E); + snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, + 0x80, 0x80); usleep_range(1000, 1010); - snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x40, 0x40); + snd_soc_component_update_bits(component, WCD937X_SLEEP_CTL, + 0x40, 0x40); usleep_range(1000, 1010); - snd_soc_update_bits(codec, WCD937X_LDORXTX_CONFIG, 0x10, 0x00); - snd_soc_update_bits(codec, WCD937X_BIAS_VBG_FINE_ADJ, 0xF0, 0x80); - snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x80, 0x80); - snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x40, 0x40); + snd_soc_component_update_bits(component, WCD937X_LDORXTX_CONFIG, + 0x10, 0x00); + snd_soc_component_update_bits(component, WCD937X_BIAS_VBG_FINE_ADJ, + 0xF0, 0x80); + snd_soc_component_update_bits(component, WCD937X_ANA_BIAS, + 0x80, 0x80); + snd_soc_component_update_bits(component, WCD937X_ANA_BIAS, + 0x40, 0x40); usleep_range(10000, 10010); - snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_HPH_OCP_CTL, 0xFF, 0x3A); - snd_soc_update_bits(codec, WCD937X_RX_OCP_CTL, 0x0F, 0x02); - snd_soc_update_bits(codec, WCD937X_HPH_R_TEST, 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_HPH_L_TEST, 0x01, 0x01); + snd_soc_component_update_bits(component, WCD937X_ANA_BIAS, + 0x40, 0x00); + snd_soc_component_update_bits(component, WCD937X_HPH_OCP_CTL, + 0xFF, 0x3A); + snd_soc_component_update_bits(component, WCD937X_RX_OCP_CTL, + 0x0F, 0x02); + snd_soc_component_update_bits(component, WCD937X_HPH_R_TEST, + 0x01, 0x01); + snd_soc_component_update_bits(component, WCD937X_HPH_L_TEST, + 0x01, 0x01); return 0; } -static int wcd937x_set_port_params(struct snd_soc_codec *codec, u8 slv_prt_type, - u8 *port_id, u8 *num_ch, u8 *ch_mask, u32 *ch_rate, - u8 *port_type, u8 path) +static int wcd937x_set_port_params(struct snd_soc_component *component, + u8 slv_prt_type, u8 *port_id, u8 *num_ch, + u8 *ch_mask, u32 *ch_rate, + u8 *port_type, u8 path) { int i, j; u8 num_ports = 0; struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT] = NULL; - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); switch (path) { case CODEC_RX: @@ -153,7 +167,7 @@ static int wcd937x_set_port_params(struct snd_soc_codec *codec, u8 slv_prt_type, } found: if (i > num_ports || j == MAX_CH_PER_PORT) { - dev_err(codec->dev, "%s Failed to find slave port for type %u\n", + dev_err(component->dev, "%s Failed to find slave port for type %u\n", __func__, slv_prt_type); return -EINVAL; } @@ -240,10 +254,10 @@ err: return ret; } -static int wcd937x_tx_connect_port(struct snd_soc_codec *codec, +static int wcd937x_tx_connect_port(struct snd_soc_component *component, u8 slv_port_type, u8 enable) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); u8 port_id; u8 num_ch; u8 ch_mask; @@ -252,7 +266,7 @@ static int wcd937x_tx_connect_port(struct snd_soc_codec *codec, u8 num_port = 1; int ret = 0; - ret = wcd937x_set_port_params(codec, slv_port_type, &port_id, + ret = wcd937x_set_port_params(component, slv_port_type, &port_id, &num_ch, &ch_mask, &ch_rate, &port_type, CODEC_TX); @@ -269,10 +283,10 @@ static int wcd937x_tx_connect_port(struct snd_soc_codec *codec, return ret; } -static int wcd937x_rx_connect_port(struct snd_soc_codec *codec, +static int wcd937x_rx_connect_port(struct snd_soc_component *component, u8 slv_port_type, u8 enable) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); u8 port_id; u8 num_ch; u8 ch_mask; @@ -281,7 +295,7 @@ static int wcd937x_rx_connect_port(struct snd_soc_codec *codec, u8 num_port = 1; int ret = 0; - ret = wcd937x_set_port_params(codec, slv_port_type, &port_id, + ret = wcd937x_set_port_params(component, slv_port_type, &port_id, &num_ch, &ch_mask, &ch_rate, &port_type, CODEC_RX); @@ -298,33 +312,34 @@ static int wcd937x_rx_connect_port(struct snd_soc_codec *codec, return ret; } -static int wcd937x_rx_clk_enable(struct snd_soc_codec *codec) +static int wcd937x_rx_clk_enable(struct snd_soc_component *component) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); if (wcd937x->rx_clk_cnt == 0) { - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x08, 0x08); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX0_CTL, - 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX1_CTL, - 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX2_CTL, - 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_RX0_CTL, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_RX1_CTL, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_RX2_CTL, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x02, 0x02); } wcd937x->rx_clk_cnt++; return 0; } -static int wcd937x_rx_clk_disable(struct snd_soc_codec *codec) +static int wcd937x_rx_clk_disable(struct snd_soc_component *component) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); if (wcd937x->rx_clk_cnt == 0) { dev_dbg(wcd937x->dev, "%s:clk already disabled\n", __func__); @@ -332,30 +347,33 @@ static int wcd937x_rx_clk_disable(struct snd_soc_codec *codec) } wcd937x->rx_clk_cnt--; if (wcd937x->rx_clk_cnt == 0) { - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x01, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x02, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, + 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, + 0x01, 0x00); } return 0; } /* - * wcd937x_soc_get_mbhc: get wcd937x_mbhc handle of corresponding codec - * @codec: handle to snd_soc_codec * + * wcd937x_soc_get_mbhc: get wcd937x_mbhc handle of corresponding component + * @component: handle to snd_soc_component * * * return wcd937x_mbhc handle or error code in case of failure */ -struct wcd937x_mbhc *wcd937x_soc_get_mbhc(struct snd_soc_codec *codec) +struct wcd937x_mbhc *wcd937x_soc_get_mbhc(struct snd_soc_component *component) { struct wcd937x_priv *wcd937x; - if (!codec) { - pr_err("%s: Invalid params, NULL codec\n", __func__); + if (!component) { + pr_err("%s: Invalid params, NULL component\n", __func__); return NULL; } - wcd937x = snd_soc_codec_get_drvdata(codec); + wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) { pr_err("%s: Invalid params, NULL tavil\n", __func__); @@ -370,44 +388,48 @@ static int wcd937x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_clk_enable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD937X_HPH_RDAC_CLK_CTL1, - 0x80, 0x00); + wcd937x_rx_clk_enable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, + 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD937X_HPH_RDAC_CLK_CTL1, + 0x80, 0x00); set_bit(HPH_COMP_DELAY, &wcd937x->status_mask); break; case SND_SOC_DAPM_POST_PMU: if (hph_mode == CLS_AB_HIFI || hph_mode == CLS_H_HIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x02); else if (hph_mode == CLS_H_LOHIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x06); if (wcd937x->comp1_enable) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x02, 0x02); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_L_EN, 0x20, 0x00); if (wcd937x->comp2_enable) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x01, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_R_EN, 0x20, 0x00); } /* @@ -420,17 +442,17 @@ static int wcd937x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, &wcd937x->status_mask); } } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x02, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_L_EN, 0x20, 0x20); } - snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD937X_HPH_NEW_INT_HPH_TIMER1, 0x02, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x01); break; @@ -443,44 +465,45 @@ static int wcd937x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_clk_enable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x02, 0x02); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, - 0x08, 0x08); - snd_soc_update_bits(codec, WCD937X_HPH_RDAC_CLK_CTL1, - 0x80, 0x00); + wcd937x_rx_clk_enable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD937X_HPH_RDAC_CLK_CTL1, 0x80, 0x00); set_bit(HPH_COMP_DELAY, &wcd937x->status_mask); break; case SND_SOC_DAPM_POST_PMU: if (hph_mode == CLS_AB_HIFI || hph_mode == CLS_H_HIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x0F, 0x02); else if (hph_mode == CLS_H_LOHIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x0F, 0x06); if (wcd937x->comp2_enable) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x01, 0x01); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_R_EN, 0x20, 0x00); if (wcd937x->comp1_enable) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x02, 0x02); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_L_EN, 0x20, 0x00); } /* @@ -493,17 +516,17 @@ static int wcd937x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, &wcd937x->status_mask); } } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_DIGITAL_CDC_COMP_CTL_0, 0x01, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_R_EN, 0x20, 0x20); } - snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x00); + snd_soc_component_update_bits(component, + WCD937X_HPH_NEW_INT_HPH_TIMER1, 0x02, 0x00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x0F, 0x01); break; @@ -516,32 +539,36 @@ static int wcd937x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_clk_enable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x01, 0x01); + wcd937x_rx_clk_enable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_HPH_GAIN_CTL, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, + 0x01, 0x01); if (hph_mode == CLS_AB_HIFI || hph_mode == CLS_H_HIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x02); else if (hph_mode == CLS_H_LOHIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x06); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_COMP_CTL_0, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_COMP_CTL_0, + 0x02, 0x02); usleep_range(5000, 5010); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_EAR, hph_mode); @@ -550,7 +577,7 @@ static int wcd937x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: if (hph_mode == CLS_AB_HIFI || hph_mode == CLS_H_LOHIFI || hph_mode == CLS_H_HIFI) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x0F, 0x01); break; @@ -563,32 +590,37 @@ static int wcd937x_codec_aux_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_clk_enable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x04, 0x04); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_AUX_GAIN_CTL, - 0x01, 0x01); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd937x_rx_clk_enable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, + 0x04, 0x04); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_AUX_GAIN_CTL, + 0x01, 0x01); + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_AUX, hph_mode); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_rx_clk_disable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x04, 0x00); + wcd937x_rx_clk_disable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, + 0x04, 0x00); break; }; return 0; @@ -599,12 +631,13 @@ static int wcd937x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int ret = 0; int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { @@ -612,11 +645,12 @@ static int wcd937x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev, wcd937x->rx_swr_dev->dev_num, true); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHR, hph_mode); - snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x10, 0x10); + snd_soc_component_update_bits(component, WCD937X_ANA_HPH, + 0x10, 0x10); usleep_range(100, 110); set_bit(HPH_PA_DELAY, &wcd937x->status_mask); break; @@ -634,11 +668,13 @@ static int wcd937x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, clear_bit(HPH_PA_DELAY, &wcd937x->status_mask); } - snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI) - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, + 0x02, 0x02); if (wcd937x->update_wcd_event) wcd937x->update_wcd_event(wcd937x->handle, WCD_BOLERO_EVT_RX_MUTE, @@ -658,8 +694,9 @@ static int wcd937x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, blocking_notifier_call_chain(&wcd937x->mbhc->notifier, WCD_EVENT_POST_HPHR_PA_OFF, &wcd937x->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x10, 0x00); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + snd_soc_component_update_bits(component, WCD937X_ANA_HPH, + 0x10, 0x00); + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHR, hph_mode); @@ -672,12 +709,13 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int ret = 0; int hph_mode = wcd937x->hph_mode; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { @@ -685,11 +723,12 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev, wcd937x->rx_swr_dev->dev_num, true); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, WCD_CLSH_STATE_HPHL, hph_mode); - snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x20, 0x20); + snd_soc_component_update_bits(component, WCD937X_ANA_HPH, + 0x20, 0x20); usleep_range(100, 110); set_bit(HPH_PA_DELAY, &wcd937x->status_mask); break; @@ -707,11 +746,13 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, clear_bit(HPH_PA_DELAY, &wcd937x->status_mask); } - snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_HPH_NEW_INT_HPH_TIMER1, + 0x02, 0x02); if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI) - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, + 0x02, 0x02); if (wcd937x->update_wcd_event) wcd937x->update_wcd_event(wcd937x->handle, WCD_BOLERO_EVT_RX_MUTE, @@ -731,8 +772,9 @@ static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, blocking_notifier_call_chain(&wcd937x->mbhc->notifier, WCD_EVENT_POST_HPHL_PA_OFF, &wcd937x->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x20, 0x00); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + snd_soc_component_update_bits(component, WCD937X_ANA_HPH, + 0x20, 0x00); + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_HPHL, hph_mode); @@ -745,12 +787,13 @@ static int wcd937x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { @@ -762,8 +805,9 @@ static int wcd937x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: usleep_range(1000, 1010); if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI) - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, + 0x02, 0x02); if (wcd937x->update_wcd_event) wcd937x->update_wcd_event(wcd937x->handle, WCD_BOLERO_EVT_RX_MUTE, @@ -778,7 +822,7 @@ static int wcd937x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: usleep_range(1000, 1010); usleep_range(1000, 1010); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_AUX, hph_mode); @@ -791,12 +835,13 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int hph_mode = wcd937x->hph_mode; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { @@ -808,8 +853,9 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: usleep_range(6000, 6010); if (hph_mode == CLS_AB || hph_mode == CLS_AB_HIFI) - snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, - 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_ANA_RX_SUPPLIES, + 0x02, 0x02); if (wcd937x->update_wcd_event) wcd937x->update_wcd_event(wcd937x->handle, WCD_BOLERO_EVT_RX_MUTE, @@ -823,7 +869,7 @@ static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: usleep_range(7000, 7010); - wcd_cls_h_fsm(codec, &wcd937x->clsh_info, + wcd_cls_h_fsm(component, &wcd937x->clsh_info, WCD_CLSH_EVENT_POST_PA, WCD_CLSH_STATE_EAR, hph_mode); @@ -836,17 +882,18 @@ static int wcd937x_enable_clsh(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int mode = wcd937x->hph_mode; int ret = 0; - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); if (mode == CLS_H_LOHIFI || mode == CLS_H_ULP || mode == CLS_H_HIFI || mode == CLS_H_LP) { - wcd937x_rx_connect_port(codec, CLSH, + wcd937x_rx_connect_port(component, CLSH, SND_SOC_DAPM_EVENT_ON(event)); } if (SND_SOC_DAPM_EVENT_OFF(event)) @@ -861,25 +908,27 @@ static int wcd937x_enable_rx1(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_connect_port(codec, HPH_L, true); + wcd937x_rx_connect_port(component, HPH_L, true); if (wcd937x->comp1_enable) - wcd937x_rx_connect_port(codec, COMP_L, true); + wcd937x_rx_connect_port(component, COMP_L, true); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_rx_connect_port(codec, HPH_L, false); + wcd937x_rx_connect_port(component, HPH_L, false); if (wcd937x->comp1_enable) - wcd937x_rx_connect_port(codec, COMP_L, false); - wcd937x_rx_clk_disable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x01, 0x00); + wcd937x_rx_connect_port(component, COMP_L, false); + wcd937x_rx_clk_disable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, + 0x01, 0x00); break; }; return 0; @@ -888,25 +937,27 @@ static int wcd937x_enable_rx1(struct snd_soc_dapm_widget *w, static int wcd937x_enable_rx2(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_connect_port(codec, HPH_R, true); + wcd937x_rx_connect_port(component, HPH_R, true); if (wcd937x->comp2_enable) - wcd937x_rx_connect_port(codec, COMP_R, true); + wcd937x_rx_connect_port(component, COMP_R, true); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_rx_connect_port(codec, HPH_R, false); + wcd937x_rx_connect_port(component, HPH_R, false); if (wcd937x->comp2_enable) - wcd937x_rx_connect_port(codec, COMP_R, false); - wcd937x_rx_clk_disable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x02, 0x00); + wcd937x_rx_connect_port(component, COMP_R, false); + wcd937x_rx_clk_disable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, + 0x02, 0x00); break; }; @@ -917,22 +968,22 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_rx_connect_port(codec, LO, true); + wcd937x_rx_connect_port(component, LO, true); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_rx_connect_port(codec, LO, false); + wcd937x_rx_connect_port(component, LO, false); usleep_range(6000, 6010); - wcd937x_rx_clk_disable(codec); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x04, 0x00); + wcd937x_rx_clk_disable(component); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x04, 0x00); break; } return 0; @@ -943,8 +994,9 @@ static int wcd937x_codec_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); u16 dmic_clk_reg; s32 *dmic_clk_cnt; unsigned int dmic; @@ -954,18 +1006,18 @@ static int wcd937x_codec_enable_dmic(struct snd_soc_dapm_widget *w, wname = strpbrk(w->name, "012345"); if (!wname) { - dev_err(codec->dev, "%s: widget not found\n", __func__); + dev_err(component->dev, "%s: widget not found\n", __func__); return -EINVAL; } ret = kstrtouint(wname, 10, &dmic); if (ret < 0) { - dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n", + dev_err(component->dev, "%s: Invalid DMIC line on the codec\n", __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (dmic) { @@ -985,24 +1037,27 @@ static int wcd937x_codec_enable_dmic(struct snd_soc_dapm_widget *w, dmic_clk_reg = WCD937X_DIGITAL_CDC_DMIC2_CTL; break; default: - dev_err(codec->dev, "%s: Invalid DMIC Selection\n", + dev_err(component->dev, "%s: Invalid DMIC Selection\n", __func__); return -EINVAL; }; - dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", + dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n", __func__, event, dmic, *dmic_clk_cnt); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x80, 0x80); - snd_soc_update_bits(codec, dmic_clk_reg, 0x07, 0x02); - snd_soc_update_bits(codec, dmic_clk_reg, 0x08, 0x08); - snd_soc_update_bits(codec, dmic_clk_reg, 0x70, 0x20); - wcd937x_tx_connect_port(codec, DMIC0 + (w->shift), true); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x80); + snd_soc_component_update_bits(component, + dmic_clk_reg, 0x07, 0x02); + snd_soc_component_update_bits(component, + dmic_clk_reg, 0x08, 0x08); + snd_soc_component_update_bits(component, + dmic_clk_reg, 0x70, 0x20); + wcd937x_tx_connect_port(component, DMIC0 + (w->shift), true); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_tx_connect_port(codec, DMIC0 + (w->shift), false); + wcd937x_tx_connect_port(component, DMIC0 + (w->shift), false); break; }; @@ -1029,16 +1084,17 @@ EXPORT_SYMBOL(wcd937x_get_micb_vout_ctl_val); /* * wcd937x_mbhc_micb_adjust_voltage: adjust specific micbias voltage - * @codec: handle to snd_soc_codec * + * @component: handle to snd_soc_component * * @req_volt: micbias voltage to be set * @micb_num: micbias to be set, e.g. micbias1 or micbias2 * * return 0 if adjustment is success or error code in case of failure */ -int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, +int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, int req_volt, int micb_num) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = + snd_soc_component_get_drvdata(component); int cur_vout_ctl, req_vout_ctl; int micb_reg, micb_val, micb_en; int ret = 0; @@ -1066,7 +1122,7 @@ int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, * momentarily, change the micbias value and then re-enable * micbias. */ - micb_val = snd_soc_read(codec, micb_reg); + micb_val = snd_soc_component_read32(component, micb_reg); micb_en = (micb_val & 0xC0) >> 6; cur_vout_ctl = micb_val & 0x3F; @@ -1080,17 +1136,17 @@ int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec, goto exit; } - dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", + dev_dbg(component->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n", __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl), req_volt, micb_en); if (micb_en == 0x1) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x80); - snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl); + snd_soc_component_update_bits(component, micb_reg, 0x3F, req_vout_ctl); if (micb_en == 0x1) { - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); + snd_soc_component_update_bits(component, micb_reg, 0xC0, 0x40); /* * Add 2ms delay as per HW requirement after enabling * micbias @@ -1107,8 +1163,9 @@ static int wcd937x_tx_swr_ctrl(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int ret = 0; switch (event) { @@ -1131,25 +1188,26 @@ static int wcd937x_codec_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event){ - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x80, 0x80); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x08, 0x08); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x10, 0x10); - wcd937x_tx_connect_port(codec, ADC1 + (w->shift), true); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x08, 0x08); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10); + wcd937x_tx_connect_port(component, ADC1 + (w->shift), true); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_tx_connect_port(codec, ADC1 + (w->shift), false); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x08, 0x00); + wcd937x_tx_connect_port(component, ADC1 + (w->shift), false); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x08, 0x00); break; }; @@ -1159,43 +1217,50 @@ static int wcd937x_codec_enable_adc(struct snd_soc_dapm_widget *w, static int wcd937x_enable_req(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_REQ_CTL, - 0x02, 0x02); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_REQ_CTL, 0x01, - 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x40, 0x40); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x30, 0x30); - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH1, 0x80, 0x80); - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x40, 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_REQ_CTL, 0x02, 0x02); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_REQ_CTL, 0x01, 0x00); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH2, 0x40, 0x40); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x30, 0x30); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH1, 0x80, 0x80); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH2, 0x40, 0x00); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH2, 0x80, 0x80); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH1, 0x80, 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x80, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x10, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, - 0x10, 0x00); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, - 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH1, 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD937X_ANA_TX_CH2, 0x80, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x00); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0x80, 0x00); break; }; return 0; } -int wcd937x_micbias_control(struct snd_soc_codec *codec, +int wcd937x_micbias_control(struct snd_soc_component *component, int micb_num, int req, bool is_dapm) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int micb_index = micb_num - 1; u16 micb_reg; int pre_off_event = 0, post_off_event = 0; @@ -1203,7 +1268,7 @@ int wcd937x_micbias_control(struct snd_soc_codec *codec, int post_dapm_on = 0; if ((micb_index < 0) || (micb_index > WCD937X_MAX_MICBIAS - 1)) { - dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n", + dev_err(component->dev, "%s: Invalid micbias index, micb_ind:%d\n", __func__, micb_index); return -EINVAL; } @@ -1223,7 +1288,7 @@ int wcd937x_micbias_control(struct snd_soc_codec *codec, micb_reg = WCD937X_ANA_MICB3; break; default: - dev_err(codec->dev, "%s: Invalid micbias number: %d\n", + dev_err(component->dev, "%s: Invalid micbias number: %d\n", __func__, micb_num); return -EINVAL; }; @@ -1234,25 +1299,33 @@ int wcd937x_micbias_control(struct snd_soc_codec *codec, wcd937x->pullup_ref[micb_index]++; if ((wcd937x->pullup_ref[micb_index] == 1) && (wcd937x->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); break; case MICB_PULLUP_DISABLE: if (wcd937x->pullup_ref[micb_index] > 0) wcd937x->pullup_ref[micb_index]--; if ((wcd937x->pullup_ref[micb_index] == 0) && (wcd937x->micb_ref[micb_index] == 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); break; case MICB_ENABLE: wcd937x->micb_ref[micb_index]++; if (wcd937x->micb_ref[micb_index] == 1) { - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0xE0, 0xE0); - snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10); - snd_soc_update_bits(codec, WCD937X_MICB1_TEST_CTL_2, 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_MICB2_TEST_CTL_2, 0x01, 0x01); - snd_soc_update_bits(codec, WCD937X_MICB3_TEST_CTL_2, 0x01, 0x01); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40); - if (post_on_event && wcd937x->mbhc) + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0xE0, 0xE0); + snd_soc_component_update_bits(component, + WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10); + snd_soc_component_update_bits(component, + WCD937X_MICB1_TEST_CTL_2, 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD937X_MICB2_TEST_CTL_2, 0x01, 0x01); + snd_soc_component_update_bits(component, + WCD937X_MICB3_TEST_CTL_2, 0x01, 0x01); + snd_soc_component_update_bits(component, + micb_reg, 0xC0, 0x40); + if (post_on_event) blocking_notifier_call_chain( &wcd937x->mbhc->notifier, post_on_event, &wcd937x->mbhc->wcd_mbhc); @@ -1267,14 +1340,16 @@ int wcd937x_micbias_control(struct snd_soc_codec *codec, wcd937x->micb_ref[micb_index]--; if ((wcd937x->micb_ref[micb_index] == 0) && (wcd937x->pullup_ref[micb_index] > 0)) - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x80); else if ((wcd937x->micb_ref[micb_index] == 0) && (wcd937x->pullup_ref[micb_index] == 0)) { if (pre_off_event && wcd937x->mbhc) blocking_notifier_call_chain( &wcd937x->mbhc->notifier, pre_off_event, &wcd937x->mbhc->wcd_mbhc); - snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00); + snd_soc_component_update_bits(component, micb_reg, + 0xC0, 0x00); if (post_off_event && wcd937x->mbhc) blocking_notifier_call_chain( &wcd937x->mbhc->notifier, @@ -1288,7 +1363,7 @@ int wcd937x_micbias_control(struct snd_soc_codec *codec, break; }; - dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", + dev_dbg(component->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n", __func__, micb_num, wcd937x->micb_ref[micb_index], wcd937x->pullup_ref[micb_index]); mutex_unlock(&wcd937x->micb_lock); @@ -1323,7 +1398,7 @@ static int wcd937x_event_notify(struct notifier_block *block, u16 mask = 0x40, reg = 0x0; int ret = 0; struct wcd937x_priv *wcd937x = dev_get_drvdata((struct device *)data); - struct snd_soc_codec *codec = wcd937x->codec; + struct snd_soc_component *component = wcd937x->component; struct wcd_mbhc *mbhc; switch (event) { @@ -1336,12 +1411,15 @@ static int wcd937x_event_notify(struct notifier_block *block, return 0; if (amic == 0x2) mask = 0x20; - snd_soc_update_bits(codec, reg, mask, 0x00); + snd_soc_component_update_bits(component, reg, mask, 0x00); break; case BOLERO_WCD_EVT_PA_OFF_PRE_SSR: - snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0xC0, 0x00); - snd_soc_update_bits(codec, WCD937X_ANA_EAR, 0x80, 0x00); - snd_soc_update_bits(codec, WCD937X_AUX_AUXPA, 0x80, 0x00); + snd_soc_component_update_bits(component, WCD937X_ANA_HPH, + 0xC0, 0x00); + snd_soc_component_update_bits(component, WCD937X_ANA_EAR, + 0x80, 0x00); + snd_soc_component_update_bits(component, WCD937X_AUX_AUXPA, + 0x80, 0x00); break; case BOLERO_WCD_EVT_SSR_DOWN: wcd937x_reset_low(wcd937x->dev); @@ -1354,16 +1432,17 @@ static int wcd937x_event_notify(struct notifier_block *block, regcache_sync(wcd937x->regmap); /* Initialize MBHC module */ mbhc = &wcd937x->mbhc->wcd_mbhc; - ret = wcd937x_mbhc_post_ssr_init(wcd937x->mbhc, codec); + ret = wcd937x_mbhc_post_ssr_init(wcd937x->mbhc, component); if (ret) { - dev_err(codec->dev, "%s: mbhc initialization failed\n", + dev_err(component->dev, "%s: mbhc initialization failed\n", __func__); } else { - wcd937x_mbhc_hs_detect(codec, mbhc->mbhc_cfg); + wcd937x_mbhc_hs_detect(component, mbhc->mbhc_cfg); } break; default: - dev_err(codec->dev, "%s: invalid event %d\n", __func__, event); + dev_err(component->dev, "%s: invalid event %d\n", __func__, + event); break; } return 0; @@ -1372,10 +1451,11 @@ static int wcd937x_event_notify(struct notifier_block *block, static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); int micb_num; - dev_dbg(codec->dev, "%s: wname: %s, event: %d\n", + dev_dbg(component->dev, "%s: wname: %s, event: %d\n", __func__, w->name, event); if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) @@ -1389,13 +1469,15 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - wcd937x_micbias_control(codec, micb_num, MICB_ENABLE, true); + wcd937x_micbias_control(component, micb_num, + MICB_ENABLE, true); break; case SND_SOC_DAPM_POST_PMU: usleep_range(1000, 1100); break; case SND_SOC_DAPM_POST_PMD: - wcd937x_micbias_control(codec, micb_num, MICB_DISABLE, true); + wcd937x_micbias_control(component, micb_num, + MICB_DISABLE, true); break; }; @@ -1413,8 +1495,9 @@ static int wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w, static int wcd937x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wcd937x->hph_mode; return 0; @@ -1423,16 +1506,17 @@ static int wcd937x_rx_hph_mode_get(struct snd_kcontrol *kcontrol, static int wcd937x_rx_hph_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); u32 mode_val; mode_val = ucontrol->value.enumerated.item[0]; - dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val); + dev_dbg(component->dev, "%s: mode: %d\n", __func__, mode_val); if (mode_val == 0) { - dev_warn(codec->dev, "%s:Invalid HPH Mode, default to class_AB\n", + dev_warn(component->dev, "%s:Invalid HPH Mode, default to class_AB\n", __func__); mode_val = 3; /* enum will be updated later */ } @@ -1444,8 +1528,9 @@ static int wcd937x_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); bool hphr; struct soc_multi_mixer_control *mc; @@ -1460,8 +1545,9 @@ static int wcd937x_get_compander(struct snd_kcontrol *kcontrol, static int wcd937x_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); int value = ucontrol->value.integer.value[0]; bool hphr; struct soc_multi_mixer_control *mc; @@ -1480,25 +1566,26 @@ static int wcd937x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); struct wcd937x_pdata *pdata = NULL; int ret = 0; pdata = dev_get_platdata(wcd937x->dev); if (!pdata) { - dev_err(codec->dev, "%s: pdata is NULL\n", __func__); + dev_err(component->dev, "%s: pdata is NULL\n", __func__); return -EINVAL; } - dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__, + dev_dbg(component->dev, "%s wname: %s event: %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (test_bit(ALLOW_BUCK_DISABLE, &wcd937x->status_mask)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: buck already in enabled state\n", __func__); return 0; @@ -1509,7 +1596,7 @@ static int wcd937x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w, pdata->num_supplies, "cdc-vdd-buck"); if (ret == -EINVAL) { - dev_err(codec->dev, "%s: vdd buck is not enabled\n", + dev_err(component->dev, "%s: vdd buck is not enabled\n", __func__); return ret; } @@ -1546,9 +1633,12 @@ static const struct snd_kcontrol_new wcd937x_snd_controls[] = { SOC_SINGLE_TLV("HPHL Volume", WCD937X_HPH_L_EN, 0, 20, 1, line_gain), SOC_SINGLE_TLV("HPHR Volume", WCD937X_HPH_R_EN, 0, 20, 1, line_gain), - SOC_SINGLE_TLV("ADC1 Volume", WCD937X_ANA_TX_CH1, 0, 20, 0, analog_gain), - SOC_SINGLE_TLV("ADC2 Volume", WCD937X_ANA_TX_CH2, 0, 20, 0, analog_gain), - SOC_SINGLE_TLV("ADC3 Volume", WCD937X_ANA_TX_CH3, 0, 20, 0, analog_gain), + SOC_SINGLE_TLV("ADC1 Volume", WCD937X_ANA_TX_CH1, 0, 20, 0, + analog_gain), + SOC_SINGLE_TLV("ADC2 Volume", WCD937X_ANA_TX_CH2, 0, 20, 0, + analog_gain), + SOC_SINGLE_TLV("ADC3 Volume", WCD937X_ANA_TX_CH3, 0, 20, 0, + analog_gain), }; static const struct snd_kcontrol_new adc1_switch[] = { @@ -1937,7 +2027,7 @@ static struct snd_info_entry_ops wcd937x_info_ops = { /* * wcd937x_info_create_codec_entry - creates wcd937x module * @codec_root: The parent directory - * @codec: Codec instance + * @component: component instance * * Creates wcd937x module and version entry under the given * parent directory. @@ -1945,26 +2035,26 @@ static struct snd_info_entry_ops wcd937x_info_ops = { * Return: 0 on success or negative error code on failure. */ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct wcd937x_priv *priv; struct snd_soc_card *card; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - priv = snd_soc_codec_get_drvdata(codec); + priv = snd_soc_component_get_drvdata(component); if (priv->entry) { dev_dbg(priv->dev, "%s:wcd937x module already created\n", __func__); return 0; } - card = codec->component.card; + card = component->card; priv->entry = snd_info_create_subdir(codec_root->module, "wcd937x", codec_root); if (!priv->entry) { - dev_dbg(codec->dev, "%s: failed to create wcd937x entry\n", + dev_dbg(component->dev, "%s: failed to create wcd937x entry\n", __func__); return -ENOMEM; } @@ -1972,7 +2062,7 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root, "version", priv->entry); if (!version_entry) { - dev_dbg(codec->dev, "%s: failed to create wcd937x version entry\n", + dev_dbg(component->dev, "%s: failed to create wcd937x version entry\n", __func__); return -ENOMEM; } @@ -1992,42 +2082,44 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root, } EXPORT_SYMBOL(wcd937x_info_create_codec_entry); -static int wcd937x_soc_codec_probe(struct snd_soc_codec *codec) +static int wcd937x_soc_codec_probe(struct snd_soc_component *component) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); int variant; int ret = -EINVAL; - dev_info(codec->dev, "%s()\n", __func__); - wcd937x = snd_soc_codec_get_drvdata(codec); + dev_info(component->dev, "%s()\n", __func__); + wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) return -EINVAL; - wcd937x->codec = codec; - variant = (snd_soc_read(codec, WCD937X_DIGITAL_EFUSE_REG_0) & 0x0E) >> 1; + wcd937x->component = component; + variant = (snd_soc_component_read32( + component, WCD937X_DIGITAL_EFUSE_REG_0) & 0x0E) >> 1; wcd937x->variant = variant; - wcd937x->fw_data = devm_kzalloc(codec->dev, + wcd937x->fw_data = devm_kzalloc(component->dev, sizeof(*(wcd937x->fw_data)), GFP_KERNEL); if (!wcd937x->fw_data) { - dev_err(codec->dev, "Failed to allocate fw_data\n"); + dev_err(component->dev, "Failed to allocate fw_data\n"); ret = -ENOMEM; goto err; } set_bit(WCD9XXX_MBHC_CAL, wcd937x->fw_data->cal_bit); ret = wcd_cal_create_hwdep(wcd937x->fw_data, - WCD9XXX_CODEC_HWDEP_NODE, codec); + WCD9XXX_CODEC_HWDEP_NODE, component); if (ret < 0) { - dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret); + dev_err(component->dev, "%s hwdep failed %d\n", __func__, ret); goto err_hwdep; } - ret = wcd937x_mbhc_init(&wcd937x->mbhc, codec, wcd937x->fw_data); + ret = wcd937x_mbhc_init(&wcd937x->mbhc, component, wcd937x->fw_data); if (ret) { pr_err("%s: mbhc initialization failed\n", __func__); goto err_hwdep; @@ -2047,20 +2139,20 @@ static int wcd937x_soc_codec_probe(struct snd_soc_codec *codec) snd_soc_dapm_sync(dapm); wcd_cls_h_init(&wcd937x->clsh_info); - wcd937x_init_reg(codec); + wcd937x_init_reg(component); if (wcd937x->variant == WCD9375_VARIANT) { ret = snd_soc_dapm_new_controls(dapm, wcd9375_dapm_widgets, ARRAY_SIZE(wcd9375_dapm_widgets)); if (ret < 0) { - dev_err(codec->dev, "%s: Failed to add snd_ctls\n", + dev_err(component->dev, "%s: Failed to add snd_ctls\n", __func__); goto err_hwdep; } ret = snd_soc_dapm_add_routes(dapm, wcd9375_audio_map, ARRAY_SIZE(wcd9375_audio_map)); if (ret < 0) { - dev_err(codec->dev, "%s: Failed to add routes\n", + dev_err(component->dev, "%s: Failed to add routes\n", __func__); goto err_hwdep; } @@ -2082,7 +2174,7 @@ static int wcd937x_soc_codec_probe(struct snd_soc_codec *codec) &wcd937x->nblock, true); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to register notifier %d\n", __func__, ret); return ret; @@ -2097,39 +2189,30 @@ err: return ret; } -static int wcd937x_soc_codec_remove(struct snd_soc_codec *codec) +static void wcd937x_soc_codec_remove(struct snd_soc_component *component) { - struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec); + struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component); if (!wcd937x) - return -EINVAL; + return; if (wcd937x->register_notifier) - return wcd937x->register_notifier(wcd937x->handle, + wcd937x->register_notifier(wcd937x->handle, &wcd937x->nblock, false); - return 0; + return; } -static struct regmap *wcd937x_get_regmap(struct device *dev) -{ - struct wcd937x_priv *wcd937x = dev_get_drvdata(dev); - - return wcd937x->regmap; -} - -static struct snd_soc_codec_driver soc_codec_dev_wcd937x = { +static const struct snd_soc_component_driver soc_codec_dev_wcd937x = { + .name = DRV_NAME, .probe = wcd937x_soc_codec_probe, .remove = wcd937x_soc_codec_remove, - .get_regmap = wcd937x_get_regmap, - .component_driver = { - .controls = wcd937x_snd_controls, - .num_controls = ARRAY_SIZE(wcd937x_snd_controls), - .dapm_widgets = wcd937x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wcd937x_dapm_widgets), - .dapm_routes = wcd937x_audio_map, - .num_dapm_routes = ARRAY_SIZE(wcd937x_audio_map), - }, + .controls = wcd937x_snd_controls, + .num_controls = ARRAY_SIZE(wcd937x_snd_controls), + .dapm_widgets = wcd937x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wcd937x_dapm_widgets), + .dapm_routes = wcd937x_audio_map, + .num_dapm_routes = ARRAY_SIZE(wcd937x_audio_map), }; #ifdef CONFIG_PM_SLEEP @@ -2472,7 +2555,7 @@ static int wcd937x_bind(struct device *dev) wcd937x->tx_swr_dev->slave_irq = wcd937x->virq; mutex_init(&wcd937x->micb_lock); - ret = snd_soc_register_codec(dev, &soc_codec_dev_wcd937x, + ret = snd_soc_register_component(dev, &soc_codec_dev_wcd937x, NULL, 0); if (ret) { dev_err(dev, "%s: Codec registration failed\n", @@ -2493,7 +2576,7 @@ static void wcd937x_unbind(struct device *dev) struct wcd937x_priv *wcd937x = dev_get_drvdata(dev); wcd_irq_exit(&wcd937x->irq_info, wcd937x->virq); - snd_soc_unregister_codec(dev); + snd_soc_unregister_component(dev); component_unbind_all(dev, wcd937x); mutex_destroy(&wcd937x->micb_lock); } diff --git a/asoc/codecs/wcd937x/wcd937x.h b/asoc/codecs/wcd937x/wcd937x.h index 1450460941..a40554e196 100644 --- a/asoc/codecs/wcd937x/wcd937x.h +++ b/asoc/codecs/wcd937x/wcd937x.h @@ -7,10 +7,10 @@ #ifdef CONFIG_SND_SOC_WCD937X extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec); + struct snd_soc_component *component); #else extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } diff --git a/asoc/codecs/wcd9xxx-common-v2.c b/asoc/codecs/wcd9xxx-common-v2.c index 78cfc15a59..d45a071b1d 100644 --- a/asoc/codecs/wcd9xxx-common-v2.c +++ b/asoc/codecs/wcd9xxx-common-v2.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ #include @@ -210,7 +210,7 @@ static const struct wcd_imped_val imped_index[] = { {13, 9}, }; -static void (*clsh_state_fp[NUM_CLSH_STATES_V2])(struct snd_soc_codec *, +static void (*clsh_state_fp[NUM_CLSH_STATES_V2])(struct snd_soc_component *, struct wcd_clsh_cdc_data *, u8 req_state, bool en, int mode); @@ -243,12 +243,13 @@ ret: /* * Function: wcd_clsh_imped_config - * Params: codec, imped, reset + * Params: component, imped, reset * Description: * This function updates HPHL and HPHR gain settings * according to the impedance value. */ -void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) +void wcd_clsh_imped_config(struct snd_soc_component *component, int imped, + bool reset) { int i; int index = 0; @@ -256,7 +257,7 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) static const struct wcd_reg_mask_val (*imped_table_ptr)[MAX_IMPED_PARAMS]; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (IS_CODEC_TYPE(wcd9xxx, WCD934X)) { table_size = ARRAY_SIZE(imped_table_tavil); @@ -269,7 +270,7 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) /* reset = 1, which means request is to reset the register values */ if (reset) { for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, 0); return; @@ -285,24 +286,25 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset) return; } for (i = 0; i < MAX_IMPED_PARAMS; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, imped_table_ptr[index][i].reg, imped_table_ptr[index][i].mask, imped_table_ptr[index][i].val); } EXPORT_SYMBOL(wcd_clsh_imped_config); -static bool is_native_44_1_active(struct snd_soc_codec *codec) +static bool is_native_44_1_active(struct snd_soc_component *component) { bool native_active = false; u8 native_clk, rx1_rate, rx2_rate; - native_clk = snd_soc_read(codec, + native_clk = snd_soc_component_read32(component, WCD9XXX_CDC_CLK_RST_CTRL_MCLK_CONTROL); - rx1_rate = snd_soc_read(codec, WCD9XXX_CDC_RX1_RX_PATH_CTL); - rx2_rate = snd_soc_read(codec, WCD9XXX_CDC_RX2_RX_PATH_CTL); - - dev_dbg(codec->dev, "%s: native_clk %x rx1_rate= %x rx2_rate= %x", + rx1_rate = snd_soc_component_read32(component, + WCD9XXX_CDC_RX1_RX_PATH_CTL); + rx2_rate = snd_soc_component_read32(component, + WCD9XXX_CDC_RX2_RX_PATH_CTL); + dev_dbg(component->dev, "%s: native_clk %x rx1_rate= %x rx2_rate= %x", __func__, native_clk, rx1_rate, rx2_rate); if ((native_clk & 0x2) && @@ -371,22 +373,23 @@ done: } static inline void -wcd_enable_clsh_block(struct snd_soc_codec *codec, +wcd_enable_clsh_block(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, bool enable) { if ((enable && ++clsh_d->clsh_users == 1) || (!enable && --clsh_d->clsh_users == 0)) - snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_CRC, 0x01, - (u8) enable); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_CLSH_CRC, + 0x01, (u8) enable); if (clsh_d->clsh_users < 0) clsh_d->clsh_users = 0; - dev_dbg(codec->dev, "%s: clsh_users %d, enable %d", __func__, + dev_dbg(component->dev, "%s: clsh_users %d, enable %d", __func__, clsh_d->clsh_users, enable); } -static inline bool wcd_clsh_enable_status(struct snd_soc_codec *codec) +static inline bool wcd_clsh_enable_status(struct snd_soc_component *component) { - return snd_soc_read(codec, WCD9XXX_A_CDC_CLSH_CRC) & 0x01; + return snd_soc_component_read32(component, WCD9XXX_A_CDC_CLSH_CRC) & + 0x01; } static inline int wcd_clsh_get_int_mode(struct wcd_clsh_cdc_data *clsh_d, @@ -417,34 +420,40 @@ static inline void wcd_clsh_set_int_mode(struct wcd_clsh_cdc_data *clsh_d, clsh_d->interpolator_modes[ffs(clsh_state)] = mode; } -static inline void wcd_clsh_set_buck_mode(struct snd_soc_codec *codec, +static inline void wcd_clsh_set_buck_mode(struct snd_soc_component *component, int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - 0x08, 0x08); /* set to HIFI */ + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + 0x08, 0x08); /* set to HIFI */ else - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - 0x08, 0x00); /* set to default */ + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + 0x08, 0x00); /* set to default */ } -static inline void wcd_clsh_set_flyback_mode(struct snd_soc_codec *codec, - int mode) +static inline void wcd_clsh_set_flyback_mode( + struct snd_soc_component *component, + int mode) { if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - 0x04, 0x04); /* set to HIFI */ + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + 0x04, 0x04); /* set to HIFI */ else - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - 0x04, 0x00); /* set to Default */ + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + 0x04, 0x00); /* set to Default */ } -static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec, - int mode) +static inline void wcd_clsh_gm3_boost_disable( + struct snd_soc_component *component, + int mode) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!IS_CODEC_TYPE(wcd9xxx, WCD934X)) return; @@ -452,46 +461,56 @@ static inline void wcd_clsh_gm3_boost_disable(struct snd_soc_codec *codec, if (mode == CLS_H_HIFI || mode == CLS_H_LOHIFI || mode == CLS_AB_HIFI || mode == CLS_AB) { if (TAVIL_IS_1_0(wcd9xxx)) - snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL, - 0x80, 0x0); /* disable GM3 Boost */ - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x80); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_CNP_WG_CTL, + 0x80, 0x0); /* disable GM3 Boost */ + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x80); } else { - snd_soc_update_bits(codec, WCD9XXX_HPH_CNP_WG_CTL, - 0x80, 0x80); /* set to Default */ - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_4, - 0xF0, 0x70); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_CNP_WG_CTL, + 0x80, 0x80); /* set to Default */ + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_4, + 0xF0, 0x70); } } -static inline void wcd_clsh_force_iq_ctl(struct snd_soc_codec *codec, +static inline void wcd_clsh_force_iq_ctl(struct snd_soc_component *component, int mode) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!IS_CODEC_TYPE(wcd9xxx, WCD934X)) return; if (mode == CLS_H_LOHIFI || mode == CLS_AB) { - snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2, - 0x20, 0x20); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0xC0); - snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1, - 0x0E, 0x02); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_NEW_INT_PA_MISC2, + 0x20, 0x20); + snd_soc_component_update_bits(component, + WCD9XXX_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0xC0); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_PA_CTL1, + 0x0E, 0x02); } else { - snd_soc_update_bits(codec, WCD9XXX_HPH_NEW_INT_PA_MISC2, - 0x20, 0x0); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_HPH_LOWPOWER, - 0xF0, 0x80); - snd_soc_update_bits(codec, WCD9XXX_HPH_PA_CTL1, - 0x0E, 0x06); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_NEW_INT_PA_MISC2, + 0x20, 0x0); + snd_soc_component_update_bits(component, + WCD9XXX_RX_BIAS_HPH_LOWPOWER, + 0xF0, 0x80); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_PA_CTL1, + 0x0E, 0x06); } } -static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, +static void wcd_clsh_buck_ctrl(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, int mode, bool enable) @@ -499,9 +518,10 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, /* enable/disable buck */ if ((enable && (++clsh_d->buck_users == 1)) || (!enable && (--clsh_d->buck_users == 0))) - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - (1 << 7), (enable << 7)); - dev_dbg(codec->dev, "%s: buck_users %d, enable %d, mode: %s", + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + (1 << 7), (enable << 7)); + dev_dbg(component->dev, "%s: buck_users %d, enable %d, mode: %s", __func__, clsh_d->buck_users, enable, mode_to_str(mode)); /* * 500us sleep is required after buck enable/disable @@ -510,29 +530,32 @@ static void wcd_clsh_buck_ctrl(struct snd_soc_codec *codec, usleep_range(500, 500 + WCD_USLEEP_RANGE); } -static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec, +static void wcd_clsh_flyback_ctrl(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, int mode, bool enable) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_reg_val bulk_reg[2]; u8 vneg[] = {0x00, 0x40}; /* enable/disable flyback */ if ((enable && (++clsh_d->flyback_users == 1)) || (!enable && (--clsh_d->flyback_users == 0))) { - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, - (1 << 6), (enable << 6)); + snd_soc_component_update_bits(component, + WCD9XXX_A_ANA_RX_SUPPLIES, + (1 << 6), (enable << 6)); /* 100usec delay is needed as per HW requirement */ usleep_range(100, 110); if (enable && (TASHA_IS_1_1(wcd9xxx))) { - wcd_clsh_set_flyback_mode(codec, CLS_H_HIFI); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN, - 0x60, 0x40); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN, - 0x10, 0x10); - vneg[0] = snd_soc_read(codec, + wcd_clsh_set_flyback_mode(component, CLS_H_HIFI); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_EN, + 0x60, 0x40); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_EN, + 0x10, 0x10); + vneg[0] = snd_soc_component_read32(component, WCD9XXX_A_ANA_RX_SUPPLIES); vneg[0] &= ~(0x40); vneg[1] = vneg[0] | 0x40; @@ -546,13 +569,14 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec, usleep_range(500, 510); wcd9xxx_slim_bulk_write(wcd9xxx, bulk_reg, 2, false); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_EN, - 0x10, 0x00); - wcd_clsh_set_flyback_mode(codec, mode); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_EN, + 0x10, 0x00); + wcd_clsh_set_flyback_mode(component, mode); } } - dev_dbg(codec->dev, "%s: flyback_users %d, enable %d, mode: %s", + dev_dbg(component->dev, "%s: flyback_users %d, enable %d, mode: %s", __func__, clsh_d->flyback_users, enable, mode_to_str(mode)); /* * 500us sleep is required after flyback enable/disable @@ -561,11 +585,11 @@ static void wcd_clsh_flyback_ctrl(struct snd_soc_codec *codec, usleep_range(500, 500 + WCD_USLEEP_RANGE); } -static void wcd_clsh_set_gain_path(struct snd_soc_codec *codec, +static void wcd_clsh_set_gain_path(struct snd_soc_component *component, int mode) { u8 val = 0; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!TASHA_IS_2_0(wcd9xxx)) return; @@ -584,11 +608,13 @@ static void wcd_clsh_set_gain_path(struct snd_soc_codec *codec, default: return; }; - snd_soc_update_bits(codec, WCD9XXX_HPH_L_EN, 0xC0, (val << 6)); - snd_soc_update_bits(codec, WCD9XXX_HPH_R_EN, 0xC0, (val << 6)); + snd_soc_component_update_bits(component, WCD9XXX_HPH_L_EN, + 0xC0, (val << 6)); + snd_soc_component_update_bits(component, WCD9XXX_HPH_R_EN, + 0xC0, (val << 6)); } -static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec, +static void wcd_clsh_set_hph_mode(struct snd_soc_component *component, int mode) { u8 val = 0; @@ -596,7 +622,7 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec, u8 res_val = VREF_FILT_R_0OHM; u8 ipeak = DELTA_I_50MA; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); switch (mode) { case CLS_H_NORMAL: @@ -646,97 +672,109 @@ static void wcd_clsh_set_hph_mode(struct snd_soc_codec *codec, (mode == CLS_H_LOHIFI || mode == CLS_AB)) val = 0x04; - snd_soc_update_bits(codec, WCD9XXX_A_ANA_HPH, 0x0C, val); + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_HPH, 0x0C, val); if (TASHA_IS_2_0(wcd9xxx)) { - snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_VCL_2, - 0x30, (res_val << 4)); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_CTRL_VCL_2, + 0x30, (res_val << 4)); if (mode != CLS_H_LP) - snd_soc_update_bits(codec, WCD9XXX_HPH_REFBUFF_UHQA_CTL, - 0x07, gain); - snd_soc_update_bits(codec, WCD9XXX_CLASSH_CTRL_CCL_1, - 0xF0, (ipeak << 4)); + snd_soc_component_update_bits(component, + WCD9XXX_HPH_REFBUFF_UHQA_CTL, + 0x07, gain); + snd_soc_component_update_bits(component, + WCD9XXX_CLASSH_CTRL_CCL_1, + 0xF0, (ipeak << 4)); } } -static void wcd_clsh_set_flyback_vneg_ctl(struct snd_soc_codec *codec, +static void wcd_clsh_set_flyback_vneg_ctl(struct snd_soc_component *component, bool enable) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!TASHA_IS_2_0(wcd9xxx)) return; if (enable) { - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0, - 0x00); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, - 0xE0, (0x07 << 5)); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0, 0x00); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, + 0xE0, (0x07 << 5)); } else { - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEG_CTRL_1, 0xE0, - (0x07 << 5)); - snd_soc_update_bits(codec, WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, - 0xE0, (0x02 << 5)); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEG_CTRL_1, + 0xE0, (0x07 << 5)); + snd_soc_component_update_bits(component, + WCD9XXX_FLYBACK_VNEGDAC_CTRL_2, + 0xE0, (0x02 << 5)); } } -static void wcd_clsh_set_flyback_current(struct snd_soc_codec *codec, int mode) +static void wcd_clsh_set_flyback_current(struct snd_soc_component *component, + int mode) { - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); if (!TASHA_IS_2_0(wcd9xxx)) return; - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0x0F, 0x0A); - snd_soc_update_bits(codec, WCD9XXX_RX_BIAS_FLYB_BUFF, 0xF0, 0xA0); + snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF, + 0x0F, 0x0A); + snd_soc_component_update_bits(component, WCD9XXX_RX_BIAS_FLYB_BUFF, + 0xF0, 0xA0); /* Sleep needed to avoid click and pop as per HW requirement */ usleep_range(100, 110); } -static void wcd_clsh_set_buck_regulator_mode(struct snd_soc_codec *codec, - int mode) +static void wcd_clsh_set_buck_regulator_mode( + struct snd_soc_component *component, + int mode) { - snd_soc_update_bits(codec, WCD9XXX_A_ANA_RX_SUPPLIES, + snd_soc_component_update_bits(component, WCD9XXX_A_ANA_RX_SUPPLIES, 0x02, 0x00); } -static void wcd_clsh_state_lo(struct snd_soc_codec *codec, +static void wcd_clsh_state_lo(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode != CLS_AB && mode != CLS_AB_HIFI) { - dev_err(codec->dev, "%s: LO cannot be in this mode: %d\n", + dev_err(component->dev, "%s: LO cannot be in this mode: %d\n", __func__, mode); return; } if (is_enable) { - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_vneg_ctl(codec, true); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_vneg_ctl(component, true); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); } else { - wcd_clsh_buck_ctrl(codec, clsh_d, mode, false); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_flyback_vneg_ctl(codec, false); - wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL); + wcd_clsh_buck_ctrl(component, clsh_d, mode, false); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); + wcd_clsh_set_flyback_vneg_ctl(component, false); + wcd_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_ear(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { int hph_mode = 0; - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (is_enable) { @@ -755,37 +793,38 @@ static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec, else return; if (hph_mode != CLS_AB && hph_mode != CLS_AB_HIFI - && !is_native_44_1_active(codec)) - snd_soc_update_bits(codec, + && !is_native_44_1_active(component)) + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x40); } - if (is_native_44_1_active(codec)) { - snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x39); - snd_soc_update_bits(codec, + if (is_native_44_1_active(component)) { + snd_soc_component_write(component, + WCD9XXX_CDC_CLSH_HPH_V_PA, 0x39); + snd_soc_component_update_bits(component, WCD9XXX_CDC_RX0_RX_PATH_SEC0, 0x03, 0x00); if ((req_state == WCD_CLSH_STATE_HPHL) || (req_state == WCD_CLSH_STATE_HPHR)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x00); } if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x40); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); if ((req_state == WCD_CLSH_STATE_HPHL) || (req_state == WCD_CLSH_STATE_HPHR)) { - wcd_clsh_set_gain_path(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); + wcd_clsh_set_gain_path(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_set_buck_mode(component, mode); } } else { if (req_state == WCD_CLSH_STATE_EAR) { @@ -795,54 +834,56 @@ static void wcd_clsh_state_hph_ear(struct snd_soc_codec *codec, * and if HPH requested mode is CLS_AB then * no need to disable EAR channel enable bit. */ - if (wcd_clsh_enable_status(codec)) - snd_soc_update_bits(codec, + if (wcd_clsh_enable_status(component)) + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x00); } - if (is_native_44_1_active(codec)) { - snd_soc_write(codec, WCD9XXX_CDC_CLSH_HPH_V_PA, 0x1C); - snd_soc_update_bits(codec, + if (is_native_44_1_active(component)) { + snd_soc_component_write(component, + WCD9XXX_CDC_CLSH_HPH_V_PA, 0x1C); + snd_soc_component_update_bits(component, WCD9XXX_CDC_RX0_RX_PATH_SEC0, 0x03, 0x01); if (((clsh_d->state & WCD_CLSH_STATE_HPH_ST) != WCD_CLSH_STATE_HPH_ST) && ((req_state == WCD_CLSH_STATE_HPHL) || (req_state == WCD_CLSH_STATE_HPHR))) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x40); } if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); if ((req_state & WCD_CLSH_STATE_HPH_ST) && - !wcd_clsh_enable_status(codec)) { + !wcd_clsh_enable_status(component)) { /* If Class-H is not enabled when HPH is turned * off, enable it as EAR is in progress */ - wcd_enable_clsh_block(codec, clsh_d, true); - snd_soc_update_bits(codec, + wcd_enable_clsh_block(component, clsh_d, true); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x40); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } } -static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec, +static void wcd_clsh_state_ear_lo(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (is_enable) { @@ -851,22 +892,22 @@ static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec, */ if (req_state == WCD_CLSH_STATE_EAR) { /* EAR powerup.*/ - if (!wcd_clsh_enable_status(codec)) { - wcd_enable_clsh_block(codec, clsh_d, true); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); + if (!wcd_clsh_enable_status(component)) { + wcd_enable_clsh_block(component, clsh_d, true); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x40); } } else { if (req_state == WCD_CLSH_STATE_EAR) { /* EAR powerdown.*/ - wcd_enable_clsh_block(codec, clsh_d, false); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - snd_soc_update_bits(codec, + wcd_enable_clsh_block(component, clsh_d, false); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x00); } @@ -876,13 +917,14 @@ static void wcd_clsh_state_ear_lo(struct snd_soc_codec *codec, } } -static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_lo(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { int hph_mode = 0; - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (is_enable) { @@ -895,31 +937,31 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, * and buck. */ if (req_state == WCD_CLSH_STATE_LO) - wcd_clsh_set_buck_regulator_mode(codec, CLS_AB); + wcd_clsh_set_buck_regulator_mode(component, CLS_AB); else { - if (!wcd_clsh_enable_status(codec)) { - wcd_enable_clsh_block(codec, clsh_d, true); - snd_soc_update_bits(codec, + if (!wcd_clsh_enable_status(component)) { + wcd_enable_clsh_block(component, clsh_d, true); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_CLSH_K1_MSB, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_CLSH_K1_LSB, 0xFF, 0xC0); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_set_flyback_vneg_ctl(codec, false); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_set_hph_mode(codec, mode); - wcd_clsh_set_gain_path(codec, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_set_flyback_vneg_ctl(component, false); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_set_hph_mode(component, mode); + wcd_clsh_set_gain_path(component, mode); } else { - dev_dbg(codec->dev, "%s:clsh is already enabled\n", + dev_dbg(component->dev, "%s:clsh is already enabled\n", __func__); } if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x40); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); } @@ -927,11 +969,11 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, if ((req_state == WCD_CLSH_STATE_HPHL) || (req_state == WCD_CLSH_STATE_HPHR)) { if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); /* @@ -941,10 +983,11 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, */ if ((clsh_d->state & WCD_CLSH_STATE_HPH_ST) != WCD_CLSH_STATE_HPH_ST) { - wcd_enable_clsh_block(codec, clsh_d, false); - wcd_clsh_set_flyback_vneg_ctl(codec, true); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_enable_clsh_block(component, clsh_d, false); + wcd_clsh_set_flyback_vneg_ctl(component, true); + wcd_clsh_set_flyback_mode( + component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } else { /* LO powerdown. @@ -960,7 +1003,7 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, WCD_CLSH_STATE_HPHR); else return; - dev_dbg(codec->dev, "%s: hph_mode = %d\n", __func__, + dev_dbg(component->dev, "%s: hph_mode = %d\n", __func__, hph_mode); if ((hph_mode == CLS_AB) || @@ -973,44 +1016,45 @@ static void wcd_clsh_state_hph_lo(struct snd_soc_codec *codec, * LO ON), no need to turn on again, just set the * regulator mode. */ - if (wcd_clsh_enable_status(codec)) { - wcd_clsh_set_buck_regulator_mode(codec, + if (wcd_clsh_enable_status(component)) { + wcd_clsh_set_buck_regulator_mode(component, hph_mode); goto end; } else { - dev_dbg(codec->dev, "%s: clsh is not enabled\n", + dev_dbg(component->dev, "%s: clsh is not enabled\n", __func__); } - wcd_enable_clsh_block(codec, clsh_d, true); - snd_soc_update_bits(codec, + wcd_enable_clsh_block(component, clsh_d, true); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_CLSH_K1_MSB, 0x0F, 0x00); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_CLSH_K1_LSB, 0xFF, 0xC0); - wcd_clsh_set_buck_regulator_mode(codec, + wcd_clsh_set_buck_regulator_mode(component, hph_mode); if (clsh_d->state & WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x40); if (clsh_d->state & WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); - wcd_clsh_set_hph_mode(codec, hph_mode); + wcd_clsh_set_hph_mode(component, hph_mode); } } end: return; } -static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_st(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_AB || mode == CLS_AB_HIFI) @@ -1018,183 +1062,190 @@ static void wcd_clsh_state_hph_st(struct snd_soc_codec *codec, if (is_enable) { if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x40); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x40); } else { if (req_state == WCD_CLSH_STATE_HPHL) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); if (req_state == WCD_CLSH_STATE_HPHR) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); } } -static void wcd_clsh_state_hph_r(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_r(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_err(codec->dev, "%s: Normal mode not applicable for hph_r\n", + dev_err(component->dev, "%s: Normal mode not applicable for hph_r\n", __func__); return; } if (is_enable) { if (mode != CLS_AB && mode != CLS_AB_HIFI) { - wcd_enable_clsh_block(codec, clsh_d, true); + wcd_enable_clsh_block(component, clsh_d, true); /* * These K1 values depend on the Headphone Impedance * For now it is assumed to be 16 ohm */ - snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_MSB, - 0x0F, 0x00); - snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB, - 0xFF, 0xC0); - snd_soc_update_bits(codec, - WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, - 0x40, 0x40); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_CLSH_K1_MSB, + 0x0F, 0x00); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_CLSH_K1_LSB, + 0xFF, 0xC0); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, + 0x40, 0x40); } - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_gm3_boost_disable(codec, mode); - wcd_clsh_force_iq_ctl(codec, mode); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_hph_mode(codec, mode); - wcd_clsh_set_gain_path(codec, mode); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_gm3_boost_disable(component, mode); + wcd_clsh_force_iq_ctl(component, mode); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_hph_mode(component, mode); + wcd_clsh_set_gain_path(component, mode); } else { - wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_hph_mode(component, CLS_H_NORMAL); if (mode != CLS_AB && mode != CLS_AB_HIFI) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX2_RX_PATH_CFG0, 0x40, 0x00); - wcd_enable_clsh_block(codec, clsh_d, false); + wcd_enable_clsh_block(component, clsh_d, false); } /* buck and flyback set to default mode and disable */ - wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL); - wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL); + wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL); + wcd_clsh_gm3_boost_disable(component, CLS_H_NORMAL); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_hph_l(struct snd_soc_codec *codec, +static void wcd_clsh_state_hph_l(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode == CLS_H_NORMAL) { - dev_err(codec->dev, "%s: Normal mode not applicable for hph_l\n", + dev_err(component->dev, "%s: Normal mode not applicable for hph_l\n", __func__); return; } if (is_enable) { if (mode != CLS_AB && mode != CLS_AB_HIFI) { - wcd_enable_clsh_block(codec, clsh_d, true); + wcd_enable_clsh_block(component, clsh_d, true); /* * These K1 values depend on the Headphone Impedance * For now it is assumed to be 16 ohm */ - snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_MSB, - 0x0F, 0x00); - snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_K1_LSB, - 0xFF, 0xC0); - snd_soc_update_bits(codec, - WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, - 0x40, 0x40); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_CLSH_K1_MSB, + 0x0F, 0x00); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_CLSH_K1_LSB, + 0xFF, 0xC0); + snd_soc_component_update_bits(component, + WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, + 0x40, 0x40); } - wcd_clsh_set_buck_regulator_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_gm3_boost_disable(codec, mode); - wcd_clsh_force_iq_ctl(codec, mode); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_hph_mode(codec, mode); - wcd_clsh_set_gain_path(codec, mode); + wcd_clsh_set_buck_regulator_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_gm3_boost_disable(component, mode); + wcd_clsh_force_iq_ctl(component, mode); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_hph_mode(component, mode); + wcd_clsh_set_gain_path(component, mode); } else { - wcd_clsh_set_hph_mode(codec, CLS_H_NORMAL); + wcd_clsh_set_hph_mode(component, CLS_H_NORMAL); if (mode != CLS_AB && mode != CLS_AB_HIFI) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX1_RX_PATH_CFG0, 0x40, 0x00); - wcd_enable_clsh_block(codec, clsh_d, false); + wcd_enable_clsh_block(component, clsh_d, false); } /* set buck and flyback to Default Mode */ - wcd_clsh_buck_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_flyback_ctrl(codec, clsh_d, CLS_H_NORMAL, false); - wcd_clsh_force_iq_ctl(codec, CLS_H_NORMAL); - wcd_clsh_gm3_boost_disable(codec, CLS_H_NORMAL); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_regulator_mode(codec, CLS_H_NORMAL); + wcd_clsh_buck_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_flyback_ctrl(component, clsh_d, CLS_H_NORMAL, false); + wcd_clsh_force_iq_ctl(component, CLS_H_NORMAL); + wcd_clsh_gm3_boost_disable(component, CLS_H_NORMAL); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_regulator_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_ear(struct snd_soc_codec *codec, +static void wcd_clsh_state_ear(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { - dev_dbg(codec->dev, "%s: mode: %s, %s\n", __func__, mode_to_str(mode), + dev_dbg(component->dev, "%s: mode: %s, %s\n", __func__, + mode_to_str(mode), is_enable ? "enable" : "disable"); if (mode != CLS_H_NORMAL) { - dev_err(codec->dev, "%s: mode: %s cannot be used for EAR\n", + dev_err(component->dev, "%s: mode: %s cannot be used for EAR\n", __func__, mode_to_str(mode)); return; } if (is_enable) { - wcd_enable_clsh_block(codec, clsh_d, true); - snd_soc_update_bits(codec, + wcd_enable_clsh_block(component, clsh_d, true); + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x40); - wcd_clsh_set_buck_mode(codec, mode); - wcd_clsh_set_flyback_mode(codec, mode); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, true); - wcd_clsh_set_flyback_current(codec, mode); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, true); + wcd_clsh_set_buck_mode(component, mode); + wcd_clsh_set_flyback_mode(component, mode); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, true); + wcd_clsh_set_flyback_current(component, mode); + wcd_clsh_buck_ctrl(component, clsh_d, mode, true); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WCD9XXX_A_CDC_RX0_RX_PATH_CFG0, 0x40, 0x00); - wcd_enable_clsh_block(codec, clsh_d, false); - wcd_clsh_buck_ctrl(codec, clsh_d, mode, false); - wcd_clsh_flyback_ctrl(codec, clsh_d, mode, false); - wcd_clsh_set_flyback_mode(codec, CLS_H_NORMAL); - wcd_clsh_set_buck_mode(codec, CLS_H_NORMAL); + wcd_enable_clsh_block(component, clsh_d, false); + wcd_clsh_buck_ctrl(component, clsh_d, mode, false); + wcd_clsh_flyback_ctrl(component, clsh_d, mode, false); + wcd_clsh_set_flyback_mode(component, CLS_H_NORMAL); + wcd_clsh_set_buck_mode(component, CLS_H_NORMAL); } } -static void wcd_clsh_state_err(struct snd_soc_codec *codec, +static void wcd_clsh_state_err(struct snd_soc_component *component, struct wcd_clsh_cdc_data *clsh_d, u8 req_state, bool is_enable, int mode) { char msg[128]; - dev_err(codec->dev, + dev_err(component->dev, "%s Wrong request for class H state machine requested to %s %s", __func__, is_enable ? "enable" : "disable", state_to_str(req_state, msg, sizeof(msg))); @@ -1231,14 +1282,14 @@ static bool wcd_clsh_is_state_valid(u8 state) /* * Function: wcd_clsh_fsm - * Params: codec, cdc_clsh_d, req_state, req_type, clsh_event + * Params: component, cdc_clsh_d, req_state, req_type, clsh_event * Description: * This function handles PRE DAC and POST DAC conditions of different devices * and updates class H configuration of different combination of devices * based on validity of their states. cdc_clsh_d will contain current * class h state information */ -void wcd_clsh_fsm(struct snd_soc_codec *codec, +void wcd_clsh_fsm(struct snd_soc_component *component, struct wcd_clsh_cdc_data *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode) @@ -1252,14 +1303,14 @@ void wcd_clsh_fsm(struct snd_soc_codec *codec, new_state = old_state | req_state; if (!wcd_clsh_is_state_valid(new_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H not a valid new state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); @@ -1267,9 +1318,9 @@ void wcd_clsh_fsm(struct snd_soc_codec *codec, } cdc_clsh_d->state = new_state; wcd_clsh_set_int_mode(cdc_clsh_d, req_state, int_mode); - (*clsh_state_fp[new_state]) (codec, cdc_clsh_d, req_state, + (*clsh_state_fp[new_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_ENABLE, int_mode); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str(old_state, msg0, sizeof(msg0)), state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1))); @@ -1279,7 +1330,7 @@ void wcd_clsh_fsm(struct snd_soc_codec *codec, new_state = old_state & (~req_state); if (new_state < NUM_CLSH_STATES_V2) { if (!wcd_clsh_is_state_valid(old_state)) { - dev_err(codec->dev, + dev_err(component->dev, "%s:Invalid old state:%s\n", __func__, state_to_str(old_state, msg0, @@ -1287,19 +1338,19 @@ void wcd_clsh_fsm(struct snd_soc_codec *codec, return; } if (new_state == old_state) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Class-H already in requested state: %s\n", __func__, state_to_str(new_state, msg0, sizeof(msg0))); return; } - (*clsh_state_fp[old_state]) (codec, cdc_clsh_d, + (*clsh_state_fp[old_state]) (component, cdc_clsh_d, req_state, CLSH_REQ_DISABLE, int_mode); cdc_clsh_d->state = new_state; wcd_clsh_set_int_mode(cdc_clsh_d, req_state, CLS_NONE); - dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n", + dev_dbg(component->dev, "%s: ClassH state transition from %s to %s\n", __func__, state_to_str(old_state, msg0, sizeof(msg0)), state_to_str(cdc_clsh_d->state, msg1, diff --git a/asoc/codecs/wcd9xxx-common-v2.h b/asoc/codecs/wcd9xxx-common-v2.h index 94679e88f5..21eadd7c6a 100644 --- a/asoc/codecs/wcd9xxx-common-v2.h +++ b/asoc/codecs/wcd9xxx-common-v2.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ #ifndef _WCD9XXX_COMMON_V2 @@ -141,15 +141,15 @@ struct wcd_reg_mask_val { u8 val; }; -extern void wcd_clsh_fsm(struct snd_soc_codec *codec, +extern void wcd_clsh_fsm(struct snd_soc_component *component, struct wcd_clsh_cdc_data *cdc_clsh_d, u8 clsh_event, u8 req_state, int int_mode); extern void wcd_clsh_init(struct wcd_clsh_cdc_data *clsh); extern int wcd_clsh_get_clsh_state(struct wcd_clsh_cdc_data *clsh); -extern void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, - bool reset); +extern void wcd_clsh_imped_config(struct snd_soc_component *component, + int imped, bool reset); enum { RESERVED = 0, diff --git a/asoc/codecs/wcd9xxx-regmap.h b/asoc/codecs/wcd9xxx-regmap.h index 8019fa12c0..2c7af0d047 100644 --- a/asoc/codecs/wcd9xxx-regmap.h +++ b/asoc/codecs/wcd9xxx-regmap.h @@ -9,7 +9,7 @@ #include #include "core.h" -typedef int (*regmap_patch_fptr)(struct regmap *, int); +typedef int (*regmap_patch_fptr)(struct regmap *regmap, int version); extern struct regmap_config wcd934x_regmap_config; extern int wcd934x_regmap_register_patch(struct regmap *regmap, diff --git a/asoc/codecs/wcd9xxx-resmgr-v2.c b/asoc/codecs/wcd9xxx-resmgr-v2.c index f14ba5e73c..4636f43b4b 100644 --- a/asoc/codecs/wcd9xxx-resmgr-v2.c +++ b/asoc/codecs/wcd9xxx-resmgr-v2.c @@ -49,8 +49,9 @@ static int wcd_resmgr_codec_reg_update_bits(struct wcd9xxx_resmgr_v2 *resmgr, if (reg == WCD93XX_CLK_SYS_MCLK_PRG) return 0; } - if (resmgr->codec) { - ret = snd_soc_update_bits(resmgr->codec, reg, mask, val); + if (resmgr->component) { + ret = snd_soc_component_update_bits(resmgr->component, reg, + mask, val); } else if (resmgr->core_res->wcd_core_regmap) { ret = regmap_update_bits_check( resmgr->core_res->wcd_core_regmap, @@ -77,8 +78,8 @@ static int wcd_resmgr_codec_reg_read(struct wcd9xxx_resmgr_v2 *resmgr, if (reg == WCD93XX_CLK_SYS_MCLK_PRG) return 0; } - if (resmgr->codec) { - val = snd_soc_read(resmgr->codec, reg); + if (resmgr->component) { + val = snd_soc_component_read32(resmgr->component, reg); } else if (resmgr->core_res->wcd_core_regmap) { ret = regmap_read(resmgr->core_res->wcd_core_regmap, reg, &val); @@ -114,8 +115,8 @@ static void wcd_resmgr_cdc_specific_get_clk(struct wcd9xxx_resmgr_v2 *resmgr, if (resmgr->resmgr_cb && resmgr->resmgr_cb->cdc_rco_ctrl) { while (clk_users--) - resmgr->resmgr_cb->cdc_rco_ctrl(resmgr->codec, - true); + resmgr->resmgr_cb->cdc_rco_ctrl( + resmgr->component, true); } } } @@ -608,11 +609,11 @@ EXPORT_SYMBOL(wcd_resmgr_disable_clk_block); * wcd_resmgr_init: initialize wcd resource manager * @core_res: handle to struct wcd9xxx_core_resource * - * Early init call without a handle to snd_soc_codec * + * Early init call without a handle to snd_soc_component * */ struct wcd9xxx_resmgr_v2 *wcd_resmgr_init( struct wcd9xxx_core_resource *core_res, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct wcd9xxx_resmgr_v2 *resmgr; struct wcd9xxx *wcd9xxx; @@ -634,7 +635,7 @@ struct wcd9xxx_resmgr_v2 *wcd_resmgr_init( resmgr->clk_mclk_users = 0; resmgr->clk_rco_users = 0; resmgr->master_bias_users = 0; - resmgr->codec = codec; + resmgr->component = component; resmgr->core_res = core_res; resmgr->sido_input_src = SIDO_SOURCE_INTERNAL; resmgr->codec_type = wcd9xxx->type; @@ -658,24 +659,24 @@ EXPORT_SYMBOL(wcd_resmgr_remove); * wcd_resmgr_post_init: post init call to assign codec handle * @resmgr: handle to struct wcd9xxx_resmgr_v2 created during early init * @resmgr_cb: codec callback function for resmgr - * @codec: handle to struct snd_soc_codec + * @component: handle to struct snd_soc_component */ int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr, const struct wcd_resmgr_cb *resmgr_cb, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { if (!resmgr) { pr_err("%s: resmgr not allocated\n", __func__); return -EINVAL; } - if (!codec) { + if (!component) { pr_err("%s: Codec memory is NULL, nothing to post init\n", __func__); return -EINVAL; } - resmgr->codec = codec; + resmgr->component = component; resmgr->resmgr_cb = resmgr_cb; return 0; diff --git a/asoc/codecs/wcd9xxx-resmgr-v2.h b/asoc/codecs/wcd9xxx-resmgr-v2.h index d1aeb04cec..8eceb8392d 100644 --- a/asoc/codecs/wcd9xxx-resmgr-v2.h +++ b/asoc/codecs/wcd9xxx-resmgr-v2.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD9XXX_COMMON_V2_H__ #define __WCD9XXX_COMMON_V2_H__ @@ -20,11 +20,11 @@ enum { }; struct wcd_resmgr_cb { - int (*cdc_rco_ctrl)(struct snd_soc_codec *, bool); + int (*cdc_rco_ctrl)(struct snd_soc_component *component, bool enable); }; struct wcd9xxx_resmgr_v2 { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wcd9xxx_core_resource *core_res; int master_bias_users; @@ -66,11 +66,11 @@ int wcd_resmgr_enable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr); int wcd_resmgr_disable_master_bias(struct wcd9xxx_resmgr_v2 *resmgr); struct wcd9xxx_resmgr_v2 *wcd_resmgr_init( struct wcd9xxx_core_resource *core_res, - struct snd_soc_codec *codec); + struct snd_soc_component *component); void wcd_resmgr_remove(struct wcd9xxx_resmgr_v2 *resmgr); int wcd_resmgr_post_init(struct wcd9xxx_resmgr_v2 *resmgr, const struct wcd_resmgr_cb *resmgr_cb, - struct snd_soc_codec *codec); + struct snd_soc_component *component); int wcd_resmgr_enable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr, enum wcd_clock_type type); int wcd_resmgr_disable_clk_block(struct wcd9xxx_resmgr_v2 *resmgr, diff --git a/asoc/codecs/wcd9xxx-utils.h b/asoc/codecs/wcd9xxx-utils.h index 048c61c232..17bb9fd175 100644 --- a/asoc/codecs/wcd9xxx-utils.h +++ b/asoc/codecs/wcd9xxx-utils.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD9XXX_UTILS_H__ @@ -20,10 +20,10 @@ int wcd9xxx_reset(struct device *dev); int wcd9xxx_reset_low(struct device *dev); int wcd9xxx_get_codec_info(struct device *dev); -typedef int (*codec_bringup_fn)(struct wcd9xxx *); -typedef int (*codec_bringdown_fn)(struct wcd9xxx *); -typedef int (*codec_type_fn)(struct wcd9xxx *, - struct wcd9xxx_codec_type *); +typedef int (*codec_bringup_fn)(struct wcd9xxx *dev); +typedef int (*codec_bringdown_fn)(struct wcd9xxx *dev); +typedef int (*codec_type_fn)(struct wcd9xxx *dev, + struct wcd9xxx_codec_type *wcd_type); codec_bringdown_fn wcd9xxx_bringdown_fn(int type); codec_bringup_fn wcd9xxx_bringup_fn(int type); diff --git a/asoc/codecs/wcd_cpe_core.c b/asoc/codecs/wcd_cpe_core.c index 1fa6eae598..00a384369c 100644 --- a/asoc/codecs/wcd_cpe_core.c +++ b/asoc/codecs/wcd_cpe_core.c @@ -92,7 +92,7 @@ struct cpe_lsm_ids { static struct wcd_cpe_core *core_d; static struct cpe_lsm_session *lsm_sessions[WCD_CPE_LSM_MAX_SESSIONS + 1]; -struct wcd_cpe_core * (*wcd_get_cpe_core)(struct snd_soc_codec *); +struct wcd_cpe_core * (*wcd_get_cpe_core)(struct snd_soc_component *component); static struct wcd_cmi_afe_port_data afe_ports[WCD_CPE_AFE_MAX_PORTS + 1]; static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param); static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core); @@ -370,7 +370,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable) return -EINVAL; } - ret = core->cpe_cdc_cb->cdc_clk_en(core->codec, enable); + ret = core->cpe_cdc_cb->cdc_clk_en(core->component, enable); if (ret) { dev_err(core->dev, "%s: Failed to enable RCO\n", __func__); @@ -385,7 +385,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable) * and be disabled at the last time. */ if (core->cpe_clk_ref == 0) { - ret = core->cpe_cdc_cb->cpe_clk_en(core->codec, enable); + ret = core->cpe_cdc_cb->cpe_clk_en(core->component, enable); if (ret) { dev_err(core->dev, "%s: cpe_clk_en() failed, err = %d\n", @@ -402,7 +402,7 @@ static int wcd_cpe_enable_cpe_clks(struct wcd_cpe_core *core, bool enable) cpe_clk_fail: /* Release the codec clk if CPE clk enable failed */ if (enable) { - ret1 = core->cpe_cdc_cb->cdc_clk_en(core->codec, !enable); + ret1 = core->cpe_cdc_cb->cdc_clk_en(core->component, !enable); if (ret1) dev_err(core->dev, "%s: Fail to release codec clk, err = %d\n", @@ -434,7 +434,7 @@ static int wcd_cpe_bus_vote_max_bw(struct wcd_cpe_core *core, if (core->cpe_cdc_cb->bus_vote_bw) { dev_dbg(core->dev, "%s: %s cdc bus max bandwidth\n", __func__, vote ? "Vote" : "Unvote"); - core->cpe_cdc_cb->bus_vote_bw(core->codec, vote); + core->cpe_cdc_cb->bus_vote_bw(core->component, vote); } return 0; @@ -454,7 +454,7 @@ static int wcd_cpe_load_fw(struct wcd_cpe_core *core, { int ret, phdr_idx; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; struct wcd9xxx *wcd9xxx = NULL; const struct elf32_hdr *ehdr; const struct elf32_phdr *phdr; @@ -469,8 +469,8 @@ static int wcd_cpe_load_fw(struct wcd_cpe_core *core, core); return -EINVAL; } - codec = core->codec; - wcd9xxx = dev_get_drvdata(codec->dev->parent); + component = core->component; + wcd9xxx = dev_get_drvdata(component->dev->parent); snprintf(mdt_name, sizeof(mdt_name), "%s.mdt", core->fname); ret = request_firmware(&fw, mdt_name, core->dev); if (ret < 0) { @@ -617,32 +617,32 @@ static void wcd_cpe_load_fw_image(struct work_struct *work) /* * wcd_cpe_get_core_handle: get the handle to wcd_cpe_core - * @codec: codec from which this handle is to be obtained + * @component: codec from which this handle is to be obtained * Codec driver should provide a callback function to obtain * handle to wcd_cpe_core during initialization of wcd_cpe_core */ void *wcd_cpe_get_core_handle( - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct wcd_cpe_core *core = NULL; - if (!codec) { + if (!component) { pr_err("%s: Invalid codec handle\n", __func__); goto done; } if (!wcd_get_cpe_core) { - dev_err(codec->dev, + dev_err(component->dev, "%s: codec callback not available\n", __func__); goto done; } - core = wcd_get_cpe_core(codec); + core = wcd_get_cpe_core(component); if (!core) - dev_err(codec->dev, + dev_err(component->dev, "%s: handle to core not available\n", __func__); done: @@ -1018,7 +1018,7 @@ static void wcd_cpe_ssr_work(struct work_struct *work) if (core->ssr_type == WCD_CPE_SSR_EVENT) { if (CPE_ERR_IRQ_CB(core)) core->cpe_cdc_cb->cpe_err_irq_control( - core->codec, + core->component, CPE_ERR_IRQ_STATUS, &status); if (status & core->irq_info.cpe_fatal_irqs) @@ -1080,7 +1080,7 @@ static void wcd_cpe_ssr_work(struct work_struct *work) * error interrupts are cleared */ if (CPE_ERR_IRQ_CB(core)) - core->cpe_cdc_cb->cpe_err_irq_control(core->codec, + core->cpe_cdc_cb->cpe_err_irq_control(core->component, CPE_ERR_IRQ_CLEAR, NULL); err_ret: @@ -1178,7 +1178,7 @@ static irqreturn_t svass_exception_irq(int irq, void *data) return IRQ_HANDLED; } - core->cpe_cdc_cb->cpe_err_irq_control(core->codec, + core->cpe_cdc_cb->cpe_err_irq_control(core->component, CPE_ERR_IRQ_STATUS, &status); while (status != 0) { @@ -1198,18 +1198,18 @@ static irqreturn_t svass_exception_irq(int irq, void *data) * Mask the interrupt that was raised to * avoid spurious interrupts */ - core->cpe_cdc_cb->cpe_err_irq_control(core->codec, + core->cpe_cdc_cb->cpe_err_irq_control(core->component, CPE_ERR_IRQ_MASK, &status); /* Clear only the interrupt that was raised */ - core->cpe_cdc_cb->cpe_err_irq_control(core->codec, + core->cpe_cdc_cb->cpe_err_irq_control(core->component, CPE_ERR_IRQ_CLEAR, &status); dev_err(core->dev, "%s: err_interrupt status = 0x%x\n", __func__, status); /* Read status for pending interrupts */ - core->cpe_cdc_cb->cpe_err_irq_control(core->codec, + core->cpe_cdc_cb->cpe_err_irq_control(core->component, CPE_ERR_IRQ_STATUS, &status); } @@ -1329,7 +1329,7 @@ static void wcd_cpe_deinitialize_afe_port_data(void) */ static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wcd_cpe_core *core; struct cpe_svc_boot_event *boot_data; bool active_sessions; @@ -1339,14 +1339,14 @@ static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param) return; } - codec = param->private_data; - if (!codec) { + component = param->private_data; + if (!component) { pr_err("%s: Invalid handle to codec\n", __func__); return; } - core = wcd_cpe_get_core_handle(codec); + core = wcd_cpe_get_core_handle(component); if (!core) { pr_err("%s: Invalid handle to core\n", __func__); @@ -1422,8 +1422,8 @@ static void wcd_cpe_svc_event_cb(const struct cpe_svc_notification *param) static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core) { - struct snd_soc_codec *codec = core->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = core->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; wcd9xxx_free_irq(core_res, @@ -1444,8 +1444,8 @@ static void wcd_cpe_cleanup_irqs(struct wcd_cpe_core *core) static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core) { int ret; - struct snd_soc_codec *codec = core->codec; - struct wcd9xxx *wcd9xxx = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = core->component; + struct wcd9xxx *wcd9xxx = dev_get_drvdata(component->dev->parent); struct wcd9xxx_core_resource *core_res = &wcd9xxx->core_res; ret = wcd9xxx_request_irq(core_res, @@ -1461,14 +1461,14 @@ static int wcd_cpe_setup_irqs(struct wcd_cpe_core *core) /* Make sure all error interrupts are cleared */ if (CPE_ERR_IRQ_CB(core)) core->cpe_cdc_cb->cpe_err_irq_control( - core->codec, + core->component, CPE_ERR_IRQ_CLEAR, NULL); /* Enable required error interrupts */ if (CPE_ERR_IRQ_CB(core)) core->cpe_cdc_cb->cpe_err_irq_control( - core->codec, + core->component, CPE_ERR_IRQ_UNMASK, NULL); @@ -1854,27 +1854,27 @@ done: } static int wcd_cpe_validate_params( - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct wcd_cpe_params *params) { - if (!codec) { + if (!component) { pr_err("%s: Invalid codec\n", __func__); return -EINVAL; } if (!params) { - dev_err(codec->dev, + dev_err(component->dev, "%s: No params supplied for codec %s\n", - __func__, codec->component.name); + __func__, component->name); return -EINVAL; } - if (!params->codec || !params->get_cpe_core || + if (!params->component || !params->get_cpe_core || !params->cdc_cb) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid params for codec %s\n", - __func__, codec->component.name); + __func__, component->name); return -EINVAL; } @@ -1884,14 +1884,14 @@ static int wcd_cpe_validate_params( /* * wcd_cpe_init: Initialize CPE related structures * @img_fname: filename for firmware image - * @codec: handle to codec requesting for image download + * @component: handle to codec requesting for image download * @params: parameter structure passed from caller * * This API will initialize the cpe core but will not * download the image or boot the cpe core. */ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, - struct snd_soc_codec *codec, + struct snd_soc_component *component, struct wcd_cpe_params *params) { struct wcd_cpe_core *core; @@ -1904,7 +1904,7 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, const struct cpe_svc_hw_cfg *hw_info; int id = 0; - if (wcd_cpe_validate_params(codec, params)) + if (wcd_cpe_validate_params(component, params)) return NULL; core = kzalloc(sizeof(struct wcd_cpe_core), GFP_KERNEL); @@ -1916,8 +1916,8 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, wcd_get_cpe_core = params->get_cpe_core; - core->codec = params->codec; - core->dev = params->codec->dev; + core->component = params->component; + core->dev = params->component->dev; core->cpe_debug_mode = params->dbg_mode; core->cdc_info.major_version = params->cdc_major_ver; @@ -1969,7 +1969,7 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, goto fail_cpe_register; } - card = codec->component.card->snd_card; + card = component->card->snd_card; snprintf(proc_name, (sizeof("cpe") + sizeof("_state") + sizeof(id) - 2), "%s%d%s", cpe_name, id, state_name); entry = snd_info_create_card_entry(card, proc_name, @@ -3248,10 +3248,10 @@ static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle, struct cpe_lsm_session *session) { struct wcd_cpe_core *core = core_handle; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int rc = 0; - if (!core || !core->codec) { + if (!core || !core->component) { pr_err("%s: Invalid handle to %s\n", __func__, (!core) ? "core" : "codec"); @@ -3275,8 +3275,8 @@ static int wcd_cpe_lsm_get_afe_out_port_id(void *core_handle, goto done; } - codec = core->codec; - rc = core->cpe_cdc_cb->get_afe_out_port_id(codec, + component = core->component; + rc = core->cpe_cdc_cb->get_afe_out_port_id(component, &session->afe_out_port_id); if (rc) { dev_err(core->dev, @@ -3667,11 +3667,11 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, enum wcd_cpe_event event) { struct wcd_cpe_core *core = core_handle; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int rc = 0; u8 cpe_intr_bits; - if (!core || !core->codec) { + if (!core || !core->component) { pr_err("%s: Invalid handle to %s\n", __func__, (!core) ? "core" : "codec"); @@ -3689,14 +3689,14 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, goto done; } - codec = core->codec; + component = core->component; dev_dbg(core->dev, "%s: event = 0x%x\n", __func__, event); switch (event) { case WCD_CPE_PRE_ENABLE: - rc = core->cpe_cdc_cb->cdc_ext_clk(codec, true, false); + rc = core->cpe_cdc_cb->cdc_ext_clk(component, true, false); if (rc) { dev_err(core->dev, "%s: failed to enable cdc clk, err = %d\n", @@ -3704,13 +3704,14 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, goto done; } - rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec, + rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(component, true); if (rc) { dev_err(core->dev, "%s: failed to enable cdc port, err = %d\n", __func__, rc); - rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false); + rc = core->cpe_cdc_cb->cdc_ext_clk( + component, false, false); goto done; } @@ -3731,11 +3732,11 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF); if (CPE_ERR_IRQ_CB(core)) core->cpe_cdc_cb->cpe_err_irq_control( - core->codec, + core->component, CPE_ERR_IRQ_MASK, &cpe_intr_bits); - rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(codec, + rc = core->cpe_cdc_cb->lab_cdc_ch_ctl(component, false); if (rc) dev_err(core->dev, @@ -3757,7 +3758,7 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, "%s: Failed to disable lab\n", __func__); /* Continue with disabling even if toggle lab fails */ - rc = core->cpe_cdc_cb->cdc_ext_clk(codec, false, false); + rc = core->cpe_cdc_cb->cdc_ext_clk(component, false, false); if (rc) dev_err(core->dev, "%s: failed to disable cdc clk, err = %d\n", @@ -3767,7 +3768,7 @@ static int wcd_cpe_lab_ch_setup(void *core_handle, cpe_intr_bits = ~(core->irq_info.cpe_fatal_irqs & 0xFF); if (CPE_ERR_IRQ_CB(core)) core->cpe_cdc_cb->cpe_err_irq_control( - core->codec, + core->component, CPE_ERR_IRQ_UNMASK, &cpe_intr_bits); break; @@ -3907,7 +3908,7 @@ done: /* * wcd_cpe_get_lsm_ops: register lsm driver to codec * @lsm_ops: structure with lsm callbacks - * @codec: codec to which this lsm driver is registered to + * @component: codec to which this lsm driver is registered to */ int wcd_cpe_get_lsm_ops(struct wcd_cpe_lsm_ops *lsm_ops) { diff --git a/asoc/codecs/wcd_cpe_core.h b/asoc/codecs/wcd_cpe_core.h index ad2ff106ab..105ece0a97 100644 --- a/asoc/codecs/wcd_cpe_core.h +++ b/asoc/codecs/wcd_cpe_core.h @@ -50,18 +50,20 @@ enum cpe_err_irq_cntl_type { struct wcd_cpe_cdc_cb { /* codec provided callback to enable RCO */ - int (*cdc_clk_en)(struct snd_soc_codec *, bool); + int (*cdc_clk_en)(struct snd_soc_component *cpmponent, bool enable); /* callback for FLL setup for codec */ - int (*cpe_clk_en)(struct snd_soc_codec *, bool); - int (*cdc_ext_clk)(struct snd_soc_codec *codec, int enable, bool dapm); - int (*lab_cdc_ch_ctl)(struct snd_soc_codec *codec, u8 event); - int (*get_afe_out_port_id)(struct snd_soc_codec *codec, u16 *port_id); - int (*bus_vote_bw)(struct snd_soc_codec *codec, + int (*cpe_clk_en)(struct snd_soc_component *component, bool enable); + int (*cdc_ext_clk)(struct snd_soc_component *component, int enable, + bool dapm); + int (*lab_cdc_ch_ctl)(struct snd_soc_component *component, u8 event); + int (*get_afe_out_port_id)(struct snd_soc_component *component, + u16 *port_id); + int (*bus_vote_bw)(struct snd_soc_component *component, bool vote); /* Callback to control the cpe error interrupt mask/status/clear */ - int (*cpe_err_irq_control)(struct snd_soc_codec *codec, + int (*cpe_err_irq_control)(struct snd_soc_component *component, enum cpe_err_irq_cntl_type cntl_type, u8 *status); }; @@ -114,7 +116,7 @@ struct wcd_cpe_core { void *cmi_afe_handle; /* handle to codec */ - struct snd_soc_codec *codec; + struct snd_soc_component *component; /* codec device */ struct device *dev; @@ -200,9 +202,9 @@ struct wcd_cpe_core { }; struct wcd_cpe_params { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wcd_cpe_core * (*get_cpe_core)( - struct snd_soc_codec *); + struct snd_soc_component *component); const struct wcd_cpe_cdc_cb *cdc_cb; int dbg_mode; u16 cdc_major_ver; @@ -218,7 +220,7 @@ struct wcd_cpe_params { int wcd_cpe_ssr_event(void *core_handle, enum wcd_cpe_ssr_state_event event); struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, -struct snd_soc_codec *codec, struct wcd_cpe_params *params); +struct snd_soc_component *component, struct wcd_cpe_params *params); #else /* CONFIG_SND_SOC_WCD_CPE */ static inline int wcd_cpe_ssr_event(void *core_handle, enum wcd_cpe_ssr_state_event event) @@ -226,8 +228,8 @@ static inline int wcd_cpe_ssr_event(void *core_handle, return 0; } static inline struct wcd_cpe_core *wcd_cpe_init(const char *img_fname, - struct snd_soc_codec *codec, - struct wcd_cpe_params *params) + struct snd_soc_component *component, + struct wcd_cpe_params *params) { return NULL; } diff --git a/asoc/codecs/wcdcal-hwdep.c b/asoc/codecs/wcdcal-hwdep.c index 9c5d0e2962..162c40746a 100644 --- a/asoc/codecs/wcdcal-hwdep.c +++ b/asoc/codecs/wcdcal-hwdep.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2015, 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2015, 2017-2018 The Linux Foundation. All rights reserved. * */ #include @@ -152,7 +152,8 @@ static int wcdcal_hwdep_release(struct snd_hwdep *hw, struct file *file) return 0; } -int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec) +int wcd_cal_create_hwdep(void *data, int node, + struct snd_soc_component *component) { char hwname[40]; struct snd_hwdep *hwdep; @@ -160,23 +161,23 @@ int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec) struct fw_info *fw_data = data; int err, cal_bit; - if (!fw_data || !codec) { + if (!fw_data || !component) { pr_err("%s: wrong arguments passed\n", __func__); return -EINVAL; } fw = fw_data->fw; snprintf(hwname, strlen("Codec %s"), "Codec %s", - codec->component.name); - err = snd_hwdep_new(codec->component.card->snd_card, + component->name); + err = snd_hwdep_new(component->card->snd_card, hwname, node, &hwdep); if (err < 0) { - dev_err(codec->dev, "%s: new hwdep failed %d\n", + dev_err(component->dev, "%s: new hwdep failed %d\n", __func__, err); return err; } snprintf(hwdep->name, strlen("Codec %s"), "Codec %s", - codec->component.name); + component->name); hwdep->iface = SNDRV_HWDEP_IFACE_AUDIO_CODEC; hwdep->private_data = fw_data; hwdep->ops.ioctl_compat = wcdcal_hwdep_ioctl_compat; @@ -188,11 +189,8 @@ int wcd_cal_create_hwdep(void *data, int node, struct snd_soc_codec *codec) set_bit(WCDCAL_UNINITIALISED, &fw_data->wcdcal_state[cal_bit]); fw[cal_bit] = kzalloc(sizeof *(fw[cal_bit]), GFP_KERNEL); - if (!fw[cal_bit]) { - dev_err(codec->dev, "%s: no memory for %s cal\n", - __func__, cal_name_info[cal_bit]); + if (!fw[cal_bit]) goto end; - } } for_each_set_bit(cal_bit, fw_data->cal_bit, WCD9XXX_MAX_CAL) { fw[cal_bit]->data = kzalloc(cal_size_info[cal_bit], diff --git a/asoc/codecs/wcdcal-hwdep.h b/asoc/codecs/wcdcal-hwdep.h index 05f1c48e26..9606cd577f 100644 --- a/asoc/codecs/wcdcal-hwdep.h +++ b/asoc/codecs/wcdcal-hwdep.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved. */ #ifndef __WCD9XXX_HWDEP_H__ #define __WCD9XXX_HWDEP_H__ @@ -26,7 +26,8 @@ struct firmware_cal { }; struct snd_soc_codec; -int wcd_cal_create_hwdep(void *fw, int node, struct snd_soc_codec *codec); +int wcd_cal_create_hwdep(void *fw, int node, + struct snd_soc_component *component); struct firmware_cal *wcdcal_get_fw_cal(struct fw_info *fw_data, enum wcd_cal_type type); #endif /* __WCD9XXX_HWDEP_H__ */ diff --git a/asoc/codecs/wsa881x-temp-sensor.c b/asoc/codecs/wsa881x-temp-sensor.c index 5f6840d1f8..598449c139 100644 --- a/asoc/codecs/wsa881x-temp-sensor.c +++ b/asoc/codecs/wsa881x-temp-sensor.c @@ -30,7 +30,7 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal, int *temp) { struct wsa881x_tz_priv *pdata; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wsa_temp_register reg; int dmeas, d1, d2; int ret = 0; @@ -44,8 +44,8 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal, if (thermal->devdata) { pdata = thermal->devdata; - if (pdata->codec) { - codec = pdata->codec; + if (pdata->component) { + component = pdata->component; } else { pr_err("%s: codec is NULL\n", __func__); return -EINVAL; @@ -70,7 +70,7 @@ int wsa881x_get_temp(struct thermal_zone_device *thermal, temp_retry: if (pdata->wsa_temp_reg_read) { - ret = pdata->wsa_temp_reg_read(codec, ®); + ret = pdata->wsa_temp_reg_read(component, ®); if (ret) { pr_err("%s: temp read failed: %d, current temp: %d\n", __func__, ret, pdata->curr_temp); diff --git a/asoc/codecs/wsa881x-temp-sensor.h b/asoc/codecs/wsa881x-temp-sensor.h index 0d61c99fa2..7c9052615d 100644 --- a/asoc/codecs/wsa881x-temp-sensor.h +++ b/asoc/codecs/wsa881x-temp-sensor.h @@ -15,11 +15,11 @@ struct wsa_temp_register { u8 dmeas_msb; u8 dmeas_lsb; }; -typedef int32_t (*wsa_temp_register_read)(struct snd_soc_codec *codec, +typedef int32_t (*wsa_temp_register_read)(struct snd_soc_component *component, struct wsa_temp_register *wsa_temp_reg); struct wsa881x_tz_priv { struct thermal_zone_device *tz_dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wsa_temp_register *wsa_temp_reg; char name[80]; wsa_temp_register_read wsa_temp_reg_read; diff --git a/asoc/codecs/wsa881x.c b/asoc/codecs/wsa881x.c index 238430cc05..da33494e0f 100644 --- a/asoc/codecs/wsa881x.c +++ b/asoc/codecs/wsa881x.c @@ -28,6 +28,7 @@ #include "wsa881x.h" #include "wsa881x-temp-sensor.h" +#define DRV_NAME "wsa-codec" #define WSA881X_NUM_RETRY 5 enum { @@ -80,7 +81,7 @@ struct wsa881x_priv { struct regmap *regmap; struct device *dev; struct swr_device *swr_slave; - struct snd_soc_codec *codec; + struct snd_soc_component *component; bool comp_enable; bool boost_enable; bool visense_enable; @@ -127,7 +128,7 @@ static struct dentry *debugfs_reg_dump; static unsigned int read_data; static unsigned int devnum; -static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec, +static int32_t wsa881x_resource_acquire(struct snd_soc_component *component, bool enable); static const char * const wsa_pa_gain_text[] = { @@ -142,12 +143,14 @@ static const struct soc_enum wsa_pa_gain_enum = static int wsa_pa_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa881x->pa_gain; - dev_dbg(codec->dev, "%s: PA gain = 0x%x\n", __func__, wsa881x->pa_gain); + dev_dbg(component->dev, "%s: PA gain = 0x%x\n", __func__, + wsa881x->pa_gain); return 0; } @@ -155,10 +158,11 @@ static int wsa_pa_gain_get(struct snd_kcontrol *kcontrol, static int wsa_pa_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); wsa881x->pa_gain = ucontrol->value.integer.value[0]; @@ -170,8 +174,9 @@ static int wsa881x_get_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa881x->pa_mute; @@ -181,15 +186,17 @@ static int wsa881x_get_mute(struct snd_kcontrol *kcontrol, static int wsa881x_set_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: mute current %d, new %d\n", + dev_dbg(component->dev, "%s: mute current %d, new %d\n", __func__, wsa881x->pa_mute, value); if (value) - snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x80, 0x00); + snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_EN, + 0x80, 0x00); wsa881x->pa_mute = value; return 0; @@ -199,12 +206,13 @@ static int wsa881x_get_t0_init(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); struct wsa881x_tz_priv *pdata = &wsa881x->tz_pdata; ucontrol->value.integer.value[0] = pdata->t0_init; - dev_dbg(codec->dev, "%s: t0 init %d\n", __func__, pdata->t0_init); + dev_dbg(component->dev, "%s: t0 init %d\n", __func__, pdata->t0_init); return 0; } @@ -212,12 +220,13 @@ static int wsa881x_get_t0_init(struct snd_kcontrol *kcontrol, static int wsa881x_set_t0_init(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); struct wsa881x_tz_priv *pdata = &wsa881x->tz_pdata; pdata->t0_init = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: t0 init %d\n", __func__, pdata->t0_init); + dev_dbg(component->dev, "%s: t0 init %d\n", __func__, pdata->t0_init); return 0; } @@ -286,7 +295,7 @@ static struct snd_info_entry_ops wsa881x_codec_info_ops = { /* * wsa881x_codec_info_create_codec_entry - creates wsa881x module * @codec_root: The parent directory - * @codec: Codec instance + * @component: Codec instance * * Creates wsa881x module and version entry under the given * parent directory. @@ -294,18 +303,18 @@ static struct snd_info_entry_ops wsa881x_codec_info_ops = { * Return: 0 on success or negative error code on failure. */ int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_info_entry *version_entry; struct wsa881x_priv *wsa881x; struct snd_soc_card *card; char name[80]; - if (!codec_root || !codec) + if (!codec_root || !component) return -EINVAL; - wsa881x = snd_soc_codec_get_drvdata(codec); - card = codec->component.card; + wsa881x = snd_soc_component_get_drvdata(component); + card = component->card; snprintf(name, sizeof(name), "%s.%x", "wsa881x", (u32)wsa881x->swr_slave->addr); @@ -313,7 +322,7 @@ int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root, (const char *)name, codec_root); if (!wsa881x->entry) { - dev_dbg(codec->dev, "%s: failed to create wsa881x entry\n", + dev_dbg(component->dev, "%s: failed to create wsa881x entry\n", __func__); return -ENOMEM; } @@ -322,7 +331,7 @@ int wsa881x_codec_info_create_codec_entry(struct snd_info_entry *codec_root, "version", wsa881x->entry); if (!version_entry) { - dev_dbg(codec->dev, "%s: failed to create wsa881x version entry\n", + dev_dbg(component->dev, "%s: failed to create wsa881x version entry\n", __func__); return -ENOMEM; } @@ -530,13 +539,15 @@ static const struct reg_sequence wsa881x_vi_txfe_en_2_0[] = { {WSA881X_SPKR_PROT_FE_GAIN, 0x47, 0}, }; -static int wsa881x_boost_ctrl(struct snd_soc_codec *codec, bool enable) +static int wsa881x_boost_ctrl(struct snd_soc_component *component, bool enable) { - dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable); + dev_dbg(component->dev, "%s: enable:%d\n", __func__, enable); if (enable) - snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x80); + snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL, + 0x80, 0x80); else - snd_soc_update_bits(codec, WSA881X_BOOST_EN_CTL, 0x80, 0x00); + snd_soc_component_update_bits(component, WSA881X_BOOST_EN_CTL, + 0x80, 0x00); /* * 1.5ms sleep is needed after boost enable/disable as per * HW requirement @@ -545,13 +556,13 @@ static int wsa881x_boost_ctrl(struct snd_soc_codec *codec, bool enable) return 0; } -static int wsa881x_visense_txfe_ctrl(struct snd_soc_codec *codec, bool enable, - u8 isense1_gain, u8 isense2_gain, - u8 vsense_gain) +static int wsa881x_visense_txfe_ctrl(struct snd_soc_component *component, + bool enable, u8 isense1_gain, + u8 isense2_gain, u8 vsense_gain) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s: enable:%d, isense1 gain: %d, isense2 gain: %d, vsense_gain %d\n", __func__, enable, isense1_gain, isense2_gain, vsense_gain); @@ -560,79 +571,91 @@ static int wsa881x_visense_txfe_ctrl(struct snd_soc_codec *codec, bool enable, wsa881x_vi_txfe_en_2_0, ARRAY_SIZE(wsa881x_vi_txfe_en_2_0)); } else { - snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_VSENSE_VCM, - 0x08, 0x08); + snd_soc_component_update_bits(component, + WSA881X_SPKR_PROT_FE_VSENSE_VCM, + 0x08, 0x08); /* * 200us sleep is needed after visense txfe disable as per * HW requirement. */ usleep_range(200, 210); - snd_soc_update_bits(codec, WSA881X_SPKR_PROT_FE_GAIN, - 0x01, 0x00); + snd_soc_component_update_bits(component, + WSA881X_SPKR_PROT_FE_GAIN, + 0x01, 0x00); } return 0; } -static int wsa881x_visense_adc_ctrl(struct snd_soc_codec *codec, bool enable) +static int wsa881x_visense_adc_ctrl(struct snd_soc_component *component, + bool enable) { - dev_dbg(codec->dev, "%s: enable:%d\n", __func__, enable); - snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_V, (0x01 << 7), - (enable << 7)); - snd_soc_update_bits(codec, WSA881X_ADC_EN_MODU_I, (0x01 << 7), - (enable << 7)); + dev_dbg(component->dev, "%s: enable:%d\n", __func__, enable); + snd_soc_component_update_bits(component, WSA881X_ADC_EN_MODU_V, + (0x01 << 7), (enable << 7)); + snd_soc_component_update_bits(component, WSA881X_ADC_EN_MODU_I, + (0x01 << 7), (enable << 7)); return 0; } -static void wsa881x_bandgap_ctrl(struct snd_soc_codec *codec, bool enable) +static void wsa881x_bandgap_ctrl(struct snd_soc_component *component, + bool enable) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: enable:%d, bg_count:%d\n", __func__, + dev_dbg(component->dev, "%s: enable:%d, bg_count:%d\n", __func__, enable, wsa881x->bg_cnt); mutex_lock(&wsa881x->bg_lock); if (enable) { ++wsa881x->bg_cnt; if (wsa881x->bg_cnt == 1) { - snd_soc_update_bits(codec, WSA881X_TEMP_OP, - 0x08, 0x08); + snd_soc_component_update_bits(component, + WSA881X_TEMP_OP, + 0x08, 0x08); /* 400usec sleep is needed as per HW requirement */ usleep_range(400, 410); - snd_soc_update_bits(codec, WSA881X_TEMP_OP, - 0x04, 0x04); + snd_soc_component_update_bits(component, + WSA881X_TEMP_OP, + 0x04, 0x04); } } else { --wsa881x->bg_cnt; if (wsa881x->bg_cnt <= 0) { WARN_ON(wsa881x->bg_cnt < 0); wsa881x->bg_cnt = 0; - snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x04, 0x00); - snd_soc_update_bits(codec, WSA881X_TEMP_OP, 0x08, 0x00); + snd_soc_component_update_bits(component, + WSA881X_TEMP_OP, 0x04, 0x00); + snd_soc_component_update_bits(component, + WSA881X_TEMP_OP, 0x08, 0x00); } } mutex_unlock(&wsa881x->bg_lock); } -static void wsa881x_clk_ctrl(struct snd_soc_codec *codec, bool enable) +static void wsa881x_clk_ctrl(struct snd_soc_component *component, bool enable) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: enable:%d, clk_count:%d\n", __func__, + dev_dbg(component->dev, "%s: enable:%d, clk_count:%d\n", __func__, enable, wsa881x->clk_cnt); mutex_lock(&wsa881x->res_lock); if (enable) { ++wsa881x->clk_cnt; if (wsa881x->clk_cnt == 1) { - snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x01); - snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x01); + snd_soc_component_write(component, + WSA881X_CDC_DIG_CLK_CTL, 0x01); + snd_soc_component_write(component, + WSA881X_CDC_ANA_CLK_CTL, 0x01); } } else { --wsa881x->clk_cnt; if (wsa881x->clk_cnt <= 0) { WARN_ON(wsa881x->clk_cnt < 0); wsa881x->clk_cnt = 0; - snd_soc_write(codec, WSA881X_CDC_DIG_CLK_CTL, 0x00); - snd_soc_write(codec, WSA881X_CDC_ANA_CLK_CTL, 0x00); + snd_soc_component_write(component, + WSA881X_CDC_DIG_CLK_CTL, 0x00); + snd_soc_component_write(component, + WSA881X_CDC_ANA_CLK_CTL, 0x00); } } mutex_unlock(&wsa881x->res_lock); @@ -642,8 +665,9 @@ static int wsa881x_get_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa881x->comp_enable; return 0; @@ -652,11 +676,12 @@ static int wsa881x_get_compander(struct snd_kcontrol *kcontrol, static int wsa881x_set_compander(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: Compander enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Compander enable current %d, new %d\n", __func__, wsa881x->comp_enable, value); wsa881x->comp_enable = value; return 0; @@ -666,8 +691,9 @@ static int wsa881x_get_boost(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa881x->boost_enable; return 0; @@ -676,11 +702,12 @@ static int wsa881x_get_boost(struct snd_kcontrol *kcontrol, static int wsa881x_set_boost(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: Boost enable current %d, new %d\n", + dev_dbg(component->dev, "%s: Boost enable current %d, new %d\n", __func__, wsa881x->boost_enable, value); wsa881x->boost_enable = value; return 0; @@ -690,8 +717,9 @@ static int wsa881x_get_visense(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wsa881x->visense_enable; return 0; @@ -700,11 +728,12 @@ static int wsa881x_get_visense(struct snd_kcontrol *kcontrol, static int wsa881x_set_visense(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int value = ucontrol->value.integer.value[0]; - dev_dbg(codec->dev, "%s: VIsense enable current %d, new %d\n", + dev_dbg(component->dev, "%s: VIsense enable current %d, new %d\n", __func__, wsa881x->visense_enable, value); wsa881x->visense_enable = value; return 0; @@ -713,14 +742,15 @@ static int wsa881x_set_visense(struct snd_kcontrol *kcontrol, static int wsa881x_set_boost_level(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u8 wsa_boost_level = 0; - dev_dbg(codec->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", + dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); wsa_boost_level = ucontrol->value.integer.value[0]; - snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT1, + snd_soc_component_update_bits(component, WSA881X_BOOST_PRESET_OUT1, 0xff, wsa_boost_level); return 0; @@ -729,12 +759,14 @@ static int wsa881x_set_boost_level(struct snd_kcontrol *kcontrol, static int wsa881x_get_boost_level(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); u8 wsa_boost_level = 0; - wsa_boost_level = snd_soc_read(codec, WSA881X_BOOST_PRESET_OUT1); + wsa_boost_level = snd_soc_component_read32(component, + WSA881X_BOOST_PRESET_OUT1); ucontrol->value.integer.value[0] = wsa_boost_level; - dev_dbg(codec->dev, "%s: boost level = 0x%x\n", __func__, + dev_dbg(component->dev, "%s: boost level = 0x%x\n", __func__, wsa_boost_level); return 0; @@ -758,11 +790,11 @@ static const struct snd_kcontrol_new swr_dac_port[] = { SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0) }; -static int wsa881x_set_port(struct snd_soc_codec *codec, int port_idx, +static int wsa881x_set_port(struct snd_soc_component *component, int port_idx, u8 *port_id, u8 *num_ch, u8 *ch_mask, u32 *ch_rate, u8 *port_type) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); *port_id = wsa881x->port[port_idx].port_id; *num_ch = wsa881x->port[port_idx].num_ch; @@ -775,8 +807,9 @@ static int wsa881x_set_port(struct snd_soc_codec *codec, int port_idx, static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); u8 port_id[WSA881X_MAX_SWR_PORTS]; u8 num_ch[WSA881X_MAX_SWR_PORTS]; u8 ch_mask[WSA881X_MAX_SWR_PORTS]; @@ -784,35 +817,35 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, u8 port_type[WSA881X_MAX_SWR_PORTS]; u8 num_port = 0; - dev_dbg(codec->dev, "%s: event %d name %s\n", __func__, + dev_dbg(component->dev, "%s: event %d name %s\n", __func__, event, w->name); if (wsa881x == NULL) return -EINVAL; switch (event) { case SND_SOC_DAPM_PRE_PMU: - wsa881x_set_port(codec, SWR_DAC_PORT, + wsa881x_set_port(component, SWR_DAC_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; if (wsa881x->comp_enable) { - wsa881x_set_port(codec, SWR_COMP_PORT, + wsa881x_set_port(component, SWR_COMP_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; } if (wsa881x->boost_enable) { - wsa881x_set_port(codec, SWR_BOOST_PORT, + wsa881x_set_port(component, SWR_BOOST_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; } if (wsa881x->visense_enable) { - wsa881x_set_port(codec, SWR_VISENSE_PORT, + wsa881x_set_port(component, SWR_VISENSE_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); @@ -827,28 +860,28 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: break; case SND_SOC_DAPM_POST_PMD: - wsa881x_set_port(codec, SWR_DAC_PORT, + wsa881x_set_port(component, SWR_DAC_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; if (wsa881x->comp_enable) { - wsa881x_set_port(codec, SWR_COMP_PORT, + wsa881x_set_port(component, SWR_COMP_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; } if (wsa881x->boost_enable) { - wsa881x_set_port(codec, SWR_BOOST_PORT, + wsa881x_set_port(component, SWR_BOOST_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); ++num_port; } if (wsa881x->visense_enable) { - wsa881x_set_port(codec, SWR_VISENSE_PORT, + wsa881x_set_port(component, SWR_VISENSE_PORT, &port_id[num_port], &num_ch[num_port], &ch_mask[num_port], &ch_rate[num_port], &port_type[num_port]); @@ -866,40 +899,41 @@ static int wsa881x_enable_swr_dac_port(struct snd_soc_dapm_widget *w, static int wsa881x_rdac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: %s %d boost %d visense %d\n", __func__, + dev_dbg(component->dev, "%s: %s %d boost %d visense %d\n", __func__, w->name, event, wsa881x->boost_enable, wsa881x->visense_enable); switch (event) { case SND_SOC_DAPM_PRE_PMU: mutex_lock(&wsa881x->temp_lock); - wsa881x_resource_acquire(codec, ENABLE); + wsa881x_resource_acquire(component, ENABLE); mutex_unlock(&wsa881x->temp_lock); - wsa881x_boost_ctrl(codec, ENABLE); + wsa881x_boost_ctrl(component, ENABLE); break; case SND_SOC_DAPM_POST_PMD: swr_slvdev_datapath_control(wsa881x->swr_slave, wsa881x->swr_slave->dev_num, false); - wsa881x_boost_ctrl(codec, DISABLE); + wsa881x_boost_ctrl(component, DISABLE); mutex_lock(&wsa881x->temp_lock); - wsa881x_resource_acquire(codec, DISABLE); + wsa881x_resource_acquire(component, DISABLE); mutex_unlock(&wsa881x->temp_lock); break; } return 0; } -static int wsa881x_ramp_pa_gain(struct snd_soc_codec *codec, +static int wsa881x_ramp_pa_gain(struct snd_soc_component *component, int min_gain, int max_gain, int udelay) { int val; for (val = min_gain; max_gain <= val; val--) { - snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN, + snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_GAIN, 0xF0, val << 4); /* * 1ms delay is needed for every step change in gain as per @@ -914,20 +948,22 @@ static void wsa881x_ocp_ctl_work(struct work_struct *work) { struct wsa881x_priv *wsa881x; struct delayed_work *dwork; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int temp_val; dwork = to_delayed_work(work); wsa881x = container_of(dwork, struct wsa881x_priv, ocp_ctl_work); - codec = wsa881x->codec; + component = wsa881x->component; wsa881x_get_temp(wsa881x->tz_pdata.tz_dev, &temp_val); - dev_dbg(codec->dev, " temp = %d\n", temp_val); + dev_dbg(component->dev, " temp = %d\n", temp_val); if (temp_val <= WSA881X_OCP_CTL_TEMP_CELSIUS) - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x00); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0x00); else - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0xC0); schedule_delayed_work(&wsa881x->ocp_ctl_work, msecs_to_jiffies(wsa881x_ocp_poll_timer_sec * 1000)); @@ -936,14 +972,16 @@ static void wsa881x_ocp_ctl_work(struct work_struct *work) static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int min_gain, max_gain; - dev_dbg(codec->dev, "%s: %s %d\n", __func__, w->name, event); + dev_dbg(component->dev, "%s: %s %d\n", __func__, w->name, event); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0x80); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0x80); regmap_multi_reg_write(wsa881x->regmap, wsa881x_pre_pmu_pa_2_0, ARRAY_SIZE(wsa881x_pre_pmu_pa_2_0)); @@ -952,11 +990,13 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, true); /* Set register mode if compander is not enabled */ if (!wsa881x->comp_enable) - snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN, - 0x08, 0x08); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_GAIN, + 0x08, 0x08); else - snd_soc_update_bits(codec, WSA881X_SPKR_DRV_GAIN, - 0x08, 0x00); + snd_soc_component_update_bits(component, + WSA881X_SPKR_DRV_GAIN, + 0x08, 0x00); break; case SND_SOC_DAPM_POST_PMU: @@ -975,14 +1015,16 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, * as per HW requirement. */ usleep_range(1000, 1010); - wsa881x_ramp_pa_gain(codec, min_gain, max_gain, 1000); + wsa881x_ramp_pa_gain(component, min_gain, max_gain, + 1000); } if (wsa881x->visense_enable) { - wsa881x_visense_txfe_ctrl(codec, ENABLE, + wsa881x_visense_txfe_ctrl(component, ENABLE, 0x00, 0x03, 0x01); - snd_soc_update_bits(codec, WSA881X_ADC_EN_SEL_IBAIS, - 0x07, 0x01); - wsa881x_visense_adc_ctrl(codec, ENABLE); + snd_soc_component_update_bits(component, + WSA881X_ADC_EN_SEL_IBAIS, + 0x07, 0x01); + wsa881x_visense_adc_ctrl(component, ENABLE); } schedule_delayed_work(&wsa881x->ocp_ctl_work, msecs_to_jiffies(WSA881X_OCP_CTL_TIMER_SEC * 1000)); @@ -992,12 +1034,13 @@ static int wsa881x_spkr_pa_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: if (wsa881x->visense_enable) { - wsa881x_visense_adc_ctrl(codec, DISABLE); - wsa881x_visense_txfe_ctrl(codec, DISABLE, + wsa881x_visense_adc_ctrl(component, DISABLE); + wsa881x_visense_txfe_ctrl(component, DISABLE, 0x00, 0x01, 0x01); } cancel_delayed_work_sync(&wsa881x->ocp_ctl_work); - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0xC0, 0xC0); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0xC0, 0xC0); break; } return 0; @@ -1029,16 +1072,16 @@ static const struct snd_soc_dapm_route wsa881x_audio_map[] = { {"SPKR", NULL, "SPKR PGA"}, }; -int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, u8 num_port, - unsigned int *ch_mask, unsigned int *ch_rate, - u8 *port_type) +int wsa881x_set_channel_map(struct snd_soc_component *component, u8 *port, + u8 num_port, unsigned int *ch_mask, + unsigned int *ch_rate, u8 *port_type) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); int i; if (!port || !ch_mask || !ch_rate || (num_port > WSA881X_MAX_SWR_PORTS)) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Invalid port=%pK, ch_mask=%pK, ch_rate=%pK\n", __func__, port, ch_mask, ch_rate); return -EINVAL; @@ -1055,70 +1098,91 @@ int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, u8 num_port, } EXPORT_SYMBOL(wsa881x_set_channel_map); -static void wsa881x_init(struct snd_soc_codec *codec) +static void wsa881x_init(struct snd_soc_component *component) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); - wsa881x->version = snd_soc_read(codec, WSA881X_CHIP_ID1); + wsa881x->version = + snd_soc_component_read32(component, WSA881X_CHIP_ID1); wsa881x_regmap_defaults(wsa881x->regmap, wsa881x->version); /* Enable software reset output from soundwire slave */ - snd_soc_update_bits(codec, WSA881X_SWR_RESET_EN, 0x07, 0x07); + snd_soc_component_update_bits(component, WSA881X_SWR_RESET_EN, + 0x07, 0x07); /* Bring out of analog reset */ - snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x02, 0x02); + snd_soc_component_update_bits(component, WSA881X_CDC_RST_CTL, + 0x02, 0x02); /* Bring out of digital reset */ - snd_soc_update_bits(codec, WSA881X_CDC_RST_CTL, 0x01, 0x01); + snd_soc_component_update_bits(component, WSA881X_CDC_RST_CTL, + 0x01, 0x01); - snd_soc_update_bits(codec, WSA881X_CLOCK_CONFIG, 0x10, 0x10); - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x02, 0x02); - snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0xC0, 0x80); - snd_soc_update_bits(codec, WSA881X_SPKR_MISC_CTL1, 0x06, 0x06); - snd_soc_update_bits(codec, WSA881X_SPKR_BIAS_INT, 0xFF, 0x00); - snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0xF0, 0x40); - snd_soc_update_bits(codec, WSA881X_SPKR_PA_INT, 0x0E, 0x0E); - snd_soc_update_bits(codec, WSA881X_BOOST_LOOP_STABILITY, - 0x03, 0x03); - snd_soc_update_bits(codec, WSA881X_BOOST_MISC2_CTL, 0xFF, 0x14); - snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x80, 0x80); - snd_soc_update_bits(codec, WSA881X_BOOST_START_CTL, 0x03, 0x00); - snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, - 0x0C, 0x04); - snd_soc_update_bits(codec, WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, - 0x03, 0x00); - if (snd_soc_read(codec, WSA881X_OTP_REG_0)) - snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT1, - 0xF0, 0x70); - snd_soc_update_bits(codec, WSA881X_BOOST_PRESET_OUT2, - 0xF0, 0x30); - snd_soc_update_bits(codec, WSA881X_SPKR_DRV_EN, 0x08, 0x08); - snd_soc_update_bits(codec, WSA881X_BOOST_CURRENT_LIMIT, - 0x0F, 0x08); - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x30, 0x30); - snd_soc_update_bits(codec, WSA881X_SPKR_OCP_CTL, 0x0C, 0x00); - snd_soc_update_bits(codec, WSA881X_OTP_REG_28, 0x3F, 0x3A); - snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG1, - 0xFF, 0xB2); - snd_soc_update_bits(codec, WSA881X_BONGO_RESRV_REG2, - 0xFF, 0x05); + snd_soc_component_update_bits(component, WSA881X_CLOCK_CONFIG, + 0x10, 0x10); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0x02, 0x02); + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, + 0xC0, 0x80); + snd_soc_component_update_bits(component, WSA881X_SPKR_MISC_CTL1, + 0x06, 0x06); + snd_soc_component_update_bits(component, WSA881X_SPKR_BIAS_INT, + 0xFF, 0x00); + snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT, + 0xF0, 0x40); + snd_soc_component_update_bits(component, WSA881X_SPKR_PA_INT, + 0x0E, 0x0E); + snd_soc_component_update_bits(component, WSA881X_BOOST_LOOP_STABILITY, + 0x03, 0x03); + snd_soc_component_update_bits(component, WSA881X_BOOST_MISC2_CTL, + 0xFF, 0x14); + snd_soc_component_update_bits(component, WSA881X_BOOST_START_CTL, + 0x80, 0x80); + snd_soc_component_update_bits(component, WSA881X_BOOST_START_CTL, + 0x03, 0x00); + snd_soc_component_update_bits(component, + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + 0x0C, 0x04); + snd_soc_component_update_bits(component, + WSA881X_BOOST_SLOPE_COMP_ISENSE_FB, + 0x03, 0x00); + if (snd_soc_component_read32(component, WSA881X_OTP_REG_0)) + snd_soc_component_update_bits(component, + WSA881X_BOOST_PRESET_OUT1, + 0xF0, 0x70); + snd_soc_component_update_bits(component, WSA881X_BOOST_PRESET_OUT2, + 0xF0, 0x30); + snd_soc_component_update_bits(component, WSA881X_SPKR_DRV_EN, + 0x08, 0x08); + snd_soc_component_update_bits(component, WSA881X_BOOST_CURRENT_LIMIT, + 0x0F, 0x08); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0x30, 0x30); + snd_soc_component_update_bits(component, WSA881X_SPKR_OCP_CTL, + 0x0C, 0x00); + snd_soc_component_update_bits(component, WSA881X_OTP_REG_28, + 0x3F, 0x3A); + snd_soc_component_update_bits(component, WSA881X_BONGO_RESRV_REG1, + 0xFF, 0xB2); + snd_soc_component_update_bits(component, WSA881X_BONGO_RESRV_REG2, + 0xFF, 0x05); } -static int32_t wsa881x_resource_acquire(struct snd_soc_codec *codec, +static int32_t wsa881x_resource_acquire(struct snd_soc_component *component, bool enable) { - wsa881x_clk_ctrl(codec, enable); - wsa881x_bandgap_ctrl(codec, enable); + wsa881x_clk_ctrl(component, enable); + wsa881x_bandgap_ctrl(component, enable); return 0; } -static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec, +static int32_t wsa881x_temp_reg_read(struct snd_soc_component *component, struct wsa_temp_register *wsa_temp_reg) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); struct swr_device *dev; u8 retry = WSA881X_NUM_RETRY; u8 devnum = 0; if (!wsa881x) { - dev_err(codec->dev, "%s: wsa881x is NULL\n", __func__); + dev_err(component->dev, "%s: wsa881x is NULL\n", __func__); return -EINVAL; } dev = wsa881x->swr_slave; @@ -1129,7 +1193,7 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec, usleep_range(1000, 1100); } if (retry == 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s get devnum %d for dev addr %lx failed\n", __func__, devnum, dev->addr); return -EINVAL; @@ -1137,81 +1201,78 @@ static int32_t wsa881x_temp_reg_read(struct snd_soc_codec *codec, } wsa881x_regcache_sync(wsa881x); mutex_lock(&wsa881x->temp_lock); - wsa881x_resource_acquire(codec, ENABLE); + wsa881x_resource_acquire(component, ENABLE); - snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x00); - wsa_temp_reg->dmeas_msb = snd_soc_read(codec, WSA881X_TEMP_MSB); - wsa_temp_reg->dmeas_lsb = snd_soc_read(codec, WSA881X_TEMP_LSB); - snd_soc_update_bits(codec, WSA881X_TADC_VALUE_CTL, 0x01, 0x01); - wsa_temp_reg->d1_msb = snd_soc_read(codec, WSA881X_OTP_REG_1); - wsa_temp_reg->d1_lsb = snd_soc_read(codec, WSA881X_OTP_REG_2); - wsa_temp_reg->d2_msb = snd_soc_read(codec, WSA881X_OTP_REG_3); - wsa_temp_reg->d2_lsb = snd_soc_read(codec, WSA881X_OTP_REG_4); + snd_soc_component_update_bits(component, WSA881X_TADC_VALUE_CTL, + 0x01, 0x00); + wsa_temp_reg->dmeas_msb = snd_soc_component_read32( + component, WSA881X_TEMP_MSB); + wsa_temp_reg->dmeas_lsb = snd_soc_component_read32( + component, WSA881X_TEMP_LSB); + snd_soc_component_update_bits(component, WSA881X_TADC_VALUE_CTL, + 0x01, 0x01); + wsa_temp_reg->d1_msb = snd_soc_component_read32( + component, WSA881X_OTP_REG_1); + wsa_temp_reg->d1_lsb = snd_soc_component_read32( + component, WSA881X_OTP_REG_2); + wsa_temp_reg->d2_msb = snd_soc_component_read32( + component, WSA881X_OTP_REG_3); + wsa_temp_reg->d2_lsb = snd_soc_component_read32( + component, WSA881X_OTP_REG_4); - wsa881x_resource_acquire(codec, DISABLE); + wsa881x_resource_acquire(component, DISABLE); mutex_unlock(&wsa881x->temp_lock); return 0; } -static int wsa881x_probe(struct snd_soc_codec *codec) +static int wsa881x_probe(struct snd_soc_component *component) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); struct swr_device *dev; if (!wsa881x) return -EINVAL; + snd_soc_component_init_regmap(component, wsa881x->regmap); dev = wsa881x->swr_slave; - wsa881x->codec = codec; + wsa881x->component = component; mutex_init(&wsa881x->bg_lock); - wsa881x_init(codec); + wsa881x_init(component); snprintf(wsa881x->tz_pdata.name, sizeof(wsa881x->tz_pdata.name), "%s.%x", "wsatz", (u8)dev->addr); wsa881x->bg_cnt = 0; wsa881x->clk_cnt = 0; - wsa881x->tz_pdata.codec = codec; + wsa881x->tz_pdata.component = component; wsa881x->tz_pdata.wsa_temp_reg_read = wsa881x_temp_reg_read; wsa881x_init_thermal(&wsa881x->tz_pdata); - snd_soc_add_codec_controls(codec, wsa_snd_controls, + snd_soc_add_component_controls(component, wsa_snd_controls, ARRAY_SIZE(wsa_snd_controls)); INIT_DELAYED_WORK(&wsa881x->ocp_ctl_work, wsa881x_ocp_ctl_work); return 0; } -static int wsa881x_remove(struct snd_soc_codec *codec) +static void wsa881x_remove(struct snd_soc_component *component) { - struct wsa881x_priv *wsa881x = snd_soc_codec_get_drvdata(codec); + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(component); if (wsa881x->tz_pdata.tz_dev) wsa881x_deinit_thermal(wsa881x->tz_pdata.tz_dev); mutex_destroy(&wsa881x->bg_lock); - return 0; + return; } -static struct regmap *wsa881x_get_regmap(struct device *dev) -{ - struct wsa881x_priv *control = swr_get_dev_data(to_swr_device(dev)); - - if (!control) - return NULL; - - return control->regmap; -} - -static struct snd_soc_codec_driver soc_codec_dev_wsa881x = { +static const struct snd_soc_component_driver soc_codec_dev_wsa881x = { + .name = DRV_NAME, .probe = wsa881x_probe, .remove = wsa881x_remove, - .get_regmap = wsa881x_get_regmap, - .component_driver = { - .controls = wsa881x_snd_controls, - .num_controls = ARRAY_SIZE(wsa881x_snd_controls), - .dapm_widgets = wsa881x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets), - .dapm_routes = wsa881x_audio_map, - .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), - }, + .controls = wsa881x_snd_controls, + .num_controls = ARRAY_SIZE(wsa881x_snd_controls), + .dapm_widgets = wsa881x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wsa881x_dapm_widgets), + .dapm_routes = wsa881x_audio_map, + .num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map), }; static int wsa881x_gpio_ctrl(struct wsa881x_priv *wsa881x, bool enable) @@ -1361,7 +1422,7 @@ static int wsa881x_swr_probe(struct swr_device *pdev) goto dev_err; } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wsa881x, + ret = snd_soc_register_component(&pdev->dev, &soc_codec_dev_wsa881x, NULL, 0); if (ret) { dev_err(&pdev->dev, "%s: Codec registration failed\n", @@ -1394,7 +1455,7 @@ static int wsa881x_swr_remove(struct swr_device *pdev) debugfs_wsa881x_dent = NULL; mutex_destroy(&wsa881x->res_lock); mutex_destroy(&wsa881x->temp_lock); - snd_soc_unregister_codec(&pdev->dev); + snd_soc_unregister_component(&pdev->dev); if (wsa881x->pd_gpio) gpio_free(wsa881x->pd_gpio); swr_set_dev_data(pdev, NULL); diff --git a/asoc/codecs/wsa881x.h b/asoc/codecs/wsa881x.h index ae30d4bd37..3922fc835d 100644 --- a/asoc/codecs/wsa881x.h +++ b/asoc/codecs/wsa881x.h @@ -13,28 +13,28 @@ #define WSA881X_MAX_SWR_PORTS 4 #if IS_ENABLED(CONFIG_SND_SOC_WSA881X) -extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, - u8 num_port, unsigned int *ch_mask, +extern int wsa881x_set_channel_map(struct snd_soc_component *component, + u8 *port, u8 num_port, unsigned int *ch_mask, unsigned int *ch_rate, u8 *port_type); extern const u8 wsa881x_reg_readable[WSA881X_CACHE_SIZE]; extern struct regmap_config wsa881x_regmap_config; extern int wsa881x_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec); + struct snd_soc_component *component); void wsa881x_regmap_defaults(struct regmap *regmap, u8 version); #else -extern int wsa881x_set_channel_map(struct snd_soc_codec *codec, u8 *port, - u8 num_port, unsigned int *ch_mask, - unsigned int *ch_rate, u8 *port_type); +extern int wsa881x_set_channel_map(struct snd_soc_component *component, + u8 *port, u8 num_port, unsigned int *ch_mask, + unsigned int *ch_rate, u8 *port_type) { return 0; } extern int wsa881x_codec_info_create_codec_entry( struct snd_info_entry *codec_root, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; }