ASoC: tegra: Align with new device model

PEQ and MBDRC are sub blocks of OPE module. So far, these sub blocks
were not represented by separate device nodes in DT. This has changed
now where PEQ and MBDRC are children of OPE block. For now the driver
structure is maintained as it is and explicitly parse PEQ and MBDRC
nodes to create corresponding regmap interfaces. With this there is
flexibility now to create separate device drivers for PEQ and MBDRC
if necessary in future.

Bug 3583581

Change-Id: I16ceb9b1a30b4ddb1a57fdef28db20c554c58b03
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2783022
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Sameer Pujar
2022-09-27 10:32:30 +00:00
committed by mobile promotions
parent 1e77ef2504
commit c4ab6f5a0e
4 changed files with 51 additions and 21 deletions

View File

@@ -7,6 +7,7 @@
#include <linux/device.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/core.h>
@@ -867,16 +868,31 @@ int tegra210_mbdrc_codec_init(struct snd_soc_component *cmpnt)
}
EXPORT_SYMBOL_GPL(tegra210_mbdrc_codec_init);
int tegra210_mbdrc_init(struct platform_device *pdev, int id)
int tegra210_mbdrc_regmap_init(struct platform_device *pdev)
{
struct tegra210_ope *ope = dev_get_drvdata(&pdev->dev);
struct resource *mem;
struct device *dev = &pdev->dev;
struct tegra210_ope *ope = dev_get_drvdata(dev);
struct device_node *child;
struct resource mem;
void __iomem *regs;
int err;
mem = platform_get_resource(pdev, IORESOURCE_MEM, id);
regs = devm_ioremap_resource(&pdev->dev, mem);
child = of_get_child_by_name(dev->of_node, "dynamic-range-compressor");
if (!child)
return -ENODEV;
err = of_address_to_resource(child, 0, &mem);
of_node_put(child);
if (err < 0) {
dev_err(dev, "fail to get MBDRC resource\n");
return err;
}
mem.flags = IORESOURCE_MEM;
regs = devm_ioremap_resource(&pdev->dev, &mem);
if (IS_ERR(regs))
return PTR_ERR(regs);
ope->mbdrc_regmap =
devm_regmap_init_mmio(&pdev->dev, regs,
&tegra210_mbdrc_regmap_config);
@@ -885,9 +901,11 @@ int tegra210_mbdrc_init(struct platform_device *pdev, int id)
return PTR_ERR(ope->mbdrc_regmap);
}
regcache_cache_only(ope->mbdrc_regmap, true);
return 0;
}
EXPORT_SYMBOL_GPL(tegra210_mbdrc_init);
EXPORT_SYMBOL_GPL(tegra210_mbdrc_regmap_init);
MODULE_AUTHOR("Sumit Bhattacharya <sumitb@nvidia.com>");
MODULE_DESCRIPTION("Tegra210 MBDRC module");

View File

@@ -328,22 +328,18 @@ static int tegra210_ope_platform_probe(struct platform_device *pdev)
dev_set_drvdata(dev, ope);
err = tegra210_peq_init(pdev, TEGRA210_PEQ_IORESOURCE_MEM);
err = tegra210_peq_regmap_init(pdev);
if (err < 0) {
dev_err(dev, "peq init failed\n");
dev_err(dev, "PEQ init failed\n");
return err;
}
regcache_cache_only(ope->peq_regmap, true);
err = tegra210_mbdrc_init(pdev, TEGRA210_MBDRC_IORESOURCE_MEM);
err = tegra210_mbdrc_regmap_init(pdev);
if (err < 0) {
dev_err(dev, "mbdrc init failed\n");
dev_err(dev, "MBDRC init failed\n");
return err;
}
regcache_cache_only(ope->mbdrc_regmap, true);
err = devm_snd_soc_register_component(dev, &tegra210_ope_cmpnt,
tegra210_ope_dais,
ARRAY_SIZE(tegra210_ope_dais));

View File

@@ -68,11 +68,11 @@ struct tegra210_ope {
u32 peq_biquad_shifts[TEGRA210_PEQ_SHIFT_PARAM_SIZE_PER_CH];
};
extern int tegra210_peq_init(struct platform_device *pdev, int id);
extern int tegra210_peq_regmap_init(struct platform_device *pdev);
extern int tegra210_peq_codec_init(struct snd_soc_component *cmpnt);
extern void tegra210_peq_restore(struct tegra210_ope *ope);
extern void tegra210_peq_save(struct tegra210_ope *ope);
extern int tegra210_mbdrc_init(struct platform_device *pdev, int id);
extern int tegra210_mbdrc_regmap_init(struct platform_device *pdev);
extern int tegra210_mbdrc_codec_init(struct snd_soc_component *cmpnt);
extern int tegra210_mbdrc_hw_params(struct snd_soc_component *cmpnt);

View File

@@ -9,6 +9,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -354,15 +355,28 @@ int tegra210_peq_codec_init(struct snd_soc_component *cmpnt)
}
EXPORT_SYMBOL_GPL(tegra210_peq_codec_init);
int tegra210_peq_init(struct platform_device *pdev, int id)
int tegra210_peq_regmap_init(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct tegra210_ope *ope = dev_get_drvdata(dev);
struct resource *mem;
struct device_node *child;
struct resource mem;
void __iomem *regs;
int err;
mem = platform_get_resource(pdev, IORESOURCE_MEM, id);
regs = devm_ioremap_resource(dev, mem);
child = of_get_child_by_name(dev->of_node, "equalizer");
if (!child)
return -ENODEV;
err = of_address_to_resource(child, 0, &mem);
of_node_put(child);
if (err < 0) {
dev_err(dev, "fail to get PEQ resource\n");
return err;
}
mem.flags = IORESOURCE_MEM;
regs = devm_ioremap_resource(dev, &mem);
if (IS_ERR(regs))
return PTR_ERR(regs);
ope->peq_regmap = devm_regmap_init_mmio(dev, regs,
@@ -372,9 +386,11 @@ int tegra210_peq_init(struct platform_device *pdev, int id)
return PTR_ERR(ope->peq_regmap);
}
regcache_cache_only(ope->peq_regmap, true);
return 0;
}
EXPORT_SYMBOL_GPL(tegra210_peq_init);
EXPORT_SYMBOL_GPL(tegra210_peq_regmap_init);
MODULE_AUTHOR("Sumit Bhattacharya <sumitb@nvidia.com>");
MODULE_DESCRIPTION("Tegra210 PEQ module");