public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <lgirdwood@gmail.com>, <yung-chuan.liao@linux.intel.com>,
	<pierre-louis.bossart@linux.dev>,
	<peter.ujfalusi@linux.intel.com>, <linux-sound@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>
Subject: [PATCH 09/10] ASoC: SDCA: Add support for clock Entity properties
Date: Wed, 5 Feb 2025 11:38:00 +0000	[thread overview]
Message-ID: <20250205113801.3699902-10-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20250205113801.3699902-1-ckeepax@opensource.cirrus.com>

Add support for parsing the Clock Source Entity properties from
DisCo/ACPI.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 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 6cb5ab79ee547..13edc976679ac 100644
--- a/include/sound/sdca_function.h
+++ b/include/sound/sdca_function.h
@@ -784,6 +784,29 @@ struct sdca_entity_iot {
 	bool is_dataport;
 };
 
+/**
+ * enum sdca_clock_type - SDCA Clock Types
+ *
+ * Indicate the synchronicity 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: Synchronicity 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
@@ -846,6 +869,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;
@@ -858,6 +882,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 8a143048a0ab9..dd9e2dce6e658 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -881,6 +881,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,
@@ -913,6 +940,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;
 	}
-- 
2.39.5


  parent reply	other threads:[~2025-02-05 11:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 11:37 [PATCH 00/10] Add SDCA DisCo parsing support Charles Keepax
2025-02-05 11:37 ` [PATCH 01/10] ASoC: SDCA: Minor formatting and naming tweaks Charles Keepax
2025-02-05 11:37 ` [PATCH 02/10] ASoC: SDCA: Add code to parse Function information Charles Keepax
2025-02-05 11:37 ` [PATCH 03/10] ASoC: SDCA: Parse initialization write table Charles Keepax
2025-02-05 11:37 ` [PATCH 04/10] ASoC: SDCA: Add support for Entity 0 Charles Keepax
2025-02-05 11:37 ` [PATCH 05/10] ASoC: SDCA: Add SDCA Control parsing Charles Keepax
2025-02-05 11:37 ` [PATCH 06/10] ASoC: SDCA: Add parsing for Control range structures Charles Keepax
2025-02-05 11:37 ` [PATCH 07/10] ASoC: SDCA: Add Channel Cluster parsing Charles Keepax
2025-02-05 11:37 ` [PATCH 08/10] ASoC: SDCA: Add support for IT/OT Entity properties Charles Keepax
2025-02-05 11:38 ` Charles Keepax [this message]
2025-02-05 11:38 ` [PATCH 10/10] ASoC: SDCA: Add support for PDE " Charles Keepax
2025-02-07 17:14 ` [PATCH 00/10] Add SDCA DisCo parsing support Pierre-Louis Bossart
2025-02-10 16:30 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250205113801.3699902-10-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox