Re: [U-Boot] [PATCH 2/4] dts: socfpga: Add trigger-address property to QSPI device
On 05/18/2017 08:26 PM, Rush, Jason A. wrote: > Add the 'cdns,trigger-address' property to the cadence QSPI device > node for Altera SoC devices. > > Signed-off-by: Jason A. Rush +CC Dinh, is that address correct ? I think there was some discussion. Jason, I'd rather prefer if you sent this as a series (with git send-email) not as a set of separate patches. Also, I'd prefer if you would just sync up the whole block with standard agreed-upon (linux) DT bindings and then ev. tweak the driver. > --- > arch/arm/dts/socfpga.dtsi | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi > index 8588221e57..abf0648a6f 100644 > --- a/arch/arm/dts/socfpga.dtsi > +++ b/arch/arm/dts/socfpga.dtsi > @@ -646,6 +646,7 @@ > num-cs = <4>; > fifo-depth = <128>; > sram-size = <128>; > + cdns,trigger-address = <0x>; > bus-num = <2>; > status = "disabled"; > }; > -- Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/3] x86: congatec: add secureboot enabled defconfig for conga-qeval20-qa3-e3845
Hi Bin, On Tue, 16 May 2017 22:39:17 +0800 Bin Meng bmeng...@gmail.com wrote: > Hi Anatolij, > > On Tue, May 16, 2017 at 3:55 PM, Anatolij Gustschin wrote: > > From: Markus Valentin > > > > Can you add a simple sentence for this commit? yes, will do in next version. ... > > +CONFIG_BAYTRAIL_SECURE_BOOT=y > > This commit should come in later in this patch series, as > CONFIG_BAYTRAIL_SECURE_BOOT is not available yet at this point. OK, will move it. -- Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v2 2/3] x86: baytrail: Add fsp-header verification for secure boot fsp
Hi Bin, On Tue, 16 May 2017 22:39:23 +0800 Bin Meng bmeng...@gmail.com wrote: > Hi Anatolij, > > On Tue, May 16, 2017 at 3:55 PM, Anatolij Gustschin wrote: > > From: Markus Valentin > > > > Introduce a new Kconfig variable for secure boot on baytrail based > > platforms. If this variable is set the build process tries to use > > fsp-sb.bin instead of fsp.bin (-sb is the secure boot enabled fsp). > > > > Also check the two fsp headers against each other and print if secure > > boot is enabled or not. > > > > Signed-off-by: Markus Valentin > > Signed-off-by: Anatolij Gustschin > > --- > > Changes in v2: > > - use if (IS_ENABLED(CONFIG_*)) instead of #ifdef > > - s/SB/Secure Boot/ > > - minor Kconfig help cleanup > > > > arch/x86/Kconfig | 13 - > > arch/x86/include/asm/fsp/fsp_support.h | 2 ++ > > arch/x86/lib/fsp/fsp_support.c | 18 ++ > > 3 files changed, 32 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > > index 9ead3eb..8cea393 100644 > > --- a/arch/x86/Kconfig > > +++ b/arch/x86/Kconfig > > @@ -348,7 +348,8 @@ config HAVE_FSP > > config FSP_FILE > > string "Firmware Support Package binary filename" > > depends on HAVE_FSP > > - default "fsp.bin" > > + default "fsp.bin" if !BAYTRAIL_SECURE_BOOT > > + default "fsp-sb.bin" if BAYTRAIL_SECURE_BOOT > > help > > The filename of the file to use as Firmware Support Package binary > > in the board directory. > > @@ -400,6 +401,16 @@ config FSP_BROKEN_HOB > > do not overwrite the important boot service data which is used by > > FSP, otherwise the subsequent call to fsp_notify() will fail. > > > > +config BAYTRAIL_SECURE_BOOT > > Should this be in arch/x86/cpu/baytrail/Kconfig instead? right, I'll move it to baytrail subdir. > > > + bool "Enable Secure Boot on BayTrail" > > + depends on HAVE_FSP > > + default n > > + help > > + Use the SecureBoot Features of the BayTrail platform. This switch > > > > nits: secure boot feature OK. > > + enables the usage of the secure-boot enabled fsp.bin (fsp-sb.bin) > > + for your board you need to provide this yourself. You can > > reconfigure > > + your fsp with the Intel BCT tool to enable SecureBoot. > > nits: secure boot OK. > > config ENABLE_MRC_CACHE > > bool "Enable MRC cache" > > depends on !EFI && !SYS_COREBOOT > > diff --git a/arch/x86/include/asm/fsp/fsp_support.h > > b/arch/x86/include/asm/fsp/fsp_support.h > > index 61d811f..bae17bc 100644 > > --- a/arch/x86/include/asm/fsp/fsp_support.h > > +++ b/arch/x86/include/asm/fsp/fsp_support.h > > @@ -21,6 +21,8 @@ > > #define FSP_LOWMEM_BASE0x10UL > > #define FSP_HIGHMEM_BASE 0x1ULL > > #define UPD_TERMINATOR 0x55AA > > +#define FSP_FIRST_HEADER_OFFSET0x94 > > +#define FSP_SECOND_HEADER_OFFSET 0x20494 > > Are these two offsets common to all FSP, or BayTrail-specific values? I think that 0x204094 is BayTrail-specific. 0x94 is common, I have seen this value in all FSP integration guide files, when it is documented there. > > diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c > > index a480361..0bbd9ae 100644 > > --- a/arch/x86/lib/fsp/fsp_support.c > > +++ b/arch/x86/lib/fsp/fsp_support.c > > @@ -120,6 +120,14 @@ void fsp_init(u32 stack_top, u32 boot_mode, void > > *nvs_buf) > > panic("Invalid FSP header"); > > } > > > > + if (IS_ENABLED(CONFIG_BAYTRAIL_SECURE_BOOT)) { > > + /* compare primary and secondary header */ > > + if (memcmp((void *)(CONFIG_FSP_ADDR + > > FSP_FIRST_HEADER_OFFSET), > > + (void *)(CONFIG_FSP_ADDR + > > FSP_SECOND_HEADER_OFFSET), > > + fsp_hdr->hdr_len)) > > + panic("Secure Boot: 1st & 2nd FSP headers don't > > match"); > > + } > > + > > config_data.common.fsp_hdr = fsp_hdr; > > config_data.common.stack_top = stack_top; > > config_data.common.boot_mode = boot_mode; > > @@ -134,6 +142,16 @@ void fsp_init(u32 stack_top, u32 boot_mode, void > > *nvs_buf) > > > > fsp_upd = &config_data.fsp_upd; > > > > + if (IS_ENABLED(CONFIG_BAYTRAIL_SECURE_BOOT)) { > > + /* > > +* if the enable secure boot flag is not 1, secure boot has > > not > > +* been activated in the FSP which results in the > > TXE-Engine not > > +* getting loaded > > +*/ > > + printf("FSP: Secure Boot %sabled\n", > > + fsp_vpd->enable_secure_boot == 1 ? "en" : "dis"); > > I believe this won't build for other FSP platforms due to no > enable_secure_boot member in fsp_vpd structure. Yes, this breaks crownbay_defconfig build. AFAI
Re: [U-Boot] [PATCH 2/2] drivers: net: fsl-mc: Include MAC addr fixup in DPL
> -Original Message- > From: york sun > Sent: Friday, May 19, 2017 12:04 AM > To: Bogdan Purcareata ; Prabhakar Kushwaha > ; u-boot@lists.denx.de > Cc: Heinz Wrobel > Subject: Re: [PATCH 2/2] drivers: net: fsl-mc: Include MAC addr fixup in > DPL > > On 05/18/2017 04:19 AM, Bogdan Purcareata wrote: > > Previous to MC v10.x, port mac address was specified via DPL. Since > > newer MC versions are compatible with old style DPLs, make the u-boot > > env mac addresses visible there. This applies only to DPLs that have an > > older version. > > > > DPLs use 32 bit values for specifying MAC addresses. U-boot environment > > variables take precedence over the MAC addresses already visible in the > > DPL/DPC. > > > > Signed-off-by: Bogdan Purcareata > > Signed-off-by: Heinz Wrobel > > --- > > drivers/net/fsl-mc/mc.c | 260 -- > -- > > 1 file changed, 197 insertions(+), 63 deletions(-) > > > > I see compiling warning about uninitialized variables "val" and "len". > Please fix. Thank you, will send v2. Regards, Bogdan P. ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v4 4/5] arm: socfpga: Move FPGA manager driver to FPGA driver
From: Tien Fong Chee Move FPGA manager driver which is Gen5 specific code from arch/arm/ into FPGA driver at driver/fpga/. No functional change. Signed-off-by: Tien Fong Chee --- arch/arm/mach-socfpga/Makefile | 1 - arch/arm/mach-socfpga/fpga_manager.c | 78 drivers/fpga/socfpga_gen5.c | 54 + 3 files changed, 54 insertions(+), 79 deletions(-) delete mode 100644 arch/arm/mach-socfpga/fpga_manager.c diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile index 286bfef..824cd8e 100644 --- a/arch/arm/mach-socfpga/Makefile +++ b/arch/arm/mach-socfpga/Makefile @@ -20,7 +20,6 @@ obj-y += reset_manager_gen5.o obj-y += scan_manager.o obj-y += system_manager_gen5.o obj-y += wrap_pll_config.o -obj-y += fpga_manager.o endif ifdef CONFIG_TARGET_SOCFPGA_ARRIA10 diff --git a/arch/arm/mach-socfpga/fpga_manager.c b/arch/arm/mach-socfpga/fpga_manager.c deleted file mode 100644 index f909573..000 --- a/arch/arm/mach-socfpga/fpga_manager.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2012 Altera Corporation - * All rights reserved. - * - * This file contains only support functions used also by the SoCFPGA - * platform code, the real meat is located in drivers/fpga/socfpga.c . - * - * SPDX-License-Identifier:BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -/* Timeout count */ -#define FPGA_TIMEOUT_CNT 0x100 - -static struct socfpga_fpga_manager *fpgamgr_regs = - (struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS; - -/* Check whether FPGA Init_Done signal is high */ -static int is_fpgamgr_initdone_high(void) -{ - unsigned long val; - - val = readl(&fpgamgr_regs->gpio_ext_porta); - return val & FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK; -} - -/* Get the FPGA mode */ -int fpgamgr_get_mode(void) -{ - unsigned long val; - - val = readl(&fpgamgr_regs->stat); - return val & FPGAMGRREGS_STAT_MODE_MASK; -} - -/* Check whether FPGA is ready to be accessed */ -int fpgamgr_test_fpga_ready(void) -{ - /* Check for init done signal */ - if (!is_fpgamgr_initdone_high()) - return 0; - - /* Check again to avoid false glitches */ - if (!is_fpgamgr_initdone_high()) - return 0; - - if (fpgamgr_get_mode() != FPGAMGRREGS_MODE_USERMODE) - return 0; - - return 1; -} - -/* Poll until FPGA is ready to be accessed or timeout occurred */ -int fpgamgr_poll_fpga_ready(void) -{ - unsigned long i; - - /* If FPGA is blank, wait till WD invoke warm reset */ - for (i = 0; i < FPGA_TIMEOUT_CNT; i++) { - /* check for init done signal */ - if (!is_fpgamgr_initdone_high()) - continue; - /* check again to avoid false glitches */ - if (!is_fpgamgr_initdone_high()) - continue; - return 1; - } - - return 0; -} diff --git a/drivers/fpga/socfpga_gen5.c b/drivers/fpga/socfpga_gen5.c index 3dfb030..d8f222a 100644 --- a/drivers/fpga/socfpga_gen5.c +++ b/drivers/fpga/socfpga_gen5.c @@ -21,6 +21,60 @@ static struct socfpga_fpga_manager *fpgamgr_regs = static struct socfpga_system_manager *sysmgr_regs = (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS; +/* Check whether FPGA Init_Done signal is high */ +static int is_fpgamgr_initdone_high(void) +{ + unsigned long val; + + val = readl(&fpgamgr_regs->gpio_ext_porta); + return val & FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK; +} + +/* Get the FPGA mode */ +int fpgamgr_get_mode(void) +{ + unsigned long val; + + val = readl(&fpgamgr_regs->stat); + return val & FPGAMGRREGS_STAT_MODE_MASK; +} + +/* Check whether FPGA is ready to be accessed */ +int fpgamgr_test_fpga_ready(void) +{ + /* Check for init done signal */ + if (!is_fpgamgr_initdone_high()) + return 0; + + /* Check again to avoid false glitches */ + if (!is_fpgamgr_initdone_high()) + return 0; + + if (fpgamgr_get_mode() != FPGAMGRREGS_MODE_USERMODE) + return 0; + + return 1; +} + +/* Poll until FPGA is ready to be accessed or timeout occurred */ +int fpgamgr_poll_fpga_ready(void) +{ + unsigned long i; + + /* If FPGA is blank, wait till WD invoke warm reset */ + for (i = 0; i < FPGA_TIMEOUT_CNT; i++) { + /* check for init done signal */ + if (!is_fpgamgr_initdone_high()) + continue; + /* check again to avoid false glitches */ + if (!is_fpgamgr_initdone_high()) + continue; + return 1; + } + + return 0; +} + /* Set CD ratio */ static void fpgamgr_set_cd_ratio(unsigned long ratio) { -- 1.8.2.3 _
[U-Boot] [PATCH v4 5/5] arm: socfpga: Add FPGA driver support for Arria 10
From: Tien Fong Chee Add FPGA driver support for Arria 10. Signed-off-by: Tien Fong Chee --- arch/arm/mach-socfpga/include/mach/fpga_manager.h | 2 + .../include/mach/fpga_manager_arria10.h| 100 + drivers/fpga/Makefile | 1 + drivers/fpga/socfpga_arria10.c | 479 + include/configs/socfpga_common.h | 3 +- 5 files changed, 583 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h create mode 100644 drivers/fpga/socfpga_arria10.c diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager.h b/arch/arm/mach-socfpga/include/mach/fpga_manager.h index b046c2c..a21c716 100644 --- a/arch/arm/mach-socfpga/include/mach/fpga_manager.h +++ b/arch/arm/mach-socfpga/include/mach/fpga_manager.h @@ -12,6 +12,8 @@ #if defined(CONFIG_TARGET_SOCFPGA_GEN5) #include +#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10) +#include #endif /* FPGA CD Ratio Value */ diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h new file mode 100644 index 000..9cbf696 --- /dev/null +++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2017 Intel Corporation + * All rights reserved. + * + * SPDX-License-Identifier:GPL-2.0 + */ + +#ifndef _FPGA_MANAGER_ARRIA10_H_ +#define _FPGA_MANAGER_ARRIA10_H_ + +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_CRC_ERROR_SET_MSK BIT(0) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK BIT(1) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_USERMODE_SET_MSK BIT(2) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_INITDONE_OE_SET_MSKBIT(3) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_NSTATUS_PIN_SET_MSKBIT(4) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_NSTATUS_OE_SET_MSK BIT(5) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_CONDONE_PIN_SET_MSKBIT(6) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_CONDONE_OE_SET_MSK BIT(7) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_CVP_CONF_DONE_SET_MSK BIT(8) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_PR_READY_SET_MSK BIT(9) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_PR_DONE_SET_MSKBIT(10) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_PR_ERROR_SET_MSK BIT(11) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_NCONFIG_PIN_SET_MSKBIT(12) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_NCEO_OE_SET_MSKBIT(13) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL0_SET_MSK BIT(16) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL1_SET_MSK BIT(17) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL2_SET_MSK BIT(18) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL_SET_MSD (\ + ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL0_SET_MSK |\ + ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL1_SET_MSK |\ + ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL2_SET_MSK) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_IMGCFG_FIFOEMPTY_SET_MSK BIT(24) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_IMGCFG_FIFOFULL_SET_MSKBIT(25) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_JTAGM_SET_MSK BIT(28) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_EMR_SET_MSKBIT(29) +#define ALT_FPGAMGR_IMGCFG_STAT_F2S_MSEL0_LSB 16 + +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_NENABLE_NCONFIG_SET_MSK BIT(0) +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_NENABLE_NSTATUS_SET_MSK BIT(1) +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_NENABLE_CONDONE_SET_MSK BIT(2) +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_NCONFIG_SET_MSK BIT(8) +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_NSTATUS_OE_SET_MSK BIT(16) +#define ALT_FPGAMGR_IMGCFG_CTL_00_S2F_CONDONE_OE_SET_MSK BIT(24) + +#define ALT_FPGAMGR_IMGCFG_CTL_01_S2F_NENABLE_CONFIG_SET_MSK BIT(0) +#define ALT_FPGAMGR_IMGCFG_CTL_01_S2F_PR_REQUEST_SET_MSK BIT(16) +#define ALT_FPGAMGR_IMGCFG_CTL_01_S2F_NCE_SET_MSK BIT(24) + +#define ALT_FPGAMGR_IMGCFG_CTL_02_EN_CFG_CTRL_SET_MSK BIT(0) +#define ALT_FPGAMGR_IMGCFG_CTL_02_EN_CFG_DATA_SET_MSK BIT(8) +#define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_SET_MSK 0x0003 +#define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24) +#define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB 16 + +#ifndef __ASSEMBLY__ + +struct socfpga_fpga_manager { + u32 _pad_0x0_0x7[2]; + u32 dclkcnt; + u32 dclkstat; + u32 gpo; + u32 gpi; + u32 misci; + u32 _pad_0x1c_0x2f[5]; + u32 emr_data0; + u32 emr_data1; + u32 emr_data2; + u32 emr_data3; + u32 emr_data4; + u32 emr_data5; + u32 emr_valid; + u32 emr_en; + u32 jtag_config; + u32 jtag_status; + u32 jtag_kick; + u32 _pad_0x5c_0x5f; + u32 jtag_data_w; + u32 jtag_data_r; + u32 _pad_0x68_0x6f[2]; + u32 imgcfg_ctrl_00; + u32 imgcfg_ctrl_01; + u32 imgcfg_ctrl_02; +
[U-Boot] [PATCH v4 3/5] arm: socfpga: Enable FPGA driver on SPL
From: Tien Fong Chee Enable FPGA driver build for SPL. FPGA driver is needed for SPL to configure and getting DDR up before loading U-boot into DDR and booting from there. Signed-off-by: Tien Fong Chee --- drivers/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/Makefile b/drivers/Makefile index 4a4b237..b4a2230 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/ obj-$(CONFIG_SPL_SATA_SUPPORT) += block/ obj-$(CONFIG_SPL_USB_HOST_SUPPORT) += block/ obj-$(CONFIG_SPL_MMC_SUPPORT) += block/ +obj-$(CONFIG_FPGA) += fpga/ endif ifdef CONFIG_TPL_BUILD -- 1.8.2.3 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v4 2/5] arm: socfpga: Restructure FPGA driver in the preparation to support A10.
From: Tien Fong Chee Move FPGA driver which is Gen5 specific code into Gen5 driver file and keeping common FPGA driver er intact. All the changes are still keeping in driver/fpga/ and no functional change. Subsequent patch would move FPGA manager driver from arch/arm into driver/fpga/ . Signed-off-by: Tien Fong Chee --- arch/arm/mach-socfpga/Makefile | 2 +- arch/arm/mach-socfpga/include/mach/fpga_manager.h | 68 +- .../mach/{fpga_manager.h => fpga_manager_gen5.h} | 69 +++--- drivers/fpga/Makefile | 1 + drivers/fpga/socfpga.c | 241 + drivers/fpga/{socfpga.c => socfpga_gen5.c} | 54 + 6 files changed, 49 insertions(+), 386 deletions(-) copy arch/arm/mach-socfpga/include/mach/{fpga_manager.h => fpga_manager_gen5.h} (57%) copy drivers/fpga/{socfpga.c => socfpga_gen5.c} (83%) diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile index 41b779c..286bfef 100644 --- a/arch/arm/mach-socfpga/Makefile +++ b/arch/arm/mach-socfpga/Makefile @@ -9,7 +9,6 @@ obj-y += board.o obj-y += clock_manager.o -obj-y += fpga_manager.o obj-y += misc.o obj-y += reset_manager.o obj-y += timer.o @@ -21,6 +20,7 @@ obj-y += reset_manager_gen5.o obj-y += scan_manager.o obj-y += system_manager_gen5.o obj-y += wrap_pll_config.o +obj-y += fpga_manager.o endif ifdef CONFIG_TARGET_SOCFPGA_ARRIA10 diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager.h b/arch/arm/mach-socfpga/include/mach/fpga_manager.h index a077e22..b046c2c 100644 --- a/arch/arm/mach-socfpga/include/mach/fpga_manager.h +++ b/arch/arm/mach-socfpga/include/mach/fpga_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Altera Corporation + * Copyright (C) 2012-2017 Altera Corporation * All rights reserved. * * SPDX-License-Identifier:BSD-3-Clause @@ -10,58 +10,9 @@ #include -struct socfpga_fpga_manager { - /* FPGA Manager Module */ - u32 stat; /* 0x00 */ - u32 ctrl; - u32 dclkcnt; - u32 dclkstat; - u32 gpo;/* 0x10 */ - u32 gpi; - u32 misci; /* 0x18 */ - u32 _pad_0x1c_0x82c[517]; - - /* Configuration Monitor (MON) Registers */ - u32 gpio_inten; /* 0x830 */ - u32 gpio_intmask; - u32 gpio_inttype_level; - u32 gpio_int_polarity; - u32 gpio_intstatus; /* 0x840 */ - u32 gpio_raw_intstatus; - u32 _pad_0x848; - u32 gpio_porta_eoi; - u32 gpio_ext_porta; /* 0x850 */ - u32 _pad_0x854_0x85c[3]; - u32 gpio_1s_sync; /* 0x860 */ - u32 _pad_0x864_0x868[2]; - u32 gpio_ver_id_code; - u32 gpio_config_reg2; /* 0x870 */ - u32 gpio_config_reg1; -}; - -#define FPGAMGRREGS_STAT_MODE_MASK 0x7 -#define FPGAMGRREGS_STAT_MSEL_MASK 0xf8 -#define FPGAMGRREGS_STAT_MSEL_LSB 3 - -#define FPGAMGRREGS_CTRL_CFGWDTH_MASK 0x200 -#define FPGAMGRREGS_CTRL_AXICFGEN_MASK 0x100 -#define FPGAMGRREGS_CTRL_NCONFIGPULL_MASK 0x4 -#define FPGAMGRREGS_CTRL_NCE_MASK 0x2 -#define FPGAMGRREGS_CTRL_EN_MASK 0x1 -#define FPGAMGRREGS_CTRL_CDRATIO_LSB 6 - -#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CRC_MASK0x8 -#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK 0x4 -#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CD_MASK 0x2 -#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_NS_MASK 0x1 - -/* FPGA Mode */ -#define FPGAMGRREGS_MODE_FPGAOFF 0x0 -#define FPGAMGRREGS_MODE_RESETPHASE0x1 -#define FPGAMGRREGS_MODE_CFGPHASE 0x2 -#define FPGAMGRREGS_MODE_INITPHASE 0x3 -#define FPGAMGRREGS_MODE_USERMODE 0x4 -#define FPGAMGRREGS_MODE_UNKNOWN 0x5 +#if defined(CONFIG_TARGET_SOCFPGA_GEN5) +#include +#endif /* FPGA CD Ratio Value */ #define CDRATIO_x1 0x0 @@ -69,9 +20,14 @@ struct socfpga_fpga_manager { #define CDRATIO_x4 0x2 #define CDRATIO_x8 0x3 -/* SoCFPGA support functions */ -int fpgamgr_test_fpga_ready(void); -int fpgamgr_poll_fpga_ready(void); +#ifndef __ASSEMBLY__ + +/* Common prototypes */ int fpgamgr_get_mode(void); +int fpgamgr_poll_fpga_ready(void); +void fpgamgr_program_write(const void *rbf_data, size_t rbf_size); +int fpgamgr_test_fpga_ready(void); +int fpgamgr_dclkcnt_set(unsigned long cnt); +#endif /* __ASSEMBLY__ */ #endif /* _FPGA_MANAGER_H_ */ diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager.h b/arch/arm/mach-socfpga/include/mach/fpga_manager_gen5.h similarity index 57% copy from arch/arm/mach-socfpga/include/mach/fpga_manager.h copy to arch/arm/mach-socfpga/include/mach/fpga_manager_gen5.h index a077e22..2de7a11 100644 --- a/arch/ar
[U-Boot] [PATCH v4 1/5] arm: socfpga: Remove unused passing parameter of socfpga_bridges_reset
From: Tien Fong Chee Remove parameter from socfpga_bridges_reset(), and keeping this function for single purpose which is just triggering reset on bridges. socfpga_reset_deassert_bridges_handoff() can be called for releasing reset on any bridges based on the bridge setting defined in fdt. Signed-off-by: Tien Fong Chee --- arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h | 2 +- arch/arm/mach-socfpga/reset_manager_arria10.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h index 7922db8..b6d7f4f 100644 --- a/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +++ b/arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h @@ -17,7 +17,7 @@ int socfpga_reset_deassert_bridges_handoff(void); void socfpga_reset_assert_fpga_connected_peripherals(void); void socfpga_reset_deassert_osc1wd0(void); void socfpga_reset_uart(int assert); -int socfpga_bridges_reset(int enable); +int socfpga_bridges_reset(void); struct socfpga_reset_manager { u32 stat; diff --git a/arch/arm/mach-socfpga/reset_manager_arria10.c b/arch/arm/mach-socfpga/reset_manager_arria10.c index d8c858c..66f1ec2 100644 --- a/arch/arm/mach-socfpga/reset_manager_arria10.c +++ b/arch/arm/mach-socfpga/reset_manager_arria10.c @@ -318,13 +318,13 @@ void socfpga_per_reset_all(void) } #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET) -int socfpga_bridges_reset(int enable) +int socfpga_bridges_reset(void) { /* For SoCFPGA-VT, this is NOP. */ return 0; } #else -int socfpga_bridges_reset(int enable) +int socfpga_bridges_reset(void) { int ret; -- 1.8.2.3 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v4 0/5] Add Intel Arria 10 SoC FPGA driver
From: Tien Fong Chee This is the 4th version of patchset to adds support for Intel Arria 10 SoC FPGA driver. This version mainly resolved comments from Ley Foon and Dinh in [v3]. This series is working on top of u-boot-socfpga-next branch http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=shortlog;h=refs/heads/next. [v3]: https://www.mail-archive.com/u-boot@lists.denx.de/msg249160.html v3 -> v4 changes: - - Fixed typo on patch 1 and patch 2. - Created separate patch for enabling FPGA driver build on SPL. - No change on patch 3. - Removed some unnecessary wrappers and unused function. Patchset history [v1]: https://www.mail-archive.com/u-boot@lists.denx.de/msg247788.html [v2]: https://www.mail-archive.com/u-boot@lists.denx.de/msg248541.html Tien Fong Chee (5): arm: socfpga: Remove unused passing parameter of socfpga_bridges_reset arm: socfpga: Restructure FPGA driver in the preparation to support A10. arm: socfpga: Enable FPGA driver on SPL arm: socfpga: Move FPGA manager driver to FPGA driver arm: socfpga: Add FPGA driver support for Arria 10 arch/arm/mach-socfpga/Makefile | 1 - arch/arm/mach-socfpga/fpga_manager.c | 78 arch/arm/mach-socfpga/include/mach/fpga_manager.h | 70 +-- .../include/mach/fpga_manager_arria10.h| 100 + .../mach/{fpga_manager.h => fpga_manager_gen5.h} | 69 ++- .../include/mach/reset_manager_arria10.h | 2 +- arch/arm/mach-socfpga/reset_manager_arria10.c | 4 +- drivers/Makefile | 1 + drivers/fpga/Makefile | 2 + drivers/fpga/socfpga.c | 241 +-- drivers/fpga/socfpga_arria10.c | 479 + drivers/fpga/{socfpga.c => socfpga_gen5.c} | 98 ++--- include/configs/socfpga_common.h | 3 +- 13 files changed, 684 insertions(+), 464 deletions(-) delete mode 100644 arch/arm/mach-socfpga/fpga_manager.c create mode 100644 arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h copy arch/arm/mach-socfpga/include/mach/{fpga_manager.h => fpga_manager_gen5.h} (57%) create mode 100644 drivers/fpga/socfpga_arria10.c copy drivers/fpga/{socfpga.c => socfpga_gen5.c} (85%) -- 1.8.2.3 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 63/72] cros_ec: Update the cros_ec keyboard driver to livetree
Update this driver and key_matrix to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/input/cros_ec_keyb.c | 24 drivers/input/key_matrix.c | 19 +-- drivers/input/tegra-kbc.c| 3 +-- include/key_matrix.h | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c index 00381dcd72..6fa35a63dd 100644 --- a/drivers/input/cros_ec_keyb.c +++ b/drivers/input/cros_ec_keyb.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -161,15 +160,15 @@ int cros_ec_kbc_check(struct input_config *input) * @param config Configuration data read from fdt * @return 0 if ok, -1 on error */ -static int cros_ec_keyb_decode_fdt(const void *blob, int node, - struct cros_ec_keyb_priv *config) +static int cros_ec_keyb_decode_fdt(struct udevice *dev, + struct cros_ec_keyb_priv *config) { /* * Get keyboard rows and columns - at present we are limited to * 8 columns by the protocol (one byte per row scan) */ - config->key_rows = fdtdec_get_int(blob, node, "keypad,num-rows", 0); - config->key_cols = fdtdec_get_int(blob, node, "keypad,num-columns", 0); + config->key_rows = dev_read_u32_default(dev, "keypad,num-rows", 0); + config->key_cols = dev_read_u32_default(dev, "keypad,num-columns", 0); if (!config->key_rows || !config->key_cols || config->key_rows * config->key_cols / 8 > CROS_EC_KEYSCAN_COLS) { @@ -177,8 +176,8 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node, config->key_rows, config->key_cols); return -1; } - config->ghost_filter = fdtdec_get_bool(blob, node, - "google,needs-ghost-filter"); + config->ghost_filter = dev_read_bool(dev, "google,needs-ghost-filter"); + return 0; } @@ -188,12 +187,13 @@ static int cros_ec_kbd_probe(struct udevice *dev) struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev); struct stdio_dev *sdev = &uc_priv->sdev; struct input_config *input = &uc_priv->input; - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev); int ret; - if (cros_ec_keyb_decode_fdt(blob, node, priv)) - return -1; + ret = cros_ec_keyb_decode_fdt(dev, priv); + if (ret) { + debug("%s: Cannot decode node (ret=%d)\n", __func__, ret); + return -EINVAL; + } input_set_delays(input, KBC_REPEAT_DELAY_MS, KBC_REPEAT_RATE_MS); ret = key_matrix_init(&priv->matrix, priv->key_rows, priv->key_cols, priv->ghost_filter); @@ -201,7 +201,7 @@ static int cros_ec_kbd_probe(struct udevice *dev) debug("%s: cannot init key matrix\n", __func__); return ret; } - ret = key_matrix_decode_fdt(&priv->matrix, gd->fdt_blob, node); + ret = key_matrix_decode_fdt(dev, &priv->matrix); if (ret) { debug("%s: Could not decode key matrix from fdt\n", __func__); return ret; diff --git a/drivers/input/key_matrix.c b/drivers/input/key_matrix.c index 8867e4964e..cd5bce3613 100644 --- a/drivers/input/key_matrix.c +++ b/drivers/input/key_matrix.c @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include @@ -105,7 +105,7 @@ int key_matrix_decode(struct key_matrix *config, struct key_matrix_key keys[], * @param pos Returns position of map_keycode, if found, else -1 * @return map Pointer to allocated map */ -static uchar *create_keymap(struct key_matrix *config, u32 *data, int len, +static uchar *create_keymap(struct key_matrix *config, const u32 *data, int len, int map_keycode, int *pos) { uchar *map; @@ -138,33 +138,32 @@ static uchar *create_keymap(struct key_matrix *config, u32 *data, int len, return map; } -int key_matrix_decode_fdt(struct key_matrix *config, const void *blob, int node) +int key_matrix_decode_fdt(struct udevice *dev, struct key_matrix *config) { - const struct fdt_property *prop; + const u32 *prop; int proplen; uchar *plain_keycode; - prop = fdt_get_property(blob, node, "linux,keymap", &proplen); + prop = dev_read_prop(dev, "linux,keymap", &proplen); /* Basic keymap is required */ if (!prop) { debug("%s: cannot find keycode-plain map\n", __func__); return -1; } - plain_keycode = create_keymap(config, (u32 *)prop->data, - proplen, KEY_FN, &config->fn_pos); + plain_keycode = create_keymap(config, prop, proplen, KEY_FN,
[U-Boot] [PATCH v3 71/72] dm: gpio: power: Convert pm8916 drivers to livetree
This PMIC driver (power and GPIO) is used by the sandbox SPMI tests. Update the drivers to support a live device tree so that the tests pass. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/gpio/pm8916_gpio.c | 8 +++- drivers/power/pmic/pm8916.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c index 8dea69f281..9ec2a24b3e 100644 --- a/drivers/gpio/pm8916_gpio.c +++ b/drivers/gpio/pm8916_gpio.c @@ -173,7 +173,7 @@ static int pm8916_gpio_probe(struct udevice *dev) struct pm8916_gpio_bank *priv = dev_get_priv(dev); int reg; - priv->pid = devfdt_get_addr(dev); + priv->pid = dev_read_addr(dev); if (priv->pid == FDT_ADDR_T_NONE) return -EINVAL; @@ -193,10 +193,8 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), -"gpio-count", 0); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), -"gpio-bank-name", NULL); + uc_priv->gpio_count = dev_read_u32_default(dev, "gpio-count", 0); + uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); if (uc_priv->bank_name == NULL) uc_priv->bank_name = "pm8916"; diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c index 3632ee2d1e..a048bbe7ce 100644 --- a/drivers/power/pmic/pm8916.c +++ b/drivers/power/pmic/pm8916.c @@ -70,7 +70,7 @@ static int pm8916_probe(struct udevice *dev) { struct pm8916_priv *priv = dev_get_priv(dev); - priv->usid = devfdt_get_addr(dev); + priv->usid = dev_read_addr(dev); if (priv->usid == FDT_ADDR_T_NONE) return -EINVAL; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 51/72] dm: clk: Update uclass to support livetree
Update the clk uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/clk/clk-uclass.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index f6194b60f9..83b63288fb 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -58,23 +58,22 @@ static int clk_of_xlate_default(struct clk *clk, int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) { int ret; - struct fdtdec_phandle_args args; + struct ofnode_phandle_args args; struct udevice *dev_clk; struct clk_ops *ops; debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk); assert(clk); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), -"clocks", "#clock-cells", 0, index, -&args); + ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0, + index, &args); if (ret) { debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n", __func__, ret); return ret; } - ret = uclass_get_device_by_of_offset(UCLASS_CLK, args.node, &dev_clk); + ret = uclass_get_device_by_ofnode(UCLASS_CLK, args.node, &dev_clk); if (ret) { debug("%s: uclass_get_device_by_of_offset failed: err=%d\n", __func__, ret); @@ -86,10 +85,9 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) ops = clk_dev_ops(dev_clk); if (ops->of_xlate) - ret = ops->of_xlate(clk, (struct ofnode_phandle_args *)&args); + ret = ops->of_xlate(clk, &args); else - ret = clk_of_xlate_default(clk, - (struct ofnode_phandle_args *)&args); + ret = clk_of_xlate_default(clk, &args); if (ret) { debug("of_xlate() failed: %d\n", ret); return ret; @@ -105,8 +103,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk) debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk); - index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), - "clock-names", name); + index = dev_read_stringlist_search(dev, "clock-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); return index; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 66/72] dm: sandbox: i2c_rtc: Drop fdtdec.h header
This is not needed in this driver. Drop it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/rtc/i2c_rtc_emul.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c index 20827fdff1..0e06c97367 100644 --- a/drivers/rtc/i2c_rtc_emul.c +++ b/drivers/rtc/i2c_rtc_emul.c @@ -16,7 +16,6 @@ #include #include -#include #include #include #include -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 52/72] dm: clk: fixed: Update to support livetree
Update the fixed-rate clock driver to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/clk/clk_fixed_rate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index 1cac4bbb85..63565b6ed8 100644 --- a/drivers/clk/clk_fixed_rate.c +++ b/drivers/clk/clk_fixed_rate.c @@ -31,9 +31,8 @@ const struct clk_ops clk_fixed_rate_ops = { static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) - to_clk_fixed_rate(dev)->fixed_rate = - fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "clock-frequency", 0); + to_clk_fixed_rate(dev)->fixed_rate = dev_read_u32_default(dev, + "clock-frequency", 0); #endif return 0; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 67/72] dm: spi-flash: Convert uclass to livetree
Update the SPI flash uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/mtd/spi/spi_flash.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index ab7910bc14..0034a28d5f 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -914,14 +914,13 @@ static int set_quad_mode(struct spi_flash *flash, } #if CONFIG_IS_ENABLED(OF_CONTROL) -int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) +int spi_flash_decode_fdt(struct spi_flash *flash) { #ifdef CONFIG_DM_SPI_FLASH fdt_addr_t addr; fdt_size_t size; - int node = dev_of_offset(flash->dev); - addr = fdtdec_get_addr_size(blob, node, "memory-map", &size); + addr = dev_read_addr_size(flash->dev, "memory-map", &size); if (addr == FDT_ADDR_T_NONE) { debug("%s: Cannot decode address\n", __func__); return 0; @@ -1081,7 +1080,7 @@ int spi_flash_scan(struct spi_flash *flash) #endif #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) - ret = spi_flash_decode_fdt(gd->fdt_blob, flash); + ret = spi_flash_decode_fdt(flash); if (ret) { debug("SF: FDT decode error\n"); return -EINVAL; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 31/72] dm: gpio: Add live tree support
Add support for requesting GPIOs with a live device tree. This involves adjusting the function signature for the legacy function gpio_request_by_name_nodev(), so fix up all callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None board/qualcomm/dragonboard410c/dragonboard410c.c | 12 +++--- board/samsung/common/board.c | 4 +- board/samsung/common/exynos5-dt.c| 2 +- drivers/gpio/gpio-uclass.c | 51 +++- drivers/i2c/mxc_i2c.c| 12 +++--- drivers/mmc/fsl_esdhc.c | 6 +-- drivers/mmc/s5p_sdhci.c | 8 ++-- drivers/mtd/nand/sunxi_nand.c| 2 +- drivers/mtd/nand/tegra_nand.c| 4 +- drivers/net/pic32_eth.c | 3 +- drivers/sound/max98095.c | 2 + drivers/sound/wm8994.c | 2 +- drivers/spi/pic32_spi.c | 2 +- drivers/usb/host/ehci-tegra.c| 7 ++-- drivers/usb/host/ehci-vf.c | 5 ++- include/asm-generic/gpio.h | 10 ++--- 16 files changed, 65 insertions(+), 67 deletions(-) diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c index e923ddc2e2..37d0b85e0e 100644 --- a/board/qualcomm/dragonboard410c/dragonboard410c.c +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c @@ -53,8 +53,8 @@ int board_prepare_usb(enum usb_init_type type) printf("Failed to find usb_hub_reset_pm dt node.\n"); return node; } - ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "gpios", 0, -&hub_reset, 0); + ret = gpio_request_by_name_nodev(offset_to_ofnode(node), +"gpios", 0, &hub_reset, 0); if (ret < 0) { printf("Failed to request usb_hub_reset_pm gpio.\n"); return ret; @@ -69,8 +69,8 @@ int board_prepare_usb(enum usb_init_type type) printf("Failed to find usb_sw_sel_pm dt node.\n"); return 0; } - ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "gpios", 0, -&usb_sel, 0); + ret = gpio_request_by_name_nodev(offset_to_ofnode(node), +"gpios", 0, &usb_sel, 0); if (ret < 0) { printf("Failed to request usb_sw_sel_pm gpio.\n"); return ret; @@ -121,8 +121,8 @@ int misc_init_r(void) return 0; } - if (gpio_request_by_name_nodev(gd->fdt_blob, node, "gpios", 0, &resin, - 0)) { + if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0, + &resin, 0)) { printf("Failed to request key_vol_down button.\n"); return 0; } diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c index 17626966aa..88299f17e3 100644 --- a/board/samsung/common/board.c +++ b/board/samsung/common/board.c @@ -351,8 +351,8 @@ void reset_misc(void) if (node < 0) return; - gpio_request_by_name_nodev(gd->fdt_blob, node, "reset-gpio", 0, &gpio, - GPIOD_IS_OUT); + gpio_request_by_name_nodev(offset_to_ofnode(node), "reset-gpio", 0, + &gpio, GPIOD_IS_OUT); if (dm_gpio_is_valid(&gpio)) { /* diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c index aec1f396b0..44f412db5d 100644 --- a/board/samsung/common/exynos5-dt.c +++ b/board/samsung/common/exynos5-dt.c @@ -45,7 +45,7 @@ static void board_enable_audio_codec(void) if (node <= 0) return; - ret = gpio_request_by_name_nodev(gd->fdt_blob, node, + ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "codec-enable-gpio", 0, &en_gpio, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); if (ret == -FDT_ERR_NOTFOUND) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 92a1346aa2..f611996f17 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -683,45 +683,41 @@ err: return ret; } -static int _gpio_request_by_name_nodev(const void *blob, int node, - const char *list_name, int index, - struct gpio_desc *desc, int flags, - bool add_index) +static int _gpio_request_by_name_nodev(ofnode no
[U-Boot] [PATCH v3 60/72] dm: reset: Update uclass to support livetree
Update the reset domain uclass to support livetree. Fix the xlate() method which has no callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/reset/reset-uclass.c | 21 ++--- include/reset-uclass.h | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c index e92b24fa34..de3695ffaa 100644 --- a/drivers/reset/reset-uclass.c +++ b/drivers/reset/reset-uclass.c @@ -18,7 +18,7 @@ static inline struct reset_ops *reset_dev_ops(struct udevice *dev) } static int reset_of_xlate_default(struct reset_ctl *reset_ctl, - struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { debug("%s(reset_ctl=%p)\n", __func__, reset_ctl); @@ -35,7 +35,7 @@ static int reset_of_xlate_default(struct reset_ctl *reset_ctl, int reset_get_by_index(struct udevice *dev, int index, struct reset_ctl *reset_ctl) { - struct fdtdec_phandle_args args; + struct ofnode_phandle_args args; int ret; struct udevice *dev_reset; struct reset_ops *ops; @@ -43,20 +43,20 @@ int reset_get_by_index(struct udevice *dev, int index, debug("%s(dev=%p, index=%d, reset_ctl=%p)\n", __func__, dev, index, reset_ctl); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), -"resets", "#reset-cells", 0, -index, &args); + ret = dev_read_phandle_with_args(dev, "resets", "#reset-cells", 0, + index, &args); if (ret) { - debug("%s: fdtdec_parse_phandle_with_args failed: %d\n", + debug("%s: fdtdec_parse_phandle_with_args() failed: %d\n", __func__, ret); return ret; } - ret = uclass_get_device_by_of_offset(UCLASS_RESET, args.node, -&dev_reset); + ret = uclass_get_device_by_ofnode(UCLASS_RESET, args.node, + &dev_reset); if (ret) { - debug("%s: uclass_get_device_by_of_offset failed: %d\n", + debug("%s: uclass_get_device_by_ofnode() failed: %d\n", __func__, ret); + debug("%s %d\n", ofnode_get_name(args.node), args.args[0]); return ret; } ops = reset_dev_ops(dev_reset); @@ -88,8 +88,7 @@ int reset_get_by_name(struct udevice *dev, const char *name, debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name, reset_ctl); - index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), - "reset-names", name); + index = dev_read_stringlist_search(dev, "reset-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); return index; diff --git a/include/reset-uclass.h b/include/reset-uclass.h index 38c716ff89..50fbeb10d6 100644 --- a/include/reset-uclass.h +++ b/include/reset-uclass.h @@ -11,7 +11,7 @@ #include -struct fdtdec_phandle_args; +struct ofnode_phandle_args; struct udevice; /** @@ -38,7 +38,7 @@ struct reset_ops { * @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct reset_ctl *reset_ctl, - struct fdtdec_phandle_args *args); + struct ofnode_phandle_args *args); /** * request - Request a translated reset control. * -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 49/72] sandbox: usb: Convert emulators to livetree
Update the sandbox flash and hub USB emulators to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/usb/emul/sandbox_flash.c | 4 +--- drivers/usb/emul/sandbox_hub.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/usb/emul/sandbox_flash.c b/drivers/usb/emul/sandbox_flash.c index 9abb323745..73fa82b8e6 100644 --- a/drivers/usb/emul/sandbox_flash.c +++ b/drivers/usb/emul/sandbox_flash.c @@ -371,10 +371,8 @@ err: static int sandbox_flash_ofdata_to_platdata(struct udevice *dev) { struct sandbox_flash_plat *plat = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; - plat->pathname = fdt_getprop(blob, dev_of_offset(dev), -"sandbox,filepath", NULL); + plat->pathname = dev_read_string(dev, "sandbox,filepath"); return 0; } diff --git a/drivers/usb/emul/sandbox_hub.c b/drivers/usb/emul/sandbox_hub.c index f0939b19f4..9ffda9cc74 100644 --- a/drivers/usb/emul/sandbox_hub.c +++ b/drivers/usb/emul/sandbox_hub.c @@ -277,8 +277,7 @@ static int sandbox_child_post_bind(struct udevice *dev) { struct sandbox_hub_platdata *plat = dev_get_parent_platdata(dev); - plat->port = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", - -1); + plat->port = dev_read_u32_default(dev, "reg", -1); return 0; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 57/72] dm: phy: Update uclass to support livetree
Update the phy uclass to support livetree. Fix the xlate() method which has no callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/phy/phy-uclass.c | 21 + include/generic-phy.h| 3 +-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 0d8bef76db..d8b8d58e44 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -17,7 +17,7 @@ static inline struct phy_ops *phy_dev_ops(struct udevice *dev) } static int generic_phy_xlate_offs_flags(struct phy *phy, -struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { debug("%s(phy=%p)\n", __func__, phy); @@ -31,14 +31,13 @@ static int generic_phy_xlate_offs_flags(struct phy *phy, else phy->id = 0; - return 0; } int generic_phy_get_by_index(struct udevice *dev, int index, struct phy *phy) { - struct fdtdec_phandle_args args; + struct ofnode_phandle_args args; struct phy_ops *ops; int ret; struct udevice *phydev; @@ -46,18 +45,17 @@ int generic_phy_get_by_index(struct udevice *dev, int index, debug("%s(dev=%p, index=%d, phy=%p)\n", __func__, dev, index, phy); assert(phy); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), -"phys", "#phy-cells", 0, index, -&args); + ret = dev_read_phandle_with_args(dev, "phys", "#phy-cells", 0, index, +&args); if (ret) { - debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n", + debug("%s: dev_read_phandle_with_args failed: err=%d\n", __func__, ret); return ret; } - ret = uclass_get_device_by_of_offset(UCLASS_PHY, args.node, &phydev); + ret = uclass_get_device_by_ofnode(UCLASS_PHY, args.node, &phydev); if (ret) { - debug("%s: uclass_get_device_by_of_offset failed: err=%d\n", + debug("%s: uclass_get_device_by_ofnode failed: err=%d\n", __func__, ret); return ret; } @@ -88,10 +86,9 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, debug("%s(dev=%p, name=%s, phy=%p)\n", __func__, dev, phy_name, phy); - index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), - "phy-names", phy_name); + index = dev_read_stringlist_search(dev, "phy-names", phy_name); if (index < 0) { - debug("fdt_stringlist_search() failed: %d\n", index); + debug("dev_read_stringlist_search() failed: %d\n", index); return index; } diff --git a/include/generic-phy.h b/include/generic-phy.h index d8cf0c9f6a..762704c208 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -50,8 +50,7 @@ struct phy_ops { * @args: The phy specifier values from device tree. * @return 0 if OK, or a negative error code. */ - int (*of_xlate)(struct phy *phy, - struct fdtdec_phandle_args *args); + int (*of_xlate)(struct phy *phy, struct ofnode_phandle_args *args); /** * init - initialize the hardware. -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 46/72] dm: mmc: Convert uclass to livetree
Update the mmc uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/mmc/mmc-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 91f6fc5753..994d2686f4 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -204,7 +204,8 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) #endif #ifndef CONFIG_SPL_BUILD /* Use the fixed index with aliase node's index */ - fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev_of_offset(dev), &devnum); + ret = dev_read_alias_seq(dev, &devnum); + debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum); #endif ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 59/72] dm: power-domain: Update uclass to support livetree
Update the power domain uclass to support livetree. Fix the xlate() method which has no callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/power/domain/power-domain-uclass.c | 19 --- include/power-domain-uclass.h | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c index 3dabbe4ac0..1847a492a3 100644 --- a/drivers/power/domain/power-domain-uclass.c +++ b/drivers/power/domain/power-domain-uclass.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -18,7 +17,7 @@ static inline struct power_domain_ops *power_domain_dev_ops(struct udevice *dev) } static int power_domain_of_xlate_default(struct power_domain *power_domain, - struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) { debug("%s(power_domain=%p)\n", __func__, power_domain); @@ -34,27 +33,25 @@ static int power_domain_of_xlate_default(struct power_domain *power_domain, int power_domain_get(struct udevice *dev, struct power_domain *power_domain) { - struct fdtdec_phandle_args args; + struct ofnode_phandle_args args; int ret; struct udevice *dev_power_domain; struct power_domain_ops *ops; debug("%s(dev=%p, power_domain=%p)\n", __func__, dev, power_domain); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), -"power-domains", -"#power-domain-cells", 0, 0, -&args); + ret = dev_read_phandle_with_args(dev, "power-domains", +"#power-domain-cells", 0, 0, &args); if (ret) { - debug("%s: fdtdec_parse_phandle_with_args failed: %d\n", + debug("%s: dev_read_phandle_with_args failed: %d\n", __func__, ret); return ret; } - ret = uclass_get_device_by_of_offset(UCLASS_POWER_DOMAIN, args.node, -&dev_power_domain); + ret = uclass_get_device_by_ofnode(UCLASS_POWER_DOMAIN, args.node, + &dev_power_domain); if (ret) { - debug("%s: uclass_get_device_by_of_offset failed: %d\n", + debug("%s: uclass_get_device_by_ofnode failed: %d\n", __func__, ret); return ret; } diff --git a/include/power-domain-uclass.h b/include/power-domain-uclass.h index 5878021e32..802233d17f 100644 --- a/include/power-domain-uclass.h +++ b/include/power-domain-uclass.h @@ -40,7 +40,7 @@ struct power_domain_ops { * @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct power_domain *power_domain, - struct fdtdec_phandle_args *args); + struct ofnode_phandle_args *args); /** * request - Request a translated power domain. * -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 48/72] dm: usb: Convert uclass to livetree
Update the usb uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/usb/host/usb-uclass.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 6eded4abad..110ddc92fa 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -683,20 +683,18 @@ int usb_detect_change(void) int usb_child_post_bind(struct udevice *dev) { struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); - const void *blob = gd->fdt_blob; int val; - if (dev_of_offset(dev) == -1) + if (!dev_of_valid(dev)) return 0; /* We only support matching a few things */ - val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,device-class", -1); + val = dev_read_u32_default(dev, "usb,device-class", -1); if (val != -1) { plat->id.match_flags |= USB_DEVICE_ID_MATCH_DEV_CLASS; plat->id.bDeviceClass = val; } - val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,interface-class", --1); + val = dev_read_u32_default(dev, "usb,interface-class", -1); if (val != -1) { plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS; plat->id.bInterfaceClass = val; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 27/72] dm: core: Run tests with both livetree and flat tree
Some tests require either livetree or flat tree. Add flags to allow the tests to specify this. Adjust the test runner to run with livetree (if supported) and then flat tree. Some video tests are quite slow and running on flat tree adds little extra test value, so run these on livetree only. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/dm/test.h | 2 ++ include/test/test.h | 2 ++ test/dm/test-main.c | 38 -- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/dm/test.h b/include/dm/test.h index cba504909a..cecee26f33 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -150,6 +150,8 @@ enum { DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */ DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */ DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */ + DM_TESTF_FLAT_TREE = 1 << 3, /* test needs flat DT */ + DM_TESTF_LIVE_TREE = 1 << 4, /* needs live device tree */ }; /* Declare a new driver model test */ diff --git a/include/test/test.h b/include/test/test.h index e3e821c6ea..646dbfd486 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -15,11 +15,13 @@ * @fail_count: Number of tests that failed * @start: Store the starting mallinfo when doing leak test * @priv: A pointer to some other info some suites want to track + * @of_root: Record of the livetree root node (used for setting up tests) */ struct unit_test_state { int fail_count; struct mallinfo start; void *priv; + struct device_node *of_root; }; /** diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 88ef267458..9d88d31467 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -110,6 +110,21 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, return 0; } +/** + * dm_test_run_on_flattree() - Check if we should run a test with flat DT + * + * This skips long/slow tests where there is not much value in running a flat + * DT test in addition to a live DT test. + * + * @return true to run the given test on the flat device tree + */ +static bool dm_test_run_on_flattree(struct unit_test *test) +{ + const char *fname = strrchr(test->file, '/') + 1; + + return !strstr(fname, "video") || strstr(test->name, "video_base"); +} + static int dm_test_main(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); @@ -140,14 +155,33 @@ static int dm_test_main(const char *test_name) #endif for (test = tests; test < tests + n_ents; test++) { const char *name = test->name; + int runs; /* All tests have this prefix */ if (!strncmp(name, "dm_test_", 8)) name += 8; if (test_name && strcmp(test_name, name)) continue; - ut_assertok(dm_do_test(uts, test, false)); - run_count++; + + /* Run with the live tree if possible */ + runs = 0; + if (IS_ENABLED(CONFIG_OF_LIVE)) { + if (!(test->flags & DM_TESTF_FLAT_TREE)) { + ut_assertok(dm_do_test(uts, test, true)); + runs++; + } + } + + /* +* Run with the flat tree if we couldn't run it with live tree, +* or it is a core test. +*/ + if (!(test->flags & DM_TESTF_LIVE_TREE) && + (!runs || dm_test_run_on_flattree(test))) { + ut_assertok(dm_do_test(uts, test, false)); + runs++; + } + run_count += runs; } if (test_name && !run_count) -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 54/72] dm: test: Disable the fdt_offset test with livetree
We cannot run this test with livetree since it uses device tree offsets. Mark it as flat tree only. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/dm/test-fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 3048a7b890..987a265ba9 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -265,4 +265,5 @@ static int dm_test_fdt_offset(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_fdt_offset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +DM_TEST(dm_test_fdt_offset, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 62/72] dm: Update the I2C eeprom driver for livetree
Update this driver so that it works with livetree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/misc/i2c_eeprom_emul.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/misc/i2c_eeprom_emul.c b/drivers/misc/i2c_eeprom_emul.c index 02de8d7df3..52aa7d69e9 100644 --- a/drivers/misc/i2c_eeprom_emul.c +++ b/drivers/misc/i2c_eeprom_emul.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -115,10 +114,8 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev) { struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev); - plat->size = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "sandbox,size", 32); - plat->filename = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), -"sandbox,filename", NULL); + plat->size = dev_read_u32_default(dev, "sandbox,size", 32); + plat->filename = dev_read_string(dev, "sandbox,filename"); if (!plat->filename) { debug("%s: No filename for device '%s'\n", __func__, dev->name); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 58/72] sandbox: phy: Update driver for livetree
Update the sandbox phy driver to support livetree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/phy/sandbox-phy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/phy/sandbox-phy.c b/drivers/phy/sandbox-phy.c index 9ad820c24c..867c6fe704 100644 --- a/drivers/phy/sandbox-phy.c +++ b/drivers/phy/sandbox-phy.c @@ -80,8 +80,7 @@ static int sandbox_phy_probe(struct udevice *dev) priv->initialized = false; priv->on = false; - priv->broken = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), - "broken"); + priv->broken = dev_read_bool(dev, "broken"); return 0; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 72/72] sandbox: Move to use live tree
This updates sandbox to use a live device tree. This means that after relocation (from board_init_r() onwards) it no-longer uses flat device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Rewrite based on testing and refining the v1 series - Convert various subsystems to enable sandbox tests to pass configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 5417057664..a7656a3ff1 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -58,6 +58,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y +CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_NETCONSOLE=y CONFIG_REGMAP=y -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 32/72] cros_ec: Fix debug() statement in ec_command_inptr()
This prints out the wrong pointers. Fix it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/misc/cros_ec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index 3d449b2a55..e2027ea5d2 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -304,8 +304,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd, NULL, 0, &din, din_len); } - debug("%s: len=%d, dinp=%p, *dinp=%p\n", __func__, len, dinp, - dinp ? *dinp : NULL); + debug("%s: len=%d, din=%p\n", __func__, len, din); if (dinp) { /* If we have any data to return, it must be 64bit-aligned */ assert(len <= 0 || !((uintptr_t)din & 7)); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 64/72] dm: spi: Convert uclass to livetree
Update the SPI uclass to support a live device tree. Also adjust spi_slave_ofdata_to_platdata() to accept a device instead of a blob and offset. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/spi/spi-uclass.c | 31 ++- include/spi.h| 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index c061c05443..e06a603ab1 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -113,11 +112,10 @@ static int spi_child_post_bind(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); - if (dev_of_offset(dev) == -1) + if (!dev_of_valid(dev)) return 0; - return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev), - plat); + return spi_slave_ofdata_to_platdata(dev, plat); } #endif @@ -126,8 +124,7 @@ static int spi_post_probe(struct udevice *bus) #if !CONFIG_IS_ENABLED(OF_PLATDATA) struct dm_spi_bus *spi = dev_get_uclass_priv(bus); - spi->max_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus), -"spi-max-frequency", 0); + spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0); #endif #if defined(CONFIG_NEEDS_MANUAL_RELOC) struct dm_spi_ops *ops = spi_get_ops(bus); @@ -375,7 +372,7 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs, int ret; ret = spi_get_bus_and_cs(busnum, cs, speed, mode, NULL, 0, &dev, - &slave); +&slave); if (ret) return NULL; @@ -388,27 +385,27 @@ void spi_free_slave(struct spi_slave *slave) slave->dev = NULL; } -int spi_slave_ofdata_to_platdata(const void *blob, int node, +int spi_slave_ofdata_to_platdata(struct udevice *dev, struct dm_spi_slave_platdata *plat) { int mode = 0; int value; - plat->cs = fdtdec_get_int(blob, node, "reg", -1); - plat->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", 0); - if (fdtdec_get_bool(blob, node, "spi-cpol")) + plat->cs = dev_read_u32_default(dev, "reg", -1); + plat->max_hz = dev_read_u32_default(dev, "spi-max-frequency", 0); + if (dev_read_bool(dev, "spi-cpol")) mode |= SPI_CPOL; - if (fdtdec_get_bool(blob, node, "spi-cpha")) + if (dev_read_bool(dev, "spi-cpha")) mode |= SPI_CPHA; - if (fdtdec_get_bool(blob, node, "spi-cs-high")) + if (dev_read_bool(dev, "spi-cs-high")) mode |= SPI_CS_HIGH; - if (fdtdec_get_bool(blob, node, "spi-3wire")) + if (dev_read_bool(dev, "spi-3wire")) mode |= SPI_3WIRE; - if (fdtdec_get_bool(blob, node, "spi-half-duplex")) + if (dev_read_bool(dev, "spi-half-duplex")) mode |= SPI_PREAMBLE; /* Device DUAL/QUAD mode */ - value = fdtdec_get_uint(blob, node, "spi-tx-bus-width", 1); + value = dev_read_u32_default(dev, "spi-tx-bus-width", 1); switch (value) { case 1: break; @@ -423,7 +420,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, break; } - value = fdtdec_get_uint(blob, node, "spi-rx-bus-width", 1); + value = dev_read_u32_default(dev, "spi-rx-bus-width", 1); switch (value) { case 1: break; diff --git a/include/spi.h b/include/spi.h index deb65efdfb..8c4b882c54 100644 --- a/include/spi.h +++ b/include/spi.h @@ -562,7 +562,7 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp); * @node: Node offset to read from * @plat: Place to put the decoded information */ -int spi_slave_ofdata_to_platdata(const void *blob, int node, +int spi_slave_ofdata_to_platdata(struct udevice *dev, struct dm_spi_slave_platdata *plat); /** -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 35/72] test: Update 'make test' to run more tests
The standard sandbox board cannot run the of-platdata test since it needs SPL. Also, we should test the flat tree version of sandbox. Add these tests to the default test script. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/run | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/run b/test/run index a6dcf8f44f..b1649ee101 100755 --- a/test/run +++ b/test/run @@ -1,4 +1,10 @@ #!/bin/sh -# Run all tests +# Run all tests that the standard sandbox build can support ./test/py/test.py --bd sandbox --build + +# Run tests which require sandbox_spl +./test/py/test.py --bd sandbox_spl --build -k test/py/tests/test_ofplatdata.py + +# Run tests for the flat DT version of sandbox +./test/py/test.py --bd sandbox_flattree --build -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 69/72] dm: sandbox: sysreset: Convert driver to livetree
Update this driver to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/sysreset/sysreset_sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c index 0c4e2e1a93..12b3e5f86e 100644 --- a/drivers/sysreset/sysreset_sandbox.c +++ b/drivers/sysreset/sysreset_sandbox.c @@ -41,7 +41,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type) * (see the U_BOOT_DEVICE() declaration below) should not do anything. * If we are that device, return an error. */ - if (state->fdt_fname && dev_of_offset(dev) == -1) + if (state->fdt_fname && !dev_of_valid(dev)) return -ENODEV; switch (type) { -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 33/72] cros_ec: Convert to support live tree
Convert this driver to support the live device tree and remove the old fdtdec support. The keyboard is not yet converted. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/misc/cros_ec.c | 33 ++--- drivers/misc/cros_ec_sandbox.c | 23 +++ include/cros_ec.h | 7 ++- include/fdtdec.h | 13 - lib/fdtdec.c | 32 5 files changed, 27 insertions(+), 81 deletions(-) diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index e2027ea5d2..feaa5d8567 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #ifdef DEBUG_TRACE @@ -996,15 +997,12 @@ int cros_ec_get_ldo(struct udevice *dev, uint8_t index, uint8_t *state) int cros_ec_register(struct udevice *dev) { struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev); char id[MSG_BYTES]; cdev->dev = dev; gpio_request_by_name(dev, "ec-interrupt", 0, &cdev->ec_int, GPIOD_IS_IN); - cdev->optimise_flash_write = fdtdec_get_bool(blob, node, -"optimise-flash-write"); + cdev->optimise_flash_write = dev_read_bool(dev, "optimise-flash-write"); if (cros_ec_check_version(cdev)) { debug("%s: Could not detect CROS-EC version\n", __func__); @@ -1023,28 +1021,26 @@ int cros_ec_register(struct udevice *dev) return 0; } -int cros_ec_decode_ec_flash(const void *blob, int node, - struct fdt_cros_ec *config) +int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config) { - int flash_node; + ofnode flash_node, node; - flash_node = fdt_subnode_offset(blob, node, "flash"); - if (flash_node < 0) { + flash_node = dev_read_subnode(dev, "flash"); + if (!ofnode_valid(flash_node)) { debug("Failed to find flash node\n"); return -1; } - if (fdtdec_read_fmap_entry(blob, flash_node, "flash", - &config->flash)) { - debug("Failed to decode flash node in chrome-ec'\n"); + if (of_read_fmap_entry(flash_node, "flash", &config->flash)) { + debug("Failed to decode flash node in chrome-ec\n"); return -1; } - config->flash_erase_value = fdtdec_get_int(blob, flash_node, - "erase-value", -1); - for (node = fdt_first_subnode(blob, flash_node); node >= 0; -node = fdt_next_subnode(blob, node)) { - const char *name = fdt_get_name(blob, node, NULL); + config->flash_erase_value = ofnode_read_s32_default(flash_node, + "erase-value", -1); + for (node = ofnode_first_subnode(flash_node); ofnode_valid(node); +node = ofnode_next_subnode(node)) { + const char *name = ofnode_get_name(node); enum ec_flash_region region; if (0 == strcmp(name, "ro")) { @@ -1058,8 +1054,7 @@ int cros_ec_decode_ec_flash(const void *blob, int node, return -1; } - if (fdtdec_read_fmap_entry(blob, node, "reg", - &config->region[region])) { + if (of_read_fmap_entry(node, "reg", &config->region[region])) { debug("Failed to decode flash region in chrome-ec'\n"); return -1; } diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 848c67bc23..c96e26e6b7 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -188,18 +188,16 @@ static int get_image_used(struct ec_state *ec, struct fmap_entry *entry) * RR=Row CC=Column =Key Code * * @param ec Current emulated EC state - * @param blob Device tree blob containing keyscan information * @param node Keyboard node of device tree containing keyscan information * @return 0 if ok, -1 on error */ -static int keyscan_read_fdt_matrix(struct ec_state *ec, const void *blob, - int node) +static int keyscan_read_fdt_matrix(struct ec_state *ec, ofnode node) { const u32 *cell; int upto; int len; - cell = fdt_getprop(blob, node, "linux,keymap", &len); + cell = ofnode_read_prop(node, "linux,keymap", &len); ec->matrix_count = len / 4; ec->matrix = calloc(ec->matrix_count, sizeof(*ec->matrix)); if (!ec->matrix) { @@ -516,28 +514,29 @@ int cros_ec_probe(struct udevice *dev) { struct ec_state *ec = dev->priv; struct cros_ec_dev *cdev
[U-Boot] [PATCH v3 19/72] dm: core: Add a way to find a device by ofnode
Add a function which looks up a device by its node (either in live tree or flat tree). Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/uclass.c| 37 + include/dm/uclass-internal.h | 18 ++ include/dm/uclass.h | 17 + 3 files changed, 72 insertions(+) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 04fb45b01a..630b2e7336 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -287,6 +288,30 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node, return -ENODEV; } +int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node, +struct udevice **devp) +{ + struct uclass *uc; + struct udevice *dev; + int ret; + + *devp = NULL; + if (!ofnode_valid(node)) + return -ENODEV; + ret = uclass_get(id, &uc); + if (ret) + return ret; + + list_for_each_entry(dev, &uc->dev_head, uclass_node) { + if (ofnode_equal(dev_ofnode(dev), node)) { + *devp = dev; + return 0; + } + } + + return -ENODEV; +} + #if CONFIG_IS_ENABLED(OF_CONTROL) static int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent, @@ -407,6 +432,18 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node, return uclass_get_device_tail(dev, ret, devp); } +int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, + struct udevice **devp) +{ + struct udevice *dev; + int ret; + + *devp = NULL; + ret = uclass_find_device_by_ofnode(id, node, &dev); + + return uclass_get_device_tail(dev, ret, devp); +} + #if CONFIG_IS_ENABLED(OF_CONTROL) int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent, const char *name, struct udevice **devp) diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index ad284b8445..c086004318 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -10,6 +10,8 @@ #ifndef _DM_UCLASS_INTERNAL_H #define _DM_UCLASS_INTERNAL_H +#include + /** * uclass_get_device_tail() - handle the end of a get_device call * @@ -115,6 +117,22 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp); /** + * uclass_find_device_by_of_node() - Find a uclass device by device tree node + * + * This searches the devices in the uclass for one attached to the given + * device tree node. + * + * The device is NOT probed, it is merely returned. + * + * @id: ID to look up + * @node: Device tree offset to search for (if NULL then -ENODEV is returned) + * @devp: Returns pointer to device (there is only one for each node) + * @return 0 if OK, -ve on error + */ +int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node, +struct udevice **devp); + +/** * uclass_bind_device() - Associate device with a uclass * * Connect the device into uclass's list of devices. diff --git a/include/dm/uclass.h b/include/dm/uclass.h index b583aa869b..7f5a1304b5 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -10,6 +10,7 @@ #ifndef _DM_UCLASS_H #define _DM_UCLASS_H +#include #include #include #include @@ -186,6 +187,22 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp); /** + * uclass_get_device_by_ofnode() - Get a uclass device by device tree node + * + * This searches the devices in the uclass for one attached to the given + * device tree node. + * + * The device is probed to activate it ready for use. + * + * @id: ID to look up + * @np: Device tree node to search for (if NULL then -ENODEV is returned) + * @devp: Returns pointer to device (there is only one for each node) + * @return 0 if OK, -ve on error + */ +int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, + struct udevice **devp); + +/** * uclass_get_device_by_phandle() - Get a uclass device by phandle * * This searches the devices in the uclass for one with the given phandle. -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 25/72] dm: test: Show the test filename when running
Show the filename of the test being run. Skip the path and show just the base name. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/test/test.h | 2 ++ test/dm/test-main.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/test/test.h b/include/test/test.h index b7e1ae2dec..e3e821c6ea 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -30,6 +30,7 @@ struct unit_test_state { * @flags: Flags indicated pre-conditions for test */ struct unit_test { + const char *file; const char *name; int (*func)(struct unit_test_state *state); int flags; @@ -38,6 +39,7 @@ struct unit_test { /* Declare a new unit test */ #define UNIT_TEST(_name, _flags, _suite) \ ll_entry_declare(struct unit_test, _name, _suite) = { \ + .file = __FILE__, \ .name = #_name, \ .flags = _flags,\ .func = _name, \ diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 2848673e06..10d2706377 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -75,8 +75,9 @@ static int dm_test_destroy(struct unit_test_state *uts) static int dm_do_test(struct unit_test_state *uts, struct unit_test *test) { struct sandbox_state *state = state_get_current(); + const char *fname = strrchr(test->file, '/') + 1; - printf("Test: %s\n", test->name); + printf("Test: %s: %s\n", test->name, fname); ut_assertok(dm_test_init(uts)); uts->start = mallinfo(); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 61/72] dm: pci: Update uclass to support livetree
Update the PCI uclass to support livetree. This mostly involves fixing the address decoding from the device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/pci/pci-uclass.c | 26 -- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 504d7e3bb1..b36ef3338c 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -8,12 +8,11 @@ #include #include #include -#include #include #include #include -#include #include +#include #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) #include #endif @@ -754,8 +753,8 @@ error: return ret; } -static int decode_regions(struct pci_controller *hose, const void *blob, - int parent_node, int node) +static int decode_regions(struct pci_controller *hose, ofnode parent_node, + ofnode node) { int pci_addr_cells, addr_cells, size_cells; phys_addr_t base = 0, size; @@ -764,12 +763,12 @@ static int decode_regions(struct pci_controller *hose, const void *blob, int len; int i; - prop = fdt_getprop(blob, node, "ranges", &len); + prop = ofnode_read_prop(node, "ranges", &len); if (!prop) return -EINVAL; - pci_addr_cells = fdt_address_cells(blob, node); - addr_cells = fdt_address_cells(blob, parent_node); - size_cells = fdt_size_cells(blob, node); + pci_addr_cells = ofnode_read_addr_cells(node); + addr_cells = ofnode_read_addr_cells(parent_node); + size_cells = ofnode_read_size_cells(node); /* PCI addresses are always 3-cells */ len /= sizeof(u32); @@ -841,9 +840,8 @@ static int pci_uclass_pre_probe(struct udevice *bus) /* For bridges, use the top-level PCI controller */ if (!device_is_on_pci_bus(bus)) { hose->ctlr = bus; - ret = decode_regions(hose, gd->fdt_blob, -dev_of_offset(bus->parent), -dev_of_offset(bus)); + ret = decode_regions(hose, dev_ofnode(bus->parent), +dev_ofnode(bus)); if (ret) { debug("%s: Cannot decode regions\n", __func__); return ret; @@ -906,7 +904,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev) struct fdt_pci_addr addr; int ret; - if (dev_of_offset(dev) == -1) + if (!dev_of_valid(dev)) return 0; /* @@ -914,8 +912,8 @@ static int pci_uclass_child_post_bind(struct udevice *dev) * just check the address. */ pplat = dev_get_parent_platdata(dev); - ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev), - FDT_PCI_SPACE_CONFIG, "reg", &addr); + ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG, "reg", + &addr); if (ret) { if (ret != -ENOENT) -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 65/72] dm: sandbox: i2c: Drop fdtdec.h header
This is not needed in this driver. Drop it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/i2c/sandbox_i2c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c index 4696a1ae62..f5978fda29 100644 --- a/drivers/i2c/sandbox_i2c.c +++ b/drivers/i2c/sandbox_i2c.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 30/72] dm: gpio: sandbox: Use dev_read...() functions to access DT
Use the new dev_read...() functions to access the device tree, so that a live tree can be used. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/gpio/sandbox.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index 0f22acb0e6..4f7b62eba0 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -198,10 +198,8 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), -"num-gpios", 0); - uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), -"gpio-bank-name", NULL); + uc_priv->gpio_count = dev_read_u32_default(dev, "num-gpios", 0); + uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); return 0; } @@ -210,10 +208,9 @@ static int gpio_sandbox_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); - if (dev_of_offset(dev) == -1) { + if (!dev_of_valid(dev)) /* Tell the uclass how many GPIOs we have */ uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT; - } dev->priv = calloc(sizeof(struct gpio_state), uc_priv->gpio_count); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 50/72] clk: Modify xlate() method for livetree
Update the xlate() method to use ofnode_phandle_args instead of the fdtdec variant. This will allow drivers to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/clk/at91/pmc.c| 2 +- drivers/clk/at91/pmc.h| 2 +- drivers/clk/clk-uclass.c | 7 --- drivers/clk/clk_stm32f7.c | 3 +-- include/clk-uclass.h | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index f4ec5fcb5e..be1d11ed4e 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -87,7 +87,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) return 0; } -int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args) +int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args) { int periph; diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index f222fce11f..bd3caba48d 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -15,7 +15,7 @@ struct pmc_platdata { int at91_pmc_core_probe(struct udevice *dev); int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name); -int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args); +int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args); int at91_clk_probe(struct udevice *dev); #endif diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 6fcfd6997c..f6194b60f9 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -38,7 +38,7 @@ int clk_get_by_index_platdata(struct udevice *dev, int index, } # else static int clk_of_xlate_default(struct clk *clk, - struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { debug("%s(clk=%p)\n", __func__, clk); @@ -86,9 +86,10 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) ops = clk_dev_ops(dev_clk); if (ops->of_xlate) - ret = ops->of_xlate(clk, &args); + ret = ops->of_xlate(clk, (struct ofnode_phandle_args *)&args); else - ret = clk_of_xlate_default(clk, &args); + ret = clk_of_xlate_default(clk, + (struct ofnode_phandle_args *)&args); if (ret) { debug("of_xlate() failed: %d\n", ret); return ret; diff --git a/drivers/clk/clk_stm32f7.c b/drivers/clk/clk_stm32f7.c index da3c204ff5..fcdc3c052b 100644 --- a/drivers/clk/clk_stm32f7.c +++ b/drivers/clk/clk_stm32f7.c @@ -252,8 +252,7 @@ static int stm32_clk_probe(struct udevice *dev) return 0; } -static int stm32_clk_of_xlate(struct clk *clk, - struct fdtdec_phandle_args *args) +static int stm32_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args) { debug("%s(clk=%p)\n", __func__, clk); diff --git a/include/clk-uclass.h b/include/clk-uclass.h index 07c1065495..e7ea334c60 100644 --- a/include/clk-uclass.h +++ b/include/clk-uclass.h @@ -12,7 +12,8 @@ /* See clk.h for background documentation. */ #include -#include + +struct ofnode_phandle_args; /** * struct clk_ops - The functions that a clock driver must implement. @@ -37,7 +38,7 @@ struct clk_ops { * @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct clk *clock, - struct fdtdec_phandle_args *args); + struct ofnode_phandle_args *args); /** * request - Request a translated clock. * -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 37/72] dm: Add more livetree helpers and definitions
Add some definitions and helpers for livetree in the main of.h header file. These include: - reading multi-cell integers - default number of address/size cells - functions for comparing names Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/ofnode.c | 4 ++-- include/dm/of.h | 36 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 6805fe2424..ac312d6546 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -457,8 +457,8 @@ fdt_addr_t ofnode_get_addr_size(ofnode node, const char *property, na = of_n_addr_cells(np); ns = of_n_addr_cells(np); - *sizep = fdt_read_number(prop + na, ns); - return fdt_read_number(prop, na); + *sizep = of_read_number(prop + na, ns); + return of_read_number(prop, na); } else { return fdtdec_get_addr_size(gd->fdt_blob, ofnode_to_offset(node), property, diff --git a/include/dm/of.h b/include/dm/of.h index 6b5afab1c1..d4d941e75c 100644 --- a/include/dm/of.h +++ b/include/dm/of.h @@ -103,4 +103,40 @@ static inline bool of_live_active(void) } #endif +#define OF_BAD_ADDR((u64)-1) + +static inline const char *of_node_full_name(const struct device_node *np) +{ + return np ? np->full_name : ""; +} + +/* Default #address and #size cells */ +#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#endif + +/* Default string compare functions */ +#if !defined(of_compat_cmp) +#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2)) +#define of_prop_cmp(s1, s2)strcmp((s1), (s2)) +#define of_node_cmp(s1, s2)strcasecmp((s1), (s2)) +#endif + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 of_read_number(const __be32 *cell, int size) +{ + u64 r = 0; + while (size--) + r = (r << 32) | be32_to_cpu(*(cell++)); + return r; +} + +/* Like of_read_number, but we want an unsigned long result */ +static inline unsigned long of_read_ulong(const __be32 *cell, int size) +{ + /* toss away upper bits if unsigned long is smaller than u64 */ + return of_read_number(cell, size); +} + #endif -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 47/72] dm: adc: Convert uclass to livetree
Update the adc uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/adc/adc-uclass.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 3e28a5600b..a5ef722d21 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -345,12 +345,11 @@ nodev: static int adc_vdd_platdata_set(struct udevice *dev) { struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); - int ret, offset = dev_of_offset(dev); - const void *fdt = gd->fdt_blob; + int ret; char *prop; prop = "vdd-polarity-negative"; - uc_pdata->vdd_polarity_negative = fdtdec_get_bool(fdt, offset, prop); + uc_pdata->vdd_polarity_negative = dev_read_bool(dev, prop); ret = adc_vdd_platdata_update(dev); if (ret != -ENOENT) @@ -358,7 +357,7 @@ static int adc_vdd_platdata_set(struct udevice *dev) /* No vdd-supply phandle. */ prop = "vdd-microvolts"; - uc_pdata->vdd_microvolts = fdtdec_get_int(fdt, offset, prop, -ENODATA); + uc_pdata->vdd_microvolts = dev_read_u32_default(dev, prop, -ENODATA); return 0; } @@ -366,12 +365,11 @@ static int adc_vdd_platdata_set(struct udevice *dev) static int adc_vss_platdata_set(struct udevice *dev) { struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev); - int ret, offset = dev_of_offset(dev); - const void *fdt = gd->fdt_blob; + int ret; char *prop; prop = "vss-polarity-negative"; - uc_pdata->vss_polarity_negative = fdtdec_get_bool(fdt, offset, prop); + uc_pdata->vss_polarity_negative = dev_read_bool(dev, prop); ret = adc_vss_platdata_update(dev); if (ret != -ENOENT) @@ -379,7 +377,7 @@ static int adc_vss_platdata_set(struct udevice *dev) /* No vss-supply phandle. */ prop = "vss-microvolts"; - uc_pdata->vss_microvolts = fdtdec_get_int(fdt, offset, prop, -ENODATA); + uc_pdata->vss_microvolts = dev_read_u32_default(dev, prop, -ENODATA); return 0; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 36/72] fdt: Rename a few functions in fdt_support
These two functions have an of_ prefix which conflicts with naming used in of_addr. Rename them: fdt_read_number fdt_support_bus_default_count_cells Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/arm/cpu/armv8/fsl-layerscape/fdt.c| 4 ++-- arch/arm/mach-tegra/tegra186/nvtboot_mem.c | 4 ++-- common/fdt_support.c | 26 +- drivers/core/ofnode.c | 4 ++-- drivers/mtd/altera_qspi.c | 2 +- drivers/mtd/cfi_flash.c| 2 +- drivers/mtd/pic32_flash.c | 2 +- drivers/net/altera_tse.c | 2 +- include/fdt_support.h | 4 ++-- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c index 05c4577753..f5f4840f19 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c @@ -79,13 +79,13 @@ remove_psci_node: puts("couldn't find /cpus node\n"); return; } - of_bus_default_count_cells(blob, off, &addr_cells, NULL); + fdt_support_default_count_cells(blob, off, &addr_cells, NULL); off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); while (off != -FDT_ERR_NOTFOUND) { reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); if (reg) { - core_id = of_read_number(reg, addr_cells); + core_id = fdt_read_number(reg, addr_cells); if (core_id == 0 || (is_core_online(core_id))) { val = spin_tbl_addr; val += id_to_core(core_id) * diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_mem.c b/arch/arm/mach-tegra/tegra186/nvtboot_mem.c index bf1616628b..966cf9f1c4 100644 --- a/arch/arm/mach-tegra/tegra186/nvtboot_mem.c +++ b/arch/arm/mach-tegra/tegra186/nvtboot_mem.c @@ -60,9 +60,9 @@ int dram_init(void) gd->ram_size = 0; for (i = 0; i < len; i++) { - ram_banks[i].start = of_read_number(prop, na); + ram_banks[i].start = fdt_read_number(prop, na); prop += na; - ram_banks[i].size = of_read_number(prop, ns); + ram_banks[i].size = fdt_read_number(prop, ns); prop += ns; gd->ram_size += ram_banks[i].size; } diff --git a/common/fdt_support.c b/common/fdt_support.c index c63b27bbb6..dfdc04dfba 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1008,7 +1008,7 @@ struct of_bus { }; /* Default translator (generic bus) */ -void of_bus_default_count_cells(const void *blob, int parentoffset, +void fdt_support_default_count_cells(const void *blob, int parentoffset, int *addrc, int *sizec) { const fdt32_t *prop; @@ -1030,9 +1030,9 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range, { u64 cp, s, da; - cp = of_read_number(range, na); - s = of_read_number(range + na + pna, ns); - da = of_read_number(addr, na); + cp = fdt_read_number(range, na); + s = fdt_read_number(range + na + pna, ns); + da = fdt_read_number(addr, na); debug("OF: default map, cp=%" PRIu64 ", s=%" PRIu64 ", da=%" PRIu64 "\n", cp, s, da); @@ -1044,7 +1044,7 @@ static u64 of_bus_default_map(fdt32_t *addr, const fdt32_t *range, static int of_bus_default_translate(fdt32_t *addr, u64 offset, int na) { - u64 a = of_read_number(addr, na); + u64 a = fdt_read_number(addr, na); memset(addr, 0, na * 4); a += offset; if (na > 1) @@ -1086,9 +1086,9 @@ static u64 of_bus_isa_map(fdt32_t *addr, const fdt32_t *range, if ((addr[0] ^ range[0]) & cpu_to_be32(1)) return OF_BAD_ADDR; - cp = of_read_number(range + 1, na - 1); - s = of_read_number(range + na + pna, ns); - da = of_read_number(addr + 1, na - 1); + cp = fdt_read_number(range + 1, na - 1); + s = fdt_read_number(range + na + pna, ns); + da = fdt_read_number(addr + 1, na - 1); debug("OF: ISA map, cp=%" PRIu64 ", s=%" PRIu64 ", da=%" PRIu64 "\n", cp, s, da); @@ -1122,7 +1122,7 @@ static struct of_bus of_busses[] = { { .name = "default", .addresses = "reg", - .count_cells = of_bus_default_count_cells, + .count_cells = fdt_support_default_count_cells, .map = of_bus_default_map, .translate = of_bus_default_translate, }, @@ -1173,7 +1173,7 @@ static int of_translate_one(const void *blob, int parent, struct of_bus *bus, */ ranges = fdt_getprop(blob, parent, rprop, &rlen); if (ranges == NULL || rlen == 0) { - offset = of_read
[U-Boot] [PATCH v3 40/72] dm: i2c: Convert uclass to livetree
Update the i2c uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/i2c/i2c-uclass.c | 28 +--- include/i2c.h| 3 +-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index f3184c71d9..1397f34dda 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -467,18 +466,20 @@ int i2c_deblock(struct udevice *bus) } #if CONFIG_IS_ENABLED(OF_CONTROL) -int i2c_chip_ofdata_to_platdata(const void *blob, int node, - struct dm_i2c_chip *chip) +int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip) { - chip->offset_len = fdtdec_get_int(gd->fdt_blob, node, - "u-boot,i2c-offset-len", 1); + int addr; + + chip->offset_len = dev_read_u32_default(dev, "u-boot,i2c-offset-len", + 1); chip->flags = 0; - chip->chip_addr = fdtdec_get_int(gd->fdt_blob, node, "reg", -1); - if (chip->chip_addr == -1) { - debug("%s: I2C Node '%s' has no 'reg' property\n", __func__, - fdt_get_name(blob, node, NULL)); + addr = dev_read_u32_default(dev, "reg", -1); + if (addr == -1) { + debug("%s: I2C Node '%s' has no 'reg' property %s\n", __func__, + dev_read_name(dev), dev->name); return -EINVAL; } + chip->chip_addr = addr; return 0; } @@ -489,8 +490,7 @@ static int i2c_post_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev); - i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), -"clock-frequency", 10); + i2c->speed_hz = dev_read_u32_default(dev, "clock-frequency", 10); return dm_i2c_set_bus_speed(dev, i2c->speed_hz); #else @@ -503,11 +503,9 @@ static int i2c_child_post_bind(struct udevice *dev) #if CONFIG_IS_ENABLED(OF_CONTROL) struct dm_i2c_chip *plat = dev_get_parent_platdata(dev); - if (dev_of_offset(dev) == -1) + if (!dev_of_valid(dev)) return 0; - - return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev), - plat); + return i2c_chip_ofdata_to_platdata(dev, plat); #else return 0; #endif diff --git a/include/i2c.h b/include/i2c.h index a88cc7cddf..d0950b5d01 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -525,8 +525,7 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, * @node: Node offset to read from * @spi: Place to put the decoded information */ -int i2c_chip_ofdata_to_platdata(const void *blob, int node, - struct dm_i2c_chip *chip); +int i2c_chip_ofdata_to_platdata(struct udevice *dev, struct dm_i2c_chip *chip); /** * i2c_dump_msgs() - Dump a list of I2C messages -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 43/72] sandbox: pmic: Convert pmic emulator to support livetree
Update this driver to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/power/pmic/i2c_pmic_emul.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/power/pmic/i2c_pmic_emul.c b/drivers/power/pmic/i2c_pmic_emul.c index 4f92e3dad8..2d35d09d45 100644 --- a/drivers/power/pmic/i2c_pmic_emul.c +++ b/drivers/power/pmic/i2c_pmic_emul.c @@ -6,7 +6,6 @@ */ #include -#include #include #include #include @@ -108,9 +107,8 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul) debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__); - reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob, - dev_of_offset(emul), "reg-defaults", - SANDBOX_PMIC_REG_COUNT); + reg_defaults = dev_read_u8_array_ptr(emul, "reg-defaults", +SANDBOX_PMIC_REG_COUNT); if (!reg_defaults) { error("Property \"reg-defaults\" not found for device: %s!", -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH] rockchip: firefly-rk3399: enable rk3399 pinctrl in defconfig
Hi Kever, Ahh, yup! You're totally right! I didn't see Heiko's patch earlier. My mistake. Cheers, Alex On 18 May 2017 12:38 PM, "Kever Yang" wrote: > Hi Alex, > > > Thanks for your patch, but this patch is just the same with the one from > Heiko[0], right? > > > Thanks, > > - Kever > > [0] https://patchwork.ozlabs.org/patch/758272/ > > > On 05/15/2017 08:01 PM, Alex Hixon wrote: > >> The config name enabling the rk3399-pinctrl driver is spelled wrong, so >> it does not get built. This causes SPL to fail during board init. >> >> Make rk3399-firefly boot by enabling the pinctrl driver via the correct >> config name. >> >> Signed-off-by: Alex Hixon >> --- >> configs/firefly-rk3399_defconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/configs/firefly-rk3399_defconfig >> b/configs/firefly-rk3399_defconfig >> index f30f131f34..0a4d005975 100644 >> --- a/configs/firefly-rk3399_defconfig >> +++ b/configs/firefly-rk3399_defconfig >> @@ -39,7 +39,7 @@ CONFIG_ETH_DESIGNWARE=y >> CONFIG_GMAC_ROCKCHIP=y >> CONFIG_PINCTRL=y >> CONFIG_SPL_PINCTRL=y >> -CONFIG_ROCKCHIP_RK3399_PINCTRL=y >> +CONFIG_PINCTRL_ROCKCHIP_RK3399=y >> CONFIG_DM_PMIC=y >> CONFIG_PMIC_RK8XX=y >> CONFIG_REGULATOR_PWM=y >> > > > ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 34/72] sandbox: Add a new sandbox_flattree board
Add a sandbox board to test the non-livetree build (i.e. with CONFIG_OF_FLAT disabled). This increases our build and test coverage. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None board/sandbox/MAINTAINERS | 7 ++ configs/sandbox_flattree_defconfig | 179 + 2 files changed, 186 insertions(+) create mode 100644 configs/sandbox_flattree_defconfig diff --git a/board/sandbox/MAINTAINERS b/board/sandbox/MAINTAINERS index 4dcbf4ba03..6d0790ccd1 100644 --- a/board/sandbox/MAINTAINERS +++ b/board/sandbox/MAINTAINERS @@ -18,3 +18,10 @@ S: Maintained F: board/sandbox/ F: include/configs/sandbox_spl.h F: configs/sandbox_spl_defconfig + +SANDBOX FLAT TREE BOARD +M: Simon Glass +S: Maintained +F: board/sandbox/ +F: include/configs/sandbox.h +F: configs/sandbox_flattree_defconfig diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig new file mode 100644 index 00..83efb23dbc --- /dev/null +++ b/configs/sandbox_flattree_defconfig @@ -0,0 +1,179 @@ +CONFIG_SYS_MALLOC_F_LEN=0x2000 +CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_FIT_VERBOSE=y +CONFIG_SPL_LOAD_FIT=y +CONFIG_BOOTSTAGE=y +CONFIG_BOOTSTAGE_REPORT=y +CONFIG_BOOTSTAGE_USER_COUNT=0x20 +CONFIG_BOOTSTAGE_FDT=y +CONFIG_BOOTSTAGE_STASH=y +CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 +CONFIG_CONSOLE_RECORD=y +CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 +CONFIG_SILENT_CONSOLE=y +CONFIG_CMD_CPU=y +CONFIG_CMD_LICENSE=y +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_ELF is not set +# CONFIG_CMD_IMLS is not set +CONFIG_CMD_ASKENV=y +CONFIG_CMD_GREPENV=y +CONFIG_CMD_MD5SUM=y +CONFIG_LOOPW=y +CONFIG_CMD_MEMTEST=y +CONFIG_CMD_MX_CYCLIC=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_DEMO=y +CONFIG_CMD_GPT=y +CONFIG_CMD_SF=y +CONFIG_CMD_SPI=y +CONFIG_CMD_I2C=y +CONFIG_CMD_USB=y +CONFIG_CMD_REMOTEPROC=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_TFTPPUT=y +CONFIG_CMD_TFTPSRV=y +CONFIG_CMD_RARP=y +CONFIG_CMD_CDP=y +CONFIG_CMD_SNTP=y +CONFIG_CMD_DNS=y +CONFIG_CMD_LINK_LOCAL=y +CONFIG_CMD_TIME=y +CONFIG_CMD_TIMER=y +CONFIG_CMD_SOUND=y +CONFIG_CMD_QFW=y +CONFIG_CMD_BOOTSTAGE=y +CONFIG_CMD_PMIC=y +CONFIG_CMD_REGULATOR=y +CONFIG_CMD_TPM=y +CONFIG_CMD_TPM_TEST=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_MAC_PARTITION=y +CONFIG_AMIGA_PARTITION=y +CONFIG_OF_CONTROL=y +CONFIG_OF_HOSTFILE=y +CONFIG_NETCONSOLE=y +CONFIG_REGMAP=y +CONFIG_SPL_REGMAP=y +CONFIG_SYSCON=y +CONFIG_SPL_SYSCON=y +CONFIG_DEVRES=y +CONFIG_DEBUG_DEVRES=y +CONFIG_ADC=y +CONFIG_ADC_SANDBOX=y +CONFIG_CLK=y +CONFIG_CPU=y +CONFIG_DM_DEMO=y +CONFIG_DM_DEMO_SIMPLE=y +CONFIG_DM_DEMO_SHAPE=y +CONFIG_PM8916_GPIO=y +CONFIG_SANDBOX_GPIO=y +CONFIG_DM_I2C_COMPAT=y +CONFIG_I2C_CROS_EC_TUNNEL=y +CONFIG_I2C_CROS_EC_LDO=y +CONFIG_DM_I2C_GPIO=y +CONFIG_SYS_I2C_SANDBOX=y +CONFIG_I2C_MUX=y +CONFIG_SPL_I2C_MUX=y +CONFIG_I2C_ARB_GPIO_CHALLENGE=y +CONFIG_CROS_EC_KEYB=y +CONFIG_I8042_KEYB=y +CONFIG_LED=y +CONFIG_LED_BLINK=y +CONFIG_LED_GPIO=y +CONFIG_DM_MAILBOX=y +CONFIG_SANDBOX_MBOX=y +CONFIG_MISC=y +CONFIG_CROS_EC=y +CONFIG_CROS_EC_I2C=y +CONFIG_CROS_EC_LPC=y +CONFIG_CROS_EC_SANDBOX=y +CONFIG_CROS_EC_SPI=y +CONFIG_PWRSEQ=y +CONFIG_SPL_PWRSEQ=y +CONFIG_I2C_EEPROM=y +CONFIG_MMC_SANDBOX=y +CONFIG_SPI_FLASH_SANDBOX=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_ATMEL=y +CONFIG_SPI_FLASH_EON=y +CONFIG_SPI_FLASH_GIGADEVICE=y +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_SPI_FLASH_SPANSION=y +CONFIG_SPI_FLASH_STMICRO=y +CONFIG_SPI_FLASH_SST=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_DM_PCI_COMPAT=y +CONFIG_PCI_SANDBOX=y +CONFIG_PINCTRL=y +CONFIG_PINCONF=y +CONFIG_PINCTRL_ROCKCHIP_RK3036=y +CONFIG_PINCTRL_ROCKCHIP_RK3288=y +CONFIG_PINCTRL_SANDBOX=y +CONFIG_POWER_DOMAIN=y +CONFIG_SANDBOX_POWER_DOMAIN=y +CONFIG_DM_PMIC=y +CONFIG_PMIC_ACT8846=y +CONFIG_DM_PMIC_PFUZE100=y +CONFIG_DM_PMIC_MAX77686=y +CONFIG_PMIC_PM8916=y +CONFIG_PMIC_RK808=y +CONFIG_PMIC_S2MPS11=y +CONFIG_DM_PMIC_SANDBOX=y +CONFIG_PMIC_S5M8767=y +CONFIG_PMIC_TPS65090=y +CONFIG_DM_REGULATOR=y +CONFIG_REGULATOR_ACT8846=y +CONFIG_DM_REGULATOR_PFUZE100=y +CONFIG_DM_REGULATOR_MAX77686=y +CONFIG_DM_REGULATOR_FIXED=y +CONFIG_REGULATOR_RK808=y +CONFIG_REGULATOR_S5M8767=y +CONFIG_DM_REGULATOR_SANDBOX=y +CONFIG_REGULATOR_TPS65090=y +CONFIG_RAM=y +CONFIG_REMOTEPROC_SANDBOX=y +CONFIG_DM_RESET=y +CONFIG_SANDBOX_RESET=y +CONFIG_DM_RTC=y +CONFIG_SANDBOX_SERIAL=y +CONFIG_SOUND=y +CONFIG_SOUND_SANDBOX=y +CONFIG_SANDBOX_SPI=y +CONFIG_SPMI=y +CONFIG_SPMI_SANDBOX=y +CONFIG_SYSRESET=y +CONFIG_TIMER=y +CONFIG_TIMER_EARLY=y +CONFIG_SANDBOX_TIMER=y +CONFIG_TPM_TIS_SANDBOX=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_USB_EMUL=y +CONFIG_USB_STORAGE=y +CONFIG_USB_KEYBOARD=y +CONFIG_SYS_USB_EVENT_POLL=y +CONFIG_DM_VIDEO=y +CONFIG_CONSOLE_ROTATION=y +CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y +CONFIG_VIDEO_SANDBOX_SDL=y +CONFIG_PHY=y +CONFIG_PHY_SANDBOX=y +CONFIG_CMD_DHRYSTONE=y +CONFIG_TP
[U-Boot] [PATCH v3 18/72] dm: core: Scan the live tree when setting up driver model
When starting up driver model with a live tree we need to scan the tree for devices. Add code to handle this. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/root.c | 58 + include/dm/root.h | 3 ++- test/dm/test-main.c | 4 ++-- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/drivers/core/root.c b/drivers/core/root.c index 0c00a4e051..d691d6ff94 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -15,7 +15,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -147,7 +150,7 @@ void fix_devices(void) #endif -int dm_init(void) +int dm_init(bool of_live) { int ret; @@ -167,7 +170,12 @@ int dm_init(void) if (ret) return ret; #if CONFIG_IS_ENABLED(OF_CONTROL) - DM_ROOT_NON_CONST->node = offset_to_ofnode(0); +# if CONFIG_IS_ENABLED(OF_LIVE) + if (of_live) + DM_ROOT_NON_CONST->node = np_to_ofnode(gd->of_root); + else +#endif + DM_ROOT_NON_CONST->node = offset_to_ofnode(0); #endif ret = device_probe(DM_ROOT_NON_CONST); if (ret) @@ -206,6 +214,36 @@ int dm_scan_platdata(bool pre_reloc_only) return ret; } +#if CONFIG_IS_ENABLED(OF_LIVE) +static int dm_scan_fdt_live(struct udevice *parent, + const struct device_node *node_parent, + bool pre_reloc_only) +{ + struct device_node *np; + int ret = 0, err; + + for (np = node_parent->child; np; np = np->sibling) { + if (pre_reloc_only && + !of_find_property(np, "u-boot,dm-pre-reloc", NULL)) + continue; + if (!of_device_is_available(np)) { + dm_dbg(" - ignoring disabled device\n"); + continue; + } + err = lists_bind_fdt(parent, np_to_ofnode(np), NULL); + if (err && !ret) { + ret = err; + debug("%s: ret=%d\n", np->name, ret); + } + } + + if (ret) + dm_warn("Some drivers failed to bind\n"); + + return ret; +} +#endif /* CONFIG_IS_ENABLED(OF_LIVE) */ + #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) /** * dm_scan_fdt_node() - Scan the device tree and bind drivers for a node @@ -251,15 +289,27 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, int dm_scan_fdt_dev(struct udevice *dev) { - if (dev_of_offset(dev) == -1) + if (!dev_of_valid(dev)) return 0; +#if CONFIG_IS_ENABLED(OF_LIVE) + if (of_live_active()) + return dm_scan_fdt_live(dev, dev_np(dev), + gd->flags & GD_FLG_RELOC ? false : true); + else +#endif return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), gd->flags & GD_FLG_RELOC ? false : true); } int dm_scan_fdt(const void *blob, bool pre_reloc_only) { +#if CONFIG_IS_ENABLED(OF_LIVE) + if (of_live_active()) + return dm_scan_fdt_live(gd->dm_root, gd->of_root, + pre_reloc_only); + else +#endif return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only); } #endif @@ -273,7 +323,7 @@ int dm_init_and_scan(bool pre_reloc_only) { int ret; - ret = dm_init(); + ret = dm_init(IS_ENABLED(CONFIG_OF_LIVE)); if (ret) { debug("dm_init() failed: %d\n", ret); return ret; diff --git a/include/dm/root.h b/include/dm/root.h index 186cf8ba1c..50a6011644 100644 --- a/include/dm/root.h +++ b/include/dm/root.h @@ -87,9 +87,10 @@ int dm_init_and_scan(bool pre_reloc_only); * This function will initialize roots of driver tree and class tree. * This needs to be called before anything uses the DM * + * @of_live: Enable live device tree * @return 0 if OK, -ve on error */ -int dm_init(void); +int dm_init(bool of_live); /** * dm_uninit - Uninitialise Driver Model structures diff --git a/test/dm/test-main.c b/test/dm/test-main.c index f2e0048143..67c0082fb8 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -30,7 +30,7 @@ static int dm_test_init(struct unit_test_state *uts) gd->dm_root = NULL; memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); - ut_assertok(dm_init()); + ut_assertok(dm_init(false)); dms->root = dm_root(); return 0; @@ -137,7 +137,7 @@ static int dm_test_main(const char *test_name) printf("Failures: %d\n", uts->fail_count); gd->dm_root = NULL; - ut_assertok(dm_init()); + ut_assertok(dm_init(false)); dm_scan_platdata(false); dm_scan_fdt(gd->fdt_blob, false); -- 2.13.0.303.g4ebf302169-goog
[U-Boot] [PATCH v3 17/72] dm: core: Update device_bind_driver_to_node() to use ofnode
Adjust this function to us an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/clk/at91/pmc.c | 2 +- drivers/core/lists.c | 15 ++- drivers/cpu/cpu-uclass.c | 6 +++--- drivers/i2c/muxes/i2c-mux-uclass.c | 11 --- drivers/led/led_bcm6328.c | 2 +- drivers/led/led_bcm6358.c | 2 +- drivers/led/led_gpio.c | 13 + drivers/misc/tegra186_bpmp.c | 6 +++--- drivers/misc/tegra_car.c | 4 ++-- drivers/net/keystone_net.c | 6 +++--- drivers/pinctrl/pinctrl-uclass.c | 15 ++- drivers/usb/musb-new/ti-musb.c | 2 +- include/dm.h | 2 ++ include/dm/lists.h | 2 +- 14 files changed, 39 insertions(+), 49 deletions(-) diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index c552c75562..f4ec5fcb5e 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -79,7 +79,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) if (!name) return -EINVAL; ret = device_bind_driver_to_node(dev, drv_name, name, -offset, NULL); + offset_to_ofnode(offset), NULL); if (ret) return ret; } diff --git a/drivers/core/lists.c b/drivers/core/lists.c index facf276474..b79f26dbe6 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -74,11 +74,12 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only) int device_bind_driver(struct udevice *parent, const char *drv_name, const char *dev_name, struct udevice **devp) { - return device_bind_driver_to_node(parent, drv_name, dev_name, -1, devp); + return device_bind_driver_to_node(parent, drv_name, dev_name, + ofnode_null(), devp); } int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, - const char *dev_name, int node, + const char *dev_name, ofnode node, struct udevice **devp) { struct driver *drv; @@ -89,14 +90,10 @@ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name, debug("Cannot find driver '%s'\n", drv_name); return -ENOENT; } - ret = device_bind(parent, drv, dev_name, NULL, node, devp); - if (ret) { - debug("Cannot create device named '%s' (err=%d)\n", - dev_name, ret); - return ret; - } + ret = device_bind_with_driver_data(parent, drv, dev_name, 0 /* data */, + node, devp); - return 0; + return ret; } #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index c57ac16b3a..73e4853939 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -63,11 +63,11 @@ U_BOOT_DRIVER(cpu_bus) = { static int uclass_cpu_init(struct uclass *uc) { struct udevice *dev; - int node; + ofnode node; int ret; - node = fdt_path_offset(gd->fdt_blob, "/cpus"); - if (node < 0) + node = ofnode_path("/cpus"); + if (!ofnode_valid(node)) return 0; ret = device_bind_driver_to_node(dm_root(), "cpu_bus", "cpus", node, diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index d243b8e32d..187e8a7c91 100644 --- a/drivers/i2c/muxes/i2c-mux-uclass.c +++ b/drivers/i2c/muxes/i2c-mux-uclass.c @@ -51,24 +51,21 @@ static int i2c_mux_child_post_bind(struct udevice *dev) /* Find the I2C buses selected by this mux */ static int i2c_mux_post_bind(struct udevice *mux) { - const void *blob = gd->fdt_blob; + ofnode node; int ret; - int offset; debug("%s: %s\n", __func__, mux->name); /* * There is no compatible string in the sub-nodes, so we must manually * bind these */ - for (offset = fdt_first_subnode(blob, dev_of_offset(mux)); -offset > 0; -offset = fdt_next_subnode(blob, offset)) { + dev_for_each_subnode(node, mux) { struct udevice *dev; const char *name; - name = fdt_get_name(blob, offset, NULL); + name = ofnode_get_name(node); ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", name, -offset, &dev); +node, &dev); debug(" - bind ret=%d, %s\n", ret, dev ? dev->name : NULL);
[U-Boot] [PATCH v3 26/72] dm: test: Add support for running tests with livetree
It is useful to run the driver model tests with both livetree and flat tree in case something is different between the two. Add this feature to the test runner. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/dm/test-main.c | 23 --- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 10d2706377..88ef267458 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -22,7 +22,7 @@ struct unit_test_state global_dm_test_state; static struct dm_test_state _global_priv_dm_test_state; /* Get ready for testing */ -static int dm_test_init(struct unit_test_state *uts) +static int dm_test_init(struct unit_test_state *uts, bool of_live) { struct dm_test_state *dms = uts->priv; @@ -31,7 +31,11 @@ static int dm_test_init(struct unit_test_state *uts) memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); state_reset_for_test(state_get_current()); - ut_assertok(dm_init(false)); +#ifdef CONFIG_OF_LIVE + /* Determine whether to make the live tree available */ + gd->of_root = of_live ? uts->of_root : NULL; +#endif + ut_assertok(dm_init(of_live)); dms->root = dm_root(); return 0; @@ -72,13 +76,15 @@ static int dm_test_destroy(struct unit_test_state *uts) return 0; } -static int dm_do_test(struct unit_test_state *uts, struct unit_test *test) +static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, + bool of_live) { struct sandbox_state *state = state_get_current(); const char *fname = strrchr(test->file, '/') + 1; - printf("Test: %s: %s\n", test->name, fname); - ut_assertok(dm_test_init(uts)); + printf("Test: %s: %s%s\n", test->name, fname, + !of_live ? " (flat tree)" : ""); + ut_assertok(dm_test_init(uts, of_live)); uts->start = mallinfo(); if (test->flags & DM_TESTF_SCAN_PDATA) @@ -109,10 +115,10 @@ static int dm_test_main(const char *test_name) struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); struct unit_test_state *uts = &global_dm_test_state; - uts->priv = &_global_priv_dm_test_state; struct unit_test *test; int run_count; + uts->priv = &_global_priv_dm_test_state; uts->fail_count = 0; /* @@ -129,6 +135,9 @@ static int dm_test_main(const char *test_name) printf("Running %d driver model tests\n", n_ents); run_count = 0; +#ifdef CONFIG_OF_LIVE + uts->of_root = gd->of_root; +#endif for (test = tests; test < tests + n_ents; test++) { const char *name = test->name; @@ -137,7 +146,7 @@ static int dm_test_main(const char *test_name) name += 8; if (test_name && strcmp(test_name, name)) continue; - ut_assertok(dm_do_test(uts, test)); + ut_assertok(dm_do_test(uts, test, false)); run_count++; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 70/72] dm: test: Fix nit with position of backslash
Line up this backslash with all the others. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/test/ut.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/test/ut.h b/include/test/ut.h index 85434d785a..d176df58c7 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -104,7 +104,7 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, } /* Assert that a pointer is not an error pointer */ -#define ut_assertok_ptr(expr) {\ +#define ut_assertok_ptr(expr) { \ const void *val = (expr); \ \ if (IS_ERR(val)) { \ -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 45/72] dm: regulator: Update fixed regulator to support livetree.
Update this driver to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/power/regulator/fixed.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index cd5213766d..656371b235 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -7,7 +7,6 @@ */ #include -#include #include #include #include @@ -27,8 +26,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) struct dm_regulator_uclass_platdata *uc_pdata; struct fixed_regulator_platdata *dev_pdata; struct gpio_desc *gpio; - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev), flags = GPIOD_IS_OUT; + int flags = GPIOD_IS_OUT; int ret; dev_pdata = dev_get_platdata(dev); @@ -39,7 +37,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) /* Set type to fixed */ uc_pdata->type = REGULATOR_TYPE_FIXED; - if (fdtdec_get_bool(blob, node, "enable-active-high")) + if (dev_read_bool(dev, "enable-active-high")) flags |= GPIOD_IS_OUT_ACTIVE; /* Get fixed regulator optional enable GPIO desc */ @@ -53,9 +51,8 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) } /* Get optional ramp up delay */ - dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob, - dev_of_offset(dev), - "startup-delay-us", 0); + dev_pdata->startup_delay_us = dev_read_u32_default(dev, + "startup-delay-us", 0); return 0; } @@ -108,8 +105,11 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable) struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev); int ret; + debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, + dev->name, enable, dev_pdata->startup_delay_us, + dm_gpio_is_valid(&dev_pdata->gpio)); /* Enable GPIO is optional */ - if (!dev_pdata->gpio.dev) { + if (!dm_gpio_is_valid(&dev_pdata->gpio)) { if (!enable) return -ENOSYS; return 0; @@ -124,6 +124,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable) if (enable && dev_pdata->startup_delay_us) udelay(dev_pdata->startup_delay_us); + debug("%s: done\n", __func__); return 0; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 39/72] string: Add strcspn()
Add an implementation of strcspn() which returns the number of initial characters that do not match any in a rejection list. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/linux/string.h | 15 +++ lib/string.c | 24 2 files changed, 39 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 718c3720a1..3606620739 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -76,6 +76,21 @@ extern __kernel_size_t strlen(const char *); #ifndef __HAVE_ARCH_STRNLEN extern __kernel_size_t strnlen(const char *,__kernel_size_t); #endif + +#ifndef __HAVE_ARCH_STRCSPN +/** + * strcspn() - find span of string without given characters + * + * Calculates the length of the initial segment of @s which consists entirely + * of bsytes not in reject. + * + * @s: string to search + * @reject: strings which cause the search to halt + * @return number of characters at the start of @s which are not in @reject + */ +size_t strcspn(const char *s, const char *reject); +#endif + #ifndef __HAVE_ARCH_STRDUP extern char * strdup(const char *); #endif diff --git a/lib/string.c b/lib/string.c index e6e749b80b..c4ca944bb4 100644 --- a/lib/string.c +++ b/lib/string.c @@ -286,6 +286,30 @@ size_t strnlen(const char * s, size_t count) } #endif +#ifndef __HAVE_ARCH_STRCSPN +/** + * strcspn - Calculate the length of the initial substring of @s which does + * not contain letters in @reject + * @s: The string to be searched + * @reject: The string to avoid + */ +size_t strcspn(const char *s, const char *reject) +{ + const char *p; + const char *r; + size_t count = 0; + + for (p = s; *p != '\0'; ++p) { + for (r = reject; *r != '\0'; ++r) { + if (*p == *r) + return count; + } + ++count; + } + return count; +} +#endif + #ifndef __HAVE_ARCH_STRDUP char * strdup(const char *s) { -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 44/72] dm: regulator: Convert regulator uclass to support livetree
Update the regulator uclass to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/power/regulator/regulator-uclass.c | 39 -- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 2e0b5ed307..a42f80bb2b 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -4,8 +4,8 @@ * * SPDX-License-Identifier:GPL-2.0+ */ + #include -#include #include #include #include @@ -278,20 +278,16 @@ static bool regulator_name_is_unique(struct udevice *check_dev, static int regulator_post_bind(struct udevice *dev) { struct dm_regulator_uclass_platdata *uc_pdata; - int offset = dev_of_offset(dev); - const void *blob = gd->fdt_blob; const char *property = "regulator-name"; uc_pdata = dev_get_uclass_platdata(dev); - if (!uc_pdata) - return -ENXIO; /* Regulator's mandatory constraint */ - uc_pdata->name = fdt_getprop(blob, offset, property, NULL); + uc_pdata->name = dev_read_string(dev, property); if (!uc_pdata->name) { - debug("%s: dev: %s has no property 'regulator-name'\n", - __func__, dev->name); - uc_pdata->name = fdt_get_name(blob, offset, NULL); + debug("%s: dev '%s' has no property '%s'\n", + __func__, dev->name, property); + uc_pdata->name = dev_read_name(dev); if (!uc_pdata->name) return -EINVAL; } @@ -299,7 +295,7 @@ static int regulator_post_bind(struct udevice *dev) if (regulator_name_is_unique(dev, uc_pdata->name)) return 0; - debug("\"%s\" of dev: \"%s\", has nonunique value: \"%s\"", + debug("'%s' of dev: '%s', has nonunique value: '%s\n", property, dev->name, uc_pdata->name); return -EINVAL; @@ -308,25 +304,22 @@ static int regulator_post_bind(struct udevice *dev) static int regulator_pre_probe(struct udevice *dev) { struct dm_regulator_uclass_platdata *uc_pdata; - int offset = dev_of_offset(dev); uc_pdata = dev_get_uclass_platdata(dev); if (!uc_pdata) return -ENXIO; /* Regulator's optional constraints */ - uc_pdata->min_uV = fdtdec_get_int(gd->fdt_blob, offset, - "regulator-min-microvolt", -ENODATA); - uc_pdata->max_uV = fdtdec_get_int(gd->fdt_blob, offset, - "regulator-max-microvolt", -ENODATA); - uc_pdata->min_uA = fdtdec_get_int(gd->fdt_blob, offset, - "regulator-min-microamp", -ENODATA); - uc_pdata->max_uA = fdtdec_get_int(gd->fdt_blob, offset, - "regulator-max-microamp", -ENODATA); - uc_pdata->always_on = fdtdec_get_bool(gd->fdt_blob, offset, - "regulator-always-on"); - uc_pdata->boot_on = fdtdec_get_bool(gd->fdt_blob, offset, - "regulator-boot-on"); + uc_pdata->min_uV = dev_read_u32_default(dev, "regulator-min-microvolt", + -ENODATA); + uc_pdata->max_uV = dev_read_u32_default(dev, "regulator-max-microvolt", + -ENODATA); + uc_pdata->min_uA = dev_read_u32_default(dev, "regulator-min-microamp", + -ENODATA); + uc_pdata->max_uA = dev_read_u32_default(dev, "regulator-max-microamp", + -ENODATA); + uc_pdata->always_on = dev_read_bool(dev, "regulator-always-on"); + uc_pdata->boot_on = dev_read_bool(dev, "regulator-boot-on"); /* Those values are optional (-ENODATA if unset) */ if ((uc_pdata->min_uV != -ENODATA) && -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 12/72] dm: core: Add a place to put extra device-tree reading functions
Some functions deal with structured data rather than simple data types. It makes sense to have these in their own file. For now this just has a function to read a flashmap entry. Move the data types also. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/Makefile | 2 +- drivers/core/of_extra.c | 37 + include/cros_ec.h | 1 + include/dm/of_extra.h | 46 ++ include/fdtdec.h| 23 +-- lib/fdtdec.c| 1 + 6 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 drivers/core/of_extra.c create mode 100644 include/dm/of_extra.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 1c6795af13..d74b065a07 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -12,4 +12,4 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP)+= regmap.o obj-$(CONFIG_$(SPL_)SYSCON)+= syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o -obj-$(CONFIG_OF_CONTROL) += ofnode.o +obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c new file mode 100644 index 00..0381909848 --- /dev/null +++ b/drivers/core/of_extra.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +int of_read_fmap_entry(ofnode node, const char *name, + struct fmap_entry *entry) +{ + const char *prop; + u32 reg[2]; + + if (ofnode_read_u32_array(node, "reg", reg, 2)) { + debug("Node '%s' has bad/missing 'reg' property\n", name); + return -FDT_ERR_NOTFOUND; + } + entry->offset = reg[0]; + entry->length = reg[1]; + entry->used = ofnode_read_s32_default(node, "used", entry->length); + prop = ofnode_read_string(node, "compress"); + entry->compress_algo = prop && !strcmp(prop, "lzo") ? + FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE; + prop = ofnode_read_string(node, "hash"); + if (prop) + entry->hash_size = strlen(prop); + entry->hash_algo = prop ? FMAP_HASH_SHA256 : FMAP_HASH_NONE; + entry->hash = (uint8_t *)prop; + + return 0; +} diff --git a/include/cros_ec.h b/include/cros_ec.h index 0271f2b827..2bd9f2251f 100644 --- a/include/cros_ec.h +++ b/include/cros_ec.h @@ -14,6 +14,7 @@ #include #include #include +#include /* Our configuration information */ struct cros_ec_dev { diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h new file mode 100644 index 00..01b6ebedff --- /dev/null +++ b/include/dm/of_extra.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef _DM_OF_EXTRA_H +#define _DM_OF_EXTRA_H + +#include + +enum fmap_compress_t { + FMAP_COMPRESS_NONE, + FMAP_COMPRESS_LZO, +}; + +enum fmap_hash_t { + FMAP_HASH_NONE, + FMAP_HASH_SHA1, + FMAP_HASH_SHA256, +}; + +/* A flash map entry, containing an offset and length */ +struct fmap_entry { + uint32_t offset; + uint32_t length; + uint32_t used; /* Number of bytes used in region */ + enum fmap_compress_t compress_algo; /* Compression type */ + enum fmap_hash_t hash_algo; /* Hash algorithm */ + const uint8_t *hash;/* Hash value */ + int hash_size; /* Hash size */ +}; + +/** + * Read a flash entry from the fdt + * + * @param node Reference to node to read + * @param name Name of node being read + * @param entryPlace to put offset and size of this node + * @return 0 if ok, -ve on error + */ +int of_read_fmap_entry(ofnode node, const char *name, + struct fmap_entry *entry); + +#endif diff --git a/include/fdtdec.h b/include/fdtdec.h index 3000ecbb58..f27fb368ad 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -815,28 +815,7 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node, int fdtdec_decode_region(const void *blob, int node, const char *prop_name, fdt_addr_t *basep, fdt_size_t *sizep); -enum fmap_compress_t { - FMAP_COMPRESS_NONE, - FMAP_COMPRESS_LZO, -}; - -enum fmap_hash_t { - FMAP_HASH_NONE, - FMAP_HASH_SHA1, - FMAP_HASH_SHA256, -}; - -/* A flash map entry, containing an offset and length */ -struct fmap_entry { - uint32_t offset; - uint32_t length; - uint32_t used; /* Number of bytes used in region */ - enum fmap_compress_t compress_algo; /* Compression type */ - enum fmap_hash_t hash_algo; /* Hash algorithm */ - const uint8_t *hash;/* Hash value */ - int h
[U-Boot] [PATCH v3 28/72] dm: gpio: Refactor to prepare for live tree support
Move the main part of the GPIO request function into a separate function so that it can be used by the live tree function when added. Update the xlate method to use a node reference. Update all GPIO drivers to handle the modified xlate() method. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/gpio/74x164_gpio.c | 2 +- drivers/gpio/gpio-uclass.c | 51 ++-- drivers/gpio/pca953x_gpio.c | 2 +- drivers/gpio/sandbox.c | 3 ++- drivers/gpio/sunxi_gpio.c| 2 +- drivers/gpio/tegra186_gpio.c | 2 +- drivers/gpio/tegra_gpio.c| 2 +- include/asm-generic/gpio.h | 6 -- 8 files changed, 41 insertions(+), 29 deletions(-) diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c index 750eedfffd..ad69cb5a65 100644 --- a/drivers/gpio/74x164_gpio.c +++ b/drivers/gpio/74x164_gpio.c @@ -106,7 +106,7 @@ static int gen_74x164_get_function(struct udevice *dev, unsigned offset) } static int gen_74x164_xlate(struct udevice *dev, struct gpio_desc *desc, - struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { desc->offset = args->args[0]; desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0; diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index ba4804083d..92a1346aa2 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -114,9 +114,8 @@ int gpio_lookup_name(const char *name, struct udevice **devp, return 0; } -int gpio_xlate_offs_flags(struct udevice *dev, -struct gpio_desc *desc, -struct fdtdec_phandle_args *args) +int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc, + struct ofnode_phandle_args *args) { if (args->args_count < 1) return -EINVAL; @@ -133,7 +132,7 @@ int gpio_xlate_offs_flags(struct udevice *dev, } static int gpio_find_and_xlate(struct gpio_desc *desc, - struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { struct dm_gpio_ops *ops = gpio_get_ops(desc->dev); @@ -642,37 +641,30 @@ int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count) return vector; } -static int _gpio_request_by_name_nodev(const void *blob, int node, - const char *list_name, int index, - struct gpio_desc *desc, int flags, - bool add_index) +static int gpio_request_tail(int ret, ofnode node, +struct ofnode_phandle_args *args, +const char *list_name, int index, +struct gpio_desc *desc, int flags, bool add_index) { - struct fdtdec_phandle_args args; - int ret; - desc->dev = NULL; desc->offset = 0; desc->flags = 0; - ret = fdtdec_parse_phandle_with_args(blob, node, list_name, -"#gpio-cells", 0, index, &args); - if (ret) { - debug("%s: fdtdec_parse_phandle_with_args failed\n", __func__); + if (ret) goto err; - } - ret = uclass_get_device_by_of_offset(UCLASS_GPIO, args.node, -&desc->dev); + ret = uclass_get_device_by_ofnode(UCLASS_GPIO, args->node, + &desc->dev); if (ret) { debug("%s: uclass_get_device_by_of_offset failed\n", __func__); goto err; } - ret = gpio_find_and_xlate(desc, &args); + ret = gpio_find_and_xlate(desc, args); if (ret) { debug("%s: gpio_find_and_xlate failed\n", __func__); goto err; } ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s", - fdt_get_name(blob, node, NULL), + ofnode_get_name(node), list_name, index); if (ret) { debug("%s: dm_gpio_requestf failed\n", __func__); @@ -687,10 +679,27 @@ static int _gpio_request_by_name_nodev(const void *blob, int node, return 0; err: debug("%s: Node '%s', property '%s', failed to request GPIO index %d: %d\n", - __func__, fdt_get_name(blob, node, NULL), list_name, index, ret); + __func__, ofnode_get_name(node), list_name, index, ret); return ret; } +static int _gpio_request_by_name_nodev(const void *blob, int node, + const char *list_name, int index, + struct gpio_desc *desc, int flags, + bool add_index) +{ + struct ofnode_phandle
[U-Boot] [PATCH v3 09/72] dm: core: Add livetree address functions
Add functions to access addresses in the device tree. These are brought in from Linux 4.10. Also fix up the header guard for fdtaddr.h to avoid confusion. Signed-off-by: Simon Glass --- Changes in v3: - Fix up the fdtaddr.h header guard to avoid conflicts Changes in v2: None drivers/core/Makefile | 2 +- drivers/core/of_addr.c | 359 + include/dm/fdtaddr.h | 4 +- include/dm/of_addr.h | 64 + 4 files changed, 426 insertions(+), 3 deletions(-) create mode 100644 drivers/core/of_addr.c create mode 100644 include/dm/of_addr.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index c25288e464..1c6795af13 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -11,5 +11,5 @@ obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP)+= regmap.o obj-$(CONFIG_$(SPL_)SYSCON)+= syscon-uclass.o -obj-$(CONFIG_OF_LIVE) += of_access.o +obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o obj-$(CONFIG_OF_CONTROL) += ofnode.o diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c new file mode 100644 index 00..4757066967 --- /dev/null +++ b/drivers/core/of_addr.c @@ -0,0 +1,359 @@ +/* + * Taken from Linux v4.9 drivers/of/address.c + * + * Modified for U-Boot + * Copyright (c) 2017 Google, Inc + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +/* Max address size we deal with */ +#define OF_MAX_ADDR_CELLS 4 +#define OF_CHECK_ADDR_COUNT(na)((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) +#define OF_CHECK_COUNTS(na, ns)(OF_CHECK_ADDR_COUNT(na) && (ns) > 0) + +static struct of_bus *of_match_bus(struct device_node *np); + +/* Debug utility */ +#ifdef DEBUG +static void of_dump_addr(const char *s, const __be32 *addr, int na) +{ + debug("%s", s); + while (na--) + pr_cont(" %08x", be32_to_cpu(*(addr++))); + pr_cont("\n"); +} +#else +static void of_dump_addr(const char *s, const __be32 *addr, int na) { } +#endif + +/* Callbacks for bus specific translators */ +struct of_bus { + const char *name; + const char *addresses; + int (*match)(struct device_node *parent); + void (*count_cells)(const struct device_node *child, int *addrc, + int *sizec); + u64 (*map)(__be32 *addr, const __be32 *range, int na, int ns, int pna); + int (*translate)(__be32 *addr, u64 offset, int na); + unsigned int (*get_flags)(const __be32 *addr); +}; + +static void of_bus_default_count_cells(const struct device_node *np, + int *addrc, int *sizec) +{ + if (addrc) + *addrc = of_n_addr_cells(np); + if (sizec) + *sizec = of_n_size_cells(np); +} + +static u64 of_bus_default_map(__be32 *addr, const __be32 *range, + int na, int ns, int pna) +{ + u64 cp, s, da; + + cp = of_read_number(range, na); + s = of_read_number(range + na + pna, ns); + da = of_read_number(addr, na); + + debug("default map, cp=%llx, s=%llx, da=%llx\n", + (unsigned long long)cp, (unsigned long long)s, + (unsigned long long)da); + + if (da < cp || da >= (cp + s)) + return OF_BAD_ADDR; + return da - cp; +} + +static int of_bus_default_translate(__be32 *addr, u64 offset, int na) +{ + u64 a = of_read_number(addr, na); + memset(addr, 0, na * 4); + a += offset; + if (na > 1) + addr[na - 2] = cpu_to_be32(a >> 32); + addr[na - 1] = cpu_to_be32(a & 0xu); + + return 0; +} + +static unsigned int of_bus_default_get_flags(const __be32 *addr) +{ + return IORESOURCE_MEM; +} + +/* + * Array of bus-specific translators + */ +static struct of_bus of_busses[] = { + /* Default */ + { + .name = "default", + .addresses = "reg", + .match = NULL, + .count_cells = of_bus_default_count_cells, + .map = of_bus_default_map, + .translate = of_bus_default_translate, + .get_flags = of_bus_default_get_flags, + }, +}; + +static struct of_bus *of_match_bus(struct device_node *np) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(of_busses); i++) + if (!of_busses[i].match || of_busses[i].match(np)) + return &of_busses[i]; + BUG(); + return NULL; +} + +static void dev_count_cells(const struct device_node *np, int *nap, int *nsp) +{ + of_bus_default_count_cells(np, nap, nsp); +} + +const __be32 *of_get_address(const struct device_node *dev, int index, +u64 *size, unsigned int *flags) +{ + const __be32 *prop; + int psize; + struct device_node *parent; + struct of_bus *bus; + int onesize, i, na, ns; + + /* Get parent & matc
[U-Boot] [PATCH v3 42/72] dm: pmic: Convert uclass to livetree
Update the pmic uclass and all pmics to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/power/pmic/act8846.c | 8 +++- drivers/power/pmic/lp873x.c | 12 +--- drivers/power/pmic/max77686.c| 8 +++- drivers/power/pmic/palmas.c | 16 +++- drivers/power/pmic/pfuze100.c| 8 +++- drivers/power/pmic/pmic-uclass.c | 22 ++ drivers/power/pmic/rk8xx.c | 8 +++- drivers/power/pmic/s5m8767.c | 7 +++ drivers/power/pmic/sandbox.c | 2 +- drivers/power/pmic/tps65090.c| 8 +++- include/power/pmic.h | 2 +- 11 files changed, 42 insertions(+), 59 deletions(-) diff --git a/drivers/power/pmic/act8846.c b/drivers/power/pmic/act8846.c index 15da12edea..a6b0940956 100644 --- a/drivers/power/pmic/act8846.c +++ b/drivers/power/pmic/act8846.c @@ -48,13 +48,11 @@ static int act8846_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int act8846_bind(struct udevice *dev) { - const void *blob = gd->fdt_blob; - int regulators_node; + ofnode regulators_node; int children; - regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), -"regulators"); - if (regulators_node <= 0) { + regulators_node = dev_read_subnode(dev, "regulators"); + if (!ofnode_valid(regulators_node)) { debug("%s: %s regulators subnode not found!", __func__, dev->name); return -ENXIO; diff --git a/drivers/power/pmic/lp873x.c b/drivers/power/pmic/lp873x.c index d8f30df371..f505468313 100644 --- a/drivers/power/pmic/lp873x.c +++ b/drivers/power/pmic/lp873x.c @@ -46,15 +46,13 @@ static int lp873x_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int lp873x_bind(struct udevice *dev) { - int regulators_node; - const void *blob = gd->fdt_blob; + ofnode regulators_node; int children; - int node = dev_of_offset(dev); - regulators_node = fdt_subnode_offset(blob, node, "regulators"); - - if (regulators_node <= 0) { - printf("%s: %s reg subnode not found!", __func__, dev->name); + regulators_node = dev_read_subnode(dev, "regulators"); + if (!ofnode_valid(regulators_node)) { + debug("%s: %s regulators subnode not found!", __func__, + dev->name); return -ENXIO; } diff --git a/drivers/power/pmic/max77686.c b/drivers/power/pmic/max77686.c index 8295fab3f0..ceca9f96a7 100644 --- a/drivers/power/pmic/max77686.c +++ b/drivers/power/pmic/max77686.c @@ -50,13 +50,11 @@ static int max77686_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int max77686_bind(struct udevice *dev) { - int regulators_node; - const void *blob = gd->fdt_blob; + ofnode regulators_node; int children; - regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev), -"voltage-regulators"); - if (regulators_node <= 0) { + regulators_node = dev_read_subnode(dev, "voltage-regulators"); + if (!ofnode_valid(regulators_node)) { debug("%s: %s regulators subnode not found!", __func__, dev->name); return -ENXIO; diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c index f5a23073c4..804c0d13a0 100644 --- a/drivers/power/pmic/palmas.c +++ b/drivers/power/pmic/palmas.c @@ -46,17 +46,15 @@ static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len) static int palmas_bind(struct udevice *dev) { - int pmic_node = -1, regulators_node; - const void *blob = gd->fdt_blob; + ofnode pmic_node = ofnode_null(), regulators_node; + ofnode subnode; int children; - int node = dev_of_offset(dev); - int subnode, len; - fdt_for_each_subnode(subnode, blob, node) { + dev_for_each_subnode(subnode, dev) { const char *name; char *temp; - name = fdt_get_name(blob, subnode, &len); + name = ofnode_get_name(subnode); temp = strstr(name, "pmic"); if (temp) { pmic_node = subnode; @@ -64,14 +62,14 @@ static int palmas_bind(struct udevice *dev) } } - if (pmic_node <= 0) { + if (!ofnode_valid(pmic_node)) { debug("%s: %s pmic subnode not found!", __func__, dev->name); return -ENXIO; } - regulators_node = fdt_subnode_offset(blob, pmic_node, "regulators"); + regulators_node = ofnode_find_subnode(pmic_node, "regulators"); - if (regulators_node <= 0) { + if (!ofnode_valid(regulators_node)) { debug("%s: %s reg subnode
[U-Boot] [PATCH v3 20/72] dm: regmap: Add support for livetree
Modify regmap to support livetree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/regmap.c | 37 ++--- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 7f21dee7e4..749d913372 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -12,8 +12,9 @@ #include #include #include - #include +#include +#include DECLARE_GLOBAL_DATA_PTR; @@ -62,25 +63,25 @@ int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count, #else int regmap_init_mem(struct udevice *dev, struct regmap **mapp) { - const void *blob = gd->fdt_blob; struct regmap_range *range; - const fdt32_t *cell; struct regmap *map; int count; int addr_len, size_len, both_len; - int parent; int len; int index; + ofnode node = dev_ofnode(dev); + struct resource r; - parent = dev_of_offset(dev->parent); - addr_len = fdt_address_cells(blob, parent); - size_len = fdt_size_cells(blob, parent); + addr_len = dev_read_addr_cells(dev->parent); + size_len = dev_read_size_cells(dev->parent); both_len = addr_len + size_len; - cell = fdt_getprop(blob, dev_of_offset(dev), "reg", &len); - len /= sizeof(*cell); + len = dev_read_size(dev, "reg"); + if (len < 0) + return len; + len /= sizeof(fdt32_t); count = len / both_len; - if (!cell || !count) + if (!count) return -EINVAL; map = regmap_alloc_count(count); @@ -88,12 +89,18 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp) return -ENOMEM; for (range = map->range, index = 0; count > 0; -count--, cell += both_len, range++, index++) { +count--, range++, index++) { fdt_size_t sz; - range->start = fdtdec_get_addr_size_fixed(blob, - dev_of_offset(dev), "reg", index, addr_len, - size_len, &sz, true); - range->size = sz; + if (of_live_active()) { + of_address_to_resource(ofnode_to_np(node), index, &r); + range->start = r.start; + range->size = r.end - r.start + 1; + } else { + range->start = fdtdec_get_addr_size_fixed(gd->fdt_blob, + dev_of_offset(dev), "reg", index, + addr_len, size_len, &sz, true); + range->size = sz; + } } map->base = map->range[0].start; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 68/72] dm: sandbox: spi: Convert driver to support livetree
Update this driver to support a live device tree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/mtd/spi/sandbox.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c index a53f4ebc68..1ba6815232 100644 --- a/drivers/mtd/spi/sandbox.c +++ b/drivers/mtd/spi/sandbox.c @@ -515,11 +515,9 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, int sandbox_sf_ofdata_to_platdata(struct udevice *dev) { struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); - const void *blob = gd->fdt_blob; - int node = dev_of_offset(dev); - pdata->filename = fdt_getprop(blob, node, "sandbox,filename", NULL); - pdata->device_name = fdt_getprop(blob, node, "compatible", NULL); + pdata->filename = dev_read_string(dev, "sandbox,filename"); + pdata->device_name = dev_read_string(dev, "compatible"); if (!pdata->filename || !pdata->device_name) { debug("%s: Missing properties, filename=%s, device_name=%s\n", __func__, pdata->filename, pdata->device_name); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 55/72] dm: phy: Update tests to use ut_asserteq()
Use ut_asserteq() to test equality since this gives a better error message on failure. Also make a few of the tests more specific. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/dm/phy.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/dm/phy.c b/test/dm/phy.c index 811045fc0a..65b33fe68d 100644 --- a/test/dm/phy.c +++ b/test/dm/phy.c @@ -49,8 +49,8 @@ static int dm_test_phy_base(struct unit_test_state *uts) /* Try to get a non-existing phy */ ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PHY, 3, &dev)); - ut_assert(generic_phy_get_by_name(parent, "phy_not_existing", - &phy1_method1) < 0) + ut_asserteq(-ENODATA, generic_phy_get_by_name(parent, + "phy_not_existing", &phy1_method1)); return 0; } @@ -68,8 +68,11 @@ static int dm_test_phy_ops(struct unit_test_state *uts) "gen_phy_user", &parent)); ut_assertok(generic_phy_get_by_name(parent, "phy1", &phy1)); + ut_asserteq(0, phy1.id); ut_assertok(generic_phy_get_by_name(parent, "phy2", &phy2)); + ut_asserteq(1, phy2.id); ut_assertok(generic_phy_get_by_name(parent, "phy3", &phy3)); + ut_asserteq(0, phy3.id); /* test normal operations */ ut_assertok(generic_phy_init(&phy1)); @@ -100,12 +103,12 @@ static int dm_test_phy_ops(struct unit_test_state *uts) /* PHY2 has a known problem with power off */ ut_assertok(generic_phy_init(&phy2)); ut_assertok(generic_phy_power_on(&phy2)); - ut_assert(generic_phy_power_off(&phy2) == -EIO); + ut_asserteq(-EIO, generic_phy_power_off(&phy2)); - /* PHY3 has a known problem with power off and power on*/ + /* PHY3 has a known problem with power off and power on */ ut_assertok(generic_phy_init(&phy3)); - ut_assert(generic_phy_power_off(&phy3) == -EIO); - ut_assert(generic_phy_power_off(&phy3) == -EIO); + ut_asserteq(-EIO, generic_phy_power_off(&phy3)); + ut_asserteq(-EIO, generic_phy_power_off(&phy3)); return 0; } -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 56/72] dm: mailbox: Update uclass to support livetree
Update the mailbox uclass to support livetree. Fix the xlate() method in all callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/mailbox/mailbox-uclass.c | 20 drivers/mailbox/tegra-hsp.c | 2 +- include/mailbox-uclass.h | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c index 38448de965..822ae5b45e 100644 --- a/drivers/mailbox/mailbox-uclass.c +++ b/drivers/mailbox/mailbox-uclass.c @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -18,7 +17,7 @@ static inline struct mbox_ops *mbox_dev_ops(struct udevice *dev) } static int mbox_of_xlate_default(struct mbox_chan *chan, -struct fdtdec_phandle_args *args) +struct ofnode_phandle_args *args) { debug("%s(chan=%p)\n", __func__, chan); @@ -34,24 +33,22 @@ static int mbox_of_xlate_default(struct mbox_chan *chan, int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan) { - struct fdtdec_phandle_args args; + struct ofnode_phandle_args args; int ret; struct udevice *dev_mbox; struct mbox_ops *ops; debug("%s(dev=%p, index=%d, chan=%p)\n", __func__, dev, index, chan); - ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev), -"mboxes", "#mbox-cells", 0, -index, &args); + ret = dev_read_phandle_with_args(dev, "mboxes", "#mbox-cells", 0, index, +&args); if (ret) { - debug("%s: fdtdec_parse_phandle_with_args failed: %d\n", - __func__, ret); + debug("%s: dev_read_phandle_with_args failed: %d\n", __func__, + ret); return ret; } - ret = uclass_get_device_by_of_offset(UCLASS_MAILBOX, args.node, -&dev_mbox); + ret = uclass_get_device_by_ofnode(UCLASS_MAILBOX, args.node, &dev_mbox); if (ret) { debug("%s: uclass_get_device_by_of_offset failed: %d\n", __func__, ret); @@ -85,8 +82,7 @@ int mbox_get_by_name(struct udevice *dev, const char *name, debug("%s(dev=%p, name=%s, chan=%p)\n", __func__, dev, name, chan); - index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev), - "mbox-names", name); + index = dev_read_stringlist_search(dev, "mbox-names", name); if (index < 0) { debug("fdt_stringlist_search() failed: %d\n", index); return index; diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index b546ba2471..bd2ec411c7 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -72,7 +72,7 @@ static int tegra_hsp_db_id(ulong chan_id) } static int tegra_hsp_of_xlate(struct mbox_chan *chan, - struct fdtdec_phandle_args *args) + struct ofnode_phandle_args *args) { debug("%s(chan=%p)\n", __func__, chan); diff --git a/include/mailbox-uclass.h b/include/mailbox-uclass.h index 6ec62e5a0e..8a638b04c5 100644 --- a/include/mailbox-uclass.h +++ b/include/mailbox-uclass.h @@ -36,7 +36,7 @@ struct mbox_ops { * @return 0 if OK, or a negative error code. */ int (*of_xlate)(struct mbox_chan *chan, - struct fdtdec_phandle_args *args); + struct ofnode_phandle_args *args); /** * request - Request a translated channel. * -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 53/72] dm: test: Separate out the bus DT offset test
We cannot access the device tree via an offset when running in livetree mode. Separate out that part of the bus' children tests and mark it as for the flat tree only. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/dm/bus.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/dm/bus.c b/test/dm/bus.c index 6a2773565e..8ba75d4b7d 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -160,8 +160,21 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts) node = fdt_path_offset(blob, "/d-test"); ut_asserteq(-ENODEV, device_find_child_by_of_offset(bus, node, &dev)); + return 0; +} +DM_TEST(dm_test_bus_children_funcs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int dm_test_bus_children_of_offset(struct unit_test_state *uts) +{ + const void *blob = gd->fdt_blob; + struct udevice *bus, *dev; + int node; + + ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus)); + /* Find a valid child */ node = fdt_path_offset(blob, "/some-bus/c-test@1"); + ut_assert(node > 0); ut_assertok(device_find_child_by_of_offset(bus, node, &dev)); ut_assert(!(dev->flags & DM_FLAG_ACTIVATED)); ut_assertok(device_get_child_by_of_offset(bus, node, &dev)); @@ -169,7 +182,8 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts) return 0; } -DM_TEST(dm_test_bus_children_funcs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +DM_TEST(dm_test_bus_children_of_offset, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE); /* Test that we can iterate through children */ static int dm_test_bus_children_iterators(struct unit_test_state *uts) -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 21/72] dm: simple-bus: Add support for livetree
Modify simple-bus to support livetree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/simple-bus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c index a300217d39..14803e32b1 100644 --- a/drivers/core/simple-bus.c +++ b/drivers/core/simple-bus.c @@ -33,8 +33,7 @@ static int simple_bus_post_bind(struct udevice *dev) u32 cell[3]; int ret; - ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "ranges", - cell, ARRAY_SIZE(cell)); + ret = dev_read_u32_array(dev, "ranges", cell, ARRAY_SIZE(cell)); if (!ret) { struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 38/72] string: Add strchrnul()
This functions works like strchr() but returns the end of the string if the character is not found. Add an implementation of this. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/linux/string.h | 13 + lib/string.c | 8 2 files changed, 21 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 091ccab395..718c3720a1 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -50,6 +50,19 @@ extern int strncasecmp(const char *s1, const char *s2, __kernel_size_t len); #ifndef __HAVE_ARCH_STRCHR extern char * strchr(const char *,int); #endif + +/** + * strchrnul() - return position of a character in the string, or end of string + * + * The strchrnul() function is like strchr() except that if c is not found + * in s, then it returns a pointer to the nul byte at the end of s, rather than + * NULL + * @s: string to search + * @c: character to search for + * @return position of @c in @s, or end of @s if not found + */ +const char *strchrnul(const char *s, int c); + #ifndef __HAVE_ARCH_STRRCHR extern char * strrchr(const char *,int); #endif diff --git a/lib/string.c b/lib/string.c index e94021c468..e6e749b80b 100644 --- a/lib/string.c +++ b/lib/string.c @@ -230,6 +230,14 @@ char * strchr(const char * s, int c) } #endif +const char *strchrnul(const char *s, int c) +{ + for (; *s != (char)c; ++s) + if (*s == '\0') + break; + return s; +} + #ifndef __HAVE_ARCH_STRRCHR /** * strrchr - Find the last occurrence of a character in a string -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 41/72] samsung: Move pmic header out of config file
We should not be including a PMIC header file in the board config. Move it to a C file. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to move pmic header out of config file Changes in v2: None board/samsung/common/misc.c | 1 + include/configs/trats2.h| 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index dc4dead20b..3a8e807736 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/include/configs/trats2.h b/include/configs/trats2.h index 6a4604ce93..927d48255c 100644 --- a/include/configs/trats2.h +++ b/include/configs/trats2.h @@ -169,7 +169,6 @@ /* Download menu - definitions for check keys */ #ifndef __ASSEMBLY__ -#include #define KEY_PWR_PMIC_NAME "MAX77686_PMIC" #define KEY_PWR_STATUS_REG MAX77686_REG_PMIC_STATUS1 -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 16/72] dm: core: Update lists_bind_fdt() to use ofnode
Adjust this function to use an ofnode instead of an offset, so it can be used with livetree. This involves updating all callers. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/lists.c | 12 ++-- drivers/core/root.c| 2 +- drivers/serial/serial-uclass.c | 3 ++- drivers/timer/timer-uclass.c | 3 ++- include/dm/lists.h | 7 +++ 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 9adfa758bc..facf276474 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -126,8 +126,7 @@ static int driver_check_compatible(const struct udevice_id *of_match, return -ENOENT; } -int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, - struct udevice **devp) +int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp) { struct driver *driver = ll_entry_start(struct driver, driver); const int n_ents = ll_entry_count(struct driver, driver); @@ -142,17 +141,18 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, if (devp) *devp = NULL; - name = fdt_get_name(blob, offset, NULL); + name = ofnode_get_name(node); dm_dbg("bind node %s\n", name); - compat_list = fdt_getprop(blob, offset, "compatible", &compat_length); + compat_list = (const char *)ofnode_read_prop(node, "compatible", +&compat_length); if (!compat_list) { if (compat_length == -FDT_ERR_NOTFOUND) { dm_dbg("Device '%s' has no compatible string\n", name); return 0; } - dm_warn("Device tree error at offset %d\n", offset); + dm_warn("Device tree error at node '%s'\n", name); return compat_length; } @@ -177,7 +177,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, dm_dbg(" - found match at '%s'\n", entry->name); ret = device_bind_with_driver_data(parent, entry, name, - id->data, offset_to_ofnode(offset), &dev); + id->data, node, &dev); if (ret == -ENODEV) { dm_dbg("Driver '%s' refuses to bind\n", entry->name); continue; diff --git a/drivers/core/root.c b/drivers/core/root.c index 570b4d855f..0c00a4e051 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -235,7 +235,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, dm_dbg(" - ignoring disabled device\n"); continue; } - err = lists_bind_fdt(parent, blob, offset, NULL); + err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL); if (err && !ret) { ret = err; debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL), diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index c2b9c5f12f..a9c4f89e1a 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -74,7 +74,8 @@ static void serial_find_console_or_panic(void) * bind it anyway. */ if (node > 0 && - !lists_bind_fdt(gd->dm_root, blob, node, &dev)) { + !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node), + &dev)) { if (!device_probe(dev)) { gd->cur_serial_dev = dev; return; diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 1caf3cd288..ec10b28288 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -103,7 +103,8 @@ int notrace dm_timer_init(void) * relocation, bind it anyway. */ if (node > 0 && - !lists_bind_fdt(gd->dm_root, blob, node, &dev)) { + !lists_bind_fdt(gd->dm_root, offset_to_ofnode(node), + &dev)) { ret = device_probe(dev); if (ret) return ret; diff --git a/include/dm/lists.h b/include/dm/lists.h index 4513d6a311..f55c41991b 100644 --- a/include/dm/lists.h +++ b/include/dm/lists.h @@ -10,6 +10,7 @@ #ifndef _DM_LISTS_H_ #define _DM_LISTS_H_ +#include #include /** @@ -51,14 +52,12 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only); * @parent as its parent. * * @parent: parent device (root) - * @blob: device tree blob - * @offset: offset of this devi
[U-Boot] [PATCH v3 15/72] dm: core: Allow binding a device from a live tree
When a live tree is being used we need to record the node that was used to create the device. Update device_bind_with_driver_data() to support this. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/device.c| 18 -- drivers/core/lists.c | 2 +- include/dm/device-internal.h | 10 ++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index f5e85413f7..5463d1ffa5 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -77,10 +78,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv, */ if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) { if (uc->uc_drv->name && ofnode_valid(node)) { - fdtdec_get_alias_seq(gd->fdt_blob, - uc->uc_drv->name, - ofnode_to_offset(node), - &dev->req_seq); + dev_read_alias_seq(dev, &dev->req_seq); } } } @@ -216,11 +214,11 @@ fail_alloc1: int device_bind_with_driver_data(struct udevice *parent, const struct driver *drv, const char *name, -ulong driver_data, int of_offset, +ulong driver_data, ofnode node, struct udevice **devp) { - return device_bind_common(parent, drv, name, NULL, driver_data, - offset_to_ofnode(of_offset), 0, devp); + return device_bind_common(parent, drv, name, NULL, driver_data, node, + 0, devp); } int device_bind(struct udevice *parent, const struct driver *drv, @@ -247,8 +245,8 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only, platdata_size = info->platdata_size; #endif return device_bind_common(parent, drv, info->name, - (void *)info->platdata, 0, offset_to_ofnode(-1), - platdata_size, devp); + (void *)info->platdata, 0, ofnode_null(), platdata_size, + devp); } static void *alloc_priv(int size, uint flags) @@ -385,7 +383,7 @@ int device_probe(struct udevice *dev) goto fail; } - if (drv->ofdata_to_platdata && dev_of_offset(dev) >= 0) { + if (drv->ofdata_to_platdata && dev_has_of_node(dev)) { ret = drv->ofdata_to_platdata(dev); if (ret) goto fail; diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 72c55e205f..9adfa758bc 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -177,7 +177,7 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, dm_dbg(" - found match at '%s'\n", entry->name); ret = device_bind_with_driver_data(parent, entry, name, - id->data, offset, &dev); + id->data, offset_to_ofnode(offset), &dev); if (ret == -ENODEV) { dm_dbg("Driver '%s' refuses to bind\n", entry->name); continue; diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h index 2cabc87338..81ab893b60 100644 --- a/include/dm/device-internal.h +++ b/include/dm/device-internal.h @@ -11,6 +11,9 @@ #ifndef _DM_DEVICE_INTERNAL_H #define _DM_DEVICE_INTERNAL_H +#include + +struct device_node; struct udevice; /** @@ -52,16 +55,15 @@ int device_bind(struct udevice *parent, const struct driver *drv, * @drv: Device's driver * @name: Name of device (e.g. device tree node name) * @driver_data: The driver_data field from the driver's match table. - * @of_offset: Offset of device tree node for this device. This is -1 for - * devices which don't use device tree. + * @node: Device tree node for this device. This is invalid for devices which + * don't use device tree. * @devp: if non-NULL, returns a pointer to the bound device * @return 0 if OK, -ve on error */ int device_bind_with_driver_data(struct udevice *parent, const struct driver *drv, const char *name, -ulong driver_data, int of_offset, +ulong driver_data, ofnode node, struct udevice **devp); - /** * device_bind_by_name: Create a device and bind it to a driver * -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 29/72] dm: gpio: Drop blank line in gpio_xlate_offs_flags() comment
This is not needed. Drop it. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/asm-generic/gpio.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index b073b39138..d78491dfc2 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -213,7 +213,6 @@ struct fdtdec_phandle_args; * * This routine sets the offset field to args[0] and the flags field to * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1]. - * */ int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc, struct ofnode_phandle_args *args); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 11/72] dm: core: Add address operations on device tree references
Add functions to add addresses in the device tree using ofnode references. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/ofnode.c | 27 +++ include/dm/ofnode.h | 23 ++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index e6c9a28bae..ac312d6546 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -195,6 +196,32 @@ int ofnode_read_size(ofnode node, const char *propname) return -EINVAL; } +fdt_addr_t ofnode_get_addr_index(ofnode node, int index) +{ + if (ofnode_is_np(node)) { + const __be32 *prop_val; + uint flags; + u64 size; + + prop_val = of_get_address( + (struct device_node *)ofnode_to_np(node), index, + &size, &flags); + if (!prop_val) + return FDT_ADDR_T_NONE; + return be32_to_cpup(prop_val); + } else { + return fdt_get_base_address(gd->fdt_blob, + ofnode_to_offset(node)); + } + + return FDT_ADDR_T_NONE; +} + +fdt_addr_t ofnode_get_addr(ofnode node) +{ + return ofnode_get_addr_index(node, 0); +} + int ofnode_stringlist_search(ofnode node, const char *property, const char *string) { diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index e8b33c158d..149622a0b2 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -245,7 +245,7 @@ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def); const char *ofnode_read_string(ofnode node, const char *propname); /** - * ofnode_read_u32_array - Find and read an array of 32 bit integers + * ofnode_read_u32_array() - Find and read an array of 32 bit integers * * @node: valid node reference to read property from * @propname: name of the property to read @@ -317,6 +317,27 @@ const char *ofnode_get_name(ofnode node); int ofnode_read_size(ofnode node, const char *propname); /** + * ofnode_get_addr_index() - get an address from a node + * + * This reads the register address from a node + * + * @node: node to read from + * @index: Index of address to read (0 for first) + * @return address, or FDT_ADDR_T_NONE if not present or invalid + */ +phys_addr_t ofnode_get_addr_index(ofnode node, int index); + +/** + * ofnode_get_addr() - get an address from a node + * + * This reads the register address from a node + * + * @node: node to read from + * @return address, or FDT_ADDR_T_NONE if not present or invalid + */ +phys_addr_t ofnode_get_addr(ofnode node); + +/** * ofnode_stringlist_search() - find a string in a string list and return index * * Note that it is possible for this function to succeed on property values -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 13/72] dm: core: Add device-based 'read' functions to access DT
It is common to read a device-tree property from the node associated with a device. Add convenience functions to do this so that drivers do not need to deal with accessing the ofnode from the device. These functions all start with 'dev_read_' to provide consistent naming for all functions which read information from a device's device tree node. These are inlined when using the flat DT to save code size. The live tree implementation is added in a later commit. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/Kconfig | 4 + include/dm/read.h| 383 +++ 2 files changed, 387 insertions(+) create mode 100644 include/dm/read.h diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 405e9ad8ef..fb5c4e834d 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -215,4 +215,8 @@ config OF_ISA_BUS mistranslation of device addresses, so ensure that this is enabled if your board does include an ISA bus. +config DM_DEV_READ_INLINE + bool + default y if !OF_LIVE + endmenu diff --git a/include/dm/read.h b/include/dm/read.h new file mode 100644 index 00..4ce2bc2d6e --- /dev/null +++ b/include/dm/read.h @@ -0,0 +1,383 @@ +/* + * Function to read values from the device tree node attached to a udevice. + * + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef _DM_READ_H +#define _DM_READ_H + +#include +#include +#include + +#if CONFIG_IS_ENABLED(OF_LIVE) +static inline const struct device_node *dev_np(struct udevice *dev) +{ + return ofnode_to_np(dev->node); +} +#else +static inline const struct device_node *dev_np(struct udevice *dev) +{ + return NULL; +} +#endif + +/** + * dev_ofnode() - get the DT node reference associated with a udevice + * + * @dev: device to check + * @return reference of the the device's DT node + */ +static inline ofnode dev_ofnode(struct udevice *dev) +{ + return dev->node; +} + +static inline bool dev_of_valid(struct udevice *dev) +{ + return ofnode_valid(dev_ofnode(dev)); +} + +#ifdef CONFIG_DM_DEV_READ_INLINE + +static inline int dev_read_u32_default(struct udevice *dev, + const char *propname, int def) +{ + return ofnode_read_u32_default(dev_ofnode(dev), propname, def); +} + +/** + * dev_read_string() - Read a string from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read + * @return string from property value, or NULL if there is no such property + */ +static inline const char *dev_read_string(struct udevice *dev, + const char *propname) +{ + return ofnode_read_string(dev_ofnode(dev), propname); +} + +/** + * dev_read_bool() - read a boolean value from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of property to read + * @return true if property is present (meaning true), false if not present + */ +static inline bool dev_read_bool(struct udevice *dev, const char *propname) +{ + return ofnode_read_bool(dev_ofnode(dev), propname); +} + +/** + * dev_read_subnode() - find a named subnode of a device + * + * @dev: device whose DT node contains the subnode + * @subnode_name: name of subnode to find + * @return reference to subnode (which can be invalid if there is no such + * subnode) + */ +static inline ofnode dev_read_subnode(struct udevice *dev, + const char *subbnode_name) +{ + return ofnode_find_subnode(dev_ofnode(dev), subbnode_name); +} + +/** + * dev_read_size() - read the size of a property + * + * @dev: device to check + * @propname: property to check + * @return size of property if present, or -EINVAL if not + */ +static inline int dev_read_size(struct udevice *dev, const char *propname) +{ + return ofnode_read_size(dev_ofnode(dev), propname); +} + +/** + * dev_read_addr_index() - Get the indexed reg property of a device + * + * @dev: Device to read from + * @index: the 'reg' property can hold a list of pairs + *and @index is used to select which one is required + * + * @return address or FDT_ADDR_T_NONE if not found + */ +static inline fdt_addr_t dev_read_addr_index(struct udevice *dev, int index) +{ + return devfdt_get_addr_index(dev, index); +} + +/** + * dev_read_addr() - Get the reg property of a device + * + * @dev: Device to read from + * + * @return address or FDT_ADDR_T_NONE if not found + */ +static inline fdt_addr_t dev_read_addr(struct udevice *dev) +{ + return devfdt_get_addr(dev); +} + +/** + * dev_read_addr_size() - get address and size from a device property + * + * This does no address translation. It simply reads an property that contains + * an address and a size value, one after the other. + * + * @dev: Device to read from + * @propn
[U-Boot] [PATCH v3 22/72] dm: core: Update uclass_find_device_by_phandle() for livetree
Adjust this function to work with livetree. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/uclass.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 630b2e7336..21dc696da3 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -324,8 +324,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id, int ret; *devp = NULL; - find_phandle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(parent), name, - -1); + find_phandle = dev_read_u32_default(parent, name, -1); if (find_phandle <= 0) return -ENOENT; ret = uclass_get(id, &uc); @@ -335,7 +334,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id, list_for_each_entry(dev, &uc->dev_head, uclass_node) { uint phandle; - phandle = fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev)); + phandle = dev_read_phandle(dev); if (phandle == find_phandle) { *devp = dev; -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 23/72] sandbox: Add a way to reset sandbox state for tests
Running a new test should reset the sandbox state to avoid tests interferring with each other. Move the existing state-reset code into a function so it can be used from tests. Also update the code to reset the SPI devices and adjust the test code to call it. Signed-off-by: Simon Glass --- Changes in v3: - Clear the watchdog state also Changes in v2: None arch/sandbox/cpu/state.c | 15 +++ arch/sandbox/include/asm/state.h | 7 +++ test/dm/test-main.c | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index 2b4dbd341f..07584486db 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -351,6 +351,16 @@ bool state_get_skip_delays(void) return state->skip_delays; } +void state_reset_for_test(struct sandbox_state *state) +{ + /* No reset yet, so mark it as such. Always allow power reset */ + state->last_sysreset = SYSRESET_COUNT; + state->sysreset_allowed[SYSRESET_POWER] = true; + + memset(&state->wdt, '\0', sizeof(state->wdt)); + memset(state->spi, '\0', sizeof(state->spi)); +} + int state_init(void) { state = &main_state; @@ -359,10 +369,7 @@ int state_init(void) state->ram_buf = os_malloc(state->ram_size); assert(state->ram_buf); - /* No reset yet, so mark it as such. Always allow power reset */ - state->last_sysreset = SYSRESET_COUNT; - state->sysreset_allowed[SYSRESET_POWER] = true; - + state_reset_for_test(state); /* * Example of how to use GPIOs: * diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 987cc7b49d..617f95291a 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -214,6 +214,13 @@ void state_set_skip_delays(bool skip_delays); bool state_get_skip_delays(void); /** + * state_reset_for_test() - Reset ready to re-run tests + * + * This clears out any test state ready for another test run. + */ +void state_reset_for_test(struct sandbox_state *state); + +/** * Initialize the test system state */ int state_init(void); diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 67c0082fb8..9aa9d3a953 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -29,6 +29,7 @@ static int dm_test_init(struct unit_test_state *uts) memset(dms, '\0', sizeof(*dms)); gd->dm_root = NULL; memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); + state_reset_for_test(state_get_current()); ut_assertok(dm_init(false)); dms->root = dm_root(); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 10/72] fdt: Update fdt_get_base_address() to use const
This function does not change the device tree so adjust it to use const for this parameter. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/fdt_support.c | 2 +- include/fdt_support.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index c6a76b7ad2..c63b27bbb6 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1539,7 +1539,7 @@ int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr) /* * Returns the base address of an SOC or PCI node */ -u64 fdt_get_base_address(void *fdt, int node) +u64 fdt_get_base_address(const void *fdt, int node) { int size; u32 naddr; diff --git a/include/fdt_support.h b/include/fdt_support.h index 955c121713..6fea5c7da0 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -207,7 +207,7 @@ int fdt_add_edid(void *blob, const char *compat, unsigned char *buf); int fdt_verify_alias_address(void *fdt, int anode, const char *alias, u64 addr); -u64 fdt_get_base_address(void *fdt, int node); +u64 fdt_get_base_address(const void *fdt, int node); int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, uint64_t *addr, uint64_t *len); -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 14/72] dm: core: Implement live tree 'read' functions
When the live tree is supported some functions need to change a little. Add an implementation which is used when not inlining these functions. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/Makefile | 3 + drivers/core/read.c | 140 + include/dm/read.h | 240 +++--- 3 files changed, 291 insertions(+), 92 deletions(-) create mode 100644 drivers/core/read.c diff --git a/drivers/core/Makefile b/drivers/core/Makefile index d74b065a07..435cf98ae1 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -12,4 +12,7 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP)+= regmap.o obj-$(CONFIG_$(SPL_)SYSCON)+= syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o +ifndef CONFIG_DM_DEV_READ_INLINE +obj-$(CONFIG_OF_CONTROL) += read.o +endif obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o diff --git a/drivers/core/read.c b/drivers/core/read.c new file mode 100644 index 00..3131e5379c --- /dev/null +++ b/drivers/core/read.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include + +int dev_read_u32_default(struct udevice *dev, const char *propname, int def) +{ + return ofnode_read_u32_default(dev_ofnode(dev), propname, def); +} + +const char *dev_read_string(struct udevice *dev, const char *propname) +{ + return ofnode_read_string(dev_ofnode(dev), propname); +} + +bool dev_read_bool(struct udevice *dev, const char *propname) +{ + return ofnode_read_bool(dev_ofnode(dev), propname); +} + +ofnode dev_read_subnode(struct udevice *dev, const char *subnode_name) +{ + return ofnode_find_subnode(dev_ofnode(dev), subnode_name); +} + +ofnode dev_read_first_subnode(struct udevice *dev) +{ + return ofnode_first_subnode(dev_ofnode(dev)); +} + +ofnode dev_read_next_subnode(ofnode node) +{ + return ofnode_next_subnode(node); +} + +int dev_read_size(struct udevice *dev, const char *propname) +{ + return ofnode_read_size(dev_ofnode(dev), propname); +} + +fdt_addr_t dev_read_addr_index(struct udevice *dev, int index) +{ + if (ofnode_is_np(dev_ofnode(dev))) + return ofnode_get_addr_index(dev_ofnode(dev), index); + else + return devfdt_get_addr_index(dev, index); +} + +fdt_addr_t dev_read_addr(struct udevice *dev) +{ + return dev_read_addr_index(dev, 0); +} + +fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property, + fdt_size_t *sizep) +{ + return ofnode_get_addr_size(dev_ofnode(dev), property, sizep); +} + +const char *dev_read_name(struct udevice *dev) +{ + return ofnode_get_name(dev_ofnode(dev)); +} + +int dev_read_stringlist_search(struct udevice *dev, const char *property, + const char *string) +{ + return ofnode_stringlist_search(dev_ofnode(dev), property, string); +} + +int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, + const char *cells_name, int cell_count, + int index, + struct ofnode_phandle_args *out_args) +{ + return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name, + cells_name, cell_count, index, + out_args); +} + +int dev_read_addr_cells(struct udevice *dev) +{ + return ofnode_read_addr_cells(dev_ofnode(dev)); +} + +int dev_read_size_cells(struct udevice *dev) +{ + return ofnode_read_size_cells(dev_ofnode(dev)); +} + +int dev_read_phandle(struct udevice *dev) +{ + ofnode node = dev_ofnode(dev); + + if (ofnode_is_np(node)) + return ofnode_to_np(node)->phandle; + else + return fdt_get_phandle(gd->fdt_blob, ofnode_to_offset(node)); +} + +const u32 *dev_read_prop(struct udevice *dev, const char *propname, int *lenp) +{ + return ofnode_read_prop(dev_ofnode(dev), propname, lenp); +} + +int dev_read_alias_seq(struct udevice *dev, int *devnump) +{ + ofnode node = dev_ofnode(dev); + const char *uc_name = dev->uclass->uc_drv->name; + int ret; + + if (ofnode_is_np(node)) { + ret = of_alias_get_id(ofnode_to_np(node), uc_name); + if (ret >= 0) + *devnump = ret; + } else { + ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name, + ofnode_to_offset(node), devnump); + } + + return ret; +} + +int dev_read_u32_array(struct udevice *dev, const char *propname, + u32 *out_values, size_t sz) +{ + return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz); +} + +const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *prop
[U-Boot] [PATCH v3 24/72] dm: test: Move test running code into a separate function
We want to run the same test on flat and live trees. In preparation for this, create a new function which handles running a test. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None test/dm/test-main.c | 56 ++--- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 9aa9d3a953..2848673e06 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -72,12 +72,42 @@ static int dm_test_destroy(struct unit_test_state *uts) return 0; } +static int dm_do_test(struct unit_test_state *uts, struct unit_test *test) +{ + struct sandbox_state *state = state_get_current(); + + printf("Test: %s\n", test->name); + ut_assertok(dm_test_init(uts)); + + uts->start = mallinfo(); + if (test->flags & DM_TESTF_SCAN_PDATA) + ut_assertok(dm_scan_platdata(false)); + if (test->flags & DM_TESTF_PROBE_TEST) + ut_assertok(do_autoprobe(uts)); + if (test->flags & DM_TESTF_SCAN_FDT) + ut_assertok(dm_scan_fdt(gd->fdt_blob, false)); + + /* +* Silence the console and rely on console reocrding to get +* our output. +*/ + console_record_reset(); + if (!state->show_test_output) + gd->flags |= GD_FLG_SILENT; + test->func(uts); + gd->flags &= ~GD_FLG_SILENT; + state_set_skip_delays(false); + + ut_assertok(dm_test_destroy(uts)); + + return 0; +} + static int dm_test_main(const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test); struct unit_test_state *uts = &global_dm_test_state; - struct sandbox_state *state = state_get_current(); uts->priv = &_global_priv_dm_test_state; struct unit_test *test; int run_count; @@ -106,30 +136,8 @@ static int dm_test_main(const char *test_name) name += 8; if (test_name && strcmp(test_name, name)) continue; - printf("Test: %s\n", test->name); + ut_assertok(dm_do_test(uts, test)); run_count++; - ut_assertok(dm_test_init(uts)); - - uts->start = mallinfo(); - if (test->flags & DM_TESTF_SCAN_PDATA) - ut_assertok(dm_scan_platdata(false)); - if (test->flags & DM_TESTF_PROBE_TEST) - ut_assertok(do_autoprobe(uts)); - if (test->flags & DM_TESTF_SCAN_FDT) - ut_assertok(dm_scan_fdt(gd->fdt_blob, false)); - - /* -* Silence the console and rely on console reocrding to get -* our output. -*/ - console_record_reset(); - if (!state->show_test_output) - gd->flags |= GD_FLG_SILENT; - test->func(uts); - gd->flags &= ~GD_FLG_SILENT; - state_set_skip_delays(false); - - ut_assertok(dm_test_destroy(uts)); } if (test_name && !run_count) -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 06/72] dm: Build a live tree after relocation
If enabled, build a live device tree after relocation. This can then be used by driver model. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/board_r.c | 12 1 file changed, 12 insertions(+) diff --git a/common/board_r.c b/common/board_r.c index 28f32c3885..a9c6a84ce4 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -42,6 +42,7 @@ #endif #include #include +#include #include #include #include @@ -294,6 +295,14 @@ static int initr_noncached(void) } #endif +#ifdef CONFIG_OF_LIVE +static int initr_of_live(void) +{ + return of_live_build(gd->fdt_blob, + (struct device_node **)&gd->of_root); +} +#endif + #ifdef CONFIG_DM static int initr_dm(void) { @@ -724,6 +733,9 @@ static init_fnc_t init_sequence_r[] = { initr_noncached, #endif bootstage_relocate, +#ifdef CONFIG_OF_LIVE + initr_of_live, +#endif #ifdef CONFIG_DM initr_dm, #endif -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 03/72] dm: core: Add livetree definitions
Add a Kconfig option to enable a live device tree, built at run time from the flat tree. Also add structure definitions and a root node. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None dts/Kconfig | 11 include/asm-generic/global_data.h | 3 ++ include/dm/of.h | 106 ++ 3 files changed, 120 insertions(+) create mode 100644 include/dm/of.h diff --git a/dts/Kconfig b/dts/Kconfig index 9a0622154a..b3009af03f 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -32,6 +32,17 @@ config SPL_OF_CONTROL which is not enough to support device tree. Enable this option to allow such boards to be supported by U-Boot SPL. +config OF_LIVE + bool "Enable use of a live tree" + depends on OF_CONTROL + help + Normally U-Boot uses a flat device tree which saves space and + avoids the need to unpack the tree before use. However a flat + tree does not support modifcation from within U-Boot since it + can invalidate driver-model device tree offsets. This option + enables a live tree which is available after relocation, + and can be adjusted as needed. + choice prompt "Provider of DTB for DT control" depends on OF_CONTROL diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 51838b5ead..e6f905110e 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -72,6 +72,9 @@ typedef struct global_data { const void *fdt_blob; /* Our device tree, NULL if none */ void *new_fdt; /* Relocated FDT */ unsigned long fdt_size; /* Space reserved for relocated FDT */ +#ifdef CONFIG_OF_LIVE + struct device_node *of_root; +#endif struct jt_funcs *jt;/* jump table */ char env_buf[32]; /* buffer for getenv() before reloc. */ #ifdef CONFIG_TRACE diff --git a/include/dm/of.h b/include/dm/of.h new file mode 100644 index 00..6b5afab1c1 --- /dev/null +++ b/include/dm/of.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#ifndef _DM_OF_H +#define _DM_OF_H + +#include +#include + +/* integer value within a device tree property which references another node */ +typedef u32 phandle; + +/** + * struct property: Device tree property + * + * @name: Property name + * @length: Length of property in bytes + * @value: Pointer to property value + * @next: Pointer to next property, or NULL if none + */ +struct property { + char *name; + int length; + void *value; + struct property *next; +}; + +/** + * struct device_node: Device tree node + * + * @name: Node name + * @type: Node type (value of device_type property) or "" if none + * @phandle: Phandle value of this none, or 0 if none + * @full_name: Full path to node, e.g. "/bus@1/spi@1100" + * @properties: Pointer to head of list of properties, or NULL if none + * @parent: Pointer to parent node, or NULL if this is the root node + * @child: Pointer to head of child node list, or NULL if no children + * @sibling: Pointer to the next sibling node, or NULL if this is the last + */ +struct device_node { + const char *name; + const char *type; + phandle phandle; + const char *full_name; + + struct property *properties; + struct device_node *parent; + struct device_node *child; + struct device_node *sibling; +}; + +#define OF_MAX_PHANDLE_ARGS 16 + +/** + * struct of_phandle_args - structure to hold phandle and arguments + * + * This is used when decoding a phandle in a device tree property. Typically + * these look like this: + * + * wibble { + *phandle = <5>; + * }; + * + * ... + * some-prop = <&wibble 1 2 3> + * + * Here &node is the phandle of the node 'wibble', i.e. 5. There are three + * arguments: 1, 2, 3. + * + * So when decoding the phandle in some-prop, np will point to wibble, + * args_count will be 3 and the three arguments will be in args. + * + * @np: Node that the phandle refers to + * @args_count: Number of arguments + * @args: Argument values + */ +struct of_phandle_args { + struct device_node *np; + int args_count; + uint32_t args[OF_MAX_PHANDLE_ARGS]; +}; + +DECLARE_GLOBAL_DATA_PTR; + +/** + * of_live_active() - check if livetree is active + * + * @returns true if livetree is active, false it not + */ +#ifdef CONFIG_OF_LIVE +static inline bool of_live_active(void) +{ + return gd->of_root != NULL; +} +#else +static inline bool of_live_active(void) +{ + return false; +} +#endif + +#endif -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 04/72] dm: core: Add livetree access functions
Add a basic assortment of functions to access the live device tree. These come from Linux v4.9 and are modified for U-Boot to the minimum extent possible. While these functions are now very stable in Linux, it will be possible to merge in fixes if needed. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/Makefile| 1 + drivers/core/of_access.c | 735 +++ include/dm/of_access.h | 347 ++ 3 files changed, 1083 insertions(+) create mode 100644 drivers/core/of_access.c create mode 100644 include/dm/of_access.h diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 8261f14f45..4211fd1e22 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP)+= regmap.o obj-$(CONFIG_$(SPL_)SYSCON)+= syscon-uclass.o +obj-$(CONFIG_OF_LIVE) += of_access.o diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c new file mode 100644 index 00..94ef3cc251 --- /dev/null +++ b/drivers/core/of_access.c @@ -0,0 +1,735 @@ +/* + * Originally from Linux v4.9 + * Paul Mackerras August 1996. + * Copyright (C) 1996-2005 Paul Mackerras. + * + * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner. + * {engebret|bergner}@us.ibm.com + * + * Adapted for sparc and sparc64 by David S. Miller da...@davemloft.net + * + * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and + * Grant Likely. + * + * Modified for U-Boot + * Copyright (c) 2017 Google, Inc + * + * This file follows drivers/of/base.c with functions in the same order as the + * Linux version. + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* list of struct alias_prop aliases */ +LIST_HEAD(aliases_lookup); + +/* "/aliaes" node */ +static struct device_node *of_aliases; + +/* "/chosen" node */ +static struct device_node *of_chosen; + +/* node pointed to by the stdout-path alias */ +static struct device_node *of_stdout; + +/* pointer to options given after the alias (separated by :) or NULL if none */ +static const char *of_stdout_options; + +/** + * struct alias_prop - Alias property in 'aliases' node + * + * The structure represents one alias property of 'aliases' node as + * an entry in aliases_lookup list. + * + * @link: List node to link the structure in aliases_lookup list + * @alias: Alias property name + * @np:Pointer to device_node that the alias stands for + * @id:Index value from end of alias name + * @stem: Alias string without the index + */ +struct alias_prop { + struct list_head link; + const char *alias; + struct device_node *np; + int id; + char stem[0]; +}; + +int of_n_addr_cells(const struct device_node *np) +{ + const __be32 *ip; + + do { + if (np->parent) + np = np->parent; + ip = of_get_property(np, "#address-cells", NULL); + if (ip) + return be32_to_cpup(ip); + } while (np->parent); + + /* No #address-cells property for the root node */ + return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; +} + +int of_n_size_cells(const struct device_node *np) +{ + const __be32 *ip; + + do { + if (np->parent) + np = np->parent; + ip = of_get_property(np, "#size-cells", NULL); + if (ip) + return be32_to_cpup(ip); + } while (np->parent); + + /* No #size-cells property for the root node */ + return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; +} + +struct property *of_find_property(const struct device_node *np, + const char *name, int *lenp) +{ + struct property *pp; + + if (!np) + return NULL; + + for (pp = np->properties; pp; pp = pp->next) { + if (strcmp(pp->name, name) == 0) { + if (lenp) + *lenp = pp->length; + break; + } + } + if (!pp && lenp) + *lenp = -FDT_ERR_NOTFOUND; + + return pp; +} + +struct device_node *of_find_all_nodes(struct device_node *prev) +{ + struct device_node *np; + + if (!prev) { + np = gd->of_root; + } else if (prev->child) { + np = prev->child; + } else { + /* +* Walk back up looking for a sibling, or the end of the +* structure +*/ + np = prev; + while (np->parent && !np->sibling) + np = np->parent; + np = np->sibling; /* Might be null at the end of the tree */ + } + + return np; +} + +
[U-Boot] [PATCH v3 05/72] dm: Add a function to create a 'live' device tree
This function converts the flat device tree into a hierarchical one with C structures and pointers. This is easier to access. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/of_live.h | 24 lib/Makefile | 1 + lib/of_live.c | 333 ++ 3 files changed, 358 insertions(+) create mode 100644 include/of_live.h create mode 100644 lib/of_live.c diff --git a/include/of_live.h b/include/of_live.h new file mode 100644 index 00..f5303bb018 --- /dev/null +++ b/include/of_live.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + * + * Support for a 'live' (as opposed to flat) device tree + */ + +#ifndef _OF_LIVE_H +#define _OF_LIVE_H + +struct device_node; + +/** + * of_live_build() - build a live (hierarchical) tree from a flat DT + * + * @fdt_blob: Input tree to convert + * @rootp: Returns live tree that was created + * @return 0 if OK, -ve on error + */ +int of_live_build(const void *fdt_blob, struct device_node **rootp); + +#endif diff --git a/lib/Makefile b/lib/Makefile index 23e9f1ef11..bc2fb0a361 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_ZLIB) += zlib/ obj-$(CONFIG_BZIP2) += bzip2/ obj-$(CONFIG_TIZEN) += tizen/ obj-$(CONFIG_FIT) += libfdt/ +obj-$(CONFIG_OF_LIVE) += of_live.o obj-$(CONFIG_CMD_DHRYSTONE) += dhry/ obj-$(CONFIG_AES) += aes.o diff --git a/lib/of_live.c b/lib/of_live.c new file mode 100644 index 00..51927f9e91 --- /dev/null +++ b/lib/of_live.c @@ -0,0 +1,333 @@ +/* + * Copyright 2009 Benjamin Herrenschmidt, IBM Corp + * b...@kernel.crashing.org + * + * Based on parts of drivers/of/fdt.c from Linux v4.9 + * Modifications for U-Boot + * Copyright (c) 2017 Google, Inc + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void *unflatten_dt_alloc(void **mem, unsigned long size, + unsigned long align) +{ + void *res; + + *mem = PTR_ALIGN(*mem, align); + res = *mem; + *mem += size; + + return res; +} + +/** + * unflatten_dt_node() - Alloc and populate a device_node from the flat tree + * @blob: The parent device tree blob + * @mem: Memory chunk to use for allocating device nodes and properties + * @poffset: pointer to node in flat tree + * @dad: Parent struct device_node + * @nodepp: The device_node tree created by the call + * @fpsize: Size of the node path up at t05he current depth. + * @dryrun: If true, do not allocate device nodes but still calculate needed + * memory size + */ +static void *unflatten_dt_node(const void *blob, void *mem, int *poffset, + struct device_node *dad, + struct device_node **nodepp, + unsigned long fpsize, bool dryrun) +{ + const __be32 *p; + struct device_node *np; + struct property *pp, **prev_pp = NULL; + const char *pathp; + int l; + unsigned int allocl; + static int depth; + int old_depth; + int offset; + int has_name = 0; + int new_format = 0; + + pathp = fdt_get_name(blob, *poffset, &l); + if (!pathp) + return mem; + + allocl = ++l; + + /* +* version 0x10 has a more compact unit name here instead of the full +* path. we accumulate the full path size using "fpsize", we'll rebuild +* it later. We detect this because the first character of the name is +* not '/'. +*/ + if ((*pathp) != '/') { + new_format = 1; + if (fpsize == 0) { + /* +* root node: special case. fpsize accounts for path +* plus terminating zero. root node only has '/', so +* fpsize should be 2, but we want to avoid the first +* level nodes to have two '/' so we use fpsize 1 here +*/ + fpsize = 1; + allocl = 2; + l = 1; + pathp = ""; + } else { + /* +* account for '/' and path size minus terminal 0 +* already in 'l' +*/ + fpsize += l; + allocl = fpsize; + } + } + + np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl, + __alignof__(struct device_node)); + if (!dryrun) { + char *fn; + + fn = (char *)np + sizeof(*np); + np->full_name = fn; + if (new_format) { + /* rebuild full path for new format */ + if (
[U-Boot] [PATCH v3 07/72] dm: core: Rename of_device_is_compatible()
The of_ prefix conflicts with the livetree version of this function. Rename it to avoid problems when we add livetree support. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/device.c | 2 +- drivers/firmware/psci.c | 4 ++-- drivers/mmc/xenon_sdhci.c | 2 +- drivers/net/cpsw-common.c | 4 ++-- drivers/net/mvneta.c | 2 +- drivers/phy/marvell/comphy_core.c | 4 ++-- drivers/usb/host/ehci-marvell.c | 2 +- drivers/usb/host/xhci-rockchip.c | 2 +- include/dm/device.h | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/core/device.c b/drivers/core/device.c index 363c1833e9..f5e85413f7 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -701,7 +701,7 @@ int device_set_name(struct udevice *dev, const char *name) return 0; } -bool of_device_is_compatible(struct udevice *dev, const char *compat) +bool device_is_compatible(struct udevice *dev, const char *compat) { const void *fdt = gd->fdt_blob; diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 7652cc27aa..451fbdebba 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -40,8 +40,8 @@ static unsigned long __invoke_psci_fn_smc(unsigned long function_id, static int psci_bind(struct udevice *dev) { /* No SYSTEM_RESET support for PSCI 0.1 */ - if (of_device_is_compatible(dev, "arm,psci-0.2") || - of_device_is_compatible(dev, "arm,psci-1.0")) { + if (device_is_compatible(dev, "arm,psci-0.2") || + device_is_compatible(dev, "arm,psci-1.0")) { int ret; /* bind psci-sysreset optionally */ diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c index 6cd176f9f8..2b7cb7f6b6 100644 --- a/drivers/mmc/xenon_sdhci.c +++ b/drivers/mmc/xenon_sdhci.c @@ -454,7 +454,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev) host->name = dev->name; host->ioaddr = (void *)devfdt_get_addr(dev); - if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci")) + if (device_is_compatible(dev, "marvell,armada-3700-sdhci")) priv->pad_ctrl_reg = (void *)devfdt_get_addr_index(dev, 1); name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type", diff --git a/drivers/net/cpsw-common.c b/drivers/net/cpsw-common.c index 55f56d9555..8970ee00af 100644 --- a/drivers/net/cpsw-common.c +++ b/drivers/net/cpsw-common.c @@ -104,10 +104,10 @@ int ti_cm_get_macid(struct udevice *dev, int slave, u8 *mac_addr) if (of_machine_is_compatible("ti,am33xx")) return cpsw_am33xx_cm_get_macid(dev, 0x630, slave, mac_addr); - if (of_device_is_compatible(dev, "ti,am3517-emac")) + if (device_is_compatible(dev, "ti,am3517-emac")) return davinci_emac_3517_get_macid(dev, 0x110, slave, mac_addr); - if (of_device_is_compatible(dev, "ti,dm816-emac")) + if (device_is_compatible(dev, "ti,dm816-emac")) return cpsw_am33xx_cm_get_macid(dev, 0x30, slave, mac_addr); if (of_machine_is_compatible("ti,am43")) diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index af07b281e8..50577d7f07 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -1695,7 +1695,7 @@ static int mvneta_probe(struct udevice *dev) pp->base = (void __iomem *)pdata->iobase; /* Configure MBUS address windows */ - if (of_device_is_compatible(dev, "marvell,armada-3700-neta")) + if (device_is_compatible(dev, "marvell,armada-3700-neta")) mvneta_bypass_mbus_windows(pp); else mvneta_conf_mbus_windows(pp); diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index ccf024b792..426db30f73 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -135,10 +135,10 @@ static int comphy_probe(struct udevice *dev) return -EINVAL; } - if (of_device_is_compatible(dev, "marvell,comphy-armada-3700")) + if (device_is_compatible(dev, "marvell,comphy-armada-3700")) chip_cfg->ptr_comphy_chip_init = comphy_a3700_init; - if (of_device_is_compatible(dev, "marvell,comphy-cp110")) + if (device_is_compatible(dev, "marvell,comphy-cp110")) chip_cfg->ptr_comphy_chip_init = comphy_cp110_init; /* diff --git a/drivers/usb/host/ehci-marvell.c b/drivers/usb/host/ehci-marvell.c index 56409df26e..7a0f2083ad 100644 --- a/drivers/usb/host/ehci-marvell.c +++ b/drivers/usb/host/ehci-marvell.c @@ -121,7 +121,7 @@ static int ehci_mvebu_probe(struct udevice *dev) * Also, the address decoder doesn't need to get setup with this * SoC, so don't call usb_brg_adrdec_setup(). */ - if (of_device_is_compatible(dev, "marvell,armada3700-ehci")) + if (device_is_compatible(dev, "marv
[U-Boot] [PATCH v3 08/72] dm: core: Add operations on device tree references
Since U-Boot supports both a live tree and a flat tree, we need an easy way to access the tree without worrying about which is currently active. To support this, U-Boot has the concept of an ofnode, which can refer either to a live tree node or a flat tree node. For the live tree, the reference contains a pointer to the node (struct device_node *) or NULL if the node is invalid. For the flat tree, the reference contains the node offset or -1 if the node is invalid. Add a basic set of operations using ofnodes. These are implemented by using either libfdt functions (in the case of a flat DT reference) or the live-tree of_...() functions. Note that it is not possible to have both live and flat references active at the same time. As soon as the live tree is available, everything in U-Boot should switch to using that. This avoids confusion and allows us to assume that the type of a reference is simply based on whether we have a live tree yet, or not. Signed-off-by: Simon Glass --- Changes in v3: - Adjust header includes in ofnode.h to make it stand alone Changes in v2: None drivers/core/Makefile | 1 + drivers/core/ofnode.c | 552 ++ include/dm/ofnode.h | 467 +- 3 files changed, 1017 insertions(+), 3 deletions(-) create mode 100644 drivers/core/ofnode.c diff --git a/drivers/core/Makefile b/drivers/core/Makefile index 4211fd1e22..c25288e464 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_DM) += dump.o obj-$(CONFIG_$(SPL_)REGMAP)+= regmap.o obj-$(CONFIG_$(SPL_)SYSCON)+= syscon-uclass.o obj-$(CONFIG_OF_LIVE) += of_access.o +obj-$(CONFIG_OF_CONTROL) += ofnode.o diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c new file mode 100644 index 00..e6c9a28bae --- /dev/null +++ b/drivers/core/ofnode.c @@ -0,0 +1,552 @@ +/* + * Copyright (c) 2017 Google, Inc + * Written by Simon Glass + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +int ofnode_read_u32(ofnode node, const char *propname, u32 *outp) +{ + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, propname); + + if (ofnode_is_np(node)) { + return of_read_u32(ofnode_to_np(node), propname, outp); + } else { + const int *cell; + int len; + + cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), + propname, &len); + if (!cell || len < sizeof(int)) { + debug("(not found)\n"); + return -EINVAL; + } + *outp = fdt32_to_cpu(cell[0]); + } + debug("%#x (%d)\n", *outp, *outp); + + return 0; +} + +int ofnode_read_u32_default(ofnode node, const char *propname, u32 def) +{ + assert(ofnode_valid(node)); + ofnode_read_u32(node, propname, &def); + + return def; +} + +int ofnode_read_s32_default(ofnode node, const char *propname, s32 def) +{ + assert(ofnode_valid(node)); + ofnode_read_u32(node, propname, (u32 *)&def); + + return def; +} + +bool ofnode_read_bool(ofnode node, const char *propname) +{ + bool val; + + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, propname); + + if (ofnode_is_np(node)) { + val = !!of_find_property(ofnode_to_np(node), propname, NULL); + } else { + val = !!fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), + propname, NULL); + } + debug("%s\n", val ? "true" : "false"); + + return val; +} + +const char *ofnode_read_string(ofnode node, const char *propname) +{ + const char *str = NULL; + int len = -1; + + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, propname); + + if (ofnode_is_np(node)) { + struct property *prop = of_find_property( + ofnode_to_np(node), propname, NULL); + + if (prop) { + str = prop->value; + len = prop->length; + } + } else { + str = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), + propname, &len); + } + if (!str) { + debug("\n"); + return NULL; + } + if (strnlen(str, len) >= len) { + debug("\n"); + return NULL; + } + debug("%s\n", str); + + return str; +} + +ofnode ofnode_find_subnode(ofnode node, const char *subnode_name) +{ + ofnode subnode; + + assert(ofnode_valid(node)); + debug("%s: %s: ", __func__, subnode_name); + + if (ofnode_is_np(node)) { + const struct device_node *np = ofnode_to_np(node); + + for (np = np->child; np; np = np->s
[U-Boot] [PATCH v3 01/72] dm: core: Set return value first in lists_bind_fdt()
Adjust the order to make it clear that *devp is set to NULL by default. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/core/lists.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 23b6ba78d3..72c55e205f 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -140,10 +140,10 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset, int result = 0; int ret = 0; - name = fdt_get_name(blob, offset, NULL); - dm_dbg("bind node %s\n", name); if (devp) *devp = NULL; + name = fdt_get_name(blob, offset, NULL); + dm_dbg("bind node %s\n", name); compat_list = fdt_getprop(blob, offset, "compatible", &compat_length); if (!compat_list) { -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 00/72] dm: Add support for a 'live' device tree
(this is series 2 of 3 for live tree support - the final series will fully convert a real board and provide size comparisons) So far U-Boot uses a 'flat' device tree, which means that it is decoded on the fly as needed. This uses the libfdt library and avoids needing extra memory for additional tables. For some time there has been discussion about moving U-Boot to use a 'live' tree, where the device tree is decoded at start-up into a set of hierarchical structures with pointers. The advantages are: - It is somewhat faster to access (in particular scanning and looking for a parent) - It permits the device tree to be changed at run-time (this is not recommended with the flat device tree since devices store the offset of their device tree node and updating the tree may invalidate that). Enabling this feature could be useful for overlays, for example. - It allows nodes to be referenced by a single pointer, instead of the current device tree pointer plus offset The disadvantages are: - It requires more memory - It takes (a little) time to build the live tree - It adds more complexity under the hood, including an additional abstraction layer This series is an attempt to introduce a useful live tree feature into U-Boot. There are many options and trade-offs. This series is the culmination of quite a bit of thought and experimentation. The approach used in this series is: - Before relocation the flat tree is used, to avoid extra memory usage and time. In general, there is not much access before relocation since most drivers are not started up. So there is little benefit in having a live tree - After relocation the live tree is built. At this point the CPU should be running quickly and there is plenty of memory. All available devices will be bound so the overhead of building the live tree may be outweighed by its greater efficiency. As a simplification, this series supports only one tree or the other. When the live tree is active, the flat tree cannot be used. That makes it easy to know the current state and avoids confusion over mixing offset and node pointers. Some drivers will need to be used both before and after relocation. This means that they must support both the flat and the live tree. To support this, the concept of a node 'reference' is defined. A reference can hold either a node offset (for the flat tree) or a node pointer (for the live tree). This allows drivers to access values from the tree regardless of which tree is in use. In addition, since most device tree access happens in the context of a device (struct udevice), a new 'dev_read' layer is provided to read device tree configuration associated with a device. This encapsulates the details of exactly how this information is read. I have taken the view that code compatibility with Linux is desirable. So the of_access.c file brings in code from Linux with very little modification. As new access methods are needed we should be able to bring in more code and avoid writing it ourselves in U-Boot. Conversion of drivers and subsystems to support the live tree (as well as flat tree) is fairly easy. Patch are included to add support to subsystems for which tests exist, to ensure that 'make tests' still passes. Future work will enable the live device tree on a real board and include code size comparisons. For now here is a code size comparison for firefly (within inlining of ofnode which I intend to implement): arm: (for 1/1 boards) all +268.0 bss -24.0 data -4.0 spl/u-boot-spl:all +240.0 spl/u-boot-spl:text +240.0 text +296.0 firefly-rk3288 : all +268 bss -24 data -4 spl/u-boot-spl:all +240 spl/u-boot-spl:text +240 text +296 u-boot: add: 18/-4, grow: 2/-22 bytes: 764/-490 (274) function old new delta gpio_request_tail- 132+132 ofnode_parse_phandle_with_args - 66 +66 uclass_find_device_by_ofnode - 64 +64 ofnode_pre_reloc - 64 +64 ofnode_read_string - 52 +52 fdt_support_default_count_cells - 52 +52 ofnode_read_u32 - 48 +48 gpio_request_by_name32 72 +40 ofnode_read_size - 34 +34 uclass_get_device_by_ofnode - 28 +28 ofnode_read_u32_array- 28 +28 ofnode_read_bool - 26 +26 ofnode_read_prop - 24 +24 ofnode_get_addr_size - 24 +24 ofnode_read_u32_default - 22 +22 ofnode_find_subnode - 18 +18
[U-Boot] [PATCH v3 02/72] Update WARN_ON() to return a value
In linux v4.9 this returns a value. This saves checking the warning condition twice in some code. Update the U-Boot version to do this also. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None include/linux/compat.h | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/compat.h b/include/linux/compat.h index a43e4d6698..03f9bef0da 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -106,8 +106,12 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep) #define BUG_ON(condition) do { if (condition) BUG(); } while(0) #endif /* BUG */ -#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \ - , __FILE__, __LINE__); } +#define WARN_ON(condition) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on))\ + printf("WARNING in %s line %d\n", __FILE__, __LINE__);; \ + unlikely(__ret_warn_on);\ +}) #define PAGE_SIZE 4096 -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/3] arm: am57xx: Set fastboot variables in environment
On Thursday 18 May 2017 06:31 PM, Sam Protsenko wrote: > One can obtain those variables using next commands: > > $ fastboot getvar cpu > $ fastboot getvar secure > $ fastboot getvar board_rev > $ fastboot getvar userdata_size > > Those variables are needed for fastboot.sh script. > > Signed-off-by: Sam Protsenko > --- > board/ti/am57xx/board.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c > index 3be697a6ea..c8ebcdbcc8 100644 > --- a/board/ti/am57xx/board.c > +++ b/board/ti/am57xx/board.c > @@ -573,6 +573,7 @@ int board_late_init(void) > val); > > omap_die_id_serial(); > + omap_set_fastboot_vars(); Any chance that we can guard this function with CONFIG_*_FASTBOOT? Thanks and regards, Lokesh ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] omap: Add routine for setting fastboot variables
On Thursday 18 May 2017 06:31 PM, Sam Protsenko wrote: > This patch reuses new option, which allows us to expose variables > from environment to "fastboot getvar" command. Those variables must be > of "fastboot.%s" format. > > Signed-off-by: Sam Protsenko > --- > arch/arm/include/asm/omap_common.h | 2 + > arch/arm/mach-omap2/utils.c| 134 > + > 2 files changed, 136 insertions(+) > > diff --git a/arch/arm/include/asm/omap_common.h > b/arch/arm/include/asm/omap_common.h > index c1a70b15d0..cede2f7b28 100644 > --- a/arch/arm/include/asm/omap_common.h > +++ b/arch/arm/include/asm/omap_common.h > @@ -643,6 +643,8 @@ void omap_die_id_get_board_serial(struct tag_serialnr > *serialnr); > void omap_die_id_usbethaddr(void); > void omap_die_id_display(void); > > +void omap_set_fastboot_vars(void); > + > void recalibrate_iodelay(void); > > void omap_smc1(u32 service, u32 val); > diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c > index 2d03ebfbd3..0689c879b0 100644 > --- a/arch/arm/mach-omap2/utils.c > +++ b/arch/arm/mach-omap2/utils.c > @@ -6,6 +6,16 @@ > */ > #include > #include > + > +/* Device type bits in CONTROL_STATUS register */ > +#define DEVICETYPE_OFFSET6 > +#define DEVICETYPE_MASK (0x7 << DEVICETYPE_OFFSET) > +#define OMAP_TYPE_TEST 0x0 > +#define OMAP_TYPE_EMU0x1 > +#define OMAP_TYPE_SEC0x2 > +#define OMAP_TYPE_GP 0x3 > +#define OMAP_TYPE_BAD0x4 > + > static void do_cancel_out(u32 *num, u32 *den, u32 factor) > { > while (1) { > @@ -18,6 +28,122 @@ static void do_cancel_out(u32 *num, u32 *den, u32 factor) > } > } > > +static const char *omap_get_cpu_type(void) > +{ > + u32 type; > + > + type = readl((*ctrl)->control_status); > + type &= DEVICETYPE_MASK; > + type >>= DEVICETYPE_OFFSET; > + > + switch (type) { > + case OMAP_TYPE_EMU: > + return "EMU"; > + case OMAP_TYPE_SEC: > + return "HS"; > + case OMAP_TYPE_GP: > + return "GP"; > + default: > + return NULL; > + } > +} use get_device_type() and drop this function. Thanks and regards, Lokesh ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: fixed relocation using proper alignment
On Thursday 18 May 2017 09:04 PM, Manfred Schlaegl wrote: > On 2017-05-18 16:59, Lothar Waßmann wrote: >> Manfred Schlaegl wrote: >> >>> On 2017-05-17 06:13, Lokesh Vutla wrote: On Tuesday 16 May 2017 07:59 PM, Manfred Schlaegl wrote: > On 2017-05-11 08:53, Lokesh Vutla wrote: >> >> >> On Wednesday 10 May 2017 07:11 PM, Manfred Schlaegl wrote: >>> Using u-boot-2017.05 on i.MX6UL we ran into following problem: >>> Initially U-Boot could be started normally. >>> If we added one random command in configuration, the newly generated >>> image hung at startup (last output was DRAM: 256 MiB). >>> >>> We tracked this down to a data abort within relocation (relocated_code). >>> >> [...] > In a good case (rel_dyn_start aligned to 8 byte), u-boot is starting up > normally > rel_dyn_start is 0x8785FC28 > rel_dyn_end is 0x87857BD0 > A dump of this memory area shows no abnormality > > In a bad case (same source, but rel_dyn_start aligned to 4 byte), the > data abort happens > rel_dyn_start is 0x8785FC24 > rel_dyn_end is 0x87857BCC > So we have the same size of 32856 bytes but a memory dump showed exactly > one difference, which is > very interesting: > > At offset 0x610 (relative to rel_dyn_start) we have following difference > -0610 30 3e 80 87 17 00 00 00 34 3e 80 87 00 00 00 00 > |0>..4>..| > +0610 30 3e 80 87 17 00 00 00 00 00 00 00 17 00 00 00 > |0>..| Looks like someone is corrupting the data(assuming). Is it all 0's just at this location or continuously after this? >>> >>> No. Above diff is the only difference of the good and bad case in memory >>> located between >>> rel_dyn_start and rel_dyn_end. >>> >>> To see if it might be a corruption I compared the the rel_dyn with the >>> created u-boot.img and >>> found the same difference >>> -0610 30 3e 80 87 17 00 00 00 34 3e 80 87 17 00 00 00 >>> |0>..4>..| <--- generated image >>> +0610 30 3e 80 87 17 00 00 00 00 00 00 00 17 00 00 00 >>> |0>..| <--- memory dump >>> >>> So it must be some kind of corruption. >>> >> This can be caused by a static variable, that is written to prior to >> relocation. Since the .rel section overlays the .bss section, the write >> to a variable in the BSS will corrupt the relocation data. >> > > Yes! That's it! > > Using a watchpoint I tracked the corruption down to an early write to a > static variable in our custom code. > > So finally: > The whole thing was a problem in a custom modification and was solved there. > It has no implication on u-boot itself. Awesome. Good to hear that it is resolved :) Thanks and regards, Lokesh ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] Please pull u-boot-fdt
Hi Tom, On 9 May 2017 at 17:59, Tom Rini wrote: > > On Tue, May 09, 2017 at 04:53:36PM -0600, Simon Glass wrote: > > > Hi Tom, > > > > Here's the conversion to use the upstream pylibfdt implementation. > > > > > > The following changes since commit 85ea850976daea57c8045f3569566fad5ce9fe0f: > > > > p1_p2_rdb: Fix unused variable warning (2017-05-09 09:11:04 -0400) > > > > are available in the git repository at: > > > > git://git.denx.de/u-boot-fdt.git > > > > for you to fetch changes up to 8fbd55f0f8730e3a6994798f4e533138d15be6aa: > > > > fdt: Drop fdt_select.py (2017-05-09 14:56:19 -0600) > > > > NAK. I get: > $ ./test/py/test.py --bd sandbox --build > make O=/home/trini/work/u-boot/u-boot/build-sandbox -s sandbox_defconfig > make O=/home/trini/work/u-boot/u-boot/build-sandbox -s -j8 > Assembler messages: > Fatal error: can't create > build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o: No such file or > directory > error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 > make[2]: *** [tools/_libfdt.so] Error 1 > make[2]: *** Waiting for unfinished jobs > make[1]: *** [tools] Error 2 > make: *** [sub-make] Error 2 > Exit code: 2 This is due to some weirdness with setup.py not allowing source files to come from a patch starting with "..". I'll send an updated patch, pull it in and then resend the pull request. > > -- > Tom Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 09/20] fdt: Build the new python libfdt module
Build the upstream python libfdt module. At present the legacy module is still built and is the one that it used. Future work will switch this over. Signed-off-by: Simon Glass --- Changes in v2: - Fix building when srcpath is ".." tools/Makefile | 23 +++ 1 file changed, 23 insertions(+) diff --git a/tools/Makefile b/tools/Makefile index cd08d3b33b..9f2d698818 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -63,6 +63,16 @@ FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \ fdt_region.c + +# Unfortunately setup.py below cannot handle srctree being ".." which it often +# is. It fails with an error like: +# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o: +#No such file or directory +# To fix this, use an absolute path. +libfdt_tree := $(shell readlink -f $(srctree)/lib/libfdt) + +LIBFDT_SRCS := $(addprefix $(libfdt_tree)/, $(LIBFDT_CSRCS)) +LIBFDT_SWIG := $(addprefix $(libfdt_tree)/, pylibfdt/libfdt.i) LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS))) RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \ @@ -114,6 +124,15 @@ mkimage-objs := $(dumpimage-mkimage-objs) mkimage.o fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o +tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG) + LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= VERSION=u-boot-$(UBOOTVERSION) \ + CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \ + SOURCES="$(LIBFDT_SRCS) $(LIBFDT_SWIG)" \ + SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \ + $(libfdt_tree)/pylibfdt/setup.py --quiet build_ext --inplace + mv $(libfdt_tree)/pylibfdt/libfdt.py tools/. + rm $(libfdt_tree)/pylibfdt/libfdt_wrap.c + # Build a libfdt Python module if swig is available # Use 'sudo apt-get install swig libpython-dev' to enable this hostprogs-y += \ @@ -219,6 +238,10 @@ clean-dirs := lib common always := $(hostprogs-y) +# Build a libfdt Python module if swig is available +# Use 'sudo apt-get install swig libpython-dev' to enable this +always += $(if $(shell which swig 2> /dev/null),_libfdt.so) + # Generated LCD/video logo LOGO_H = $(objtree)/include/bmp_logo.h LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h -- 2.13.0.303.g4ebf302169-goog ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [U-Boot,v2] ARM: dts: am335x-evm: disable mmc3
On Wed, May 17, 2017 at 09:22:55PM +0200, Jean-Jacques Hiblot wrote: > SDIO is not supported in u-boot, there is no point in enabling mmc3. > For this purpose, add u-boot specific dtsi that this will be included > automatically while building the dtb. > > Signed-off-by: Jean-Jacques Hiblot > Reviewed-by: Tom Rini Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [U-Boot, PATCHv2] scripts/Makefile.lib: Always have ...-u-boot.dtsi be able to override
On Wed, May 17, 2017 at 02:06:08PM -0400, Tom Rini wrote: > The intention of having a -u-boot.dtsi file is to be able to make > changes to the provided upstream dts files as well as to be able to add > nodes. Change the logic for adding the file from making it the last > included file at the top of the dts to being included at the end of the > file. > > Cc: Jean-Jacques Hiblot > Cc: Simon Glass > Signed-off-by: Tom Rini > Tested-by: Jean-Jacques Hiblot > Reviewed-by: Simon Glass Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-socfpga/master
On Thu, May 18, 2017 at 11:42:02AM +0200, Marek Vasut wrote: > The following changes since commit fa8967cfbaed5582ba987756fa9f0470a9affbf4: > > Merge git://git.denx.de/u-boot-uniphier (2017-05-17 14:13:58 -0400) > > are available in the git repository at: > > git://git.denx.de/u-boot-socfpga.git master > > for you to fetch changes up to d89e979c42892db572c4ef5d56bc207075953f58: > > arm: socfpga: Enable build for Arria 10 (2017-05-18 11:33:19 +0200) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-usb/master
On Thu, May 18, 2017 at 11:32:47AM +0200, Marek Vasut wrote: > The following changes since commit fa8967cfbaed5582ba987756fa9f0470a9affbf4: > > Merge git://git.denx.de/u-boot-uniphier (2017-05-17 14:13:58 -0400) > > are available in the git repository at: > > git://git.denx.de/u-boot-usb.git master > > for you to fetch changes up to 9ad69f0ba45b1e1a95be04fcc2d7e143fa24627c: > > > usb: lpc32xx: add i2c DM support (2017-05-18 11:31:56 +0200) > > > Applied to u-boot/master, thanks! -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v3] fastboot: Add support for flashing zImage
On Thu, May 18, 2017 at 03:04:59PM +0300, Sam Protsenko wrote: > This patch adds support for flashing zImage to the Android boot > partition on eMMC. > > Usage: > > $ fastboot flash zImage > > It's based on [1]. > > [1] > http://omapzoom.org/?p=repo/u-boot.git;a=commit;h=3393b908c1e848bba3706612cbe50aa8970720b3 > > Signed-off-by: Sam Protsenko Reviewed-by: Tom Rini -- Tom signature.asc Description: Digital signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 2/2] dm: serial: bcm6345: fix baud rate clock calculation
It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases. Signed-off-by: Álvaro Fernández Rojas --- drivers/serial/serial_bcm6345.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c index 14c1bf2..9638952 100644 --- a/drivers/serial/serial_bcm6345.c +++ b/drivers/serial/serial_bcm6345.c @@ -157,11 +157,9 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate) UART_FIFO_CFG_TX_4); /* set baud rate */ - val = (clk / baudrate) / 16; - if (val & 0x1) - val = val; - else - val = val / 2 - 1; + val = ((clk / baudrate) >> 5); + if (!(val & 0x1)) + val -= 1; writel_be(val, base + UART_BAUD_REG); /* clear interrupts */ @@ -243,7 +241,7 @@ static int bcm6345_serial_probe(struct udevice *dev) ret = clk_get_by_index(dev, 0, &clk); if (ret < 0) return ret; - priv->uartclk = clk_get_rate(&clk) / 2; + priv->uartclk = clk_get_rate(&clk); clk_free(&clk); /* initialize serial */ -- 2.1.4 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v3 1/2] dm: serial: bcm6345: fix uart stop bits
I missed this when I added support for BMIPS UART driver and it's needed to achieve a real 115200 8N1 setup. Signed-off-by: Álvaro Fernández Rojas --- v3: no changes, added another fix on a separate patch. v2: fix commit title (missed bcm6345) drivers/serial/serial_bcm6345.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/serial/serial_bcm6345.c b/drivers/serial/serial_bcm6345.c index db270e3..14c1bf2 100644 --- a/drivers/serial/serial_bcm6345.c +++ b/drivers/serial/serial_bcm6345.c @@ -141,6 +141,8 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate) UART_CTL_RXTIMEOUT_5 | /* set 8 bits/symbol */ UART_CTL_BITSPERSYM_8 | + /* set 1 stop bit */ + UART_CTL_STOPBITS_1 | /* set parity to even */ UART_CTL_RXPAREVEN_MASK | UART_CTL_TXPAREVEN_MASK); -- 2.1.4 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] drivers: net: fsl-mc: Include MAC addr fixup in DPL
On 05/18/2017 04:19 AM, Bogdan Purcareata wrote: > Previous to MC v10.x, port mac address was specified via DPL. Since > newer MC versions are compatible with old style DPLs, make the u-boot > env mac addresses visible there. This applies only to DPLs that have an > older version. > > DPLs use 32 bit values for specifying MAC addresses. U-boot environment > variables take precedence over the MAC addresses already visible in the > DPL/DPC. > > Signed-off-by: Bogdan Purcareata > Signed-off-by: Heinz Wrobel > --- > drivers/net/fsl-mc/mc.c | 260 > > 1 file changed, 197 insertions(+), 63 deletions(-) > I see compiling warning about uninitialized variables "val" and "len". Please fix. York ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH] cmd/elf.c: Support passing arguments with bootelf
The bootelf command could, but does not, pass additional arguments along on the command line. Make do_bootelf consume bootelf/flags/address as needed and then pass along anything else to the ELF application we've launched. Reported-by: Thomas Doerfler Signed-off-by: Tom Rini --- Yes, this bug was reported back in 2009, and then not corrected. It was slightly more complex than Wolfgang had implied (even at the time) and I assume then slipped his mind. I ran into this myself now, and Thomas' post was one of the first things I found. --- cmd/elf.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/elf.c b/cmd/elf.c index e4c65351118a..ed9625b221fe 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -147,25 +147,25 @@ int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long addr; /* Address of the ELF image */ unsigned long rc; /* Return value from user code */ - char *sload, *saddr; + char *sload = NULL; const char *ep = getenv("autostart"); - int rcode = 0; - sload = saddr = NULL; - if (argc == 3) { - sload = argv[1]; - saddr = argv[2]; - } else if (argc == 2) { - if (argv[1][0] == '-') - sload = argv[1]; - else - saddr = argv[1]; - } + /* Consume 'bootelf' */ + argc--; argv++; - if (saddr) - addr = simple_strtoul(saddr, NULL, 16); - else + /* Check for flag. */ + if (argc >= 1 && (argv[0][0] == '-' && \ + (argv[0][1] == 'p' || argv[0][1] == 's'))) { + sload = argv[0]; + /* Consume flag. */ + argc--; argv++; + } + /* Check for address. */ + if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) != -EINVAL) { + /* Consume address */ + argc--; argv++; + } else addr = load_addr; if (!valid_elf_image(addr)) @@ -185,7 +185,7 @@ int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * pass address parameter as argv[0] (aka command name), * and all remaining args */ - rc = do_bootelf_exec((void *)addr, argc - 1, argv + 1); + rc = do_bootelf_exec((void *)addr, argc, argv); if (rc != 0) rcode = 1; @@ -385,7 +385,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } U_BOOT_CMD( - bootelf, 3, 0, do_bootelf, + bootelf, CONFIG_SYS_MAXARGS, 0, do_bootelf, "Boot from an ELF image in memory", "[-p|-s] [address]\n" "\t- load ELF image at [address] via program headers (-p)\n" -- 1.9.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 3/6] SPL: Add XIP booting support
On 05/18/2017 11:49 AM, Vikas Manocha wrote: Enable support for XIP (execute in place) of U-Boot or kernel image. There is no need to copy image from flash to ram if flash supports execute in place. Awesome. I've had to hack u-boot before to achieve exactly this. It's nice to have a proper implementation. [snip] diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c index 4f2b677..e330b1f 100644 --- a/board/st/stm32f746-disco/stm32f746-disco.c +++ b/board/st/stm32f746-disco/stm32f746-disco.c @@ -91,6 +91,7 @@ int board_early_init_f(void) #endif #ifdef CONFIG_SPL_BUILD + Unrelated change. [snip] diff --git a/common/spl/spl_xip.c b/common/spl/spl_xip.c new file mode 100644 index 000..50e2f34 --- /dev/null +++ b/common/spl/spl_xip.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 Vikas Manocha + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include + +static int spl_xip(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) +{ +#ifdef CONFIG_SPL_OS_BOOT + if (!spl_start_uboot()) { + spl_image->arg = (void *)CONFIG_SYS_FDT_BASE; + spl_image->name = "Linux"; + spl_image->os = IH_OS_LINUX; + spl_image->load_addr = CONFIG_SYS_LOAD_ADDR; + spl_image->entry_point = CONFIG_SYS_LOAD_ADDR; +#ifdef CONFIG_CPU_V7M This looks like it should be handled by spl_set_header_raw_uboot(). I don't see other SPL loaders do this. + spl_image->entry_point |= 0x1; +#endif + debug("spl: payload xipImage, load addr: 0x%lx\n", + spl_image->load_addr); + return 0; + } +#endif + return(spl_parse_image_header(spl_image, (const struct image_header *) + CONFIG_SYS_UBOOT_BASE)); +} +SPL_LOAD_IMAGE_METHOD("XIP", 0, BOOT_DEVICE_XIP, spl_xip); Alex ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 07/10] mips: bmips: add bcm63xx-spi driver support for BCM3380
This driver manages the SPI controller present on this SoC. Signed-off-by: Álvaro Fernández Rojas --- arch/mips/dts/brcm,bcm3380.dtsi | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/mips/dts/brcm,bcm3380.dtsi b/arch/mips/dts/brcm,bcm3380.dtsi index e351d58..3c19b90 100644 --- a/arch/mips/dts/brcm,bcm3380.dtsi +++ b/arch/mips/dts/brcm,bcm3380.dtsi @@ -142,6 +142,19 @@ status = "disabled"; }; + spi: spi@14e02000 { + compatible = "brcm,bcm6358-spi"; + reg = <0x14e02000 0x70c>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&periph_clk0 BCM3380_CLK0_SPI>; + resets = <&periph_rst0 BCM3380_RST0_SPI>; + spi-max-frequency = <2500>; + num-cs = <6>; + + status = "disabled"; + }; + leds: led-controller@14e00f00 { compatible = "brcm,bcm6328-leds"; reg = <0x14e00f00 0x1c>; -- 2.1.4 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot