summaryrefslogtreecommitdiff
path: root/sound/soc/sof/core.c
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@nxp.com>2019-11-07 18:54:01 +0200
committerDaniel Baluta <daniel.baluta@nxp.com>2019-11-27 21:49:11 +0200
commit19fa41a7ab8226a7ca92eb72d40edc0f3a39ed63 (patch)
tree01a85f1d45fb0118931d63767f845fd4898e3258 /sound/soc/sof/core.c
parent3d9382581a26b8f059075ee9832ed99fc7dbef7a (diff)
ASoC: Make creation of machine device from SOF core optional
Currently, SOF probes machine drivers by creating a platform device and passing the machine description as private data. This is driven by the ACPI restrictions. Ideally, ACPI tables should contain the description for the machine driver. This is not possible because ACPI tables are frozen and used on multiple OS-es (e.g Windows). In the case, of Device Tree we don't have this restrictions, so we choose to probe the machine drivers by creating a DT node as is the standard ALSA way. This patch makes the probing of machine drivers from SOF core optional allowing for arm platforms to decouple the SOF core from machine driver probing. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Diffstat (limited to 'sound/soc/sof/core.c')
-rw-r--r--sound/soc/sof/core.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index 2311c273441c..f4702b49e67b 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -197,7 +197,7 @@ EXPORT_SYMBOL(snd_sof_get_status);
/*
* SOF Driver enumeration.
*/
-static int sof_machine_check(struct snd_sof_dev *sdev)
+int sof_machine_check(struct snd_sof_dev *sdev)
{
struct snd_sof_pdata *plat_data = sdev->pdata;
#if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC)
@@ -228,13 +228,45 @@ static int sof_machine_check(struct snd_sof_dev *sdev)
return 0;
#endif
}
+EXPORT_SYMBOL(sof_machine_check);
-static int sof_probe_continue(struct snd_sof_dev *sdev)
+int sof_machine_register(struct snd_sof_dev *sdev, void *pdata)
{
- struct snd_sof_pdata *plat_data = sdev->pdata;
+ struct snd_sof_pdata *plat_data = (struct snd_sof_pdata *)pdata;
const char *drv_name;
const void *mach;
int size;
+
+ drv_name = plat_data->machine->drv_name;
+ mach = (const void *)plat_data->machine;
+ size = sizeof(*plat_data->machine);
+
+ /* register machine driver, pass machine info as pdata */
+ plat_data->pdev_mach =
+ platform_device_register_data(sdev->dev, drv_name,
+ PLATFORM_DEVID_NONE, mach, size);
+ if (IS_ERR(plat_data->pdev_mach))
+ return PTR_ERR(plat_data->pdev_mach);
+
+ dev_dbg(sdev->dev, "created machine %s\n",
+ dev_name(&plat_data->pdev_mach->dev));
+
+ return 0;
+}
+EXPORT_SYMBOL(sof_machine_register);
+
+void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
+{
+ struct snd_sof_pdata *plat_data = (struct snd_sof_pdata *)pdata;
+
+ if (!IS_ERR_OR_NULL(plat_data->pdev_mach))
+ platform_device_unregister(plat_data->pdev_mach);
+}
+EXPORT_SYMBOL(sof_machine_unregister);
+
+static int sof_probe_continue(struct snd_sof_dev *sdev)
+{
+ struct snd_sof_pdata *plat_data = sdev->pdata;
int ret;
/* probe the DSP hardware */
@@ -245,7 +277,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
}
/* check machine info */
- ret = sof_machine_check(sdev);
+ ret = snd_sof_machine_check(sdev);
if (ret < 0) {
dev_err(sdev->dev, "error: failed to get machine info %d\n",
ret);
@@ -312,22 +344,9 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
goto fw_run_err;
}
- drv_name = plat_data->machine->drv_name;
- mach = (const void *)plat_data->machine;
- size = sizeof(*plat_data->machine);
-
- /* register machine driver, pass machine info as pdata */
- plat_data->pdev_mach =
- platform_device_register_data(sdev->dev, drv_name,
- PLATFORM_DEVID_NONE, mach, size);
-
- if (IS_ERR(plat_data->pdev_mach)) {
- ret = PTR_ERR(plat_data->pdev_mach);
+ ret = snd_sof_machine_register(sdev, plat_data);
+ if (ret < 0)
goto fw_run_err;
- }
-
- dev_dbg(sdev->dev, "created machine %s\n",
- dev_name(&plat_data->pdev_mach->dev));
/*
* Some platforms in SOF, ex: BYT, may not have their platform PM
@@ -453,9 +472,7 @@ int snd_sof_device_remove(struct device *dev)
* will remove the component driver and unload the topology
* before freeing the snd_card.
*/
- if (!IS_ERR_OR_NULL(pdata->pdev_mach))
- platform_device_unregister(pdata->pdev_mach);
-
+ snd_sof_machine_unregister(sdev, pdata);
/*
* Unregistering the machine driver results in unloading the topology.
* Some widgets, ex: scheduler, attempt to power down the core they are