Commit cb67d765 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: bytcr_rt5640: log quirk configuration errors

Now that quirks can be overridden with a module parameter,
log errors so that non-sensical quirks introduced by mistake
are identified.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0b2c9f88
...@@ -57,6 +57,7 @@ enum { ...@@ -57,6 +57,7 @@ enum {
struct byt_rt5640_private { struct byt_rt5640_private {
struct clk *mclk; struct clk *mclk;
}; };
static bool is_bytcr;
static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN; static unsigned long byt_rt5640_quirk = BYT_RT5640_MCLK_EN;
static unsigned int quirk_override; static unsigned int quirk_override;
...@@ -65,30 +66,79 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override"); ...@@ -65,30 +66,79 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");
static void log_quirks(struct device *dev) static void log_quirks(struct device *dev)
{ {
if (BYT_RT5640_MAP(byt_rt5640_quirk) == BYT_RT5640_DMIC1_MAP) int map;
dev_info(dev, "quirk DMIC1_MAP enabled"); bool has_dmic = false;
if (BYT_RT5640_MAP(byt_rt5640_quirk) == BYT_RT5640_DMIC2_MAP) bool has_mclk = false;
dev_info(dev, "quirk DMIC2_MAP enabled"); bool has_ssp0 = false;
if (BYT_RT5640_MAP(byt_rt5640_quirk) == BYT_RT5640_IN1_MAP) bool has_ssp0_aif1 = false;
dev_info(dev, "quirk IN1_MAP enabled"); bool has_ssp0_aif2 = false;
if (BYT_RT5640_MAP(byt_rt5640_quirk) == BYT_RT5640_IN3_MAP) bool has_ssp2_aif2 = false;
dev_info(dev, "quirk IN3_MAP enabled");
if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) map = BYT_RT5640_MAP(byt_rt5640_quirk);
dev_info(dev, "quirk DMIC enabled"); switch (map) {
case BYT_RT5640_DMIC1_MAP:
dev_info(dev, "quirk DMIC1_MAP enabled\n");
has_dmic = true;
break;
case BYT_RT5640_DMIC2_MAP:
dev_info(dev, "quirk DMIC2_MAP enabled\n");
has_dmic = true;
break;
case BYT_RT5640_IN1_MAP:
dev_info(dev, "quirk IN1_MAP enabled\n");
break;
case BYT_RT5640_IN3_MAP:
dev_info(dev, "quirk IN3_MAP enabled\n");
break;
default:
dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map);
break;
}
if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) {
if (has_dmic)
dev_info(dev, "quirk DMIC enabled\n");
else
dev_err(dev, "quirk DMIC enabled but no DMIC input set, will be ignored\n");
}
if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER)
dev_info(dev, "quirk MONO_SPEAKER enabled"); dev_info(dev, "quirk MONO_SPEAKER enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) {
dev_info(dev, "quirk DIFF_MIC enabled"); if (!has_dmic)
if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) dev_info(dev, "quirk DIFF_MIC enabled\n");
dev_info(dev, "quirk SSP2_AIF2 enabled"); else
if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) dev_info(dev, "quirk DIFF_MIC enabled but DMIC input selected, will be ignored\n");
dev_info(dev, "quirk SSP0_AIF1 enabled"); }
if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
dev_info(dev, "quirk SSP0_AIF2 enabled"); dev_info(dev, "quirk SSP0_AIF1 enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) has_ssp0 = true;
dev_info(dev, "quirk MCLK_EN enabled"); has_ssp0_aif1 = true;
if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) }
dev_info(dev, "quirk MCLK_25MHZ enabled"); if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2) {
dev_info(dev, "quirk SSP0_AIF2 enabled\n");
has_ssp0 = true;
has_ssp0_aif2 = true;
}
if (byt_rt5640_quirk & BYT_RT5640_SSP2_AIF2) {
dev_info(dev, "quirk SSP2_AIF2 enabled\n");
has_ssp2_aif2 = true;
}
if (is_bytcr && !has_ssp0)
dev_err(dev, "Invalid routing, bytcr detected but no SSP0-based quirk, audio cannot work with SSP2 on bytcr\n");
if (has_ssp0_aif1 && has_ssp0_aif2)
dev_err(dev, "Invalid routing, SSP0 cannot be connected to both AIF1 and AIF2\n");
if (has_ssp0 && has_ssp2_aif2)
dev_err(dev, "Invalid routing, cannot have both SSP0 and SSP2 connected to codec\n");
if (byt_rt5640_quirk & BYT_RT5640_MCLK_EN) {
dev_info(dev, "quirk MCLK_EN enabled\n");
has_mclk = true;
}
if (byt_rt5640_quirk & BYT_RT5640_MCLK_25MHZ) {
if (has_mclk)
dev_info(dev, "quirk MCLK_25MHZ enabled\n");
else
dev_err(dev, "quirk MCLK_25MHZ enabled but quirk MCLK not selected, will be ignored\n");
}
} }
...@@ -132,7 +182,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, ...@@ -132,7 +182,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w,
ret = clk_prepare_enable(priv->mclk); ret = clk_prepare_enable(priv->mclk);
if (ret < 0) { if (ret < 0) {
dev_err(card->dev, dev_err(card->dev,
"could not configure MCLK state"); "could not configure MCLK state\n");
return ret; return ret;
} }
} }
...@@ -714,8 +764,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ...@@ -714,8 +764,8 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
int i; int i;
int dai_index; int dai_index;
struct byt_rt5640_private *priv; struct byt_rt5640_private *priv;
bool is_bytcr = false;
is_bytcr = false;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_ATOMIC);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment