Support reading Subsystem ID from Device Tree
Subsystems (4)
v2 cover Support reading Subsystem ID from Device Tree
In PC systems using ACPI, the driver is able to read back an SSID from the _SUB property. This SSID uniquely identifies the system, which enables the driver to read the correct firmware and tuning for that system from linux-firmware. Currently there is no way of reading this property from device tree. Add an equivalent property in device tree to perform the same role.
Changes since v1:
- Fixed device tree property type
Stefan Binding (2):
ASoC: dt-bindings: cirrus,cs35l41: Document the cirrus,subsystem-id
property
ASoC: cs35l41: Fallback to reading Subsystem ID property if not ACPI
.../bindings/sound/cirrus,cs35l41.yaml | 6 ++ sound/soc/codecs/cs35l41.c | 77 +++++++++++-------- 2 files changed, 50 insertions(+), 33 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 ASoC: dt-bindings: cirrus,cs35l41: Document the cirrus,subsystem-id property
Add new property: cirrus,subsystem-id
This new property is used to uniquely identify the system if device tree is used, to allow the driver to select the correct firmware and tuning for the system.
--- Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml +6 -0
@@ -151,6 +151,12 @@ properties: minimum: 0 maximum: 5 + cirrus,subsystem-id: + $ref: /schemas/types.yaml#/definitions/string + description: + Subsystem ID. If this property is present, it sets the system name, + used to identify the firmware and tuning to load. + required: - compatible - reg
Signature · 1 line
2.43.0
Re: [PATCH v2 1/2] ASoC: dt-bindings: cirrus,cs35l41: Document the cirrus,subsystem-id property
Quoted 15 lines · Stefan Binding
Add new property: cirrus,subsystem-id
This new property is used to uniquely identify the system if device tree is used, to allow the driver to select the correct firmware and tuning for the system.Signed-off-by Stefan Binding <[email protected]>--- Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml +0
-0
Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml properties: · line 158
Quoted 8 lines
Documentation/devicetree/bindings/sound/cirrus,cs35l41.yaml +5
-0@@ -151,6 +151,12 @@ properties: minimum: 0 maximum: 5 + cirrus,subsystem-id: + $ref: /schemas/types.yaml#/definitions/string + description: + Subsystem ID. If this property is present, it sets the system name, + used to identify the firmware and tuning to load.
Please do not send new version immediately, but allow people to actually review your code. You received the review on v1.
Best regards,
Krzysztof
PATCH v2 2/2 ASoC: cs35l41: Fallback to reading Subsystem ID property if not ACPI
In reply to Stefan BindingIf 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.
--- sound/soc/codecs/cs35l41.c | 77 ++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 33 deletions(-)
sound/soc/codecs/cs35l41.c +44 -33
@@ -7,6 +7,7 @@// Author: David Rhodes <[email protected]> #include <linux/acpi.h> +#include <acpi/acpi_bus.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/init.h>
@@ -1147,45 +1148,55 @@ static int cs35l41_dsp_init(struct cs35l41_private *cs35l41)return ret; } -#ifdef CONFIG_ACPI -static int cs35l41_acpi_get_name (struct cs35l41_private *cs35l41) +static int cs35l41_get_system_name (struct cs35l41_private *cs35l41) {struct acpi_device *adev =ACPI_COMPANION (cs35l41->dev); -acpi_handle handle =acpi_device_handle (adev); -const char *hid; -const char *sub; - -/* If there is no acpi_device, there is no ACPI for this system, return 0 */ -if (!adev) -return 0 ; +const char *sub =NULL ; +const char *tmp; +int ret =0 ; - sub =acpi_get_subsystem_id (handle); -if (IS_ERR (sub)) { -/* If no _SUB, fallback to _HID, otherwise fail */ -if (PTR_ERR (sub) == -ENODATA ) { - hid =acpi_device_hid (adev); -/* If dummy hid, return 0 and fallback to legacy firmware path */ -if (!strcmp (hid,"device" )) -return 0 ; - sub =kstrdup (hid,GFP_KERNEL ); -if (!sub) - sub =ERR_PTR (-ENOMEM ); - - }else -return PTR_ERR (sub); +/* If there is no acpi_device, there is no ACPI for this system, skip checking ACPI */ +if (adev) { +acpi_handle handle =acpi_device_handle (adev); + + sub =acpi_get_subsystem_id (handle); + ret =PTR_ERR (sub); +if (ret) { + sub =NULL ; +/* If no _SUB, fallback to _HID, otherwise fail */ +if (ret == -ENODATA ) { + tmp =acpi_device_hid (adev); +/* If dummy hid, return 0 and fallback to legacy firmware path */ +if (!strcmp (tmp,"device" )) { + ret =0 ; + goto err; + } + sub =kstrdup (tmp,GFP_KERNEL ); +if (!sub) { + ret = -ENOMEM ; + 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; + } + } } - cs35l41->dsp.system_name = sub; -dev_dbg (cs35l41->dev,"Subsystem ID: %s\n" , cs35l41->dsp.system_name); +err: +if (sub) { + cs35l41->dsp.system_name = sub; +dev_info (cs35l41->dev,"Subsystem ID: %s\n" , cs35l41->dsp.system_name); + }else +dev_warn (cs35l41->dev,"Subsystem ID not found\n" ); -return 0 ; -} -#else -static int cs35l41_acpi_get_name (struct cs35l41_private *cs35l41) -{ -return 0 ; +return ret; } -#endif /* CONFIG_ACPI */ 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; } - ret =cs35l41_acpi_get_name (cs35l41); + ret =cs35l41_get_system_name (cs35l41);if (ret <0 ) goto err;
Signature · 1 line
2.43.0