From 1610b68ea305cf00a8570dcb273ea585c4c4f8df Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Sat, 12 Mar 2022 08:11:10 +0100 Subject: [PATCH 1/6] power: Rename CONFIG_POWER_TPS65217 with CONFIG_PMIC_TPS65217 Up till now the CONFIG_POWER_TPS65217 has been defined in several header files for am335x SoC. This patch renames it to CONFIG_PMIC_TPS65217, which better reflects the role of this IC circuit. Moreover, new CONFIG_PMIC_TPS65217 has been introduced in Kconfig to be used with boards, which both support DM_PMIC and DM_I2C. Signed-off-by: Lukasz Majewski Reviewed-by: Jaehoon Chung [trini: Migrate all other platforms as well] Signed-off-by: Tom Rini --- configs/am335x_boneblack_vboot_defconfig | 3 +++ configs/am335x_evm_defconfig | 3 +++ configs/am335x_evm_spiboot_defconfig | 3 +++ configs/am335x_guardian_defconfig | 1 + configs/am335x_hs_evm_defconfig | 3 +++ configs/am335x_hs_evm_uart_defconfig | 3 +++ configs/am335x_shc_defconfig | 1 + configs/am335x_shc_ict_defconfig | 1 + configs/am335x_shc_netboot_defconfig | 1 + configs/am335x_shc_sdboot_defconfig | 1 + configs/am335x_sl50_defconfig | 1 + configs/brppt1_mmc_defconfig | 3 +++ configs/brppt1_nand_defconfig | 3 +++ configs/brppt1_spi_defconfig | 3 +++ configs/brsmarc1_defconfig | 1 + configs/brxre1_defconfig | 1 + configs/chiliboard_defconfig | 1 + drivers/power/pmic/Kconfig | 8 ++++++++ drivers/power/pmic/Makefile | 2 +- include/configs/am335x_evm.h | 1 - include/configs/am335x_guardian.h | 3 --- include/configs/am335x_shc.h | 3 --- include/configs/am335x_sl50.h | 1 - include/configs/brppt1.h | 2 -- include/configs/bur_am335x_common.h | 1 - include/configs/chiliboard.h | 3 --- scripts/config_whitelist.txt | 1 - 27 files changed, 42 insertions(+), 16 deletions(-) diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index 3e1296916cb..dc4693d40bf 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -65,6 +65,9 @@ CONFIG_DM_ETH=y CONFIG_PHY_GIGE=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig index fa97ec12d82..30577a6fce4 100644 --- a/configs/am335x_evm_defconfig +++ b/configs/am335x_evm_defconfig @@ -88,6 +88,9 @@ CONFIG_DM_ETH=y CONFIG_PHY_GIGE=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_evm_spiboot_defconfig b/configs/am335x_evm_spiboot_defconfig index abcc3e6e79f..f1b9d6c3ad8 100644 --- a/configs/am335x_evm_spiboot_defconfig +++ b/configs/am335x_evm_spiboot_defconfig @@ -79,6 +79,9 @@ CONFIG_PHY_SMSC=y CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_guardian_defconfig b/configs/am335x_guardian_defconfig index 28ebe00fd21..60e428d2a1e 100644 --- a/configs/am335x_guardian_defconfig +++ b/configs/am335x_guardian_defconfig @@ -110,6 +110,7 @@ CONFIG_PHY=y CONFIG_NOP_PHY=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_hs_evm_defconfig b/configs/am335x_hs_evm_defconfig index b6fd86fa167..ca425969469 100644 --- a/configs/am335x_hs_evm_defconfig +++ b/configs/am335x_hs_evm_defconfig @@ -72,6 +72,9 @@ CONFIG_PHY_SMSC=y CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_hs_evm_uart_defconfig b/configs/am335x_hs_evm_uart_defconfig index 15483176caa..c8df89bf6d5 100644 --- a/configs/am335x_hs_evm_uart_defconfig +++ b/configs/am335x_hs_evm_uart_defconfig @@ -74,6 +74,9 @@ CONFIG_PHY_SMSC=y CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/am335x_shc_defconfig b/configs/am335x_shc_defconfig index 5953193bc24..65cdc2acf56 100644 --- a/configs/am335x_shc_defconfig +++ b/configs/am335x_shc_defconfig @@ -70,4 +70,5 @@ CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_PMIC_TPS65217=y CONFIG_LZO=y diff --git a/configs/am335x_shc_ict_defconfig b/configs/am335x_shc_ict_defconfig index 00442d8ca8b..a59ebf4a4ed 100644 --- a/configs/am335x_shc_ict_defconfig +++ b/configs/am335x_shc_ict_defconfig @@ -68,4 +68,5 @@ CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_PMIC_TPS65217=y CONFIG_LZO=y diff --git a/configs/am335x_shc_netboot_defconfig b/configs/am335x_shc_netboot_defconfig index 37899df596f..3c291cfe6d6 100644 --- a/configs/am335x_shc_netboot_defconfig +++ b/configs/am335x_shc_netboot_defconfig @@ -71,4 +71,5 @@ CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_PMIC_TPS65217=y CONFIG_LZO=y diff --git a/configs/am335x_shc_sdboot_defconfig b/configs/am335x_shc_sdboot_defconfig index c33c94f8503..8c4f14d764e 100644 --- a/configs/am335x_shc_sdboot_defconfig +++ b/configs/am335x_shc_sdboot_defconfig @@ -70,4 +70,5 @@ CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y CONFIG_PINCTRL=y CONFIG_PINCTRL_SINGLE=y +CONFIG_PMIC_TPS65217=y CONFIG_LZO=y diff --git a/configs/am335x_sl50_defconfig b/configs/am335x_sl50_defconfig index c71741c7069..41017de2f9c 100644 --- a/configs/am335x_sl50_defconfig +++ b/configs/am335x_sl50_defconfig @@ -68,6 +68,7 @@ CONFIG_MMC_OMAP_HS=y CONFIG_PHY_SMSC=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/configs/brppt1_mmc_defconfig b/configs/brppt1_mmc_defconfig index ac0fbd5c3fa..1c72c79c3d1 100644 --- a/configs/brppt1_mmc_defconfig +++ b/configs/brppt1_mmc_defconfig @@ -91,6 +91,9 @@ CONFIG_MMC_OMAP_HS=y CONFIG_PHY_NATSEMI=y CONFIG_DM_ETH=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_DM_SERIAL=y CONFIG_USB=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/brppt1_nand_defconfig b/configs/brppt1_nand_defconfig index 9df5121964d..267cdf41b6e 100644 --- a/configs/brppt1_nand_defconfig +++ b/configs/brppt1_nand_defconfig @@ -100,6 +100,9 @@ CONFIG_SYS_NAND_U_BOOT_OFFS=0x80000 CONFIG_PHY_NATSEMI=y CONFIG_DM_ETH=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_DM_SERIAL=y CONFIG_USB=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/brppt1_spi_defconfig b/configs/brppt1_spi_defconfig index 11d7d7bcde2..e39294f6bff 100644 --- a/configs/brppt1_spi_defconfig +++ b/configs/brppt1_spi_defconfig @@ -104,6 +104,9 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_PHY_NATSEMI=y CONFIG_DM_ETH=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_DM_PMIC=y +# CONFIG_SPL_DM_PMIC is not set +CONFIG_PMIC_TPS65217=y CONFIG_DM_SERIAL=y CONFIG_SPI=y CONFIG_DM_SPI=y diff --git a/configs/brsmarc1_defconfig b/configs/brsmarc1_defconfig index 771a42f6388..8e8f471a704 100644 --- a/configs/brsmarc1_defconfig +++ b/configs/brsmarc1_defconfig @@ -104,6 +104,7 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_PHY_NATSEMI=y CONFIG_DM_ETH=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_PMIC_TPS65217=y CONFIG_DM_SERIAL=y CONFIG_SPI=y CONFIG_DM_SPI=y diff --git a/configs/brxre1_defconfig b/configs/brxre1_defconfig index 35b2b6545e6..e1c81d1cdfd 100644 --- a/configs/brxre1_defconfig +++ b/configs/brxre1_defconfig @@ -87,6 +87,7 @@ CONFIG_MISC=y CONFIG_MMC_OMAP_HS=y CONFIG_DM_ETH=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_PMIC_TPS65217=y CONFIG_DM_SERIAL=y CONFIG_USB=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/chiliboard_defconfig b/configs/chiliboard_defconfig index ae101da9c2f..1b03d836944 100644 --- a/configs/chiliboard_defconfig +++ b/configs/chiliboard_defconfig @@ -66,6 +66,7 @@ CONFIG_PHY_SMSC=y CONFIG_DM_ETH=y CONFIG_MII=y CONFIG_DRIVER_TI_CPSW=y +CONFIG_PMIC_TPS65217=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_OMAP3_SPI=y diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index ce0adb18a44..953c92e2128 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -369,6 +369,14 @@ config PMIC_TPS65941 endif +config PMIC_TPS65217 + bool "Enable driver for Texas Instruments TPS65217 PMIC" + ---help--- + The TPS65217 is a PMIC containing several LDOs, DC to DC convertors, + FETs and a battery charger. This driver provides register access + only, and you can enable the regulator/charger drivers separately if + required. + config POWER_MC34VR500 bool "Enable driver for Freescale MC34VR500 PMIC" depends on !DM_PMIC diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 401cde32cf1..584d6e0e78e 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -36,7 +36,7 @@ obj-$(CONFIG_POWER_MUIC_MAX8997) += muic_max8997.o obj-$(CONFIG_POWER_PCA9450) += pmic_pca9450.o obj-$(CONFIG_POWER_PFUZE100) += pmic_pfuze100.o obj-$(CONFIG_POWER_PFUZE3000) += pmic_pfuze3000.o -obj-$(CONFIG_POWER_TPS65217) += pmic_tps65217.o +obj-$(CONFIG_PMIC_TPS65217) += pmic_tps65217.o obj-$(CONFIG_POWER_TPS65218) += pmic_tps62362.o obj-$(CONFIG_POWER_TPS65218) += pmic_tps65218.o obj-$(CONFIG_POWER_TPS65910) += pmic_tps65910.o diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 748cbe3c7d7..cbb7b91139d 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -166,7 +166,6 @@ #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ /* PMIC support */ -#define CONFIG_POWER_TPS65217 #define CONFIG_POWER_TPS65910 /* SPL */ diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h index 608a22db444..b92703205cd 100644 --- a/include/configs/am335x_guardian.h +++ b/include/configs/am335x_guardian.h @@ -94,9 +94,6 @@ #define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ -/* PMIC support */ -#define CONFIG_POWER_TPS65217 - /* Bootcount using the RTC block */ #define CONFIG_SYS_BOOTCOUNT_LE diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h index 4c8df57bdf0..5964ccc74c2 100644 --- a/include/configs/am335x_shc.h +++ b/include/configs/am335x_shc.h @@ -145,7 +145,4 @@ #define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ -/* PMIC support */ -#define CONFIG_POWER_TPS65217 - #endif /* ! __CONFIG_AM335X_SHC_H */ diff --git a/include/configs/am335x_sl50.h b/include/configs/am335x_sl50.h index 0da98975adf..a57d551bcf1 100644 --- a/include/configs/am335x_sl50.h +++ b/include/configs/am335x_sl50.h @@ -50,7 +50,6 @@ #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ /* PMIC support */ -#define CONFIG_POWER_TPS65217 #define CONFIG_POWER_TPS65910 /* SPL */ diff --git a/include/configs/brppt1.h b/include/configs/brppt1.h index d5458edbdb6..769b3f073ac 100644 --- a/include/configs/brppt1.h +++ b/include/configs/brppt1.h @@ -22,8 +22,6 @@ #define V_OSCK 26000000 /* Clock output from T2 */ #define V_SCLK (V_OSCK) -#define CONFIG_POWER_TPS65217 - /* * When we have NAND flash we expect to be making use of mtdparts, * both for ease of use in U-Boot and for passing information on to diff --git a/include/configs/bur_am335x_common.h b/include/configs/bur_am335x_common.h index 9b2e8b5c6eb..5fc8ce622b1 100644 --- a/include/configs/bur_am335x_common.h +++ b/include/configs/bur_am335x_common.h @@ -26,7 +26,6 @@ /* Timer information */ #define CONFIG_SYS_PTV 2 /* Divisor: 2^(PTV+1) => 8 */ #define CONFIG_SYS_TIMERBASE 0x48040000 /* Use Timer2 */ -#define CONFIG_POWER_TPS65217 #include diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h index ad1cd864c85..82acda595f0 100644 --- a/include/configs/chiliboard.h +++ b/include/configs/chiliboard.h @@ -106,9 +106,6 @@ #define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ -/* PMIC support */ -#define CONFIG_POWER_TPS65217 - /* SPL */ /* Bootcount using the RTC block */ #define CONFIG_SYS_BOOTCOUNT_BE diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index e4c5f743c94..12208c7a2f8 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -549,7 +549,6 @@ CONFIG_POWER_PFUZE3000_I2C_ADDR CONFIG_POWER_SPI CONFIG_POWER_TPS62362 CONFIG_POWER_TPS65090_EC -CONFIG_POWER_TPS65217 CONFIG_POWER_TPS65218 CONFIG_POWER_TPS65910 CONFIG_PPC_CLUSTER_START From e8cb4e78c7dcd51f5ef92f465919ce19f8a0356f Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Sat, 12 Mar 2022 08:11:11 +0100 Subject: [PATCH 2/6] power: pmic: Provide DM_PMIC support for tps65217 driver The tps65217 PMIC driver is used with am335x SoC based designs. It is used in the SPL (MLO) as well, so the DM conversion only is for u-boot proper. This driver only allows simple reading/writing/dumping of the content of its registers and requires the DM_I2C for proper operation. Signed-off-by: Lukasz Majewski Reviewed-by: Jaehoon Chung --- drivers/power/pmic/pmic_tps65217.c | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/drivers/power/pmic/pmic_tps65217.c b/drivers/power/pmic/pmic_tps65217.c index c7f532df4d5..ccbf2235933 100644 --- a/drivers/power/pmic/pmic_tps65217.c +++ b/drivers/power/pmic/pmic_tps65217.c @@ -6,8 +6,13 @@ #include #include +#include +#include +#include +#include #include +#if !CONFIG_IS_ENABLED(DM_PMIC) struct udevice *tps65217_dev __section(".data") = NULL; /** @@ -148,3 +153,80 @@ int power_tps65217_init(unsigned char bus) #endif return 0; } +#else /* CONFIG_IS_ENABLED(DM_PMIC) */ +static const struct pmic_child_info pmic_children_info[] = { + { .prefix = "ldo", .driver = "tps65217_ldo" }, + { }, +}; + +static int tps65217_reg_count(struct udevice *dev) +{ + return TPS65217_PMIC_NUM_OF_REGS; +} + +static int tps65217_write(struct udevice *dev, uint reg, const uint8_t *buff, + int len) +{ + if (dm_i2c_write(dev, reg, buff, len)) { + pr_err("write error to device: %p register: %#x!\n", dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65217_read(struct udevice *dev, uint reg, uint8_t *buff, int len) +{ + int ret; + + ret = dm_i2c_read(dev, reg, buff, len); + if (ret) { + pr_err("read error %d from device: %p register: %#x!\n", ret, + dev, reg); + return -EIO; + } + + return 0; +} + +static int tps65217_bind(struct udevice *dev) +{ + ofnode regulators_node; + int children; + + regulators_node = dev_read_subnode(dev, "regulators"); + if (!ofnode_valid(regulators_node)) { + debug("%s: %s regulators subnode not found!\n", __func__, + dev->name); + return -ENXIO; + } + + debug("%s: '%s' - found regulators subnode\n", __func__, dev->name); + + children = pmic_bind_children(dev, regulators_node, pmic_children_info); + if (!children) + debug("%s: %s - no child found\n", __func__, dev->name); + + /* Always return success for this device */ + return 0; +} + +static struct dm_pmic_ops tps65217_ops = { + .reg_count = tps65217_reg_count, + .read = tps65217_read, + .write = tps65217_write, +}; + +static const struct udevice_id tps65217_ids[] = { + { .compatible = "ti,tps65217" }, + { } +}; + +U_BOOT_DRIVER(pmic_tps65217) = { + .name = "tps65217 pmic", + .id = UCLASS_PMIC, + .of_match = tps65217_ids, + .bind = tps65217_bind, + .ops = &tps65217_ops, +}; +#endif From 21d3e3d107f3b60abe3b10f50930e22330d7e2d3 Mon Sep 17 00:00:00 2001 From: Du Huanpeng Date: Thu, 31 Mar 2022 02:41:42 +0800 Subject: [PATCH 3/6] Makefile: add endian link flag to u-boot-elf.o fix compile error when using a little-endian to build with configs: sfr_nb4-ser_ram_defconfig comtrend_wap5813n_ram_defconfig comtrend_ar5387un_ram_defconfig comtrend_ct5361_ram_defconfig comtrend_vr3032u_ram_defconfig comtrend_ar5315u_ram_defconfig huawei_hg556a_ram_defconfig netgear_dgnd3700v2_ram_defconfig Signed-off-by: Du Huanpeng --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 81349a76948..4b347d3603a 100644 --- a/Makefile +++ b/Makefile @@ -1708,6 +1708,7 @@ u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE quiet_cmd_u-boot-elf ?= LD $@ cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ + $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \ -T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) u-boot.elf: u-boot.bin u-boot-elf.lds From 3548903fc8eafa469f57e3dd11cf0046f2034699 Mon Sep 17 00:00:00 2001 From: Yi Liu Date: Wed, 30 Mar 2022 18:05:59 +0800 Subject: [PATCH 4/6] tools: mkimage: No need to verify_header for header_v2 rockchip header_v2 do not have a spl_hdr, so remove the verify. Signed-off-by: Yi Liu Signed-off-by: Kever Yang --- tools/rkcommon.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 29f2676c19d..ff62c75caad 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -450,6 +450,10 @@ int rkcommon_verify_header(unsigned char *buf, int size, struct spl_info *img_spl_info, *spl_info; int ret; + /* spl_hdr is abandon on header_v2 */ + if ((*(uint32_t *)buf) == RK_MAGIC_V2) + return 0; + ret = rkcommon_parse_header(buf, &header0, &img_spl_info); /* If this is the (unimplemented) RC4 case, then rewrite the result */ From d3b1ca21e253547599a28002c1ea51348cb75c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Fri, 14 Jan 2022 18:34:43 +0100 Subject: [PATCH 5/6] tools: mkimage: Call verify_header after writing image to disk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If image backend provides verify_header callback then call it after writing image to disk. This ensures that written image is correct. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese Reviewed-by: Simon Glass --- tools/mkimage.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/mkimage.c b/tools/mkimage.c index b46216fdc59..be58e565463 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -341,6 +341,44 @@ static void process_args(int argc, char **argv) usage("Missing output filename"); } +static void verify_image(const struct image_type_params *tparams) +{ + struct stat sbuf; + void *ptr; + int ifd; + + ifd = open(params.imagefile, O_RDONLY | O_BINARY); + if (ifd < 0) { + fprintf(stderr, "%s: Can't open %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); + exit(EXIT_FAILURE); + } + + if (fstat(ifd, &sbuf) < 0) { + fprintf(stderr, "%s: Can't stat %s: %s\n", + params.cmdname, params.imagefile, strerror(errno)); + exit(EXIT_FAILURE); + } + params.file_size = sbuf.st_size; + + ptr = mmap(0, params.file_size, PROT_READ, MAP_SHARED, ifd, 0); + if (ptr == MAP_FAILED) { + fprintf(stderr, "%s: Can't map %s: %s\n", + params.cmdname, params.imagefile, strerror(errno)); + exit(EXIT_FAILURE); + } + + if (tparams->verify_header((unsigned char *)ptr, params.file_size, ¶ms) != 0) { + fprintf(stderr, "%s: Failed to verify header of %s\n", + params.cmdname, params.imagefile); + exit(EXIT_FAILURE); + } + + (void)munmap(ptr, params.file_size); + (void)close(ifd); +} + int main(int argc, char **argv) { int ifd = -1; @@ -703,6 +741,9 @@ int main(int argc, char **argv) exit (EXIT_FAILURE); } + if (tparams->verify_header) + verify_image(tparams); + exit (EXIT_SUCCESS); } From d23f29084018a3aa5ca6399a08c12eb7617ffa55 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 24 Mar 2022 16:22:32 +0100 Subject: [PATCH 6/6] dm: fix function documentation in include/dm/ofnode.h We use Sphinx style comments to describe functions. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng --- include/dm/ofnode.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 744dffe0a2d..6a996d95217 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -900,10 +900,10 @@ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device); * Look at the compatible property of a device node that represents a eth phy * device and extract phy vendor id and device id from it. * - * @param node node to examine - * @param vendor vendor id of the eth phy device - * @param device device id of the eth phy device - * @return 0 if ok, negative on error + * @node: node to examine + * @vendor: vendor id of the eth phy device + * @device: device id of the eth phy device + * Return: 0 if ok, negative on error */ int ofnode_read_eth_phy_id(ofnode node, u16 *vendor, u16 *device);