Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: firmware: scmi: add more protocols and APIs #77437

Merged
merged 2 commits into from
Jan 15, 2025

Conversation

yangbolu1991
Copy link
Contributor

This patch-set is to add more SCMI clock protocol APIs and power domain protocol driver.
These are essential for platform to configure clock and control power domain.
These had been verified on NXP i.MX95 platforms.

Thank you very much.

@LaurentiuM1234
Copy link
Collaborator

thanks for your contribution! does #74920 depend on this? if not, I propose we handle these new additions after that gets merged. As things stand now we've no twister tests for SCMI (since there's no platform using it) so it's more prone to issues such as #77344

@yangbolu1991
Copy link
Contributor Author

@LaurentiuM1234 Thanks.
Logically, this is an independent change to add more APIs/protocol for SCMI.
As we know, setting clock parent and power domain control are not supported in SCMI, which should be basic features.

Actually I will send NETC support PR, which needs this to set clock and power up NETCMIX domain. That will include,

  • new i.mx netc drivers
  • imx95 platform netc support.

So, not sure if the PR will be huge making all changes together with this in one PR.
But I'm ok for either.

THanks.

@GrygiriiS
Copy link

Hi @LaurentiuM1234, @yangbolu1991

First of all I'd like to thank you for your tremendous work adding SCMI support in Zephyr.

Regarding this PR - it's probably would be better to split it. At least patch which fixes code formatting.
Actually CLK update vs PD management API introduce - also looks like two different functional changes (especially taking into account that SCMI POWER_DOMAIN driver probably should also be added) .

Below is just FYI.
We also worked on Zephyr SCMI implementation on raspberry pi 5 [1], but, of course, now we will migrate on already existing solution (Our solution implements SMC/HVC transport only). But what you might find interesting/useful is that we added SHELL interface and SCMI sample application which allows to test SCMI - at least manually.

[1] xen-troops#124

@LaurentiuM1234
Copy link
Collaborator

Below is just FYI. We also worked on Zephyr SCMI implementation on raspberry pi 5 [1], but, of course, now we will migrate on already existing solution (Our solution implements SMC/HVC transport only). But what you might find interesting/useful is that we added SHELL interface and SCMI sample application which allows to test SCMI - at least manually.

[1] xen-troops#124

great to see more platforms using the SCMI support! Do you plan on also upstreaming the patches to Zephyr? I think it would be good to have another upstream platform using SCMI so we could have more coverage. Also, IMO, the sample is a very good idea since we're lacking in that department.

@GrygiriiS
Copy link

@LaurentiuM1234 Hope to have smth this week. I was able to port on top of current code, need to look at it one more time. Current state in https://github.com/GrygiriiS/zephyr/commits/zm_rpi5_dev_scmi/

@yangbolu1991
Copy link
Contributor Author

@LaurentiuM1234 @GrygiriiS

Since I had create PR for i.MX95 NETC feature support, which depends on this PR, I updated this to v2. Changes,

  • Dropped clang-format patch for existed code.

Thank you very much.

Copy link
Collaborator

@LaurentiuM1234 LaurentiuM1234 left a comment

Choose a reason for hiding this comment

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

Sorry for the (very) long review time. Some comments below. Also, is there a particular reason you didn't implement the clock_control_set_rate() function? Should be useful for #81113.

reply.len = sizeof(status);
reply.content = &status;

ret = scmi_send_message(proto, &msg, &reply);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is synchronous so if someone sets the ASYNC bit it will come in contradiction with it. For now, since we don't support ASYNC messages, maybe we can return an error if someone attempts to call this function with that bit set? Or perhaps force it to 0 and print a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The scmi driver should be standard. I think it's not good to limit only SYNC flag here.
Actually, if ASYNC is used, I think the reply from system manager will be error, right?

Copy link
Collaborator

@LaurentiuM1234 LaurentiuM1234 Dec 15, 2024

Choose a reason for hiding this comment

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

we're limited to SYNC because that's the only option the support allows. Allowing people to set the ASYNC flag and still using SYNC messaging behind the scenes is not the way IMO. This deserves a comment at least.

EDIT: could add a comment to the flags field of the affected structures. People will have to look up their definitions anyways when using them, thus making sure that they know the ASYNC flag will be ignored.

#include <zephyr/drivers/firmware/scmi/power.h>
#include <string.h>

DT_SCMI_PROTOCOL_DEFINE_NODEV(DT_INST(0, arm_scmi_power), NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

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

A note on this: not exactly ideal to put this here as we'd normally have a generic power domain driver using this, but since Zephyr doesn't really support DT nodes providing multiple PDs it becomes a bit tricky. For now, I'd say it's fine to go with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, thanks:)

reply.len = sizeof(status);
reply.content = &status;

ret = scmi_send_message(proto, &msg, &reply);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as for scmi_power_state_set().

return 0;
}

int scmi_clock_parent_set(struct scmi_protocol *proto, struct scmi_clock_parent_config *cfg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems kinda odd to encase clock ID and parent ID in a structure here and not in scmi_clock_parent_get()? I'd suggest going with the same approach as scmi_clock_parent_get() (i.e: don't encase the parameters in a structure unless we have > 2?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, I can't understand why I encased the parameters too.
Thanks.

@dleach02 dleach02 self-assigned this Dec 4, 2024
@yangbolu1991
Copy link
Contributor Author

Sorry for the (very) long review time. Some comments below. Also, is there a particular reason you didn't implement the clock_control_set_rate() function? Should be useful for #81113.

I think the common clock control driver is missing function like set_parent.
It's not able to directly use set_rate since we have to set parent clock before that.
So, to quick support NXP platform, I use scmi APIs directly.
Thanks.

@LaurentiuM1234
Copy link
Collaborator

BTW, could you please also add the PD protocol to the list of supported protocols in https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/hardware/arch/arm-scmi.rst? Thanks!

Added more APIs for ARM SCMI clock management protocol.
- scmi_clock_rate_set
- scmi_clock_parent_get
- scmi_clock_parent_set

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Added helpers for ARM SCMI power dmomain protocol.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
@yangbolu1991
Copy link
Contributor Author

Updated to v3. Changes include,

  • Returned not supported for ASYNC flag for clk/power API. I had some misunderstand before.
  • Converted to use clk_id/parent_id as scmi_clock_parent_set() arguments.
  • Added power domain protocol in zephyr scmi doc.

Thanks a lot.

Copy link
Collaborator

@LaurentiuM1234 LaurentiuM1234 left a comment

Choose a reason for hiding this comment

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

good with me @dleach02

@mmahadevan108
Copy link
Collaborator

@LaurentiuM1234 , would you like to add a change PR to make yourself the maintainer for ARM SCMI?

@kartben kartben merged commit 7c57fec into zephyrproject-rtos:main Jan 15, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants