I2S driver changes for Jadeite platform
Merge series from Vijendar Mukunda <Vijendar.Mukunda@amd.com>: Jadeite(JD) platform is Stoney APU varaint which uses I2S MICSP instance and ES8336 Codec. This patch series creates I2S platform devices for JD platform, adds I2S MICSP instance support and Machine driver support
This commit is contained in:
commit
676c6cc50d
|
@ -23,6 +23,19 @@ config SND_SOC_AMD_CZ_RT5645_MACH
|
||||||
help
|
help
|
||||||
This option enables machine driver for rt5645.
|
This option enables machine driver for rt5645.
|
||||||
|
|
||||||
|
config SND_SOC_AMD_ST_ES8336_MACH
|
||||||
|
tristate "AMD ST support for ES8336"
|
||||||
|
select SND_SOC_ACPI
|
||||||
|
select SND_SOC_ES8316
|
||||||
|
depends on SND_SOC_AMD_ACP
|
||||||
|
depends on ACPI || COMPILE_TEST
|
||||||
|
depends on I2C || COMPILE_TEST
|
||||||
|
help
|
||||||
|
This option enables machine driver for Jadeite platform
|
||||||
|
using es8336 codec.
|
||||||
|
Say m if you have such a device.
|
||||||
|
If unsure select "N".
|
||||||
|
|
||||||
config SND_SOC_AMD_ACP3x
|
config SND_SOC_AMD_ACP3x
|
||||||
tristate "AMD Audio Coprocessor-v3.x support"
|
tristate "AMD Audio Coprocessor-v3.x support"
|
||||||
depends on X86 && PCI
|
depends on X86 && PCI
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
acp_audio_dma-objs := acp-pcm-dma.o
|
acp_audio_dma-objs := acp-pcm-dma.o
|
||||||
snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o
|
snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o
|
||||||
snd-soc-acp-rt5645-mach-objs := acp-rt5645.o
|
snd-soc-acp-rt5645-mach-objs := acp-rt5645.o
|
||||||
|
snd-soc-acp-es8336-mach-objs := acp-es8336.o
|
||||||
snd-soc-acp-rt5682-mach-objs := acp3x-rt5682-max9836.o
|
snd-soc-acp-rt5682-mach-objs := acp3x-rt5682-max9836.o
|
||||||
snd-acp-config-objs := acp-config.o
|
snd-acp-config-objs := acp-config.o
|
||||||
|
|
||||||
obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o
|
obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o
|
||||||
obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += snd-soc-acp-da7219mx98357-mach.o
|
obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += snd-soc-acp-da7219mx98357-mach.o
|
||||||
obj-$(CONFIG_SND_SOC_AMD_CZ_RT5645_MACH) += snd-soc-acp-rt5645-mach.o
|
obj-$(CONFIG_SND_SOC_AMD_CZ_RT5645_MACH) += snd-soc-acp-rt5645-mach.o
|
||||||
|
obj-$(CONFIG_SND_SOC_AMD_ST_ES8336_MACH) += snd-soc-acp-es8336-mach.o
|
||||||
obj-$(CONFIG_SND_SOC_AMD_ACP3x) += raven/
|
obj-$(CONFIG_SND_SOC_AMD_ACP3x) += raven/
|
||||||
obj-$(CONFIG_SND_SOC_AMD_RV_RT5682_MACH) += snd-soc-acp-rt5682-mach.o
|
obj-$(CONFIG_SND_SOC_AMD_RV_RT5682_MACH) += snd-soc-acp-rt5682-mach.o
|
||||||
obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/
|
obj-$(CONFIG_SND_SOC_AMD_RENOIR) += renoir/
|
||||||
|
|
|
@ -0,0 +1,324 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Machine driver for AMD Stoney platform using ES8336 Codec
|
||||||
|
*
|
||||||
|
* Copyright 2022 Advanced Micro Devices, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sound/core.h>
|
||||||
|
#include <sound/soc.h>
|
||||||
|
#include <sound/pcm.h>
|
||||||
|
#include <sound/pcm_params.h>
|
||||||
|
#include <sound/soc-dapm.h>
|
||||||
|
#include <sound/jack.h>
|
||||||
|
#include <linux/gpio.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
#include <linux/dmi.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
|
#include <linux/gpio/machine.h>
|
||||||
|
#include <linux/i2c.h>
|
||||||
|
#include <linux/input.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/acpi.h>
|
||||||
|
|
||||||
|
#include "../codecs/es8316.h"
|
||||||
|
#include "acp.h"
|
||||||
|
|
||||||
|
#define DUAL_CHANNEL 2
|
||||||
|
#define DRV_NAME "acp2x_mach"
|
||||||
|
#define ST_JADEITE 1
|
||||||
|
#define ES8336_PLL_FREQ (48000 * 256)
|
||||||
|
|
||||||
|
static unsigned long acp2x_machine_id;
|
||||||
|
static struct snd_soc_jack st_jack;
|
||||||
|
struct device *codec_dev;
|
||||||
|
struct gpio_desc *gpio_pa;
|
||||||
|
|
||||||
|
static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
|
||||||
|
struct snd_kcontrol *kcontrol, int event)
|
||||||
|
{
|
||||||
|
if (SND_SOC_DAPM_EVENT_ON(event))
|
||||||
|
gpiod_set_value_cansleep(gpio_pa, true);
|
||||||
|
else
|
||||||
|
gpiod_set_value_cansleep(gpio_pa, false);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct snd_soc_jack_pin st_es8316_jack_pins[] = {
|
||||||
|
{
|
||||||
|
.pin = "Headphone",
|
||||||
|
.mask = SND_JACK_HEADPHONE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.pin = "Headset Mic",
|
||||||
|
.mask = SND_JACK_MICROPHONE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int st_es8336_init(struct snd_soc_pcm_runtime *rtd)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct snd_soc_card *card;
|
||||||
|
struct snd_soc_component *codec;
|
||||||
|
|
||||||
|
codec = asoc_rtd_to_codec(rtd, 0)->component;
|
||||||
|
card = rtd->card;
|
||||||
|
|
||||||
|
ret = snd_soc_card_jack_new_pins(card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0,
|
||||||
|
&st_jack, st_es8316_jack_pins,
|
||||||
|
ARRAY_SIZE(st_es8316_jack_pins));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(card->dev, "HP jack creation failed %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
snd_jack_set_key(st_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
|
||||||
|
ret = snd_soc_component_set_jack(codec, &st_jack, NULL);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const unsigned int st_channels[] = {
|
||||||
|
DUAL_CHANNEL,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned int st_rates[] = {
|
||||||
|
48000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_pcm_hw_constraint_list st_constraints_rates = {
|
||||||
|
.count = ARRAY_SIZE(st_rates),
|
||||||
|
.list = st_rates,
|
||||||
|
.mask = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_pcm_hw_constraint_list st_constraints_channels = {
|
||||||
|
.count = ARRAY_SIZE(st_channels),
|
||||||
|
.list = st_channels,
|
||||||
|
.mask = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int st_es8336_codec_startup(struct snd_pcm_substream *substream)
|
||||||
|
{
|
||||||
|
struct snd_pcm_runtime *runtime;
|
||||||
|
struct snd_soc_pcm_runtime *rtd;
|
||||||
|
struct snd_soc_card *card;
|
||||||
|
struct acp_platform_info *machine;
|
||||||
|
struct snd_soc_dai *codec_dai;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
runtime = substream->runtime;
|
||||||
|
rtd = asoc_substream_to_rtd(substream);
|
||||||
|
card = rtd->card;
|
||||||
|
machine = snd_soc_card_get_drvdata(card);
|
||||||
|
codec_dai = asoc_rtd_to_codec(rtd, 0);
|
||||||
|
ret = snd_soc_dai_set_sysclk(codec_dai, 0, ES8336_PLL_FREQ, SND_SOC_CLOCK_IN);
|
||||||
|
if (ret < 0) {
|
||||||
|
dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
runtime->hw.channels_max = DUAL_CHANNEL;
|
||||||
|
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
|
||||||
|
&st_constraints_channels);
|
||||||
|
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
|
||||||
|
&st_constraints_rates);
|
||||||
|
|
||||||
|
machine->play_i2s_instance = I2S_MICSP_INSTANCE;
|
||||||
|
machine->cap_i2s_instance = I2S_MICSP_INSTANCE;
|
||||||
|
machine->capture_channel = CAP_CHANNEL0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct snd_soc_ops st_es8336_ops = {
|
||||||
|
.startup = st_es8336_codec_startup,
|
||||||
|
};
|
||||||
|
|
||||||
|
SND_SOC_DAILINK_DEF(designware1,
|
||||||
|
DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.2.auto")));
|
||||||
|
SND_SOC_DAILINK_DEF(codec,
|
||||||
|
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8336:00", "ES8316 HiFi")));
|
||||||
|
SND_SOC_DAILINK_DEF(platform,
|
||||||
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_audio_dma.1.auto")));
|
||||||
|
|
||||||
|
static struct snd_soc_dai_link st_dai_es8336[] = {
|
||||||
|
{
|
||||||
|
.name = "amdes8336",
|
||||||
|
.stream_name = "ES8336 HiFi Play",
|
||||||
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
|
||||||
|
| SND_SOC_DAIFMT_CBP_CFP,
|
||||||
|
.stop_dma_first = 1,
|
||||||
|
.dpcm_capture = 1,
|
||||||
|
.dpcm_playback = 1,
|
||||||
|
.init = st_es8336_init,
|
||||||
|
.ops = &st_es8336_ops,
|
||||||
|
SND_SOC_DAILINK_REG(designware1, codec, platform),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_widget st_widgets[] = {
|
||||||
|
SND_SOC_DAPM_SPK("Speaker", NULL),
|
||||||
|
SND_SOC_DAPM_HP("Headphone", NULL),
|
||||||
|
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||||
|
SND_SOC_DAPM_MIC("Internal Mic", NULL),
|
||||||
|
|
||||||
|
SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
|
||||||
|
sof_es8316_speaker_power_event,
|
||||||
|
SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_route st_audio_route[] = {
|
||||||
|
{"Speaker", NULL, "HPOL"},
|
||||||
|
{"Speaker", NULL, "HPOR"},
|
||||||
|
{"Headphone", NULL, "HPOL"},
|
||||||
|
{"Headphone", NULL, "HPOR"},
|
||||||
|
{"MIC1", NULL, "Headset Mic"},
|
||||||
|
{"MIC2", NULL, "Internal Mic"},
|
||||||
|
{"Speaker", NULL, "Speaker Power"},
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new st_mc_controls[] = {
|
||||||
|
SOC_DAPM_PIN_SWITCH("Speaker"),
|
||||||
|
SOC_DAPM_PIN_SWITCH("Headphone"),
|
||||||
|
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||||
|
SOC_DAPM_PIN_SWITCH("Internal Mic"),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct acpi_gpio_params pa_enable_gpio = { 0, 0, false };
|
||||||
|
static const struct acpi_gpio_mapping acpi_es8336_gpios[] = {
|
||||||
|
{ "pa-enable-gpios", &pa_enable_gpio, 1 },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
static int st_es8336_late_probe(struct snd_soc_card *card)
|
||||||
|
{
|
||||||
|
struct acpi_device *adev;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
adev = acpi_dev_get_first_match_dev("ESSX8336", NULL, -1);
|
||||||
|
if (adev)
|
||||||
|
put_device(&adev->dev);
|
||||||
|
codec_dev = acpi_get_first_physical_node(adev);
|
||||||
|
if (!codec_dev)
|
||||||
|
dev_err(card->dev, "can not find codec dev\n");
|
||||||
|
|
||||||
|
ret = devm_acpi_dev_add_driver_gpios(codec_dev, acpi_es8336_gpios);
|
||||||
|
|
||||||
|
gpio_pa = gpiod_get_optional(codec_dev, "pa-enable", GPIOD_OUT_LOW);
|
||||||
|
if (IS_ERR(gpio_pa)) {
|
||||||
|
ret = dev_err_probe(card->dev, PTR_ERR(gpio_pa),
|
||||||
|
"could not get pa-enable GPIO\n");
|
||||||
|
gpiod_put(gpio_pa);
|
||||||
|
put_device(codec_dev);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct snd_soc_card st_card = {
|
||||||
|
.name = "acpes8336",
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.dai_link = st_dai_es8336,
|
||||||
|
.num_links = ARRAY_SIZE(st_dai_es8336),
|
||||||
|
.dapm_widgets = st_widgets,
|
||||||
|
.num_dapm_widgets = ARRAY_SIZE(st_widgets),
|
||||||
|
.dapm_routes = st_audio_route,
|
||||||
|
.num_dapm_routes = ARRAY_SIZE(st_audio_route),
|
||||||
|
.controls = st_mc_controls,
|
||||||
|
.num_controls = ARRAY_SIZE(st_mc_controls),
|
||||||
|
.late_probe = st_es8336_late_probe,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int st_es8336_quirk_cb(const struct dmi_system_id *id)
|
||||||
|
{
|
||||||
|
acp2x_machine_id = ST_JADEITE;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct dmi_system_id st_es8336_quirk_table[] = {
|
||||||
|
{
|
||||||
|
.callback = st_es8336_quirk_cb,
|
||||||
|
.matches = {
|
||||||
|
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMD"),
|
||||||
|
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Jadeite"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.callback = st_es8336_quirk_cb,
|
||||||
|
.matches = {
|
||||||
|
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "IP3 Technology CO.,Ltd."),
|
||||||
|
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ASN1D"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.callback = st_es8336_quirk_cb,
|
||||||
|
.matches = {
|
||||||
|
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Standard"),
|
||||||
|
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ASN10"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int st_es8336_probe(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct snd_soc_card *card;
|
||||||
|
struct acp_platform_info *machine;
|
||||||
|
|
||||||
|
machine = devm_kzalloc(&pdev->dev, sizeof(struct acp_platform_info), GFP_KERNEL);
|
||||||
|
if (!machine)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
dmi_check_system(st_es8336_quirk_table);
|
||||||
|
switch (acp2x_machine_id) {
|
||||||
|
case ST_JADEITE:
|
||||||
|
card = &st_card;
|
||||||
|
st_card.dev = &pdev->dev;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, card);
|
||||||
|
snd_soc_card_set_drvdata(card, machine);
|
||||||
|
ret = devm_snd_soc_register_card(&pdev->dev, &st_card);
|
||||||
|
if (ret) {
|
||||||
|
return dev_err_probe(&pdev->dev, ret,
|
||||||
|
"devm_snd_soc_register_card(%s) failed\n",
|
||||||
|
card->name);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int st_es8336_remove(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_ACPI
|
||||||
|
static const struct acpi_device_id st_audio_acpi_match[] = {
|
||||||
|
{"AMDI8336", 0},
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(acpi, st_audio_acpi_match);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static struct platform_driver st_mach_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "st-es8316",
|
||||||
|
.acpi_match_table = ACPI_PTR(st_audio_acpi_match),
|
||||||
|
.pm = &snd_soc_pm_ops,
|
||||||
|
},
|
||||||
|
.probe = st_es8336_probe,
|
||||||
|
.remove = st_es8336_remove,
|
||||||
|
};
|
||||||
|
|
||||||
|
module_platform_driver(st_mach_driver);
|
||||||
|
|
||||||
|
MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
|
||||||
|
MODULE_DESCRIPTION("st-es8316 audio support");
|
||||||
|
MODULE_LICENSE("GPL v2");
|
|
@ -433,6 +433,7 @@ static void acp_dma_start(void __iomem *acp_mmio, u16 ch_num, bool is_circular)
|
||||||
case I2S_TO_ACP_DMA_CH_NUM:
|
case I2S_TO_ACP_DMA_CH_NUM:
|
||||||
case ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM:
|
case ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM:
|
||||||
case I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM:
|
case I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM:
|
||||||
|
case ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM:
|
||||||
dma_ctrl |= ACP_DMA_CNTL_0__DMAChIOCEn_MASK;
|
dma_ctrl |= ACP_DMA_CNTL_0__DMAChIOCEn_MASK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -710,6 +711,13 @@ static irqreturn_t dma_irq_handler(int irq, void *arg)
|
||||||
acp_mmio, mmACP_EXTERNAL_INTR_STAT);
|
acp_mmio, mmACP_EXTERNAL_INTR_STAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((intr_flag & BIT(ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM)) != 0) {
|
||||||
|
valid_irq = true;
|
||||||
|
snd_pcm_period_elapsed(irq_data->play_i2s_micsp_stream);
|
||||||
|
acp_reg_write((intr_flag & BIT(ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM)) << 16,
|
||||||
|
acp_mmio, mmACP_EXTERNAL_INTR_STAT);
|
||||||
|
}
|
||||||
|
|
||||||
if ((intr_flag & BIT(ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM)) != 0) {
|
if ((intr_flag & BIT(ACP_TO_I2S_DMA_BT_INSTANCE_CH_NUM)) != 0) {
|
||||||
valid_irq = true;
|
valid_irq = true;
|
||||||
snd_pcm_period_elapsed(irq_data->play_i2sbt_stream);
|
snd_pcm_period_elapsed(irq_data->play_i2sbt_stream);
|
||||||
|
@ -807,7 +815,8 @@ static int acp_dma_open(struct snd_soc_component *component,
|
||||||
* stream is not closed
|
* stream is not closed
|
||||||
*/
|
*/
|
||||||
if (!intr_data->play_i2ssp_stream && !intr_data->capture_i2ssp_stream &&
|
if (!intr_data->play_i2ssp_stream && !intr_data->capture_i2ssp_stream &&
|
||||||
!intr_data->play_i2sbt_stream && !intr_data->capture_i2sbt_stream)
|
!intr_data->play_i2sbt_stream && !intr_data->capture_i2sbt_stream &&
|
||||||
|
!intr_data->play_i2s_micsp_stream)
|
||||||
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
|
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
|
@ -867,6 +876,9 @@ static int acp_dma_hw_params(struct snd_soc_component *component,
|
||||||
case I2S_BT_INSTANCE:
|
case I2S_BT_INSTANCE:
|
||||||
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
|
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
|
val |= ACP_I2S_MICSP_16BIT_RESOLUTION_EN;
|
||||||
|
break;
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
val |= ACP_I2S_SP_16BIT_RESOLUTION_EN;
|
val |= ACP_I2S_SP_16BIT_RESOLUTION_EN;
|
||||||
|
@ -876,6 +888,7 @@ static int acp_dma_hw_params(struct snd_soc_component *component,
|
||||||
case I2S_BT_INSTANCE:
|
case I2S_BT_INSTANCE:
|
||||||
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
|
val |= ACP_I2S_BT_16BIT_RESOLUTION_EN;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
val |= ACP_I2S_MIC_16BIT_RESOLUTION_EN;
|
val |= ACP_I2S_MIC_16BIT_RESOLUTION_EN;
|
||||||
|
@ -901,6 +914,27 @@ static int acp_dma_hw_params(struct snd_soc_component *component,
|
||||||
mmACP_I2S_BT_TRANSMIT_BYTE_CNT_LOW;
|
mmACP_I2S_BT_TRANSMIT_BYTE_CNT_LOW;
|
||||||
adata->play_i2sbt_stream = substream;
|
adata->play_i2sbt_stream = substream;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
|
switch (adata->asic_type) {
|
||||||
|
case CHIP_STONEY:
|
||||||
|
rtd->pte_offset = ACP_ST_PLAYBACK_PTE_OFFSET;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rtd->pte_offset = ACP_PLAYBACK_PTE_OFFSET;
|
||||||
|
}
|
||||||
|
rtd->ch1 = SYSRAM_TO_ACP_MICSP_INSTANCE_CH_NUM;
|
||||||
|
rtd->ch2 = ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM;
|
||||||
|
rtd->sram_bank = ACP_SRAM_BANK_1_ADDRESS;
|
||||||
|
rtd->destination = TO_ACP_I2S_2;
|
||||||
|
rtd->dma_dscr_idx_1 = PLAYBACK_START_DMA_DESCR_CH4;
|
||||||
|
rtd->dma_dscr_idx_2 = PLAYBACK_START_DMA_DESCR_CH5;
|
||||||
|
rtd->byte_cnt_high_reg_offset =
|
||||||
|
mmACP_I2S_MICSP_TRANSMIT_BYTE_CNT_HIGH;
|
||||||
|
rtd->byte_cnt_low_reg_offset =
|
||||||
|
mmACP_I2S_MICSP_TRANSMIT_BYTE_CNT_LOW;
|
||||||
|
|
||||||
|
adata->play_i2s_micsp_stream = substream;
|
||||||
|
break;
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
switch (adata->asic_type) {
|
switch (adata->asic_type) {
|
||||||
|
@ -939,6 +973,7 @@ static int acp_dma_hw_params(struct snd_soc_component *component,
|
||||||
rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_11;
|
rtd->dma_curr_dscr = mmACP_DMA_CUR_DSCR_11;
|
||||||
adata->capture_i2sbt_stream = substream;
|
adata->capture_i2sbt_stream = substream;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
rtd->pte_offset = ACP_CAPTURE_PTE_OFFSET;
|
rtd->pte_offset = ACP_CAPTURE_PTE_OFFSET;
|
||||||
|
@ -1160,6 +1195,9 @@ static int acp_dma_close(struct snd_soc_component *component,
|
||||||
case I2S_BT_INSTANCE:
|
case I2S_BT_INSTANCE:
|
||||||
adata->play_i2sbt_stream = NULL;
|
adata->play_i2sbt_stream = NULL;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
|
adata->play_i2s_micsp_stream = NULL;
|
||||||
|
break;
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
adata->play_i2ssp_stream = NULL;
|
adata->play_i2ssp_stream = NULL;
|
||||||
|
@ -1181,6 +1219,7 @@ static int acp_dma_close(struct snd_soc_component *component,
|
||||||
case I2S_BT_INSTANCE:
|
case I2S_BT_INSTANCE:
|
||||||
adata->capture_i2sbt_stream = NULL;
|
adata->capture_i2sbt_stream = NULL;
|
||||||
break;
|
break;
|
||||||
|
case I2S_MICSP_INSTANCE:
|
||||||
case I2S_SP_INSTANCE:
|
case I2S_SP_INSTANCE:
|
||||||
default:
|
default:
|
||||||
adata->capture_i2ssp_stream = NULL;
|
adata->capture_i2ssp_stream = NULL;
|
||||||
|
@ -1197,7 +1236,8 @@ static int acp_dma_close(struct snd_soc_component *component,
|
||||||
* another stream is also not active.
|
* another stream is also not active.
|
||||||
*/
|
*/
|
||||||
if (!adata->play_i2ssp_stream && !adata->capture_i2ssp_stream &&
|
if (!adata->play_i2ssp_stream && !adata->capture_i2ssp_stream &&
|
||||||
!adata->play_i2sbt_stream && !adata->capture_i2sbt_stream)
|
!adata->play_i2sbt_stream && !adata->capture_i2sbt_stream &&
|
||||||
|
!adata->play_i2s_micsp_stream)
|
||||||
acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
|
acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
|
||||||
kfree(rtd);
|
kfree(rtd);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1245,6 +1285,7 @@ static int acp_audio_probe(struct platform_device *pdev)
|
||||||
audio_drv_data->capture_i2ssp_stream = NULL;
|
audio_drv_data->capture_i2ssp_stream = NULL;
|
||||||
audio_drv_data->play_i2sbt_stream = NULL;
|
audio_drv_data->play_i2sbt_stream = NULL;
|
||||||
audio_drv_data->capture_i2sbt_stream = NULL;
|
audio_drv_data->capture_i2sbt_stream = NULL;
|
||||||
|
audio_drv_data->play_i2s_micsp_stream = NULL;
|
||||||
|
|
||||||
audio_drv_data->asic_type = *pdata;
|
audio_drv_data->asic_type = *pdata;
|
||||||
|
|
||||||
|
@ -1333,6 +1374,11 @@ static int acp_pcm_resume(struct device *dev)
|
||||||
config_acp_dma(adata->acp_mmio, rtd, adata->asic_type);
|
config_acp_dma(adata->acp_mmio, rtd, adata->asic_type);
|
||||||
}
|
}
|
||||||
if (adata->asic_type != CHIP_CARRIZO) {
|
if (adata->asic_type != CHIP_CARRIZO) {
|
||||||
|
if (adata->play_i2s_micsp_stream &&
|
||||||
|
adata->play_i2s_micsp_stream->runtime) {
|
||||||
|
rtd = adata->play_i2s_micsp_stream->runtime->private_data;
|
||||||
|
config_acp_dma(adata->acp_mmio, rtd, adata->asic_type);
|
||||||
|
}
|
||||||
if (adata->play_i2sbt_stream &&
|
if (adata->play_i2sbt_stream &&
|
||||||
adata->play_i2sbt_stream->runtime) {
|
adata->play_i2sbt_stream->runtime) {
|
||||||
rtd = adata->play_i2sbt_stream->runtime->private_data;
|
rtd = adata->play_i2sbt_stream->runtime->private_data;
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
|
|
||||||
#define I2S_SP_INSTANCE 0x01
|
#define I2S_SP_INSTANCE 0x01
|
||||||
#define I2S_BT_INSTANCE 0x02
|
#define I2S_BT_INSTANCE 0x02
|
||||||
|
#define I2S_MICSP_INSTANCE 0x03
|
||||||
#define CAP_CHANNEL0 0x00
|
#define CAP_CHANNEL0 0x00
|
||||||
#define CAP_CHANNEL1 0x01
|
#define CAP_CHANNEL1 0x01
|
||||||
|
|
||||||
|
@ -85,6 +86,10 @@
|
||||||
#define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10
|
#define I2S_TO_ACP_DMA_BT_INSTANCE_CH_NUM 10
|
||||||
#define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11
|
#define ACP_TO_SYSRAM_BT_INSTANCE_CH_NUM 11
|
||||||
|
|
||||||
|
/* Playback DMA channels for I2S MICSP instance */
|
||||||
|
#define SYSRAM_TO_ACP_MICSP_INSTANCE_CH_NUM 4
|
||||||
|
#define ACP_TO_I2S_DMA_MICSP_INSTANCE_CH_NUM 5
|
||||||
|
|
||||||
#define NUM_DSCRS_PER_CHANNEL 2
|
#define NUM_DSCRS_PER_CHANNEL 2
|
||||||
|
|
||||||
#define PLAYBACK_START_DMA_DESCR_CH12 0
|
#define PLAYBACK_START_DMA_DESCR_CH12 0
|
||||||
|
@ -108,8 +113,15 @@
|
||||||
#define CAPTURE_START_DMA_DESCR_CH11 14
|
#define CAPTURE_START_DMA_DESCR_CH11 14
|
||||||
#define CAPTURE_END_DMA_DESCR_CH11 15
|
#define CAPTURE_END_DMA_DESCR_CH11 15
|
||||||
|
|
||||||
|
/* I2S MICSP Instance DMA Descriptors */
|
||||||
|
#define PLAYBACK_START_DMA_DESCR_CH4 0
|
||||||
|
#define PLAYBACK_END_DMA_DESCR_CH4 1
|
||||||
|
#define PLAYBACK_START_DMA_DESCR_CH5 2
|
||||||
|
#define PLAYBACK_END_DMA_DESCR_CH5 3
|
||||||
|
|
||||||
#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
|
#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
|
||||||
#define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
|
#define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
|
||||||
|
#define ACP_I2S_MICSP_16BIT_RESOLUTION_EN 0x01
|
||||||
#define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02
|
#define ACP_I2S_SP_16BIT_RESOLUTION_EN 0x02
|
||||||
#define ACP_I2S_BT_16BIT_RESOLUTION_EN 0x04
|
#define ACP_I2S_BT_16BIT_RESOLUTION_EN 0x04
|
||||||
#define ACP_BT_UART_PAD_SELECT_MASK 0x1
|
#define ACP_BT_UART_PAD_SELECT_MASK 0x1
|
||||||
|
@ -149,6 +161,7 @@ struct audio_drv_data {
|
||||||
struct snd_pcm_substream *capture_i2ssp_stream;
|
struct snd_pcm_substream *capture_i2ssp_stream;
|
||||||
struct snd_pcm_substream *play_i2sbt_stream;
|
struct snd_pcm_substream *play_i2sbt_stream;
|
||||||
struct snd_pcm_substream *capture_i2sbt_stream;
|
struct snd_pcm_substream *capture_i2sbt_stream;
|
||||||
|
struct snd_pcm_substream *play_i2s_micsp_stream;
|
||||||
void __iomem *acp_mmio;
|
void __iomem *acp_mmio;
|
||||||
u32 asic_type;
|
u32 asic_type;
|
||||||
snd_pcm_sframes_t delay;
|
snd_pcm_sframes_t delay;
|
||||||
|
|
Loading…
Reference in New Issue