Add SDCA class driver
Subsystems (4)
Charles Keepax
maintainerv3 cover Add SDCA class driver
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers representing each of the functions of the SDCA device. These drivers all use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.
Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
Thanks,
Charles
Changes since v2:
- Updated the locking in sdca_fdl_process
- Correct some spelling in comments
- Renamed suspend/resume functions to be a little short
Changes since v1:
- Add a bunch of bug fix patches
- Change some prints to dbgs
- Add some additional comments
- Flip order on regcache operations in resume
Charles Keepax (12):
ASoC: SDCA: Remove duplicated module macros
ASoC: SDCA: Fix missing dash in HIDE DisCo property
ASoC: SDCA: Add missing forward declaration in header
ASoC: SDCA: Correct FDL locking in sdca_fdl_process()
ASoC: SDCA: Add comment for function reset polling
ASoC: SDCA: Move most of the messages from info to debug
ASoC: SDCA: Use helper macros for control identification
ASoC: SDCA: Factor out helper to process Control defaults
ASoC: SDCA: Populate regmap cache for readable Controls
ASoC: SDCA: Add helper to write initialization writes
ASoC: SDCA: Add basic SDCA class driver
ASoC: SDCA: Add basic SDCA function driver
Pierre-Louis Bossart (1):
ASoC: SDCA: add function devices
include/linux/soundwire/sdw_registers.h | 2 + include/sound/sdca.h | 14 + include/sound/sdca_regmap.h | 2 + sound/soc/sdca/Kconfig | 18 + sound/soc/sdca/Makefile | 10 +- sound/soc/sdca/sdca_class.c | 304 ++++++++++++++++ sound/soc/sdca/sdca_class.h | 37 ++ sound/soc/sdca/sdca_class_function.c | 460 ++++++++++++++++++++++++ sound/soc/sdca/sdca_fdl.c | 8 +- sound/soc/sdca/sdca_function_device.c | 117 ++++++ sound/soc/sdca/sdca_function_device.h | 15 + sound/soc/sdca/sdca_functions.c | 52 ++- sound/soc/sdca/sdca_hid.c | 3 - sound/soc/sdca/sdca_interrupts.c | 39 +- sound/soc/sdca/sdca_regmap.c | 89 +++-- 15 files changed, 1089 insertions(+), 81 deletions(-) create mode 100644 sound/soc/sdca/sdca_class.c create mode 100644 sound/soc/sdca/sdca_class.h create mode 100644 sound/soc/sdca/sdca_class_function.c create mode 100644 sound/soc/sdca/sdca_function_device.c create mode 100644 sound/soc/sdca/sdca_function_device.h
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 1/13 ASoC: SDCA: Remove duplicated module macros
Both HID and the IRQ are now build into the wider SDCA kernel module, so their module macros are redundant, remove them.
---
No changes since v2.
sound/soc/sdca/sdca_hid.c | 3 --- sound/soc/sdca/sdca_interrupts.c | 3 --- 2 files changed, 6 deletions(-)
sound/soc/sdca/sdca_hid.c +0 -3
@@ -166,6 +166,3 @@ int sdca_hid_process_report(struct sdca_interrupt *interrupt)return 0 ; }EXPORT_SYMBOL_NS (sdca_hid_process_report,"SND_SOC_SDCA" ); - -MODULE_LICENSE ("Dual BSD/GPL" ); -MODULE_DESCRIPTION ("SDCA HID library" );
sound/soc/sdca/sdca_interrupts.c +0 -3
@@ -618,6 +618,3 @@ struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev,return info; }EXPORT_SYMBOL_NS_GPL (sdca_irq_allocate,"SND_SOC_SDCA" ); - -MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("SDCA IRQ library" );
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 2/13 ASoC: SDCA: Fix missing dash in HIDE DisCo property
In reply to Charles KeepaxThe property name is "mipi-sdca-RxUMP-ownership-transition-max-delay", with a dash between max and delay. Add the missing dash.
---
No changes since v2.
sound/soc/sdca/sdca_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +1 -1
@@ -1321,7 +1321,7 @@ find_sdca_entity_hide(struct device *dev, struct sdw_slave *sdw,unsigned char *report_desc =NULL ; ret =fwnode_property_read_u32 (entity_node, -"mipi-sdca-RxUMP-ownership-transition-maxdelay" , &delay); +"mipi-sdca-RxUMP-ownership-transition-max-delay" , &delay);if (!ret) hide->max_delay = delay;
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 3/13 ASoC: SDCA: Add missing forward declaration in header
In reply to Charles KeepaxThe structure sdca_function_desc contains a fwnode_handle which is undefined if the user doesn't pull in an appropriate header. Add a forward declaration to avoid this.
---
No changes since v2.
include/sound/sdca.h | 1 + 1 file changed, 1 insertion(+)
include/sound/sdca.h +1 -0
@@ -13,6 +13,7 @@#include <linux/kconfig.h> struct acpi_table_swft ; +struct fwnode_handle ;struct sdw_slave ;#define SDCA_MAX_FUNCTION_COUNT 8
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 4/13 ASoC: SDCA: Correct FDL locking in sdca_fdl_process()
In reply to Charles KeepaxThe current locking in sdca_fdl_process() locks over sdca_ump_cancel_timeout() and the timeout work function takes the same lock, this can lead to a deadlock if the work runs as part of the cancel. To fix this move the guard() call to below the cancel timeout, putting it outside the lock.
---
Changes since v2:
- Switched back to guard() and just moved it down a little.
sound/soc/sdca/sdca_fdl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sdca/sdca_fdl.c +2 -2
@@ -402,8 +402,6 @@ int sdca_fdl_process(struct sdca_interrupt *interrupt)unsigned int reg, status;int response, ret; -guard (mutex)(&fdl_state->lock); - ret =sdca_ump_get_owner_host (dev, interrupt->function_regmap, interrupt->function, interrupt->entity, interrupt->control);
@@ -412,6 +410,8 @@ int sdca_fdl_process(struct sdca_interrupt *interrupt)sdca_ump_cancel_timeout (&fdl_state->timeout); +guard (mutex)(&fdl_state->lock); + reg =SDW_SDCA_CTL (interrupt->function->desc->adr, interrupt->entity->id,SDCA_CTL_XU_FDL_STATUS ,0 ); ret =regmap_read (interrupt->function_regmap, reg, &status);
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 5/13 ASoC: SDCA: Add comment for function reset polling
In reply to Charles KeepaxAdd a comment to better explain the function reset polling rate.
---
Changes since v2:
- Correct some spelling
sound/soc/sdca/sdca_fdl.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/sdca/sdca_fdl.c +4 -0
@@ -51,6 +51,10 @@ int sdca_reset_function(struct device *dev, struct sdca_function_data *function,return -EINVAL ; } +/* +* Poll up to 16 times but no more than once per ms, these are just +* arbitrarily selected values, so may be fine tuned in future. +*/ poll_us =umin (function->reset_max_delay >>4 ,1000 ); ret = regmap_read_poll_timeout(regmap, reg, val, !val, poll_us,
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 6/13 ASoC: SDCA: Move most of the messages from info to debug
In reply to Charles KeepaxThe SDCA code is very spammy on boot as it prints a lot of parsing details using info prints. Now primary development is complete move these to debug prints to reduce the spam.
---
No changes since v2.
sound/soc/sdca/sdca_functions.c | 50 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 26 deletions(-)
sound/soc/sdca/sdca_functions.c +24 -26
@@ -6,8 +6,6 @@* https://www.mipi.org/mipi-sdca-v1-0-download */ -#define dev_fmt (fmt) "%s: " fmt, __func__ -#include <linux/acpi.h> #include <linux/byteorder/generic.h> #include <linux/cleanup.h>
@@ -1010,10 +1008,10 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti control->type =find_sdca_control_datatype (entity, control); control->nbits =find_sdca_control_bits (entity, control); -dev_info (dev,"%s: %s: control %#x mode %#x layers %#x cn %#llx int %d %s\n" , - entity->label, control->label, control->sel, - control->mode, control->layers, control->cn_list, - control->interrupt_position, control->deferrable ?"deferrable" :"" ); +dev_dbg (dev,"%s: %s: control %#x mode %#x layers %#x cn %#llx int %d %s\n" , + entity->label, control->label, control->sel, + control->mode, control->layers, control->cn_list, + control->interrupt_position, control->deferrable ?"deferrable" :"" );return 0 ; }
@@ -1134,9 +1132,9 @@ static int find_sdca_entity_iot(struct device *dev,if (!ret) terminal->num_transducer = tmp; -dev_info (dev,"%s: terminal type %#x ref %#x conn %#x count %d\n" , - entity->label, terminal->type, terminal->reference, - terminal->connector, terminal->num_transducer); +dev_dbg (dev,"%s: terminal type %#x ref %#x conn %#x count %d\n" , + entity->label, terminal->type, terminal->reference, + terminal->connector, terminal->num_transducer);return 0 ; }
@@ -1162,8 +1160,8 @@ static int find_sdca_entity_cs(struct device *dev,if (!ret) clock->max_delay = tmp; -dev_info (dev,"%s: clock type %#x delay %d\n" , entity->label, - clock->type, clock->max_delay); +dev_dbg (dev,"%s: clock type %#x delay %d\n" , entity->label, + clock->type, clock->max_delay);return 0 ; }
@@ -1214,8 +1212,8 @@ static int find_sdca_entity_pde(struct device *dev, delays[i].to_ps = delay_list[j++]; delays[i].us = delay_list[j++]; -dev_info (dev,"%s: from %#x to %#x delay %dus\n" , entity->label, - delays[i].from_ps, delays[i].to_ps, delays[i].us); +dev_dbg (dev,"%s: from %#x to %#x delay %dus\n" , entity->label, + delays[i].from_ps, delays[i].to_ps, delays[i].us); } power->num_max_delay = num_delays;
@@ -1444,8 +1442,8 @@ static int find_sdca_entity(struct device *dev, struct sdw_slave *sdw, entity->type = tmp; -dev_info (dev,"%s: entity %#x type %#x\n" , - entity->label, entity->id, entity->type); +dev_dbg (dev,"%s: entity %#x type %#x\n" , + entity->label, entity->id, entity->type);switch (entity->type) {case SDCA_ENTITY_TYPE_IT :
@@ -1620,7 +1618,7 @@ static int find_sdca_entity_connection_iot(struct device *dev, terminal->clock = clock_entity; -dev_info (dev,"%s -> %s\n" , clock_entity->label, entity->label); +dev_dbg (dev,"%s -> %s\n" , clock_entity->label, entity->label);fwnode_handle_put (clock_node);return 0 ;
@@ -1670,7 +1668,7 @@ static int find_sdca_entity_connection_pde(struct device *dev,return -EINVAL ; } -dev_info (dev,"%s -> %s\n" , managed[i]->label, entity->label); +dev_dbg (dev,"%s -> %s\n" , managed[i]->label, entity->label); } power->num_managed = num_managed;
@@ -1805,7 +1803,7 @@ static int find_sdca_entity_connection(struct device *dev, pins[i] = connected_entity; -dev_info (dev,"%s -> %s\n" , connected_entity->label, entity->label); +dev_dbg (dev,"%s -> %s\n" , connected_entity->label, entity->label); i++;fwnode_handle_put (connected_node);
@@ -1890,8 +1888,8 @@ static int find_sdca_cluster_channel(struct device *dev, channel->relationship = tmp; -dev_info (dev,"cluster %#x: channel id %#x purpose %#x relationship %#x\n" , - cluster->id, channel->id, channel->purpose, channel->relationship); +dev_dbg (dev,"cluster %#x: channel id %#x purpose %#x relationship %#x\n" , + cluster->id, channel->id, channel->purpose, channel->relationship);return 0 ; }
@@ -2062,7 +2060,7 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw,return -EINVAL ; } -dev_info (dev,"fileset: %#x\n" , filesets_list[i]); +dev_dbg (dev,"fileset: %#x\n" , filesets_list[i]); files =devm_kcalloc (dev, num_entries / mult_fileset,sizeof (struct sdca_fdl_file ),GFP_KERNEL );
@@ -2083,8 +2081,8 @@ static int find_sdca_filesets(struct device *dev, struct sdw_slave *sdw, file->file_id = fileset_entries[j++]; file->fdl_offset = fileset_entries[j++]; -dev_info (dev,"file: %#x, vendor: %#x, offset: %#x\n" , - file->file_id, file->vendor_id, file->fdl_offset); +dev_dbg (dev,"file: %#x, vendor: %#x, offset: %#x\n" , + file->file_id, file->vendor_id, file->fdl_offset); } set->id = filesets_list[i];
@@ -2127,9 +2125,9 @@ int sdca_parse_function(struct device *dev, struct sdw_slave *sdw,if (!ret) function->reset_max_delay = tmp; -dev_info (dev,"%pfwP: name %s busy delay %dus reset delay %dus\n" , - function->desc->node, function->desc->name, - function->busy_max_delay, function->reset_max_delay); +dev_dbg (dev,"%pfwP: name %s busy delay %dus reset delay %dus\n" , + function->desc->node, function->desc->name, + function->busy_max_delay, function->reset_max_delay); ret =find_sdca_init_table (dev, function_desc->node, function);if (ret)
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 7/13 ASoC: SDCA: Use helper macros for control identification
In reply to Charles KeepaxWe have the SDCA_CTL_TYPE helper macros, we should use them when identifying specific controls to simplify the code a little.
---
No changes since v2.
sound/soc/sdca/sdca_interrupts.c | 36 +++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-)
sound/soc/sdca/sdca_interrupts.c +14 -22
@@ -456,11 +456,8 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap,else if (!interrupt)continue ; -switch (entity->type) { -case SDCA_ENTITY_TYPE_XU : -if (control->sel !=SDCA_CTL_XU_FDL_CURRENTOWNER ) -break ; - +switch (SDCA_CTL_TYPE (entity->type, control->sel)) { +case SDCA_CTL_TYPE_S (XU ,FDL_CURRENTOWNER ): ret =sdca_irq_data_populate (dev, regmap,NULL , function, entity, control, interrupt);
@@ -534,27 +531,22 @@ int sdca_irq_populate(struct sdca_function_data *function, handler = base_handler; -switch (entity->type) { -case SDCA_ENTITY_TYPE_ENTITY_0 : -if (control->sel ==SDCA_CTL_ENTITY_0_FUNCTION_STATUS ) - handler = function_status_handler; +switch (SDCA_CTL_TYPE (entity->type, control->sel)) { +case SDCA_CTL_TYPE_S (ENTITY_0 ,FUNCTION_STATUS ): + handler = function_status_handler;break ; -case SDCA_ENTITY_TYPE_GE : -if (control->sel ==SDCA_CTL_GE_DETECTED_MODE ) - handler = detected_mode_handler; +case SDCA_CTL_TYPE_S (GE ,DETECTED_MODE ): + handler = detected_mode_handler;break ; -case SDCA_ENTITY_TYPE_XU : -if (control->sel ==SDCA_CTL_XU_FDL_CURRENTOWNER ) { - ret =sdca_fdl_alloc_state (interrupt); -if (ret) -return ret; +case SDCA_CTL_TYPE_S (XU ,FDL_CURRENTOWNER ): + ret =sdca_fdl_alloc_state (interrupt); +if (ret) +return ret; - handler = fdl_owner_handler; - } + handler = fdl_owner_handler;break ; -case SDCA_ENTITY_TYPE_HIDE : -if (control->sel ==SDCA_CTL_HIDE_HIDTX_CURRENTOWNER ) - handler = hid_handler; +case SDCA_CTL_TYPE_S (HIDE ,HIDTX_CURRENTOWNER ): + handler = hid_handler;break ;default :break ;
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 8/13 ASoC: SDCA: Factor out helper to process Control defaults
In reply to Charles KeepaxThe indentation of the loop processing writing out SDCA Control default values is getting a bit large. Reduce indentation and make adding more functionality easier by factoring out the Control handling into a helper function.
---
No changes since v2.
sound/soc/sdca/sdca_regmap.c | 61 +++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 22 deletions(-)
sound/soc/sdca/sdca_regmap.c +39 -22
@@ -275,6 +275,40 @@ int sdca_regmap_populate_constants(struct device *dev, }EXPORT_SYMBOL_NS (sdca_regmap_populate_constants,"SND_SOC_SDCA" ); +static int populate_control_defaults (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function, +struct sdca_entity *entity, +struct sdca_control *control) +{ +int i, ret; +int cn; + +if (control->mode ==SDCA_ACCESS_MODE_DC ) +return 0 ; + +if (!control->has_default && !control->has_fixed) +return 0 ; + + i =0 ; +for_each_set_bit (cn, (unsigned long *)&control->cn_list, +BITS_PER_TYPE (control->cn_list)) { +unsigned int reg; + + reg =SDW_SDCA_CTL (function->desc->adr, entity->id, control->sel, cn); + + ret =regmap_write (regmap, reg, control->values[i]); +if (ret) { +dev_err (dev,"Failed to write default %#x: %d\n" , + reg, ret); +return ret; + } + + i++; + } + +return 0 ; +} +/** * sdca_regmap_write_defaults - write out DisCo defaults to device * @dev: Pointer to the device.
@@ -290,7 +324,7 @@ EXPORT_SYMBOL_NS(sdca_regmap_populate_constants, "SND_SOC_SDCA");int sdca_regmap_write_defaults (struct device *dev,struct regmap *regmap,struct sdca_function_data *function) { -int i, j, k; +int i, j;int ret;for (i =0 ; i < function->num_entities; i++) {
@@ -298,28 +332,11 @@ int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,for (j =0 ; j < entity->num_controls; j++) {struct sdca_control *control = &entity->controls[j]; -int cn; - -if (control->mode ==SDCA_ACCESS_MODE_DC ) -continue ; -if (!control->has_default && !control->has_fixed) -continue ; - - k =0 ; -for_each_set_bit (cn, (unsigned long *)&control->cn_list, -BITS_PER_TYPE (control->cn_list)) { -unsigned int reg; - - reg =SDW_SDCA_CTL (function->desc->adr, entity->id, - control->sel, cn); - - ret =regmap_write (regmap, reg, control->values[k]); -if (ret) -return ret; - - k++; - } + ret =populate_control_defaults (dev, regmap, function, + entity, control); +if (ret) +return ret; } }
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 9/13 ASoC: SDCA: Populate regmap cache for readable Controls
In reply to Charles KeepaxIt is not uncommon for an SDCA Control to have no specified default value in the DisCo. Non-volatile registers with no defaults will not be present in the cache until they are accessed. However, if the first operation user-space performs is a read whilst the device is runtime suspended this read will fail.
To avoid such problems we should populate values from the hardware into the cache for all non-volatile readable registers with no defaults. Update the defaults handling to do this cache population since it is iterating over the Controls and happens at a time the hardware is always powered up.
---
No changes since v2.
sound/soc/sdca/sdca_regmap.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
sound/soc/sdca/sdca_regmap.c +22 -10
@@ -286,24 +286,33 @@ static int populate_control_defaults(struct device *dev, struct regmap *regmap,if (control->mode ==SDCA_ACCESS_MODE_DC )return 0 ; -if (!control->has_default && !control->has_fixed) +if (control->layers &SDCA_ACCESS_LAYER_DEVICE )return 0 ; i =0 ;for_each_set_bit (cn, (unsigned long *)&control->cn_list,BITS_PER_TYPE (control->cn_list)) { -unsigned int reg; +unsigned int reg, val; reg =SDW_SDCA_CTL (function->desc->adr, entity->id, control->sel, cn); - ret =regmap_write (regmap, reg, control->values[i]); -if (ret) { -dev_err (dev,"Failed to write default %#x: %d\n" , - reg, ret); -return ret; - } +if (control->has_default || control->has_fixed) { + ret =regmap_write (regmap, reg, control->values[i]); +if (ret) { +dev_err (dev,"Failed to write default %#x: %d\n" , + reg, ret); +return ret; + } - i++; + i++; + }else if (!control->is_volatile) { + ret =regmap_read (regmap, reg, &val); +if (ret) { +dev_err (dev,"Failed to read initial %#x: %d\n" , + reg, ret); +return ret; + } + } }return 0 ;
@@ -317,7 +326,10 @@ static int populate_control_defaults(struct device *dev, struct regmap *regmap,* * This function will write out to the hardware all the DisCo default and * fixed value controls. This will cause them to be populated into the cache, -* and subsequent handling can be done through a cache sync. +* and subsequent handling can be done through a cache sync. It will also +* read any non-volatile registers that don't have defaults/fixed values to +* populate those into the cache, this ensures they are available for reads +* even when the device is runtime suspended. * * Return: Returns zero on success, and a negative error code on failure. */
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 10/13 ASoC: SDCA: Add helper to write initialization writes
In reply to Charles KeepaxAdd a helper function to write out the SDCA blind initialization writes.
---
No changes since v2.
include/sound/sdca_regmap.h | 2 ++ sound/soc/sdca/sdca_regmap.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+)
include/sound/sdca_regmap.h +2 -0
@@ -27,5 +27,7 @@ int sdca_regmap_populate_constants(struct device *dev, struct sdca_function_dataint sdca_regmap_write_defaults (struct device *dev,struct regmap *regmap,struct sdca_function_data *function); +int sdca_regmap_write_init (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function);#endif // __SDCA_REGMAP_H__
sound/soc/sdca/sdca_regmap.c +16 -0
@@ -355,3 +355,19 @@ int sdca_regmap_write_defaults(struct device *dev, struct regmap *regmap,return 0 ; }EXPORT_SYMBOL_NS (sdca_regmap_write_defaults,"SND_SOC_SDCA" ); + +int sdca_regmap_write_init (struct device *dev,struct regmap *regmap, +struct sdca_function_data *function) +{ +struct sdca_init_write *init = function->init_table; +int ret, i; + +for (i =0 ; i < function->num_init_table; i++) { + ret =regmap_write (regmap, init[i].addr, init[i].val); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_NS (sdca_regmap_write_init,"SND_SOC_SDCA" );
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 11/13 ASoC: SDCA: add function devices
In reply to Charles KeepaxFrom: Pierre-Louis Bossart <[email protected]>
Use the auxiliary bus to register/unregister subdevices for each function. Each function will be handled with a separate driver, matched using a name.
If a vendor wants to override a specific function driver, they could use a custom name to match with a custom function driver.
---
No changes since v2.
include/sound/sdca.h | 13 +++ sound/soc/sdca/Kconfig | 1 + sound/soc/sdca/Makefile | 4 +- sound/soc/sdca/sdca_function_device.c | 117 ++++++++++++++++++++++++++ sound/soc/sdca/sdca_function_device.h | 15 ++++ 5 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 sound/soc/sdca/sdca_function_device.c create mode 100644 sound/soc/sdca/sdca_function_device.h
include/sound/sdca.h +13 -0
@@ -15,18 +15,21 @@struct acpi_table_swft ;struct fwnode_handle ;struct sdw_slave ; +struct sdca_dev ;#define SDCA_MAX_FUNCTION_COUNT 8/** * struct sdca_function_desc - short descriptor for an SDCA Function * @node: firmware node for the Function. +* @func_dev: pointer to SDCA function device. * @name: Human-readable string. * @type: Function topology type. * @adr: ACPI address (used for SDCA register access). */ struct sdca_function_desc {struct fwnode_handle *node; +struct sdca_dev *func_dev;const char *name;u32 type;u8 adr;
@@ -59,6 +62,8 @@ void sdca_lookup_functions(struct sdw_slave *slave);void sdca_lookup_swft (struct sdw_slave *slave);void sdca_lookup_interface_revision (struct sdw_slave *slave);bool sdca_device_quirk_match (struct sdw_slave *slave,enum sdca_quirk quirk); +int sdca_dev_register_functions (struct sdw_slave *slave); +void sdca_dev_unregister_functions (struct sdw_slave *slave);#else
@@ -69,6 +74,14 @@ static inline bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_qu {return false; } + +static inline int sdca_dev_register_functions (struct sdw_slave *slave) +{ +return 0 ; +} + +static inline void sdca_dev_unregister_functions (struct sdw_slave *slave) {} +#endif #endif
sound/soc/sdca/Kconfig +1 -0
@@ -4,6 +4,7 @@ menu "SoundWire (SDCA)" config SND_SOC_SDCA tristate depends on ACPI + select AUXILIARY_BUS help This option enables support for the MIPI SoundWire Device Class for Audio (SDCA).
sound/soc/sdca/Makefile +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-sdca-y := sdca_functions.o sdca_device.o sdca_regmap.o sdca_asoc.o \ - sdca_ump.o +snd-soc-sdca-y := sdca_functions.o sdca_device.o sdca_function_device.o \ + sdca_regmap.o sdca_asoc.o sdca_ump.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_HID) += sdca_hid.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_IRQ) += sdca_interrupts.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_FDL) += sdca_fdl.o
sound/soc/sdca/sdca_function_device.c new file +117 -0
117 lines not on this page · raw message
sound/soc/sdca/sdca_function_device.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/* Copyright(c) 2024 Intel Corporation. */ + +#ifndef __SDCA_FUNCTION_DEVICE_H +#define __SDCA_FUNCTION_DEVICE_H + +struct sdca_dev { +struct auxiliary_device auxdev; +struct sdca_function_data function; +}; + +#define auxiliary_dev_to_sdca_dev (auxiliary_dev) \ + container_of(auxiliary_dev, struct sdca_dev, auxdev) + +#endif
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 12/13 ASoC: SDCA: Add basic SDCA class driver
In reply to Charles KeepaxAdd a device level driver as the entry point for the class driver. Additional auxiliary drivers will be registered to support each function within the device. This driver will register those function drivers and provide the device level functionality, such as monitoring bus attach/detach, the device level register map, and the root for the IRQ handling.
---
No changes since v2.
include/linux/soundwire/sdw_registers.h | 2 + sound/soc/sdca/Kconfig | 10 + sound/soc/sdca/Makefile | 4 + sound/soc/sdca/sdca_class.c | 304 ++++++++++++++++++++++++ sound/soc/sdca/sdca_class.h | 37 +++ 5 files changed, 357 insertions(+) create mode 100644 sound/soc/sdca/sdca_class.c create mode 100644 sound/soc/sdca/sdca_class.h
include/linux/soundwire/sdw_registers.h +2 -0
@@ -355,4 +355,6 @@/* Check the reserved and fixed bits in address */ #define SDW_SDCA_VALID_CTL (reg) (((reg) & (GENMASK(31, 25) | BIT(18) | BIT(13))) == BIT(30)) +#define SDW_SDCA_MAX_REGISTER 0x47FFFFFF +#endif /* __SDW_REGISTERS_H */
sound/soc/sdca/Kconfig +10 -0
@@ -37,4 +37,14 @@ config SND_SOC_SDCA_FDL config SND_SOC_SDCA_OPTIONAL def_tristate SND_SOC_SDCA || !SND_SOC_SDCA +config SND_SOC_SDCA_CLASS + tristate "SDCA Class Driver" + select SND_SOC_SDCA + select SND_SOC_SDCA_FDL + select SND_SOC_SDCA_HID + select SND_SOC_SDCA_IRQ + help + This option enables support for the SDCA Class driver which should + support any class compliant SDCA part. + endmenu
sound/soc/sdca/Makefile +4 -0
@@ -6,4 +6,8 @@ snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_HID) += sdca_hid.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_IRQ) += sdca_interrupts.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_FDL) += sdca_fdl.o +snd-soc-sdca-class-y := sdca_class.o + obj-$(CONFIG_SND_SOC_SDCA) += snd-soc-sdca.o + +obj-$(CONFIG_SND_SOC_SDCA_CLASS) += snd-soc-sdca-class.o
sound/soc/sdca/sdca_class.c new file +304 -0
304 lines not on this page · raw message
sound/soc/sdca/sdca_class.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* The MIPI SDCA specification is available for public downloads at +* https://www.mipi.org/mipi-sdca-v1-0-download +* +* Copyright (C) 2025 Cirrus Logic, Inc. and +* Cirrus Logic International Semiconductor Ltd. +*/ + +#ifndef __SDCA_CLASS_H__ +#define __SDCA_CLASS_H__ + +#include <linux/completion.h> +#include <linux/mutex.h> +#include <linux/workqueue.h> + +struct device ; +struct regmap ; +struct sdw_slave ; +struct sdca_function_data ; + +struct sdca_class_drv { +struct device *dev; +struct regmap *dev_regmap; +struct sdw_slave *sdw; + +struct sdca_function_data *functions; +struct sdca_interrupt_info *irq_info; + +struct mutex regmap_lock; +struct work_struct boot_work; +struct completion device_attach; + +bool attached; +}; + +#endif /* __SDCA_CLASS_H__ */
Signature · 1 line
2.47.3
Charles Keepax
maintainerPATCH v3 13/13 ASoC: SDCA: Add basic SDCA function driver
In reply to Charles KeepaxAdd a driver to support the individual SDCA functions within the class driver. Use the SDCA helpers to parse the DisCo information and register a function driver based on those properties. Manage the boot of the function, reset, FDL, defaults. Manage the function level register map.
---
Changes since v2:
- Renamed suspend/resume functions to be a little less wordy.
sound/soc/sdca/Kconfig | 7 + sound/soc/sdca/Makefile | 2 + sound/soc/sdca/sdca_class_function.c | 460 +++++++++++++++++++++++++++ 3 files changed, 469 insertions(+) create mode 100644 sound/soc/sdca/sdca_class_function.c
sound/soc/sdca/Kconfig +7 -0
@@ -39,6 +39,7 @@ config SND_SOC_SDCA_OPTIONAL config SND_SOC_SDCA_CLASS tristate "SDCA Class Driver" + select SND_SOC_SDCA_CLASS_FUNCTION select SND_SOC_SDCA select SND_SOC_SDCA_FDL select SND_SOC_SDCA_HID
@@ -47,4 +48,10 @@ config SND_SOC_SDCA_CLASS This option enables support for the SDCA Class driver which should support any class compliant SDCA part. +config SND_SOC_SDCA_CLASS_FUNCTION + tristate + help + This option enables support for the SDCA Class Function drivers, + these implement the individual functions of the SDCA Class driver. + endmenu
sound/soc/sdca/Makefile +2 -0
@@ -7,7 +7,9 @@ snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_IRQ) += sdca_interrupts.o snd-soc-sdca-$(CONFIG_SND_SOC_SDCA_FDL) += sdca_fdl.o snd-soc-sdca-class-y := sdca_class.o +snd-soc-sdca-class-function-y := sdca_class_function.o obj-$(CONFIG_SND_SOC_SDCA) += snd-soc-sdca.o obj-$(CONFIG_SND_SOC_SDCA_CLASS) += snd-soc-sdca-class.o +obj-$(CONFIG_SND_SOC_SDCA_CLASS_FUNCTION) += snd-soc-sdca-class-function.o
sound/soc/sdca/sdca_class_function.c new file +460 -0
460 lines not on this page · raw message
Signature · 1 line
2.47.3
Liao, Bard
maintainerQuoted 54 lines · Charles Keepax
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers representing each of the functions of the SDCA device. These drivers all use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.
Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
Thanks,
CharlesChanges since v2:
- Updated the locking insdca_fdl_process
- Correct some spelling in comments
- Renamed suspend/resume functions to be a little shortChanges since v1:
- Add a bunch of bug fix patches
- Change some prints to dbgs
- Add some additional comments
- Flip order on regcache operations in resumeCharles Keepax (12):
ASoC: SDCA: Remove duplicated module macros
ASoC: SDCA: Fix missing dash in HIDE DisCo property
ASoC: SDCA: Add missing forward declaration in header
ASoC: SDCA: Correct FDL locking insdca_fdl_process()
ASoC: SDCA: Add comment for function reset polling
ASoC: SDCA: Move most of the messages from info to debug
ASoC: SDCA: Use helper macros for control identification
ASoC: SDCA: Factor out helper to process Control defaults
ASoC: SDCA: Populate regmap cache for readable Controls
ASoC: SDCA: Add helper to write initialization writes
ASoC: SDCA: Add basic SDCA class driver
ASoC: SDCA: Add basic SDCA function driverPierre-Louis Bossart (1):
ASoC: SDCA: add function devicesinclude/linux/soundwire/sdw_registers.h | 2 + include/sound/sdca.h | 14 + include/sound/sdca_regmap.h | 2 + sound/soc/sdca/Kconfig | 18 + sound/soc/sdca/Makefile | 10 +- sound/soc/sdca/sdca_class.c | 304 ++++++++++++++++ sound/soc/sdca/sdca_class.h | 37 ++ sound/soc/sdca/sdca_class_function.c | 460 ++++++++++++++++++++++++ sound/soc/sdca/sdca_fdl.c | 8 +- sound/soc/sdca/sdca_function_device.c | 117 ++++++ sound/soc/sdca/sdca_function_device.h | 15 + sound/soc/sdca/sdca_functions.c | 52 ++- sound/soc/sdca/sdca_hid.c | 3 -
Quoted 9 lines
sound/soc/sdca/sdca_interrupts.c | 39 +- sound/soc/sdca/sdca_regmap.c | 89 +++-- 15 files changed, 1089 insertions(+), 81 deletions(-) create mode 100644 sound/soc/sdca/sdca_class.c create mode 100644 sound/soc/sdca/sdca_class.h create mode 100644 sound/soc/sdca/sdca_class_function.c create mode 100644 sound/soc/sdca/sdca_function_device.c create mode 100644 sound/soc/sdca/sdca_function_device.h
For this series: Tested-by: Bard Liao <[email protected]>
W dniu czw, 06.11.2025 o godzinie 11∶44 +0000, użytkownik Charles
Quoted 59 lines · Keepax
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers
representing each of the functions of the SDCA device. These drivers all
use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
Thanks,
CharlesChanges since v2:
- Updated the locking insdca_fdl_process
- Correct some spelling in comments
- Renamed suspend/resume functions to be a little shortChanges since v1:
- Add a bunch of bug fix patches
- Change some prints to dbgs
- Add some additional comments
- Flip order on regcache operations in resumeCharles Keepax (12):
ASoC: SDCA: Remove duplicated module macros
ASoC: SDCA: Fix missing dash in HIDE DisCo property
ASoC: SDCA: Add missing forward declaration in header
ASoC: SDCA: Correct FDL locking insdca_fdl_process()
ASoC: SDCA: Add comment for function reset polling
ASoC: SDCA: Move most of the messages from info to debug
ASoC: SDCA: Use helper macros for control identification
ASoC: SDCA: Factor out helper to process Control defaults
ASoC: SDCA: Populate regmap cache for readable Controls
ASoC: SDCA: Add helper to write initialization writes
ASoC: SDCA: Add basic SDCA class driver
ASoC: SDCA: Add basic SDCA function driverPierre-Louis Bossart (1):
ASoC: SDCA: add function devicesinclude/linux/soundwire/sdw_registers.h | 2 + include/sound/sdca.h | 14 + include/sound/sdca_regmap.h | 2 + sound/soc/sdca/Kconfig | 18 + sound/soc/sdca/Makefile | 10 +- sound/soc/sdca/sdca_class.c | 304 ++++++++++++++++ sound/soc/sdca/sdca_class.h | 37 ++ sound/soc/sdca/sdca_class_function.c | 460
++++++++++++++++++++++++
sound/soc/sdca/sdca_fdl.c | 8 +- sound/soc/sdca/sdca_function_device.c | 117 ++++++ sound/soc/sdca/sdca_function_device.h | 15 + sound/soc/sdca/sdca_functions.c | 52 ++- sound/soc/sdca/sdca_hid.c | 3 - sound/soc/sdca/sdca_interrupts.c | 39 +- sound/soc/sdca/sdca_regmap.c | 89 +++--
Quoted 6 lines
15 files changed, 1089 insertions(+), 81 deletions(-)create mode 100644
sound/soc/sdca/sdca_class.ccreate mode 100644sound/soc/sdca/sdca_class.hcreate mode 100644sound/soc/sdca/sdca_class_function.ccreate mode 100644sound/soc/sdca/sdca_function_device.ccreate mode 100644sound/soc/sdca/sdca_function_device.h
For the series:
Signature · 2 lines
Regards, Maciej
Quoted 17 lines · Charles Keepax
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers representing each of the functions of the SDCA device. These drivers all use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.
Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
Thanks,
CharlesChanges since v2:
- Updated the locking insdca_fdl_process
- Correct some spelling in comments
- Renamed suspend/resume functions to be a little short
Quoted 5 lines
Changes since v1:
- Add a bunch of bug fix patches
- Change some prints to dbgs
- Add some additional comments
- Flip order on regcache operations in resume
Quoted 40 lines
Charles Keepax (12):
ASoC: SDCA: Remove duplicated module macros
ASoC: SDCA: Fix missing dash in HIDE DisCo property
ASoC: SDCA: Add missing forward declaration in header
ASoC: SDCA: Correct FDL locking insdca_fdl_process()
ASoC: SDCA: Add comment for function reset polling
ASoC: SDCA: Move most of the messages from info to debug
ASoC: SDCA: Use helper macros for control identification
ASoC: SDCA: Factor out helper to process Control defaults
ASoC: SDCA: Populate regmap cache for readable Controls
ASoC: SDCA: Add helper to write initialization writes
ASoC: SDCA: Add basic SDCA class driver
ASoC: SDCA: Add basic SDCA function driverPierre-Louis Bossart (1):
ASoC: SDCA: add function devicesinclude/linux/soundwire/sdw_registers.h | 2 + include/sound/sdca.h | 14 + include/sound/sdca_regmap.h | 2 + sound/soc/sdca/Kconfig | 18 + sound/soc/sdca/Makefile | 10 +- sound/soc/sdca/sdca_class.c | 304 ++++++++++++++++ sound/soc/sdca/sdca_class.h | 37 ++ sound/soc/sdca/sdca_class_function.c | 460 ++++++++++++++++++++++++ sound/soc/sdca/sdca_fdl.c | 8 +- sound/soc/sdca/sdca_function_device.c | 117 ++++++ sound/soc/sdca/sdca_function_device.h | 15 + sound/soc/sdca/sdca_functions.c | 52 ++- sound/soc/sdca/sdca_hid.c | 3 - sound/soc/sdca/sdca_interrupts.c | 39 +- sound/soc/sdca/sdca_regmap.c | 89 +++-- 15 files changed, 1089 insertions(+), 81 deletions(-) create mode 100644 sound/soc/sdca/sdca_class.c create mode 100644 sound/soc/sdca/sdca_class.h create mode 100644 sound/soc/sdca/sdca_class_function.c create mode 100644 sound/soc/sdca/sdca_function_device.c create mode 100644 sound/soc/sdca/sdca_function_device.h
Signature · 1 line
Péter
Quoted 11 lines · Charles Keepax
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers representing each of the functions of the SDCA device. These drivers all use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.
Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
Thanks,
Charles
Mark Brown
maintainerQuoted 10 lines · Charles Keepax
This series adds an initial SDCA class driver, this consists of a primary driver attached to the SoundWire device, and auxiliary drivers representing each of the functions of the SDCA device. These drivers all use the APIs added over the past series's to provide the class functionality, as such these final drivers themselves are quite thin.
Also a few fix ups at the start of the series that have gathered up whilst the last SDCA series was in review.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/13] ASoC: SDCA: Remove duplicated module macros
commit: 549f618516a17f7d492cf64048713f77e057cd37
[02/13] ASoC: SDCA: Fix missing dash in HIDE DisCo property
commit: 3508311f2e1c872b645f13c6fd52840418089d41
[03/13] ASoC: SDCA: Add missing forward declaration in header
commit: 5fe65824b74c0414f105f0535437108cd6c31cc7
[04/13] ASoC: SDCA: Correct FDL locking in sdca_fdl_process()
commit: cc58055bfefa065b68a8ab92a0196c9b24f46f02
[05/13] ASoC: SDCA: Add comment for function reset polling
commit: 336beae295bf6973e5c8c222dfec6b8faf3c55f6
[06/13] ASoC: SDCA: Move most of the messages from info to debug
commit: edb82534ee655091e198edf95e223115dc27c284
[07/13] ASoC: SDCA: Use helper macros for control identification
commit: fb62da31fad29fe3c9844ba217b9bc99820d4622
[08/13] ASoC: SDCA: Factor out helper to process Control defaults
commit: 222cbe172e5f7de130cc9c3c85f8f33d51c131bc
[09/13] ASoC: SDCA: Populate regmap cache for readable Controls
commit: 193c65ec8ed4d946b3f80b7d08e4320ded7ac4fa
[10/13] ASoC: SDCA: Add helper to write initialization writes
commit: 5acf17b6df5e759bfb8bc0a75fadcbb3e363a17b
[11/13] ASoC: SDCA: add function devices
commit: 4496d1c65bad7a3a32d2e09aaf3c54bc562c3fcc
[12/13] ASoC: SDCA: Add basic SDCA class driver
commit: 2d877d0659cb69cc0677ee2805e9521966d70ac5
[13/13] ASoC: SDCA: Add basic SDCA function driver
commit: 3af1815a2f9caebfc666af3912e24d030a5368d5All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark