mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
ASoC: tegra-alt: unify tegra-alt driver
Unify adsp and i2s driver to support kernel unification. Bug 200257345 Change-Id: Ic472c4fec0e1febf9b26a9a0ad67138329a25884 Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Reviewed-on: http://git-master/r/1477310 GVS: Gerrit_Virtual_Submit Reviewed-by: Sameer Pujar <spujar@nvidia.com> Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com> Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
This commit is contained in:
committed by
Sameer Pujar
parent
f070dc4c40
commit
9a3f4fe1d7
@@ -143,8 +143,13 @@ struct tegra210_adsp_compr_rtd {
|
|||||||
int is_draining;
|
int is_draining;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct adsp_soc_data {
|
||||||
|
bool is_soc_t210;
|
||||||
|
};
|
||||||
|
|
||||||
struct tegra210_adsp {
|
struct tegra210_adsp {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
struct adsp_soc_data *soc_data;
|
||||||
struct tegra210_adsp_app apps[TEGRA210_ADSP_VIRT_REG_MAX];
|
struct tegra210_adsp_app apps[TEGRA210_ADSP_VIRT_REG_MAX];
|
||||||
atomic_t reg_val[TEGRA210_ADSP_VIRT_REG_MAX];
|
atomic_t reg_val[TEGRA210_ADSP_VIRT_REG_MAX];
|
||||||
DECLARE_BITMAP(adma_usage, TEGRA210_ADSP_ADMA_CHANNEL_COUNT);
|
DECLARE_BITMAP(adma_usage, TEGRA210_ADSP_ADMA_CHANNEL_COUNT);
|
||||||
@@ -2619,7 +2624,7 @@ static int tegra210_adsp_runtime_suspend(struct device *dev)
|
|||||||
adsp->adsp_started = 0;
|
adsp->adsp_started = 0;
|
||||||
|
|
||||||
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
||||||
if (IS_ENABLED(CONFIG_ARCH_TEGRA_18x_SOC))
|
if (!adsp->soc_data->is_soc_t210)
|
||||||
clk_disable_unprepare(adsp->apb2ape_clk);
|
clk_disable_unprepare(adsp->apb2ape_clk);
|
||||||
clk_disable_unprepare(adsp->ahub_clk);
|
clk_disable_unprepare(adsp->ahub_clk);
|
||||||
clk_disable_unprepare(adsp->ape_clk);
|
clk_disable_unprepare(adsp->ape_clk);
|
||||||
@@ -2650,7 +2655,7 @@ static int tegra210_adsp_runtime_resume(struct device *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_ARCH_TEGRA_18x_SOC)) {
|
if (!adsp->soc_data->is_soc_t210) {
|
||||||
ret = clk_prepare_enable(adsp->apb2ape_clk);
|
ret = clk_prepare_enable(adsp->apb2ape_clk);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(dev, "apb2ape clk_enable failed: %d\n"
|
dev_err(dev, "apb2ape clk_enable failed: %d\n"
|
||||||
@@ -4368,9 +4373,18 @@ static struct snd_soc_platform_driver tegra210_adsp_platform = {
|
|||||||
|
|
||||||
static u64 tegra_dma_mask = DMA_BIT_MASK(32);
|
static u64 tegra_dma_mask = DMA_BIT_MASK(32);
|
||||||
|
|
||||||
|
static struct adsp_soc_data adsp_soc_data_t210 = {
|
||||||
|
.is_soc_t210 = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct adsp_soc_data adsp_soc_data_t186 = {
|
||||||
|
.is_soc_t210 = false,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct of_device_id tegra210_adsp_audio_of_match[] = {
|
static const struct of_device_id tegra210_adsp_audio_of_match[] = {
|
||||||
{ .compatible = "nvidia,tegra210-adsp-audio", },
|
{ .compatible = "nvidia,tegra210-adsp-audio", .data = &adsp_soc_data_t210},
|
||||||
{ .compatible = "nvidia,tegra210-adsp-audio-hv", },
|
{ .compatible = "nvidia,tegra186-adsp-audio", .data = &adsp_soc_data_t186},
|
||||||
|
{ .compatible = "nvidia,tegra210-adsp-audio-hv", .data = &adsp_soc_data_t186},
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4423,6 +4437,7 @@ static int tegra210_adsp_audio_platform_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
dev_set_drvdata(&pdev->dev, adsp);
|
dev_set_drvdata(&pdev->dev, adsp);
|
||||||
adsp->dev = &pdev->dev;
|
adsp->dev = &pdev->dev;
|
||||||
|
adsp->soc_data = (struct adsp_soc_data *)match->data;
|
||||||
|
|
||||||
|
|
||||||
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
||||||
@@ -4440,7 +4455,7 @@ static int tegra210_adsp_audio_platform_probe(struct platform_device *pdev)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_ENABLED(CONFIG_ARCH_TEGRA_210_SOC)) {
|
if (!adsp->soc_data->is_soc_t210) {
|
||||||
adsp->apb2ape_clk = devm_clk_get(&pdev->dev, "apb2ape");
|
adsp->apb2ape_clk = devm_clk_get(&pdev->dev, "apb2ape");
|
||||||
if (IS_ERR(adsp->apb2ape_clk)) {
|
if (IS_ERR(adsp->apb2ape_clk)) {
|
||||||
dev_err(&pdev->dev, "Error: Missing APB2APE clock\n");
|
dev_err(&pdev->dev, "Error: Missing APB2APE clock\n");
|
||||||
@@ -4619,7 +4634,7 @@ err_unregister_platform:
|
|||||||
err_pm_disable:
|
err_pm_disable:
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
err:
|
err:
|
||||||
if (IS_ENABLED(CONFIG_ARCH_TEGRA_18x_SOC))
|
if (!adsp->soc_data->is_soc_t210)
|
||||||
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
|
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
|
||||||
tegra_alt_asoc_utils_clk_put
|
tegra_alt_asoc_utils_clk_put
|
||||||
(&pdev->dev, adsp->apb2ape_clk);
|
(&pdev->dev, adsp->apb2ape_clk);
|
||||||
@@ -4639,7 +4654,7 @@ static int __maybe_unused tegra210_adsp_audio_platform_remove(
|
|||||||
struct tegra210_adsp *adsp = dev_get_drvdata(&pdev->dev);
|
struct tegra210_adsp *adsp = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
if (IS_ENABLED(CONFIG_ARCH_TEGRA_18x_SOC))
|
if (!adsp->soc_data->is_soc_t210)
|
||||||
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
|
if (!IS_ERR_OR_NULL(adsp->apb2ape_clk))
|
||||||
tegra_alt_asoc_utils_clk_put
|
tegra_alt_asoc_utils_clk_put
|
||||||
(&pdev->dev, adsp->apb2ape_clk);
|
(&pdev->dev, adsp->apb2ape_clk);
|
||||||
|
|||||||
@@ -46,14 +46,12 @@
|
|||||||
|
|
||||||
#define DRV_NAME "tegra210-i2s"
|
#define DRV_NAME "tegra210-i2s"
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_TEGRA_21X_SOC)
|
|
||||||
#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
|
#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
|
||||||
static struct of_device_id tegra_ape_pd[] = {
|
static struct of_device_id tegra_ape_pd[] = {
|
||||||
{ .compatible = "nvidia,tegra210-ape-pd", },
|
{ .compatible = "nvidia,tegra210-ape-pd", },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
static const struct reg_default tegra210_i2s_reg_defaults[] = {
|
static const struct reg_default tegra210_i2s_reg_defaults[] = {
|
||||||
{ TEGRA210_I2S_AXBAR_RX_INT_MASK, 0x00000003},
|
{ TEGRA210_I2S_AXBAR_RX_INT_MASK, 0x00000003},
|
||||||
@@ -981,10 +979,18 @@ static const struct regmap_config tegra210_i2s_regmap_config = {
|
|||||||
static const struct tegra210_i2s_soc_data soc_data_tegra210 = {
|
static const struct tegra210_i2s_soc_data soc_data_tegra210 = {
|
||||||
.set_audio_cif = tegra210_xbar_set_cif,
|
.set_audio_cif = tegra210_xbar_set_cif,
|
||||||
.set_slot_ctrl = tegra210_i2s_set_slot_ctrl,
|
.set_slot_ctrl = tegra210_i2s_set_slot_ctrl,
|
||||||
|
.is_soc_t210 = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct tegra210_i2s_soc_data soc_data_tegra186 = {
|
||||||
|
.set_audio_cif = tegra210_xbar_set_cif,
|
||||||
|
.set_slot_ctrl = tegra210_i2s_set_slot_ctrl,
|
||||||
|
.is_soc_t210 = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id tegra210_i2s_of_match[] = {
|
static const struct of_device_id tegra210_i2s_of_match[] = {
|
||||||
{ .compatible = "nvidia,tegra210-i2s", .data = &soc_data_tegra210 },
|
{ .compatible = "nvidia,tegra210-i2s", .data = &soc_data_tegra210 },
|
||||||
|
{ .compatible = "nvidia,tegra186-i2s", .data = &soc_data_tegra186 },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -999,17 +1005,7 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
|
|||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
int ret = 0, count = 0, num_supplies;
|
int ret = 0, count = 0, num_supplies;
|
||||||
const char *supply, *prod_name;
|
const char *supply, *prod_name;
|
||||||
#if defined(CONFIG_ARCH_TEGRA_21X_SOC)
|
int partition_id = 0;
|
||||||
int partition_id;
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
|
|
||||||
partition_id = tegra_pd_get_powergate_id(tegra_ape_pd);
|
|
||||||
if (partition_id < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
#else
|
|
||||||
partition_id = TEGRA_POWERGATE_APE;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
match = of_match_device(tegra210_i2s_of_match, &pdev->dev);
|
match = of_match_device(tegra210_i2s_of_match, &pdev->dev);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@@ -1032,6 +1028,16 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
|
|||||||
i2s->enable_cya = false;
|
i2s->enable_cya = false;
|
||||||
i2s->loopback = 0;
|
i2s->loopback = 0;
|
||||||
|
|
||||||
|
if (i2s->soc_data->is_soc_t210) {
|
||||||
|
#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
|
||||||
|
partition_id = tegra_pd_get_powergate_id(tegra_ape_pd);
|
||||||
|
if (partition_id < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
#else
|
||||||
|
partition_id = TEGRA_POWERGATE_APE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) {
|
||||||
i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL);
|
i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(i2s->clk_i2s)) {
|
if (IS_ERR(i2s->clk_i2s)) {
|
||||||
@@ -1092,10 +1098,9 @@ static int tegra210_i2s_platform_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
i2s->slgc_notifier.notifier_call = _tegra210_i2s_slcg_notifier;
|
i2s->slgc_notifier.notifier_call = _tegra210_i2s_slcg_notifier;
|
||||||
#if defined(CONFIG_ARCH_TEGRA_21X_SOC)
|
|
||||||
slcg_register_notifier(partition_id, &i2s->slgc_notifier);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
if (i2s->soc_data->is_soc_t210)
|
||||||
|
slcg_register_notifier(partition_id, &i2s->slgc_notifier);
|
||||||
|
|
||||||
regcache_cache_only(i2s->regmap, true);
|
regcache_cache_only(i2s->regmap, true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user