Commit c4ba51ba authored by Fang, Yang A's avatar Fang, Yang A Committed by Mark Brown

ASoC: Intel: Support rt5650 codec for Cherrytrail & Braswell

rt5650 and rt5645 are similar codec so reuse the cht_bsw_rt5645 driver
Signed-off-by: default avatarFang, Yang A <yang.a.fang@intel.com>
Acked-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 17119a46
...@@ -112,14 +112,14 @@ config SND_SOC_INTEL_CHT_BSW_RT5672_MACH ...@@ -112,14 +112,14 @@ config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
If unsure select "N". If unsure select "N".
config SND_SOC_INTEL_CHT_BSW_RT5645_MACH config SND_SOC_INTEL_CHT_BSW_RT5645_MACH
tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5645 codec" tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5645/5650 codec"
depends on X86_INTEL_LPSS depends on X86_INTEL_LPSS
select SND_SOC_RT5645 select SND_SOC_RT5645
select SND_SST_MFLD_PLATFORM select SND_SST_MFLD_PLATFORM
select SND_SST_IPC_ACPI select SND_SST_IPC_ACPI
help help
This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
platforms with RT5645 audio codec. platforms with RT5645/5650 audio codec.
If unsure select "N". If unsure select "N".
config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/acpi.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -33,9 +34,16 @@ ...@@ -33,9 +34,16 @@
#define CHT_PLAT_CLK_3_HZ 19200000 #define CHT_PLAT_CLK_3_HZ 19200000
#define CHT_CODEC_DAI "rt5645-aif1" #define CHT_CODEC_DAI "rt5645-aif1"
struct cht_acpi_card {
char *codec_id;
int codec_type;
struct snd_soc_card *soc_card;
};
struct cht_mc_private { struct cht_mc_private {
struct snd_soc_jack hp_jack; struct snd_soc_jack hp_jack;
struct snd_soc_jack mic_jack; struct snd_soc_jack mic_jack;
struct cht_acpi_card *acpi_card;
}; };
static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card) static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
...@@ -94,7 +102,7 @@ static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { ...@@ -94,7 +102,7 @@ static const struct snd_soc_dapm_widget cht_dapm_widgets[] = {
platform_clock_control, SND_SOC_DAPM_POST_PMD), platform_clock_control, SND_SOC_DAPM_POST_PMD),
}; };
static const struct snd_soc_dapm_route cht_audio_map[] = { static const struct snd_soc_dapm_route cht_rt5645_audio_map[] = {
{"IN1P", NULL, "Headset Mic"}, {"IN1P", NULL, "Headset Mic"},
{"IN1N", NULL, "Headset Mic"}, {"IN1N", NULL, "Headset Mic"},
{"DMIC L1", NULL, "Int Mic"}, {"DMIC L1", NULL, "Int Mic"},
...@@ -115,6 +123,27 @@ static const struct snd_soc_dapm_route cht_audio_map[] = { ...@@ -115,6 +123,27 @@ static const struct snd_soc_dapm_route cht_audio_map[] = {
{"Ext Spk", NULL, "Platform Clock"}, {"Ext Spk", NULL, "Platform Clock"},
}; };
static const struct snd_soc_dapm_route cht_rt5650_audio_map[] = {
{"IN1P", NULL, "Headset Mic"},
{"IN1N", NULL, "Headset Mic"},
{"DMIC L2", NULL, "Int Mic"},
{"DMIC R2", NULL, "Int Mic"},
{"Headphone", NULL, "HPOL"},
{"Headphone", NULL, "HPOR"},
{"Ext Spk", NULL, "SPOL"},
{"Ext Spk", NULL, "SPOR"},
{"AIF1 Playback", NULL, "ssp2 Tx"},
{"ssp2 Tx", NULL, "codec_out0"},
{"ssp2 Tx", NULL, "codec_out1"},
{"codec_in0", NULL, "ssp2 Rx" },
{"codec_in1", NULL, "ssp2 Rx" },
{"ssp2 Rx", NULL, "AIF1 Capture"},
{"Headphone", NULL, "Platform Clock"},
{"Headset Mic", NULL, "Platform Clock"},
{"Int Mic", NULL, "Platform Clock"},
{"Ext Spk", NULL, "Platform Clock"},
};
static const struct snd_kcontrol_new cht_mc_controls[] = { static const struct snd_kcontrol_new cht_mc_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headphone"),
SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Headset Mic"),
...@@ -239,7 +268,7 @@ static struct snd_soc_dai_link cht_dailink[] = { ...@@ -239,7 +268,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
.codec_dai_name = "snd-soc-dummy-dai", .codec_dai_name = "snd-soc-dummy-dai",
.codec_name = "snd-soc-dummy", .codec_name = "snd-soc-dummy",
.platform_name = "sst-mfld-platform", .platform_name = "sst-mfld-platform",
.ignore_suspend = 1, .nonatomic = true,
.dynamic = 1, .dynamic = 1,
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
...@@ -267,7 +296,7 @@ static struct snd_soc_dai_link cht_dailink[] = { ...@@ -267,7 +296,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
| SND_SOC_DAIFMT_CBS_CFS, | SND_SOC_DAIFMT_CBS_CFS,
.init = cht_codec_init, .init = cht_codec_init,
.be_hw_params_fixup = cht_codec_fixup, .be_hw_params_fixup = cht_codec_fixup,
.ignore_suspend = 1, .nonatomic = true,
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
.ops = &cht_be_ssp2_ops, .ops = &cht_be_ssp2_ops,
...@@ -275,43 +304,85 @@ static struct snd_soc_dai_link cht_dailink[] = { ...@@ -275,43 +304,85 @@ static struct snd_soc_dai_link cht_dailink[] = {
}; };
/* SoC card */ /* SoC card */
static struct snd_soc_card snd_soc_card_cht = { static struct snd_soc_card snd_soc_card_chtrt5645 = {
.name = "chtrt5645", .name = "chtrt5645",
.dai_link = cht_dailink, .dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink), .num_links = ARRAY_SIZE(cht_dailink),
.dapm_widgets = cht_dapm_widgets, .dapm_widgets = cht_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets),
.dapm_routes = cht_audio_map, .dapm_routes = cht_rt5645_audio_map,
.num_dapm_routes = ARRAY_SIZE(cht_audio_map), .num_dapm_routes = ARRAY_SIZE(cht_rt5645_audio_map),
.controls = cht_mc_controls, .controls = cht_mc_controls,
.num_controls = ARRAY_SIZE(cht_mc_controls), .num_controls = ARRAY_SIZE(cht_mc_controls),
}; };
static struct snd_soc_card snd_soc_card_chtrt5650 = {
.name = "chtrt5650",
.dai_link = cht_dailink,
.num_links = ARRAY_SIZE(cht_dailink),
.dapm_widgets = cht_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets),
.dapm_routes = cht_rt5650_audio_map,
.num_dapm_routes = ARRAY_SIZE(cht_rt5650_audio_map),
.controls = cht_mc_controls,
.num_controls = ARRAY_SIZE(cht_mc_controls),
};
static struct cht_acpi_card snd_soc_cards[] = {
{"10EC5645", CODEC_TYPE_RT5645, &snd_soc_card_chtrt5645},
{"10EC5650", CODEC_TYPE_RT5650, &snd_soc_card_chtrt5650},
};
static acpi_status snd_acpi_codec_match(acpi_handle handle, u32 level,
void *context, void **ret)
{
*(bool *)context = true;
return AE_OK;
}
static int snd_cht_mc_probe(struct platform_device *pdev) static int snd_cht_mc_probe(struct platform_device *pdev)
{ {
int ret_val = 0; int ret_val = 0;
int i;
struct cht_mc_private *drv; struct cht_mc_private *drv;
struct snd_soc_card *card = snd_soc_cards[0].soc_card;
bool found = false;
char codec_name[16];
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC);
if (!drv) if (!drv)
return -ENOMEM; return -ENOMEM;
snd_soc_card_cht.dev = &pdev->dev; for (i = 0; i < ARRAY_SIZE(snd_soc_cards); i++) {
snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); if (ACPI_SUCCESS(acpi_get_devices(
ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); snd_soc_cards[i].codec_id,
snd_acpi_codec_match,
&found, NULL)) && found) {
dev_dbg(&pdev->dev,
"found codec %s\n", snd_soc_cards[i].codec_id);
card = snd_soc_cards[i].soc_card;
drv->acpi_card = &snd_soc_cards[i];
break;
}
}
card->dev = &pdev->dev;
sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
/* set correct codec name */
strcpy((char *)card->dai_link[2].codec_name, codec_name);
snd_soc_card_set_drvdata(card, drv);
ret_val = devm_snd_soc_register_card(&pdev->dev, card);
if (ret_val) { if (ret_val) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"snd_soc_register_card failed %d\n", ret_val); "snd_soc_register_card failed %d\n", ret_val);
return ret_val; return ret_val;
} }
platform_set_drvdata(pdev, &snd_soc_card_cht); platform_set_drvdata(pdev, card);
return ret_val; return ret_val;
} }
static struct platform_driver snd_cht_mc_driver = { static struct platform_driver snd_cht_mc_driver = {
.driver = { .driver = {
.name = "cht-bsw-rt5645", .name = "cht-bsw-rt5645",
.pm = &snd_soc_pm_ops,
}, },
.probe = snd_cht_mc_probe, .probe = snd_cht_mc_probe,
}; };
......
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