ASoC: SOF: OF: Avoid reverse module dependency

Similar with commit 8a49cd11e6 ("ASoC: SOF: ACPI: avoid reverse
module dependency") we will be having hardware specific drivers that
link against a common "helper" framework.

sof-of-dev.c becomes a library with the interface defined in the newly
created file sof-of-dev.h.

This is the final step started with Kconfig simplification in
commit 7548a391c5 ("ASoC: SOF: i.MX: simplify Kconfig")

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Paul Olaru <paul.olaru@oss.nxp.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211215085703.137414-1-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Daniel Baluta 2021-12-15 10:57:03 +02:00 committed by Mark Brown
parent 9e376b14ef
commit 28084f4a0e
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
7 changed files with 118 additions and 99 deletions

View File

@ -1,10 +0,0 @@
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
#ifndef __IMX_OPS_H__
#define __IMX_OPS_H__
extern struct snd_sof_dsp_ops sof_imx8_ops;
extern struct snd_sof_dsp_ops sof_imx8x_ops;
extern struct snd_sof_dsp_ops sof_imx8m_ops;
#endif

View File

@ -21,8 +21,8 @@
#include <linux/firmware/imx/svc/misc.h>
#include <dt-bindings/firmware/imx/rsrc.h>
#include "../ops.h"
#include "../sof-of-dev.h"
#include "imx-common.h"
#include "imx-ops.h"
/* DSP memories */
#define IRAM_OFFSET 0x10000
@ -487,7 +487,7 @@ static int imx8_dsp_set_power_state(struct snd_sof_dev *sdev,
}
/* i.MX8 ops */
struct snd_sof_dsp_ops sof_imx8_ops = {
static const struct snd_sof_dsp_ops sof_imx8_ops = {
/* probe and remove */
.probe = imx8_probe,
.remove = imx8_remove,
@ -548,10 +548,9 @@ struct snd_sof_dsp_ops sof_imx8_ops = {
.set_power_state = imx8_dsp_set_power_state,
};
EXPORT_SYMBOL(sof_imx8_ops);
/* i.MX8X ops */
struct snd_sof_dsp_ops sof_imx8x_ops = {
static const struct snd_sof_dsp_ops sof_imx8x_ops = {
/* probe and remove */
.probe = imx8_probe,
.remove = imx8_remove,
@ -612,7 +611,41 @@ struct snd_sof_dsp_ops sof_imx8x_ops = {
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP
};
EXPORT_SYMBOL(sof_imx8x_ops);
static struct sof_dev_desc sof_of_imx8qxp_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8x.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8x_ops,
};
static struct sof_dev_desc sof_of_imx8qm_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8_ops,
};
static const struct of_device_id sof_of_imx8_ids[] = {
{ .compatible = "fsl,imx8qxp-dsp", .data = &sof_of_imx8qxp_desc},
{ .compatible = "fsl,imx8qm-dsp", .data = &sof_of_imx8qm_desc},
{ }
};
MODULE_DEVICE_TABLE(of, sof_of_imx8_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_imx8_driver = {
.probe = sof_of_probe,
.remove = sof_of_remove,
.driver = {
.name = "sof-audio-of-imx8",
.pm = &sof_of_pm,
.of_match_table = sof_of_imx8_ids,
},
};
module_platform_driver(snd_sof_of_imx8_driver);
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
MODULE_LICENSE("Dual BSD/GPL");

View File

@ -20,8 +20,8 @@
#include <linux/firmware/imx/dsp.h>
#include "../ops.h"
#include "../sof-of-dev.h"
#include "imx-common.h"
#include "imx-ops.h"
#define MBOX_OFFSET 0x800000
#define MBOX_SIZE 0x1000
@ -411,7 +411,7 @@ static int imx8m_dsp_suspend(struct snd_sof_dev *sdev, unsigned int target_state
}
/* i.MX8 ops */
struct snd_sof_dsp_ops sof_imx8m_ops = {
static const struct snd_sof_dsp_ops sof_imx8m_ops = {
/* probe and remove */
.probe = imx8m_probe,
.remove = imx8m_remove,
@ -470,7 +470,32 @@ struct snd_sof_dsp_ops sof_imx8m_ops = {
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
};
EXPORT_SYMBOL(sof_imx8m_ops);
static struct sof_dev_desc sof_of_imx8mp_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8m.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8m_ops,
};
static const struct of_device_id sof_of_imx8m_ids[] = {
{ .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc},
{ }
};
MODULE_DEVICE_TABLE(of, sof_of_imx8m_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_imx8m_driver = {
.probe = sof_of_probe,
.remove = sof_of_remove,
.driver = {
.name = "sof-audio-of-imx8m",
.pm = &sof_of_pm,
.of_match_table = sof_of_imx8m_ids,
},
};
module_platform_driver(snd_sof_of_imx8m_driver);
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
MODULE_LICENSE("Dual BSD/GPL");

View File

@ -1,8 +0,0 @@
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
#ifndef __MEDIATEK_OPS_H__
#define __MEDIATEK_OPS_H__
extern const struct snd_sof_dsp_ops sof_mt8195_ops;
#endif

View File

@ -21,9 +21,9 @@
#include <sound/sof.h>
#include <sound/sof/xtensa.h>
#include "../../ops.h"
#include "../../sof-of-dev.h"
#include "../../sof-audio.h"
#include "../adsp_helper.h"
#include "../mediatek-ops.h"
#include "mt8195.h"
#include "mt8195-clk.h"
@ -388,7 +388,7 @@ static struct snd_soc_dai_driver mt8195_dai[] = {
};
/* mt8195 ops */
const struct snd_sof_dsp_ops sof_mt8195_ops = {
static const struct snd_sof_dsp_ops sof_mt8195_ops = {
/* probe and remove */
.probe = mt8195_dsp_probe,
.remove = mt8195_dsp_remove,
@ -432,7 +432,32 @@ const struct snd_sof_dsp_ops sof_mt8195_ops = {
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_NO_PERIOD_WAKEUP,
};
EXPORT_SYMBOL(sof_mt8195_ops);
static const struct sof_dev_desc sof_of_mt8195_desc = {
.default_fw_path = "mediatek/sof",
.default_tplg_path = "mediatek/sof-tplg",
.default_fw_filename = "sof-mt8195.ri",
.nocodec_tplg_filename = "sof-mt8195-nocodec.tplg",
.ops = &sof_mt8195_ops,
};
static const struct of_device_id sof_of_mt8195_ids[] = {
{ .compatible = "mediatek,mt8195-dsp", .data = &sof_of_mt8195_desc},
{ }
};
MODULE_DEVICE_TABLE(of, sof_of_mt8195_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_mt8195_driver = {
.probe = sof_of_probe,
.remove = sof_of_remove,
.driver = {
.name = "sof-audio-of-mt8195",
.pm = &sof_of_pm,
.of_match_table = sof_of_mt8195_ids,
},
};
module_platform_driver(snd_sof_of_mt8195_driver);
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
MODULE_LICENSE("Dual BSD/GPL");

View File

@ -11,9 +11,8 @@
#include <linux/pm_runtime.h>
#include <sound/sof.h>
#include "sof-of-dev.h"
#include "ops.h"
#include "imx/imx-ops.h"
#include "mediatek/mediatek-ops.h"
static char *fw_path;
module_param(fw_path, charp, 0444);
@ -23,51 +22,14 @@ static char *tplg_path;
module_param(tplg_path, charp, 0444);
MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology.");
/* platform specific devices */
#if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8)
static struct sof_dev_desc sof_of_imx8qxp_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8x.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8x_ops,
};
static struct sof_dev_desc sof_of_imx8qm_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8_ops,
};
#endif
#if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8M)
static struct sof_dev_desc sof_of_imx8mp_desc = {
.default_fw_path = "imx/sof",
.default_tplg_path = "imx/sof-tplg",
.default_fw_filename = "sof-imx8m.ri",
.nocodec_tplg_filename = "sof-imx8-nocodec.tplg",
.ops = &sof_imx8m_ops,
};
#endif
#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195)
static const struct sof_dev_desc sof_of_mt8195_desc = {
.default_fw_path = "mediatek/sof",
.default_tplg_path = "mediatek/sof-tplg",
.default_fw_filename = "sof-mt8195.ri",
.nocodec_tplg_filename = "sof-mt8195-nocodec.tplg",
.ops = &sof_mt8195_ops,
};
#endif
static const struct dev_pm_ops sof_of_pm = {
const struct dev_pm_ops sof_of_pm = {
.prepare = snd_sof_prepare,
.complete = snd_sof_complete,
SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume)
SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume,
NULL)
};
EXPORT_SYMBOL(sof_of_pm);
static void sof_of_probe_complete(struct device *dev)
{
@ -79,7 +41,7 @@ static void sof_of_probe_complete(struct device *dev)
pm_runtime_enable(dev);
}
static int sof_of_probe(struct platform_device *pdev)
int sof_of_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct sof_dev_desc *desc;
@ -120,8 +82,9 @@ static int sof_of_probe(struct platform_device *pdev)
/* call sof helper for DSP hardware probe */
return snd_sof_device_probe(dev, sof_pdata);
}
EXPORT_SYMBOL(sof_of_probe);
static int sof_of_remove(struct platform_device *pdev)
int sof_of_remove(struct platform_device *pdev)
{
pm_runtime_disable(&pdev->dev);
@ -130,32 +93,6 @@ static int sof_of_remove(struct platform_device *pdev)
return 0;
}
static const struct of_device_id sof_of_ids[] = {
#if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8)
{ .compatible = "fsl,imx8qxp-dsp", .data = &sof_of_imx8qxp_desc},
{ .compatible = "fsl,imx8qm-dsp", .data = &sof_of_imx8qm_desc},
#endif
#if IS_ENABLED(CONFIG_SND_SOC_SOF_IMX8M)
{ .compatible = "fsl,imx8mp-dsp", .data = &sof_of_imx8mp_desc},
#endif
#if IS_ENABLED(CONFIG_SND_SOC_SOF_MT8195)
{ .compatible = "mediatek,mt8195-dsp", .data = &sof_of_mt8195_desc},
#endif
{ }
};
MODULE_DEVICE_TABLE(of, sof_of_ids);
/* DT driver definition */
static struct platform_driver snd_sof_of_driver = {
.probe = sof_of_probe,
.remove = sof_of_remove,
.driver = {
.name = "sof-audio-of",
.pm = &sof_of_pm,
.of_match_table = sof_of_ids,
},
};
module_platform_driver(snd_sof_of_driver);
EXPORT_SYMBOL(sof_of_remove);
MODULE_LICENSE("Dual BSD/GPL");

View File

@ -0,0 +1,17 @@
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* Copyright 2021 NXP
*/
#ifndef __SOUND_SOC_SOF_OF_H
#define __SOUND_SOC_SOF_OF_H
extern const struct dev_pm_ops sof_of_pm;
int sof_of_probe(struct platform_device *pdev);
int sof_of_remove(struct platform_device *pdev);
#endif