summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--arch/arm/cpu/armv8/fsl-layerscape/fdt.c9
-rw-r--r--arch/arm/dts/mt7622.dtsi19
-rw-r--r--arch/arm/dts/mt7623.dtsi17
-rw-r--r--arch/arm/dts/mt7629.dtsi16
-rw-r--r--arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h5
-rw-r--r--arch/arm/lib/bootm.c3
-rw-r--r--arch/powerpc/cpu/mpc8xxx/fdt.c9
-rw-r--r--board/freescale/ls1028a/ls1028a.c40
-rw-r--r--board/freescale/ls1046aqds/eth.c19
-rw-r--r--board/freescale/lx2160a/eth_lx2160aqds.c9
-rw-r--r--board/freescale/lx2160a/lx2160a.c2
-rw-r--r--board/freescale/t208xqds/eth_t208xqds.c29
-rw-r--r--cmd/Kconfig17
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/booti.c40
-rw-r--r--cmd/eeprom.c2
-rw-r--r--cmd/fat.c6
-rw-r--r--cmd/mem.c92
-rw-r--r--cmd/ubi.c39
-rw-r--r--cmd/unlz4.c45
-rw-r--r--common/image.c23
-rw-r--r--doc/README.SPL2
-rw-r--r--doc/README.distro12
-rw-r--r--doc/README.fdt-control2
-rw-r--r--doc/board/sifive/fu540.rst58
-rw-r--r--drivers/block/ide.c8
-rw-r--r--drivers/i2c/Kconfig8
-rw-r--r--drivers/i2c/Makefile1
-rw-r--r--drivers/i2c/davinci_i2c.c2
-rw-r--r--drivers/i2c/iproc_i2c.c713
-rw-r--r--drivers/i2c/iproc_i2c.h335
-rw-r--r--drivers/i2c/kona_i2c.c2
-rw-r--r--drivers/i2c/muxes/Kconfig4
-rw-r--r--drivers/i2c/muxes/pca954x.c6
-rw-r--r--drivers/i2c/sh_i2c.c2
-rw-r--r--drivers/i2c/soft_i2c.c2
-rw-r--r--drivers/net/fm/fm.c2
-rw-r--r--drivers/pwm/Kconfig7
-rw-r--r--drivers/pwm/Makefile1
-rw-r--r--drivers/pwm/pwm-mtk.c188
-rw-r--r--drivers/tee/optee/core.c13
-rw-r--r--env/nvram.c2
-rw-r--r--env/remote.c4
-rw-r--r--fs/btrfs/extent-io.c6
-rw-r--r--include/ata.h41
-rw-r--r--include/configs/ls1012afrwy.h7
-rw-r--r--include/image.h21
-rw-r--r--include/libata.h84
-rw-r--r--include/phy_interface.h23
-rw-r--r--lib/Kconfig5
-rwxr-xr-xscripts/documentation-file-ref-check226
-rw-r--r--tools/buildman/README171
-rw-r--r--tools/buildman/builder.py216
-rw-r--r--tools/buildman/builderthread.py6
-rw-r--r--tools/buildman/cmdline.py11
-rw-r--r--tools/buildman/control.py22
-rw-r--r--tools/buildman/func_test.py30
-rw-r--r--tools/buildman/test.py305
-rw-r--r--tools/dtoc/dtb_platdata.py4
-rwxr-xr-xtools/dtoc/dtoc.py2
-rw-r--r--tools/fit_image.c2
-rwxr-xr-xtools/patman/patman.py2
-rw-r--r--tools/patman/terminal.py110
64 files changed, 2688 insertions, 426 deletions
diff --git a/README b/README
index 19dae14ac0..7ebf9f577e 100644
--- a/README
+++ b/README
@@ -3203,9 +3203,9 @@ is done by typing:
make NAME_defconfig
where "NAME_defconfig" is the name of one of the existing configu-
-rations; see boards.cfg for supported names.
+rations; see configs/*_defconfig for supported names.
-Note: for some board special configuration names may exist; check if
+Note: for some boards special configuration names may exist; check if
additional information is available from the board vendor; for
instance, the TQM823L systems are available without (standard)
or with LCD support. You can select such additional "features"
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 87c3e05f45..077438765c 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2014-2015 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
*/
#include <common.h>
@@ -31,6 +32,14 @@
int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
{
+ const char *conn;
+
+ /* Do NOT apply fixup for backplane modes specified in DT */
+ if (phyc == PHY_INTERFACE_MODE_XGMII) {
+ conn = fdt_getprop(blob, offset, "phy-connection-type", NULL);
+ if (is_backplane_mode(conn))
+ return 0;
+ }
return fdt_setprop_string(blob, offset, "phy-connection-type",
phy_string_for_interface(phyc));
}
diff --git a/arch/arm/dts/mt7622.dtsi b/arch/arm/dts/mt7622.dtsi
index 1e8ec9b48b..f9ce0c6c3e 100644
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -227,4 +227,23 @@
#clock-cells = <1>;
};
+ pwm: pwm@11006000 {
+ compatible = "mediatek,mt7622-pwm";
+ reg = <0x11006000 0x1000>;
+ #clock-cells = <1>;
+ #pwm-cells = <2>;
+ interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&topckgen CLK_TOP_PWM_SEL>,
+ <&pericfg CLK_PERI_PWM_PD>,
+ <&pericfg CLK_PERI_PWM1_PD>,
+ <&pericfg CLK_PERI_PWM2_PD>,
+ <&pericfg CLK_PERI_PWM3_PD>,
+ <&pericfg CLK_PERI_PWM4_PD>,
+ <&pericfg CLK_PERI_PWM5_PD>,
+ <&pericfg CLK_PERI_PWM6_PD>;
+ clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4",
+ "pwm5", "pwm6";
+ status = "disabled";
+ };
+
};
diff --git a/arch/arm/dts/mt7623.dtsi b/arch/arm/dts/mt7623.dtsi
index 1f45dea575..0452889ef8 100644
--- a/arch/arm/dts/mt7623.dtsi
+++ b/arch/arm/dts/mt7623.dtsi
@@ -400,4 +400,21 @@
mediatek,ethsys = <&ethsys>;
status = "disabled";
};
+
+ pwm: pwm@11006000 {
+ compatible = "mediatek,mt7623-pwm";
+ reg = <0x11006000 0x1000>;
+ #clock-cells = <1>;
+ #pwm-cells = <2>;
+ clocks = <&topckgen CLK_TOP_PWM_SEL>,
+ <&pericfg CLK_PERI_PWM>,
+ <&pericfg CLK_PERI_PWM1>,
+ <&pericfg CLK_PERI_PWM2>,
+ <&pericfg CLK_PERI_PWM3>,
+ <&pericfg CLK_PERI_PWM4>,
+ <&pericfg CLK_PERI_PWM5>;
+ clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4",
+ "pwm5";
+ status = "disabled";
+ };
};
diff --git a/arch/arm/dts/mt7629.dtsi b/arch/arm/dts/mt7629.dtsi
index a33a74a556..644d2da4a8 100644
--- a/arch/arm/dts/mt7629.dtsi
+++ b/arch/arm/dts/mt7629.dtsi
@@ -281,4 +281,20 @@
reg = <0x1b130000 0x1000>;
#clock-cells = <1>;
};
+
+ pwm: pwm@11006000 {
+ compatible = "mediatek,mt7629-pwm";
+ reg = <0x11006000 0x1000>;
+ #clock-cells = <1>;
+ #pwm-cells = <2>;
+ interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&topckgen CLK_TOP_PWM_SEL>,
+ <&pericfg CLK_PERI_PWM_PD>,
+ <&pericfg CLK_PERI_PWM1_PD>;
+ clock-names = "top", "main", "pwm1";
+ assigned-clocks = <&topckgen CLK_TOP_PWM_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL2_D4>;
+ status = "disabled";
+ };
+
};
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
index 299201b157..c2fbc23b11 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -232,7 +232,12 @@
#define DCFG_PORSR1 0x000
#define DCFG_PORSR1_RCW_SRC 0xff800000
#define DCFG_PORSR1_RCW_SRC_NOR 0x12f00000
+#define DCFG_RCWSR12 0x12c
+#define DCFG_RCWSR12_SDHC_SHIFT 24
+#define DCFG_RCWSR12_SDHC_MASK 0x7
#define DCFG_RCWSR13 0x130
+#define DCFG_RCWSR13_SDHC_SHIFT 3
+#define DCFG_RCWSR13_SDHC_MASK 0x7
#define DCFG_RCWSR13_DSPI (0 << 8)
#define DCFG_RCWSR15 0x138
#define DCFG_RCWSR15_IFCGRPABASE_QSPI 0x3
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index a135bcfc7b..f4b5ca6de0 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -75,6 +75,9 @@ void arch_lmb_reserve(struct lmb *lmb)
gd->bd->bi_dram[bank].size - 1;
if (sp > bank_end)
continue;
+ if (bank_end > gd->ram_top)
+ bank_end = gd->ram_top - 1;
+
lmb_reserve(lmb, sp, bank_end - sp + 1);
break;
}
diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c
index 485c2d4feb..67f8b10001 100644
--- a/arch/powerpc/cpu/mpc8xxx/fdt.c
+++ b/arch/powerpc/cpu/mpc8xxx/fdt.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2009-2014 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
*
* This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and
* arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains
@@ -76,6 +77,14 @@ void ft_fixup_num_cores(void *blob) {
int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
{
+ const char *conn;
+
+ /* Do NOT apply fixup for backplane modes specified in DT */
+ if (phyc == PHY_INTERFACE_MODE_XGMII) {
+ conn = fdt_getprop(blob, offset, "phy-connection-type", NULL);
+ if (is_backplane_mode(conn))
+ return 0;
+ }
return fdt_setprop_string(blob, offset, "phy-connection-type",
phy_string_for_interface(phyc));
}
diff --git a/board/freescale/ls1028a/ls1028a.c b/board/freescale/ls1028a/ls1028a.c
index aa93534ac6..0b7504aea1 100644
--- a/board/freescale/ls1028a/ls1028a.c
+++ b/board/freescale/ls1028a/ls1028a.c
@@ -135,6 +135,46 @@ void detail_board_ddr_info(void)
print_ddr_info(0);
}
+int esdhc_status_fixup(void *blob, const char *compat)
+{
+ void __iomem *dcfg_ccsr = (void __iomem *)DCFG_BASE;
+ char esdhc1_path[] = "/soc/mmc@2140000";
+ char esdhc2_path[] = "/soc/mmc@2150000";
+ char dspi1_path[] = "/soc/spi@2100000";
+ char dspi2_path[] = "/soc/spi@2110000";
+ u32 mux_sdhc1, mux_sdhc2;
+ u32 io = 0;
+
+ /*
+ * The PMUX IO-expander for mux select is used to control
+ * the muxing of various onboard interfaces.
+ */
+
+ io = in_le32(dcfg_ccsr + DCFG_RCWSR12);
+ mux_sdhc1 = (io >> DCFG_RCWSR12_SDHC_SHIFT) & DCFG_RCWSR12_SDHC_MASK;
+
+ /* Disable esdhc1/dspi1 if not selected. */
+ if (mux_sdhc1 != 0)
+ do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
+ sizeof("disabled"), 1);
+ if (mux_sdhc1 != 2)
+ do_fixup_by_path(blob, dspi1_path, "status", "disabled",
+ sizeof("disabled"), 1);
+
+ io = in_le32(dcfg_ccsr + DCFG_RCWSR13);
+ mux_sdhc2 = (io >> DCFG_RCWSR13_SDHC_SHIFT) & DCFG_RCWSR13_SDHC_MASK;
+
+ /* Disable esdhc2/dspi2 if not selected. */
+ if (mux_sdhc2 != 0)
+ do_fixup_by_path(blob, esdhc2_path, "status", "disabled",
+ sizeof("disabled"), 1);
+ if (mux_sdhc2 != 2)
+ do_fixup_by_path(blob, dspi2_path, "status", "disabled",
+ sizeof("disabled"), 1);
+
+ return 0;
+}
+
#ifdef CONFIG_OF_BOARD_SETUP
int ft_board_setup(void *blob, bd_t *bd)
{
diff --git a/board/freescale/ls1046aqds/eth.c b/board/freescale/ls1046aqds/eth.c
index 1eb40677b5..1d40e8bd17 100644
--- a/board/freescale/ls1046aqds/eth.c
+++ b/board/freescale/ls1046aqds/eth.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2016 Freescale Semiconductor, Inc.
- * Copyright 2018-2019 NXP
+ * Copyright 2018-2020 NXP
*/
#include <common.h>
@@ -154,9 +154,7 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
enum fm_port port, int offset)
{
struct fixed_link f_link;
- const u32 *handle;
- const char *prop = NULL;
- int off;
+ const char *phyconn;
if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) {
switch (port) {
@@ -212,14 +210,11 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
"qsgmii");
} else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII &&
(port == FM1_10GEC1 || port == FM1_10GEC2)) {
- handle = fdt_getprop(fdt, offset, "phy-handle", NULL);
- prop = NULL;
- if (handle) {
- off = fdt_node_offset_by_phandle(fdt,
- fdt32_to_cpu(*handle));
- prop = fdt_getprop(fdt, off, "backplane-mode", NULL);
- }
- if (!prop || strcmp(prop, "10gbase-kr")) {
+ phyconn = fdt_getprop(fdt, offset, "phy-connection-type", NULL);
+ if (is_backplane_mode(phyconn)) {
+ /* Backplane KR mode: skip fixups */
+ printf("Interface %d in backplane KR mode\n", port);
+ } else {
/* XFI interface */
f_link.phy_id = cpu_to_fdt32(port);
f_link.duplex = cpu_to_fdt32(1);
diff --git a/board/freescale/lx2160a/eth_lx2160aqds.c b/board/freescale/lx2160a/eth_lx2160aqds.c
index 6500649d7b..0e928ebd86 100644
--- a/board/freescale/lx2160a/eth_lx2160aqds.c
+++ b/board/freescale/lx2160a/eth_lx2160aqds.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright 2018-2019 NXP
+ * Copyright 2018-2020 NXP
*
*/
@@ -616,6 +616,13 @@ int fdt_fixup_dpmac_phy_handle(void *fdt, int dpmac_id, int node_phandle)
return offset;
}
+ phy_string = fdt_getprop(fdt, offset, "phy-connection-type", NULL);
+ if (is_backplane_mode(phy_string)) {
+ /* Backplane KR mode: skip fixups */
+ printf("Interface %d in backplane KR mode\n", dpmac_id);
+ return 0;
+ }
+
ret = fdt_appendprop_cell(fdt, offset, "phy-handle", node_phandle);
if (ret)
printf("%d@%s %d\n", __LINE__, __func__, ret);
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index 4b20bb440f..23ea1b6f16 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -670,7 +670,7 @@ int ft_board_setup(void *blob, bd_t *bd)
u64 mc_memory_base = 0;
u64 mc_memory_size = 0;
u16 total_memory_banks;
- u64 gic_lpi_base;
+ u64 __maybe_unused gic_lpi_base;
ft_cpu_setup(blob, bd);
diff --git a/board/freescale/t208xqds/eth_t208xqds.c b/board/freescale/t208xqds/eth_t208xqds.c
index 23b59bcc09..697c23b038 100644
--- a/board/freescale/t208xqds/eth_t208xqds.c
+++ b/board/freescale/t208xqds/eth_t208xqds.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2013 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
*
* Shengzhou Liu <Shengzhou.Liu@freescale.com>
*/
@@ -200,6 +201,7 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
char buf[32] = "serdes-1,";
struct fixed_link f_link;
int media_type = 0;
+ const char *phyconn;
int off;
ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
@@ -412,15 +414,24 @@ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
}
if (!media_type) {
- /* fixed-link is used for XFI fiber cable */
- f_link.phy_id = port;
- f_link.duplex = 1;
- f_link.link_speed = 10000;
- f_link.pause = 0;
- f_link.asym_pause = 0;
- fdt_delprop(fdt, offset, "phy-handle");
- fdt_setprop(fdt, offset, "fixed-link", &f_link,
- sizeof(f_link));
+ phyconn = fdt_getprop(fdt, offset,
+ "phy-connection-type",
+ NULL);
+ if (is_backplane_mode(phyconn)) {
+ /* Backplane KR mode: skip fixups */
+ printf("Interface %d in backplane KR mode\n",
+ port);
+ } else {
+ /* fixed-link for XFI fiber cable */
+ f_link.phy_id = port;
+ f_link.duplex = 1;
+ f_link.link_speed = 10000;
+ f_link.pause = 0;
+ f_link.asym_pause = 0;
+ fdt_delprop(fdt, offset, "phy-handle");
+ fdt_setprop(fdt, offset, "fixed-link",
+ &f_link, sizeof(f_link));
+ }
} else {
/* set property for copper cable */
off = fdt_node_offset_by_compat_reg(fdt,
diff --git a/cmd/Kconfig b/cmd/Kconfig
index b81400c6ba..6ce9e5521c 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -770,6 +770,13 @@ config CMD_LZMADEC
Support decompressing an LZMA (Lempel-Ziv-Markov chain algorithm)
image from memory.
+config CMD_UNLZ4
+ bool "unlz4"
+ default y if CMD_BOOTI
+ select LZ4
+ help
+ Support decompressing an LZ4 image from memory region.
+
config CMD_UNZIP
bool "unzip"
default y if CMD_BOOTI
@@ -2100,7 +2107,7 @@ config CMD_BEDBUG
help
The bedbug (emBEDded deBUGger) command provides debugging features
for some PowerPC processors. For details please see the
- docuemntation in doc/README.beddbug
+ documentation in doc/README.bedbug.
config CMD_DIAG
bool "diag - Board diagnostics"
@@ -2177,6 +2184,14 @@ config CMD_UBI
It is also strongly encouraged to also enable CONFIG_MTD to get full
partition support.
+config CMD_UBI_RENAME
+ bool "Enable rename"
+ depends on CMD_UBI
+ default n
+ help
+ Enable a "ubi" command to rename ubi volume:
+ ubi rename <oldname> <newname>
+
config CMD_UBIFS
tristate "Enable UBIFS - Unsorted block images filesystem commands"
depends on CMD_UBI
diff --git a/cmd/Makefile b/cmd/Makefile
index f1dd513a4b..6692ed96c6 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -144,6 +144,7 @@ obj-$(CONFIG_CMD_TSI148) += tsi148.o
obj-$(CONFIG_CMD_UBI) += ubi.o
obj-$(CONFIG_CMD_UBIFS) += ubifs.o
obj-$(CONFIG_CMD_UNIVERSE) += universe.o
+obj-$(CONFIG_CMD_UNLZ4) += unlz4.o
obj-$(CONFIG_CMD_UNZIP) += unzip.o
obj-$(CONFIG_CMD_VIRTIO) += virtio.o
obj-$(CONFIG_CMD_WDT) += wdt.o
diff --git a/cmd/booti.c b/cmd/booti.c
index de5058236e..4fff8cfcf6 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/sizes.h>
+DECLARE_GLOBAL_DATA_PTR;
/*
* Image booting support
*/
@@ -24,6 +25,12 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
ulong ld;
ulong relocated_addr;
ulong image_size;
+ uint8_t *temp;
+ ulong dest;
+ ulong dest_end;
+ unsigned long comp_len;
+ unsigned long decomp_len;
+ int ctype;
ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
images, 1);
@@ -38,6 +45,33 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
debug("* kernel: cmdline image address = 0x%08lx\n", ld);
}
+ temp = map_sysmem(ld, 0);
+ ctype = image_decomp_type(temp, 2);
+ if (ctype > 0) {
+ dest = env_get_ulong("kernel_comp_addr_r", 16, 0);
+ comp_len = env_get_ulong("kernel_comp_size", 16, 0);
+ if (!dest || !comp_len) {
+ puts("kernel_comp_addr_r or kernel_comp_size is not provided!\n");
+ return -EINVAL;
+ }
+ if (dest < gd->ram_base || dest > gd->ram_top) {
+ puts("kernel_comp_addr_r is outside of DRAM range!\n");
+ return -EINVAL;
+ }
+
+ debug("kernel image compression type %d size = 0x%08lx address = 0x%08lx\n",
+ ctype, comp_len, (ulong)dest);
+ decomp_len = comp_len * 10;
+ ret = image_decomp(ctype, 0, ld, IH_TYPE_KERNEL,
+ (void *)dest, (void *)ld, comp_len,
+ decomp_len, &dest_end);
+ if (ret)
+ return ret;
+ /* dest_end contains the uncompressed Image size */
+ memmove((void *) ld, (void *)dest, dest_end);
+ }
+ unmap_sysmem((void *)ld);
+
ret = booti_setup(ld, &relocated_addr, &image_size, false);
if (ret != 0)
return 1;
@@ -100,10 +134,14 @@ int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef CONFIG_SYS_LONGHELP
static char booti_help_text[] =
"[addr [initrd[:size]] [fdt]]\n"
- " - boot Linux 'Image' stored at 'addr'\n"
+ " - boot Linux flat or compressed 'Image' stored at 'addr'\n"
"\tThe argument 'initrd' is optional and specifies the address\n"
"\tof an initrd in memory. The optional parameter ':size' allows\n"
"\tspecifying the size of a RAW initrd.\n"
+ "\tCurrently only booting from gz, bz2, lzma and lz4 compression\n"
+ "\ttypes are supported. In order to boot from any of these compressed\n"
+ "\timages, user have to set kernel_comp_addr_r and kernel_comp_size enviornment\n"
+ "\tvariables beforehand.\n"
#if defined(CONFIG_OF_LIBFDT)
"\tSince booting a Linux kernel requires a flat device-tree, a\n"
"\tthird argument providing the address of the device-tree blob\n"
diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index 667149e2d4..792415ef93 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -61,7 +61,7 @@
#endif
#if defined(CONFIG_DM_I2C)
-int eeprom_i2c_bus;
+static int eeprom_i2c_bus;
#endif
__weak int eeprom_write_enable(unsigned dev_addr, int state)
diff --git a/cmd/fat.c b/cmd/fat.c
index 50df127f6d..abce2f1e0c 100644
--- a/cmd/fat.c
+++ b/cmd/fat.c
@@ -8,13 +8,7 @@
* Boot support
*/
#include <common.h>
-#include <command.h>
-#include <s_record.h>
-#include <net.h>
-#include <ata.h>
-#include <asm/io.h>
#include <mapmem.h>
-#include <part.h>
#include <fat.h>
#include <fs.h>
diff --git a/cmd/mem.c b/cmd/mem.c
index 6d54f19527..0bfb6081e7 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -801,6 +801,59 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
return errs;
}
+static int compare_regions(volatile unsigned long *bufa,
+ volatile unsigned long *bufb, size_t count)
+{
+ volatile unsigned long *p1 = bufa;
+ volatile unsigned long *p2 = bufb;
+ int errs = 0;
+ size_t i;
+
+ for (i = 0; i < count; i++, p1++, p2++) {
+ if (*p1 != *p2) {
+ printf("FAILURE: 0x%08lx != 0x%08lx (delta=0x%08lx -> bit %ld) at offset 0x%08lx\n",
+ (unsigned long)*p1, (unsigned long)*p2,
+ *p1 ^ *p2, __ffs(*p1 ^ *p2),
+ (unsigned long)(i * sizeof(unsigned long)));
+ errs++;
+ }
+ }
+
+ return errs;
+}
+
+static ulong test_bitflip_comparison(volatile unsigned long *bufa,
+ volatile unsigned long *bufb, size_t count)
+{
+ volatile unsigned long *p1 = bufa;
+ volatile unsigned long *p2 = bufb;
+ unsigned int j, k;
+ unsigned long q;
+ size_t i;
+ int max;
+ int errs = 0;
+
+ max = sizeof(unsigned long) * 8;
+ for (k = 0; k < max; k++) {
+ q = 0x00000001L << k;
+ for (j = 0; j < 8; j++) {
+ WATCHDOG_RESET();
+ q = ~q;
+ p1 = (volatile unsigned long *)bufa;
+ p2 = (volatile unsigned long *)bufb;
+ for (i = 0; i < count; i++)
+ *p1++ = *p2++ = (i % 2) == 0 ? q : ~q;
+
+ errs += compare_regions(bufa, bufb, count);
+ }
+
+ if (ctrlc())
+ return -1UL;
+ }
+
+ return errs;
+}
+
static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr,
vu_long pattern, int iteration)
{
@@ -871,15 +924,10 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
ulong start, end;
vu_long *buf, *dummy;
ulong iteration_limit = 0;
- int ret;
+ ulong count = 0;
ulong errs = 0; /* number of errors, or -1 if interrupted */
ulong pattern = 0;
int iteration;
-#if defined(CONFIG_SYS_ALT_MEMTEST)
- const int alt_test = 1;
-#else
- const int alt_test = 0;
-#endif
start = CONFIG_SYS_MEMTEST_START;
end = CONFIG_SYS_MEMTEST_END;
@@ -921,40 +969,34 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
printf("Iteration: %6d\r", iteration + 1);
debug("\n");
- if (alt_test) {
+ if (IS_ENABLED(CONFIG_SYS_ALT_MEMTEST)) {
errs = mem_test_alt(buf, start, end, dummy);
+ if (errs == -1UL)
+ break;
+ count += errs;
+ errs = test_bitflip_comparison(buf,
+ buf + (end - start) / 2,
+ (end - start) /
+ sizeof(unsigned long));
} else {
errs = mem_test_quick(buf, start, end, pattern,
iteration);
}
if (errs == -1UL)
break;
+ count += errs;
}
- /*
- * Work-around for eldk-4.2 which gives this warning if we try to
- * case in the unmap_sysmem() call:
- * warning: initialization discards qualifiers from pointer target type
- */
- {
- void *vbuf = (void *)buf;
- void *vdummy = (void *)dummy;
-
- unmap_sysmem(vbuf);
- unmap_sysmem(vdummy);
- }
+ unmap_sysmem((void *)buf);
+ unmap_sysmem((void *)dummy);
if (errs == -1UL) {
/* Memory test was aborted - write a newline to finish off */
putc('\n');
- ret = 1;
- } else {
- printf("Tested %d iteration(s) with %lu errors.\n",
- iteration, errs);
- ret = errs != 0;
}
+ printf("Tested %d iteration(s) with %lu errors.\n", iteration, count);
- return ret;
+ return errs != 0;
}
#endif /* CONFIG_CMD_MEMTEST */
diff --git a/cmd/ubi.c b/cmd/ubi.c
index cecf251fdb..54d128dbc5 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -251,6 +251,39 @@ out_err:
return err;
}
+static int ubi_rename_vol(char *oldname, char *newname)
+{
+ struct ubi_volume *vol;
+ struct ubi_rename_entry rename;
+ struct ubi_volume_desc desc;
+ struct list_head list;
+
+ vol = ubi_find_volume(oldname);
+ if (!vol) {
+ printf("%s: volume %s doesn't exist\n", __func__, oldname);
+ return ENODEV;
+ }
+
+ printf("Rename UBI volume %s to %s\n", oldname, newname);
+
+ if (ubi->ro_mode) {
+ printf("%s: ubi device is in read-only mode\n", __func__);
+ return EROFS;
+ }
+
+ rename.new_name_len = strlen(newname);
+ strcpy(rename.new_name, newname);
+ rename.remove = 0;
+ desc.vol = vol;
+ desc.mode = 0;
+ rename.desc = &desc;
+ INIT_LIST_HEAD(&rename.list);
+ INIT_LIST_HEAD(&list);
+ list_add(&rename.list, &list);
+
+ return ubi_rename_volumes(ubi, &list);
+}
+
static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
{
int err = 1;
@@ -604,6 +637,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return ubi_remove_vol(argv[2]);
}
+ if (IS_ENABLED(CONFIG_CMD_UBI_RENAME) && !strncmp(argv[1], "rename", 6))
+ return ubi_rename_vol(argv[2], argv[3]);
+
if (strncmp(argv[1], "skipcheck", 9) == 0) {
/* E.g., change skip_check flag */
if (argc == 4) {
@@ -692,6 +728,9 @@ U_BOOT_CMD(
" - Read volume to address with size\n"
"ubi remove[vol] volume"
" - Remove volume\n"
+#if IS_ENABLED(CONFIG_CMD_UBI_RENAME)
+ "ubi rename oldname newname\n"
+#endif
"ubi skipcheck volume on/off - Set or clear skip_check flag in volume header\n"
"[Legends]\n"
" volume: character name\n"
diff --git a/cmd/unlz4.c b/cmd/unlz4.c
new file mode 100644
index 0000000000..5320b378d3
--- /dev/null
+++ b/cmd/unlz4.c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020
+ * FUJITSU COMPUTERTECHNOLOGIES LIMITED. All rights reserved.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <env.h>
+#include <lz4.h>
+
+static int do_unlz4(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ unsigned long src, dst;
+ size_t src_len = ~0UL, dst_len = ~0UL;
+ int ret;
+
+ switch (argc) {
+ case 4:
+ src = simple_strtoul(argv[1], NULL, 16);
+ dst = simple_strtoul(argv[2], NULL, 16);
+ dst_len = simple_strtoul(argv[3], NULL, 16);
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
+ ret = ulz4fn((void *)src, src_len, (void *)dst, &dst_len);
+ if (ret) {
+ printf("Uncompressed err :%d\n", ret);
+ return 1;
+ }
+
+ printf("Uncompressed size: %zd = 0x%zX\n", dst_len, dst_len);
+ env_set_hex("filesize", dst_len);
+
+ return 0;
+}
+
+U_BOOT_CMD(unlz4, 4, 1, do_unlz4,
+ "lz4 uncompress a memory region",
+ "srcaddr dstaddr dstsize\n"
+ "NOTE: Specify the destination size that is sufficiently larger\n"
+ " than the source size.\n"
+);
diff --git a/common/image.c b/common/image.c
index 94873cb6ed..d8d14e871c 100644
--- a/common/image.c
+++ b/common/image.c
@@ -202,6 +202,14 @@ struct table_info {
const table_entry_t *table;
};
+static const struct comp_magic_map image_comp[] = {
+ { IH_COMP_BZIP2, "bzip2", {0x42, 0x5a},},
+ { IH_COMP_GZIP, "gzip", {0x1f, 0x8b},},
+ { IH_COMP_LZMA, "lzma", {0x5d, 0x00},},
+ { IH_COMP_LZO, "lzo", {0x89, 0x4c},},
+ { IH_COMP_NONE, "none", {}, },
+};
+
static const struct table_info table_info[IH_COUNT] = {
{ "architecture", IH_ARCH_COUNT, uimage_arch },
{ "compression", IH_COMP_COUNT, uimage_comp },
@@ -407,6 +415,21 @@ static void print_decomp_msg(int comp_type, int type, bool is_xip)
printf(" Uncompressing %s\n", name);
}
+int image_decomp_type(const unsigned char *buf, ulong len)
+{
+ const struct comp_magic_map *cmagic = image_comp;
+
+ if (len < 2)
+ return -EINVAL;
+
+ for (; cmagic->comp_id > 0; cmagic++) {
+ if (!memcmp(buf, cmagic->magic, 2))
+ break;
+ }
+
+ return cmagic->comp_id;
+}
+
int image_decomp(int comp, ulong load, ulong image_start, int type,
void *load_buf, void *image_buf, ulong image_len,
uint unc_len, ulong *load_end)
diff --git a/doc/README.SPL b/doc/README.SPL
index 929b9672b0..2beb6d8f11 100644
--- a/doc/README.SPL
+++ b/doc/README.SPL
@@ -81,7 +81,7 @@ fdtgrep is also used to remove:
('u-boot,dm-pre-reloc', 'u-boot,dm-spl' and 'u-boot,dm-tpl')
All the nodes remaining in the SPL devicetree are bound
-(see driver-model/README.txt).
+(see doc/driver-model/design.rst).
Debugging
---------
diff --git a/doc/README.distro b/doc/README.distro
index ab6e6f4e74..5076bebd18 100644
--- a/doc/README.distro
+++ b/doc/README.distro
@@ -246,6 +246,18 @@ kernel_addr_r:
A size of 16MB for the kernel is likely adequate.
+kernel_comp_addr_r:
+ Optional. This is only required if user wants to boot Linux from a compressed
+ Image(.gz, .bz2, .lzma, .lzo) using booti command. It represents the location
+ in RAM where the compressed Image will be decompressed temporarily. Once the
+ decompression is complete, decompressed data will be moved kernel_addr_r for
+ booting.
+
+kernel_comp_size:
+ Optional. This is only required if user wants to boot Linux from a compressed
+ Image using booti command. It represents the size of the compressed file. The
+ size has to at least the size of loaded image for decompression to succeed.
+
pxefile_addr_r:
Mandatory. The location in RAM where extlinux.conf will be loaded to prior
diff --git a/doc/README.fdt-control b/doc/README.fdt-control
index e53cf51875..424d13fc5b 100644
--- a/doc/README.fdt-control
+++ b/doc/README.fdt-control
@@ -182,7 +182,7 @@ U-Boot can be divided into three phases: TPL, SPL and U-Boot proper.
The full device tree is available to U-Boot proper, but normally only a subset
(or none at all) is available to TPL and SPL. See 'Pre-Relocation Support' and
-'SPL Support' in doc/driver-model/README.txt for more details.
+'SPL Support' in doc/driver-model/design.rst for more details.
Using several DTBs in the SPL (CONFIG_SPL_MULTI_DTB)
diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
index 3937222c6c..610ba87074 100644
--- a/doc/board/sifive/fu540.rst
+++ b/doc/board/sifive/fu540.rst
@@ -135,6 +135,11 @@ load uImage.
=> setenv netmask 255.255.252.0
=> setenv serverip 10.206.4.143
=> setenv gateway 10.206.4.1
+
+If you want to use a flat kernel image such as Image file
+
+.. code-block:: none
+
=> tftpboot ${kernel_addr_r} /sifive/fu540/Image
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
@@ -174,6 +179,59 @@ load uImage.
1.2 MiB/s
done
Bytes transferred = 8867100 (874d1c hex)
+
+Or if you want to use a compressed kernel image file such as Image.gz
+
+.. code-block:: none
+
+ => tftpboot ${kernel_addr_r} /sifive/fu540/Image.gz
+ ethernet@10090000: PHY present at 0
+ ethernet@10090000: Starting autonegotiation...
+ ethernet@10090000: Autonegotiation complete
+ ethernet@10090000: link up, 1000Mbps full-duplex (lpa: 0x3c00)
+ Using ethernet@10090000 device
+ TFTP from server 10.206.4.143; our IP address is 10.206.7.133
+ Filename '/sifive/fu540/Image.gz'.
+ Load address: 0x84000000
+ Loading: #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ #################################################################
+ ##########################################
+ 1.2 MiB/s
+ done
+ Bytes transferred = 4809458 (4962f2 hex)
+ =>setenv kernel_comp_addr_r 0x90000000
+ =>setenv kernel_comp_size 0x500000
+
+By this time, correct kernel image is loaded and required enviornment variables
+are set. You can proceed to load the ramdisk and device tree from the tftp server
+as well.
+
+.. code-block:: none
+
=> tftpboot ${ramdisk_addr_r} /sifive/fu540/uRamdisk
ethernet@10090000: PHY present at 0
ethernet@10090000: Starting autonegotiation...
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 4b8a4eac17..67cc4fbc02 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -231,7 +231,7 @@ unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
(unsigned char) ((buflen >> 8) & 0xFF));
ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
- ide_outb(device, ATA_COMMAND, ATAPI_CMD_PACKET);
+ ide_outb(device, ATA_COMMAND, ATA_CMD_PACKET);
udelay(50);
mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
@@ -570,7 +570,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/*
* Start Ident Command
*/
- ide_outb(device, ATA_COMMAND, ATAPI_CMD_IDENT);
+ ide_outb(device, ATA_COMMAND, ATA_CMD_ID_ATAPI);
/*
* Wait for completion - ATAPI devices need more time
* to become ready
@@ -582,7 +582,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/*
* Start Ident Command
*/
- ide_outb(device, ATA_COMMAND, ATA_CMD_IDENT);
+ ide_outb(device, ATA_COMMAND, ATA_CMD_ID_ATA);
/*
* Wait for completion
@@ -966,7 +966,7 @@ ulong ide_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
/* first check if the drive is in Powersaving mode, if yes,
* increase the timeout value */
- ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_PWR);
+ ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_POWER);
udelay(50);
c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 03d2fed341..e42b6516bf 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -71,6 +71,14 @@ config SYS_I2C_AT91
i2c-gpio driver unless your system can cope with this limitation.
Binding info: doc/device-tree-bindings/i2c/i2c-at91.txt
+config SYS_I2C_IPROC
+ bool "Broadcom I2C driver"
+ depends on DM_I2C
+ help
+ Broadcom I2C driver.
+ Add support for Broadcom I2C driver.
+ Say yes here to to enable the Broadco I2C driver.
+
config SYS_I2C_FSL
bool "Freescale I2C bus driver"
depends on DM_I2C
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index f5a471f887..62935b7ebc 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o
obj-$(CONFIG_SYS_I2C_IMX_LPI2C) += imx_lpi2c.o
+obj-$(CONFIG_SYS_I2C_IPROC) += iproc_i2c.o
obj-$(CONFIG_SYS_I2C_KONA) += kona_i2c.o
obj-$(CONFIG_SYS_I2C_LPC32XX) += lpc32xx_i2c.o
obj-$(CONFIG_SYS_I2C_MESON) += meson_i2c.o
diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index 2c77234c60..edc40f706c 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -8,7 +8,7 @@
* --------------------------------------------------------
*
* NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
*/
#include <common.h>
diff --git a/drivers/i2c/iproc_i2c.c b/drivers/i2c/iproc_i2c.c
new file mode 100644
index 0000000000..a846e0a1fe
--- /dev/null
+++ b/drivers/i2c/iproc_i2c.c
@@ -0,0 +1,713 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Broadcom
+ *
+ */
+
+#include <asm/io.h>
+#include <common.h>
+#include <config.h>
+#include <dm.h>
+#include "errno.h"
+#include <i2c.h>
+#include "iproc_i2c.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct iproc_i2c_regs {
+ u32 cfg_reg;
+ u32 timg_cfg;
+ u32 addr_reg;
+ u32 mstr_fifo_ctrl;
+ u32 slv_fifo_ctrl;
+ u32 bitbng_ctrl;
+ u32 blnks[6]; /* Not to be used */
+ u32 mstr_cmd;
+ u32 slv_cmd;
+ u32 evt_en;
+ u32 evt_sts;
+ u32 mstr_datawr;
+ u32 mstr_datard;
+ u32 slv_datawr;
+ u32 slv_datard;
+};
+
+struct iproc_i2c {
+ struct iproc_i2c_regs __iomem *base; /* register base */
+ int bus_speed;
+ int i2c_init_done;
+};
+
+/* Function to read a value from specified register. */
+static unsigned int iproc_i2c_reg_read(u32 *reg_addr)
+{
+ unsigned int val;
+
+ val = readl((void *)(reg_addr));
+ return cpu_to_le32(val);
+}
+
+/* Function to write a value ('val') in to a specified register. */
+static int iproc_i2c_reg_write(u32 *reg_addr, unsigned int val)
+{
+ val = cpu_to_le32(val);
+ writel(val, (void *)(reg_addr));
+ return 0;
+}
+
+#if defined(DEBUG)
+static int iproc_dump_i2c_regs(struct iproc_i2c *bus_prvdata)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+
+ debug("\n----------------------------------------------\n");
+ debug("%s: Dumping SMBus registers...\n", __func__);
+
+ regval = iproc_i2c_reg_read(&base->cfg_reg);
+ debug("CCB_SMB_CFG_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->timg_cfg);
+ debug("CCB_SMB_TIMGCFG_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->addr_reg);
+ debug("CCB_SMB_ADDR_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->mstr_fifo_ctrl);
+ debug("CCB_SMB_MSTRFIFOCTL_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->slv_fifo_ctrl);
+ debug("CCB_SMB_SLVFIFOCTL_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->bitbng_ctrl);
+ debug("CCB_SMB_BITBANGCTL_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ debug("CCB_SMB_MSTRCMD_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->slv_cmd);
+ debug("CCB_SMB_SLVCMD_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->evt_en);
+ debug("CCB_SMB_EVTEN_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->evt_sts);
+ debug("CCB_SMB_EVTSTS_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->mstr_datawr);
+ debug("CCB_SMB_MSTRDATAWR_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->mstr_datard);
+ debug("CCB_SMB_MSTRDATARD_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->slv_datawr);
+ debug("CCB_SMB_SLVDATAWR_REG=0x%08X\n", regval);
+
+ regval = iproc_i2c_reg_read(&base->slv_datard);
+ debug("CCB_SMB_SLVDATARD_REG=0x%08X\n", regval);
+
+ debug("----------------------------------------------\n\n");
+ return 0;
+}
+#else
+static int iproc_dump_i2c_regs(struct iproc_i2c *bus_prvdata)
+{
+ return 0;
+}
+#endif
+
+/*
+ * Function to ensure that the previous transaction was completed before
+ * initiating a new transaction. It can also be used in polling mode to
+ * check status of completion of a command
+ */
+static int iproc_i2c_startbusy_wait(struct iproc_i2c *bus_prvdata)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+
+ /* Check if an operation is in progress. During probe it won't be.
+ * But when shutdown/remove was called we want to make sure that
+ * the transaction in progress completed
+ */
+ if (regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK) {
+ unsigned int i = 0;
+
+ do {
+ mdelay(10);
+ i++;
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+
+ /* If start-busy bit cleared, exit the loop */
+ } while ((regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK) &&
+ (i < IPROC_SMB_MAX_RETRIES));
+
+ if (i >= IPROC_SMB_MAX_RETRIES) {
+ pr_err("%s: START_BUSY bit didn't clear, exiting\n",
+ __func__);
+ return -ETIMEDOUT;
+ }
+ }
+ return 0;
+}
+
+/*
+ * This function set clock frequency for SMBus block. As per hardware
+ * engineering, the clock frequency can be changed dynamically.
+ */
+static int iproc_i2c_set_clk_freq(struct iproc_i2c *bus_prvdata)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+
+ regval = iproc_i2c_reg_read(&base->timg_cfg);
+
+ switch (bus_prvdata->bus_speed) {
+ case I2C_SPEED_STANDARD_RATE:
+ regval &= ~CCB_SMB_TIMGCFG_MODE400_MASK;
+ break;
+
+ case I2C_SPEED_FAST_RATE:
+ regval |= CCB_SMB_TIMGCFG_MODE400_MASK;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ iproc_i2c_reg_write(&base->timg_cfg, regval);
+ return 0;
+}
+
+static int iproc_i2c_init(struct udevice *bus)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+
+ debug("\nEntering %s\n", __func__);
+
+ /* Put controller in reset */
+ regval = iproc_i2c_reg_read(&base->cfg_reg);
+ regval |= CCB_SMB_CFG_RST_MASK;
+ regval &= ~CCB_SMB_CFG_SMBEN_MASK;
+ iproc_i2c_reg_write(&base->cfg_reg, regval);
+
+ /* Wait 100 usec as per spec */
+ udelay(100);
+
+ /* bring controller out of reset */
+ regval &= ~CCB_SMB_CFG_RST_MASK;
+ iproc_i2c_reg_write(&base->cfg_reg, regval);
+
+ /* Flush Tx, Rx FIFOs. Note we are setting the Rx FIFO threshold to 0.
+ * May be OK since we are setting RX_EVENT and RX_FIFO_FULL interrupts
+ */
+ regval = CCB_SMB_MSTRRXFIFOFLSH_MASK | CCB_SMB_MSTRTXFIFOFLSH_MASK;
+ iproc_i2c_reg_write(&base->mstr_fifo_ctrl, regval);
+
+ /* Enable SMbus block. Note, we are setting MASTER_RETRY_COUNT to zero
+ * since there will be only one master
+ */
+ regval = iproc_i2c_reg_read(&base->cfg_reg);
+ regval |= CCB_SMB_CFG_SMBEN_MASK;
+ iproc_i2c_reg_write(&base->cfg_reg, regval);
+
+ /* Set default clock frequency */
+ iproc_i2c_set_clk_freq(bus_prvdata);
+
+ /* Disable intrs */
+ iproc_i2c_reg_write(&base->evt_en, 0);
+
+ /* Clear intrs (W1TC) */
+ regval = iproc_i2c_reg_read(&base->evt_sts);
+ iproc_i2c_reg_write(&base->evt_sts, regval);
+
+ bus_prvdata->i2c_init_done = 1;
+
+ iproc_dump_i2c_regs(bus_prvdata);
+ debug("%s: Init successful\n", __func__);
+
+ return 0;
+}
+
+/*
+ * This function copies data to SMBus's Tx FIFO. Valid for write transactions
+ * only
+ *
+ * base_addr: Mapped address of this SMBus instance
+ * dev_addr: SMBus (I2C) device address. We are assuming 7-bit addresses
+ * initially
+ * info: Data to copy in to Tx FIFO. For read commands, the size should be
+ * set to zero by the caller
+ *
+ */
+static void iproc_i2c_write_trans_data(struct iproc_i2c *bus_prvdata,
+ unsigned short dev_addr,
+ struct iproc_xact_info *info)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+ unsigned int i;
+ unsigned int num_data_bytes = 0;
+
+ debug("%s: dev_addr=0x%X cmd_valid=%d cmd=0x%02x size=%u proto=%d buf[] %x\n",
+ __func__, dev_addr, info->cmd_valid,
+ info->command, info->size, info->smb_proto, info->data[0]);
+
+ /* Write SMBus device address first */
+ /* Note, we are assuming 7-bit addresses for now. For 10-bit addresses,
+ * we may have one more write to send the upper 3 bits of 10-bit addr
+ */
+ iproc_i2c_reg_write(&base->mstr_datawr, dev_addr);
+
+ /* If the protocol needs command code, copy it */
+ if (info->cmd_valid)
+ iproc_i2c_reg_write(&base->mstr_datawr, info->command);
+
+ /* Depending on the SMBus protocol, we need to write additional
+ * transaction data in to Tx FIFO. Refer to section 5.5 of SMBus
+ * spec for sequence for a transaction
+ */
+ switch (info->smb_proto) {
+ case SMBUS_PROT_RECV_BYTE:
+ /* No additional data to be written */
+ num_data_bytes = 0;
+ break;
+
+ case SMBUS_PROT_SEND_BYTE:
+ num_data_bytes = info->size;
+ break;
+
+ case SMBUS_PROT_RD_BYTE:
+ case SMBUS_PROT_RD_WORD:
+ case SMBUS_PROT_BLK_RD:
+ /* Write slave address with R/W~ set (bit #0) */
+ iproc_i2c_reg_write(&base->mstr_datawr,
+ dev_addr | 0x1);
+ num_data_bytes = 0;
+ break;
+
+ case SMBUS_PROT_BLK_WR_BLK_RD_PROC_CALL:
+ iproc_i2c_reg_write(&base->mstr_datawr,
+ dev_addr | 0x1 |
+ CCB_SMB_MSTRWRSTS_MASK);
+ num_data_bytes = 0;
+ break;
+
+ case SMBUS_PROT_WR_BYTE:
+ case SMBUS_PROT_WR_WORD:
+ /* No additional bytes to be written.
+ * Data portion is written in the
+ * 'for' loop below
+ */
+ num_data_bytes = info->size;
+ break;
+
+ case SMBUS_PROT_BLK_WR:
+ /* 3rd byte is byte count */
+ iproc_i2c_reg_write(&base->mstr_datawr, info->size);
+ num_data_bytes = info->size;
+ break;
+
+ default:
+ return;
+ }
+
+ /* Copy actual data from caller, next. In general, for reads,
+ * no data is copied
+ */
+ for (i = 0; num_data_bytes; --num_data_bytes, i++) {
+ /* For the last byte, set MASTER_WR_STATUS bit */
+ regval = (num_data_bytes == 1) ?
+ info->data[i] | CCB_SMB_MSTRWRSTS_MASK :
+ info->data[i];
+
+ iproc_i2c_reg_write(&base->mstr_datawr, regval);
+ }
+}
+
+static int iproc_i2c_data_send(struct iproc_i2c *bus_prvdata,
+ unsigned short addr,
+ struct iproc_xact_info *info)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ int rc, retry = 3;
+ unsigned int regval;
+
+ /* Make sure the previous transaction completed */
+ rc = iproc_i2c_startbusy_wait(bus_prvdata);
+
+ if (rc < 0) {
+ pr_err("%s: Send: bus is busy, exiting\n", __func__);
+ return rc;
+ }
+
+ /* Write transaction bytes to Tx FIFO */
+ iproc_i2c_write_trans_data(bus_prvdata, addr, info);
+
+ /* Program master command register (0x30) with protocol type and set
+ * start_busy_command bit to initiate the write transaction
+ */
+ regval = (info->smb_proto << CCB_SMB_MSTRSMBUSPROTO_SHIFT) |
+ CCB_SMB_MSTRSTARTBUSYCMD_MASK;
+
+ iproc_i2c_reg_write(&base->mstr_cmd, regval);
+
+ /* Check for Master status */
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ while (regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK) {
+ mdelay(10);
+ if (retry-- <= 0)
+ break;
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ }
+
+ /* If start_busy bit cleared, check if there are any errors */
+ if (!(regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK)) {
+ /* start_busy bit cleared, check master_status field now */
+ regval &= CCB_SMB_MSTRSTS_MASK;
+ regval >>= CCB_SMB_MSTRSTS_SHIFT;
+
+ if (regval != MSTR_STS_XACT_SUCCESS) {
+ /* Error We can flush Tx FIFO here */
+ pr_err("%s: ERROR: Error in transaction %u, exiting\n",
+ __func__, regval);
+ return -EREMOTEIO;
+ }
+ }
+
+ return 0;
+}
+
+static int iproc_i2c_data_recv(struct iproc_i2c *bus_prvdata,
+ unsigned short addr,
+ struct iproc_xact_info *info,
+ unsigned int *num_bytes_read)
+{
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ int rc, retry = 3;
+ unsigned int regval;
+
+ /* Make sure the previous transaction completed */
+ rc = iproc_i2c_startbusy_wait(bus_prvdata);
+
+ if (rc < 0) {
+ pr_err("%s: Receive: Bus is busy, exiting\n", __func__);
+ return rc;
+ }
+
+ /* Program all transaction bytes into master Tx FIFO */
+ iproc_i2c_write_trans_data(bus_prvdata, addr, info);
+
+ /* Program master command register (0x30) with protocol type and set
+ * start_busy_command bit to initiate the write transaction
+ */
+ regval = (info->smb_proto << CCB_SMB_MSTRSMBUSPROTO_SHIFT) |
+ CCB_SMB_MSTRSTARTBUSYCMD_MASK | info->size;
+
+ iproc_i2c_reg_write(&base->mstr_cmd, regval);
+
+ /* Check for Master status */
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ while (regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK) {
+ udelay(1000);
+ if (retry-- <= 0)
+ break;
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ }
+
+ /* If start_busy bit cleared, check if there are any errors */
+ if (!(regval & CCB_SMB_MSTRSTARTBUSYCMD_MASK)) {
+ /* start_busy bit cleared, check master_status field now */
+ regval &= CCB_SMB_MSTRSTS_MASK;
+ regval >>= CCB_SMB_MSTRSTS_SHIFT;
+
+ if (regval != MSTR_STS_XACT_SUCCESS) {
+ /* We can flush Tx FIFO here */
+ pr_err("%s: Error in transaction %d, exiting\n",
+ __func__, regval);
+ return -EREMOTEIO;
+ }
+ }
+
+ /* Read received byte(s), after TX out address etc */
+ regval = iproc_i2c_reg_read(&base->mstr_datard);
+
+ /* For block read, protocol (hw) returns byte count,
+ * as the first byte
+ */
+ if (info->smb_proto == SMBUS_PROT_BLK_RD) {
+ int i;
+
+ *num_bytes_read = regval & CCB_SMB_MSTRRDDATA_MASK;
+
+ /* Limit to reading a max of 32 bytes only; just a safeguard.
+ * If # bytes read is a number > 32, check transaction set up,
+ * and contact hw engg. Assumption: PEC is disabled
+ */
+ for (i = 0;
+ (i < *num_bytes_read) && (i < I2C_SMBUS_BLOCK_MAX);
+ i++) {
+ /* Read Rx FIFO for data bytes */
+ regval = iproc_i2c_reg_read(&base->mstr_datard);
+ info->data[i] = regval & CCB_SMB_MSTRRDDATA_MASK;
+ }
+ } else {
+ /* 1 Byte data */
+ *info->data = regval & CCB_SMB_MSTRRDDATA_MASK;
+ *num_bytes_read = 1;
+ }
+
+ return 0;
+}
+
+static int i2c_write_byte(struct iproc_i2c *bus_prvdata,
+ u8 devaddr, u8 regoffset, u8 value)
+{
+ int rc;
+ struct iproc_xact_info info;
+
+ devaddr <<= 1;
+
+ info.cmd_valid = 1;
+ info.command = (unsigned char)regoffset;
+ info.data = &value;
+ info.size = 1;
+ info.flags = 0;
+ info.smb_proto = SMBUS_PROT_WR_BYTE;
+ /* Refer to i2c_smbus_write_byte params passed. */
+ rc = iproc_i2c_data_send(bus_prvdata, devaddr, &info);
+
+ if (rc < 0) {
+ pr_err("%s: %s error accessing device 0x%X\n",
+ __func__, "Write", devaddr);
+ return -EREMOTEIO;
+ }
+
+ return 0;
+}
+
+int i2c_write(struct udevice *bus,
+ uchar chip, uint regaddr, int alen, uchar *buffer, int len)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ int i, data_len;
+ u8 *data;
+
+ if (len > 256) {
+ pr_err("I2C write: address out of range\n");
+ return 1;
+ }
+
+ if (len < 1) {
+ pr_err("I2C write: Need offset addr and value\n");
+ return 1;
+ }
+
+ /* buffer contains offset addr followed by value to be written */
+ regaddr = buffer[0];
+ data = &buffer[1];
+ data_len = len - 1;
+
+ for (i = 0; i < data_len; i++) {
+ if (i2c_write_byte(bus_prvdata, chip, regaddr + i, data[i])) {
+ pr_err("I2C write (%d): I/O error\n", i);
+ iproc_i2c_init(bus);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int i2c_read_byte(struct iproc_i2c *bus_prvdata,
+ u8 devaddr, u8 regoffset, u8 *value)
+{
+ int rc;
+ struct iproc_xact_info info;
+ unsigned int num_bytes_read = 0;
+
+ devaddr <<= 1;
+
+ info.cmd_valid = 1;
+ info.command = (unsigned char)regoffset;
+ info.data = value;
+ info.size = 1;
+ info.flags = 0;
+ info.smb_proto = SMBUS_PROT_RD_BYTE;
+ /* Refer to i2c_smbus_read_byte for params passed. */
+ rc = iproc_i2c_data_recv(bus_prvdata, devaddr, &info, &num_bytes_read);
+
+ if (rc < 0) {
+ pr_err("%s: %s error accessing device 0x%X\n",
+ __func__, "Read", devaddr);
+ return -EREMOTEIO;
+ }
+
+ return 0;
+}
+
+int i2c_read(struct udevice *bus,
+ uchar chip, uint addr, int alen, uchar *buffer, int len)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ int i;
+
+ if (len > 256) {
+ pr_err("I2C read: address out of range\n");
+ return 1;
+ }
+
+ for (i = 0; i < len; i++) {
+ if (i2c_read_byte(bus_prvdata, chip, addr + i, &buffer[i])) {
+ pr_err("I2C read: I/O error\n");
+ iproc_i2c_init(bus);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int iproc_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
+{
+ int ret = 0;
+
+ debug("%s: %d messages\n", __func__, nmsgs);
+
+ for (; nmsgs > 0; nmsgs--, msg++) {
+ if (msg->flags & I2C_M_RD)
+ ret = i2c_read(bus, msg->addr, 0, 0,
+ msg->buf, msg->len);
+ else
+ ret = i2c_write(bus, msg->addr, 0, 0,
+ msg->buf, msg->len);
+ }
+
+ return ret;
+}
+
+static int iproc_i2c_probe_chip(struct udevice *bus, uint chip_addr,
+ uint chip_flags)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ u32 regval;
+
+ debug("\n%s: Entering chip probe\n", __func__);
+
+ /* Init internal regs, disable intrs (and then clear intrs), set fifo
+ * thresholds, etc.
+ */
+ if (!bus_prvdata->i2c_init_done)
+ iproc_i2c_init(bus);
+
+ regval = (chip_addr << 1);
+ iproc_i2c_reg_write(&base->mstr_datawr, regval);
+ regval = ((SMBUS_PROT_QUICK_CMD << CCB_SMB_MSTRSMBUSPROTO_SHIFT) |
+ (1 << CCB_SMB_MSTRSTARTBUSYCMD_SHIFT));
+ iproc_i2c_reg_write(&base->mstr_cmd, regval);
+
+ do {
+ udelay(100);
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+ regval &= CCB_SMB_MSTRSTARTBUSYCMD_MASK;
+ } while (regval);
+
+ regval = iproc_i2c_reg_read(&base->mstr_cmd);
+
+ if ((regval & CCB_SMB_MSTRSTS_MASK) != 0)
+ return -1;
+
+ iproc_dump_i2c_regs(bus_prvdata);
+ debug("%s: chip probe successful\n", __func__);
+
+ return 0;
+}
+
+static int iproc_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+
+ bus_prvdata->bus_speed = speed;
+ return iproc_i2c_set_clk_freq(bus_prvdata);
+}
+
+/**
+ * i2c_get_bus_speed - get i2c bus speed
+ *
+ * This function returns the speed of operation in Hz
+ */
+int iproc_i2c_get_bus_speed(struct udevice *bus)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ struct iproc_i2c_regs *base = bus_prvdata->base;
+ unsigned int regval;
+ int ret = 0;
+
+ regval = iproc_i2c_reg_read(&base->timg_cfg);
+ regval = (regval & CCB_SMB_TIMGCFG_MODE400_MASK) >>
+ CCB_SMB_TIMGCFG_MODE400_SHIFT;
+
+ switch (regval) {
+ case 0:
+ ret = I2C_SPEED_STANDARD_RATE;
+ break;
+ case 1:
+ ret = I2C_SPEED_FAST_RATE;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
+static int iproc_i2c_probe(struct udevice *bus)
+{
+ return iproc_i2c_init(bus);
+}
+
+static int iproc_i2c_ofdata_to_platdata(struct udevice *bus)
+{
+ struct iproc_i2c *bus_prvdata = dev_get_priv(bus);
+ int node = dev_of_offset(bus);
+ const void *blob = gd->fdt_blob;
+
+ bus_prvdata->base = map_physmem(devfdt_get_addr(bus),
+ sizeof(void *),
+ MAP_NOCACHE);
+
+ bus_prvdata->bus_speed =
+ fdtdec_get_int(blob, node, "bus-frequency",
+ I2C_SPEED_STANDARD_RATE);
+
+ return 0;
+}
+
+static const struct dm_i2c_ops iproc_i2c_ops = {
+ .xfer = iproc_i2c_xfer,
+ .probe_chip = iproc_i2c_probe_chip,
+ .set_bus_speed = iproc_i2c_set_bus_speed,
+ .get_bus_speed = iproc_i2c_get_bus_speed,
+};
+
+static const struct udevice_id iproc_i2c_ids[] = {
+ { .compatible = "brcm,iproc-i2c" },
+ { }
+};
+
+U_BOOT_DRIVER(iproc_i2c) = {
+ .name = "iproc_i2c",
+ .id = UCLASS_I2C,
+ .of_match = iproc_i2c_ids,
+ .ofdata_to_platdata = iproc_i2c_ofdata_to_platdata,
+ .probe = iproc_i2c_probe,
+ .priv_auto_alloc_size = sizeof(struct iproc_i2c),
+ .ops = &iproc_i2c_ops,
+ .flags = DM_FLAG_PRE_RELOC,
+};
diff --git a/drivers/i2c/iproc_i2c.h b/drivers/i2c/iproc_i2c.h
new file mode 100644
index 0000000000..8c3d84f62b
--- /dev/null
+++ b/drivers/i2c/iproc_i2c.h
@@ -0,0 +1,335 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Broadcom
+ *
+ */
+
+#ifndef __IPROC_I2C_H__
+#define __IPROC_I2C_H__
+
+/* Registers */
+#define CCB_SMB_CFG_REG 0x0
+
+#define CCB_SMB_CFG_RST_MASK 0x80000000
+#define CCB_SMB_CFG_RST_SHIFT 31
+
+#define CCB_SMB_CFG_SMBEN_MASK 0x40000000
+#define CCB_SMB_CFG_SMBEN_SHIFT 30
+
+#define CCB_SMB_CFG_BITBANGEN_MASK 0x20000000
+#define CCB_SMB_CFG_BITBANGEN_SHIFT 29
+
+#define CCB_SMB_CFG_EN_NIC_SMBADDR0_MASK 0x10000000
+#define CCB_SMB_CFG_EN_NIC_SMBADDR0_SHIFT 28
+
+#define CCB_SMB_CFG_PROMISCMODE_MASK 0x08000000
+#define CCB_SMB_CFG_PROMISCMODE_SHIFT 27
+
+#define CCB_SMB_CFG_TSTMPCNTEN_MASK 0x04000000
+#define CCB_SMB_CFG_TSTMPCNTEN_SHIFT 26
+
+#define CCB_SMB_CFG_MSTRRTRYCNT_MASK 0x000F0000
+#define CCB_SMB_CFG_MSTRRTRYCNT_SHIFT 16
+
+#define CCB_SMB_TIMGCFG_REG 0x4
+
+#define CCB_SMB_TIMGCFG_MODE400_MASK 0x80000000
+#define CCB_SMB_TIMGCFG_MODE400_SHIFT 31
+
+#define CCB_SMB_TIMGCFG_RNDSLVSTR_MASK 0x7F000000
+#define CCB_SMB_TIMGCFG_RNDSLVSTR_SHIFT 24
+
+#define CCB_SMB_TIMGCFG_PERSLVSTR_MASK 0x00FF0000
+#define CCB_SMB_TIMGCFG_PERSLVSTR_SHIFT 16
+
+#define CCB_SMB_TIMGCFG_IDLTIME_MASK 0x0000FF00
+#define CCB_SMB_TIMGCFG_IDLTIME_SHIFT 8
+
+#define CCB_SMB_ADDR_REG 0x8
+
+#define CCB_SMB_EN_NIC_SMBADDR3_MASK 0x80000000
+#define CCB_SMB_EN_NIC_SMBADDR3_SHIFT 31
+
+#define CCB_SMB_NIC_SMBADDR3_MASK 0x7F000000
+#define CCB_SMB_NIC_SMBADDR3_SHIFT 24
+
+#define CCB_SMB_EN_NIC_SMBADDR2_MASK 0x00800000
+#define CCB_SMB_EN_NIC_SMBADDR2_SHIFT 23
+
+#define CCB_SMB_NIC_SMBADDR2_MASK 0x007F0000
+#define CCB_SMB_NIC_SMBADDR2_SHIFT 16
+
+#define CCB_SMB_EN_NIC_SMBADDR1_MASK 0x00008000
+#define CCB_SMB_EN_NIC_SMBADDR1_SHIFT 15
+
+#define CCB_SMB_NIC_SMBADDR1_MASK 0x00007F00
+#define CCB_SMB_NIC_SMBADDR1_SHIFT 8
+
+#define CCB_SMB_EN_NIC_SMBADDR0_MASK 0x00000080
+#define CCB_SMB_EN_NIC_SMBADDR0_SHIFT 7
+
+#define CCB_SMB_NIC_SMBADDR0_MASK 0x0000007F
+#define CCB_SMB_NIC_SMBADDR0_SHIFT 0
+
+#define CCB_SMB_MSTRFIFOCTL_REG 0xC
+
+#define CCB_SMB_MSTRRXFIFOFLSH_MASK 0x80000000
+#define CCB_SMB_MSTRRXFIFOFLSH_SHIFT 31
+
+#define CCB_SMB_MSTRTXFIFOFLSH_MASK 0x40000000
+#define CCB_SMB_MSTRTXFIFOFLSH_SHIFT 30
+
+#define CCB_SMB_MSTRRXPKTCNT_MASK 0x007F0000
+#define CCB_SMB_MSTRRXPKTCNT_SHIFT 16
+
+#define CCB_SMB_MSTRRXFIFOTHR_MASK 0x00003F00
+#define CCB_SMB_MSTRRXFIFOTHR_SHIFT 8
+
+#define CCB_SMB_SLVFIFOCTL_REG 0x10
+
+#define CCB_SMB_SLVRXFIFOFLSH_MASK 0x80000000
+#define CCB_SMB_SLVRXFIFOFLSH_SHIFT 31
+
+#define CCB_SMB_SLVTXFIFOFLSH_MASK 0x40000000
+#define CCB_SMB_SLVTXFIFOFLSH_SHIFT 30
+
+#define CCB_SMB_SLVRXPKTCNT_MASK 0x007F0000
+#define CCB_SMB_SLVRXPKTCNT_SHIFT 16
+
+#define CCB_SMB_SLVRXFIFOTHR_MASK 0x00003F00
+#define CCB_SMB_SLVRXFIFOTHR_SHIFT 8
+
+#define CCB_SMB_BITBANGCTL_REG 0x14
+
+#define CCB_SMB_SMBCLKIN_MASK 0x80000000
+#define CCB_SMB_SMBCLKIN_SHIFT 31
+
+#define CCB_SMB_SMBCLKOUTEN_MASK 0x40000000
+#define CCB_SMB_SMBCLKOUTEN_SHIFT 30
+
+#define CCB_SMB_SMBDATAIN_MASK 0x20000000
+#define CCB_SMB_SMBDATAIN_SHIFT 29
+
+#define CCB_SMB_SMBDATAOUTEN_MASK 0x10000000
+#define CCB_SMB_SMBDATAOUTEN_SHIFT 28
+
+#define CCB_SMB_MSTRCMD_REG 0x30
+
+#define CCB_SMB_MSTRSTARTBUSYCMD_MASK 0x80000000
+#define CCB_SMB_MSTRSTARTBUSYCMD_SHIFT 31
+
+#define CCB_SMB_MSTRABORT_MASK 0x40000000
+#define CCB_SMB_MSTRABORT_SHIFT 30
+
+#define CCB_SMB_MSTRSTS_MASK 0x0E000000
+#define CCB_SMB_MSTRSTS_SHIFT 25
+
+#define CCB_SMB_MSTRSMBUSPROTO_MASK 0x00001E00
+#define CCB_SMB_MSTRSMBUSPROTO_SHIFT 9
+
+#define CCB_SMB_MSTRPEC_MASK 0x00000100
+#define CCB_SMB_MSTRPEC_SHIFT 8
+
+#define CCB_SMB_MSTRRDBYTECNT_MASK 0x000000FF
+#define CCB_SMB_MSTRRDBYTECNT_SHIFT 0
+
+#define CCB_SMB_SLVCMD_REG 0x34
+
+#define CCB_SMB_SLVSTARTBUSYCMD_MASK 0x80000000
+#define CCB_SMB_SLVSTARTBUSYCMD_SHIFT 31
+
+#define CCB_SMB_SLVABORT_MASK 0x40000000
+#define CCB_SMB_SLVABORT_SHIFT 30
+
+#define CCB_SMB_SLVSTS_MASK 0x03800000
+#define CCB_SMB_SLVSTS_SHIFT 23
+
+#define CCB_SMB_SLVPEC_MASK 0x00000100
+#define CCB_SMB_SLVPEC_SHIFT 8
+
+#define CCB_SMB_EVTEN_REG 0x38
+
+#define CCB_SMB_MSTRRXFIFOFULLEN_MASK 0x80000000
+#define CCB_SMB_MSTRRXFIFOFULLEN_SHIFT 31
+
+#define CCB_SMB_MSTRRXFIFOTHRHITEN_MASK 0x40000000
+#define CCB_SMB_MSTRRXFIFOTHRHITEN_SHIFT 30
+
+#define CCB_SMB_MSTRRXEVTEN_MASK 0x20000000
+#define CCB_SMB_MSTRRXEVTEN_SHIFT 29
+
+#define CCB_SMB_MSTRSTARTBUSYEN_MASK 0x10000000
+#define CCB_SMB_MSTRSTARTBUSYEN_SHIFT 28
+
+#define CCB_SMB_MSTRTXUNDEN_MASK 0x08000000
+#define CCB_SMB_MSTRTXUNDEN_SHIFT 27
+
+#define CCB_SMB_SLVRXFIFOFULLEN_MASK 0x04000000
+#define CCB_SMB_SLVRXFIFOFULLEN_SHIFT 26
+
+#define CCB_SMB_SLVRXFIFOTHRHITEN_MASK 0x02000000
+#define CCB_SMB_SLVRXFIFOTHRHITEN_SHIFT 25
+
+#define CCB_SMB_SLVRXEVTEN_MASK 0x01000000
+#define CCB_SMB_SLVRXEVTEN_SHIFT 24
+
+#define CCB_SMB_SLVSTARTBUSYEN_MASK 0x00800000
+#define CCB_SMB_SLVSTARTBUSYEN_SHIFT 23
+
+#define CCB_SMB_SLVTXUNDEN_MASK 0x00400000
+#define CCB_SMB_SLVTXUNDEN_SHIFT 22
+
+#define CCB_SMB_SLVRDEVTEN_MASK 0x00200000
+#define CCB_SMB_SLVRDEVTEN_SHIFT 21
+
+#define CCB_SMB_EVTSTS_REG 0x3C
+
+#define CCB_SMB_MSTRRXFIFOFULLSTS_MASK 0x80000000
+#define CCB_SMB_MSTRRXFIFOFULLSTS_SHIFT 31
+
+#define CCB_SMB_MSTRRXFIFOTHRHITSTS_MASK 0x40000000
+#define CCB_SMB_MSTRRXFIFOTHRHITSTS_SHIFT 30
+
+#define CCB_SMB_MSTRRXEVTSTS_MASK 0x20000000
+#define CCB_SMB_MSTRRXEVTSTS_SHIFT 29
+
+#define CCB_SMB_MSTRSTARTBUSYSTS_MASK 0x10000000
+#define CCB_SMB_MSTRSTARTBUSYSTS_SHIFT 28
+
+#define CCB_SMB_MSTRTXUNDSTS_MASK 0x08000000
+#define CCB_SMB_MSTRTXUNDSTS_SHIFT 27
+
+#define CCB_SMB_SLVRXFIFOFULLSTS_MASK 0x04000000
+#define CCB_SMB_SLVRXFIFOFULLSTS_SHIFT 26
+
+#define CCB_SMB_SLVRXFIFOTHRHITSTS_MASK 0x02000000
+#define CCB_SMB_SLVRXFIFOTHRHITSTS_SHIFT 25
+
+#define CCB_SMB_SLVRXEVTSTS_MASK 0x01000000
+#define CCB_SMB_SLVRXEVTSTS_SHIFT 24
+
+#define CCB_SMB_SLVSTARTBUSYSTS_MASK 0x00800000
+#define CCB_SMB_SLVSTARTBUSYSTS_SHIFT 23
+
+#define CCB_SMB_SLVTXUNDSTS_MASK 0x00400000
+#define CCB_SMB_SLVTXUNDSTS_SHIFT 22
+
+#define CCB_SMB_SLVRDEVTSTS_MASK 0x00200000
+#define CCB_SMB_SLVRDEVTSTS_SHIFT 21
+
+#define CCB_SMB_MSTRDATAWR_REG 0x40
+
+#define CCB_SMB_MSTRWRSTS_MASK 0x80000000
+#define CCB_SMB_MSTRWRSTS_SHIFT 31
+
+#define CCB_SMB_MSTRWRDATA_MASK 0x000000FF
+#define CCB_SMB_MSTRWRDATA_SHIFT 0
+
+#define CCB_SMB_MSTRDATARD_REG 0x44
+
+#define CCB_SMB_MSTRRDSTS_MASK 0xC0000000
+#define CCB_SMB_MSTRRDSTS_SHIFT 30
+
+#define CCB_SMB_MSTRRDPECERR_MASK 0x20000000
+#define CCB_SMB_MSTRRDPECERR_SHIFT 29
+
+#define CCB_SMB_MSTRRDDATA_MASK 0x000000FF
+#define CCB_SMB_MSTRRDDATA_SHIFT 0
+
+#define CCB_SMB_SLVDATAWR_REG 0x48
+
+#define CCB_SMB_SLVWRSTS_MASK 0x80000000
+#define CCB_SMB_SLVWRSTS_SHIFT 31
+
+#define CCB_SMB_SLVWRDATA_MASK 0x000000FF
+#define CCB_SMB_SLVWRDATA_SHIFT 0
+
+#define CCB_SMB_SLVDATARD_REG 0x4C
+
+#define CCB_SMB_SLVRDSTS_MASK 0xC0000000
+#define CCB_SMB_SLVRDSTS_SHIFT 30
+
+#define CCB_SMB_SLVRDERRSTS_MASK 0x30000000
+#define CCB_SMB_SLVRDERRSTS_SHIFT 28
+
+#define CCB_SMB_SLVRDDATA_MASK 0x000000FF
+#define CCB_SMB_SLVRDDATA_SHIFT 0
+
+/* --Registers-- */
+
+/* Transaction error codes defined in Master command register (0x30) */
+#define MSTR_STS_XACT_SUCCESS 0
+#define MSTR_STS_LOST_ARB 1
+#define MSTR_STS_NACK_FIRST_BYTE 2
+
+/* NACK on a byte other than
+ * the first byte
+ */
+#define MSTR_STS_NACK_NON_FIRST_BYTE 3
+
+#define MSTR_STS_TTIMEOUT_EXCEEDED 4
+#define MSTR_STS_TX_TLOW_MEXT_EXCEEDED 5
+#define MSTR_STS_RX_TLOW_MEXT_EXCEEDED 6
+
+/* SMBUS protocol values defined in register 0x30 */
+#define SMBUS_PROT_QUICK_CMD 0
+#define SMBUS_PROT_SEND_BYTE 1
+#define SMBUS_PROT_RECV_BYTE 2
+#define SMBUS_PROT_WR_BYTE 3
+#define SMBUS_PROT_RD_BYTE 4
+#define SMBUS_PROT_WR_WORD 5
+#define SMBUS_PROT_RD_WORD 6
+#define SMBUS_PROT_BLK_WR 7
+#define SMBUS_PROT_BLK_RD 8
+#define SMBUS_PROT_PROC_CALL 9
+#define SMBUS_PROT_BLK_WR_BLK_RD_PROC_CALL 10
+
+/* SMBUS Block speed mode */
+#define SMBUS_BLOCK_MODE_100 0
+#define SMBUS_BLOCK_MODE_400 1
+
+#define BUS_BUSY_COUNT 100000 /* Number can be changed later */
+#define IPROC_I2C_INVALID_ADDR 0xFF
+#define IPROC_SMB_MAX_RETRIES 35
+#define I2C_SMBUS_BLOCK_MAX 32
+#define GETREGFLDVAL(regval, mask, startbit) \
+ (((regval) & (mask)) >> (startbit))
+
+/* This enum will be used to notify the user of status of a data transfer
+ * request
+ */
+enum iproc_smb_error_code {
+ I2C_NO_ERR = 0,
+ I2C_TIMEOUT_ERR = 1,
+
+ /* Invalid parameter(s) passed to the driver */
+ I2C_INVALID_PARAM_ERR = 2,
+
+ /* The driver API was called before the present
+ * transfer was completed
+ */
+ I2C_OPER_IN_PROGRESS = 3,
+
+ /* Transfer aborted unexpectedly, for example a NACK
+ * received, before last byte was read/written
+ */
+ I2C_OPER_ABORT_ERR = 4,
+
+ /* Feature or function not supported
+ * (e.g., 10-bit addresses, or clock speeds
+ * other than 100KHz, 400KHz)
+ */
+ I2C_FUNC_NOT_SUPPORTED = 5,
+};
+
+/* Structure used to pass information to read/write functions. */
+struct iproc_xact_info {
+ unsigned char command;
+ unsigned char *data;
+ unsigned int size;
+ unsigned short flags; /* used for specifying PEC, 10-bit addresses */
+ unsigned char smb_proto; /* SMBus protocol */
+ unsigned int cmd_valid; /* true if command is valid else false */
+};
+
+#endif /* __IPROC_I2C_H__ */
diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c
index 0726b4c956..8e31481c0f 100644
--- a/drivers/i2c/kona_i2c.c
+++ b/drivers/i2c/kona_i2c.c
@@ -3,7 +3,7 @@
* Copyright 2013 Broadcom Corporation.
*
* NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
*/
#include <common.h>
diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig
index 68f15261be..39683fc43b 100644
--- a/drivers/i2c/muxes/Kconfig
+++ b/drivers/i2c/muxes/Kconfig
@@ -33,8 +33,8 @@ config I2C_MUX_PCA954x
devices. It is x width I2C multiplexer which enables to partitioning
I2C bus and connect multiple devices with the same address to the same
I2C controller where driver handles proper routing to target i2c
- device. Supported chips are PCA9543, PCA9544, PCA9547, PCA9548 and
- PCA9646.
+ device. Supported chips are PCA9543, PCA9544, PCA9546, PCA9547,
+ PCA9548 and PCA9646.
config I2C_MUX_GPIO
tristate "GPIO-based I2C multiplexer"
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index be90a7b24a..cc8afc93b5 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
enum pca_type {
PCA9543,
PCA9544,
+ PCA9546,
PCA9547,
PCA9548,
PCA9646
@@ -48,6 +49,10 @@ static const struct chip_desc chips[] = {
.muxtype = pca954x_ismux,
.width = 4,
},
+ [PCA9546] = {
+ .muxtype = pca954x_isswi,
+ .width = 4,
+ },
[PCA9547] = {
.enable = 0x8,
.muxtype = pca954x_ismux,
@@ -95,6 +100,7 @@ static const struct i2c_mux_ops pca954x_ops = {
static const struct udevice_id pca954x_ids[] = {
{ .compatible = "nxp,pca9543", .data = PCA9543 },
{ .compatible = "nxp,pca9544", .data = PCA9544 },
+ { .compatible = "nxp,pca9546", .data = PCA9546 },
{ .compatible = "nxp,pca9547", .data = PCA9547 },
{ .compatible = "nxp,pca9548", .data = PCA9548 },
{ .compatible = "nxp,pca9646", .data = PCA9646 },
diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
index b69d213593..834f1f2179 100644
--- a/drivers/i2c/sh_i2c.c
+++ b/drivers/i2c/sh_i2c.c
@@ -4,7 +4,7 @@
* Copyright (C) 2011, 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
*
* NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
*/
#include <common.h>
diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
index 7f0303cc05..9ad1c281ff 100644
--- a/drivers/i2c/soft_i2c.c
+++ b/drivers/i2c/soft_i2c.c
@@ -12,7 +12,7 @@
* Neil Russell.
*
* NOTE: This driver should be converted to driver model before June 2017.
- * Please see doc/driver-model/i2c-howto.txt for instructions.
+ * Please see doc/driver-model/i2c-howto.rst for instructions.
*/
#include <common.h>
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 926cf81a07..7a081b9d03 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -360,6 +360,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
if (src == BOOT_SOURCE_IFC_NOR) {
addr = (void *)(CONFIG_SYS_FMAN_FW_ADDR +
CONFIG_SYS_FSL_IFC_BASE);
+#ifdef CONFIG_CMD_NAND
} else if (src == BOOT_SOURCE_IFC_NAND) {
size_t fw_length = CONFIG_SYS_QE_FMAN_FW_LENGTH;
@@ -372,6 +373,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
printf("NAND read of FMAN firmware at offset 0x%x failed %d\n",
CONFIG_SYS_FMAN_FW_ADDR, rc);
}
+#endif
} else if (src == BOOT_SOURCE_QSPI_NOR) {
struct spi_flash *ucode_flash;
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 1f36fc78fa..edb3f0f538 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -23,6 +23,13 @@ config PWM_IMX
help
This PWM is found i.MX27 and later i.MX SoCs.
+config PWM_MTK
+ bool "Enable support for MediaTek PWM"
+ depends on DM_PWM
+ help
+ This PWM is found on MT7622, MT7623, and MT7629. It supports a
+ programmable period and duty cycle.
+
config PWM_ROCKCHIP
bool "Enable support for the Rockchip PWM"
depends on DM_PWM
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index a837c35ed2..2c3a069006 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_DM_PWM) += pwm-uclass.o
obj-$(CONFIG_PWM_EXYNOS) += exynos_pwm.o
obj-$(CONFIG_PWM_IMX) += pwm-imx.o pwm-imx-util.o
+obj-$(CONFIG_PWM_MTK) += pwm-mtk.o
obj-$(CONFIG_PWM_ROCKCHIP) += rk_pwm.o
obj-$(CONFIG_PWM_SANDBOX) += sandbox_pwm.o
obj-$(CONFIG_PWM_TEGRA) += tegra_pwm.o
diff --git a/drivers/pwm/pwm-mtk.c b/drivers/pwm/pwm-mtk.c
new file mode 100644
index 0000000000..97ed477025
--- /dev/null
+++ b/drivers/pwm/pwm-mtk.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 MediaTek Inc. All Rights Reserved.
+ *
+ * Author: Sam Shih <sam.shih@mediatek.com>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <pwm.h>
+#include <div64.h>
+#include <linux/bitops.h>
+#include <linux/io.h>
+
+/* PWM registers and bits definitions */
+#define PWMCON 0x00
+#define PWMHDUR 0x04
+#define PWMLDUR 0x08
+#define PWMGDUR 0x0c
+#define PWMWAVENUM 0x28
+#define PWMDWIDTH 0x2c
+#define PWM45DWIDTH_FIXUP 0x30
+#define PWMTHRES 0x30
+#define PWM45THRES_FIXUP 0x34
+
+#define PWM_CLK_DIV_MAX 7
+#define MAX_PWM_NUM 8
+
+#define NSEC_PER_SEC 1000000000L
+
+static const unsigned int mtk_pwm_reg_offset[] = {
+ 0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220
+};
+
+struct mtk_pwm_soc {
+ unsigned int num_pwms;
+ bool pwm45_fixup;
+};
+
+struct mtk_pwm_priv {
+ void __iomem *base;
+ struct clk top_clk;
+ struct clk main_clk;
+ struct clk pwm_clks[MAX_PWM_NUM];
+ const struct mtk_pwm_soc *soc;
+};
+
+static void mtk_pwm_w32(struct udevice *dev, uint channel, uint reg, uint val)
+{
+ struct mtk_pwm_priv *priv = dev_get_priv(dev);
+ u32 offset = mtk_pwm_reg_offset[channel];
+
+ writel(val, priv->base + offset + reg);
+}
+
+static int mtk_pwm_set_config(struct udevice *dev, uint channel,
+ uint period_ns, uint duty_ns)
+{
+ struct mtk_pwm_priv *priv = dev_get_priv(dev);
+ u32 clkdiv = 0, clksel = 0, cnt_period, cnt_duty,
+ reg_width = PWMDWIDTH, reg_thres = PWMTHRES;
+ u64 resolution;
+ int ret = 0;
+
+ clk_enable(&priv->top_clk);
+ clk_enable(&priv->main_clk);
+ /* Using resolution in picosecond gets accuracy higher */
+ resolution = (u64)NSEC_PER_SEC * 1000;
+ do_div(resolution, clk_get_rate(&priv->pwm_clks[channel]));
+ cnt_period = DIV_ROUND_CLOSEST_ULL((u64)period_ns * 1000, resolution);
+ while (cnt_period > 8191) {
+ resolution *= 2;
+ clkdiv++;
+ cnt_period = DIV_ROUND_CLOSEST_ULL((u64)period_ns * 1000,
+ resolution);
+ if (clkdiv > PWM_CLK_DIV_MAX && clksel == 0) {
+ clksel = 1;
+ clkdiv = 0;
+ resolution = (u64)NSEC_PER_SEC * 1000 * 1625;
+ do_div(resolution,
+ clk_get_rate(&priv->pwm_clks[channel]));
+ cnt_period = DIV_ROUND_CLOSEST_ULL(
+ (u64)period_ns * 1000, resolution);
+ clk_enable(&priv->pwm_clks[channel]);
+ }
+ }
+ if (clkdiv > PWM_CLK_DIV_MAX && clksel == 1) {
+ printf("pwm period %u not supported\n", period_ns);
+ return -EINVAL;
+ }
+ if (priv->soc->pwm45_fixup && channel > 2) {
+ /*
+ * PWM[4,5] has distinct offset for PWMDWIDTH and PWMTHRES
+ * from the other PWMs on MT7623.
+ */
+ reg_width = PWM45DWIDTH_FIXUP;
+ reg_thres = PWM45THRES_FIXUP;
+ }
+ cnt_duty = DIV_ROUND_CLOSEST_ULL((u64)duty_ns * 1000, resolution);
+ if (clksel == 1)
+ mtk_pwm_w32(dev, channel, PWMCON, BIT(15) | BIT(3) | clkdiv);
+ else
+ mtk_pwm_w32(dev, channel, PWMCON, BIT(15) | clkdiv);
+ mtk_pwm_w32(dev, channel, reg_width, cnt_period);
+ mtk_pwm_w32(dev, channel, reg_thres, cnt_duty);
+
+ return ret;
+};
+
+static int mtk_pwm_set_enable(struct udevice *dev, uint channel, bool enable)
+{
+ struct mtk_pwm_priv *priv = dev_get_priv(dev);
+ u32 val = 0;
+
+ val = readl(priv->base);
+ if (enable)
+ val |= BIT(channel);
+ else
+ val &= ~BIT(channel);
+ writel(val, priv->base);
+
+ return 0;
+};
+
+static int mtk_pwm_probe(struct udevice *dev)
+{
+ struct mtk_pwm_priv *priv = dev_get_priv(dev);
+ int ret = 0;
+ int i;
+
+ priv->soc = (struct mtk_pwm_soc *)dev_get_driver_data(dev);
+ priv->base = (void __iomem *)devfdt_get_addr(dev);
+ if (!priv->base)
+ return -EINVAL;
+ ret = clk_get_by_name(dev, "top", &priv->top_clk);
+ if (ret < 0)
+ return ret;
+ ret = clk_get_by_name(dev, "main", &priv->main_clk);
+ if (ret < 0)
+ return ret;
+ for (i = 0; i < priv->soc->num_pwms; i++) {
+ char name[8];
+
+ snprintf(name, sizeof(name), "pwm%d", i + 1);
+ ret = clk_get_by_name(dev, name, &priv->pwm_clks[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return ret;
+}
+
+static const struct pwm_ops mtk_pwm_ops = {
+ .set_config = mtk_pwm_set_config,
+ .set_enable = mtk_pwm_set_enable,
+};
+
+static const struct mtk_pwm_soc mt7622_data = {
+ .num_pwms = 6,
+ .pwm45_fixup = false,
+};
+
+static const struct mtk_pwm_soc mt7623_data = {
+ .num_pwms = 5,
+ .pwm45_fixup = true,
+};
+
+static const struct mtk_pwm_soc mt7629_data = {
+ .num_pwms = 1,
+ .pwm45_fixup = false,
+};
+
+static const struct udevice_id mtk_pwm_ids[] = {
+ { .compatible = "mediatek,mt7622-pwm", .data = (ulong)&mt7622_data },
+ { .compatible = "mediatek,mt7623-pwm", .data = (ulong)&mt7623_data },
+ { .compatible = "mediatek,mt7629-pwm", .data = (ulong)&mt7629_data },
+ { }
+};
+
+U_BOOT_DRIVER(mtk_pwm) = {
+ .name = "mtk_pwm",
+ .id = UCLASS_PWM,
+ .of_match = mtk_pwm_ids,
+ .ops = &mtk_pwm_ops,
+ .probe = mtk_pwm_probe,
+ .priv_auto_alloc_size = sizeof(struct mtk_pwm_priv),
+};
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 9fb5e658f9..5260dab3ac 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -512,7 +512,7 @@ static bool is_optee_api(optee_invoke_fn *invoke_fn)
res.a2 == OPTEE_MSG_UID_2 && res.a3 == OPTEE_MSG_UID_3;
}
-static void print_os_revision(optee_invoke_fn *invoke_fn)
+static void print_os_revision(struct udevice *dev, optee_invoke_fn *invoke_fn)
{
union {
struct arm_smccc_res smccc;
@@ -527,11 +527,12 @@ static void print_os_revision(optee_invoke_fn *invoke_fn)
&res.smccc);
if (res.result.build_id)
- debug("OP-TEE revision %lu.%lu (%08lx)\n", res.result.major,
- res.result.minor, res.result.build_id);
+ dev_info(dev, "OP-TEE: revision %lu.%lu (%08lx)\n",
+ res.result.major, res.result.minor,
+ res.result.build_id);
else
- debug("OP-TEE revision %lu.%lu\n", res.result.major,
- res.result.minor);
+ dev_info(dev, "OP-TEE: revision %lu.%lu\n",
+ res.result.major, res.result.minor);
}
static bool api_revision_is_compatible(optee_invoke_fn *invoke_fn)
@@ -626,7 +627,7 @@ static int optee_probe(struct udevice *dev)
return -ENOENT;
}
- print_os_revision(pdata->invoke_fn);
+ print_os_revision(dev, pdata->invoke_fn);
if (!api_revision_is_compatible(pdata->invoke_fn)) {
debug("%s: OP-TEE api revision mismatch\n", __func__);
diff --git a/env/nvram.c b/env/nvram.c
index a78db21623..1a9fcf1c06 100644
--- a/env/nvram.c
+++ b/env/nvram.c
@@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;
extern void *nvram_read(void *dest, const long src, size_t count);
extern void nvram_write(long dest, const void *src, size_t count);
#else
-env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
+static env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
#endif
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
diff --git a/env/remote.c b/env/remote.c
index 50d77b8dfe..e3f0608b16 100644
--- a/env/remote.c
+++ b/env/remote.c
@@ -12,9 +12,9 @@
#include <u-boot/crc.h>
#ifdef ENV_IS_EMBEDDED
-env_t *env_ptr = &environment;
+static env_t *env_ptr = &environment;
#else /* ! ENV_IS_EMBEDDED */
-env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
+static env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
#endif /* ENV_IS_EMBEDDED */
DECLARE_GLOBAL_DATA_PTR;
diff --git a/fs/btrfs/extent-io.c b/fs/btrfs/extent-io.c
index 66d0e1c7d6..2e4599cf64 100644
--- a/fs/btrfs/extent-io.c
+++ b/fs/btrfs/extent-io.c
@@ -78,6 +78,12 @@ u64 btrfs_read_extent_reg(struct btrfs_path *path,
if (size > dlen - offset)
size = dlen - offset;
+ /* sparse extent */
+ if (extent->disk_bytenr == 0) {
+ memset(out, 0, size);
+ return size;
+ }
+
physical = btrfs_map_logical_to_physical(extent->disk_bytenr);
if (physical == -1ULL)
return -1ULL;
diff --git a/include/ata.h b/include/ata.h
index 3f4e4a0234..3d870c973f 100644
--- a/include/ata.h
+++ b/include/ata.h
@@ -6,11 +6,8 @@
/*
* Most of the following information was derived from the document
- * "Information Technology - AT Attachment-3 Interface (ATA-3)"
- * which can be found at:
- * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
- * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
- * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
+ * "Information Technology - AT Attachment-3 Interface (ATA-3)",
+ * ANSI X3.298-1997.
*/
#ifndef _ATA_H
@@ -71,42 +68,8 @@
#define ATA_LBA 0xE0
/*
- * ATA Commands (only mandatory commands listed here)
- */
-#define ATA_CMD_READ 0x20 /* Read Sectors (with retries) */
-#define ATA_CMD_READN 0x21 /* Read Sectors ( no retries) */
-#define ATA_CMD_WRITE 0x30 /* Write Sectores (with retries)*/
-#define ATA_CMD_WRITEN 0x31 /* Write Sectors ( no retries)*/
-#define ATA_CMD_VRFY 0x40 /* Read Verify (with retries) */
-#define ATA_CMD_VRFYN 0x41 /* Read verify ( no retries) */
-#define ATA_CMD_SEEK 0x70 /* Seek */
-#define ATA_CMD_DIAG 0x90 /* Execute Device Diagnostic */
-#define ATA_CMD_INIT 0x91 /* Initialize Device Parameters */
-#define ATA_CMD_RD_MULT 0xC4 /* Read Multiple */
-#define ATA_CMD_WR_MULT 0xC5 /* Write Multiple */
-#define ATA_CMD_SETMULT 0xC6 /* Set Multiple Mode */
-#define ATA_CMD_RD_DMA 0xC8 /* Read DMA (with retries) */
-#define ATA_CMD_RD_DMAN 0xC9 /* Read DMS ( no retries) */
-#define ATA_CMD_WR_DMA 0xCA /* Write DMA (with retries) */
-#define ATA_CMD_WR_DMAN 0xCB /* Write DMA ( no retires) */
-#define ATA_CMD_IDENT 0xEC /* Identify Device */
-#define ATA_CMD_SETF 0xEF /* Set Features */
-#define ATA_CMD_CHK_PWR 0xE5 /* Check Power Mode */
-
-#define ATA_CMD_READ_EXT 0x24 /* Read Sectors (with retries) with 48bit addressing */
-#define ATA_CMD_WRITE_EXT 0x34 /* Write Sectores (with retries) with 48bit addressing */
-#define ATA_CMD_VRFY_EXT 0x42 /* Read Verify (with retries) with 48bit addressing */
-
-#define ATA_CMD_FLUSH 0xE7 /* Flush drive cache */
-#define ATA_CMD_FLUSH_EXT 0xEA /* Flush drive cache, with 48bit addressing */
-
-/*
* ATAPI Commands
*/
-#define ATAPI_CMD_IDENT 0xA1 /* Identify AT Atachment Packed Interface Device */
-#define ATAPI_CMD_PACKET 0xA0 /* Packed Command */
-
-
#define ATAPI_CMD_INQUIRY 0x12
#define ATAPI_CMD_REQ_SENSE 0x03
#define ATAPI_CMD_READ_CAP 0x25
diff --git a/include/configs/ls1012afrwy.h b/include/configs/ls1012afrwy.h
index 899dfdbdf1..6143e9731e 100644
--- a/include/configs/ls1012afrwy.h
+++ b/include/configs/ls1012afrwy.h
@@ -72,6 +72,7 @@
"kernel_size=0x2800000\0" \
"kernelheader_size=0x40000\0" \
"console=ttyS0,115200\0" \
+ "BOARD=ls1012afrwy\0" \
BOOTENV \
"boot_scripts=ls1012afrwy_boot.scr\0" \
"boot_script_hdr=hdr_ls1012afrwy_bs.out\0" \
@@ -103,20 +104,20 @@
"source ${scriptaddr}\0" \
"installer=load mmc 0:2 $load_addr " \
"/flex_installer_arm64.itb; " \
- "bootm $load_addr#$board\0" \
+ "bootm $load_addr#$BOARD\0" \
"qspi_bootcmd=pfe stop; echo Trying load from qspi..;" \
"sf probe && sf read $load_addr " \
"$kernel_addr $kernel_size; env exists secureboot " \
"&& sf read $kernelheader_addr_r $kernelheader_addr " \
"$kernelheader_size && esbc_validate ${kernelheader_addr_r}; " \
- "bootm $load_addr#$board\0" \
+ "bootm $load_addr#$BOARD\0" \
"sd_bootcmd=pfe stop; echo Trying load from sd card..;" \
"mmcinfo; mmc read $load_addr " \
"$kernel_addr_sd $kernel_size_sd ;" \
"env exists secureboot && mmc read $kernelheader_addr_r "\
"$kernelhdr_addr_sd $kernelhdr_size_sd " \
" && esbc_validate ${kernelheader_addr_r};" \
- "bootm $load_addr#$board\0"
+ "bootm $load_addr#$BOARD\0"
#undef CONFIG_BOOTCOMMAND
#ifdef CONFIG_TFABOOT
diff --git a/include/image.h b/include/image.h
index 2388c1f204..de55b2fb57 100644
--- a/include/image.h
+++ b/include/image.h
@@ -453,6 +453,15 @@ typedef struct table_entry {
} table_entry_t;
/*
+ * Compression type and magic number mapping table.
+ */
+struct comp_magic_map {
+ int comp_id;
+ const char *name;
+ unsigned char magic[2];
+};
+
+/*
* get_table_entry_id() scans the translation table trying to find an
* entry that matches the given short name. If a matching entry is
* found, it's id is returned to the caller.
@@ -869,6 +878,18 @@ static inline int image_check_target_arch(const image_header_t *hdr)
#endif /* USE_HOSTCC */
/**
+ * image_decomp_type() - Find out compression type of an image
+ *
+ * @buf: Address in U-Boot memory where image is loaded.
+ * @len: Length of the compressed image.
+ * @return compression type or IH_COMP_NONE if not compressed.
+ *
+ * Note: Only following compression types are supported now.
+ * lzo, lzma, gzip, bzip2
+ */
+int image_decomp_type(const unsigned char *buf, ulong len);
+
+/**
* image_decomp() - decompress an image
*
* @comp: Compression algorithm that is used (IH_COMP_...)
diff --git a/include/libata.h b/include/libata.h
index 25296ac66d..b03b29960d 100644
--- a/include/libata.h
+++ b/include/libata.h
@@ -133,49 +133,49 @@ enum {
ATA_REG_IRQ = ATA_REG_NSECT,
/* ATA device commands */
- ATA_CMD_DEV_RESET = 0x08, /* ATAPI device reset */
- ATA_CMD_CHK_POWER = 0xE5, /* check power mode */
- ATA_CMD_STANDBY = 0xE2, /* place in standby power mode */
- ATA_CMD_IDLE = 0xE3, /* place in idle power mode */
- ATA_CMD_EDD = 0x90, /* execute device diagnostic */
- ATA_CMD_FLUSH = 0xE7,
- ATA_CMD_FLUSH_EXT = 0xEA,
- ATA_CMD_ID_ATA = 0xEC,
- ATA_CMD_ID_ATAPI = 0xA1,
- ATA_CMD_READ = 0xC8,
- ATA_CMD_READ_EXT = 0x25,
- ATA_CMD_WRITE = 0xCA,
- ATA_CMD_WRITE_EXT = 0x35,
- ATA_CMD_WRITE_FUA_EXT = 0x3D,
- ATA_CMD_FPDMA_READ = 0x60,
- ATA_CMD_FPDMA_WRITE = 0x61,
- ATA_CMD_PIO_READ = 0x20,
- ATA_CMD_PIO_READ_EXT = 0x24,
- ATA_CMD_PIO_WRITE = 0x30,
- ATA_CMD_PIO_WRITE_EXT = 0x34,
- ATA_CMD_READ_MULTI = 0xC4,
- ATA_CMD_READ_MULTI_EXT = 0x29,
- ATA_CMD_WRITE_MULTI = 0xC5,
- ATA_CMD_WRITE_MULTI_EXT = 0x39,
- ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE,
- ATA_CMD_SET_FEATURES = 0xEF,
- ATA_CMD_SET_MULTI = 0xC6,
- ATA_CMD_PACKET = 0xA0,
- ATA_CMD_VERIFY = 0x40,
- ATA_CMD_VERIFY_EXT = 0x42,
- ATA_CMD_STANDBYNOW1 = 0xE0,
- ATA_CMD_IDLEIMMEDIATE = 0xE1,
- ATA_CMD_SLEEP = 0xE6,
- ATA_CMD_INIT_DEV_PARAMS = 0x91,
- ATA_CMD_READ_NATIVE_MAX = 0xF8,
+ ATA_CMD_DEV_RESET = 0x08, /* ATAPI device reset */
+ ATA_CMD_PIO_READ = 0x20, /* Read sectors with retry */
+ ATA_CMD_PIO_READ_EXT = 0x24,
+ ATA_CMD_READ_EXT = 0x25,
ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
- ATA_CMD_SET_MAX = 0xF9,
- ATA_CMD_SET_MAX_EXT = 0x37,
- ATA_CMD_READ_LOG_EXT = 0x2f,
- ATA_CMD_PMP_READ = 0xE4,
- ATA_CMD_PMP_WRITE = 0xE8,
- ATA_CMD_CONF_OVERLAY = 0xB1,
- ATA_CMD_SEC_FREEZE_LOCK = 0xF5,
+ ATA_CMD_READ_MULTI_EXT = 0x29,
+ ATA_CMD_READ_LOG_EXT = 0x2f,
+ ATA_CMD_PIO_WRITE = 0x30, /* write sectors with retry */
+ ATA_CMD_PIO_WRITE_EXT = 0x34,
+ ATA_CMD_WRITE_EXT = 0x35,
+ ATA_CMD_SET_MAX_EXT = 0x37,
+ ATA_CMD_WRITE_MULTI_EXT = 0x39,
+ ATA_CMD_WRITE_FUA_EXT = 0x3D,
+ ATA_CMD_VERIFY = 0x40, /* read verify sectors with retry */
+ ATA_CMD_VERIFY_EXT = 0x42,
+ ATA_CMD_FPDMA_READ = 0x60,
+ ATA_CMD_FPDMA_WRITE = 0x61,
+ ATA_CMD_EDD = 0x90, /* execute device diagnostic */
+ ATA_CMD_INIT_DEV_PARAMS = 0x91, /* initialize device parameters */
+ ATA_CMD_PACKET = 0xA0, /* ATAPI packet */
+ ATA_CMD_ID_ATAPI = 0xA1, /* ATAPI identify device */
+ ATA_CMD_CONF_OVERLAY = 0xB1,
+ ATA_CMD_READ_MULTI = 0xC4, /* read multiple */
+ ATA_CMD_WRITE_MULTI = 0xC5, /* write multiple */
+ ATA_CMD_SET_MULTI = 0xC6, /* set multiple mode */
+ ATA_CMD_READ = 0xC8, /* read DMA with retry */
+ ATA_CMD_WRITE = 0xCA, /* write DMA with retry */
+ ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE,
+ ATA_CMD_STANDBYNOW1 = 0xE0, /* standby immediate */
+ ATA_CMD_IDLEIMMEDIATE = 0xE1, /* idle immediate */
+ ATA_CMD_STANDBY = 0xE2, /* place in standby power mode */
+ ATA_CMD_IDLE = 0xE3, /* place in idle power mode */
+ ATA_CMD_PMP_READ = 0xE4, /* read buffer */
+ ATA_CMD_CHK_POWER = 0xE5, /* check power mode */
+ ATA_CMD_SLEEP = 0xE6, /* sleep */
+ ATA_CMD_FLUSH = 0xE7,
+ ATA_CMD_PMP_WRITE = 0xE8, /* write buffer */
+ ATA_CMD_FLUSH_EXT = 0xEA,
+ ATA_CMD_ID_ATA = 0xEC, /* identify device */
+ ATA_CMD_SET_FEATURES = 0xEF, /* set features */
+ ATA_CMD_SEC_FREEZE_LOCK = 0xF5, /* security freeze */
+ ATA_CMD_READ_NATIVE_MAX = 0xF8,
+ ATA_CMD_SET_MAX = 0xF9,
/* READ_LOG_EXT pages */
ATA_LOG_SATA_NCQ = 0x10,
diff --git a/include/phy_interface.h b/include/phy_interface.h
index 31ca72a81f..882e4af8ff 100644
--- a/include/phy_interface.h
+++ b/include/phy_interface.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
* Andy Fleming <afleming@gmail.com>
*
* This file pretty much stolen from Linux's mii.h/ethtool.h/phy.h
@@ -67,6 +68,15 @@ static const char * const phy_interface_strings[] = {
[PHY_INTERFACE_MODE_NONE] = "",
};
+/* Backplane modes:
+ * are considered a sub-type of phy_interface_t: XGMII
+ * and are specified in "phy-connection-type" with one of the following strings
+ */
+static const char * const backplane_mode_strings[] = {
+ "10gbase-kr",
+ "40gbase-kr4",
+};
+
static inline const char *phy_string_for_interface(phy_interface_t i)
{
/* Default to unknown */
@@ -76,4 +86,17 @@ static inline const char *phy_string_for_interface(phy_interface_t i)
return phy_interface_strings[i];
}
+static inline bool is_backplane_mode(const char *phyconn)
+{
+ int i;
+
+ if (!phyconn)
+ return false;
+ for (i = 0; i < ARRAY_SIZE(backplane_mode_strings); i++) {
+ if (!strcmp(phyconn, backplane_mode_strings[i]))
+ return true;
+ }
+ return false;
+}
+
#endif /* _PHY_INTERFACE_H */
diff --git a/lib/Kconfig b/lib/Kconfig
index 452f390c80..144a54da28 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -409,6 +409,11 @@ config GZIP
help
This enables support for GZIP compression algorithm.
+config BZIP2
+ bool "Enable bzip2 decompression support"
+ help
+ This enables support for BZIP2 compression algorithm.
+
config ZLIB
bool
default y
diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
new file mode 100755
index 0000000000..0bfc5feefb
--- /dev/null
+++ b/scripts/documentation-file-ref-check
@@ -0,0 +1,226 @@
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
+# Treewide grep for references to files under doc, and report
+# non-existing files in stderr.
+
+use warnings;
+use strict;
+use Getopt::Long qw(:config no_auto_abbrev);
+
+# NOTE: only add things here when the file was gone, but the text wants
+# to mention a past documentation file, for example, to give credits for
+# the original work.
+my %false_positives = (
+);
+
+my $scriptname = $0;
+$scriptname =~ s,.*/([^/]+/),$1,;
+
+# Parse arguments
+my $help = 0;
+my $fix = 0;
+my $warn = 0;
+
+if (! -d ".git") {
+ printf "Warning: can't check if file exists, as this is not a git tree";
+ exit 0;
+}
+
+GetOptions(
+ 'fix' => \$fix,
+ 'warn' => \$warn,
+ 'h|help|usage' => \$help,
+);
+
+if ($help != 0) {
+ print "$scriptname [--help] [--fix]\n";
+ exit -1;
+}
+
+# Step 1: find broken references
+print "Finding broken references. This may take a while... " if ($fix);
+
+my %broken_ref;
+
+my $doc_fix = 0;
+
+open IN, "git grep ':doc:\`' doc/|"
+ or die "Failed to run git grep";
+while (<IN>) {
+ next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,);
+
+ my $d = $1;
+ my $doc_ref = $2;
+
+ my $f = $doc_ref;
+
+ $d =~ s,(.*/).*,$1,;
+ $f =~ s,.*\<([^\>]+)\>,$1,;
+
+ $f ="$d$f.rst";
+
+ next if (grep -e, glob("$f"));
+
+ if ($fix && !$doc_fix) {
+ print STDERR "\nWARNING: Currently, can't fix broken :doc:`` fields\n";
+ }
+ $doc_fix++;
+
+ print STDERR "$f: :doc:`$doc_ref`\n";
+}
+close IN;
+
+open IN, "git grep 'doc/'|"
+ or die "Failed to run git grep";
+while (<IN>) {
+ next if (!m/^([^:]+):(.*)/);
+
+ my $f = $1;
+ my $ln = $2;
+
+ # On linux-next, discard the Next/ directory
+ next if ($f =~ m,^Next/,);
+
+ # Makefiles and scripts contain nasty expressions to parse docs
+ next if ($f =~ m/Makefile/ || $f =~ m/\.sh$/);
+
+ # Skip this script
+ next if ($f eq $scriptname);
+
+ # Ignore the dir where documentation will be built
+ next if ($ln =~ m,\b(\S*)doc/output,);
+
+ if ($ln =~ m,\b(\S*)(doc/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*)(.*),) {
+ my $prefix = $1;
+ my $ref = $2;
+ my $base = $2;
+ my $extra = $3;
+
+ # some file references are like:
+ # /usr/src/linux/doc/DMA-{API,mapping}.txt
+ # For now, ignore them
+ next if ($extra =~ m/^{/);
+
+ # Remove footnotes at the end like:
+ # doc/devicetree/dt-object-internal.txt[1]
+ $ref =~ s/(txt|rst)\[\d+]$/$1/;
+
+ # Remove ending ']' without any '['
+ $ref =~ s/\].*// if (!($ref =~ m/\[/));
+
+ # Remove puntuation marks at the end
+ $ref =~ s/[\,\.]+$//;
+
+ my $fulref = "$prefix$ref";
+
+ $fulref =~ s/^(\<file|ref)://;
+ $fulref =~ s/^[\'\`]+//;
+ $fulref =~ s,^\$\(.*\)/,,;
+ $base =~ s,.*/,,;
+
+ # Remove URL false-positives
+ next if ($fulref =~ m/^http/);
+
+ # Check if exists, evaluating wildcards
+ next if (grep -e, glob("$ref $fulref"));
+
+ # Accept relative doc patches for tools/
+ if ($f =~ m/tools/) {
+ my $path = $f;
+ $path =~ s,(.*)/.*,$1,;
+ next if (grep -e, glob("$path/$ref $path/../$ref $path/$fulref"));
+ }
+
+ # Discard known false-positives
+ if (defined($false_positives{$f})) {
+ next if ($false_positives{$f} eq $fulref);
+ }
+
+ if ($fix) {
+ if (!($ref =~ m/(scripts|Kconfig|Kbuild)/)) {
+ $broken_ref{$ref}++;
+ }
+ } elsif ($warn) {
+ print STDERR "Warning: $f references a file that doesn't exist: $fulref\n";
+ } else {
+ print STDERR "$f: $fulref\n";
+ }
+ }
+}
+close IN;
+
+exit 0 if (!$fix);
+
+# Step 2: Seek for file name alternatives
+print "Auto-fixing broken references. Please double-check the results\n";
+
+foreach my $ref (keys %broken_ref) {
+ my $new =$ref;
+
+ my $basedir = ".";
+ # On translations, only seek inside the translations directory
+ $basedir = $1 if ($ref =~ m,(doc/translations/[^/]+),);
+
+ # get just the basename
+ $new =~ s,.*/,,;
+
+ my $f="";
+
+ # usual reason for breakage: DT file moved around
+ if ($ref =~ /devicetree/) {
+ # usual reason for breakage: DT file renamed to .yaml
+ if (!$f) {
+ my $new_ref = $ref;
+ $new_ref =~ s/\.txt$/.yaml/;
+ $f=$new_ref if (-f $new_ref);
+ }
+
+ if (!$f) {
+ my $search = $new;
+ $search =~ s,^.*/,,;
+ $f = qx(find doc/device-tree-bindings/ -iname "*$search*") if ($search);
+ if (!$f) {
+ # Manufacturer name may have changed
+ $search =~ s/^.*,//;
+ $f = qx(find doc/device-tree-bindings/ -iname "*$search*") if ($search);
+ }
+ }
+ }
+
+ # usual reason for breakage: file renamed to .rst
+ if (!$f) {
+ $new =~ s/\.txt$/.rst/;
+ $f=qx(find $basedir -iname $new) if ($new);
+ }
+
+ # usual reason for breakage: use dash or underline
+ if (!$f) {
+ $new =~ s/[-_]/[-_]/g;
+ $f=qx(find $basedir -iname $new) if ($new);
+ }
+
+ # Wild guess: seek for the same name on another place
+ if (!$f) {
+ $f = qx(find $basedir -iname $new) if ($new);
+ }
+
+ my @find = split /\s+/, $f;
+
+ if (!$f) {
+ print STDERR "ERROR: Didn't find a replacement for $ref\n";
+ } elsif (scalar(@find) > 1) {
+ print STDERR "WARNING: Won't auto-replace, as found multiple files close to $ref:\n";
+ foreach my $j (@find) {
+ $j =~ s,^./,,;
+ print STDERR " $j\n";
+ }
+ } else {
+ $f = $find[0];
+ $f =~ s,^./,,;
+ print "INFO: Replacing $ref to $f\n";
+ foreach my $j (qx(git grep -l $ref)) {
+ qx(sed "s\@$ref\@$f\@g" -i $j);
+ }
+ }
+}
diff --git a/tools/buildman/README b/tools/buildman/README
index 4cf0114157..f3a0dc7288 100644
--- a/tools/buildman/README
+++ b/tools/buildman/README
@@ -51,23 +51,25 @@ Theory of Operation
Buildman is a builder. It is not make, although it runs make. It does not
produce any useful output on the terminal while building, except for
-progress information (except with -v, see below). All the output (errors,
-warnings and binaries if you ask for them) is stored in output
-directories, which you can look at while the build is progressing, or when
-it is finished.
+progress information (but see -v below). All the output (errors, warnings and
+binaries if you ask for them) is stored in output directories, which you can
+look at from a separate 'buildman -s' instance while the build is progressing,
+or when it is finished.
Buildman is designed to build entire git branches, i.e. muliple commits. It
-can be run repeatedly on the same branch. In this case it will automatically
-rebuild commits which have changed (and remove its old results for that
-commit). It is possible to build a branch for one board, then later build it
-for another board. If you want buildman to re-build a commit it has already
-built (e.g. because of a toolchain update), use the -f flag.
+can be run repeatedly on the same branch after making changes to commits on
+that branch. In this case it will automatically rebuild commits which have
+changed (and remove its old results for that commit). It is possible to build
+a branch for one board, then later build it for another board. This adds to
+the output, so now you have results for two boards. If you want buildman to
+re-build a commit it has already built (e.g. because of a toolchain update),
+use the -f flag.
Buildman produces a concise summary of which boards succeeded and failed.
It shows which commit introduced which board failure using a simple
-red/green colour coding. Full error information can be requested, in which
-case it is de-duped and displayed against the commit that introduced the
-error. An example workflow is below.
+red/green colour coding (with yellow/cyan for warnings). Full error
+information can be requested, in which case it is de-duped and displayed
+against the commit that introduced the error. An example workflow is below.
Buildman stores image size information and can report changes in image size
from commit to commit. An example of this is below.
@@ -75,16 +77,20 @@ from commit to commit. An example of this is below.
Buildman starts multiple threads, and each thread builds for one board at
a time. A thread starts at the first commit, configures the source for your
board and builds it. Then it checks out the next commit and does an
-incremental build. Eventually the thread reaches the last commit and stops.
-If errors or warnings are found along the way, the thread will reconfigure
-after every commit, and your build will be very slow. This is because a
-file that produces just a warning would not normally be rebuilt in an
-incremental build.
+incremental build (i.e. not using 'make xxx_defconfig' unless you use -C).
+Eventually the thread reaches the last commit and stops. If a commit causes
+an error or warning, buildman will try it again after reconfiguring (but see
+-Q). Thus some commits may be built twice, with the first result silently
+discarded. Lots of errors and warnings will causes lots of reconfigures and your
+build will be very slow. This is because a file that produces just a warning
+would not normally be rebuilt in an incremental build. Once a thread finishes
+building all the commits for a board, it starts on the commits for another
+board.
Buildman works in an entirely separate place from your U-Boot repository.
It creates a separate working directory for each thread, and puts the
output files in the working directory, organised by commit name and board
-name, in a two-level hierarchy.
+name, in a two-level hierarchy (but see -P).
Buildman is invoked in your U-Boot directory, the one with the .git
directory. It clones this repository into a copy for each thread, and the
@@ -92,20 +98,23 @@ threads do not affect the state of your git repository. Any checkouts done
by the thread affect only the working directory for that thread.
Buildman automatically selects the correct tool chain for each board. You
-must supply suitable tool chains, but buildman takes care of selecting the
-right one.
+must supply suitable tool chains (see --fetch-arch), but buildman takes care
+of selecting the right one.
Buildman generally builds a branch (with the -b flag), and in this case
-builds the upstream commit as well, for comparison. It cannot build
-individual commits at present, unless (maybe) you point it at an empty
-branch. Put all your commits in a branch, set the branch's upstream to a
-valid value, and all will be well. Otherwise buildman will perform random
-actions. Use -n to check what the random actions might be.
+builds the upstream commit as well, for comparison. So even if you have one
+commit in your branch, two commits will be built. Put all your commits in a
+branch, set the branch's upstream to a valid value, and all will be well.
+Otherwise buildman will perform random actions. Use -n to check what the
+random actions might be.
+
+Buildman effectively has two modes: without -s it builds, with -s it
+summarises the results of previous (or active) builds.
-If you just want to build the current source tree, leave off the -b flag
-and add -e. This will display results and errors as they happen. You can
-still look at them later using -se. Note that buildman will assume that the
-source has changed, and will build all specified boards in this case.
+If you just want to build the current source tree, leave off the -b flag.
+This will display results and errors as they happen. You can still look at
+them later using -se. Note that buildman will assume that the source has
+changed, and will build all specified boards in this case.
Buildman is optimised for building many commits at once, for many boards.
On multi-core machines, Buildman is fast because it uses most of the
@@ -142,9 +151,9 @@ You can also use -x to specifically exclude some boards. For example:
means to build all arm boards except nvidia, freescale and anything ending
with 'ball'.
-For building specific boards you can use the --boards option, which takes a
-comma-separated list of board target names and be used multiple times on
-the command line:
+For building specific boards you can use the --boards (or --bo) option, which
+takes a comma-separated list of board target names and be used multiple times
+on the command line:
buildman --boards sandbox,snow --boards
@@ -492,6 +501,8 @@ If it can't detect the upstream branch, try checking out the branch, and
doing something like 'git branch --set-upstream-to upstream/master'
or something similar. Buildman will try to guess a suitable upstream branch
if it can't find one (you will see a message like" Guessing upstream as ...).
+You can also use the -c option to manually specify the number of commits to
+build.
As an example:
@@ -542,12 +553,13 @@ Buildman will set up some working directories, and get started. After a
minute or so it will settle down to a steady pace, with a display like this:
Building 18 commits for 1059 boards (4 threads, 1 job per thread)
- 528 36 124 /19062 1:13:30 : SIMPC8313_SP
+ 528 36 124 /19062 -18374 1:13:30 : SIMPC8313_SP
This means that it is building 19062 board/commit combinations. So far it
has managed to successfully build 528. Another 36 have built with warnings,
-and 124 more didn't build at all. Buildman expects to complete the process
-in around an hour and a quarter. Use this time to buy a faster computer.
+and 124 more didn't build at all. It has 18374 builds left to complete.
+Buildman expects to complete the process in around an hour and a quarter.
+Use this time to buy a faster computer.
To find out how the build went, ask for a summary with -s. You can do this
@@ -579,32 +591,32 @@ $ ./tools/buildman/buildman -b lcd9b -s
This shows which commits have succeeded and which have failed. In this case
the build is still in progress so many boards are not built yet (use -u to
-see which ones). But still we can see a few failures. The galaxy5200_LOWBOOT
+see which ones). But already we can see a few failures. The galaxy5200_LOWBOOT
never builds correctly. This could be a problem with our toolchain, or it
could be a bug in the upstream. The good news is that we probably don't need
to blame our commits. The bad news is that our commits are not tested on that
board.
-Commit 12 broke lubbock. That's what the '+ lubbock' means. The failure
-is never fixed by a later commit, or you would see lubbock again, in green,
-without the +.
+Commit 12 broke lubbock. That's what the '+ lubbock', in red, means. The
+failure is never fixed by a later commit, or you would see lubbock again, in
+green, without the +.
To see the actual error:
-$ ./tools/buildman/buildman -b <branch> -se lubbock
+$ ./tools/buildman/buildman -b <branch> -se
...
12: lcd: Add support for flushing LCD fb from dcache after update
arm: + lubbock
+common/libcommon.o: In function `lcd_sync':
-+/u-boot/lcd9b/.bm-work/00/common/lcd.c:120: undefined reference to `flush_dcache_range'
++common/lcd.c:120: undefined reference to `flush_dcache_range'
+arm-none-linux-gnueabi-ld: BFD (Sourcery G++ Lite 2010q1-202) 2.19.51.20090709 assertion fail /scratch/julian/2010q1-release-linux-lite/obj/binutils-src-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/bfd/elf32-arm.c:12572
-+make: *** [/u-boot/lcd9b/.bm-work/00/build/u-boot] Error 139
++make: *** [build/u-boot] Error 139
13: tegra: Align LCD frame buffer to section boundary
14: tegra: Support control of cache settings for LCD
15: tegra: fdt: Add LCD definitions for Seaboard
16: lcd: Add CONFIG_CONSOLE_SCROLL_LINES option to speed console
--/u-boot/lcd9b/.bm-work/00/common/lcd.c:120: undefined reference to `flush_dcache_range'
-+/u-boot/lcd9b/.bm-work/00/common/lcd.c:125: undefined reference to `flush_dcache_range'
+-common/lcd.c:120: undefined reference to `flush_dcache_range'
++common/lcd.c:125: undefined reference to `flush_dcache_range'
17: tegra: Enable display/lcd support on Seaboard
18: wip
@@ -612,6 +624,21 @@ So the problem is in lcd.c, due to missing cache operations. This information
should be enough to work out what that commit is doing to break these
boards. (In this case pxa did not have cache operations defined).
+Note that if there were other boards with errors, the above command would
+show their errors also. Each line is shown only once. So if lubbock and snow
+produce the same error, we just see:
+
+12: lcd: Add support for flushing LCD fb from dcache after update
+ arm: + lubbock snow
++common/libcommon.o: In function `lcd_sync':
++common/lcd.c:120: undefined reference to `flush_dcache_range'
++arm-none-linux-gnueabi-ld: BFD (Sourcery G++ Lite 2010q1-202) 2.19.51.20090709 assertion fail /scratch/julian/2010q1-release-linux-lite/obj/binutils-src-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu/bfd/elf32-arm.c:12572
++make: *** [build/u-boot] Error 139
+
+But if you did want to see just the errors for lubbock, use:
+
+$ ./tools/buildman/buildman -b <branch> -se lubbock
+
If you see error lines marked with '-', that means that the errors were fixed
by that commit. Sometimes commits can be in the wrong order, so that a
breakage is introduced for a few commits and fixed by later commits. This
@@ -622,13 +649,14 @@ At commit 16, the error moves: you can see that the old error at line 120
is fixed, but there is a new one at line 126. This is probably only because
we added some code and moved the broken line further down the file.
-If many boards have the same error, then -e will display the error only
-once. This makes the output as concise as possible. To see which boards have
-each error, use -l. So it is safe to omit the board name - you will not get
-lots of repeated output for every board.
+As mentioned, if many boards have the same error, then -e will display the
+error only once. This makes the output as concise as possible. To see which
+boards have each error, use -l. So it is safe to omit the board name - you
+will not get lots of repeated output for every board.
Buildman tries to distinguish warnings from errors, and shows warning lines
-separately with a 'w' prefix.
+separately with a 'w' prefix. Warnings introduced show as yellow. Warnings
+fixed show as cyan.
The full build output in this case is available in:
@@ -930,12 +958,11 @@ will build commits in us-buildman that are not in upstream/master.
Building Faster
===============
-By default, buildman executes 'make mrproper' prior to building the first
-commit for each board. This causes everything to be built from scratch. If you
-trust the build system's incremental build capabilities, you can pass the -I
-flag to skip the 'make mproper' invocation, which will reduce the amount of
-work 'make' does, and hence speed up the build. This flag will speed up any
-buildman invocation, since it reduces the amount of work done on any build.
+By default, buildman doesn't execute 'make mrproper' prior to building the
+first commit for each board. This reduces the amount of work 'make' does, and
+hence speeds up the build. To force use of 'make mrproper', use -the -m flag.
+This flag will slow down any buildman invocation, since it increases the amount
+of work done on any build.
One possible application of buildman is as part of a continual edit, build,
edit, build, ... cycle; repeatedly applying buildman to the same change or
@@ -966,7 +993,7 @@ Combining all of these options together yields the command-line shown below.
This will provide the quickest possible feedback regarding the current content
of the source tree, thus allowing rapid tested evolution of the code.
- SOURCE_DATE_EPOCH=0 ./tools/buildman/buildman -I -P tegra
+ SOURCE_DATE_EPOCH=0 ./tools/buildman/buildman -P tegra
Checking configuration
@@ -1087,15 +1114,18 @@ with -E, e.g. the migration warnings:
When doing builds, Buildman's return code will reflect the overall result:
0 (success) No errors or warnings found
- 128 Errors found
- 129 Warnings found (only if no -W)
+ 100 Errors found
+ 101 Warnings found (only if no -W)
-You can use -W to tell Buildman to return 0 (success) instead of 129 when
+You can use -W to tell Buildman to return 0 (success) instead of 101 when
warnings are found. Note that it can be useful to combine -E and -W. This means
-that all compiler warnings will produce failures (code 128) and all other
-warnings will produce success (since 129 is changed to 0).
+that all compiler warnings will produce failures (code 100) and all other
+warnings will produce success (since 101 is changed to 0).
+
+If there are both warnings and errors, errors win, so buildman returns 100.
-If there are both warnings and errors, errors win, so buildman returns 128.
+The -y option is provided (for use with -s) to ignore the bountiful device-tree
+warnings. Similarly, -Y tells buildman to ignore the migration warnings.
How to change from MAKEALL
@@ -1202,12 +1232,16 @@ Some options you might like are:
TODO
====
-This has mostly be written in my spare time as a response to my difficulties
-in testing large series of patches. Apart from tidying up there is quite a
-bit of scope for improvement. Things like better error diffs and easier
-access to log files. Also it would be nice if buildman could 'hunt' for
-problems, perhaps by building a few boards for each arch, or checking
-commits for changed files and building only boards which use those files.
+Many improvements have been made over the years. There is still quite a bit of
+scope for more though, e.g.:
+
+- easier access to log files
+- 'hunting' for problems, perhaps by building a few boards for each arch, or
+ checking commits for changed files and building only boards which use those
+ files
+- using the same git repo for all threads instead of cloning it. Currently
+ it uses about 500MB per thread, so on a 64-thread machine this is 32GB for
+ the build.
Credits
@@ -1223,3 +1257,4 @@ sjg@chromium.org
Halloween 2012
Updated 12-12-12
Updated 23-02-13
+Updated 09-04-20
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 70c55c588a..30ebe1d820 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -24,7 +24,6 @@ import terminal
from terminal import Print
import toolchain
-
"""
Theory of Operation
@@ -91,6 +90,15 @@ u-boot/ source directory
.git/ repository
"""
+"""Holds information about a particular error line we are outputing
+
+ char: Character representation: '+': error, '-': fixed error, 'w+': warning,
+ 'w-' = fixed warning
+ boards: List of Board objects which have line in the error/warning output
+ errline: The text of the error line
+"""
+ErrLine = collections.namedtuple('ErrLine', 'char,boards,errline')
+
# Possible build outcomes
OUTCOME_OK, OUTCOME_WARNING, OUTCOME_ERROR, OUTCOME_UNKNOWN = list(range(4))
@@ -154,8 +162,6 @@ class Builder:
force_build_failures: If a previously-built build (i.e. built on
a previous run of buildman) is marked as failed, rebuild it.
git_dir: Git directory containing source repository
- last_line_len: Length of the last line we printed (used for erasing
- it with new progress information)
num_jobs: Number of jobs to run at once (passed to make as -j)
num_threads: Number of builder threads to run
out_queue: Queue of results to process
@@ -186,6 +192,7 @@ class Builder:
_next_delay_update: Next time we plan to display a progress update
(datatime)
_show_unknown: Show unknown boards (those not built) in summary
+ _start_time: Start time for the build
_timestamps: List of timestamps for the completion of the last
last _timestamp_count builds. Each is a datetime object.
_timestamp_count: Number of timestamps to keep in our list.
@@ -224,7 +231,7 @@ class Builder:
def __init__(self, toolchains, base_dir, git_dir, num_threads, num_jobs,
gnu_make='make', checkout=True, show_unknown=True, step=1,
no_subdirs=False, full_path=False, verbose_build=False,
- incremental=False, per_board_out_dir=False,
+ mrproper=False, per_board_out_dir=False,
config_only=False, squash_config_y=False,
warnings_as_errors=False, work_in_output=False):
"""Create a new Builder object
@@ -245,8 +252,7 @@ class Builder:
full_path: Return the full path in CROSS_COMPILE and don't set
PATH
verbose_build: Run build with V=1 and don't use 'make -s'
- incremental: Always perform incremental builds; don't run make
- mrproper when configuring
+ mrproper: Always run 'make mrproper' when configuring
per_board_out_dir: Build in a separate persistent directory per
board rather than a thread-specific directory
config_only: Only configure each build, don't build it
@@ -275,6 +281,7 @@ class Builder:
self._build_period_us = None
self._complete_delay = None
self._next_delay_update = datetime.now()
+ self._start_time = datetime.now()
self.force_config_on_failure = True
self.force_build_failures = False
self.force_reconfig = False
@@ -299,17 +306,18 @@ class Builder:
self._re_warning = re.compile('(.*):(\d*):(\d*): warning: .*')
self._re_dtb_warning = re.compile('(.*): Warning .*')
self._re_note = re.compile('(.*):(\d*):(\d*): note: this is the location of the previous.*')
+ self._re_migration_warning = re.compile(r'^={21} WARNING ={22}\n.*\n=+\n',
+ re.MULTILINE | re.DOTALL)
self.queue = queue.Queue()
self.out_queue = queue.Queue()
for i in range(self.num_threads):
- t = builderthread.BuilderThread(self, i, incremental,
+ t = builderthread.BuilderThread(self, i, mrproper,
per_board_out_dir)
t.setDaemon(True)
t.start()
self.threads.append(t)
- self.last_line_len = 0
t = builderthread.ResultThread(self)
t.setDaemon(True)
t.start()
@@ -332,16 +340,22 @@ class Builder:
def SetDisplayOptions(self, show_errors=False, show_sizes=False,
show_detail=False, show_bloat=False,
list_error_boards=False, show_config=False,
- show_environment=False):
+ show_environment=False, filter_dtb_warnings=False,
+ filter_migration_warnings=False):
"""Setup display options for the builder.
- show_errors: True to show summarised error/warning info
- show_sizes: Show size deltas
- show_detail: Show size delta detail for each board if show_sizes
- show_bloat: Show detail for each function
- list_error_boards: Show the boards which caused each error/warning
- show_config: Show config deltas
- show_environment: Show environment deltas
+ Args:
+ show_errors: True to show summarised error/warning info
+ show_sizes: Show size deltas
+ show_detail: Show size delta detail for each board if show_sizes
+ show_bloat: Show detail for each function
+ list_error_boards: Show the boards which caused each error/warning
+ show_config: Show config deltas
+ show_environment: Show environment deltas
+ filter_dtb_warnings: Filter out any warnings from the device-tree
+ compiler
+ filter_migration_warnings: Filter out any warnings about migrating
+ a board to driver model
"""
self._show_errors = show_errors
self._show_sizes = show_sizes
@@ -350,6 +364,8 @@ class Builder:
self._list_error_boards = list_error_boards
self._show_config = show_config
self._show_environment = show_environment
+ self._filter_dtb_warnings = filter_dtb_warnings
+ self._filter_migration_warnings = filter_migration_warnings
def _AddTimestamp(self):
"""Add a new timestamp to the list and record the build period.
@@ -380,22 +396,6 @@ class Builder:
self._timestamps.popleft()
count -= 1
- def ClearLine(self, length):
- """Clear any characters on the current line
-
- Make way for a new line of length 'length', by outputting enough
- spaces to clear out the old line. Then remember the new length for
- next time.
-
- Args:
- length: Length of new line, in characters
- """
- if length < self.last_line_len:
- Print(' ' * (self.last_line_len - length), newline=False)
- Print('\r', newline=False)
- self.last_line_len = length
- sys.stdout.flush()
-
def SelectCommit(self, commit, checkout=True):
"""Checkout the selected commit for this build
"""
@@ -441,8 +441,7 @@ class Builder:
if result.already_done:
self.already_done += 1
if self._verbose:
- Print('\r', newline=False)
- self.ClearLine(0)
+ terminal.PrintClear()
boards_selected = {target : result.brd}
self.ResetResultSummary(boards_selected)
self.ProduceResultSummary(result.commit_upto, self.commits,
@@ -456,22 +455,21 @@ class Builder:
line += self.col.Color(self.col.YELLOW, '%5d' % self.warned)
line += self.col.Color(self.col.RED, '%5d' % self.fail)
- name = ' /%-5d ' % self.count
+ line += ' /%-5d ' % self.count
+ remaining = self.count - self.upto
+ if remaining:
+ line += self.col.Color(self.col.MAGENTA, ' -%-5d ' % remaining)
+ else:
+ line += ' ' * 8
# Add our current completion time estimate
self._AddTimestamp()
if self._complete_delay:
- name += '%s : ' % self._complete_delay
- # When building all boards for a commit, we can print a commit
- # progress message.
- if result and result.commit_upto is None:
- name += 'commit %2d/%-3d' % (self.commit_upto + 1,
- self.commit_count)
-
- name += target
- Print(line + name, newline=False)
- length = 16 + len(name)
- self.ClearLine(length)
+ line += '%s : ' % self._complete_delay
+
+ line += target
+ terminal.PrintClear()
+ Print(line, newline=False, limit_to_line=True)
def _GetOutputDir(self, commit_upto):
"""Get the name of the output directory for a commit number
@@ -567,9 +565,16 @@ class Builder:
New list with only interesting lines included
"""
out_lines = []
+ if self._filter_migration_warnings:
+ text = '\n'.join(lines)
+ text = self._re_migration_warning.sub('', text)
+ lines = text.splitlines()
for line in lines:
- if not self.re_make_err.search(line):
- out_lines.append(line)
+ if self.re_make_err.search(line):
+ continue
+ if self._filter_dtb_warnings and self._re_dtb_warning.search(line):
+ continue
+ out_lines.append(line)
return out_lines
def ReadFuncSizes(self, fname, fd):
@@ -1128,32 +1133,52 @@ class Builder:
Args:
line: Error line to search for
+ line_boards: boards to search, each a Board
Return:
- String containing a list of boards with that error line, or
- '' if the user has not requested such a list
+ List of boards with that error line, or [] if the user has not
+ requested such a list
"""
+ boards = []
+ board_set = set()
if self._list_error_boards:
- names = []
for board in line_boards[line]:
- if not board.target in names:
- names.append(board.target)
- names_str = '(%s) ' % ','.join(names)
- else:
- names_str = ''
- return names_str
+ if not board in board_set:
+ boards.append(board)
+ board_set.add(board)
+ return boards
def _CalcErrorDelta(base_lines, base_line_boards, lines, line_boards,
char):
+ """Calculate the required output based on changes in errors
+
+ Args:
+ base_lines: List of errors/warnings for previous commit
+ base_line_boards: Dict keyed by error line, containing a list
+ of the Board objects with that error in the previous commit
+ lines: List of errors/warning for this commit, each a str
+ line_boards: Dict keyed by error line, containing a list
+ of the Board objects with that error in this commit
+ char: Character representing error ('') or warning ('w'). The
+ broken ('+') or fixed ('-') characters are added in this
+ function
+
+ Returns:
+ Tuple
+ List of ErrLine objects for 'better' lines
+ List of ErrLine objects for 'worse' lines
+ """
better_lines = []
worse_lines = []
for line in lines:
if line not in base_lines:
- worse_lines.append(char + '+' +
- _BoardList(line, line_boards) + line)
+ errline = ErrLine(char + '+', _BoardList(line, line_boards),
+ line)
+ worse_lines.append(errline)
for line in base_lines:
if line not in lines:
- better_lines.append(char + '-' +
- _BoardList(line, base_line_boards) + line)
+ errline = ErrLine(char + '-',
+ _BoardList(line, base_line_boards), line)
+ better_lines.append(errline)
return better_lines, worse_lines
def _CalcConfig(delta, name, config):
@@ -1209,6 +1234,34 @@ class Builder:
col = self.col.YELLOW
Print(' ' + line, newline=True, colour=col)
+ def _OutputErrLines(err_lines, colour):
+ """Output the line of error/warning lines, if not empty
+
+ Also increments self._error_lines if err_lines not empty
+
+ Args:
+ err_lines: List of ErrLine objects, each an error or warning
+ line, possibly including a list of boards with that
+ error/warning
+ colour: Colour to use for output
+ """
+ if err_lines:
+ out_list = []
+ for line in err_lines:
+ boards = ''
+ names = [board.target for board in line.boards]
+ board_str = ' '.join(names) if names else ''
+ if board_str:
+ out = self.col.Color(colour, line.char + '(')
+ out += self.col.Color(self.col.MAGENTA, board_str,
+ bright=False)
+ out += self.col.Color(colour, ') %s' % line.errline)
+ else:
+ out = self.col.Color(colour, line.char + line.errline)
+ out_list.append(out)
+ Print('\n'.join(out_list))
+ self._error_lines += 1
+
ok_boards = [] # List of boards fixed since last commit
warn_boards = [] # List of boards with warnings since last commit
@@ -1239,7 +1292,7 @@ class Builder:
else:
new_boards.append(target)
- # Get a list of errors that have appeared, and disappeared
+ # Get a list of errors and warnings that have appeared, and disappeared
better_err, worse_err = _CalcErrorDelta(self._base_err_lines,
self._base_err_line_boards, err_lines, err_line_boards, '')
better_warn, worse_warn = _CalcErrorDelta(self._base_warn_lines,
@@ -1262,18 +1315,10 @@ class Builder:
for arch, target_list in arch_list.items():
Print('%10s: %s' % (arch, target_list))
self._error_lines += 1
- if better_err:
- Print('\n'.join(better_err), colour=self.col.GREEN)
- self._error_lines += 1
- if worse_err:
- Print('\n'.join(worse_err), colour=self.col.RED)
- self._error_lines += 1
- if better_warn:
- Print('\n'.join(better_warn), colour=self.col.CYAN)
- self._error_lines += 1
- if worse_warn:
- Print('\n'.join(worse_warn), colour=self.col.MAGENTA)
- self._error_lines += 1
+ _OutputErrLines(better_err, colour=self.col.GREEN)
+ _OutputErrLines(worse_err, colour=self.col.RED)
+ _OutputErrLines(better_warn, colour=self.col.CYAN)
+ _OutputErrLines(worse_warn, colour=self.col.YELLOW)
if show_sizes:
self.PrintSizeSummary(board_selected, board_dict, show_detail,
@@ -1506,12 +1551,15 @@ class Builder:
if setup_git and self.git_dir:
src_dir = os.path.abspath(self.git_dir)
if os.path.exists(git_dir):
+ Print('\rFetching repo for thread %d' % thread_num,
+ newline=False)
gitutil.Fetch(git_dir, thread_dir)
+ terminal.PrintClear()
else:
Print('\rCloning repo for thread %d' % thread_num,
newline=False)
gitutil.Clone(src_dir, thread_dir)
- Print('\r%s\r' % (' ' * 30), newline=False)
+ terminal.PrintClear()
def _PrepareWorkingSpace(self, max_threads, setup_git):
"""Prepare the working directory for use.
@@ -1564,7 +1612,7 @@ class Builder:
newline=False)
for dirname in to_remove:
shutil.rmtree(dirname)
- Print('done')
+ terminal.PrintClear()
def BuildBoards(self, commits, board_selected, keep_outputs, verbose):
"""Build all commits for a list of boards
@@ -1612,5 +1660,19 @@ class Builder:
# Wait until we have processed all output
self.out_queue.join()
Print()
- self.ClearLine(0)
+
+ msg = 'Completed: %d total built' % self.count
+ if self.already_done:
+ msg += ' (%d previously' % self.already_done
+ if self.already_done != self.count:
+ msg += ', %d newly' % (self.count - self.already_done)
+ msg += ')'
+ duration = datetime.now() - self._start_time
+ if duration > timedelta(microseconds=1000000):
+ if duration.microseconds >= 500000:
+ duration = duration + timedelta(seconds=1)
+ duration = duration - timedelta(microseconds=duration.microseconds)
+ msg += ', duration %s' % duration
+ Print(msg)
+
return (self.fail, self.warned)
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 7561f39942..fc6e1ab25d 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -90,12 +90,12 @@ class BuilderThread(threading.Thread):
thread_num: Our thread number (0-n-1), used to decide on a
temporary directory
"""
- def __init__(self, builder, thread_num, incremental, per_board_out_dir):
+ def __init__(self, builder, thread_num, mrproper, per_board_out_dir):
"""Set up a new builder thread"""
threading.Thread.__init__(self)
self.builder = builder
self.thread_num = thread_num
- self.incremental = incremental
+ self.mrproper = mrproper
self.per_board_out_dir = per_board_out_dir
def Make(self, commit, brd, stage, cwd, *args, **kwargs):
@@ -243,7 +243,7 @@ class BuilderThread(threading.Thread):
# If we need to reconfigure, do that now
if do_config:
config_out = ''
- if not self.incremental:
+ if self.mrproper:
result = self.Make(commit, brd, 'mrproper', cwd,
'mrproper', *args, env=env)
config_out += result.combined
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index 17ea015a95..1377b9d2be 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -55,8 +55,9 @@ def ParseArgs():
parser.add_option('-i', '--in-tree', dest='in_tree',
action='store_true', default=False,
help='Build in the source tree instead of a separate directory')
+ # -I will be removed after April 2021
parser.add_option('-I', '--incremental', action='store_true',
- default=False, help='Do not run make mrproper (when reconfiguring)')
+ default=False, help='Deprecated, does nothing. See -m')
parser.add_option('-j', '--jobs', dest='jobs', type='int',
default=None, help='Number of jobs to run at once (passed to make)')
parser.add_option('-k', '--keep-outputs', action='store_true',
@@ -69,6 +70,8 @@ def ParseArgs():
default=False, help='Show a list of boards next to each error/warning')
parser.add_option('--list-tool-chains', action='store_true', default=False,
help='List available tool chains (use -v to see probing detail)')
+ parser.add_option('-m', '--mrproper', action='store_true',
+ default=False, help="Run 'make mrproper before reconfiguring")
parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
default=False, help="Do a dry run (describe actions, but do nothing)")
parser.add_option('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
@@ -111,6 +114,12 @@ def ParseArgs():
parser.add_option('-x', '--exclude', dest='exclude',
type='string', action='append',
help='Specify a list of boards to exclude, separated by comma')
+ parser.add_option('-y', '--filter-dtb-warnings', action='store_true',
+ default=False,
+ help='Filter out device-tree-compiler warnings from output')
+ parser.add_option('-Y', '--filter-migration-warnings', action='store_true',
+ default=False,
+ help='Filter out migration warnings from output')
parser.usage += """ [list of target/arch/cpu/board/vendor/soc to build]
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 5ddc598c95..30c030fd16 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -172,6 +172,10 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
print()
return 0
+ if options.incremental:
+ print(col.Color(col.RED,
+ 'Warning: -I has been removed. See documentation'))
+
# Work out what subset of the boards we are building
if not boards:
if not os.path.exists(options.output_dir):
@@ -309,7 +313,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
show_unknown=options.show_unknown, step=options.step,
no_subdirs=options.no_subdirs, full_path=options.full_path,
verbose_build=options.verbose_build,
- incremental=options.incremental,
+ mrproper=options.mrproper,
per_board_out_dir=options.per_board_out_dir,
config_only=options.config_only,
squash_config_y=not options.preserve_config_y,
@@ -341,23 +345,23 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
commits = None
Print(GetActionSummary(options.summary, commits, board_selected,
- options))
+ options))
# We can't show function sizes without board details at present
if options.show_bloat:
options.show_detail = True
- builder.SetDisplayOptions(options.show_errors, options.show_sizes,
- options.show_detail, options.show_bloat,
- options.list_error_boards,
- options.show_config,
- options.show_environment)
+ builder.SetDisplayOptions(
+ options.show_errors, options.show_sizes, options.show_detail,
+ options.show_bloat, options.list_error_boards, options.show_config,
+ options.show_environment, options.filter_dtb_warnings,
+ options.filter_migration_warnings)
if options.summary:
builder.ShowSummary(commits, board_selected)
else:
fail, warned = builder.BuildBoards(commits, board_selected,
options.keep_outputs, options.verbose)
if fail:
- return 128
+ return 100
elif warned and not options.ignore_warnings:
- return 129
+ return 101
return 0
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 2a256a9263..1fbc6f6b00 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -454,7 +454,7 @@ class TestFunctional(unittest.TestCase):
# Only sandbox should succeed, the others don't have toolchains
self.assertEqual(self._builder.fail,
self._total_builds - self._commits)
- self.assertEqual(ret_code, 128)
+ self.assertEqual(ret_code, 100)
for commit in range(self._commits):
for board in self._boards.GetList():
@@ -476,15 +476,15 @@ class TestFunctional(unittest.TestCase):
self._RunControl('-b', TEST_BRANCH, '-c2', '-o', self._output_dir)
self.assertEqual(self._builder.count, 2 * len(boards))
self.assertEqual(self._builder.fail, 0)
- # Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (2 + 2))
+ # Each board has a config, and then one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (1 + 2))
def testIncremental(self):
"""Test building a branch twice - the second time should do nothing"""
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir)
# Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 1))
self._make_calls = 0
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir, clean_dir=False)
self.assertEqual(self._make_calls, 0)
@@ -496,14 +496,26 @@ class TestFunctional(unittest.TestCase):
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir)
self._make_calls = 0
self._RunControl('-b', TEST_BRANCH, '-f', '-o', self._output_dir, clean_dir=False)
- # Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
+ # Each board has a config and one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 1))
def testForceReconfigure(self):
"""The -f flag should force a rebuild"""
self._RunControl('-b', TEST_BRANCH, '-C', '-o', self._output_dir)
- # Each commit has a mrproper, config and make
- self.assertEqual(self._make_calls, len(boards) * self._commits * 3)
+ # Each commit has a config and make
+ self.assertEqual(self._make_calls, len(boards) * self._commits * 2)
+
+ def testForceReconfigure(self):
+ """The -f flag should force a rebuild"""
+ self._RunControl('-b', TEST_BRANCH, '-C', '-o', self._output_dir)
+ # Each commit has a config and make
+ self.assertEqual(self._make_calls, len(boards) * self._commits * 2)
+
+ def testMrproper(self):
+ """The -f flag should force a rebuild"""
+ self._RunControl('-b', TEST_BRANCH, '-m', '-o', self._output_dir)
+ # Each board has a mkproper, config and then one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
def testErrors(self):
"""Test handling of build errors"""
@@ -525,7 +537,7 @@ class TestFunctional(unittest.TestCase):
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir, '-F', clean_dir=False)
self.assertEqual(self._builder.count, self._total_builds)
self.assertEqual(self._builder.fail, 0)
- self.assertEqual(self._make_calls, 3)
+ self.assertEqual(self._make_calls, 2)
def testBranchWithSlash(self):
"""Test building a branch with a '/' in the name"""
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 2aaedf44ac..d32b22653f 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -36,6 +36,14 @@ main: /usr/sbin
x86: i386 x86_64
'''
+migration = '''===================== WARNING ======================
+This board does not use CONFIG_DM. CONFIG_DM will be
+compulsory starting with the v2020.01 release.
+Failure to update may result in board removal.
+See doc/driver-model/migration.rst for more info.
+====================================================
+'''
+
errors = [
'''main.c: In function 'main_loop':
main.c:260:6: warning: unused variable 'joe' [-Wunused-variable]
@@ -79,13 +87,14 @@ make: *** [sub-make] Error 2
# hash, subject, return code, list of errors/warnings
commits = [
- ['1234', 'upstream/master, ok', 0, []],
+ ['1234', 'upstream/master, migration warning', 0, []],
['5678', 'Second commit, a warning', 0, errors[0:1]],
['9012', 'Third commit, error', 1, errors[0:2]],
['3456', 'Fourth commit, warning', 0, [errors[0], errors[2]]],
['7890', 'Fifth commit, link errors', 1, [errors[0], errors[3]]],
['abcd', 'Sixth commit, fixes all errors', 0, []],
- ['ef01', 'Seventh commit, check directory suppression', 1, [errors[4]]],
+ ['ef01', 'Seventh commit, fix migration, check directory suppression', 1,
+ [errors[4]]],
]
boards = [
@@ -118,6 +127,8 @@ class TestBuild(unittest.TestCase):
comm.subject = commit_info[1]
comm.return_code = commit_info[2]
comm.error_list = commit_info[3]
+ if sequence < 6:
+ comm.error_list += [migration]
comm.sequence = sequence
sequence += 1
self.commits.append(comm)
@@ -143,9 +154,14 @@ class TestBuild(unittest.TestCase):
terminal.SetPrintTestMode()
self._col = terminal.Color()
- def Make(self, commit, brd, stage, *args, **kwargs):
- global base_dir
+ self.base_dir = tempfile.mkdtemp()
+ if not os.path.isdir(self.base_dir):
+ os.mkdir(self.base_dir)
+ def tearDown(self):
+ shutil.rmtree(self.base_dir)
+
+ def Make(self, commit, brd, stage, *args, **kwargs):
result = command.CommandResult()
boardnum = int(brd.target[-1])
result.return_code = 0
@@ -156,7 +172,9 @@ class TestBuild(unittest.TestCase):
boardnum == 4 and commit.sequence == 6):
result.return_code = commit.return_code
result.stderr = (''.join(commit.error_list)
- % {'basedir' : base_dir + '/.bm-work/00/'})
+ % {'basedir' : self.base_dir + '/.bm-work/00/'})
+ elif commit.sequence < 6:
+ result.stderr = migration
result.combined = result.stdout + result.stderr
return result
@@ -173,17 +191,19 @@ class TestBuild(unittest.TestCase):
expect += col.Color(expected_colour, ' %s' % board)
self.assertEqual(text, expect)
- def testOutput(self):
- """Test basic builder operation and output
+ def _SetupTest(self, echo_lines=False, **kwdisplay_args):
+ """Set up the test by running a build and summary
- This does a line-by-line verification of the summary output.
- """
- global base_dir
+ Args:
+ echo_lines: True to echo lines to the terminal to aid test
+ development
+ kwdisplay_args: Dict of arguemnts to pass to
+ Builder.SetDisplayOptions()
- base_dir = tempfile.mkdtemp()
- if not os.path.isdir(base_dir):
- os.mkdir(base_dir)
- build = builder.Builder(self.toolchains, base_dir, None, 1, 2,
+ Returns:
+ Iterator containing the output lines, each a PrintLine() object
+ """
+ build = builder.Builder(self.toolchains, self.base_dir, None, 1, 2,
checkout=False, show_unknown=False)
build.do_make = self.Make
board_selected = self.boards.GetSelectedDict()
@@ -198,124 +218,238 @@ class TestBuild(unittest.TestCase):
if line.text.strip():
count += 1
- # We should get two starting messages, then an update for every commit
- # built.
- self.assertEqual(count, len(commits) * len(boards) + 2)
- build.SetDisplayOptions(show_errors=True);
+ # We should get two starting messages, an update for every commit built
+ # and a summary message
+ self.assertEqual(count, len(commits) * len(boards) + 3)
+ build.SetDisplayOptions(**kwdisplay_args);
build.ShowSummary(self.commits, board_selected)
- #terminal.EchoPrintTestLines()
- lines = terminal.GetPrintTestLines()
+ if echo_lines:
+ terminal.EchoPrintTestLines()
+ return iter(terminal.GetPrintTestLines())
+
+ def _CheckOutput(self, lines, list_error_boards=False,
+ filter_dtb_warnings=False,
+ filter_migration_warnings=False):
+ """Check for expected output from the build summary
+
+ Args:
+ lines: Iterator containing the lines returned from the summary
+ list_error_boards: Adjust the check for output produced with the
+ --list-error-boards flag
+ filter_dtb_warnings: Adjust the check for output produced with the
+ --filter-dtb-warnings flag
+ """
+ def add_line_prefix(prefix, boards, error_str, colour):
+ """Add a prefix to each line of a string
+
+ The training \n in error_str is removed before processing
+
+ Args:
+ prefix: String prefix to add
+ error_str: Error string containing the lines
+ colour: Expected colour for the line. Note that the board list,
+ if present, always appears in magenta
+
+ Returns:
+ New string where each line has the prefix added
+ """
+ lines = error_str.strip().splitlines()
+ new_lines = []
+ for line in lines:
+ if boards:
+ expect = self._col.Color(colour, prefix + '(')
+ expect += self._col.Color(self._col.MAGENTA, boards,
+ bright=False)
+ expect += self._col.Color(colour, ') %s' % line)
+ else:
+ expect = self._col.Color(colour, prefix + line)
+ new_lines.append(expect)
+ return '\n'.join(new_lines)
- # Upstream commit: no errors
- self.assertEqual(lines[0].text, '01: %s' % commits[0][1])
+ col = terminal.Color()
+ boards01234 = ('board0 board1 board2 board3 board4'
+ if list_error_boards else '')
+ boards1234 = 'board1 board2 board3 board4' if list_error_boards else ''
+ boards234 = 'board2 board3 board4' if list_error_boards else ''
+ boards34 = 'board3 board4' if list_error_boards else ''
+ boards4 = 'board4' if list_error_boards else ''
+
+ # Upstream commit: migration warnings only
+ self.assertEqual(next(lines).text, '01: %s' % commits[0][1])
+
+ if not filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'arm', 'w+',
+ ['board0', 'board1'], outcome=OUTCOME_WARN)
+ self.assertSummary(next(lines).text, 'powerpc', 'w+',
+ ['board2', 'board3'], outcome=OUTCOME_WARN)
+ self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
+ outcome=OUTCOME_WARN)
+
+ self.assertEqual(next(lines).text,
+ add_line_prefix('+', boards01234, migration, col.RED))
# Second commit: all archs should fail with warnings
- self.assertEqual(lines[1].text, '02: %s' % commits[1][1])
+ self.assertEqual(next(lines).text, '02: %s' % commits[1][1])
- col = terminal.Color()
- self.assertSummary(lines[2].text, 'arm', 'w+', ['board1'],
- outcome=OUTCOME_WARN)
- self.assertSummary(lines[3].text, 'powerpc', 'w+', ['board2', 'board3'],
- outcome=OUTCOME_WARN)
- self.assertSummary(lines[4].text, 'sandbox', 'w+', ['board4'],
- outcome=OUTCOME_WARN)
+ if filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'arm', 'w+',
+ ['board1'], outcome=OUTCOME_WARN)
+ self.assertSummary(next(lines).text, 'powerpc', 'w+',
+ ['board2', 'board3'], outcome=OUTCOME_WARN)
+ self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
+ outcome=OUTCOME_WARN)
# Second commit: The warnings should be listed
- self.assertEqual(lines[5].text, 'w+%s' %
- errors[0].rstrip().replace('\n', '\nw+'))
- self.assertEqual(lines[5].colour, col.MAGENTA)
+ self.assertEqual(next(lines).text,
+ add_line_prefix('w+', boards1234, errors[0], col.YELLOW))
# Third commit: Still fails
- self.assertEqual(lines[6].text, '03: %s' % commits[2][1])
- self.assertSummary(lines[7].text, 'arm', '', ['board1'],
- outcome=OUTCOME_OK)
- self.assertSummary(lines[8].text, 'powerpc', '+', ['board2', 'board3'])
- self.assertSummary(lines[9].text, 'sandbox', '+', ['board4'])
+ self.assertEqual(next(lines).text, '03: %s' % commits[2][1])
+ if filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'arm', '',
+ ['board1'], outcome=OUTCOME_OK)
+ self.assertSummary(next(lines).text, 'powerpc', '+',
+ ['board2', 'board3'])
+ self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
# Expect a compiler error
- self.assertEqual(lines[10].text, '+%s' %
- errors[1].rstrip().replace('\n', '\n+'))
+ self.assertEqual(next(lines).text,
+ add_line_prefix('+', boards234, errors[1], col.RED))
# Fourth commit: Compile errors are fixed, just have warning for board3
- self.assertEqual(lines[11].text, '04: %s' % commits[3][1])
- expect = '%10s: ' % 'powerpc'
- expect += ' ' + col.Color(col.GREEN, '')
- expect += ' '
- expect += col.Color(col.GREEN, ' %s' % 'board2')
- expect += ' ' + col.Color(col.YELLOW, 'w+')
- expect += ' '
- expect += col.Color(col.YELLOW, ' %s' % 'board3')
- self.assertEqual(lines[12].text, expect)
- self.assertSummary(lines[13].text, 'sandbox', 'w+', ['board4'],
- outcome=OUTCOME_WARN)
+ self.assertEqual(next(lines).text, '04: %s' % commits[3][1])
+ if filter_migration_warnings:
+ expect = '%10s: ' % 'powerpc'
+ expect += ' ' + col.Color(col.GREEN, '')
+ expect += ' '
+ expect += col.Color(col.GREEN, ' %s' % 'board2')
+ expect += ' ' + col.Color(col.YELLOW, 'w+')
+ expect += ' '
+ expect += col.Color(col.YELLOW, ' %s' % 'board3')
+ self.assertEqual(next(lines).text, expect)
+ else:
+ self.assertSummary(next(lines).text, 'powerpc', 'w+',
+ ['board2', 'board3'], outcome=OUTCOME_WARN)
+ self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
+ outcome=OUTCOME_WARN)
# Compile error fixed
- self.assertEqual(lines[14].text, '-%s' %
- errors[1].rstrip().replace('\n', '\n-'))
- self.assertEqual(lines[14].colour, col.GREEN)
+ self.assertEqual(next(lines).text,
+ add_line_prefix('-', boards234, errors[1], col.GREEN))
- self.assertEqual(lines[15].text, 'w+%s' %
- errors[2].rstrip().replace('\n', '\nw+'))
- self.assertEqual(lines[15].colour, col.MAGENTA)
+ if not filter_dtb_warnings:
+ self.assertEqual(
+ next(lines).text,
+ add_line_prefix('w+', boards34, errors[2], col.YELLOW))
# Fifth commit
- self.assertEqual(lines[16].text, '05: %s' % commits[4][1])
- self.assertSummary(lines[17].text, 'powerpc', '', ['board3'],
- outcome=OUTCOME_OK)
- self.assertSummary(lines[18].text, 'sandbox', '+', ['board4'])
+ self.assertEqual(next(lines).text, '05: %s' % commits[4][1])
+ if filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'powerpc', '', ['board3'],
+ outcome=OUTCOME_OK)
+ self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
# The second line of errors[3] is a duplicate, so buildman will drop it
expect = errors[3].rstrip().split('\n')
expect = [expect[0]] + expect[2:]
- self.assertEqual(lines[19].text, '+%s' %
- '\n'.join(expect).replace('\n', '\n+'))
+ expect = '\n'.join(expect)
+ self.assertEqual(next(lines).text,
+ add_line_prefix('+', boards4, expect, col.RED))
- self.assertEqual(lines[20].text, 'w-%s' %
- errors[2].rstrip().replace('\n', '\nw-'))
+ if not filter_dtb_warnings:
+ self.assertEqual(
+ next(lines).text,
+ add_line_prefix('w-', boards34, errors[2], col.CYAN))
# Sixth commit
- self.assertEqual(lines[21].text, '06: %s' % commits[5][1])
- self.assertSummary(lines[22].text, 'sandbox', '', ['board4'],
- outcome=OUTCOME_OK)
+ self.assertEqual(next(lines).text, '06: %s' % commits[5][1])
+ if filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'sandbox', '', ['board4'],
+ outcome=OUTCOME_OK)
+ else:
+ self.assertSummary(next(lines).text, 'sandbox', 'w+', ['board4'],
+ outcome=OUTCOME_WARN)
# The second line of errors[3] is a duplicate, so buildman will drop it
expect = errors[3].rstrip().split('\n')
expect = [expect[0]] + expect[2:]
- self.assertEqual(lines[23].text, '-%s' %
- '\n'.join(expect).replace('\n', '\n-'))
-
- self.assertEqual(lines[24].text, 'w-%s' %
- errors[0].rstrip().replace('\n', '\nw-'))
+ expect = '\n'.join(expect)
+ self.assertEqual(next(lines).text,
+ add_line_prefix('-', boards4, expect, col.GREEN))
+ self.assertEqual(next(lines).text,
+ add_line_prefix('w-', boards4, errors[0], col.CYAN))
# Seventh commit
- self.assertEqual(lines[25].text, '07: %s' % commits[6][1])
- self.assertSummary(lines[26].text, 'sandbox', '+', ['board4'])
+ self.assertEqual(next(lines).text, '07: %s' % commits[6][1])
+ if filter_migration_warnings:
+ self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
+ else:
+ self.assertSummary(next(lines).text, 'arm', '', ['board0', 'board1'],
+ outcome=OUTCOME_OK)
+ self.assertSummary(next(lines).text, 'powerpc', '',
+ ['board2', 'board3'], outcome=OUTCOME_OK)
+ self.assertSummary(next(lines).text, 'sandbox', '+', ['board4'])
# Pick out the correct error lines
expect_str = errors[4].rstrip().replace('%(basedir)s', '').split('\n')
expect = expect_str[3:8] + [expect_str[-1]]
- self.assertEqual(lines[27].text, '+%s' %
- '\n'.join(expect).replace('\n', '\n+'))
+ expect = '\n'.join(expect)
+ if not filter_migration_warnings:
+ self.assertEqual(
+ next(lines).text,
+ add_line_prefix('-', boards01234, migration, col.GREEN))
+
+ self.assertEqual(next(lines).text,
+ add_line_prefix('+', boards4, expect, col.RED))
# Now the warnings lines
expect = [expect_str[0]] + expect_str[10:12] + [expect_str[9]]
- self.assertEqual(lines[28].text, 'w+%s' %
- '\n'.join(expect).replace('\n', '\nw+'))
+ expect = '\n'.join(expect)
+ self.assertEqual(next(lines).text,
+ add_line_prefix('w+', boards4, expect, col.YELLOW))
- self.assertEqual(len(lines), 29)
- shutil.rmtree(base_dir)
+ def testOutput(self):
+ """Test basic builder operation and output
+
+ This does a line-by-line verification of the summary output.
+ """
+ lines = self._SetupTest(show_errors=True)
+ self._CheckOutput(lines, list_error_boards=False,
+ filter_dtb_warnings=False)
+
+ def testErrorBoards(self):
+ """Test output with --list-error-boards
+
+ This does a line-by-line verification of the summary output.
+ """
+ lines = self._SetupTest(show_errors=True, list_error_boards=True)
+ self._CheckOutput(lines, list_error_boards=True)
+
+ def testFilterDtb(self):
+ """Test output with --filter-dtb-warnings
+
+ This does a line-by-line verification of the summary output.
+ """
+ lines = self._SetupTest(show_errors=True, filter_dtb_warnings=True)
+ self._CheckOutput(lines, filter_dtb_warnings=True)
+
+ def testFilterMigration(self):
+ """Test output with --filter-migration-warnings
+
+ This does a line-by-line verification of the summary output.
+ """
+ lines = self._SetupTest(show_errors=True,
+ filter_migration_warnings=True)
+ self._CheckOutput(lines, filter_migration_warnings=True)
def _testGit(self):
"""Test basic builder operation by building a branch"""
- base_dir = tempfile.mkdtemp()
- if not os.path.isdir(base_dir):
- os.mkdir(base_dir)
options = Options()
options.git = os.getcwd()
options.summary = False
options.jobs = None
options.dry_run = False
- #options.git = os.path.join(base_dir, 'repo')
+ #options.git = os.path.join(self.base_dir, 'repo')
options.branch = 'test-buildman'
options.force_build = False
options.list_tool_chains = False
@@ -328,7 +462,6 @@ class TestBuild(unittest.TestCase):
options.keep_outputs = False
args = ['tegra20']
control.DoBuildman(options, args)
- shutil.rmtree(base_dir)
def testBoardSingle(self):
"""Test single board selection"""
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 037e82c8bb..90a9e1a626 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -423,7 +423,7 @@ class DtbPlatdata(object):
This writes out the body of a header file consisting of structure
definitions for node in self._valid_nodes. See the documentation in
- README.of-plat for more information.
+ doc/driver-model/of-plat.rst for more information.
"""
self.out_header()
self.out('#include <stdbool.h>\n')
@@ -527,7 +527,7 @@ class DtbPlatdata(object):
U_BOOT_DEVICE() declarations for each valid node. Where a node has
multiple compatible strings, a #define is used to make them equivalent.
- See the documentation in doc/driver-model/of-plat.txt for more
+ See the documentation in doc/driver-model/of-plat.rst for more
information.
"""
self.out_header()
diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index b3596a5918..f31cba900e 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -22,7 +22,7 @@ Dtoc produces two output files:
This tool is used in U-Boot to provide device tree data to SPL without
increasing the code size of SPL. This supports the CONFIG_SPL_OF_PLATDATA
options. For more information about the use of this options and tool please
-see doc/driver-model/of-plat.txt
+see doc/driver-model/of-plat.rst
"""
from __future__ import print_function
diff --git a/tools/fit_image.c b/tools/fit_image.c
index dd61a816c9..4301b5decb 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -642,7 +642,7 @@ static int copyfile(const char *src, const char *dst)
goto out;
}
- fd_dst = open(dst, O_WRONLY | O_CREAT, 0700);
+ fd_dst = open(dst, O_WRONLY | O_CREAT, 0666);
if (fd_dst < 0) {
printf("Can't open file %s (%s)\n", dst, strerror(errno));
goto out;
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index cf53e532dd..7f4ac9aef4 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -93,7 +93,7 @@ elif options.test:
suite = unittest.TestLoader().loadTestsFromTestCase(module)
suite.run(result)
- for module in ['gitutil', 'settings']:
+ for module in ['gitutil', 'settings', 'terminal']:
suite = doctest.DocTestSuite(module)
suite.run(result)
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py
index 7a3b658b00..5c9e3eea20 100644
--- a/tools/patman/terminal.py
+++ b/tools/patman/terminal.py
@@ -10,6 +10,8 @@ This module handles terminal interaction including ANSI color codes.
from __future__ import print_function
import os
+import re
+import shutil
import sys
# Selection of when we want our output to be colored
@@ -19,6 +21,13 @@ COLOR_IF_TERMINAL, COLOR_ALWAYS, COLOR_NEVER = range(3)
print_test_mode = False
print_test_list = []
+# The length of the last line printed without a newline
+last_print_len = None
+
+# credit:
+# stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python
+ansi_escape = re.compile(r'\x1b(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
+
class PrintLine:
"""A line of text output
@@ -36,7 +45,86 @@ class PrintLine:
return 'newline=%s, colour=%s, text=%s' % (self.newline, self.colour,
self.text)
-def Print(text='', newline=True, colour=None):
+def CalcAsciiLen(text):
+ """Calculate the length of a string, ignoring any ANSI sequences
+
+ When displayed on a terminal, ANSI sequences don't take any space, so we
+ need to ignore them when calculating the length of a string.
+
+ Args:
+ text: Text to check
+
+ Returns:
+ Length of text, after skipping ANSI sequences
+
+ >>> col = Color(COLOR_ALWAYS)
+ >>> text = col.Color(Color.RED, 'abc')
+ >>> len(text)
+ 14
+ >>> CalcAsciiLen(text)
+ 3
+ >>>
+ >>> text += 'def'
+ >>> CalcAsciiLen(text)
+ 6
+ >>> text += col.Color(Color.RED, 'abc')
+ >>> CalcAsciiLen(text)
+ 9
+ """
+ result = ansi_escape.sub('', text)
+ return len(result)
+
+def TrimAsciiLen(text, size):
+ """Trim a string containing ANSI sequences to the given ASCII length
+
+ The string is trimmed with ANSI sequences being ignored for the length
+ calculation.
+
+ >>> col = Color(COLOR_ALWAYS)
+ >>> text = col.Color(Color.RED, 'abc')
+ >>> len(text)
+ 14
+ >>> CalcAsciiLen(TrimAsciiLen(text, 4))
+ 3
+ >>> CalcAsciiLen(TrimAsciiLen(text, 2))
+ 2
+ >>> text += 'def'
+ >>> CalcAsciiLen(TrimAsciiLen(text, 4))
+ 4
+ >>> text += col.Color(Color.RED, 'ghi')
+ >>> CalcAsciiLen(TrimAsciiLen(text, 7))
+ 7
+ """
+ if CalcAsciiLen(text) < size:
+ return text
+ pos = 0
+ out = ''
+ left = size
+
+ # Work through each ANSI sequence in turn
+ for m in ansi_escape.finditer(text):
+ # Find the text before the sequence and add it to our string, making
+ # sure it doesn't overflow
+ before = text[pos:m.start()]
+ toadd = before[:left]
+ out += toadd
+
+ # Figure out how much non-ANSI space we have left
+ left -= len(toadd)
+
+ # Add the ANSI sequence and move to the position immediately after it
+ out += m.group()
+ pos = m.start() + len(m.group())
+
+ # Deal with text after the last ANSI sequence
+ after = text[pos:]
+ toadd = after[:left]
+ out += toadd
+
+ return out
+
+
+def Print(text='', newline=True, colour=None, limit_to_line=False):
"""Handle a line of output to the terminal.
In test mode this is recorded in a list. Otherwise it is output to the
@@ -47,17 +135,31 @@ def Print(text='', newline=True, colour=None):
newline: True to add a new line at the end of the text
colour: Colour to use for the text
"""
+ global last_print_len
+
if print_test_mode:
print_test_list.append(PrintLine(text, newline, colour))
else:
if colour:
col = Color()
text = col.Color(colour, text)
- print(text, end='')
if newline:
- print()
+ print(text)
+ last_print_len = None
else:
- sys.stdout.flush()
+ if limit_to_line:
+ cols = shutil.get_terminal_size().columns
+ text = TrimAsciiLen(text, cols)
+ print(text, end='', flush=True)
+ last_print_len = CalcAsciiLen(text)
+
+def PrintClear():
+ """Clear a previously line that was printed with no newline"""
+ global last_print_len
+
+ if last_print_len:
+ print('\r%s\r' % (' '* last_print_len), end='', flush=True)
+ last_print_len = None
def SetPrintTestMode():
"""Go into test mode, where all printing is recorded"""