All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: "Alice Guo (OSS)" <alice.guo@oss.nxp.com>,
	"Tom Rini" <trini@konsulko.com>,
	"Lukasz Majewski" <lukma@denx.de>,
	"Sean Anderson" <seanga2@gmail.com>,
	"Simon Glass" <sjg@chromium.org>,
	"Stefano Babic" <sbabic@denx.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
	"Alper Nebi Yasak" <alpernebiyasak@gmail.com>,
	"Alice Guo" <alice.guo@nxp.com>,
	"Lothar Waßmann" <LW@KARO-electronics.de>
Cc: u-boot@lists.denx.de, Ye Li <ye.li@nxp.com>, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH v8 07/19] clk: scmi: check the clock state/parent/rate control permissions
Date: Sat, 22 Mar 2025 03:02:14 +0100	[thread overview]
Message-ID: <78f7d9f2-6226-49bb-8568-41e7ca0cdaba@denx.de> (raw)
In-Reply-To: <20250321-imx95-v1-7-f2c8ba815f89@oss.nxp.com>

On 3/21/25 8:15 AM, Alice Guo (OSS) wrote:

[...]

> +static int scmi_clk_get_permissions(struct udevice *dev, int clkid, u32 *perm)
> +{
> +	u32 version;
> +	int ret;
> +
> +	struct scmi_clk_get_permissions_in in = {
> +		.clock_id = clkid,
> +	};
> +	struct scmi_clk_get_permissions_out out;
> +	struct scmi_msg msg = {
> +		.protocol_id = SCMI_PROTOCOL_ID_CLOCK,
> +		.message_id = SCMI_CLOCK_GET_PERMISSIONS,
> +		.in_msg = (u8 *)&in,
> +		.in_msg_sz = sizeof(in),
> +		.out_msg = (u8 *)&out,
> +		.out_msg_sz = sizeof(out),
> +	};
> +
> +	ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_CLOCK, &version);

Would it be possible to query the version in .probe() once and cache the 
value in private data ?

> +	if (ret) {
> +		log_debug("%s: get SCMI clock management protocol version failed\n", __func__);
> +		return ret;
> +	}
> +
> +	if (version < CLOCK_PROTOCOL_VERSION_3_0) {
> +		log_debug("%s: SCMI clock management protocol version is less than 3.0.\n", __func__);
> +		return -EINVAL;
> +	}
> +
> +	ret = devm_scmi_process_msg(dev, &msg);
> +	if (ret) {
> +		log_debug("%s: get SCMI clock management protocol permissions failed\n", __func__);
> +		return ret;
> +	}
> +
> +	ret = scmi_to_linux_errno(out.status);
> +	if (ret < 0) {
> +		log_debug("%s: the status code of getting permissions: %d\n", __func__, ret);
> +		return ret;
> +	}
> +
> +	*perm = out.permissions;
> +	return 0;
> +}

[...]

> @@ -156,29 +267,44 @@ static int scmi_clk_probe(struct udevice *dev)
>   
>   	for (i = 0; i < num_clocks; i++) {
>   		char *clock_name;
> +		u32 attributes;
>   
> -		if (!scmi_clk_get_attibute(dev, i, &clock_name)) {
> -			clk = kzalloc(sizeof(*clk), GFP_KERNEL);
> -			if (!clk || !clock_name)
> +		if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {
> +			clk_scmi = kzalloc(sizeof(*clk_scmi), GFP_KERNEL);
> +			if (!clk_scmi || !clock_name)
>   				ret = -ENOMEM;
>   			else
> -				ret = clk_register(clk, dev->driver->name,
> +				ret = clk_register(&clk_scmi->clk, dev->driver->name,
>   						   clock_name, dev->name);
>   
>   			if (ret) {
> -				free(clk);
> +				free(clk_scmi);
>   				free(clock_name);
> +				free(&attributes);

Do you really need to free() an u32 attributes here ?

>   				return ret;
>   			}
>   
> -			clk_dm(i, clk);
> +			clk_dm(i, &clk_scmi->clk);
> +
> +			if (CLK_HAS_RESTRICTIONS(attributes)) {
> +				u32 perm;
> +
> +				ret = scmi_clk_get_permissions(dev, i, &perm);
> +				if (ret < 0)
> +					clk_scmi->ctrl_flags = 0;
> +				else
> +					clk_scmi->ctrl_flags = perm;
> +			} else {
> +				clk_scmi->ctrl_flags = SUPPORT_CLK_STAT_CONTROL | SUPPORT_CLK_PARENT_CONTROL |
> +						       SUPPORT_CLK_RATE_CONTROL;
> +			}
>   		}
>   	}
>   
>   	return 0;
>   }

[...]

>   enum scmi_clock_message_id {
>   	SCMI_CLOCK_ATTRIBUTES = 0x3,
> @@ -738,6 +739,7 @@ enum scmi_clock_message_id {
>   	SCMI_CLOCK_RATE_GET = 0x6,
>   	SCMI_CLOCK_CONFIG_SET = 0x7,
>   	SCMI_CLOCK_PARENT_SET = 0xD,
> +	SCMI_CLOCK_GET_PERMISSIONS = 0xF,

Better call it SCMI_CLOCK_PERMISSIONS_GET to be consistent with the rest 
of these fields , unless this is some SCMI specification name ?

[...]

  reply	other threads:[~2025-03-22  2:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21  7:15 [PATCH v8 00/19] imx: add i.MX95 support Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 01/19] firmware: scmi: smt: Interrupt communication enable Alice Guo (OSS)
2025-03-22  0:38   ` Marek Vasut
2025-04-01  8:02     ` 回复: " Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 02/19] pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol Alice Guo (OSS)
2025-03-22  0:46   ` Marek Vasut
2025-03-25  8:06     ` Peng Fan
2025-03-26  1:24       ` Marek Vasut
2025-03-26  1:52         ` Peng Fan
2025-03-26  3:00           ` Marek Vasut
2025-03-26  6:42             ` Peng Fan
2025-03-27 13:18               ` Marek Vasut
2025-04-01 10:57                 ` 回复: " Alice Guo (OSS)
2025-04-01 12:53                   ` Marek Vasut
2025-04-01 13:22                     ` 回复: " Alice Guo (OSS)
2025-04-01 13:27                     ` Fabio Estevam
2025-04-01  8:17     ` Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 03/19] firmware: scmi_agent: add SCMI pin control protocol support Alice Guo (OSS)
2025-03-22  1:55   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 04/19] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data Alice Guo (OSS)
2025-03-22  1:55   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 05/19] scmi_protocols: add SCMI Performance domain management protocol message IDs Alice Guo (OSS)
2025-03-22  1:55   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 06/19] clk: scmi: add the command CLOCK_PARENT_SET Alice Guo (OSS)
2025-03-22  1:57   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 07/19] clk: scmi: check the clock state/parent/rate control permissions Alice Guo (OSS)
2025-03-22  2:02   ` Marek Vasut [this message]
2025-03-28 10:26     ` 回复: " Alice Guo (OSS)
2025-03-30 21:05       ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 08/19] sandbox: add SCMI clock control permissions to sandbox Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 09/19] scmi_protocols: update struct scmi_base_discover_list_protocols_out Alice Guo (OSS)
2025-03-22  2:10   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 10/19] imx9: scmi: add i.MX95 SoC and clock related code Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 11/19] spl: imx: use trampoline buffer to load images to secure region Alice Guo (OSS)
2025-03-22  2:14   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 12/19] imx9: add i.MX95 Kconfig and Makefile Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 13/19] imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95 Alice Guo (OSS)
2025-03-22  2:15   ` Marek Vasut
2025-03-21  7:15 ` [PATCH v8 14/19] binman: add a new entry type for packing DDR PHY firmware images Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 15/19] tools: imx8image: add i.MX95 support Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 16/19] imx: container: add V2X container support for i.MX95 Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 17/19] doc: imx: add document for i.MX95 Image Container Format Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 18/19] imx95_evk: add i.MX95 19x19 EVK board basic support Alice Guo (OSS)
2025-03-21  7:15 ` [PATCH v8 19/19] Makefile: add some files to CLEAN_FILES Alice Guo (OSS)
2025-03-22  2:20 ` [PATCH v8 00/19] imx: add i.MX95 support Marek Vasut

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=78f7d9f2-6226-49bb-8568-41e7ca0cdaba@denx.de \
    --to=marex@denx.de \
    --cc=LW@KARO-electronics.de \
    --cc=alice.guo@nxp.com \
    --cc=alice.guo@oss.nxp.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=festevam@gmail.com \
    --cc=lukma@denx.de \
    --cc=peng.fan@nxp.com \
    --cc=sbabic@denx.de \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=ye.li@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.