ASoC: cs35l41: Fallback to reading Subsystem ID property if not ACPI
If ACPI is not used, then there is currently no way of reading a Subsystem ID property used for a system name to uniquely identify the system in order to load the correct firmware and tuning. Add a new property which can be read from device tree to be able to set the system name. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Link: https://patch.msgid.link/20250917153722.94978-3-sbinding@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>pull/1354/merge
parent
f8673e4069
commit
46c8b4d2a6
|
|
@ -7,6 +7,7 @@
|
||||||
// Author: David Rhodes <david.rhodes@cirrus.com>
|
// Author: David Rhodes <david.rhodes@cirrus.com>
|
||||||
|
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
|
#include <acpi/acpi_bus.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
|
@ -1147,45 +1148,55 @@ err_dsp:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI
|
static int cs35l41_get_system_name(struct cs35l41_private *cs35l41)
|
||||||
static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41)
|
|
||||||
{
|
{
|
||||||
struct acpi_device *adev = ACPI_COMPANION(cs35l41->dev);
|
struct acpi_device *adev = ACPI_COMPANION(cs35l41->dev);
|
||||||
acpi_handle handle = acpi_device_handle(adev);
|
const char *sub = NULL;
|
||||||
const char *hid;
|
const char *tmp;
|
||||||
const char *sub;
|
int ret = 0;
|
||||||
|
|
||||||
/* If there is no acpi_device, there is no ACPI for this system, return 0 */
|
/* If there is no acpi_device, there is no ACPI for this system, skip checking ACPI */
|
||||||
if (!adev)
|
if (adev) {
|
||||||
return 0;
|
acpi_handle handle = acpi_device_handle(adev);
|
||||||
|
|
||||||
sub = acpi_get_subsystem_id(handle);
|
sub = acpi_get_subsystem_id(handle);
|
||||||
if (IS_ERR(sub)) {
|
ret = PTR_ERR_OR_ZERO(sub);
|
||||||
|
if (ret) {
|
||||||
|
sub = NULL;
|
||||||
/* If no _SUB, fallback to _HID, otherwise fail */
|
/* If no _SUB, fallback to _HID, otherwise fail */
|
||||||
if (PTR_ERR(sub) == -ENODATA) {
|
if (ret == -ENODATA) {
|
||||||
hid = acpi_device_hid(adev);
|
tmp = acpi_device_hid(adev);
|
||||||
/* If dummy hid, return 0 and fallback to legacy firmware path */
|
/* If dummy hid, return 0 and fallback to legacy firmware path */
|
||||||
if (!strcmp(hid, "device"))
|
if (!strcmp(tmp, "device")) {
|
||||||
return 0;
|
ret = 0;
|
||||||
sub = kstrdup(hid, GFP_KERNEL);
|
goto err;
|
||||||
if (!sub)
|
}
|
||||||
sub = ERR_PTR(-ENOMEM);
|
sub = kstrdup(tmp, GFP_KERNEL);
|
||||||
|
if (!sub) {
|
||||||
} else
|
ret = -ENOMEM;
|
||||||
return PTR_ERR(sub);
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!device_property_read_string(cs35l41->dev, "cirrus,subsystem-id", &tmp)) {
|
||||||
|
sub = kstrdup(tmp, GFP_KERNEL);
|
||||||
|
if (!sub) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err:
|
||||||
|
if (sub) {
|
||||||
cs35l41->dsp.system_name = sub;
|
cs35l41->dsp.system_name = sub;
|
||||||
dev_dbg(cs35l41->dev, "Subsystem ID: %s\n", cs35l41->dsp.system_name);
|
dev_info(cs35l41->dev, "Subsystem ID: %s\n", cs35l41->dsp.system_name);
|
||||||
|
} else
|
||||||
|
dev_warn(cs35l41->dev, "Subsystem ID not found\n");
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_ACPI */
|
|
||||||
|
|
||||||
int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
|
int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
|
||||||
{
|
{
|
||||||
|
|
@ -1317,7 +1328,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = cs35l41_acpi_get_name(cs35l41);
|
ret = cs35l41_get_system_name(cs35l41);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue