From 3f11e303ade9288b5ccd83ffdd851028dd96454f Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Wed, 15 Jan 2025 15:24:12 +0000 Subject: [PATCH] ASoC: SDCA: Add support for clock Entity properties Add supprot for parsing the Clock Source Entity properties from DisCo/ACPI. Signed-off-by: Charles Keepax --- include/sound/sdca_function.h | 25 +++++++++++++++++++++++++ sound/soc/sdca/sdca_functions.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/sound/sdca_function.h b/include/sound/sdca_function.h index e36f91800eec63..ace219a29ca54e 100644 --- a/include/sound/sdca_function.h +++ b/include/sound/sdca_function.h @@ -752,6 +752,29 @@ struct sdca_entity_iot { int num_transducer; }; +/** + * enum sdca_clock_type - SDCA Clock Types + * + * Indicate the synchronisity of an Clock Entity, see section 6.4.1.3 + * of the SDCA v1.0 specification. + */ +enum sdca_clock_type { + SDCA_CLOCK_TYPE_EXTERNAL = 0x00, + SDCA_CLOCK_TYPE_INTERNAL_ASYNC = 0x01, + SDCA_CLOCK_TYPE_INTERNAL_SYNC = 0x02, + SDCA_CLOCK_TYPE_INTERNAL_SOURCE_SYNC = 0x03, +}; + +/** + * struct sdca_entity_cs - information specific to Clock Source Entities + * @type: Synchronisity of the Clock Source. + * @max_delay: The maximum delay in microseconds before the clock is stable. + */ +struct sdca_entity_cs { + enum sdca_clock_type type; + unsigned int max_delay; +}; + /** * enum sdca_entity_type - SDCA Entity Type codes * @SDCA_ENTITY_TYPE_ENTITY_0: Entity 0, not actually from the @@ -814,6 +837,7 @@ enum sdca_entity_type { * @num_sources: Number of sources for the Entity. * @num_controls: Number of Controls for the Entity. * @iot: Input/Output Terminal specific Entity properties. + * @cs: Clock Source specific Entity properties. */ struct sdca_entity { const char *label; @@ -826,6 +850,7 @@ struct sdca_entity { int num_controls; union { struct sdca_entity_iot iot; + struct sdca_entity_cs cs; }; }; diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index 7c44d3b7a28fcb..3c4baf41d5bc66 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -876,6 +876,33 @@ static int find_sdca_entity_iot(struct device *dev, return 0; } +static int find_sdca_entity_cs(struct device *dev, + struct fwnode_handle *entity_node, + struct sdca_entity *entity) +{ + struct sdca_entity_cs *clock = &entity->cs; + u32 tmp; + int ret; + + ret = fwnode_property_read_u32(entity_node, "mipi-sdca-cs-type", &tmp); + if (ret) { + dev_err(dev, "%s: clock type missing: %d\n", entity->label, ret); + return ret; + } + + clock->type = tmp; + + ret = fwnode_property_read_u32(entity_node, + "mipi-sdca-clock-valid-max-delay", &tmp); + if (!ret) + clock->max_delay = tmp; + + dev_info(dev, "%s: clock type %#x delay %d\n", entity->label, + clock->type, clock->max_delay); + + return 0; +} + static int find_sdca_entity(struct device *dev, struct fwnode_handle *function_node, struct fwnode_handle *entity_node, @@ -908,6 +935,9 @@ static int find_sdca_entity(struct device *dev, case SDCA_ENTITY_TYPE_OT: ret = find_sdca_entity_iot(dev, entity_node, entity); break; + case SDCA_ENTITY_TYPE_CS: + ret = find_sdca_entity_cs(dev, entity_node, entity); + break; default: break; }