mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
Merge remote-tracking branches 'asoc/topic/da7219', 'asoc/topic/da732x', 'asoc/topic/da9055' and 'asoc/topic/dmic' into asoc-next
This commit is contained in:
commit
e540808131
@ -25,6 +25,9 @@ Optional properties:
|
||||
interrupt is to be used to wake system, otherwise "irq" should be used.
|
||||
- wakeup-source: Flag to indicate this device can wake system (suspend/resume).
|
||||
|
||||
- #clock-cells : Should be set to '<0>', only one clock source provided;
|
||||
- clock-output-names : Name given for DAI clocks output;
|
||||
|
||||
- clocks : phandle and clock specifier for codec MCLK.
|
||||
- clock-names : Clock name string for 'clocks' attribute, should be "mclk".
|
||||
|
||||
@ -83,6 +86,9 @@ Example:
|
||||
VDDMIC-supply = <®_audio>;
|
||||
VDDIO-supply = <®_audio>;
|
||||
|
||||
#clock-cells = <0>;
|
||||
clock-output-names = "dai-clks";
|
||||
|
||||
clocks = <&clks 201>;
|
||||
clock-names = "mclk";
|
||||
|
||||
|
@ -8,6 +8,7 @@ Required properties:
|
||||
Optional properties:
|
||||
- dmicen-gpios: GPIO specifier for dmic to control start and stop
|
||||
- num-channels: Number of microphones on this DAI
|
||||
- wakeup-delay-ms: Delay (in ms) after enabling the DMIC
|
||||
|
||||
Example node:
|
||||
|
||||
@ -15,4 +16,5 @@ Example node:
|
||||
compatible = "dmic-codec";
|
||||
dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>;
|
||||
num-channels = <1>;
|
||||
wakeup-delay-ms <50>;
|
||||
};
|
||||
|
@ -36,6 +36,8 @@ struct da7219_aad_pdata;
|
||||
struct da7219_pdata {
|
||||
bool wakeup_source;
|
||||
|
||||
const char *dai_clks_name;
|
||||
|
||||
/* Mic */
|
||||
enum da7219_micbias_voltage micbias_lvl;
|
||||
enum da7219_mic_amp_in_sel mic_amp_in_sel;
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clkdev.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/property.h>
|
||||
@ -772,16 +774,27 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
|
||||
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
u8 pll_ctrl, pll_status;
|
||||
int i = 0;
|
||||
int i = 0, ret;
|
||||
bool srm_lock = false;
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
if (da7219->master)
|
||||
if (da7219->master) {
|
||||
/* Enable DAI clks for master mode */
|
||||
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK,
|
||||
DA7219_DAI_CLK_EN_MASK);
|
||||
if (da7219->dai_clks) {
|
||||
ret = clk_prepare_enable(da7219->dai_clks);
|
||||
if (ret) {
|
||||
dev_err(component->dev,
|
||||
"Failed to enable dai_clks\n");
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
snd_soc_component_update_bits(component,
|
||||
DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK,
|
||||
DA7219_DAI_CLK_EN_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
/* PC synchronised to DAI */
|
||||
snd_soc_component_update_bits(component, DA7219_PC_COUNT,
|
||||
@ -814,9 +827,16 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
|
||||
DA7219_PC_FREERUN_MASK);
|
||||
|
||||
/* Disable DAI clks if in master mode */
|
||||
if (da7219->master)
|
||||
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK, 0);
|
||||
if (da7219->master) {
|
||||
if (da7219->dai_clks)
|
||||
clk_disable_unprepare(da7219->dai_clks);
|
||||
else
|
||||
snd_soc_component_update_bits(component,
|
||||
DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK,
|
||||
0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@ -1598,6 +1618,12 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *compone
|
||||
|
||||
pdata->wakeup_source = device_property_read_bool(dev, "wakeup-source");
|
||||
|
||||
pdata->dai_clks_name = "da7219-dai-clks";
|
||||
if (device_property_read_string(dev, "clock-output-names",
|
||||
&pdata->dai_clks_name))
|
||||
dev_warn(dev, "Using default clk name: %s\n",
|
||||
pdata->dai_clks_name);
|
||||
|
||||
if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0)
|
||||
pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32);
|
||||
else
|
||||
@ -1712,6 +1738,88 @@ static int da7219_handle_supplies(struct snd_soc_component *component)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
static int da7219_dai_clks_prepare(struct clk_hw *hw)
|
||||
{
|
||||
struct da7219_priv *da7219 =
|
||||
container_of(hw, struct da7219_priv, dai_clks_hw);
|
||||
struct snd_soc_component *component = da7219->aad->component;
|
||||
|
||||
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK,
|
||||
DA7219_DAI_CLK_EN_MASK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void da7219_dai_clks_unprepare(struct clk_hw *hw)
|
||||
{
|
||||
struct da7219_priv *da7219 =
|
||||
container_of(hw, struct da7219_priv, dai_clks_hw);
|
||||
struct snd_soc_component *component = da7219->aad->component;
|
||||
|
||||
snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE,
|
||||
DA7219_DAI_CLK_EN_MASK, 0);
|
||||
}
|
||||
|
||||
static int da7219_dai_clks_is_prepared(struct clk_hw *hw)
|
||||
{
|
||||
struct da7219_priv *da7219 =
|
||||
container_of(hw, struct da7219_priv, dai_clks_hw);
|
||||
struct snd_soc_component *component = da7219->aad->component;
|
||||
u8 clk_reg;
|
||||
|
||||
clk_reg = snd_soc_component_read32(component, DA7219_DAI_CLK_MODE);
|
||||
|
||||
return !!(clk_reg & DA7219_DAI_CLK_EN_MASK);
|
||||
}
|
||||
|
||||
static const struct clk_ops da7219_dai_clks_ops = {
|
||||
.prepare = da7219_dai_clks_prepare,
|
||||
.unprepare = da7219_dai_clks_unprepare,
|
||||
.is_prepared = da7219_dai_clks_is_prepared,
|
||||
};
|
||||
|
||||
static void da7219_register_dai_clks(struct snd_soc_component *component)
|
||||
{
|
||||
struct device *dev = component->dev;
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
struct da7219_pdata *pdata = da7219->pdata;
|
||||
struct clk_init_data init = {};
|
||||
struct clk *dai_clks;
|
||||
struct clk_lookup *dai_clks_lookup;
|
||||
|
||||
init.parent_names = NULL;
|
||||
init.num_parents = 0;
|
||||
init.name = pdata->dai_clks_name;
|
||||
init.ops = &da7219_dai_clks_ops;
|
||||
da7219->dai_clks_hw.init = &init;
|
||||
|
||||
dai_clks = devm_clk_register(dev, &da7219->dai_clks_hw);
|
||||
if (IS_ERR(dai_clks)) {
|
||||
dev_warn(dev, "Failed to register DAI clocks: %ld\n",
|
||||
PTR_ERR(dai_clks));
|
||||
return;
|
||||
}
|
||||
da7219->dai_clks = dai_clks;
|
||||
|
||||
/* If we're using DT, then register as provider accordingly */
|
||||
if (dev->of_node) {
|
||||
devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
|
||||
&da7219->dai_clks_hw);
|
||||
} else {
|
||||
dai_clks_lookup = clkdev_create(dai_clks, pdata->dai_clks_name,
|
||||
"%s", dev_name(dev));
|
||||
if (!dai_clks_lookup)
|
||||
dev_warn(dev, "Failed to create DAI clkdev");
|
||||
else
|
||||
da7219->dai_clks_lookup = dai_clks_lookup;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void da7219_register_dai_clks(struct snd_soc_component *component) {}
|
||||
#endif /* CONFIG_COMMON_CLK */
|
||||
|
||||
static void da7219_handle_pdata(struct snd_soc_component *component)
|
||||
{
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
@ -1722,6 +1830,8 @@ static void da7219_handle_pdata(struct snd_soc_component *component)
|
||||
|
||||
da7219->wakeup_source = pdata->wakeup_source;
|
||||
|
||||
da7219_register_dai_clks(component);
|
||||
|
||||
/* Mic Bias voltages */
|
||||
switch (pdata->micbias_lvl) {
|
||||
case DA7219_MICBIAS_1_6V:
|
||||
@ -1856,6 +1966,11 @@ static void da7219_remove(struct snd_soc_component *component)
|
||||
|
||||
da7219_aad_exit(component);
|
||||
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
if (da7219->dai_clks_lookup)
|
||||
clkdev_drop(da7219->dai_clks_lookup);
|
||||
#endif
|
||||
|
||||
/* Supplies */
|
||||
regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies);
|
||||
}
|
||||
|
@ -14,6 +14,9 @@
|
||||
#ifndef __DA7219_H
|
||||
#define __DA7219_H
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clkdev.h>
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <sound/da7219.h>
|
||||
@ -813,6 +816,12 @@ struct da7219_priv {
|
||||
struct mutex ctrl_lock;
|
||||
struct mutex pll_lock;
|
||||
|
||||
#ifdef CONFIG_COMMON_CLK
|
||||
struct clk_hw dai_clks_hw;
|
||||
#endif
|
||||
struct clk_lookup *dai_clks_lookup;
|
||||
struct clk *dai_clks;
|
||||
|
||||
struct clk *mclk;
|
||||
unsigned int mclk_rate;
|
||||
int clk_src;
|
||||
|
@ -168,7 +168,7 @@ static const struct reg_default da732x_reg_cache[] = {
|
||||
{ DA732X_REG_UNLOCK , 0x00 },
|
||||
};
|
||||
|
||||
static inline int da732x_get_input_div(struct snd_soc_codec *codec, int sysclk)
|
||||
static inline int da732x_get_input_div(struct snd_soc_component *component, int sysclk)
|
||||
{
|
||||
int val;
|
||||
int ret;
|
||||
@ -192,28 +192,28 @@ static inline int da732x_get_input_div(struct snd_soc_codec *codec, int sysclk)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_PLL_CTRL, val);
|
||||
snd_soc_component_write(component, DA732X_REG_PLL_CTRL, val);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void da732x_set_charge_pump(struct snd_soc_codec *codec, int state)
|
||||
static void da732x_set_charge_pump(struct snd_soc_component *component, int state)
|
||||
{
|
||||
switch (state) {
|
||||
case DA732X_ENABLE_CP:
|
||||
snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_EN);
|
||||
snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_CLK_EN2, DA732X_CP_CLK_EN);
|
||||
snd_soc_component_write(component, DA732X_REG_CP_HP2, DA732X_HP_CP_EN |
|
||||
DA732X_HP_CP_REG | DA732X_HP_CP_PULSESKIP);
|
||||
snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA732X_CP_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_CP_CTRL1, DA732X_CP_EN |
|
||||
DA732X_CP_CTRL_CPVDD1);
|
||||
snd_soc_write(codec, DA732X_REG_CP_CTRL2,
|
||||
snd_soc_component_write(component, DA732X_REG_CP_CTRL2,
|
||||
DA732X_CP_MANAGE_MAGNITUDE | DA732X_CP_BOOST);
|
||||
snd_soc_write(codec, DA732X_REG_CP_CTRL3, DA732X_CP_1MHZ);
|
||||
snd_soc_component_write(component, DA732X_REG_CP_CTRL3, DA732X_CP_1MHZ);
|
||||
break;
|
||||
case DA732X_DISABLE_CP:
|
||||
snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_DIS);
|
||||
snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_DIS);
|
||||
snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA723X_CP_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_CLK_EN2, DA732X_CP_CLK_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_CP_HP2, DA732X_HP_CP_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_CP_CTRL1, DA723X_CP_DIS);
|
||||
break;
|
||||
default:
|
||||
pr_err("Wrong charge pump state\n");
|
||||
@ -331,7 +331,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum,
|
||||
static int da732x_hpf_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 soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value;
|
||||
unsigned int reg = enum_ctrl->reg;
|
||||
unsigned int sel = ucontrol->value.enumerated.item[0];
|
||||
@ -351,7 +351,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, reg, DA732X_HPF_MASK, bits);
|
||||
snd_soc_component_update_bits(component, reg, DA732X_HPF_MASK, bits);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -359,12 +359,12 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol,
|
||||
static int da732x_hpf_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 soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value;
|
||||
unsigned int reg = enum_ctrl->reg;
|
||||
int val;
|
||||
|
||||
val = snd_soc_read(codec, reg) & DA732X_HPF_MASK;
|
||||
val = snd_soc_component_read32(component, reg) & DA732X_HPF_MASK;
|
||||
|
||||
switch (val) {
|
||||
case DA732X_HPF_VOICE_EN:
|
||||
@ -609,18 +609,18 @@ static const struct snd_kcontrol_new da732x_snd_controls[] = {
|
||||
static int da732x_adc_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);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
switch (w->reg) {
|
||||
case DA732X_REG_ADC1_PD:
|
||||
snd_soc_update_bits(codec, DA732X_REG_CLK_EN3,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3,
|
||||
DA732X_ADCA_BB_CLK_EN,
|
||||
DA732X_ADCA_BB_CLK_EN);
|
||||
break;
|
||||
case DA732X_REG_ADC2_PD:
|
||||
snd_soc_update_bits(codec, DA732X_REG_CLK_EN3,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3,
|
||||
DA732X_ADCC_BB_CLK_EN,
|
||||
DA732X_ADCC_BB_CLK_EN);
|
||||
break;
|
||||
@ -628,24 +628,24 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, DA732X_ADC_RST_MASK,
|
||||
DA732X_ADC_SET_ACT);
|
||||
snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, DA732X_ADC_PD_MASK,
|
||||
DA732X_ADC_ON);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, DA732X_ADC_PD_MASK,
|
||||
DA732X_ADC_OFF);
|
||||
snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK,
|
||||
snd_soc_component_update_bits(component, w->reg, DA732X_ADC_RST_MASK,
|
||||
DA732X_ADC_SET_RST);
|
||||
|
||||
switch (w->reg) {
|
||||
case DA732X_REG_ADC1_PD:
|
||||
snd_soc_update_bits(codec, DA732X_REG_CLK_EN3,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3,
|
||||
DA732X_ADCA_BB_CLK_EN, 0);
|
||||
break;
|
||||
case DA732X_REG_ADC2_PD:
|
||||
snd_soc_update_bits(codec, DA732X_REG_CLK_EN3,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3,
|
||||
DA732X_ADCC_BB_CLK_EN, 0);
|
||||
break;
|
||||
default:
|
||||
@ -663,16 +663,16 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w,
|
||||
static int da732x_out_pga_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);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
snd_soc_update_bits(codec, w->reg,
|
||||
snd_soc_component_update_bits(component, w->reg,
|
||||
(1 << w->shift) | DA732X_OUT_HIZ_EN,
|
||||
(1 << w->shift) | DA732X_OUT_HIZ_EN);
|
||||
break;
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
snd_soc_update_bits(codec, w->reg,
|
||||
snd_soc_component_update_bits(component, w->reg,
|
||||
(1 << w->shift) | DA732X_OUT_HIZ_EN,
|
||||
(1 << w->shift) | DA732X_OUT_HIZ_DIS);
|
||||
break;
|
||||
@ -949,7 +949,7 @@ static int da732x_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;
|
||||
u32 aif = 0;
|
||||
u32 reg_aif;
|
||||
u32 fs;
|
||||
@ -1011,15 +1011,15 @@ static int da732x_hw_params(struct snd_pcm_substream *substream,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_update_bits(codec, reg_aif, DA732X_AIF_WORD_MASK, aif);
|
||||
snd_soc_update_bits(codec, DA732X_REG_CLK_CTRL, DA732X_SR1_MASK, fs);
|
||||
snd_soc_component_update_bits(component, reg_aif, DA732X_AIF_WORD_MASK, aif);
|
||||
snd_soc_component_update_bits(component, DA732X_REG_CLK_CTRL, DA732X_SR1_MASK, fs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int da732x_set_dai_fmt(struct snd_soc_dai *dai, u32 fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
u32 aif_mclk, pc_count;
|
||||
u32 reg_aif1, aif1;
|
||||
u32 reg_aif3, aif3;
|
||||
@ -1107,29 +1107,29 @@ static int da732x_set_dai_fmt(struct snd_soc_dai *dai, u32 fmt)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_AIF_MCLK, aif_mclk);
|
||||
snd_soc_update_bits(codec, reg_aif1, DA732X_AIF1_CLK_MASK, aif1);
|
||||
snd_soc_update_bits(codec, reg_aif3, DA732X_AIF_BCLK_INV |
|
||||
snd_soc_component_write(component, DA732X_REG_AIF_MCLK, aif_mclk);
|
||||
snd_soc_component_update_bits(component, reg_aif1, DA732X_AIF1_CLK_MASK, aif1);
|
||||
snd_soc_component_update_bits(component, reg_aif3, DA732X_AIF_BCLK_INV |
|
||||
DA732X_AIF_WCLK_INV | DA732X_AIF_MODE_MASK, aif3);
|
||||
snd_soc_write(codec, DA732X_REG_PC_CTRL, pc_count);
|
||||
snd_soc_component_write(component, DA732X_REG_PC_CTRL, pc_count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id,
|
||||
static int da732x_set_dai_pll(struct snd_soc_component *component, int pll_id,
|
||||
int source, unsigned int freq_in,
|
||||
unsigned int freq_out)
|
||||
{
|
||||
struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec);
|
||||
struct da732x_priv *da732x = snd_soc_component_get_drvdata(component);
|
||||
int fref, indiv;
|
||||
u8 div_lo, div_mid, div_hi;
|
||||
u64 frac_div;
|
||||
|
||||
/* Disable PLL */
|
||||
if (freq_out == 0) {
|
||||
snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL,
|
||||
DA732X_PLL_EN, 0);
|
||||
da732x->pll_en = false;
|
||||
return 0;
|
||||
@ -1147,17 +1147,17 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id,
|
||||
case 24576000:
|
||||
case 45160000:
|
||||
case 49152000:
|
||||
snd_soc_write(codec, DA732X_REG_PLL_CTRL,
|
||||
snd_soc_component_write(component, DA732X_REG_PLL_CTRL,
|
||||
DA732X_PLL_BYPASS);
|
||||
return 0;
|
||||
default:
|
||||
dev_err(codec->dev,
|
||||
dev_err(component->dev,
|
||||
"Cannot use PLL Bypass, invalid SYSCLK rate\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
indiv = da732x_get_input_div(codec, da732x->sysclk);
|
||||
indiv = da732x_get_input_div(component, da732x->sysclk);
|
||||
if (indiv < 0)
|
||||
return indiv;
|
||||
|
||||
@ -1168,11 +1168,11 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id,
|
||||
div_mid = (frac_div >> DA732X_1BYTE_SHIFT) & DA732X_U8_MASK;
|
||||
div_lo = (frac_div) & DA732X_U8_MASK;
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_PLL_DIV_LO, div_lo);
|
||||
snd_soc_write(codec, DA732X_REG_PLL_DIV_MID, div_mid);
|
||||
snd_soc_write(codec, DA732X_REG_PLL_DIV_HI, div_hi);
|
||||
snd_soc_component_write(component, DA732X_REG_PLL_DIV_LO, div_lo);
|
||||
snd_soc_component_write(component, DA732X_REG_PLL_DIV_MID, div_mid);
|
||||
snd_soc_component_write(component, DA732X_REG_PLL_DIV_HI, div_hi);
|
||||
|
||||
snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, DA732X_PLL_EN,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL, DA732X_PLL_EN,
|
||||
DA732X_PLL_EN);
|
||||
|
||||
da732x->pll_en = true;
|
||||
@ -1183,8 +1183,8 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id,
|
||||
static int da732x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
|
||||
unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct da732x_priv *da732x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
da732x->sysclk = freq;
|
||||
|
||||
@ -1268,21 +1268,21 @@ static const struct regmap_config da732x_regmap = {
|
||||
};
|
||||
|
||||
|
||||
static void da732x_dac_offset_adjust(struct snd_soc_codec *codec)
|
||||
static void da732x_dac_offset_adjust(struct snd_soc_component *component)
|
||||
{
|
||||
u8 offset[DA732X_HP_DACS];
|
||||
u8 sign[DA732X_HP_DACS];
|
||||
u8 step = DA732X_DAC_OFFSET_STEP;
|
||||
|
||||
/* Initialize DAC offset calibration circuits and registers */
|
||||
snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET,
|
||||
DA732X_HP_DAC_OFFSET_TRIM_VAL);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET,
|
||||
DA732X_HP_DAC_OFFSET_TRIM_VAL);
|
||||
snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFF_CNTL,
|
||||
DA732X_HP_DAC_OFF_CALIBRATION |
|
||||
DA732X_HP_DAC_OFF_SCALE_STEPS);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFF_CNTL,
|
||||
DA732X_HP_DAC_OFF_CALIBRATION |
|
||||
DA732X_HP_DAC_OFF_SCALE_STEPS);
|
||||
|
||||
@ -1290,9 +1290,9 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec)
|
||||
msleep(DA732X_WAIT_FOR_STABILIZATION);
|
||||
|
||||
/* Check DAC offset sign */
|
||||
sign[DA732X_HPL_DAC] = (snd_soc_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) &
|
||||
sign[DA732X_HPL_DAC] = (snd_soc_component_read32(component, DA732X_REG_HPL_DAC_OFF_CNTL) &
|
||||
DA732X_HP_DAC_OFF_CNTL_COMPO);
|
||||
sign[DA732X_HPR_DAC] = (snd_soc_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) &
|
||||
sign[DA732X_HPR_DAC] = (snd_soc_component_read32(component, DA732X_REG_HPR_DAC_OFF_CNTL) &
|
||||
DA732X_HP_DAC_OFF_CNTL_COMPO);
|
||||
|
||||
/* Binary search DAC offset values (both channels at once) */
|
||||
@ -1302,17 +1302,17 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec)
|
||||
do {
|
||||
offset[DA732X_HPL_DAC] |= step;
|
||||
offset[DA732X_HPR_DAC] |= step;
|
||||
snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET,
|
||||
~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET,
|
||||
~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK);
|
||||
|
||||
msleep(DA732X_WAIT_FOR_STABILIZATION);
|
||||
|
||||
if ((snd_soc_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) &
|
||||
if ((snd_soc_component_read32(component, DA732X_REG_HPL_DAC_OFF_CNTL) &
|
||||
DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPL_DAC])
|
||||
offset[DA732X_HPL_DAC] &= ~step;
|
||||
if ((snd_soc_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) &
|
||||
if ((snd_soc_component_read32(component, DA732X_REG_HPR_DAC_OFF_CNTL) &
|
||||
DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPR_DAC])
|
||||
offset[DA732X_HPR_DAC] &= ~step;
|
||||
|
||||
@ -1320,19 +1320,19 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec)
|
||||
} while (step);
|
||||
|
||||
/* Write final DAC offsets to registers */
|
||||
snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET,
|
||||
~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET,
|
||||
~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK);
|
||||
|
||||
/* End DAC calibration mode */
|
||||
snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFF_CNTL,
|
||||
DA732X_HP_DAC_OFF_SCALE_STEPS);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFF_CNTL,
|
||||
DA732X_HP_DAC_OFF_SCALE_STEPS);
|
||||
}
|
||||
|
||||
static void da732x_output_offset_adjust(struct snd_soc_codec *codec)
|
||||
static void da732x_output_offset_adjust(struct snd_soc_component *component)
|
||||
{
|
||||
u8 offset[DA732X_HP_AMPS];
|
||||
u8 sign[DA732X_HP_AMPS];
|
||||
@ -1342,26 +1342,26 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec)
|
||||
offset[DA732X_HPR_AMP] = DA732X_HP_OUT_TRIM_VAL;
|
||||
|
||||
/* Initialize output offset calibration circuits and registers */
|
||||
snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL);
|
||||
snd_soc_write(codec, DA732X_REG_HPL,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL);
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL);
|
||||
snd_soc_component_write(component, DA732X_REG_HPL,
|
||||
DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN);
|
||||
snd_soc_write(codec, DA732X_REG_HPR,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR,
|
||||
DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN);
|
||||
|
||||
/* Wait for voltage stabilization */
|
||||
msleep(DA732X_WAIT_FOR_STABILIZATION);
|
||||
|
||||
/* Check output offset sign */
|
||||
sign[DA732X_HPL_AMP] = snd_soc_read(codec, DA732X_REG_HPL) &
|
||||
sign[DA732X_HPL_AMP] = snd_soc_component_read32(component, DA732X_REG_HPL) &
|
||||
DA732X_HP_OUT_COMPO;
|
||||
sign[DA732X_HPR_AMP] = snd_soc_read(codec, DA732X_REG_HPR) &
|
||||
sign[DA732X_HPR_AMP] = snd_soc_component_read32(component, DA732X_REG_HPR) &
|
||||
DA732X_HP_OUT_COMPO;
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_COMP |
|
||||
snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_OUT_COMP |
|
||||
(sign[DA732X_HPL_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) |
|
||||
DA732X_HP_OUT_EN);
|
||||
snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_COMP |
|
||||
snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_OUT_COMP |
|
||||
(sign[DA732X_HPR_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) |
|
||||
DA732X_HP_OUT_EN);
|
||||
|
||||
@ -1369,17 +1369,17 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec)
|
||||
do {
|
||||
offset[DA732X_HPL_AMP] |= step;
|
||||
offset[DA732X_HPR_AMP] |= step;
|
||||
snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET,
|
||||
offset[DA732X_HPL_AMP]);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET,
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET,
|
||||
offset[DA732X_HPR_AMP]);
|
||||
|
||||
msleep(DA732X_WAIT_FOR_STABILIZATION);
|
||||
|
||||
if ((snd_soc_read(codec, DA732X_REG_HPL) &
|
||||
if ((snd_soc_component_read32(component, DA732X_REG_HPL) &
|
||||
DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPL_AMP])
|
||||
offset[DA732X_HPL_AMP] &= ~step;
|
||||
if ((snd_soc_read(codec, DA732X_REG_HPR) &
|
||||
if ((snd_soc_component_read32(component, DA732X_REG_HPR) &
|
||||
DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPR_AMP])
|
||||
offset[DA732X_HPR_AMP] &= ~step;
|
||||
|
||||
@ -1387,80 +1387,80 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec)
|
||||
} while (step);
|
||||
|
||||
/* Write final DAC offsets to registers */
|
||||
snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]);
|
||||
snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]);
|
||||
snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]);
|
||||
snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]);
|
||||
}
|
||||
|
||||
static void da732x_hp_dc_offset_cancellation(struct snd_soc_codec *codec)
|
||||
static void da732x_hp_dc_offset_cancellation(struct snd_soc_component *component)
|
||||
{
|
||||
/* Make sure that we have Soft Mute enabled */
|
||||
snd_soc_write(codec, DA732X_REG_DAC1_SOFTMUTE, DA732X_SOFTMUTE_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_DAC1_SOFTMUTE, DA732X_SOFTMUTE_EN |
|
||||
DA732X_GAIN_RAMPED | DA732X_16_SAMPLES);
|
||||
snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACL_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_DAC1_SEL, DA732X_DACL_EN |
|
||||
DA732X_DACR_EN | DA732X_DACL_SDM | DA732X_DACR_SDM |
|
||||
DA732X_DACL_MUTE | DA732X_DACR_MUTE);
|
||||
snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN |
|
||||
DA732X_HP_OUT_MUTE | DA732X_HP_OUT_EN);
|
||||
snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_EN |
|
||||
snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_OUT_EN |
|
||||
DA732X_HP_OUT_MUTE | DA732X_HP_OUT_DAC_EN);
|
||||
|
||||
da732x_dac_offset_adjust(codec);
|
||||
da732x_output_offset_adjust(codec);
|
||||
da732x_dac_offset_adjust(component);
|
||||
da732x_output_offset_adjust(component);
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACS_DIS);
|
||||
snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_DIS);
|
||||
snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_DAC1_SEL, DA732X_DACS_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_DIS);
|
||||
snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_DIS);
|
||||
}
|
||||
|
||||
static int da732x_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int da732x_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec);
|
||||
struct da732x_priv *da732x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (level) {
|
||||
case SND_SOC_BIAS_ON:
|
||||
snd_soc_update_bits(codec, DA732X_REG_BIAS_EN,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN,
|
||||
DA732X_BIAS_BOOST_MASK,
|
||||
DA732X_BIAS_BOOST_100PC);
|
||||
break;
|
||||
case SND_SOC_BIAS_PREPARE:
|
||||
break;
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
/* Init Codec */
|
||||
snd_soc_write(codec, DA732X_REG_REF1,
|
||||
snd_soc_component_write(component, DA732X_REG_REF1,
|
||||
DA732X_VMID_FASTCHG);
|
||||
snd_soc_write(codec, DA732X_REG_BIAS_EN,
|
||||
snd_soc_component_write(component, DA732X_REG_BIAS_EN,
|
||||
DA732X_BIAS_EN);
|
||||
|
||||
mdelay(DA732X_STARTUP_DELAY);
|
||||
|
||||
/* Disable Fast Charge and enable DAC ref voltage */
|
||||
snd_soc_write(codec, DA732X_REG_REF1,
|
||||
snd_soc_component_write(component, DA732X_REG_REF1,
|
||||
DA732X_REFBUFX2_EN);
|
||||
|
||||
/* Enable bypass DSP routing */
|
||||
snd_soc_write(codec, DA732X_REG_DATA_ROUTE,
|
||||
snd_soc_component_write(component, DA732X_REG_DATA_ROUTE,
|
||||
DA732X_BYPASS_DSP);
|
||||
|
||||
/* Enable Digital subsystem */
|
||||
snd_soc_write(codec, DA732X_REG_DSP_CTRL,
|
||||
snd_soc_component_write(component, DA732X_REG_DSP_CTRL,
|
||||
DA732X_DIGITAL_EN);
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_SPARE1_OUT,
|
||||
snd_soc_component_write(component, DA732X_REG_SPARE1_OUT,
|
||||
DA732X_HP_DRIVER_EN |
|
||||
DA732X_HP_GATE_LOW |
|
||||
DA732X_HP_LOOP_GAIN_CTRL);
|
||||
snd_soc_write(codec, DA732X_REG_HP_LIN1_GNDSEL,
|
||||
snd_soc_component_write(component, DA732X_REG_HP_LIN1_GNDSEL,
|
||||
DA732X_HP_OUT_GNDSEL);
|
||||
|
||||
da732x_set_charge_pump(codec, DA732X_ENABLE_CP);
|
||||
da732x_set_charge_pump(component, DA732X_ENABLE_CP);
|
||||
|
||||
snd_soc_write(codec, DA732X_REG_CLK_EN1,
|
||||
snd_soc_component_write(component, DA732X_REG_CLK_EN1,
|
||||
DA732X_SYS3_CLK_EN | DA732X_PC_CLK_EN);
|
||||
|
||||
/* Enable Zero Crossing */
|
||||
snd_soc_write(codec, DA732X_REG_INP_ZC_EN,
|
||||
snd_soc_component_write(component, DA732X_REG_INP_ZC_EN,
|
||||
DA732X_MIC1_PRE_ZC_EN |
|
||||
DA732X_MIC1_ZC_EN |
|
||||
DA732X_MIC2_PRE_ZC_EN |
|
||||
@ -1469,28 +1469,28 @@ static int da732x_set_bias_level(struct snd_soc_codec *codec,
|
||||
DA732X_AUXR_ZC_EN |
|
||||
DA732X_MIC3_PRE_ZC_EN |
|
||||
DA732X_MIC3_ZC_EN);
|
||||
snd_soc_write(codec, DA732X_REG_OUT_ZC_EN,
|
||||
snd_soc_component_write(component, DA732X_REG_OUT_ZC_EN,
|
||||
DA732X_HPL_ZC_EN | DA732X_HPR_ZC_EN |
|
||||
DA732X_LIN2_ZC_EN | DA732X_LIN3_ZC_EN |
|
||||
DA732X_LIN4_ZC_EN);
|
||||
|
||||
da732x_hp_dc_offset_cancellation(codec);
|
||||
da732x_hp_dc_offset_cancellation(component);
|
||||
|
||||
regcache_cache_only(da732x->regmap, false);
|
||||
regcache_sync(da732x->regmap);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, DA732X_REG_BIAS_EN,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN,
|
||||
DA732X_BIAS_BOOST_MASK,
|
||||
DA732X_BIAS_BOOST_50PC);
|
||||
snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL,
|
||||
snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL,
|
||||
DA732X_PLL_EN, 0);
|
||||
da732x->pll_en = false;
|
||||
}
|
||||
break;
|
||||
case SND_SOC_BIAS_OFF:
|
||||
regcache_cache_only(da732x->regmap, true);
|
||||
da732x_set_charge_pump(codec, DA732X_DISABLE_CP);
|
||||
snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, DA732X_BIAS_EN,
|
||||
da732x_set_charge_pump(component, DA732X_DISABLE_CP);
|
||||
snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN, DA732X_BIAS_EN,
|
||||
DA732X_BIAS_DIS);
|
||||
da732x->pll_en = false;
|
||||
break;
|
||||
@ -1499,17 +1499,19 @@ static int da732x_set_bias_level(struct snd_soc_codec *codec,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_da732x = {
|
||||
static const struct snd_soc_component_driver soc_component_dev_da732x = {
|
||||
.set_bias_level = da732x_set_bias_level,
|
||||
.component_driver = {
|
||||
.controls = da732x_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(da732x_snd_controls),
|
||||
.dapm_widgets = da732x_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(da732x_dapm_widgets),
|
||||
.dapm_routes = da732x_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(da732x_dapm_routes),
|
||||
},
|
||||
.controls = da732x_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(da732x_snd_controls),
|
||||
.dapm_widgets = da732x_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(da732x_dapm_widgets),
|
||||
.dapm_routes = da732x_dapm_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(da732x_dapm_routes),
|
||||
.set_pll = da732x_set_dai_pll,
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static int da732x_i2c_probe(struct i2c_client *i2c,
|
||||
@ -1543,10 +1545,11 @@ static int da732x_i2c_probe(struct i2c_client *i2c,
|
||||
(reg & DA732X_ID_MAJOR_MASK) >> 4,
|
||||
(reg & DA732X_ID_MINOR_MASK));
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da732x,
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_da732x,
|
||||
da732x_dai, ARRAY_SIZE(da732x_dai));
|
||||
if (ret != 0)
|
||||
dev_err(&i2c->dev, "Failed to register codec.\n");
|
||||
dev_err(&i2c->dev, "Failed to register component.\n");
|
||||
|
||||
err:
|
||||
return ret;
|
||||
@ -1554,8 +1557,6 @@ err:
|
||||
|
||||
static int da732x_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ static const char * const da9055_hold_time_txt[] = {
|
||||
static SOC_ENUM_SINGLE_DECL(da9055_hold_time,
|
||||
DA9055_ALC_CTRL3, 0, da9055_hold_time_txt);
|
||||
|
||||
static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
|
||||
static int da9055_get_alc_data(struct snd_soc_component *component, u8 reg_val)
|
||||
{
|
||||
int mid_data, top_data;
|
||||
int sum = 0;
|
||||
@ -460,17 +460,17 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
|
||||
for (iteration = 0; iteration < DA9055_ALC_AVG_ITERATIONS;
|
||||
iteration++) {
|
||||
/* Select the left or right channel and capture data */
|
||||
snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val);
|
||||
snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val);
|
||||
|
||||
/* Select middle 8 bits for read back from data register */
|
||||
snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL,
|
||||
snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL,
|
||||
reg_val | DA9055_ALC_DATA_MIDDLE);
|
||||
mid_data = snd_soc_read(codec, DA9055_ALC_CIC_OP_LVL_DATA);
|
||||
mid_data = snd_soc_component_read32(component, DA9055_ALC_CIC_OP_LVL_DATA);
|
||||
|
||||
/* Select top 8 bits for read back from data register */
|
||||
snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL,
|
||||
snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL,
|
||||
reg_val | DA9055_ALC_DATA_TOP);
|
||||
top_data = snd_soc_read(codec, DA9055_ALC_CIC_OP_LVL_DATA);
|
||||
top_data = snd_soc_component_read32(component, DA9055_ALC_CIC_OP_LVL_DATA);
|
||||
|
||||
sum += ((mid_data << 8) | (top_data << 16));
|
||||
}
|
||||
@ -481,7 +481,7 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
|
||||
static int da9055_put_alc_sw(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 reg_val, adc_left, adc_right, mic_left, mic_right;
|
||||
int avg_left_data, avg_right_data, offset_l, offset_r;
|
||||
|
||||
@ -492,31 +492,31 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
|
||||
*/
|
||||
|
||||
/* Save current values from Mic control registers */
|
||||
mic_left = snd_soc_read(codec, DA9055_MIC_L_CTRL);
|
||||
mic_right = snd_soc_read(codec, DA9055_MIC_R_CTRL);
|
||||
mic_left = snd_soc_component_read32(component, DA9055_MIC_L_CTRL);
|
||||
mic_right = snd_soc_component_read32(component, DA9055_MIC_R_CTRL);
|
||||
|
||||
/* Mute Mic PGA Left and Right */
|
||||
snd_soc_update_bits(codec, DA9055_MIC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIC_L_CTRL,
|
||||
DA9055_MIC_L_MUTE_EN, DA9055_MIC_L_MUTE_EN);
|
||||
snd_soc_update_bits(codec, DA9055_MIC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIC_R_CTRL,
|
||||
DA9055_MIC_R_MUTE_EN, DA9055_MIC_R_MUTE_EN);
|
||||
|
||||
/* Save current values from ADC control registers */
|
||||
adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL);
|
||||
adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL);
|
||||
adc_left = snd_soc_component_read32(component, DA9055_ADC_L_CTRL);
|
||||
adc_right = snd_soc_component_read32(component, DA9055_ADC_R_CTRL);
|
||||
|
||||
/* Enable ADC Left and Right */
|
||||
snd_soc_update_bits(codec, DA9055_ADC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_ADC_L_CTRL,
|
||||
DA9055_ADC_L_EN, DA9055_ADC_L_EN);
|
||||
snd_soc_update_bits(codec, DA9055_ADC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_ADC_R_CTRL,
|
||||
DA9055_ADC_R_EN, DA9055_ADC_R_EN);
|
||||
|
||||
/* Calculate average for Left and Right data */
|
||||
/* Left Data */
|
||||
avg_left_data = da9055_get_alc_data(codec,
|
||||
avg_left_data = da9055_get_alc_data(component,
|
||||
DA9055_ALC_CIC_OP_CHANNEL_LEFT);
|
||||
/* Right Data */
|
||||
avg_right_data = da9055_get_alc_data(codec,
|
||||
avg_right_data = da9055_get_alc_data(component,
|
||||
DA9055_ALC_CIC_OP_CHANNEL_RIGHT);
|
||||
|
||||
/* Calculate DC offset */
|
||||
@ -524,22 +524,22 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
|
||||
offset_r = -avg_right_data;
|
||||
|
||||
reg_val = (offset_l & DA9055_ALC_OFFSET_15_8) >> 8;
|
||||
snd_soc_write(codec, DA9055_ALC_OFFSET_OP2M_L, reg_val);
|
||||
snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2M_L, reg_val);
|
||||
reg_val = (offset_l & DA9055_ALC_OFFSET_17_16) >> 16;
|
||||
snd_soc_write(codec, DA9055_ALC_OFFSET_OP2U_L, reg_val);
|
||||
snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2U_L, reg_val);
|
||||
|
||||
reg_val = (offset_r & DA9055_ALC_OFFSET_15_8) >> 8;
|
||||
snd_soc_write(codec, DA9055_ALC_OFFSET_OP2M_R, reg_val);
|
||||
snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2M_R, reg_val);
|
||||
reg_val = (offset_r & DA9055_ALC_OFFSET_17_16) >> 16;
|
||||
snd_soc_write(codec, DA9055_ALC_OFFSET_OP2U_R, reg_val);
|
||||
snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2U_R, reg_val);
|
||||
|
||||
/* Restore original values of ADC control registers */
|
||||
snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left);
|
||||
snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right);
|
||||
snd_soc_component_write(component, DA9055_ADC_L_CTRL, adc_left);
|
||||
snd_soc_component_write(component, DA9055_ADC_R_CTRL, adc_right);
|
||||
|
||||
/* Restore original values of Mic control registers */
|
||||
snd_soc_write(codec, DA9055_MIC_L_CTRL, mic_left);
|
||||
snd_soc_write(codec, DA9055_MIC_R_CTRL, mic_right);
|
||||
snd_soc_component_write(component, DA9055_MIC_L_CTRL, mic_left);
|
||||
snd_soc_component_write(component, DA9055_MIC_R_CTRL, mic_right);
|
||||
}
|
||||
|
||||
return snd_soc_put_volsw(kcontrol, ucontrol);
|
||||
@ -1052,8 +1052,8 @@ static int da9055_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 da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = dai->component;
|
||||
struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component);
|
||||
u8 aif_ctrl, fs;
|
||||
u32 sysclk;
|
||||
|
||||
@ -1075,7 +1075,7 @@ static int da9055_hw_params(struct snd_pcm_substream *substream,
|
||||
}
|
||||
|
||||
/* Set AIF format */
|
||||
snd_soc_update_bits(codec, DA9055_AIF_CTRL, DA9055_AIF_WORD_LENGTH_MASK,
|
||||
snd_soc_component_update_bits(component, DA9055_AIF_CTRL, DA9055_AIF_WORD_LENGTH_MASK,
|
||||
aif_ctrl);
|
||||
|
||||
switch (params_rate(params)) {
|
||||
@ -1125,7 +1125,7 @@ static int da9055_hw_params(struct snd_pcm_substream *substream,
|
||||
|
||||
if (da9055->mclk_rate) {
|
||||
/* PLL Mode, Write actual FS */
|
||||
snd_soc_write(codec, DA9055_SR, fs);
|
||||
snd_soc_component_write(component, DA9055_SR, fs);
|
||||
} else {
|
||||
/*
|
||||
* Non-PLL Mode
|
||||
@ -1134,24 +1134,24 @@ static int da9055_hw_params(struct snd_pcm_substream *substream,
|
||||
* to derive its sys clk. As sys clk has to be 256 * Fs, we
|
||||
* need to write constant sample rate i.e. 48KHz.
|
||||
*/
|
||||
snd_soc_write(codec, DA9055_SR, DA9055_SR_48000);
|
||||
snd_soc_component_write(component, DA9055_SR, DA9055_SR_48000);
|
||||
}
|
||||
|
||||
if (da9055->mclk_rate && (da9055->mclk_rate != sysclk)) {
|
||||
/* PLL Mode */
|
||||
if (!da9055->master) {
|
||||
/* PLL slave mode, enable PLL and also SRM */
|
||||
snd_soc_update_bits(codec, DA9055_PLL_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_PLL_CTRL,
|
||||
DA9055_PLL_EN | DA9055_PLL_SRM_EN,
|
||||
DA9055_PLL_EN | DA9055_PLL_SRM_EN);
|
||||
} else {
|
||||
/* PLL master mode, only enable PLL */
|
||||
snd_soc_update_bits(codec, DA9055_PLL_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_PLL_CTRL,
|
||||
DA9055_PLL_EN, DA9055_PLL_EN);
|
||||
}
|
||||
} else {
|
||||
/* Non PLL Mode, disable PLL */
|
||||
snd_soc_update_bits(codec, DA9055_PLL_CTRL, DA9055_PLL_EN, 0);
|
||||
snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1160,8 +1160,8 @@ static int da9055_hw_params(struct snd_pcm_substream *substream,
|
||||
/* Set DAI mode and Format */
|
||||
static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component);
|
||||
u8 aif_clk_mode, aif_ctrl, mode;
|
||||
|
||||
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
@ -1180,7 +1180,7 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||
}
|
||||
|
||||
/* Don't allow change of mode if PLL is enabled */
|
||||
if ((snd_soc_read(codec, DA9055_PLL_CTRL) & DA9055_PLL_EN) &&
|
||||
if ((snd_soc_component_read32(component, DA9055_PLL_CTRL) & DA9055_PLL_EN) &&
|
||||
(da9055->master != mode))
|
||||
return -EINVAL;
|
||||
|
||||
@ -1207,27 +1207,27 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||
/* By default only 32 BCLK per WCLK is supported */
|
||||
aif_clk_mode |= DA9055_AIF_BCLKS_PER_WCLK_32;
|
||||
|
||||
snd_soc_update_bits(codec, DA9055_AIF_CLK_MODE,
|
||||
snd_soc_component_update_bits(component, DA9055_AIF_CLK_MODE,
|
||||
(DA9055_AIF_CLK_MODE_MASK | DA9055_AIF_BCLK_MASK),
|
||||
aif_clk_mode);
|
||||
snd_soc_update_bits(codec, DA9055_AIF_CTRL, DA9055_AIF_FORMAT_MASK,
|
||||
snd_soc_component_update_bits(component, DA9055_AIF_CTRL, DA9055_AIF_FORMAT_MASK,
|
||||
aif_ctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int da9055_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
struct snd_soc_codec *codec = dai->codec;
|
||||
struct snd_soc_component *component = dai->component;
|
||||
|
||||
if (mute) {
|
||||
snd_soc_update_bits(codec, DA9055_DAC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL,
|
||||
DA9055_DAC_L_MUTE_EN, DA9055_DAC_L_MUTE_EN);
|
||||
snd_soc_update_bits(codec, DA9055_DAC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL,
|
||||
DA9055_DAC_R_MUTE_EN, DA9055_DAC_R_MUTE_EN);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, DA9055_DAC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL,
|
||||
DA9055_DAC_L_MUTE_EN, 0);
|
||||
snd_soc_update_bits(codec, DA9055_DAC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL,
|
||||
DA9055_DAC_R_MUTE_EN, 0);
|
||||
}
|
||||
|
||||
@ -1240,8 +1240,8 @@ static int da9055_mute(struct snd_soc_dai *dai, int mute)
|
||||
static int da9055_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
||||
int clk_id, unsigned int freq, int dir)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (clk_id) {
|
||||
case DA9055_CLKSRC_MCLK:
|
||||
@ -1283,13 +1283,13 @@ static int da9055_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
||||
static int da9055_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
int source, unsigned int fref, unsigned int fout)
|
||||
{
|
||||
struct snd_soc_codec *codec = codec_dai->codec;
|
||||
struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
u8 pll_frac_top, pll_frac_bot, pll_integer, cnt;
|
||||
|
||||
/* Disable PLL before setting the divisors */
|
||||
snd_soc_update_bits(codec, DA9055_PLL_CTRL, DA9055_PLL_EN, 0);
|
||||
snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN, 0);
|
||||
|
||||
/* In slave mode, there is only one set of divisors */
|
||||
if (!da9055->master && (fout != 2822400))
|
||||
@ -1312,9 +1312,9 @@ static int da9055_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
||||
goto pll_err;
|
||||
|
||||
/* Write PLL dividers */
|
||||
snd_soc_write(codec, DA9055_PLL_FRAC_TOP, pll_frac_top);
|
||||
snd_soc_write(codec, DA9055_PLL_FRAC_BOT, pll_frac_bot);
|
||||
snd_soc_write(codec, DA9055_PLL_INTEGER, pll_integer);
|
||||
snd_soc_component_write(component, DA9055_PLL_FRAC_TOP, pll_frac_top);
|
||||
snd_soc_component_write(component, DA9055_PLL_FRAC_BOT, pll_frac_bot);
|
||||
snd_soc_component_write(component, DA9055_PLL_INTEGER, pll_integer);
|
||||
|
||||
return 0;
|
||||
pll_err:
|
||||
@ -1353,7 +1353,7 @@ static struct snd_soc_dai_driver da9055_dai = {
|
||||
.symmetric_rates = 1,
|
||||
};
|
||||
|
||||
static int da9055_set_bias_level(struct snd_soc_codec *codec,
|
||||
static int da9055_set_bias_level(struct snd_soc_component *component,
|
||||
enum snd_soc_bias_level level)
|
||||
{
|
||||
switch (level) {
|
||||
@ -1361,48 +1361,48 @@ static int da9055_set_bias_level(struct snd_soc_codec *codec,
|
||||
case SND_SOC_BIAS_PREPARE:
|
||||
break;
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
|
||||
if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
|
||||
/* Enable VMID reference & master bias */
|
||||
snd_soc_update_bits(codec, DA9055_REFERENCES,
|
||||
snd_soc_component_update_bits(component, DA9055_REFERENCES,
|
||||
DA9055_VMID_EN | DA9055_BIAS_EN,
|
||||
DA9055_VMID_EN | DA9055_BIAS_EN);
|
||||
}
|
||||
break;
|
||||
case SND_SOC_BIAS_OFF:
|
||||
/* Disable VMID reference & master bias */
|
||||
snd_soc_update_bits(codec, DA9055_REFERENCES,
|
||||
snd_soc_component_update_bits(component, DA9055_REFERENCES,
|
||||
DA9055_VMID_EN | DA9055_BIAS_EN, 0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int da9055_probe(struct snd_soc_codec *codec)
|
||||
static int da9055_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec);
|
||||
struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
/* Enable all Gain Ramps */
|
||||
snd_soc_update_bits(codec, DA9055_AUX_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_AUX_L_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_AUX_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_AUX_R_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_L_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_R_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_ADC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_ADC_L_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_ADC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_ADC_R_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_DAC_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_DAC_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_HP_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_HP_L_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_HP_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_HP_R_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
snd_soc_update_bits(codec, DA9055_LINE_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_LINE_CTRL,
|
||||
DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
|
||||
|
||||
/*
|
||||
@ -1412,28 +1412,28 @@ static int da9055_probe(struct snd_soc_codec *codec)
|
||||
* being managed by DAPM while other (non power related) bits are
|
||||
* enabled here
|
||||
*/
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_L_CTRL,
|
||||
DA9055_MIXIN_L_MIX_EN, DA9055_MIXIN_L_MIX_EN);
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_R_CTRL,
|
||||
DA9055_MIXIN_R_MIX_EN, DA9055_MIXIN_R_MIX_EN);
|
||||
|
||||
snd_soc_update_bits(codec, DA9055_MIXOUT_L_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXOUT_L_CTRL,
|
||||
DA9055_MIXOUT_L_MIX_EN, DA9055_MIXOUT_L_MIX_EN);
|
||||
snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXOUT_R_CTRL,
|
||||
DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN);
|
||||
|
||||
/* Set this as per your system configuration */
|
||||
snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ);
|
||||
snd_soc_component_write(component, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ);
|
||||
|
||||
/* Set platform data values */
|
||||
if (da9055->pdata) {
|
||||
/* set mic bias source */
|
||||
if (da9055->pdata->micbias_source) {
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_R_SELECT,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_R_SELECT,
|
||||
DA9055_MICBIAS2_EN,
|
||||
DA9055_MICBIAS2_EN);
|
||||
} else {
|
||||
snd_soc_update_bits(codec, DA9055_MIXIN_R_SELECT,
|
||||
snd_soc_component_update_bits(component, DA9055_MIXIN_R_SELECT,
|
||||
DA9055_MICBIAS2_EN, 0);
|
||||
}
|
||||
/* set mic bias voltage */
|
||||
@ -1442,7 +1442,7 @@ static int da9055_probe(struct snd_soc_codec *codec)
|
||||
case DA9055_MICBIAS_2_1V:
|
||||
case DA9055_MICBIAS_1_8V:
|
||||
case DA9055_MICBIAS_1_6V:
|
||||
snd_soc_update_bits(codec, DA9055_MIC_CONFIG,
|
||||
snd_soc_component_update_bits(component, DA9055_MIC_CONFIG,
|
||||
DA9055_MICBIAS_LEVEL_MASK,
|
||||
(da9055->pdata->micbias) << 4);
|
||||
break;
|
||||
@ -1451,18 +1451,19 @@ static int da9055_probe(struct snd_soc_codec *codec)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_codec_driver soc_codec_dev_da9055 = {
|
||||
static const struct snd_soc_component_driver soc_component_dev_da9055 = {
|
||||
.probe = da9055_probe,
|
||||
.set_bias_level = da9055_set_bias_level,
|
||||
|
||||
.component_driver = {
|
||||
.controls = da9055_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(da9055_snd_controls),
|
||||
.dapm_widgets = da9055_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(da9055_dapm_widgets),
|
||||
.dapm_routes = da9055_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(da9055_audio_map),
|
||||
},
|
||||
.controls = da9055_snd_controls,
|
||||
.num_controls = ARRAY_SIZE(da9055_snd_controls),
|
||||
.dapm_widgets = da9055_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(da9055_dapm_widgets),
|
||||
.dapm_routes = da9055_audio_map,
|
||||
.num_dapm_routes = ARRAY_SIZE(da9055_audio_map),
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static const struct regmap_config da9055_regmap_config = {
|
||||
@ -1499,21 +1500,15 @@ static int da9055_i2c_probe(struct i2c_client *i2c,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_register_codec(&i2c->dev,
|
||||
&soc_codec_dev_da9055, &da9055_dai, 1);
|
||||
ret = devm_snd_soc_register_component(&i2c->dev,
|
||||
&soc_component_dev_da9055, &da9055_dai, 1);
|
||||
if (ret < 0) {
|
||||
dev_err(&i2c->dev, "Failed to register da9055 codec: %d\n",
|
||||
dev_err(&i2c->dev, "Failed to register da9055 component: %d\n",
|
||||
ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int da9055_remove(struct i2c_client *client)
|
||||
{
|
||||
snd_soc_unregister_codec(&client->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* DO NOT change the device Ids. The naming is intentionally specific as both
|
||||
* the CODEC and PMIC parts of this chip are instantiated separately as I2C
|
||||
@ -1540,7 +1535,6 @@ static struct i2c_driver da9055_i2c_driver = {
|
||||
.of_match_table = of_match_ptr(da9055_of_match),
|
||||
},
|
||||
.probe = da9055_i2c_probe,
|
||||
.remove = da9055_remove,
|
||||
.id_table = da9055_i2c_id,
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/platform_device.h>
|
||||
@ -29,34 +30,33 @@
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
|
||||
static int dmic_daiops_trigger(struct snd_pcm_substream *substream,
|
||||
int cmd, struct snd_soc_dai *dai)
|
||||
{
|
||||
struct gpio_desc *dmic_en = snd_soc_dai_get_drvdata(dai);
|
||||
struct dmic {
|
||||
struct gpio_desc *gpio_en;
|
||||
int wakeup_delay;
|
||||
};
|
||||
|
||||
if (!dmic_en)
|
||||
return 0;
|
||||
static int dmic_aif_event(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 dmic *dmic = snd_soc_component_get_drvdata(component);
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
|
||||
gpiod_set_value(dmic_en, 1);
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_POST_PMU:
|
||||
if (dmic->gpio_en)
|
||||
gpiod_set_value(dmic->gpio_en, 1);
|
||||
|
||||
if (dmic->wakeup_delay)
|
||||
msleep(dmic->wakeup_delay);
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
|
||||
gpiod_set_value(dmic_en, 0);
|
||||
case SND_SOC_DAPM_POST_PMD:
|
||||
if (dmic->gpio_en)
|
||||
gpiod_set_value(dmic->gpio_en, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dai_ops dmic_dai_ops = {
|
||||
.trigger = dmic_daiops_trigger,
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_driver dmic_dai = {
|
||||
.name = "dmic-hifi",
|
||||
.capture = {
|
||||
@ -68,26 +68,33 @@ static struct snd_soc_dai_driver dmic_dai = {
|
||||
| SNDRV_PCM_FMTBIT_S24_LE
|
||||
| SNDRV_PCM_FMTBIT_S16_LE,
|
||||
},
|
||||
.ops = &dmic_dai_ops,
|
||||
};
|
||||
|
||||
static int dmic_codec_probe(struct snd_soc_codec *codec)
|
||||
static int dmic_component_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct gpio_desc *dmic_en;
|
||||
struct dmic *dmic;
|
||||
|
||||
dmic_en = devm_gpiod_get_optional(codec->dev,
|
||||
"dmicen", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(dmic_en))
|
||||
return PTR_ERR(dmic_en);
|
||||
dmic = devm_kzalloc(component->dev, sizeof(*dmic), GFP_KERNEL);
|
||||
if (!dmic)
|
||||
return -ENOMEM;
|
||||
|
||||
snd_soc_codec_set_drvdata(codec, dmic_en);
|
||||
dmic->gpio_en = devm_gpiod_get_optional(component->dev,
|
||||
"dmicen", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(dmic->gpio_en))
|
||||
return PTR_ERR(dmic->gpio_en);
|
||||
|
||||
device_property_read_u32(component->dev, "wakeup-delay-ms",
|
||||
&dmic->wakeup_delay);
|
||||
|
||||
snd_soc_component_set_drvdata(component, dmic);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = {
|
||||
SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0,
|
||||
SND_SOC_NOPM, 0, 0),
|
||||
SND_SOC_DAPM_AIF_OUT_E("DMIC AIF", "Capture", 0,
|
||||
SND_SOC_NOPM, 0, 0, dmic_aif_event,
|
||||
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
|
||||
SND_SOC_DAPM_INPUT("DMic"),
|
||||
};
|
||||
|
||||
@ -95,14 +102,16 @@ static const struct snd_soc_dapm_route intercon[] = {
|
||||
{"DMIC AIF", NULL, "DMic"},
|
||||
};
|
||||
|
||||
static const struct snd_soc_codec_driver soc_dmic = {
|
||||
.probe = dmic_codec_probe,
|
||||
.component_driver = {
|
||||
.dapm_widgets = dmic_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets),
|
||||
.dapm_routes = intercon,
|
||||
.num_dapm_routes = ARRAY_SIZE(intercon),
|
||||
},
|
||||
static const struct snd_soc_component_driver soc_dmic = {
|
||||
.probe = dmic_component_probe,
|
||||
.dapm_widgets = dmic_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets),
|
||||
.dapm_routes = intercon,
|
||||
.num_dapm_routes = ARRAY_SIZE(intercon),
|
||||
.idle_bias_on = 1,
|
||||
.use_pmdown_time = 1,
|
||||
.endianness = 1,
|
||||
.non_legacy_dai_naming = 1,
|
||||
};
|
||||
|
||||
static int dmic_dev_probe(struct platform_device *pdev)
|
||||
@ -129,16 +138,10 @@ static int dmic_dev_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
return snd_soc_register_codec(&pdev->dev,
|
||||
return devm_snd_soc_register_component(&pdev->dev,
|
||||
&soc_dmic, dai_drv, 1);
|
||||
}
|
||||
|
||||
static int dmic_dev_remove(struct platform_device *pdev)
|
||||
{
|
||||
snd_soc_unregister_codec(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MODULE_ALIAS("platform:dmic-codec");
|
||||
|
||||
static const struct of_device_id dmic_dev_match[] = {
|
||||
@ -152,7 +155,6 @@ static struct platform_driver dmic_driver = {
|
||||
.of_match_table = dmic_dev_match,
|
||||
},
|
||||
.probe = dmic_dev_probe,
|
||||
.remove = dmic_dev_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(dmic_driver);
|
||||
|
Loading…
Reference in New Issue
Block a user