Skip to content

adsp: add PCG driver - #3706

Open
sipraga wants to merge 9 commits into
adsp-6.18.31-yfrom
alvin/adsp/pcg
Open

sipraga wants to merge 9 commits into
adsp-6.18.31-yfrom
alvin/adsp/pcg

Conversation

@sipraga

@sipraga sipraga commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

The DAIs contain a PCG block, consisting of multiple PCG units, each of which can generate a synchronous CLK/FS (bitclock/fsync) pair. I needed a driver for this so that I could have the chip generate an FSYNC independently of the audio state, which the A2B driver requires.

See the commits for more details.

@sipraga
sipraga requested review from a team and qasim-ijaz December 3, 2026 15:39
@sipraga sipraga added this to ADSP Dec 3, 2026
@sipraga
sipraga force-pushed the alvin/adsp/pcg branch 2 times, most recently from c5ddd65 to 95902da Compare December 3, 2026 16:54

@nunojsa nunojsa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Nor much to say

extN is an external input clock for the Nth PCG unit of this DAI, routed
from a DAI pin to PCG0_EXTCLKx_I via the SRU, where the units are A, B,
E, F on DAI0 and C, D, G, H on DAI1. Inputs which are not connected or not
used are given as 0.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean, "are given as 0"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the clocks entry which should be <0>, I'll clarify.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarified, have another look


info = match->data;
if (adev->id >= info->num_dais)
return -EINVAL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device_get_match_data()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm! thanks for the tip. maybe I can dispose of this "manual" matching I was doing for aux devices. let me play around with it :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, auxiliary bus strikes again...

device_get_match_data
-> of_fwnode_device_get_match_data
-> of_device_get_match_data
-> of_match_device(dev->driver->of_match_table, dev)

const struct of_device_id *of_match_device(const struct of_device_id *matches,
					   const struct device *dev)
{
	if (!matches || !dev->of_node || dev->of_node_reused) <-- !!
		return NULL;
	return of_match_node(matches, dev->of_node);
}

Above returns NULL if of_node_reused.

and dev->of_node_reused gets set to true by auxiliary bus:

struct auxiliary_device *auxiliary_device_create(struct device *dev,
						 const char *modname,
						 const char *devname,
						 void *platform_data,
						 int id)
{
	struct auxiliary_device *auxdev;
	...
	device_set_of_node_from_dev(&auxdev->dev, dev);
}

void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
{
	of_node_put(dev->of_node);
	dev->of_node = of_node_get(dev2->of_node);
	dev->of_node_reused = true; <-- !!
}

I was hoping I could do something like:

static const struct of_device_id adsp_pcg_of_match[] = {
	{ .compatible = "adi,adsp-sc573-dai", .data = &adsp_sc573_pcg_info },
	{ .compatible = "adi,adsp-sc589-dai", .data = &adsp_sc589_pcg_info },
	{ .compatible = "adi,adsp-sc598-dai", .data = &adsp_sc598_pcg_info },
	{ .compatible = "adi,adsp-sc846-dai", .data = &adsp_sc846_pcg_info },
	{ }
};

static const struct auxiliary_device_id adsp_pcg_id_table[] = {
	{ .name = "adsp_dai.pcg" },
	{ }
};
MODULE_DEVICE_TABLE(auxiliary, adsp_pcg_id_table);

static struct auxiliary_driver adsp_pcg_driver = {
	.probe = adsp_pcg_probe,
	.id_table = adsp_pcg_id_table,
	.driver = {
		.of_match_table = adsp_pcg_of_match, <-- !!
	},
};
module_auxiliary_driver(adsp_pcg_driver);

which is a bit cheating, but would've been nice.

The shared of node check is from this patch:

commit 9b22c17a3cc5f61b195da624cbb48634b4e42055
Author: Rob Herring <robh@kernel.org>
Date:   Tue Jan 18 11:34:04 2022 -0600

    of: Check 'of_node_reused' flag on of_match_device()

    Commit 0f153a1b8193 ("usb: chipidea: Set the DT node on the child
    device") caused the child device to match on the parent driver
    instead of the child's driver since the child's DT node pointer matched.
    The worst case result is a loop of the parent driver probing another
    instance and creating yet another child device eventually exhausting the
    stack. If the child driver happens to match first, then everything works
    fine.

    A device sharing the DT node should never do DT based driver matching,
    so let's simply check of_node_reused in of_match_device() to prevent
    that.

    Fixes: 0f153a1b8193 ("usb: chipidea: Set the DT node on the child device")
    Link: https://lore.kernel.org/all/20220114105620.GK18506@ediswmail.ad.cirrus.com/

I get the rationale but actually it doesn't apply for auxiliary bus, since the driver already matched and probed on an auxiliary device table. So maybe there's some improvement that can be made. But since this is not yet going upstream I would rather revisit it later.

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to put this soc data in adsp-dai.c, but it seems like a layering violation IMO

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh crap!! I'm also better understanding what's going on... I don't really like much of what's being done in here tbh and I have vague memory about discussing this already. IMO, and assuming the driver creating the auxdevs have the same compatibles, we should get this kind of info with dev_get_platdata() (or at the least a magic/key/id to decide what to use in the auxdriver). Using of_id like this already seems to be like a violation tbh :)

But probably the above now would need more changes, not sure. So I won't be to grumpy over this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's precedent for what I'm doing upstream, I got the idea from /home/alvin/projects/vendor/linux-next/drivers/power/supply/qcom_battmgr.c and I see pinctrl-eyeq5.c does it too (although there he's stashing it in .driver.of_match_table, which I could also do to avoid a forward declaration)

I agree it's a bit a bit crude though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nunojsa I think this looks better, what say you?

diff --git a/drivers/clk/adi/clk-adsp-pcg.c b/drivers/clk/adi/clk-adsp-pcg.c
index 4722b41bccf0..a7920253a9c9 100644
--- a/drivers/clk/adi/clk-adsp-pcg.c
+++ b/drivers/clk/adi/clk-adsp-pcg.c
@@ -87,6 +87,42 @@
 #define PCG_SYNC_CLK_FP1CLKSEL	BIT(12)
 #define PCG_SYNC_FS_FP1CLKSEL	BIT(13)

+#define ADSP_PCG_MAX_DAIS	2
+
+/**
+ * struct adsp_pcg_unit_desc - static description of a PCG unit
+ *
+ * @ctl0: offset of the PCG_CTLx0 register for this unit
+ * @ctl1: offset of the PCG_CTLx1 register for this unit
+ * @sync: offset of the PCG_SYNCn register for this unit (shared among 2 units)
+ * @shift: bit offset of this unit's fields in PCG_SYNCn
+ * @letters: HRM letter of the unit on DAI0 and DAI1 (i.e. PCGA, PCGB, ...)
+ */
+struct adsp_pcg_unit_desc {
+	unsigned int ctl0;
+	unsigned int ctl1;
+	unsigned int sync;
+	unsigned int shift;
+	char letters[ADSP_PCG_MAX_DAIS];
+};
+
+#define ADSP_PCG_UNIT(_ctl0, _ctl1, _sync, _shift, _dai0, _dai1) \
+	{                                                        \
+		.ctl0 = _ctl0,                                   \
+		.ctl1 = _ctl1,                                   \
+		.sync = _sync,                                   \
+		.shift = _shift,                                 \
+		.letters = { _dai0, _dai1 },                     \
+	}
+
+static const struct adsp_pcg_unit_desc adsp_pcg_unit_descs[] = {
+	/*            ctl0   ctl1   sync   shift  DAI0  DAI1 */
+	ADSP_PCG_UNIT(0x300, 0x304, 0x314, 0,     'a',  'c'),
+	ADSP_PCG_UNIT(0x308, 0x30c, 0x314, 16,    'b',  'd'),
+	ADSP_PCG_UNIT(0x318, 0x31c, 0x32c, 0,     'e',  'g'),
+	ADSP_PCG_UNIT(0x320, 0x324, 0x32c, 16,    'f',  'h'),
+};
+
 /*
  * Possible clock parents for a PCG unit. SYS_CLKIN is for SoCs where the CLKIN
  * of a PCG is fixed.
@@ -115,25 +151,6 @@ static const char *const adsp_pcg_src_names[ADSP_PCG_SRC_NUM] = {
 	[ADSP_PCG_SRC_FRACN1] = "fracnpll1",
 };

-#define ADSP_PCG_MAX_DAIS	2
-
-/**
- * struct adsp_pcg_unit_desc - static description of a PCG unit
- *
- * @ctl0: offset of the PCG_CTLx0 register for this unit
- * @ctl1: offset of the PCG_CTLx1 register for this unit
- * @sync: offset of the PCG_SYNCn register for this unit (shared among 2 units)
- * @shift: bit offset of this unit's fields in PCG_SYNCn
- * @letters: HRM letter of the unit on DAI0 and DAI1 (i.e. PCGA, PCGB, ...)
- */
-struct adsp_pcg_unit_desc {
-	unsigned int ctl0;
-	unsigned int ctl1;
-	unsigned int sync;
-	unsigned int shift;
-	char letters[ADSP_PCG_MAX_DAIS];
-};
-
 /**
  * struct adsp_pcg_info - per-SoC PCG information
  *
@@ -649,9 +666,6 @@ static struct clk_hw *adsp_pcg_of_clk_get(struct of_phandle_args *clkspec,
 	}
 }

-static const struct adsp_pcg_unit_desc adsp_pcg_unit_descs[];
-static const struct of_device_id adsp_pcg_of_match[];
-
 static int adsp_pcg_probe(struct auxiliary_device *adev,
 			  const struct auxiliary_device_id *id)
 {
@@ -661,7 +675,7 @@ static int adsp_pcg_probe(struct auxiliary_device *adev,
 	struct adsp_pcg *pcg;
 	int ret;

-	match = of_match_node(adsp_pcg_of_match, dev->of_node);
+	match = of_match_node(dev->driver->of_match_table, dev->of_node);
 	if (!match)
 		return -ENODEV;

@@ -698,23 +712,6 @@ static int adsp_pcg_probe(struct auxiliary_device *adev,
 	return devm_of_clk_add_hw_provider(dev, adsp_pcg_of_clk_get, pcg);
 }

-#define ADSP_PCG_UNIT(_ctl0, _ctl1, _sync, _shift, _dai0, _dai1) \
-	{                                                        \
-		.ctl0 = _ctl0,                                   \
-		.ctl1 = _ctl1,                                   \
-		.sync = _sync,                                   \
-		.shift = _shift,                                 \
-		.letters = { _dai0, _dai1 },                     \
-	}
-
-static const struct adsp_pcg_unit_desc adsp_pcg_unit_descs[] = {
-	/*            ctl0   ctl1   sync   shift  DAI0  DAI1 */
-	ADSP_PCG_UNIT(0x300, 0x304, 0x314, 0,     'a',  'c'),
-	ADSP_PCG_UNIT(0x308, 0x30c, 0x314, 16,    'b',  'd'),
-	ADSP_PCG_UNIT(0x318, 0x31c, 0x32c, 0,     'e',  'g'),
-	ADSP_PCG_UNIT(0x320, 0x324, 0x32c, 16,    'f',  'h'),
-};
-
 static const enum adsp_pcg_src adsp_sc573_pcg_srcs[] = {
 	ADSP_PCG_SRC_SYS_CLKIN0,
 	ADSP_PCG_SRC_SYS_CLKIN1,
@@ -790,6 +787,9 @@ MODULE_DEVICE_TABLE(auxiliary, adsp_pcg_id_table);
 static struct auxiliary_driver adsp_pcg_driver = {
 	.probe = adsp_pcg_probe,
 	.id_table = adsp_pcg_id_table,
+	.driver = {
+		.of_match_table = adsp_pcg_of_match,
+	},
 };
 module_auxiliary_driver(adsp_pcg_driver);

Comment thread drivers/clk/adi/clk-adsp-pcg.c Resolved
}

static const struct adsp_pcg_unit_desc adsp_pcg_unit_descs[];
static const struct of_device_id adsp_pcg_of_match[];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the above? (naturally assuming we move from of_match_node())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could put the match table and SoC data above the probe function (perhaps before all the function definitions of the driver). But I thought this was preferable, since we normally look for such information at the bottom. Thoughts?

* PCGs are alphabetically named, the DT bindings expect a numerical
* "ext1" for DAI0's PCGB unit.
*/
snprintf(ext_name, sizeof(ext_name), "ext%u", unit->index);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could support/honor clock-output-names

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? These "extN"s are inputs to the PCG.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yes! I just blindly looked but the comment still holds for the clocks we register! Not a big deal anyways

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was once told by Stephen not to use clock-output-names, see https://lore.kernel.org/all/8e6fcde41671b0a1e8365214e6df4ec2.sboyd@kernel.org/


/*
* Frame sync (FS)
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to have more blank lines than needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant it to be a bit "fatter" so as to divide the file into sections


/*
* Bit clock (CLK)
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But seems to be style choice :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;)

The DAI contains Precision Clock Generator (PCG) units which generate
serial audio bit clocks and frame syncs. Make the DAI a clock provider
with one clock cell, and add a header with clock IDs for the bit clock,
frame sync and input source of each PCG unit. The units are named by
their letter in the hardware reference manual, A to H, and each DAI only
provides the clocks of its own units.

Besides sclk, the PCG units can be clocked from the SYS_CLKIN pins, an
external clock routed to the unit via the SRU, and (on SC84x) the
fractional-N PLLs. Describe these as clock inputs in a fixed order per
SoC, where inputs which are not connected are given as 0 and trailing
ones may be omitted. As both DAIs of a SoC share a compatible, the
external inputs are named by the index of the PCG unit within the DAI
rather than by its letter.

Also add missing copyright license message.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
The Digital Audio Interfaces (DAIs) found on Analog Devices ADSP SoCs
contain Precision Clock Generator (PCG) units, each of which generates a
bit clock (CLK) and a frame sync (FS) for serial audio. Add a clock
driver for them. It binds to the pcg auxiliary device of a DAI, accesses
the PCG registers through the DAI regmap, and provides the clocks of the
units of that DAI, named by their letter in the hardware reference
manual.

Each unit is modelled as a source mux, a gate, and two sibling dividers
for CLK and FS. The mux programs the CLK and FS source selection
together, and the gate sets CLKEN and FSEN in a single register write,
as the hardware requires for the two outputs to be synchronized. The
gate is implemented with prepare/unprepare, so that the clk core's
prepare lock serializes all register accesses. As the clk core does not
protect a divider against rate changes while only its sibling is
prepared, the dividers refuse rate changes while the unit is running.

The selectable sources are described per SoC: SYS_CLKIN, which is fixed
per DAI on the SC58x, SCLK0, an external input per unit routed via the
SRU, and on the SC84x the fractional-N PLLs.

Enable the driver by default along with the DAI driver, so that
defconfigs need not be updated.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Create a pcg auxiliary device for each DAI alongside the sru one, so
that the PCG clock driver can bind to it and provide the clocks of the
DAI's PCG units.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Make the DAI a clock provider for the clocks of its PCG units, and
describe the SYS_CLKIN0 and SYS_CLKIN1 inputs of the PCG units.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Make the DAIs clock providers for the clocks of their PCG units, and
describe the SYS_CLKIN input of the PCG units. On the SC58x, DAIn is
hardwired to SYS_CLKINn.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Make the DAIs clock providers for the clocks of their PCG units, and
describe the SYS_CLKIN0 and SYS_CLKIN1 inputs of the PCG units.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Make the DAIs clock providers for the clocks of their PCG units, and
describe the SYS_CLKIN0 and SYS_CLKIN1 inputs of the PCG units.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Make the DAIs clock providers for the clocks of their PCG units, and
describe the SYS_CLKIN0 and SYS_CLKIN1 inputs of the PCG units. The
fractional-N PLL inputs are left out for now, since they aren't
described in the devicetree.

Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
Not sure how it became 1.1, but everything else in-tree uses 1.2. Fix.

Also add copyright header.

Fixes: 03a8e02 ("ASoC: dt-bindings: document Analog Devices ADSP SPORT")
Signed-off-by: Alvin Šipraga <alvin.sipraga@analog.com>
@sipraga

sipraga commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Only change:

--- a/Documentation/devicetree/bindings/sound/adi,adsp-dai.yaml
+++ b/Documentation/devicetree/bindings/sound/adi,adsp-dai.yaml
@@ -60,7 +60,7 @@ properties:
       extN is an external input clock for the Nth PCG unit of this DAI, routed
       from a DAI pin to PCG0_EXTCLKx_I via the SRU, where the units are A, B,
       E, F on DAI0 and C, D, G, H on DAI1. Inputs which are not connected or not
-      used are given as 0.
+      used are given as <0> in the clocks property.
     minItems: 1
     maxItems: 9

per Nuno's comment

@qasim-ijaz qasim-ijaz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass from me

@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
/*
* Clock IDs for the ADSP Precision Clock Generator (PCG)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would change this to Device tree binding constants for the ADSP Precision Clock Generator (PCG) (as seen in many other upstream drivers).

if (src == ADSP_PCG_SRC_EXT)
src_parents[i].fw_name = ext_name;
else
src_parents[i].fw_name = adsp_pcg_src_names[src];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fracN clocks aren't valid clocks right? (since we don't have a fracn-pll driver and so they aren't registered with CCF) so CCF basically thinks the parent clock is a non-existent clock (also none of the DTs currently have those fracpll clocks in clock-names) so why is this here right now? I think it might better to add those once we actually have the frac-N PLL driver in tbh.

Edit: I think the ext clock has the same issue?

if (ret)
return ret;

ret = adsp_pcg_hw_register(dev, &unit->fs, &fs_init, unit->letter,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe return adsp_pcg_hw_register(...);? since it returns 0 on success anyways

if (ret)
return ret;

return 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe return regmap_update_bits(...);, i think theres a few other places where this is applicable (adsp_pcg_fs_set_rate, adsp_pcg_clk_set_rate, etc.)

* of a PCG is fixed.
*/
enum adsp_pcg_src {
ADSP_PCG_SRC_SYS_CLKIN,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADSP_PCG_SRC_SYS_CLKIN

So on some SoCs each PCG can select between SYS_CLKIN0 and SYS_CLKIN1, but on SC589, SYS_CLKIN0 is a fixed input for the PCGs in DAI0 and SYS_CLKIN1 for the PCGs in DAI1? If that's the case, could we maybe elaborate a bit in the comment above the enum? Something like:

"SYS_CLKIN is used on SoCs where each PCG is hardwired to either SYS_CLKIN0 or SYS_CLKIN1, rather than being able to select between them."

I was initially a bit confused seeing SYS_CLKIN0/SYS_CLKIN1 alongside an unnumbered SYS_CLKIN =P

/**
* struct adsp_pcg_info - per-SoC PCG information
*
* @num_units: number of units per PCG

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

units per PCG? shouldn't it be units per DAI? since a unit is a single instance of a PCG inside the DAI iiuc?

from the HRM for example:

There are four PCG units per DAI


sync >>= unit->desc->shift;

for (u8 i = 0; i < info->num_srcs; i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the clock callbacks we could replace uses of info->num_srcs with clk_hw_get_num_parents(hw). I generally prefer using existing CCF APIs wherever possible, and it makes it a tad easier to realise "ah, so he's iterating over the parents" when reading the call name, but your call

}

err:
return info->num_srcs;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on the above, return clk_hw_get_num_parents(hw); for example. I did something very similar in my CDU driver, and there's upstream precedent for using this helper in clock callbacks too.

};

/*
* Gate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really a fan of these small separator-like comments, I would drop personally. The rest of the kernel-doc I like a lot since they provide a bunch of context.

enum adsp_pcg_src src = info->srcs[i];

if (src == ADSP_PCG_SRC_EXT)
src_parents[i].fw_name = ext_name;

@qasim-ijaz qasim-ijaz Dec 4, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now you're using .fw_name, which is fine, but I wonder if .index might be cleaner? If we order the srcs[] arrays to match the ordering of the clocks property in DT, with ADSP_PCG_SRC_EXT last, then we could do something like the following in adsp_pcg_register_unit:

for (i = 0; i < info->num_srcs; i++)
	src_parents[i].index = i;

src_parents[info->num_srcs - 1].index += unit->index;

The final += just adds the index from the loop in probe, so the EXT clock doesn't overlap with any other ext clock. Then I guess we could drop adsp_pcg_src_names[], and the snprintf() altogether. what do you think?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants