[PATCH v2 0/2] clk: add a stub clock driver

As U-Boot works to align itself with upstream devicetrees, there are some common issues we start to run into, that of hardware blocks which might be important for an OS like Linux, but which aren't useful in U-Boot.
For example, the Resource Power Manager found on Qualcomm platforms includes clock controllers and power domains which are only useful for managing power consumption and enabling low power states.
As this is not at all relevant for U-Boot, we can safely ignore these devices, but we don't have a good way to communicate that to U-Boot.
As an initial step, implement a "stub" clock driver which can be bound to these devices so that drivers will work as expected. Make the Qualcomm SM6115 RPMCC the first user of this, and enable the driver for Qualcomm platforms.
To: Tom Rini trini@konsulko.com To: Lukasz Majewski lukma@denx.de To: Sean Anderson seanga2@gmail.com To: Caleb Connolly caleb.connolly@linaro.org To: Neil Armstrong neil.armstrong@linaro.org To: Sumit Garg sumit.garg@linaro.org Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de Cc: u-boot-qcom@groups.io
Changes in v2: - Take the other discussed approach of just implementing a stub driver. - Link to v1: https://lore.kernel.org/r/20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro....
--- Caleb Connolly (2): clk: add stub clock driver qcom_defconfig: enable stub clock
configs/qcom_defconfig | 1 + drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) --- change-id: 20240527-b4-clk-stub-9698797a65ef base-commit: 7e52d6ccfb76e2afc2d183b357abe2a2e2f948cf
// Caleb (they/them)

Add a stub clock driver which can be used to bind clock controllers which aren't required for the platform to boot, but which are needed for U-Boot drivers to work.
In addition, add a NOP parent driver to allow for binding the parent nodes of the clock.
Initially this driver supports a Qualcomm platform where the MMC driver tries to fetch the RPM clock controller, which is not actually required for the device to work.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 9acbc47fe8ed..965bc4959403 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -95,8 +95,15 @@ config SPL_CLK_GPIO help Enable this option to add GPIO-controlled clock gate driver in U-Boot SPL.
+config CLK_STUB + bool "Stub clock driver" + depends on CLK + help + Enable this to provide a stub clock driver for non-essential clock + controllers. + config CLK_BCM6345 bool "Clock controller driver for BCM6345" depends on CLK && ARCH_BMIPS default y diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 847b9b291100..b2cea41419b7 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -10,8 +10,9 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o obj-$(CONFIG_$(SPL_TPL_)CLK_GPIO) += clk-gpio.o +obj-$(CONFIG_CLK_STUB) += clk-stub.o
obj-y += adi/ obj-y += analogbits/ obj-y += imx/ diff --git a/drivers/clk/clk-stub.c b/drivers/clk/clk-stub.c new file mode 100644 index 000000000000..3f9c758ef115 --- /dev/null +++ b/drivers/clk/clk-stub.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Stub clk driver for non-essential clocks. + * + * This driver should be used for clock controllers + * which are described as dependencies in DT but aren't + * actually necessary for hardware functionality. + */ + +#include <clk-uclass.h> +#include <dm.h> + +/* NOP parent nodes to stub clocks */ +static const struct udevice_id nop_parent_ids[] = { + { .compatible = "qcom,rpm-proc" }, + { .compatible = "qcom,glink-rpm" }, + { .compatible = "qcom,rpm-sm6115" }, + { } +}; + +U_BOOT_DRIVER(nop_parent) = { + .name = "nop_parent", + .id = UCLASS_NOP, + .of_match = nop_parent_ids, + .bind = dm_scan_fdt_dev, + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, +}; + +static ulong stub_clk_set_rate(struct clk *clk, ulong rate) +{ + return (clk->rate = rate); +} + +static ulong stub_clk_get_rate(struct clk *clk) +{ + return clk->rate; +} + +static int stub_clk_nop(struct clk *clk) +{ + return 0; +} + +static struct clk_ops stub_clk_ops = { + .set_rate = stub_clk_set_rate, + .get_rate = stub_clk_get_rate, + .enable = stub_clk_nop, + .disable = stub_clk_nop, +}; + +static const struct udevice_id stub_clk_ids[] = { + { .compatible = "qcom,rpmcc" }, + { } +}; + +U_BOOT_DRIVER(clk_stub) = { + .name = "clk_stub", + .id = UCLASS_CLK, + .ops = &stub_clk_ops, + .of_match = stub_clk_ids, + .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF, +}; +

On 27/05/2024 19:12, Caleb Connolly wrote:
Add a stub clock driver which can be used to bind clock controllers which aren't required for the platform to boot, but which are needed for U-Boot drivers to work.
In addition, add a NOP parent driver to allow for binding the parent nodes of the clock.
Initially this driver supports a Qualcomm platform where the MMC driver tries to fetch the RPM clock controller, which is not actually required for the device to work.
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org
drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 9acbc47fe8ed..965bc4959403 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -95,8 +95,15 @@ config SPL_CLK_GPIO help Enable this option to add GPIO-controlled clock gate driver in U-Boot SPL.
+config CLK_STUB
- bool "Stub clock driver"
- depends on CLK
- help
Enable this to provide a stub clock driver for non-essential clock
controllers.
- config CLK_BCM6345 bool "Clock controller driver for BCM6345" depends on CLK && ARCH_BMIPS default y
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 847b9b291100..b2cea41419b7 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -10,8 +10,9 @@ obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk.o clk-divider.o clk-mux.o clk-gate.o obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o obj-$(CONFIG_$(SPL_TPL_)CLK_GPIO) += clk-gpio.o +obj-$(CONFIG_CLK_STUB) += clk-stub.o
obj-y += adi/ obj-y += analogbits/ obj-y += imx/ diff --git a/drivers/clk/clk-stub.c b/drivers/clk/clk-stub.c new file mode 100644 index 000000000000..3f9c758ef115 --- /dev/null +++ b/drivers/clk/clk-stub.c @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-2.0 +/*
- Stub clk driver for non-essential clocks.
- This driver should be used for clock controllers
- which are described as dependencies in DT but aren't
- actually necessary for hardware functionality.
- */
+#include <clk-uclass.h> +#include <dm.h>
+/* NOP parent nodes to stub clocks */ +static const struct udevice_id nop_parent_ids[] = {
- { .compatible = "qcom,rpm-proc" },
- { .compatible = "qcom,glink-rpm" },
- { .compatible = "qcom,rpm-sm6115" },
- { }
+};
+U_BOOT_DRIVER(nop_parent) = {
- .name = "nop_parent",
- .id = UCLASS_NOP,
- .of_match = nop_parent_ids,
- .bind = dm_scan_fdt_dev,
- .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
+};
+static ulong stub_clk_set_rate(struct clk *clk, ulong rate) +{
- return (clk->rate = rate);
+}
+static ulong stub_clk_get_rate(struct clk *clk) +{
- return clk->rate;
+}
+static int stub_clk_nop(struct clk *clk) +{
- return 0;
+}
+static struct clk_ops stub_clk_ops = {
- .set_rate = stub_clk_set_rate,
- .get_rate = stub_clk_get_rate,
- .enable = stub_clk_nop,
- .disable = stub_clk_nop,
+};
+static const struct udevice_id stub_clk_ids[] = {
- { .compatible = "qcom,rpmcc" },
If you resend, please add: - qcom,sm8550-rpmh-clk - qcom,sm8650-rpmh-clk
Thanks, Neil
- { }
+};
+U_BOOT_DRIVER(clk_stub) = {
- .name = "clk_stub",
- .id = UCLASS_CLK,
- .ops = &stub_clk_ops,
- .of_match = stub_clk_ids,
- .flags = DM_FLAG_DEFAULT_PD_CTRL_OFF,
+};

Enable the stub clock driver for rpmcc
Signed-off-by: Caleb Connolly caleb.connolly@linaro.org --- configs/qcom_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig index 80ad3b32e139..65f13ae7a089 100644 --- a/configs/qcom_defconfig +++ b/configs/qcom_defconfig @@ -43,8 +43,9 @@ CONFIG_CLK_QCOM_SDM845=y CONFIG_CLK_QCOM_SM6115=y CONFIG_CLK_QCOM_SM8250=y CONFIG_CLK_QCOM_SM8550=y CONFIG_CLK_QCOM_SM8650=y +CONFIG_CLK_STUB=y CONFIG_MSM_GPIO=y CONFIG_QCOM_PMIC_GPIO=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_QUP=y

Small bump, would folks mind taking a look at this?
On 27/05/2024 19:12, Caleb Connolly wrote:
As U-Boot works to align itself with upstream devicetrees, there are some common issues we start to run into, that of hardware blocks which might be important for an OS like Linux, but which aren't useful in U-Boot.
For example, the Resource Power Manager found on Qualcomm platforms includes clock controllers and power domains which are only useful for managing power consumption and enabling low power states.
As this is not at all relevant for U-Boot, we can safely ignore these devices, but we don't have a good way to communicate that to U-Boot.
As an initial step, implement a "stub" clock driver which can be bound to these devices so that drivers will work as expected. Make the Qualcomm SM6115 RPMCC the first user of this, and enable the driver for Qualcomm platforms.
To: Tom Rini trini@konsulko.com To: Lukasz Majewski lukma@denx.de To: Sean Anderson seanga2@gmail.com To: Caleb Connolly caleb.connolly@linaro.org To: Neil Armstrong neil.armstrong@linaro.org To: Sumit Garg sumit.garg@linaro.org Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de Cc: u-boot-qcom@groups.io
Changes in v2:
- Take the other discussed approach of just implementing a stub driver.
- Link to v1: https://lore.kernel.org/r/20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro....
Caleb Connolly (2): clk: add stub clock driver qcom_defconfig: enable stub clock
configs/qcom_defconfig | 1 + drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+)
change-id: 20240527-b4-clk-stub-9698797a65ef base-commit: 7e52d6ccfb76e2afc2d183b357abe2a2e2f948cf
// Caleb (they/them)

On 27/05/2024 19:12, Caleb Connolly wrote:
As U-Boot works to align itself with upstream devicetrees, there are some common issues we start to run into, that of hardware blocks which might be important for an OS like Linux, but which aren't useful in U-Boot.
For example, the Resource Power Manager found on Qualcomm platforms includes clock controllers and power domains which are only useful for managing power consumption and enabling low power states.
As this is not at all relevant for U-Boot, we can safely ignore these devices, but we don't have a good way to communicate that to U-Boot.
As an initial step, implement a "stub" clock driver which can be bound to these devices so that drivers will work as expected. Make the Qualcomm SM6115 RPMCC the first user of this, and enable the driver for Qualcomm platforms.
To: Tom Rini trini@konsulko.com To: Lukasz Majewski lukma@denx.de To: Sean Anderson seanga2@gmail.com To: Caleb Connolly caleb.connolly@linaro.org To: Neil Armstrong neil.armstrong@linaro.org To: Sumit Garg sumit.garg@linaro.org Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de Cc: u-boot-qcom@groups.io
Changes in v2:
- Take the other discussed approach of just implementing a stub driver.
- Link to v1: https://lore.kernel.org/r/20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro....
Caleb Connolly (2): clk: add stub clock driver qcom_defconfig: enable stub clock
configs/qcom_defconfig | 1 + drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+)
change-id: 20240527-b4-clk-stub-9698797a65ef base-commit: 7e52d6ccfb76e2afc2d183b357abe2a2e2f948cf
// Caleb (they/them)
LGTM
Reviewed-by: Neil Armstrong neil.armstrong@linaro.org

On Mon, 27 May 2024 at 20:12, Caleb Connolly caleb.connolly@linaro.org wrote:
As U-Boot works to align itself with upstream devicetrees, there are some common issues we start to run into, that of hardware blocks which might be important for an OS like Linux, but which aren't useful in U-Boot.
For example, the Resource Power Manager found on Qualcomm platforms includes clock controllers and power domains which are only useful for managing power consumption and enabling low power states.
As this is not at all relevant for U-Boot, we can safely ignore these devices, but we don't have a good way to communicate that to U-Boot.
As an initial step, implement a "stub" clock driver which can be bound to these devices so that drivers will work as expected. Make the Qualcomm SM6115 RPMCC the first user of this, and enable the driver for Qualcomm platforms.
To: Tom Rini trini@konsulko.com To: Lukasz Majewski lukma@denx.de To: Sean Anderson seanga2@gmail.com To: Caleb Connolly caleb.connolly@linaro.org To: Neil Armstrong neil.armstrong@linaro.org To: Sumit Garg sumit.garg@linaro.org Cc: Heinrich Schuchardt xypron.glpk@gmx.de Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de Cc: u-boot-qcom@groups.io
Changes in v2:
- Take the other discussed approach of just implementing a stub driver.
- Link to v1: https://lore.kernel.org/r/20240410-b4-stub-drivers-v1-0-6935bd2c07d1@linaro....
Caleb Connolly (2): clk: add stub clock driver qcom_defconfig: enable stub clock
configs/qcom_defconfig | 1 + drivers/clk/Kconfig | 7 ++++++ drivers/clk/Makefile | 1 + drivers/clk/clk-stub.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+)
change-id: 20240527-b4-clk-stub-9698797a65ef base-commit: 7e52d6ccfb76e2afc2d183b357abe2a2e2f948cf
// Caleb (they/them)
Acked-by: Ilias Apalodimas ilias.apalodimas@linaro.org
participants (3)
-
Caleb Connolly
-
Ilias Apalodimas
-
Neil Armstrong