[PATCH v3 2/2] clk: scmi: add compatibility for clock version 3.0 and onwards
Maxim Kochetkov
fido_max at inbox.ru
Sun Oct 12 13:58:44 CEST 2025
08.10.2025 15:27, Kamlesh Gurudasani wrote:
>>> Could you elaborate?
>>> I think clk->dev should be fine, similar to other instances in the same
>>> file. Maybe I am missing something?
>>>
>>
>> clk->dev points to hw clock device. It has no struct scmi_clock_priv
>> stored in priv data. So we have to step up to parent device to get SCMI
>> protocol device to get struct scmi_clock_priv to get protocol version
>> priv->version.
> Hi Maxim,
>
> in probe function, we are making sure that priv data is available
> struct scmi_clock_priv *priv = dev_get_priv(dev);
> size_t num_clocks, i;
> int ret;
>
> ret = devm_scmi_of_get_channel(dev);
> if (ret)
> return ret;
>
> ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK,
> &priv->version);
>
>
> Also, the code is working just fine and returns correct version with
> clk->dev
>
> Let me know if I missed something
Here is my debug path:
--- a/drivers/clk/clk_scmi.c
+++ b/drivers/clk/clk_scmi.c
@@ -135,6 +135,10 @@ static int scmi_clk_gate(struct clk *clk, int enable)
struct scmi_clk_state_out out;
int ret;
+ printf("%s name:%s dev:0x%px dev->priv:0x%px parent->name:%s
parent->dev:0x%px parent->dev->priv:0x%px\n", __FUNCTION__,
+ clk->dev->name, clk->dev, dev_get_priv(clk->dev),
+ clk->dev->parent->name, clk->dev->parent,
dev_get_priv(clk->dev->parent));
+
if (priv->version >= CLOCK_PROTOCOL_VERSION_3_0) {
struct scmi_clk_state_in_v2 in = {
.clock_id = clk_get_id(clk),
@@ -288,6 +292,8 @@ static int scmi_clk_probe(struct udevice *dev)
size_t num_clocks, i;
int ret;
+ printf("%s name:%s dev:0x%px dev->priv:0x%px\n", __FUNCTION__,
dev->name, dev, priv);
+
ret = devm_scmi_of_get_channel(dev);
if (ret)
return ret;
And output:
DRAM: 510 MiB
scmi_clk_probe name:protocol at 14 dev:0x000000041f51fc50
dev->priv:0x000000041f520ae0
scmi_clk_gate name:UART0 dev:0x000000041f522710
dev->priv:0x0000000000000000 parent->name:protocol at 14
parent->dev:0x000000041f51fc50 parent->dev->priv:0x000000041f520ae0
Core: 132 devices, 22 uclasses, devicetree: board
MMC: scmi_clk_gate name:EMMC_S dev:0x000000041f521950
dev->priv:0x0000000000000000 parent->name:protocol at 14
parent->dev:0x000000041f51fc50 parent->dev->priv:0x000000041f520ae0
sdhci at 0: 0
Loading Environment from nowhere... OK
In: serial
Out: serial
Err: serial
As we can see here, we have two different devs in scmi_clk_probe() and
scmi_clk_gate(). dev from scmi_clk_gate() have NULL in dev->priv. So we
can't get scmi version form clk->dev direcrly.
P.S.: I have CONFIG_CLK_CCF=y
More information about the U-Boot
mailing list