TI J7 SoC HSM Rearch support series
Subsystems (6)
cover TI J7 SoC HSM Rearch support series
Hello,
On TI J7 SoCs the device manager firmware is now split into two portions instead of the existing one which supported all services via a single firmware image running on DMSC core. Now, the existing DMSC core is dedicated for secure services only, and the PM and RM functionality is moved under a separate firmware image running on MCU R5 core. This is completely transparent for the firmware users, as the existing messaging mechanism (TI-SCI) routes everything to proper destination, except for anything that runs on MCU R5, and in our case it happens to be R5 SPL bootloader.
To support the firmware split, R5 SPL implementation must be changed in a way that it implements its own PM features, as these are needed during boot time. This series thus implements a couple of new drivers, PLL clock driver for the SoCs, and also a generic clock provider driver which is used to attach device drivers to proper clock entries. Also implemented is a power domain driver to power up/down IP blocks. R5 SPL bootloader also now needs to load and start the new DM firmware image and this is handled in the series.
There are also a number of fixes attached to the series for fixing issues noticed while implementing the new drivers, mostly on the generic clock drivers side. I decided to keep the series as a single chunk for now, as it probably makes it easier to see why certain things are done. Let me know if you want me to split this series somehow.
-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 1/26 lib: rational: copy the rational fraction lib routines from Linux
Copy the best rational approximation calculation routines from Linux. Typical usecase for these routines is to calculate the M/N divider values for PLLs to reach a specific clock rate.
--- include/linux/rational.h | 20 ++++++++ lib/Kconfig | 7 +++ lib/Makefile | 2 + lib/rational.c | 99 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 include/linux/rational.h create mode 100644 lib/rational.c
include/linux/rational.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* rational fractions +* +* Copyright (C) 2009 emlix GmbH, Oskar Schirmer <[email protected]> +* +* helper functions when coping with rational numbers, +* e.g. when calculating optimum numerator/denominator pairs for +* pll configuration taking into account restricted register size +*/ + +#ifndef _LINUX_RATIONAL_H +#define _LINUX_RATIONAL_H + +void rational_best_approximation ( +unsigned long given_numerator,unsigned long given_denominator, +unsigned long max_numerator,unsigned long max_denominator, +unsigned long *best_numerator,unsigned long *best_denominator); + +#endif /* _LINUX_RATIONAL_H */
lib/Kconfig +7 -0
@@ -660,6 +660,13 @@ config SMBIOS_PRODUCT_NAME The product name to store in SMBIOS structures. Change this to override the default one (CONFIG_SYS_BOARD). +config LIB_RATIONAL + bool "enable continued fraction calculation routines" + +config SPL_LIB_RATIONAL + bool "enable continued fraction calculation routines for SPL" + depends on SPL + endmenu config ASN1_COMPILER
lib/Makefile +2 -0
@@ -70,6 +70,8 @@ obj-$(CONFIG_$(SPL_)LZO) += lzo/ obj-$(CONFIG_$(SPL_)LZMA) += lzma/ obj-$(CONFIG_$(SPL_)LZ4) += lz4_wrapper.o +obj-$(CONFIG_$(SPL_)LIB_RATIONAL) += rational.o + obj-$(CONFIG_LIBAVB) += libavb/ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += libfdt/
lib/rational.c new file +99 -0
99 lines not on this page · raw message
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 1/26 lib: rational: copy the rational fraction lib routines from Linux
Quoted 5 lines · Tero Kristo
Copy the best rational approximation calculation routines from Linux. Typical usecase for these routines is to calculate the M/N divider values for PLLs to reach a specific clock rate.
Signed-off-by Tero Kristo <[email protected]>
Please say what version of the Linux kernel this is from, for easier later re-syncing. Thanks.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201110/87490707/attachment.sig>
PATCH 1/26 lib: rational: copy the rational fraction lib routines from Linux
Quoted 11 lines · Tom Rini
Quoted 5 lines · Tero Kristo
Copy the best rational approximation calculation routines from Linux. Typical usecase for these routines is to calculate the M/N divider values for PLLs to reach a specific clock rate.
Signed-off-by Tero Kristo <[email protected]>Please say what version of the Linux kernel this is from, for easier later re-syncing. Thanks.
This is based on kernel commit:
commit 323dd2c3ed0641f49e89b4e420f9eef5d3d5a881
Author: Trent Piepho <[email protected]> Date: Wed Dec 4 16:51:57 2019 -0800
lib/math/rational.c: fix possible incorrect result from rational
fractions helper
-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 2/26 ram: k3-j721e: fix clk_set_rate API usage
In reply to Tero Kristoclk_set_rate returns the new clock rate for the clock, not 0 in success. Fix the error checks to reflect proper API usage.
--- drivers/ram/k3-j721e/k3-j721e-ddrss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ram/k3-j721e/k3-j721e-ddrss.c +4 -2
@@ -195,8 +195,10 @@ static int j721e_ddrss_ofdata_to_priv(struct udevice *dev)/* Put DDR pll in bypass mode */ ret =clk_set_rate (&ddrss->ddr_clk,clk_get_rate (&ddrss->osc_clk)); -if (ret) -dev_err (dev,"ddr clk bypass failed\n" ); +if (ret <0 ) +dev_err (dev,"ddr clk bypass failed: %d\n" , ret); +else + ret =0 ;return ret; }
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 3/26 remoteproc: k3-r5: remove sysfw PM calls if not supported
In reply to Tero KristoWith the sysfw rearch, sysfw PM calls are no longer available from SPL level. To properly support this, remove the is_on checks and the reset assertion from the R5 remoteproc driver as these are not supported. Attempting to access unavailable services will cause the device to hang.
--- drivers/remoteproc/ti_k3_r5f_rproc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +4 -0
@@ -781,7 +781,9 @@ static int k3_r5f_probe(struct udevice *dev) {struct k3_r5f_cluster *cluster =dev_get_priv (dev->parent);struct k3_r5f_core *core =dev_get_priv (dev); +#ifdef CONFIG_CLK_TI_SCI bool r_state; +#endif int ret;dev_dbg (dev,"%s\n" , __func__);
@@ -804,6 +806,7 @@ static int k3_r5f_probe(struct udevice *dev)return ret; } +#ifdef CONFIG_CLK_TI_SCI ret = core->tsp.sci->ops.dev_ops.is_on (core->tsp.sci, core->tsp.dev_id, &r_state, &core->in_use);if (ret)
@@ -817,6 +820,7 @@ static int k3_r5f_probe(struct udevice *dev)/* Make sure Local reset is asserted. Redundant? */ reset_assert (&core->reset); +#endif ret =k3_r5f_rproc_configure (core);if (ret) {
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 3/26 remoteproc: k3-r5: remove sysfw PM calls if not supported
Quoted 15 lines · Tero Kristo
With the sysfw rearch, sysfw PM calls are no longer available from SPL level. To properly support this, remove the
is_onchecks and the reset assertion from the R5 remoteproc driver as these are not supported. Attempting to access unavailable services will cause the device to hang.Signed-off-by Tero Kristo <[email protected]>--- drivers/remoteproc/ti_k3_r5f_rproc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/remoteproc/ti_k3_r5f_rproc.c +0
-0
drivers/remoteproc/ti_k3_r5f_rproc.c static int k3_r5f_probe(struct udevice *dev) · line 784
Quoted 4 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0@@ -781,7 +781,9 @@ static int k3_r5f_probe(struct udevice *dev) {struct k3_r5f_cluster *cluster =dev_get_priv (dev->parent);struct k3_r5f_core *core =dev_get_priv (dev); +#ifdef CONFIG_CLK_TI_SCI
Since we are checking for device state, can you make this guard under power domain instead of clock?
drivers/remoteproc/ti_k3_r5f_rproc.c static int k3_r5f_probe(struct udevice *dev) · line 809
Quoted 10 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +2
-0bool r_state; +#endif int ret;dev_dbg (dev,"%s\n" , __func__);@@ -804,6 +806,7 @@ static int k3_r5f_probe(struct udevice *dev)return ret; } +#ifdef CONFIG_CLK_TI_SCI
Can you also add a comment here on why we are doing this?
Thanks and regards,
Lokesh
Quoted 12 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0ret = core->tsp.sci->ops.dev_ops.is_on (core->tsp.sci, core->tsp.dev_id, &r_state, &core->in_use);if (ret)@@ -817,6 +820,7 @@ static int k3_r5f_probe(struct udevice *dev)/* Make sure Local reset is asserted. Redundant? */ reset_assert (&core->reset); +#endif ret =k3_r5f_rproc_configure (core);if (ret) {
PATCH 3/26 remoteproc: k3-r5: remove sysfw PM calls if not supported
Quoted 13 lines · Lokesh Vutla
Quoted 10 lines · Tero Kristo
With the sysfw rearch, sysfw PM calls are no longer available from SPL level. To properly support this, remove the
is_onchecks and the reset assertion from the R5 remoteproc driver as these are not supported. Attempting to access unavailable services will cause the device to hang.Signed-off-by Tero Kristo <[email protected]>--- drivers/remoteproc/ti_k3_r5f_rproc.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 12 lines
drivers/remoteproc/ti_k3_r5f_rproc.c static int k3_r5f_probe(struct udevice *dev) · line 784
Quoted 9 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0@@ -781,7 +781,9 @@ static int k3_r5f_probe(struct udevice *dev) {struct k3_r5f_cluster *cluster =dev_get_priv (dev->parent);struct k3_r5f_core *core =dev_get_priv (dev); +#ifdef CONFIG_CLK_TI_SCI Since we are checking for device state, can you make this guard under power domain instead of clock?
Hmm right, that would work. Will change.
Quoted 5 lines
Quoted 5 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0bool r_state; +#endif int ret;
Quoted 8 lines
drivers/remoteproc/ti_k3_r5f_rproc.c static int k3_r5f_probe(struct udevice *dev) · line 809
Quoted 6 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0dev_dbg (dev,"%s\n" , __func__);@@ -804,6 +806,7 @@ static int k3_r5f_probe(struct udevice *dev)return ret; } +#ifdef CONFIG_CLK_TI_SCI Can you also add a comment here on why we are doing this?
I can add an inline comment for this.
-Tero
Quoted 9 lines
Thanks and regards,
LokeshQuoted 5 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +0
-0ret = core->tsp.sci->ops.dev_ops.is_on (core->tsp.sci, core->tsp.dev_id, &r_state, &core->in_use);if (ret)@@ -817,6 +820,7 @@ static int k3_r5f_probe(struct udevice *dev)
Quoted 7 lines
drivers/remoteproc/ti_k3_r5f_rproc.c static int k3_r5f_probe(struct udevice *dev) · line 826
Quoted 7 lines
drivers/remoteproc/ti_k3_r5f_rproc.c +1
-0/* Make sure Local reset is asserted. Redundant? */ reset_assert (&core->reset); +#endif ret =k3_r5f_rproc_configure (core);if (ret) {
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 4/26 common: fit: Update board_fit_image_post_process() to pass fit and node_offset
In reply to Tero KristoFrom: Lokesh Vutla <[email protected]>
board_fit_image_post_process() passes only start and size of the image, but type of the image is not passed. So pass fit and node_offset, to derive information about image to be processed.
--- arch/arm/mach-k3/security.c | 3 ++- arch/arm/mach-keystone/mon.c | 3 ++- board/ti/am335x/board.c | 3 ++- board/ti/am43xx/board.c | 3 ++- board/ti/am57xx/board.c | 3 ++- board/ti/dra7xx/evm.c | 3 ++- common/image-fit.c | 2 +- common/spl/spl_fit.c | 2 +- include/image.h | 7 +++++-- 9 files changed, 19 insertions(+), 10 deletions(-)
arch/arm/mach-k3/security.c +2 -1
@@ -18,7 +18,8 @@#include <spl.h> #include <asm/arch/sys_proto.h> -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {struct ti_sci_handle *ti_sci =get_ti_sci_handle ();struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops;
arch/arm/mach-keystone/mon.c +2 -1
@@ -103,7 +103,8 @@ static int k2_hs_bm_auth(int cmd, void *arg1)return result; } -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {int result =0 ;void *image = *p_image;
board/ti/am335x/board.c +2 -1
@@ -956,7 +956,8 @@ int board_fit_config_name_match(const char *name)#endif #ifdef CONFIG_TI_SECURE_DEVICE -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {secure_boot_verify_image (p_image, p_size); }
board/ti/am43xx/board.c +2 -1
@@ -895,7 +895,8 @@ int embedded_dtb_select(void)#endif #ifdef CONFIG_TI_SECURE_DEVICE -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {secure_boot_verify_image (p_image, p_size); }
board/ti/am57xx/board.c +2 -1
@@ -1197,7 +1197,8 @@ static int board_bootmode_has_emmc(void)#endif #ifdef CONFIG_TI_SECURE_DEVICE -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {secure_boot_verify_image (p_image, p_size); }
board/ti/dra7xx/evm.c +2 -1
@@ -1064,7 +1064,8 @@ int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)#endif #ifdef CONFIG_TI_SECURE_DEVICE -void board_fit_image_post_process (void **p_image,size_t *p_size) +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) {secure_boot_verify_image (p_image, p_size); }
common/image-fit.c +1 -1
@@ -2042,7 +2042,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,#if !defined(USE_HOSTCC ) && defined(CONFIG_FIT_IMAGE_POST_PROCESS )/* perform any post-processing on the image data */ -board_fit_image_post_process (&buf, &size); +board_fit_image_post_process (fit, noffset, &buf, &size);#endif len = (ulong )size;
common/spl/spl_fit.c +1 -1
@@ -316,7 +316,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,#endif #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS -board_fit_image_post_process (&src, &length); +board_fit_image_post_process (fit, node, &src, &length);#endif if (IS_ENABLED (CONFIG_SPL_GZIP ) && image_comp ==IH_COMP_GZIP ) {
include/image.h +5 -2
@@ -1537,12 +1537,15 @@ int board_fit_config_name_match(const char *name);* into the FIT creation (i.e. the binary blobs would have been pre-processed * before being added to the FIT image). * +* @fit: pointer to fit image +* @node: offset of image node * @image: pointer to the image start pointer * @size: pointer to the image size * @return no return value (failure should be handled internally) */ -void board_fit_image_post_process (void **p_image,size_t *p_size); -#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */ +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size); +#endif #define FDT_ERROR ((ulong)(-1))
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 5/26 clk: fixed_rate: add API for directly registering fixed rate clocks
In reply to Tero KristoCurrent driver only supports registering fixed rate clocks from DT. Add new API which makes it possible to register fixed rate clocks directly from e.g. platform specific clock drivers.
--- drivers/clk/clk_fixed_rate.c | 45 +++++++++++++++++++++++++++++++++++- include/linux/clk-provider.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-)
drivers/clk/clk_fixed_rate.c +44 -1
@@ -8,6 +8,9 @@#include <dm.h> #include <linux/clk-provider.h> +#define UBOOT_DM_CLK_FIXED_RATE "fixed_rate_clock" +#define UBOOT_DM_CLK_FIXED_RATE_RAW "fixed_rate_raw_clock" +static ulong clk_fixed_rate_get_rate (struct clk *clk) {return to_clk_fixed_rate (clk->dev)->fixed_rate;
@@ -24,6 +27,15 @@ const struct clk_ops clk_fixed_rate_ops = { .enable = dummy_enable, }; +static ulong clk_fixed_rate_raw_get_rate (struct clk *clk) +{ + return container_of(clk, struct clk_fixed_rate, clk)->fixed_rate; +} + +const struct clk_ops clk_fixed_rate_raw_ops = { + .get_rate = clk_fixed_rate_raw_get_rate, +}; +static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) {struct clk *clk = &to_clk_fixed_rate (dev)->clk;
@@ -39,6 +51,30 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)return 0 ; } +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate) +{ +struct clk *clk; +struct clk_fixed_rate *fixed; +int ret; + + fixed =kzalloc (sizeof (*fixed),GFP_KERNEL ); +if (!fixed) +return ERR_PTR (-ENOMEM ); + + fixed->fixed_rate = rate; + + clk = &fixed->clk; + + ret =clk_register (clk,UBOOT_DM_CLK_FIXED_RATE_RAW , name,NULL ); +if (ret) { +kfree (fixed); +return ERR_PTR (ret); + } + +return clk; +} +static const struct udevice_id clk_fixed_rate_match[] = { { .compatible ="fixed-clock" ,
@@ -47,7 +83,7 @@ static const struct udevice_id clk_fixed_rate_match[] = { };U_BOOT_DRIVER (clk_fixed_rate) = { - .name ="fixed_rate_clock" , + .name =UBOOT_DM_CLK_FIXED_RATE , .id =UCLASS_CLK , .of_match = clk_fixed_rate_match, .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata,
@@ -55,3 +91,10 @@ U_BOOT_DRIVER(clk_fixed_rate) = { .ops = &clk_fixed_rate_ops, .flags = DM_FLAG_PRE_RELOC, }; + +U_BOOT_DRIVER (clk_fixed_rate_raw) = { + .name =UBOOT_DM_CLK_FIXED_RATE_RAW , + .id =UCLASS_CLK , + .ops = &clk_fixed_rate_raw_ops, + .flags =DM_FLAG_PRE_RELOC , +};
include/linux/clk-provider.h +3 -0
@@ -186,6 +186,9 @@ struct clk *clk_register_mux(struct device *dev, const char *name, void __iomem *reg, u8 shift, u8 width, u8 clk_mux_flags); +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate); +const char *clk_hw_get_name (const struct clk *hw);ulong clk_generic_get_rate (struct clk *clk);
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 5/26 clk: fixed_rate: add API for directly registering fixed rate clocks
+ Simon, Peng, Lukasz
Quoted 108 lines · Tero Kristo
Current driver only supports registering fixed rate clocks from DT. Add new API which makes it possible to register fixed rate clocks directly from e.g. platform specific clock drivers.
Signed-off-by Tero Kristo <[email protected]>--- drivers/clk/clk_fixed_rate.c | 45 +++++++++++++++++++++++++++++++++++- include/linux/clk-provider.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-)drivers/clk/clk_fixed_rate.c +44
-1@@ -8,6 +8,9 @@#include <dm.h> #include <linux/clk-provider.h> +#define UBOOT_DM_CLK_FIXED_RATE "fixed_rate_clock" +#define UBOOT_DM_CLK_FIXED_RATE_RAW "fixed_rate_raw_clock" +static ulong clk_fixed_rate_get_rate (struct clk *clk) {return to_clk_fixed_rate (clk->dev)->fixed_rate;@@ -24,6 +27,15 @@ const struct clk_ops clk_fixed_rate_ops = { .enable = dummy_enable, }; +static ulong clk_fixed_rate_raw_get_rate (struct clk *clk) +{ + return container_of(clk, struct clk_fixed_rate, clk)->fixed_rate; +} + +const struct clk_ops clk_fixed_rate_raw_ops = { + .get_rate = clk_fixed_rate_raw_get_rate, +}; +static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) {struct clk *clk = &to_clk_fixed_rate (dev)->clk;@@ -39,6 +51,30 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)return 0 ; } +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate) +{ +struct clk *clk; +struct clk_fixed_rate *fixed; +int ret; + + fixed =kzalloc (sizeof (*fixed),GFP_KERNEL ); +if (!fixed) +return ERR_PTR (-ENOMEM ); + + fixed->fixed_rate = rate; + + clk = &fixed->clk; + + ret =clk_register (clk,UBOOT_DM_CLK_FIXED_RATE_RAW , name,NULL ); +if (ret) { +kfree (fixed); +return ERR_PTR (ret); + } + +return clk; +} +static const struct udevice_id clk_fixed_rate_match[] = { { .compatible ="fixed-clock" ,@@ -47,7 +83,7 @@ static const struct udevice_id clk_fixed_rate_match[] = { };U_BOOT_DRIVER (clk_fixed_rate) = { - .name ="fixed_rate_clock" , + .name =UBOOT_DM_CLK_FIXED_RATE , .id =UCLASS_CLK , .of_match = clk_fixed_rate_match, .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata,@@ -55,3 +91,10 @@ U_BOOT_DRIVER(clk_fixed_rate) = { .ops = &clk_fixed_rate_ops, .flags = DM_FLAG_PRE_RELOC, }; + +U_BOOT_DRIVER (clk_fixed_rate_raw) = { + .name =UBOOT_DM_CLK_FIXED_RATE_RAW , + .id =UCLASS_CLK , + .ops = &clk_fixed_rate_raw_ops, + .flags =DM_FLAG_PRE_RELOC , +};include/linux/clk-provider.h +3
-0@@ -186,6 +186,9 @@ struct clk *clk_register_mux(struct device *dev, const char *name, void __iomem *reg, u8 shift, u8 width, u8 clk_mux_flags); +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate); +const char *clk_hw_get_name (const struct clk *hw);ulong clk_generic_get_rate (struct clk *clk);
PATCH 5/26 clk: fixed_rate: add API for directly registering fixed rate clocks
In reply to Tero KristoQuoted 8 lines
Subject: [PATCH 05/26] clk:
fixed_rate: add API for directly registering fixed rate clocksCurrent driver only supports registering fixed rate clocks from DT. Add new API which makes it possible to register fixed rate clocks directly from e.g. platform specific clock drivers.
Signed-off-by Tero Kristo <[email protected]>
Quoted 104 lines
--- drivers/clk/clk_fixed_rate.c | 45 +++++++++++++++++++++++++++++++++++- include/linux/clk-provider.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-)drivers/clk/clk_fixed_rate.c index renamed from drivers/clk/clk_fixed_rate.c +0
-0
55e1f8caa5..5556acaf86100644drivers/clk/clk_fixed_rate.c +25
-0@@ -8,6 +8,9 @@#include <dm.h> #include <linux/clk-provider.h> +#define UBOOT_DM_CLK_FIXED_RATE "fixed_rate_clock" +#define UBOOT_DM_CLK_FIXED_RATE_RAW "fixed_rate_raw_clock" +static ulong clk_fixed_rate_get_rate (struct clk *clk) {return to_clk_fixed_rate (clk->dev)->fixed_rate;@@ -24,6 +27,15 @@ const struct clk_ops clk_fixed_rate_ops = { .enable = dummy_enable, }; +static ulong clk_fixed_rate_raw_get_rate (struct clk *clk) { + return container_of(clk, struct clk_fixed_rate, clk)->fixed_rate; } + +const struct clk_ops clk_fixed_rate_raw_ops = { + .get_rate = clk_fixed_rate_raw_get_rate, }; +static int clk_fixed_rate_ofdata_to_platdata (struct udevice *dev) { struct clk *clk = &to_clk_fixed_rate(dev)->clk; @@ -39,6 +51,30 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev) return 0; } +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate) +{ +struct clk *clk; +struct clk_fixed_rate *fixed; +int ret; + + fixed =kzalloc (sizeof (*fixed),GFP_KERNEL ); +if (!fixed) +return ERR_PTR (-ENOMEM ); + + fixed->fixed_rate = rate; + + clk = &fixed->clk; + + ret = clk_register(clk, UBOOT_DM_CLK_FIXED_RATE_RAW, name,NULL);
drivers/clk/clk_fixed_rate.c +16
-1+if (ret) { +kfree (fixed); +return ERR_PTR (ret); + } + +return clk; +} +static const struct udevice_id clk_fixed_rate_match[] = { { .compatible ="fixed-clock" ,@@ -47,7 +83,7 @@ static const struct udevice_id clk_fixed_rate_match[] = { };U_BOOT_DRIVER (clk_fixed_rate) = { - .name ="fixed_rate_clock" , + .name =UBOOT_DM_CLK_FIXED_RATE , .id =UCLASS_CLK , .of_match = clk_fixed_rate_match, .ofdata_to_platdata = clk_fixed_rate_ofdata_to_platdata,@@ -55,3 +91,10 @@ U_BOOT_DRIVER(clk_fixed_rate) = { .ops = &clk_fixed_rate_ops, .flags = DM_FLAG_PRE_RELOC, }; + +U_BOOT_DRIVER (clk_fixed_rate_raw) = { + .name =UBOOT_DM_CLK_FIXED_RATE_RAW , + .id =UCLASS_CLK , + .ops = &clk_fixed_rate_raw_ops, + .flags =DM_FLAG_PRE_RELOC , +};include/linux/clk-provider.h index renamed from include/linux/clk-provider.h +0
-0
79dce8f0ad..6b50c42214100644include/linux/clk-provider.h +3
-1@@ -186,6 +186,9 @@ struct clk *clk_register_mux(struct device *dev, constchar *name, void __iomem *reg, u8 shift, u8 width, u8 clk_mux_flags); +struct clk *clk_register_fixed_rate (struct device *dev,const char *name, +ulong rate); +const char *clk_hw_get_name (const struct clk *hw);ulong clk_generic_get_rate (struct clk *clk); --2.17.1
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 6/26 clk: fix clock tree dump to properly dump out every registered clock
In reply to Tero KristoSome clocks are not associated to a DM node, so just parsing the DM is not enough. This is especially true for root clocks, which typically don't have any parents. Instead, fetch every registered UCLASS_CLK instance, and dump these out.
--- cmd/clk.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
cmd/clk.c +19 -8
@@ -18,11 +18,14 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) {int i, is_last;struct udevice *child; -struct clk *clkp; +struct clk *clkp, *parent;u32 rate; clkp =dev_get_clk_ptr (dev);if (device_get_uclass_id (dev) ==UCLASS_CLK && clkp) { + parent =clk_get_parent (clkp); +if (!IS_ERR (parent) && depth ==-1 ) +return ; depth++; rate =clk_get_rate (clkp);
@@ -47,6 +50,9 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) }list_for_each_entry (child, &dev->child_head, sibling_node) { +if (child == dev) +continue ; + is_last =list_is_last (&child->sibling_node, &dev->child_head);show_clks (child, depth, (last_flag <<1 ) | is_last); }
@@ -54,14 +60,19 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)int __weak soc_clk_dump (void ) { -struct udevice *root; +struct udevice *dev; +struct uclass *uc; +int ret; - root =dm_root (); -if (root) { -printf (" Rate Usecnt Name\n" ); -printf ("------------------------------------------\n" ); -show_clks (root,-1 ,0 ); - } + ret =uclass_get (UCLASS_CLK , &uc); +if (ret) +return ret; + +printf (" Rate Usecnt Name\n" ); +printf ("------------------------------------------\n" ); + + uclass_foreach_dev(dev, uc) +show_clks (dev,-1 ,0 );return 0 ; }
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 6/26 clk: fix clock tree dump to properly dump out every registered clock
+Lucasz
Quoted 68 lines · Tero Kristo
Some clocks are not associated to a DM node, so just parsing the DM is not enough. This is especially true for root clocks, which typically don't have any parents. Instead, fetch every registered
UCLASS_CLKinstance, and dump these out.Signed-off-by Tero Kristo <[email protected]>--- cmd/clk.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)cmd/clk.c +19
-8@@ -18,11 +18,14 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) {int i, is_last;struct udevice *child; -struct clk *clkp; +struct clk *clkp, *parent;u32 rate; clkp =dev_get_clk_ptr (dev);if (device_get_uclass_id (dev) ==UCLASS_CLK && clkp) { + parent =clk_get_parent (clkp); +if (!IS_ERR (parent) && depth ==-1 ) +return ; depth++; rate =clk_get_rate (clkp);@@ -47,6 +50,9 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) }list_for_each_entry (child, &dev->child_head, sibling_node) { +if (child == dev) +continue ; + is_last =list_is_last (&child->sibling_node, &dev->child_head);show_clks (child, depth, (last_flag <<1 ) | is_last); }@@ -54,14 +60,19 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)int __weak soc_clk_dump (void ) { -struct udevice *root; +struct udevice *dev; +struct uclass *uc; +int ret; - root =dm_root (); -if (root) { -printf (" Rate Usecnt Name\n" ); -printf ("------------------------------------------\n" ); -show_clks (root,-1 ,0 ); - } + ret =uclass_get (UCLASS_CLK , &uc); +if (ret) +return ret; + +printf (" Rate Usecnt Name\n" ); +printf ("------------------------------------------\n" ); + + uclass_foreach_dev(dev, uc) +show_clks (dev,-1 ,0 );return 0 ; }
PATCH 7/26 clk: do not attempt to fetch clock pointer with null device
In reply to Tero KristoBail out early if device returned for the parent clock is null. This avoids warning prints like this when doing clk dump:
dev_get_uclass_priv: null device
--- drivers/clk/clk-uclass.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/clk-uclass.c +2 -0
@@ -493,6 +493,8 @@ struct clk *clk_get_parent(struct clk *clk)return NULL ; pdev =dev_get_parent (clk->dev); +if (!pdev) +return ERR_PTR (-ENODEV ); pclk =dev_get_clk_ptr (pdev);if (!pclk)return ERR_PTR (-ENODEV );
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 8/26 clk: add support for setting clk rate from cmdline
In reply to Tero KristoAdd new clk subcommand "clk setfreq", for setting up a clock rate directly from u-boot cmdline. This is handy for any debugging purposes towards clocks.
--- cmd/clk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
cmd/clk.c +47 -2
@@ -98,8 +98,52 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc,return ret; } +struct udevice *clk_lookup (const char *name) +{ +int i =0 ; +struct udevice *dev; + +do { +uclass_get_device (UCLASS_CLK , i++, &dev); +if (!strcmp (name, dev->name)) +return dev; + }while (dev); + +return NULL ; +} + +static int do_clk_setfreq (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct clk *clk =NULL ; +s32 freq; +struct udevice *dev; + + freq =simple_strtoul (argv[2 ],NULL ,10 ); + + dev =clk_lookup (argv[1 ]); + +if (dev) + clk =dev_get_clk_ptr (dev); + +if (!clk) { +printf ("clock '%s' not found.\n" , argv[1 ]); +return -EINVAL ; + } + + freq =clk_set_rate (clk, freq); +if (freq <0 ) { +printf ("set_rate failed: %d\n" , freq); +return CMD_RET_FAILURE ; + } + +printf ("set_rate returns %u\n" , freq); +return 0 ; +} +static struct cmd_tbl cmd_clk_sub[] = {U_BOOT_CMD_MKENT (dump,1 ,1 , do_clk_dump,"" ,"" ), +U_BOOT_CMD_MKENT (setfreq,3 ,1 , do_clk_setfreq,"" ,"" ), }; static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -124,7 +168,8 @@ static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,#ifdef CONFIG_SYS_LONGHELP static char clk_help_text[] = -"dump - Print clock frequencies" ; +"dump - Print clock frequencies\n" +"setfreq [clk] [freq] - Set clock frequency" ;#endif -U_BOOT_CMD (clk,2 ,1 , do_clk,"CLK sub-system" , clk_help_text); +U_BOOT_CMD (clk,4 ,1 , do_clk,"CLK sub-system" , clk_help_text);
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 8/26 clk: add support for setting clk rate from cmdline
+Lucasz
Quoted 78 lines · Tero Kristo
Add new clk subcommand "clk setfreq", for setting up a clock rate directly from u-boot cmdline. This is handy for any debugging purposes towards clocks.
Signed-off-by Tero Kristo <[email protected]>--- cmd/clk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)cmd/clk.c +47
-2@@ -98,8 +98,52 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc,return ret; } +struct udevice *clk_lookup (const char *name) +{ +int i =0 ; +struct udevice *dev; + +do { +uclass_get_device (UCLASS_CLK , i++, &dev); +if (!strcmp (name, dev->name)) +return dev; + }while (dev); + +return NULL ; +} + +static int do_clk_setfreq (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct clk *clk =NULL ; +s32 freq; +struct udevice *dev; + + freq =simple_strtoul (argv[2 ],NULL ,10 ); + + dev =clk_lookup (argv[1 ]); + +if (dev) + clk =dev_get_clk_ptr (dev); + +if (!clk) { +printf ("clock '%s' not found.\n" , argv[1 ]); +return -EINVAL ; + } + + freq =clk_set_rate (clk, freq); +if (freq <0 ) { +printf ("set_rate failed: %d\n" , freq); +return CMD_RET_FAILURE ; + } + +printf ("set_rate returns %u\n" , freq); +return 0 ; +} +static struct cmd_tbl cmd_clk_sub[] = {U_BOOT_CMD_MKENT (dump,1 ,1 , do_clk_dump,"" ,"" ), +U_BOOT_CMD_MKENT (setfreq,3 ,1 , do_clk_setfreq,"" ,"" ), }; static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,@@ -124,7 +168,8 @@ static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,#ifdef CONFIG_SYS_LONGHELP static char clk_help_text[] = -"dump - Print clock frequencies" ; +"dump - Print clock frequencies\n" +"setfreq [clk] [freq] - Set clock frequency" ;#endif -U_BOOT_CMD (clk,2 ,1 , do_clk,"CLK sub-system" , clk_help_text); +U_BOOT_CMD (clk,4 ,1 , do_clk,"CLK sub-system" , clk_help_text);
PATCH 8/26 clk: add support for setting clk rate from cmdline
Quoted 1 line · Lokesh Vutla
+Lucasz
This is just a nice to have patch. Found it quite useful while debugging the new drivers so decided to share.
-Tero
Quoted 77 lines · Tero Kristo
Quoted 75 lines
Add new clk subcommand "clk setfreq", for setting up a clock rate directly from u-boot cmdline. This is handy for any debugging purposes towards clocks.
Signed-off-by Tero Kristo <[email protected]>--- cmd/clk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)cmd/clk.c +46
-1@@ -98,8 +98,52 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc,return ret; } +struct udevice *clk_lookup (const char *name) +{ +int i =0 ; +struct udevice *dev; + +do { +uclass_get_device (UCLASS_CLK , i++, &dev); +if (!strcmp (name, dev->name)) +return dev; + }while (dev); + +return NULL ; +} + +static int do_clk_setfreq (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct clk *clk =NULL ; +s32 freq; +struct udevice *dev; + + freq =simple_strtoul (argv[2 ],NULL ,10 ); + + dev =clk_lookup (argv[1 ]); + +if (dev) + clk =dev_get_clk_ptr (dev); + +if (!clk) { +printf ("clock '%s' not found.\n" , argv[1 ]); +return -EINVAL ; + } + + freq =clk_set_rate (clk, freq); +if (freq <0 ) { +printf ("set_rate failed: %d\n" , freq); +return CMD_RET_FAILURE ; + } + +printf ("set_rate returns %u\n" , freq); +return 0 ; +} +static struct cmd_tbl cmd_clk_sub[] = {U_BOOT_CMD_MKENT (dump,1 ,1 , do_clk_dump,"" ,"" ), +U_BOOT_CMD_MKENT (setfreq,3 ,1 , do_clk_setfreq,"" ,"" ), }; static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,@@ -124,7 +168,8 @@ static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,#ifdef CONFIG_SYS_LONGHELP static char clk_help_text[] = -"dump - Print clock frequencies" ; +"dump - Print clock frequencies\n" +"setfreq [clk] [freq] - Set clock frequency" ;#endif
Quoted 3 lines
cmd/clk.c static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc, · line 175
Quoted 3 lines
cmd/clk.c +1
-1-U_BOOT_CMD (clk,2 ,1 , do_clk,"CLK sub-system" , clk_help_text); +U_BOOT_CMD (clk,4 ,1 , do_clk,"CLK sub-system" , clk_help_text);
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 8/26 clk: add support for setting clk rate from cmdline
Hi Tero,
Quoted 86 lines · Lokesh Vutla
Quoted 1 line
+Lucasz
This is just a nice to have patch. Found it quite useful while debugging the new drivers so decided to share.
-Tero
Quoted 78 lines · Tero Kristo
Quoted 76 lines
Add new clk subcommand "clk setfreq", for setting up a clock rate directly from u-boot cmdline. This is handy for any debugging purposes towards clocks.
Signed-off-by Tero Kristo <[email protected]>--- cmd/clk.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)cmd/clk.c +44
-0@@ -98,8 +98,52 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc, return ret; } +struct udevice *clk_lookup (const char *name) +{ +int i =0 ; +struct udevice *dev; + +do { +uclass_get_device (UCLASS_CLK , i++, &dev); +if (!strcmp (name, dev->name)) +return dev; + }while (dev); + +return NULL ; +} + +static int do_clk_setfreq (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct clk *clk =NULL ; +s32 freq; +struct udevice *dev; + + freq =simple_strtoul (argv[2 ],NULL ,10 ); + + dev =clk_lookup (argv[1 ]); + +if (dev) + clk =dev_get_clk_ptr (dev); + +if (!clk) { +printf ("clock '%s' not found.\n" , argv[1 ]); +return -EINVAL ; + } + + freq =clk_set_rate (clk, freq); +if (freq <0 ) { +printf ("set_rate failed: %d\n" , freq); +return CMD_RET_FAILURE ; + } + +printf ("set_rate returns %u\n" , freq); +return 0 ; +} +static struct cmd_tbl cmd_clk_sub[] = {U_BOOT_CMD_MKENT (dump,1 ,1 , do_clk_dump,"" ,"" ), +U_BOOT_CMD_MKENT (setfreq,3 ,1 , do_clk_setfreq,"" ,"" ), };static int do_clk(struct
cmd_tbl*cmdtp, int flag, int argc,cmd/clk.c +2
-1@@ -124,7 +168,8 @@ static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc,#ifdef CONFIG_SYS_LONGHELP static char clk_help_text[] = -"dump - Print clock frequencies" ; +"dump - Print clock frequencies\n" +"setfreq [clk] [freq] - Set clock frequency" ;#endif
Quoted 7 lines
Quoted 3 lines
cmd/clk.c static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc, · line 175
Quoted 3 lines
cmd/clk.c +1
-1-U_BOOT_CMD (clk,2 ,1 , do_clk,"CLK sub-system" , clk_help_text); +U_BOOT_CMD (clk,4 ,1 , do_clk,"CLK sub-system" , clk_help_text);--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201116/17ee7fa0/attachment.sig>
PATCH 9/26 clk: sci-clk: fix return value of set_rate
In reply to Tero KristoSet rate should return the new clock rate on success, and negative error value on failure. Fix this, as currently set_rate returns 0 on success.
--- drivers/clk/clk-ti-sci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/clk-ti-sci.c +4 -2
@@ -111,10 +111,12 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)#endif ret = cops->set_freq (sci, clk->id, clk->data,0 , rate,ULONG_MAX ); -if (ret) +if (ret) {dev_err (clk->dev,"%s: set_freq failed (%d)\n" , __func__, ret); +return ret; + } -return ret; +return rate; }static int ti_sci_clk_set_parent (struct clk *clk,struct clk *parent)
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 10/26 clk: fix assigned-clocks to pass with deferring provider
In reply to Tero KristoIf a clock provider is not ready for assigning default rates/parents during its probe, it may return -EPROBE_DEFER directly from xlate. Handle this special case properly by skipping the entry and adjusting the return value to pass. The defaults will be handled properly in post probe phase then.
--- drivers/clk/clk-uclass.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/clk/clk-uclass.c +18 -0
@@ -239,6 +239,15 @@ static int clk_set_default_parents(struct udevice *dev, int stage) ret =clk_get_by_indexed_prop (dev,"assigned-clocks" , index, &clk); +/* +* If the clock provider is not ready yet, let it handle +* the re-programming later. +*/ +if (ret == -EPROBE_DEFER ) { + ret =0 ; +continue ; + } +if (ret) {debug ("%s: could not get assigned clock %d for %s\n" , __func__, index,dev_read_name (dev));
@@ -307,6 +316,15 @@ static int clk_set_default_rates(struct udevice *dev, int stage) ret =clk_get_by_indexed_prop (dev,"assigned-clocks" , index, &clk); +/* +* If the clock provider is not ready yet, let it handle +* the re-programming later. +*/ +if (ret == -EPROBE_DEFER ) { + ret =0 ; +continue ; + } +if (ret) {debug ("%s: could not get assigned clock %d for %s\n" , __func__, index,dev_read_name (dev));
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 11/26 clk: fix set_rate to clean up cached rates for the hierarchy
In reply to Tero KristoClock rates are cached within the individual clock nodes, and right now if one changes a clock rate somewhere in the middle of the tree, none of its child clocks notice the change. To fix this, clear up all the cached rates for us and our child clocks.
--- drivers/clk/clk-uclass.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/clk/clk-uclass.c +19 -0
@@ -544,6 +544,22 @@ long long clk_get_parent_rate(struct clk *clk)return pclk->rate; } +static void clk_clean_rate_cache (struct clk *clk) +{ +struct udevice *child_dev; +struct clk *clkp; + +if (!clk) +return ; + + clk->rate =0 ; + +list_for_each_entry (child_dev, &clk->dev->child_head, sibling_node) { + clkp =dev_get_clk_ptr (child_dev); +clk_clean_rate_cache (clkp); + } +} +ulong clk_set_rate (struct clk *clk,ulong rate) {const struct clk_ops *ops;
@@ -556,6 +572,9 @@ ulong clk_set_rate(struct clk *clk, ulong rate)if (!ops->set_rate)return -ENOSYS ; +/* Clean up cached rates for us and all child clocks */ +clk_clean_rate_cache (clk); +return ops->set_rate (clk, rate); }
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 12/26 clk: add support for TI K3 SoC PLL
In reply to Tero KristoAdd support for TI K3 SoC PLLs. This clock type supports enabling/disabling/setting and querying the clock rate for the PLL. The euclidean library routine is used to calculate divider/multiplier rates for the PLLs.
--- drivers/clk/Kconfig | 12 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-k3-pll.c | 273 +++++++++++++++++++++++++++++++++++++++ include/k3-clk.h | 15 +++ 4 files changed, 301 insertions(+) create mode 100644 drivers/clk/clk-k3-pll.c create mode 100644 include/k3-clk.h
drivers/clk/Kconfig +12 -0
@@ -106,6 +106,18 @@ config CLK_TI_SCI available on some new TI's SoCs. If you wish to use clock resources managed by the TI System Controller, say Y here. Otherwise, say N. +config CLK_K3_PLL + bool "PLL clock support for K3 SoC family of devices" + depends on CLK && LIB_RATIONAL + help + Enables PLL clock support for K3 SoC family of devices. + +config SPL_CLK_K3_PLL + bool "PLL clock support for K3 SoC family of devices" + depends on CLK && LIB_RATIONAL && SPL + help + Enables PLL clock support for K3 SoC family of devices. + config CLK_HSDK bool "Enable cgu clock driver for HSDK boards" depends on CLK && TARGET_HSDK
drivers/clk/Makefile +1 -0
@@ -48,5 +48,6 @@ obj-$(CONFIG_SANDBOX) += clk_sandbox_test.o obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o obj-$(CONFIG_STM32H7) += clk_stm32h7.o obj-$(CONFIG_CLK_TI_SCI) += clk-ti-sci.o +obj-$(CONFIG_$(SPL_TPL_)CLK_K3_PLL) += clk-k3-pll.o obj-$(CONFIG_CLK_VERSAL) += clk_versal.o obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
drivers/clk/clk-k3-pll.c new file +273 -0
273 lines not on this page · raw message
include/k3-clk.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com +* Tero Kristo <[email protected]> +*/ + +#ifndef __K3_CLK_H__ +#define __K3_CLK_H__ + +#include <linux/clk-provider.h> + +struct clk *clk_register_ti_pll (const char *name,const char *parent_name, +void __iomem *reg); + +#endif /* __K3_CLK_H__ */
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 13/26 clk: add support for TI K3 SoC clocks
In reply to Tero KristoAdd driver to support TI K3 generation SoC clocks. This driver registers the clocks provided via platform data, and adds support for controlling the clocks via DT handles.
--- drivers/clk/Kconfig | 10 ++ drivers/clk/Makefile | 1 + drivers/clk/clk-k3.c | 340 +++++++++++++++++++++++++++++++++++++++++++ include/k3-clk.h | 162 +++++++++++++++++++++ 4 files changed, 513 insertions(+) create mode 100644 drivers/clk/clk-k3.c
drivers/clk/Kconfig +10 -0
@@ -106,6 +106,16 @@ config CLK_TI_SCI available on some new TI's SoCs. If you wish to use clock resources managed by the TI System Controller, say Y here. Otherwise, say N. +config CLK_K3 + bool "Clock support for K3 SoC family of devices" + depends on CLK + help + Enables the clock translation layer from DT to device clocks. + +config SPL_CLK_K3 + bool "Clock support for K3 SoC family of devices" + depends on CLK && SPL + config CLK_K3_PLL bool "PLL clock support for K3 SoC family of devices" depends on CLK && LIB_RATIONAL
drivers/clk/Makefile +1 -0
@@ -49,5 +49,6 @@ obj-$(CONFIG_SANDBOX_CLK_CCF) += clk_sandbox_ccf.o obj-$(CONFIG_STM32H7) += clk_stm32h7.o obj-$(CONFIG_CLK_TI_SCI) += clk-ti-sci.o obj-$(CONFIG_$(SPL_TPL_)CLK_K3_PLL) += clk-k3-pll.o +obj-$(CONFIG_$(SPL_TPL_)CLK_K3) += clk-k3.o obj-$(CONFIG_CLK_VERSAL) += clk_versal.o obj-$(CONFIG_CLK_CDCE9XX) += clk-cdce9xx.o
drivers/clk/clk-k3.c new file +340 -0
340 lines not on this page · raw message
include/k3-clk.h +162 -0
169 lines not on this page · raw message
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 14/26 power: domain: Introduce driver for raw TI K3 PDs
In reply to Tero KristoNormally, power domains are handled via TI-SCI in K3 SoCs. However, SPL is not going to have access to sysfw resources, so it must control them directly. Add driver for supporting this.
--- drivers/power/domain/Kconfig | 7 + drivers/power/domain/Makefile | 1 + drivers/power/domain/ti-power-domain.c | 377 +++++++++++++++++++++++++ include/k3-dev.h | 76 +++++ 4 files changed, 461 insertions(+) create mode 100644 drivers/power/domain/ti-power-domain.c create mode 100644 include/k3-dev.h
drivers/power/domain/Kconfig +7 -0
@@ -72,4 +72,11 @@ config TI_SCI_POWER_DOMAIN help Generic power domain implementation for TI devices implementing the TI SCI protocol. + +config TI_POWER_DOMAIN + bool "Enable the TI K3 Power domain driver" + depends on POWER_DOMAIN + help + Generic power domain implementation for TI K3 devices. + endmenu
drivers/power/domain/Makefile +1 -0
@@ -14,3 +14,4 @@ obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain-test.o obj-$(CONFIG_TEGRA186_POWER_DOMAIN) += tegra186-power-domain.o obj-$(CONFIG_TI_SCI_POWER_DOMAIN) += ti-sci-power-domain.o +obj-$(CONFIG_TI_POWER_DOMAIN) += ti-power-domain.o
drivers/power/domain/ti-power-domain.c new file +377 -0
377 lines not on this page · raw message
include/k3-dev.h new file +76 -0
76 lines not on this page · raw message
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 15/26 cmd: ti: pd: Add debug command for K3 power domains
In reply to Tero KristoAdd support command for debugging K3 power domains. This is useful with the HSM rearch setup, where power domains are directly controlled by SPL instead of going through the TI SCI layer. The debugging support is only available in the u-boot codebase though, so the raw register access power domain layer must be enabled on u-boot side for this to work. By default, u-boot side uses the TI SCI layer, and R5 SPL only uses the direct access methods.
--- cmd/ti/Kconfig | 8 ++ cmd/ti/Makefile | 1 + cmd/ti/pd.c | 185 +++++++++++++++++++++++++ drivers/power/domain/ti-power-domain.c | 6 +- include/k3-dev.h | 9 ++ 5 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 cmd/ti/pd.c
cmd/ti/Kconfig +8 -0
@@ -7,4 +7,12 @@ config CMD_DDR3 supports memory verification, memory comapre and ecc verification if supported. +config CMD_PD + bool "command for verifying power domains" + depends on TI_POWER_DOMAIN + help + Debug command for K3 power domains. For this to work, the + K3 power domain driver must be enabled for the u-boot; by + default it is only enabled for SPL. + endmenu
cmd/ti/Makefile +1 -0
@@ -5,4 +5,5 @@ obj- += dummy.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_CMD_DDR3) += ddr3.o +obj-$(CONFIG_CMD_PD) += pd.o endif
cmd/ti/pd.c new file +185 -0
185 lines not on this page · raw message
drivers/power/domain/ti-power-domain.c +3 -3
@@ -134,7 +134,7 @@ static void ti_pd_transition(struct ti_pd *pd)psc_write (BIT (pd->id), pd->psc,PSC_PTCMD ); } -static u8 ti_pd_state (struct ti_pd *pd) +u8 ti_pd_state (struct ti_pd *pd) {u32 pdctl;
@@ -233,7 +233,7 @@ static int ti_lpsc_wait(struct ti_lpsc *lpsc)return -ETIMEDOUT ; } -static u8 lpsc_get_state (struct ti_lpsc *lpsc) +u8 lpsc_get_state (struct ti_lpsc *lpsc) {u32 mdctl;
@@ -241,7 +241,7 @@ static u8 lpsc_get_state(struct ti_lpsc *lpsc)return mdctl &MDSTAT_STATE_MASK ; } -static int ti_lpsc_transition (struct ti_lpsc *lpsc,u8 state) +int ti_lpsc_transition (struct ti_lpsc *lpsc,u8 state) {struct ti_pd *psc_pd;int ret;
include/k3-dev.h +9 -0
@@ -22,6 +22,11 @@#define PSC_PD_ALWAYSON BIT(1)#define PSC_PD_DEPENDS BIT(2) +#define MDSTAT_STATE_MASK 0x3f +#define MDSTAT_BUSY_MASK 0x30 +#define MDSTAT_STATE_SWRSTDISABLE 0x0 +#define MDSTAT_STATE_ENABLE 0x3 +struct ti_psc {int id;void __iomem *base;
@@ -73,4 +78,8 @@ struct ti_k3_pd_platdata {extern const struct ti_k3_pd_platdata j721e_pd_platdata;extern const struct ti_k3_pd_platdata j7200_pd_platdata; +u8 ti_pd_state (struct ti_pd *pd); +u8 lpsc_get_state (struct ti_lpsc *lpsc); +int ti_lpsc_transition (struct ti_lpsc *lpsc,u8 state); +#endif
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 16/26 tools: k3_fit_atf: add DM binary to the FIT image
In reply to Tero KristoAdd DM (device manager) firmware image to the fit image that is loaded by R5 SPL. This is needed with the HSM rearch where the firmware allocation has been changed slightly.
--- arch/arm/mach-k3/config.mk | 4 ++++ tools/k3_fit_atf.sh | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-)
arch/arm/mach-k3/config.mk +4 -0
@@ -49,6 +49,10 @@ endif ifdef CONFIG_ARM64 +ifeq ($(CONFIG_SOC_K3_J721E),) +export DM := /dev/null +endif + ifeq ($(CONFIG_TI_SECURE_DEVICE),y) SPL_ITS := u-boot-spl-k3_HS.its $(SPL_ITS): export IS_HS=1
tools/k3_fit_atf.sh +18 -1
@@ -21,6 +21,13 @@ if [ ! -f $TEE ]; then TEE=/dev/null fi +[ -z "$DM" ] && DM="dm.bin" + +if [ ! -e $DM ]; then + echo "WARNING DM file $DM NOT found, resulting might be non-functional" >&2 + DM=/dev/null +fi + if [ ! -z "$IS_HS" ]; then HS_APPEND=_HS fi
@@ -53,6 +60,16 @@ cat << __HEADER_EOF load = <0x9e800000>; entry = <0x9e800000>; }; + dm { + description = "DM binary"; + data = /incbin/("$DM"); + type = "firmware"; + arch = "arm32"; + compression = "none"; + os = "DM"; + load = <0xa0000000>; + entry = <0xa0000000>; + }; spl { description = "SPL (64-bit)"; data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
@@ -91,7 +108,7 @@ do $(basename $dtname) { description = "$(basename $dtname .dtb)"; firmware = "atf"; - loadables = "tee", "spl"; + loadables = "tee", "dm", "spl"; fdt = "$(basename $dtname)"; }; __CONF_SECTION_EOF
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 17/26 arm: mach-k3: Add platform data for j721e and j7200
In reply to Tero KristoFrom: Dave Gerlach <[email protected]>
Add platform clock and powerdomain data for J721e and J7200. This data is used by the corresponding drivers to register all the required device clocks and powerdomains.
--- arch/arm/mach-k3/Makefile | 2 +- arch/arm/mach-k3/j7200/Makefile | 5 + arch/arm/mach-k3/j7200/clk-data.c | 232 ++++++++++++++++++++++++++ arch/arm/mach-k3/j7200/dev-data.c | 71 ++++++++ arch/arm/mach-k3/j721e/Makefile | 5 + arch/arm/mach-k3/j721e/clk-data.c | 259 ++++++++++++++++++++++++++++++ arch/arm/mach-k3/j721e/dev-data.c | 67 ++++++++ 7 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-k3/j7200/Makefile create mode 100644 arch/arm/mach-k3/j7200/clk-data.c create mode 100644 arch/arm/mach-k3/j7200/dev-data.c create mode 100644 arch/arm/mach-k3/j721e/Makefile create mode 100644 arch/arm/mach-k3/j721e/clk-data.c create mode 100644 arch/arm/mach-k3/j721e/dev-data.c
arch/arm/mach-k3/Makefile +1 -1
@@ -4,7 +4,7 @@ # Lokesh Vutla <[email protected]> obj-$(CONFIG_SOC_K3_AM6) += am6_init.o -obj-$(CONFIG_SOC_K3_J721E) += j721e_init.o +obj-$(CONFIG_SOC_K3_J721E) += j721e_init.o j721e/ j7200/ obj-$(CONFIG_ARM64) += arm64-mmu.o obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o obj-$(CONFIG_TI_SECURE_DEVICE) += security.o
arch/arm/mach-k3/j7200/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +obj-y += clk-data.o +obj-y += dev-data.o
arch/arm/mach-k3/j7200/clk-data.c new file +232 -0
232 lines not on this page · raw message
arch/arm/mach-k3/j7200/dev-data.c new file +71 -0
71 lines not on this page · raw message
arch/arm/mach-k3/j721e/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +obj-y += clk-data.o +obj-y += dev-data.o
arch/arm/mach-k3/j721e/clk-data.c new file +259 -0
259 lines not on this page · raw message
arch/arm/mach-k3/j721e/dev-data.c new file +67 -0
67 lines not on this page · raw message
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 18/26 arm: mach-k3: add support for detecting firmware images from FIT
In reply to Tero KristoAdd callback routines for parsing the firmware info from FIT image, and use the data to boot up ATF and the MCU R5 firmware.
--- arch/arm/mach-k3/common.c | 80 +++++++++++++++++++++++++++++++++---- arch/arm/mach-k3/common.h | 1 + arch/arm/mach-k3/security.c | 3 +- 3 files changed, 75 insertions(+), 9 deletions(-)
arch/arm/mach-k3/common.c +73 -7
@@ -27,6 +27,27 @@#include <elf.h> #include <soc.h> +#ifdef CONFIG_SYS_K3_SPL_ATF +enum { +IMAGE_ID_ATF , +IMAGE_ID_OPTEE , +IMAGE_ID_SPL , +IMAGE_ID_DM_FW , +IMAGE_AMT , +}; + +#ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS +static const char *image_os_match[IMAGE_AMT ] = { +"arm-trusted-firmware" , +"tee" , +"U-Boot" , +"DM" , +}; +#endif + +static struct image_info fit_image_info[IMAGE_AMT ]; +#endif +struct ti_sci_handle *get_ti_sci_handle (void ) {struct udevice *dev;
@@ -180,7 +201,7 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)typedef void __noreturn (*image_entry_noargs_t )(void );struct ti_sci_handle *ti_sci =get_ti_sci_handle ();u32 loadaddr =0 ; -int ret, size; +int ret, size =0 ;/* Release all the exclusive devices held by SPL before starting ATF */ ti_sci->ops.dev_ops.release_exclusive_devices (ti_sci);
@@ -191,15 +212,20 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)init_env ();start_non_linux_remote_cores (); - size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , - &loadaddr); +if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) + size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , + &loadaddr);/* * It is assumed that remoteproc device 1 is the corresponding * Cortex-A core which runs ATF. Make sure DT reflects the same. */ - ret =rproc_load (1 , spl_image->entry_point,0x200 ); +if (!fit_image_info[IMAGE_ID_ATF ].image_start) + fit_image_info[IMAGE_ID_ATF ].image_start = + spl_image->entry_point; + + ret =rproc_load (1 , fit_image_info[IMAGE_ID_ATF ].image_start,0x200 );if (ret)panic ("%s: ATF failed to load on rproc (%d)\n" , __func__, ret);
@@ -209,7 +235,8 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) ret =rproc_start (1 );if (ret)panic ("%s: ATF failed to start on rproc (%d)\n" , __func__, ret); -if (!(size >0 &&valid_elf_image (loadaddr))) { +if (!fit_image_info[IMAGE_ID_DM_FW ].image_len && + !(size >0 &&valid_elf_image (loadaddr))) {debug ("Shutting down...\n" );release_resources_for_core_shutdown ();
@@ -217,13 +244,52 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) asm volatile("wfe"); } -image_entry_noargs_t image_entry = - (image_entry_noargs_t )load_elf_image_phdr (loadaddr); +if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) { + loadaddr =load_elf_image_phdr (loadaddr); + }else { + loadaddr = fit_image_info[IMAGE_ID_DM_FW ].image_start; +if (valid_elf_image (loadaddr)) + loadaddr =load_elf_image_phdr (loadaddr); + } + +debug ("%s: jumping to address %x\n" , __func__, loadaddr); + +image_entry_noargs_t image_entry = (image_entry_noargs_t )loadaddr;image_entry (); }#endif +#ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size) +{ +int len; +int i; +const char *os; +u32 addr; + + os =fdt_getprop (fit, node,"os" , &len); + addr =fdt_getprop_u32_default_node (fit, node,0 ,"entry" ,-1 ); + +debug ("%s: processing image: addr=%x, size=%d, os=%s\n" , __func__, + addr, *p_size, os); + +for (i =0 ; i <IMAGE_AMT ; i++) { +if (!strcmp (os, image_os_match[i])) { + fit_image_info[i].image_start = addr; + fit_image_info[i].image_len = *p_size; +debug ("%s: matched image for ID %d\n" , __func__, i); +break ; + } + } + +#ifdef CONFIG_TI_SECURE_DEVICE +ti_secure_image_post_process (p_image, p_size); +#endif +} +#endif +#if defined(CONFIG_OF_LIBFDT )int fdt_fixup_msmc_ram (void *blob,char *parent_path,char *node_name) {
arch/arm/mach-k3/common.h +1 -0
@@ -28,3 +28,4 @@ void k3_sysfw_print_ver(void);void spl_enable_dcache (void );void mmr_unlock (phys_addr_t base,u32 partition);bool is_rom_loaded_sysfw (struct rom_extended_boot_data *data); +void ti_secure_image_post_process (void **p_image,size_t *p_size);
arch/arm/mach-k3/security.c +1 -2
@@ -18,8 +18,7 @@#include <spl.h> #include <asm/arch/sys_proto.h> -void board_fit_image_post_process (const void *fit,int node,void **p_image, -size_t *p_size) +void ti_secure_image_post_process (void **p_image,size_t *p_size) {struct ti_sci_handle *ti_sci =get_ti_sci_handle ();struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops;
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 19/26 arm: mach-k3: j721e: force enable A72 core 0 during spl shutdown
In reply to Tero KristoWith the new raw register mode access PM drivers, A72 core is not enabled via ti-sci services, leading into bad usecounts for the core. This effectively shuts down the A72 core when SPL goes down. Prevent the problem by force enabling the A72 core once, which increases the use count.
--- arch/arm/mach-k3/j721e_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/mach-k3/j721e_init.c +14 -0
@@ -306,6 +306,7 @@ u32 spl_boot_device(void)#ifdef CONFIG_SYS_K3_SPL_ATF +#define J721E_DEV_A72SS0_CORE0 202#define J721E_DEV_MCU_RTI0 262#define J721E_DEV_MCU_RTI1 263#define J721E_DEV_MCU_ARMSS0_CPU0 250
@@ -324,10 +325,23 @@ void release_resources_for_core_shutdown(void) J721E_DEV_MCU_RTI1, }; +const u32 get_device_ids[] = { +J721E_DEV_A72SS0_CORE0 + }; + ti_sci =get_ti_sci_handle (); dev_ops = &ti_sci->ops.dev_ops; proc_ops = &ti_sci->ops.proc_ops; +/* Iterate through list of devices to get (enable) */ +for (i =0 ; i <ARRAY_SIZE (get_device_ids); i++) { +u32 id = get_device_ids[i]; + + ret = dev_ops->get_device (ti_sci, id); +if (ret) +panic ("Failed to get device %u (%d)\n" , id, ret); + } +/* Iterate through list of devices to put (shutdown) */ for (i =0 ; i <ARRAY_SIZE (put_device_ids); i++) {u32 id = put_device_ids[i];
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 19/26 arm: mach-k3: j721e: force enable A72 core 0 during spl shutdown
Quoted 3 lines · Tero Kristo
With the new raw register mode access PM drivers, A72 core is not enabled via ti-sci services, leading into bad usecounts for the core. This effectively shuts down the A72 core when SPL goes down. Prevent the
When you meant SPL that is R5 going down correct?. But in this case R5 can never go down no? I am still trying to understand what happens if this patch is not applied.
Is it that R5 gets reset before jumping to DM firmware? Also at this point DM services are not available no? who services this get_device request?
Thanks and regards,
Lokesh
Quoted 45 lines
problem by force enabling the A72 core once, which increases the use count.
Signed-off-by Tero Kristo <[email protected]>--- arch/arm/mach-k3/j721e_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/arm/mach-k3/j721e_init.c +14
-0@@ -306,6 +306,7 @@ u32 spl_boot_device(void)#ifdef CONFIG_SYS_K3_SPL_ATF +#define J721E_DEV_A72SS0_CORE0 202#define J721E_DEV_MCU_RTI0 262#define J721E_DEV_MCU_RTI1 263#define J721E_DEV_MCU_ARMSS0_CPU0 250@@ -324,10 +325,23 @@ void release_resources_for_core_shutdown(void) J721E_DEV_MCU_RTI1, }; +const u32 get_device_ids[] = { +J721E_DEV_A72SS0_CORE0 + }; + ti_sci =get_ti_sci_handle (); dev_ops = &ti_sci->ops.dev_ops; proc_ops = &ti_sci->ops.proc_ops; +/* Iterate through list of devices to get (enable) */ +for (i =0 ; i <ARRAY_SIZE (get_device_ids); i++) { +u32 id = get_device_ids[i]; + + ret = dev_ops->get_device (ti_sci, id); +if (ret) +panic ("Failed to get device %u (%d)\n" , id, ret); + } +/* Iterate through list of devices to put (shutdown) */ for (i =0 ; i <ARRAY_SIZE (put_device_ids); i++) {u32 id = put_device_ids[i];
PATCH 19/26 arm: mach-k3: j721e: force enable A72 core 0 during spl shutdown
Quoted 7 lines · Lokesh Vutla
Quoted 3 lines · Tero Kristo
With the new raw register mode access PM drivers, A72 core is not enabled via ti-sci services, leading into bad usecounts for the core. This effectively shuts down the A72 core when SPL goes down. Prevent the
Quoted 6 lines
When you meant SPL that is R5 going down correct?. But in this case R5 can never go down no? I am still trying to understand what happens if this patch is not applied.
Is it that R5 gets reset before jumping to DM firmware? Also at this point DM services are not available no? who services this
get_devicerequest?
This does not touch R5 as you see from the code, the device ID touched is A72SS0. Basically what happens is that A72 is booted directly by R5 SPL, but once u-boot shutdown services kick in, they terminate A72 power-domain because it is no longer used by any of the device drivers. Sysfw usecount is increased by A72 ATF, which keeps the core enabled in pure sysfw case, but our R5 SPL drivers do not have this info so they terminate it forcibly.
However, this might not be needed at all in the latest version of the code, as we always start a firmware image on MCU R5 and the release_resources_for_core_shutdown never gets called. Let me retry this once I re-spin this series.
-Tero
Quoted 36 lines
Thanks and regards,
LokeshQuoted 32 lines
problem by force enabling the A72 core once, which increases the use count.
Signed-off-by Tero Kristo <[email protected]>--- arch/arm/mach-k3/j721e_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/arm/mach-k3/j721e_init.c +5
-0@@ -306,6 +306,7 @@ u32 spl_boot_device(void)#ifdef CONFIG_SYS_K3_SPL_ATF +#define J721E_DEV_A72SS0_CORE0 202#define J721E_DEV_MCU_RTI0 262#define J721E_DEV_MCU_RTI1 263#define J721E_DEV_MCU_ARMSS0_CPU0 250@@ -324,10 +325,23 @@ void release_resources_for_core_shutdown(void) J721E_DEV_MCU_RTI1, }; +const u32 get_device_ids[] = { +J721E_DEV_A72SS0_CORE0 + }; + ti_sci =get_ti_sci_handle (); dev_ops = &ti_sci->ops.dev_ops; proc_ops = &ti_sci->ops.proc_ops;
Quoted 13 lines
arch/arm/mach-k3/j721e_init.c void release_resources_for_core_shutdown(void) · line 347
Quoted 13 lines
arch/arm/mach-k3/j721e_init.c +9
-0+/* Iterate through list of devices to get (enable) */ +for (i =0 ; i <ARRAY_SIZE (get_device_ids); i++) { +u32 id = get_device_ids[i]; + + ret = dev_ops->get_device (ti_sci, id); +if (ret) +panic ("Failed to get device %u (%d)\n" , id, ret); + } +/* Iterate through list of devices to put (shutdown) */ for (i =0 ; i <ARRAY_SIZE (put_device_ids); i++) {u32 id = put_device_ids[i];
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
In reply to Tero KristoIf the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this case, skip the board config for these two.
--- arch/arm/mach-k3/sysfw-loader.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +4 -0
@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef CONFIG_CLK_TI_SCI ret = board_ops->board_config_pm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board PM configuration (%d)\n" , ret); +#endif /* Extract resource management (RM) specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_RM,
@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifdef CONFIG_CLK_TI_SCI /* Apply resource management (RM) configuration to SYSFW */ ret = board_ops->board_config_rm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board RM configuration (%d)\n" , ret); +#endif /* Extract security specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_SEC,
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 14 lines · Tero Kristo
If the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this case, skip the board config for these two.
Signed-off-by Tero Kristo <[email protected]>--- arch/arm/mach-k3/sysfw-loader.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/mach-k3/sysfw-loader.c +0
-0
arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 161
Quoted 4 lines
arch/arm/mach-k3/sysfw-loader.c +1
-0@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef CONFIG_CLK_TI_SCI
IMHO, using CONFIG_CLK_TI_SCI is hack here. Can we showhow derive this information based on the images loaded in FIT?
Thanks and regards,
Lokesh
Quoted 25 lines
arch/arm/mach-k3/sysfw-loader.c +3
-0ret = board_ops->board_config_pm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board PM configuration (%d)\n" , ret); +#endif /* Extract resource management (RM) specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_RM,@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifdef CONFIG_CLK_TI_SCI /* Apply resource management (RM) configuration to SYSFW */ ret = board_ops->board_config_rm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board RM configuration (%d)\n" , ret); +#endif /* Extract security specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_SEC,
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 19 lines · Lokesh Vutla
Quoted 16 lines · Tero Kristo
If the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this case, skip the board config for these two.
Signed-off-by Tero Kristo <[email protected]>--- arch/arm/mach-k3/sysfw-loader.c | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/mach-k3/sysfw-loader.c +0
-0@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);
Quoted 5 lines
arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 161
Quoted 2 lines
arch/arm/mach-k3/sysfw-loader.c +1
-0/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef CONFIG_CLK_TI_SCI IMHO, using
CONFIG_CLK_TI_SCIis hack here. Can we showhow derive this information based on the images loaded in FIT?
At this point we have only loaded the sysfw image. DM image against which we could check this will only be loaded during A72 SPL FIT loading process, and it will only happen later.
-Tero
Quoted 26 lines
Thanks and regards,
LokeshQuoted 22 lines
arch/arm/mach-k3/sysfw-loader.c +3
-0ret = board_ops->board_config_pm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board PM configuration (%d)\n" , ret); +#endif /* Extract resource management (RM) specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_RM,@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifdef CONFIG_CLK_TI_SCI /* Apply resource management (RM) configuration to SYSFW */ ret = board_ops->board_config_rm (ti_sci, (u64 )(u32 )cfg_fragment_addr, (u32 )cfg_fragment_size);if (ret)panic ("Failed to set board RM configuration (%d)\n" , ret); +#endif
Quoted 3 lines
arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 186
Quoted 3 lines
arch/arm/mach-k3/sysfw-loader.c +0
-0/* Extract security specific configuration from FIT */ ret = fit_get_data_by_name(fit, images, SYSFW_CFG_SEC,
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 25 lines · Tero Kristo
Quoted 12 lines · Lokesh Vutla
Quoted 9 lines · Tero Kristo
If the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this case, skip the board config for these two.
Signed-off-by Tero Kristo <[email protected]>---
?arch/arm/mach-k3/sysfw-loader.c| 4 ++++
? 1 file changed, 4 insertions(+)Quoted 11 lines
Quoted 8 lines
arch/arm/mach-k3/sysfw-loader.c +0
-0@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ??????????????? ret);? ????? /* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef
CONFIG_CLK_TI_SCIIMHO, using
CONFIG_CLK_TI_SCIis hack here. Can we showhow derive this information based on the images loaded in FIT?
Quoted 1 line
At this point we have only loaded the sysfw image. DM image against which we
This sysfw.itb contains all the board configurations?
If yes, then we are adding board configurations in sysfw.itb that does not belong here.
If no, then can we check for the entries before loading?
Thanks and regards,
Lokesh
Quoted 35 lines
could check this will only be loaded during A72 SPL FIT loading process, and it will only happen later.
-Tero
Quoted 26 lines
Thanks and regards,
LokeshQuoted 22 lines
????? ret = board_ops->board_config_pm(ti_sci, ?????????????????????? (u64)(u32)cfg_fragment_addr, ?????????????????????? (u32)cfg_fragment_size);
????? if (ret)
?????????panic("Failed to set board PM configuration (%d)\n", ret); +#endif
? ????? /* Extract resource management (RM) specific configuration from FIT */ ????? ret = fit_get_data_by_name(fit, images,SYSFW_CFG_RM,arch/arm/mach-k3/sysfw-loader.c +0
-0@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit, ????????? panic("Error accessing %s node in FIT (%d)\n", SYSFW_CFG_RM, ??????????????? ret);? +#ifdef
CONFIG_CLK_TI_SCI
????? /* Apply resource management (RM) configuration to SYSFW */ ????? ret = board_ops->board_config_rm(ti_sci, ?????????????????????? (u64)(u32)cfg_fragment_addr, ?????????????????????? (u32)cfg_fragment_size);
????? if (ret)
?????????panic("Failed to set board RM configuration (%d)\n", ret); +#endif
? ????? /* Extract security specific configuration from FIT */ ????? ret = fit_get_data_by_name(fit, images,SYSFW_CFG_SEC,Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 28 lines · Lokesh Vutla
Quoted 25 lines · Tero Kristo
Quoted 23 lines · Lokesh Vutla
Quoted 14 lines · Tero Kristo
If the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this case, skip the board config for these two.
Signed-off-by Tero Kristo <[email protected]>--- ? arch/arm/mach-k3/sysfw-loader.c | 4 ++++? 1 file changed, 4 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +0
-0arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 160
Quoted 3 lines
arch/arm/mach-k3/sysfw-loader.c +1
-0@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ??????????????? ret); ? ????? /* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef CONFIG_CLK_TI_SCI IMHO, using
CONFIG_CLK_TI_SCIis hack here. Can we showhow derive this information based on the images loaded in FIT?
Quoted 7 lines
Quoted 1 line
At this point we have only loaded the sysfw image. DM image against which we
This sysfw.itb contains all the board configurations?
If yes, then we are adding board configurations in sysfw.itb that does not belong here.If no, then can we check for the entries before loading?
Technically feasible yes, let me check with Dave offline what we can craft for this (the image generation part was done by him); the firmware image generator does something along these lines already, basically splitting the cfg portions to different images.
-Tero
Quoted 37 lines
Thanks and regards,
LokeshQuoted 33 lines
could check this will only be loaded during A72 SPL FIT loading process, and it will only happen later.
-Tero
Quoted 26 lines
Thanks and regards,
LokeshQuoted 22 lines
arch/arm/mach-k3/sysfw-loader.c +2
-0????? ret = board_ops->board_config_pm(ti_sci, ?????????????????????? (u64)(u32)cfg_fragment_addr, ?????????????????????? (u32)cfg_fragment_size); ????? if (ret) ????????? panic("Failed to set board PM configuration (%d)\n", ret); +#endif ? ????? /* Extract resource management (RM) specific configuration from FIT */ ????? ret = fit_get_data_by_name(fit, images, SYSFW_CFG_RM,@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit, ????????? panic("Error accessing %s node in FIT (%d)\n", SYSFW_CFG_RM, ??????????????? ret); ? +#ifdef CONFIG_CLK_TI_SCI ????? /* Apply resource management (RM) configuration to SYSFW */ ????? ret = board_ops->board_config_rm(ti_sci, ?????????????????????? (u64)(u32)cfg_fragment_addr, ?????????????????????? (u32)cfg_fragment_size); ????? if (ret) ????????? panic("Failed to set board RM configuration (%d)\n", ret); +#endif ? ????? /* Extract security specific configuration from FIT */ ????? ret = fit_get_data_by_name(fit, images, SYSFW_CFG_SEC,
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 20/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 40 lines · Tero Kristo
Quoted 39 lines · Lokesh Vutla
Quoted 28 lines · Tero Kristo
Quoted 13 lines · Lokesh Vutla
Quoted 10 lines · Tero Kristo
If the raw PM support is built in, we are operating in the split firmware approach mode where RM and PM support is not available. In this
case, skip the board config for these two.Signed-off-by Tero Kristo <[email protected]>---
??arch/arm/mach-k3/sysfw-loader.c| 4 ++++
?? 1 file changed, 4 insertions(+)Quoted 13 lines
Quoted 10 lines
arch/arm/mach-k3/sysfw-loader.c +0
-0@@ -158,11 +158,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ???????????????? ret);?? ????? /* Apply power/clock (PM) specific configuration to SYSFW */ +#ifdef
CONFIG_CLK_TI_SCIIMHO, using
CONFIG_CLK_TI_SCIis hack here. Can we showhow derive this information based on the images loaded in FIT?Quoted 2 lines
At this point we have only loaded the sysfw image. DM image against which we
This sysfw.itb contains all the board configurations?
If yes, then we are adding board configurations in sysfw.itb that does not
belong here.
Quoted 6 lines
Quoted 1 line
If no, then can we check for the entries before loading?
Technically feasible yes, let me check with Dave offline what we can craft for this (the image generation part was done by him); the firmware image generator does something along these lines already, basically splitting the cfg portions to different images.
Ok, after some offline discussions, we ended up with a solution that for the sysfw_loader portion at least we have to use a config option, as otherwise the build process becomes completely broken with multiple cross dependencies towards/between external build tools etc... To make things a bit more clear though, I'll add a new config option called CONFIG_TI_DM_FW, which would indicate that we are using a separate DM firmware image in the system. This avoids overloading the CONFIG_CLK_TI_SCI or something else, even if these two effectively follow each other in their value.
I'll re-work the relevant patches around this and re-post.
-Tero
Quoted 45 lines
-Tero
Quoted 41 lines
Thanks and regards,
LokeshQuoted 37 lines
could check this will only be loaded during A72 SPL FIT loading process, and it
will only happen later.-Tero
Quoted 29 lines
Thanks and regards,
LokeshQuoted 25 lines
?????? ret = board_ops->board_config_pm(ti_sci, ??????????????????????? (u64)(u32)cfg_fragment_addr, ??????????????????????? (u32)cfg_fragment_size);
?????? if (ret)
??????????panic("Failed to set board PM configuration (%d)\n", ret); +#endif
?? ????? /* Extract resource management (RM) specific configuration from FIT */
?????? ret = fit_get_data_by_name(fit, images,SYSFW_CFG_RM,arch/arm/mach-k3/sysfw-loader.c +0
-0@@ -171,12 +173,14 @@ static void k3_sysfw_configure_using_fit(void *fit, ?????????? panic("Error accessing %s node in FIT (%d)\n",SYSFW_CFG_RM , ???????????????? ret);?? +#ifdef
CONFIG_CLK_TI_SCI
?????? /* Apply resource management (RM) configuration to SYSFW */ ?????? ret = board_ops->board_config_rm(ti_sci, ??????????????????????? (u64)(u32)cfg_fragment_addr, ??????????????????????? (u32)cfg_fragment_size);
?????? if (ret)
??????????panic("Failed to set board RM configuration (%d)\n", ret); +#endif
?? ????? /* Extract security specific configuration from FIT */ ?????? ret = fit_get_data_by_name(fit, images,SYSFW_CFG_SEC,
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 21/26 arm: mach-k3: common: Drop main r5 start
In reply to Tero KristoFrom: Dave Gerlach <[email protected]>
Only start-up the non-linux remote cores if we are running in legacy boot mode. HSM rearch is not yet supporting this.
--- arch/arm/mach-k3/common.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-k3/common.c +2 -0
@@ -211,7 +211,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)panic ("rproc failed to be initialized (%d)\n" , ret);init_env (); +#ifdef CONFIG_CLK_TI_SCI start_non_linux_remote_cores (); +#endif if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , &loadaddr);
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 21/26 arm: mach-k3: common: Drop main r5 start
Quoted 15 lines · Tero Kristo
From: Dave Gerlach <[email protected]>
Only start-up the non-linux remote cores if we are running in legacy boot mode. HSM rearch is not yet supporting this.
Signed-off-by Dave Gerlach <[email protected]>--- arch/arm/mach-k3/common.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-k3/common.c +0
-0
arch/arm/mach-k3/common.c void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) · line 214
Quoted 4 lines
arch/arm/mach-k3/common.c +1
-0@@ -211,7 +211,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)panic ("rproc failed to be initialized (%d)\n" , ret);init_env (); +#ifdef CONFIG_CLK_TI_SCI
Again. This config ussage is a hack. Can we get a better way to do these things?
Thanks and regards,
Lokesh
Quoted 6 lines
arch/arm/mach-k3/common.c +1
-0start_non_linux_remote_cores (); +#endif if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , &loadaddr);
PATCH 21/26 arm: mach-k3: common: Drop main r5 start
Quoted 7 lines · Lokesh Vutla
Quoted 4 lines · Tero Kristo
From: Dave Gerlach <[email protected]>
Only start-up the non-linux remote cores if we are running in legacy boot mode. HSM rearch is not yet supporting this.
This one, we can check against DM_FW image presence as it has been loaded already.
-Tero
Quoted 13 lines
Quoted 13 lines
Signed-off-by Dave Gerlach <[email protected]>--- arch/arm/mach-k3/common.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-k3/common.c +0
-0@@ -211,7 +211,9 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)panic ("rproc failed to be initialized (%d)\n" , ret);
Quoted 14 lines
arch/arm/mach-k3/common.c void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) · line 214
Quoted 2 lines
arch/arm/mach-k3/common.c +1
-0init_env (); +#ifdef CONFIG_CLK_TI_SCI Again. This config ussage is a hack. Can we get a better way to do these things?
Thanks and regards,
LokeshQuoted 6 lines
arch/arm/mach-k3/common.c +1
-0start_non_linux_remote_cores (); +#endif if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , &loadaddr);
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 22/26 arm: mach-k3: sysfw-loader: pass boardcfg to sciserver
In reply to Tero KristoCopy the contents of the board config loaded from sysfw.itb into an EXTBOOT shared memory buffer that gets passed to sciserver. This only needs to be done if EXTBOOT area has not been populated by ROM code yet.
--- arch/arm/mach-k3/sysfw-loader.c | 98 +++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +98 -0
@@ -39,6 +39,43 @@ DECLARE_GLOBAL_DATA_PTR;*/ #define K3_SYSTEM_CONTROLLER_RPROC_ID 0 +#define BOARDCFG_ADDRESS 0x41c80000 + +#define COMP_TYPE_SBL_DATA 0x11 +#define DESC_TYPE_BOARDCFG_PM_INDEX 0x2 +#define DESC_TYPE_BOARDCFG_RM_INDEX 0x3 + +#define BOARD_CONFIG_RM_DESC_TYPE 0x000c +#define BOARD_CONFIG_PM_DESC_TYPE 0x000e + +struct extboot_comp { +u32 comp_type; +u32 boot_core; +u32 comp_opts; +u64 dest_addr; +u32 comp_size; +} __packed; + +struct extboot_header { +u8 magic[8 ]; +u32 num_comps; +struct extboot_comp comps[5 ]; +} __packed; + +struct bcfg_desc { +u16 type; +u16 offset; +u16 size; +u8 devgrp; +u8 reserved; +} __packed; + +struct bcfg_header { +u8 num_elems; +u8 sw_rev; +struct bcfg_desc descs[4 ]; +} __packed; +static bool sysfw_loaded;static void *sysfw_load_address;
@@ -130,6 +167,15 @@ static void k3_sysfw_configure_using_fit(void *fit,const void *cfg_fragment_addr;size_t cfg_fragment_size;int ret; +#ifndef CONFIG_CLK_TI_SCI +u8 *buf; +struct extboot_header *common_header; +struct bcfg_header *bcfg_header; +struct extboot_comp *comp; +struct bcfg_desc *desc; +u32 addr; +bool copy_bcfg = false; +#endif /* Find the node holding the images information */ images =fdt_path_offset (fit,FIT_IMAGES_PATH );
@@ -164,6 +210,46 @@ static void k3_sysfw_configure_using_fit(void *fit, (u32)cfg_fragment_size);if (ret)panic ("Failed to set board PM configuration (%d)\n" , ret); +#else +/* Initialize shared memory boardconfig buffer */ + buf = (u8 *)BOARDCFG_ADDRESS ; + common_header = (struct extboot_header *)buf; + +/* Check if we have a struct populated by ROM in memory already */ +if (strcmp ((char *)common_header->magic,"EXTBOOT" )) + copy_bcfg = true; + +if (copy_bcfg) { +strcpy ((char *)common_header->magic,"EXTBOOT" ); + common_header->num_comps =1 ; + + comp = &common_header->comps[0 ]; + + comp->comp_type =COMP_TYPE_SBL_DATA ; + comp->boot_core =0x10 ; + comp->comp_opts =0 ; + addr = (u32 )buf +sizeof (*common_header); + comp->dest_addr = addr; + comp->comp_size =sizeof (*bcfg_header); + + bcfg_header = (struct bcfg_header *)addr; + + bcfg_header->num_elems =2 ; + bcfg_header->sw_rev =0 ; + + desc = &bcfg_header->descs[0 ]; + + desc->type =BOARD_CONFIG_PM_DESC_TYPE ; + desc->offset =sizeof (*bcfg_header); + desc->size = cfg_fragment_size; + comp->comp_size += desc->size; + desc->devgrp =0 ; + desc->reserved =0 ; +memcpy ((u8 *)bcfg_header + desc->offset, cfg_fragment_addr, + cfg_fragment_size); + + bcfg_header->descs[1 ].offset = desc->offset + desc->size; + }#endif /* Extract resource management (RM) specific configuration from FIT */
@@ -180,6 +266,18 @@ static void k3_sysfw_configure_using_fit(void *fit, (u32)cfg_fragment_size);if (ret)panic ("Failed to set board RM configuration (%d)\n" , ret); +#else +if (copy_bcfg) { + desc = &bcfg_header->descs[1 ]; + + desc->type =BOARD_CONFIG_RM_DESC_TYPE ; + desc->size = cfg_fragment_size; + comp->comp_size += desc->size; + desc->devgrp =0 ; + desc->reserved =0 ; +memcpy ((u8 *)bcfg_header + desc->offset, cfg_fragment_addr, + cfg_fragment_size); + }#endif /* Extract security specific configuration from FIT */
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 23/26 configs: j721e_evm_r5: Enable raw access power management features
In reply to Tero KristoSysfw is not going to provide access to power management features in the new architecture, so SPL must implement these itself. Enable all the raw register access based clock + power domain drivers.
--- configs/j721e_evm_r5_defconfig | 6 ++++++ 1 file changed, 6 insertions(+)
configs/j721e_evm_r5_defconfig +6 -0
@@ -140,3 +140,9 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6163 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_FS_EXT4=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_TI_POWER_DOMAIN=y +CONFIG_SPL_CLK_CCF=y +CONFIG_LIB_RATIONAL=y +CONFIG_SPL_LIB_RATIONAL=y +CONFIG_SPL_CLK_K3_PLL=y +CONFIG_SPL_CLK_K3=y
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 24/26 configs: j721e_evm_r5: disable SCI PM drivers
In reply to Tero KristoWith the sysfw rearch, PM services are no longer available for R5 SPL to use. Instead, we will be using the raw PM register level access drivers for any PM. Thus, disable the SCI PM drivers to reflect this.
--- configs/j721e_evm_r5_defconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
configs/j721e_evm_r5_defconfig +2 -2
@@ -72,7 +72,7 @@ CONFIG_SPL_REGMAP=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_CLK_TI_SCI=y +# CONFIG_CLK_TI_SCI is not set CONFIG_DMA_CHANNELS=y CONFIG_TI_K3_NAVSS_UDMA=y CONFIG_TI_SCI_PROTOCOL=y
@@ -102,7 +102,7 @@ CONFIG_SPL_PINCTRL=y # CONFIG_SPL_PINCTRL_GENERIC is not set CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y -CONFIG_TI_SCI_POWER_DOMAIN=y +# CONFIG_TI_SCI_POWER_DOMAIN is not set CONFIG_DM_PMIC=y CONFIG_PMIC_TPS65941=y CONFIG_DM_REGULATOR=y
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 25/26 configs: j721e_evm_r5: enable FIT image post processing
In reply to Tero KristoThis is used to parse the images from FIT, and to determine image types.
--- configs/j721e_evm_r5_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/j721e_evm_r5_defconfig +1 -0
@@ -146,3 +146,4 @@ CONFIG_LIB_RATIONAL=y CONFIG_SPL_LIB_RATIONAL=y CONFIG_SPL_CLK_K3_PLL=y CONFIG_SPL_CLK_K3=y +CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 26/26 configs: j7200_evm_r5: Enable raw access power management features
In reply to Tero KristoFrom: Dave Gerlach <[email protected]>
Sysfw is not going to provide access to power management features in the new architecture, so SPL must implement these itself. Enable all the raw register access based clock + power domain drivers.
--- configs/j7200_evm_r5_defconfig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
configs/j7200_evm_r5_defconfig +11 -2
@@ -75,7 +75,7 @@ CONFIG_SPL_SYSCON=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_CLK=y CONFIG_SPL_CLK=y -CONFIG_CLK_TI_SCI=y +# CONFIG_CLK_TI_SCI is not set CONFIG_DMA_CHANNELS=y CONFIG_TI_K3_NAVSS_UDMA=y CONFIG_TI_SCI_PROTOCOL=y
@@ -110,7 +110,7 @@ CONFIG_SPL_PINCTRL=y # CONFIG_SPL_PINCTRL_GENERIC is not set CONFIG_PINCTRL_SINGLE=y CONFIG_POWER_DOMAIN=y -CONFIG_TI_SCI_POWER_DOMAIN=y +# CONFIG_TI_SCI_POWER_DOMAIN is not set CONFIG_K3_SYSTEM_CONTROLLER=y CONFIG_REMOTEPROC_TI_K3_ARM64=y CONFIG_DM_RESET=y
@@ -142,3 +142,12 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x6164 CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_FS_EXT4=y CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 +CONFIG_SOC_DEVICE=y +CONFIG_SOC_DEVICE_TI_K3=y +CONFIG_TI_POWER_DOMAIN=y +CONFIG_SPL_CLK_CCF=y +CONFIG_LIB_RATIONAL=y +CONFIG_SPL_LIB_RATIONAL=y +CONFIG_SPL_CLK_K3_PLL=y +CONFIG_SPL_CLK_K3=y +CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
Signature · 4 lines
2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
cover TI J7 SoC HSM Rearch support series
In reply to Tero KristoQuoted 11 lines · Tero Kristo
Hello,
On TI J7 SoCs the device manager firmware is now split into two portions instead of the existing one which supported all services via a single firmware image running on DMSC core. Now, the existing DMSC core is dedicated for secure services only, and the PM and RM functionality is moved under a separate firmware image running on MCU R5 core. This is completely transparent for the firmware users, as the existing messaging mechanism (TI-SCI) routes everything to proper destination, except for anything that runs on MCU R5, and in our case it happens to be R5 SPL bootloader.
Can you update board/ti/j721e/README with the detail of the boot flow and build steps?
Thanks and regards,
Lokesh
cover TI J7 SoC HSM Rearch support series
Quoted 15 lines · Lokesh Vutla
Quoted 11 lines · Tero Kristo
Hello,
On TI J7 SoCs the device manager firmware is now split into two portions instead of the existing one which supported all services via a single firmware image running on DMSC core. Now, the existing DMSC core is dedicated for secure services only, and the PM and RM functionality is moved under a separate firmware image running on MCU R5 core. This is completely transparent for the firmware users, as the existing messaging mechanism (TI-SCI) routes everything to proper destination, except for anything that runs on MCU R5, and in our case it happens to be R5 SPL bootloader.
Quoted 2 lines
Can you update board/ti/j721e/README with the detail of the boot flow and build steps?
Sure, I can craft additional patch for that purpose. Its good that j7 has its separate doc actually, so am65x can stay in its current form.
-Tero
Quoted 4 lines
Thanks and regards,
Lokesh
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
cover TI J7 SoC HSM Rearch support series
Quoted 16 lines · Tero Kristo
Quoted 15 lines · Lokesh Vutla
Quoted 11 lines · Tero Kristo
Hello,
On TI J7 SoCs the device manager firmware is now split into two portions instead of the existing one which supported all services via a single firmware image running on DMSC core. Now, the existing DMSC core is dedicated for secure services only, and the PM and RM functionality is moved under a separate firmware image running on MCU R5 core. This is completely transparent for the firmware users, as the existing messaging mechanism (TI-SCI) routes everything to proper destination, except for anything that runs on MCU R5, and in our case it happens to be R5 SPL bootloader.
Quoted 5 lines
Quoted 2 lines
Can you update board/ti/j721e/README with the detail of the boot flow and build steps?
Sure, I can craft additional patch for that purpose. Its good that j7 has its separate doc actually, so am65x can stay in its current form.
And can we please find some time to convert all of these to rST and move under doc/board/ ? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201116/7ddbd047/attachment.sig>