[PATCH] mailmap: Update e-mail for Jernej Skrabec
Old address doesn't exist anymore. Map it to new one. Signed-off-by: Jernej Skrabec --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index b76f02283c57..3d15a09d1c2d 100644 --- a/.mailmap +++ b/.mailmap @@ -29,6 +29,7 @@ Jagan Teki Jagan Teki Jagan Teki Jagan Teki +Jernej Skrabec Igor Opaniuk Igor Opaniuk Markus Klotzbuecher -- 2.33.0
[u-boot-test-hooks PATCH] travis-ci: Add SiFive Unleashed QEMU targets
Add support for testing sifive_unleashed_defconfig via QEMU. QEMU supports booting exact the same images as used on the real hardware out of the box, that U-Boot SPL loads U-Boot proper from either an SD card or the SPI NOR flash, hence we can easily set up CI to cover these 2 boot flows of SiFive Unleashed board. Signed-off-by: Bin Meng --- bin/travis-ci/conf.sifive_unleashed_sdcard_qemu | 11 +++ bin/travis-ci/conf.sifive_unleashed_spi-nor_qemu | 11 +++ .../u_boot_boardenv_sifive_unleashed_sdcard_qemu.py | 10 ++ .../u_boot_boardenv_sifive_unleashed_spi-nor_qemu.py | 10 ++ 4 files changed, 42 insertions(+) create mode 100644 bin/travis-ci/conf.sifive_unleashed_sdcard_qemu create mode 100644 bin/travis-ci/conf.sifive_unleashed_spi-nor_qemu create mode 100644 py/travis-ci/u_boot_boardenv_sifive_unleashed_sdcard_qemu.py create mode 100644 py/travis-ci/u_boot_boardenv_sifive_unleashed_spi-nor_qemu.py diff --git a/bin/travis-ci/conf.sifive_unleashed_sdcard_qemu b/bin/travis-ci/conf.sifive_unleashed_sdcard_qemu new file mode 100644 index 000..f3c3da1 --- /dev/null +++ b/bin/travis-ci/conf.sifive_unleashed_sdcard_qemu @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +# +# Copyright (c) 2021 Bin Meng + +console_impl=qemu +qemu_machine="sifive_u,msel=11" +qemu_binary="qemu-system-riscv64" +qemu_extra_args="-smp 5 -m 8G -nographic -nic user,tftp=${UBOOT_TRAVIS_BUILD_DIR}" +qemu_kernel_args="-bios ${U_BOOT_BUILD_DIR}/spl/u-boot-spl.bin -drive file=${U_BOOT_BUILD_DIR}/sdcard.img,if=sd" +reset_impl=none +flash_impl=none diff --git a/bin/travis-ci/conf.sifive_unleashed_spi-nor_qemu b/bin/travis-ci/conf.sifive_unleashed_spi-nor_qemu new file mode 100644 index 000..e28bfc4 --- /dev/null +++ b/bin/travis-ci/conf.sifive_unleashed_spi-nor_qemu @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +# +# Copyright (c) 2021 Bin Meng + +console_impl=qemu +qemu_machine="sifive_u,msel=6" +qemu_binary="qemu-system-riscv64" +qemu_extra_args="-smp 5 -m 8G -nographic -nic user,tftp=${UBOOT_TRAVIS_BUILD_DIR}" +qemu_kernel_args="-bios ${U_BOOT_BUILD_DIR}/spl/u-boot-spl.bin -drive file=${U_BOOT_BUILD_DIR}/spi-nor.img,if=mtd" +reset_impl=none +flash_impl=none diff --git a/py/travis-ci/u_boot_boardenv_sifive_unleashed_sdcard_qemu.py b/py/travis-ci/u_boot_boardenv_sifive_unleashed_sdcard_qemu.py new file mode 100644 index 000..a86e0bd --- /dev/null +++ b/py/travis-ci/u_boot_boardenv_sifive_unleashed_sdcard_qemu.py @@ -0,0 +1,10 @@ +import os +import travis_tftp + +env__net_dhcp_server = True +env__net_tftp_readable_file = travis_tftp.file2env('u-boot') +env__efi_loader_helloworld_file = travis_tftp.file2env('lib/efi_loader/helloworld.efi') +env__efi_loader_grub_file = travis_tftp.file2env('grub_riscv64.efi') +env__efi_fit_tftp_file = { +"dn" : os.environ['UBOOT_TRAVIS_BUILD_DIR'], +} diff --git a/py/travis-ci/u_boot_boardenv_sifive_unleashed_spi-nor_qemu.py b/py/travis-ci/u_boot_boardenv_sifive_unleashed_spi-nor_qemu.py new file mode 100644 index 000..a86e0bd --- /dev/null +++ b/py/travis-ci/u_boot_boardenv_sifive_unleashed_spi-nor_qemu.py @@ -0,0 +1,10 @@ +import os +import travis_tftp + +env__net_dhcp_server = True +env__net_tftp_readable_file = travis_tftp.file2env('u-boot') +env__efi_loader_helloworld_file = travis_tftp.file2env('lib/efi_loader/helloworld.efi') +env__efi_loader_grub_file = travis_tftp.file2env('grub_riscv64.efi') +env__efi_fit_tftp_file = { +"dn" : os.environ['UBOOT_TRAVIS_BUILD_DIR'], +} -- 2.25.1
[PATCH v2 4/4] sunxi: Support building a SPL as a TOC0 image
Now that mkimage can generate TOC0 images, and the SPL can interpret them, hook up the build infrastructure so the user can choose which image type to build. Signed-off-by: Samuel Holland --- Changes in v2: - Rebase on top of Icenowy's RISC-V support series - Rename Kconfig symbols to include the full image type name arch/arm/mach-sunxi/Kconfig | 2 ++ board/sunxi/Kconfig | 24 scripts/Makefile.spl| 5 - 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 board/sunxi/Kconfig diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 49f94f095c1..b0191d00808 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -1091,6 +1091,8 @@ config BLUETOOTH_DT_DEVICE_FIXUP The used address is "bdaddr" if set, and "ethaddr" with the LSB flipped elsewise. +source "board/sunxi/Kconfig" + endif config CHIP_DIP_SCAN diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig new file mode 100644 index 000..084a8b0c6ca --- /dev/null +++ b/board/sunxi/Kconfig @@ -0,0 +1,24 @@ +choice + prompt "SPL Image Type" + default SPL_IMAGE_TYPE_SUNXI_EGON + +config SPL_IMAGE_TYPE_SUNXI_EGON + bool "eGON (normal)" + help + Select this option to embed the SPL binary in an eGON.BT0 image, + which is compatible with the normal boot ROM (NBROM). + + This is usually the correct option to choose. + +config SPL_IMAGE_TYPE_SUNXI_TOC0 + bool "TOC0 (secure)" + help + Select this option to embed the SPL binary in a TOC0 image, + which is compatible with the secure boot ROM (SBROM). + +endchoice + +config SPL_IMAGE_TYPE + string + default "sunxi_egon" if SPL_IMAGE_TYPE_SUNXI_EGON + default "sunxi_toc0" if SPL_IMAGE_TYPE_SUNXI_TOC0 diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index c90d692c500..53e3ef164c6 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -414,7 +414,10 @@ endif $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE $(call if_changed,mkimage) -MKIMAGEFLAGS_sunxi-spl.bin = -A $(ARCH) -T sunxi_egon \ +MKIMAGEFLAGS_sunxi-spl.bin = \ + -A $(ARCH) \ + -T $(CONFIG_SPL_IMAGE_TYPE) \ + -a $(CONFIG_SPL_TEXT_BASE) \ -n $(CONFIG_DEFAULT_DEVICE_TREE) OBJCOPYFLAGS_u-boot-spl-dtb.hex := -I binary -O ihex --change-address=$(CONFIG_SPL_TEXT_BASE) -- 2.31.1
[PATCH v2 3/4] sunxi: Support SPL in both eGON and TOC0 images
SPL uses the image header to detect the boot device and to find the offset of the next U-Boot stage. Since this information is stored differently in the eGON and TOC0 image headers, add code to find the correct value based on the image type currently in use. Signed-off-by: Samuel Holland --- Changes in v2: - Moved SPL header signature checks out of sunxi_image.h - Refactored SPL header signature checks to use fewer casts arch/arm/include/asm/arch-sunxi/spl.h | 2 -- arch/arm/mach-sunxi/board.c | 50 +++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 58cdf806d9a..157b11e4897 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -19,8 +19,6 @@ #define SUNXI_BOOTED_FROM_MMC0_HIGH0x10 #define SUNXI_BOOTED_FROM_MMC2_HIGH0x12 -#define is_boot0_magic(addr) (memcmp((void *)(addr), BOOT0_MAGIC, 8) == 0) - uint32_t sunxi_get_boot_device(void); #endif diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index d9b04f75fc4..b6f92bdc5e7 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -244,12 +244,40 @@ void s_init(void) #define SUNXI_INVALID_BOOT_SOURCE -1 -static int sunxi_get_boot_source(void) +static struct boot_file_head *sunxi_egon_get_head(void) { - if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */ - return SUNXI_INVALID_BOOT_SOURCE; + struct boot_file_head *egon_head = (void *)SPL_ADDR; + + if (memcmp(egon_head, BOOT0_MAGIC, 8)) /* eGON.BT0 */ + return NULL; + + return egon_head; +} + +static struct toc0_main_info *sunxi_toc0_get_info(void) +{ + struct toc0_main_info *toc0_info = (void *)SPL_ADDR; + + if (memcmp(toc0_info->name, TOC0_MAIN_INFO_NAME, 8)) /* TOC0.GLH */ + return NULL; - return readb(SPL_ADDR + 0x28); + return toc0_info; +} + +static int sunxi_get_boot_source(void) +{ + struct boot_file_head *egon_head; + struct toc0_main_info *toc0_info; + + egon_head = sunxi_egon_get_head(); + if (egon_head) + return readb(&egon_head->boot_media); + toc0_info = sunxi_toc0_get_info(); + if (toc0_info) + return readb(&toc0_info->platform[0]); + + /* Not a valid image, so we must have been booted via FEL. */ + return SUNXI_INVALID_BOOT_SOURCE; } /* The sunxi internal brom will try to loader external bootloader @@ -297,10 +325,18 @@ uint32_t sunxi_get_boot_device(void) #ifdef CONFIG_SPL_BUILD static u32 sunxi_get_spl_size(void) { - if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */ - return 0; + struct boot_file_head *egon_head; + struct toc0_main_info *toc0_info; + + egon_head = sunxi_egon_get_head(); + if (egon_head) + return readl(&egon_head->length); + toc0_info = sunxi_toc0_get_info(); + if (toc0_info) + return readl(&toc0_info->length); - return readl(SPL_ADDR + 0x10); + /* Not a valid image, so use the default U-Boot offset. */ + return 0; } /* -- 2.31.1
[PATCH v2 0/4] sunxi: TOC0 image type support
This series adds support for the TOC0 image format used by the Allwinner secure boot ROM (SBROM). This series has been tested on the following SoCs/boards, with the eFuse burnt to enable secure mode: - A50: Ainol Q88 Tablet - A64: Pine A64 Plus - H5: Orange Pi Zero Plus - H6: Pine H64 Model B - H616: Orange Pi Zero 2 Due to a small conflict in Makefile.spl, the last patch depends on: https://patchwork.ozlabs.org/project/uboot/list/?series=249757 Changes in v2: - Refactored the first patch on top of TOOLS_LIBCRYPTO - Moved certificate and key item structures out of sunxi_image.h - Renamed "main" and "item" variables for clarity - Improved error messages, and added a hint about key generation - Added a comment explaining the purpose of the various key files - Mentioned testing this code on A50 in the commit message - Moved SPL header signature checks out of sunxi_image.h - Refactored SPL header signature checks to use fewer casts - Rebase on top of Icenowy's RISC-V support series - Rename Kconfig symbols to include the full image type name Samuel Holland (4): tools: Separate image types which depend on OpenSSL tools: mkimage: Add Allwinner TOC0 support sunxi: Support SPL in both eGON and TOC0 images sunxi: Support building a SPL as a TOC0 image arch/arm/Kconfig | 1 + arch/arm/include/asm/arch-sunxi/spl.h | 2 - arch/arm/mach-imx/mxs/Kconfig | 2 + arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-sunxi/Kconfig | 2 + arch/arm/mach-sunxi/board.c | 50 +- board/sunxi/Kconfig | 24 + common/image.c| 1 + include/image.h | 1 + include/sunxi_image.h | 36 + scripts/Makefile.spl | 5 +- scripts/config_whitelist.txt | 1 - tools/Makefile| 20 +- tools/mxsimage.c | 3 - tools/sunxi_toc0.c| 907 ++ 15 files changed, 1028 insertions(+), 28 deletions(-) create mode 100644 board/sunxi/Kconfig create mode 100644 tools/sunxi_toc0.c -- 2.31.1
[PATCH v2 2/4] tools: mkimage: Add Allwinner TOC0 support
Most Allwinner sunxi SoCs have separate boot ROMs in non-secure and secure mode. The "non-secure" or "normal" boot ROM (NBROM) uses the existing sunxi_egon image type. The secure boot ROM (SBROM) uses a completely different image type, known as TOC0. A TOC0 image is composed of a header and two or more items. One item is the firmware binary. The others form a chain linking the firmware signature to the root-of-trust public key (ROTPK), which has its hash burned in the SoC's eFuses. Signatures are made using RSA-2048 + SHA256. The pseudo-ASN.1 structure is manually assembled; this is done to work around bugs/quirks in the boot ROM, which vary between SoCs. This TOC0 implementation has been verified to work with the A50, A64, H5, H6, and H616 SBROMs, and it may work with other SoCs. Signed-off-by: Samuel Holland --- Changes in v2: - Moved certificate and key item structures out of sunxi_image.h - Renamed "main" and "item" variables for clarity - Improved error messages, and added a hint about key generation - Added a comment explaining the purpose of the various key files - Mentioned testing this code on A50 in the commit message arch/arm/Kconfig | 1 + common/image.c| 1 + include/image.h | 1 + include/sunxi_image.h | 36 ++ tools/Makefile| 3 +- tools/sunxi_toc0.c| 907 ++ 6 files changed, 948 insertions(+), 1 deletion(-) create mode 100644 tools/sunxi_toc0.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index d692139199c..799fe7d43af 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1014,6 +1014,7 @@ config ARCH_SUNXI select SUNXI_GPIO select SYS_NS16550 select SYS_THUMB_BUILD if !ARM64 + select TOOLS_LIBCRYPTO select USB if DISTRO_DEFAULTS select USB_KEYBOARD if DISTRO_DEFAULTS && USB_HOST select USB_STORAGE if DISTRO_DEFAULTS && USB_HOST diff --git a/common/image.c b/common/image.c index 59c52a1f9ad..8f1634c1206 100644 --- a/common/image.c +++ b/common/image.c @@ -191,6 +191,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" }, { IH_TYPE_COPRO, "copro", "Coprocessor Image"}, { IH_TYPE_SUNXI_EGON, "sunxi_egon", "Allwinner eGON Boot Image" }, + { IH_TYPE_SUNXI_TOC0, "sunxi_toc0", "Allwinner TOC0 Boot Image" }, { -1, "", "", }, }; diff --git a/include/image.h b/include/image.h index e20f0b69d58..a4efc090309 100644 --- a/include/image.h +++ b/include/image.h @@ -284,6 +284,7 @@ enum { IH_TYPE_IMX8IMAGE, /* Freescale IMX8Boot Image */ IH_TYPE_COPRO, /* Coprocessor Image for remoteproc*/ IH_TYPE_SUNXI_EGON, /* Allwinner eGON Boot Image */ + IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/include/sunxi_image.h b/include/sunxi_image.h index 5b2055c0af3..399ad0be999 100644 --- a/include/sunxi_image.h +++ b/include/sunxi_image.h @@ -9,9 +9,12 @@ * * Shared between mkimage and the SPL. */ + #ifndefSUNXI_IMAGE_H #defineSUNXI_IMAGE_H +#include + #define BOOT0_MAGIC"eGON.BT0" #define BROM_STAMP_VALUE 0x5f0a6c39 #define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ @@ -79,4 +82,37 @@ struct boot_file_head { /* Compile time check to assure proper alignment of structure */ typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_head) % 32)]; +struct toc0_main_info { + uint8_t name[8]; + __le32 magic; + __le32 checksum; + __le32 serial; + __le32 status; + __le32 num_items; + __le32 length; + uint8_t platform[4]; + uint8_t reserved[8]; + uint8_t end[4]; +}; + +#define TOC0_MAIN_INFO_NAME"TOC0.GLH" +#define TOC0_MAIN_INFO_MAGIC 0x89119800 +#define TOC0_MAIN_INFO_END "MIE;" + +struct toc0_item_info { + __le32 name; + __le32 offset; + __le32 length; + __le32 status; + __le32 type; + __le32 load_addr; + uint8_t reserved[4]; + uint8_t end[4]; +}; + +#define TOC0_ITEM_INFO_NAME_CERT 0x00010101 +#define TOC0_ITEM_INFO_NAME_FIRMWARE 0x00010202 +#define TOC0_ITEM_INFO_NAME_KEY0x00010303 +#define TOC0_ITEM_INFO_END "IIE;" + #endif diff --git a/tools/Makefile b/tools/Makefile index ad0e9cf9490..fc3b66af6af 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -98,7 +98,8 @@ AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \ LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \ lib/fdt-libcrypto.o \ kwbimage.o \ - mxsimage.o + mxsimage.o \ +
[PATCH v2 1/4] tools: Separate image types which depend on OpenSSL
Some image types always depend on OpenSSL, so they can only be included in mkimage when TOOLS_LIBCRYPTO is selected. Instead of using arbitrary preprocessor definitions, conditionally link the files. When building for platforms which use those image types, automatically select TOOLS_LIBCRYPTO, it is required for the build to complete. Signed-off-by: Samuel Holland --- Changes in v2: - Refactored the first patch on top of TOOLS_LIBCRYPTO arch/arm/mach-imx/mxs/Kconfig | 2 ++ arch/arm/mach-mvebu/Kconfig | 1 + scripts/config_whitelist.txt | 1 - tools/Makefile| 19 +-- tools/mxsimage.c | 3 --- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-imx/mxs/Kconfig b/arch/arm/mach-imx/mxs/Kconfig index 9f48ffda414..24d452942a5 100644 --- a/arch/arm/mach-imx/mxs/Kconfig +++ b/arch/arm/mach-imx/mxs/Kconfig @@ -3,6 +3,7 @@ if ARCH_MX23 config MX23 bool default y + select TOOLS_LIBCRYPTO choice prompt "MX23 board select" @@ -34,6 +35,7 @@ if ARCH_MX28 config MX28 bool default y + select TOOLS_LIBCRYPTO choice prompt "MX28 board select" diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 89737a37ad9..c02521c71bc 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -29,6 +29,7 @@ config ARMADA_38X bool select ARMADA_32BIT select HAVE_MVEBU_EFUSE + select TOOLS_LIBCRYPTO config ARMADA_38X_HS_IMPEDANCE_THRESH hex "Armada 38x USB 2.0 High-Speed Impedance Threshold (0x0 - 0x7)" diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 2d70bf5da7c..5caaad0c3dc 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -1000,7 +1000,6 @@ CONFIG_MXC_UART_BASE CONFIG_MXC_USB_FLAGS CONFIG_MXC_USB_PORT CONFIG_MXC_USB_PORTSC -CONFIG_MXS CONFIG_MXS_AUART CONFIG_MXS_AUART_BASE CONFIG_MXS_OCOTP diff --git a/tools/Makefile b/tools/Makefile index 4a86321f646..ad0e9cf9490 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -94,9 +94,11 @@ ECDSA_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/ecdsa/, ecdsa-libcrypto. AES_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/aes/, \ aes-encrypt.o aes-decrypt.o) -# Cryptographic helpers that depend on openssl/libcrypto -LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := $(addprefix lib/, \ - fdt-libcrypto.o) +# Cryptographic helpers and image types that depend on openssl/libcrypto +LIBCRYPTO_OBJS-$(CONFIG_TOOLS_LIBCRYPTO) := \ + lib/fdt-libcrypto.o \ + kwbimage.o \ + mxsimage.o ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o rkspi.o @@ -117,10 +119,8 @@ dumpimage-mkimage-objs := aisimage.o \ imximage.o \ imx8image.o \ imx8mimage.o \ - kwbimage.o \ lib/md5.o \ lpc32xximage.o \ - mxsimage.o \ omapimage.o \ os_support.o \ pblimage.o \ @@ -155,22 +155,13 @@ fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o file2include-objs := file2include.o -ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_TOOLS_LIBCRYPTO),) -# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register -# the mxsimage support within tools/mxsimage.c . -HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS -endif - ifdef CONFIG_TOOLS_LIBCRYPTO # This affects include/image.h, but including the board config file # is tricky, so manually define this options here. HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0x HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER -endif -# MXSImage needs LibSSL -ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),) HOSTCFLAGS_kwbimage.o += \ $(shell pkg-config --cflags libssl libcrypto 2> /dev/null || echo "") HOSTLDLIBS_mkimage += \ diff --git a/tools/mxsimage.c b/tools/mxsimage.c index 002f4b525aa..2bfbb421eb6 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -5,8 +5,6 @@ * Copyright (C) 2012-2013 Marek Vasut */ -#ifdef CONFIG_MXS - #include #include #include @@ -2363,4 +2361,3 @@ U_BOOT_IMAGE_TYPE( NULL, mxsimage_generate ); -#endif -- 2.31.1
Re: [PATCH 0/4] sunxi: TOC0 image type support
Hi Andre, On 6/21/21 6:56 PM, Andre Przywara wrote: > On Mon, 21 Jun 2021 16:35:37 -0400 > Tom Rini wrote: >> On Mon, Jun 21, 2021 at 04:43:00PM +0100, Andre Przywara wrote: >>> On Sun, 20 Jun 2021 21:55:51 -0500 >>> Samuel Holland wrote: >>> >>> (CC:ing Tom and Simon for the compatibility problem below) >>> >>> Hi, >>> This series adds support for the TOC0 image format used by the Allwinner secure boot ROM (SBROM). This series has been tested on the following SoCs/boards, with the eFuse burnt to enable secure mode: - A64: Pine A64 Plus - H5: Orange Pi Zero Plus - H6: Pine H64 Model B - H616: Orange Pi Zero 2 >>> >>> many thanks for sending this. In general this looks good (will do a >>> more thorough review soon), just one thing that bothered me: >>> >>> This requires OpenSLL 1.1.x. There is nothing really wrong about this, >>> but my (admittedly not the freshest) Slackware, but also long term >>> distros like RHEL/CentOS (<=7), still come with 1.0.x (headers) only. >>> >>> I was wondering how important this is? I have the impression that >>> embedded developers sometimes use old^Wstable systems, so some people >>> might be bitten by it. I think in this case it will affect all user >>> trying to build mkimage, regardless of the target platform? >>> >>> So I wanted to know what to do here? >>> - Can we provide some kind of compatibility support? OpenSSL seems >>> to provide something: >>> https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes#Compatibility_Layer >>> Haven't tested that fully yet, just downloading that tarball >>> does not seem to cut it (or is missing files?). I guess one needs to >>> copy&paste some code from the Wiki? >>> - Shall we detect missing v1.1.x support (via #if OPENSSL_VERSION_NUMBER >>> < 0x1010L) and disable just sunxi_toc0 support in this case? >> >> There's two things. First, the series should be on top of (sorry!) >> https://patchwork.ozlabs.org/project/uboot/patch/20210524202317.1492578-1-mr.nuke...@gmail.com/ >> which adds a similar Kconfig option to make building tools easier. > > So this is on top of Simon's large series? Poor Samuel! Is there a > branch somewhere? Now that all of these have landed, I'm rebasing this series. >> Second, while I think not supporting openssl 1.0.x is fine, > > Well, this was not what I was hoping for ;-) > I followed the advice on the OpenSSL wiki and now have a rather small > compatibility header file, which lets me compile mkimage even against > OpenSSL v1.0.2u. It seems like kwbimage.c has similar provisions in > place, I guess this could be merged into the external header? > Happy to send a patch on top, if this seems useful. Considering the note from the OpenSSL website: > Note: The latest stable version is the 1.1.1 series. This is also > our Long Term Support (LTS) version, supported until 11th September > 2023. All older versions (including 1.1.0, 1.0.2, 1.0.0 and 0.9.8) > are now out of support and should not be used. Users of these older > versions are encouraged to upgrade to 1.1.1 as soon as possible. and the fact that that I don't have access a system with an old OpenSSL, I'm not too interested in spending much effort on it. I will, though, happily test a patch if you do send one. >> I would like >> to again ask for someone to spend the time looking at switching to one >> of the GPL-compatible libraries as I'm pretty sure it's been raised a >> few times that we can't link with openssl like we do. > > Why is that? Because Apache is not compatible with GPLv2? The OpenSSL > webpage says that: > "Can I use OpenSSL with GPL software? > On many systems including the major Linux and BSD distributions, yes > (the GPL does not place restrictions on using libraries that are part > of the normal operating system distribution)." > And for mkimage we just build a regular userspace tool, which is linked > against the system installed OpenSSL library. From my understanding > this is what this quote above means with being permitted? > > And what would be the alternatives? Take one of the smaller ones and > embed them into the code? > Otherwise we would probably need to pick something that is widely > available and shipped with distros, I guess? Like GnuTLS, > libgcrypt, nettle? Maybe LibreSSL? > > Samuel, do you have an insight what would be a good fit? My original code was written against nettle. I switched to OpenSSL because that was already integrated into U-Boot (oops!), and to use the ASN.1 generation library (which the code no longer uses). So nettle would work well here because all we need is SHA256 and plain RSA. I don't know about the other image types. Regards, Samuel
Re: [PATCH v2 0/4] mkimage: sunxi_egon: add riscv support
On 6/19/21 4:18 AM, Icenowy Zheng wrote: > This patchset tries to make mkimage -T sunxi_egon to be able to generate > an eGON.BT0 image for Allwinner RISC-V SoCs (e.g. D1). > > In addition, to keep the compatibility, it will still consider the > architecture to be ARM when no architecture is specified. > > Icenowy Zheng (4): > mkimage: add a flag to describe whether -A is specified > mkimage: sunxi_egon: refactor for multi-architecture support > mkimage: sunxi_egon: add support for riscv > sunxi: specify architecture when generating SPL boot image > > scripts/Makefile.spl | 2 +- > tools/imagetool.h| 1 + > tools/mkimage.c | 1 + > tools/sunxi_egon.c | 86 > 4 files changed, 82 insertions(+), 8 deletions(-) This works great on D1. For the whole series: Tested-by: Samuel Holland
[PATCH v2] ARM: Prevent the compiler from using NEON registers
For ARMv8-A, NEON is standard, so the compiler can use it even when no special target flags are provided. For example, it can use stores from NEON registers to zero-initialize large structures. GCC 11 decides to do this inside the DRAM init code for the Allwinner H6. However, GCC 11 has a bug where it generates misaligned NEON register stores even with -mstrict-align. Since the MMU is not enabled this early in SPL, the misaligned store causes an exception and breaks booting. Work around this issue by restricting the compiler to using GPRs only, not vector registers. This prevents any future surprises relating to NEON use as well. Signed-off-by: Samuel Holland --- Changes in v2: - Updated commit message to describe problem more precisely arch/arm/config.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/config.mk b/arch/arm/config.mk index 16c63e12667..964c6b026ec 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -25,6 +25,7 @@ endif PLATFORM_RELFLAGS += -fno-common -ffixed-r9 PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \ +$(call cc-option,-mgeneral-regs-only) \ $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) # LLVM support -- 2.31.1
[PATCH] i2c: i2c-gpio: Support the named GPIO binding
To avoid confusion about the order of the GPIOs, the i2c-gpio binding was updated to use a separate property for each GPIO instead of an array. However, the driver only supports the old binding. Add support for the new binding as well, so the driver continues to work as device trees are updated. Signed-off-by: Samuel Holland --- drivers/i2c/i2c-gpio.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index cf8f8f40359..1aedad5c8ed 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -336,8 +336,17 @@ static int i2c_gpio_of_to_plat(struct udevice *dev) struct i2c_gpio_bus *bus = dev_get_priv(dev); int ret; + /* "gpios" is deprecated and replaced by "sda-gpios" + "scl-gpios". */ ret = gpio_request_list_by_name(dev, "gpios", bus->gpios, ARRAY_SIZE(bus->gpios), 0); + if (ret == -ENOENT) { + ret = gpio_request_by_name(dev, "sda-gpios", 0, + &bus->gpios[PIN_SDA], 0); + if (ret < 0) + goto error; + ret = gpio_request_by_name(dev, "scl-gpios", 0, + &bus->gpios[PIN_SCL], 0); + } if (ret < 0) goto error; -- 2.31.1
[PATCH 11/11] sunxi: Enable DM_I2C for all sunxi boards
Now that the last users of legacy I2C (outside of SPL) have been resolved, we can enable DM_I2C at the sunxi architecture level. Signed-off-by: Samuel Holland --- arch/arm/Kconfig| 1 + arch/arm/mach-sunxi/Kconfig | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0720647e876..ae5cc13916c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1000,6 +1000,7 @@ config ARCH_SUNXI select DM select DM_ETH select DM_GPIO + select DM_I2C if I2C select DM_KEYBOARD select DM_MMC if MMC select DM_SCSI if SCSI diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 82b598e6e7f..4b805c67423 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -165,7 +165,6 @@ endif config MACH_SUNXI_H3_H5 bool - select DM_I2C select PHY_SUN4I_USB select SUNXI_DE2 select SUNXI_DRAM_DW @@ -322,7 +321,6 @@ config MACH_SUN50I bool "sun50i (Allwinner A64)" select ARM64 select SPI - select DM_I2C select DM_SPI if SPI select DM_SPI_FLASH select PHY_SUN4I_USB @@ -929,7 +927,6 @@ config VIDEO_LCD_BL_PWM_ACTIVE_LOW config VIDEO_LCD_PANEL_I2C bool "LCD panel needs to be configured via i2c" depends on VIDEO_SUNXI - select DM_I2C select DM_I2C_GPIO ---help--- Say y here if the LCD panel needs to be configured via i2c. This -- 2.31.1
[PATCH 10/11] sunxi: video: Convert panel I2C to use DM_I2C
Two displays supported by the sunxi display driver (each one used by a single board) require initialization over I2C. Both previously used i2c_soft; replace this with the i2c-gpio instance that already exists in those boards' device trees (sun5i-a13-utoo-p66 and sun6i-a31-colombus). Since the i2c-gpio nodes are not referenced by any other node in the device trees (the device trees have no panel node), the I2C bus is selected by its node name. This panel initialization code was the only i2c_soft user, so the i2c_soft GPIO setup code can be removed now as well. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig | 22 ++ board/sunxi/board.c | 44 +--- configs/Colombus_defconfig | 6 -- configs/UTOO_P66_defconfig | 3 - drivers/video/anx9804.c | 107 ++-- drivers/video/anx9804.h | 5 +- drivers/video/sunxi/sunxi_display.c | 55 +- include/configs/sunxi-common.h | 17 - 8 files changed, 102 insertions(+), 157 deletions(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 4dd83a2280e..82b598e6e7f 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -929,28 +929,18 @@ config VIDEO_LCD_BL_PWM_ACTIVE_LOW config VIDEO_LCD_PANEL_I2C bool "LCD panel needs to be configured via i2c" depends on VIDEO_SUNXI - default n - select CMD_I2C + select DM_I2C + select DM_I2C_GPIO ---help--- Say y here if the LCD panel needs to be configured via i2c. This will add a bitbang i2c controller using gpios to talk to the LCD. -config VIDEO_LCD_PANEL_I2C_SDA - string "LCD panel i2c interface SDA pin" +config VIDEO_LCD_PANEL_I2C_NAME + string "LCD panel i2c interface node name" depends on VIDEO_LCD_PANEL_I2C - default "PG12" + default "i2c@0" ---help--- - Set the SDA pin for the LCD i2c interface. This takes a string in the - format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. - -config VIDEO_LCD_PANEL_I2C_SCL - string "LCD panel i2c interface SCL pin" - depends on VIDEO_LCD_PANEL_I2C - default "PG10" - ---help--- - Set the SCL pin for the LCD i2c interface. This takes a string in the - format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. - + Set the device tree node name for the LCD i2c interface. # Note only one of these may be selected at a time! But hidden choices are # not supported by Kconfig diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 2b7d655678d..dabe6734b81 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -47,47 +47,6 @@ #include #include -#if defined(CONFIG_VIDEO_LCD_PANEL_I2C) -/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */ -int soft_i2c_gpio_sda; -int soft_i2c_gpio_scl; - -static int soft_i2c_board_init(void) -{ - int ret; - - soft_i2c_gpio_sda = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SDA); - if (soft_i2c_gpio_sda < 0) { - printf("Error invalid soft i2c sda pin: '%s', err %d\n", - CONFIG_VIDEO_LCD_PANEL_I2C_SDA, soft_i2c_gpio_sda); - return soft_i2c_gpio_sda; - } - ret = gpio_request(soft_i2c_gpio_sda, "soft-i2c-sda"); - if (ret) { - printf("Error requesting soft i2c sda pin: '%s', err %d\n", - CONFIG_VIDEO_LCD_PANEL_I2C_SDA, ret); - return ret; - } - - soft_i2c_gpio_scl = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SCL); - if (soft_i2c_gpio_scl < 0) { - printf("Error invalid soft i2c scl pin: '%s', err %d\n", - CONFIG_VIDEO_LCD_PANEL_I2C_SCL, soft_i2c_gpio_scl); - return soft_i2c_gpio_scl; - } - ret = gpio_request(soft_i2c_gpio_scl, "soft-i2c-scl"); - if (ret) { - printf("Error requesting soft i2c scl pin: '%s', err %d\n", - CONFIG_VIDEO_LCD_PANEL_I2C_SCL, ret); - return ret; - } - - return 0; -} -#else -static int soft_i2c_board_init(void) { return 0; } -#endif - DECLARE_GLOBAL_DATA_PTR; void i2c_init_board(void) @@ -312,8 +271,7 @@ int board_init(void) #endif #endif /* CONFIG_DM_MMC */ - /* Uses dm gpio code so do this here and not in i2c_init_board() */ - return soft_i2c_board_init(); + return 0; } /* diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig index 31541f898d4..270bd7d351a 100644 --- a/configs/Colombus_defconfig +++ b/configs/Colombus_defconfig @@ -13,15 +13,9 @@ CONFIG_VIDEO_LCD_DCLK_PHASE=0 CONFIG_VIDEO_LCD_POWER="PH27" CONFIG_VIDEO_LCD_BL_EN="PM1" CONFIG_VIDEO_LCD_BL_PWM="PH13" -CONFIG_VIDEO_LCD_PANEL_I2C_SDA="PA23" -CONFIG_VIDEO_LCD_PANEL_I2C_SCL="PA24" CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804=y # CONFIG_SYS
[PATCH 08/11] sunxi: pmic_bus: Clean up preprocessor conditions
Instead of using the SoC symbols to decide the bus type, use whichever bus driver is actually enabled. This allows collapsing all of the AXP2xx and AXP8xx variants into one "else" case. It also has the advantage of falling back to I2C when the other bus drivers are disabled; this works because all of the PMICs support I2C in addition to other interfaces. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/pmic_bus.c | 90 +++--- 1 file changed, 39 insertions(+), 51 deletions(-) diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c index 827797249ea..a3c3a34b5fb 100644 --- a/arch/arm/mach-sunxi/pmic_bus.c +++ b/arch/arm/mach-sunxi/pmic_bus.c @@ -23,75 +23,63 @@ #define AXP221_CHIP_ADDR 0x68 +static int pmic_i2c_address(void) +{ + if (IS_ENABLED(CONFIG_AXP152_POWER)) + return AXP152_I2C_ADDR; + if (IS_ENABLED(CONFIG_AXP305_POWER)) + return AXP305_I2C_ADDR; + + /* Other AXP2xx and AXP8xx variants */ + return AXP209_I2C_ADDR; +} + int pmic_bus_init(void) { /* This cannot be 0 because it is used in SPL before BSS is ready */ static int needs_init = 1; - __maybe_unused int ret; + int ret = 0; if (!needs_init) return 0; -#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER -# ifdef CONFIG_MACH_SUN6I - p2wi_init(); - ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP_PMIC_MODE_REG, - AXP_PMIC_MODE_P2WI); -# elif defined CONFIG_MACH_SUN8I_R40 - /* Nothing. R40 uses the AXP221s in I2C mode */ - ret = 0; -# else - ret = rsb_init(); - if (ret) - return ret; + if (IS_ENABLED(CONFIG_SUN6I_P2WI)) { + p2wi_init(); + ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, + AXP_PMIC_MODE_REG, + AXP_PMIC_MODE_P2WI); + } else if (IS_ENABLED(CONFIG_SUN8I_RSB)) { + ret = rsb_init(); + if (ret) + return ret; - ret = rsb_set_device_address(AXP_PMIC_PRI_DEVICE_ADDR, -AXP_PMIC_PRI_RUNTIME_ADDR); -# endif - if (ret) - return ret; -#endif + ret = rsb_set_device_address(AXP_PMIC_PRI_DEVICE_ADDR, +AXP_PMIC_PRI_RUNTIME_ADDR); + } + + needs_init = ret; - needs_init = 0; - return 0; + return ret; } int pmic_bus_read(u8 reg, u8 *data) { -#ifdef CONFIG_AXP152_POWER - return i2c_read(AXP152_I2C_ADDR, reg, 1, data, 1); -#elif defined CONFIG_AXP209_POWER - return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1); -#elif defined CONFIG_AXP305_POWER - return i2c_read(AXP305_I2C_ADDR, reg, 1, data, 1); -#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER -# ifdef CONFIG_MACH_SUN6I - return p2wi_read(reg, data); -# elif defined CONFIG_MACH_SUN8I_R40 - return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1); -# else - return rsb_read(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); -# endif -#endif + if (IS_ENABLED(CONFIG_SUN6I_P2WI)) + return p2wi_read(reg, data); + if (IS_ENABLED(CONFIG_SUN8I_RSB)) + return rsb_read(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); + + return i2c_read(pmic_i2c_address(), reg, 1, data, 1); } int pmic_bus_write(u8 reg, u8 data) { -#ifdef CONFIG_AXP152_POWER - return i2c_write(AXP152_I2C_ADDR, reg, 1, &data, 1); -#elif defined CONFIG_AXP209_POWER - return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1); -#elif defined CONFIG_AXP305_POWER - return i2c_write(AXP305_I2C_ADDR, reg, 1, &data, 1); -#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER -# ifdef CONFIG_MACH_SUN6I - return p2wi_write(reg, data); -# elif defined CONFIG_MACH_SUN8I_R40 - return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1); -# else - return rsb_write(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); -# endif -#endif + if (IS_ENABLED(CONFIG_SUN6I_P2WI)) + return p2wi_write(reg, data); + if (IS_ENABLED(CONFIG_SUN8I_RSB)) + return rsb_write(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); + + return i2c_write(pmic_i2c_address(), reg, 1, &data, 1); } int pmic_bus_setbits(u8 reg, u8 bits) -- 2.31.1
[PATCH 09/11] sunxi: pmic_bus: Use the DM PMIC interface when possible
The pmic_bus functions are used in both SPL (for regulator setup) and U-Boot proper (for regulator setup, SID access, GPIO, and poweroff). Currently, pmic_bus conflicts with DM_I2C because it uses the legacy I2C interface. This commit makes pmic_bus dual-compatible with either the legacy I2C functions or the newly-added PMIC_AXP driver (which uses DM_I2C). In turn, this allows platforms to start transitioning to DM_I2C in U-Boot proper, without breaking boards that still depend on the legacy I2C interface for other reasons. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig| 2 ++ arch/arm/mach-sunxi/pmic_bus.c | 19 +++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 12235fabc06..4dd83a2280e 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -96,6 +96,8 @@ config SUN6I_PRCM config AXP_PMIC_BUS bool + select DM_PMIC if DM_I2C + select PMIC_AXP if DM_I2C help Select this PMIC bus access helpers for Sunxi platform PRCM or other AXP family PMIC devices. diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c index a3c3a34b5fb..b0957d7afe5 100644 --- a/arch/arm/mach-sunxi/pmic_bus.c +++ b/arch/arm/mach-sunxi/pmic_bus.c @@ -10,9 +10,11 @@ #include #include +#include #include #include #include +#include #include #define AXP152_I2C_ADDR0x30 @@ -23,6 +25,9 @@ #define AXP221_CHIP_ADDR 0x68 +#if CONFIG_IS_ENABLED(PMIC_AXP) +static struct udevice *pmic; +#else static int pmic_i2c_address(void) { if (IS_ENABLED(CONFIG_AXP152_POWER)) @@ -33,6 +38,7 @@ static int pmic_i2c_address(void) /* Other AXP2xx and AXP8xx variants */ return AXP209_I2C_ADDR; } +#endif int pmic_bus_init(void) { @@ -43,6 +49,10 @@ int pmic_bus_init(void) if (!needs_init) return 0; +#if CONFIG_IS_ENABLED(PMIC_AXP) + ret = uclass_get_device_by_driver(UCLASS_PMIC, DM_DRIVER_GET(axp_pmic), + &pmic); +#else if (IS_ENABLED(CONFIG_SUN6I_P2WI)) { p2wi_init(); ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, @@ -56,6 +66,7 @@ int pmic_bus_init(void) ret = rsb_set_device_address(AXP_PMIC_PRI_DEVICE_ADDR, AXP_PMIC_PRI_RUNTIME_ADDR); } +#endif needs_init = ret; @@ -64,22 +75,30 @@ int pmic_bus_init(void) int pmic_bus_read(u8 reg, u8 *data) { +#if CONFIG_IS_ENABLED(PMIC_AXP) + return pmic_read(pmic, reg, data, 1); +#else if (IS_ENABLED(CONFIG_SUN6I_P2WI)) return p2wi_read(reg, data); if (IS_ENABLED(CONFIG_SUN8I_RSB)) return rsb_read(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); return i2c_read(pmic_i2c_address(), reg, 1, data, 1); +#endif } int pmic_bus_write(u8 reg, u8 data) { +#if CONFIG_IS_ENABLED(PMIC_AXP) + return pmic_write(pmic, reg, &data, 1); +#else if (IS_ENABLED(CONFIG_SUN6I_P2WI)) return p2wi_write(reg, data); if (IS_ENABLED(CONFIG_SUN8I_RSB)) return rsb_write(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); return i2c_write(pmic_i2c_address(), reg, 1, &data, 1); +#endif } int pmic_bus_setbits(u8 reg, u8 bits) -- 2.31.1
[PATCH 06/11] sunxi: Select SUN8I_RSB more carefully
SUN8I_RSB should not be selected by MACH_SUN8I, because the hardware is not present in half of those SoCs (H3/H5, R40, and V3s). Move the selection to the SoCs where the hardware actually exists. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 3a1916759dc..28332008501 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -241,6 +241,7 @@ config MACH_SUN8I_A23 select ARCH_SUPPORT_PSCI select DRAM_SUN8I_A23 select PHY_SUN4I_USB + select SUN8I_RSB select SUNXI_GEN_SUN6I select SUPPORT_SPL select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT @@ -254,6 +255,7 @@ config MACH_SUN8I_A33 select ARCH_SUPPORT_PSCI select DRAM_SUN8I_A33 select PHY_SUN4I_USB + select SUN8I_RSB select SUNXI_GEN_SUN6I select SUPPORT_SPL select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT @@ -264,6 +266,7 @@ config MACH_SUN8I_A83T select CPU_V7A select DRAM_SUN8I_A83T select PHY_SUN4I_USB + select SUN8I_RSB select SUNXI_GEN_SUN6I select MMC_SUNXI_HAS_NEW_MODE select MMC_SUNXI_HAS_MODE_SWITCH @@ -358,7 +361,6 @@ endchoice # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33" config MACH_SUN8I bool - select SUN8I_RSB select SUN6I_PRCM default y if MACH_SUN8I_A23 default y if MACH_SUN8I_A33 -- 2.31.1
[PATCH 07/11] sunxi: pmic_bus: Fix Kconfig dependencies
AXP_PMIC_BUS enables communication with a specific AXP PMIC at a PMIC-dependent I2C/P2WI/RSB bus address. It is automatically selected as a dependency of the PMIC driver. It should not be selectable by the user when no PMIC is chosen. AXP_GPIO uses the pmic_bus functions, and also depends on a specific PMIC header to pick up register definitions. Both of these changes have no impact on any existing configs, since the code does not compile if the dependencies are not met. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 28332008501..12235fabc06 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -95,7 +95,7 @@ config SUN6I_PRCM in A31 SoC. config AXP_PMIC_BUS - bool "Sunxi AXP PMIC bus access helpers" + bool help Select this PMIC bus access helpers for Sunxi platform PRCM or other AXP family PMIC devices. @@ -796,6 +796,7 @@ endif config AXP_GPIO bool "Enable support for gpio-s on axp PMICs" + depends on AXP_PMIC_BUS default n ---help--- Say Y here to enable support for the gpio pins of the axp PMIC ICs. -- 2.31.1
[PATCH 05/11] power: pmic: Add a driver for X-Powers AXP PMICs
These PMICs provide some combination of battery charger, fuel gauge, GPIOs, regulators, and VBUS routing. These functions are represented as child nodes in the device tree. Add the minimal driver needed to probe these child devices and provide the DM_PMIC ops. Enable the driver by default for SoCs that normally pair with a PMIC. Signed-off-by: Samuel Holland --- drivers/power/pmic/Kconfig | 14 +++ drivers/power/pmic/Makefile | 1 + drivers/power/pmic/axp.c| 49 + 3 files changed, 64 insertions(+) create mode 100644 drivers/power/pmic/axp.c diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 0c4da9c5536..6a3e82e1be7 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -57,6 +57,20 @@ config PMIC_ACT8846 functions. It uses an I2C interface and is designed for use with tablets and smartphones. +config PMIC_AXP + bool "Enable Driver Model for X-Powers AXP PMICs" + depends on DM_I2C + help + This config enables driver-model PMIC uclass features for + X-Powers AXP152, AXP2xx, and AXP8xx PMICs. + +config SPL_PMIC_AXP + bool "Enable Driver Model for X-Powers AXP PMICs in SPL" + depends on SPL_DM_I2C && SPL_DM_PMIC + help + This config enables driver-model PMIC uclass features in the SPL for + X-Powers AXP152, AXP2xx, and AXP8xx PMICs. + config DM_PMIC_DA9063 bool "Enable Driver Model for the Dialog DA9063 PMIC" help diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 6e40c0971fb..4021be8e801 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o obj-$(CONFIG_PMIC_AB8500) += ab8500.o obj-$(CONFIG_PMIC_ACT8846) += act8846.o obj-$(CONFIG_PMIC_AS3722) += as3722.o as3722_gpio.o +obj-$(CONFIG_$(SPL_)PMIC_AXP) += axp.o obj-$(CONFIG_PMIC_MAX8997) += max8997.o obj-$(CONFIG_PMIC_PM8916) += pm8916.o obj-$(CONFIG_PMIC_RK8XX) += rk8xx.o diff --git a/drivers/power/pmic/axp.c b/drivers/power/pmic/axp.c new file mode 100644 index 000..7720e1afd9b --- /dev/null +++ b/drivers/power/pmic/axp.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include + +static int axp_pmic_reg_count(struct udevice *dev) +{ + /* TODO: Get the specific value from driver data. */ + return 0x100; +} + +static struct dm_pmic_ops axp_pmic_ops = { + .reg_count = axp_pmic_reg_count, + .read = dm_i2c_read, + .write = dm_i2c_write, +}; + +static int axp_pmic_bind(struct udevice *dev) +{ + int ret; + + ret = dm_scan_fdt_dev(dev); + if (ret) + return ret; + + return 0; +} + +static const struct udevice_id axp_pmic_ids[] = { + { .compatible = "x-powers,axp152" }, + { .compatible = "x-powers,axp202" }, + { .compatible = "x-powers,axp209" }, + { .compatible = "x-powers,axp221" }, + { .compatible = "x-powers,axp223" }, + { .compatible = "x-powers,axp803" }, + { .compatible = "x-powers,axp806" }, + { .compatible = "x-powers,axp809" }, + { .compatible = "x-powers,axp813" }, + { } +}; + +U_BOOT_DRIVER(axp_pmic) = { + .name = "axp_pmic", + .id = UCLASS_PMIC, + .of_match = axp_pmic_ids, + .bind = axp_pmic_bind, + .ops= &axp_pmic_ops, +}; -- 2.31.1
[PATCH 04/11] power: pmic: Make the uclass optional in SPL
Some platforms still cannot use the driver model in SPL due to SRAM space limitations. However, they need to use DM_PMIC in U-Boot proper. Add a new symbol so that DM_PMIC can be disabled in SPL, while keeping it available elsewhere. Also update the SPL-specific symbols to depend on this new option. Signed-off-by: Samuel Holland --- drivers/power/pmic/Kconfig | 17 - drivers/power/pmic/Makefile | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index 56c0ef70312..0c4da9c5536 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -12,6 +12,13 @@ config DM_PMIC if DM_PMIC +config SPL_DM_PMIC + bool "Enable Driver Model for PMIC drivers (UCLASS_PMIC) in SPL" + depends on SPL_DM + default y + help + This config enables the driver-model PMIC support in SPL. + config PMIC_CHILDREN bool "Allow child devices for PMICs" default y @@ -23,6 +30,7 @@ config PMIC_CHILDREN config SPL_PMIC_CHILDREN bool "Allow child devices for PMICs in SPL" + depends on SPL_DM_PMIC default y ---help--- This allows PMICs to support child devices (such as regulators) in @@ -57,7 +65,7 @@ config DM_PMIC_DA9063 config SPL_DM_PMIC_DA9063 bool "Enable Driver Model for the Dialog DA9063 PMIC in SPL" - depends on SPL + depends on SPL_DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC DA9063. The driver implements read/write operations. @@ -78,6 +86,7 @@ config DM_PMIC_BD71837 config SPL_DM_PMIC_BD71837 bool "Enable Driver Model for PMIC BD71837 in SPL stage" + depends on SPL_DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC BD71837. The driver implements read/write @@ -105,6 +114,7 @@ config DM_PMIC_MP5416 config SPL_DM_PMIC_MP5416 bool "Enable Driver Model for PMIC MP5416 in SPL stage" + depends on SPL_DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC MP5416. The driver implements read/write @@ -118,6 +128,7 @@ config DM_PMIC_PCA9450 config SPL_DM_PMIC_PCA9450 bool "Enable Driver Model for PMIC PCA9450" + depends on SPL_DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC PCA9450 in SPL. The driver implements read/write operations. @@ -130,6 +141,7 @@ config DM_PMIC_PFUZE100 config SPL_DM_PMIC_PFUZE100 bool "Enable Driver Model for PMIC PFUZE100 in SPL" + depends on SPL_DM_PMIC ---help--- This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100 in SPL. The driver implements read/write operations. @@ -292,18 +304,21 @@ config PMIC_STPMIC1 config SPL_PMIC_PALMAS bool "Enable driver for Texas Instruments PALMAS PMIC" + depends on SPL_DM_PMIC help The PALMAS is a PMIC containing several LDOs, SMPS. This driver binds the pmic children in SPL. config SPL_PMIC_LP873X bool "Enable driver for Texas Instruments LP873X PMIC" + depends on SPL_DM_PMIC help The LP873X is a PMIC containing couple of LDOs and couple of SMPS. This driver binds the pmic children in SPL. config SPL_PMIC_LP87565 bool "Enable driver for Texas Instruments LP87565 PMIC" + depends on SPL_DM_PMIC help The LP87565 is a PMIC containing a bunch of SMPS. This driver binds the pmic children in SPL. diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile index 5d1a97e5f6f..6e40c0971fb 100644 --- a/drivers/power/pmic/Makefile +++ b/drivers/power/pmic/Makefile @@ -3,7 +3,7 @@ # Copyright (C) 2012 Samsung Electronics # Lukasz Majewski -obj-$(CONFIG_DM_PMIC) += pmic-uclass.o +obj-$(CONFIG_$(SPL_)DM_PMIC) += pmic-uclass.o obj-$(CONFIG_DM_PMIC_FAN53555) += fan53555.o obj-$(CONFIG_$(SPL_)DM_PMIC_DA9063) += da9063.o obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o -- 2.31.1
[PATCH 03/11] power: pmic: Consistently depend on DM_PMIC
Kconfig symbols for two PMIC drivers (PMIC_AS3722 and DM_PMIC_MC34708) were missing a dependency on DM_PMIC. To fix this inconsistency, and to keep it from happening again, wrap the driver section with "if DM_PMIC" instead of using a "depends on DM_PMIC" clause for each driver. Signed-off-by: Samuel Holland --- drivers/power/pmic/Kconfig | 43 +++--- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig index fd6648b313e..56c0ef70312 100644 --- a/drivers/power/pmic/Kconfig +++ b/drivers/power/pmic/Kconfig @@ -10,9 +10,10 @@ config DM_PMIC - 'drivers/power/pmic/pmic-uclass.c' - 'include/power/pmic.h' +if DM_PMIC + config PMIC_CHILDREN bool "Allow child devices for PMICs" - depends on DM_PMIC default y ---help--- This allows PMICs to support child devices (such as regulators) in @@ -22,7 +23,6 @@ config PMIC_CHILDREN config SPL_PMIC_CHILDREN bool "Allow child devices for PMICs in SPL" - depends on DM_PMIC default y ---help--- This allows PMICs to support child devices (such as regulators) in @@ -33,7 +33,6 @@ config SPL_PMIC_CHILDREN config PMIC_AB8500 bool "Enable driver for ST-Ericsson AB8500 PMIC via PRCMU" - depends on DM_PMIC select REGMAP select SYSCON help @@ -43,7 +42,7 @@ config PMIC_AB8500 config PMIC_ACT8846 bool "Enable support for the active-semi 8846 PMIC" - depends on DM_PMIC && DM_I2C + depends on DM_I2C ---help--- This PMIC includes 4 DC/DC step-down buck regulators and 8 low-dropout regulators (LDOs). It also provides some GPIO, reset and battery @@ -52,14 +51,13 @@ config PMIC_ACT8846 config DM_PMIC_DA9063 bool "Enable Driver Model for the Dialog DA9063 PMIC" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC DA9063. The driver implements read/write operations. config SPL_DM_PMIC_DA9063 bool "Enable Driver Model for the Dialog DA9063 PMIC in SPL" - depends on DM_PMIC && SPL + depends on SPL help This config enables implementation of driver-model pmic uclass features for PMIC DA9063. The driver implements read/write operations. @@ -74,14 +72,12 @@ config PMIC_AS3722 config DM_PMIC_BD71837 bool "Enable Driver Model for PMIC BD71837" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC BD71837. The driver implements read/write operations. config SPL_DM_PMIC_BD71837 bool "Enable Driver Model for PMIC BD71837 in SPL stage" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC BD71837. The driver implements read/write @@ -89,7 +85,7 @@ config SPL_DM_PMIC_BD71837 config DM_PMIC_FAN53555 bool "Enable support for OnSemi FAN53555" - depends on DM_PMIC && DM_REGULATOR && DM_I2C + depends on DM_REGULATOR && DM_I2C select DM_REGULATOR_FAN53555 help This config enables implementation of driver-model PMIC @@ -103,14 +99,12 @@ config DM_PMIC_FAN53555 config DM_PMIC_MP5416 bool "Enable Driver Model for PMIC MP5416" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC MP5416. The driver implements read/write operations. config SPL_DM_PMIC_MP5416 bool "Enable Driver Model for PMIC MP5416 in SPL stage" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC MP5416. The driver implements read/write @@ -118,56 +112,48 @@ config SPL_DM_PMIC_MP5416 config DM_PMIC_PCA9450 bool "Enable Driver Model for PMIC PCA9450" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC PCA9450. The driver implements read/write operations. config SPL_DM_PMIC_PCA9450 bool "Enable Driver Model for PMIC PCA9450" - depends on DM_PMIC help This config enables implementation of driver-model pmic uclass features for PMIC PCA9450 in SPL. The driver implements read/write operations. config DM_PMIC_PFUZE100 bool "Enable Driver Model for PMIC PFUZE100" - depends on DM_PMIC ---help--- This config enables implementation of driver-model pmic uclass features for PMIC PFUZE100. The driver implements read/write operations. config SPL_DM_PMIC_PFUZE100 bool "Enable Driver Model for PMIC PFUZE100 in SPL" - depends on DM_PMIC ---help--- This config enables implementation
[PATCH 02/11] i2c: Add a DM_I2C wrapper for the sun8i_rsb controller
This bus controller is used to communicate with an X-Powers AXP PMIC. Currently, various drivers access PMIC registers through a platform- specific non-DM "pmic_bus" interface, which depends on the legacy I2C framework. In order to convert those drivers to use DM_PMIC, this bus needs a DM_I2C driver. Since the non-DM bus controller driver is still needed in SPL, the quick solution is to implement the DM_I2C ops using the existing functions. The register for switching between I2C/P2WI/RSB mode is the same across all PMIC variants, so move that to the common header. There are only a couple of pairs of hardware/runtime addresses used across all PMIC variants. So far the code expected only the "primary" pair, but some PMICs like the AXP305 and AXP805 use the secondary pair, so add support for that to the DM driver as well. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig| 8 arch/arm/mach-sunxi/pmic_bus.c | 11 ++--- drivers/i2c/Kconfig| 8 drivers/i2c/Makefile | 1 + drivers/i2c/sun8i_rsb.c| 86 ++ include/axp_pmic.h | 6 +++ 6 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 drivers/i2c/sun8i_rsb.c diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 37076c2dfb3..3a1916759dc 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -100,14 +100,6 @@ config AXP_PMIC_BUS Select this PMIC bus access helpers for Sunxi platform PRCM or other AXP family PMIC devices. -config SUN8I_RSB - bool "Allwinner sunXi Reduced Serial Bus Driver" - help - Say y here to enable support for Allwinner's Reduced Serial Bus - (RSB) support. This controller is responsible for communicating - with various RSB based devices, such as AXP223, AXP8XX PMICs, - and AC100/AC200 ICs. - config SUNXI_SRAM_ADDRESS hex default 0x1 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5 diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c index 673a05fdd16..827797249ea 100644 --- a/arch/arm/mach-sunxi/pmic_bus.c +++ b/arch/arm/mach-sunxi/pmic_bus.c @@ -23,10 +23,6 @@ #define AXP221_CHIP_ADDR 0x68 -/* AXP818 device and runtime addresses are same as AXP223 */ -#define AXP223_DEVICE_ADDR 0x3a3 -#define AXP223_RUNTIME_ADDR0x2d - int pmic_bus_init(void) { /* This cannot be 0 because it is used in SPL before BSS is ready */ @@ -49,7 +45,8 @@ int pmic_bus_init(void) if (ret) return ret; - ret = rsb_set_device_address(AXP223_DEVICE_ADDR, AXP223_RUNTIME_ADDR); + ret = rsb_set_device_address(AXP_PMIC_PRI_DEVICE_ADDR, +AXP_PMIC_PRI_RUNTIME_ADDR); # endif if (ret) return ret; @@ -73,7 +70,7 @@ int pmic_bus_read(u8 reg, u8 *data) # elif defined CONFIG_MACH_SUN8I_R40 return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1); # else - return rsb_read(AXP223_RUNTIME_ADDR, reg, data); + return rsb_read(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); # endif #endif } @@ -92,7 +89,7 @@ int pmic_bus_write(u8 reg, u8 data) # elif defined CONFIG_MACH_SUN8I_R40 return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1); # else - return rsb_write(AXP223_RUNTIME_ADDR, reg, data); + return rsb_write(AXP_PMIC_PRI_RUNTIME_ADDR, reg, data); # endif #endif } diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index d082676c4b2..3d97be7a1de 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -585,6 +585,14 @@ config SUN6I_P2WI in the Allwinner A31 and A31s SOCs. This interface is used to connect to specific devices like the X-Powers AXP221 PMIC. +config SUN8I_RSB + bool "Allwinner sun8i Reduced Serial Bus controller" + depends on ARCH_SUNXI + help + Support for Allwinner's Reduced Serial Bus (RSB) controller. This + controller is responsible for communicating with various RSB based + devices, such as X-Powers AXPxxx PMICs and AC100/AC200 CODEC ICs. + config SYS_I2C_SYNQUACER bool "Socionext SynQuacer I2C controller" depends on ARCH_SYNQUACER && DM_I2C diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 2461f0a2db8..c9e910c4724 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o obj-$(CONFIG_SYS_I2C_STM32F7) += stm32f7_i2c.o obj-$(CONFIG_SUN6I_P2WI) += sun6i_p2wi.o +obj-$(CONFIG_SUN8I_RSB) += sun8i_rsb.o obj-$(CONFIG_SYS_I2C_SYNQUACER) += synquacer_i2c.o obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o diff --git a/drivers/i2c/sun8i_rsb.c b/drivers/i2c/sun8i_rsb.c new file mode 100644 index 000..46d11afa174 --- /dev/null +++ b/drivers/i2c/sun8i_rsb.c @@ -0,0 +1,86 @@
[PATCH 01/11] i2c: Add a DM_I2C wrapper for the sun6i_p2wi controller
This bus controller is used to communicate with an X-Powers AXP PMIC. Currently, various drivers access PMIC registers through a platform- specific non-DM "pmic_bus" interface, which depends on the legacy I2C framework. In order to convert those drivers to use DM_PMIC, this bus needs a DM_I2C driver. Since the non-DM bus controller driver is still needed in SPL, the quick solution is to implement the DM_I2C ops using the existing functions. The register for switching between I2C/P2WI/RSB mode is the same across all PMIC variants, so move that to the common header. Signed-off-by: Samuel Holland --- arch/arm/mach-sunxi/Kconfig| 11 -- arch/arm/mach-sunxi/pmic_bus.c | 7 ++-- drivers/i2c/Kconfig| 8 + drivers/i2c/Makefile | 1 + drivers/i2c/sun6i_p2wi.c | 66 ++ include/axp_pmic.h | 6 6 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 drivers/i2c/sun6i_p2wi.c diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index 79c669a4813..37076c2dfb3 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig @@ -88,17 +88,6 @@ config DRAM_SUN50I_H616_UNKNOWN_FEATURE feature. endif -config SUN6I_P2WI - bool "Allwinner sun6i internal P2WI controller" - help - If you say yes to this option, support will be included for the - P2WI (Push/Pull 2 Wire Interface) controller embedded in some sunxi - SOCs. - The P2WI looks like an SMBus controller (which supports only byte - accesses), except that it only supports one slave device. - This interface is used to connect to specific PMIC devices (like the - AXP221). - config SUN6I_PRCM bool help diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c index 0394ce85644..673a05fdd16 100644 --- a/arch/arm/mach-sunxi/pmic_bus.c +++ b/arch/arm/mach-sunxi/pmic_bus.c @@ -8,6 +8,7 @@ * axp223 uses the rsb bus, these functions abstract this. */ +#include #include #include #include @@ -21,8 +22,6 @@ #define AXP305_I2C_ADDR0x36 #define AXP221_CHIP_ADDR 0x68 -#define AXP221_CTRL_ADDR 0x3e -#define AXP221_INIT_DATA 0x3e /* AXP818 device and runtime addresses are same as AXP223 */ #define AXP223_DEVICE_ADDR 0x3a3 @@ -40,8 +39,8 @@ int pmic_bus_init(void) #if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER # ifdef CONFIG_MACH_SUN6I p2wi_init(); - ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR, - AXP221_INIT_DATA); + ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP_PMIC_MODE_REG, + AXP_PMIC_MODE_P2WI); # elif defined CONFIG_MACH_SUN8I_R40 /* Nothing. R40 uses the AXP221s in I2C mode */ ret = 0; diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 5d27f503bfc..d082676c4b2 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -577,6 +577,14 @@ config SYS_I2C_STM32F7 _ Optional clock stretching _ Software reset +config SUN6I_P2WI + bool "Allwinner sun6i P2WI controller" + depends on ARCH_SUNXI + help + Support for the P2WI (Push/Pull 2 Wire Interface) controller embedded + in the Allwinner A31 and A31s SOCs. This interface is used to connect + to specific devices like the X-Powers AXP221 PMIC. + config SYS_I2C_SYNQUACER bool "Socionext SynQuacer I2C controller" depends on ARCH_SYNQUACER && DM_I2C diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index 3a7ecd9274b..2461f0a2db8 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_SYS_I2C_SANDBOX) += sandbox_i2c.o i2c-emul-uclass.o obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o obj-$(CONFIG_SYS_I2C_STM32F7) += stm32f7_i2c.o +obj-$(CONFIG_SUN6I_P2WI) += sun6i_p2wi.o obj-$(CONFIG_SYS_I2C_SYNQUACER) += synquacer_i2c.o obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o diff --git a/drivers/i2c/sun6i_p2wi.c b/drivers/i2c/sun6i_p2wi.c new file mode 100644 index 000..f1e8e5ed107 --- /dev/null +++ b/drivers/i2c/sun6i_p2wi.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include + +#if CONFIG_IS_ENABLED(DM_I2C) + +static int sun6i_p2wi_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) +{ + /* The hardware only supports SMBus-style transfers. */ + if (nmsgs == 2 && msg[1].flags == I2C_M_RD && msg[1].len == 1) + return p2wi_read(msg[0].buf[0], msg[1].buf); + + if (nmsgs == 1 && msg[0].len == 2) + return p2wi_write(msg[0].buf[0], msg[0].buf[1]); + + return -EINVAL; +} + +static int sun6i_p2wi
[PATCH 00/11] sunxi: Migrate to DM_I2C
This series does the initial work to migrate sunxi boards to DM_I2C. First it takes care of the PMIC: - Patches 1-2 add DM_I2C versions of two drivers. - Patches 3-4 allow us to use DM_PMIC without DM_SPL. - Patch 5 then adds a DM_PMIC driver. - Patches 6-9 migrate the "pmic_bus" functions to use that DM_PMIC driver when possible. Then it takes care of the LCD panels: - Patch 10 converts those drivers to use DM_I2C. Finally, patch 11 switches all sunxi boards over to DM_I2C. There is some remaining work to clean up uses of pmic_bus in U-Boot proper and replace them with DM_PMIC functions: - drivers/gpio/axp_gpio.c - I have a series for this. - do_poweroff() in drivers/gpio/axp???.c - I have a series for this. - axp_get_sid() in drivers/power/axp221.c - Not sure what to do here. - axp_set_eldo() in drivers/video/sunxi/sunxi_display.c - This will need a DM_REGULATOR driver. This series is on top of https://patchwork.ozlabs.org/project/uboot/list/?series=258648 which is on top of https://patchwork.ozlabs.org/project/uboot/list/?series=258482 I have build-tested each commit on all sunxi boards, and boot-tested the series on Pine H64 (H6) and Orange Pi Zero2 (H616). Samuel Holland (11): i2c: Add a DM_I2C wrapper for the sun6i_p2wi controller i2c: Add a DM_I2C wrapper for the sun8i_rsb controller power: pmic: Consistently depend on DM_PMIC power: pmic: Make the uclass optional in SPL power: pmic: Add a driver for X-Powers AXP PMICs sunxi: Select SUN8I_RSB more carefully sunxi: pmic_bus: Fix Kconfig dependencies sunxi: pmic_bus: Clean up preprocessor conditions sunxi: pmic_bus: Use the DM PMIC interface when possible sunxi: video: Convert panel I2C to use DM_I2C sunxi: Enable DM_I2C for all sunxi boards arch/arm/Kconfig| 1 + arch/arm/mach-sunxi/Kconfig | 51 +++-- arch/arm/mach-sunxi/pmic_bus.c | 109 ++-- board/sunxi/board.c | 44 +-- configs/Colombus_defconfig | 6 -- configs/UTOO_P66_defconfig | 3 - drivers/i2c/Kconfig | 16 drivers/i2c/Makefile| 2 + drivers/i2c/sun6i_p2wi.c| 66 + drivers/i2c/sun8i_rsb.c | 86 ++ drivers/power/pmic/Kconfig | 72 +- drivers/power/pmic/Makefile | 3 +- drivers/power/pmic/axp.c| 49 + drivers/video/anx9804.c | 107 +-- drivers/video/anx9804.h | 5 +- drivers/video/sunxi/sunxi_display.c | 55 +- include/axp_pmic.h | 12 +++ include/configs/sunxi-common.h | 17 - 18 files changed, 435 insertions(+), 269 deletions(-) create mode 100644 drivers/i2c/sun6i_p2wi.c create mode 100644 drivers/i2c/sun8i_rsb.c create mode 100644 drivers/power/pmic/axp.c -- 2.31.1
[PATCH 7/9] nxp: Migrate CONFIG_DDR_CLK_FREQ to Kconfig
As this symbol can either be a fixed value or the function get_board_ddr_clk, migration is tricky. Introduce a choice of DYNAMIC or STATIC_DDR_CLK_FREQ. If DYNAMIC, we continue to use the board defined get_board_ddr_clk function. If STATIC, set CONFIG_DDR_CLK_FREQ to that value and now include/clock_legacy.h contains the function prototype or defines get_board_ddr_clk() to that static value. Update callers to test for DYNAMIC or STATIC. Signed-off-by: Tom Rini --- arch/arm/cpu/armv7/ls102xa/clock.c| 4 +-- .../armv8/fsl-layerscape/fsl_lsch2_speed.c| 4 +-- .../armv8/fsl-layerscape/fsl_lsch3_speed.c| 6 ++--- arch/powerpc/cpu/mpc85xx/cpu.c| 8 +++--- arch/powerpc/cpu/mpc85xx/speed.c | 9 --- board/freescale/common/ics307_clk.h | 1 - board/freescale/ls1021aqds/ls1021aqds.c | 2 ++ board/freescale/t102xrdb/spl.c| 5 board/freescale/t102xrdb/t102xrdb.c | 5 board/freescale/t104xrdb/spl.c| 5 board/freescale/t208xrdb/spl.c| 5 board/freescale/t208xrdb/t208xrdb.c | 5 board/freescale/t4rdb/spl.c | 5 configs/P1010RDB-PA_36BIT_NAND_defconfig | 1 + configs/P1010RDB-PA_36BIT_NOR_defconfig | 1 + configs/P1010RDB-PA_36BIT_SDCARD_defconfig| 1 + configs/P1010RDB-PA_36BIT_SPIFLASH_defconfig | 1 + configs/P1010RDB-PA_NAND_defconfig| 1 + configs/P1010RDB-PA_NOR_defconfig | 1 + configs/P1010RDB-PA_SDCARD_defconfig | 1 + configs/P1010RDB-PA_SPIFLASH_defconfig| 1 + configs/P1010RDB-PB_36BIT_NAND_defconfig | 1 + configs/P1010RDB-PB_36BIT_NOR_defconfig | 1 + configs/P1010RDB-PB_36BIT_SDCARD_defconfig| 1 + configs/P1010RDB-PB_36BIT_SPIFLASH_defconfig | 1 + configs/P1010RDB-PB_NAND_defconfig| 1 + configs/P1010RDB-PB_NOR_defconfig | 1 + configs/P1010RDB-PB_SDCARD_defconfig | 1 + configs/P1010RDB-PB_SPIFLASH_defconfig| 1 + configs/P1020RDB-PC_36BIT_NAND_defconfig | 1 + configs/P1020RDB-PC_36BIT_SDCARD_defconfig| 1 + configs/P1020RDB-PC_36BIT_SPIFLASH_defconfig | 1 + configs/P1020RDB-PC_36BIT_defconfig | 1 + configs/P1020RDB-PC_NAND_defconfig| 1 + configs/P1020RDB-PC_SDCARD_defconfig | 1 + configs/P1020RDB-PC_SPIFLASH_defconfig| 1 + configs/P1020RDB-PC_defconfig | 1 + configs/P1020RDB-PD_NAND_defconfig| 1 + configs/P1020RDB-PD_SDCARD_defconfig | 1 + configs/P1020RDB-PD_SPIFLASH_defconfig| 1 + configs/P1020RDB-PD_defconfig | 1 + configs/P2020RDB-PC_36BIT_NAND_defconfig | 1 + configs/P2020RDB-PC_36BIT_SDCARD_defconfig| 1 + configs/P2020RDB-PC_36BIT_SPIFLASH_defconfig | 1 + configs/P2020RDB-PC_36BIT_defconfig | 1 + configs/P2020RDB-PC_NAND_defconfig| 1 + configs/P2020RDB-PC_SDCARD_defconfig | 1 + configs/P2020RDB-PC_SPIFLASH_defconfig| 1 + configs/P2020RDB-PC_defconfig | 1 + configs/T1042D4RDB_NAND_defconfig | 1 + configs/T1042D4RDB_SDCARD_defconfig | 1 + configs/T1042D4RDB_SPIFLASH_defconfig | 1 + configs/T1042D4RDB_defconfig | 1 + configs/T2080QDS_NAND_defconfig | 1 + configs/T2080QDS_SDCARD_defconfig | 1 + configs/T2080QDS_SECURE_BOOT_defconfig| 1 + configs/T2080QDS_SPIFLASH_defconfig | 1 + configs/T2080QDS_SRIO_PCIE_BOOT_defconfig | 1 + configs/T2080QDS_defconfig| 1 + configs/T2080RDB_NAND_defconfig | 1 + configs/T2080RDB_SDCARD_defconfig | 1 + configs/T2080RDB_SPIFLASH_defconfig | 1 + configs/T2080RDB_defconfig| 1 + configs/T2080RDB_revD_NAND_defconfig | 1 + configs/T2080RDB_revD_SDCARD_defconfig| 1 + configs/T2080RDB_revD_SPIFLASH_defconfig | 1 + configs/T2080RDB_revD_defconfig | 1 + configs/T4240RDB_SDCARD_defconfig | 1 + configs/T4240RDB_defconfig| 1 + configs/UCP1020_defconfig | 1 + configs/kmcent2_defconfig | 1 + configs/ls1021aqds_ddr4_nor_defconfig | 1 + configs/ls1021aqds_ddr4_nor_lpuart_defconfig | 1 + configs/ls1021aqds_nand_defconfig | 1 + configs/ls1021aqds_nor_SECURE_BOOT_defconfig | 1 + configs/ls1021aqds_nor_defconfig | 1 + configs/ls1021aqds_nor_lpuart_defconfig | 1 + configs/ls1021aqds_sdcard_ifc_defconfig | 1 + configs/ls1043aqds_defconfig | 1 + configs/ls1043aqds_lpuart_defconfig | 1 + configs/ls1043aqds_nand_defconfig | 1 + configs/ls1043aqds_nor_ddr3_defconfig | 1 + configs/ls1043aqds_qspi_defconfig | 1 + con
[PATCH 8/9] nxp: Migrate a number of DDR related symbols to Kconfig
- Guard most of the options in drivers/ddr/fsl/Kconfig with SYS_FSL_DDR || SYS_FSL_MMDC. - Migrate FSL_DMA, DDR_ECC, DDR_ECC_CMD, and ECC_INIT_VIA_DDRCONTROLLER to Kconfig. - Clean up the logic for including the DDR_ECC_CMD code. Signed-off-by: Tom Rini --- arch/powerpc/cpu/mpc83xx/Makefile | 2 +- arch/powerpc/cpu/mpc83xx/ecc.c| 2 -- arch/powerpc/include/asm/config.h | 8 --- configs/MPC8349EMDS_PCI64_defconfig | 2 ++ configs/MPC8349EMDS_SDRAM_defconfig | 2 ++ configs/MPC8349EMDS_SLAVE_defconfig | 2 ++ configs/MPC8349EMDS_defconfig | 2 ++ configs/MPC8548CDS_36BIT_defconfig| 2 ++ configs/MPC8548CDS_defconfig | 2 ++ configs/MPC8548CDS_legacy_defconfig | 2 ++ configs/P3041DS_NAND_defconfig| 2 ++ configs/P3041DS_SDCARD_defconfig | 2 ++ configs/P3041DS_SPIFLASH_defconfig| 2 ++ configs/P3041DS_defconfig | 2 ++ configs/P4080DS_SDCARD_defconfig | 2 ++ configs/P4080DS_SPIFLASH_defconfig| 2 ++ configs/P4080DS_defconfig | 2 ++ configs/P5040DS_NAND_defconfig| 2 ++ configs/P5040DS_SDCARD_defconfig | 2 ++ configs/P5040DS_SPIFLASH_defconfig| 2 ++ configs/P5040DS_defconfig | 2 ++ configs/T1024RDB_NAND_defconfig | 2 ++ configs/T1024RDB_SDCARD_defconfig | 2 ++ configs/T1024RDB_SPIFLASH_defconfig | 2 ++ configs/T1024RDB_defconfig| 2 ++ configs/T1042D4RDB_NAND_defconfig | 2 ++ configs/T1042D4RDB_SDCARD_defconfig | 2 ++ configs/T1042D4RDB_SPIFLASH_defconfig | 2 ++ configs/T1042D4RDB_defconfig | 2 ++ configs/T2080QDS_NAND_defconfig | 2 ++ configs/T2080QDS_SDCARD_defconfig | 2 ++ configs/T2080QDS_SECURE_BOOT_defconfig| 2 ++ configs/T2080QDS_SPIFLASH_defconfig | 2 ++ configs/T2080QDS_SRIO_PCIE_BOOT_defconfig | 2 ++ configs/T2080QDS_defconfig| 2 ++ configs/T2080RDB_NAND_defconfig | 2 ++ configs/T2080RDB_SDCARD_defconfig | 2 ++ configs/T2080RDB_SPIFLASH_defconfig | 2 ++ configs/T2080RDB_defconfig| 2 ++ configs/T2080RDB_revD_NAND_defconfig | 2 ++ configs/T2080RDB_revD_SDCARD_defconfig| 2 ++ configs/T2080RDB_revD_SPIFLASH_defconfig | 2 ++ configs/T2080RDB_revD_defconfig | 2 ++ configs/T4240RDB_SDCARD_defconfig | 2 ++ configs/T4240RDB_defconfig| 2 ++ configs/UCP1020_defconfig | 1 + configs/kontron_sl28_defconfig| 2 ++ configs/ls1021aqds_ddr4_nor_defconfig | 2 ++ configs/ls1021aqds_ddr4_nor_lpuart_defconfig | 2 ++ configs/ls1021aqds_nand_defconfig | 2 ++ configs/ls1021aqds_nor_SECURE_BOOT_defconfig | 2 ++ configs/ls1021aqds_nor_defconfig | 2 ++ configs/ls1021aqds_nor_lpuart_defconfig | 2 ++ configs/ls1021aqds_qspi_defconfig | 2 ++ configs/ls1021aqds_sdcard_ifc_defconfig | 2 ++ configs/ls1021aqds_sdcard_qspi_defconfig | 2 ++ configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 1 + configs/ls1028aqds_tfa_defconfig | 1 + configs/ls1028aqds_tfa_lpuart_defconfig | 1 + configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 1 + configs/ls1028ardb_tfa_defconfig | 1 + configs/ls1043aqds_defconfig | 2 ++ configs/ls1043aqds_lpuart_defconfig | 2 ++ configs/ls1043aqds_nand_defconfig | 2 ++ configs/ls1043aqds_nor_ddr3_defconfig | 2 ++ configs/ls1043aqds_qspi_defconfig | 2 ++ configs/ls1043aqds_sdcard_ifc_defconfig | 2 ++ configs/ls1043aqds_sdcard_qspi_defconfig | 2 ++ configs/ls1043aqds_tfa_SECURE_BOOT_defconfig | 2 ++ configs/ls1043aqds_tfa_defconfig | 2 ++ configs/ls1043ardb_SECURE_BOOT_defconfig | 2 ++ configs/ls1043ardb_defconfig | 2 ++ configs/ls1043ardb_tfa_SECURE_BOOT_defconfig | 2 ++ configs/ls1043ardb_tfa_defconfig | 2 ++ configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig | 1 + configs/ls1046afrwy_tfa_defconfig | 1 + configs/ls1046aqds_SECURE_BOOT_defconfig | 2 ++ configs/ls1046aqds_defconfig | 2 ++ configs/ls1046aqds_lpuart_defconfig | 2 ++ configs/ls1046aqds_nand_defconfig | 2 ++ configs/ls1046aqds_qspi_defconfig | 2 ++ configs/ls1046aqds_sdcard_ifc_defconfig | 2 ++ configs/ls1046aqds_sdcard_qspi_defconfig | 2 ++ configs/ls1046aqds_tfa_SECURE_BOOT_defconfig | 2 ++ configs/ls1046aqds_tfa_defconfig | 2 ++ configs/ls1046ardb_emmc_defconfig | 2 ++ configs
[PATCH 9/9] Convert CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT to Kconfig
This converts the following to Kconfig: CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT Signed-off-by: Tom Rini --- configs/ls1021aiot_sdcard_defconfig | 1 + configs/ls1046aqds_nand_defconfig | 1 + include/configs/ls1021aiot.h| 1 - include/configs/ls1046a_common.h| 1 - 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/ls1021aiot_sdcard_defconfig b/configs/ls1021aiot_sdcard_defconfig index 7c198988b889..e8fdd2a37992 100644 --- a/configs/ls1021aiot_sdcard_defconfig +++ b/configs/ls1021aiot_sdcard_defconfig @@ -16,6 +16,7 @@ CONFIG_MISC_INIT_R=y CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xe8 +CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GREPENV=y CONFIG_CMD_MEMINFO=y diff --git a/configs/ls1046aqds_nand_defconfig b/configs/ls1046aqds_nand_defconfig index b099b8452a4d..7483308ba756 100644 --- a/configs/ls1046aqds_nand_defconfig +++ b/configs/ls1046aqds_nand_defconfig @@ -28,6 +28,7 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SPL_BOARD_INIT=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110 +CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_IMLS=y CONFIG_CMD_GREPENV=y diff --git a/include/configs/ls1021aiot.h b/include/configs/ls1021aiot.h index 6c1d1beb7278..7c29bedb8360 100644 --- a/include/configs/ls1021aiot.h +++ b/include/configs/ls1021aiot.h @@ -63,7 +63,6 @@ #define CONFIG_SPL_LIBCOMMON_SUPPORT #define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_ENV_SUPPORT -#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT #define CONFIG_SPL_I2C #define CONFIG_SPL_WATCHDOG #define CONFIG_SPL_MMC_SUPPORT diff --git a/include/configs/ls1046a_common.h b/include/configs/ls1046a_common.h index 289acc02d380..aa222e026931 100644 --- a/include/configs/ls1046a_common.h +++ b/include/configs/ls1046a_common.h @@ -108,7 +108,6 @@ #define CONFIG_SPL_ENV_SUPPORT #define CONFIG_SPL_WATCHDOG #define CONFIG_SPL_I2C -#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT #define CONFIG_SPL_NAND_SUPPORT #define CONFIG_SPL_DRIVERS_MISC -- 2.17.1
[PATCH 5/9] mvebe: Migrate CONFIG_DDR_LOG_LEVEL to Kconfig
Move this specific option to Kconfig. Signed-off-by: Tom Rini --- arch/arm/mach-mvebu/Kconfig | 14 ++ drivers/ddr/marvell/axp/ddr3_axp_config.h | 4 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 1daa64763b03..944bbee7634d 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -197,6 +197,20 @@ config DDR_32BIT endchoice +config DDR_LOG_LEVEL + int "DDR training code log level" + depends on ARMADA_XP + default 0 + range 0 3 + help + Amount of information provided on error while running the DDR + training code. At level 0, provides an error code in a case of + failure, RL, WL errors and other algorithm failure. At level 1, + provides the D-Unit setup (SPD/Static configuration). At level 2, + provides the windows margin as a results of DQS centeralization. + At level 3, rovides the windows margin of each DQ as a results of + DQS centeralization. + config SYS_BOARD default "clearfog" if TARGET_CLEARFOG default "helios4" if TARGET_HELIOS4 diff --git a/drivers/ddr/marvell/axp/ddr3_axp_config.h b/drivers/ddr/marvell/axp/ddr3_axp_config.h index 10d064d0a308..437a02efbac9 100644 --- a/drivers/ddr/marvell/axp/ddr3_axp_config.h +++ b/drivers/ddr/marvell/axp/ddr3_axp_config.h @@ -16,11 +16,7 @@ * Level 3: Provides the windows margin of each DQ as a results of DQS * centeralization */ -#ifdef CONFIG_DDR_LOG_LEVEL #defineDDR3_LOG_LEVEL CONFIG_DDR_LOG_LEVEL -#else -#defineDDR3_LOG_LEVEL 0 -#endif #define DDR3_PBS1 -- 2.17.1
[PATCH 6/9] ddr: Migrate DDR_SPD to Kconfig
Move the symbol that controls building some JEDEC SPD support functions to Kconfig. This is required on the TI keystone 2 platforms and very frequently (but not always) used on large number of Freescale/NXP platforms, so use imply there. Signed-off-by: Tom Rini --- arch/arm/Kconfig| 1 + drivers/ddr/Kconfig | 6 ++ drivers/ddr/fsl/Kconfig | 4 3 files changed, 11 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index d692139199c4..9c18c47540c7 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -723,6 +723,7 @@ config ARCH_KEYSTONE bool "TI Keystone" select CMD_POWEROFF select CPU_V7A + select DDR_SPD select GPIO_EXTRA_HEADER select SUPPORT_SPL select SYS_ARCH_TIMER diff --git a/drivers/ddr/Kconfig b/drivers/ddr/Kconfig index d4b393d25e07..0b767acee811 100644 --- a/drivers/ddr/Kconfig +++ b/drivers/ddr/Kconfig @@ -1,2 +1,8 @@ +config DDR_SPD + bool "JEDEC Serial Presence Detect (SPD) support" + help + For memory controllers that can utilize it, add enable support for + using the JEDEC SDP standard. + source "drivers/ddr/altera/Kconfig" source "drivers/ddr/imx/Kconfig" diff --git a/drivers/ddr/fsl/Kconfig b/drivers/ddr/fsl/Kconfig index 8246f627982c..6461a54d7a8e 100644 --- a/drivers/ddr/fsl/Kconfig +++ b/drivers/ddr/fsl/Kconfig @@ -116,22 +116,26 @@ choice config SYS_FSL_DDR4 bool "Freescale DDR4 controller" depends on SYS_FSL_HAS_DDR4 + imply DDR_SPD select SYS_FSL_DDRC_GEN4 config SYS_FSL_DDR3 bool "Freescale DDR3 controller" depends on SYS_FSL_HAS_DDR3 + imply DDR_SPD select SYS_FSL_DDRC_GEN3 if PPC select SYS_FSL_DDRC_ARM_GEN3 if ARM config SYS_FSL_DDR2 bool "Freescale DDR2 controller" depends on SYS_FSL_HAS_DDR2 + imply DDR_SPD select SYS_FSL_DDRC_GEN2 if (!MPC86xx && !SYS_FSL_DDRC_GEN3) config SYS_FSL_DDR1 bool "Freescale DDR1 controller" depends on SYS_FSL_HAS_DDR1 + imply DDR_SPD select SYS_FSL_DDRC_GEN1 endchoice -- 2.17.1
[PATCH 3/9] mvebu: Migrate CONFIG_DDR_32BIT/64BIT to Kconfig
Move CONFIG_DDR_32BIT/64BIT to Kconfig as a choice for Armada XP platforms. Make 64bit the default as this mirrors the current code. Cc: Marek BehĂșn Cc: Stefan Roese Signed-off-by: Tom Rini --- arch/arm/mach-mvebu/Kconfig | 13 + configs/ds414_defconfig | 1 + include/configs/ds414.h | 3 --- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 89737a37ad9e..1daa64763b03 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -184,6 +184,19 @@ config TARGET_CRS3XX_98DX3236 endchoice +choice + prompt "DDR bus width" + default DDR_64BIT + depends on ARMADA_XP + +config DDR_64BIT + bool "64bit bus width" + +config DDR_32BIT + bool "32bit bus width" + +endchoice + config SYS_BOARD default "clearfog" if TARGET_CLEARFOG default "helios4" if TARGET_HELIOS4 diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig index bfe2e5f4fe70..d3fb1dcd40b1 100644 --- a/configs/ds414_defconfig +++ b/configs/ds414_defconfig @@ -7,6 +7,7 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_DS414=y +CONFIG_DDR_32BIT=y CONFIG_ENV_SIZE=0x1 CONFIG_ENV_OFFSET=0x7E CONFIG_ENV_SECT_SIZE=0x1 diff --git a/include/configs/ds414.h b/include/configs/ds414.h index 5d401281c7e6..66bbff71a948 100644 --- a/include/configs/ds414.h +++ b/include/configs/ds414.h @@ -67,9 +67,6 @@ #define CONFIG_SPL_STACK (0x4000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE(CONFIG_SPL_STACK + 4) -/* DS414 bus width is 32bits */ -#define CONFIG_DDR_32BIT - /* Default Environment */ #define CONFIG_LOADADDR0x8 #define CONFIG_BOOTCOMMAND \ -- 2.17.1
[PATCH 4/9] mvebu: ddr: Rename CONFIG_DDR_FIXED_SIZE to CONFIG_SYS_SDRAM_SIZE
We have a number of CONFIG symbols to express the fixed size of system memory. For now, rename CONFIG_DDR_FIXED_SIZE to CONFIG_SYS_SDRAM_SIZE and adjust usage to match that CONFIG_SYS_SDRAM_SIZE expects the entire size rather than MiB. Cc: Marek BehĂșn Cc: Stefan Roese Signed-off-by: Tom Rini --- drivers/ddr/marvell/axp/ddr3_axp.h | 4 ++-- include/configs/maxbcm.h | 4 +++- include/configs/theadorable.h | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/ddr/marvell/axp/ddr3_axp.h b/drivers/ddr/marvell/axp/ddr3_axp.h index 270691e9bcd3..970651f87029 100644 --- a/drivers/ddr/marvell/axp/ddr3_axp.h +++ b/drivers/ddr/marvell/axp/ddr3_axp.h @@ -19,10 +19,10 @@ #define FAR_END_DIMM_ADDR 0x50 #define MAX_DIMM_ADDR 0x60 -#ifndef CONFIG_DDR_FIXED_SIZE +#ifndef CONFIG_SYS_SDRAM_SIZE #define SDRAM_CS_SIZE 0xFFF #else -#define SDRAM_CS_SIZE (CONFIG_DDR_FIXED_SIZE - 1) +#define SDRAM_CS_SIZE ((CONFIG_SYS_SDRAM_SIZE >> 10) - 1) #endif #define SDRAM_CS_BASE 0x0 #define SDRAM_DIMM_SIZE0x8000 diff --git a/include/configs/maxbcm.h b/include/configs/maxbcm.h index fc2393204bec..5098f12f5425 100644 --- a/include/configs/maxbcm.h +++ b/include/configs/maxbcm.h @@ -6,6 +6,8 @@ #ifndef _CONFIG_DB_MV7846MP_GP_H #define _CONFIG_DB_MV7846MP_GP_H +#include + /* * High Level Configuration Options (easy to change) */ @@ -65,7 +67,7 @@ /* SPL related SPI defines */ /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ -#define CONFIG_DDR_FIXED_SIZE (1 << 20) /* 1GiB */ +#define CONFIG_SYS_SDRAM_SIZE SZ_1G #define CONFIG_BOARD_ECC_SUPPORT /* this board supports ECC */ #endif /* _CONFIG_DB_MV7846MP_GP_H */ diff --git a/include/configs/theadorable.h b/include/configs/theadorable.h index 760713d3ef87..abc48ff44ca5 100644 --- a/include/configs/theadorable.h +++ b/include/configs/theadorable.h @@ -6,6 +6,8 @@ #ifndef _CONFIG_THEADORABLE_H #define _CONFIG_THEADORABLE_H +#include + /* * High Level Configuration Options (easy to change) */ @@ -93,6 +95,6 @@ #define CONFIG_SPL_BOOTROM_SAVE(CONFIG_SPL_STACK + 4) /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ -#define CONFIG_DDR_FIXED_SIZE (2 << 20) /* 2GiB */ +#define CONFIG_SYS_SDRAM_SIZE SZ_2G #endif /* _CONFIG_THEADORABLE_H */ -- 2.17.1
[PATCH 2/9] global: Remove unused or unnecessary CONFIG symbols related to DDR
These symbols are now either unused or were only used within the config file to determine other logic, which could be done in a way that doesn't further pollute the CONFIG namespace. Signed-off-by: Tom Rini --- arch/powerpc/cpu/mpc83xx/spd_sdram.c | 10 --- arch/powerpc/include/asm/config.h | 3 +- board/freescale/mpc8349emds/mpc8349emds.c | 23 --- drivers/dma/fsl_dma.c | 4 +-- include/configs/MPC8349EMDS.h | 36 --- include/configs/MPC8349EMDS_SDRAM.h | 36 --- include/configs/MPC837XERDB.h | 8 - include/configs/UCP1020.h | 9 -- include/configs/km/km-mpc83xx.h | 1 - include/configs/socrates.h| 1 - post/cpu/mpc83xx/ecc.c| 5 11 files changed, 2 insertions(+), 134 deletions(-) diff --git a/arch/powerpc/cpu/mpc83xx/spd_sdram.c b/arch/powerpc/cpu/mpc83xx/spd_sdram.c index a861e8dd2ddc..e12043b26093 100644 --- a/arch/powerpc/cpu/mpc83xx/spd_sdram.c +++ b/arch/powerpc/cpu/mpc83xx/spd_sdram.c @@ -834,12 +834,6 @@ long int spd_sdram() #endif debug(" DDRC ECC mode: %s\n", ddrc_ecc_enable ? "ON":"OFF"); -#if defined(CONFIG_DDR_2T_TIMING) - /* -* Enable 2T timing by setting sdram_cfg[16]. -*/ - sdram_cfg |= SDRAM_CFG_2T_EN; -#endif /* Enable controller, and GO! */ ddr->sdram_cfg = sdram_cfg; sync(); @@ -914,16 +908,12 @@ void ddr_enable_ecc(unsigned int dram_size) pattern[0] = 0xdeadbeef; pattern[1] = 0xdeadbeef; -#if defined(CONFIG_DDR_ECC_INIT_VIA_DMA) - dma_meminit(pattern[0], dram_size); -#else debug("ddr init: CPU FP write method\n"); size = dram_size; for (p = 0; p < (u64*)(size); p++) { ppcDWstore((u32*)p, pattern); } sync(); -#endif t_end = get_tbms(); icache_disable(); diff --git a/arch/powerpc/include/asm/config.h b/arch/powerpc/include/asm/config.h index 2c96378efef8..2a78551ce39c 100644 --- a/arch/powerpc/include/asm/config.h +++ b/arch/powerpc/include/asm/config.h @@ -28,8 +28,7 @@ /* Check if boards need to enable FSL DMA engine for SDRAM init */ #if !defined(CONFIG_FSL_DMA) && defined(CONFIG_DDR_ECC) -#if (defined(CONFIG_MPC83xx) && defined(CONFIG_DDR_ECC_INIT_VIA_DMA)) || \ - ((defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) && \ +#if ((defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)) && \ !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)) #define CONFIG_FSL_DMA #endif diff --git a/board/freescale/mpc8349emds/mpc8349emds.c b/board/freescale/mpc8349emds/mpc8349emds.c index 5f38639afd42..861cf5d6b7ec 100644 --- a/board/freescale/mpc8349emds/mpc8349emds.c +++ b/board/freescale/mpc8349emds/mpc8349emds.c @@ -102,21 +102,6 @@ int fixed_sdram(void) #if (CONFIG_SYS_DDR_SIZE != 256) #warning Currenly any ddr size other than 256 is not supported #endif -#ifdef CONFIG_DDR_II - im->ddr.csbnds[2].csbnds = CONFIG_SYS_DDR_CS2_BNDS; - im->ddr.cs_config[2] = CONFIG_SYS_DDR_CS2_CONFIG; - im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; - im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; - im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; - im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3; - im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG; - im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2; - im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE; - im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2; - im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL; - im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL; -#else - #if ((CONFIG_SYS_SDRAM_BASE & 0x00FF) != 0) #warning Chip select bounds is only configurable in 16MB increments #endif @@ -136,18 +121,10 @@ int fixed_sdram(void) im->ddr.sdram_cfg = SDRAM_CFG_SREN -#if defined(CONFIG_DDR_2T_TIMING) - | SDRAM_CFG_2T_EN -#endif | 2 << SDRAM_CFG_SDRAM_TYPE_SHIFT; -#if defined (CONFIG_DDR_32BIT) - /* for 32-bit mode burst length is 8 */ - im->ddr.sdram_cfg |= (SDRAM_CFG_32_BE | SDRAM_CFG_8_BE); -#endif im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE; im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL; -#endif udelay(200); /* enable DDR controller */ diff --git a/drivers/dma/fsl_dma.c b/drivers/dma/fsl_dma.c index b7eddf0f04c5..1864b5d88b08 100644 --- a/drivers/dma/fsl_dma.c +++ b/drivers/dma/fsl_dma.c @@ -130,11 +130,9 @@ int dmacpy(phys_addr_t dest, phys_addr_t src, phys_size_t count) { /* * 85xx/86xx use dma to initialize SDRAM when !CONFIG_ECC_INIT_VIA_DDRCONTROLLER - * while 83xx uses dma to initialize SDRAM when CONFIG_DDR_ECC_INIT_VIA_DMA */ #if ((!defined CONFIG_MPC83xx && defined(CONFIG_DDR_ECC) &&\ - !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)) || \ - (defined(CONFIG_MPC83xx) && defined(CONFIG_DDR_ECC_INIT_VI
[PATCH 1/9] Kconfig: Use spaces not tabs in Kconfig entires
While the Kconfig language seems to accept either form of whitespace, we use a space throughout the project, except in these spots. Signed-off-by: Tom Rini --- arch/arm/mach-exynos/Kconfig | 2 +- board/freescale/mx6memcal/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 0b4276c03628..7df0e176179d 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -141,7 +141,7 @@ if ARCH_EXYNOS7 choice prompt "EXYNOS7 board select" -config TARGET_ESPRESSO7420 +config TARGET_ESPRESSO7420 bool "ESPRESSO7420 board" select ARM64 select ARMV8_MULTIENTRY diff --git a/board/freescale/mx6memcal/Kconfig b/board/freescale/mx6memcal/Kconfig index 9987cba5dcb7..481403ae855d 100644 --- a/board/freescale/mx6memcal/Kconfig +++ b/board/freescale/mx6memcal/Kconfig @@ -87,12 +87,12 @@ choice help Select the type of DDR (DDR3 or LPDDR2) used on your design -config DDR3 +config DDR3 bool "DDR3" help Select this if your board design uses DDR3. -config LPDDR2 +config LPDDR2 bool "LPDDR2" help Select this if your board design uses LPDDR2. -- 2.17.1
[u-boot-test-hooks PATCH] travis-ci: Correct the memory size for Xilinx Zynq QEMU
Currently the memory is specified to be an insane size of about 38TB. This happens to be not an issue with QEMU 4.2.0 which is what U-Boot CI is currently using, but it does not make newer QEMU (e.g.: 6.0.0) happy. Change it to use a 1G memory size. Fixes: 4fcc1d95a39f ("Add support for Xilinx Zynq Virtual platform") Signed-off-by: Bin Meng --- bin/travis-ci/conf.xilinx_zynq_virt_qemu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/travis-ci/conf.xilinx_zynq_virt_qemu b/bin/travis-ci/conf.xilinx_zynq_virt_qemu index eef7904..a6af659 100644 --- a/bin/travis-ci/conf.xilinx_zynq_virt_qemu +++ b/bin/travis-ci/conf.xilinx_zynq_virt_qemu @@ -21,7 +21,7 @@ console_impl=qemu qemu_machine="xilinx-zynq-a9" qemu_binary="qemu-system-arm" -qemu_extra_args="-display none -m 4000 -nographic -serial /dev/null -serial mon:stdio -monitor null" +qemu_extra_args="-display none -m 1G -nographic -serial /dev/null -serial mon:stdio -monitor null" qemu_kernel_args="-device loader,file=${U_BOOT_BUILD_DIR}/u-boot-dtb.bin,addr=0x400,cpu-num=0" reset_impl=none flash_impl=none -- 2.25.1
[u-boot-test-hooks PATCH] Update Contributing.md with up-to-date information
As Stephen is no longer actively maintaining the uboot-test-hooks, and the repo itself has been moved to source.denx.de, update the Contributing.md with up-to-date information on how patches should be sent against this repo. Signed-off-by: Bin Meng --- Contributing.md | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Contributing.md b/Contributing.md index e8bcfc4..b1f78a8 100644 --- a/Contributing.md +++ b/Contributing.md @@ -1,16 +1,14 @@ -To add patches to this repo, please either: +To add patches to this repo, please send the patch via email, at least: -a) Submit a github pull request. - -b) Send the patch via email, at least: - -To: swar...@nvidia.com +To: "Tom Rini " Cc: u-boot@lists.denx.de -With a subject prefix of "[PATCH test hooks]", i.e.: +With a subject prefix of "[u-boot-test-hooks PATCH]", i.e.: + +git format-patch --subject-prefix='u-boot-test-hooks PATCH' ... -git format-patch --subject-prefix='PATCH test hooks' ... +or using patman with "Series-prefix: u-boot-test-hooks" to generate the patch. You will need to include a signed-off-by line in your patch. See https://developercertificate.org/ for the meaning of this. -- 2.25.1