aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini2019-08-07 23:13:35 -0400
committerTom Rini2019-08-07 23:13:35 -0400
commitdb857dcbbfe993c21781524e44404f9800db87c7 (patch)
tree6f94410d22fa9bffc0c44feb11241ef8e012edfd
parent7127151d538d878bd073ca6d6cca630a4b35b76f (diff)
parent0b6febfdb3cf9b4a51fa65fbd94f9ab2d7738f32 (diff)
Merge branch '2019-08-07-master-imports'
- Misc Android / AVB bugfixes (including updating the header from Android). - MediaTek updates - Other assorted bugfixes.
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/dts/mt7623.dtsi7
-rw-r--r--arch/arm/dts/mt7629-rfb.dts18
-rw-r--r--arch/arm/dts/mt7629.dtsi14
-rw-r--r--cmd/avb.c4
-rw-r--r--common/autoboot.c15
-rw-r--r--common/avb_verify.c3
-rw-r--r--common/console.c47
-rw-r--r--common/image-android-dt.c11
-rw-r--r--common/image-fit.c13
-rw-r--r--drivers/clk/mediatek/clk-mt7623.c68
-rw-r--r--drivers/clk/mediatek/clk-mt7629.c4
-rw-r--r--drivers/clk/mediatek/clk-mtk.h2
-rw-r--r--drivers/pci_endpoint/pci_ep-uclass.c2
-rw-r--r--include/android_image.h120
-rw-r--r--include/dt-bindings/reset/mtk-reset.h9
-rw-r--r--include/log.h12
-rwxr-xr-xtest/py/tests/test_fit.py10
18 files changed, 274 insertions, 86 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 182c9c7fc20..b443c5af75f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -196,6 +196,7 @@ F: arch/arm/include/asm/arch-pxa/
ARM MEDIATEK
M: Ryder Lee <ryder.lee@mediatek.com>
M: Weijie Gao <weijie.gao@mediatek.com>
+R: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>
S: Maintained
F: arch/arm/mach-mediatek/
F: arch/arm/include/asm/arch-mediatek/
diff --git a/arch/arm/dts/mt7623.dtsi b/arch/arm/dts/mt7623.dtsi
index 448d1d73810..64079c61bfb 100644
--- a/arch/arm/dts/mt7623.dtsi
+++ b/arch/arm/dts/mt7623.dtsi
@@ -248,6 +248,13 @@
status = "disabled";
};
+ hifsys: syscon@1a000000 {
+ compatible = "mediatek,mt7623-hifsys", "syscon";
+ reg = <0x1a000000 0x1000>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
+
ethsys: syscon@1b000000 {
compatible = "mediatek,mt7623-ethsys", "syscon";
reg = <0x1b000000 0x1000>;
diff --git a/arch/arm/dts/mt7629-rfb.dts b/arch/arm/dts/mt7629-rfb.dts
index 08c3b592223..0981f9b3b1e 100644
--- a/arch/arm/dts/mt7629-rfb.dts
+++ b/arch/arm/dts/mt7629-rfb.dts
@@ -13,7 +13,7 @@
compatible = "mediatek,mt7629-rfb", "mediatek,mt7629";
aliases {
- spi0 = &qspi;
+ spi0 = &snfi;
};
chosen {
@@ -33,7 +33,14 @@
};
&pinctrl {
- qspi_pins: qspi-pins {
+ snfi_pins: snfi-pins {
+ mux {
+ function = "flash";
+ groups = "snfi";
+ };
+ };
+
+ snor_pins: snor-pins {
mux {
function = "flash";
groups = "spi_nor";
@@ -55,9 +62,10 @@
};
};
-&qspi {
- pinctrl-names = "default";
- pinctrl-0 = <&qspi_pins>;
+&snfi {
+ pinctrl-names = "default", "snfi";
+ pinctrl-0 = <&snor_pins>;
+ pinctrl-1 = <&snfi_pins>;
status = "okay";
spi-flash@0{
diff --git a/arch/arm/dts/mt7629.dtsi b/arch/arm/dts/mt7629.dtsi
index ecbd29d7ae4..8ff19162f06 100644
--- a/arch/arm/dts/mt7629.dtsi
+++ b/arch/arm/dts/mt7629.dtsi
@@ -215,10 +215,16 @@
status = "disabled";
};
- qspi: qspi@11014000 {
- compatible = "mediatek,mt7629-qspi";
- reg = <0x11014000 0xe0>, <0x30000000 0x10000000>;
- reg-names = "reg_base", "mem_base";
+ snfi: snfi@1100d000 {
+ compatible = "mediatek,mtk-snfi-spi";
+ reg = <0x1100d000 0x2000>;
+ clocks = <&pericfg CLK_PERI_NFI_PD>,
+ <&pericfg CLK_PERI_SNFI_PD>;
+ clock-names = "nfi_clk", "pad_clk";
+ assigned-clocks = <&topckgen CLK_TOP_AXI_SEL>,
+ <&topckgen CLK_TOP_NFI_INFRA_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_SYSPLL1_D2>,
+ <&topckgen CLK_TOP_UNIVPLL2_D8>;
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
diff --git a/cmd/avb.c b/cmd/avb.c
index c5af4a2e461..3f6fd763a0b 100644
--- a/cmd/avb.c
+++ b/cmd/avb.c
@@ -368,7 +368,7 @@ int do_avb_read_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
if (avb_ops->read_persistent_value(avb_ops, name, bytes, buffer,
&bytes_read) == AVB_IO_RESULT_OK) {
- printf("Read %ld bytes, value = %s\n", bytes_read,
+ printf("Read %zu bytes, value = %s\n", bytes_read,
(char *)buffer);
free(buffer);
return CMD_RET_SUCCESS;
@@ -401,7 +401,7 @@ int do_avb_write_pvalue(cmd_tbl_t *cmdtp, int flag, int argc,
if (avb_ops->write_persistent_value(avb_ops, name, strlen(value) + 1,
(const uint8_t *)value) ==
AVB_IO_RESULT_OK) {
- printf("Wrote %ld bytes\n", strlen(value) + 1);
+ printf("Wrote %zu bytes\n", strlen(value) + 1);
return CMD_RET_SUCCESS;
}
diff --git a/common/autoboot.c b/common/autoboot.c
index 42fbd7614a8..7a91736a00f 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -11,6 +11,7 @@
#include <console.h>
#include <fdtdec.h>
#include <hash.h>
+#include <memalign.h>
#include <menu.h>
#include <post.h>
#include <u-boot/sha256.h>
@@ -71,8 +72,8 @@ static int passwd_abort_sha256(uint64_t etime)
{
const char *sha_env_str = env_get("bootstopkeysha256");
u8 sha_env[SHA256_SUM_LEN];
- u8 sha[SHA256_SUM_LEN];
- char presskey[MAX_DELAY_STOP_STR];
+ u8 *sha;
+ char *presskey;
const char *algo_name = "sha256";
u_int presskey_len = 0;
int abort = 0;
@@ -93,6 +94,9 @@ static int passwd_abort_sha256(uint64_t etime)
return 0;
}
+ presskey = malloc_cache_aligned(MAX_DELAY_STOP_STR);
+ sha = malloc_cache_aligned(SHA256_SUM_LEN);
+ size = SHA256_SUM_LEN;
/*
* We don't know how long the stop-string is, so we need to
* generate the sha256 hash upon each input character and
@@ -101,8 +105,11 @@ static int passwd_abort_sha256(uint64_t etime)
do {
if (tstc()) {
/* Check for input string overflow */
- if (presskey_len >= MAX_DELAY_STOP_STR)
+ if (presskey_len >= MAX_DELAY_STOP_STR) {
+ free(presskey);
+ free(sha);
return 0;
+ }
presskey[presskey_len++] = getc();
@@ -116,6 +123,8 @@ static int passwd_abort_sha256(uint64_t etime)
}
} while (!abort && get_ticks() <= etime);
+ free(presskey);
+ free(sha);
return abort;
}
diff --git a/common/avb_verify.c b/common/avb_verify.c
index 32034d927cf..36898a610f8 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -851,6 +851,7 @@ static AvbIOResult get_size_of_partition(AvbOps *ops,
return AVB_IO_RESULT_OK;
}
+#ifdef CONFIG_OPTEE_TA_AVB
static AvbIOResult read_persistent_value(AvbOps *ops,
const char *name,
size_t buffer_size,
@@ -968,6 +969,8 @@ free_name:
return rc;
}
+#endif
+
/**
* ============================================================================
* AVB2.0 AvbOps alloc/initialisation/free
diff --git a/common/console.c b/common/console.c
index 0b0dd76256c..d086feabb11 100644
--- a/common/console.c
+++ b/common/console.c
@@ -463,6 +463,11 @@ static void print_pre_console_buffer(int flushpoint)
char buf_out[CONFIG_PRE_CON_BUF_SZ + 1];
char *buf_in;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (gd->flags & GD_FLG_SILENT)
+ return;
+#endif
+
buf_in = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ);
if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ)
in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ;
@@ -511,8 +516,11 @@ void putc(const char c)
membuff_putbyte(&gd->console_out, c);
#endif
#ifdef CONFIG_SILENT_CONSOLE
- if (gd->flags & GD_FLG_SILENT)
+ if (gd->flags & GD_FLG_SILENT) {
+ if (!(gd->flags & GD_FLG_DEVINIT))
+ pre_console_putc(c);
return;
+ }
#endif
#ifdef CONFIG_DISABLE_CONSOLE
@@ -559,8 +567,11 @@ void puts(const char *s)
membuff_put(&gd->console_out, s, strlen(s));
#endif
#ifdef CONFIG_SILENT_CONSOLE
- if (gd->flags & GD_FLG_SILENT)
+ if (gd->flags & GD_FLG_SILENT) {
+ if (!(gd->flags & GD_FLG_DEVINIT))
+ pre_console_puts(s);
return;
+ }
#endif
#ifdef CONFIG_DISABLE_CONSOLE
@@ -720,14 +731,22 @@ int console_assign(int file, const char *devname)
return -1;
}
-static void console_update_silent(void)
+/* return true if the 'silent' flag is removed */
+static bool console_update_silent(void)
{
#ifdef CONFIG_SILENT_CONSOLE
- if (env_get("silent") != NULL)
+ if (env_get("silent")) {
gd->flags |= GD_FLG_SILENT;
- else
+ } else {
+ unsigned long flags = gd->flags;
+
gd->flags &= ~GD_FLG_SILENT;
+
+ return !!(flags & GD_FLG_SILENT);
+ }
#endif
+
+ return false;
}
int console_announce_r(void)
@@ -792,6 +811,13 @@ int console_init_r(void)
#if CONFIG_IS_ENABLED(CONSOLE_MUX)
int iomux_err = 0;
#endif
+ int flushpoint;
+
+ /* update silent for env loaded from flash (initr_env) */
+ if (console_update_silent())
+ flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL;
+ else
+ flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL;
/* set default handlers at first */
gd->jt->getc = serial_getc;
@@ -869,7 +895,7 @@ done:
if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
return 0;
#endif
- print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL);
+ print_pre_console_buffer(flushpoint);
return 0;
}
@@ -883,8 +909,13 @@ int console_init_r(void)
struct list_head *list = stdio_get_list();
struct list_head *pos;
struct stdio_dev *dev;
+ int flushpoint;
- console_update_silent();
+ /* update silent for env loaded from flash (initr_env) */
+ if (console_update_silent())
+ flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL;
+ else
+ flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL;
#ifdef CONFIG_SPLASH_SCREEN
/*
@@ -947,7 +978,7 @@ int console_init_r(void)
if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL))
return 0;
#endif
- print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL);
+ print_pre_console_buffer(flushpoint);
return 0;
}
diff --git a/common/image-android-dt.c b/common/image-android-dt.c
index 69168261793..a2d52df4a2a 100644
--- a/common/image-android-dt.c
+++ b/common/image-android-dt.c
@@ -78,17 +78,18 @@ static void android_dt_print_fdt_info(const struct fdt_header *fdt)
{
u32 fdt_size;
int root_node_off;
- const char *compatible = NULL;
+ const char *compatible;
- fdt_size = fdt_totalsize(fdt);
root_node_off = fdt_path_offset(fdt, "/");
if (root_node_off < 0) {
printf("Error: Root node not found\n");
- } else {
- compatible = fdt_getprop(fdt, root_node_off, "compatible",
- NULL);
+ return;
}
+ fdt_size = fdt_totalsize(fdt);
+ compatible = fdt_getprop(fdt, root_node_off, "compatible",
+ NULL);
+
printf(" (FDT)size = %d\n", fdt_size);
printf(" (FDT)compatible = %s\n",
compatible ? compatible : "(unknown)");
diff --git a/common/image-fit.c b/common/image-fit.c
index e346fed550e..5c63c769de2 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1998,10 +1998,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
comp = IH_COMP_NONE;
loadbuf = buf;
/* Kernel images get decompressed later in bootm_load_os(). */
- if (!(image_type == IH_TYPE_KERNEL ||
- image_type == IH_TYPE_KERNEL_NOLOAD) &&
- !fit_image_get_comp(fit, noffset, &comp) &&
- comp != IH_COMP_NONE) {
+ if (!fit_image_get_comp(fit, noffset, &comp) &&
+ comp != IH_COMP_NONE &&
+ !(image_type == IH_TYPE_KERNEL ||
+ image_type == IH_TYPE_KERNEL_NOLOAD ||
+ image_type == IH_TYPE_RAMDISK)) {
ulong max_decomp_len = len * 20;
if (load == data) {
loadbuf = malloc(max_decomp_len);
@@ -2021,6 +2022,10 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
memcpy(loadbuf, buf, len);
}
+ if (image_type == IH_TYPE_RAMDISK && comp != IH_COMP_NONE)
+ puts("WARNING: 'compression' nodes for ramdisks are deprecated,"
+ " please fix your .its file!\n");
+
/* verify that image data is a proper FDT blob */
if (image_type == IH_TYPE_FLATDT && fdt_check_header(loadbuf)) {
puts("Subimage data is not a FDT");
diff --git a/drivers/clk/mediatek/clk-mt7623.c b/drivers/clk/mediatek/clk-mt7623.c
index 87ad4f79ced..dfce32e2836 100644
--- a/drivers/clk/mediatek/clk-mt7623.c
+++ b/drivers/clk/mediatek/clk-mt7623.c
@@ -691,34 +691,42 @@ static const struct mtk_gate peri_cgs[] = {
GATE_PERI1(CLK_PERI_FCI, CLK_TOP_MS_CARD_SEL, 11),
};
-/* ethsys */
-static const struct mtk_gate_regs eth_cg_regs = {
+/* ethsys and hifsys */
+static const struct mtk_gate_regs eth_hif_cg_regs = {
.sta_ofs = 0x30,
};
-#define GATE_ETH(_id, _parent, _shift, _flag) { \
+#define GATE_ETH_HIF(_id, _parent, _shift, _flag) { \
.id = _id, \
.parent = _parent, \
- .regs = &eth_cg_regs, \
+ .regs = &eth_hif_cg_regs, \
.shift = _shift, \
.flags = CLK_GATE_NO_SETCLR_INV | (_flag), \
}
-#define GATE_ETH0(_id, _parent, _shift) \
- GATE_ETH(_id, _parent, _shift, CLK_PARENT_APMIXED)
+#define GATE_ETH_HIF0(_id, _parent, _shift) \
+ GATE_ETH_HIF(_id, _parent, _shift, CLK_PARENT_APMIXED)
-#define GATE_ETH1(_id, _parent, _shift) \
- GATE_ETH(_id, _parent, _shift, CLK_PARENT_TOPCKGEN)
+#define GATE_ETH_HIF1(_id, _parent, _shift) \
+ GATE_ETH_HIF(_id, _parent, _shift, CLK_PARENT_TOPCKGEN)
static const struct mtk_gate eth_cgs[] = {
- GATE_ETH1(CLK_ETHSYS_HSDMA, CLK_TOP_ETHIF_SEL, 5),
- GATE_ETH1(CLK_ETHSYS_ESW, CLK_TOP_ETHPLL_500M, 6),
- GATE_ETH0(CLK_ETHSYS_GP2, CLK_APMIXED_TRGPLL, 7),
- GATE_ETH1(CLK_ETHSYS_GP1, CLK_TOP_ETHPLL_500M, 8),
- GATE_ETH1(CLK_ETHSYS_PCM, CLK_TOP_ETHIF_SEL, 11),
- GATE_ETH1(CLK_ETHSYS_GDMA, CLK_TOP_ETHIF_SEL, 14),
- GATE_ETH1(CLK_ETHSYS_I2S, CLK_TOP_ETHIF_SEL, 17),
- GATE_ETH1(CLK_ETHSYS_CRYPTO, CLK_TOP_ETHIF_SEL, 29),
+ GATE_ETH_HIF1(CLK_ETHSYS_HSDMA, CLK_TOP_ETHIF_SEL, 5),
+ GATE_ETH_HIF1(CLK_ETHSYS_ESW, CLK_TOP_ETHPLL_500M, 6),
+ GATE_ETH_HIF0(CLK_ETHSYS_GP2, CLK_APMIXED_TRGPLL, 7),
+ GATE_ETH_HIF1(CLK_ETHSYS_GP1, CLK_TOP_ETHPLL_500M, 8),
+ GATE_ETH_HIF1(CLK_ETHSYS_PCM, CLK_TOP_ETHIF_SEL, 11),
+ GATE_ETH_HIF1(CLK_ETHSYS_GDMA, CLK_TOP_ETHIF_SEL, 14),
+ GATE_ETH_HIF1(CLK_ETHSYS_I2S, CLK_TOP_ETHIF_SEL, 17),
+ GATE_ETH_HIF1(CLK_ETHSYS_CRYPTO, CLK_TOP_ETHIF_SEL, 29),
+};
+
+static const struct mtk_gate hif_cgs[] = {
+ GATE_ETH_HIF1(CLK_HIFSYS_USB0PHY, CLK_TOP_ETHPLL_500M, 21),
+ GATE_ETH_HIF1(CLK_HIFSYS_USB1PHY, CLK_TOP_ETHPLL_500M, 22),
+ GATE_ETH_HIF1(CLK_HIFSYS_PCIE0, CLK_TOP_ETHPLL_500M, 24),
+ GATE_ETH_HIF1(CLK_HIFSYS_PCIE1, CLK_TOP_ETHPLL_500M, 25),
+ GATE_ETH_HIF1(CLK_HIFSYS_PCIE2, CLK_TOP_ETHPLL_500M, 26),
};
static const struct mtk_clk_tree mt7623_clk_tree = {
@@ -778,19 +786,24 @@ static int mt7623_pericfg_probe(struct udevice *dev)
return mtk_common_clk_gate_init(dev, &mt7623_clk_tree, peri_cgs);
}
+static int mt7623_hifsys_probe(struct udevice *dev)
+{
+ return mtk_common_clk_gate_init(dev, &mt7623_clk_tree, hif_cgs);
+}
+
static int mt7623_ethsys_probe(struct udevice *dev)
{
return mtk_common_clk_gate_init(dev, &mt7623_clk_tree, eth_cgs);
}
-static int mt7623_ethsys_bind(struct udevice *dev)
+static int mt7623_ethsys_hifsys_bind(struct udevice *dev)
{
int ret = 0;
#if CONFIG_IS_ENABLED(RESET_MEDIATEK)
- ret = mediatek_reset_bind(dev, ETHSYS_RST_CTRL_OFS, 1);
+ ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
if (ret)
- debug("Warning: failed to bind ethsys reset controller\n");
+ debug("Warning: failed to bind reset controller\n");
#endif
return ret;
@@ -821,6 +834,11 @@ static const struct udevice_id mt7623_ethsys_compat[] = {
{ }
};
+static const struct udevice_id mt7623_hifsys_compat[] = {
+ { .compatible = "mediatek,mt7623-hifsys" },
+ { }
+};
+
static const struct udevice_id mt7623_mcucfg_compat[] = {
{ .compatible = "mediatek,mt7623-mcucfg" },
{ }
@@ -874,12 +892,22 @@ U_BOOT_DRIVER(mtk_clk_pericfg) = {
.flags = DM_FLAG_PRE_RELOC,
};
+U_BOOT_DRIVER(mtk_clk_hifsys) = {
+ .name = "mt7623-clock-hifsys",
+ .id = UCLASS_CLK,
+ .of_match = mt7623_hifsys_compat,
+ .probe = mt7623_hifsys_probe,
+ .bind = mt7623_ethsys_hifsys_bind,
+ .priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
+ .ops = &mtk_clk_gate_ops,
+};
+
U_BOOT_DRIVER(mtk_clk_ethsys) = {
.name = "mt7623-clock-ethsys",
.id = UCLASS_CLK,
.of_match = mt7623_ethsys_compat,
.probe = mt7623_ethsys_probe,
- .bind = mt7623_ethsys_bind,
+ .bind = mt7623_ethsys_hifsys_bind,
.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
.ops = &mtk_clk_gate_ops,
};
diff --git a/drivers/clk/mediatek/clk-mt7629.c b/drivers/clk/mediatek/clk-mt7629.c
index 6a9f60139c0..30a919f224b 100644
--- a/drivers/clk/mediatek/clk-mt7629.c
+++ b/drivers/clk/mediatek/clk-mt7629.c
@@ -608,9 +608,9 @@ static int mt7629_ethsys_bind(struct udevice *dev)
int ret = 0;
#if CONFIG_IS_ENABLED(RESET_MEDIATEK)
- ret = mediatek_reset_bind(dev, ETHSYS_RST_CTRL_OFS, 1);
+ ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
if (ret)
- debug("Warning: failed to bind ethsys reset controller\n");
+ debug("Warning: failed to bind reset controller\n");
#endif
return ret;
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 7847388b2a1..dce93253ad0 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -23,7 +23,7 @@
#define CLK_PARENT_TOPCKGEN BIT(5)
#define CLK_PARENT_MASK GENMASK(5, 4)
-#define ETHSYS_RST_CTRL_OFS 0x34
+#define ETHSYS_HIFSYS_RST_CTRL_OFS 0x34
/* struct mtk_pll_data - hardware-specific PLLs data */
struct mtk_pll_data {
diff --git a/drivers/pci_endpoint/pci_ep-uclass.c b/drivers/pci_endpoint/pci_ep-uclass.c
index 2f9c70398d7..9f53a9a9b97 100644
--- a/drivers/pci_endpoint/pci_ep-uclass.c
+++ b/drivers/pci_endpoint/pci_ep-uclass.c
@@ -43,7 +43,7 @@ int pci_ep_set_bar(struct udevice *dev, uint func_no, struct pci_bar *ep_bar)
int flags = ep_bar->flags;
/* Some basic bar validity checks */
- if (ep_bar->barno > BAR_5 || ep_bar < BAR_0)
+ if (ep_bar->barno > BAR_5 || ep_bar->barno < BAR_0)
return -EINVAL;
if ((ep_bar->barno == BAR_5 &&
diff --git a/include/android_image.h b/include/android_image.h
index d78db9e2b7a..0519ece368d 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -1,59 +1,78 @@
-/* SPDX-License-Identifier: BSD-2-Clause */
+/* SPDX-License-Identifier: BSD-3-Clause */
/*
* This is from the Android Project,
- * Repository: https://android.googlesource.com/platform/system/core/
- * File: mkbootimg/bootimg.h
- * Commit: d162828814b08ada310846a33205befb69ef5799
+ * Repository: https://android.googlesource.com/platform/system/tools/mkbootimg
+ * File: include/bootimg/bootimg.h
+ * Commit: e55998a0f2b61b685d5eb4a486ca3a0c680b1a2f
*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2007 The Android Open Source Project
*/
#ifndef _ANDROID_IMAGE_H_
#define _ANDROID_IMAGE_H_
-typedef struct andr_img_hdr andr_img_hdr;
-
#define ANDR_BOOT_MAGIC "ANDROID!"
#define ANDR_BOOT_MAGIC_SIZE 8
#define ANDR_BOOT_NAME_SIZE 16
#define ANDR_BOOT_ARGS_SIZE 512
#define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
+/*
+ * It is expected that callers would explicitly specify which version of the
+ * boot image header they need to use.
+ */
+typedef struct andr_img_hdr andr_img_hdr;
+
+/* The bootloader expects the structure of andr_img_hdr with header
+ * version 0 to be as follows: */
struct andr_img_hdr {
- char magic[ANDR_BOOT_MAGIC_SIZE];
+ /* Must be ANDR_BOOT_MAGIC. */
+ char magic[ANDR_BOOT_MAGIC_SIZE];
- u32 kernel_size; /* size in bytes */
- u32 kernel_addr; /* physical load addr */
+ u32 kernel_size; /* size in bytes */
+ u32 kernel_addr; /* physical load addr */
- u32 ramdisk_size; /* size in bytes */
- u32 ramdisk_addr; /* physical load addr */
+ u32 ramdisk_size; /* size in bytes */
+ u32 ramdisk_addr; /* physical load addr */
- u32 second_size; /* size in bytes */
- u32 second_addr; /* physical load addr */
+ u32 second_size; /* size in bytes */
+ u32 second_addr; /* physical load addr */
- u32 tags_addr; /* physical addr for kernel tags */
- u32 page_size; /* flash page size we assume */
- u32 unused; /* reserved for future expansion: MUST be 0 */
+ u32 tags_addr; /* physical addr for kernel tags */
+ u32 page_size; /* flash page size we assume */
- /* operating system version and security patch level; for
- * version "A.B.C" and patch level "Y-M-D":
- * ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
- * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M)
- * os_version = ver << 11 | lvl */
- u32 os_version;
+ /* Version of the boot image header. */
+ u32 header_version;
- char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
+ /* Operating system version and security patch level.
+ * For version "A.B.C" and patch level "Y-M-D":
+ * (7 bits for each of A, B, C; 7 bits for (Y-2000), 4 bits for M)
+ * os_version = A[31:25] B[24:18] C[17:11] (Y-2000)[10:4] M[3:0] */
+ u32 os_version;
- char cmdline[ANDR_BOOT_ARGS_SIZE];
+ char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
- u32 id[8]; /* timestamp / checksum / sha1 / etc */
+ char cmdline[ANDR_BOOT_ARGS_SIZE];
- /* Supplemental command line data; kept here to maintain
- * binary compatibility with older versions of mkbootimg */
- char extra_cmdline[ANDR_BOOT_EXTRA_ARGS_SIZE];
+ u32 id[8]; /* timestamp / checksum / sha1 / etc */
+
+ /* Supplemental command line data; kept here to maintain
+ * binary compatibility with older versions of mkbootimg. */
+ char extra_cmdline[ANDR_BOOT_EXTRA_ARGS_SIZE];
+
+ /* Fields in boot_img_hdr_v1 and newer. */
+ u32 recovery_dtbo_size; /* size in bytes for recovery DTBO/ACPIO image */
+ u64 recovery_dtbo_offset; /* offset to recovery dtbo/acpio in boot image */
+ u32 header_size;
+
+ /* Fields in boot_img_hdr_v2 and newer. */
+ u32 dtb_size; /* size in bytes for DTB image */
+ u64 dtb_addr; /* physical load address for DTB image */
} __attribute__((packed));
-/*
+/* When a boot header is of version 0, the structure of boot image is as
+ * follows:
+ *
* +-----------------+
* | boot header | 1 page
* +-----------------+
@@ -79,4 +98,45 @@ struct andr_img_hdr {
* 6. if second_size != 0: jump to second_addr
* else: jump to kernel_addr
*/
+
+/* When the boot image header has a version of 2, the structure of the boot
+ * image is as follows:
+ *
+ * +---------------------+
+ * | boot header | 1 page
+ * +---------------------+
+ * | kernel | n pages
+ * +---------------------+
+ * | ramdisk | m pages
+ * +---------------------+
+ * | second stage | o pages
+ * +---------------------+
+ * | recovery dtbo/acpio | p pages
+ * +---------------------+
+ * | dtb | q pages
+ * +---------------------+
+
+ * n = (kernel_size + page_size - 1) / page_size
+ * m = (ramdisk_size + page_size - 1) / page_size
+ * o = (second_size + page_size - 1) / page_size
+ * p = (recovery_dtbo_size + page_size - 1) / page_size
+ * q = (dtb_size + page_size - 1) / page_size
+ *
+ * 0. all entities are page_size aligned in flash
+ * 1. kernel, ramdisk and DTB are required (size != 0)
+ * 2. recovery_dtbo/recovery_acpio is required for recovery.img in non-A/B
+ * devices(recovery_dtbo_size != 0)
+ * 3. second is optional (second_size == 0 -> no second)
+ * 4. load each element (kernel, ramdisk, second, dtb) at
+ * the specified physical address (kernel_addr, etc)
+ * 5. If booting to recovery mode in a non-A/B device, extract recovery
+ * dtbo/acpio and apply the correct set of overlays on the base device tree
+ * depending on the hardware/product revision.
+ * 6. prepare tags at tag_addr. kernel_args[] is
+ * appended to the kernel commandline in the tags.
+ * 7. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
+ * 8. if second_size != 0: jump to second_addr
+ * else: jump to kernel_addr
+ */
+
#endif
diff --git a/include/dt-bindings/reset/mtk-reset.h b/include/dt-bindings/reset/mtk-reset.h
index 5f0a74f280c..78fcdab009d 100644
--- a/include/dt-bindings/reset/mtk-reset.h
+++ b/include/dt-bindings/reset/mtk-reset.h
@@ -15,4 +15,13 @@
#define ETHSYS_MCM_RST 2
#define ETHSYS_SYS_RST 0
+/* HIFSYS resets */
+#define HIFSYS_PCIE2_RST 26
+#define HIFSYS_PCIE1_RST 25
+#define HIFSYS_PCIE0_RST 24
+#define HIFSYS_UPHY1_RST 22
+#define HIFSYS_UPHY0_RST 21
+#define HIFSYS_UHOST1_RST 4
+#define HIFSYS_UHOST0_RST 3
+
#endif /* _DT_BINDINGS_MTK_RESET_H_ */
diff --git a/include/log.h b/include/log.h
index 7566ba7f2db..6d15e955d7e 100644
--- a/include/log.h
+++ b/include/log.h
@@ -183,6 +183,18 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
*/
void __assert_fail(const char *assertion, const char *file, unsigned int line,
const char *function);
+
+/**
+ * assert() - assert expression is true
+ *
+ * If the expression x evaluates to false and _DEBUG evaluates to true, a panic
+ * message is written and the system stalls. The value of _DEBUG is set to true
+ * if DEBUG is defined before including common.h.
+ *
+ * The expression x is always executed irrespective of the value of _DEBUG.
+ *
+ * @x: expression to test
+ */
#define assert(x) \
({ if (!(x) && _DEBUG) \
__assert_fail(#x, __FILE__, __LINE__, __func__); })
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index 8009d2907b1..e3210ed43fa 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -269,6 +269,11 @@ def test_fit(u_boot_console):
def check_equal(expected_fname, actual_fname, failure_msg):
"""Check that a file matches its expected contents
+ This is always used on out-buffers whose size is decided by the test
+ script anyway, which in some cases may be larger than what we're
+ actually looking for. So it's safe to truncate it to the size of the
+ expected data.
+
Args:
expected_fname: Filename containing expected contents
actual_fname: Filename containing actual contents
@@ -276,6 +281,8 @@ def test_fit(u_boot_console):
"""
expected_data = read_file(expected_fname)
actual_data = read_file(actual_fname)
+ if len(expected_data) < len(actual_data):
+ actual_data = actual_data[:len(expected_data)]
assert expected_data == actual_data, failure_msg
def check_not_equal(expected_fname, actual_fname, failure_msg):
@@ -435,7 +442,8 @@ def test_fit(u_boot_console):
output = cons.run_command_list(cmd.splitlines())
check_equal(kernel, kernel_out, 'Kernel not loaded')
check_equal(control_dtb, fdt_out, 'FDT not loaded')
- check_equal(ramdisk, ramdisk_out, 'Ramdisk not loaded')
+ check_not_equal(ramdisk, ramdisk_out, 'Ramdisk got decompressed?')
+ check_equal(ramdisk + '.gz', ramdisk_out, 'Ramdist not loaded')
cons = u_boot_console