R-Car X5H Ironhide pure SCMI proof-of-concept
Subsystems (5)
Geert Uytterhoeven
maintainercover R-Car X5H Ironhide pure SCMI proof-of-concept
Hi all,
As promised[1], I tried handling all issues with current R-Car X5H Ironhide SCP FW SDK v4.28, v4.31, and v4.32 as SCMI quirks. This helped identifying missing features in the SCMI drivers and/or protocol:
- The SCMI PM domain driver does not support always-on domains. This limits the ability of the Linux Power Management core to optimize its decisions by taking into account which PM domains cannot be disabled,
- The SCMI protocol does not support clock domains.
- Power management of on-SoC modules is typically handled through two
methods: module power control and module clock gating. The former can be exposed as an SCMI power domain, the latter as an SCMI clock. Currently, the SCMI clock protocol does not support advertizing whether a clock is intended for power-management of a hardware module, so such clocks can not be managed automatically through Runtime PM. To solve this in general, the SCMI CLOCK_ATTRIBUTES could be extended with a new flag in the returned attributes (which is not done by this series).
Series overvies:
- Patch 1 is a preparatory refactoring,
- Patches 2-3 add support for always-on power areas,
- Patches 4-7 add support for clock domains,
- Patch 8 adds an SCMI quirk to advertize power-management clocks on
R-Car X5H,
- Patch 9 switches the (still minimal) Ironhide DTS to SCMI (this needs manual configuration for the actual SCP firmware version, as the SCMI domain IDs differ).
Note that other SCMI quirks than patch 8 are not included in this series[2], as IMHO the original issues must be fixed in the SCP firmware instead.
While the result works, and we might get stable SCMI domain IDs (eventually), I still prefer the approach taking by the CPG/MDLC remapping driver series[3], as:
- It describes in DT the actual hardware (which is needed for U-Boot
IPL),
- It does not depend on SCMI domain IDs defined by firmware that is still under active development,
- It lets us keep the DTB stable, while SCMI domain IDs may change, depending on system partitioning (i.e. software policy),
- It allows us to support (in the Renesas LTS tree, not upstream) firmware versions that already exist, but need quirks for proper operation.
Thanks for your comments!
[1] "Re: [PATCH/RFC 05/14] firmware: arm_scmi: Add scmi_get_base_info()"
https://lore.kernel.org/CAMuHMdWJvMH+a1RqozbaCxxH_8M569JcruTFa8PW+87FysnjHw@mail.gmail.com
[2] List of SCMI quirks which are not included in this series, but are needed to boot on R-Car X5H Ironhide:
firmware: arm_scmi: quirk: Handle critical clocks on R-Car X5H
firmware: arm_scmi: quirk: Handle bad power domains on R-Car X5H
firmware: arm_scmi: quirk: Handle bad clocks on R-Car X5H
firmware: arm_scmi: quirk: Handle wrong clock rates on R-Car X5H
firmware: arm_scmi: Add support for retrieving rates from another clock
firmware: arm_scmi: quirk: Handle zero clock rates on R-Car X5H
firmware: arm_scmi: quirk: Add always-on power domains on R-Car X5H
firmware: arm_scmi: quirk: Handle broken HSCIF0 reset on R-Car X5H
With diffstat:
drivers/firmware/arm_scmi/clock.c | 2555 +++++++++++++++++++++++++++-
drivers/firmware/arm_scmi/power.c | 83 +
drivers/firmware/arm_scmi/quirks.c | 12 +
drivers/firmware/arm_scmi/quirks.h | 4 +
drivers/firmware/arm_scmi/reset.c | 9 +
5 files changed, 2655 insertions(+), 8 deletions(-)
[3] "[PATCH/RFC 00/14] R-Car X5H Ironhide SCMI CPG/MDLC remapping"
https://lore.kernel.org/[email protected]
Geert Uytterhoeven (9):
firmware: arm_scmi: Replace scmi_power_proto_ops.name_get() by
.info_get()
firmware: arm_scmi: Advertize always-on power domains
pmdomain: arm: scmi: Add always-on support
firmware: arm_scmi: Add a flag for power-management clocks
clk: scmi: Add scmi_clk_is_pm_clk()
dt-bindings: firmware: arm,scmi: Document arm,clock-domain
pmdomain: arm: scmi: Add clock domain support
firmware: arm_scmi: quirk: Handle power management clocks on R-Car X5H
arm64: dts: renesas: ironhide: Switch to pure SCMI
.../bindings/firmware/arm,scmi.yaml | 7 ++ .../boot/dts/renesas/r8a78000-ironhide.dts | 44 +++++++++ drivers/clk/clk-scmi.c | 9 ++ drivers/firmware/arm_scmi/clock.c | 15 +++ drivers/firmware/arm_scmi/power.c | 21 +++-- drivers/pmdomain/arm/Kconfig | 1 + drivers/pmdomain/arm/scmi_pm_domain.c | 93 ++++++++++++++++++- include/linux/clk/scmi.h | 17 ++++ include/linux/scmi_protocol.h | 12 ++- 9 files changed, 204 insertions(+), 15 deletions(-) create mode 100644 include/linux/clk/scmi.h
Signature · 12 lines
2.43.0
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsGeert Uytterhoeven
maintainerPATCH 1/9 firmware: arm_scmi: Replace scmi_power_proto_ops.name_get() by .info_get()
The SCMI power domain protocol operations structure does not provide a .info_get() method, unlike most other protocols. Instead, it provides a .name_get() method.
Replace the .name_get() method by the .info_get() method, to increase uniformity, and to prepare for returning more information.
--- drivers/firmware/arm_scmi/power.c | 17 ++++++++--------- drivers/pmdomain/arm/scmi_pm_domain.c | 9 ++++++++- include/linux/scmi_protocol.h | 10 +++++++--- 3 files changed, 23 insertions(+), 13 deletions(-)
drivers/firmware/arm_scmi/power.c +8 -9
@@ -63,7 +63,7 @@ struct power_dom_info {bool state_set_sync;bool state_set_async;bool state_set_notify; -char name[SCMI_MAX_STR_SIZE ]; +struct scmi_power_domain_info info; };struct scmi_power_info {
@@ -132,7 +132,7 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph,SUPPORTS_STATE_SET_NOTIFY (flags); dom_info->state_set_async =SUPPORTS_STATE_SET_ASYNC (flags); dom_info->state_set_sync =SUPPORTS_STATE_SET_SYNC (flags); -strscpy (dom_info->name, attr->name,SCMI_SHORT_NAME_MAX_SIZE ); +strscpy (dom_info->info.name, attr->name,SCMI_SHORT_NAME_MAX_SIZE ); } ph->xops->xfer_put (ph, t);
@@ -143,7 +143,7 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph,if (!ret &&PROTOCOL_REV_MAJOR (ph->version) >=0x3 &&SUPPORTS_EXTENDED_NAMES (flags)) { ph->hops->extended_name_get (ph,POWER_DOMAIN_NAME_GET , - domain,NULL , dom_info->name, + domain,NULL , dom_info->info.name,SCMI_MAX_STR_SIZE ); }
@@ -199,23 +199,22 @@ static int scmi_power_num_domains_get(const struct scmi_protocol_handle *ph)return pi->num_domains; } -static const char * -scmi_power_name_get (const struct scmi_protocol_handle *ph, -u32 domain) +static const struct scmi_power_domain_info * +scmi_power_info_get (const struct scmi_protocol_handle *ph,u32 domain) {struct scmi_power_info *pi = ph->get_priv (ph);struct power_dom_info *dom;if (domain >= pi->num_domains) -return "unknown" ; +return NULL ; dom = pi->dom_info + domain; -return dom->name; +return &dom->info; }static const struct scmi_power_proto_ops power_proto_ops = { .num_domains_get = scmi_power_num_domains_get, - .name_get = scmi_power_name_get, + .info_get = scmi_power_info_get, .state_set = scmi_power_state_set, .state_get = scmi_power_state_get, };
drivers/pmdomain/arm/scmi_pm_domain.c +8 -1
@@ -76,8 +76,15 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)return -ENOMEM ;for (i =0 ; i < num_domains; i++, scmi_pd++) { +const struct scmi_power_domain_info *info;u32 state; + info = power_ops->info_get (ph, i); +if (!info) { +dev_warn (dev,"failed to get info for domain %d\n" , i); +continue ; + } +if (power_ops->state_get (ph, i, &state)) {dev_warn (dev,"failed to get state for domain %d\n" , i);continue ;
@@ -93,7 +100,7 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) scmi_pd->domain = i; scmi_pd->ph = ph; - scmi_pd->name = power_ops->name_get (ph, i); + scmi_pd->name = info->name; scmi_pd->genpd.name = scmi_pd->name; scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_on = scmi_pd_power_on;
include/linux/scmi_protocol.h +7 -3
@@ -191,19 +191,23 @@ struct scmi_perf_proto_ops {enum scmi_power_scale (*power_scale_get)(const struct scmi_protocol_handle *ph); }; +struct scmi_power_domain_info { +char name[SCMI_MAX_STR_SIZE ]; +}; +/** * struct scmi_power_proto_ops - represents the various operations provided * by SCMI Power Protocol * * @num_domains_get: get the count of power domains provided by SCMI -* @name_get: gets the name of a power domain +* @info_get: gets the information of the specified power domain * @state_set: sets the power state of a power domain * @state_get: gets the power state of a power domain */ struct scmi_power_proto_ops {int (*num_domains_get)(const struct scmi_protocol_handle *ph); -const char *(*name_get)(const struct scmi_protocol_handle *ph, -u32 domain); +const struct scmi_power_domain_info __must_check *(*info_get) + (const struct scmi_protocol_handle *ph,u32 domain);#define SCMI_POWER_STATE_TYPE_SHIFT 30#define SCMI_POWER_STATE_ID_MASK (BIT(28) - 1)#define SCMI_POWER_STATE_PARAM (type, id) \
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 2/9 firmware: arm_scmi: Advertize always-on power domains
In reply to Geert UytterhoevenA power domains indicates in its attribute flags if it supports setting its power state synchronously and/or asynchronously. If none of them is supported, it must be an always-on power domain.
Make this information available to SCMI protocol drivers, so they can make use of it.
--- drivers/firmware/arm_scmi/power.c | 4 ++++ include/linux/scmi_protocol.h | 1 + 2 files changed, 5 insertions(+)
drivers/firmware/arm_scmi/power.c +4 -0
@@ -8,6 +8,7 @@#define pr_fmt (fmt) "SCMI Notifications POWER - " fmt#include <linux/module.h> +#include <linux/pm_domain.h> #include <linux/scmi_protocol.h> #include "protocols.h"
@@ -147,6 +148,9 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, SCMI_MAX_STR_SIZE); } +if (!ret && !dom_info->state_set_async && !dom_info->state_set_sync) + dom_info->info.genpd_flags |=GENPD_FLAG_ALWAYS_ON ; +return ret; }
include/linux/scmi_protocol.h +1 -0
@@ -193,6 +193,7 @@ struct scmi_perf_proto_ops {struct scmi_power_domain_info {char name[SCMI_MAX_STR_SIZE ]; +unsigned int genpd_flags; };/**
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 3/9 pmdomain: arm: scmi: Add always-on support
In reply to Geert UytterhoevenExtend the PM domain flags with the flags advertized by the SCMI core. For now this is limited to GENPD_FLAG_ALWAYS_ON.
---
Questions:
- Should the power_ops->state_get() call be skipped in case of an always-on domain, and state just be force to SCMI_POWER_STATE_GENERIC_ON instead?
- Should the power_ops->state_set() call be skipped in case of an always-on domain? Or might this cause issues with some firmware implementations?
Skipping these calls may avoid adding quirk code later...
--- drivers/pmdomain/arm/scmi_pm_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pmdomain/arm/scmi_pm_domain.c +2 -1
@@ -104,7 +104,8 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.name = scmi_pd->name; scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_on = scmi_pd_power_on; - scmi_pd->genpd.flags =GENPD_FLAG_ACTIVE_WAKEUP ; + scmi_pd->genpd.flags =GENPD_FLAG_ACTIVE_WAKEUP | + info->genpd_flags;pm_genpd_init (&scmi_pd->genpd,NULL , state ==SCMI_POWER_STATE_GENERIC_OFF );
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 4/9 firmware: arm_scmi: Add a flag for power-management clocks
In reply to Geert UytterhoevenPower management of on-SoC modules is typically handled through two
methods: module power control and module clock gating. The former is exposed as an SCMI power domain, the latter as an SCMI clock.
Add a flag to indicate if a clock is intended for power-management of a hardware module.
As the SCMI clock protocol does not support advertizing power-management clocks yet, this flag can only be set by a quirk.
--- include/linux/scmi_protocol.h | 1 + 1 file changed, 1 insertion(+)
include/linux/scmi_protocol.h +1 -0
@@ -55,6 +55,7 @@ struct scmi_clock_info {bool rate_ctrl_forbidden;bool parent_ctrl_forbidden;bool extended_config; +bool pm_clk;u64 min_rate;u64 max_rate;int num_parents;
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 5/9 clk: scmi: Add scmi_clk_is_pm_clk()
In reply to Geert UytterhoevenAdd a helper for querying if an SCMI clock can be used for power-management.
--- drivers/clk/clk-scmi.c | 9 +++++++++ include/linux/clk/scmi.h | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 include/linux/clk/scmi.h
drivers/clk/clk-scmi.c +9 -0
@@ -7,6 +7,7 @@#include <linux/bits.h> #include <linux/clk-provider.h> +#include <linux/clk/scmi.h> #include <linux/device.h> #include <linux/err.h> #include <linux/of.h>
@@ -364,6 +365,14 @@ scmi_clk_ops_select(struct scmi_clk *sclk, bool atomic_capable,return ops; } +bool scmi_clk_is_pm_clk (struct clk *clk) +{ +struct clk_hw *hw =__clk_get_hw (clk); + +return hw &&to_scmi_clk (hw)->info->pm_clk; +} +EXPORT_SYMBOL_GPL (scmi_clk_is_pm_clk); +static int scmi_clocks_probe (struct scmi_device *sdev) {int idx, count, err;
include/linux/clk/scmi.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __LINUX_CLK_SCMI_H_ +#define __LINUX_CLK_SCMI_H_ + +#include <linux/types.h> + +struct clk ; + +#if IS_ENABLED (CONFIG_COMMON_CLK_SCMI ) +bool scmi_clk_is_pm_clk (struct clk *clk); +#else +static inline bool scmi_clk_is_pm_clk (struct clk *clk) {return false; } +#endif + +#endif /* __LINUX_CLK_SCMI_H_ */
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 6/9 dt-bindings: firmware: arm,scmi: Document arm,clock-domain
In reply to Geert UytterhoevenPower management of on-SoC modules is typically handled through two
methods: module power control and module clock gating. The former is exposed as an SCMI power domain, the latter as an SCMI clock.
Document the new arm,clock-domain property, to link the SCMI power domain provider to the clock domain provider that is responsible for module clock gating.
--- Documentation/devicetree/bindings/firmware/arm,scmi.yaml | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/firmware/arm,scmi.yaml +7 -0
@@ -174,6 +174,13 @@ properties: '#power-domain-cells': const: 1 + arm,clock-domain: + $ref: /schemas/types.yaml#/definitions/phandle + description: + When PM domain consumer devices are also part of a clock domain, this + property should be a reference to the SCMI clock protocol node for + the power management clocks in the clock domain. + required: - '#power-domain-cells'
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 7/9 pmdomain: arm: scmi: Add clock domain support
In reply to Geert UytterhoevenPM domain consumer devices may also part of a clock domain.
Add support for managing power management clocks in a clock domain through Runtime PM.
--- drivers/pmdomain/arm/Kconfig | 1 + drivers/pmdomain/arm/scmi_pm_domain.c | 81 ++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-)
drivers/pmdomain/arm/Kconfig +1 -0
@@ -14,6 +14,7 @@ config ARM_SCMI_PERF_DOMAIN config ARM_SCMI_POWER_DOMAIN tristate "SCMI power domain driver" depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + depends on COMMON_CLK_SCMI || !COMMON_CLK_SCMI default ARM_SCMI_PROTOCOL select PM_GENERIC_DOMAINS if PM help
drivers/pmdomain/arm/scmi_pm_domain.c +80 -1
139 lines not on this page · raw message
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 8/9 firmware: arm_scmi: quirk: Handle power management clocks on R-Car X5H
In reply to Geert UytterhoevenOn Renesas R-Car X5H, power management of on-SoC modules is handled through two methods: module power control and module clock gating. The former is exposed as an SCMI power domain, the latter as an SCMI clock.
Currently the SCMI clock protocol does not support advertizing power-management clocks yet. Add quirks to mark all module clocks suitable for power management, reusing the existing clock_rcar_x5h_4_28 and clock_rcar_x5h_4_31 quirk keys.
---
This patch is included as a PoC.
This does not build as the quirk keys are not added in this series.
--- drivers/firmware/arm_scmi/clock.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/firmware/arm_scmi/clock.c +15 -0
@@ -355,6 +355,18 @@ scmi_clock_get_permissions(const struct scmi_protocol_handle *ph, u32 clk_id,return ret; } +#define QUIRK_RCAR_X5H_4_28_PM_CLK \ + ({ \ + if (clk_id <= 818 /* Last MDLC clock MDLC_GPIODM3 */) \ + clk->pm_clk = true; \ + }) + +#define QUIRK_RCAR_X5H_4_31_PM_CLK \ + ({ \ + if (clk_id <= 814 /* Last MDLC clock MDLC_GPIODM3 */) \ + clk->pm_clk = true; \ + }) +static int scmi_clock_attributes_get (const struct scmi_protocol_handle *ph,u32 clk_id,struct clock_info *cinfo) {
@@ -410,6 +422,9 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph,if (SUPPORTS_EXTENDED_CONFIG (attributes)) clk->extended_config = true; } + +SCMI_QUIRK (clock_rcar_x5h_4_28,QUIRK_RCAR_X5H_4_28_PM_CLK ); +SCMI_QUIRK (clock_rcar_x5h_4_31,QUIRK_RCAR_X5H_4_31_PM_CLK ); }return ret;
Signature · 1 line
2.43.0
Geert Uytterhoeven
maintainerPATCH 9/9 arm64: dts: renesas: ironhide: Switch to pure SCMI
In reply to Geert UytterhoevenSwitch from CPG/MDLC remapping to pure SCMI:
- Add SCMI IDs for selected devices, supporting SCP FW SDK v4.28,
v4.31, and v4.32,
- Enable SCMI clock domain support,
- Replace clocks, power-domains, and resets properties by pure SCMI references.
Note that the user must uncomment the line that defines R_CAR_X5H_SCP_FW_SDK_VERSION to the SCP FW SDK version being used.
---
This patch is included as a PoC.
This fails to apply, as the SCMI protocol subnodes are not added in this series.
--- .../boot/dts/renesas/r8a78000-ironhide.dts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+)
arch/arm64/boot/dts/renesas/r8a78000-ironhide.dts +44 -0
@@ -9,6 +9,45 @@ #include <dt-bindings/soc/renesas,r8a78000-mfis.h> #include "r8a78000.dtsi" +#define V4_28 4028 +#define V4_31 4031 // Supports v4.31 and v4.32 + +//#define R_CAR_X5H_SCP_FW_SDK_VERSION V4_28 +#define R_CAR_X5H_SCP_FW_SDK_VERSION V4_31 + +#if R_CAR_X5H_SCP_FW_SDK_VERSION == V4_28 + +#define CLK_SGD4_PERW_BUS 1661 +#define MDLC_HSCIF0 228 +#define MDLC_HSCIF1 229 +#define MDLC_SCIF0 209 +#define MDLC_SCIF1 210 +#define MDLC_UFS1 203 +#define RESET_HSCIF0 228 +#define RESET_HSCIF1 229 +#define RESET_SCIF0 209 +#define RESET_SCIF1 210 +#define RESET_UFS1 203 + +#elif R_CAR_X5H_SCP_FW_SDK_VERSION == V4_31 + +#define CLK_SGD4_PERW_BUS 1657 +#define MDLC_HSCIF0 224 +#define MDLC_HSCIF1 225 +#define MDLC_SCIF0 205 +#define MDLC_SCIF1 206 +#define MDLC_UFS1 199 +#define RESET_HSCIF0 224 +#define RESET_HSCIF1 225 +#define RESET_SCIF0 205 +#define RESET_SCIF1 206 +#define RESET_UFS1 199 + +#endif + +#define PD_APL 257 +#define PD_UFS1 13 + / { model = "Renesas Ironhide board based on r8a78000"; compatible = "renesas,ironhide", "renesas,r8a78000";
@@ -35,6 +74,7 @@ scmi: scmi { scmi_devpd: protocol@11 { reg = <0x11>; #power-domain-cells = <1>; + arm,clock-domain = <&scmi_clk>; }; scmi_sys: protocol@12 {
@@ -138,6 +178,10 @@ &extalr_clk { }; &hscif0 { + clocks = <&scmi_clk MDLC_HSCIF0>, <&scmi_clk CLK_SGD4_PERW_BUS>, + <&scif_clk>; + power-domains = <&scmi_devpd PD_APL>; + resets = <&scmi_reset RESET_HSCIF0>; uart-has-rtscts; status = "okay"; };
Signature · 1 line
2.43.0