J72xx: HSM rearch support series
Subsystems (7)
Tero Kristo
maintainerv3 cover J72xx: HSM rearch support series
Hello,
Resurrecting this series; v2 [1] was sort of put on hold due to some org changes at TI. Sorry about the delay caused by this.
Anyways, v3 is mostly just a rebase of this series on top of 2021.07-rc1, and addition of some new data to support new boot modes for j721e and j7200. This series has been tested on top of Dave's DDR driver series [2]; on both J721e and J7200 boards.
Here are the details of changes compared to v2:
old-patch #2: removed (incorporated to Dave's DDR series now) patch #12 & #13: squashed in some fixes for clock rate handling patch #17: data additions
patch #21: squashed in a fix handle the boot headers properly patch #22: new patch
patch #26: new patch to address the timer issues uncovered by Dario's
fix to omap timer code (commit 11326f379329: omap: timer: fix the rate setting)
Rest of the changes are basically just rebases.
-Tero
[1] https://www.mail-archive.com/u-boot at lists.denx.de/msg390172.html
[2] https://www.mail-archive.com/u-boot at lists.denx.de/msg405657.html
Tero Kristo
maintainerPATCH v3 1/26 lib: rational: copy the rational fraction lib routines from Linux
From: Tero Kristo <[email protected]>
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.
This is based on linux kernel commit:
"lib/math/rational.c: fix possible incorrect result from rational fractions helper"
(sha1: 323dd2c3ed0641f49e89b4e420f9eef5d3d5a881)
--- 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
@@ -663,6 +663,13 @@ config GENERATE_SMBIOS_TABLE See also SMBIOS_SYSINFO which allows SMBIOS values to be provided in the devicetree. +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
@@ -73,6 +73,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 2/26 arm: mach-k3: introduce new config option for sysfw split
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
On J7 family of SoCs (J721E and J7200), sysfw is being split to be run under two cores, TIFS portion on DMSC core, and DM firmware under MCU R5. As MCU R5 is also used to run one phase of the bootloader, we must prevent access from here towards sysfw services. To support this, add new config option which can be used to detect presence of RM/PM sysfw services.
--- arch/arm/mach-k3/Kconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm/mach-k3/Kconfig +11 -0
@@ -141,6 +141,17 @@ config SYS_K3_SPL_ATF Enabling this will try to start Cortex-A (typically with ATF) after SPL from R5. +config K3_DM_FW + bool "Separate DM firmware image" + depends on SPL && CPU_V7R && SOC_K3_J721E && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN + default y + help + Enabling this will indicate that the system has separate DM + and TIFS firmware images in place, instead of a single SYSFW + firmware. Due to DM being executed on the same core as R5 SPL + bootloader, it makes RM and PM services not being available + during R5 SPL execution time. + source "board/ti/am65x/Kconfig" source "board/ti/j721e/Kconfig" endif
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 3/26 remoteproc: k3-r5: remove sysfw PM calls if not supported
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
With 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 | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/remoteproc/ti_k3_r5f_rproc.c +9 -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); +#ifndef CONFIG_K3_DM_FW bool r_state; +#endif int ret;dev_dbg (dev,"%s\n" , __func__);
@@ -804,6 +806,12 @@ static int k3_r5f_probe(struct udevice *dev)return ret; } +/* +* The PM functionality is not supported by the firmware during +* SPL execution with the separated DM firmware image. The following +* piece of code is not compiled in that case. +*/ +#ifndef CONFIG_K3_DM_FW 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 +825,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 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 | 5 ++++- 9 files changed, 18 insertions(+), 9 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
@@ -957,7 +957,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
@@ -896,7 +896,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
@@ -1198,7 +1198,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
@@ -1065,7 +1065,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
@@ -2143,7 +2143,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,/* perform any post-processing on the image data */ if (!host_build () &&IS_ENABLED (CONFIG_FIT_IMAGE_POST_PROCESS )) -board_fit_image_post_process (&buf, &size); +board_fit_image_post_process (fit, noffset, &buf, &size); 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, }if (CONFIG_IS_ENABLED (FIT_IMAGE_POST_PROCESS )) -board_fit_image_post_process (&src, &length); +board_fit_image_post_process (fit, node, &src, &length); load_ptr =map_sysmem (load_addr, length);if (IS_ENABLED (CONFIG_SPL_GZIP ) && image_comp ==IH_COMP_GZIP ) {
include/image.h +4 -1
@@ -1581,11 +1581,14 @@ 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); +void board_fit_image_post_process (const void *fit,int node,void **p_image, +size_t *p_size);#define FDT_ERROR ((ulong)(-1))
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 5/26 clk: fixed_rate: add API for directly registering fixed rate clocks
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
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.
--- drivers/clk/clk_fixed_rate.c | 43 ++++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 3 +++ 2 files changed, 46 insertions(+)
drivers/clk/clk_fixed_rate.c +43 -0
@@ -9,6 +9,9 @@#include <dm/device-internal.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;
@@ -40,6 +43,15 @@ void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev, clk->enable_count =0 ; } +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_of_to_plat (struct udevice *dev) {clk_fixed_rate_ofdata_to_plat_ (dev,to_clk_fixed_rate (dev));
@@ -47,6 +59,30 @@ static int clk_fixed_rate_of_to_plat(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" ,
@@ -63,3 +99,10 @@ U_BOOT_DRIVER(fixed_clock) = { .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
@@ -247,6 +247,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 6/26 clk: fix clock tree dump to properly dump out every registered clock
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
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_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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 7/26 clk: do not attempt to fetch clock pointer with null device
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Bail 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
@@ -499,6 +499,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 8/26 clk: add support for setting clk rate from cmdline
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
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.
--- 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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 9/26 clk: sci-clk: fix return value of set_rate
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Set 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/ti/clk-sci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/ti/clk-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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 10/26 clk: fix assigned-clocks to pass with deferring provider
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
If 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
@@ -240,6 +240,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));
@@ -308,6 +317,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 11/26 clk: fix set_rate to clean up cached rates for the hierarchy
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Clock 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
@@ -565,6 +565,22 @@ ulong clk_round_rate(struct clk *clk, ulong rate)return ops->round_rate (clk, 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;
@@ -577,6 +593,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 12/26 clk: add support for TI K3 SoC PLL
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Add 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/ti/Kconfig | 12 ++ drivers/clk/ti/Makefile | 1 + drivers/clk/ti/clk-k3-pll.c | 283 ++++++++++++++++++++++++++++++++++++ include/k3-clk.h | 15 ++ 4 files changed, 311 insertions(+) create mode 100644 drivers/clk/ti/clk-k3-pll.c create mode 100644 include/k3-clk.h
drivers/clk/ti/Kconfig +12 -0
@@ -41,3 +41,15 @@ config CLK_TI_SCI This enables the clock driver support over TI System Control Interface 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.
drivers/clk/ti/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_CLK_TI_DIVIDER) += clk-divider.o obj-$(CONFIG_CLK_TI_GATE) += clk-gate.o obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o obj-$(CONFIG_CLK_TI_SCI) += clk-sci.o +obj-$(CONFIG_$(SPL_TPL_)CLK_K3_PLL) += clk-k3-pll.o
drivers/clk/ti/clk-k3-pll.c new file +283 -0
283 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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 13/26 clk: add support for TI K3 SoC clocks
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Add 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/ti/Kconfig | 12 ++ drivers/clk/ti/Makefile | 1 + drivers/clk/ti/clk-k3.c | 374 ++++++++++++++++++++++++++++++++++++++++ include/k3-clk.h | 162 +++++++++++++++++ 4 files changed, 549 insertions(+) create mode 100644 drivers/clk/ti/clk-k3.c
drivers/clk/ti/Kconfig +12 -0
@@ -53,3 +53,15 @@ config SPL_CLK_K3_PLL depends on CLK && LIB_RATIONAL && SPL help Enables PLL clock support for K3 SoC family of devices. + +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 + help + Enables the clock translation layer from DT to device clocks.
drivers/clk/ti/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_CLK_TI_GATE) += clk-gate.o obj-$(CONFIG_CLK_TI_MUX) += clk-mux.o obj-$(CONFIG_CLK_TI_SCI) += clk-sci.o obj-$(CONFIG_$(SPL_TPL_)CLK_K3_PLL) += clk-k3-pll.o +obj-$(CONFIG_$(SPL_TPL_)CLK_K3) += clk-k3.o
drivers/clk/ti/clk-k3.c new file +374 -0
374 lines not on this page · raw message
include/k3-clk.h +162 -0
169 lines not on this page · raw message
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 14/26 power: domain: Introduce driver for raw TI K3 PDs
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Normally, 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 · 1 line
2.17.1
PATCH v3 14/26 power: domain: Introduce driver for raw TI K3 PDs
Hi Tero,
Quoted 22 lines · Tero Kristo
From: Tero Kristo <[email protected]>
Normally, 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.
Signed-off-by Tero Kristo <[email protected]>Signed-off-by Tero Kristo <[email protected]>--- 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.hdrivers/power/domain/Kconfig +0
-0
drivers/power/domain/Kconfig config TI_SCI_POWER_DOMAIN · line 78
Quoted 7 lines
drivers/power/domain/Kconfig +4
-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
Add your ARCH config as "depends on". This is TI specific thing.
Quoted 19 lines
drivers/power/domain/Kconfig +3
-0+ help + Generic power domain implementation for TI K3 devices. + endmenudrivers/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.odrivers/power/domain/ti-power-domain.c new file +0
-0
drivers/power/domain/ti-power-domain.c line 5
Quoted 5 lines
drivers/power/domain/ti-power-domain.c new file +5
-0@@ -0,0 +1,377 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Texas Instruments power domain driver +* +* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
2021?
Quoted 109 lines
drivers/power/domain/ti-power-domain.c new file +109
-0+* Tero Kristo <[email protected]> +*/ + +#include <asm/io.h> +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <power-domain-uclass.h> +#include <soc.h> +#include <k3-dev.h> + +#define PSC_PTCMD 0x120 +#define PSC_PTSTAT 0x128 +#define PSC_PDSTAT 0x200 +#define PSC_PDCTL 0x300 +#define PSC_MDSTAT 0x800 +#define PSC_MDCTL 0xa00 + +#define PDCTL_STATE_MASK 0x1 +#define PDCTL_STATE_OFF 0x0 +#define PDCTL_STATE_ON 0x1 + +#define MDSTAT_STATE_MASK 0x3f +#define MDSTAT_BUSY_MASK 0x30 +#define MDSTAT_STATE_SWRSTDISABLE 0x0 +#define MDSTAT_STATE_ENABLE 0x3 + +#define LPSC_TIMEOUT 100000 +#define PD_TIMEOUT 100000 + +static u32 psc_read (struct ti_psc *psc,u32 reg) +{ +u32 val; + + val =readl (psc->base + reg); +debug ("%s: 0x%x from %p\n" , __func__, val, psc->base + reg); +return val; +} + +static void psc_write (u32 val,struct ti_psc *psc,u32 reg) +{ +debug ("%s: 0x%x to %p\n" , __func__, val, psc->base + reg); +writel (val, psc->base + reg); +} + +static u32 pd_read (struct ti_pd *pd,u32 reg) +{ +return psc_read (pd->psc, reg +4 * pd->id); +} + +static void pd_write (u32 val,struct ti_pd *pd,u32 reg) +{ +psc_write (val, pd->psc, reg +4 * pd->id); +} + +static u32 lpsc_read (struct ti_lpsc *lpsc,u32 reg) +{ +return psc_read (lpsc->psc, reg +4 * lpsc->id); +} + +static void lpsc_write (u32 val,struct ti_lpsc *lpsc,u32 reg) +{ +psc_write (val, lpsc->psc, reg +4 * lpsc->id); +} + +static const struct soc_attr ti_k3_soc_pd_data[] = { +#ifdef CONFIG_SOC_K3_J721E + { + .family ="J721E" , + .data = &j721e_pd_platdata, + }, + { + .family ="J7200" , + .data = &j7200_pd_platdata, + }, +#endif + {/* sentinel */ } +}; + +static int ti_power_domain_probe (struct udevice *dev) +{ +struct ti_k3_pd_platdata *data =dev_get_priv (dev); +const struct soc_attr *soc_match_data; +const struct ti_k3_pd_platdata *pdata; + +printf ("%s(dev=%p)\n" , __func__, dev); + +if (!data) +return -ENOMEM ; + + soc_match_data =soc_device_match (ti_k3_soc_pd_data); +if (!soc_match_data) +return -ENODEV ; + + pdata = (const struct ti_k3_pd_platdata *)soc_match_data->data; + + data->psc = pdata->psc; + data->pd = pdata->pd; + data->lpsc = pdata->lpsc; + data->devs = pdata->devs; + data->num_psc = pdata->num_psc; + data->num_pd = pdata->num_pd; + data->num_lpsc = pdata->num_lpsc; + data->num_devs = pdata->num_devs; + +return 0 ; +} + +static int ti_pd_wait (struct ti_pd *pd)
drivers/power/domain/ti-power-domain.c line 124
Quoted 10 lines
drivers/power/domain/ti-power-domain.c new file +10
-0+{ +u32 ptstat; +int i =PD_TIMEOUT ; + +while (i) { + ptstat =psc_read (pd->psc,PSC_PTSTAT ); +if (!(ptstat &BIT (pd->id))) +return 0 ; + i--; + }
doesn't use readl_pool_timeout() function?
Quoted 5 lines
drivers/power/domain/ti-power-domain.c new file +5
-0+ +debug ("%s: psc%d, pd%d failed to transition.\n" , __func__, + pd->psc->id, pd->id); + +return -ETIMEDOUT ;
drivers/power/domain/ti-power-domain.c line 139
Quoted 10 lines
drivers/power/domain/ti-power-domain.c new file +10
-0+} + +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) +{ +u32 pdctl;
Not need to use pdctl variable.
return pd_read(pd, PSC_PDCTL) & PDCTL_STATE_MASK;
Quoted 92 lines
drivers/power/domain/ti-power-domain.c new file +92
-0+ + pdctl =pd_read (pd,PSC_PDCTL ); +return pdctl &PDCTL_STATE_MASK ; +} + +static int ti_pd_get (struct ti_pd *pd) +{ +u32 pdctl; +int ret; + + pd->usecount++; + +if (pd->usecount >1 ) +return 0 ; + +if (pd->depend) { + ret =ti_pd_get (pd->depend); +if (ret) +return ret; +ti_pd_transition (pd->depend); + ret =ti_pd_wait (pd->depend); +if (ret) +return ret; + } + + pdctl =pd_read (pd,PSC_PDCTL ); + +if ((pdctl &PDCTL_STATE_MASK ) ==PDCTL_STATE_ON ) +return 0 ; + +debug ("%s: enabling psc:%d, pd:%d\n" , __func__, pd->psc->id, pd->id); + + pdctl &= ~PDCTL_STATE_MASK ; + pdctl |=PDCTL_STATE_ON ; + +pd_write (pdctl, pd,PSC_PDCTL ); + +return 0 ; +} + +static int ti_pd_put (struct ti_pd *pd) +{ +u32 pdctl; +int ret; + + pd->usecount--; + +if (pd->usecount >0 ) +return 0 ; + + pdctl =pd_read (pd,PSC_PDCTL ); +if ((pdctl &PDCTL_STATE_MASK ) ==PDCTL_STATE_OFF ) +return 0 ; + + pdctl &= ~PDCTL_STATE_MASK ; + pdctl |=PDCTL_STATE_OFF ; + +debug ("%s: disabling psc:%d, pd:%d\n" , __func__, pd->psc->id, pd->id); + +pd_write (pdctl, pd,PSC_PDCTL ); + +if (pd->depend) { +ti_pd_transition (pd); + ret =ti_pd_wait (pd); +if (ret) +return ret; + + ret =ti_pd_put (pd->depend); +if (ret) +return ret; +ti_pd_transition (pd->depend); + ret =ti_pd_wait (pd->depend); +if (ret) +return ret; + } + +return 0 ; +} + +static int ti_lpsc_wait (struct ti_lpsc *lpsc) +{ +u32 mdstat; +int i =LPSC_TIMEOUT ; + +while (i) { + mdstat =lpsc_read (lpsc,PSC_MDSTAT ); +if (!(mdstat &MDSTAT_BUSY_MASK )) +return 0 ; + i--; + } + +printf ("%s: module %d failed to transition.\n" , __func__, lpsc->id);
drivers/power/domain/ti-power-domain.c line 241
Quoted 10 lines
drivers/power/domain/ti-power-domain.c new file +10
-0+ +return -ETIMEDOUT ; +} + +static u8 lpsc_get_state (struct ti_lpsc *lpsc) +{ +u32 mdctl; + + mdctl =lpsc_read (lpsc,PSC_MDCTL ); +return mdctl &MDSTAT_STATE_MASK ;
Ditto. return lpas_rad() & MDSTATE_STATE_MASK;
Quoted 86 lines
drivers/power/domain/ti-power-domain.c new file +86
-0+} + +static int ti_lpsc_transition (struct ti_lpsc *lpsc,u8 state) +{ +struct ti_pd *psc_pd; +int ret; +u32 mdctl; + + psc_pd = lpsc->pd; + +if (state ==MDSTAT_STATE_ENABLE ) { + lpsc->usecount++; +if (lpsc->usecount >1 ) +return 0 ; + }else { + lpsc->usecount--; +if (lpsc->usecount >=1 ) +return 0 ; + } + +debug ("%s: transitioning psc:%d, lpsc:%d to %x\n" , __func__, + lpsc->psc->id, lpsc->id, state); + +if (lpsc->depend) +ti_lpsc_transition (lpsc->depend, state); + + mdctl =lpsc_read (lpsc,PSC_MDCTL ); +if ((mdctl &MDSTAT_STATE_MASK ) == state) +return 0 ; + +if (state ==MDSTAT_STATE_ENABLE ) +ti_pd_get (psc_pd); +else +ti_pd_put (psc_pd); + + mdctl &= ~MDSTAT_STATE_MASK ; + mdctl |= state; + +lpsc_write (mdctl, lpsc,PSC_MDCTL ); + +ti_pd_transition (psc_pd); + ret =ti_pd_wait (psc_pd); +if (ret) +return ret; + +return ti_lpsc_wait (lpsc); +} + +static int ti_power_domain_transition (struct power_domain *pd,u8 state) +{ +struct ti_lpsc *lpsc = pd->priv; + +return ti_lpsc_transition (lpsc, state); +} + +static int ti_power_domain_on (struct power_domain *pd) +{ +debug ("%s(pd=%p, id=%lu)\n" , __func__, pd, pd->id); + +return ti_power_domain_transition (pd,MDSTAT_STATE_ENABLE ); +} + +static int ti_power_domain_off (struct power_domain *pd) +{ +debug ("%s(pd=%p, id=%lu)\n" , __func__, pd, pd->id); + +return ti_power_domain_transition (pd,MDSTAT_STATE_SWRSTDISABLE ); +} + +static struct ti_lpsc *lpsc_lookup (struct ti_k3_pd_platdata *data,int id) +{ +int idx; + +for (idx =0 ; idx < data->num_devs; idx++) +if (data->devs[idx].id == id) +return data->devs[idx].lpsc; + +return NULL ; +} + +static int ti_power_domain_of_xlate (struct power_domain *pd, +struct ofnode_phandle_args *args) +{ +struct ti_k3_pd_platdata *data =dev_get_priv (pd->dev); +struct ti_lpsc *lpsc; +
drivers/power/domain/ti-power-domain.c line 337
Quoted 10 lines
drivers/power/domain/ti-power-domain.c new file +10
-0+debug ("%s(power_domain=%p, id=%d)\n" , __func__, pd, args->args[0 ]); + +if (args->args_count <1 ) { +debug ("Invalid args_count: %d\n" , args->args_count); +return -EINVAL ; + } + + lpsc =lpsc_lookup (data, args->args[0 ]); +if (!lpsc) { +printf ("%s: invalid dev-id: %d\n" , __func__, args->args[0 ]);
Well, you're using debug to display error message. but it's used printf at here. how about choosing one of them?
Quoted 123 lines
drivers/power/domain/ti-power-domain.c new file +40
-0+return -ENOENT ; + } + + pd->id = lpsc->id; + pd->priv = lpsc; + +return 0 ; +} + +static int ti_power_domain_request (struct power_domain *pd) +{ +return 0 ; +} + +static int ti_power_domain_free (struct power_domain *pd) +{ +return 0 ; +} + +static const struct udevice_id ti_power_domain_of_match[] = { + { .compatible ="ti,sci-pm-domain" }, + {/* sentinel */ } +}; + +static struct power_domain_ops ti_power_domain_ops = { + .on = ti_power_domain_on, + .off = ti_power_domain_off, + .of_xlate = ti_power_domain_of_xlate, + .request = ti_power_domain_request, + .rfree = ti_power_domain_free, +}; + +U_BOOT_DRIVER (ti_pm_domains) = { + .name ="ti-pm-domains" , + .id =UCLASS_POWER_DOMAIN , + .of_match = ti_power_domain_of_match, + .probe = ti_power_domain_probe, + .priv_auto =sizeof (struct ti_k3_pd_platdata ), + .ops = &ti_power_domain_ops, +};include/k3-dev.h new file +76
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Texas Instruments K3 Device Platform Data +* +* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +*/ +#ifndef __K3_DEV_H__ +#define __K3_DEV_H__ + +#include <asm/io.h> +#include <linux/types.h> +#include <stdint.h> + +#define LPSC_MODULE_EXISTS BIT(0) +#define LPSC_NO_CLOCK_GATING BIT(1) +#define LPSC_DEPENDS BIT(2) +#define LPSC_HAS_RESET_ISO BIT(3) +#define LPSC_HAS_LOCAL_RESET BIT(4) +#define LPSC_NO_MODULE_RESET BIT(5) + +#define PSC_PD_EXISTS BIT(0) +#define PSC_PD_ALWAYSON BIT(1) +#define PSC_PD_DEPENDS BIT(2) + +struct ti_psc { +int id; +void __iomem *base; +}; + +struct ti_pd ; + +struct ti_pd { +int id; +int usecount; +struct ti_psc *psc; +struct ti_pd *depend; +}; + +struct ti_lpsc ; + +struct ti_lpsc { +int id; +int usecount; +struct ti_psc *psc; +struct ti_pd *pd; +struct ti_lpsc *depend; +}; + +struct ti_dev { +struct ti_lpsc *lpsc; +int id; +}; + +/** +* struct ti_k3_pd_platdata - pm domain controller information structure +*/ +struct ti_k3_pd_platdata { +struct ti_psc *psc; +struct ti_pd *pd; +struct ti_lpsc *lpsc; +struct ti_dev *devs; +int num_psc; +int num_pd; +int num_lpsc; +int num_devs; +}; + +#define PSC (_id, _base) { .id = _id, .base = (void *)_base, } +#define PSC_PD (_id, _psc, _depend) { .id = _id, .psc = _psc, .depend = _depend } +#define PSC_LPSC (_id, _psc, _pd, _depend) { .id = _id, .psc = _psc, .pd = _pd, .depend = _depend } +#define PSC_DEV (_id, _lpsc) { .id = _id, .lpsc = _lpsc } + +extern const struct ti_k3_pd_platdata j721e_pd_platdata; +extern const struct ti_k3_pd_platdata j7200_pd_platdata; + +#endif
Tero Kristo
maintainerPATCH v3 14/26 power: domain: Introduce driver for raw TI K3 PDs
Quoted 20 lines · Jaehoon Chung
Hi Tero,
Quoted 17 lines · Tero Kristo
From: Tero Kristo <[email protected]>
Normally, 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.
Signed-off-by Tero Kristo <[email protected]>Signed-off-by Tero Kristo <[email protected]>--- 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.ccreate mode 100644include/k3-dev.h
Quoted 14 lines
drivers/power/domain/Kconfig config TI_SCI_POWER_DOMAIN · line 78
Quoted 12 lines
drivers/power/domain/Kconfig +4
-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_DOMAINAdd your ARCH config as "depends on". This is TI specific thing.
Right, will do that.
Quoted 19 lines
Quoted 19 lines
drivers/power/domain/Kconfig +3
-0+ help + Generic power domain implementation for TI K3 devices. + endmenudrivers/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.odrivers/power/domain/ti-power-domain.c new file +0
-0
Quoted 8 lines
drivers/power/domain/ti-power-domain.c line 5
Quoted 6 lines
drivers/power/domain/ti-power-domain.c new file +5
-0@@ -0,0 +1,377 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Texas Instruments power domain driver +* +* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ 2021?
Will change to 2020-2021.
Quoted 114 lines
Quoted 114 lines
drivers/power/domain/ti-power-domain.c new file +113
-0+* Tero Kristo <[email protected]> +*/ + +#include <asm/io.h> +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <power-domain-uclass.h> +#include <soc.h> +#include <k3-dev.h> + +#define PSC_PTCMD 0x120 +#define PSC_PTSTAT 0x128 +#define PSC_PDSTAT 0x200 +#define PSC_PDCTL 0x300 +#define PSC_MDSTAT 0x800 +#define PSC_MDCTL 0xa00 + +#define PDCTL_STATE_MASK 0x1 +#define PDCTL_STATE_OFF 0x0 +#define PDCTL_STATE_ON 0x1 + +#define MDSTAT_STATE_MASK 0x3f +#define MDSTAT_BUSY_MASK 0x30 +#define MDSTAT_STATE_SWRSTDISABLE 0x0 +#define MDSTAT_STATE_ENABLE 0x3 + +#define LPSC_TIMEOUT 100000 +#define PD_TIMEOUT 100000 + +static u32 psc_read (struct ti_psc *psc,u32 reg) +{ +u32 val; + + val =readl (psc->base + reg); +debug ("%s: 0x%x from %p\n" , __func__, val, psc->base + reg); +return val; +} + +static void psc_write (u32 val,struct ti_psc *psc,u32 reg) +{ +debug ("%s: 0x%x to %p\n" , __func__, val, psc->base + reg); +writel (val, psc->base + reg); +} + +static u32 pd_read (struct ti_pd *pd,u32 reg) +{ +return psc_read (pd->psc, reg +4 * pd->id); +} + +static void pd_write (u32 val,struct ti_pd *pd,u32 reg) +{ +psc_write (val, pd->psc, reg +4 * pd->id); +} + +static u32 lpsc_read (struct ti_lpsc *lpsc,u32 reg) +{ +return psc_read (lpsc->psc, reg +4 * lpsc->id); +} + +static void lpsc_write (u32 val,struct ti_lpsc *lpsc,u32 reg) +{ +psc_write (val, lpsc->psc, reg +4 * lpsc->id); +} + +static const struct soc_attr ti_k3_soc_pd_data[] = { +#ifdef CONFIG_SOC_K3_J721E + { + .family ="J721E" , + .data = &j721e_pd_platdata, + }, + { + .family ="J7200" , + .data = &j7200_pd_platdata, + }, +#endif + {/* sentinel */ } +}; + +static int ti_power_domain_probe (struct udevice *dev) +{ +struct ti_k3_pd_platdata *data =dev_get_priv (dev); +const struct soc_attr *soc_match_data; +const struct ti_k3_pd_platdata *pdata; + +printf ("%s(dev=%p)\n" , __func__, dev); + +if (!data) +return -ENOMEM ; + + soc_match_data =soc_device_match (ti_k3_soc_pd_data); +if (!soc_match_data) +return -ENODEV ; + + pdata = (const struct ti_k3_pd_platdata *)soc_match_data->data; + + data->psc = pdata->psc; + data->pd = pdata->pd; + data->lpsc = pdata->lpsc; + data->devs = pdata->devs; + data->num_psc = pdata->num_psc; + data->num_pd = pdata->num_pd; + data->num_lpsc = pdata->num_lpsc; + data->num_devs = pdata->num_devs; + +return 0 ; +} + +static int ti_pd_wait (struct ti_pd *pd) +{ +u32 ptstat; +int i =PD_TIMEOUT ; +
Quoted 8 lines
drivers/power/domain/ti-power-domain.c line 124
Quoted 6 lines
drivers/power/domain/ti-power-domain.c new file +6
-0+while (i) { + ptstat =psc_read (pd->psc,PSC_PTSTAT ); +if (!(ptstat &BIT (pd->id))) +return 0 ; + i--; + }doesn't use
readl_pool_timeout()function?
This was based on assumption that the timer would not work very early in boot, but seems I was mistaken. It does work so I'll replace this.
There is another poll in the file within the ti_lpsc_wait, will change that also.
Quoted 19 lines
Quoted 6 lines
drivers/power/domain/ti-power-domain.c new file +5
-0+ +debug ("%s: psc%d, pd%d failed to transition.\n" , __func__, + pd->psc->id, pd->id); + +return -ETIMEDOUT ;drivers/power/domain/ti-power-domain.c line 139
Quoted 10 lines
drivers/power/domain/ti-power-domain.c new file +10
-0+} + +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) +{ +u32 pdctl;Not need to use pdctl variable.
Quoted 1 line
return
pd_read(pd, PSC_PDCTL)&PDCTL_STATE_MASK;
Sure, will change that.
Quoted 83 lines
Quoted 83 lines
drivers/power/domain/ti-power-domain.c new file +82
-0+ + pdctl =pd_read (pd,PSC_PDCTL ); +return pdctl &PDCTL_STATE_MASK ; +} + +static int ti_pd_get (struct ti_pd *pd) +{ +u32 pdctl; +int ret; + + pd->usecount++; + +if (pd->usecount >1 ) +return 0 ; + +if (pd->depend) { + ret =ti_pd_get (pd->depend); +if (ret) +return ret; +ti_pd_transition (pd->depend); + ret =ti_pd_wait (pd->depend); +if (ret) +return ret; + } + + pdctl =pd_read (pd,PSC_PDCTL ); + +if ((pdctl &PDCTL_STATE_MASK ) ==PDCTL_STATE_ON ) +return 0 ; + +debug ("%s: enabling psc:%d, pd:%d\n" , __func__, pd->psc->id, pd->id); + + pdctl &= ~PDCTL_STATE_MASK ; + pdctl |=PDCTL_STATE_ON ; + +pd_write (pdctl, pd,PSC_PDCTL ); + +return 0 ; +} + +static int ti_pd_put (struct ti_pd *pd) +{ +u32 pdctl; +int ret; + + pd->usecount--; + +if (pd->usecount >0 ) +return 0 ; + + pdctl =pd_read (pd,PSC_PDCTL ); +if ((pdctl &PDCTL_STATE_MASK ) ==PDCTL_STATE_OFF ) +return 0 ; + + pdctl &= ~PDCTL_STATE_MASK ; + pdctl |=PDCTL_STATE_OFF ; + +debug ("%s: disabling psc:%d, pd:%d\n" , __func__, pd->psc->id, pd->id); + +pd_write (pdctl, pd,PSC_PDCTL ); + +if (pd->depend) { +ti_pd_transition (pd); + ret =ti_pd_wait (pd); +if (ret) +return ret; + + ret =ti_pd_put (pd->depend); +if (ret) +return ret; +ti_pd_transition (pd->depend); + ret =ti_pd_wait (pd->depend); +if (ret) +return ret; + } + +return 0 ; +} + +static int ti_lpsc_wait (struct ti_lpsc *lpsc) +{ +u32 mdstat;
Quoted 8 lines
drivers/power/domain/ti-power-domain.c line 229
Quoted 8 lines
drivers/power/domain/ti-power-domain.c new file +8
-0+int i =LPSC_TIMEOUT ; + +while (i) { + mdstat =lpsc_read (lpsc,PSC_MDSTAT ); +if (!(mdstat &MDSTAT_BUSY_MASK )) +return 0 ; + i--; + }
Here is another manual iopoll to be replaced.
Quoted 6 lines
Quoted 6 lines
drivers/power/domain/ti-power-domain.c new file +6
-0+ +printf ("%s: module %d failed to transition.\n" , __func__, lpsc->id); + +return -ETIMEDOUT ; +} +
Quoted 8 lines
drivers/power/domain/ti-power-domain.c line 241
Quoted 6 lines
drivers/power/domain/ti-power-domain.c new file +6
-0+static u8 lpsc_get_state (struct ti_lpsc *lpsc) +{ +u32 mdctl; + + mdctl =lpsc_read (lpsc,PSC_MDCTL ); +return mdctl &MDSTAT_STATE_MASK ;Ditto. return
lpas_rad()&MDSTATE_STATE_MASK;
Will fix that also.
Quoted 92 lines
Quoted 92 lines
drivers/power/domain/ti-power-domain.c new file +91
-0+} + +static int ti_lpsc_transition (struct ti_lpsc *lpsc,u8 state) +{ +struct ti_pd *psc_pd; +int ret; +u32 mdctl; + + psc_pd = lpsc->pd; + +if (state ==MDSTAT_STATE_ENABLE ) { + lpsc->usecount++; +if (lpsc->usecount >1 ) +return 0 ; + }else { + lpsc->usecount--; +if (lpsc->usecount >=1 ) +return 0 ; + } + +debug ("%s: transitioning psc:%d, lpsc:%d to %x\n" , __func__, + lpsc->psc->id, lpsc->id, state); + +if (lpsc->depend) +ti_lpsc_transition (lpsc->depend, state); + + mdctl =lpsc_read (lpsc,PSC_MDCTL ); +if ((mdctl &MDSTAT_STATE_MASK ) == state) +return 0 ; + +if (state ==MDSTAT_STATE_ENABLE ) +ti_pd_get (psc_pd); +else +ti_pd_put (psc_pd); + + mdctl &= ~MDSTAT_STATE_MASK ; + mdctl |= state; + +lpsc_write (mdctl, lpsc,PSC_MDCTL ); + +ti_pd_transition (psc_pd); + ret =ti_pd_wait (psc_pd); +if (ret) +return ret; + +return ti_lpsc_wait (lpsc); +} + +static int ti_power_domain_transition (struct power_domain *pd,u8 state) +{ +struct ti_lpsc *lpsc = pd->priv; + +return ti_lpsc_transition (lpsc, state); +} + +static int ti_power_domain_on (struct power_domain *pd) +{ +debug ("%s(pd=%p, id=%lu)\n" , __func__, pd, pd->id); + +return ti_power_domain_transition (pd,MDSTAT_STATE_ENABLE ); +} + +static int ti_power_domain_off (struct power_domain *pd) +{ +debug ("%s(pd=%p, id=%lu)\n" , __func__, pd, pd->id); + +return ti_power_domain_transition (pd,MDSTAT_STATE_SWRSTDISABLE ); +} + +static struct ti_lpsc *lpsc_lookup (struct ti_k3_pd_platdata *data,int id) +{ +int idx; + +for (idx =0 ; idx < data->num_devs; idx++) +if (data->devs[idx].id == id) +return data->devs[idx].lpsc; + +return NULL ; +} + +static int ti_power_domain_of_xlate (struct power_domain *pd, +struct ofnode_phandle_args *args) +{ +struct ti_k3_pd_platdata *data =dev_get_priv (pd->dev); +struct ti_lpsc *lpsc; + +debug ("%s(power_domain=%p, id=%d)\n" , __func__, pd, args->args[0 ]); + +if (args->args_count <1 ) { +debug ("Invalid args_count: %d\n" , args->args_count); +return -EINVAL ;
Quoted 8 lines
drivers/power/domain/ti-power-domain.c line 337
Quoted 5 lines
drivers/power/domain/ti-power-domain.c new file +5
-0+ } + + lpsc =lpsc_lookup (data, args->args[0 ]); +if (!lpsc) { +printf ("%s: invalid dev-id: %d\n" , __func__, args->args[0 ]);Well, you're using debug to display error message. but it's used printf at here. how about choosing one of them?
True, I'll change these both to be printfs as they are actual error conditions.
Thanks for the review, I'll wait for additional comments on the series and post updated version next week.
-Tero
Quoted 125 lines
Quoted 124 lines
drivers/power/domain/ti-power-domain.c new file +40
-0+return -ENOENT ; + } + + pd->id = lpsc->id; + pd->priv = lpsc; + +return 0 ; +} + +static int ti_power_domain_request (struct power_domain *pd) +{ +return 0 ; +} + +static int ti_power_domain_free (struct power_domain *pd) +{ +return 0 ; +} + +static const struct udevice_id ti_power_domain_of_match[] = { + { .compatible ="ti,sci-pm-domain" }, + {/* sentinel */ } +}; + +static struct power_domain_ops ti_power_domain_ops = { + .on = ti_power_domain_on, + .off = ti_power_domain_off, + .of_xlate = ti_power_domain_of_xlate, + .request = ti_power_domain_request, + .rfree = ti_power_domain_free, +}; + +U_BOOT_DRIVER (ti_pm_domains) = { + .name ="ti-pm-domains" , + .id =UCLASS_POWER_DOMAIN , + .of_match = ti_power_domain_of_match, + .probe = ti_power_domain_probe, + .priv_auto =sizeof (struct ti_k3_pd_platdata ), + .ops = &ti_power_domain_ops, +};include/k3-dev.h new file +76
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Texas Instruments K3 Device Platform Data +* +* Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ +*/ +#ifndef __K3_DEV_H__ +#define __K3_DEV_H__ + +#include <asm/io.h> +#include <linux/types.h> +#include <stdint.h> + +#define LPSC_MODULE_EXISTS BIT(0) +#define LPSC_NO_CLOCK_GATING BIT(1) +#define LPSC_DEPENDS BIT(2) +#define LPSC_HAS_RESET_ISO BIT(3) +#define LPSC_HAS_LOCAL_RESET BIT(4) +#define LPSC_NO_MODULE_RESET BIT(5) + +#define PSC_PD_EXISTS BIT(0) +#define PSC_PD_ALWAYSON BIT(1) +#define PSC_PD_DEPENDS BIT(2) + +struct ti_psc { +int id; +void __iomem *base; +}; + +struct ti_pd ; + +struct ti_pd { +int id; +int usecount; +struct ti_psc *psc; +struct ti_pd *depend; +}; + +struct ti_lpsc ; + +struct ti_lpsc { +int id; +int usecount; +struct ti_psc *psc; +struct ti_pd *pd; +struct ti_lpsc *depend; +}; + +struct ti_dev { +struct ti_lpsc *lpsc; +int id; +}; + +/** +* struct ti_k3_pd_platdata - pm domain controller information structure +*/ +struct ti_k3_pd_platdata { +struct ti_psc *psc; +struct ti_pd *pd; +struct ti_lpsc *lpsc; +struct ti_dev *devs; +int num_psc; +int num_pd; +int num_lpsc; +int num_devs; +}; + +#define PSC (_id, _base) { .id = _id, .base = (void *)_base, } +#define PSC_PD (_id, _psc, _depend) { .id = _id, .psc = _psc, .depend = _depend } +#define PSC_LPSC (_id, _psc, _pd, _depend) { .id = _id, .psc = _psc, .pd = _pd, .depend = _depend } +#define PSC_DEV (_id, _lpsc) { .id = _id, .lpsc = _lpsc } + +extern const struct ti_k3_pd_platdata j721e_pd_platdata; +extern const struct ti_k3_pd_platdata j7200_pd_platdata; + +#endif
Tero Kristo
maintainerPATCH v3 15/26 cmd: ti: pd: Add debug command for K3 power domains
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Add 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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 16/26 tools: k3_fit_atf: add DM binary to the FIT image
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Add 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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 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 | 547 +++++++++++++++++++++ arch/arm/mach-k3/j7200/dev-data.c | 77 +++ arch/arm/mach-k3/j721e/Makefile | 5 + arch/arm/mach-k3/j721e/clk-data.c | 781 ++++++++++++++++++++++++++++++ arch/arm/mach-k3/j721e/dev-data.c | 75 +++ 7 files changed, 1491 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 +547 -0
547 lines not on this page · raw message
arch/arm/mach-k3/j7200/dev-data.c new file +77 -0
77 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 +781 -0
781 lines not on this page · raw message
arch/arm/mach-k3/j721e/dev-data.c new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 18/26 arm: mach-k3: add support for detecting firmware images from FIT
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Add 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
@@ -28,6 +28,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;
@@ -181,7 +202,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);
@@ -192,15 +213,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);
@@ -210,7 +236,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 ();
@@ -218,13 +245,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 19/26 arm: mach-k3: do board config for PM and RM only if supported
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
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.
--- arch/arm/mach-k3/sysfw-loader.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +4 -0
@@ -159,11 +159,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifndef CONFIG_K3_DM_FW 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,
@@ -172,12 +174,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifndef CONFIG_K3_DM_FW /* 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 · 1 line
2.17.1
PATCH v3 19/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 36 lines · Tero Kristo
From: Tero Kristo <[email protected]>
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]>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 +3
-0@@ -159,11 +159,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifndef CONFIG_K3_DM_FW 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,@@ -172,12 +174,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifndef CONFIG_K3_DM_FW
arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 187
Quoted 10 lines
arch/arm/mach-k3/sysfw-loader.c +1
-0/* 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,
We still need to send RM CFG to TIFS in case of J721e in order for DMA to work at R5 SPL. TIFS needs RM CFG to disable firewalls when R5 SPL sends DMA channel cfg requests.
Could you squash the following diff for next version:
arch/arm/mach-k3/sysfw-loader.c +8 -8
@@ -263,14 +263,7 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); -#ifndef CONFIG_K3_DM_FW -/* 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); -#else +#ifdef CONFIG_K3_DM_FW if (copy_bcfg) { desc = &bcfg_header->descs[1 ];
@@ -284,6 +277,13 @@ static void k3_sysfw_configure_using_fit(void *fit, }#endif +/* 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); +/* Extract security specific configuration from FIT */ ret =fit_get_data_by_name (fit, images,SYSFW_CFG_SEC , &cfg_fragment_addr, &cfg_fragment_size);
Regards
Vignesh
Tero Kristo
maintainerPATCH v3 19/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 55 lines · Vignesh Raghavendra
Quoted 36 lines · Tero Kristo
From: Tero Kristo <[email protected]>
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]>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 +3
-0@@ -159,11 +159,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ret);/* Apply power/clock (PM) specific configuration to SYSFW */ +#ifndef CONFIG_K3_DM_FW 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,@@ -172,12 +174,14 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); +#ifndef CONFIG_K3_DM_FW arch/arm/mach-k3/sysfw-loader.c static void k3_sysfw_configure_using_fit(void *fit, · line 187
Quoted 10 lines
arch/arm/mach-k3/sysfw-loader.c +1
-0/* 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,We still need to send RM CFG to TIFS in case of J721e in order for DMA to work at R5 SPL. TIFS needs RM CFG to disable firewalls when R5 SPL sends DMA channel cfg requests.
Quoted 1 line
Could you squash the following diff for next version:
Yes, I can squash that in. I believe you have tested this change and it works? (I will obviously double check at my end though.)
-Tero
Quoted 40 lines
arch/arm/mach-k3/sysfw-loader.c +8
-8@@ -263,14 +263,7 @@ static void k3_sysfw_configure_using_fit(void *fit,panic ("Error accessing %s node in FIT (%d)\n" ,SYSFW_CFG_RM , ret); -#ifndef CONFIG_K3_DM_FW -/* 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); -#else +#ifdef CONFIG_K3_DM_FW if (copy_bcfg) { desc = &bcfg_header->descs[1 ];@@ -284,6 +277,13 @@ static void k3_sysfw_configure_using_fit(void *fit, }#endif +/* 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); +/* Extract security specific configuration from FIT */ ret =fit_get_data_by_name (fit, images,SYSFW_CFG_SEC , &cfg_fragment_addr, &cfg_fragment_size);Regards
Vignesh
PATCH v3 19/26 arm: mach-k3: do board config for PM and RM only if supported
Quoted 56 lines · Tero Kristo
Quoted 55 lines · Vignesh Raghavendra
Quoted 37 lines · Tero Kristo
From: Tero Kristo <[email protected]>
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]>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@@ -159,11 +159,13 @@ static void k3_sysfw_configure_using_fit(void *fit, ??????????????? ret);? ????? /* Apply power/clock (PM) specific configuration to SYSFW */ +#ifndef
CONFIG_K3_DM_FW
????? 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@@ -172,12 +174,14 @@ static void k3_sysfw_configure_using_fit(void *fit, ????????? panic("Error accessing %s node in FIT (%d)\n", SYSFW_CFG_RM, ??????????????? ret);? +#ifndef
CONFIG_K3_DM_FW
????? /* Apply resource management (RM) configuration to SYSFW */Quoted 9 lines
????? 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,We still need to send RM CFG to TIFS in case of J721e in order for DMA to work at R5 SPL. TIFS needs RM CFG to disable firewalls when R5 SPL sends? DMA channel cfg requests.
Quoted 5 lines
Quoted 1 line
Could you squash the following diff for next version:
Yes, I can squash that in. I believe you have tested this change and it works? (I will obviously double check at my end though.)
Yes, I discovered this when adding DMA support at R5 SPL level
on top of current series. Diff is essentially this commit by Dave on TI SDK tree:
Regards
Vignesh
Tero Kristo
maintainerPATCH v3 20/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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm/mach-k3/common.c +4 -3
@@ -212,11 +212,12 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)panic ("rproc failed to be initialized (%d)\n" , ret);init_env (); -start_non_linux_remote_cores (); -if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) + +if (!fit_image_info[IMAGE_ID_DM_FW ].image_start) { +start_non_linux_remote_cores (); size =load_firmware ("name_mcur5f0_0fw" ,"addr_mcur5f0_0load" , &loadaddr); - + }/* * It is assumed that remoteproc device 1 is the corresponding
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 21/26 arm: mach-k3: sysfw-loader: pass boardcfg to sciserver
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Copy 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 | 101 ++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
arch/arm/mach-k3/sysfw-loader.c +101 -0
@@ -40,6 +40,46 @@ DECLARE_GLOBAL_DATA_PTR;*/ #define K3_SYSTEM_CONTROLLER_RPROC_ID 0 +#define COMMON_HEADER_ADDRESS 0x41cffb00 +#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; +}; + +struct extboot_header { +u8 magic[8 ]; +u32 num_comps; +struct extboot_comp comps[5 ]; +u32 reserved; +}; + +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 ]; +u16 reserved; +} __packed; +static bool sysfw_loaded;static void *sysfw_load_address;
@@ -131,6 +171,15 @@ static void k3_sysfw_configure_using_fit(void *fit,const void *cfg_fragment_addr;size_t cfg_fragment_size;int ret; +#ifdef CONFIG_K3_DM_FW +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 );
@@ -165,6 +214,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 *)COMMON_HEADER_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 )BOARDCFG_ADDRESS ; + 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 */
@@ -181,6 +270,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 · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 22/26 arm: mach-k3: j721e_init: Force early probe of clk-k3 driver
In reply to Tero KristoFrom: Dave Gerlach <[email protected]>
Force the clk-k3 driver to probe early during R5 SPL boot to ensure the default system clock configuration is completed. Many other drivers assume a default state of the clock tree and it is currently possible for them to probe before clk-k3 depending on the exact system configuration.
--- arch/arm/mach-k3/j721e_init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/mach-k3/j721e_init.c +12 -0
@@ -180,6 +180,18 @@ void board_init_f(ulong dummy)k3_sysfw_loader (is_rom_loaded_sysfw (&bootdata), k3_mmc_stop_clock, k3_mmc_restart_clock); +#ifdef CONFIG_SPL_CLK_K3 +/* +* Force probe of clk_k3 driver here to ensure basic default clock +* configuration is always done. +*/ + ret =uclass_get_device_by_driver (UCLASS_CLK , +DM_DRIVER_GET (ti_clk), + &dev); +if (ret) +panic ("Failed to initialize clk-k3!\n" ); +#endif +/* Prepare console output */ preloader_console_init ();
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 23/26 configs: j721e_evm_r5: Enable raw access power management features
In reply to Tero KristoFrom: Tero Kristo <[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/j721e_evm_r5_defconfig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
configs/j721e_evm_r5_defconfig +10 -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
@@ -103,7 +103,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
@@ -141,3 +141,11 @@ 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 +CONFIG_K3_DM_FW=y +CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 24/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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
configs/j7200_evm_r5_defconfig +12 -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
@@ -111,7 +111,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
@@ -143,3 +143,13 @@ 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_K3_DM_FW=y +CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 25/26 board: ti: j72xx: README: update build instructions and image formats
In reply to Tero KristoFrom: Tero Kristo <[email protected]>
Update build instructions and image formats based on HSM rearch. A new DM image is added into the build, which gets executed right after R5 SPL finishes its job.
--- board/ti/j721e/README | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
board/ti/j721e/README +6 -3
@@ -73,12 +73,12 @@ support. Below is the pictorial representation of boot flow: | | | | +-------------+ | | | | | |<--------|---| Start A72 | | | | | | | | | and jump to | | | | -| | | | | next image | | | | +| | | | | DM fw image | | | | | | | | +-------------+ | | | | | | | | +-----------+ | | | | |---------|-----------------------|---->| Reset rls | | | | | | | | +-----------+ | | -| | DMSC | | | : | | +| | TIFS | | | : | | | |Services | | | +-----------+ | | | | |<--------|-----------------------|---->|*ATF/OPTEE*| | | | | | | | +-----------+ | |
@@ -154,7 +154,7 @@ $ make CROSS_COMPILE=arm-linux-gnueabihf- O=/tmp/r5 4.2. A72: $ make CROSS_COMPILE=aarch64-linux-gnu- j721e_evm_a72_defconfig O=/tmp/a72 -$ make CROSS_COMPILE=aarch64-linux-gnu- ATF=<path to ATF dir>/build/k3/generic/release/bl31.bin TEE=<path to OPTEE OS dir>/out/arm-plat-k3/core/tee-pager_v2.bin O=/tmp/a72 +$ make CROSS_COMPILE=aarch64-linux-gnu- ATF=<path to ATF dir>/build/k3/generic/release/bl31.bin TEE=<path to OPTEE OS dir>/out/arm-plat-k3/core/tee-pager_v2.bin DM=<path to DM firmware image> O=/tmp/a72 Target Images --------------
@@ -197,6 +197,9 @@ Image formats: | | A72 OPTEE | | | +-------------------+ | | | | | + | | R5 DM FW | | + | +-------------------+ | + | | | | | | A72 SPL | | | +-------------------+ | | | | |
Signature · 1 line
2.17.1
Tero Kristo
maintainerPATCH v3 26/26 arm: dts: k3-j72xx: correct MCU timer1 frequency
In reply to Tero KristoMCU timer1 is used as the tick timer for MCU R5 SPL, and the clock-frequency defined in DT appears to be incorrect at the moment. Actual clock source for the timer is MCU_SYSCLK0 / 4 which is 250MHz.
Earlier setup of 25MHz went unnoticed, as there was a separate issue with omap-timer, which caused an error to the clock by a factor of 8 with j7 devices. This problem surfaced once the omap-timer was fixed.
--- arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi | 2 +- arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi +1 -1
@@ -33,7 +33,7 @@ compatible = "ti,omap5430-timer"; reg = <0x0 0x40400000 0x0 0x80>; ti,timer-alwon; - clock-frequency = <25000000>; + clock-frequency = <250000000>; u-boot,dm-spl; };
arch/arm/dts/k3-j721e-common-proc-board-u-boot.dtsi +1 -1
@@ -46,7 +46,7 @@ compatible = "ti,omap5430-timer"; reg = <0x0 0x40400000 0x0 0x80>; ti,timer-alwon; - clock-frequency = <25000000>; + clock-frequency = <250000000>; u-boot,dm-spl; };
Signature · 1 line
2.17.1
Tero Kristo
maintainerv3 cover J72xx: HSM rearch support series
In reply to Tero KristoUhm,
Sorry for CC:ing a stale email address with the patches, t-kristo at ti.com is no longer functional. Please drop that from any of the replies if you don't fancy spam replies from server.
-Tero
Quoted 29 lines · Tero Kristo
Hello,
Resurrecting this series; v2 [1] was sort of put on hold due to some org changes at TI. Sorry about the delay caused by this.
Anyways, v3 is mostly just a rebase of this series on top of 2021.07-rc1, and addition of some new data to support new boot modes for j721e and j7200. This series has been tested on top of Dave's DDR driver series [2]; on both J721e and J7200 boards.
Here are the details of changes compared to v2:
old-patch #2: removed (incorporated to Dave's DDR series now) patch #12 & #13: squashed in some fixes for clock rate handling patch #17: data additions
patch #21: squashed in a fix handle the boot headers properly patch #22: new patch
patch #26: new patch to address the timer issues uncovered by Dario's
fix to omap timer code (commit11326f379329: omap: timer: fix the rate setting)Rest of the changes are basically just rebases.
-Tero
[1] https://www.mail-archive.com/u-boot at lists.denx.de/msg390172.html
[2] https://www.mail-archive.com/u-boot at lists.denx.de/msg405657.html