From 68a90c3146e9ad8b113606fb76ada5f00784927e Mon Sep 17 00:00:00 2001 From: shengfei Xu Date: Tue, 31 Mar 2020 17:20:57 +0800 Subject: [PATCH 1/8] regulator: rk809/817: implement get the switch voltage If the switch is enabled, it's voltage is same as parent supply. Signed-off-by: shengfei Xu Change-Id: I8fb60bd5aa3bb0a47cac84982113663e2bf5941e --- drivers/power/regulator/rk8xx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/power/regulator/rk8xx.c b/drivers/power/regulator/rk8xx.c index 744b99ca30..73d5c09ba2 100644 --- a/drivers/power/regulator/rk8xx.c +++ b/drivers/power/regulator/rk8xx.c @@ -1135,6 +1135,23 @@ static int switch_get_suspend_enable(struct udevice *dev) */ static int switch_get_value(struct udevice *dev) { + const char *supply_name[] = { "vcc9-supply", "vcc8-supply", }; + struct rk8xx_priv *priv = dev_get_priv(dev->parent); + struct udevice *supply; + int id = dev->driver_data - 1; + + if (!switch_get_enable(dev)) + return 0; + + /* note: rk817 only contains switch0 */ + if ((priv->variant == RK809_ID) || (priv->variant == RK817_ID)) { + if (!uclass_get_device_by_phandle(UCLASS_REGULATOR, + dev_get_parent(dev), + supply_name[id], + &supply)) + return regulator_get_value(supply); + } + return 0; } From 479fbf72ee0660f74652da35a9f837b0e0ee06e8 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Thu, 2 Apr 2020 21:45:55 +0800 Subject: [PATCH 2/8] drivers: mmc: use pre-configure set by pre-loader or bootrom The MMC is initialized by pre-loader or bootrom, so it is no need to initialize it again. Open this config to skip some unused initialized process. Signed-off-by: Jason Zhu Change-Id: If00fc3ce7df4d15e71ecfd8f8717a59640c3b7a9 --- drivers/mmc/Kconfig | 7 ++++++ drivers/mmc/mmc.c | 56 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 689c184256..0b3c45af56 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -386,6 +386,13 @@ config GENERIC_ATMEL_MCI the SD Memory Card Specification V2.0, the SDIO V2.0 specification and CE-ATA V1.1. +config MMC_USE_PRE_CONFIG + bool "Enable to use pre-configure set by pre-loader or bootrom" + help + The MMC is initialized by pre-loader or bootrom, so it is no need to + initialize it again. Open this config to skip some unused initialized + process. + endif config TEGRA124_MMC_DISABLE_EXT_LOOPBACK diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 7bbce128e5..fdaf5a0ba3 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -386,6 +386,7 @@ static int mmc_go_idle(struct mmc *mmc) return 0; } +#ifndef CONFIG_MMC_USE_PRE_CONFIG static int sd_send_op_cond(struct mmc *mmc) { int timeout = 1000; @@ -453,6 +454,7 @@ static int sd_send_op_cond(struct mmc *mmc) return 0; } +#endif static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg) { @@ -475,6 +477,7 @@ static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg) return 0; } +#ifndef CONFIG_MMC_USE_PRE_CONFIG static int mmc_send_op_cond(struct mmc *mmc) { int err, i; @@ -495,7 +498,7 @@ static int mmc_send_op_cond(struct mmc *mmc) mmc->op_cond_pending = 1; return 0; } - +#endif static int mmc_complete_op_cond(struct mmc *mmc) { struct mmc_cmd cmd; @@ -1553,7 +1556,7 @@ static int mmc_startup(struct mmc *mmc) return err; } #endif - +#ifndef CONFIG_MMC_USE_PRE_CONFIG /* Put the Card in Identify Mode */ cmd.cmdidx = mmc_host_is_spi(mmc) ? MMC_CMD_SEND_CID : MMC_CMD_ALL_SEND_CID; /* cmd not supported in spi */ @@ -1585,7 +1588,7 @@ static int mmc_startup(struct mmc *mmc) if (IS_SD(mmc)) mmc->rca = (cmd.response[0] >> 16) & 0xffff; } - +#endif /* Get the Card-Specific Data */ cmd.cmdidx = MMC_CMD_SEND_CSD; cmd.resp_type = MMC_RSP_R2; @@ -1924,6 +1927,7 @@ static int mmc_startup(struct mmc *mmc) return 0; } +#ifndef CONFIG_MMC_USE_PRE_CONFIG static int mmc_send_if_cond(struct mmc *mmc) { struct mmc_cmd cmd; @@ -1946,6 +1950,7 @@ static int mmc_send_if_cond(struct mmc *mmc) return 0; } +#endif #if !CONFIG_IS_ENABLED(DM_MMC) /* board-specific MMC power initializations. */ @@ -1954,6 +1959,7 @@ __weak void board_mmc_power_init(void) } #endif +#ifndef CONFIG_MMC_USE_PRE_CONFIG static int mmc_power_init(struct mmc *mmc) { #if CONFIG_IS_ENABLED(DM_MMC) @@ -1983,7 +1989,50 @@ static int mmc_power_init(struct mmc *mmc) #endif return 0; } +#endif +#ifdef CONFIG_MMC_USE_PRE_CONFIG +static int mmc_select_card(struct mmc *mmc, int n) +{ + struct mmc_cmd cmd; + int err = 0; + memset(&cmd, 0, sizeof(struct mmc_cmd)); + if (!mmc_host_is_spi(mmc)) { /* cmd not supported in spi */ + mmc->rca = n; + cmd.cmdidx = MMC_CMD_SELECT_CARD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = mmc->rca << 16; + err = mmc_send_cmd(mmc, &cmd, NULL); + } + + return err; +} + +int mmc_start_init(struct mmc *mmc) +{ + /* + * We use the MMC config set by the bootrom. + * So it is no need to reset the eMMC device. + */ + mmc_set_bus_width(mmc, 8); + mmc_set_clock(mmc, 1); + mmc_set_timing(mmc, MMC_TIMING_LEGACY); + /* Send cmd7 to return stand-by state*/ + mmc_select_card(mmc, 0); + mmc->version = MMC_VERSION_UNKNOWN; + mmc->high_capacity = 1; + /* + * The RCA is set to 2 by rockchip bootrom, use the default + * value here. + */ +#ifdef CONFIG_ARCH_ROCKCHIP + mmc->rca = 2; +#else + mmc->rca = 1; +#endif + return 0; +} +#else int mmc_start_init(struct mmc *mmc) { bool no_card; @@ -2056,6 +2105,7 @@ int mmc_start_init(struct mmc *mmc) return err; } +#endif static int mmc_complete_init(struct mmc *mmc) { From 10530d82c2787a966b8c35a171bca4ba921bd61b Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 2 Apr 2020 10:50:59 +0800 Subject: [PATCH 3/8] rockchip: its: add "rollback-index" property This property is verified to support rollback index protect for verified-boot. Signed-off-by: Joseph Chen Change-Id: I54c5baaa275189ca96f18be66753b1292a395df6 --- arch/arm/mach-rockchip/kernel_arm.its | 2 +- arch/arm/mach-rockchip/kernel_arm64.its | 2 +- arch/arm/mach-rockchip/make_fit_atf.py | 1 + arch/arm/mach-rockchip/make_fit_optee.sh | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-rockchip/kernel_arm.its b/arch/arm/mach-rockchip/kernel_arm.its index e717ccea08..fb5f1ebb25 100644 --- a/arch/arm/mach-rockchip/kernel_arm.its +++ b/arch/arm/mach-rockchip/kernel_arm.its @@ -67,7 +67,7 @@ default = "conf@1"; conf@1 { description = "Boot Linux kernel with FDT blob"; - conf-version = <1>; + rollback-index = <0x0>; fdt = "fdt@1"; kernel = "kernel@1"; ramdisk = "ramdisk@1"; diff --git a/arch/arm/mach-rockchip/kernel_arm64.its b/arch/arm/mach-rockchip/kernel_arm64.its index 06ee7997d4..61ff1e5481 100644 --- a/arch/arm/mach-rockchip/kernel_arm64.its +++ b/arch/arm/mach-rockchip/kernel_arm64.its @@ -68,7 +68,7 @@ default = "conf@1"; conf@1 { description = "Boot Linux kernel with FDT blob"; - conf-version = <1>; + rollback-index = <0x0>; fdt = "fdt@1"; kernel = "kernel@1"; ramdisk = "ramdisk@1"; diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py index 9f54fcbb82..609c706909 100755 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ b/arch/arm/mach-rockchip/make_fit_atf.py @@ -103,6 +103,7 @@ def append_fdt_node(file, dtbs): def append_conf_section(file, cnt, dtname, atf_cnt): print >> file, '\t\tconfig@%d {' % cnt print >> file, '\t\t\tdescription = "Rockchip armv8 with ATF";' + print >> file, '\t\t\trollback-index = <0x0>;' print >> file, '\t\t\tfirmware = "atf@1";' print >> file, '\t\t\tloadables = "uboot@1",', for i in range(1, atf_cnt): diff --git a/arch/arm/mach-rockchip/make_fit_optee.sh b/arch/arm/mach-rockchip/make_fit_optee.sh index a0aa9251f9..9eb45e7e44 100755 --- a/arch/arm/mach-rockchip/make_fit_optee.sh +++ b/arch/arm/mach-rockchip/make_fit_optee.sh @@ -66,6 +66,7 @@ cat << EOF default = "conf@1"; conf@1 { description = "Rockchip armv7 with OP-TEE"; + rollback-index = <0x0>; firmware = "optee@1"; loadables = "uboot@1"; fdt = "fdt@1"; From 2dc02ea3807580f3ca6c3069f0c554f74e6247fd Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 2 Apr 2020 14:51:26 +0800 Subject: [PATCH 4/8] common: bootm: support host sign check for armv7 fit image including: fdt, u-boot, op-tee. Signed-off-by: Joseph Chen Change-Id: Ieb3dc15383f47626ef125b5d64e96b90a0a67cc6 --- common/bootm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/bootm.c b/common/bootm.c index afb01b9238..92f0b9f2f8 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -1033,6 +1033,7 @@ int bootm_host_load_images(const void *fit, int cfg_noffset, int is_spl) IH_TYPE_FLATDT, IH_TYPE_RAMDISK, }; +#ifdef CONFIG_SPL_ATF static uint8_t image_types_spl[] = { IH_TYPE_FLATDT, IH_TYPE_FIRMWARE, @@ -1040,6 +1041,13 @@ int bootm_host_load_images(const void *fit, int cfg_noffset, int is_spl) IH_TYPE_LOADABLE, IH_TYPE_LOADABLE, }; +#else + static uint8_t image_types_spl[] = { + IH_TYPE_FLATDT, + IH_TYPE_FIRMWARE, + IH_TYPE_LOADABLE, + }; +#endif int loadable_index = 0; int err = 0; int index; From d871c07160f200e0401b6494b594c7af06b34379 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 2 Apr 2020 17:05:28 +0800 Subject: [PATCH 5/8] common: image-fit: add some common APIs Signed-off-by: Joseph Chen Change-Id: I3df010d3b6a07efc7287779fe4a0a60ce9f1d2dc --- common/image-fit.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ include/image.h | 5 +++++ 2 files changed, 56 insertions(+) diff --git a/common/image-fit.c b/common/image-fit.c index 101b3f02df..29c38aa356 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -949,6 +949,30 @@ int fit_image_get_data_size(const void *fit, int noffset, int *data_size) return 0; } +/** + * Get 'rollback-index' property from a given image node. + * + * @fit: pointer to the FIT image header + * @noffset: component image node offset + * @index: holds the rollback-index property + * + * returns: + * 0, on success + * -ENOENT if the property could not be found + */ +int fit_image_get_rollback_index(const void *fit, int noffset, uint32_t *index) +{ + const fdt32_t *val; + + val = fdt_getprop(fit, noffset, FIT_ROLLBACK_PROP, NULL); + if (!val) + return -ENOENT; + + *index = fdt32_to_cpu(*val); + + return 0; +} + /** * fit_image_hash_get_algo - get hash algorithm name * @fit: pointer to the FIT format image header @@ -1070,6 +1094,33 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) return 0; } +int fit_get_image_defconf_node(const void *fit, int *images_noffset, int *def_noffset) +{ + int images_node, confs_node, defconf_node; + const char *def_name; + + images_node = fdt_path_offset(fit, FIT_IMAGES_PATH); + if (images_node < 0) + return images_node; + + confs_node = fdt_path_offset(fit, FIT_CONFS_PATH); + if (confs_node < 0) + return confs_node; + + def_name = fdt_getprop(fit, confs_node, FIT_DEFAULT_PROP, NULL); + if (!def_name) + return -ENOENT; + + defconf_node = fdt_subnode_offset(fit, confs_node, def_name); + if (defconf_node < 0) + return defconf_node; + + *images_noffset = images_node; + *def_noffset = defconf_node; + + return 0; +} + /** * calculate_hash - calculate and return hash for provided input data * @data: pointer to the input data diff --git a/include/image.h b/include/image.h index 4d877b84d1..c74b57c56a 100644 --- a/include/image.h +++ b/include/image.h @@ -921,6 +921,7 @@ int bootz_setup(ulong image, ulong *start, ulong *end); #define FIT_COMP_PROP "compression" #define FIT_ENTRY_PROP "entry" #define FIT_LOAD_PROP "load" +#define FIT_ROLLBACK_PROP "rollback-index" /* configuration node */ #define FIT_KERNEL_PROP "kernel" @@ -1005,6 +1006,7 @@ int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset); int fit_image_get_data_position(const void *fit, int noffset, int *data_position); int fit_image_get_data_size(const void *fit, int noffset, int *data_size); +int fit_image_get_rollback_index(const void *fit, int noffset, uint32_t *index); int fit_image_hash_get_algo(const void *fit, int noffset, char **algo); int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value, @@ -1012,6 +1014,9 @@ int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value, int fit_set_timestamp(void *fit, int noffset, time_t timestamp); +int fit_get_image_defconf_node(const void *fit, + int *images_noffset, int *def_noffset); + /** * fit_add_verification_data() - add verification data to FIT image nodes * From 767fd95d066e21d7025a6994a8408177528569a8 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 2 Apr 2020 17:06:18 +0800 Subject: [PATCH 6/8] rockchip: fit: remove fit_get_image_defconf_node() It is added in image-fit.c as a common function. Signed-off-by: Joseph Chen Change-Id: I105e0a7cacde226da1bb787ba1f4f320d6daa55d --- arch/arm/mach-rockchip/fit.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/arch/arm/mach-rockchip/fit.c b/arch/arm/mach-rockchip/fit.c index 1e442df05c..d11f94135d 100644 --- a/arch/arm/mach-rockchip/fit.c +++ b/arch/arm/mach-rockchip/fit.c @@ -55,33 +55,6 @@ static int fit_is_required(void *fit, const void *sig_blob) return 0; } -static int fit_get_image_defconf_node(void *fit, int *images, int *defconf) -{ - int images_node, confs_node, defconf_node; - const char *def_name; - - images_node = fdt_path_offset(fit, FIT_IMAGES_PATH); - if (images_node < 0) - return images_node; - - confs_node = fdt_path_offset(fit, FIT_CONFS_PATH); - if (confs_node < 0) - return confs_node; - - def_name = fdt_getprop(fit, confs_node, FIT_DEFAULT_PROP, NULL); - if (!def_name) - return -ENOENT; - - defconf_node = fdt_subnode_offset(fit, confs_node, def_name); - if (defconf_node < 0) - return defconf_node; - - *images = images_node; - *defconf = defconf_node; - - return 0; -} - int fit_fixup_load_entry(void *fit, int images, int defconf, char *name, ulong *load, ulong new_addr) { From 6f3e9d5cd7d8874db71edae35869b9e8822a2327 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Thu, 2 Apr 2020 15:08:03 +0800 Subject: [PATCH 7/8] rockchip: fit: rename "required" to "verified-boot" "verified-boot" is more clearly for developers. Signed-off-by: Joseph Chen Change-Id: Ib8a87af18480f2d5e765b9007eb5f8473ee424fb --- arch/arm/mach-rockchip/fit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-rockchip/fit.c b/arch/arm/mach-rockchip/fit.c index d11f94135d..752b2a7217 100644 --- a/arch/arm/mach-rockchip/fit.c +++ b/arch/arm/mach-rockchip/fit.c @@ -466,7 +466,7 @@ void *fit_image_load_bootables(ulong *size) static void verbose_msg(void *fit, int defconf) { - FIT_I("%ssigned, %srequired\n", + FIT_I("%ssigned, %sverified-boot\n", fit_is_signed(fit, gd_fdt_blob()) ? "" : "no ", fit_is_required(fit, gd_fdt_blob()) ? "" : "no "); From b4e157ffa2b4dbaaac0181bea4c99b11563295d3 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Fri, 3 Apr 2020 12:05:36 +0800 Subject: [PATCH 8/8] make.sh: add version for spl loader before: rk3399_loader_v1.24.124.bin => rk3399_loader_spl.bin after: rk3399_loader_v1.24.124.bin => rk3399_spl_loader_v1.24.124.bin Signed-off-by: Joseph Chen Change-Id: If5bcc02504760d178557d8db78889074fcad0427 --- make.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/make.sh b/make.sh index 7e9232597e..586a7bc041 100755 --- a/make.sh +++ b/make.sh @@ -547,11 +547,10 @@ pack_spl_loader_image() rm ${RKBIN}/.temp -rf cd - ls *_loader_*.bin >/dev/null 2>&1 && rm *_loader_*.bin - - RKCHIP_LOWCASE=`echo ${RKCHIP} |tr '[A-Z]' '[a-z]'` - mv ${RKBIN}/*_loader_*.bin ./${RKCHIP_LOWCASE}_loader_spl.bin + mv ${RKBIN}/*_loader_*.bin ./ + rename 's/loader_/spl_loader_/' *_loader_*.bin echo "pack loader(${label}) okay! Input: ${ini}" - ls ./${RKCHIP_LOWCASE}_loader_spl.bin + ls ./*_loader_*.bin } pack_loader_image()