Re: [PATCH 7/7] sunxi: H6: Enable SPI0 in DT when no eMMC is used
Hi Andre, On Thu, Jan 20, 2022 at 8:06 PM Jagan Teki wrote: > > On Thu, Jan 20, 2022 at 7:36 PM Andre Przywara wrote: > > > > On Thu, 20 Jan 2022 19:08:57 +0530 > > Jagan Teki wrote: > > > > Hi, > > > > > On Tue, Jan 11, 2022 at 6:16 PM Andre Przywara > > > wrote: > > > > > > > > On the Allwinner H6 SoC both the SPI0 and the eMMC device share one pin, > > > > so cannot be used simultaneously. On Linux this is a showstopper, since > > > > only one of them would be able to claim the pin, and the probe order is > > > > somewhat random. The DT consequently disables SPI0 in favour of the more > > > > useful eMMC. > > > > > > > > But a comment in the DT actually suggests that this could be reversed by > > > > U-Boot, if no eMMC is actually connected. Let's now implement this: > > > > When we fix up the device tree before booting a kernel, we iterate over > > > > all MMC devices, and check if there is an eMMC device among them. If > > > > none > > > > can be found, we enable SPI0 instead, to allow Linux access to the SPI > > > > flash. > > > > > > > Since this fixup is not really universally applicable to all boards, > > > > let's hide it behind a Kconfig option, and enable it only on the one > > > > supported board where this makes sense: the Pine H64. > > > > > > > > Please note that the SPI functionality is still disabled in U-Boot > > > > proper, the pinmux clash affects us too: it would always disable the > > > > eMMC > > > > and so spoil this algorithm here. > > > > > > > > Signed-off-by: Andre Przywara > > > > --- > > > > arch/arm/mach-sunxi/Kconfig | 10 > > > > board/sunxi/board.c | 50 + > > > > configs/pine_h64_defconfig | 1 + > > > > 3 files changed, 61 insertions(+) > > > > > > > > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig > > > > index 56ff1e197c..ce66453029 100644 > > > > --- a/arch/arm/mach-sunxi/Kconfig > > > > +++ b/arch/arm/mach-sunxi/Kconfig > > > > @@ -1047,6 +1047,16 @@ config BLUETOOTH_DT_DEVICE_FIXUP > > > > The used address is "bdaddr" if set, and "ethaddr" with the > > > > LSB > > > > flipped elsewise. > > > > > > > > +config SUNXI_H6_ENABLE_SPIFLASH > > > > + bool "Enable H6 SPI flash vs. eMMC enablement" > > > > + depends on MACH_SUN50I_H6 > > > > + default n > > > > + help > > > > + Enable this option if you want U-Boot check for an eMMC device > > > > + on Allwinner H6 boards, and enable the SPI flash if none is > > > > found. > > > > + SPI0 and MMC2 share one pin, so cannot coexist in Linux. The > > > > + DT prefers eMMC, but if none is used, we can safely enable > > > > SPI. > > > > > > Why we need a separate macro, cannot we check it H6 globally as it SoC > > > design? > > > > This "hack" is board dependent. We don't know if there is a SPI flash or > > eMMC in the first place, and this whole concept is weird enough that it > > warrants a separate config option. > > Probably due to this hardware issue the PineH64 is actually the only board > > in mainline that has both SPI flash and eMMC, and I don't want to enable > > SPI flash on every eMMC less board. Also it simplifies the code if we can > > assume that both DT nodes exist, when that config is enabled. > > > > Cheers, > > Andre > > > > P.S. Actually I wanted to forgot to mark this one as RFC, as I am not sure > > that it's justified. The comment in the mainline DT suggests this > > solution, and I was curious what it would take to make it work, as > > apparently some people are interested in it. > > If it board-specific, better switch to RFC or load the overlay by > checking on board specific boot script. Anything about this? Jagan.
Re: [PATCH 2/7] sunxi: Kconfig: Fix up SPI configuration
On Thu, Feb 24, 2022 at 12:56 PM Jagan Teki wrote: > > On Tue, Jan 11, 2022 at 6:16 PM Andre Przywara wrote: > > > > Commit 7945caf22c44 ("arm: sunxi: Enable SPI/SPI-FLASH support for A64") > > selected CONFIG_SPI by default on all Allwinner A64 boards, even though > > only 4 out of the 14 A64 boards have a SPI flash chip. All other SoCs > > had to manually select DM_SPI and friends, even though they are a > > platform property (the sunxi SPI driver is DM_SPI only). > > > > Clean this up to allow easy selection of SPI flash support in U-Boot > > proper, by selecting DM_SPI and DM_SPI_FLASH *if* CONFIG_SPI is > > selected, for *all* Allwinner SoCs. This simplifies the defconfig for > > two Libretech boards already. > > > > Also remove the forced CONFIG_SPI from the A64 Kconfig, instead let the > > four boards which allow SPI booting select this explicitly. > > > > Any board wishing to support SPI flash in U-Boot proper now just defines > > CONFIG_SPI and CONFIG_SPI_FLASH_ in its defconfig, Kconfig takes > > care of the rest. > > > > Signed-off-by: Andre Przywara Reviewed-by: Jagan Teki
Re: [PATCH 2/7] sunxi: Kconfig: Fix up SPI configuration
On Tue, Jan 11, 2022 at 6:16 PM Andre Przywara wrote: > > Commit 7945caf22c44 ("arm: sunxi: Enable SPI/SPI-FLASH support for A64") > selected CONFIG_SPI by default on all Allwinner A64 boards, even though > only 4 out of the 14 A64 boards have a SPI flash chip. All other SoCs > had to manually select DM_SPI and friends, even though they are a > platform property (the sunxi SPI driver is DM_SPI only). > > Clean this up to allow easy selection of SPI flash support in U-Boot > proper, by selecting DM_SPI and DM_SPI_FLASH *if* CONFIG_SPI is > selected, for *all* Allwinner SoCs. This simplifies the defconfig for > two Libretech boards already. > > Also remove the forced CONFIG_SPI from the A64 Kconfig, instead let the > four boards which allow SPI booting select this explicitly. > > Any board wishing to support SPI flash in U-Boot proper now just defines > CONFIG_SPI and CONFIG_SPI_FLASH_ in its defconfig, Kconfig takes > care of the rest. > > Signed-off-by: Andre Przywara
Re: [PATCH v2] arm: mach-k3: am6_init: Use CONFIG_TI_I2C_BOARD_DETECT
Hi Am Di., 15. Feb. 2022 um 07:48 Uhr schrieb Christian Gmeiner : > > We only want to call do_board_detect() if CONFIG_TI_I2C_BOARD_DETECT > is set. Same as done for am64. > > This makes it possible to add a custom am65 based board design to > U-Boot that does not use this board detection mechanism. > > Signed-off-by: Christian Gmeiner Gentle ping. -- greets -- Christian Gmeiner, MSc https://christian-gmeiner.info/privacypolicy
Re: [PATCH 2/2] ARM: imx: imx8mn-*-evk: add qca, disable-smarteee phy node
On 2/23/22 10:48, Heiko Thiery wrote: To be in sync with the linux devicetree add the disable-smarteee property. Tested-by: Marek Vasut # 8MNANOD4-EVK
Re: [PATCH 1/2] ARM: imx: imx8mn-*-evk: use reset-gpios in phy node
On 2/23/22 10:48, Heiko Thiery wrote: To be in sync with the linux devicetree change the 'phy-reset-gpios' in the fec node to 'reset-gpios' in the phy node. The PHY reset will be done by the eth-phy-uclass driver while probing the PHY. This is ok since it is done before probing the fec. Signed-off-by: Heiko Thiery Tested-by: Marek Vasut # 8MNANOD4-EVK
Re: [PATCH v3] ARM: imx: imx8mn-*-evk: use DM settings for PHY configuration
On 2/23/22 09:10, Heiko Thiery wrote: With the correct settings described in the device-tree the PHY settings in the board init are no longer required. The values are taken from the linux device tree. The PHY latency settings are derived from the phy-mode property and the voltage seetings are done via the regulator. Suggested-by: Michael Walle Signed-off-by: Heiko Thiery Tested-by: Marek Vasut # 8MNANOD4-EVK
Re: [PATCH 3/4] arm: exynos: Move BL1/2 SPI flash defines to their user, drop CONFIG
Dear Tom, 2022년 2월 24일 (목) 09:03, Jaehoon Chung 님이 작성: > On 2/24/22 02:28, Tom Rini wrote: > > These particular values are not configurable and today we always set > > CONFIG_SECURE_BL1_ONLY. Move these to where they're used in the code, > > and drop from the CONFIG namespace. > > > > Cc: Minkyu Kang > > Cc: Jaehoon Chung > > Signed-off-by: Tom Rini > > Reviewed-by: Jaehoon Chung > > Best Regards, > Jaehoon Chung > Reviewed-by: Minkyu Kang Thanks. -- Thanks. Minkyu Kang.
Re: [PATCH v2] mmc: fsl_esdhc_imx: use VENDORSPEC_FRC_SDCLK_ON when necessary
On 2/22/22 12:28, haibo.c...@nxp.com wrote: > From: Haibo Chen > > After commit f132aab40327 ("Revert "mmc: fsl_esdhc_imx: use > VENDORSPEC_FRC_SDCLK_ON to control card clock output""), it > involve issue in mmc_switch_voltage(), because of the special > design of usdhc. > > For FSL_USDHC, it do not implement VENDORSPEC_CKEN/PEREN/HCKEN/IPGEN, > these are reserved bits(Though RM contain the definition of these bits, > but actually internal IC logic do not implement, already confirm with > IC team). Instead, use VENDORSPEC_FRC_SDCLK_ON to gate on/off the card > clock output. Here is the definition of this bit in RM: > > [8] FRC_SDCLK_ON > Force CLK output active > Do not set this bit to 1 unless it is necessary. Also, make sure that > this bit is cleared when uSDHC’s clock is about to be changed (frequency > change, clock source change, or delay chain tuning). > 0b - CLK active or inactive is fully controlled by the hardware. > 1b - Force CLK active > > In default, the FRC_SDCLK_ON is 0. This means, when there is no command > or data transfer on bus, hardware will gate off the card clock. But in > some case, we need the card clock keep on. Take IO voltage 1.8v switch > as example, after IO voltage change to 1.8v, spec require gate off the > card clock for 5ms, and gate on the clock back, once detect the card > clock on, then the card will draw the dat0 to high immediately. If there > is not clock gate off/on behavior, some card will keep the dat0 to low > level. This is the reason we fail in mmc_switch_voltage(). > > To fix this issue, and concern that this is only the fsl usdhc hardware > design limitation, set the bit FRC_SDCLK_ON in the beginning of the > wait_dat0() and clear it in the end. To make sure the 1.8v IO voltage > switch process align with SD specification. > > For standard tuning process, usdhc specification also require the card > clock keep on, so also add these behavior in fsl_esdhc_execute_tuning(). > > Reviewed-by: Marek Vasut > Tested-by: Fabio Estevam > Signed-off-by: Haibo Chen Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > drivers/mmc/fsl_esdhc_imx.c | 25 ++--- > include/fsl_esdhc_imx.h | 2 ++ > 2 files changed, 24 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c > index 9299635f50..e0108144e7 100644 > --- a/drivers/mmc/fsl_esdhc_imx.c > +++ b/drivers/mmc/fsl_esdhc_imx.c > @@ -831,13 +831,16 @@ static int fsl_esdhc_execute_tuning(struct udevice > *dev, uint32_t opcode) > struct mmc *mmc = &plat->mmc; > u32 irqstaten = esdhc_read32(®s->irqstaten); > u32 irqsigen = esdhc_read32(®s->irqsigen); > - int i, ret = -ETIMEDOUT; > - u32 val, mixctrl; > + int i, err, ret = -ETIMEDOUT; > + u32 val, mixctrl, tmp; > > /* clock tuning is not needed for upto 52MHz */ > if (mmc->clock <= 5200) > return 0; > > + /* make sure the card clock keep on */ > + esdhc_setbits32(®s->vendorspec, VENDORSPEC_FRC_SDCLK_ON); > + > /* This is readw/writew SDHCI_HOST_CONTROL2 when tuning */ > if (priv->flags & ESDHC_FLAG_STD_TUNING) { > val = esdhc_read32(®s->autoc12err); > @@ -897,6 +900,12 @@ static int fsl_esdhc_execute_tuning(struct udevice *dev, > uint32_t opcode) > > esdhc_stop_tuning(mmc); > > + /* change to default setting, let host control the card clock */ > + esdhc_clrbits32(®s->vendorspec, VENDORSPEC_FRC_SDCLK_ON); > + err = readx_poll_timeout(esdhc_read32, ®s->prsstat, tmp, tmp & > PRSSTAT_SDOFF, 100); > + if (err) > + dev_warn(dev, "card clock not gate off as expect.\n"); > + > return ret; > } > #endif > @@ -1555,14 +1564,24 @@ static int __maybe_unused > fsl_esdhc_set_enhanced_strobe(struct udevice *dev) > static int fsl_esdhc_wait_dat0(struct udevice *dev, int state, > int timeout_us) > { > - int ret; > + int ret, err; > u32 tmp; > struct fsl_esdhc_priv *priv = dev_get_priv(dev); > struct fsl_esdhc *regs = priv->esdhc_regs; > > + /* make sure the card clock keep on */ > + esdhc_setbits32(®s->vendorspec, VENDORSPEC_FRC_SDCLK_ON); > + > ret = readx_poll_timeout(esdhc_read32, ®s->prsstat, tmp, > !!(tmp & PRSSTAT_DAT0) == !!state, > timeout_us); > + > + /* change to default setting, let host control the card clock */ > + esdhc_clrbits32(®s->vendorspec, VENDORSPEC_FRC_SDCLK_ON); > + err = readx_poll_timeout(esdhc_read32, ®s->prsstat, tmp, tmp & > PRSSTAT_SDOFF, 100); > + if (err) > + dev_warn(dev, "card clock not gate off as expect.\n"); > + > return ret; > } > > diff --git a/include/fsl_esdhc_imx.h b/include/fsl_esdhc_imx.h > index 2153f29bef..b8efd2a166 100644 > --- a/include/fsl_esdhc_imx.h > +++ b/include/fsl_esdhc_imx.h > @@ -37,6 +37,7 @@ > #define VENDORSPEC_HCKEN
Re: [PATCH 3/4] arm: exynos: Move BL1/2 SPI flash defines to their user, drop CONFIG
On 2/24/22 02:28, Tom Rini wrote: > These particular values are not configurable and today we always set > CONFIG_SECURE_BL1_ONLY. Move these to where they're used in the code, > and drop from the CONFIG namespace. > > Cc: Minkyu Kang > Cc: Jaehoon Chung > Signed-off-by: Tom Rini Reviewed-by: Jaehoon Chung Best Regards, Jaehoon Chung > --- > arch/arm/mach-exynos/spl_boot.c | 30 ++ > include/configs/exynos5-common.h | 24 > include/configs/origen.h | 5 - > include/configs/smdkv310.h | 5 - > 4 files changed, 30 insertions(+), 34 deletions(-) > > diff --git a/arch/arm/mach-exynos/spl_boot.c b/arch/arm/mach-exynos/spl_boot.c > index 722449881af2..93fea9c749a6 100644 > --- a/arch/arm/mach-exynos/spl_boot.c > +++ b/arch/arm/mach-exynos/spl_boot.c > @@ -22,6 +22,36 @@ > #include "common_setup.h" > #include "clock_init.h" > > +#ifdef CONFIG_ARCH_EXYNOS5 > +#define SECURE_BL1_ONLY > + > +/* Secure FW size configuration */ > +#ifdef SECURE_BL1_ONLY > +#define SEC_FW_SIZE (8 << 10) /* 8KB */ > +#else > +#define SEC_FW_SIZE 0 > +#endif > + > +/* Configuration of BL1, BL2, ENV Blocks on mmc */ > +#define RES_BLOCK_SIZE (512) > +#define BL1_SIZE (16 << 10) /*16 K reserved for BL1*/ > +#define BL2_SIZE (512UL << 10UL) /* 512 KB */ > + > +#define BL1_OFFSET (RES_BLOCK_SIZE + SEC_FW_SIZE) > +#define BL2_OFFSET (BL1_OFFSET + BL1_SIZE) > + > +/* U-Boot copy size from boot Media to DRAM.*/ > +#define BL2_START_OFFSET (BL2_OFFSET/512) > +#define BL2_SIZE_BLOC_COUNT (BL2_SIZE/512) > + > +#define EXYNOS_COPY_SPI_FNPTR_ADDR 0x02020058 > +#define SPI_FLASH_UBOOT_POS (SEC_FW_SIZE + BL1_SIZE) > +#elif defined(CONFIG_ARCH_EXYNOS4) > +#define COPY_BL2_SIZE0x8 > +#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) > +#define BL2_SIZE_BLOC_COUNT (COPY_BL2_SIZE/512) > +#endif > + > DECLARE_GLOBAL_DATA_PTR; > > /* Index into irom ptr table */ > diff --git a/include/configs/exynos5-common.h > b/include/configs/exynos5-common.h > index 90d095d535b0..410243bb2c91 100644 > --- a/include/configs/exynos5-common.h > +++ b/include/configs/exynos5-common.h > @@ -58,30 +58,6 @@ > > #define CONFIG_SYS_MONITOR_BASE 0x > > -#define CONFIG_SECURE_BL1_ONLY > - > -/* Secure FW size configuration */ > -#ifdef CONFIG_SECURE_BL1_ONLY > -#define CONFIG_SEC_FW_SIZE (8 << 10) /* 8KB */ > -#else > -#define CONFIG_SEC_FW_SIZE 0 > -#endif > - > -/* Configuration of BL1, BL2, ENV Blocks on mmc */ > -#define CONFIG_RES_BLOCK_SIZE(512) > -#define CONFIG_BL1_SIZE (16 << 10) /*16 K reserved for BL1*/ > -#define CONFIG_BL2_SIZE (512UL << 10UL) /* 512 KB */ > - > -#define CONFIG_BL1_OFFSET(CONFIG_RES_BLOCK_SIZE + CONFIG_SEC_FW_SIZE) > -#define CONFIG_BL2_OFFSET(CONFIG_BL1_OFFSET + CONFIG_BL1_SIZE) > - > -/* U-Boot copy size from boot Media to DRAM.*/ > -#define BL2_START_OFFSET (CONFIG_BL2_OFFSET/512) > -#define BL2_SIZE_BLOC_COUNT (CONFIG_BL2_SIZE/512) > - > -#define EXYNOS_COPY_SPI_FNPTR_ADDR 0x02020058 > -#define SPI_FLASH_UBOOT_POS (CONFIG_SEC_FW_SIZE + CONFIG_BL1_SIZE) > - > /* SPI */ > > /* Ethernet Controllor Driver */ > diff --git a/include/configs/origen.h b/include/configs/origen.h > index 1caeed6ba5cd..22325180ce0e 100644 > --- a/include/configs/origen.h > +++ b/include/configs/origen.h > @@ -58,9 +58,4 @@ > > #define CONFIG_SYS_INIT_SP_ADDR 0x0204 > > -/* U-Boot copy size from boot Media to DRAM.*/ > -#define COPY_BL2_SIZE0x8 > -#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) > -#define BL2_SIZE_BLOC_COUNT (COPY_BL2_SIZE/512) > - > #endif /* __CONFIG_H */ > diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h > index f113fa44045e..32196a5aef94 100644 > --- a/include/configs/smdkv310.h > +++ b/include/configs/smdkv310.h > @@ -51,11 +51,6 @@ > > #define CONFIG_SYS_INIT_SP_ADDR 0x0204 > > -/* U-Boot copy size from boot Media to DRAM.*/ > -#define COPY_BL2_SIZE 0x8 > -#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) > -#define BL2_SIZE_BLOC_COUNT (COPY_BL2_SIZE/512) > - > /* Ethernet Controllor Driver */ > #ifdef CONFIG_CMD_NET > #define CONFIG_ENV_SROM_BANK 1
[PATCH v2 12/25] binman: Change how faked blobs are created
At present fake blobs are created but internally an empty blob is used. Change it to use the contents of the faked file. Also return whether the blob was faked, in case the caller needs to know that. Add a TODO to put fake blobs in their own directory. Signed-off-by: Simon Glass --- Changes in v2: - Add a patch to change how faked blobs are created tools/binman/binman.rst | 3 ++- tools/binman/entry.py | 9 ++--- tools/binman/etype/blob.py | 7 --- tools/binman/etype/blob_ext_list.py | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 85f8337a31..a90364f2fb 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1500,7 +1500,8 @@ Some ideas: - Figure out how to make Fdt support changing the node order, so that Node.AddSubnode() can support adding a node before another, existing node. Perhaps it should completely regenerate the flat tree? - +- Put faked files into a separate subdir and remove them on start-up, to avoid + seeing them as 'real' files on a subsequent run -- Simon Glass diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 00a13c5839..2fb0050da5 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -997,15 +997,18 @@ features to produce new behaviours. fname (str): Filename to check Returns: -fname (str): Filename of faked file +tuple: +fname (str): Filename of faked file +bool: True if the blob was faked, False if not """ if self.allow_fake and not pathlib.Path(fname).is_file(): outfname = tools.get_output_filename(os.path.basename(fname)) with open(outfname, "wb") as out: out.truncate(1024) self.faked = True -return outfname -return fname +tout.info(f"Entry '{self._node.path}': Faked file '{outfname}'") +return outfname, True +return fname, False def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index 25ec5d26c9..89f089e740 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -41,10 +41,11 @@ class Entry_blob(Entry): self.external and self.section.GetAllowMissing()) # Allow the file to be missing if not self._pathname: -self._pathname = self.check_fake_fname(self._filename) -self.SetContents(b'') +self._pathname, faked = self.check_fake_fname(self._filename) self.missing = True -return True +if not faked: +self.SetContents(b'') +return True self.ReadBlobContents() return True diff --git a/tools/binman/etype/blob_ext_list.py b/tools/binman/etype/blob_ext_list.py index 76ad32a1ee..f00202e9eb 100644 --- a/tools/binman/etype/blob_ext_list.py +++ b/tools/binman/etype/blob_ext_list.py @@ -37,7 +37,7 @@ class Entry_blob_ext_list(Entry_blob): missing = False pathnames = [] for fname in self._filenames: -fname = self.check_fake_fname(fname) +fname, _ = self.check_fake_fname(fname) pathname = tools.get_input_filename( fname, self.external and self.section.GetAllowMissing()) # Allow the file to be missing -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 11/25] binman: Rename tools parameter to btools
This shadows the patman.tools library so rename it to avoid a pylint warning. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/entry.py| 4 ++-- tools/binman/etype/fit.py| 6 +++--- tools/binman/etype/gbb.py| 4 ++-- tools/binman/etype/intel_ifwi.py | 4 ++-- tools/binman/etype/mkimage.py| 4 ++-- tools/binman/etype/section.py| 4 ++-- tools/binman/etype/vblock.py | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 90a40bb274..00a13c5839 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -1099,11 +1099,11 @@ features to produce new behaviours. """ pass -def AddBintools(self, tools): +def AddBintools(self, btools): """Add the bintools used by this entry type Args: -tools (dict of Bintool): +btools (dict of Bintool): """ pass diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 61c72780e9..2b82955226 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -484,6 +484,6 @@ class Entry_fit(Entry_section): section.SetOffsetSize(offset, size) section.SetImagePos(self.image_pos) -def AddBintools(self, tools): -super().AddBintools(tools) -self.mkimage = self.AddBintool(tools, 'mkimage') +def AddBintools(self, btools): +super().AddBintools(btools) +self.mkimage = self.AddBintool(btools, 'mkimage') diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py index e32fae27ce..7394e4e5d3 100644 --- a/tools/binman/etype/gbb.py +++ b/tools/binman/etype/gbb.py @@ -99,5 +99,5 @@ class Entry_gbb(Entry): return True -def AddBintools(self, tools): -self.futility = self.AddBintool(tools, 'futility') +def AddBintools(self, btools): +self.futility = self.AddBintool(btools, 'futility') diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py index 46bdf116e6..4fa7d636fe 100644 --- a/tools/binman/etype/intel_ifwi.py +++ b/tools/binman/etype/intel_ifwi.py @@ -143,5 +143,5 @@ class Entry_intel_ifwi(Entry_blob_ext): for entry in self._ifwi_entries.values(): entry.WriteSymbols(self) -def AddBintools(self, tools): -self.ifwitool = self.AddBintool(tools, 'ifwitool') +def AddBintools(self, btools): +self.ifwitool = self.AddBintool(btools, 'ifwitool') diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index c28141ff69..9f4717e4ea 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -93,5 +93,5 @@ class Entry_mkimage(Entry): for entry in self._mkimage_entries.values(): entry.CheckFakedBlobs(faked_blobs_list) -def AddBintools(self, tools): -self.mkimage = self.AddBintool(tools, 'mkimage') +def AddBintools(self, btools): +self.mkimage = self.AddBintool(btools, 'mkimage') diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index f2d401d95b..16ee5ed723 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -894,6 +894,6 @@ class Entry_section(Entry): for entry in self._entries.values(): entry.CheckAltFormats(alt_formats) -def AddBintools(self, tools): +def AddBintools(self, btools): for entry in self._entries.values(): -entry.AddBintools(tools) +entry.AddBintools(btools) diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py index a1de98290b..065b6ed2f6 100644 --- a/tools/binman/etype/vblock.py +++ b/tools/binman/etype/vblock.py @@ -97,5 +97,5 @@ class Entry_vblock(Entry_collection): data = self.GetVblock(True) return self.ProcessContentsUpdate(data) -def AddBintools(self, tools): -self.futility = self.AddBintool(tools, 'futility') +def AddBintools(self, btools): +self.futility = self.AddBintool(btools, 'futility') -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 15/25] binman: Read the fit entries only once
At present the entries are read twice, once by the entry_Section class and once by the FIT implementation. This is harmless but can be confusing when debugging. Fix it. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 2b82955226..7b0c94dfee 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -185,7 +185,6 @@ class Entry_fit(Entry_section): self.mkimage = None def ReadNode(self): -self.ReadEntries() super().ReadNode() def _get_operation(self, subnode): -- 2.35.1.574.g5d30c73bfb-goog
Re: [PATCH 17/24] binman: fit: Refactor to reduce function size
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:50, Simon Glass wrote: > > Split subnode and property processing into separate functions to make > > the _AddNode() function a little smaller. Tweak a few comments. > > > > This does not change any functionality. > > > > Signed-off-by: Simon Glass > > --- > > I know this just moves code around a bit, but I think the code here > could be cleaned up much further with a bit of redesign. I'm not sure of > the details, but was thinking of at least: > > - self._add_fit_image() to handle image/* subnodes > - self._add_fit_config() to handle configuration/* subnodes > - self._gen_fdt_nodes() to handle template nodes by calling the above > - Switching away from recursion to iterating subnodes of fixed nodes This code is significantly different now, so see what you think. The last point is interesting...at present you can use property substitution in any node. I tend to agree the recursion doesn't really help, but let me know what you think of the latest version. > > > > > tools/binman/etype/fit.py | 116 -- > > 1 file changed, 73 insertions(+), 43 deletions(-) > > > > diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py > > index 6ad4a686df..b159844960 100644 > > --- a/tools/binman/etype/fit.py > > +++ b/tools/binman/etype/fit.py > > @@ -141,12 +141,82 @@ class Entry_fit(Entry): > > super().ReadNode() > > > > def ReadEntries(self): > > I think the following functions could be moved out of this one into the > class scope, even including _AddNode. OK, will hold off on this one until after the series. [..] Regards, Simon
[PATCH v2 19/25] binman: Keep a separate list of entries for fit
The current implementation sets up the FIT entries but then deletes the 'generator' ones so they don't appear in the final image. This is a bit clumsy. We cannot build the image more than once, since the generator entries are lost during the first build. Binman requires that calling BuildSectionData() multiple times returns a valid result each time. Keep a separate, private list which includes the generator nodes and use that where needed, to correct this problem. Ensure that the missing list includes removed generator entries too. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 33 - 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index e1b056f56e..30b20a07a2 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -163,10 +163,15 @@ class Entry_fit(Entry_section): key: relative path to entry Node (from the base of the FIT) value: Entry_section object comprising the contents of this node +_priv_entries: Internal copy of _entries which includes 'generator' +entries which are used to create the FIT, but should not be +processed as real entries. This is set up once we have the +entries """ super().__init__(section, etype, node) self._fit = None self._fit_props = {} +self._priv_entries = {} for pname, prop in self._node.props.items(): if pname.startswith('fit,'): @@ -239,6 +244,10 @@ class Entry_fit(Entry_section): _add_entries(self._node, 0, self._node) +# Keep a copy of all entries, including generator entries, since these +# removed from self._entries later. +self._priv_entries = dict(self._entries) + def BuildSectionData(self, required): """Build FIT entry contents @@ -415,11 +424,12 @@ class Entry_fit(Entry_section): has_images = depth == 2 and in_images if has_images: -entry = self._entries[rel_path] +entry = self._priv_entries[rel_path] data = entry.GetData() fsw.property('data', bytes(data)) for subnode in node.subnodes: +subnode_path = f'{rel_path}/{subnode.name}' if has_images and not (subnode.name.startswith('hash') or subnode.name.startswith('signature')): # This subnode is a content node not meant to appear in @@ -427,11 +437,11 @@ class Entry_fit(Entry_section): # fsw.add_node() or _add_node() for it. pass elif self.GetImage().generate and subnode.name.startswith('@'): -subnode_path = f'{rel_path}/{subnode.name}' -entry = self._entries.get(subnode_path) _gen_node(base_node, subnode, depth, in_images) -if entry: -del self._entries[subnode_path] +# This is a generator (template) entry, so remove it from +# the list of entries used by PackEntries(), etc. Otherwise +# it will appear in the binman output +to_remove.append(subnode_path) else: with fsw.add_node(subnode.name): _add_node(base_node, depth + 1, subnode) @@ -440,10 +450,16 @@ class Entry_fit(Entry_section): # entry node fsw = libfdt.FdtSw() fsw.finish_reservemap() +to_remove = [] with fsw.add_node(''): _add_node(self._node, 0, self._node) fdt = fsw.as_fdt() +# Remove generator entries from the main list +for path in to_remove: +if path in self._entries: +del self._entries[path] + # Pack this new FDT and scan it so we can add the data later fdt.pack() data = fdt.as_bytearray() @@ -503,3 +519,10 @@ class Entry_fit(Entry_section): def AddBintools(self, btools): super().AddBintools(btools) self.mkimage = self.AddBintool(btools, 'mkimage') + +def CheckMissing(self, missing_list): +# We must use our private entry list for this since generator notes +# which are removed from self._entries will otherwise not show up as +# missing +for entry in self._priv_entries.values(): +entry.CheckMissing(missing_list) -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 25/25] rockchip: Drop the FIT generator script
This is not used anymore. Drop it. Signed-off-by: Simon Glass --- Changes in v2: - Drop patches previously applied - Add various suggestions from Alper Nebi Yasak - Add patches to refactor binman's FIT support Makefile | 3 - arch/arm/mach-rockchip/make_fit_atf.py | 240 - boot/Kconfig | 1 - 3 files changed, 244 deletions(-) delete mode 100755 arch/arm/mach-rockchip/make_fit_atf.py diff --git a/Makefile b/Makefile index 7a4f95b898..f0b01a8f1b 100644 --- a/Makefile +++ b/Makefile @@ -1352,9 +1352,6 @@ $(U_BOOT_ITS): $(subst ",,$(CONFIG_SPL_FIT_SOURCE)) else ifneq ($(CONFIG_USE_SPL_FIT_GENERATOR),) U_BOOT_ITS := u-boot.its -ifeq ($(CONFIG_SPL_FIT_GENERATOR),"arch/arm/mach-rockchip/make_fit_atf.py") -U_BOOT_ITS_DEPS += u-boot -endif $(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE $(srctree)/$(CONFIG_SPL_FIT_GENERATOR) \ $(patsubst %,arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) > $@ diff --git a/arch/arm/mach-rockchip/make_fit_atf.py b/arch/arm/mach-rockchip/make_fit_atf.py deleted file mode 100755 index f3224d2555..00 --- a/arch/arm/mach-rockchip/make_fit_atf.py +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python3 -""" -# SPDX-License-Identifier: GPL-2.0+ -# -# A script to generate FIT image source for rockchip boards -# with ARM Trusted Firmware -# and multiple device trees (given on the command line) -# -# usage: $0 [ [; - - images { -""" - -DT_UBOOT = """ - uboot { - description = "U-Boot (64-bit)"; - data = /incbin/("u-boot-nodtb.bin"); - type = "standalone"; - os = "U-Boot"; - arch = "arm64"; - compression = "none"; - load = <0x%08x>; - }; - -""" - -DT_IMAGES_NODE_END = """ }; - -""" - -DT_END = "};" - -def append_bl31_node(file, atf_index, phy_addr, elf_entry): -# Append BL31 DT node to input FIT dts file. -data = 'bl31_0x%08x.bin' % phy_addr -file.write('\t\tatf_%d {\n' % atf_index) -file.write('\t\t\tdescription = \"ARM Trusted Firmware\";\n') -file.write('\t\t\tdata = /incbin/("%s");\n' % data) -file.write('\t\t\ttype = "firmware";\n') -file.write('\t\t\tarch = "arm64";\n') -file.write('\t\t\tos = "arm-trusted-firmware";\n') -file.write('\t\t\tcompression = "none";\n') -file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) -if atf_index == 1: -file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) -file.write('\t\t};\n') -file.write('\n') - -def append_tee_node(file, atf_index, phy_addr, elf_entry): -# Append TEE DT node to input FIT dts file. -data = 'tee_0x%08x.bin' % phy_addr -file.write('\t\tatf_%d {\n' % atf_index) -file.write('\t\t\tdescription = \"TEE\";\n') -file.write('\t\t\tdata = /incbin/("%s");\n' % data) -file.write('\t\t\ttype = "tee";\n') -file.write('\t\t\tarch = "arm64";\n') -file.write('\t\t\tos = "tee";\n') -file.write('\t\t\tcompression = "none";\n') -file.write('\t\t\tload = <0x%08x>;\n' % phy_addr) -file.write('\t\t\tentry = <0x%08x>;\n' % elf_entry) -file.write('\t\t};\n') -file.write('\n') - -def append_fdt_node(file, dtbs): -# Append FDT nodes. -cnt = 1 -for dtb in dtbs: -dtname = os.path.basename(dtb) -file.write('\t\tfdt_%d {\n' % cnt) -file.write('\t\t\tdescription = "%s";\n' % dtname) -file.write('\t\t\tdata = /incbin/("%s");\n' % dtb) -file.write('\t\t\ttype = "flat_dt";\n') -file.write('\t\t\tcompression = "none";\n') -file.write('\t\t};\n') -file.write('\n') -cnt = cnt + 1 - -def append_conf_section(file, cnt, dtname, segments): -file.write('\t\tconfig_%d {\n' % cnt) -file.write('\t\t\tdescription = "%s";\n' % dtname) -file.write('\t\t\tfirmware = "atf_1";\n') -file.write('\t\t\tloadables = "uboot"') -if segments > 1: -file.write(',') -for i in range(1, segments): -file.write('"atf_%d"' % (i + 1)) -if i != (segments - 1): -file.write(',') -else: -file.write(';\n') -if segments <= 1: -file.write(';\n') -file.write('\t\t\tfdt = "fdt_%d";\n' % cnt) -file.write('\t\t};\n') -file.write('\n') - -def append_conf_node(file, dtbs, segments): -# Append configeration nodes. -cnt = 1 -file.write('\tconfigurations {\n') -file.write('\t\tdefault = "config_1";\n') -for dtb in dtbs: -dtname = os.path.basename(dtb) -append_conf_section(file, cnt, dtname, segments) -cnt = cnt + 1 -file.write('\t};\n') -file.write('\n') - -def generate_atf_fit_dts_uboot(fit_file, uboot_file_name): -segments = unpack_elf(uboot_file_name) -if len(segments) != 1: -raise ValueError("Invalid u-boot ELF image '%s'" % uboot_file_name) -ind
[PATCH v2 24/25] rockchip: Convert all boards to use binman
Instead of the bash script, use binman to generate the FIT for arm64. For 32-bit boards, use binman for all images, dropping the intermediate files. With this change, only Zynq is now using SPL_FIT_GENERATOR so update the Kconfig rule accordingly. Clean up the Makefile to the extent possible. Unfortunately, two boards do not use SPL_FRAMEWORK so don't enable the u-boot.img rule: evb-rk3036 kylin-rk3036 So a small remnant remains. Signed-off-by: Simon Glass --- (no changes since v1) Makefile | 39 ++- boot/Kconfig | 2 +- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 697cc51d67..7a4f95b898 100644 --- a/Makefile +++ b/Makefile @@ -976,19 +976,8 @@ ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy) INPUTS-y += u-boot-with-dtb.bin endif -ifeq ($(CONFIG_ARCH_ROCKCHIP),y) -# On ARM64 this target is produced by binman so we don't need this dep -ifeq ($(CONFIG_ARM64),y) -ifeq ($(CONFIG_SPL),y) -# TODO: Get binman to generate this too -INPUTS-y += u-boot-rockchip.bin -endif -else -ifeq ($(CONFIG_SPL),y) -# Generate these inputs for binman which will create the output files -INPUTS-y += idbloader.img u-boot.img -endif -endif +ifeq ($(CONFIG_ARCH_ROCKCHIP)_$(CONFIG_SPL_FRAMEWORK),y_) +INPUTS-y += u-boot.img endif INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ @@ -1473,30 +1462,6 @@ OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE $(call if_changed,pad_cat) -ifeq ($(CONFIG_ARCH_ROCKCHIP),y) - -# TPL + SPL -ifeq ($(CONFIG_SPL)$(CONFIG_TPL),yy) -MKIMAGEFLAGS_u-boot-tpl-rockchip.bin = -n $(CONFIG_SYS_SOC) -T rksd -tpl/u-boot-tpl-rockchip.bin: tpl/u-boot-tpl.bin FORCE - $(call if_changed,mkimage) -idbloader.img: tpl/u-boot-tpl-rockchip.bin spl/u-boot-spl.bin FORCE - $(call if_changed,cat) -else -MKIMAGEFLAGS_idbloader.img = -n $(CONFIG_SYS_SOC) -T rksd -idbloader.img: spl/u-boot-spl.bin FORCE - $(call if_changed,mkimage) -endif - -ifeq ($(CONFIG_ARM64),y) -OBJCOPYFLAGS_u-boot-rockchip.bin = -I binary -O binary \ - --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff -u-boot-rockchip.bin: idbloader.img u-boot.itb FORCE - $(call if_changed,pad_cat) -endif # CONFIG_ARM64 - -endif # CONFIG_ARCH_ROCKCHIP - ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy) MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) diff --git a/boot/Kconfig b/boot/Kconfig index b83a4e8400..ae1a37ae92 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -275,7 +275,7 @@ config SPL_FIT_SOURCE config USE_SPL_FIT_GENERATOR bool "Use a script to generate the .its script" - default y if SPL_FIT && (!ARCH_SUNXI && !RISCV) + default y if SPL_FIT && ARCH_ZYNQMP config SPL_FIT_GENERATOR string ".its file generator script for U-Boot FIT image" -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 21/25] rockchip: evb-rk3288: Drop raw-image support
This boards uses SPL_FIT so does not need to support loading a raw image. Drop it to avoid binman trying to insert a symbol which has no value. Signed-off-by: Simon Glass --- (no changes since v1) configs/evb-rk3288_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig index 97d4c14f65..6143c4d989 100644 --- a/configs/evb-rk3288_defconfig +++ b/configs/evb-rk3288_defconfig @@ -24,6 +24,7 @@ CONFIG_USE_PREBOOT=y CONFIG_DEFAULT_FDT_FILE="rk3288-evb-rk808.dtb" CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x1 CONFIG_SPL_OPTEE_IMAGE=y -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 14/25] binman: Allow mkimage to use a non-zero fake-blob size
Unfortunately mkimage gets upset with zero-sized files. Update the ObtainContents() method to support specifying the size, if a fake blob is created. Signed-off-by: Simon Glass --- Changes in v2: - Add a patch to allow mkimage to use a non-zero fake-blob size tools/binman/entry.py | 11 --- tools/binman/etype/_testing.py| 2 +- tools/binman/etype/blob.py| 5 +++-- tools/binman/etype/mkimage.py | 13 - tools/binman/etype/section.py | 2 +- tools/binman/ftest.py | 10 ++ tools/binman/test/229_mkimage_missing.dts | 18 ++ 7 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 tools/binman/test/229_mkimage_missing.dts diff --git a/tools/binman/entry.py b/tools/binman/entry.py index e4c0fbe23d..249f117ace 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -415,9 +415,13 @@ class Entry(object): self.SetContents(data) return size_ok -def ObtainContents(self): +def ObtainContents(self, skip_entry=None, fake_size=0): """Figure out the contents of an entry. +Args: +skip_entry (Entry): Entry to skip when obtaining section contents +fake_size (int): Size of fake file to create if needed + Returns: True if the contents were found, False if another call is needed after the other entries are processed. @@ -1130,12 +1134,13 @@ features to produce new behaviours. """ self.update_hash = update_hash -def collect_contents_to_file(self, entries, prefix): +def collect_contents_to_file(self, entries, prefix, fake_size=0): """Put the contents of a list of entries into a file Args: entries (list of Entry): Entries to collect prefix (str): Filename prefix of file to write to +fake_size (int): Size of fake file to create if needed If any entry does not have contents yet, this function returns False for the data. @@ -1150,7 +1155,7 @@ features to produce new behaviours. for entry in entries: # First get the input data and put it in a file. If not available, # try later. -if not entry.ObtainContents(): +if not entry.ObtainContents(fake_size=fake_size): return None, None, None data += entry.GetData() uniq = self.GetUniqueName() diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py index 0800c25899..5089de3642 100644 --- a/tools/binman/etype/_testing.py +++ b/tools/binman/etype/_testing.py @@ -82,7 +82,7 @@ class Entry__testing(Entry): self.return_contents = True self.contents = b'aa' -def ObtainContents(self): +def ObtainContents(self, fake_size=0): if self.return_unknown_contents or not self.return_contents: return False if self.return_contents_later: diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index 89f089e740..ceaefb07b7 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -35,13 +35,14 @@ class Entry_blob(Entry): super().__init__(section, etype, node) self._filename = fdt_util.GetString(self._node, 'filename', self.etype) -def ObtainContents(self): +def ObtainContents(self, fake_size=0): self._filename = self.GetDefaultFilename() self._pathname = tools.get_input_filename(self._filename, self.external and self.section.GetAllowMissing()) # Allow the file to be missing if not self._pathname: -self._pathname, faked = self.check_fake_fname(self._filename) +self._pathname, faked = self.check_fake_fname(self._filename, + fake_size) self.missing = True if not faked: self.SetContents(b'') diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 9f4717e4ea..5f6def2287 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -51,8 +51,9 @@ class Entry_mkimage(Entry): self.ReadEntries() def ObtainContents(self): +# Use a non-zero size for any fake files to keep mkimage happy data, input_fname, uniq = self.collect_contents_to_file( -self._mkimage_entries.values(), 'mkimage') +self._mkimage_entries.values(), 'mkimage', 1024) if data is None: return False output_fname = tools.get_output_filename('mkimage-out.%s' % uniq) @@ -73,6 +74,16 @@ class Entry_mkimage(Entry): entry.ReadNode() self._mkimage_entries[entry.name] = entry +def SetAllowMissing(self, allow_missing): +"""Set whether a section allows missing external blobs + +Args: +allow_missing: True if
[PATCH v2 18/25] binman: Update fit to use node instead of subnode
It doesn't make sense to use 'subnode' as a function parameter since it is just a 'node' so far as the function is concerned. Update two functions to use 'node' instead. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 50a9179f9f..e1b056f56e 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -332,7 +332,7 @@ class Entry_fit(Entry_section): return fsw.property(pname, prop.bytes) -def _gen_fdt_nodes(subnode, depth, in_images): +def _gen_fdt_nodes(node, depth, in_images): """Generate FDT nodes This creates one node for each member of self._fdts using the @@ -342,7 +342,7 @@ class Entry_fit(Entry_section): first. Args: -subnode (None): Generator node to process +node (None): Generator node to process depth: Current node depth (0 is the base 'fit' node) in_images: True if this is inside the 'images' node, so that 'data' properties should be generated @@ -350,10 +350,10 @@ class Entry_fit(Entry_section): if self._fdts: # Generate nodes for each FDT for seq, fdt_fname in enumerate(self._fdts): -node_name = subnode.name[1:].replace('SEQ', str(seq + 1)) +node_name = node.name[1:].replace('SEQ', str(seq + 1)) fname = tools.get_input_filename(fdt_fname + '.dtb') with fsw.add_node(node_name): -for pname, prop in subnode.props.items(): +for pname, prop in node.props.items(): val = prop.bytes.replace( b'NAME', tools.to_bytes(fdt_fname)) val = val.replace( @@ -371,7 +371,7 @@ class Entry_fit(Entry_section): else: self.Raise("Generator node requires 'fit,fdt-list' property") -def _gen_node(base_node, subnode, depth, in_images): +def _gen_node(base_node, node, depth, in_images): """Generate nodes from a template This creates one node for each member of self._fdts using the @@ -383,14 +383,14 @@ class Entry_fit(Entry_section): Args: base_node (Node): Base Node of the FIT (with 'description' property) -subnode (Node): Generator node to process +node (Node): Generator node to process depth (int): Current node depth (0 is the base 'fit' node) in_images (bool): True if this is inside the 'images' node, so that 'data' properties should be generated """ -oper = self._get_operation(base_node, subnode) +oper = self._get_operation(base_node, node) if oper == OP_GEN_FDT_NODES: -_gen_fdt_nodes(subnode, depth, in_images) +_gen_fdt_nodes(node, depth, in_images) def _add_node(base_node, depth, node): """Add nodes to the output FIT -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 10/25] binman: Refactor fit to generate output at the end
At present the fit implementation creates the output tree while scanning the FIT description. Then it updates the tree later when the data is known. This works, but is a bit confusing, since it requires mixing the scanning code with the generation code, with a fix-up step at the end. It is actually possible to do this in two phases, one to scan everything and the other to generate the FIT. Thus the FIT is generated in one pass, when everything is known. Update the code accordingly. The only functional change is that the 'data' property for each node are now last instead of first, which is really a more natural position. Update the affected test to deal with this. One wrinkle is that the calculated properties (image-pos, size and offset) are now added before the FIT is generated. so we must filter these out when copying properties from the binman description to the FIT. Most of the change here is splitting out some of the code from the ReadEntries() implementation into _BuildInput(). So despite the large diff, most of the code is the same. It is not feasible to split this patch up, so far as I can tell. Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to refactor fit to generate output at the end tools/binman/etype/fit.py | 178 ++--- tools/binman/ftest.py | 13 +- tools/binman/test/224_fit_bad_oper.dts | 2 - 3 files changed, 109 insertions(+), 84 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 2d4c5f6545..61c72780e9 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -209,6 +209,81 @@ class Entry_fit(Entry_section): return oper def ReadEntries(self): +def _add_entries(base_node, depth, node): +"""Add entries for any nodes that need them + +Args: +base_node: Base Node of the FIT (with 'description' property) +depth: Current node depth (0 is the base 'fit' node) +node: Current node to process + +He we only need to provide binman entries which are used to define +the 'data' for each image. We create an entry_Section for each. +""" +rel_path = node.path[len(base_node.path):] +in_images = rel_path.startswith('/images') +has_images = depth == 2 and in_images +if has_images: +# This node is a FIT subimage node (e.g. "/images/kernel") +# containing content nodes. We collect the subimage nodes and +# section entries for them here to merge the content subnodes +# together and put the merged contents in the subimage node's +# 'data' property later. +entry = Entry.Create(self.section, node, etype='section') +entry.ReadNode() +# The hash subnodes here are for mkimage, not binman. +entry.SetUpdateHash(False) +self._entries[rel_path] = entry + +for subnode in node.subnodes: +_add_entries(base_node, depth + 1, subnode) + +_add_entries(self._node, 0, self._node) + +def BuildSectionData(self, required): +"""Build FIT entry contents + +This adds the 'data' properties to the input ITB (Image-tree Binary) +then runs mkimage to process it. + +Args: +required: True if the data must be present, False if it is OK to +return None + +Returns: +Contents of the section (bytes) +""" +data = self._BuildInput() +uniq = self.GetUniqueName() +input_fname = tools.get_output_filename('%s.itb' % uniq) +output_fname = tools.get_output_filename('%s.fit' % uniq) +tools.write_file(input_fname, data) +tools.write_file(output_fname, data) + +args = {} +ext_offset = self._fit_props.get('fit,external-offset') +if ext_offset is not None: +args = { +'external': True, +'pad': fdt_util.fdt32_to_cpu(ext_offset.value) +} +if self.mkimage.run(reset_timestamp=True, output_fname=output_fname, +**args) is None: +# Bintool is missing; just use empty data as the output +self.record_missing_bintool(self.mkimage) +return tools.get_bytes(0, 1024) + +return tools.read_file(output_fname) + +def _BuildInput(self): +"""Finish the FIT by adding the 'data' properties to it + +Arguments: +fdt: FIT to update + +Returns: +New fdt contents (bytes) +""" def _process_prop(pname, prop): """Process special properties @@ -236,9 +311,15 @@ class Entry_fit(Entry_section): val = val[1:].replace('DEFAULT-SEQ', str(seq + 1)) fsw.property_string(pname, val)
[PATCH v2 16/25] binman: Fix some pylint warnings in fit
Some warnings have crept in, so fix those that are easy to fix. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 50 +++ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 7b0c94dfee..70966028e8 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -2,10 +2,9 @@ # Copyright (c) 2016 Google, Inc # Written by Simon Glass # -# Entry-type module for producing a FIT -# -from collections import defaultdict, OrderedDict +"""Entry-type module for producing a FIT""" + import libfdt from binman.entry import Entry, EntryArg @@ -246,16 +245,16 @@ class Entry_fit(Entry_section): then runs mkimage to process it. Args: -required: True if the data must be present, False if it is OK to -return None +required (bool): True if the data must be present, False if it is OK +to return None Returns: -Contents of the section (bytes) +bytes: Contents of the section """ -data = self._BuildInput() +data = self._build_input() uniq = self.GetUniqueName() -input_fname = tools.get_output_filename('%s.itb' % uniq) -output_fname = tools.get_output_filename('%s.fit' % uniq) +input_fname = tools.get_output_filename(f'{uniq}.itb') +output_fname = tools.get_output_filename(f'{uniq}.fit') tools.write_file(input_fname, data) tools.write_file(output_fname, data) @@ -274,14 +273,14 @@ class Entry_fit(Entry_section): return tools.read_file(output_fname) -def _BuildInput(self): +def _build_input(self): """Finish the FIT by adding the 'data' properties to it Arguments: fdt: FIT to update Returns: -New fdt contents (bytes) +bytes: New fdt contents """ def _process_prop(pname, prop): """Process special properties @@ -303,9 +302,9 @@ class Entry_fit(Entry_section): if not self._fit_default_dt: self.Raise("Generated 'default' node requires default-dt entry argument") if self._fit_default_dt not in self._fdts: -self.Raise("default-dt entry argument '%s' not found in fdt list: %s" % - (self._fit_default_dt, -', '.join(self._fdts))) +self.Raise( +f"default-dt entry argument '{self._fit_default_dt}' " +f"not found in fdt list: {', '.join(self._fdts)}") seq = self._fdts.index(self._fit_default_dt) val = val[1:].replace('DEFAULT-SEQ', str(seq + 1)) fsw.property_string(pname, val) @@ -352,8 +351,8 @@ class Entry_fit(Entry_section): else: if self._fdts is None: if self._fit_list_prop: -self.Raise("Generator node requires '%s' entry argument" % - self._fit_list_prop.value) +self.Raise('Generator node requires ' +f"'{self._fit_list_prop.value}' entry argument") else: self.Raise("Generator node requires 'fit,fdt-list' property") @@ -367,10 +366,10 @@ class Entry_fit(Entry_section): first. Args: -subnode (None): Generator node to process -depth: Current node depth (0 is the base 'fit' node) -in_images: True if this is inside the 'images' node, so that -'data' properties should be generated +subnode (Node): Generator node to process +depth (int): Current node depth (0 is the base 'fit' node) +in_images (bool): True if this is inside the 'images' node, so +that 'data' properties should be generated """ oper = self._get_operation(subnode) if oper == OP_GEN_FDT_NODES: @@ -380,9 +379,10 @@ class Entry_fit(Entry_section): """Add nodes to the output FIT Args: -base_node: Base Node of the FIT (with 'description' property) -depth: Current node depth (0 is the base 'fit' node) -node: Current node to process +base_node (Node): Base Node of the FIT (with 'description' +property) +depth (int): Current node depth (0 is the base 'fit' node) +node (Node): Current node to process There are two cases to deal with: - hash and signature nodes which become part of the FIT @@ -439,7 +439,7 @@ class Entry_fit(Entry_section):
[PATCH v2 17/25] binman: Add a consistent way to report errors with fit
Add a new function to handling reporting errors within a particular subnode of the FIT description. This can be used to make the format of these errors consistent. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/fit.py | 33 + tools/binman/ftest.py | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 70966028e8..50a9179f9f 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -186,11 +186,11 @@ class Entry_fit(Entry_section): def ReadNode(self): super().ReadNode() -def _get_operation(self, subnode): +def _get_operation(self, base_node, node): """Get the operation referenced by a subnode Args: -subnode (Node): Subnode (of the FIT) to check +node (Node): Subnode (of the FIT) to check Returns: int: Operation to perform @@ -198,12 +198,13 @@ class Entry_fit(Entry_section): Raises: ValueError: Invalid operation name """ -oper_name = subnode.props.get('fit,operation') +oper_name = node.props.get('fit,operation') if not oper_name: return OP_GEN_FDT_NODES oper = OPERATIONS.get(oper_name.value) -if not oper: -self.Raise(f"Unknown operation '{oper_name.value}'") +if oper is None: +self._raise(base_node, node, +f"Unknown operation '{oper_name.value}'") return oper def ReadEntries(self): @@ -273,6 +274,20 @@ class Entry_fit(Entry_section): return tools.read_file(output_fname) +def _raise(self, base_node, node, msg): +"""Raise an error with a paticular FIT subnode + +Args: +base_node (Node): Base Node of the FIT (with 'description' property) +node (Node): FIT subnode containing the error +msg (str): Message to report + +Raises: +ValueError, as requested +""" +rel_path = node.path[len(base_node.path) + 1:] +self.Raise(f"subnode '{rel_path}': {msg}") + def _build_input(self): """Finish the FIT by adding the 'data' properties to it @@ -356,7 +371,7 @@ class Entry_fit(Entry_section): else: self.Raise("Generator node requires 'fit,fdt-list' property") -def _gen_node(subnode, depth, in_images): +def _gen_node(base_node, subnode, depth, in_images): """Generate nodes from a template This creates one node for each member of self._fdts using the @@ -366,12 +381,14 @@ class Entry_fit(Entry_section): first. Args: +base_node (Node): Base Node of the FIT (with 'description' +property) subnode (Node): Generator node to process depth (int): Current node depth (0 is the base 'fit' node) in_images (bool): True if this is inside the 'images' node, so that 'data' properties should be generated """ -oper = self._get_operation(subnode) +oper = self._get_operation(base_node, subnode) if oper == OP_GEN_FDT_NODES: _gen_fdt_nodes(subnode, depth, in_images) @@ -412,7 +429,7 @@ class Entry_fit(Entry_section): elif self.GetImage().generate and subnode.name.startswith('@'): subnode_path = f'{rel_path}/{subnode.name}' entry = self._entries.get(subnode_path) -_gen_node(subnode, depth, in_images) +_gen_node(base_node, subnode, depth, in_images) if entry: del self._entries[subnode_path] else: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 106027d245..16463518aa 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5319,7 +5319,7 @@ fdt fdtmapExtract the devicetree blob from the fdtmap """Check handling of an FDT map when the section cannot be found""" with self.assertRaises(ValueError) as exc: self._DoReadFileDtb('224_fit_bad_oper.dts') -self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", +self.assertIn("Node '/binman/fit': subnode 'images/@fdt-SEQ': Unknown operation 'unknown'", str(exc.exception)) def test_uses_expand_size(self): -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 23/25] rockchip: Support building the all output files in binman
Add the required binman images to replace the Makefile rules which are currently used. This includes subsuming: - tpl/u-boot-tpl-rockchip.bin if TPL is enabled - idbloader.img if either or both of SPL and TPL are enabled - u-boot.itb if SPL_FIT is enabled - u-boot-rockchip.bin if SPL is used, either using u-boot.itb when SPL_FIT is enabled or u-boot.img when it isn't Note that the intermediate files are dropped with binman, since it producing everything in one pass. This means that tpl/u-boot-tpl-rockchip.bin is not created, for example. Note that for some 32-bit rk3288 boards, rockchip-optee.dtsi is included. Signed-off-by: Simon Glass --- Changes in v2: - Rename op-tee to tee-os - Drop use of .itb2 arch/arm/dts/rockchip-u-boot.dtsi | 84 ++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index eae3ee715d..64e4466489 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -17,13 +17,93 @@ filename = "u-boot-rockchip.bin"; pad-byte = <0xff>; - blob { - filename = "idbloader.img"; +#ifdef CONFIG_TPL + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; + + u-boot-tpl { + }; + }; + + u-boot-spl { }; +#elif defined(CONFIG_SPL) /* SPL only */ + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; + + u-boot-spl { + }; + }; +#endif +#if defined(CONFIG_SPL_FIT) && defined(CONFIG_ARM64) + fit: fit { + description = "FIT image for U-Boot with bl31 (TF-A)"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + fit,external-offset = ; + images { + u-boot { + description = "U-Boot (64-bit)"; + type = "standalone"; + os = "U-Boot"; + arch = "arm64"; + compression = "none"; + load = ; + u-boot-nodtb { + }; + }; + @atf-SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; + @tee-SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + tee-os { + }; + }; + + @fdt-SEQ { + description = "fdt-NAME"; + compression = "none"; + type = "flat_dt"; + }; + }; + + configurations { + default = "@config-DEFAULT-SEQ"; + @config-SEQ { + description = "NAME.dtb"; + fdt = "fdt-SEQ"; + firmware = "u-boot"; + fit,loadables; + }; + }; + }; +#else u-boot-img { offset = ; }; +#endif /* CONFIG_ARM64 */ }; }; #endif -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 20/25] binman: Support splitting an ELF file into multiple nodes
Some boards need to load an ELF file using the 'loadables' property, but the file has segments at different memory addresses. This means that it cannot be supplied as a flat binary. Allow generating a separate node in the FIT for each segment in the ELF, with a different load address for each. Also add checks that the fit,xxx directives are valid. Signed-off-by: Simon Glass --- Changes in v2: - Rewrite this to use the new FIT entry-type implementation - Rename op-tee to tee-os tools/binman/entries.rst | 146 tools/binman/etype/fit.py| 230 ++- tools/binman/ftest.py| 147 tools/binman/test/226_fit_split_elf.dts | 67 ++ tools/binman/test/227_fit_bad_dir.dts| 9 + tools/binman/test/228_fit_bad_dir_config.dts | 9 + 6 files changed, 598 insertions(+), 10 deletions(-) create mode 100644 tools/binman/test/226_fit_split_elf.dts create mode 100644 tools/binman/test/227_fit_bad_dir.dts create mode 100644 tools/binman/test/228_fit_bad_dir_config.dts diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 484cde5c80..a915f64d46 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -612,6 +612,9 @@ gen-fdt-nodes Generate FDT nodes as above. This is the default if there is no `fit,operation` property. +split-elf +Split an ELF file into a separate node for each segment. + Generating nodes from an FDT list (gen-fdt-nodes) ~ @@ -655,6 +658,149 @@ for each of your two files. Note that if no devicetree files are provided (with '-a of-list' as above) then no nodes will be generated. +Generating nodes from an ELF file (split-elf) +~ + +This uses the node as a template to generate multiple nodes. The following +special properties are available: + +split-elf +Split an ELF file into a separate node for each segment. This uses the +node as a template to generate multiple nodes. The following special +properties are available: + +fit,load +Generates a `load = <...>` property with the load address of the +segmnet + +fit,entry +Generates a `entry = <...>` property with the entry address of the +ELF. This is only produced for the first entry + +fit,data +Generates a `data = <...>` property with the contents of the segment + +fit,loadables +Generates a `loadable = <...>` property with a list of the generated +nodes (including all nodes if this operation is used multiple times) + + +Here is an example showing ATF, TEE and a device tree all combined:: + +fit { +description = "test-desc"; +#address-cells = <1>; +fit,fdt-list = "of-list"; + +images { +u-boot { +description = "U-Boot (64-bit)"; +type = "standalone"; +os = "U-Boot"; +arch = "arm64"; +compression = "none"; +load = ; +u-boot-nodtb { +}; +}; +@fdt-SEQ { +description = "fdt-NAME.dtb"; +type = "flat_dt"; +compression = "none"; +}; +@atf-SEQ { +fit,operation = "split-elf"; +description = "ARM Trusted Firmware"; +type = "firmware"; +arch = "arm64"; +os = "arm-trusted-firmware"; +compression = "none"; +fit,load; +fit,entry; +fit,data; + +atf-bl31 { +}; +}; + +@tee-SEQ { +fit,operation = "split-elf"; +description = "TEE"; +type = "tee"; +arch = "arm64"; +os = "tee"; +compression = "none"; +fit,load; +fit,entry; +fit,data; + +tee-os { +}; +}; +}; + +configurations { +default = "@config-DEFAULT-SEQ"; +@config-SEQ { +description = "conf-NAME.dtb"; +fdt = "fdt-SEQ"; +firmware = "u-boot"; +fit,loadables; +}; +}; +}; + +If ATF-BL31 is available, this generates a node for each segment in the +ELF file, for example:: + +images { +atf-1 { +data = <...contents of first segment...>; +data-offset = <0x>; +entry = <0x0004>; +load = <0x0004>; +compression = "none"; +os = "arm-trusted-firmware"; +arch = "arm64"; +type = "firmware"; +description = "ARM Trusted Firmware"; +}; +atf-2 { +data = <...con
[PATCH v2 22/25] rockchip: Include binman script in 64-bit boards
Include the rockchip-u-boot.dtsi file with 64-bit boards and enable binman so that these boards can also use it, rather than using special Makefile rules and scripts. This does not change the Makefile nor remove any scripts, but sets it up so that this is possible. Signed-off-by: Simon Glass --- (no changes since v1) arch/arm/dts/px30-u-boot.dtsi | 2 ++ arch/arm/dts/rk3308-u-boot.dtsi| 2 ++ arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 2 ++ arch/arm/dts/rk3328-u-boot.dtsi| 2 ++ arch/arm/dts/rk3368-u-boot.dtsi| 1 + arch/arm/dts/rk3399-u-boot.dtsi| 5 +++-- arch/arm/dts/rk3568-u-boot.dtsi| 2 ++ arch/arm/mach-rockchip/Kconfig | 6 ++ 8 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/px30-u-boot.dtsi b/arch/arm/dts/px30-u-boot.dtsi index f102b2aef4..462eaf68f8 100644 --- a/arch/arm/dts/px30-u-boot.dtsi +++ b/arch/arm/dts/px30-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3308-u-boot.dtsi b/arch/arm/dts/rk3308-u-boot.dtsi index 4bfad31fba..ab5bfc2ce9 100644 --- a/arch/arm/dts/rk3308-u-boot.dtsi +++ b/arch/arm/dts/rk3308-u-boot.dtsi @@ -3,6 +3,8 @@ *(C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi index 95f2652494..16c33735eb 100644 --- a/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi +++ b/arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi @@ -3,6 +3,8 @@ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH */ +#include "rockchip-u-boot.dtsi" + / { chosen { u-boot,spl-boot-order = &sdmmc; diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi index 1633558264..d4a7540a92 100644 --- a/arch/arm/dts/rk3328-u-boot.dtsi +++ b/arch/arm/dts/rk3328-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3368-u-boot.dtsi b/arch/arm/dts/rk3368-u-boot.dtsi index 2767c2678d..b37da4e851 100644 --- a/arch/arm/dts/rk3368-u-boot.dtsi +++ b/arch/arm/dts/rk3368-u-boot.dtsi @@ -3,6 +3,7 @@ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH */ +#include "rockchip-u-boot.dtsi" #include / { diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi index 716b9a433a..fd4150e3f0 100644 --- a/arch/arm/dts/rk3399-u-boot.dtsi +++ b/arch/arm/dts/rk3399-u-boot.dtsi @@ -60,8 +60,9 @@ }; -#ifdef CONFIG_ROCKCHIP_SPI_IMAGE &binman { + multiple-images; +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE rom { filename = "u-boot.rom"; size = <0x40>; @@ -81,8 +82,8 @@ fdtmap { }; }; -}; #endif +}; &cru { u-boot,dm-pre-reloc; diff --git a/arch/arm/dts/rk3568-u-boot.dtsi b/arch/arm/dts/rk3568-u-boot.dtsi index 5a80dda275..fa9b6ae23b 100644 --- a/arch/arm/dts/rk3568-u-boot.dtsi +++ b/arch/arm/dts/rk3568-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2021 Rockchip Electronics Co., Ltd */ +#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &sdhci; diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 92f35309e4..c8df65980f 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -15,6 +15,7 @@ config ROCKCHIP_PX30 select DEBUG_UART_BOARD_INIT imply ROCKCHIP_COMMON_BOARD imply SPL_ROCKCHIP_COMMON_BOARD + imply BINMAN help The Rockchip PX30 is a ARM-based SoC with a quad-core Cortex-A35 including NEON and GPU, Mali-400 graphics, several DDR3 options @@ -146,6 +147,7 @@ config ROCKCHIP_RK3308 imply SPL_SERIAL imply TPL_SERIAL imply SPL_SEPARATE_BSS + imply BINMAN help The Rockchip RK3308 is a ARM-based Soc which embedded with quad Cortex-A35 and highly integrated audio interfaces. @@ -167,6 +169,7 @@ config ROCKCHIP_RK3328 select ENABLE_ARM_SOC_BOOT0_HOOK select DEBUG_UART_BOARD_INIT select SYS_NS16550 + imply BINMAN help The Rockchip RK3328 is a ARM-based SoC with a quad-core Cortex-A53. including NEON and GPU, 1MB L2 cache, Mali-T7 graphics, two @@ -186,6 +189,7 @@ config ROCKCHIP_RK3368 imply SPL_SERIAL imply TPL_SERIAL imply TPL_ROCKCHIP_COMMON_BOARD + imply BINMAN help The Rockchip RK3368 is a ARM-based SoC with a octa-core (organised into a big and little cluster with 4 cores each) Cortex-A53 including @@ -244,6 +248,7 @@ conf
[PATCH v2 13/25] binman: Make fake blobs zero-sized by default
On x86 devices having even a small amount of data can cause an overlap between regions. For example, bayleybay complains when the intel-vga region overlaps with u-boot-ucode: ImagePosOffset Size Name 0080 main-section ff80 0080 intel-descriptor ff800400 0080 intel-me fff0 00098f24 u-boot-with-ucode-ptr fff98f24 1aa0 u-boot-dtb-with-ucode fff9a9d0 0002a000 u-boot-ucode fffb 0080 intel-vga ... It is safer to use an empty file in most cases. Add an option to set the size for those uses that need it. Signed-off-by: Simon Glass --- Changes in v2: - Add a patch to make fake blobs zero-sized by default tools/binman/entry.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 2fb0050da5..e4c0fbe23d 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -988,13 +988,14 @@ features to produce new behaviours. if self.missing: missing_list.append(self) -def check_fake_fname(self, fname): +def check_fake_fname(self, fname, size=0): """If the file is missing and the entry allows fake blobs, fake it Sets self.faked to True if faked Args: fname (str): Filename to check +size (int): Size of fake file to create Returns: tuple: @@ -1004,7 +1005,7 @@ features to produce new behaviours. if self.allow_fake and not pathlib.Path(fname).is_file(): outfname = tools.get_output_filename(os.path.basename(fname)) with open(outfname, "wb") as out: -out.truncate(1024) +out.truncate(size) self.faked = True tout.info(f"Entry '{self._node.path}': Faked file '{outfname}'") return outfname, True -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 08/25] binman: Rename ExpandToLimit to extend_to_limit
The word 'expand' is used for entries which generate subentries. It is also used for entries that can have an '_expanded' version which is used to break out its contents. Rather than talking about expanding an entry's size, use the term 'extending'. It is slightly more precise and avoids the above conflicts. This change renders the old 'expand-size' property invalid, so add an error check for that. Signed-off-by: Simon Glass --- Changes in v2: - Add patch to rename ExpandToLimit to extend_to_limit tools/binman/binman.rst | 2 +- tools/binman/entry.py | 8 +--- tools/binman/etype/section.py | 10 +- tools/binman/ftest.py | 8 tools/binman/test/088_expand_size.dts | 8 tools/binman/test/089_expand_size_bad.dts | 2 +- tools/binman/test/225_expand_size_bad.dts | 10 ++ 7 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 tools/binman/test/225_expand_size_bad.dts diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 0061e43659..85f8337a31 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -480,7 +480,7 @@ image-pos: for each entry. This makes it easy to find out exactly where the entry ended up in the image, regardless of parent sections, etc. -expand-size: +extend-size: Expand the size of this entry to fit available space. This space is only limited by the size of the image/section and the position of the next entry. diff --git a/tools/binman/entry.py b/tools/binman/entry.py index de8526618d..a59eb56f14 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -233,6 +233,8 @@ class Entry(object): """ if 'pos' in self._node.props: self.Raise("Please use 'offset' instead of 'pos'") +if 'expand-size' in self._node.props: +self.Raise("Please use 'extend-size' instead of 'expand-size'") self.offset = fdt_util.GetInt(self._node, 'offset') self.size = fdt_util.GetInt(self._node, 'size') self.orig_offset = fdt_util.GetInt(self._node, 'orig-offset') @@ -260,7 +262,7 @@ class Entry(object): self.align_size) self.align_end = fdt_util.GetInt(self._node, 'align-end') self.offset_unset = fdt_util.GetBool(self._node, 'offset-unset') -self.expand_size = fdt_util.GetBool(self._node, 'expand-size') +self.expand_size = fdt_util.GetBool(self._node, 'extend-size') self.missing_msg = fdt_util.GetString(self._node, 'missing-msg') # This is only supported by blobs and sections at present @@ -772,8 +774,8 @@ features to produce new behaviours. name = '%s.%s' % (node.name, name) return name -def ExpandToLimit(self, limit): -"""Expand an entry so that it ends at the given offset limit""" +def extend_to_limit(self, limit): +"""Extent an entry so that it ends at the given offset limit""" if self.offset + self.size < limit: self.size = limit - self.offset # Request the contents again, since changing the size requires that diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 25159074ba..0cfee5f3e3 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -385,7 +385,7 @@ class Entry_section(Entry): self._PackEntries() if self._sort: self._SortEntries() -self._ExpandEntries() +self._extend_entries() data = self.BuildSectionData(True) self.SetContents(data) @@ -403,17 +403,17 @@ class Entry_section(Entry): offset = entry.Pack(offset) return offset -def _ExpandEntries(self): -"""Expand any entries that are permitted to""" +def _extend_entries(self): +"""Extend any entries that are permitted to""" exp_entry = None for entry in self._entries.values(): if exp_entry: -exp_entry.ExpandToLimit(entry.offset) +exp_entry.extend_to_limit(entry.offset) exp_entry = None if entry.expand_size: exp_entry = entry if exp_entry: -exp_entry.ExpandToLimit(self.size) +exp_entry.extend_to_limit(self.size) def _SortEntries(self): """Sort entries by offset""" diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 8f00db6945..62528ccbfa 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5321,6 +5321,14 @@ fdt fdtmapExtract the devicetree blob from the fdtmap self.assertIn("Node '/binman/fit': Unknown operation 'unknown'", str(exc.exception)) +def test_uses_expand_size(self): +"""Test that the 'expand-size' property cannot be used anymore""" +with self.assertRaises(ValueError) as e: + data =
[PATCH v2 09/25] binman: Rename ExpandEntries to gen_entries
Leave the 'expand' term for use by entry types which have an expanded version of themselves. Rename this method to indicate that it generates subentries. Signed-off-by: Simon Glass --- Changes in v2: - Add patch to rename ExpandEntries to gen_entries tools/binman/control.py | 2 +- tools/binman/entry.py| 4 ++-- tools/binman/etype/blob_phase.py | 2 +- tools/binman/etype/files.py | 2 +- tools/binman/etype/section.py| 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/binman/control.py b/tools/binman/control.py index a179f78129..be2b422e62 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -501,7 +501,7 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): # entry offsets remain the same. for image in images.values(): image.CollectBintools() -image.ExpandEntries() +image.gen_entries() if update_fdt: image.AddMissingProperties(True) image.ProcessFdt(dtb) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index a59eb56f14..90a40bb274 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -284,8 +284,8 @@ class Entry(object): """ return {} -def ExpandEntries(self): -"""Expand out entries which produce other entries +def gen_entries(self): +"""Allow entries to generate other entries Some entries generate subnodes automatically, from which sub-entries are then created. This method allows those to be added to the binman diff --git a/tools/binman/etype/blob_phase.py b/tools/binman/etype/blob_phase.py index ed25e467a1..aba93b759b 100644 --- a/tools/binman/etype/blob_phase.py +++ b/tools/binman/etype/blob_phase.py @@ -39,7 +39,7 @@ class Entry_blob_phase(Entry_section): self.dtb_file = dtb_file self.bss_pad = bss_pad -def ExpandEntries(self): +def gen_entries(self): """Create the subnodes""" names = [self.root_fname + '-nodtb', self.root_fname + '-dtb'] if self.bss_pad: diff --git a/tools/binman/etype/files.py b/tools/binman/etype/files.py index 0650a69c55..210a16d671 100644 --- a/tools/binman/etype/files.py +++ b/tools/binman/etype/files.py @@ -46,7 +46,7 @@ class Entry_files(Entry_section): self._require_matches = fdt_util.GetBool(self._node, 'require-matches') -def ExpandEntries(self): +def gen_entries(self): files = tools.get_input_filename_glob(self._pattern) if self._require_matches and not files: self.Raise("Pattern '%s' matched no files" % self._pattern) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 0cfee5f3e3..f2d401d95b 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -233,10 +233,10 @@ class Entry_section(Entry): todo) return True -def ExpandEntries(self): -super().ExpandEntries() +def gen_entries(self): +super().gen_entries() for entry in self._entries.values(): -entry.ExpandEntries() +entry.gen_entries() def AddMissingProperties(self, have_image_pos): """Add new properties to the device tree as needed for this entry""" -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 07/25] binman: Tweak collect_contents_to_file() and docs
Update the return value of this function, fix the 'create' typo and update the documentation for clarity. Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to tweak collect_contents_to_file() and docs tools/binman/binman.rst | 25 +++-- tools/binman/entry.py | 8 tools/binman/etype/mkimage.py | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 771645380e..0061e43659 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1375,18 +1375,20 @@ Some entry types deal with data obtained from others. For example, }; This shows mkimage being passed a file consisting of SPL and U-Boot proper. It -is create by calling `Entry.collect_contents_to_file()`. Note that in this case, -the data is passed to mkimage for processing but does not appear separately in -the image. It may not appear at all, depending on what mkimage does. The -contents of the `mkimage` entry are entirely dependent on the processing done -by the entry, with the provided subnodes (`u-boot-spl` and `u-boot`) simply -providing the input data for that processing. +is created by calling `Entry.collect_contents_to_file()`. Note that in this +case, the data is passed to mkimage for processing but does not appear +separately in the image. It may not appear at all, depending on what mkimage +does. The contents of the `mkimage` entry are entirely dependent on the +processing done by the entry, with the provided subnodes (`u-boot-spl` and +`u-boot`) simply providing the input data for that processing. Note that `Entry.collect_contents_to_file()` simply concatenates the data from the different entries together, with no control over alignment, etc. Another approach is to subclass `Entry_section` so that those features become available, such as `size` and `pad-byte`. Then the contents of the entry can be obtained by -calling `BuildSectionData()`. +calling `super().BuildSectionData()` in the entry's BuildSectionData() +implementation to get the input data, then write it to a file and process it +however is desired. There are other ways to obtain data also, depending on the situation. If the entry type is simply signing data which exists elsewhere in the image, then @@ -1396,6 +1398,7 @@ is used by `Entry_vblock`, for example:: u_boot: u-boot { }; + vblock { content = <&u_boot &dtb>; keyblock = "firmware.keyblock"; @@ -1440,9 +1443,11 @@ The `soc-fw` node is a `blob-ext` (i.e. it reads in a named binary file) whereas a known blob type. When adding new entry types you are encouraged to use subnodes to provide the -data for processing, unless the `content` approach is more suitable. Ad-hoc -properties and other methods of obtaining data are discouraged, since it adds to -confusion for users. +data for processing, unless the `content` approach is more suitable. Consider +whether the input entries are contained within (or consumed by) the entry, vs +just being 'referenced' by the entry. In the latter case, the `content` approach +makes more sense. Ad-hoc properties and other methods of obtaining data are +discouraged, since it adds to confusion for users. History / Credits - diff --git a/tools/binman/entry.py b/tools/binman/entry.py index bf68a85b24..de8526618d 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -1136,16 +1136,16 @@ features to produce new behaviours. Returns: Tuple: -bytes: Concatenated data from all the entries (or False) -str: Filename of file written (or False if no data) -str: Unique portion of filename (or False if no data) +bytes: Concatenated data from all the entries (or None) +str: Filename of file written (or None if no data) +str: Unique portion of filename (or None if no data) """ data = b'' for entry in entries: # First get the input data and put it in a file. If not available, # try later. if not entry.ObtainContents(): -return False, False, False +return None, None, None data += entry.GetData() uniq = self.GetUniqueName() fname = tools.get_output_filename(f'{prefix}.{uniq}') diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 8e74ebb9c0..c28141ff69 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -53,7 +53,7 @@ class Entry_mkimage(Entry): def ObtainContents(self): data, input_fname, uniq = self.collect_contents_to_file( self._mkimage_entries.values(), 'mkimage') -if data is False: +if data is None: return False output_fname = tools.get_output_filename('mkimage-out.%s' % uniq) if
[PATCH v2 06/25] elf: Rename load_segments() and module failure
Rename this function to make it clear that it only reads loadable segments. Also update the error for missing module to better match the message emitted by Python. Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to rename load_segments() and module failure tools/binman/elf.py | 6 +++--- tools/binman/elf_test.py | 18 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/binman/elf.py b/tools/binman/elf.py index 5e7d6ae7b9..016e9b2885 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -105,7 +105,7 @@ def GetSymbolFileOffset(fname, patterns): return addr - seg['p_vaddr'] + seg['p_offset'] if not ELF_TOOLS: -raise ValueError('Python elftools package is not available') +raise ValueError("Python: No module named 'elftools'") syms = {} with open(fname, 'rb') as fd: @@ -371,7 +371,7 @@ def UpdateFile(infile, outfile, start_sym, end_sym, insert): tools.write_file(outfile, newdata) tout.info('Written to offset %#x' % syms[start_sym].offset) -def read_segments(data): +def read_loadable_segments(data): """Read segments from an ELF file Args: @@ -389,7 +389,7 @@ def read_segments(data): ValueError: elftools is not available """ if not ELF_TOOLS: -raise ValueError('Python elftools package is not available') +raise ValueError("Python: No module named 'elftools'") with io.BytesIO(data) as inf: try: elf = ELFFile(inf) diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index a67915bda6..4c881a9755 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -244,7 +244,7 @@ class TestElf(unittest.TestCase): fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: elf.GetSymbolFileOffset(fname, ['embed_start', 'embed_end']) -self.assertIn('Python elftools package is not available', +self.assertIn("Python: No module named 'elftools'", str(e.exception)) finally: elf.ELF_TOOLS = old_val @@ -258,31 +258,31 @@ class TestElf(unittest.TestCase): offset = elf.GetSymbolFileOffset(fname, ['missing_sym']) self.assertEqual({}, offset) -def test_read_segments(self): -"""Test for read_segments()""" +def test_read_loadable_segments(self): +"""Test for read_loadable_segments()""" if not elf.ELF_TOOLS: self.skipTest('Python elftools not available') fname = self.ElfTestFile('embed_data') -segments, entry = elf.read_segments(tools.read_file(fname)) +segments, entry = elf.read_loadable_segments(tools.read_file(fname)) def test_read_segments_fail(self): -"""Test for read_segments() without elftools""" +"""Test for read_loadable_segments() without elftools""" try: old_val = elf.ELF_TOOLS elf.ELF_TOOLS = False fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: -elf.read_segments(tools.read_file(fname)) -self.assertIn('Python elftools package is not available', +elf.read_loadable_segments(tools.read_file(fname)) +self.assertIn("Python: No module named 'elftools'", str(e.exception)) finally: elf.ELF_TOOLS = old_val def test_read_segments_bad_data(self): -"""Test for read_segments() with an invalid ELF file""" +"""Test for read_loadable_segments() with an invalid ELF file""" fname = self.ElfTestFile('embed_data') with self.assertRaises(ValueError) as e: -elf.read_segments(tools.get_bytes(100, 100)) +elf.read_loadable_segments(tools.get_bytes(100, 100)) self.assertIn('Magic number does not match', str(e.exception)) -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 05/25] dtoc: Tidy up implementation of AddStringList()
Refactor this to avoid a loop. Also add a test for an empty string. Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to tidy up implementaiton of AddStringList() tools/dtoc/fdt.py | 4 +--- tools/dtoc/test_fdt.py | 6 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index c16909a876..d933972918 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -516,9 +516,7 @@ class Node: Returns: Prop added """ -out = b'' -for string in val: -out += bytes(string, 'utf-8') + b'\0' +out = b'\0'.join(bytes(s, 'utf-8') for s in val) + b'\0' if val else b'' return self.AddData(prop_name, out) def AddInt(self, prop_name, val): diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index c2013b9289..d33328c392 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -550,6 +550,12 @@ class TestProp(unittest.TestCase): data = self.fdt.getprop(self.node.Offset(), 'stringlist') self.assertEqual(b'123\x00456\0', data) +val = [] +self.node.AddStringList('stringlist', val) +self.dtb.Sync(auto_resize=True) +data = self.fdt.getprop(self.node.Offset(), 'stringlist') +self.assertEqual(b'', data) + def test_delete_node(self): """Test deleting a node""" old_offset = self.fdt.path_offset('/spl-test') -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 03/25] moveconfig: Use re.fullmatch() to avoid extra check
Simplify the code by using the available function. Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to use re.fullmatch() to avoid extra check tools/moveconfig.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index dea60f4661..4b0e2e250b 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1610,8 +1610,8 @@ def defconfig_matches(configs, re_match): bool: True if any CONFIG matches the regex """ for cfg in configs: -m_cfg = re_match.match(cfg) -if m_cfg and m_cfg.span()[1] == len(cfg): +m_cfg = re_match.fullmatch(cfg) +if m_cfg: return True return False -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 02/25] moveconfig: Remove remove_defconfig()
This is not necessary if simpler code is used. Use the split function and drop the unnecessary [] Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to remove remove_defconfig() tools/moveconfig.py | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index cff1e30658..dea60f4661 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -94,17 +94,6 @@ SIZES = { RE_REMOVE_DEFCONFIG = re.compile(r'(.*)_defconfig') ### helper functions ### -def remove_defconfig(defc): -"""Drop the _defconfig suffix on a string - -Args: -defc (str): String to convert - -Returns: -str: string with the '_defconfig' suffix removed -""" -return RE_REMOVE_DEFCONFIG.match(defc)[1] - def check_top_directory(): """Exit if we are not at the top of source directory.""" for fname in 'README', 'Licenses': @@ -1671,7 +1660,7 @@ def do_find_config(config_list): print(f"Error: Not in Kconfig: %s" % ' '.join(adhoc)) else: print(f'{len(out)} matches') -print(' '.join([remove_defconfig(item) for item in out])) +print(' '.join(item.split('_defconfig')[0] for item in out)) def prefix_config(cfg): -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 04/25] spl: Correct Kconfig help for TPL_BINMAN_SYMBOLS
Fix the help which should refer to TPL, not SPL. Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to correct Kconfig help for TPL_BINMAN_SYMBOLS common/spl/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 9418d37b2e..dc319adeac 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1334,16 +1334,16 @@ config TPL_SIZE_LIMIT If this value is zero, it is ignored. config TPL_BINMAN_SYMBOLS - bool "Declare binman symbols in SPL" + bool "Declare binman symbols in TPL" depends on SPL_FRAMEWORK && BINMAN default y help - This enables use of symbols in TPL which refer to U-Boot, enabling SPL + This enables use of symbols in TPL which refer to U-Boot, enabling TPL to obtain the location of U-Boot simply by calling spl_get_image_pos() and spl_get_image_size(). For this to work, you must have a U-Boot image in the binman image, so - binman can update SPL with the location of it. + binman can update TPL with the location of it. config TPL_FRAMEWORK bool "Support TPL based upon the common SPL framework" -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 01/25] dtoc: Make GetArgs() more flexible
At present it is not possible to have arguments whic include spaces. Update the function to only split the args if the property is a single string. This is a bit inconsistent, but might still be useful. Signed-off-by: Simon Glass Suggested-by: Alper Nebi Yasak --- Changes in v2: - Add new patch to make GetArgs() more flexible tools/dtoc/fdt_util.py | 8 ++-- tools/dtoc/test/dtoc_test_simple.dts | 2 ++ tools/dtoc/test_fdt.py | 6 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index c82e7747aa..57550624bb 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -192,8 +192,12 @@ def GetArgs(node, propname): value = GetStringList(node, propname) else: value = [] -lists = [v.split() for v in value] -args = [x for l in lists for x in l] +if not value: +args = [] +elif len(value) == 1: +args = value[0].split() +else: +args = value return args def GetBool(node, propname, default=False): diff --git a/tools/dtoc/test/dtoc_test_simple.dts b/tools/dtoc/test/dtoc_test_simple.dts index 2d321fb034..aef07efeae 100644 --- a/tools/dtoc/test/dtoc_test_simple.dts +++ b/tools/dtoc/test/dtoc_test_simple.dts @@ -63,5 +63,7 @@ orig-node { orig = <1 23 4>; args = "-n first", "second", "-p", "123,456", "-x"; + args2 = "a space", "there"; + args3 = "-n first second -p 123,456 -x"; }; }; diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 576d65b97e..c2013b9289 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -659,8 +659,12 @@ class TestFdtUtil(unittest.TestCase): ['multi-word', 'message'], fdt_util.GetArgs(self.node, 'stringarray')) self.assertEqual([], fdt_util.GetArgs(self.node, 'boolval')) -self.assertEqual(['-n', 'first', 'second', '-p', '123,456', '-x'], +self.assertEqual(['-n first', 'second', '-p', '123,456', '-x'], fdt_util.GetArgs(node, 'args')) +self.assertEqual(['a space', 'there'], + fdt_util.GetArgs(node, 'args2')) +self.assertEqual(['-n', 'first', 'second', '-p', '123,456', '-x'], + fdt_util.GetArgs(node, 'args3')) with self.assertRaises(ValueError) as exc: fdt_util.GetArgs(self.node, 'missing') self.assertIn( -- 2.35.1.574.g5d30c73bfb-goog
[PATCH v2 00/25] binman: rockchip: Migrate from rockchip SPL_FIT_GENERATOR script
At present rockchip 64-bit boards make use of a FIT-generator script written in Python. The script supports splitting an ELF file into several 'loadable' nodes in the FIT. Binman does not current support this feature. This series adds binman support for ELF splitting. This works by adding a new 'fit,operation' property to the FIT subnodes, allowing this new way of generating nodes. Some other fixes and improvements are needed along the way. A new, common binman description is added for 64-bit boards which includes the required u-boot.itb file. The existing script is removed, so that only a few zynq boards are now using a SPL_FIT_GENERATOR script: avnet_ultrazedev_cc_v1_0_ultrazedev_som_v1_0 xilinx_zynqmp_virt Migration of those is hopefully in progress. Note however that tools/k3_fit_atf.sh remains, used by a few boards that enable CONFIG_TI_SECURE_DEVICE so this series is copied there too: am335x_hs_evm am335x_hs_evm_uart am43xx_hs_evm am57xx_hs_evm am57xx_hs_evm_usb am65x_hs_evm_a53 am65x_hs_evm_r5 dra7xx_hs_evm dra7xx_hs_evm_usb j721e_hs_evm_a72 j721e_hs_evm_r5 k2e_hs_evm k2g_hs_evm k2hk_hs_evm k2l_hs_evm Ivan Mikhaylov has sent a patch to help with these, but I need to take a look at the testing side. In any case they should really be using binman for the image generation. Changes in v2: - Add new patch to make GetArgs() more flexible - Add new patch to remove remove_defconfig() - Add new patch to use re.fullmatch() to avoid extra check - Add new patch to correct Kconfig help for TPL_BINMAN_SYMBOLS - Add new patch to tidy up implementaiton of AddStringList() - Add new patch to rename load_segments() and module failure - Add new patch to tweak collect_contents_to_file() and docs - Add patch to rename ExpandToLimit to extend_to_limit - Add patch to rename ExpandEntries to gen_entries - Add new patch to refactor fit to generate output at the end - Add a patch to change how faked blobs are created - Add a patch to make fake blobs zero-sized by default - Add a patch to allow mkimage to use a non-zero fake-blob size - Rewrite this to use the new FIT entry-type implementation - Rename op-tee to tee-os - Rename op-tee to tee-os - Drop use of .itb2 - Drop patches previously applied - Add various suggestions from Alper Nebi Yasak - Add patches to refactor binman's FIT support Simon Glass (25): dtoc: Make GetArgs() more flexible moveconfig: Remove remove_defconfig() moveconfig: Use re.fullmatch() to avoid extra check spl: Correct Kconfig help for TPL_BINMAN_SYMBOLS dtoc: Tidy up implementaiton of AddStringList() elf: Rename load_segments() and module failure binman: Tweak collect_contents_to_file() and docs binman: Rename ExpandToLimit to extend_to_limit binman: Rename ExpandEntries to gen_entries binman: Refactor fit to generate output at the end binman: Rename tools parameter to btools binman: Change how faked blobs are created binman: Make fake blobs zero-sized by default binman: Allow mkimage to use a non-zero fake-blob size binman: Read the fit entries only once binman: Fix some pylint warnings in fit binman: Add a consistent way to report errors with fit binman: Update fit to use node instead of subnode binman: Keep a separate list of entries for fit binman: Support splitting an ELF file into multiple nodes rockchip: evb-rk3288: Drop raw-image support rockchip: Include binman script in 64-bit boards rockchip: Support building the all output files in binman rockchip: Convert all boards to use binman rockchip: Drop the FIT generator script Makefile | 42 +- arch/arm/dts/px30-u-boot.dtsi| 2 + arch/arm/dts/rk3308-u-boot.dtsi | 2 + arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 2 + arch/arm/dts/rk3328-u-boot.dtsi | 2 + arch/arm/dts/rk3368-u-boot.dtsi | 1 + arch/arm/dts/rk3399-u-boot.dtsi | 5 +- arch/arm/dts/rk3568-u-boot.dtsi | 2 + arch/arm/dts/rockchip-u-boot.dtsi| 84 +++- arch/arm/mach-rockchip/Kconfig | 6 + arch/arm/mach-rockchip/make_fit_atf.py | 240 - boot/Kconfig | 3 +- common/spl/Kconfig | 6 +- configs/evb-rk3288_defconfig | 1 + tools/binman/binman.rst | 30 +- tools/binman/control.py | 2 +- tools/binman/elf.py | 6 +- tools/binman/elf_test.py | 18 +- tools/binman/entries.rst | 146 ++ tools/binman/entry.py| 49 +- tools/binman/etype/_testing.py | 2 +- tools/binman/etype/blob.py | 10 +- tools/binman/etype/blob_ext_list.py | 2 +- tools/binman/etype/blob_phase.py | 2 +- tools/binman/etype/files.py
Re: [PATCH] Makefile: Sort u-boot-initial-env output
Hi Christoph, On Wed, 23 Feb 2022 at 02:33, Christoph Niedermaier wrote: > > For a better overview and better comparison sort the initial > environment as the get_default_env.sh script does. We need > to preserve the order of equal variable names. So only sort > by the variable name, and disable the last-resort comparison. > Also remove blank lines before sorting. > > Signed-off-by: Christoph Niedermaier > Cc: Stefano Babic > Cc: Simon Glass > Cc: Marek Behún > To: u-boot@lists.denx.de > --- > Makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Does this sort the text environment too? > > diff --git a/Makefile b/Makefile > index 4b152249ca..67ed4edc1a 100644 > --- a/Makefile > +++ b/Makefile > @@ -2439,7 +2439,8 @@ endif > > quiet_cmd_genenv = GENENV $@ > cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ > env/common.o; \ > - sed --in-place -e 's/\x00/\x0A/g' $@ > + sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' > $@; \ > + sort --field-separator== -k1,1 --stable $@ -o $@ > > u-boot-initial-env: u-boot.bin > $(call if_changed,genenv) > -- > 2.11.0 > Regards, Simon
Re: [PATCH v2 4/5] binman: Convert FIT entry type to a subclass of Section entry type
Hi Alper, On Tue, 22 Feb 2022 at 11:58, Alper Nebi Yasak wrote: > > On 21/02/2022 07:40, Simon Glass wrote: > > On Sat, 19 Feb 2022 at 08:53, Simon Glass wrote: > >> On Fri, 18 Feb 2022 at 10:34, Alper Nebi Yasak > >> wrote: > >>> I can reproduce this and tried a few things, but more issues just kept > >>> popping up (outside u-boot as well). I got it to a point where the > >>> command re-packs the FIT and the image but quite wrongly. The offset and > >>> image-pos properties get added in the FIT, and the image main-section > >>> just concatenates all entries without regard to set offsets. I'll > >>> need more time to work those out, then to add tests and send patches. > >> > >> I am going to try to merge my fit generator series today. > >> > >> One issue I notice is that the conversion to use entry_Section changes > >> the contents of the self._fit_entries dict. Before it was keyed by > >> relative path, but entry_section keys self._entries by node name. > > Yeah, this causes an error in image.FindEntryPath() while trying to > replace e.g. "/fit@0x28/images/u-boot" since there is no "images" > entry in the FIT. Changing the key to the node name works, but then the > "binman replace" invocation needs to use e.g. "/fit@0x28/u-boot". > > >> > >> We may need to split it up. I will see if I can at least merge my > >> series, which should not make things any worse, then see if I can come > >> up with ideas. > >> > >> Thanks for the diff. > > > > I did a bit more fiddling and pushed a tree to u-boot-dm/fit-working > > > > It refactors the fit implementation to separate scanning from emitting > > the tree and I think this might help quite a bit. I'll send out the > > series when I get a chance in the next few days or so. > > I've also managed to somewhat fix the rest of the issues I wrote, so now > I can replace a FIT entry with a modified one (having a different u-boot > file), or replace a subentry of the FIT with an arbitrary file. > > I couldn't look at your new version much but I'll try to see how good my > fixes apply on top of it, will probably take me longer to patchify things. OK I'm going to send a new series with (most of) your suggested fixes a new patches, then my refactoring. Just need to get things through CI. Regards, Simon
Re: [PATCH] arm: pdu001: Fix early debugging UART
On Tue, 15 Feb 2022 at 07:27, Felix Brack wrote: > > The changes from commit 0dba45864b2a ("arm: Init the debug UART") > prevent the early debug UART from being initialized correctly. > To fix this we not just configure the pin multiplexer but add setting up > early clocks. > > Signed-off-by: Felix Brack > --- > > board/eets/pdu001/Makefile | 6 +- > board/eets/pdu001/board.c | 2 ++ > 2 files changed, 3 insertions(+), 5 deletions(-) Reviewed-by: Simon Glass
Re: [PATCH 03/24] spl: x86: Correct the binman symbols for SPL
Hi Alper, On Tue, 15 Feb 2022 at 04:52, Alper Nebi Yasak wrote: > > On 08/02/2022 21:49, Simon Glass wrote: > > These symbols are incorrect, meaning that binman cannot find the > > associated entry. This leads to errors like: > > > > binman: Section '/binman/simple-bin': Symbol '_binman_spl_prop_size' > >in entry '/binman/simple-bin/u-boot-spl/u-boot-spl-nodtb': > >Entry 'spl' not found in list (mkimage,u-boot-spl-nodtb, > >u-boot-spl-bss-pad,u-boot-spl-dtb,u-boot-spl,u-boot-img,main-section) > > I can't help but feel like this is a bug with entry expansion where the > name of the expanded node is ignored (and replaced by its type?) when it > comes to the symbols. The problem is that there is only really one value for a symbol. E.g. U-Boot has an image-pos and it doesn't matter what you call it; it is the same value. So does it make sense to disallow different names for the same thing? See testSymbol() which actually creates two SPLs and checks that both are updated. That is the opposite to what you are talking about, of course, since it is the properties of the 'u-boot' entry which are used to write into the SPL entries. If we move to using the name instead, we could have two different copies of U-Boot in the image and each SPL could refer to a different one. At present this is done by puting the pairs into their own section. I think this needs more discussionwhat do you think? Regards, Simon > > > > > Fix it. > > > > Signed-off-by: Simon Glass > > --- > > > > arch/x86/dts/u-boot.dtsi | 2 +- > > common/spl/spl.c | 8 > > include/spl.h| 4 ++-- > > 3 files changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/dts/u-boot.dtsi b/arch/x86/dts/u-boot.dtsi > > index ca84d18ad9..24e692f988 100644 > > --- a/arch/x86/dts/u-boot.dtsi > > +++ b/arch/x86/dts/u-boot.dtsi > > @@ -37,7 +37,7 @@ > > u-boot-tpl-dtb { > > }; > > #endif > > - spl { > > + u-boot-spl { > > type = "u-boot-spl"; > > I guess the type can be removed now that it's the same as the node name. > > > offset = ; > > }; > > diff --git a/common/spl/spl.c b/common/spl/spl.c > > index 884102bdea..444907432c 100644 > > --- a/common/spl/spl.c > > +++ b/common/spl/spl.c > > @@ -54,8 +54,8 @@ binman_sym_declare(ulong, u_boot_any, image_pos); > > binman_sym_declare(ulong, u_boot_any, size); > > > > #ifdef CONFIG_TPL > > -binman_sym_declare(ulong, spl, image_pos); > > -binman_sym_declare(ulong, spl, size); > > +binman_sym_declare(ulong, u_boot_spl, image_pos); > > +binman_sym_declare(ulong, u_boot_spl, size); > > #endif > > > > /* Define board data structure */ > > @@ -143,14 +143,14 @@ void spl_fixup_fdt(void *fdt_blob) > > ulong spl_get_image_pos(void) > > { > > return spl_phase() == PHASE_TPL ? > > - binman_sym(ulong, spl, image_pos) : > > + binman_sym(ulong, u_boot_spl, image_pos) : > > binman_sym(ulong, u_boot_any, image_pos); > > } > > > > ulong spl_get_image_size(void) > > { > > return spl_phase() == PHASE_TPL ? > > - binman_sym(ulong, spl, size) : > > + binman_sym(ulong, u_boot_spl, size) : > > binman_sym(ulong, u_boot_any, size); > > } > > > > diff --git a/include/spl.h b/include/spl.h > > index bb92bc6ec6..8ceb3c0f09 100644 > > --- a/include/spl.h > > +++ b/include/spl.h > > @@ -269,8 +269,8 @@ struct spl_load_info { > > */ > > binman_sym_extern(ulong, u_boot_any, image_pos); > > binman_sym_extern(ulong, u_boot_any, size); > > -binman_sym_extern(ulong, spl, image_pos); > > -binman_sym_extern(ulong, spl, size); > > +binman_sym_extern(ulong, u_boot_spl, image_pos); > > +binman_sym_extern(ulong, u_boot_spl, size); > > > > /** > > * spl_get_image_pos() - get the image position of the next phase
Re: [PATCH 1/4] powerpc: Remove unused MPC8540/60ADS code
On Wed, 23 Feb 2022 at 10:29, Tom Rini wrote: > > Remove some code, primarily CPM2 related, that is now unused since the > removal of MPC8540/60ADS. > > Fixes 3913191c8a6b ("powerpc: mpc8540ads: mpc8560ads: Drop support for > MPC8540/60ADS") > Signed-off-by: Tom Rini > --- > arch/powerpc/cpu/mpc85xx/Makefile | 2 - > arch/powerpc/cpu/mpc85xx/commproc.c| 188 -- > arch/powerpc/cpu/mpc85xx/cpu.c | 4 - > arch/powerpc/cpu/mpc85xx/cpu_init.c| 72 --- > arch/powerpc/cpu/mpc85xx/fdt.c | 8 - > arch/powerpc/cpu/mpc85xx/serial_scc.c | 262 > arch/powerpc/cpu/mpc85xx/speed.c | 16 - > arch/powerpc/include/asm/cpm_85xx.h| 824 - > arch/powerpc/include/asm/global_data.h | 11 - > arch/powerpc/include/asm/immap_85xx.h | 327 -- > arch/powerpc/lib/bdinfo.c | 13 - > arch/powerpc/lib/bootm.c | 6 - > drivers/pci/pci_mpc85xx.c | 1 - > include/asm-generic/u-boot.h | 6 - > include/configs/MPC8540ADS.h | 303 - > include/configs/MPC8560ADS.h | 292 - > 16 files changed, 2335 deletions(-) > delete mode 100644 arch/powerpc/cpu/mpc85xx/commproc.c > delete mode 100644 arch/powerpc/cpu/mpc85xx/serial_scc.c > delete mode 100644 arch/powerpc/include/asm/cpm_85xx.h > delete mode 100644 include/configs/MPC8540ADS.h > delete mode 100644 include/configs/MPC8560ADS.h Reviewed-by: Simon Glass
Re: [PATCH] dm: pinctrl: Use explicit values for enums
On Wed, 23 Feb 2022 at 07:02, Michal Simek wrote: > > From: Ashok Reddy Soma > > Based on discussion at > https://lore.kernel.org/r/20200318125003.ga2727...@kroah.com we got > recommendation to use explicit values for all enums. > > So, add explicit values to all pinctrl related enums for readability. > > Signed-off-by: Ashok Reddy Soma > Signed-off-by: Michal Simek > --- > > include/dm/pinctrl.h | 48 ++-- > 1 file changed, 24 insertions(+), 24 deletions(-) Reviewed-by: Simon Glass
Re: [PATCH 20/24] binman: Support splitting an ELF file into multiple nodes
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:50, Simon Glass wrote: > > Some boards need to load an ELF file using the 'loadables' property, but > > the file has segments at different memory addresses. This means that it > > cannot be supplied as a flat binary. > > > > Allow generating a separate node in the FIT for each segment in the ELF, > > with a different load address for each. > > > > Signed-off-by: Simon Glass > > --- > > > > tools/binman/entries.rst | 146 +++ > > tools/binman/etype/fit.py| 259 ++- > > tools/binman/ftest.py| 116 + > > tools/binman/test/221_fit_split_elf.dts | 67 + > > tools/binman/test/222_fit_bad_dir.dts| 9 + > > tools/binman/test/223_fit_bad_dir_config.dts | 9 + > > 6 files changed, 594 insertions(+), 12 deletions(-) > > create mode 100644 tools/binman/test/221_fit_split_elf.dts > > create mode 100644 tools/binman/test/222_fit_bad_dir.dts > > create mode 100644 tools/binman/test/223_fit_bad_dir_config.dts > > > > diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst > > index d483169712..079fed1a9c 100644 > > --- a/tools/binman/entries.rst > > +++ b/tools/binman/entries.rst > > @@ -612,6 +612,9 @@ gen-fdt-nodes > > Generate FDT nodes as above. This is the default if there is no > > `fit,operation` property. > > > > +split-elf > > +Split an ELF file into a separate node for each segment. > > + > > Generating nodes from an FDT list (gen-fdt-nodes) > > ~ > > > > @@ -655,6 +658,149 @@ for each of your two files. > > Note that if no devicetree files are provided (with '-a of-list' as above) > > then no nodes will be generated. > > > > +Generating nodes from an ELF file (split-elf) > > +~ > > + > > +This uses the node as a template to generate multiple nodes. The following > > +special properties are available: > > + > > +split-elf > > +Split an ELF file into a separate node for each segment. This uses the > > +node as a template to generate multiple nodes. The following special > > +properties are available: > > + > > +fit,load > > +Generates a `load = <...>` property with the load address of the > > +segmnet > > + > > +fit,entry > > +Generates a `entry = <...>` property with the entry address of the > > +ELF. This is only produced for the first entry > > + > > +fit,data > > +Generates a `data = <...>` property with the contents of the > > segment > > I think all these should be done by default. I don't see the point of > not setting the properties, or setting them manually to values that will > be the same for multiple nodes. My intent is to make things discoverable and obvious, so that magic processing is explicit. > > > + > > +fit,loadables > > +Generates a `loadable = <...>` property with a list of the > > generated > > +nodes (including all nodes if this operation is used multiple > > times) > > I think this could also be the default behaviour like the above, and > even for configs which have a "loadables" property we could append to it > by default. > > Either way, if the "loadables" property exists this needs to append to > it instead of entirely replacing it. (Needs to append to "u-boot", see > comment at example generated config below.) Yes, makes sense. > > > + > > + > > +Here is an example showing ATF, TEE and a device tree all combined:: > > This looks like a better place to write about the template node design > so I'll try here instead of the previous patch. I've always thought they > were ugly but I couldn't think of a good enough design when they were > introduced. Maybe I have now. > > > + > > +fit { > > +description = "test-desc"; > > +#address-cells = <1>; > > +fit,fdt-list = "of-list"; > > + > > +images { > > +u-boot { > > +description = "U-Boot (64-bit)"; > > +type = "standalone"; > > +os = "U-Boot"; > > +arch = "arm64"; > > +compression = "none"; > > +load = ; > > +u-boot-nodtb { > > +}; > > +}; > > +@fdt-SEQ { > > +description = "fdt-NAME.dtb"; > > +type = "flat_dt"; > > +compression = "none"; > > +}; > > Instead of putting these into the images subnode, we could have > images-level subnodes for the operations. For example, instead of the above: > >images@gen-fdt-nodes { >fdt-list = "of-list"; > >fdt { >type = "flat_dt"; >compression = "none"; >}; >}; What does that mean, though? I presume it creates a second images {} no
Re: [PATCH 14/24] binman: Support a list of strings with the mkimage etype
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:49, Simon Glass wrote: > > At present the 'args' property of the mkimage entry type is a string. This > > makes it difficult to include CONFIG options in that property. In > > particular, this does not work: > > > >args = "-n CONFIG_SYS_SOC -E" > > > > since the preprocessor does not operate within strings, nor does this: > > > >args = "-n" CONFIG_SYS_SOC" "-E" > > > > since the device tree compiler does not understand string concatenation. > > Fun fact, I got something like this roughly working: > > #define _QUOTE(x) #x > #define QUOTE(x) _QUOTE(x) > > #define MKIMAGE_ARGS QUOTE( \ >-A arm -T kernel -C none -O linux -n U-Boot \ >-a CONFIG_SYS_TEXT_BASE -e CONFIG_SYS_TEXT_BASE \ > ) > > But obviously a string list is the better choice. :-) > > > > > With this new feature, we can do: > > > >args = "-n", CONFIG_SYS_SOC, "-E"; > > > > Signed-off-by: Simon Glass > > --- > > > > tools/binman/entries.rst | 11 +++ > > tools/binman/etype/mkimage.py | 13 - > > 2 files changed, 23 insertions(+), 1 deletion(-) > > > > diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst > > index 0fb6d56296..b32dc58933 100644 > > --- a/tools/binman/entries.rst > > +++ b/tools/binman/entries.rst > > @@ -931,6 +931,17 @@ This calls mkimage to create an imximage with > > u-boot-spl.bin as the input > > file. The output from mkimage then becomes part of the image produced by > > binman. > > > > +To use CONFIG options in the arguments, use a string list instead, as in > > +this example which also produces four arguments:: > > + > > +mkimage { > > +args = "-n", CONFIG_SYS_SOC, "-T imximage"; > > + > > +u-boot-spl { > > +}; > > +}; > > + > > + > > > > > > Entry: op-tee: Open Portable Trusted Execution Environment (OP-TEE) blob > > diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py > > index 201ee4b569..9ecd1c2548 100644 > > --- a/tools/binman/etype/mkimage.py > > +++ b/tools/binman/etype/mkimage.py > > @@ -31,10 +31,21 @@ class Entry_mkimage(Entry): > > This calls mkimage to create an imximage with u-boot-spl.bin as the > > input > > file. The output from mkimage then becomes part of the image produced > > by > > binman. > > + > > +To use CONFIG options in the arguments, use a string list instead, as > > in > > +this example which also produces four arguments:: > > + > > +mkimage { > > +args = "-n", CONFIG_SYS_SOC, "-T imximage"; > > + > > +u-boot-spl { > > +}; > > +}; > > + > > """ > > def __init__(self, section, etype, node): > > super().__init__(section, etype, node) > > -self._args = fdt_util.GetString(self._node, 'args').split(' ') > > +self._args = fdt_util.GetArgs(self._node, 'args') > > If you're OK with each string being a single argument, I think you could > use GetStringList(default=[]) and shlex.join() here instead. See what you think of what I have come up with here. The arg is not optional, actually. > > > self._mkimage_entries = OrderedDict() > > self.align_default = None > > self.ReadEntries() Regards, Simon
Re: [PATCH 06/24] dtoc: Support adding a string list to a device tree
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:49, Simon Glass wrote: > > Add a new function to add a string list. > > > > Signed-off-by: Simon Glass > > --- > > > > tools/dtoc/fdt.py | 18 ++ > > tools/dtoc/test_fdt.py | 8 > > 2 files changed, 26 insertions(+) > > > > diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py > > index 32a7aa9829..e7197f8f12 100644 > > --- a/tools/dtoc/fdt.py > > +++ b/tools/dtoc/fdt.py > > @@ -501,6 +501,24 @@ class Node: > > val = bytes(val, 'utf-8') > > return self.AddData(prop_name, val + b'\0') > > > > +def AddStringList(self, prop_name, val): > > +"""Add a new string-list property to a node > > + > > +The device tree is marked dirty so that the value will be written > > to > > +the blob on the next sync. > > + > > +Args: > > +prop_name: Name of property to add > > +val (list of str): List of strings to add > > + > > +Returns: > > +Prop added > > +""" > > +out = b'' > > +for string in val: > > +out += bytes(string, 'utf-8') + b'\0' > > +return self.AddData(prop_name, out) > > If val is an empty list this would try to set a zero-byte data, but then > the Prop class considers that a boolean True. Yes, but I believe that is correct, isn't it? I did propose a change to DT bool props but it has not got anywhere. > > Perhaps use "s" as the variable name as there's a "string" module > (though not imported here). > > Also, b'\0'.join() works just like in strings if you prefer that to a loop. OK, will update both of those. Regards, Simon
Re: [PATCH 11/24] elf: Add a way to read segment information from an ELF file
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:49, Simon Glass wrote: > > Add a function which reads the segments and the entry address. > > > > Also fix a comment nit in the tests while we are here. > > > > Signed-off-by: Simon Glass > > --- > > > > tools/binman/elf.py | 37 + > > tools/binman/elf_test.py | 31 +-- > > 2 files changed, 66 insertions(+), 2 deletions(-) > > > > diff --git a/tools/binman/elf.py b/tools/binman/elf.py > > index de2bb4651f..2b83ac1876 100644 > > --- a/tools/binman/elf.py > > +++ b/tools/binman/elf.py > > @@ -20,6 +20,7 @@ from patman import tout > > ELF_TOOLS = True > > try: > > from elftools.elf.elffile import ELFFile > > +from elftools.elf.elffile import ELFError > > from elftools.elf.sections import SymbolTableSection > > except: # pragma: no cover > > ELF_TOOLS = False > > @@ -369,3 +370,39 @@ def UpdateFile(infile, outfile, start_sym, end_sym, > > insert): > > newdata += data[syms[end_sym].offset:] > > tools.WriteFile(outfile, newdata) > > tout.Info('Written to offset %#x' % syms[start_sym].offset) > > + > > +def read_segments(data): > > +"""Read segments from an ELF file > > + > > +Args: > > +data (bytes): Contents of file > > + > > +Returns: > > +tuple: > > +list of segments, each: > > +int: Segment number (0 = first) > > +int: Start address of segment in memory > > +bytes: Contents of segment > > +int: entry address for image > > + > > +Raises: > > +ValueError: elftools is not available > > ... or input data is not a correct ELF file? > > > +""" > > +if not ELF_TOOLS: > > +raise ValueError('Python elftools package is not available') > > I see something like ModuleNotFoundError("No module named 'elftools'") > when I try to import an unavailable module, so maybe this could match that. OK, will update. > > > +with io.BytesIO(data) as inf: > > +try: > > +elf = ELFFile(inf) > > +except ELFError as err: > > +raise ValueError(err) > > Could also be: raise ValueError("Not an ELF file") from err > > But I guess you want err's message here to match on it in tests. (It's > also possible but slightly inconvenient with __cause__ when using > raise-from) It might be a corrupt ELF file, perhaps. > > > +entry = elf.header['e_entry'] > > +segments = [] > > +for i in range(elf.num_segments()): > > +segment = elf.get_segment(i) > > +if segment['p_type'] != 'PT_LOAD' or not segment['p_memsz']: > > I can't say I fully understand ELF details, is it obvious in context > that a function named read_segments() would only return these segments, > or should the name be explicit about it e.g. read_loadable_segments()? Yes I agree. [..] Regards, Simon
Re: [PATCH 09/24] dtoc: Support reading a list of arguments
Hi Alper, On Tue, 15 Feb 2022 at 04:53, Alper Nebi Yasak wrote: > > On 08/02/2022 21:49, Simon Glass wrote: > > It is helpful to support a string or stringlist containing a list of > > space-separated arguments, for example: > > > >args = "-n fred", "-a", "123"; > > > > This resolves to the list: > > > >-n fred -a 123 > > Would be clearer as ['-n', 'fred', '-a', '123'] OK > > > > > which can be passed to a program as arguments. > > > > Add a helper to do the required processing. > > > > Signed-off-by: Simon Glass > > --- > > > > tools/dtoc/fdt_util.py | 12 > > tools/dtoc/test/dtoc_test_simple.dts | 1 + > > tools/dtoc/test_fdt.py | 15 +++ > > 3 files changed, 28 insertions(+) > > > > diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py > > index 19eb13aef3..59e065884f 100644 > > --- a/tools/dtoc/fdt_util.py > > +++ b/tools/dtoc/fdt_util.py > > @@ -184,6 +184,18 @@ def GetStringList(node, propname, default=None): > > return [strval] > > return value > > > > +def GetArgs(node, propname): > > +prop = node.props.get(propname) > > +if not prop: > > +raise ValueError(f"Node '{node.path}': Expected property > > '{propname}'") > > +if prop.bytes: > > +value = GetStringList(node, propname) > > +else: > > +value = [] > > Isn't GetStringList(node, propname, default=[]) enough here, why check > prop.bytes? Because the default value is for when there is no such property. In this case there is a property, so the default will not be used. > > > +lists = [v.split() for v in value] > > Use shlex.split() to handle quotes inside the strings, so that we can > pass args with spaces inside them. e.g. mkimage -n "U-Boot v2022.04". > Or each list element could be a single argument with no splitting done. > > I also wish mkimage -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" from > Makefile was possible, but can't think of a great way. That's actually not what I was trying to do. I want "-n first" to mean two args. It is like normally command-line processing. Of course this means that it isn't possible to do what you want here. I am not sure of a good way to support that. One way would be to only split into args if there is a single string in the list? I will try that for now. > > > +args = [x for l in lists for x in l] > > +return args > > + > > Anyway, I don't think this belongs here as argument lists are not really > a device-tree construct. It would be better in a new binman entry type > ("command"?) which mkimage can subclass from. Well I am trying to keep all typing stuff in here, i.e. everything that guesses what is meant by a DT property. That way I can have DT tests and expand as needed. I agree this is a borderline case, but I'm not sure it is a good to have lots of logic (that depends on the internal working of Fdt) in a different file. E.g. I hate all of this code and would like to refactor it to put more stuff in pylibfdt one day. > > > def GetBool(node, propname, default=False): > > """Get an boolean from a property > > > > diff --git a/tools/dtoc/test/dtoc_test_simple.dts > > b/tools/dtoc/test/dtoc_test_simple.dts > > index 4c2c70af22..2d321fb034 100644 > > --- a/tools/dtoc/test/dtoc_test_simple.dts > > +++ b/tools/dtoc/test/dtoc_test_simple.dts > > @@ -62,5 +62,6 @@ > > > > orig-node { > > orig = <1 23 4>; > > + args = "-n first", "second", "-p", "123,456", "-x"; > > Could be useful to add an argument with single quotes, and one with > escaped double quotes. I reverted the shlex change in the end...can we do that in a separate patch? I think it has interesting implications for the Makefile and we should think about what tests to add and what the use cases are. > > > }; > > }; > > diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py > > index c8fe5fc1de..5d46e69b8b 100755 > > --- a/tools/dtoc/test_fdt.py > > +++ b/tools/dtoc/test_fdt.py > > @@ -652,6 +652,21 @@ class TestFdtUtil(unittest.TestCase): > > self.assertEqual(['test'], > > fdt_util.GetStringList(self.node, 'missing', > > ['test'])) > > > > +def testGetArgs(self): > > +node = self.dtb.GetNode('/orig-node') > > +self.assertEqual(['message'], fdt_util.GetArgs(self.node, > > 'stringval')) > > +self.assertEqual( > > +['multi-word', 'message'], > > +fdt_util.GetArgs(self.node, 'stringarray')) > > +self.assertEqual([], fdt_util.GetArgs(self.node, 'boolval')) > > +self.assertEqual(['-n', 'first', 'second', '-p', '123,456', '-x'], > > + fdt_util.GetArgs(node, 'args')) > > +with self.assertRaises(ValueError) as exc: > > +fdt_util.GetArgs(self.node, 'missing') > > +self.assertIn( > > +"Node '/spl-test': Expected property 'missing'", > > +str(exc.exception)) > > + > > def testGetB
Re: [PATCH] arm: am33xx: Fix early debug UART initialization
Hi Felix, On Mon, 14 Feb 2022 at 09:57, Felix Brack wrote: > > The changes from commit 0dba45864b2a ("arm: Init the debug UART") > prevent the early debug UART from being initialized correctly. > By adding a new SoC specific early UART initialization function this SoC-specific You need the hyphen for this to make sense, since you are creating an adjective. > patch provides a generic location to add the required code. This code > has to be SoC and not board specific. board-specific > For the am33xx SoCs the fix consist of configuring early clocks. > > Signed-off-by: Felix Brack > --- > > arch/arm/mach-omap2/am33xx/board.c | 7 +++ > drivers/serial/Kconfig | 13 + > include/debug_uart.h | 15 +++ > 3 files changed, 35 insertions(+) More nits below. Reviewed-by: Simon Glass > > diff --git a/arch/arm/mach-omap2/am33xx/board.c > b/arch/arm/mach-omap2/am33xx/board.c > index c44667668e..a7f0445b93 100644 > --- a/arch/arm/mach-omap2/am33xx/board.c > +++ b/arch/arm/mach-omap2/am33xx/board.c > @@ -604,3 +604,10 @@ int arch_cpu_init_dm(void) > #endif > return 0; > } > + > +#if IS_ENABLED(CONFIG_DEBUG_UART_SOC_INIT) > +void soc_debug_uart_init(void) > +{ > + setup_early_clocks(); > +} > +#endif > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index 345d1881f5..3da4064d35 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -490,6 +490,19 @@ config DEBUG_UART_SHIFT > value. Use this value to specify the shift to use, where 0=byte > registers, 2=32-bit word registers, etc. > > +config DEBUG_UART_SOC_INIT > + bool "Enable SoC-specific debug UART init" > + depends on DEBUG_UART > + help > + Boards using the same SoC might require some common settings before > + the debug UART can be used. The board specific > board_debug_uart_init() > + is not the right place for such common settings as they would apply > + to a specific board only instead of all boards using the same SoC. > + When this option is enabled, the SoC specific function > + soc_debug_uart_init() will be called when debug_uart_init() is > called. > + You can put any code here that is needed to set up the UART ready > for > + use. Please mention the order in which the board and SoC functions are called. > + > config DEBUG_UART_BOARD_INIT > bool "Enable board-specific debug UART init" > depends on DEBUG_UART > diff --git a/include/debug_uart.h b/include/debug_uart.h > index 714b369e6f..ebc84c44cd 100644 > --- a/include/debug_uart.h > +++ b/include/debug_uart.h > @@ -42,6 +42,12 @@ > * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the > * functionality (printch(), etc.) > * > + * If your SoC needs additional init for the UART to work, enable > + * CONFIG_DEBUG_UART_SOC_INIT and write a function called > + * soc_debug_uart_init() to perform that init. When debug_uart_init() is > + * called, the init will happen automatically. Board specific code does not > + * go here, see board_debug_uart_init() below. Again please fix your specifics. > + * > * If your board needs additional init for the UART to work, enable > * CONFIG_DEBUG_UART_BOARD_INIT and write a function called > * board_debug_uart_init() to perform that init. When debug_uart_init() is > @@ -61,6 +67,14 @@ > */ > void debug_uart_init(void); > > +#ifdef CONFIG_DEBUG_UART_SOC_INIT > +void soc_debug_uart_init(void); > +#else > +static inline void soc_debug_uart_init(void) > +{ > +} > +#endif > + > #ifdef CONFIG_DEBUG_UART_BOARD_INIT > void board_debug_uart_init(void); > #else > @@ -192,6 +206,7 @@ void printdec(unsigned int value); > \ > void debug_uart_init(void) \ > { \ > + soc_debug_uart_init(); \ > board_debug_uart_init(); \ > _debug_uart_init(); \ > _DEBUG_UART_ANNOUNCE \ > -- > 2.25.1 >
Re: Tips on porting a board from older u-boot versions
On Wed, Feb 23, 2022 at 5:13 PM Jayson Reis wrote: > > Hey there folks, Good Evening, > I just have at hands a board from Radxa, called Rock 3-A which has a rockchip > RK3568, and they do provide a version of u-boot but rather old. > As a fun side project, I am trying to port all things to the current master. > I am still at really early stages, got a minimum .config that compiles for > that board and using their provided TPL, I can load my compiled version of > u-boot's SPL. > After doing this, some questions came which I could not find on the docs or > some other good resource for really beginners in all this embedded world. > First, the initial SPL problem is because the DRAM is not configured, and I > saw that there is a driver for that chip that uses dts for its configuration: > > drivers/ram/rockchip/sdram_rk3568.c > static const struct udevice_id rk3568_dmc_ids[] = { > { .compatible = "rockchip,rk3568-dmc" }, > { } > }; > > But searching the code, I could not find any dts that configures it that way, > from where should I get this information? In some chips I found this > configuration in .c, and .h files, ideally, where should they go? > Also, about the dts, what is the right way to write them in the sense of, how > do you find out the peripherals and their configuration? Is it from a data > sheet or something like that? > If you can point to any other documentation for beginners on how to port > boards, it will be much appreciated. rk356x support in mainline isn't currently viable, though it is close. You may want to check out my gitlab, which maintains my currently out of tree patches: https://gitlab.com/pgwipeout/u-boot-quartz64 I recently submitted the first batch, which includes some fixes for rk356x including ram detection (which is really broken currently). Also, for building examples, check out my CI: https://gitlab.com/pgwipeout/quartz64_ci > Thank you in advance, > Jayson Very Respectfully, Peter Geis
Tips on porting a board from older u-boot versions
Hey there folks, I just have at hands a board from Radxa, called Rock 3-A which has a rockchip RK3568, and they do provide a version of u-boot but rather old. As a fun side project, I am trying to port all things to the current master. I am still at really early stages, got a minimum .config that compiles for that board and using their provided TPL, I can load my compiled version of u-boot's SPL. After doing this, some questions came which I could not find on the docs or some other good resource for really beginners in all this embedded world. First, the initial SPL problem is because the DRAM is not configured, and I saw that there is a driver for that chip that uses dts for its configuration: drivers/ram/rockchip/sdram_rk3568.c static const struct udevice_id rk3568_dmc_ids[] = { { .compatible = "rockchip,rk3568-dmc" }, { } }; But searching the code, I could not find any dts that configures it that way, from where should I get this information? In some chips I found this configuration in .c, and .h files, ideally, where should they go? Also, about the dts, what is the right way to write them in the sense of, how do you find out the peripherals and their configuration? Is it from a data sheet or something like that? If you can point to any other documentation for beginners on how to port boards, it will be much appreciated. Thank you in advance, Jayson
Re: [PULL] u-boot-usb/master
On Wed, Feb 23, 2022 at 06:20:03AM +0100, Marek Vasut wrote: > This is likely the last bigger series for this cycle: > > The following changes since commit 17a0dc6abfdbf392f6a27074f2633608038c4221: > > Merge branch '2022-02-21-platform-updates' (2022-02-21 08:53:24 -0500) > > are available in the Git repository at: > > git://source.denx.de/u-boot-usb.git master > > for you to fetch changes up to 4cea6ed92da456fe234b4f3439707ff29c6a790e: > > configs: omap various: Remove OMAP_EHCI_PHY from defconfigs (2022-02-23 > 05:25:17 +0100) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: Please pull u-boot-dm
On Tue, Feb 22, 2022 at 04:45:30PM -0700, Simon Glass wrote: > Hi Tom, > > https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/11053 > > > The following changes since commit 17a0dc6abfdbf392f6a27074f2633608038c4221: > > Merge branch '2022-02-21-platform-updates' (2022-02-21 08:53:24 -0500) > > are available in the Git repository at: > > git://git.denx.de/u-boot-dm.git tags/dm-pull-2 > > for you to fetch changes up to 70f42e720c90faa2fa27836288559e0d647862b7: > > scripts: dtc: libfdt: fdt_ro.c: always define fdt_check_full (2022-02-22 > 10:05:44 -0700) > Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH] usb: dwc3: Add support to reset usb ULPI phy
On 2/23/22 16:06, Michal Simek wrote: From: T Karthik Reddy When usb PHY initialization is done, the PHY need to be reset. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- drivers/usb/dwc3/Kconfig| 2 +- drivers/usb/dwc3/dwc3-generic.c | 28 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 62aa65bf0cd2..685bda3729e5 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -25,7 +25,7 @@ config USB_DWC3_OMAP config USB_DWC3_GENERIC bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)" - depends on DM_USB && USB_DWC3 && MISC + depends on DM_USB && USB_DWC3 && MISC && DM_GPIO help Select this for Xilinx ZynqMP and similar Platforms. This wrapper supports Host and Peripheral operation modes. diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index b1e019b5b91a..17d35a6dc60c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -25,6 +25,7 @@ #include #include #include +#include struct dwc3_glue_data { struct clk_bulk clks; @@ -42,6 +43,7 @@ struct dwc3_generic_priv { void *base; struct dwc3 dwc3; struct phy_bulk phys; + struct gpio_desc ulpi_reset; }; struct dwc3_generic_host_priv { @@ -77,6 +79,26 @@ static int dwc3_generic_probe(struct udevice *dev, if (rc && rc != -ENOTSUPP) return rc; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + rc = gpio_request_by_name(dev->parent, "reset-gpios", 0, + &priv->ulpi_reset, GPIOD_ACTIVE_LOW); + if (rc != -EBUSY && rc) + return rc; + + /* Toggle ulpi to reset the phy. */ + rc = dm_gpio_set_value(&priv->ulpi_reset, 1); + if (rc) + return rc; + + mdelay(5); + + rc = dm_gpio_set_value(&priv->ulpi_reset, 0); + if (rc) + return rc; + + mdelay(5); + } + if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) reset_deassert_bulk(&glue->resets); @@ -98,6 +120,12 @@ static int dwc3_generic_remove(struct udevice *dev, { struct dwc3 *dwc3 = &priv->dwc3; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + struct gpio_desc *ulpi_reset = &priv->ulpi_reset; + + dm_gpio_free(ulpi_reset->dev, ulpi_reset); + } + dwc3_remove(dwc3); dwc3_shutdown_phy(dev, &priv->phys); unmap_physmem(dwc3->regs, MAP_NOCACHE); CC Bin please.
Re: [PATCH] usb: dwc3: Add support for usb3-phy PHY configuration
On 2/23/22 15:56, Michal Simek wrote: When usb3-phy label is found, PHY driver is called and serdes line is initialized. This is preparation for serdes/psgtr driver to configure GT lines based on description in DT. Signed-off-by: Michal Simek --- drivers/usb/dwc3/dwc3-generic.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 01bd0ca190e3..b1e019b5b91a 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -409,6 +409,17 @@ static int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; + struct phy phy; + + ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + if (!ret) { + ret = generic_phy_init(&phy); + if (ret) + return ret; + } else if (ret != -ENOENT) { + debug("could not get phy (err %d)\n", ret); + return ret; + } glue->regs = dev_read_addr(dev); @@ -420,6 +431,12 @@ static int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; + if (phy.dev) { + ret = generic_phy_power_on(&phy); + if (ret) + return ret; + } + ret = device_find_first_child(dev, &child); if (ret) return ret; CC Bin please.
[PATCH 1/4] powerpc: Remove unused MPC8540/60ADS code
Remove some code, primarily CPM2 related, that is now unused since the removal of MPC8540/60ADS. Fixes 3913191c8a6b ("powerpc: mpc8540ads: mpc8560ads: Drop support for MPC8540/60ADS") Signed-off-by: Tom Rini --- arch/powerpc/cpu/mpc85xx/Makefile | 2 - arch/powerpc/cpu/mpc85xx/commproc.c| 188 -- arch/powerpc/cpu/mpc85xx/cpu.c | 4 - arch/powerpc/cpu/mpc85xx/cpu_init.c| 72 --- arch/powerpc/cpu/mpc85xx/fdt.c | 8 - arch/powerpc/cpu/mpc85xx/serial_scc.c | 262 arch/powerpc/cpu/mpc85xx/speed.c | 16 - arch/powerpc/include/asm/cpm_85xx.h| 824 - arch/powerpc/include/asm/global_data.h | 11 - arch/powerpc/include/asm/immap_85xx.h | 327 -- arch/powerpc/lib/bdinfo.c | 13 - arch/powerpc/lib/bootm.c | 6 - drivers/pci/pci_mpc85xx.c | 1 - include/asm-generic/u-boot.h | 6 - include/configs/MPC8540ADS.h | 303 - include/configs/MPC8560ADS.h | 292 - 16 files changed, 2335 deletions(-) delete mode 100644 arch/powerpc/cpu/mpc85xx/commproc.c delete mode 100644 arch/powerpc/cpu/mpc85xx/serial_scc.c delete mode 100644 arch/powerpc/include/asm/cpm_85xx.h delete mode 100644 include/configs/MPC8540ADS.h delete mode 100644 include/configs/MPC8560ADS.h diff --git a/arch/powerpc/cpu/mpc85xx/Makefile b/arch/powerpc/cpu/mpc85xx/Makefile index 6f4ad1f9b762..c32cde04e16a 100644 --- a/arch/powerpc/cpu/mpc85xx/Makefile +++ b/arch/powerpc/cpu/mpc85xx/Makefile @@ -27,7 +27,6 @@ obj-$(CONFIG_MP) += release.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_CMD_ERRATA) += cmd_errata.o endif -obj-$(CONFIG_CPM2) += commproc.o obj-$(CONFIG_OF_LIBFDT) += fdt.o obj-$(CONFIG_FSL_CORENET) += liodn.o @@ -49,7 +48,6 @@ obj-$(CONFIG_ARCH_T2080) += t2080_ids.o obj-$(CONFIG_QE) += qe_io.o -obj-$(CONFIG_CPM2) += serial_scc.o obj-$(CONFIG_SYS_FSL_QORIQ_CHASSIS1) += fsl_corenet_serdes.o obj-$(CONFIG_SYS_FSL_QORIQ_CHASSIS2) += fsl_corenet2_serdes.o diff --git a/arch/powerpc/cpu/mpc85xx/commproc.c b/arch/powerpc/cpu/mpc85xx/commproc.c deleted file mode 100644 index 8e8427a08bbe.. --- a/arch/powerpc/cpu/mpc85xx/commproc.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Adapted for Motorola MPC8560 chips - * Xianghua Xiao - * - * This file is based on "arch/powerpc/8260_io/commproc.c" - here is it's - * copyright notice: - * - * General Purpose functions for the global management of the - * 8220 Communication Processor Module. - * Copyright (c) 1999 Dan Malek (dma...@jlc.net) - * Copyright (c) 2000 MontaVista Software, Inc (sou...@mvista.com) - * 2.3.99 Updates - * Copyright (c) 2003 Motorola,Inc. - * - * In addition to the individual control of the communication - * channels, there are a few functions that globally affect the - * communication processor. - * - * Buffer descriptors must be allocated from the dual ported memory - * space. The allocator for that is here. When the communication - * process is reset, we reclaim the memory available. There is - * currently no deallocator for this memory. - */ -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -/* - * because we have stack and init data in dual port ram - * we must reduce the size - */ -#undef CPM_DATAONLY_SIZE -#define CPM_DATAONLY_SIZE ((uint)(8 * 1024) - CPM_DATAONLY_BASE) - -void -m8560_cpm_reset(void) -{ - volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; - volatile ulong count; - - gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); - - /* Reclaim the DP memory for our use. - */ - gd->arch.dp_alloc_base = CPM_DATAONLY_BASE; - gd->arch.dp_alloc_top = gd->arch.dp_alloc_base + CPM_DATAONLY_SIZE; - - /* -* Reset CPM -*/ - cpm->im_cpm_cp.cpcr = CPM_CR_RST; - count = 0; - do {/* Spin until command processed */ - __asm__ __volatile__ ("eieio"); - } while ((cpm->im_cpm_cp.cpcr & CPM_CR_FLG) && ++count < 100); -} - -/* Allocate some memory from the dual ported ram. - * To help protocols with object alignment restrictions, we do that - * if they ask. - */ -uint -m8560_cpm_dpalloc(uint size, uint align) -{ - volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; - uintretloc; - uintalign_mask, off; - uintsavebase; - - align_mask = align - 1; - savebase = gd->arch.dp_alloc_base; - - off = gd->arch.dp_alloc_base & align_mask; - if (off != 0) - gd->arch.dp_alloc_base += (align - off); - - if ((off = size & align_mask) != 0) - size += align - off; - - if ((gd->arch.dp_alloc_base + size) >= gd->arch.dp_alloc_top) { - gd->arch.dp_alloc_base = savebase; - panic("m8560_cpm_dpalloc: ran out of dual port ram!"); - } - - retloc
[PATCH 3/4] arm: exynos: Move BL1/2 SPI flash defines to their user, drop CONFIG
These particular values are not configurable and today we always set CONFIG_SECURE_BL1_ONLY. Move these to where they're used in the code, and drop from the CONFIG namespace. Cc: Minkyu Kang Cc: Jaehoon Chung Signed-off-by: Tom Rini --- arch/arm/mach-exynos/spl_boot.c | 30 ++ include/configs/exynos5-common.h | 24 include/configs/origen.h | 5 - include/configs/smdkv310.h | 5 - 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/arch/arm/mach-exynos/spl_boot.c b/arch/arm/mach-exynos/spl_boot.c index 722449881af2..93fea9c749a6 100644 --- a/arch/arm/mach-exynos/spl_boot.c +++ b/arch/arm/mach-exynos/spl_boot.c @@ -22,6 +22,36 @@ #include "common_setup.h" #include "clock_init.h" +#ifdef CONFIG_ARCH_EXYNOS5 +#define SECURE_BL1_ONLY + +/* Secure FW size configuration */ +#ifdef SECURE_BL1_ONLY +#define SEC_FW_SIZE (8 << 10) /* 8KB */ +#else +#define SEC_FW_SIZE 0 +#endif + +/* Configuration of BL1, BL2, ENV Blocks on mmc */ +#define RES_BLOCK_SIZE (512) +#define BL1_SIZE (16 << 10) /*16 K reserved for BL1*/ +#define BL2_SIZE (512UL << 10UL) /* 512 KB */ + +#define BL1_OFFSET (RES_BLOCK_SIZE + SEC_FW_SIZE) +#define BL2_OFFSET (BL1_OFFSET + BL1_SIZE) + +/* U-Boot copy size from boot Media to DRAM.*/ +#define BL2_START_OFFSET (BL2_OFFSET/512) +#define BL2_SIZE_BLOC_COUNT(BL2_SIZE/512) + +#define EXYNOS_COPY_SPI_FNPTR_ADDR 0x02020058 +#define SPI_FLASH_UBOOT_POS(SEC_FW_SIZE + BL1_SIZE) +#elif defined(CONFIG_ARCH_EXYNOS4) +#define COPY_BL2_SIZE 0x8 +#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) +#define BL2_SIZE_BLOC_COUNT(COPY_BL2_SIZE/512) +#endif + DECLARE_GLOBAL_DATA_PTR; /* Index into irom ptr table */ diff --git a/include/configs/exynos5-common.h b/include/configs/exynos5-common.h index 90d095d535b0..410243bb2c91 100644 --- a/include/configs/exynos5-common.h +++ b/include/configs/exynos5-common.h @@ -58,30 +58,6 @@ #define CONFIG_SYS_MONITOR_BASE0x -#define CONFIG_SECURE_BL1_ONLY - -/* Secure FW size configuration */ -#ifdef CONFIG_SECURE_BL1_ONLY -#define CONFIG_SEC_FW_SIZE (8 << 10) /* 8KB */ -#else -#define CONFIG_SEC_FW_SIZE 0 -#endif - -/* Configuration of BL1, BL2, ENV Blocks on mmc */ -#define CONFIG_RES_BLOCK_SIZE (512) -#define CONFIG_BL1_SIZE(16 << 10) /*16 K reserved for BL1*/ -#define CONFIG_BL2_SIZE(512UL << 10UL) /* 512 KB */ - -#define CONFIG_BL1_OFFSET (CONFIG_RES_BLOCK_SIZE + CONFIG_SEC_FW_SIZE) -#define CONFIG_BL2_OFFSET (CONFIG_BL1_OFFSET + CONFIG_BL1_SIZE) - -/* U-Boot copy size from boot Media to DRAM.*/ -#define BL2_START_OFFSET (CONFIG_BL2_OFFSET/512) -#define BL2_SIZE_BLOC_COUNT(CONFIG_BL2_SIZE/512) - -#define EXYNOS_COPY_SPI_FNPTR_ADDR 0x02020058 -#define SPI_FLASH_UBOOT_POS(CONFIG_SEC_FW_SIZE + CONFIG_BL1_SIZE) - /* SPI */ /* Ethernet Controllor Driver */ diff --git a/include/configs/origen.h b/include/configs/origen.h index 1caeed6ba5cd..22325180ce0e 100644 --- a/include/configs/origen.h +++ b/include/configs/origen.h @@ -58,9 +58,4 @@ #define CONFIG_SYS_INIT_SP_ADDR0x0204 -/* U-Boot copy size from boot Media to DRAM.*/ -#define COPY_BL2_SIZE 0x8 -#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) -#define BL2_SIZE_BLOC_COUNT(COPY_BL2_SIZE/512) - #endif /* __CONFIG_H */ diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h index f113fa44045e..32196a5aef94 100644 --- a/include/configs/smdkv310.h +++ b/include/configs/smdkv310.h @@ -51,11 +51,6 @@ #define CONFIG_SYS_INIT_SP_ADDR0x0204 -/* U-Boot copy size from boot Media to DRAM.*/ -#defineCOPY_BL2_SIZE 0x8 -#define BL2_START_OFFSET ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512) -#define BL2_SIZE_BLOC_COUNT(COPY_BL2_SIZE/512) - /* Ethernet Controllor Driver */ #ifdef CONFIG_CMD_NET #define CONFIG_ENV_SROM_BANK 1 -- 2.25.1
[PATCH 4/4] Convert CONFIG_BOARD_COMMON to Kconfig
This converts the following to Kconfig: CONFIG_BOARD_COMMON Signed-off-by: Tom Rini --- arch/arm/mach-exynos/Kconfig| 4 include/configs/espresso7420.h | 2 -- include/configs/exynos4-common.h| 2 -- include/configs/exynos5-dt-common.h | 2 -- include/configs/exynos78x0-common.h | 2 -- include/configs/odroid_xu3.h| 2 -- include/configs/smdk5250.h | 2 -- include/configs/smdk5420.h | 2 -- include/configs/smdkv310.h | 1 - include/configs/snow.h | 2 -- include/configs/spring.h| 2 -- scripts/config_whitelist.txt| 1 - 12 files changed, 4 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index 6087d93c71a4..f73dbbb507d1 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -1,5 +1,9 @@ if ARCH_EXYNOS +config BOARD_COMMON + def_bool y + depends on !TARGET_SMDKV310 && !TARGET_ARNDALE + choice prompt "EXYNOS architecture type select" optional diff --git a/include/configs/espresso7420.h b/include/configs/espresso7420.h index 2495db93f8d4..d936b7f09fcd 100644 --- a/include/configs/espresso7420.h +++ b/include/configs/espresso7420.h @@ -10,8 +10,6 @@ #include -#define CONFIG_BOARD_COMMON - #define CONFIG_ESPRESSO7420 #define CONFIG_SYS_SDRAM_BASE 0x4000 diff --git a/include/configs/exynos4-common.h b/include/configs/exynos4-common.h index 52dcf7a3bc42..4202c6261262 100644 --- a/include/configs/exynos4-common.h +++ b/include/configs/exynos4-common.h @@ -12,8 +12,6 @@ #include "exynos-common.h" -#define CONFIG_BOARD_COMMON - /* SD/MMC configuration */ #define CONFIG_MMC_DEFAULT_DEV 0 diff --git a/include/configs/exynos5-dt-common.h b/include/configs/exynos5-dt-common.h index 00b67787d9e6..bcbdfa7ae35a 100644 --- a/include/configs/exynos5-dt-common.h +++ b/include/configs/exynos5-dt-common.h @@ -21,8 +21,6 @@ #define FLASH_SIZE (4 << 20) #define CONFIG_SPI_BOOTING -#define CONFIG_BOARD_COMMON - /* Display */ #ifdef CONFIG_LCD #define CONFIG_EXYNOS_FB diff --git a/include/configs/exynos78x0-common.h b/include/configs/exynos78x0-common.h index 8d3449f028c3..6b1df63dc32f 100644 --- a/include/configs/exynos78x0-common.h +++ b/include/configs/exynos78x0-common.h @@ -36,8 +36,6 @@ #define CONFIG_SYS_BAUDRATE_TABLE \ {9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600} -#define CONFIG_BOARD_COMMON - #define CONFIG_SYS_SDRAM_BASE 0x4000 #define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_TEXT_BASE + SZ_2M - GENERATED_GBL_DATA_SIZE) /* DRAM Memory Banks */ diff --git a/include/configs/odroid_xu3.h b/include/configs/odroid_xu3.h index a4825982a898..616f25eafd3e 100644 --- a/include/configs/odroid_xu3.h +++ b/include/configs/odroid_xu3.h @@ -10,8 +10,6 @@ #include #include -#define CONFIG_BOARD_COMMON - #define CONFIG_SYS_SDRAM_BASE 0x4000 #define TZPC_BASE_OFFSET 0x1 diff --git a/include/configs/smdk5250.h b/include/configs/smdk5250.h index d7e86f2f7644..1ea3b650cd26 100644 --- a/include/configs/smdk5250.h +++ b/include/configs/smdk5250.h @@ -15,6 +15,4 @@ #undef CONFIG_EXYNOS_FB #undef CONFIG_EXYNOS_DP -#define CONFIG_BOARD_COMMON - #endif /* __CONFIG_SMDK_H */ diff --git a/include/configs/smdk5420.h b/include/configs/smdk5420.h index 38691b63dafe..f26995d5c1c9 100644 --- a/include/configs/smdk5420.h +++ b/include/configs/smdk5420.h @@ -15,8 +15,6 @@ #undef CONFIG_EXYNOS_FB #undef CONFIG_EXYNOS_DP -#define CONFIG_BOARD_COMMON - #define CONFIG_SMDK5420/* which is in a SMDK5420 */ #define CONFIG_SYS_SDRAM_BASE 0x2000 diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h index 32196a5aef94..84b8537e54df 100644 --- a/include/configs/smdkv310.h +++ b/include/configs/smdkv310.h @@ -10,7 +10,6 @@ #include "exynos4-common.h" -#undef CONFIG_BOARD_COMMON #undef CONFIG_USB_GADGET_DWC2_OTG_PHY /* High Level Configuration Options */ diff --git a/include/configs/snow.h b/include/configs/snow.h index c082b2d82d86..00d9b4d41673 100644 --- a/include/configs/snow.h +++ b/include/configs/snow.h @@ -15,6 +15,4 @@ #include #include -#define CONFIG_BOARD_COMMON - #endif /* __CONFIG_SNOW_H */ diff --git a/include/configs/spring.h b/include/configs/spring.h index 0b052453a51c..2f0a5807be0d 100644 --- a/include/configs/spring.h +++ b/include/configs/spring.h @@ -10,6 +10,4 @@ #include #include -#define CONFIG_BOARD_COMMON - #endif /* __CONFIG_SPRING_H */ diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index a6bc234f51ed..1e78d266aed4 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -37,7 +37,6 @@ CONFIG_BL2_OFFSET CONFIG_BL2_SIZE CONFIG_BOARDDIR CONFIG_BOARDNAME -CONFIG_BOARD_COMMON CONFIG_BOARD_ECC_SUPPORT CONFIG_BOARD_NAME CONFIG_BOARD_POSTCLK_INIT -- 2.25.1
[PATCH 2/4] Convert CONFIG_BTB to Kconfig
This converts the following to Kconfig: CONFIG_BTB Signed-off-by: Tom Rini --- arch/powerpc/cpu/mpc85xx/Kconfig | 10 ++ include/configs/MPC8548CDS.h | 1 - include/configs/P1010RDB.h | 1 - include/configs/P2041RDB.h | 1 - include/configs/T102xRDB.h | 1 - include/configs/T104xRDB.h | 1 - include/configs/T208xQDS.h | 1 - include/configs/T208xRDB.h | 1 - include/configs/T4240RDB.h | 1 - include/configs/corenet_ds.h | 1 - include/configs/kmcent2.h| 1 - include/configs/p1_p2_rdb_pc.h | 1 - include/configs/socrates.h | 1 - 13 files changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig index c308447d493a..a978eea1617a 100644 --- a/arch/powerpc/cpu/mpc85xx/Kconfig +++ b/arch/powerpc/cpu/mpc85xx/Kconfig @@ -317,6 +317,7 @@ config ARCH_MPC8540 config ARCH_MPC8544 bool + select BTB select FSL_LAW select SYS_CACHE_SHIFT_5 select SYS_FSL_ERRATUM_A005125 @@ -330,6 +331,7 @@ config ARCH_MPC8544 config ARCH_MPC8548 bool + select BTB select FSL_LAW select SYS_FSL_ERRATUM_A005125 select SYS_FSL_ERRATUM_NMG_DDR120 @@ -352,6 +354,7 @@ config ARCH_MPC8560 config ARCH_P1010 bool + select BTB select FSL_LAW select SYS_CACHE_SHIFT_5 select SYS_HAS_SERDES @@ -400,6 +403,7 @@ config ARCH_P1011 config ARCH_P1020 bool + select BTB select FSL_LAW select SYS_CACHE_SHIFT_5 select SYS_FSL_ERRATUM_A004508 @@ -496,6 +500,7 @@ config ARCH_P1025 config ARCH_P2020 bool + select BTB select FSL_LAW select SYS_CACHE_SHIFT_5 select SYS_FSL_ERRATUM_A004477 @@ -772,6 +777,9 @@ config MPC85XX_HAVE_RESET_VECTOR bool "Indicate reset vector at CONFIG_RESET_VECTOR_ADDRESS - 0xffc" depends on MPC85xx +config BTB + bool "toggle branch predition" + config BOOKE bool default y @@ -784,12 +792,14 @@ config E500 config E500MC bool + select BTB imply CMD_PCI help Enble PowerPC E500MC core config E6500 bool + select BTB help Enable PowerPC E6500 core diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h index e16d870a5e66..b5430c950d03 100644 --- a/include/configs/MPC8548CDS.h +++ b/include/configs/MPC8548CDS.h @@ -30,7 +30,6 @@ * These can be toggled for performance analysis, otherwise use default. */ #define CONFIG_L2_CACHE/* toggle L2 cache */ -#define CONFIG_BTB /* toggle branch predition */ /* * Only possible on E500 Version 2 or newer cores. diff --git a/include/configs/P1010RDB.h b/include/configs/P1010RDB.h index 106d1e6a4b7e..827edf484b76 100644 --- a/include/configs/P1010RDB.h +++ b/include/configs/P1010RDB.h @@ -151,7 +151,6 @@ * These can be toggled for performance analysis, otherwise use default. */ #define CONFIG_L2_CACHE/* toggle L2 cache */ -#define CONFIG_BTB /* toggle branch predition */ #define CONFIG_ENABLE_36BIT_PHYS diff --git a/include/configs/P2041RDB.h b/include/configs/P2041RDB.h index e6d5321070bf..027f1479319d 100644 --- a/include/configs/P2041RDB.h +++ b/include/configs/P2041RDB.h @@ -58,7 +58,6 @@ #define CONFIG_SYS_CACHE_STASHING #define CONFIG_BACKSIDE_L2_CACHE #define CONFIG_SYS_INIT_L2CSR0 L2CSR0_L2E -#define CONFIG_BTB /* toggle branch predition */ #define CONFIG_ENABLE_36BIT_PHYS diff --git a/include/configs/T102xRDB.h b/include/configs/T102xRDB.h index d24cfce8b3b9..2fe53bf6be9f 100644 --- a/include/configs/T102xRDB.h +++ b/include/configs/T102xRDB.h @@ -121,7 +121,6 @@ #define CONFIG_SYS_CACHE_STASHING #define CONFIG_BACKSIDE_L2_CACHE #define CONFIG_SYS_INIT_L2CSR0 L2CSR0_L2E -#define CONFIG_BTB /* toggle branch predition */ #ifdef CONFIG_DDR_ECC #define CONFIG_MEM_INIT_VALUE 0xdeadbeef #endif diff --git a/include/configs/T104xRDB.h b/include/configs/T104xRDB.h index 9433f14227bb..2c4ede960ec1 100644 --- a/include/configs/T104xRDB.h +++ b/include/configs/T104xRDB.h @@ -98,7 +98,6 @@ #define CONFIG_SYS_CACHE_STASHING #define CONFIG_BACKSIDE_L2_CACHE #define CONFIG_SYS_INIT_L2CSR0 L2CSR0_L2E -#define CONFIG_BTB /* toggle branch predition */ #ifdef CONFIG_DDR_ECC #define CONFIG_MEM_INIT_VALUE 0xdeadbeef #endif diff --git a/include/configs/T208xQDS.h b/include/configs/T208xQDS.h index a41f9f0d9b83..3fcab6a0213c 100644 --- a/include/configs/T208xQDS.h +++ b/include/configs/T208xQDS.h @@ -88,7 +88,6 @@ * These can be toggled for performance analysis, otherwise use default. */ #define CONFIG_SYS_CACHE_STASHING -#define CONFIG_BTB /* toggle branch predition */ #ifdef
[PATCH] gpio: slg7xl45106: Add support for slg7xl45106 i2c gpo expander
From: T Karthik Reddy slg7xl45106 is i2c based 8-bit gpo expander, gpo pins are set and get by writing and reading corresponding gpo bit value into its data register. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- MAINTAINERS | 1 + drivers/gpio/Kconfig| 8 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio_slg7xl45106.c | 115 4 files changed, 125 insertions(+) create mode 100644 drivers/gpio/gpio_slg7xl45106.c diff --git a/MAINTAINERS b/MAINTAINERS index a75f429cb972..055d7ec2043c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -638,6 +638,7 @@ F: arch/arm/mach-zynqmp/ F: drivers/clk/clk_zynqmp.c F: driver/firmware/firmware-zynqmp.c F: drivers/fpga/zynqpl.c +F: drivers/gpio/gpio_slg7xl45106.c F: drivers/gpio/zynq_gpio.c F: drivers/gpio/zynqmp_gpio_modepin.c F: drivers/i2c/i2c-cdns.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 8d0e47c67d9e..a9b3bb854f09 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -544,4 +544,12 @@ config ZYNQMP_GPIO_MODEPIN are accessed using xilinx firmware. In modepin register, [3:0] bits set direction, [7:4] bits read IO, [11:8] bits set/clear IO. +config SLG7XL45106_I2C_GPO + bool "slg7xl45106 i2c gpo expander" + depends on DM_GPIO + help + Support for slg7xl45106 i2c gpo expander. It is an i2c based + 8-bit gpo expander, all gpo lines are controlled by writing + value into data register. + endif diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 63e9be6034f2..dd288c497a70 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -71,3 +71,4 @@ obj-$(CONFIG_SIFIVE_GPIO) += sifive-gpio.o obj-$(CONFIG_NOMADIK_GPIO) += nmk_gpio.o obj-$(CONFIG_MAX7320_GPIO) += max7320_gpio.o obj-$(CONFIG_ZYNQMP_GPIO_MODEPIN) += zynqmp_gpio_modepin.o +obj-$(CONFIG_SLG7XL45106_I2C_GPO) += gpio_slg7xl45106.o diff --git a/drivers/gpio/gpio_slg7xl45106.c b/drivers/gpio/gpio_slg7xl45106.c new file mode 100644 index ..2cbf7488ad62 --- /dev/null +++ b/drivers/gpio/gpio_slg7xl45106.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * slg7xl45106_i2c_gpo driver + * + * Copyright (C) 2021 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define SLG7XL45106_REG0xdb + +static int slg7xl45106_i2c_gpo_direction_input(struct udevice *dev, + unsigned int offset) +{ + return 0; +} + +static int slg7xl45106_i2c_gpo_xlate(struct udevice *dev, +struct gpio_desc *desc, +struct ofnode_phandle_args *args) +{ + desc->offset = (unsigned int)args->args[0]; + + return 0; +} + +static int slg7xl45106_i2c_gpo_set_value(struct udevice *dev, +unsigned int offset, int value) +{ + int ret; + u8 val; + + ret = dm_i2c_read(dev, SLG7XL45106_REG, &val, 1); + if (ret) + return ret; + + if (value) + val |= BIT(offset); + else + val &= ~BIT(offset); + + return dm_i2c_write(dev, SLG7XL45106_REG, &val, 1); +} + +static int slg7xl45106_i2c_gpo_direction_output(struct udevice *dev, + unsigned int offset, int value) +{ + return slg7xl45106_i2c_gpo_set_value(dev, offset, value); +} + +static int slg7xl45106_i2c_gpo_get_value(struct udevice *dev, +unsigned int offset) +{ + int ret; + u8 val; + + ret = dm_i2c_read(dev, SLG7XL45106_REG, &val, 1); + if (ret) + return ret; + + return !!(val & BIT(offset)); +} + +static int slg7xl45106_i2c_gpo_get_function(struct udevice *dev, + unsigned int offset) +{ + return GPIOF_OUTPUT; +} + +static const struct dm_gpio_ops slg7xl45106_i2c_gpo_ops = { + .direction_input = slg7xl45106_i2c_gpo_direction_input, + .direction_output = slg7xl45106_i2c_gpo_direction_output, + .get_value = slg7xl45106_i2c_gpo_get_value, + .set_value = slg7xl45106_i2c_gpo_set_value, + .get_function = slg7xl45106_i2c_gpo_get_function, + .xlate = slg7xl45106_i2c_gpo_xlate, +}; + +static int slg7xl45106_i2c_gpo_probe(struct udevice *dev) +{ + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + const void *label_ptr; + + label_ptr = dev_read_prop(dev, "label", NULL); + if (label_ptr) { + uc_priv->bank_name = strdup(label_ptr); + if (!uc_priv->bank_name) + return -ENOMEM; + } else { + uc_priv->bank_name = dev->name; + } + + uc_priv->gpio_count = 8; + + return 0; +} + +static const stru
[PATCH 6/6] arm64: zynqmp: Fix level of gpio reset for usb on kv260 boards
Active level is low that's why it should be fixed. Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp-sck-kv-g-revA.dts | 2 +- arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts index 9445dace7393..85994bef7cc0 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts @@ -131,7 +131,7 @@ phys = <&psgtr 2 PHY_TYPE_USB3 0 1>; usbhub: usb5744 { /* u43 */ compatible = "microchip,usb5744"; - reset-gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>; }; }; diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index 28a3f3c21992..b81c2e6b7543 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -115,7 +115,7 @@ status = "okay"; compatible = "microchip,usb5744"; i2c-bus = <&i2c1>; - reset-gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>; }; }; -- 2.35.1
[PATCH 5/6] arm64: zynqmp: Enable DP driver for SOMs
The main reason is to send pmufw cfg overlay from U-Boot to PMUFW to enable access to DP. Overlay is sent when cls command is called and for that IP has to be enabled in carrier cards. And IP needs to be also enabled in SOM dt because with DTB reselection new DT is not parsed in pre reloc U-Boot instance. It is called from board_f via embedded_dtb_select(). That's why bind function is not able to allocate memory and it ends up with error: "Video device 'display@fd4a' cannot allocate frame buffer memory -ensure the device is set up before relocation" To avoid this situation DP is placed also to SOM where bind function is called and frame buffer memory is allocated and just reused after DTB reselection. Result is the same. There could be a problem in Linux with different DP configurations but that's need to be solved there because console should be on from u-boot already. Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 2 +- arch/arm/dts/zynqmp-sm-k26-revA.dts | 4 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index 6ea950a13f45..28a3f3c21992 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -92,7 +92,7 @@ }; &zynqmp_dpsub { - status = "disabled"; + status = "okay"; phy-names = "dp-phy0", "dp-phy1"; phys = <&psgtr 1 PHY_TYPE_DP 0 0>, <&psgtr 0 PHY_TYPE_DP 1 0>; assigned-clock-rates = <2700>, <2500>, <3>; diff --git a/arch/arm/dts/zynqmp-sm-k26-revA.dts b/arch/arm/dts/zynqmp-sm-k26-revA.dts index e9baf4cb4148..d242f8712b84 100644 --- a/arch/arm/dts/zynqmp-sm-k26-revA.dts +++ b/arch/arm/dts/zynqmp-sm-k26-revA.dts @@ -317,3 +317,7 @@ &ams_pl { status = "okay"; }; + +&zynqmp_dpsub { + status = "okay"; +}; -- 2.35.1
[PATCH 4/6] arm64: zynqmp: Switch to ethernet-phy-id in kv260
Use ethernet-phy-id compatible string to properly describe phy reset on kv260 boards. Previous description wasn't correct because reset was done for mdio bus to operate and it was in this case used for different purpose which was eth phy reset. With ethernet-phy-id phy reset happens only for the phy via phy framework. Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp-sck-kv-g-revA.dts | 6 -- arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 6 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts index f58ad69be311..9445dace7393 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts @@ -168,16 +168,18 @@ mdio: mdio { #address-cells = <1>; #size-cells = <0>; - reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>; - reset-delay-us = <2>; phy0: ethernet-phy@1 { #phy-cells = <1>; reg = <1>; + compatible = "ethernet-phy-id2000.a231"; ti,rx-internal-delay = ; ti,tx-internal-delay = ; ti,fifo-depth = ; ti,dp83867-rxctrl-strap-quirk; + reset-assert-us = <100>; + reset-deassert-us = <280>; + reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>; }; }; }; diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index 7236e03a5a74..6ea950a13f45 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -155,16 +155,18 @@ mdio: mdio { #address-cells = <1>; #size-cells = <0>; - reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>; - reset-delay-us = <2>; phy0: ethernet-phy@1 { #phy-cells = <1>; reg = <1>; + compatible = "ethernet-phy-id2000.a231"; ti,rx-internal-delay = ; ti,tx-internal-delay = ; ti,fifo-depth = ; ti,dp83867-rxctrl-strap-quirk; + reset-assert-us = <100>; + reset-deassert-us = <280>; + reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>; }; }; }; -- 2.35.1
[PATCH 3/6] arm64: zynqmp: Use assigned-clock-rates for setting up clock in SOM
With limited low level configuration done via psu-init only IPs connected on SOM are initialized and configured. All IPs connected to carrier card are not initialized. There is a need to do proper reset, pin configuration and also clock setting. The patch targets the last part which is setting up proper clock for USBs and SDs. Also setup proper bus width for SD cards. Signed-off-by: Michal Simek Signed-off-by: Sai Krishna Potthuri --- arch/arm/dts/zynqmp-clk-ccf.dtsi | 4 arch/arm/dts/zynqmp-sck-kv-g-revA.dts | 2 ++ arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 3 +++ arch/arm/dts/zynqmp-sm-k26-revA.dts | 1 + 4 files changed, 10 insertions(+) diff --git a/arch/arm/dts/zynqmp-clk-ccf.dtsi b/arch/arm/dts/zynqmp-clk-ccf.dtsi index 86b99070c4a8..7b09d7515186 100644 --- a/arch/arm/dts/zynqmp-clk-ccf.dtsi +++ b/arch/arm/dts/zynqmp-clk-ccf.dtsi @@ -215,10 +215,12 @@ &sdhci0 { clocks = <&zynqmp_clk SDIO0_REF>, <&zynqmp_clk LPD_LSBUS>; + assigned-clocks = <&zynqmp_clk SDIO0_REF>; }; &sdhci1 { clocks = <&zynqmp_clk SDIO1_REF>, <&zynqmp_clk LPD_LSBUS>; + assigned-clocks = <&zynqmp_clk SDIO1_REF>; }; &spi0 { @@ -255,10 +257,12 @@ &usb0 { clocks = <&zynqmp_clk USB0_BUS_REF>, <&zynqmp_clk USB3_DUAL_REF>; + assigned-clocks = <&zynqmp_clk USB0_BUS_REF>, <&zynqmp_clk USB3_DUAL_REF>; }; &usb1 { clocks = <&zynqmp_clk USB1_BUS_REF>, <&zynqmp_clk USB3_DUAL_REF>; + assigned-clocks = <&zynqmp_clk USB1_BUS_REF>, <&zynqmp_clk USB3_DUAL_REF>; }; &watchdog0 { diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts index 34fb592d4fa5..f58ad69be311 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts @@ -154,6 +154,8 @@ no-1-8-v; disable-wp; xlnx,mio-bank = <1>; + assigned-clock-rates = <187498123>; + bus-width = <8>; }; &gem3 { /* required by spec */ diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index 35247b0bbd2e..7236e03a5a74 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -109,6 +109,7 @@ pinctrl-0 = <&pinctrl_usb0_default>; phy-names = "usb3-phy"; phys = <&psgtr 2 PHY_TYPE_USB3 0 1>; + assigned-clock-rates = <25000>, <2000>; usb5744: usb-hub { /* u43 */ status = "okay"; @@ -140,6 +141,8 @@ clk-phase-sd-hs = <126>, <60>; clk-phase-uhs-sdr25 = <120>, <60>; clk-phase-uhs-ddr50 = <126>, <48>; + assigned-clock-rates = <187498123>; + bus-width = <8>; }; &gem3 { /* required by spec */ diff --git a/arch/arm/dts/zynqmp-sm-k26-revA.dts b/arch/arm/dts/zynqmp-sm-k26-revA.dts index 5f55df28f331..e9baf4cb4148 100644 --- a/arch/arm/dts/zynqmp-sm-k26-revA.dts +++ b/arch/arm/dts/zynqmp-sm-k26-revA.dts @@ -189,6 +189,7 @@ disable-wp; bus-width = <8>; xlnx,mio-bank = <0>; + assigned-clock-rates = <187498123>; }; &spi1 { /* MIO6, 9-11 */ -- 2.35.1
[PATCH 1/6] arm64: zynqmp: Move usb hub from i2c to usb node
Based on upstream discussion based on link below usb hub should be placed to usb node directly as child node. Based on this Linux driver was updated and the same change should be also reflected in kv260 board. Link: https://lore.kernel.org/all/cal_jsqjzbbu+uxqundzwg-uv0pasng55026ptwhkr5wqtxc...@mail.gmail.com/ Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index df054e152a77..01b14ebcb609 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -36,11 +36,7 @@ label = "ina260-u14"; reg = <0x40>; }; - usbhub: usb5744@2d { /* u43 */ - compatible = "microchip,usb5744"; - reg = <0x2d>; - reset-gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; - }; + /* u43 - 0x2d - USB hub */ /* u27 - 0xe0 - STDP4320 DP/HDMI splitter */ }; @@ -111,6 +107,13 @@ pinctrl-0 = <&pinctrl_usb0_default>; phy-names = "usb3-phy"; phys = <&psgtr 2 PHY_TYPE_USB3 0 1>; + + usb5744: usb-hub { /* u43 */ + status = "okay"; + compatible = "microchip,usb5744"; + i2c-bus = <&i2c1>; + reset-gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; + }; }; &dwc3_0 { -- 2.35.1
[PATCH 2/6] arm64: zynqmp: Setup clock for DP and DPDMA
Clocks are coming from shared HW design where these frequencies should be aligned with PLL setup. Signed-off-by: Michal Simek --- arch/arm/dts/zynqmp-clk-ccf.dtsi | 4 arch/arm/dts/zynqmp-sck-kv-g-revA.dts | 2 ++ arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/arch/arm/dts/zynqmp-clk-ccf.dtsi b/arch/arm/dts/zynqmp-clk-ccf.dtsi index 664e65896d7e..86b99070c4a8 100644 --- a/arch/arm/dts/zynqmp-clk-ccf.dtsi +++ b/arch/arm/dts/zynqmp-clk-ccf.dtsi @@ -279,10 +279,14 @@ &zynqmp_dpdma { clocks = <&zynqmp_clk DPDMA_REF>; + assigned-clocks = <&zynqmp_clk DPDMA_REF>; /* apll */ }; &zynqmp_dpsub { clocks = <&zynqmp_clk TOPSW_LSBUS>, <&zynqmp_clk DP_AUDIO_REF>, <&zynqmp_clk DP_VIDEO_REF>; + assigned-clocks = <&zynqmp_clk DP_STC_REF>, + <&zynqmp_clk DP_AUDIO_REF>, + <&zynqmp_clk DP_VIDEO_REF>; /* rpll, rpll, vpll */ }; diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts index 22602d8c33f8..34fb592d4fa5 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revA.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revA.dts @@ -115,10 +115,12 @@ status = "disabled"; phy-names = "dp-phy0", "dp-phy1"; phys = <&psgtr 1 PHY_TYPE_DP 0 0>, <&psgtr 0 PHY_TYPE_DP 1 0>; + assigned-clock-rates = <2700>, <2500>, <3>; }; &zynqmp_dpdma { status = "okay"; + assigned-clock-rates = <6>; }; &usb0 { diff --git a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts index 01b14ebcb609..35247b0bbd2e 100644 --- a/arch/arm/dts/zynqmp-sck-kv-g-revB.dts +++ b/arch/arm/dts/zynqmp-sck-kv-g-revB.dts @@ -95,10 +95,12 @@ status = "disabled"; phy-names = "dp-phy0", "dp-phy1"; phys = <&psgtr 1 PHY_TYPE_DP 0 0>, <&psgtr 0 PHY_TYPE_DP 1 0>; + assigned-clock-rates = <2700>, <2500>, <3>; }; &zynqmp_dpdma { status = "okay"; + assigned-clock-rates = <6>; }; &usb0 { -- 2.35.1
[PATCH 0/6] arm64: zynqmp: Update SOM boards
Hi, kv-g boards have been moved to new model where u-boot configures a lot of things at run time which requires updates in DTs especially in connection to enabling clocks for these platforms. There are also small adjustment to match the latest state. Thanks, Michal Michal Simek (6): arm64: zynqmp: Move usb hub from i2c to usb node arm64: zynqmp: Setup clock for DP and DPDMA arm64: zynqmp: Use assigned-clock-rates for setting up clock in SOM arm64: zynqmp: Switch to ethernet-phy-id in kv260 arm64: zynqmp: Enable DP driver for SOMs arm64: zynqmp: Fix level of gpio reset for usb on kv260 boards arch/arm/dts/zynqmp-clk-ccf.dtsi | 8 arch/arm/dts/zynqmp-sck-kv-g-revA.dts | 12 +--- arch/arm/dts/zynqmp-sck-kv-g-revB.dts | 26 ++ arch/arm/dts/zynqmp-sm-k26-revA.dts | 5 + 4 files changed, 40 insertions(+), 11 deletions(-) -- 2.35.1
[PATCH] usb: dwc3: Add support to reset usb ULPI phy
From: T Karthik Reddy When usb PHY initialization is done, the PHY need to be reset. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- drivers/usb/dwc3/Kconfig| 2 +- drivers/usb/dwc3/dwc3-generic.c | 28 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 62aa65bf0cd2..685bda3729e5 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -25,7 +25,7 @@ config USB_DWC3_OMAP config USB_DWC3_GENERIC bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)" - depends on DM_USB && USB_DWC3 && MISC + depends on DM_USB && USB_DWC3 && MISC && DM_GPIO help Select this for Xilinx ZynqMP and similar Platforms. This wrapper supports Host and Peripheral operation modes. diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index b1e019b5b91a..17d35a6dc60c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -25,6 +25,7 @@ #include #include #include +#include struct dwc3_glue_data { struct clk_bulk clks; @@ -42,6 +43,7 @@ struct dwc3_generic_priv { void *base; struct dwc3 dwc3; struct phy_bulk phys; + struct gpio_desc ulpi_reset; }; struct dwc3_generic_host_priv { @@ -77,6 +79,26 @@ static int dwc3_generic_probe(struct udevice *dev, if (rc && rc != -ENOTSUPP) return rc; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + rc = gpio_request_by_name(dev->parent, "reset-gpios", 0, + &priv->ulpi_reset, GPIOD_ACTIVE_LOW); + if (rc != -EBUSY && rc) + return rc; + + /* Toggle ulpi to reset the phy. */ + rc = dm_gpio_set_value(&priv->ulpi_reset, 1); + if (rc) + return rc; + + mdelay(5); + + rc = dm_gpio_set_value(&priv->ulpi_reset, 0); + if (rc) + return rc; + + mdelay(5); + } + if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) reset_deassert_bulk(&glue->resets); @@ -98,6 +120,12 @@ static int dwc3_generic_remove(struct udevice *dev, { struct dwc3 *dwc3 = &priv->dwc3; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + struct gpio_desc *ulpi_reset = &priv->ulpi_reset; + + dm_gpio_free(ulpi_reset->dev, ulpi_reset); + } + dwc3_remove(dwc3); dwc3_shutdown_phy(dev, &priv->phys); unmap_physmem(dwc3->regs, MAP_NOCACHE); -- 2.35.1
[PATCH] usb: dwc3: Add support for usb3-phy PHY configuration
When usb3-phy label is found, PHY driver is called and serdes line is initialized. This is preparation for serdes/psgtr driver to configure GT lines based on description in DT. Signed-off-by: Michal Simek --- drivers/usb/dwc3/dwc3-generic.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 01bd0ca190e3..b1e019b5b91a 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -409,6 +409,17 @@ static int dwc3_glue_probe(struct udevice *dev) struct udevice *child = NULL; int index = 0; int ret; + struct phy phy; + + ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); + if (!ret) { + ret = generic_phy_init(&phy); + if (ret) + return ret; + } else if (ret != -ENOENT) { + debug("could not get phy (err %d)\n", ret); + return ret; + } glue->regs = dev_read_addr(dev); @@ -420,6 +431,12 @@ static int dwc3_glue_probe(struct udevice *dev) if (ret) return ret; + if (phy.dev) { + ret = generic_phy_power_on(&phy); + if (ret) + return ret; + } + ret = device_find_first_child(dev, &child); if (ret) return ret; -- 2.35.1
[PATCH 2/2] dma: xilinx: Add Display Port DMA driver
Display Port (DP) has own dma driver that's why add this skeleton driver only for handling power domain setting and send configuration object to PMUFW to enable it. Signed-off-by: Michal Simek --- drivers/dma/Kconfig| 7 +++ drivers/dma/Makefile | 1 + drivers/dma/xilinx_dpdma.c | 43 ++ 3 files changed, 51 insertions(+) create mode 100644 drivers/dma/xilinx_dpdma.c diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index 9cacea88d0cb..0af546042119 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -68,6 +68,13 @@ config APBH_DMA help Enable APBH DMA driver. +config XILINX_DPDMA + bool "Enable ZynqMP Display Port DMA driver" + depends on DMA && ZYNQMP_POWER_DOMAIN + help + Enable support for Xilinx ZynqMP Display DMA driver. Currently + this file is used as placeholder for driver. The main reason is + to record compatible string and calling power domain driver. if APBH_DMA config APBH_DMA_BURST diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile index afab324461b9..a75572fe5dec 100644 --- a/drivers/dma/Makefile +++ b/drivers/dma/Makefile @@ -13,5 +13,6 @@ obj-$(CONFIG_SANDBOX_DMA) += sandbox-dma-test.o obj-$(CONFIG_TI_KSNAV) += keystone_nav.o keystone_nav_cfg.o obj-$(CONFIG_TI_EDMA3) += ti-edma3.o obj-$(CONFIG_DMA_LPC32XX) += lpc32xx_dma.o +obj-$(CONFIG_XILINX_DPDMA) += xilinx_dpdma.o obj-y += ti/ diff --git a/drivers/dma/xilinx_dpdma.c b/drivers/dma/xilinx_dpdma.c new file mode 100644 index ..d4ee21dfc07f --- /dev/null +++ b/drivers/dma/xilinx_dpdma.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Xilinx Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +/** + * struct zynqmp_dpdma_priv - Private structure + * @dev: Device uclass for video_ops + */ +struct zynqmp_dpdma_priv { + struct udevice *dev; +}; + +static int zynqmp_dpdma_probe(struct udevice *dev) +{ + /* Only placeholder for power domain driver */ + return 0; +} + +static const struct dma_ops zynqmp_dpdma_ops = { +}; + +static const struct udevice_id zynqmp_dpdma_ids[] = { + { .compatible = "xlnx,zynqmp-dpdma" }, + { } +}; + +U_BOOT_DRIVER(zynqmp_dpdma) = { + .name = "zynqmp_dpdma", + .id = UCLASS_DMA, + .of_match = zynqmp_dpdma_ids, + .ops = &zynqmp_dpdma_ops, + .probe = zynqmp_dpdma_probe, + .priv_auto = sizeof(struct zynqmp_dpdma_priv), +}; -- 2.35.1
[PATCH 1/2] video: Add skeleton driver for ZynqMP Display port driver
The reason for this driver is to use call power management driver to enable it in PMUFW. There is missing functionality now but should be added in near future. Signed-off-by: Michal Simek --- drivers/video/Kconfig| 8 + drivers/video/Makefile | 1 + drivers/video/zynqmp_dpsub.c | 66 3 files changed, 75 insertions(+) create mode 100644 drivers/video/zynqmp_dpsub.c diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index ff8e11f6489d..646fec70262c 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -680,6 +680,14 @@ config VIDEO_SEPS525 Enable support for the Syncoam PM-OLED display driver (RGB 160x128). Currently driver is supporting only SPI interface. +config VIDEO_ZYNQMP_DPSUB + bool "Enable video support for ZynqMP Display Port" + depends on DM_VIDEO && ZYNQMP_POWER_DOMAIN + help + Enable support for Xilinx ZynqMP Display Port. Currently this file + is used as placeholder for driver. The main reason is to record + compatible string and calling power domain driver. + source "drivers/video/nexell/Kconfig" config VIDEO diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 4038395b1289..2530791eb43a 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o obj-$(CONFIG_VIDEO_VESA) += vesa.o obj-$(CONFIG_VIDEO_SEPS525) += seps525.o +obj-$(CONFIG_VIDEO_ZYNQMP_DPSUB) += zynqmp_dpsub.o obj-y += bridge/ obj-y += sunxi/ diff --git a/drivers/video/zynqmp_dpsub.c b/drivers/video/zynqmp_dpsub.c new file mode 100644 index ..4ead663cd59f --- /dev/null +++ b/drivers/video/zynqmp_dpsub.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Xilinx Inc. + */ + +#include +#include +#include +#include +#include +#include + +#define WIDTH 640 +#define HEIGHT 480 + +/** + * struct zynqmp_dpsub_priv - Private structure + * @dev: Device uclass for video_ops + */ +struct zynqmp_dpsub_priv { + struct udevice *dev; +}; + +static int zynqmp_dpsub_probe(struct udevice *dev) +{ + struct video_priv *uc_priv = dev_get_uclass_priv(dev); + struct zynqmp_dpsub_priv *priv = dev_get_priv(dev); + + uc_priv->bpix = VIDEO_BPP16; + uc_priv->xsize = WIDTH; + uc_priv->ysize = HEIGHT; + uc_priv->rot = 0; + + priv->dev = dev; + + /* Only placeholder for power domain driver */ + return 0; +} + +static int zynqmp_dpsub_bind(struct udevice *dev) +{ + struct video_uc_plat *plat = dev_get_uclass_plat(dev); + + plat->size = WIDTH * HEIGHT * 16; + + return 0; +} + +static const struct video_ops zynqmp_dpsub_ops = { +}; + +static const struct udevice_id zynqmp_dpsub_ids[] = { + { .compatible = "xlnx,zynqmp-dpsub-1.7" }, + { } +}; + +U_BOOT_DRIVER(zynqmp_dpsub_video) = { + .name = "zynqmp_dpsub_video", + .id = UCLASS_VIDEO, + .of_match = zynqmp_dpsub_ids, + .ops = &zynqmp_dpsub_ops, + .plat_auto = sizeof(struct video_uc_plat), + .bind = zynqmp_dpsub_bind, + .probe = zynqmp_dpsub_probe, + .priv_auto = sizeof(struct zynqmp_dpsub_priv), +}; -- 2.35.1
[PATCH 0/2] xilinx: video: add skeleton drivers for zynqmp DP
Hi, add skeleton drivers for display port and display port DMA. The purpose of having sketon drivers is to use the whole power domain infrastructure is used. Without driver power domain driver is not asking for enabling power for these devices. That's why having simple driver is necessary because OS doesn't need to have a way to ask for enabling power for these devices. Thanks, Michal Michal Simek (2): video: Add skeleton driver for ZynqMP Display port driver dma: xilinx: Add Display Port DMA driver drivers/dma/Kconfig | 7 drivers/dma/Makefile | 1 + drivers/dma/xilinx_dpdma.c | 43 +++ drivers/video/Kconfig| 8 + drivers/video/Makefile | 1 + drivers/video/zynqmp_dpsub.c | 66 6 files changed, 126 insertions(+) create mode 100644 drivers/dma/xilinx_dpdma.c create mode 100644 drivers/video/zynqmp_dpsub.c -- 2.35.1
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
On Tue, 22 Feb 2022 21:47:57 +0100 Pali Rohár wrote: > On Thursday 17 February 2022 15:31:10 Marek Behún wrote: > > > + * But this command does not provide access to lock bit. > > > + */ > > > + if (word < 2) { > > > + in[0] = row; > > > + in[1] = word * 32; > > > + res = mbox_do_cmd(MBOX_CMD_OTP_READ_32B, in, 2, out, 2); > > > + if (res != -ENOSYS) { > > > + if (!res) > > > + *data = out[0]; > > > + return res; > > > + } > > > + /* Fallback for old version of CZ.NIC wtmi firmware. */ > > > + } > > > > I am afraid this is not correct, because Marvell's firmware reads the > > efuse without Error Correction. So it is possible for Marvell's command > > to return different value than CZ.NIC's command. > > This is not truth. CZ.NIC firmware for MBOX_CMD_OTP_READ command calls > efuse_read_row_no_ecc which is not doing error correction too. > > So both commands return same value, without error correction. Seems that I have trouble remembering what how I have actually implemented it :) Oh well. Sorry about this.
[PATCH 3/3] net: phy: Add support for ethernet-phy-id with gpio reset
Ethernet phy like dp83867 is using strapping resistors to setup PHY address. On Xilinx boards strapping is setup on wires which are connected to SOC where internal pull ups/downs influnce phy address. That's why there is a need to setup pins properly (via pinctrl driver for example) and then perform phy reset. I can be workarounded by reset gpio done for mdio bus but this is not working properly when multiply phys sitting on the same bus. That's why it needs to be done via ethernet-phy-id driver where dt binding has gpio reset per phy. DT binding is available here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/net/ethernet-phy.yaml The driver is are reading the vendor and device id from valid phy node using ofnode_read_eth_phy_id() and creating a phy device. Kconfig PHY_ETHERNET_ID symbol is used because not every platform has gpio support. Signed-off-by: Michal Simek Signed-off-by: T Karthik Reddy --- MAINTAINERS | 1 + drivers/net/phy/Kconfig | 8 drivers/net/phy/Makefile | 1 + drivers/net/phy/ethernet_id.c | 69 +++ drivers/net/phy/phy.c | 5 +++ include/phy.h | 13 +++ 6 files changed, 97 insertions(+) create mode 100644 drivers/net/phy/ethernet_id.c diff --git a/MAINTAINERS b/MAINTAINERS index c1a5ac95f295..a75f429cb972 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -617,6 +617,7 @@ F: drivers/i2c/muxes/pca954x.c F: drivers/i2c/zynq_i2c.c F: drivers/mmc/zynq_sdhci.c F: drivers/mtd/nand/raw/zynq_nand.c +F: drivers/net/phy/ethernet_id.c F: drivers/net/phy/xilinx_phy.c F: drivers/net/zynq_gem.c F: drivers/pinctrl/pinctrl-zynqmp.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 4f8d33ce8fd5..74339a25ca53 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -307,6 +307,14 @@ config PHY_XILINX_GMII2RGMII as bridge between MAC connected over GMII and external phy that is connected over RGMII interface. +config PHY_ETHERNET_ID + bool "Read ethernet PHY id" + depends on DM_GPIO + default y if ZYNQ_GEM + help + Enable this config to read ethernet phy id from the phy node of DT + and create a phy device using id. + config PHY_FIXED bool "Fixed-Link PHY" depends on DM_ETH diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 77f7f606215c..b28440bc4e52 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_PHY_TI_DP83867) += dp83867.o obj-$(CONFIG_PHY_TI_DP83869) += dp83869.o obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o +obj-$(CONFIG_PHY_ETHERNET_ID) += ethernet_id.o obj-$(CONFIG_PHY_VITESSE) += vitesse.o obj-$(CONFIG_PHY_MSCC) += mscc.o obj-$(CONFIG_PHY_FIXED) += fixed.o diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c new file mode 100644 index ..5617ac3ad62f --- /dev/null +++ b/drivers/net/phy/ethernet_id.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Xilinx ethernet phy reset driver + * + * Copyright (C) 2022 Xilinx, Inc. + */ + +#include +#include +#include +#include +#include + +struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, + phy_interface_t interface) +{ + struct phy_device *phydev; + struct ofnode_phandle_args phandle_args; + struct gpio_desc gpio; + ofnode node; + u32 id, assert, deassert; + u16 vendor, device; + int ret; + + if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, + &phandle_args)) + return NULL; + + if (!ofnode_valid(phandle_args.node)) + return NULL; + + node = phandle_args.node; + + ret = ofnode_read_eth_phy_id(node, &vendor, &device); + if (ret) { + dev_err(dev, "Failed to read eth PHY id, err: %d\n", ret); + return NULL; + } + + ret = gpio_request_by_name_nodev(node, "reset-gpios", 0, &gpio, +GPIOD_ACTIVE_LOW); + if (!ret) { + assert = ofnode_read_u32_default(node, "reset-assert-us", 0); + deassert = ofnode_read_u32_default(node, + "reset-deassert-us", 0); + ret = dm_gpio_set_value(&gpio, 1); + if (ret) { + dev_err(dev, "Failed assert gpio, err: %d\n", ret); + return NULL; + } + + udelay(assert); + + ret = dm_gpio_set_value(&gpio, 0); + if (ret) { + dev_err(dev, "Failed deassert gpio, err: %d\n", ret); + return NULL; + } + +
[PATCH 2/3] net: phy: Remove static return type for phy_device_create()
Remove static return type for phy_device_create() to avoid file scope for this function. Also add required prototype in phy.h. Signed-off-by: Michal Simek Signed-off-by: T Karthik Reddy --- drivers/net/phy/phy.c | 6 +++--- include/phy.h | 13 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index c9fc20855ba1..f63705e1b9a1 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -659,9 +659,9 @@ static struct phy_driver *get_phy_driver(struct phy_device *phydev, return generic_for_interface(interface); } -static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, - u32 phy_id, bool is_c45, - phy_interface_t interface) +struct phy_device *phy_device_create(struct mii_dev *bus, int addr, +u32 phy_id, bool is_c45, +phy_interface_t interface) { struct phy_device *dev; diff --git a/include/phy.h b/include/phy.h index c66fd43ea887..832d7a169578 100644 --- a/include/phy.h +++ b/include/phy.h @@ -454,6 +454,19 @@ void phy_connect_dev(struct phy_device *phydev, struct udevice *dev); struct phy_device *phy_connect(struct mii_dev *bus, int addr, struct udevice *dev, phy_interface_t interface); +/** + * phy_device_create() - Create a PHY device + * + * @bus: MII/MDIO bus that hosts the PHY + * @addr: PHY address on MDIO bus + * @phy_id:where to store the ID retrieved + * @is_c45:Device Identifiers if is_c45 + * @interface: interface between the MAC and PHY + * @return: pointer to phy_device if a PHY is found, or NULL otherwise + */ +struct phy_device *phy_device_create(struct mii_dev *bus, int addr, +u32 phy_id, bool is_c45, +phy_interface_t interface); static inline ofnode phy_get_ofnode(struct phy_device *phydev) { -- 2.35.1
[PATCH 1/3] net: phy: Add new read ethernet phy id function
Add new function to get ethernet phy id from compatible property of the mdio phy node. Signed-off-by: Michal Simek Signed-off-by: T Karthik Reddy --- drivers/core/ofnode.c | 36 include/dm/ofnode.h | 13 + 2 files changed, 49 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 709bea272a6e..8042847f3c14 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -898,6 +898,42 @@ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device) return -ENOENT; } +int ofnode_read_eth_phy_id(ofnode node, u16 *vendor, u16 *device) +{ + const char *list, *end; + int len; + + list = ofnode_get_property(node, "compatible", &len); + + if (!list) + return -ENOENT; + + end = list + len; + while (list < end) { + len = strlen(list); + + if (len >= strlen("ethernet-phy-id,")) { + char *s = strstr(list, "ethernet-phy-id"); + + /* +* check if the string is something like +* ethernet-phy-id, +*/ + if (s && s[19] == '.') { + s += strlen("ethernet-phy-id"); + *vendor = simple_strtol(s, NULL, 16); + s += 5; + *device = simple_strtol(s, NULL, 16); + + return 0; + } + } + list += (len + 1); + } + + return -ENOENT; +} + int ofnode_read_addr_cells(ofnode node) { if (ofnode_is_np(node)) { diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 0cb324c8b0c1..744dffe0a2dd 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -894,6 +894,19 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, */ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device); +/** + * ofnode_read_eth_phy_id() - look up eth phy vendor and device id + * + * Look at the compatible property of a device node that represents a eth phy + * device and extract phy vendor id and device id from it. + * + * @param node node to examine + * @param vendor vendor id of the eth phy device + * @param device device id of the eth phy device + * @return 0 if ok, negative on error + */ +int ofnode_read_eth_phy_id(ofnode node, u16 *vendor, u16 *device); + /** * ofnode_read_addr_cells() - Get the number of address cells for a node * -- 2.35.1
[PATCH 0/3] net: phy: Add support for ethernet-phy-id
Hi, this series is adding support for ethernet-phy-id with reset gpio support. There is another series related to DM_ETH_PHY but it is missing creating phy devices based on decoded phy IDs from compatible string. We would like to adopt DM_ETH_PHY in our driver but still this series can be useful for other drivers which are not DM_ETH_PHY ready. At the end this same file should be used also for DM_ETH_PHY driver. The reason for complete separatation from phy.c is that there is requirement for gpio headers which is not done by all arch. That's why new symbol and separate file is the way to go. Thanks, Michal Michal Simek (3): net: phy: Add new read ethernet phy id function net: phy: Remove static return type for phy_device_create() net: phy: Add support for ethernet-phy-id with gpio reset MAINTAINERS | 1 + drivers/core/ofnode.c | 36 ++ drivers/net/phy/Kconfig | 8 drivers/net/phy/Makefile | 1 + drivers/net/phy/ethernet_id.c | 69 +++ drivers/net/phy/phy.c | 11 -- include/dm/ofnode.h | 13 +++ include/phy.h | 26 + 8 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 drivers/net/phy/ethernet_id.c -- 2.35.1
[PATCH 4/4] mmc: zynq_sdhci: Add support for dynamic configuration
From: Ashok Reddy Soma Add support for dynamic configuration which will takes care of configuring the SD secure space configuration registers using firmware APIs, performing SD reset assert and deassert. High level sequence: - Check for the PM dynamic configuration support, if no error proceed with SD dynamic configurations(next steps) otherwise skip the dynamic configuration. - Put the SD Controller in reset. - Configure SD Fixed configurations. - Configure the SD Slot Type. - Configure the BASE_CLOCK. - Configure the 8-bit support. - Bring the SD Controller out of reset. In the above steps, apart from the Fixed configurations, remaining all configurations are dynamic and they will be read from devicetree. And also remove hardcoded secure register writes, as dynamic sd config support is added. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 101 ++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 33d00b06c777..d96f5d543f54 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -12,9 +12,12 @@ #include #include "mmc_private.h" #include +#include #include #include #include +#include +#include #include #include #include @@ -61,6 +64,7 @@ struct arasan_sdhci_priv { u8 deviceid; u8 bank; u8 no_1p8; + struct reset_ctl_bulk resets; }; /* For Versal platforms zynqmp_mmio_write() won't be available */ @@ -243,7 +247,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT; u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; - debug("%s\n", __func__); + dev_dbg(mmc->dev, "%s\n", __func__); host = priv->host; @@ -703,6 +707,87 @@ static const struct sdhci_ops arasan_ops = { }; #endif +#if defined(CONFIG_ARCH_ZYNQMP) +static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, + struct udevice *dev) +{ + int ret; + u32 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; + struct clk clk; + unsigned long clock, mhz; + + ret = xilinx_pm_request(PM_REQUEST_NODE, node_id, ZYNQMP_PM_CAPABILITY_ACCESS, + ZYNQMP_PM_MAX_QOS, ZYNQMP_PM_REQUEST_ACK_NO, NULL); + if (ret) { + dev_err(dev, "Request node failed for %d\n", node_id); + return ret; + } + + ret = reset_get_bulk(dev, &priv->resets); + if (ret == -ENOTSUPP || ret == -ENOENT) { + dev_err(dev, "Reset not found\n"); + return 0; + } else if (ret) { + dev_err(dev, "Reset failed\n"); + return ret; + } + + ret = reset_assert_bulk(&priv->resets); + if (ret) { + dev_err(dev, "Reset assert failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_FIXED, 0); + if (ret) { + dev_err(dev, "SD_CONFIG_FIXED failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_EMMC_SEL, + dev_read_bool(dev, "non-removable")); + if (ret) { + dev_err(dev, "SD_CONFIG_EMMC_SEL failed\n"); + return ret; + } + + ret = clk_get_by_index(dev, 0, &clk); + if (ret < 0) { + dev_err(dev, "failed to get clock\n"); + return ret; + } + + clock = clk_get_rate(&clk); + if (IS_ERR_VALUE(clock)) { + dev_err(dev, "failed to get rate\n"); + return clock; + } + + mhz = DIV64_U64_ROUND_UP(clock, 100); + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_BASECLK, mhz); + if (ret) { + dev_err(dev, "SD_CONFIG_BASECLK failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_8BIT, + (dev_read_u32_default(dev, "bus-width", 1) == 8)); + if (ret) { + dev_err(dev, "SD_CONFIG_8BIT failed\n"); + return ret; + } + + ret = reset_deassert_bulk(&priv->resets); + if (ret) { + dev_err(dev, "Reset release failed\n"); + return ret; + } + + return 0; +} +#endif + static int arasan_sdhci_probe(struct udevice *dev) { struct arasan_sdhci_plat *plat = dev_get_plat(dev); @@ -715,6 +800,18 @@ static int arasan_sdhci_probe(struct udevice *dev) host = priv->host; +#if defined(CONFIG_ARCH_ZYNQMP) + if (device_is_compatible(dev, "xlnx,zynqmp-8.9a")) { + ret = zynqmp_pm_is_function_supported(PM_IOCTL, + IOCTL_SET_SD_CONFIG); + if
[PATCH 2/4] firmware: zynqmp: Add support for set sd config and is function supported
From: Ashok Reddy Soma Add firmware API's to set SD configuration and to check if a purticular function is supported. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/firmware/firmware-zynqmp.c | 51 ++ include/zynqmp_firmware.h | 6 2 files changed, 57 insertions(+) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index 8d8492d99f7e..8916c5589635 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -140,6 +140,57 @@ unsigned int zynqmp_firmware_version(void) return pm_api_version; }; +int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value) +{ + int ret; + + ret = xilinx_pm_request(PM_IOCTL, node, IOCTL_SET_SD_CONFIG, + config, value, NULL); + if (ret) + printf("%s: node %d: set_sd_config %d failed\n", + __func__, node, config); + + return ret; +} + +int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) +{ + int ret; + u32 *bit_mask; + u32 ret_payload[PAYLOAD_ARG_CNT]; + + /* Input arguments validation */ + if (id >= 64 || (api_id != PM_IOCTL && api_id != PM_QUERY_DATA)) + return -EINVAL; + + /* Check feature check API version */ + ret = xilinx_pm_request(PM_FEATURE_CHECK, PM_FEATURE_CHECK, 0, 0, 0, + ret_payload); + if (ret) + return ret; + + /* Check if feature check version 2 is supported or not */ + if ((ret_payload[1] & FIRMWARE_VERSION_MASK) == PM_API_VERSION_2) { + /* +* Call feature check for IOCTL/QUERY API to get IOCTL ID or +* QUERY ID feature status. +*/ + + ret = xilinx_pm_request(PM_FEATURE_CHECK, api_id, 0, 0, 0, + ret_payload); + if (ret) + return ret; + + bit_mask = &ret_payload[2]; + if ((bit_mask[(id / 32)] & BIT((id % 32))) == 0) + return -EOPNOTSUPP; + } else { + return -ENODATA; + } + + return 0; +} + /** * Send a configuration object to the PMU firmware. * diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 6d7614f4af00..f577008736d9 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -438,6 +438,8 @@ int zynqmp_pmufw_config_close(void); void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 *ret_payload); +int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value); +int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id); /* Type of Config Object */ #define PM_CONFIG_OBJECT_TYPE_BASE 0x1U @@ -469,5 +471,9 @@ enum zynqmp_pm_request_ack { #define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U #define ZYNQMP_PM_MAX_QOS 100U +/* Firmware feature check version mask */ +#define FIRMWARE_VERSION_MASK GENMASK(15, 0) +/* PM API versions */ +#define PM_API_VERSION_2 2 #endif /* _ZYNQMP_FIRMWARE_H_ */ -- 2.35.1
[PATCH 3/4] lib: div64: Add support for round up of div64_u64
From: Ashok Reddy Soma Most of the frequencies are not rounded up to a proper number. When we need to devide these frequencies to get a number for example frequency in Mhz, we see it as one less than the actual intended value. Ex: If we want to get Mhz from frequency 19994hz, we will calculate it using div64_u64(19994, 100) and we will get 199Mhz in place of 200Mhz. Add a macro DIV64_U64_ROUND_UP for rounding up div64_u64. This is taken from linux 'commit 68600f623d69("mm: don't miss the last page because of round-off error")'. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/linux/math64.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/math64.h b/include/linux/math64.h index 08584c8f237f..eaa9fd5b9685 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h @@ -48,6 +48,9 @@ static inline u64 div64_u64(u64 dividend, u64 divisor) return dividend / divisor; } +#define DIV64_U64_ROUND_UP(ll, d) \ + ({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); }) + /** * div64_s64 - signed 64bit divide with 64bit divisor */ -- 2.35.1
[PATCH 0/4] mmc: zynq_sdhci: Add support for dynamic IP configuration
Hi, with SOM boards low level sdhci setting is not fully done. There are additional registers which are normally programmed via psu_init() but in this case they are not initialized. Information can be taken from DT and via firmware interface that values can be setup and that's exactly what this series is doing. Thanks, Michal Ashok Reddy Soma (4): firmware: zynqmp: Add and update firmware enums firmware: zynqmp: Add support for set sd config and is function supported lib: div64: Add support for round up of div64_u64 mmc: zynq_sdhci: Add support for dynamic configuration drivers/firmware/firmware-zynqmp.c | 51 +++ drivers/mmc/zynq_sdhci.c | 101 - include/linux/math64.h | 3 + include/zynqmp_firmware.h | 29 + 4 files changed, 182 insertions(+), 2 deletions(-) -- 2.35.1
[PATCH 1/4] firmware: zynqmp: Add and update firmware enums
From: Ashok Reddy Soma Update enum pm_ioctl_id with more IOCTLs. Add enum pm_sd_config_type to support dynamic sd configuration. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/zynqmp_firmware.h | 23 +++ 1 file changed, 23 insertions(+) diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 41abc2eee951..6d7614f4af00 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -383,6 +383,29 @@ enum pm_ioctl_id { IOCTL_GET_LAST_RESET_REASON = 23, /* AIE ISR Clear */ IOCTL_AIE_ISR_CLEAR = 24, + /* Register SGI to ATF */ + IOCTL_REGISTER_SGI = 25, + /* Runtime feature configuration */ + IOCTL_SET_FEATURE_CONFIG = 26, + IOCTL_GET_FEATURE_CONFIG = 27, + /* IOCTL for Secure Read/Write Interface */ + IOCTL_READ_REG = 28, + IOCTL_MASK_WRITE_REG = 29, + /* Dynamic SD/GEM/USB configuration */ + IOCTL_SET_SD_CONFIG = 30, + IOCTL_SET_GEM_CONFIG = 31, + IOCTL_SET_USB_CONFIG = 32, + /* AIE/AIEML Operations */ + IOCTL_AIE_OPS = 33, + /* IOCTL to get default/current QoS */ + IOCTL_GET_QOS = 34, +}; + +enum pm_sd_config_type { + SD_CONFIG_EMMC_SEL = 1, /* To set SD_EMMC_SEL in CTRL_REG_SD */ + SD_CONFIG_BASECLK = 2, /* To set SD_BASECLK in SD_CONFIG_REG1 */ + SD_CONFIG_8BIT = 3, /* To set SD_8BIT in SD_CONFIG_REG2 */ + SD_CONFIG_FIXED = 4,/* To set fixed config registers */ }; #define PM_SIP_SVC 0xc200 -- 2.35.1
Re: [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running
On Wed, 23 Feb 2022 14:21:40 +0100 Pali Rohár wrote: > If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit > is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot > is unable to use or kick this watchdog. > > Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same > behavior is implemented in Linux kernel driver. > > This change allows to activate watchdog in firmware which loads U-Boot. > > Signed-off-by: Pali Rohár Reviewed-by: Marek Behún
[PATCH 2/2] pinctrl: zynqmp: Add pinctrl driver
From: Ashok Reddy Soma Add pinctrl driver for Xilinx ZynqMP SOC. This driver is compatible with linux device tree parameters for configuring pinmux and pinconf. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-zynqmp.c | 644 +++ include/zynqmp_firmware.h| 43 +++ 5 files changed, 699 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-zynqmp.c diff --git a/MAINTAINERS b/MAINTAINERS index fb171e0c687b..c1a5ac95f295 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -619,6 +619,7 @@ F: drivers/mmc/zynq_sdhci.c F: drivers/mtd/nand/raw/zynq_nand.c F: drivers/net/phy/xilinx_phy.c F: drivers/net/zynq_gem.c +F: drivers/pinctrl/pinctrl-zynqmp.c F: drivers/serial/serial_zynq.c F: drivers/spi/zynq_qspi.c F: drivers/spi/zynq_spi.c diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 03946245c7d5..d7477d7c3364 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -318,6 +318,16 @@ config PINCTRL_K210 Support pin multiplexing on the K210. The "FPIOA" can remap any supported function to any multifunctional IO pin. It can also perform basic GPIO functions, such as reading the current value of a pin. + +config PINCTRL_ZYNQMP + bool "Xilinx ZynqMP pin control driver" + depends on DM && PINCTRL_GENERIC && ARCH_ZYNQMP + default y + help + Support pin multiplexing control on Xilinx ZynqMP. The driver uses + Generic Pinctrl framework and is compatible with the Linux driver, + i.e. it uses the same device tree configuration. + endif source "drivers/pinctrl/broadcom/Kconfig" diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index fd736a7f640a..d13433c5 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -30,3 +30,4 @@ obj-$(CONFIG_PINCTRL_STI) += pinctrl-sti.o obj-$(CONFIG_PINCTRL_STM32)+= pinctrl_stm32.o obj-$(CONFIG_$(SPL_)PINCTRL_STMFX) += pinctrl-stmfx.o obj-y += broadcom/ +obj-$(CONFIG_PINCTRL_ZYNQMP) += pinctrl-zynqmp.o diff --git a/drivers/pinctrl/pinctrl-zynqmp.c b/drivers/pinctrl/pinctrl-zynqmp.c new file mode 100644 index ..7c5a02db1b98 --- /dev/null +++ b/drivers/pinctrl/pinctrl-zynqmp.c @@ -0,0 +1,644 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Xilinx pinctrl driver for ZynqMP + * + * Author(s): Ashok Reddy Soma + * Michal Simek + * + * Copyright (C) 2021 Xilinx, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PINCTRL_GET_FUNC_GROUPS_RESP_LEN 12 +#define PINCTRL_GET_PIN_GROUPS_RESP_LEN12 +#define NUM_GROUPS_PER_RESP6 +#define NA_GROUP -1 +#define RESERVED_GROUP -2 +#define MAX_GROUP_PIN 50 +#define MAX_PIN_GROUPS 50 +#define MAX_GROUP_NAME_LEN 32 +#define MAX_FUNC_NAME_LEN 16 + +#define DRIVE_STRENGTH_2MA 2 +#define DRIVE_STRENGTH_4MA 4 +#define DRIVE_STRENGTH_8MA 8 +#define DRIVE_STRENGTH_12MA12 + +/* + * This driver works with very simple configuration that has the same name + * for group and function. This way it is compatible with the Linux Kernel + * driver. + */ +struct zynqmp_pinctrl_priv { + u32 npins; + u32 nfuncs; + u32 ngroups; + struct zynqmp_pmux_function *funcs; + struct zynqmp_pctrl_group *groups; +}; + +/** + * struct zynqmp_pinctrl_config - pinconfig parameters + * @slew: Slew rate slow or fast + * @bias: Bias enabled or disabled + * @pull_ctrl: Pull control pull up or pull down + * @input_type:CMOS or Schmitt + * @drive_strength:Drive strength 2mA/4mA/8mA/12mA + * @volt_sts: Voltage status 1.8V or 3.3V + * @tri_state: Tristate enabled or disabled + * + * This structure holds information about pin control config + * option that can be set for each pin. + */ +struct zynqmp_pinctrl_config { + u32 slew; + u32 bias; + u32 pull_ctrl; + u32 input_type; + u32 drive_strength; + u32 volt_sts; + u32 tri_state; +}; + +/** + * enum zynqmp_pin_config_param - possible pin configuration parameters + * @PIN_CONFIG_IOSTANDARD: if the pin can select an IO standard, + * the argument to this parameter (on a + * custom format) tells the driver which + * alternative IO standard to use + * @PIN_CONFIG_SCHMITTCMOS:this parameter (on a custom format) allows + * to select schmitt or cmos i
[PATCH 1/2] pinctrl: Increase length of pinmux status buffer
From: Ashok Reddy Soma Xilinx ZynqMP SOC can set 6 parameters for its pins. pinmux status command will print the status of these parameters for each pin. But current print buffer length is only 40 characters long, increase it to 80 to print all the parameters. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/dm/pinctrl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h index 0c461e56bb48..a09b242fd990 100644 --- a/include/dm/pinctrl.h +++ b/include/dm/pinctrl.h @@ -7,7 +7,7 @@ #define __PINCTRL_H #define PINNAME_SIZE 10 -#define PINMUX_SIZE40 +#define PINMUX_SIZE80 /** * struct pinconf_param - pin config parameters -- 2.35.1
[PATCH 3/3] mmc: zynq_sdhci: Enable card detect workaround for ZynqMP
From: Ashok Reddy Soma Card detect state stable issue is observed on few ZynqMP boards(SOM), so enable the workaround 'commit b6f44082d5cd ("mmc: zynq_sdhci: Wait till sd card detect state is stable")' for ZynqMP platforms also. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 7d62d05eda71..33d00b06c777 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -769,7 +769,7 @@ static int arasan_sdhci_probe(struct udevice *dev) * causing sd card timeout error. Workaround this by adding a wait for * 1000msec till the card detect state gets stable. */ - if (IS_ENABLED(CONFIG_ARCH_VERSAL)) { + if (IS_ENABLED(CONFIG_ARCH_ZYNQMP) || IS_ENABLED(CONFIG_ARCH_VERSAL)) { u32 timeout = 100; while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & -- 2.35.1
[PATCH 2/3] mmc: zynq_sdhci: Change granularity of timeout to 1us
From: Ashok Reddy Soma The timeout used in 'commit b6f44082d5cd ("mmc: zynq_sdhci: Wait till sd card detect state is stable")' workaround is 1000ms at a granularity of 1msec. Change it to 1usec, to not waste time incase the cd is stable. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index f4d69a2f7098..7d62d05eda71 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -770,11 +770,11 @@ static int arasan_sdhci_probe(struct udevice *dev) * 1000msec till the card detect state gets stable. */ if (IS_ENABLED(CONFIG_ARCH_VERSAL)) { - u32 timeout = 1000; + u32 timeout = 100; while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_STATE_STABLE) == 0) && timeout) { - mdelay(1); + udelay(1); timeout--; } if (!timeout) { -- 2.35.1
[PATCH 1/3] mmc: zynq_sdhci: Fix timeout issue
From: Ashok Reddy Soma In the workaround added with 'commit b6f44082d5cd ("mmc: zynq_sdhci: Wait till sd card detect state is stable")' the timeout variable has post decrement. Whenever timeout happens, this post decrement is making timeout=0x, so timeout error print and return statement are never reached. Fix it by decrementing it inside the while loop. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 5cea4c695e8d..f4d69a2f7098 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -773,8 +773,9 @@ static int arasan_sdhci_probe(struct udevice *dev) u32 timeout = 1000; while (((sdhci_readl(host, SDHCI_PRESENT_STATE) & -SDHCI_CARD_STATE_STABLE) == 0) && timeout--) { +SDHCI_CARD_STATE_STABLE) == 0) && timeout) { mdelay(1); + timeout--; } if (!timeout) { dev_err(dev, "Sdhci card detect state not stable\n"); -- 2.35.1
[PATCH 0/3] mmc: zynqmp_sdhci: Driver fixes
Hi, we found 3 issues recently with this driver which needs to be fixed. Thanks, Michal Ashok Reddy Soma (3): mmc: zynq_sdhci: Fix timeout issue mmc: zynq_sdhci: Change granularity of timeout to 1us mmc: zynq_sdhci: Enable card detect workaround for ZynqMP drivers/mmc/zynq_sdhci.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.35.1
[PATCH 2/2] ARM: dts: zynq: add NAND flash controller node
From: Michael Walle Recently, a driver for the ARM Primecell PL35x static memory controller (including NAND controller) was added in linux. Add the corresponding device tree node. Also update cfi-flash registers and location in DT. Signed-off-by: Michael Walle Signed-off-by: Amit Kumar Mahapatra Signed-off-by: Michal Simek Link: https://lore.kernel.org/r/20210616155437.27378-3-mich...@walle.cc --- arch/arm/dts/bitmain-antminer-s9.dts | 2 +- arch/arm/dts/zynq-7000.dtsi | 57 +++- arch/arm/dts/zynq-zc770-xm011.dts| 2 +- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/arch/arm/dts/bitmain-antminer-s9.dts b/arch/arm/dts/bitmain-antminer-s9.dts index 0694350555f5..408862bef042 100644 --- a/arch/arm/dts/bitmain-antminer-s9.dts +++ b/arch/arm/dts/bitmain-antminer-s9.dts @@ -50,7 +50,7 @@ ps-clk-frequency = <>; }; -&nand0 { +&nfc0 { status = "okay"; }; diff --git a/arch/arm/dts/zynq-7000.dtsi b/arch/arm/dts/zynq-7000.dtsi index 4dda753671c2..9495911397eb 100644 --- a/arch/arm/dts/zynq-7000.dtsi +++ b/arch/arm/dts/zynq-7000.dtsi @@ -246,33 +246,6 @@ #size-cells = <0>; }; - smcc: memory-controller@e000e000 { - #address-cells = <1>; - #size-cells = <1>; - status = "disabled"; - clock-names = "memclk", "apb_pclk"; - clocks = <&clkc 11>, <&clkc 44>; - compatible = "arm,pl353-smc-r2p1", "arm,primecell"; - interrupt-parent = <&intc>; - interrupts = <0 18 4>; - ranges ; - reg = <0xe000e000 0x1000>; - nand0: flash@e100 { - status = "disabled"; - compatible = "arm,pl353-nand-r2p1"; - reg = <0xe100 0x100>; - #address-cells = <1>; - #size-cells = <1>; - }; - nor0: flash@e200 { - status = "disabled"; - compatible = "cfi-flash"; - reg = <0xe200 0x200>; - #address-cells = <1>; - #size-cells = <1>; - }; - }; - gem0: ethernet@e000b000 { compatible = "cdns,zynq-gem", "cdns,gem"; reg = <0xe000b000 0x1000>; @@ -295,6 +268,36 @@ #size-cells = <0>; }; + smcc: memory-controller@e000e000 { + compatible = "arm,pl353-smc-r2p1", "arm,primecell"; + reg = <0xe000e000 0x0001000>; + status = "disabled"; + clock-names = "memclk", "apb_pclk"; + clocks = <&clkc 11>, <&clkc 44>; + ranges = <0x0 0x0 0xe100 0x100 /* Nand CS region */ + 0x1 0x0 0xe200 0x200 /* SRAM/NOR CS0 region */ + 0x2 0x0 0xe400 0x200>; /* SRAM/NOR CS1 region */ + #address-cells = <2>; + #size-cells = <1>; + interrupt-parent = <&intc>; + interrupts = <0 18 4>; + + nfc0: nand-controller@0,0 { + compatible = "arm,pl353-nand-r2p1"; + reg = <0 0 0x100>; + status = "disabled"; + #address-cells = <1>; + #size-cells = <1>; + }; + nor0: flash@1,0 { + status = "disabled"; + compatible = "cfi-flash"; + reg = <1 0 0x200>; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + sdhci0: mmc@e010 { compatible = "arasan,sdhci-8.9a"; status = "disabled"; diff --git a/arch/arm/dts/zynq-zc770-xm011.dts b/arch/arm/dts/zynq-zc770-xm011.dts index b6e3e255d731..0ef2ae1744f2 100644 --- a/arch/arm/dts/zynq-zc770-xm011.dts +++ b/arch/arm/dts/zynq-zc770-xm011.dts @@ -47,7 +47,7 @@ }; }; -&nand0 { +&nfc0 { status = "okay"; }; -- 2.35.1
[PATCH 1/2] mtd: nand: Update driver to match new DT binding
New binding changed node name from flash@e100 to nand-controller@0,0 which should be reflected in the driver. Both names are supported for backward compatibility. Signed-off-by: Michal Simek --- drivers/mtd/nand/raw/zynq_nand.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/zynq_nand.c b/drivers/mtd/nand/raw/zynq_nand.c index d79252837065..10e9cd18b077 100644 --- a/drivers/mtd/nand/raw/zynq_nand.c +++ b/drivers/mtd/nand/raw/zynq_nand.c @@ -1086,10 +1086,13 @@ static int zynq_nand_probe(struct udevice *dev) int is_16bit_bw; smc->reg = (struct zynq_nand_smc_regs *)dev_read_addr(dev); - of_nand = dev_read_subnode(dev, "flash@e100"); + of_nand = dev_read_subnode(dev, "nand-controller@0,0"); if (!ofnode_valid(of_nand)) { - printf("Failed to find nand node in dt\n"); - return -ENODEV; + of_nand = dev_read_subnode(dev, "flash@e100"); + if (!ofnode_valid(of_nand)) { + printf("Failed to find nand node in dt\n"); + return -ENODEV; + } } if (!ofnode_is_available(of_nand)) { -- 2.35.1
[PATCH 0/2] nand: zynq: Sync up with Linux
Hi, recently PL35x driver was upstreamed and there were some changes in DT binding which should be reflected here too. That's why sending these two patches to update the driver and the way how nand and nor memories are described in DT. Thanks, Michal Michael Walle (1): ARM: dts: zynq: add NAND flash controller node Michal Simek (1): mtd: nand: Update driver to match new DT binding arch/arm/dts/bitmain-antminer-s9.dts | 2 +- arch/arm/dts/zynq-7000.dtsi | 57 +++- arch/arm/dts/zynq-zc770-xm011.dts| 2 +- drivers/mtd/nand/raw/zynq_nand.c | 9 +++-- 4 files changed, 38 insertions(+), 32 deletions(-) -- 2.35.1
[PATCH] dm: pinctrl: Use explicit values for enums
From: Ashok Reddy Soma Based on discussion at https://lore.kernel.org/r/20200318125003.ga2727...@kroah.com we got recommendation to use explicit values for all enums. So, add explicit values to all pinctrl related enums for readability. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/dm/pinctrl.h | 48 ++-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h index 8b869c4fbfb7..0c461e56bb48 100644 --- a/include/dm/pinctrl.h +++ b/include/dm/pinctrl.h @@ -453,30 +453,30 @@ struct pinctrl_ops { * presented using the packed format. */ enum pin_config_param { - PIN_CONFIG_BIAS_BUS_HOLD, - PIN_CONFIG_BIAS_DISABLE, - PIN_CONFIG_BIAS_HIGH_IMPEDANCE, - PIN_CONFIG_BIAS_PULL_DOWN, - PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, - PIN_CONFIG_BIAS_PULL_UP, - PIN_CONFIG_DRIVE_OPEN_DRAIN, - PIN_CONFIG_DRIVE_OPEN_SOURCE, - PIN_CONFIG_DRIVE_PUSH_PULL, - PIN_CONFIG_DRIVE_STRENGTH, - PIN_CONFIG_DRIVE_STRENGTH_UA, - PIN_CONFIG_INPUT_DEBOUNCE, - PIN_CONFIG_INPUT_ENABLE, - PIN_CONFIG_INPUT_SCHMITT, - PIN_CONFIG_INPUT_SCHMITT_ENABLE, - PIN_CONFIG_LOW_POWER_MODE, - PIN_CONFIG_OUTPUT_ENABLE, - PIN_CONFIG_OUTPUT, - PIN_CONFIG_POWER_SOURCE, - PIN_CONFIG_SLEEP_HARDWARE_STATE, - PIN_CONFIG_SLEW_RATE, - PIN_CONFIG_SKEW_DELAY, - PIN_CONFIG_END = 0x7F, - PIN_CONFIG_MAX = 0xFF, + PIN_CONFIG_BIAS_BUS_HOLD = 0, + PIN_CONFIG_BIAS_DISABLE = 1, + PIN_CONFIG_BIAS_HIGH_IMPEDANCE = 2, + PIN_CONFIG_BIAS_PULL_DOWN = 3, + PIN_CONFIG_BIAS_PULL_PIN_DEFAULT = 4, + PIN_CONFIG_BIAS_PULL_UP = 5, + PIN_CONFIG_DRIVE_OPEN_DRAIN = 6, + PIN_CONFIG_DRIVE_OPEN_SOURCE = 7, + PIN_CONFIG_DRIVE_PUSH_PULL = 8, + PIN_CONFIG_DRIVE_STRENGTH = 9, + PIN_CONFIG_DRIVE_STRENGTH_UA = 10, + PIN_CONFIG_INPUT_DEBOUNCE = 11, + PIN_CONFIG_INPUT_ENABLE = 12, + PIN_CONFIG_INPUT_SCHMITT = 13, + PIN_CONFIG_INPUT_SCHMITT_ENABLE = 14, + PIN_CONFIG_LOW_POWER_MODE = 15, + PIN_CONFIG_OUTPUT_ENABLE = 16, + PIN_CONFIG_OUTPUT = 17, + PIN_CONFIG_POWER_SOURCE = 18, + PIN_CONFIG_SLEEP_HARDWARE_STATE = 19, + PIN_CONFIG_SLEW_RATE = 20, + PIN_CONFIG_SKEW_DELAY = 21, + PIN_CONFIG_END = 127, /* 0x7F */ + PIN_CONFIG_MAX = 255, /* 0xFF */ }; #if CONFIG_IS_ENABLED(PINCTRL_GENERIC) -- 2.35.1
[PATCH] Revert "board: zynqmp: Fix for wrong AMS setting by ROM"
From: T Karthik Reddy This reverts commit dfbe492edef421de09617dc26805fc428440924e. Analog bus control register should be programmed in SPL only. This commit 3414712ba8a ("arm64: zynqmp: Writing correct value to ANALOG_BUS") is programming the same. So revert this commit. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f1284..bc2090941d90 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -399,9 +399,6 @@ static void print_secure_boot(void) status & ZYNQMP_CSU_STATUS_ENCRYPTED ? "" : "not "); } -#define PS_SYSMON_ANALOG_BUS_VAL 0x3210 -#define PS_SYSMON_ANALOG_BUS_REG 0xFFA50914 - int board_init(void) { #if defined(CONFIG_ZYNQMP_FIRMWARE) @@ -429,9 +426,6 @@ int board_init(void) printf("EL Level:\tEL%d\n", current_el()); - /* Bug in ROM sets wrong value in this register */ - writel(PS_SYSMON_ANALOG_BUS_VAL, PS_SYSMON_ANALOG_BUS_REG); - #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) zynqmppl.name = zynqmp_get_silicon_idcode_name(); printf("Chip ID:\t%s\n", zynqmppl.name); -- 2.35.1
[PATCH 4/4] fru: ops: Add support to read mac addresses from multirecord
From: Ashok Reddy Soma Add support to read MAC addresses from mac address multirecord. Check if multi record is found, then jump to mac address multirecord by comparing the record type field. If it matches mac address multirecord(0xD2), then copy mac addresses. Copy these read MAC address in xilinx_read_eeprom_fru so that they are updated to eth*addr in board_late_init_xilinx(). Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 9 board/xilinx/common/fru.h | 21 +++ board/xilinx/common/fru_ops.c | 39 +++ 3 files changed, 69 insertions(+) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index db089c4a0b17..0769189dcf21 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -171,6 +171,7 @@ static int xilinx_read_eeprom_fru(struct udevice *dev, char *name, { int i, ret, eeprom_size; u8 *fru_content; + u8 id = 0; /* FIXME this is shortcut - if eeprom type is wrong it will fail */ eeprom_size = i2c_eeprom_size(dev); @@ -218,6 +219,14 @@ static int xilinx_read_eeprom_fru(struct udevice *dev, char *name, sizeof(desc->revision)); strncpy(desc->serial, (char *)fru_data.brd.serial_number, sizeof(desc->serial)); + + while (id < EEPROM_HDR_NO_OF_MAC_ADDR) { + if (is_valid_ethaddr((const u8 *)fru_data.mac.macid[id])) + memcpy(&desc->mac_addr[id], + (char *)fru_data.mac.macid[id], ETH_ALEN); + id++; + } + desc->header = EEPROM_HEADER_MAGIC; end: diff --git a/board/xilinx/common/fru.h b/board/xilinx/common/fru.h index e7284709ddea..59f6b722cf12 100644 --- a/board/xilinx/common/fru.h +++ b/board/xilinx/common/fru.h @@ -6,6 +6,7 @@ #ifndef __FRU_H #define __FRU_H +#include struct fru_common_hdr { u8 version; @@ -19,6 +20,7 @@ struct fru_common_hdr { }; #define FRU_BOARD_MAX_LEN 32 +#define FRU_MAX_NO_OF_MAC_ADDR 4 struct __packed fru_board_info_header { u8 ver; @@ -56,9 +58,24 @@ struct fru_board_data { u8 uuid[FRU_BOARD_MAX_LEN]; }; +struct fru_multirec_hdr { + u8 rec_type; + u8 type; + u8 len; + u8 csum; + u8 hdr_csum; +}; + +struct fru_multirec_mac { + u8 xlnx_iana_id[3]; + u8 ver; + u8 macid[FRU_MAX_NO_OF_MAC_ADDR][ETH_ALEN]; +}; + struct fru_table { struct fru_common_hdr hdr; struct fru_board_data brd; + struct fru_multirec_mac mac; bool captured; }; @@ -69,6 +86,10 @@ struct fru_table { #define FRU_LANG_CODE_ENGLISH 0 #define FRU_LANG_CODE_ENGLISH_125 #define FRU_TYPELEN_EOF0xC1 +#define FRU_MULTIREC_TYPE_OEM 0xD2 +#define FRU_MULTIREC_MAC_OFFSET4 +#define FRU_LAST_REC BIT(7) +#define FRU_DUT_MACID 0x31 /* This should be minimum of fields */ #define FRU_BOARD_AREA_TOTAL_FIELDS5 diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index 058e750c442f..49846ae3d660 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -218,10 +219,43 @@ static int fru_parse_board(unsigned long addr) return 0; } +static int fru_parse_multirec(unsigned long addr) +{ + struct fru_multirec_hdr mrc; + u8 checksum = 0; + u8 hdr_len = sizeof(struct fru_multirec_hdr); + int mac_len = 0; + + debug("%s: multirec addr %lx\n", __func__, addr); + + do { + memcpy(&mrc.rec_type, (void *)addr, hdr_len); + + checksum = fru_checksum((u8 *)addr, hdr_len); + if (checksum) { + debug("%s header CRC error\n", __func__); + return -EINVAL; + } + + if (mrc.rec_type == FRU_MULTIREC_TYPE_OEM) { + struct fru_multirec_mac *mac = (void *)addr + hdr_len; + + if (mac->ver == FRU_DUT_MACID) { + mac_len = mrc.len - FRU_MULTIREC_MAC_OFFSET; + memcpy(&fru_data.mac.macid, mac->macid, mac_len); + } + } + addr += mrc.len + hdr_len; + } while (!(mrc.type & FRU_LAST_REC)); + + return 0; +} + int fru_capture(unsigned long addr) { struct fru_common_hdr *hdr; u8 checksum = 0; + unsigned long multirec_addr = addr; checksum = fru_checksum((u8 *)addr, sizeof(struct fru_common_hdr)); if (checksum) { @@ -243,6 +277,11 @@ int fru_capture(unsigned long addr) env_set_hex("fru_addr", addr); + if (hdr->off_multirec) { + multirec_addr += fru_cal_area_len(hdr->off_multirec); +
[PATCH 3/4] xilinx: common: Optimise updating ethaddr from eeprom
From: Ashok Reddy Soma In board_late_init_xilinx() eth*addr are updated from the values read from eeprom. Ideally the MAC addresses are updated sequencially. So if any MAC address is invalid, it means there are no further valid values. So optimise this logic by replacing continue with break. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 0068cb879263..db089c4a0b17 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -416,7 +416,7 @@ int board_late_init_xilinx(void) for (i = 0; i < EEPROM_HDR_NO_OF_MAC_ADDR; i++) { if (!desc->mac_addr[i]) - continue; + break; if (is_valid_ethaddr((const u8 *)desc->mac_addr[i])) ret |= eth_env_set_enetaddr_by_index("eth", -- 2.35.1
[PATCH 1/4] fru: ops: Clear fru table before storing data
From: Ashok Reddy Soma Fill fru table with 0's before using it, to avoid junk data. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/common/fru_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index 6ed63bb7ee11..a0a1441a8eef 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -222,7 +222,7 @@ int fru_capture(unsigned long addr) } hdr = (struct fru_common_hdr *)addr; - + memset((void *)&fru_data, 0, sizeof(fru_data)); memcpy((void *)&fru_data, (void *)hdr, sizeof(struct fru_common_hdr)); -- 2.35.1
[PATCH 2/4] fru: ops: Return error from checksum if data is all zero's
From: Ashok Reddy Soma fru_checksum function is simply adding all the bytes and returning the sum. If the data passed to this function is all zero's then it will return 0, and the functions calling this api will assume that checksum is correct. Ideally this is not good. Fix this by returning error if all the data is 0's. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/common/fru_ops.c | 8 1 file changed, 8 insertions(+) diff --git a/board/xilinx/common/fru_ops.c b/board/xilinx/common/fru_ops.c index a0a1441a8eef..058e750c442f 100644 --- a/board/xilinx/common/fru_ops.c +++ b/board/xilinx/common/fru_ops.c @@ -39,12 +39,20 @@ static int fru_check_language(u8 code) u8 fru_checksum(u8 *addr, u8 len) { u8 checksum = 0; + u8 cnt = len; while (len--) { + if (*addr == 0) + cnt--; + checksum += *addr; addr++; } + /* If all data bytes are 0's return error */ + if (!cnt) + return EINVAL; + return checksum; } -- 2.35.1
[PATCH 0/4] xilinx: Fru tool update
Hi, the first 3 patches are fixes in current fru implementation to make sure that code is not working with incorrect data or not waste time. The last patch adds decoder for xilinx multirecord which stores MAC addresses for DUT. Thanks, Michal Ashok Reddy Soma (4): fru: ops: Clear fru table before storing data fru: ops: Return error from checksum if data is all zero's xilinx: common: Optimise updating ethaddr from eeprom fru: ops: Add support to read mac addresses from multirecord board/xilinx/common/board.c | 11 +++- board/xilinx/common/fru.h | 21 +++ board/xilinx/common/fru_ops.c | 49 ++- 3 files changed, 79 insertions(+), 2 deletions(-) -- 2.35.1
[PATCH] imx: imx8mm/imx8mn_beacon: Remove redundant code
The Ethernet controller and PHY use the device tree info to configure themselves, so it's not necessary to manually do it in the board file. This permits the removal of a bunch of headers as well. Signed-off-by: Adam Ford diff --git a/board/beacon/imx8mm/imx8mm_beacon.c b/board/beacon/imx8mm/imx8mm_beacon.c index c228bbf777..204235a3f8 100644 --- a/board/beacon/imx8mm/imx8mm_beacon.c +++ b/board/beacon/imx8mm/imx8mm_beacon.c @@ -1,52 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2020 Compass Electronics Group, LLC + * Copyright 2022 Logic PD, Inc. dba Beacon EmbeddedWorks */ -#include -#include -#include #include -#include -#include -#include - DECLARE_GLOBAL_DATA_PTR; -#if IS_ENABLED(CONFIG_FEC_MXC) -static int setup_fec(void) -{ - struct iomuxc_gpr_base_regs *gpr = - (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; - - /* Use 125M anatop REF_CLK1 for ENET1, not from external */ - clrsetbits_le32(&gpr->gpr[1], 0x2000, 0); - - return 0; -} - -int board_phy_config(struct phy_device *phydev) -{ - /* enable rgmii rxc skew and phy mode select to RGMII copper */ - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); - - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); - - if (phydev->drv->config) - phydev->drv->config(phydev); - return 0; -} -#endif - int board_init(void) { - if (IS_ENABLED(CONFIG_FEC_MXC)) - setup_fec(); - return 0; } diff --git a/board/beacon/imx8mn/imx8mn_beacon.c b/board/beacon/imx8mn/imx8mn_beacon.c index 6397dac872..204235a3f8 100644 --- a/board/beacon/imx8mn/imx8mn_beacon.c +++ b/board/beacon/imx8mn/imx8mn_beacon.c @@ -1,52 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2020 Compass Electronics Group, LLC + * Copyright 2022 Logic PD, Inc. dba Beacon EmbeddedWorks */ -#include -#include -#include - -#include -#include #include -#include DECLARE_GLOBAL_DATA_PTR; -#if IS_ENABLED(CONFIG_FEC_MXC) -static int setup_fec(void) -{ - struct iomuxc_gpr_base_regs *gpr = - (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR; - - /* Use 125M anatop REF_CLK1 for ENET1, not from external */ - clrsetbits_le32(&gpr->gpr[1], 0x2000, 0); - - return 0; -} - -int board_phy_config(struct phy_device *phydev) -{ - /* enable rgmii rxc skew and phy mode select to RGMII copper */ - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8); - - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); - phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100); - - if (phydev->drv->config) - phydev->drv->config(phydev); - return 0; -} -#endif - int board_init(void) { - if (IS_ENABLED(CONFIG_FEC_MXC)) - setup_fec(); - return 0; } -- 2.34.1