* [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper
@ 2026-04-30 7:23 Niranjan H Y
2026-04-30 10:57 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Niranjan H Y @ 2026-04-30 7:23 UTC (permalink / raw)
To: linux-sound
Cc: linux-kernel, broonie, ckeepax, lgirdwood, perex, tiwai,
cezary.rojewski, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, baojun.xu,
shenghao-ding, sandeepk, v-hampiholi, Niranjan H Y
Implement sdca_asoc_pde_ensure_ps() helper function to poll for PDE
power state transitions. Per SDCA specification, after writing
REQUESTED_PS, drivers must poll ACTUAL_PS until the target power state
is reached.
Changes include:
- Add sdca_asoc_pde_ensure_ps() to handle ACTUAL_PS polling with
support for device-specific delay tables or default intervals
- Export function via sdca_asoc.h for use by SDCA-compliant drivers
- Refactor entity_pde_event() in sdca_asoc.c to use the helper
Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
v13:
- no change
v12:
- use correct namespace while exporting the variable
- fix missing entity information while logging
v11:
- revert v10 changes
- API is renamed from sdca_asoc_pde_ensure_ps to
sdca_asoc_pde_poll_actual_ps
v10:
- write REQUESTED_PS before checking the target state.
- change the API name sdca_asoc_pde_ensure_ps to
sdca_asoc_set_pde_poll_sync
v9:
- newly added interface
---
include/sound/sdca_asoc.h | 6 +++
sound/soc/sdca/sdca_asoc.c | 106 ++++++++++++++++++++++++++-----------
2 files changed, 82 insertions(+), 30 deletions(-)
diff --git a/include/sound/sdca_asoc.h b/include/sound/sdca_asoc.h
index 46a61a52d..ca35d5a44 100644
--- a/include/sound/sdca_asoc.h
+++ b/include/sound/sdca_asoc.h
@@ -13,6 +13,7 @@
struct device;
struct regmap;
struct sdca_function_data;
+struct sdca_pde_delay;
struct snd_ctl_elem_value;
struct snd_kcontrol;
struct snd_kcontrol_new;
@@ -99,4 +100,9 @@ int sdca_asoc_q78_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
int sdca_asoc_q78_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol);
+int sdca_asoc_pde_poll_actual_ps(struct device *dev, struct regmap *regmap,
+ int function_id, int entity_id,
+ int from_ps, int to_ps,
+ const struct sdca_pde_delay *pde_delays,
+ int num_delays);
#endif // __SDCA_ASOC_H__
diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
index 2bfc8e5ae..e76afa396 100644
--- a/sound/soc/sdca/sdca_asoc.c
+++ b/sound/soc/sdca/sdca_asoc.c
@@ -359,15 +359,77 @@ static int entity_parse_ot(struct device *dev,
return 0;
}
+/**
+ * sdca_asoc_pde_poll_actual_ps - Verify PDE power state reached target state
+ * @dev: Pointer to the device for error logging.
+ * @regmap: Register map for reading ACTUAL_PS register.
+ * @function_id: SDCA function identifier.
+ * @entity_id: SDCA entity identifier for the power domain.
+ * @from_ps: Source power state (SDCA_PDE_PSn value).
+ * @to_ps: Target power state (SDCA_PDE_PSn value).
+ * @pde_delays: Pointer to array of PDE delay specifications for this device,
+ * or NULL to use default polling interval.
+ * @num_delays: Number of entries in pde_delays array.
+ *
+ * This function polls the ACTUAL_PS register to verify that a PDE power state
+ * transition has completed. Per SDCA specification, after writing REQUESTED_PS,
+ * the caller must poll ACTUAL_PS until it reflects the requested state.
+ *
+ * This function implements the polling logic but does NOT modify the power state.
+ * The caller is responsible for writing REQUESTED_PS before invoking this function.
+ *
+ * If a delay table is provided, appropriate polling intervals are extracted based
+ * on the from_ps and to_ps transition. If no table is provided or no matching entry
+ * is found, a default polling interval is used.
+ *
+ * Return: Returns zero when ACTUAL_PS reaches the target state, -ETIMEDOUT if the
+ * polling times out before reaching the target state, or a negative error code if
+ * a register read fails.
+ */
+int sdca_asoc_pde_poll_actual_ps(struct device *dev, struct regmap *regmap,
+ int function_id, int entity_id,
+ int from_ps, int to_ps,
+ const struct sdca_pde_delay *pde_delays,
+ int num_delays)
+{
+ static const int polls = 100;
+ static const int default_poll_us = 1000;
+ unsigned int reg, val;
+ int i, poll_us = default_poll_us;
+ int ret;
+
+ if (pde_delays && num_delays > 0) {
+ for (i = 0; i < num_delays; i++) {
+ if (pde_delays[i].from_ps == from_ps && pde_delays[i].to_ps == to_ps) {
+ poll_us = pde_delays[i].us / polls;
+ break;
+ }
+ }
+ }
+
+ reg = SDW_SDCA_CTL(function_id, entity_id, SDCA_CTL_PDE_ACTUAL_PS, 0);
+
+ for (i = 0; i < polls; i++) {
+ if (i)
+ fsleep(poll_us);
+
+ ret = regmap_read(regmap, reg, &val);
+ if (ret)
+ return ret;
+ else if (val == to_ps)
+ return 0;
+ }
+
+ return -ETIMEDOUT;
+}
+EXPORT_SYMBOL_NS(sdca_asoc_pde_poll_actual_ps, "SND_SOC_SDCA");
+
static int entity_pde_event(struct snd_soc_dapm_widget *widget,
struct snd_kcontrol *kctl, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
struct sdca_entity *entity = widget->priv;
- static const int polls = 100;
- unsigned int reg, val;
- int from, to, i;
- int poll_us;
+ int from, to;
int ret;
if (!component)
@@ -386,33 +448,17 @@ static int entity_pde_event(struct snd_soc_dapm_widget *widget,
return 0;
}
- for (i = 0; i < entity->pde.num_max_delay; i++) {
- struct sdca_pde_delay *delay = &entity->pde.max_delay[i];
-
- if (delay->from_ps == from && delay->to_ps == to) {
- poll_us = delay->us / polls;
- break;
- }
- }
-
- reg = SDW_SDCA_CTL(SDW_SDCA_CTL_FUNC(widget->reg),
- SDW_SDCA_CTL_ENT(widget->reg),
- SDCA_CTL_PDE_ACTUAL_PS, 0);
-
- for (i = 0; i < polls; i++) {
- if (i)
- fsleep(poll_us);
-
- ret = regmap_read(component->regmap, reg, &val);
- if (ret)
- return ret;
- else if (val == to)
- return 0;
- }
+ ret = sdca_asoc_pde_poll_actual_ps(component->dev, component->regmap,
+ SDW_SDCA_CTL_FUNC(widget->reg),
+ SDW_SDCA_CTL_ENT(widget->reg),
+ from, to,
+ entity->pde.max_delay,
+ entity->pde.num_max_delay);
+ if (ret)
+ dev_err(component->dev, "%s: PDE transition %x -> %x failed, err=%d\n",
+ entity->label, from, to, ret);
- dev_err(component->dev, "%s: power transition failed: %x\n",
- entity->label, val);
- return -ETIMEDOUT;
+ return ret;
}
static int entity_parse_pde(struct device *dev,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper
2026-04-30 7:23 [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper Niranjan H Y
@ 2026-04-30 10:57 ` Mark Brown
2026-04-30 11:21 ` Holalu Yogendra, Niranjan
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-04-30 10:57 UTC (permalink / raw)
To: Niranjan H Y
Cc: linux-sound, linux-kernel, ckeepax, lgirdwood, perex, tiwai,
cezary.rojewski, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, baojun.xu,
shenghao-ding, sandeepk, v-hampiholi
[-- Attachment #1: Type: text/plain, Size: 838 bytes --]
On Thu, Apr 30, 2026 at 12:53:21PM +0530, Niranjan H Y wrote:
> Implement sdca_asoc_pde_ensure_ps() helper function to poll for PDE
> power state transitions. Per SDCA specification, after writing
> REQUESTED_PS, drivers must poll ACTUAL_PS until the target power state
> is reached.
You've not copied me on the rest of the series so I don't know what's
going on with dependencies. When sending a patch series it is important
to ensure that all the various maintainers understand what the
relationship between the patches as the expecation is that there will be
interdependencies. Either copy everyone on the whole series or at least
copy them on the cover letter and explain what's going on. If there are
no strong interdependencies then it's generally simplest to just send
the patches separately to avoid any possible confusion.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper
2026-04-30 10:57 ` Mark Brown
@ 2026-04-30 11:21 ` Holalu Yogendra, Niranjan
0 siblings, 0 replies; 3+ messages in thread
From: Holalu Yogendra, Niranjan @ 2026-04-30 11:21 UTC (permalink / raw)
To: Mark Brown
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
ckeepax@opensource.cirrus.com, lgirdwood@gmail.com,
perex@perex.cz, tiwai@suse.com, cezary.rojewski@intel.com,
peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
pierre-louis.bossart@linux.dev, Xu, Baojun, Ding, Shenghao,
Kasargod, Sandeep, Hampiholi, Vallabha
> On 16:27-20260430, Mark Brown wrote:
> Subject: Re: [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper
> On Thu, Apr 30, 2026 at 12:53:21PM +0530, Niranjan H Y wrote:
> > Implement sdca_asoc_pde_ensure_ps() helper function to poll for PDE
> > power state transitions. Per SDCA specification, after writing
> > REQUESTED_PS, drivers must poll ACTUAL_PS until the target power state
> > is reached.
>
> You've not copied me on the rest of the series so I don't know what's
> going on with dependencies. When sending a patch series it is important
> to ensure that all the various maintainers understand what the
> relationship between the patches as the expecation is that there will be
> interdependencies. Either copy everyone on the whole series or at least
> copy them on the cover letter and explain what's going on. If there are
> no strong interdependencies then it's generally simplest to just send
> the patches separately to avoid any possible confusion.
My apologies, I am yet to send the rest of the series.
Accidentally sent this alone. Next time I will send all the patches at once.
Sorry for the inconvenience.
Regards
Niranjan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-30 11:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 7:23 [PATCH v13 1/4] ASoC: SDCA: Add PDE verification reusable helper Niranjan H Y
2026-04-30 10:57 ` Mark Brown
2026-04-30 11:21 ` Holalu Yogendra, Niranjan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox