Re: [PATCH 1/1] doc: riscv: debug UART for MAIX

2020-08-12 Thread Heinrich Schuchardt
On 8/13/20 7:42 AM, Rick Chen wrote:
> Hi Heinrich
>
>> From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Heinrich 
>> Schuchardt
>> Sent: Thursday, July 30, 2020 1:24 AM
>> To: Sean Anderson
>> Cc: u-boot@lists.denx.de; Heinrich Schuchardt
>> Subject: [PATCH 1/1] doc: riscv: debug UART for MAIX
>>
>> Provide the required settings for the debug UART.
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>>  doc/board/sipeed/maix.rst | 10 ++
>>  1 file changed, 10 insertions(+)
>>
>
> Applying: doc: riscv: debug UART for MAIX
> error: patch failed: doc/board/sipeed/maix.rst:262
> error: doc/board/sipeed/maix.rst: patch does not apply
> Patch failed at 0001 doc: riscv: debug UART for MAIX
>
> Thanks,
> Rick
>


The problem is with the patch sequence. Please, apply

[v2,1/1] doc: riscv: Update documentation for Sipeed MAIX boards
https://patchwork.ozlabs.org/project/uboot/patch/20200728180530.135264-1-xypron.g...@gmx.de/

first.

Best regards

Heinrich


[PATCH v4 9/9] asm-generic/u-boot.h: Remove bi_memstart & bi_memsize from bd_info

2020-08-12 Thread Stefan Roese
bi_memstart & bi_memsize are now not referenced any more. This patch
removes their definitions from the bd_info struct.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 include/asm-generic/u-boot.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h
index 99d3fe33ad..637de0c455 100644
--- a/include/asm-generic/u-boot.h
+++ b/include/asm-generic/u-boot.h
@@ -27,8 +27,6 @@
 #include 
 
 struct bd_info {
-   unsigned long   bi_memstart;/* start of DRAM memory */
-   phys_size_t bi_memsize; /* size  of DRAM memory in bytes */
unsigned long   bi_flashstart;  /* start of FLASH memory */
unsigned long   bi_flashsize;   /* size  of FLASH memory */
unsigned long   bi_flashoffset; /* reserved area for startup monitor */
-- 
2.28.0



[PATCH v4 3/9] board_f: Add default values for bi_dram[] in dram_init_banksize()

2020-08-12 Thread Stefan Roese
Remove the bi_memstart / bi_memsize assignment in setup_bdinfo() and
make sure, that bd_dram[] is always configured in the weak default
implementation of dram_init_banksize(), when CONFIG_SYS_SDRAM_BASE is
not set.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 common/board_f.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index dd9a5220e1..bfbeda29b2 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -240,6 +240,9 @@ __weak int dram_init_banksize(void)
 #if defined(CONFIG_SYS_SDRAM_BASE)
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
gd->bd->bi_dram[0].size = get_effective_memsize();
+#else
+   gd->bd->bi_dram[0].start = gd->ram_base;
+   gd->bd->bi_dram[0].size = gd->ram_size;
 #endif
 
return 0;
@@ -602,9 +605,6 @@ int setup_bdinfo(void)
 {
struct bd_info *bd = gd->bd;
 
-   bd->bi_memstart = gd->ram_base;  /* start of memory */
-   bd->bi_memsize = gd->ram_size;   /* size in bytes */
-
if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;  /* size  of SRAM */
-- 
2.28.0



[PATCH v4 7/9] powerpc: Remove bi_memstart & bi_memsize assignments in spl.c

2020-08-12 Thread Stefan Roese
Most likely these deprecated (removed) variables are not needed. Lets
remove the assignments completely from all spl.c files.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 board/Arcturus/ucp1020/spl.c   | 2 --
 board/freescale/p1010rdb/spl.c | 2 --
 board/freescale/p1_p2_rdb_pc/spl.c | 2 --
 board/freescale/t102xrdb/spl.c | 2 --
 board/freescale/t104xrdb/spl.c | 2 --
 board/freescale/t208xqds/spl.c | 2 --
 board/freescale/t208xrdb/spl.c | 2 --
 board/freescale/t4rdb/spl.c| 2 --
 8 files changed, 16 deletions(-)

diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c
index 5416a5b663..0fd9532d74 100644
--- a/board/Arcturus/ucp1020/spl.c
+++ b/board/Arcturus/ucp1020/spl.c
@@ -83,8 +83,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L2_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c
index 4ee4573d2b..fbaa6a6514 100644
--- a/board/freescale/p1010rdb/spl.c
+++ b/board/freescale/p1010rdb/spl.c
@@ -69,8 +69,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L2_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c 
b/board/freescale/p1_p2_rdb_pc/spl.c
index e76c3e82c3..8aceceb56a 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -75,8 +75,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L2_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c
index da442fcc18..09dd88ac4e 100644
--- a/board/freescale/t102xrdb/spl.c
+++ b/board/freescale/t102xrdb/spl.c
@@ -103,8 +103,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(gd + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L3_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c
index f83d69ba15..e7922954de 100644
--- a/board/freescale/t104xrdb/spl.c
+++ b/board/freescale/t104xrdb/spl.c
@@ -94,8 +94,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(gd + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L3_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c
index c197884421..d8c2bbe28d 100644
--- a/board/freescale/t208xqds/spl.c
+++ b/board/freescale/t208xqds/spl.c
@@ -102,8 +102,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(gd + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L3_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c
index 07aab6349c..c64bd87115 100644
--- a/board/freescale/t208xrdb/spl.c
+++ b/board/freescale/t208xrdb/spl.c
@@ -72,8 +72,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(gd + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L3_SIZE;
 
arch_cpu_init();
get_clocks();
diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c
index 64d2753da8..9aa0a9b052 100644
--- a/board/freescale/t4rdb/spl.c
+++ b/board/freescale/t4rdb/spl.c
@@ -75,8 +75,6 @@ void board_init_r(gd_t *gd, ulong dest_addr)
bd = (struct bd_info *)(gd + sizeof(gd_t));
memset(bd, 0, sizeof(struct bd_info));
gd->bd = bd;
-   bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
-   bd->bi_memsize = CONFIG_SYS_L3_SIZE;
 
arch_cpu_init();
get_clocks();
-- 
2.28.0



[PATCH v4 4/9] global: Move from bi_memstart/memsize -> gd->ram_base/ram_size

2020-08-12 Thread Stefan Roese
With the removal of bi_memstart & bi_memsize, this patch now moves the
references to the better suiting gd->ram_base/ram_size variables.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 api/api_platform-mips.c  | 3 +--
 api/api_platform-powerpc.c   | 2 +-
 arch/mips/lib/boot.c | 2 +-
 arch/mips/lib/bootm.c| 2 +-
 arch/powerpc/cpu/mpc83xx/fdt.c   | 2 +-
 arch/powerpc/cpu/mpc83xx/traps.c | 2 +-
 arch/powerpc/cpu/mpc85xx/fdt.c   | 4 ++--
 arch/powerpc/cpu/mpc85xx/traps.c | 2 +-
 arch/powerpc/cpu/mpc86xx/fdt.c   | 4 +++-
 arch/powerpc/cpu/mpc86xx/traps.c | 2 +-
 arch/powerpc/cpu/mpc8xx/fdt.c| 2 +-
 arch/powerpc/lib/bootm.c | 4 ++--
 arch/xtensa/lib/bootm.c  | 5 ++---
 cmd/bedbug.c | 2 +-
 14 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/api/api_platform-mips.c b/api/api_platform-mips.c
index 51cd328b3d..e1509663af 100644
--- a/api/api_platform-mips.c
+++ b/api/api_platform-mips.c
@@ -24,8 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;
 int platform_sys_info(struct sys_info *si)
 {
 
-   platform_set_mr(si, gd->bd->bi_memstart,
-   gd->bd->bi_memsize, MR_ATTR_DRAM);
+   platform_set_mr(si, gd->ram_base, gd->ram_size, MR_ATTR_DRAM);
 
return 1;
 }
diff --git a/api/api_platform-powerpc.c b/api/api_platform-powerpc.c
index 15930cfdb6..847a4a3015 100644
--- a/api/api_platform-powerpc.c
+++ b/api/api_platform-powerpc.c
@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si)
si->bar = 0;
 #endif
 
-   platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, 
MR_ATTR_DRAM);
+   platform_set_mr(si, gd->ram_base, gd->ram_size, MR_ATTR_DRAM);
platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, 
MR_ATTR_FLASH);
platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, 
MR_ATTR_SRAM);
 
diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c
index db862f6379..6ef9109022 100644
--- a/arch/mips/lib/boot.c
+++ b/arch/mips/lib/boot.c
@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),
 * whole SDRAM area, since we don't know the size of the image
 * that was loaded.
 */
-   flush_cache(gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart);
+   flush_cache(gd->ram_base, gd->ram_top - gd->ram_base);
 
return entry(argc, argv);
 }
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0a13f6edb7..d5c99d891c 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
 #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
 int arch_fixup_fdt(void *blob)
 {
-   u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
+   u64 mem_start = virt_to_phys((void *)gd->ram_base);
u64 mem_size = gd->ram_size;
 
return fdt_fixup_memory_banks(blob, _start, _size, 1);
diff --git a/arch/powerpc/cpu/mpc83xx/fdt.c b/arch/powerpc/cpu/mpc83xx/fdt.c
index ebdedb2888..4ea7b27ef4 100644
--- a/arch/powerpc/cpu/mpc83xx/fdt.c
+++ b/arch/powerpc/cpu/mpc83xx/fdt.c
@@ -121,7 +121,7 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)
 "clock-frequency", get_serial_clock(), 1);
 #endif
 
-   fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+   fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size);
 
 #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
(defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
diff --git a/arch/powerpc/cpu/mpc83xx/traps.c b/arch/powerpc/cpu/mpc83xx/traps.c
index c3cc119d65..ea8bc6c152 100644
--- a/arch/powerpc/cpu/mpc83xx/traps.c
+++ b/arch/powerpc/cpu/mpc83xx/traps.c
@@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Returns 0 if exception not found and fixup otherwise.  */
 extern unsigned long search_exception_table(unsigned long);
 
-#define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize)
+#define END_OF_MEM (gd->ram_base + gd->ram_size)
 
 /*
  * Trap & Exception support
diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index 9569c1a64b..0d8353ceb2 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -672,10 +672,10 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)
"clock-frequency", get_bus_freq(0), 1);
 #endif
 
-   fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+   fdt_fixup_memory(blob, (u64)gd->ram_base, (u64)gd->ram_size);
 
 #ifdef CONFIG_MP
-   ft_fixup_cpu(blob, (u64)bd->bi_memstart + (u64)bd->bi_memsize);
+   ft_fixup_cpu(blob, (u64)gd->ram_base + (u64)gd->ram_size);
ft_fixup_num_cores(blob);
 #endif
 
diff --git a/arch/powerpc/cpu/mpc85xx/traps.c b/arch/powerpc/cpu/mpc85xx/traps.c
index f37a45e269..db6ed1fc92 100644
--- a/arch/powerpc/cpu/mpc85xx/traps.c
+++ b/arch/powerpc/cpu/mpc85xx/traps.c
@@ -37,7 +37,7 @@ extern unsigned long 

[PATCH v4 8/9] cmd: bdinfo: Remove print of superseeded bi_memstart / bi_memsize values

2020-08-12 Thread Stefan Roese
Remove printing of the superseeded (by bi_dram[]) memory values from the
bdinfo command.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 cmd/bdinfo.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 9e230f23cb..0229846d3e 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -34,12 +34,6 @@ static void print_eth(int idx)
printf("%-12s= %s\n", name, val);
 }
 
-static void print_phys_addr(const char *name, phys_addr_t value)
-{
-   printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong),
-  (unsigned long long)value);
-}
-
 void bdinfo_print_mhz(const char *name, unsigned long hz)
 {
char buf[32];
@@ -73,8 +67,6 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char 
*const argv[])
 #endif
bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
print_bi_dram(bd);
-   bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
-   print_phys_addr("memsize", bd->bi_memsize);
if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
bdinfo_print_num("sramstart", (ulong)bd->bi_sramstart);
bdinfo_print_num("sramsize", (ulong)bd->bi_sramsize);
-- 
2.28.0



[PATCH v4 1/9] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Stefan Roese
Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") &
commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"),
CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default).
It makes no sense to still carry code that is guarded with
"#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes
all these unreferenced code paths.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- Only remove dead code with CONFIG_NR_DRAM_BANKS always defined

 arch/x86/cpu/broadwell/cpu_from_spl.c |  2 --
 board/xilinx/zynqmp/zynqmp.c  |  2 --
 cmd/bdinfo.c  |  2 --
 common/board_f.c  |  7 +-
 common/image.c|  3 +--
 common/init/handoff.c | 33 +++
 drivers/pci/pci-uclass.c  | 17 +-
 include/asm-generic/u-boot.h  |  2 --
 include/handoff.h |  2 --
 lib/fdtdec.c  |  5 
 lib/lmb.c |  9 ++--
 11 files changed, 18 insertions(+), 66 deletions(-)

diff --git a/arch/x86/cpu/broadwell/cpu_from_spl.c 
b/arch/x86/cpu/broadwell/cpu_from_spl.c
index 6567d50653..4d4cdafa2b 100644
--- a/arch/x86/cpu/broadwell/cpu_from_spl.c
+++ b/arch/x86/cpu/broadwell/cpu_from_spl.c
@@ -53,14 +53,12 @@ void board_debug_uart_init(void)
 
 int dram_init_banksize(void)
 {
-#ifdef CONFIG_NR_DRAM_BANKS
struct spl_handoff *ho;
 
ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(*ho));
if (!ho)
return log_msg_ret("Missing SPL hand-off info", -ENOENT);
handoff_load_dram_banks(ho);
-#endif
 
return 0;
 }
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index ebb7172908..4cc5cb6fd7 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -467,10 +467,8 @@ int dram_init(void)
 #else
 int dram_init_banksize(void)
 {
-#if defined(CONFIG_NR_DRAM_BANKS)
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
gd->bd->bi_dram[0].size = get_effective_memsize();
-#endif
 
mem_map_fill();
 
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 9593b345a3..9e230f23cb 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -49,7 +49,6 @@ void bdinfo_print_mhz(const char *name, unsigned long hz)
 
 static void print_bi_dram(const struct bd_info *bd)
 {
-#ifdef CONFIG_NR_DRAM_BANKS
int i;
 
for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
@@ -59,7 +58,6 @@ static void print_bi_dram(const struct bd_info *bd)
bdinfo_print_num("-> size", bd->bi_dram[i].size);
}
}
-#endif
 }
 
 __weak void arch_print_bdinfo(void)
diff --git a/common/board_f.c b/common/board_f.c
index 79532f4365..dd9a5220e1 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -215,8 +215,6 @@ static int announce_dram_init(void)
 static int show_dram_config(void)
 {
unsigned long long size;
-
-#ifdef CONFIG_NR_DRAM_BANKS
int i;
 
debug("\nRAM Configuration:\n");
@@ -229,9 +227,6 @@ static int show_dram_config(void)
 #endif
}
debug("\nDRAM:  ");
-#else
-   size = gd->ram_size;
-#endif
 
print_size(size, "");
board_add_ram_info(0);
@@ -242,7 +237,7 @@ static int show_dram_config(void)
 
 __weak int dram_init_banksize(void)
 {
-#if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
+#if defined(CONFIG_SYS_SDRAM_BASE)
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
gd->bd->bi_dram[0].size = get_effective_memsize();
 #endif
diff --git a/common/image.c b/common/image.c
index 9d7d5c17d1..2ed46f7685 100644
--- a/common/image.c
+++ b/common/image.c
@@ -685,8 +685,7 @@ phys_size_t env_get_bootm_size(void)
return tmp;
}
 
-#if (defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE)) && \
- defined(CONFIG_NR_DRAM_BANKS)
+#if defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE)
start = gd->bd->bi_dram[0].start;
size = gd->bd->bi_dram[0].size;
 #else
diff --git a/common/init/handoff.c b/common/init/handoff.c
index e00b43e6a7..62071bd017 100644
--- a/common/init/handoff.c
+++ b/common/init/handoff.c
@@ -12,18 +12,15 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void handoff_save_dram(struct spl_handoff *ho)
 {
+   struct bd_info *bd = gd->bd;
+   int i;
+
ho->ram_size = gd->ram_size;
-#ifdef CONFIG_NR_DRAM_BANKS
-   {
-   struct bd_info *bd = gd->bd;
-   int i;
-
-   for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-   ho->ram_bank[i].start = bd->bi_dram[i].start;
-   ho->ram_bank[i].size = bd->bi_dram[i].size;
-   }
+
+   for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+   ho->ram_bank[i].start = bd->bi_dram[i].start;
+   ho->ram_bank[i].size = bd->bi_dram[i].size;
}
-#endif
 }
 
 void handoff_load_dram_size(struct spl_handoff *ho)
@@ -33,15 +30,11 @@ void 

[PATCH v4 5/9] xtensa: Remove arch_setup_bdinfo()

2020-08-12 Thread Stefan Roese
arch_setup_bdinfo() only configures the deprecated bi_memstart &
bi_memsize values, which should not be needed any more. Lets remove
this file completely.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 arch/xtensa/lib/Makefile |  2 +-
 arch/xtensa/lib/bdinfo.c | 22 --
 2 files changed, 1 insertion(+), 23 deletions(-)
 delete mode 100644 arch/xtensa/lib/bdinfo.c

diff --git a/arch/xtensa/lib/Makefile b/arch/xtensa/lib/Makefile
index ceee59b9bd..c59df7d372 100644
--- a/arch/xtensa/lib/Makefile
+++ b/arch/xtensa/lib/Makefile
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 
-obj-y  += cache.o misc.o relocate.o time.o bdinfo.o
+obj-y  += cache.o misc.o relocate.o time.o
diff --git a/arch/xtensa/lib/bdinfo.c b/arch/xtensa/lib/bdinfo.c
deleted file mode 100644
index 4ec8529521..00
--- a/arch/xtensa/lib/bdinfo.c
+++ /dev/null
@@ -1,22 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * XTENSA-specific information for the 'bd' command
- *
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, w...@denx.de.
- */
-
-#include 
-#include 
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int arch_setup_bdinfo(void)
-{
-   struct bd_info *bd = gd->bd;
-
-   bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE);
-   bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
-
-   return 0;
-}
-- 
2.28.0



[PATCH v4 6/9] video: cfb_console.c: Use bi_dram[] values on all platforms

2020-08-12 Thread Stefan Roese
All platforms support bi_dram[] since quite some time. Lets remove the
and bi_memsize values completely.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 drivers/video/cfb_console.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index badade353e..3f07f4eb29 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1983,8 +1983,6 @@ static void *video_logo(void)
 static int cfb_fb_is_in_dram(void)
 {
struct bd_info *bd = gd->bd;
-#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || \
-defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
ulong start, end;
int i;
 
@@ -1995,11 +1993,7 @@ defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
(ulong)video_fb_address < end)
return 1;
}
-#else
-   if ((ulong)video_fb_address >= bd->bi_memstart &&
-   (ulong)video_fb_address < bd->bi_memstart + bd->bi_memsize)
-   return 1;
-#endif
+
return 0;
 }
 
-- 
2.28.0



[PATCH v4 2/9] image: Use gd->ram_base/_size in env_get_bootm_size()

2020-08-12 Thread Stefan Roese
Use only gd->ram_base/_size in env_get_bootm_size() instead of bi_dram[]
in some cases and bi_memstart in others.

Signed-off-by: Stefan Roese 

---

Changes in v4:
- New patch

 common/image.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/common/image.c b/common/image.c
index 2ed46f7685..6f68b13fce 100644
--- a/common/image.c
+++ b/common/image.c
@@ -685,13 +685,8 @@ phys_size_t env_get_bootm_size(void)
return tmp;
}
 
-#if defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE)
-   start = gd->bd->bi_dram[0].start;
-   size = gd->bd->bi_dram[0].size;
-#else
-   start = gd->bd->bi_memstart;
-   size = gd->bd->bi_memsize;
-#endif
+   start = gd->ram_base;
+   size = gd->ram_size;
 
s = env_get("bootm_low");
if (s)
-- 
2.28.0



Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Stefan Roese

On 12.08.20 16:21, Daniel Schwierzeck wrote:

Am Mittwoch, den 12.08.2020, 14:37 +0200 schrieb Pali Rohár:

Hello!


diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0a13f6edb7..b3ef15963e 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
   #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
   int arch_fixup_fdt(void *blob)
   {
-   u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
+   u64 mem_start = virt_to_phys((void *)gd->bd->bi_dram[0].start);
u64 mem_size = gd->ram_size;


I do not fully understand this change. Why on some places you are suing
bi_dram[0].size and on some places gd->ram_size?


This patch is mainly a search and replace
s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is
not always
correct.


Yes, this search+replace needs to be better reviewed and tested. Such
big change has potential to break random stuff which nobody think about.


@@ -607,8 +603,11 @@ int setup_bdinfo(void)
   {
struct bd_info *bd = gd->bd;
-   bd->bi_memstart = gd->ram_base;  /* start of memory */
-   bd->bi_memsize = gd->ram_size;   /* size in bytes */
+   /* Only overwrite bi_dram[0] values if not already set */
+   if (!bd->bi_dram[0].size) {


This still look suspicious. When is bi_dram[0].size zero? I tried to
trace source code. dram_init_banksize() is always called before
setup_bdinfo() which fills bi_dram[], so when can be dram size zero?
Or I'm missing something?


dram_init_banksize() is always called earlier, yes. But its weak default
only sets the bi_dram[] values when CONFIG_SYS_SDRAM_BASE is configured.
I'm checking right now, if this might be a problem.


Should not be in this case extended dram_init_banksize() to always
properly fill bi_dram[] structure? Setting bi_dram[] on more places and
doing overwriting could complicate things for future debugging or
extending.


for all users of bi_memstart/bi_memsize the search+replace should be
enough. But in setup_bdinfo() it is wrong because it overrides the
initialization done in dram_init_banksize(). But setup_bdinfo() is a
new function due to some other bd_info refactoring merged two weeks ago
and was not available in v2 of this patch. I guess N900 was still
working with v2 and v3 now has this kind of merge conflict regression.

Just removing those lines without replacing with bi_dram should fix
this:

bd->bi_memstart = gd->ram_base;  /* start of memory */
bd->bi_memsize = gd->ram_size;   /* size in bytes */


Yes. A new patchset will follow soon, which removes these assignments
in setup_bdinfo() but also adds a default assignment to
dram_init_banksize().


BTW: looking deeper in the code and history I think bd_info.bi_dram is
heavily misused as storage for DRAM configuration. Such information
should be stored in global_data where generic code can access it if
needed (e.g. LMB, fdt_fixup_memory_banks()).


I agree. Some of this is addressed in the upcoming patchset.


bd_info should just be
initialized and used when needed to boot old kernels. Also there should
be a Kconfig option to completely disable the support of bd_info.


I agree in general, but:

If we want to support booting of the old kernels (at least on PowerPC),
then we can't remove bi_memstart/memsize from bd_info. This is a
decision that we need to make. Currently my patches remove it and
therefore at least booting of old PowerPC kernels using bd_info to
transfer the memory infos to the kernel will not work any more. This
could easily be changed by not removing those values from the struct
and adding one assignment of them to some common place. I'm not sure
if its worth it though. And I'm not even sure, if I can test this
somehow, as I would need a PowerPC board that is supported in U-Boot &
Linux for a very long time.

Thanks,
Stefan


Re: [PATCH 1/1] doc: riscv: debug UART for MAIX

2020-08-12 Thread Rick Chen
Hi Heinrich

> From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Heinrich 
> Schuchardt
> Sent: Thursday, July 30, 2020 1:24 AM
> To: Sean Anderson
> Cc: u-boot@lists.denx.de; Heinrich Schuchardt
> Subject: [PATCH 1/1] doc: riscv: debug UART for MAIX
>
> Provide the required settings for the debug UART.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  doc/board/sipeed/maix.rst | 10 ++
>  1 file changed, 10 insertions(+)
>

Applying: doc: riscv: debug UART for MAIX
error: patch failed: doc/board/sipeed/maix.rst:262
error: doc/board/sipeed/maix.rst: patch does not apply
Patch failed at 0001 doc: riscv: debug UART for MAIX

Thanks,
Rick


[PATCH v3] common/board_f: make sure to call fix_fdt() before reserve_fdt()

2020-08-12 Thread Pragnesh Patel
There may be a chance that board specific fix_fdt() will change the
size of FDT blob so it's safe to call reserve_fdt() after fix_fdt()
otherwise global data (gd) will overwrite with FDT blob values.

Fixes: a8492e25ac71 ("riscv: Expand the DT size before copy reserved memory 
node")

Signed-off-by: Pragnesh Patel 
Reviewed-by: Bin Meng 
Reviewed-by: Rick Chen 
Reviewed-by: Atish Patra 
---

Changes in v3:
- Rebase on master

Changes in v2:
- Add Fixes tag

 common/board_f.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 79532f4365..3932e0c69d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -919,6 +919,9 @@ static const init_fnc_t init_sequence_f[] = {
 *  - board info struct
 */
setup_dest_addr,
+#ifdef CONFIG_OF_BOARD_FIXUP
+   fix_fdt,
+#endif
 #ifdef CONFIG_PRAM
reserve_pram,
 #endif
@@ -941,9 +944,6 @@ static const init_fnc_t init_sequence_f[] = {
INIT_FUNC_WATCHDOG_RESET
setup_bdinfo,
display_new_sp,
-#ifdef CONFIG_OF_BOARD_FIXUP
-   fix_fdt,
-#endif
INIT_FUNC_WATCHDOG_RESET
reloc_fdt,
reloc_bootstage,
-- 
2.17.1



RE: [PATCH v2] common/board_f: make sure to call fix_fdt() before reserve_fdt()

2020-08-12 Thread Pragnesh Patel
Hi Rick,

>-Original Message-
>From: Rick Chen 
>Sent: 13 August 2020 08:59
>To: Pragnesh Patel 
>Cc: U-Boot Mailing List ; Atish Patra
>; Bin Meng ; Anup Patel
>; Sagar Kadam ; Paul
>Walmsley ( Sifive) ; Simon Glass
>; ovpan...@gmail.com; swar...@nvidia.com; rick
>; Alan Kao 
>Subject: Re: [PATCH v2] common/board_f: make sure to call fix_fdt() before
>reserve_fdt()
>
>[External Email] Do not click links or attachments unless you recognize the
>sender and know the content is safe
>
>Hi Pragnesh
>
>> From: Pragnesh Patel [mailto:pragnesh.pa...@sifive.com]
>> Sent: Thursday, August 06, 2020 3:55 PM
>> To: atish.pa...@wdc.com; bmeng...@gmail.com; u-boot@lists.denx.de;
>> anup.pa...@wdc.com; sagar.ka...@sifive.com; Rick Jian-Zhi Chen(陳建志)
>> Cc: paul.walms...@sifive.com; Pragnesh Patel; Simon Glass; Ovidiu
>> Panait; Stephen Warren; Patrick Delaunay; Joe Hershberger; Vikas
>> Manocha; Masahiro Yamada; Ye Li
>> Subject: [PATCH v2] common/board_f: make sure to call fix_fdt() before
>> reserve_fdt()
>>
>> There may be a chance that board specific fix_fdt() will change the size of 
>> FDT
>blob so it's safe to call reserve_fdt() after fix_fdt() otherwise global data 
>(gd) will
>overwrite with FDT blob values.
>>
>> Fixes: a8492e25ac71 ("riscv: Expand the DT size before copy reserved
>> memory node")
>>
>> Signed-off-by: Pragnesh Patel 
>> Reviewed-by: Bin Meng 
>> Reviewed-by: Rick Chen 
>> ---
>>  common/board_f.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/common/board_f.c b/common/board_f.c index
>> 88ff0424a7..7ae01e9fff 100644
>> --- a/common/board_f.c
>> +++ b/common/board_f.c
>> @@ -956,6 +956,9 @@ static const init_fnc_t init_sequence_f[] = {
>>  *  - board info struct
>>  */
>> setup_dest_addr,
>> +#ifdef CONFIG_OF_BOARD_FIXUP
>> +   fix_fdt,
>> +#endif
>>  #ifdef CONFIG_PRAM
>> reserve_pram,
>>  #endif
>> @@ -984,9 +987,6 @@ static const init_fnc_t init_sequence_f[] = {
>> setup_board_part2,
>>  #endif
>> display_new_sp,
>> -#ifdef CONFIG_OF_BOARD_FIXUP
>> -   fix_fdt,
>> -#endif
>> INIT_FUNC_WATCHDOG_RESET
>> reloc_fdt,
>> reloc_bootstage,
>> --
>> 2.17.1
>>
>
>Applying: common/board_f: make sure to call fix_fdt() before reserve_fdt()
>error: patch failed: common/board_f.c:984
>error: common/board_f.c: patch does not apply Patch failed at 0001
>common/board_f: make sure to call fix_fdt() before reserve_fdt()

Will rebase and send it again.

>
>Thanks,
>Rick


Re: [PATCH v2] common/board_f: make sure to call fix_fdt() before reserve_fdt()

2020-08-12 Thread Rick Chen
Hi Pragnesh

> From: Pragnesh Patel [mailto:pragnesh.pa...@sifive.com]
> Sent: Thursday, August 06, 2020 3:55 PM
> To: atish.pa...@wdc.com; bmeng...@gmail.com; u-boot@lists.denx.de; 
> anup.pa...@wdc.com; sagar.ka...@sifive.com; Rick Jian-Zhi Chen(陳建志)
> Cc: paul.walms...@sifive.com; Pragnesh Patel; Simon Glass; Ovidiu Panait; 
> Stephen Warren; Patrick Delaunay; Joe Hershberger; Vikas Manocha; Masahiro 
> Yamada; Ye Li
> Subject: [PATCH v2] common/board_f: make sure to call fix_fdt() before 
> reserve_fdt()
>
> There may be a chance that board specific fix_fdt() will change the size of 
> FDT blob so it's safe to call reserve_fdt() after fix_fdt() otherwise global 
> data (gd) will overwrite with FDT blob values.
>
> Fixes: a8492e25ac71 ("riscv: Expand the DT size before copy reserved memory 
> node")
>
> Signed-off-by: Pragnesh Patel 
> Reviewed-by: Bin Meng 
> Reviewed-by: Rick Chen 
> ---
>  common/board_f.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/common/board_f.c b/common/board_f.c index 88ff0424a7..7ae01e9fff 
> 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -956,6 +956,9 @@ static const init_fnc_t init_sequence_f[] = {
>  *  - board info struct
>  */
> setup_dest_addr,
> +#ifdef CONFIG_OF_BOARD_FIXUP
> +   fix_fdt,
> +#endif
>  #ifdef CONFIG_PRAM
> reserve_pram,
>  #endif
> @@ -984,9 +987,6 @@ static const init_fnc_t init_sequence_f[] = {
> setup_board_part2,
>  #endif
> display_new_sp,
> -#ifdef CONFIG_OF_BOARD_FIXUP
> -   fix_fdt,
> -#endif
> INIT_FUNC_WATCHDOG_RESET
> reloc_fdt,
> reloc_bootstage,
> --
> 2.17.1
>

Applying: common/board_f: make sure to call fix_fdt() before reserve_fdt()
error: patch failed: common/board_f.c:984
error: common/board_f.c: patch does not apply
Patch failed at 0001 common/board_f: make sure to call fix_fdt()
before reserve_fdt()

Thanks,
Rick


[PATCH 05/11] usb: xhci: convert to TRB_TYPE()

2020-08-12 Thread Chunfeng Yun
Use TRB_TYPE(p) instead of ((p) << TRB_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c  |  3 +--
 drivers/usb/host/xhci-ring.c | 11 +--
 include/usb/xhci.h   |  1 -
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1da0524..d627aa5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -236,8 +236,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
 */
val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control);
val &= ~TRB_TYPE_BITMASK;
-   val |= (TRB_LINK << TRB_TYPE_SHIFT);
-
+   val |= TRB_TYPE(TRB_LINK);
prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
}
 }
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index cf8b9d2..87891fd 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -696,7 +696,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
trb_fields[2] = length_field;
-   trb_fields[3] = field | (TRB_NORMAL << TRB_TYPE_SHIFT);
+   trb_fields[3] = field | TRB_TYPE(TRB_NORMAL);
 
queue_trb(ctrl, ring, (num_trbs > 1), trb_fields);
 
@@ -823,7 +823,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* Queue setup TRB - see section 6.4.1.2.1 */
/* FIXME better way to translate setup_packet into two u32 fields? */
field = 0;
-   field |= TRB_IDT | (TRB_SETUP << TRB_TYPE_SHIFT);
+   field |= TRB_IDT | TRB_TYPE(TRB_SETUP);
if (start_cycle == 0)
field |= 0x1;
 
@@ -860,9 +860,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
/* If there's data, queue data TRBs */
/* Only set interrupt on short packet for IN endpoints */
if (usb_pipein(pipe))
-   field = TRB_ISP | (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_ISP | TRB_TYPE(TRB_DATA);
else
-   field = (TRB_DATA << TRB_TYPE_SHIFT);
+   field = TRB_TYPE(TRB_DATA);
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
@@ -904,8 +904,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
-   (TRB_STATUS << TRB_TYPE_SHIFT) |
-   ep_ring->cycle_state;
+   TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
 
queue_trb(ctrl, ep_ring, false, trb_fields);
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index cf4c020..bdba51d 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -903,7 +903,6 @@ union xhci_trb {
 /* TRB bit mask */
 #defineTRB_TYPE_BITMASK(0xfc00)
 #define TRB_TYPE(p)((p) << 10)
-#define TRB_TYPE_SHIFT (10)
 #define TRB_FIELD_TO_TYPE(p)   (((p) & TRB_TYPE_BITMASK) >> 10)
 
 /* TRB type IDs */
-- 
1.9.1


[PATCH 08/11] usb: xhci: convert to TRB_TX_TYPE()

2020-08-12 Thread Chunfeng Yun
Use TRB_TX_TYPE() instead of (TRB_DATA_OUT/IN << TRB_TX_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 include/usb/xhci.h   | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 99c84f9..ccf2a35 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -830,9 +830,9 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
-   field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_IN);
else
-   field |= (TRB_DATA_OUT << TRB_TX_TYPE_SHIFT);
+   field |= TRB_TX_TYPE(TRB_DATA_OUT);
}
}
 
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 35c6604..07b1aeb 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -879,7 +879,6 @@ struct xhci_event_cmd {
 /* Control transfer TRB specific fields */
 #define TRB_DIR_IN (1<<16)
 #defineTRB_TX_TYPE(p)  ((p) << 16)
-#defineTRB_TX_TYPE_SHIFT   (16)
 #defineTRB_DATA_OUT2
 #defineTRB_DATA_IN 3
 
-- 
1.9.1


[PATCH 04/11] usb: xhci: convert to HCS_MAX_PORTS()

2020-08-12 Thread Chunfeng Yun
Use HCS_MAX_PORTS(p) instead of
((p & HCS_MAX_PORTS_MASK) >> HCS_MAX_PORTS_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h  | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 51edeb2..5f3a0fb 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1257,8 +1257,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
return -ENOMEM;
 
reg = xhci_readl(>cr_hcsparams1);
-   descriptor.hub.bNbrPorts = ((reg & HCS_MAX_PORTS_MASK) >>
-   HCS_MAX_PORTS_SHIFT);
+   descriptor.hub.bNbrPorts = HCS_MAX_PORTS(reg);
printf("Register %x NbrPorts %d\n", reg, descriptor.hub.bNbrPorts);
 
/* Port Indicators */
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 3de46cd..cf4c020 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -101,8 +101,6 @@ struct xhci_hccr {
 /* bits 8:18, Max Interrupters */
 #define HCS_MAX_INTRS(p)   (((p) >> 8) & 0x7ff)
 /* bits 24:31, Max Ports - max value is 0x7F = 127 ports */
-#define HCS_MAX_PORTS_SHIFT24
-#define HCS_MAX_PORTS_MASK (0xff << HCS_MAX_PORTS_SHIFT)
 #define HCS_MAX_PORTS(p)   (((p) >> 24) & 0xff)
 
 /* HCSPARAMS2 - hcs_params2 - bitmasks */
-- 
1.9.1


[PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()

2020-08-12 Thread Chunfeng Yun
Use readx_poll_sleep_timeout() to poll the register status

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index fe30101..3547a9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
@@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
  * @param usec time to wait till
  * @return 0 if handshake is success else < 0 on failure
  */
-static int handshake(uint32_t volatile *ptr, uint32_t mask,
-   uint32_t done, int usec)
+static int
+handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec)
 {
uint32_t result;
+   int ret;
+
+   ret = readx_poll_sleep_timeout(xhci_readl, ptr, result,
+(result & mask) == done || result == U32_MAX,
+1, usec);
+   if (result == U32_MAX)  /* card removed */
+   return -ENODEV;
 
-   do {
-   result = xhci_readl(ptr);
-   if (result == ~(uint32_t)0)
-   return -ENODEV;
-   result &= mask;
-   if (result == done)
-   return 0;
-   usec--;
-   udelay(1);
-   } while (usec > 0);
-
-   return -ETIMEDOUT;
+   return ret;
 }
 
 /**
-- 
1.9.1


[PATCH 09/11] usb: xhci: convert to EP_TYPE()

2020-08-12 Thread Chunfeng Yun
Use EP_TYPE(type) macro instead of ((type) << EP_TYPE_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c | 2 +-
 drivers/usb/host/xhci.c | 3 +--
 include/usb/xhci.h  | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index d627aa5..6292542 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -825,7 +825,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
 
/* Step 4 - ring already allocated */
/* Step 5 */
-   ep0_ctx->ep_info2 = cpu_to_le32(CTRL_EP << EP_TYPE_SHIFT);
+   ep0_ctx->ep_info2 = cpu_to_le32(EP_TYPE(CTRL_EP));
debug("SPEED = %d\n", speed);
 
switch (speed) {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 5f3a0fb..6244f25 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -618,8 +618,7 @@ static int xhci_set_configuration(struct usb_device *udev)
cpu_to_le32(EP_MAX_ESIT_PAYLOAD_HI(max_esit_payload) |
EP_INTERVAL(interval) | EP_MULT(mult));
 
-   ep_ctx[ep_index]->ep_info2 =
-   cpu_to_le32(ep_type << EP_TYPE_SHIFT);
+   ep_ctx[ep_index]->ep_info2 = cpu_to_le32(EP_TYPE(ep_type));
ep_ctx[ep_index]->ep_info2 |=
cpu_to_le32(MAX_PACKET
(get_unaligned(_desc->wMaxPacketSize)));
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 07b1aeb..c534297 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -636,7 +636,6 @@ struct xhci_ep_ctx {
 #define ERROR_COUNT_MASK   (0x3)
 #define CTX_TO_EP_TYPE(p)  (((p) >> 3) & 0x7)
 #define EP_TYPE(p) ((p) << 3)
-#define EP_TYPE_SHIFT  (3)
 #define ISOC_OUT_EP1
 #define BULK_OUT_EP2
 #define INT_OUT_EP 3
-- 
1.9.1


[PATCH 06/11] usb: xhci: convert to TRB_INTR_TARGET()

2020-08-12 Thread Chunfeng Yun
Use TRB_INTR_TARGET(x) instead of
(((x) & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 10 --
 include/usb/xhci.h   |  2 --
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 87891fd..16d2e02 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -690,8 +690,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
 
length_field = ((trb_buff_len & TRB_LEN_MASK) |
TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   TRB_INTR_TARGET(0));
 
trb_fields[0] = lower_32_bits(addr);
trb_fields[1] = upper_32_bits(addr);
@@ -849,8 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[1] = le16_to_cpu(req->index) |
le16_to_cpu(req->length) << 16;
/* TRB_LEN | (TRB_INTR_TARGET) */
-   trb_fields[2] = (8 | ((0 & TRB_INTR_TARGET_MASK) <<
-   TRB_INTR_TARGET_SHIFT));
+   trb_fields[2] = (8 | TRB_INTR_TARGET(0));
/* Immediate data in pointer */
trb_fields[3] = field;
queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -867,7 +865,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
-   ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   TRB_INTR_TARGET(0);
debug("length_field = %d, length = %d,"
"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
length_field, (length & TRB_LEN_MASK),
@@ -901,7 +899,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
trb_fields[0] = 0;
trb_fields[1] = 0;
-   trb_fields[2] = ((0 & TRB_INTR_TARGET_MASK) << TRB_INTR_TARGET_SHIFT);
+   trb_fields[2] = TRB_INTR_TARGET(0);
/* Event on completion */
trb_fields[3] = field | TRB_IOC |
TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state;
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index bdba51d..ca3d99b 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -851,8 +851,6 @@ struct xhci_event_cmd {
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)  (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-#defineTRB_INTR_TARGET_SHIFT   (22)
-#defineTRB_INTR_TARGET_MASK(0x3ff)
 #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22)
 #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff)
 #define TRB_TBC(p) (((p) & 0x3) << 7)
-- 
1.9.1


[PATCH 02/11] usb: xhci: create one unified function to calculate TRB TD remainder.

2020-08-12 Thread Chunfeng Yun
xhci versions 1.0 and later report the untransferred data remaining in a
TD a bit differently than older hosts.

We used to have separate functions for these, and needed to check host
version before calling the right function.

Now Mediatek host has an additional quirk on how it uses the TD Size
field for remaining data. To prevent yet another function for calculating
remainder we instead want to make one quirk friendly unified function.

Porting from the Linux:
c840d6ce772d("xhci: create one unified function to calculate TRB TD remainder.")
124c39371114("xhci: use boolean to indicate last trb in td remainder 
calculation")

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 105 +--
 include/usb/xhci.h   |   2 +
 2 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 79bfc34..0f86b01 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -298,55 +298,52 @@ void xhci_queue_command(struct xhci_ctrl *ctrl, u8 *ptr, 
u32 slot_id,
xhci_writel(>dba->doorbell[0], DB_VALUE_HOST);
 }
 
-/**
- * The TD size is the number of bytes remaining in the TD (including this TRB),
- * right shifted by 10.
- * It must fit in bits 21:17, so it can't be bigger than 31.
+/*
+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
+ * packets remaining in the TD (*not* including this TRB).
  *
- * @param remainderremaining packets to be sent
- * @return remainder if remainder is less than max else max
- */
-static u32 xhci_td_remainder(unsigned int remainder)
-{
-   u32 max = (1 << (21 - 17 + 1)) - 1;
-
-   if ((remainder >> 10) >= max)
-   return max << 17;
-   else
-   return (remainder >> 10) << 17;
-}
-
-/**
- * Finds out the remanining packets to be sent
+ * Total TD packet count = total_packet_count =
+ * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
+ *
+ * Packets transferred up to and including this TRB = packets_transferred =
+ * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
+ *
+ * TD size = total_packet_count - packets_transferred
  *
- * @param running_totaltotal size sent so far
+ * For xHCI 0.96 and older, TD size field should be the remaining bytes
+ * including this TRB, right shifted by 10
+ *
+ * For all hosts it must fit in bits 21:17, so it can't be bigger than 31.
+ * This is taken care of in the TRB_TD_SIZE() macro
+ *
+ * The last TRB in a TD must have the TD size set to zero.
+ *
+ * @param ctrl host controller data structure
+ * @param transferred  total size sent so far
  * @param trb_buff_len length of the TRB Buffer
- * @param total_packet_count   total packet count
- * @param maxpacketsizemax packet size of current pipe
- * @param num_trbs_leftnumber of TRBs left to be processed
- * @return 0 if running_total or trb_buff_len is 0, else remainder
+ * @param td_total_len total packet count
+ * @param maxp max packet size of current pipe
+ * @param more_trbs_coming indicate last trb in TD
+ * @return remainder
  */
-static u32 xhci_v1_0_td_remainder(int running_total,
-   int trb_buff_len,
-   unsigned int total_packet_count,
-   int maxpacketsize,
-   unsigned int num_trbs_left)
+static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int transferred,
+int trb_buff_len, unsigned int td_total_len,
+int maxp, bool more_trbs_coming)
 {
-   int packets_transferred;
+   u32 total_packet_count;
+
+   if (ctrl->hci_version < 0x100)
+   return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
-   if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
+   if (!more_trbs_coming || (transferred == 0 && trb_buff_len == 0) ||
+   trb_buff_len == td_total_len)
return 0;
 
-   /*
-* All the TRB queueing functions don't count the current TRB in
-* running_total.
-*/
-   packets_transferred = (running_total + trb_buff_len) / maxpacketsize;
+   total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
-   if ((total_packet_count - packets_transferred) > 31)
-   return 31 << 17;
-   return (total_packet_count - packets_transferred) << 17;
+   /* Queueing functions don't count the current TRB into transferred */
+   return (total_packet_count - ((transferred + trb_buff_len) / maxp));
 }
 
 /**
@@ -572,7 +569,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
union xhci_trb *event;
 
int running_total, trb_buff_len;
-   unsigned int total_packet_count;
+   bool more_trbs_coming = true;
int maxpacketsize;
u64 addr;
int 

[PATCH 10/11] usb: xhci: use macros with parameter to fill ep_info2

2020-08-12 Thread Chunfeng Yun
Use macros with parameter to fill ep_info2, then some macros
for MASK and SHIFT can be removed

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mem.c | 13 -
 drivers/usb/host/xhci.c |  3 +--
 include/usb/xhci.h  |  5 -
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 6292542..0b49614 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -830,20 +830,17 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl 
*ctrl,
 
switch (speed) {
case USB_SPEED_SUPER:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((512 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(512));
debug("Setting Packet size = 512bytes\n");
break;
case USB_SPEED_HIGH:
/* USB core guesses at a 64-byte max packet first for FS devices */
case USB_SPEED_FULL:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((64 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(64));
debug("Setting Packet size = 64bytes\n");
break;
case USB_SPEED_LOW:
-   ep0_ctx->ep_info2 |= cpu_to_le32(((8 & MAX_PACKET_MASK) <<
-   MAX_PACKET_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(8));
debug("Setting Packet size = 8bytes\n");
break;
default:
@@ -852,9 +849,7 @@ void xhci_setup_addressable_virt_dev(struct xhci_ctrl *ctrl,
}
 
/* EP 0 can handle "burst" sizes of 1, so Max Burst Size field is 0 */
-   ep0_ctx->ep_info2 |=
-   cpu_to_le32(((0 & MAX_BURST_MASK) << MAX_BURST_SHIFT) |
-   ((3 & ERROR_COUNT_MASK) << ERROR_COUNT_SHIFT));
+   ep0_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(0) | ERROR_COUNT(3));
 
trb_64 = virt_to_phys(virt_dev->eps[0].ring->first_seg->trbs);
ep0_ctx->deq = cpu_to_le64(trb_64 | virt_dev->eps[0].ring->cycle_state);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6244f25..fe30101 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -831,8 +831,7 @@ int xhci_check_maxpacket(struct usb_device *udev)
ctrl->devs[slot_id]->out_ctx, ep_index);
in_ctx = ctrl->devs[slot_id]->in_ctx;
ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
-   ep_ctx->ep_info2 &= cpu_to_le32(~((0x & MAX_PACKET_MASK)
-   << MAX_PACKET_SHIFT));
+   ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET(MAX_PACKET_MASK));
ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
/*
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index c534297..e1d3823 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -632,8 +632,6 @@ struct xhci_ep_ctx {
  */
 #defineFORCE_EVENT (0x1)
 #define ERROR_COUNT(p) (((p) & 0x3) << 1)
-#define ERROR_COUNT_SHIFT  (1)
-#define ERROR_COUNT_MASK   (0x3)
 #define CTX_TO_EP_TYPE(p)  (((p) >> 3) & 0x7)
 #define EP_TYPE(p) ((p) << 3)
 #define ISOC_OUT_EP1
@@ -646,13 +644,10 @@ struct xhci_ep_ctx {
 /* bit 6 reserved */
 /* bit 7 is Host Initiate Disable - for disabling stream selection */
 #define MAX_BURST(p)   (((p)&0xff) << 8)
-#define MAX_BURST_MASK (0xff)
-#define MAX_BURST_SHIFT(8)
 #define CTX_TO_MAX_BURST(p)(((p) >> 8) & 0xff)
 #define MAX_PACKET(p)  (((p)&0x) << 16)
 #define MAX_PACKET_MASK(0x)
 #define MAX_PACKET_DECODED(p)  (((p) >> 16) & 0x)
-#define MAX_PACKET_SHIFT   (16)
 
 /* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
  * USB2.0 spec 9.6.6.
-- 
1.9.1


[PATCH 03/11] usb: xhci: add quirks flag to support MediaTek xHCI 0.96

2020-08-12 Thread Chunfeng Yun
There some vendor quirks for MTK xHCI 0.96 host controller:
1. It defines some extra SW scheduling parameters for HW
   to minimize the scheduling effort for synchronous and
   interrupt endpoints. The parameters are put into reseved
   DWs of slot context and endpoint context.
2. Its TDS in  Normal TRB defines a number of packets that
   remains to be transferred for a TD after processing all
   Max packets in all previous TRBs.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c  | 1 +
 drivers/usb/host/xhci-ring.c | 9 +++--
 drivers/usb/host/xhci.c  | 2 +-
 include/usb/xhci.h   | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8ff7185..f3f181d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -258,6 +258,7 @@ static int xhci_mtk_probe(struct udevice *dev)
if (ret)
goto ssusb_init_err;
 
+   mtk->ctrl.quirks = XHCI_MTK_HOST;
hcor = (struct xhci_hcor *)((uintptr_t)mtk->hcd +
HC_LENGTH(xhci_readl(>hcd->cr_capbase)));
 
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 0f86b01..cf8b9d2 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -332,7 +332,8 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
 {
u32 total_packet_count;
 
-   if (ctrl->hci_version < 0x100)
+   /* MTK xHCI 0.96 contains some features from 1.0 */
+   if (ctrl->hci_version < 0x100 && !(ctrl->quirks & XHCI_MTK_HOST))
return ((td_total_len - transferred) >> 10);
 
/* One TRB with a zero-length data packet. */
@@ -340,6 +341,10 @@ static u32 xhci_td_remainder(struct xhci_ctrl *ctrl, int 
transferred,
trb_buff_len == td_total_len)
return 0;
 
+   /* for MTK xHCI 0.96, TD size include this TRB, but not in 1.x */
+   if ((ctrl->quirks & XHCI_MTK_HOST) && (ctrl->hci_version < 0x100))
+   trb_buff_len = 0;
+
total_packet_count = DIV_ROUND_UP(td_total_len, maxp);
 
/* Queueing functions don't count the current TRB into transferred */
@@ -823,7 +828,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (ctrl->hci_version >= 0x100) {
+   if (ctrl->hci_version >= 0x100 || ctrl->quirks & XHCI_MTK_HOST) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4be1411..51edeb2 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -650,7 +650,7 @@ static int xhci_set_configuration(struct usb_device *udev)
 * are put into reserved DWs in Slot and Endpoint Contexts
 * for synchronous endpoints.
 */
-   if (IS_ENABLED(CONFIG_USB_XHCI_MTK)) {
+   if (ctrl->quirks & XHCI_MTK_HOST) {
ep_ctx[ep_index]->reserved[0] =
cpu_to_le32(EP_BPKTS(1) | EP_BBM(1));
}
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 15926eb..3de46cd 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1230,6 +1230,8 @@ struct xhci_ctrl {
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
u16 hci_version;
+   u32 quirks;
+#define XHCI_MTK_HOST  BIT(0)
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
1.9.1


[PATCH 01/11] usb: xhci: add a member hci_version in xhci_ctrl struct

2020-08-12 Thread Chunfeng Yun
Add a member to save xHCI version, it's used some times.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 4 ++--
 drivers/usb/host/xhci.c  | 1 +
 include/usb/xhci.h   | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 092ed6e..79bfc34 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -682,7 +682,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
field |= TRB_ISP;
 
/* Set the TRB length, TD size, and interrupter fields. */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) < 0x100)
+   if (ctrl->hci_version < 0x100)
remainder = xhci_td_remainder(length - running_total);
else
remainder = xhci_v1_0_td_remainder(running_total,
@@ -830,7 +830,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
field |= 0x1;
 
/* xHCI 1.0 6.4.1.2.1: Transfer Type field */
-   if (HC_VERSION(xhci_readl(>hccr->cr_capbase)) >= 0x100) {
+   if (ctrl->hci_version >= 0x100) {
if (length > 0) {
if (req->requesttype & USB_DIR_IN)
field |= (TRB_DATA_IN << TRB_TX_TYPE_SHIFT);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 126dabc..4be1411 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1283,6 +1283,7 @@ static int xhci_lowlevel_init(struct xhci_ctrl *ctrl)
 
reg = HC_VERSION(xhci_readl(>cr_capbase));
printf("USB XHCI %x.%02x\n", reg >> 8, reg & 0xff);
+   ctrl->hci_version = reg;
 
return 0;
 }
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index 7d34103..a3e5914 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -1227,6 +1227,7 @@ struct xhci_ctrl {
struct xhci_scratchpad *scratchpad;
struct xhci_virt_device *devs[MAX_HC_SLOTS];
int rootdev;
+   u16 hci_version;
 };
 
 unsigned long trb_addr(struct xhci_segment *seg, union xhci_trb *trb);
-- 
1.9.1


[PATCH 07/11] usb: xhci: convert to TRB_LEN()

2020-08-12 Thread Chunfeng Yun
Use TRB_LEN(x) instead of ((x) & TRB_LEN_MASK)

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-ring.c | 8 
 include/usb/xhci.h   | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 16d2e02..99c84f9 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -688,7 +688,7 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long 
pipe,
  length, maxpacketsize,
  more_trbs_coming);
 
-   length_field = ((trb_buff_len & TRB_LEN_MASK) |
+   length_field = (TRB_LEN(trb_buff_len) |
TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0));
 
@@ -848,7 +848,7 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
trb_fields[1] = le16_to_cpu(req->index) |
le16_to_cpu(req->length) << 16;
/* TRB_LEN | (TRB_INTR_TARGET) */
-   trb_fields[2] = (8 | TRB_INTR_TARGET(0));
+   trb_fields[2] = (TRB_LEN(8) | TRB_INTR_TARGET(0));
/* Immediate data in pointer */
trb_fields[3] = field;
queue_trb(ctrl, ep_ring, true, trb_fields);
@@ -864,11 +864,11 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long 
pipe,
 
remainder = xhci_td_remainder(ctrl, 0, length, length,
  usb_maxpacket(udev, pipe), 1);
-   length_field = (length & TRB_LEN_MASK) | TRB_TD_SIZE(remainder) |
+   length_field = TRB_LEN(length) | TRB_TD_SIZE(remainder) |
TRB_INTR_TARGET(0);
debug("length_field = %d, length = %d,"
"xhci_td_remainder(length) = %d , TRB_INTR_TARGET(0) = %d\n",
-   length_field, (length & TRB_LEN_MASK),
+   length_field, TRB_LEN(length),
TRB_TD_SIZE(remainder), 0);
 
if (length > 0) {
diff --git a/include/usb/xhci.h b/include/usb/xhci.h
index ca3d99b..35c6604 100644
--- a/include/usb/xhci.h
+++ b/include/usb/xhci.h
@@ -847,7 +847,6 @@ struct xhci_event_cmd {
 /* Normal TRB fields */
 /* transfer_len bitmasks - bits 0:16 */
 #defineTRB_LEN(p)  ((p) & 0x1)
-#defineTRB_LEN_MASK(0x1)
 /* TD Size, packets remaining in this TD, bits 21:17 (5 bits, so max 31) */
 #define TRB_TD_SIZE(p)  (min((p), (u32)31) << 17)
 /* Interrupter Target - which MSI-X vector to target the completion event at */
-- 
1.9.1


Re: [PATCH v4 07/27] rockchip: Enable building a SPI ROM image on bob

2020-08-12 Thread Simon Glass
Hi Kever,

On Mon, 10 Aug 2020 at 01:47, Kever Yang  wrote:
>
> Hi Simon,
>
> On 2020/8/8 下午9:28, Simon Glass wrote:
>
> +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
> + {
> + rom {
> + filename = "u-boot.rom";
> + size = <0x40>;
> + pad-byte = <0xff>;
> +
> + mkimage {
> + args = "-n rk3399 -T rkspi";
> + u-boot-spl {
> + };
> + };
> + u-boot-img {
> + offset = <0x4>;
> + };
> + u-boot {
> + offset = <0x30>;
> + };
> + fdtmap {
> + };
>
> There is a output name 'u-boot.rom' including:
>
> - u-boot-spl output with mkimage cmd at offset 0?
>
> Yes
>
> - u-boot-img at offset 0x4, how this is generated and what is
> inside? does binary in bl31.elf included?
>
> It is just the u-boot.img file created by the Makefile. There is no BL31.
>
> - u-boot at offset 0x30, what is this binary and where is it from?
>
> This is u-boot.bin as created by the Makefile.
>
> Why do you need both u-boot.img and u-boot.bin, I don't understand this.

Neither do I. It needs a look.

>
> And if there is no BL31, the system is not possible to boot up.

This was done quite a while ago with the objective of getting a basic
U-Boot going on this board, so it needs more work to finish it off.

Regards,
SImon


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Weijie Gao
Hi Andrew,

According to my past experience, I believe this is caused by the
W25Q256 NOR flash.

Your bootlog shows that it's booted with SPI-NOR 3-Byte Addr, and your
board is using W25Q256 which requires 4-byte address access when
accessing the higher 16MB memory array.

According to the datasheet of W25Q256, there are three ways to use the
4-byte address mode:

1. By using the dedicate opcodes which always require 4-byte address
2. By using "Enter 4-Byte Address Mode" opcode, to convert all opcodes
   to use 4-byte address
3. By using the Extended Address Register to specify the 4th address
   byte for opcodes which require 3-byte address

The spi-nor driver in u-boot uses combined 2 & 3 for W25Q256.
For details please refer to set_4byte() in
drivers/mtd/spi/spi-nor-core.c

However, u-boot only enables 4-byte mode and never disables it. So after
you reset the board, the flash will remain in 4-byte mode, and the CPU
tries to access the flash with 3-byte address mode. In this situation
the flash will return unexpected data to the CPU, and the CPU will
apparently fail to boot.

The solution is simple, just set the flash to 3-byte mode before
resetting the board by calling set_4byte() with enable=0. But you can
never 100% fix this because the watchdog reset won't give you a chance
to call set_4byte() before resetting the board.

Best Regards,
Weijie


On Wed, 2020-08-12 at 16:14 +0300, Andrii Voloshyn wrote:
> Hi Stefan,
> 
>  On Wed, 12 Aug 2020 15:57:31 +0300 Stefan Roese  wrote 
> 
>  > Hi Andrew, 
>  >  
>  > On 12.08.20 14:48, Andrii Voloshyn wrote: 
>  > > Hi Stefan, 
>  > > 
>  > >  On Wed, 12 Aug 2020 15:08:41 +0300 Stefan Roese  
> wrote  
>  > > 
>  > >   > Hi Andrew, 
>  > >   > 
>  > >   > On 12.08.20 14:04, Andrii Voloshyn wrote: 
>  > >   > > Hi Stefan, 
>  > >   > > 
>  > >   > >   > Hi Andrew, 
>  > >   > >   > 
>  > >   > >   > (added Weijie to Cc) 
>  > >   > >   > 
>  > >   > >   > On 12.08.20 09:18, Andrii Voloshyn wrote: 
>  > >   > >   > >Hi there, 
>  > >   > >   > > 
>  > >   > >   > >There is one issue, I experience with (U-Boot 2020.07) on 
> MT7628DAN, "reset" command issued in hush prompt 
>  > >   > >   > >causes board to hang, until I do a power cycle. On the 
> other hand there is no such issue on mt7688 board. 
>  > >   > >   > 
>  > >   > >   > Do you see no further output? Or is it perhaps stuck at the 
> DDR init 
>  > >   > >   > code in SPL? Can you please post the log (complete boot log 
> with reset 
>  > >   > >   > command)? 
>  > >   > > 
>  > >   > > There is only "resetting..." printed, once the reset command is 
> executed. 
>  > >   > 
>  > >   > I see. Thanks. 
>  > >   > 
>  > >   > >  By the way, I am not using SPL loader. 
>  > >   > 
>  > >   > Why not? Did you give the version with SPL a try? Here most of the 
>  > >   > lowlevel init stuff is executed. Something might be missing in the 
>  > >   > general HW setup if its not used. 
>  > > 
>  > > Then I will need to flash two binaries, spl + uboot, right? 
>  >  
>  > Not really. The 2 images are generated automatically and combined into 
>  > one image (u-boot-with-spl.bin) that needs to be flashed instead. The 
>  > main pro of this SPL + U-Boot proper is that the resulting image is 
>  > *much* smaller (because of the compression of the U-Boot proper) and 
>  > therefore, booting is usually faster as well compared to the "old" 
>  > non-SPL only image. 
>  >  
>  > In my case its ~250kByte (combined image) compared to ~600kByte. 
>  >  
>  > > In any case SPL is optional, at least it should be. :) on this hw. 
>  >  
>  > Yes, correct. But frankly, I have not tested without SPL for a few 
>  > months now. Mainly because of the reasons I mentioned above. 
>  >  
>  
> Just tried u-boot-with-spl.bin image, the result is the same reset command 
> doesn't work :(
>  
>  > >   > 
>  > >   > How are you running the non-SPL (main) U-Boot on your board? Do you 
>  > >   > load it via an old U-Boot? Or is it configured for SPI flash usage 
>  > >   > without SPL instead? 
>  > > 
>  > > I am running the way it was done prior to recent SPL changes. 
>  > > SPI NOR flash  is mapped to 0x9c00 address, and that's what the text 
> base address is set to when SPL is disabled: 
>  > > arch/mips/mach-mtmips/Konfig 
>  >  
>  > Okay. So you are flashing a non-SPL only image into SPI NOR and you are 
>  > not loading it via some other bootloader. That is what I wanted to make 
>  > sure of. 
>  >  
>  > > config SYS_TEXT_BASE 
>  > >> ---default 0x9c00 if !SPL 
>  > >> ---default 0x8020 if SPL 
>  > > 
>  > > Also, I'd like to note that all other functionality in the u-boot works 
> fine, booting of FIT images, other commands I use, 
>  > > the only problem is with the reset command. 
>  > > 
>  > > When I trigger reset manually (writing to RSTCTL register), I get the 
> same behavior: 
>  > > mw 0x1034 0x1 
>  >  
>  > I see. Again, I have no real clue, sorry. 
> 
>  

[RFC PATCH] tools: env: Add an option to have an empty default environment

2020-08-12 Thread Chris Packham
When building envtools via tools-only_defconfig the builtin defaults
are based on options in the defconfig. For example:

  bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} 
ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
  bootdelay=2
  baudrate=115200
  stdin=serial,cros-ec-keyb,usbkbd
  stdout=serial,vidconsole
  stderr=serial,vidconsole
  ethaddr=00:00:11:22:33:44
  eth3addr=00:00:11:22:33:45
  eth5addr=00:00:11:22:33:46
  eth6addr=00:00:11:22:33:47
  ipaddr=1.2.3.4
  bootm_size=0x1000
  kernel_addr_r=0x100
  fdt_addr_r=0xc0
  ramdisk_addr_r=0x200
  scriptaddr=0x1000
  pxefile_addr_r=0x2000

These may or may not be sensible for any particular target. Rather than
trying to have a set of defaults that work for every target add a config
option to make the default environment completely empty.

Signed-off-by: Chris Packham 
---

 configs/tools-only_defconfig | 1 +
 env/Kconfig  | 7 +++
 include/env_default.h| 2 ++
 3 files changed, 10 insertions(+)

diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig
index a853abf2b8fc..0ddd0518ef9a 100644
--- a/configs/tools-only_defconfig
+++ b/configs/tools-only_defconfig
@@ -12,6 +12,7 @@ CONFIG_BOOTP_DNS2=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_EMPTY_DEFAULT_ENV=y
 CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_IP_DEFRAG=y
 # CONFIG_ACPIGEN is not set
diff --git a/env/Kconfig b/env/Kconfig
index af4d9cbaa4d8..f7860f01cc16 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -614,6 +614,13 @@ config DEFAULT_ENV_FILE
  containing key=value pairs, blank lines and lines beginning
  with # are ignored.
 
+config EMPTY_DEFAULT_ENV
+   bool "Create an empty default environment"
+   help
+ Create an empty default environment. This is intended to be
+ used when building generic target tools and no sensible
+ default that can be included.
+
 config ENV_VARS_UBOOT_RUNTIME_CONFIG
bool "Add run-time information to the environment"
help
diff --git a/include/env_default.h b/include/env_default.h
index 8a0c3057f0aa..859188a8e7c9 100644
--- a/include/env_default.h
+++ b/include/env_default.h
@@ -23,6 +23,7 @@ static char default_environment[] = {
 const uchar default_environment[] = {
 #endif
 #ifndef CONFIG_USE_DEFAULT_ENV_FILE
+#ifndef CONFIG_EMPTY_DEFAULT_ENV
 #ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT
ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
 #endif
@@ -107,6 +108,7 @@ const uchar default_environment[] = {
 #endif
 #ifdef CONFIG_EXTRA_ENV_SETTINGS
CONFIG_EXTRA_ENV_SETTINGS
+#endif
 #endif
"\0"
 #else /* CONFIG_USE_DEFAULT_ENV_FILE */
-- 
2.28.0



Re: [PATCH] arm: mx6: Make all i.MX6 SoCs user-selectable

2020-08-12 Thread Tom Rini
On Thu, Aug 13, 2020 at 12:52:22AM +, Peng Fan wrote:
> Hi Tom,
> 
> > Subject: [PATCH] arm: mx6: Make all i.MX6 SoCs user-selectable
> >
> []
>  
> > +
> >  config MX6UL_LITESOM
> > bool
> > select DM
> > select DM_THERMAL
> > -   select MX6UL
> 
> Would keep it here to simplify defconfig?

No.  The litesom / opos6 cases highlight that we have two different ways
SoM+carrier are being handled today and those too could use unifacation.
But we can't drop MX6UL_LITESOM (or MX6UL_OPOS6UL) and would have
arch/arm/mach-imx/mx6/Makefile reference CONFIG_TARGET_xxx options,
which isn't something that looks right.

-- 
Tom


signature.asc
Description: PGP signature


RE: [PATCH] arm: mx6: Make all i.MX6 SoCs user-selectable

2020-08-12 Thread Peng Fan
Hi Tom,

> Subject: [PATCH] arm: mx6: Make all i.MX6 SoCs user-selectable
>
[]
 
> +
>  config MX6UL_LITESOM
>   bool
>   select DM
>   select DM_THERMAL
> - select MX6UL

Would keep it here to simplify defconfig?

Regards,
Peng.

>   select SUPPORT_SPL
>   imply CMD_DM
> 
> @@ -73,7 +83,6 @@ config MX6UL_OPOS6UL
>   select DM_GPIO
>   select DM_MMC
>   select DM_THERMAL
> - select MX6UL
>   select SPL_DM if SPL
>   select SPL_OF_CONTROL if SPL
>   select SPL_PINCTRL if SPL
> @@ -81,12 +90,6 @@ config MX6UL_OPOS6UL
>   select SUPPORT_SPL
>   imply CMD_DM
> 
> -config MX6ULL
> - bool
> - select ROM_UNIFIED_SECTIONS
> - select SYSCOUNTER_TIMER
> - select SYS_L2CACHE_OFF
> -
>  config MX6_OCRAM_256KB
>   bool "Support 256KB OCRAM"
>   depends on MX6D || MX6Q
> @@ -110,14 +113,14 @@ choice
> 
>  config TARGET_ADVANTECH_DMS_BA16
>   bool "Advantech dms-ba16"
> + depends on MX6Q
>   select BOARD_LATE_INIT
> - select MX6Q
>   imply CMD_SATA
> 
>  config TARGET_APALIS_IMX6
>   bool "Toradex Apalis iMX6 board"
> + depends on MX6Q
>   select BOARD_LATE_INIT
> - select MX6Q
>   select DM
>   select DM_SERIAL
>   select DM_THERMAL
> @@ -127,8 +130,8 @@ config TARGET_APALIS_IMX6
> 
>  config TARGET_ARISTAINETOS2
>   bool "aristainetos2"
> + depends on MX6DL
>   select BOARD_LATE_INIT
> - select MX6DL
>   select SYS_I2C_MXC
>   select MXC_UART
>   select FEC_MXC
> @@ -138,8 +141,8 @@ config TARGET_ARISTAINETOS2
> 
>  config TARGET_ARISTAINETOS2B
>   bool "Support aristainetos2-revB"
> + depends on MX6DL
>   select BOARD_LATE_INIT
> - select MX6DL
>   select SYS_I2C_MXC
>   select MXC_UART
>   select FEC_MXC
> @@ -149,8 +152,8 @@ config TARGET_ARISTAINETOS2B
> 
>  config TARGET_ARISTAINETOS2BCSL
>   bool "Support aristainetos2-revB CSL"
> + depends on MX6DL
>   select BOARD_LATE_INIT
> - select MX6DL
>   select SYS_I2C_MXC
>   select MXC_UART
>   select FEC_MXC
> @@ -160,8 +163,8 @@ config TARGET_ARISTAINETOS2BCSL
> 
>  config TARGET_ARISTAINETOS2C
>   bool "Support aristainetos2-revC"
> + depends on MX6DL
>   select BOARD_LATE_INIT
> - select MX6DL
>   select SYS_I2C_MXC
>   select MXC_UART
>   select FEC_MXC
> @@ -171,20 +174,20 @@ config TARGET_ARISTAINETOS2C
> 
>  config TARGET_CGTQMX6EVAL
>   bool "cgtqmx6eval"
> + depends on MX6QDL
>   select BOARD_LATE_INIT
>   select DM
>   select DM_THERMAL
> - select MX6QDL
>   select SUPPORT_SPL
>   imply CMD_DM
> 
>  config TARGET_CM_FX6
>   bool "CM-FX6"
> + depends on MX6QDL
>   select BOARD_LATE_INIT
>   select DM
>   select DM_GPIO
>   select DM_SERIAL
> - select MX6QDL
>   select SUPPORT_SPL
>   imply CMD_DM
> 
> @@ -199,14 +202,14 @@ config TARGET_COLIBRI_IMX6
> 
>  config TARGET_COLIBRI_IMX6ULL
>   bool "Toradex Colibri iMX6ULL"
> + depends on MX6ULL
>   select BOARD_LATE_INIT
>   select DM
>   select DM_THERMAL
> - select MX6ULL
> 
>  config TARGET_DART_6UL
>   bool "Variscite imx6ULL dart(DART-SOM-6ULL)"
> - select MX6ULL
> + depends on MX6ULL
>   select DM
>   select DM_ETH
>   select DM_GPIO
> @@ -218,17 +221,18 @@ config TARGET_DART_6UL
> 
>  config TARGET_DHCOMIMX6
>   bool "dh_imx6"
> + depends on MX6QDL
>   select BOARD_EARLY_INIT_F
>   select BOARD_LATE_INIT
>   select DM
>   select DM_THERMAL
> - select MX6QDL
>   select SUPPORT_SPL
>   imply CMD_DM
>   imply CMD_SPL
> 
>  config TARGET_DISPLAY5
>   bool "LWN DISPLAY5 board"
> + depends on MX6Q
>   select DM
>   select DM_ETH
>   select DM_I2C
> @@ -246,12 +250,12 @@ config TARGET_EMBESTMX6BOARDS
> 
>  config TARGET_GE_BX50V3
>   bool "General Electric Bx50v3"
> + depends on MX6Q
>   select BOARD_LATE_INIT
> - select MX6Q
> 
>  config TARGET_GW_VENTANA
>   bool "gw_ventana"
> - select MX6QDL
> + depends on MX6QDL
>   select SUPPORT_SPL
>   imply CMD_SATA
>   imply CMD_SPL
> @@ -272,7 +276,7 @@ config TARGET_KOSAGI_NOVENA
> 
>  config TARGET_MCCMON6
>   bool "mccmon6"
> - select MX6QDL
> + depends on MX6QDL
>   select SUPPORT_SPL
>   select DM
>   select DM_GPIO
> @@ -284,13 +288,13 @@ config TARGET_MCCMON6
> 
>  config TARGET_MX6CUBOXI
>   bool "Solid-run mx6 boards"
> + depends on MX6QDL
>   select BOARD_LATE_INIT
> - select MX6QDL
>   select SUPPORT_SPL
> 
>  config TARGET_MX6LOGICPD
>   bool "Logic PD i.MX6 SOM"
> - select MX6Q
> + depends on MX6Q
>   select SUPPORT_SPL
>   select BOARD_EARLY_INIT_F
>   select BOARD_LATE_INIT
> @@ -305,6 +309,7 @@ config TARGET_MX6LOGICPD
> 
>  config TARGET_MX6MEMCAL
>   bool "mx6memcal"
> + depends on MX6QDL
>   select SUPPORT_SPL
> 

Cannot boot from eMMC on Odroid C4 with u-boot 2020.10-rc2

2020-08-12 Thread Garrick James
As I understand it, initial support for the Odroid C4 (OC4) has been added
to u-boot and is included in 2020.10-rc2.  I have been able to successfully
boot my OC4 using u-boot 2020.10-rc2 from the SD card.  Yay!  Thank you.

Unfortunately, I cannot boot from the eMMC.  U-boot is unable to reliably
communicate with the eMMC--it encounters random, sporadic errors (more
often errors than success).  Note that once Linux (kernel version 5.8) is
booted (using u-boot on the SD card), Linux has no problems communicating
with the eMMC.  In fact all Linux file systems reside on the eMMC.  (The
only files on the SD card are boot.scr, the Linux kernel image, initramfs
image, and the dtb.)

Below is a log of an interactive u-boot session that shows that the same
commands accessing the eMMC both succeeding and failing.  You will note
that the u-boot version includes "-dirty."  This is because I
changed EXTRAVERSION in the toplevel Makefile to be "-rc2" (it was still
set to "-rc1" in commit 554e551, tagged as 2020.10-rc2).

Is eMMC support supposed to be working at this point?  If so, does anyone
have any ideas about what I need to do to get it working?

Thank you,
Garrick

P.S.
Please CC me, as I am not subscribed to the list.

U-Boot 2020.10-rc2-dirty (Aug 12 2020 - 15:08:40 -0700) odroid-c4

Model: Hardkernel ODROID-C4
SoC:   Amlogic Meson SM1 (Unknown) Revision 2b:c (10:2)
DRAM:  3.8 GiB
MMC:   sd@ffe05000: 0, mmc@ffe07000: 1
In:serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@ff3f
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
switch to partitions #0, OK
mmc1(part 0) is current device
Scanning mmc 1:1...
** Unrecognized filesystem type **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
** No partition table - mmc 1 **
MMC Device 2 not found
no mmc device at slot 2
starting USB...
Bus usb@ff50: Register 3000140 NbrPorts 3
Starting the controller
USB XHCI 1.10
scanning bus usb@ff50 for devices... 3 USB Device(s) found
   scanning usb for storage devices... 0 Storage Device(s) found

Device 0: unknown device
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4

Abort
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/01-00-1e-06-48-0b-c7
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-meson-odroid-n2
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-meson
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
Speed: 1000, full duplex
*** ERROR: `serverip' not set
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
Speed: 1000, full duplex
*** ERROR: `serverip' not set
Config file not found
=> mmc list
sd@ffe05000: 0
mmc@ffe07000: 1 (eMMC)
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
=> fatls mmc 1:1
** No partition table - mmc 1 **
=> mmc dev 0
Card did not respond to voltage select!
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc part
## Unknown partition table type 0
=> mmc part
## Unknown partition table type 0
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc part

Partition Map for MMC device 1  --   Partition Type: DOS

PartStart SectorNum Sectors UUIDType
  1 32768   2097152 03823826-01 0c Boot
  2 2129920 5754060803823826-02 83
  3 596705285754060803823826-03 83
  4 117211136   4931584 03823826-04 83
=> fatls mmc 1:1
  

[PATCH] arm: mx6: Make all i.MX6 SoCs user-selectable

2020-08-12 Thread Tom Rini
We have a number of platforms that are a combination of a carrier board
and System-on-Module (SoM) that in turn allows for the board to have
different SoCs on it.  In some cases, this is handled via board-specific
Kconfig options.  In other cases we make use of
CONFIG_SYS_EXTRA_OPTIONS.  This latter case however can lead to invalid
configurations as we will not in turn get options that in Kconfig are
selected by or depend on that setting.

To resolve this, make the SoC option a choice in Kconfig and make boards
depend on what they can support.  This change opens us up for further
clean-ups in the cases where a single CONFIG_TARGET_xxx can support
different SoCs and today they do not, or do not cleanly do so.

Reported-by: Matt Porter 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: "NXP i.MX U-Boot Team" 
Cc: Soeren Moch 
Cc: Markus Niebel 
Cc: Igor Opaniuk 
Cc: Heiko Schocher 
Cc: Hannes Schmelzer 
Cc: Otavio Salvador 
Cc: Nikita Kiryanov 
Cc: Andreas Geisreiter 
Cc: Ludwig Zenz 
Cc: Lukasz Majewski 
Cc: Akshay Bhat 
Cc: Ken Lin 
Cc: Ian Ray 
Cc: Tim Harvey 
Cc: Jagan Teki 
Cc: Raffaele RECALCATI 
Cc: Simone CIANNI 
Cc: Adam Ford 
Cc: Marcin Niestroj 
Cc: "Eric Bénard" 
Cc: Baruch Siach 
Cc: Jason Liu 
Cc: Ye Li 
Cc: Eric Nelson 
Cc: Troy Kisky 
Cc: Peng Fan 
Cc: Parthiban Nallathambi 
Cc: Marek Vasut 
Cc: "Sébastien Szymanski" 
Cc: Christian Gmeiner 
Cc: Niel Fourie 
Cc: Martyn Welch 
Cc: Richard Hu 
Cc: Stefan Roese 
Cc: Boris Brezillon 
Cc: Arkadiusz Karas 
Cc: Breno Lima 
Cc: Francesco Montefoschi 
Cc: Silvio Fricke 
Tested-by: Matt Porter  [colibri_imx6]
Signed-off-by: Tom Rini 
---
 arch/arm/mach-imx/mx6/Kconfig | 136 --
 board/seco/Kconfig|   6 +-
 board/tbs/tbs2910/Kconfig |   3 -
 board/tqc/tqma6/Kconfig   |   6 +-
 configs/apalis_imx6_defconfig |   3 +-
 configs/aristainetos2_defconfig   |   1 +
 configs/aristainetos2b_defconfig  |   1 +
 configs/aristainetos2bcsl_defconfig   |   1 +
 configs/aristainetos2c_defconfig  |   1 +
 configs/brppt2_defconfig  |   1 +
 configs/cgtqmx6eval_defconfig |   1 +
 configs/cm_fx6_defconfig  |   1 +
 configs/colibri-imx6ull_defconfig |   3 +-
 configs/colibri_imx6_defconfig|   3 +-
 configs/dh_imx6_defconfig |   1 +
 configs/display5_defconfig|   3 +-
 configs/display5_factory_defconfig|   3 +-
 configs/dms-ba16-1g_defconfig |   1 +
 configs/dms-ba16_defconfig|   1 +
 configs/ge_bx50v3_defconfig   |   1 +
 configs/gwventana_emmc_defconfig  |   1 +
 configs/gwventana_gw5904_defconfig|   1 +
 configs/gwventana_nand_defconfig  |   1 +
 configs/imx6dl_icore_nand_defconfig   |   1 +
 configs/imx6dl_mamoj_defconfig|   1 +
 configs/imx6q_icore_nand_defconfig|   1 +
 configs/imx6q_logic_defconfig |   1 +
 configs/imx6qdl_icore_mipi_defconfig  |   1 +
 configs/imx6qdl_icore_mmc_defconfig   |   1 +
 configs/imx6qdl_icore_nand_defconfig  |   1 +
 configs/imx6qdl_icore_rqs_defconfig   |   1 +
 configs/imx6ul_geam_mmc_defconfig |   1 +
 configs/imx6ul_geam_nand_defconfig|   1 +
 configs/imx6ul_isiot_emmc_defconfig   |   1 +
 configs/imx6ul_isiot_nand_defconfig   |   1 +
 configs/kp_imx6q_tpc_defconfig|   1 +
 configs/liteboard_defconfig   |   1 +
 configs/marsboard_defconfig   |   3 +-
 configs/mccmon6_nor_defconfig |   1 +
 configs/mccmon6_sd_defconfig  |   1 +
 configs/mx6cuboxi_defconfig   |   1 +
 configs/mx6dlarm2_defconfig   |   3 +-
 configs/mx6dlarm2_lpddr2_defconfig|   3 +-
 configs/mx6memcal_defconfig   |   3 +-
 configs/mx6qarm2_defconfig|   3 +-
 configs/mx6qarm2_lpddr2_defconfig |   3 +-
 configs/mx6qsabrelite_defconfig   |   3 +-
 configs/mx6sabreauto_defconfig|   1 +
 configs/mx6sabresd_defconfig  |   1 +
 configs/mx6slevk_defconfig|   1 +
 configs/mx6slevk_spinor_defconfig |   1 +
 configs/mx6slevk_spl_defconfig|   1 +
 configs/mx6sllevk_defconfig   |   1 +
 configs/mx6sllevk_plugin_defconfig|   1 +
 configs/mx6sxsabreauto_defconfig  |   1 +
 configs/mx6sxsabresd_defconfig|   1 +
 configs/mx6ul_14x14_evk_defconfig |   1 +
 configs/mx6ul_9x9_evk_defconfig   |   1 +
 configs/mx6ull_14x14_evk_defconfig|   1 +
 configs/mx6ull_14x14_evk_plugin_defconfig |   1 +
 configs/mx6ulz_14x14_evk_defconfig|   1 +
 configs/myir_mys_6ulx_defconfig   |   1 +
 configs/nitrogen6dl2g_defconfig   |   3 +-
 configs/nitrogen6dl_defconfig |   3 +-
 configs/nitrogen6q2g_defconfig|   3 +-
 configs/nitrogen6q_defconfig   

[PATCH 1/2] board/freescale/vid: rework of VID support

2020-08-12 Thread Wasim Khan
The VID code does not properly set the voltages on all chips.
It does not properly reports voltage changes.
For IR, the read accuracy was incorrect and for
the LTC the step width was too wide.

This patchset fix above problems and also make LTC channel
use configurable to deal properly with single and dual
channel setups.

Signed-off-by: Dan Nica 
Signed-off-by: Heinz Wrobel 
Signed-off-by: Wasim Khan 
---
 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  |  19 +-
 board/freescale/common/vid.c   | 662 +++--
 board/freescale/common/vid.h   |  42 +-
 3 files changed, 403 insertions(+), 320 deletions(-)

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 baa9fa8..6147fad 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -2,7 +2,7 @@
 /*
  * LayerScape Internal Memory Map
  *
- * Copyright 2017-2019 NXP
+ * Copyright 2017-2020 NXP
  * Copyright 2014 Freescale Semiconductor, Inc.
  */
 
@@ -324,15 +324,14 @@ struct ccsr_gur {
u32 gpporcr3;
u32 gpporcr4;
u8  res_030[0x60-0x30];
-#define FSL_CHASSIS3_DCFG_FUSESR_VID_MASK  0x1F
-#define FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK   0x1F
-#if defined(CONFIG_ARCH_LS1088A)
-#define FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT 25
-#define FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT  20
-#else
-#define FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT 2
-#define FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT  7
-#endif
+#define FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT  25
+#define FSL_CHASSIS3_DCFG_FUSESR_VID_MASK  0x1F
+#define FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT   20
+#define FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK0x1F
+#define FSL_CHASSIS3_DCFG_FUSESR_LOW_VID_SHIFT  2
+#define FSL_CHASSIS3_DCFG_FUSESR_LOW_VID_MASK   0x1F
+#define FSL_CHASSIS3_DCFG_FUSESR_LOW_ALTVID_SHIFT 7
+#define FSL_CHASSIS3_DCFG_FUSESR_LOW_ALTVID_MASK0x1F
u32 dcfg_fusesr;/* Fuse status register */
u8  res_064[0x70-0x64];
u32 devdisr;/* Device disable control 1 */
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index ed0d9b4..0ba672d 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2014 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
  */
 
 #include 
@@ -20,6 +21,8 @@
 #include 
 #include "vid.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int __weak i2c_multiplexer_select_vid_channel(u8 channel)
 {
return 0;
@@ -42,10 +45,8 @@ int __weak board_adjust_vdd(int vdd)
return 0;
 }
 
-#if defined(CONFIG_VOL_MONITOR_IR36021_SET) || \
-   defined(CONFIG_VOL_MONITOR_IR36021_READ)
 /*
- * Get the i2c address configuration for the IR regulator chip
+ * Get the i2c address configuration for the regulator chip
  *
  * There are some variance in the RDB HW regarding the I2C address 
configuration
  * for the IR regulator chip, which is likely a problem of external resistor
@@ -56,9 +57,14 @@ int __weak board_adjust_vdd(int vdd)
  * 0x08 (Verified on T1040RDB-PA,T4240RDB-PB,X-T4240RDB-16GPA)
  * 0x09 (Verified on T1040RDB-PA)
  * 0x38 (Verified on T2080QDS, T2081QDS, T4240RDB)
+ *
+ * For other types of regulator chips, we check the IDs before we
+ * return the address to avoid making damaging mistakes
  */
-static int find_ir_chip_on_i2c(void)
+static int find_vid_chip_on_i2c(void)
 {
+#if defined(CONFIG_VOL_MONITOR_IR36021_READ) || \
+   defined(CONFIG_VOL_MONITOR_IR36021_SET)
int i2caddress;
int ret;
u8 byte;
@@ -81,33 +87,75 @@ static int find_ir_chip_on_i2c(void)
ret = dm_i2c_read(dev, IR36021_MFR_ID_OFFSET,
  (void *), sizeof(byte));
 #endif
-   if ((ret >= 0) && (byte == IR36021_MFR_ID))
+   if (!ret && byte == IR36021_MFR_ID)
+   return i2caddress;
+   }
+#endif
+#if defined(CONFIG_VOL_MONITOR_LTC3882_READ) || \
+   defined(CONFIG_VOL_MONITOR_LTC3882_SET)
+   int i2caddress = I2C_VOL_MONITOR_ADDR;
+   int ret;
+   u8 buf[8];
+#ifdef CONFIG_DM_I2C
+   struct udevice *dev;
+#endif
+
+#ifndef CONFIG_DM_I2C
+   ret = i2c_read(i2caddress,
+  LTC3882_MFR_ID, 1, (void *)[0],
+  4);
+#else
+   ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
+   if (!ret)
+   ret = dm_i2c_read(dev, LTC3882_MFR_ID,
+ (void *)[0], 4);
+#endif
+   if (!ret && memcmp(buf, "\3LTC", 4) == 0) {
+#ifndef CONFIG_DM_I2C
+   ret = i2c_read(i2caddress,
+  LTC3882_MFR_MODEL, 1, (void *)[0],
+  8);
+#else
+   ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
+   if 

[PATCH 0/2] board/freescale/vid: rework of VID support

2020-08-12 Thread Wasim Khan
The VID code does not properly set the voltages on all chips.
It does not properly reports voltage changes.
For IR, the read accuracy was incorrect and for
the LTC the step width was too wide.

- This patchset rework the vid driver and make LTC channel
  use configurable to deal properly with single and dual
  channel setups.
- Add support for LTC7132

Wasim Khan (2):
  board/freescale/vid: rework of VID support
  board/freescale/vid: Add support for LTC7132 voltage regulator

 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  |  19 +-
 board/freescale/common/vid.c   | 685 +++--
 board/freescale/common/vid.h   |  42 +-
 3 files changed, 423 insertions(+), 323 deletions(-)

-- 
2.7.4



[PATCH 2/2] board/freescale/vid: Add support for LTC7132 voltage regulator

2020-08-12 Thread Wasim Khan
Add support for LTC7132 voltage regulator

Signed-off-by: Wasim Khan 
Reviewed-by: Heinz Wrobel 
---
 board/freescale/common/vid.c | 121 ---
 board/freescale/common/vid.h |  32 ++--
 2 files changed, 85 insertions(+), 68 deletions(-)

diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index 0ba672d..095781f 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -92,7 +92,9 @@ static int find_vid_chip_on_i2c(void)
}
 #endif
 #if defined(CONFIG_VOL_MONITOR_LTC3882_READ) || \
-   defined(CONFIG_VOL_MONITOR_LTC3882_SET)
+   defined(CONFIG_VOL_MONITOR_LTC7132_READ) || \
+   defined(CONFIG_VOL_MONITOR_LTC3882_SET) || \
+   defined(CONFIG_VOL_MONITOR_LTC7132_SET)
int i2caddress = I2C_VOL_MONITOR_ADDR;
int ret;
u8 buf[8];
@@ -102,27 +104,35 @@ static int find_vid_chip_on_i2c(void)
 
 #ifndef CONFIG_DM_I2C
ret = i2c_read(i2caddress,
-  LTC3882_MFR_ID, 1, (void *)[0],
+  LTC_MFR_ID, 1, (void *)[0],
   4);
 #else
ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
if (!ret)
-   ret = dm_i2c_read(dev, LTC3882_MFR_ID,
+   ret = dm_i2c_read(dev, LTC_MFR_ID,
  (void *)[0], 4);
 #endif
if (!ret && memcmp(buf, "\3LTC", 4) == 0) {
 #ifndef CONFIG_DM_I2C
ret = i2c_read(i2caddress,
-  LTC3882_MFR_MODEL, 1, (void *)[0],
+  LTC_MFR_MODEL, 1, (void *)[0],
   8);
 #else
ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
if (!ret)
-   ret = dm_i2c_read(dev, LTC3882_MFR_MODEL,
+   ret = dm_i2c_read(dev, LTC_MFR_MODEL,
  (void *)[0], 8);
 #endif
-   if (!ret && memcmp(buf, "\7LTC3882", 8) == 0)
-   return i2caddress;
+   if (!ret) {
+#if defined(CONFIG_VOL_MONITOR_LTC3882_SET) || \
+   defined(CONFIG_VOL_MONITOR_LTC3882_READ)
+   if (memcmp(buf, "\7LTC3882", 8) == 0)
+#elif defined(CONFIG_VOL_MONITOR_LTC7132_SET) || \
+   defined(CONFIG_VOL_MONITOR_LTC7132_READ)
+   if (memcmp(buf, "\7LTC7132", 8) == 0)
+#endif
+   return i2caddress;
+   }
}
 #endif
return -1;
@@ -148,7 +158,8 @@ static int find_vid_chip_on_i2c(void)
 #define VDD_STEP_UPIR_VDD_STEP_UP
 #define VDD_STEP_DOWN  IR_VDD_STEP_DOWN
 #endif
-#ifdef CONFIG_VOL_MONITOR_LTC3882_READ
+#if defined(CONFIG_VOL_MONITOR_LTC3882_READ) || \
+   defined(CONFIG_VOL_MONITOR_LTC7132_READ)
 #define WAIT_FOR_ADC   0
 #define ADC_MIN_ACCURACY   LTC_ADC_MIN_ACCURACY
 #define VDD_STEP_UPLTC_VDD_STEP_UP
@@ -253,14 +264,15 @@ static int read_voltage_from_IR(int i2caddress)
 }
 #endif
 
-#ifdef CONFIG_VOL_MONITOR_LTC3882_READ
+#if defined(CONFIG_VOL_MONITOR_LTC3882_READ) || \
+   defined(CONFIG_VOL_MONITOR_LTC7132_READ)
 /* read the current value of the LTC Regulator Voltage.
  * This will only read the first channel for dual channel setups
  */
 static int read_voltage_from_LTC(int i2caddress)
 {
int  ret, vcode = 0;
-   u8 chan = LTC3882_VID_CHANNEL;
+   u8 chan = LTC_VID_CHANNEL;
u8 buf[2];
 #ifdef CONFIG_DM_I2C
struct udevice *dev;
@@ -269,11 +281,11 @@ static int read_voltage_from_LTC(int i2caddress)
/* select the PAGE 0 using PMBus commands PAGE for VDD*/
 #ifndef CONFIG_DM_I2C
ret = i2c_write(i2caddress,
-   LTC3882_PAGE, 1, , 1);
+   LTC_PAGE, 1, , 1);
 #else
ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
if (!ret)
-   ret = dm_i2c_write(dev, LTC3882_PAGE, , 1);
+   ret = dm_i2c_write(dev, LTC_PAGE, , 1);
 #endif
if (ret) {
printf("VID: failed to select VDD Page\n");
@@ -283,11 +295,11 @@ static int read_voltage_from_LTC(int i2caddress)
/*read the output voltage using PMBus command READ_VOUT*/
 #ifndef CONFIG_DM_I2C
ret = i2c_read(i2caddress,
-  LTC3882_READ_VOUT, 1, (void *)[0], 2);
+  LTC_READ_VOUT, 1, (void *)[0], 2);
 #else
ret = i2c_get_chip_for_busnum(0, i2caddress, 1, );
if (!ret)
-   ret = dm_i2c_read(dev, LTC3882_READ_VOUT,
+   ret = dm_i2c_read(dev, LTC_READ_VOUT,
  (void *)[0], 2);
 #endif
if (ret) {
@@ -310,7 +322,8 @@ static int read_voltage(int i2caddress)
voltage_read = read_voltage_from_INA220(I2C_VOL_MONITOR_ADDR);
 #elif defined CONFIG_VOL_MONITOR_IR36021_READ
voltage_read = read_voltage_from_IR(i2caddress);
-#elif defined CONFIG_VOL_MONITOR_LTC3882_READ
+#elif 

Re: [PATCH 1/2] avb: Make AVB independent of fastboot

2020-08-12 Thread Igor Opaniuk
Hi Usama,

On Tue, Aug 11, 2020, 17:46 Usama Arif  wrote:

> AVB only uses CONFIG_FASTBOOT_BUF_ADDR from fastboot for memory.
> This memory is used for assigning temporary buffers.
> This can be assigned a new variable and used as CONFIG_AVB_BUF_ADDR.
> This is to support future boards that support AVB but dont support
> USB and therefore dont support FASTBOOT.
>
> Signed-off-by: Usama Arif 
> Cc: Igor Opaniuk 
> ---
>  common/Kconfig  | 18 +-
>  common/avb_verify.c |  1 -
>  configs/am57xx_evm_defconfig|  2 ++
>  configs/am57xx_hs_evm_defconfig |  2 ++
>  configs/am57xx_hs_evm_usb_defconfig |  2 ++
>  include/avb_verify.h|  4 ++--
>  6 files changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/common/Kconfig b/common/Kconfig
> index 62d78c5bd7..bbacc33f80 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -986,7 +986,7 @@ config HASH
>
>  config AVB_VERIFY
> bool "Build Android Verified Boot operations"
> -   depends on LIBAVB && FASTBOOT
> +   depends on LIBAVB
> depends on PARTITION_UUIDS
> help
>   This option enables compilation of bootloader-dependent
> operations,
> @@ -995,6 +995,22 @@ config AVB_VERIFY
> * Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
> * Helpers to alloc/init/free avb ops.
>
> +if AVB_VERIFY
> +
> +config AVB_BUF_ADDR
> +   hex "Define AVB buffer address"
> +   help
> + AVB requires a buffer for memory transactions. This variable
> defines the
> + buffer address.
> +
> +config AVB_BUF_SIZE
> +   hex "Define AVB buffer SIZE"
> +   help
> + AVB requires a buffer for memory transactions. This variable
> defines the
> + buffer size.
> +
> +endif # AVB_VERIFY
> +
>  config SPL_HASH
> bool # "Support hashing API (SHA1, SHA256, etc.)"
> help
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index a2b739626b..db10d0f21f 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -7,7 +7,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
> index 2e6787a906..41cd76d198 100644
> --- a/configs/am57xx_evm_defconfig
> +++ b/configs/am57xx_evm_defconfig
> @@ -28,6 +28,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_VERSION_VARIABLE=y
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_AVB_VERIFY=y
> +CONFIG_AVB_BUF_ADDR=0x8200
> +CONFIG_AVB_BUF_SIZE=0x2F00
>  CONFIG_ANDROID_AB=y
>  CONFIG_SPL_SYS_MALLOC_SIMPLE=y
>  CONFIG_SPL_SEPARATE_BSS=y
> diff --git a/configs/am57xx_hs_evm_defconfig
> b/configs/am57xx_hs_evm_defconfig
> index 808bd2881e..9505549439 100644
> --- a/configs/am57xx_hs_evm_defconfig
> +++ b/configs/am57xx_hs_evm_defconfig
> @@ -33,6 +33,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_VERSION_VARIABLE=y
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_AVB_VERIFY=y
> +CONFIG_AVB_BUF_ADDR=0x8200
> +CONFIG_AVB_BUF_SIZE=0x2F00
>  CONFIG_ANDROID_AB=y
>  CONFIG_SPL_SYS_MALLOC_SIMPLE=y
>  CONFIG_SPL_SEPARATE_BSS=y
> diff --git a/configs/am57xx_hs_evm_usb_defconfig
> b/configs/am57xx_hs_evm_usb_defconfig
> index 8698b7c8b5..73df983e2d 100644
> --- a/configs/am57xx_hs_evm_usb_defconfig
> +++ b/configs/am57xx_hs_evm_usb_defconfig
> @@ -35,6 +35,8 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
>  CONFIG_VERSION_VARIABLE=y
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_AVB_VERIFY=y
> +CONFIG_AVB_BUF_ADDR=0x8200
> +CONFIG_AVB_BUF_SIZE=0x2F00
>  CONFIG_ANDROID_AB=y
>  CONFIG_SPL_SYS_MALLOC_SIMPLE=y
>  CONFIG_SPL_SEPARATE_BSS=y
> diff --git a/include/avb_verify.h b/include/avb_verify.h
> index a8d7090f79..1e787ba666 100644
> --- a/include/avb_verify.h
> +++ b/include/avb_verify.h
> @@ -72,12 +72,12 @@ static inline uint64_t calc_offset(struct mmc_part
> *part, int64_t offset)
>
>  static inline size_t get_sector_buf_size(void)
>  {
> -   return (size_t)CONFIG_FASTBOOT_BUF_SIZE;
> +   return (size_t)CONFIG_AVB_BUF_SIZE;
>  }
>
>  static inline void *get_sector_buf(void)
>  {
> -   return map_sysmem(CONFIG_FASTBOOT_BUF_ADDR,
> CONFIG_FASTBOOT_BUF_SIZE);
> +   return map_sysmem(CONFIG_AVB_BUF_ADDR, CONFIG_AVB_BUF_SIZE);
>  }
>
>  static inline bool is_buf_unaligned(void *buffer)
> --
> 2.17.1A


Acked-by: Igor Opaniuk 


Re: [PATCH v3] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 04:12:53PM +0100, Usama Arif wrote:

> Total Compute is based on ARM architecture and has
> the following features enabled in u-boot:
> - PL011 UART
> - PL180 MMC
> - NOR Flash
> - FIT image with Signature
> - AVB
> 
> Signed-off-by: Usama Arif 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 0/2] fs/squashfs: Add new decompression algorithms

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 05:13:06PM +0200, Joao Marcos Costa wrote:
> On Tue, 11 Aug 2020 11:13:41 -0400
> Tom Rini  wrote:
> 
> > On Tue, Aug 11, 2020 at 03:17:53PM +0200, Joao Marcos Costa wrote:
> > 
> > > Hello,
> > > 
> > > Following the SquashFS support, this series adds support for LZO
> > > and ZSTD algorithms. The only compression type enabled by default
> > > is ZLIB, so LZO and ZSTD need to be manually selected.
> > > 
> > > Joao Marcos Costa (2):
> > >   fs/squashfs: add support for LZO decompression
> > >   fs/squashfs: add support for ZSTD decompression
> > > 
> > >  fs/squashfs/sqfs_decompressor.c | 60
> > > +++-- 1 file changed, 58 insertions(+),
> > > 2 deletions(-)  
> > 
> > Can we add tests for this to sandbox?  Thanks!
> > 
> 
> Hello,
> 
> Is there any way to check the package version with the python API? I
> already use 'requiredtool' marker, but apparently it is not enough. My
> host machine (Ubuntu 18.04) has mksquashfs at its version 4.3, without
> zstd support. However, v4.4 has such support, and I had to download it
> and build it myself to use zstd compression. The tests will fail if the
> user has an older version of mksquashfs installed. Would you have any
> suggestion on how to proceed?

This sounds like the cases where we have to build the tools we need.
There's an example in .travis.yml for QEMU already, and we use
https://gitlab.denx.de/u-boot/gitlab-ci-runner/ for Azure/GitLab.
Testing those with your own container does require setting up an Azure
account or using your own GitLab + runner.

That said, if you unit test things and are confident it won't blow up
when I test it, that can be good enough.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v3] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Usama Arif
Total Compute is based on ARM architecture and has
the following features enabled in u-boot:
- PL011 UART
- PL180 MMC
- NOR Flash
- FIT image with Signature
- AVB

Signed-off-by: Usama Arif 
---
Changes for v2:
 - Added arch/arm/dts/total_compute.dts to 
board/armltd/total_compute/MAINTAINERS
 - Added bootm_size of 512 MB for total compute board. 

Changes for v3:
 - Removed fdt_high and initrd_high to allow relocation

 arch/arm/Kconfig   | 11 +++
 arch/arm/dts/Makefile  |  2 +
 arch/arm/dts/total_compute.dts | 48 
 arch/arm/include/asm/gpio.h|  2 +-
 board/armltd/total_compute/Kconfig | 12 +++
 board/armltd/total_compute/MAINTAINERS |  7 ++
 board/armltd/total_compute/Makefile|  6 ++
 board/armltd/total_compute/total_compute.c | 67 
 configs/total_compute_defconfig| 53 +
 include/configs/total_compute.h| 89 ++
 10 files changed, 296 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/total_compute.dts
 create mode 100644 board/armltd/total_compute/Kconfig
 create mode 100644 board/armltd/total_compute/MAINTAINERS
 create mode 100644 board/armltd/total_compute/Makefile
 create mode 100644 board/armltd/total_compute/total_compute.c
 create mode 100644 configs/total_compute_defconfig
 create mode 100644 include/configs/total_compute.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6b8a32c38d..20ae4af9c2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1195,6 +1195,15 @@ config TARGET_VEXPRESS64_JUNO
select USB
select DM_USB
 
+config TARGET_TOTAL_COMPUTE
+   bool "Support Total Compute Platform"
+   select ARM64
+   select PL01X_SERIAL
+   select DM
+   select DM_SERIAL
+   select DM_MMC
+   select DM_GPIO
+
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
select ARCH_LS2080A
@@ -1893,6 +1902,8 @@ source "arch/arm/mach-imx/Kconfig"
 
 source "arch/arm/mach-nexell/Kconfig"
 
+source "board/armltd/total_compute/Kconfig"
+
 source "board/bosch/shc/Kconfig"
 source "board/bosch/guardian/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8ecf63e988..5fc0840c5a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -978,6 +978,8 @@ dtb-$(CONFIG_TARGET_VEXPRESS_CA5X2) += vexpress-v2p-ca5s.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA9X4) += vexpress-v2p-ca9.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA15_TC2) += vexpress-v2p-ca15_a7.dtb
 
+dtb-$(CONFIG_TARGET_TOTAL_COMPUTE) += total_compute.dtb
+
 dtb-$(CONFIG_TARGET_DURIAN) += phytium-durian.dtb
 
 dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
diff --git a/arch/arm/dts/total_compute.dts b/arch/arm/dts/total_compute.dts
new file mode 100644
index 00..4399269a44
--- /dev/null
+++ b/arch/arm/dts/total_compute.dts
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 Arm Limited
+ */
+
+/dts-v1/;
+
+/ {
+   model = "total_compute";
+   compatible = "arm,total_compute";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   sysreg: sysreg@1c01 {
+   compatible = "arm,vexpress-sysreg";
+   reg = <0x0 0x001c01 0x0 0x1000>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   fixed_3v3: v2m-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   mmci@1c05 {
+   compatible = "arm,pl180", "arm,primecell";
+   reg = <0x0 0x001c05 0x0 0x1000>;
+   cd-gpios = < 0 0>;
+   arm,primecell-periphid = <0x00880180>;
+   wp-gpios = < 1 0>;
+   bus-width = <8>;
+   max-frequency = <1200>;
+   vmmc-supply = <_3v3>;
+   clocks = <>, <>;
+   clock-names = "mclk", "apb_pclk";
+   };
+
+   clock24mhz: clock24mhz {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2400>;
+   clock-output-names = "bp:clock24mhz";
+   };
+};
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
index 7dc87afb83..6ecb876eda 100644
--- a/arch/arm/include/asm/gpio.h
+++ b/arch/arm/include/asm/gpio.h
@@ -3,7 +3,7 @@
!defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \
!defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \
!defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) && \
-   !defined(CONFIG_TARGET_BCMNS3)
+   !defined(CONFIG_TARGET_BCMNS3) && !defined(CONFIG_TARGET_TOTAL_COMPUTE)
 #include 
 #endif
 #include 
diff --git 

Re: [PATCH 0/2] fs/squashfs: Add new decompression algorithms

2020-08-12 Thread Joao Marcos Costa
On Tue, 11 Aug 2020 11:13:41 -0400
Tom Rini  wrote:

> On Tue, Aug 11, 2020 at 03:17:53PM +0200, Joao Marcos Costa wrote:
> 
> > Hello,
> > 
> > Following the SquashFS support, this series adds support for LZO
> > and ZSTD algorithms. The only compression type enabled by default
> > is ZLIB, so LZO and ZSTD need to be manually selected.
> > 
> > Joao Marcos Costa (2):
> >   fs/squashfs: add support for LZO decompression
> >   fs/squashfs: add support for ZSTD decompression
> > 
> >  fs/squashfs/sqfs_decompressor.c | 60
> > +++-- 1 file changed, 58 insertions(+),
> > 2 deletions(-)  
> 
> Can we add tests for this to sandbox?  Thanks!
> 

Hello,

Is there any way to check the package version with the python API? I
already use 'requiredtool' marker, but apparently it is not enough. My
host machine (Ubuntu 18.04) has mksquashfs at its version 4.3, without
zstd support. However, v4.4 has such support, and I had to download it
and build it myself to use zstd compression. The tests will fail if the
user has an older version of mksquashfs installed. Would you have any
suggestion on how to proceed?

Best regards,
Joao


Re: [PATCH v2] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Usama Arif




On 12/08/2020 15:53, Tom Rini wrote:

On Wed, Aug 12, 2020 at 03:08:14PM +0100, Usama Arif wrote:

Total Compute is based on ARM architecture and has
the following features enabled in u-boot:
- PL011 UART
- PL180 MMC
- NOR Flash
- FIT image with Signature
- AVB

Signed-off-by: Usama Arif 
---
Changes for v2:
  - Added arch/arm/dts/total_compute.dts to 
board/armltd/total_compute/MAINTAINERS
  - Added bootm_size of 512 MB for total compute board.

[snip]

+#define CONFIG_EXTRA_ENV_SETTINGS  \
+   "bootm_size=0x2000\0" \
+   "load_addr=0xa000\0"  \
+   "kernel_addr_r=0x8008\0"  \
+   "initrd_addr_r=0x8800\0"  \
+   "fdt_addr_r=0x8300\0" \
+   "fdt_high=0x\0"   \
+   "initrd_high=0x\0"


You need to drop fdt_high/initrd_high too as that's disabling relocation
and that is almost never the right choice.  Thanks!



Removed fdt_high and initrd_high in v3 to allow relocation. Thanks again 
for the review.


Usama


[PATCH] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Usama Arif
Total Compute is based on ARM architecture and has
the following features enabled in u-boot:
- PL011 UART
- PL180 MMC
- NOR Flash
- FIT image with Signature
- AVB

Signed-off-by: Usama Arif 
---
Changes for v2:
 - Added arch/arm/dts/total_compute.dts to 
board/armltd/total_compute/MAINTAINERS
 - Added bootm_size of 512 MB for total compute board. 

Changes for v3:
 - Removed fdt_high and initrd_high to allow relocation

 arch/arm/Kconfig   | 11 +++
 arch/arm/dts/Makefile  |  2 +
 arch/arm/dts/total_compute.dts | 48 
 arch/arm/include/asm/gpio.h|  2 +-
 board/armltd/total_compute/Kconfig | 12 +++
 board/armltd/total_compute/MAINTAINERS |  7 ++
 board/armltd/total_compute/Makefile|  6 ++
 board/armltd/total_compute/total_compute.c | 67 
 configs/total_compute_defconfig| 53 +
 include/configs/total_compute.h| 89 ++
 10 files changed, 296 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/total_compute.dts
 create mode 100644 board/armltd/total_compute/Kconfig
 create mode 100644 board/armltd/total_compute/MAINTAINERS
 create mode 100644 board/armltd/total_compute/Makefile
 create mode 100644 board/armltd/total_compute/total_compute.c
 create mode 100644 configs/total_compute_defconfig
 create mode 100644 include/configs/total_compute.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6b8a32c38d..20ae4af9c2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1195,6 +1195,15 @@ config TARGET_VEXPRESS64_JUNO
select USB
select DM_USB
 
+config TARGET_TOTAL_COMPUTE
+   bool "Support Total Compute Platform"
+   select ARM64
+   select PL01X_SERIAL
+   select DM
+   select DM_SERIAL
+   select DM_MMC
+   select DM_GPIO
+
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
select ARCH_LS2080A
@@ -1893,6 +1902,8 @@ source "arch/arm/mach-imx/Kconfig"
 
 source "arch/arm/mach-nexell/Kconfig"
 
+source "board/armltd/total_compute/Kconfig"
+
 source "board/bosch/shc/Kconfig"
 source "board/bosch/guardian/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8ecf63e988..5fc0840c5a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -978,6 +978,8 @@ dtb-$(CONFIG_TARGET_VEXPRESS_CA5X2) += vexpress-v2p-ca5s.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA9X4) += vexpress-v2p-ca9.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA15_TC2) += vexpress-v2p-ca15_a7.dtb
 
+dtb-$(CONFIG_TARGET_TOTAL_COMPUTE) += total_compute.dtb
+
 dtb-$(CONFIG_TARGET_DURIAN) += phytium-durian.dtb
 
 dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
diff --git a/arch/arm/dts/total_compute.dts b/arch/arm/dts/total_compute.dts
new file mode 100644
index 00..4399269a44
--- /dev/null
+++ b/arch/arm/dts/total_compute.dts
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 Arm Limited
+ */
+
+/dts-v1/;
+
+/ {
+   model = "total_compute";
+   compatible = "arm,total_compute";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   sysreg: sysreg@1c01 {
+   compatible = "arm,vexpress-sysreg";
+   reg = <0x0 0x001c01 0x0 0x1000>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   fixed_3v3: v2m-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   mmci@1c05 {
+   compatible = "arm,pl180", "arm,primecell";
+   reg = <0x0 0x001c05 0x0 0x1000>;
+   cd-gpios = < 0 0>;
+   arm,primecell-periphid = <0x00880180>;
+   wp-gpios = < 1 0>;
+   bus-width = <8>;
+   max-frequency = <1200>;
+   vmmc-supply = <_3v3>;
+   clocks = <>, <>;
+   clock-names = "mclk", "apb_pclk";
+   };
+
+   clock24mhz: clock24mhz {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2400>;
+   clock-output-names = "bp:clock24mhz";
+   };
+};
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
index 7dc87afb83..6ecb876eda 100644
--- a/arch/arm/include/asm/gpio.h
+++ b/arch/arm/include/asm/gpio.h
@@ -3,7 +3,7 @@
!defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \
!defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \
!defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) && \
-   !defined(CONFIG_TARGET_BCMNS3)
+   !defined(CONFIG_TARGET_BCMNS3) && !defined(CONFIG_TARGET_TOTAL_COMPUTE)
 #include 
 #endif
 #include 
diff --git 

Re: [PATCH v2] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 03:08:14PM +0100, Usama Arif wrote:
> Total Compute is based on ARM architecture and has
> the following features enabled in u-boot:
> - PL011 UART
> - PL180 MMC
> - NOR Flash
> - FIT image with Signature
> - AVB
> 
> Signed-off-by: Usama Arif 
> ---
> Changes for v2:
>  - Added arch/arm/dts/total_compute.dts to 
> board/armltd/total_compute/MAINTAINERS
>  - Added bootm_size of 512 MB for total compute board.
[snip]
> +#define CONFIG_EXTRA_ENV_SETTINGS\
> + "bootm_size=0x2000\0"   \
> + "load_addr=0xa000\0"\
> + "kernel_addr_r=0x8008\0"\
> + "initrd_addr_r=0x8800\0"\
> + "fdt_addr_r=0x8300\0"   \
> + "fdt_high=0x\0" \
> + "initrd_high=0x\0"

You need to drop fdt_high/initrd_high too as that's disabling relocation
and that is almost never the right choice.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] avb: Make AVB independent of fastboot

2020-08-12 Thread Tom Rini
On Tue, Aug 11, 2020 at 03:46:03PM +0100, Usama Arif wrote:

> AVB only uses CONFIG_FASTBOOT_BUF_ADDR from fastboot for memory.
> This memory is used for assigning temporary buffers.
> This can be assigned a new variable and used as CONFIG_AVB_BUF_ADDR.
> This is to support future boards that support AVB but dont support
> USB and therefore dont support FASTBOOT.
> 
> Signed-off-by: Usama Arif 
> Cc: Igor Opaniuk 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL v2] TI changes for v2020.10-rc3

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 08:02:45AM +0530, Lokesh Vutla wrote:

> Hi Tom,
>   Please find the pull request for v2020.10-rc3 containing TI specific
> changes. This should have been sent for rc2 but delayed due to some
> comments in the last minute. Please look at the PR description for the
> details on the PR. Also tag message is updated with details.
> 
> Changes since v1:
> - Dropped an invalid commit
> - Updated Tag message
> 
> Travis-CI build: 
> https://travis-ci.org/github/lokeshvutla/u-boot/builds/716955604
> 
> The following changes since commit c045207f96f7f7ae8c7f134a6010e636176b:
> 
>   Prepare v2020.10-rc2 (2020-08-10 16:10:09 -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-ti.git tags/ti-v2020.10-rc3
> 
> for you to fetch changes up to db6451ec0e8483f76f3364293d48e86249c52322:
> 
>   arm: dts: k3-j7200-common-proc-board: Enable CPSW2G port (2020-08-11 
> 20:34:46 +0530)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Tom Rini
On Tue, Aug 11, 2020 at 05:19:54PM +0200, Frank Wunderlich wrote:

> From: Frank Wunderlich 
> 
> every compilation shows this error
> 
>  Hack for sunxi which doesn't have a proper binman definition for
>  64-bit boards
> 
> not only for sunxi-boards/arm64
> 
> fix this by changing to real comments
> 
> Fixes: 9f55ee259d0c ("Makefile: sunxi: Don't use binman to build ATF image")
> Signed-off-by: Frank Wunderlich 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Daniel Schwierzeck
Am Mittwoch, den 12.08.2020, 09:44 +0200 schrieb Stefan Roese:
> Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") &
> commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"),
> CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default).
> It makes no sense to still carry code that is guarded with
> "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes
> all these unreferenced code paths.
> 
> Also complete remove bi_memstart & bi_memsize from the board-info
> struct. As now bi_dram[] is always enabled and should be used instead.
> This removes the redundant varriables.
> 
> Signed-off-by: Stefan Roese 
> Cc: Daniel Schwierzeck 
> Cc: Tom Rini 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Michal Simek 
> Cc: Pali Rohár 
> ---
> v3:
> - Rebase on TOT
> - Add check to not overwrite bi_dram[0] if already configured in
>   setup_bdinfo(). This fixes the test issue with Nokia RX51.
> 
> Azure test report success:
> https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26=results
>   
> v2:
> - Change all references to bi_memstart & bi_memsize to bi_dram[0].start/
>   size and remove it from the bd_info struct completely, as suggested by
>   Daniel
> 
>  api/api_platform-mips.c   |  4 ++--
>  api/api_platform-powerpc.c|  2 +-
>  arch/mips/lib/boot.c  |  2 +-
>  arch/mips/lib/bootm.c |  2 +-
>  arch/powerpc/cpu/mpc83xx/fdt.c|  2 +-
>  arch/powerpc/cpu/mpc83xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc85xx/fdt.c|  4 ++--
>  arch/powerpc/cpu/mpc85xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc86xx/fdt.c|  2 +-
>  arch/powerpc/cpu/mpc86xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc8xx/fdt.c |  2 +-
>  arch/powerpc/lib/bootm.c  |  4 ++--
>  arch/x86/cpu/broadwell/cpu_from_spl.c |  2 --
>  arch/xtensa/lib/bdinfo.c  |  4 ++--
>  arch/xtensa/lib/bootm.c   |  4 ++--
>  board/Arcturus/ucp1020/spl.c  |  4 ++--
>  board/freescale/p1010rdb/spl.c|  4 ++--
>  board/freescale/p1_p2_rdb_pc/spl.c|  4 ++--
>  board/freescale/t102xrdb/spl.c|  4 ++--
>  board/freescale/t104xrdb/spl.c|  4 ++--
>  board/freescale/t208xqds/spl.c|  4 ++--
>  board/freescale/t208xrdb/spl.c|  4 ++--
>  board/freescale/t4rdb/spl.c   |  4 ++--
>  board/xilinx/zynqmp/zynqmp.c  |  2 --
>  cmd/bdinfo.c  |  6 ++---
>  cmd/bedbug.c  |  2 +-
>  common/board_f.c  | 13 +--
>  common/image.c| 10 +---
>  common/init/handoff.c | 33 +++
>  drivers/pci/pci-uclass.c  | 17 +-
>  drivers/video/cfb_console.c   |  8 +--
>  include/asm-generic/u-boot.h  |  4 
>  include/handoff.h |  2 --
>  lib/fdtdec.c  |  5 
>  lib/lmb.c |  7 --
>  35 files changed, 60 insertions(+), 121 deletions(-)
> 
> diff --git a/api/api_platform-mips.c b/api/api_platform-mips.c
> index 51cd328b3d..f1721cef19 100644
> --- a/api/api_platform-mips.c
> +++ b/api/api_platform-mips.c
> @@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
>  int platform_sys_info(struct sys_info *si)
>  {
>  
> - platform_set_mr(si, gd->bd->bi_memstart,
> - gd->bd->bi_memsize, MR_ATTR_DRAM);
> + platform_set_mr(si, gd->bd->bi_dram[0].start,
> + gd->bd->bi_dram[0].size, MR_ATTR_DRAM);
>  
>   return 1;
>  }
> diff --git a/api/api_platform-powerpc.c b/api/api_platform-powerpc.c
> index 15930cfdb6..8fff6e4cae 100644
> --- a/api/api_platform-powerpc.c
> +++ b/api/api_platform-powerpc.c
> @@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si)
>   si->bar = 0;
>  #endif
>  
> - platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, 
> MR_ATTR_DRAM);
> + platform_set_mr(si, gd->bd->bi_dram[0].start, gd->bd->bi_dram[0].size, 
> MR_ATTR_DRAM);
>   platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, 
> MR_ATTR_FLASH);
>   platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, 
> MR_ATTR_SRAM);
>  
> diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c
> index db862f6379..3b960691c5 100644
> --- a/arch/mips/lib/boot.c
> +++ b/arch/mips/lib/boot.c
> @@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const 
> []),
>* whole SDRAM area, since we don't know the size of the image
>* that was loaded.
>*/
> - flush_cache(gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart);
> + flush_cache(gd->bd->bi_dram[0].start, gd->ram_top - 
> gd->bd->bi_dram[0].start);
>  
>   return entry(argc, argv);
>  }
> diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
> index 0a13f6edb7..b3ef15963e 100644
> --- a/arch/mips/lib/bootm.c
> +++ b/arch/mips/lib/bootm.c
> @@ -242,7 +242,7 @@ static int 

Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Daniel Schwierzeck
Am Mittwoch, den 12.08.2020, 14:37 +0200 schrieb Pali Rohár:
> Hello!
> 
> > > > diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
> > > > index 0a13f6edb7..b3ef15963e 100644
> > > > --- a/arch/mips/lib/bootm.c
> > > > +++ b/arch/mips/lib/bootm.c
> > > > @@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
> > > >   #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
> > > >   int arch_fixup_fdt(void *blob)
> > > >   {
> > > > -   u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
> > > > +   u64 mem_start = virt_to_phys((void *)gd->bd->bi_dram[0].start);
> > > > u64 mem_size = gd->ram_size;
> > > 
> > > I do not fully understand this change. Why on some places you are suing
> > > bi_dram[0].size and on some places gd->ram_size?
> > 
> > This patch is mainly a search and replace
> > s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is
> > not always
> > correct.
> 
> Yes, this search+replace needs to be better reviewed and tested. Such
> big change has potential to break random stuff which nobody think about.
> 
> > > > @@ -607,8 +603,11 @@ int setup_bdinfo(void)
> > > >   {
> > > > struct bd_info *bd = gd->bd;
> > > > -   bd->bi_memstart = gd->ram_base;  /* start of memory */
> > > > -   bd->bi_memsize = gd->ram_size;   /* size in bytes */
> > > > +   /* Only overwrite bi_dram[0] values if not already set */
> > > > +   if (!bd->bi_dram[0].size) {
> > > 
> > > This still look suspicious. When is bi_dram[0].size zero? I tried to
> > > trace source code. dram_init_banksize() is always called before
> > > setup_bdinfo() which fills bi_dram[], so when can be dram size zero?
> > > Or I'm missing something?
> > 
> > dram_init_banksize() is always called earlier, yes. But its weak default
> > only sets the bi_dram[] values when CONFIG_SYS_SDRAM_BASE is configured.
> > I'm checking right now, if this might be a problem.
> 
> Should not be in this case extended dram_init_banksize() to always
> properly fill bi_dram[] structure? Setting bi_dram[] on more places and
> doing overwriting could complicate things for future debugging or
> extending.

for all users of bi_memstart/bi_memsize the search+replace should be
enough. But in setup_bdinfo() it is wrong because it overrides the
initialization done in dram_init_banksize(). But setup_bdinfo() is a
new function due to some other bd_info refactoring merged two weeks ago
and was not available in v2 of this patch. I guess N900 was still
working with v2 and v3 now has this kind of merge conflict regression. 

Just removing those lines without replacing with bi_dram should fix
this:

bd->bi_memstart = gd->ram_base;  /* start of memory */
bd->bi_memsize = gd->ram_size;   /* size in bytes */


BTW: looking deeper in the code and history I think bd_info.bi_dram is
heavily misused as storage for DRAM configuration. Such information
should be stored in global_data where generic code can access it if
needed (e.g. LMB, fdt_fixup_memory_banks()). bd_info should just be
initialized and used when needed to boot old kernels. Also there should
be a Kconfig option to completely disable the support of bd_info.

-- 
- Daniel



Re: [PATCH 2/2] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Usama Arif




On 12/08/2020 13:40, Tom Rini wrote:

On Tue, Aug 11, 2020 at 03:46:04PM +0100, Usama Arif wrote:


Total Compute is based on ARM architecture and has
the following features enabled in u-boot:
- PL011 UART
- PL180 MMC
- NOR Flash
- FIT image with Signature
- AVB

Signed-off-by: Usama Arif 

[snip]

diff --git a/board/armltd/total_compute/MAINTAINERS 
b/board/armltd/total_compute/MAINTAINERS
new file mode 100644
index 00..7c653d469a
--- /dev/null
+++ b/board/armltd/total_compute/MAINTAINERS
@@ -0,0 +1,6 @@
+TOTAL_COMPUTE BOARD
+M: Usama Arif 
+S: Maintained
+F: board/armltd/total_compute/
+F: include/configs/total_compute.h
+F: configs/total_compute_defconfig


Please list the dtb files as well here.


+#define CONFIG_EXTRA_ENV_SETTINGS  \
+   "load_addr=0xa000\0"  \
+   "kernel_addr_r=0x8008\0"  \
+   "initrd_addr_r=0x8800\0"  \
+   "fdt_addr_r=0x8300\0" \
+   "fdt_high=0x\0"   \
+   "initrd_high=0x\0"
+


Disabling fdt/initrd relocation is wrong.  Please set bootm_size as
needed if fdt/initrd need to be relocated to within a window of memory
rather than all available.  Thanks!



Hi,

Thanks for the review.

I have submitted a v2 version of the patch with 
arch/arm/dts/total_compute.dts addded to 
board/armltd/total_compute/MAINTAINERS and a bootm_size of 512 MB.


Thanks,
Usama


[PATCH v2] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Usama Arif
Total Compute is based on ARM architecture and has
the following features enabled in u-boot:
- PL011 UART
- PL180 MMC
- NOR Flash
- FIT image with Signature
- AVB

Signed-off-by: Usama Arif 
---
Changes for v2:
 - Added arch/arm/dts/total_compute.dts to 
board/armltd/total_compute/MAINTAINERS
 - Added bootm_size of 512 MB for total compute board.

 arch/arm/Kconfig   | 11 +++
 arch/arm/dts/Makefile  |  2 +
 arch/arm/dts/total_compute.dts | 48 +++
 arch/arm/include/asm/gpio.h|  2 +-
 board/armltd/total_compute/Kconfig | 12 +++
 board/armltd/total_compute/MAINTAINERS |  7 ++
 board/armltd/total_compute/Makefile|  6 ++
 board/armltd/total_compute/total_compute.c | 67 
 configs/total_compute_defconfig| 53 +
 include/configs/total_compute.h| 92 ++
 10 files changed, 299 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/total_compute.dts
 create mode 100644 board/armltd/total_compute/Kconfig
 create mode 100644 board/armltd/total_compute/MAINTAINERS
 create mode 100644 board/armltd/total_compute/Makefile
 create mode 100644 board/armltd/total_compute/total_compute.c
 create mode 100644 configs/total_compute_defconfig
 create mode 100644 include/configs/total_compute.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6b8a32c38d..20ae4af9c2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1195,6 +1195,15 @@ config TARGET_VEXPRESS64_JUNO
select USB
select DM_USB
 
+config TARGET_TOTAL_COMPUTE
+   bool "Support Total Compute Platform"
+   select ARM64
+   select PL01X_SERIAL
+   select DM
+   select DM_SERIAL
+   select DM_MMC
+   select DM_GPIO
+
 config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
select ARCH_LS2080A
@@ -1893,6 +1902,8 @@ source "arch/arm/mach-imx/Kconfig"
 
 source "arch/arm/mach-nexell/Kconfig"
 
+source "board/armltd/total_compute/Kconfig"
+
 source "board/bosch/shc/Kconfig"
 source "board/bosch/guardian/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 8ecf63e988..5fc0840c5a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -978,6 +978,8 @@ dtb-$(CONFIG_TARGET_VEXPRESS_CA5X2) += vexpress-v2p-ca5s.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA9X4) += vexpress-v2p-ca9.dtb
 dtb-$(CONFIG_TARGET_VEXPRESS_CA15_TC2) += vexpress-v2p-ca15_a7.dtb
 
+dtb-$(CONFIG_TARGET_TOTAL_COMPUTE) += total_compute.dtb
+
 dtb-$(CONFIG_TARGET_DURIAN) += phytium-durian.dtb
 
 dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
diff --git a/arch/arm/dts/total_compute.dts b/arch/arm/dts/total_compute.dts
new file mode 100644
index 00..4399269a44
--- /dev/null
+++ b/arch/arm/dts/total_compute.dts
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 Arm Limited
+ */
+
+/dts-v1/;
+
+/ {
+   model = "total_compute";
+   compatible = "arm,total_compute";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   sysreg: sysreg@1c01 {
+   compatible = "arm,vexpress-sysreg";
+   reg = <0x0 0x001c01 0x0 0x1000>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   };
+
+   fixed_3v3: v2m-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   mmci@1c05 {
+   compatible = "arm,pl180", "arm,primecell";
+   reg = <0x0 0x001c05 0x0 0x1000>;
+   cd-gpios = < 0 0>;
+   arm,primecell-periphid = <0x00880180>;
+   wp-gpios = < 1 0>;
+   bus-width = <8>;
+   max-frequency = <1200>;
+   vmmc-supply = <_3v3>;
+   clocks = <>, <>;
+   clock-names = "mclk", "apb_pclk";
+   };
+
+   clock24mhz: clock24mhz {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <2400>;
+   clock-output-names = "bp:clock24mhz";
+   };
+};
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
index 7dc87afb83..6ecb876eda 100644
--- a/arch/arm/include/asm/gpio.h
+++ b/arch/arm/include/asm/gpio.h
@@ -3,7 +3,7 @@
!defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \
!defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \
!defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) && \
-   !defined(CONFIG_TARGET_BCMNS3)
+   !defined(CONFIG_TARGET_BCMNS3) && !defined(CONFIG_TARGET_TOTAL_COMPUTE)
 #include 
 #endif
 #include 
diff --git a/board/armltd/total_compute/Kconfig 
b/board/armltd/total_compute/Kconfig
new file mode 

Re: [PATCH v4 00/12] riscv: Add FPIOA and GPIO support for Kendryte K210

2020-08-12 Thread Sean Anderson


On 6/24/20 6:29 AM, Sean Anderson wrote:
> This patch series adds support for pinmuxing, gpios, and leds on the Kendyte
> K210.
> 
> This patch series was previously part of
> https://patchwork.ozlabs.org/project/uboot/list/?series=161576
> 
> This patch series depends on
> https://patchwork.ozlabs.org/project/uboot/list/?series=178480
> 
> Changes in v4:
> - Add sandbox dt-binding headers to MAINTAINERS
> - Add test for led behavior
> - Add test/dm/pinmux.c to patch
> - Move sandbox_* variables into a priv structure. This resets them to the
>   default state every time we re-probe.
> - Reformat documentation in dm/pinctrl.h
> 
> Changes in v3:
> - Add dt-bindings/pinctrl/sandbox-pinmux.h to patch
> 
> Changes in v2:
> - Add test for pinmuxing
> - Don't clear existing pinctrl settings on probe
> - Re-order GPIOs to match the defaults more closely
> - Rebase onto v13 of "riscv: Add Sipeed Maix support"
> - Rewrite FPIOA driver to use pinmux property
> - Support muxing the output enable signal for each function in the FPIOA
> - Support output and input inversion in the pinmux driver
> - Support pinmux property in pinctrl-generic
> 
> Sean Anderson (12):
>   pinctrl: Add pinmux property support to pinctrl-generic
>   pinctrl: Reformat documentation in dm/pinctrl.h
>   test: pinmux: Add test for pin muxing
>   pinctrl: Add support for Kendryte K210 FPIOA
>   gpio: sifive: Use generic reg read function
>   gpio: dw: Fix warnings about casting int to pointer
>   gpio: dw: Add a trailing underscore to generated name
>   gpio: dw: Return output value when direction is out
>   led: gpio: Default to using node name if label is absent
>   test: dm: Test for default led naming
>   riscv: Add pinmux and gpio bindings for Kendryte K210
>   riscv: Add FPIOA and GPIO support for Kendryte K210
> 
>  MAINTAINERS   |   3 +
>  arch/riscv/dts/k210-maix-bit.dts  | 104 +++
>  arch/riscv/dts/k210.dtsi  |  12 +
>  arch/sandbox/dts/test.dts |  47 +-
>  board/sipeed/maix/Kconfig |   9 +
>  doc/board/sipeed/maix.rst |  64 +-
>  .../pinctrl/kendryte,k210-fpioa.txt   | 102 +++
>  .../pinctrl/pinctrl-bindings.txt  |  65 +-
>  drivers/gpio/dwapb_gpio.c |  33 +-
>  drivers/gpio/sifive-gpio.c|   2 +-
>  drivers/led/led_gpio.c|   7 +-
>  drivers/pinctrl/Kconfig   |   1 +
>  drivers/pinctrl/Makefile  |   1 +
>  drivers/pinctrl/kendryte/Kconfig  |   7 +
>  drivers/pinctrl/kendryte/Makefile |   1 +
>  drivers/pinctrl/kendryte/pinctrl.c| 678 ++
>  drivers/pinctrl/kendryte/pinctrl.h|  70 ++
>  drivers/pinctrl/pinctrl-generic.c | 125 +++-
>  drivers/pinctrl/pinctrl-sandbox.c | 186 +++--
>  include/dm/pinctrl.h  | 360 +++---
>  include/dt-bindings/pinctrl/k210-pinctrl.h| 277 +++
>  include/dt-bindings/pinctrl/sandbox-pinmux.h  |  19 +
>  test/dm/Makefile  |   3 +
>  test/dm/led.c |   3 +-
>  test/dm/pinmux.c  |  57 ++
>  test/py/tests/test_pinmux.py  |  36 +-
>  26 files changed, 2027 insertions(+), 245 deletions(-)
>  create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt
>  create mode 100644 drivers/pinctrl/kendryte/Kconfig
>  create mode 100644 drivers/pinctrl/kendryte/Makefile
>  create mode 100644 drivers/pinctrl/kendryte/pinctrl.c
>  create mode 100644 drivers/pinctrl/kendryte/pinctrl.h
>  create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h
>  create mode 100644 include/dt-bindings/pinctrl/sandbox-pinmux.h
>  create mode 100644 test/dm/pinmux.c
> 

Rick can you put this in your rc3 PR? I think there are reviews for all
patches in this series.

--Sean


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Andrii Voloshyn
Hi Stefan,

 On Wed, 12 Aug 2020 15:57:31 +0300 Stefan Roese  wrote 

 > Hi Andrew, 
 >  
 > On 12.08.20 14:48, Andrii Voloshyn wrote: 
 > > Hi Stefan, 
 > > 
 > >  On Wed, 12 Aug 2020 15:08:41 +0300 Stefan Roese  wrote 
 > >  
 > > 
 > >   > Hi Andrew, 
 > >   > 
 > >   > On 12.08.20 14:04, Andrii Voloshyn wrote: 
 > >   > > Hi Stefan, 
 > >   > > 
 > >   > >   > Hi Andrew, 
 > >   > >   > 
 > >   > >   > (added Weijie to Cc) 
 > >   > >   > 
 > >   > >   > On 12.08.20 09:18, Andrii Voloshyn wrote: 
 > >   > >   > >Hi there, 
 > >   > >   > > 
 > >   > >   > >There is one issue, I experience with (U-Boot 2020.07) on 
 > > MT7628DAN, "reset" command issued in hush prompt 
 > >   > >   > >causes board to hang, until I do a power cycle. On the 
 > > other hand there is no such issue on mt7688 board. 
 > >   > >   > 
 > >   > >   > Do you see no further output? Or is it perhaps stuck at the DDR 
 > > init 
 > >   > >   > code in SPL? Can you please post the log (complete boot log with 
 > > reset 
 > >   > >   > command)? 
 > >   > > 
 > >   > > There is only "resetting..." printed, once the reset command is 
 > > executed. 
 > >   > 
 > >   > I see. Thanks. 
 > >   > 
 > >   > >  By the way, I am not using SPL loader. 
 > >   > 
 > >   > Why not? Did you give the version with SPL a try? Here most of the 
 > >   > lowlevel init stuff is executed. Something might be missing in the 
 > >   > general HW setup if its not used. 
 > > 
 > > Then I will need to flash two binaries, spl + uboot, right? 
 >  
 > Not really. The 2 images are generated automatically and combined into 
 > one image (u-boot-with-spl.bin) that needs to be flashed instead. The 
 > main pro of this SPL + U-Boot proper is that the resulting image is 
 > *much* smaller (because of the compression of the U-Boot proper) and 
 > therefore, booting is usually faster as well compared to the "old" 
 > non-SPL only image. 
 >  
 > In my case its ~250kByte (combined image) compared to ~600kByte. 
 >  
 > > In any case SPL is optional, at least it should be. :) on this hw. 
 >  
 > Yes, correct. But frankly, I have not tested without SPL for a few 
 > months now. Mainly because of the reasons I mentioned above. 
 >  
 
Just tried u-boot-with-spl.bin image, the result is the same reset command 
doesn't work :(
 
 > >   > 
 > >   > How are you running the non-SPL (main) U-Boot on your board? Do you 
 > >   > load it via an old U-Boot? Or is it configured for SPI flash usage 
 > >   > without SPL instead? 
 > > 
 > > I am running the way it was done prior to recent SPL changes. 
 > > SPI NOR flash  is mapped to 0x9c00 address, and that's what the text 
 > > base address is set to when SPL is disabled: 
 > > arch/mips/mach-mtmips/Konfig 
 >  
 > Okay. So you are flashing a non-SPL only image into SPI NOR and you are 
 > not loading it via some other bootloader. That is what I wanted to make 
 > sure of. 
 >  
 > > config SYS_TEXT_BASE 
 > >> ---default 0x9c00 if !SPL 
 > >> ---default 0x8020 if SPL 
 > > 
 > > Also, I'd like to note that all other functionality in the u-boot works 
 > > fine, booting of FIT images, other commands I use, 
 > > the only problem is with the reset command. 
 > > 
 > > When I trigger reset manually (writing to RSTCTL register), I get the same 
 > > behavior: 
 > > mw 0x1034 0x1 
 >  
 > I see. Again, I have no real clue, sorry. 

 Thank you for your help in any case. I've seen that Weijie made a lot of work 
for the chip, may be he will have some clue.

 >  
 > Thanks, 
 > Stefan 
 > 
Thanks,
Andrii



Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Stefan Roese

Hi Andrew,

On 12.08.20 14:48, Andrii Voloshyn wrote:

Hi Stefan,

 On Wed, 12 Aug 2020 15:08:41 +0300 Stefan Roese  wrote 

  > Hi Andrew,
  >
  > On 12.08.20 14:04, Andrii Voloshyn wrote:
  > > Hi Stefan,
  > >
  > >   > Hi Andrew,
  > >   >
  > >   > (added Weijie to Cc)
  > >   >
  > >   > On 12.08.20 09:18, Andrii Voloshyn wrote:
  > >   > >Hi there,
  > >   > >
  > >   > >There is one issue, I experience with (U-Boot 2020.07) on MT7628DAN, 
"reset" command issued in hush prompt
  > >   > >causes board to hang, until I do a power cycle. On the other 
hand there is no such issue on mt7688 board.
  > >   >
  > >   > Do you see no further output? Or is it perhaps stuck at the DDR init
  > >   > code in SPL? Can you please post the log (complete boot log with reset
  > >   > command)?
  > >
  > > There is only "resetting..." printed, once the reset command is executed.
  >
  > I see. Thanks.
  >
  > >  By the way, I am not using SPL loader.
  >
  > Why not? Did you give the version with SPL a try? Here most of the
  > lowlevel init stuff is executed. Something might be missing in the
  > general HW setup if its not used.

Then I will need to flash two binaries, spl + uboot, right?


Not really. The 2 images are generated automatically and combined into
one image (u-boot-with-spl.bin) that needs to be flashed instead. The
main pro of this SPL + U-Boot proper is that the resulting image is
*much* smaller (because of the compression of the U-Boot proper) and
therefore, booting is usually faster as well compared to the "old"
non-SPL only image.

In my case its ~250kByte (combined image) compared to ~600kByte.


In any case SPL is optional, at least it should be. :) on this hw.


Yes, correct. But frankly, I have not tested without SPL for a few
months now. Mainly because of the reasons I mentioned above.


  >
  > How are you running the non-SPL (main) U-Boot on your board? Do you
  > load it via an old U-Boot? Or is it configured for SPI flash usage
  > without SPL instead?

I am running the way it was done prior to recent SPL changes.
SPI NOR flash  is mapped to 0x9c00 address, and that's what the text base 
address is set to when SPL is disabled:
arch/mips/mach-mtmips/Konfig


Okay. So you are flashing a non-SPL only image into SPI NOR and you are
not loading it via some other bootloader. That is what I wanted to make
sure of.


config SYS_TEXT_BASE

---default 0x9c00 if !SPL
---default 0x8020 if SPL


Also, I'd like to note that all other functionality in the u-boot works fine, 
booting of FIT images, other commands I use,
the only problem is with the reset command.

When I trigger reset manually (writing to RSTCTL register), I get the same 
behavior:
mw 0x1034 0x1


I see. Again, I have no real clue, sorry.

Thanks,
Stefan


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Andrii Voloshyn
Hi Stefan,

 On Wed, 12 Aug 2020 15:08:41 +0300 Stefan Roese  wrote 

 > Hi Andrew, 
 >  
 > On 12.08.20 14:04, Andrii Voloshyn wrote: 
 > > Hi Stefan, 
 > > 
 > >   > Hi Andrew, 
 > >   > 
 > >   > (added Weijie to Cc) 
 > >   > 
 > >   > On 12.08.20 09:18, Andrii Voloshyn wrote: 
 > >   > >Hi there, 
 > >   > > 
 > >   > >There is one issue, I experience with (U-Boot 2020.07) on 
 > > MT7628DAN, "reset" command issued in hush prompt 
 > >   > >causes board to hang, until I do a power cycle. On the other hand 
 > > there is no such issue on mt7688 board. 
 > >   > 
 > >   > Do you see no further output? Or is it perhaps stuck at the DDR init 
 > >   > code in SPL? Can you please post the log (complete boot log with reset 
 > >   > command)? 
 > > 
 > > There is only "resetting..." printed, once the reset command is executed. 
 >  
 > I see. Thanks. 
 >  
 > >  By the way, I am not using SPL loader. 
 >  
 > Why not? Did you give the version with SPL a try? Here most of the 
 > lowlevel init stuff is executed. Something might be missing in the 
 > general HW setup if its not used.

   Then I will need to flash two binaries, spl + uboot, right?
In any case SPL is optional, at least it should be. :) on this hw.

 >  
 > How are you running the non-SPL (main) U-Boot on your board? Do you 
 > load it via an old U-Boot? Or is it configured for SPI flash usage 
 > without SPL instead? 

I am running the way it was done prior to recent SPL changes.
SPI NOR flash  is mapped to 0x9c00 address, and that's what the text base 
address is set to when SPL is disabled:
arch/mips/mach-mtmips/Konfig

config SYS_TEXT_BASE
>---default 0x9c00 if !SPL
>---default 0x8020 if SPL

Also, I'd like to note that all other functionality in the u-boot works fine, 
booting of FIT images, other commands I use,
the only problem is with the reset command.

When I trigger reset manually (writing to RSTCTL register), I get the same 
behavior:
mw 0x1034 0x1

 >  
 > > Console output below: 
 > > 
 > > U-Boot 2020.07 
 > > 
 > > CPU:   MediaTek MT7628A ver:1 eco:2 
 > > Boot:  DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL 
 > > Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz 
 > > Model: test 
 > > DRAM:  64 MiB 
 > > Loading Environment from SPI Flash... SF: Detected w25q256 with page size 
 > > 256 Bytes, erase size 4 KiB, total 32 MiB 
 > > OK 
 > > Net: 
 > > Warning: eth@1011 (eth0) using random MAC address - ba:f6:29:35:59:b5 
 > > eth0: eth@1011 
 > > Hit any key to stop autoboot:  0 
 > > => reset 
 > > resetting ... 
 >  
 > Thanks, 
 > Stefan 
 > 

Thanks.
Andrii


Re: [PATCH 2/2] board: armltd: Add support for Total Compute platform

2020-08-12 Thread Tom Rini
On Tue, Aug 11, 2020 at 03:46:04PM +0100, Usama Arif wrote:

> Total Compute is based on ARM architecture and has
> the following features enabled in u-boot:
> - PL011 UART
> - PL180 MMC
> - NOR Flash
> - FIT image with Signature
> - AVB
> 
> Signed-off-by: Usama Arif 
[snip]
> diff --git a/board/armltd/total_compute/MAINTAINERS 
> b/board/armltd/total_compute/MAINTAINERS
> new file mode 100644
> index 00..7c653d469a
> --- /dev/null
> +++ b/board/armltd/total_compute/MAINTAINERS
> @@ -0,0 +1,6 @@
> +TOTAL_COMPUTE BOARD
> +M:   Usama Arif 
> +S:   Maintained
> +F:   board/armltd/total_compute/
> +F:   include/configs/total_compute.h
> +F:   configs/total_compute_defconfig

Please list the dtb files as well here.

> +#define CONFIG_EXTRA_ENV_SETTINGS\
> + "load_addr=0xa000\0"\
> + "kernel_addr_r=0x8008\0"\
> + "initrd_addr_r=0x8800\0"\
> + "fdt_addr_r=0x8300\0"   \
> + "fdt_high=0x\0" \
> + "initrd_high=0x\0"
> +

Disabling fdt/initrd relocation is wrong.  Please set bootm_size as
needed if fdt/initrd need to be relocated to within a window of memory
rather than all available.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Pali Rohár
Hello!

> > > diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
> > > index 0a13f6edb7..b3ef15963e 100644
> > > --- a/arch/mips/lib/bootm.c
> > > +++ b/arch/mips/lib/bootm.c
> > > @@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
> > >   #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
> > >   int arch_fixup_fdt(void *blob)
> > >   {
> > > - u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
> > > + u64 mem_start = virt_to_phys((void *)gd->bd->bi_dram[0].start);
> > >   u64 mem_size = gd->ram_size;
> > 
> > I do not fully understand this change. Why on some places you are suing
> > bi_dram[0].size and on some places gd->ram_size?
> 
> This patch is mainly a search and replace
> s/bd->bi_memstart/bd->bi_dram[0].start. But as your test has shown, this is
> not always
> correct.

Yes, this search+replace needs to be better reviewed and tested. Such
big change has potential to break random stuff which nobody think about.

> > > @@ -607,8 +603,11 @@ int setup_bdinfo(void)
> > >   {
> > >   struct bd_info *bd = gd->bd;
> > > - bd->bi_memstart = gd->ram_base;  /* start of memory */
> > > - bd->bi_memsize = gd->ram_size;   /* size in bytes */
> > > + /* Only overwrite bi_dram[0] values if not already set */
> > > + if (!bd->bi_dram[0].size) {
> > 
> > This still look suspicious. When is bi_dram[0].size zero? I tried to
> > trace source code. dram_init_banksize() is always called before
> > setup_bdinfo() which fills bi_dram[], so when can be dram size zero?
> > Or I'm missing something?
> 
> dram_init_banksize() is always called earlier, yes. But its weak default
> only sets the bi_dram[] values when CONFIG_SYS_SDRAM_BASE is configured.
> I'm checking right now, if this might be a problem.

Should not be in this case extended dram_init_banksize() to always
properly fill bi_dram[] structure? Setting bi_dram[] on more places and
doing overwriting could complicate things for future debugging or
extending.

> > For me it looks like that this patch is mixing different structures for
> > ram size from different sources.
> 
> Again, it started as a "simple" search and replace. It seems, that I
> need to change this patch, so that the "correct" value is used in
> place of bi_memstart & bi_memsize instead of always using bi_dram[].
> 
> I'll rework this patch again.
> 
> > It is really correct? Does not it break
> > other boards?
> > 
> > I think that there is missing explanation of these changes.
> 
> Perhaps its also the patch history that you are missing. This patch
> started with a simple remove of the unreferenced CONFIG_NR_DRAM_BANKS
> code paths (as the patch subject still mentions). And its extended,
> after Daniel pointed out, that with the move of CONFIG_NR_DRAM_BANKS
> the usage of bi_memstart etc is now not 100% correct any more. He
> suggested to replace those references with bi_dram[].

I have not seen patch history, only its current version which caused
u-boot failure on n900. So I was not sure what is intension of this
patch. Sorry for that.

I think 1:1 replacement is not such trivial as with more dram banks you
would need to join address space from bi_dram[0], bi_dram[1], ... as
previous code is expecting.

I would suggest that more people with different hardware affected by
this change would test if everything is working fine.

I do not know how many boards have full boot test scenarios (from
booting u-boot to booting kernel) like N900 and such tests are useful
when playing with patches which changes such big parts.

I would suggest to other board maintainers to write or provides test
suite as it can really help with catching such fatal errors.

I cannot believe that N900 was the only device on which u-boot stopped
booting kernel. From that code it looks like that all OMAP3 devices must
have been affected and possible any architecture with two or more dram
banks.

> I agree that this is a bit confusing. I'll rework this patch into
> multiple separate patches now instead. This will hopefully make it
> easier to follow the intention and review these changes.

Lokesh, do you have OMAP3 devices to test these future Stefan's patches?
For me it looks like that OMAP3 is good candidate which can be affected
by these changes if code is not properly reviewed.


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Stefan Roese

Hi Andrew,

On 12.08.20 14:04, Andrii Voloshyn wrote:

Hi Stefan,

  > Hi Andrew,
  >
  > (added Weijie to Cc)
  >
  > On 12.08.20 09:18, Andrii Voloshyn wrote:
  > >Hi there,
  > >
  > >There is one issue, I experience with (U-Boot 2020.07) on MT7628DAN, 
"reset" command issued in hush prompt
  > >causes board to hang, until I do a power cycle. On the other hand 
there is no such issue on mt7688 board.
  >
  > Do you see no further output? Or is it perhaps stuck at the DDR init
  > code in SPL? Can you please post the log (complete boot log with reset
  > command)?

There is only "resetting..." printed, once the reset command is executed.


I see. Thanks.


 By the way, I am not using SPL loader.


Why not? Did you give the version with SPL a try? Here most of the
lowlevel init stuff is executed. Something might be missing in the
general HW setup if its not used.

How are you running the non-SPL (main) U-Boot on your board? Do you
load it via an old U-Boot? Or is it configured for SPI flash usage
without SPL instead?


Console output below:

U-Boot 2020.07

CPU:   MediaTek MT7628A ver:1 eco:2
Boot:  DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL
Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz
Model: test
DRAM:  64 MiB
Loading Environment from SPI Flash... SF: Detected w25q256 with page size 256 
Bytes, erase size 4 KiB, total 32 MiB
OK
Net:
Warning: eth@1011 (eth0) using random MAC address - ba:f6:29:35:59:b5
eth0: eth@1011
Hit any key to stop autoboot:  0
=> reset
resetting ...


Thanks,
Stefan


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Andrii Voloshyn
Hi Stefan,

 > Hi Andrew, 
 >  
 > (added Weijie to Cc) 
 >  
 > On 12.08.20 09:18, Andrii Voloshyn wrote: 
 > >Hi there, 
 > > 
 > >There is one issue, I experience with (U-Boot 2020.07) on MT7628DAN, 
 > > "reset" command issued in hush prompt 
 > >causes board to hang, until I do a power cycle. On the other hand there 
 > > is no such issue on mt7688 board. 
 >  
 > Do you see no further output? Or is it perhaps stuck at the DDR init 
 > code in SPL? Can you please post the log (complete boot log with reset 
 > command)?

There is only "resetting..." printed, once the reset command is executed.  By 
the way, I am not using SPL loader.
Console output below:

U-Boot 2020.07

CPU:   MediaTek MT7628A ver:1 eco:2
Boot:  DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL
Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz
Model: test
DRAM:  64 MiB
Loading Environment from SPI Flash... SF: Detected w25q256 with page size 256 
Bytes, erase size 4 KiB, total 32 MiB
OK
Net:   
Warning: eth@1011 (eth0) using random MAC address - ba:f6:29:35:59:b5
eth0: eth@1011
Hit any key to stop autoboot:  0 
=> reset
resetting ...


 >  
 > >What's interesting, is that "reboot" issued in Linux shell makes board 
 > > reboot as expected on mt7628 board. 
 > > 
 > >It seems like some sort of configuration issue, but I couldn't find 
 > > anything specific in the datasheet. Maybe 
 > >you have some idea what could cause it? 
 > > 
 > >One more thing, when running the following version of bootloader 
 > > (https://github.com/gnubee-git/GnuBee-MT76x8-uboot) 
 > >"reset" command works as expected. 
 >  
 > I do not have a MT7628 based board, so I can't test. Perhaps Weijie has 
 > an idea? 
 >  
 > Thanks, 
 > Stefan 
 > 
Thanks,
Andrew



Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 01:48:33PM +0200, Michal Simek wrote:
> 
> 
> On 12. 08. 20 13:41, Tom Rini wrote:
> > On Wed, Aug 12, 2020 at 09:59:15AM +0200, Michal Simek wrote:
> >> út 11. 8. 2020 v 17:33 odesílatel Tom Rini  napsal:
> >>>
> >>> On Tue, Aug 11, 2020 at 05:19:54PM +0200, Frank Wunderlich wrote:
> >>>
>  From: Frank Wunderlich 
> 
>  every compilation shows this error
> 
>   Hack for sunxi which doesn't have a proper binman definition for
>   64-bit boards
> 
>  not only for sunxi-boards/arm64
> 
>  fix this by changing to real comments
> 
>  Fixes: 9f55ee259d0c ("Makefile: sunxi: Don't use binman to build ATF 
>  image")
>  Signed-off-by: Frank Wunderlich 
>  ---
>   Makefile | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
>  diff --git a/Makefile b/Makefile
>  index 4483a9bc8a..75c2987405 100644
>  --- a/Makefile
>  +++ b/Makefile
>  @@ -1024,8 +1024,8 @@ PHONY += inputs
>   inputs: $(INPUTS-y)
> 
>   all: .binman_stamp inputs
>  - # Hack for sunxi which doesn't have a proper binman definition for
>  - # 64-bit boards
>  +# Hack for sunxi which doesn't have a proper binman definition for
>  +# 64-bit boards
>   ifneq ($(CONFIG_ARCH_SUNXI)$(CONFIG_ARM64),yy)
>   ifeq ($(CONFIG_BINMAN),y)
>    $(call if_changed,binman)
> >>>
> >>> Um, what environment is this failing on?  Thanks!
> >>
> >> I also see this message when I build stuff for zynqmp.
> > 
> > Interesting, are you also on make 4.2 ?
> 
> I am on 4.1.

Ugh.  I'll apply the patch shortly as clearly we need it.  But I don't
see why it's failing in some places and not others, which is worrying.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Michal Simek


On 12. 08. 20 13:41, Tom Rini wrote:
> On Wed, Aug 12, 2020 at 09:59:15AM +0200, Michal Simek wrote:
>> út 11. 8. 2020 v 17:33 odesílatel Tom Rini  napsal:
>>>
>>> On Tue, Aug 11, 2020 at 05:19:54PM +0200, Frank Wunderlich wrote:
>>>
 From: Frank Wunderlich 

 every compilation shows this error

  Hack for sunxi which doesn't have a proper binman definition for
  64-bit boards

 not only for sunxi-boards/arm64

 fix this by changing to real comments

 Fixes: 9f55ee259d0c ("Makefile: sunxi: Don't use binman to build ATF 
 image")
 Signed-off-by: Frank Wunderlich 
 ---
  Makefile | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/Makefile b/Makefile
 index 4483a9bc8a..75c2987405 100644
 --- a/Makefile
 +++ b/Makefile
 @@ -1024,8 +1024,8 @@ PHONY += inputs
  inputs: $(INPUTS-y)

  all: .binman_stamp inputs
 - # Hack for sunxi which doesn't have a proper binman definition for
 - # 64-bit boards
 +# Hack for sunxi which doesn't have a proper binman definition for
 +# 64-bit boards
  ifneq ($(CONFIG_ARCH_SUNXI)$(CONFIG_ARM64),yy)
  ifeq ($(CONFIG_BINMAN),y)
   $(call if_changed,binman)
>>>
>>> Um, what environment is this failing on?  Thanks!
>>
>> I also see this message when I build stuff for zynqmp.
> 
> Interesting, are you also on make 4.2 ?

I am on 4.1.

Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs




signature.asc
Description: OpenPGP digital signature


Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Tom Rini
On Wed, Aug 12, 2020 at 09:59:15AM +0200, Michal Simek wrote:
> út 11. 8. 2020 v 17:33 odesílatel Tom Rini  napsal:
> >
> > On Tue, Aug 11, 2020 at 05:19:54PM +0200, Frank Wunderlich wrote:
> >
> > > From: Frank Wunderlich 
> > >
> > > every compilation shows this error
> > >
> > >  Hack for sunxi which doesn't have a proper binman definition for
> > >  64-bit boards
> > >
> > > not only for sunxi-boards/arm64
> > >
> > > fix this by changing to real comments
> > >
> > > Fixes: 9f55ee259d0c ("Makefile: sunxi: Don't use binman to build ATF 
> > > image")
> > > Signed-off-by: Frank Wunderlich 
> > > ---
> > >  Makefile | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 4483a9bc8a..75c2987405 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1024,8 +1024,8 @@ PHONY += inputs
> > >  inputs: $(INPUTS-y)
> > >
> > >  all: .binman_stamp inputs
> > > - # Hack for sunxi which doesn't have a proper binman definition for
> > > - # 64-bit boards
> > > +# Hack for sunxi which doesn't have a proper binman definition for
> > > +# 64-bit boards
> > >  ifneq ($(CONFIG_ARCH_SUNXI)$(CONFIG_ARM64),yy)
> > >  ifeq ($(CONFIG_BINMAN),y)
> > >   $(call if_changed,binman)
> >
> > Um, what environment is this failing on?  Thanks!
> 
> I also see this message when I build stuff for zynqmp.

Interesting, are you also on make 4.2 ?

-- 
Tom


signature.asc
Description: PGP signature


Re: reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Stefan Roese

Hi Andrew,

(added Weijie to Cc)

On 12.08.20 09:18, Andrii Voloshyn wrote:

   Hi there,

   There is one issue, I experience with (U-Boot 2020.07) on MT7628DAN, "reset" command issued in hush prompt

   causes board to hang, until I do a power cycle. On the other hand there is 
no such issue on mt7688 board.


Do you see no further output? Or is it perhaps stuck at the DDR init
code in SPL? Can you please post the log (complete boot log with reset
command)?


   What's interesting, is that "reboot" issued in Linux shell makes board 
reboot as expected on mt7628 board.

   It seems like some sort of configuration issue, but I couldn't find anything specific in the datasheet. Maybe

   you have some idea what could cause it?

   One more thing, when running the following version of bootloader (https://github.com/gnubee-git/GnuBee-MT76x8-uboot)

   "reset" command works as expected.


I do not have a MT7628 based board, so I can't test. Perhaps Weijie has
an idea?

Thanks,
Stefan


reset command doesn't work on MT7628 (CPU: MediaTek MT7628A ver:1 eco:2)

2020-08-12 Thread Andrii Voloshyn
  Hi there, 
   
  There is one issue, I experience with (U-Boot 2020.07) on MT7628DAN, "reset" 
command issued in hush prompt 
  causes board to hang, until I do a power cycle. On the other hand there is no 
such issue on mt7688 board. 
  What's interesting, is that "reboot" issued in Linux shell makes board reboot 
as expected on mt7628 board. 
   
  It seems like some sort of configuration issue, but I couldn't find anything 
specific in the datasheet. Maybe 
  you have some idea what could cause it? 
   
  One more thing, when running the following version of bootloader 
(https://github.com/gnubee-git/GnuBee-MT76x8-uboot) 
  "reset" command works as expected. 
   
  Thank you for your help 
   
  Cheers, 
  Andrew  


[PATCH 4/4] xilinx: common: Change bootm_size variable setting

2020-08-12 Thread Michal Simek
Linux kernel for arm32 requires dtb and initrd to be placed in low memory
to work properly. This requirement is described in chapter 4b) and 5) in
Linux documentation (Documentation/arm/booting.rst).

There is an issue on arm32 with 2GB of memory that bootm_size is bigger
than Linux lowmem (for example with VMSPLIT_3G). That's why limit bootm
size on these systems not to be above 768MB.

Signed-off-by: Michal Simek 
---

 board/xilinx/common/board.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 581c88ad49a4..eab389d049f2 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -78,11 +78,15 @@ void *board_fdt_blob_setup(void)
 int board_late_init_xilinx(void)
 {
u32 ret = 0;
+   phys_size_t bootm_size = gd->ram_size;
+
+   if (CONFIG_IS_ENABLED(ARCH_ZYNQ))
+   bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
 
ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
 
ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
-   ret |= env_set_addr("bootm_size", (void *)gd->ram_size);
+   ret |= env_set_addr("bootm_size", (void *)bootm_size);
 
if (ret)
printf("%s: Saving run time variables FAILED\n", __func__);
-- 
2.28.0



[PATCH 2/4] xilinx: common: Get rid of initrd_high variable setup

2020-08-12 Thread Michal Simek
When bootm_low/bootm_size are setup properly there is no need to setup any
initrd_high address. Location for initrd is determined through LMB.

Signed-off-by: Michal Simek 
---

 board/xilinx/common/board.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 0782d08ee3fe..901591ba2a85 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -77,14 +77,8 @@ void *board_fdt_blob_setup(void)
 
 int board_late_init_xilinx(void)
 {
-   ulong initrd_hi;
-
env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
 
-   initrd_hi = gd->start_addr_sp - CONFIG_STACK_SIZE;
-   initrd_hi = round_down(initrd_hi, SZ_16M);
-   env_set_addr("initrd_high", (void *)initrd_hi);
-
env_set_addr("bootm_low", (void *)gd->ram_base);
env_set_addr("bootm_size", (void *)gd->ram_size);
 
-- 
2.28.0



[PATCH 3/4] xilinx: common: Check return value from variable setup

2020-08-12 Thread Michal Simek
env_set..() can failed that's why check return status and report it back to
make sure that user is aware that's something went wrong.

Signed-off-by: Michal Simek 
---

Change type to u32 to have defined bit operations (mentioned by Marek)
Origin patch sent as 
https://lists.denx.de/pipermail/u-boot/2020-August/422508.html
---
 board/xilinx/common/board.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 901591ba2a85..581c88ad49a4 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -77,10 +77,15 @@ void *board_fdt_blob_setup(void)
 
 int board_late_init_xilinx(void)
 {
-   env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
+   u32 ret = 0;
 
-   env_set_addr("bootm_low", (void *)gd->ram_base);
-   env_set_addr("bootm_size", (void *)gd->ram_size);
+   ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
+
+   ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
+   ret |= env_set_addr("bootm_size", (void *)gd->ram_size);
+
+   if (ret)
+   printf("%s: Saving run time variables FAILED\n", __func__);
 
return 0;
 }
-- 
2.28.0



[PATCH 0/4] xilinx: common: Fix fdt/initrd_high and bootm_* variables

2020-08-12 Thread Michal Simek
Hi,

this series is removing fdt/initrd_high variables and tune bootm_size run
time setup to match needs from Linux kernel.

Thanks,
Michal


Michal Simek (4):
  xilinx: common: Get rid of fdt_high variable
  xilinx: common: Get rid of initrd_high variable setup
  xilinx: common: Check return value from variable setup
  xilinx: common: Change bootm_size variable setting

 board/xilinx/common/board.c | 17 ++---
 include/configs/xilinx_versal.h |  1 -
 include/configs/xilinx_zynqmp.h |  1 -
 include/configs/zynq-common.h   |  1 -
 4 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.28.0



[PATCH 1/4] xilinx: common: Get rid of fdt_high variable

2020-08-12 Thread Michal Simek
There is no need to setup this variable if bootm_low and bootm_size
variable are properly setup. If fdt_high variable is missing U-Boot is
asking LMB to return free memory which is not used.

Signed-off-by: Michal Simek 
---

 include/configs/xilinx_versal.h | 1 -
 include/configs/xilinx_zynqmp.h | 1 -
 include/configs/zynq-common.h   | 1 -
 3 files changed, 3 deletions(-)

diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h
index 32cd5b21f7b7..d7255a05dff1 100644
--- a/include/configs/xilinx_versal.h
+++ b/include/configs/xilinx_versal.h
@@ -79,7 +79,6 @@
 #define CONFIG_CLOCKS
 
 #define ENV_MEM_LAYOUT_SETTINGS \
-   "fdt_high=1000\0" \
"fdt_addr_r=0x4000\0" \
"fdt_size_r=0x40\0" \
"pxefile_addr_r=0x1000\0" \
diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
index 7c24bf632e3f..15ad4198a6be 100644
--- a/include/configs/xilinx_zynqmp.h
+++ b/include/configs/xilinx_zynqmp.h
@@ -101,7 +101,6 @@
 #define CONFIG_CLOCKS
 
 #define ENV_MEM_LAYOUT_SETTINGS \
-   "fdt_high=1000\0" \
"fdt_addr_r=0x4000\0" \
"fdt_size_r=0x40\0" \
"pxefile_addr_r=0x1000\0" \
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 79c75784f2bf..1607a8d06518 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -196,7 +196,6 @@
 /* Default environment */
 #ifndef CONFIG_EXTRA_ENV_SETTINGS
 #define CONFIG_EXTRA_ENV_SETTINGS  \
-   "fdt_high=0x2000\0" \
"scriptaddr=0x2\0"  \
"script_size_f=0x4\0"   \
"fdt_addr_r=0x1f0\0"\
-- 
2.28.0



Re: [PATCH] xilinx: Check return value from variable setup

2020-08-12 Thread Michal Simek
st 5. 8. 2020 v 14:03 odesílatel Michal Simek  napsal:
>
> env_set..() can failed that's why check return status and report it back to
> make sure that user is aware that's something went wrong.
>
> Signed-off-by: Michal Simek 
> ---
>
>  board/xilinx/common/board.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
> index 0782d08ee3fe..0d6d0d29ac0f 100644
> --- a/board/xilinx/common/board.c
> +++ b/board/xilinx/common/board.c
> @@ -78,15 +78,19 @@ void *board_fdt_blob_setup(void)
>  int board_late_init_xilinx(void)
>  {
> ulong initrd_hi;
> +   int ret = 0;
>
> -   env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
> +   ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
>
> initrd_hi = gd->start_addr_sp - CONFIG_STACK_SIZE;
> initrd_hi = round_down(initrd_hi, SZ_16M);
> -   env_set_addr("initrd_high", (void *)initrd_hi);
> +   ret |= env_set_addr("initrd_high", (void *)initrd_hi);
>
> -   env_set_addr("bootm_low", (void *)gd->ram_base);
> -   env_set_addr("bootm_size", (void *)gd->ram_size);
> +   ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
> +   ret |= env_set_addr("bootm_size", (void *)gd->ram_size);
> +
> +   if (ret)
> +   printf("%s: Saving run time variables FAILED\n", __func__);
>
> return 0;
>  }
> --
> 2.27.0
>

Please ignore this patch. I will change this to be align with the latest work.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Stefan Roese

Hi Pali,

On 12.08.20 10:05, Pali Rohár wrote:

On Wednesday 12 August 2020 09:44:17 Stefan Roese wrote:

Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") &
commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"),
CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default).
It makes no sense to still carry code that is guarded with
"#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes
all these unreferenced code paths.

Also complete remove bi_memstart & bi_memsize from the board-info
struct. As now bi_dram[] is always enabled and should be used instead.
This removes the redundant varriables.

Signed-off-by: Stefan Roese 
Cc: Daniel Schwierzeck 
Cc: Tom Rini 
Cc: Ramon Fried 
Cc: Simon Glass 
Cc: Michal Simek 
Cc: Pali Rohár 
---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured in
   setup_bdinfo(). This fixes the test issue with Nokia RX51.

Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26=results
   
v2:

- Change all references to bi_memstart & bi_memsize to bi_dram[0].start/
   size and remove it from the bd_info struct completely, as suggested by
   Daniel

  api/api_platform-mips.c   |  4 ++--
  api/api_platform-powerpc.c|  2 +-
  arch/mips/lib/boot.c  |  2 +-
  arch/mips/lib/bootm.c |  2 +-
  arch/powerpc/cpu/mpc83xx/fdt.c|  2 +-
  arch/powerpc/cpu/mpc83xx/traps.c  |  2 +-
  arch/powerpc/cpu/mpc85xx/fdt.c|  4 ++--
  arch/powerpc/cpu/mpc85xx/traps.c  |  2 +-
  arch/powerpc/cpu/mpc86xx/fdt.c|  2 +-
  arch/powerpc/cpu/mpc86xx/traps.c  |  2 +-
  arch/powerpc/cpu/mpc8xx/fdt.c |  2 +-
  arch/powerpc/lib/bootm.c  |  4 ++--
  arch/x86/cpu/broadwell/cpu_from_spl.c |  2 --
  arch/xtensa/lib/bdinfo.c  |  4 ++--
  arch/xtensa/lib/bootm.c   |  4 ++--
  board/Arcturus/ucp1020/spl.c  |  4 ++--
  board/freescale/p1010rdb/spl.c|  4 ++--
  board/freescale/p1_p2_rdb_pc/spl.c|  4 ++--
  board/freescale/t102xrdb/spl.c|  4 ++--
  board/freescale/t104xrdb/spl.c|  4 ++--
  board/freescale/t208xqds/spl.c|  4 ++--
  board/freescale/t208xrdb/spl.c|  4 ++--
  board/freescale/t4rdb/spl.c   |  4 ++--
  board/xilinx/zynqmp/zynqmp.c  |  2 --
  cmd/bdinfo.c  |  6 ++---
  cmd/bedbug.c  |  2 +-
  common/board_f.c  | 13 +--
  common/image.c| 10 +---
  common/init/handoff.c | 33 +++
  drivers/pci/pci-uclass.c  | 17 +-
  drivers/video/cfb_console.c   |  8 +--
  include/asm-generic/u-boot.h  |  4 
  include/handoff.h |  2 --
  lib/fdtdec.c  |  5 
  lib/lmb.c |  7 --
  35 files changed, 60 insertions(+), 121 deletions(-)

diff --git a/api/api_platform-mips.c b/api/api_platform-mips.c
index 51cd328b3d..f1721cef19 100644
--- a/api/api_platform-mips.c
+++ b/api/api_platform-mips.c
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
  int platform_sys_info(struct sys_info *si)
  {
  
-	platform_set_mr(si, gd->bd->bi_memstart,

-   gd->bd->bi_memsize, MR_ATTR_DRAM);
+   platform_set_mr(si, gd->bd->bi_dram[0].start,
+   gd->bd->bi_dram[0].size, MR_ATTR_DRAM);
  
  	return 1;

  }
diff --git a/api/api_platform-powerpc.c b/api/api_platform-powerpc.c
index 15930cfdb6..8fff6e4cae 100644
--- a/api/api_platform-powerpc.c
+++ b/api/api_platform-powerpc.c
@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si)
si->bar = 0;
  #endif
  
-	platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, MR_ATTR_DRAM);

+   platform_set_mr(si, gd->bd->bi_dram[0].start, gd->bd->bi_dram[0].size, 
MR_ATTR_DRAM);
platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, 
MR_ATTR_FLASH);
platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, 
MR_ATTR_SRAM);
  
diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c

index db862f6379..3b960691c5 100644
--- a/arch/mips/lib/boot.c
+++ b/arch/mips/lib/boot.c
@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),
 * whole SDRAM area, since we don't know the size of the image
 * that was loaded.
 */
-   flush_cache(gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart);
+   flush_cache(gd->bd->bi_dram[0].start, gd->ram_top - 
gd->bd->bi_dram[0].start);
  
  	return entry(argc, argv);

  }
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0a13f6edb7..b3ef15963e 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
  #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
  int 

pytest to test reset

2020-08-12 Thread Peng Fan
Hi All,

Any ideas how to test uboot reset cmd many times with pytest?

Thanks,
Peng.


Re: [PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Pali Rohár
On Wednesday 12 August 2020 09:44:17 Stefan Roese wrote:
> Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") &
> commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"),
> CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default).
> It makes no sense to still carry code that is guarded with
> "#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes
> all these unreferenced code paths.
> 
> Also complete remove bi_memstart & bi_memsize from the board-info
> struct. As now bi_dram[] is always enabled and should be used instead.
> This removes the redundant varriables.
> 
> Signed-off-by: Stefan Roese 
> Cc: Daniel Schwierzeck 
> Cc: Tom Rini 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Michal Simek 
> Cc: Pali Rohár 
> ---
> v3:
> - Rebase on TOT
> - Add check to not overwrite bi_dram[0] if already configured in
>   setup_bdinfo(). This fixes the test issue with Nokia RX51.
> 
> Azure test report success:
> https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26=results
>   
> v2:
> - Change all references to bi_memstart & bi_memsize to bi_dram[0].start/
>   size and remove it from the bd_info struct completely, as suggested by
>   Daniel
> 
>  api/api_platform-mips.c   |  4 ++--
>  api/api_platform-powerpc.c|  2 +-
>  arch/mips/lib/boot.c  |  2 +-
>  arch/mips/lib/bootm.c |  2 +-
>  arch/powerpc/cpu/mpc83xx/fdt.c|  2 +-
>  arch/powerpc/cpu/mpc83xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc85xx/fdt.c|  4 ++--
>  arch/powerpc/cpu/mpc85xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc86xx/fdt.c|  2 +-
>  arch/powerpc/cpu/mpc86xx/traps.c  |  2 +-
>  arch/powerpc/cpu/mpc8xx/fdt.c |  2 +-
>  arch/powerpc/lib/bootm.c  |  4 ++--
>  arch/x86/cpu/broadwell/cpu_from_spl.c |  2 --
>  arch/xtensa/lib/bdinfo.c  |  4 ++--
>  arch/xtensa/lib/bootm.c   |  4 ++--
>  board/Arcturus/ucp1020/spl.c  |  4 ++--
>  board/freescale/p1010rdb/spl.c|  4 ++--
>  board/freescale/p1_p2_rdb_pc/spl.c|  4 ++--
>  board/freescale/t102xrdb/spl.c|  4 ++--
>  board/freescale/t104xrdb/spl.c|  4 ++--
>  board/freescale/t208xqds/spl.c|  4 ++--
>  board/freescale/t208xrdb/spl.c|  4 ++--
>  board/freescale/t4rdb/spl.c   |  4 ++--
>  board/xilinx/zynqmp/zynqmp.c  |  2 --
>  cmd/bdinfo.c  |  6 ++---
>  cmd/bedbug.c  |  2 +-
>  common/board_f.c  | 13 +--
>  common/image.c| 10 +---
>  common/init/handoff.c | 33 +++
>  drivers/pci/pci-uclass.c  | 17 +-
>  drivers/video/cfb_console.c   |  8 +--
>  include/asm-generic/u-boot.h  |  4 
>  include/handoff.h |  2 --
>  lib/fdtdec.c  |  5 
>  lib/lmb.c |  7 --
>  35 files changed, 60 insertions(+), 121 deletions(-)
> 
> diff --git a/api/api_platform-mips.c b/api/api_platform-mips.c
> index 51cd328b3d..f1721cef19 100644
> --- a/api/api_platform-mips.c
> +++ b/api/api_platform-mips.c
> @@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
>  int platform_sys_info(struct sys_info *si)
>  {
>  
> - platform_set_mr(si, gd->bd->bi_memstart,
> - gd->bd->bi_memsize, MR_ATTR_DRAM);
> + platform_set_mr(si, gd->bd->bi_dram[0].start,
> + gd->bd->bi_dram[0].size, MR_ATTR_DRAM);
>  
>   return 1;
>  }
> diff --git a/api/api_platform-powerpc.c b/api/api_platform-powerpc.c
> index 15930cfdb6..8fff6e4cae 100644
> --- a/api/api_platform-powerpc.c
> +++ b/api/api_platform-powerpc.c
> @@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si)
>   si->bar = 0;
>  #endif
>  
> - platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, 
> MR_ATTR_DRAM);
> + platform_set_mr(si, gd->bd->bi_dram[0].start, gd->bd->bi_dram[0].size, 
> MR_ATTR_DRAM);
>   platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, 
> MR_ATTR_FLASH);
>   platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, 
> MR_ATTR_SRAM);
>  
> diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c
> index db862f6379..3b960691c5 100644
> --- a/arch/mips/lib/boot.c
> +++ b/arch/mips/lib/boot.c
> @@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const 
> []),
>* whole SDRAM area, since we don't know the size of the image
>* that was loaded.
>*/
> - flush_cache(gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart);
> + flush_cache(gd->bd->bi_dram[0].start, gd->ram_top - 
> gd->bd->bi_dram[0].start);
>  
>   return entry(argc, argv);
>  }
> diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
> index 0a13f6edb7..b3ef15963e 100644
> --- a/arch/mips/lib/bootm.c
> +++ b/arch/mips/lib/bootm.c
> @@ -242,7 +242,7 @@ static int 

Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Michal Simek
út 11. 8. 2020 v 17:33 odesílatel Tom Rini  napsal:
>
> On Tue, Aug 11, 2020 at 05:19:54PM +0200, Frank Wunderlich wrote:
>
> > From: Frank Wunderlich 
> >
> > every compilation shows this error
> >
> >  Hack for sunxi which doesn't have a proper binman definition for
> >  64-bit boards
> >
> > not only for sunxi-boards/arm64
> >
> > fix this by changing to real comments
> >
> > Fixes: 9f55ee259d0c ("Makefile: sunxi: Don't use binman to build ATF image")
> > Signed-off-by: Frank Wunderlich 
> > ---
> >  Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 4483a9bc8a..75c2987405 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1024,8 +1024,8 @@ PHONY += inputs
> >  inputs: $(INPUTS-y)
> >
> >  all: .binman_stamp inputs
> > - # Hack for sunxi which doesn't have a proper binman definition for
> > - # 64-bit boards
> > +# Hack for sunxi which doesn't have a proper binman definition for
> > +# 64-bit boards
> >  ifneq ($(CONFIG_ARCH_SUNXI)$(CONFIG_ARM64),yy)
> >  ifeq ($(CONFIG_BINMAN),y)
> >   $(call if_changed,binman)
>
> Um, what environment is this failing on?  Thanks!

I also see this message when I build stuff for zynqmp.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


[PATCH v3] CONFIG_NR_DRAM_BANKS: Remove unreferenced code as its always defined

2020-08-12 Thread Stefan Roese
Since commit 86cf1c82850f ("configs: Migrate CONFIG_NR_DRAM_BANKS") &
commit 999a772d9f24 ("Kconfig: Migrate CONFIG_NR_DRAM_BANKS"),
CONFIG_NR_DRAM_BANKS is always defined with a value (4 is default).
It makes no sense to still carry code that is guarded with
"#ifndef CONFIG_NR_DRAM_BANKS" (and similar). This patch removes
all these unreferenced code paths.

Also complete remove bi_memstart & bi_memsize from the board-info
struct. As now bi_dram[] is always enabled and should be used instead.
This removes the redundant varriables.

Signed-off-by: Stefan Roese 
Cc: Daniel Schwierzeck 
Cc: Tom Rini 
Cc: Ramon Fried 
Cc: Simon Glass 
Cc: Michal Simek 
Cc: Pali Rohár 
---
v3:
- Rebase on TOT
- Add check to not overwrite bi_dram[0] if already configured in
  setup_bdinfo(). This fixes the test issue with Nokia RX51.

Azure test report success:
https://dev.azure.com/sr0718/u-boot/_build/results?buildId=26=results
  
v2:
- Change all references to bi_memstart & bi_memsize to bi_dram[0].start/
  size and remove it from the bd_info struct completely, as suggested by
  Daniel

 api/api_platform-mips.c   |  4 ++--
 api/api_platform-powerpc.c|  2 +-
 arch/mips/lib/boot.c  |  2 +-
 arch/mips/lib/bootm.c |  2 +-
 arch/powerpc/cpu/mpc83xx/fdt.c|  2 +-
 arch/powerpc/cpu/mpc83xx/traps.c  |  2 +-
 arch/powerpc/cpu/mpc85xx/fdt.c|  4 ++--
 arch/powerpc/cpu/mpc85xx/traps.c  |  2 +-
 arch/powerpc/cpu/mpc86xx/fdt.c|  2 +-
 arch/powerpc/cpu/mpc86xx/traps.c  |  2 +-
 arch/powerpc/cpu/mpc8xx/fdt.c |  2 +-
 arch/powerpc/lib/bootm.c  |  4 ++--
 arch/x86/cpu/broadwell/cpu_from_spl.c |  2 --
 arch/xtensa/lib/bdinfo.c  |  4 ++--
 arch/xtensa/lib/bootm.c   |  4 ++--
 board/Arcturus/ucp1020/spl.c  |  4 ++--
 board/freescale/p1010rdb/spl.c|  4 ++--
 board/freescale/p1_p2_rdb_pc/spl.c|  4 ++--
 board/freescale/t102xrdb/spl.c|  4 ++--
 board/freescale/t104xrdb/spl.c|  4 ++--
 board/freescale/t208xqds/spl.c|  4 ++--
 board/freescale/t208xrdb/spl.c|  4 ++--
 board/freescale/t4rdb/spl.c   |  4 ++--
 board/xilinx/zynqmp/zynqmp.c  |  2 --
 cmd/bdinfo.c  |  6 ++---
 cmd/bedbug.c  |  2 +-
 common/board_f.c  | 13 +--
 common/image.c| 10 +---
 common/init/handoff.c | 33 +++
 drivers/pci/pci-uclass.c  | 17 +-
 drivers/video/cfb_console.c   |  8 +--
 include/asm-generic/u-boot.h  |  4 
 include/handoff.h |  2 --
 lib/fdtdec.c  |  5 
 lib/lmb.c |  7 --
 35 files changed, 60 insertions(+), 121 deletions(-)

diff --git a/api/api_platform-mips.c b/api/api_platform-mips.c
index 51cd328b3d..f1721cef19 100644
--- a/api/api_platform-mips.c
+++ b/api/api_platform-mips.c
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int platform_sys_info(struct sys_info *si)
 {
 
-   platform_set_mr(si, gd->bd->bi_memstart,
-   gd->bd->bi_memsize, MR_ATTR_DRAM);
+   platform_set_mr(si, gd->bd->bi_dram[0].start,
+   gd->bd->bi_dram[0].size, MR_ATTR_DRAM);
 
return 1;
 }
diff --git a/api/api_platform-powerpc.c b/api/api_platform-powerpc.c
index 15930cfdb6..8fff6e4cae 100644
--- a/api/api_platform-powerpc.c
+++ b/api/api_platform-powerpc.c
@@ -42,7 +42,7 @@ int platform_sys_info(struct sys_info *si)
si->bar = 0;
 #endif
 
-   platform_set_mr(si, gd->bd->bi_memstart, gd->bd->bi_memsize, 
MR_ATTR_DRAM);
+   platform_set_mr(si, gd->bd->bi_dram[0].start, gd->bd->bi_dram[0].size, 
MR_ATTR_DRAM);
platform_set_mr(si, gd->bd->bi_flashstart, gd->bd->bi_flashsize, 
MR_ATTR_FLASH);
platform_set_mr(si, gd->bd->bi_sramstart, gd->bd->bi_sramsize, 
MR_ATTR_SRAM);
 
diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c
index db862f6379..3b960691c5 100644
--- a/arch/mips/lib/boot.c
+++ b/arch/mips/lib/boot.c
@@ -17,7 +17,7 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []),
 * whole SDRAM area, since we don't know the size of the image
 * that was loaded.
 */
-   flush_cache(gd->bd->bi_memstart, gd->ram_top - gd->bd->bi_memstart);
+   flush_cache(gd->bd->bi_dram[0].start, gd->ram_top - 
gd->bd->bi_dram[0].start);
 
return entry(argc, argv);
 }
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0a13f6edb7..b3ef15963e 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -242,7 +242,7 @@ static int boot_reloc_fdt(bootm_headers_t *images)
 #if CONFIG_IS_ENABLED(MIPS_BOOT_FDT) && CONFIG_IS_ENABLED(OF_LIBFDT)
 int arch_fixup_fdt(void *blob)
 {
-   u64 mem_start = virt_to_phys((void *)gd->bd->bi_memstart);
+   u64 mem_start = virt_to_phys((void 

[PATCH] common: Kconfig: Add dependency for default variables strings

2020-08-12 Thread Michal Simek
Kconfig provides several config options for setting up default variables
but these are unused when variables are passed to U-Boot via file.
That's why cover this dependency in Kconfig.

Signed-off-by: Michal Simek 
---

There are likely other Kconfig entries which should be fixed too.

---
 common/Kconfig | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 62d78c5bd739..b7d5a8f28cf8 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -355,7 +355,7 @@ endmenu
 config BOOTDELAY
int "delay in seconds before automatically booting"
default 2
-   depends on AUTOBOOT
+   depends on AUTOBOOT && !USE_DEFAULT_ENV_FILE
help
  Delay before automatically running bootcmd;
  set to 0 to autoboot with no delay, but you can stop it by key input.
@@ -378,7 +378,7 @@ config USE_BOOTARGS
 
 config BOOTARGS
string "Boot arguments"
-   depends on USE_BOOTARGS
+   depends on USE_BOOTARGS && !USE_DEFAULT_ENV_FILE
help
  This can be used to pass arguments to the bootm command. The value of
  CONFIG_BOOTARGS goes into the environment value "bootargs". Note that
@@ -395,7 +395,7 @@ config USE_BOOTCOMMAND
 
 config BOOTCOMMAND
string "bootcmd value"
-   depends on USE_BOOTCOMMAND
+   depends on USE_BOOTCOMMAND && !USE_DEFAULT_ENV_FILE
default "run distro_bootcmd" if DISTRO_DEFAULTS
help
  This is the string of commands that will be used as bootcmd and if
@@ -416,7 +416,7 @@ config USE_PREBOOT
 
 config PREBOOT
string "preboot default value"
-   depends on USE_PREBOOT
+   depends on USE_PREBOOT && !USE_DEFAULT_ENV_FILE
default ""
help
  This is the default of "preboot" environment variable.
-- 
2.28.0



[PATCH v2] firmware: psci: Do not bind driver if U-Boot runs in EL3

2020-08-12 Thread Michal Simek
There is no reason to bind psci driver if U-Boot runs in EL3 because
SMC/HVC instructions can't be called. That's why detect this state and
don't let user to crash from prompt by performing reset or poweroff
commands (if enabled).

Signed-off-by: Michal Simek 
---

Changes in v2:
- Add missing asm/system.h header

Maybe there is a better way how to do it. Maybe do it in probe instead of
bind. Feel free to comment but this doesn't look right behavior.

Before:

U-Boot SPL 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200)
PMUFW:  v1.1
Loading new PMUFW cfg obj (2024 bytes)
EL Level:   EL3
Multiboot:  0
Trying to boot from MMC2
spl: could not initialize mmc. error: -19
Trying to boot from MMC1
spl_load_image_fat_os: error reading image u-boot.bin, err - -2

U-Boot 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200)

Model: ZynqMP ZCU104 RevC
Board: Xilinx ZynqMP
DRAM:  2 GiB
PMUFW:  v1.1
EL Level:   EL3
Chip ID:zu7e
Multiboot:  0
WDT:   Started with servicing (60s timeout)
NAND:  0 MiB
MMC:   mmc@ff17: 0
In:serial@ff00
Out:   serial@ff00
Err:   serial@ff00
Bootmode: LVL_SHFT_SD_MODE1
Reset reason:   EXTERNAL
Net:
ZYNQ GEM: ff0e, mdio bus ff0e, phyaddr 12, interface rgmii-id
eth0: ethernet@ff0e
Hit any key to stop autoboot:  0
ZynqMP> reset
resetting ...
"Synchronous Abort" handler, esr 0x5e00
elr: 08000194 lr : 08000220 (reloc)
elr: 7fec9194 lr : 7fec9220
x0 : 8409 x1 : 
x2 :  x3 : 
x4 :  x5 : 
x6 :  x7 : 
x8 : 7deaedb0 x9 : 000c
x10: 07c4 x11: 7deae92c
x12: 0006 x13: 0001869f
x14: 7deaedb0 x15: 0002
x16: 7ff2b20c x17: 
x18: 7deb8db0 x19: 
x20: 7ffb0ae0 x21: 
x22: 7debc600 x23: 0001
x24: 7ffc8158 x25: 
x26:  x27: 
x28: 7debc640 x29: 7deaeaf0

Code:  f902  d403 (f94003e4)
Resetting CPU ...

 ### ERROR ### Please RESET the board ###

After:

U-Boot SPL 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200)
PMUFW:  v1.1
Loading new PMUFW cfg obj (2024 bytes)
EL Level:   EL3
Multiboot:  0
Trying to boot from MMC2
spl: could not initialize mmc. error: -19
Trying to boot from MMC1
spl_load_image_fat_os: error reading image u-boot.bin, err - -2

U-Boot 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200)

Model: ZynqMP ZCU104 RevC
Board: Xilinx ZynqMP
DRAM:  2 GiB
PMUFW:  v1.1
EL Level:   EL3
Chip ID:zu7e
Multiboot:  0
WDT:   Started with servicing (60s timeout)
NAND:  0 MiB
MMC:   mmc@ff17: 0
In:serial@ff00
Out:   serial@ff00
Err:   serial@ff00
Bootmode: LVL_SHFT_SD_MODE1
Reset reason:   EXTERNAL
Net:
ZYNQ GEM: ff0e, mdio bus ff0e, phyaddr 12, interface rgmii-id
eth0: ethernet@ff0e
Hit any key to stop autoboot:  0
ZynqMP>
ZynqMP> reset
resetting ...
ZynqMP>

---
 drivers/firmware/psci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 7d2e49fd3e3b..e6425e8ffcf4 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DRIVER_NAME "psci"
 
@@ -73,6 +74,9 @@ static int psci_probe(struct udevice *dev)
 {
const char *method;
 
+   if (current_el() == 3)
+   return -EINVAL;
+
method = ofnode_read_string(dev_ofnode(dev), "method");
if (!method) {
pr_warn("missing \"method\" property\n");
-- 
2.28.0



Re: [PATCH 3/6] riscv: load addresses for Sipeed MAIX

2020-08-12 Thread Rick Chen
Hi Heinrich

> On 8/6/20 9:07 AM, Rick Chen wrote:
> >> From: U-Boot [mailto:u-boot-boun...@lists.denx.de] On Behalf Of Heinrich 
> >> Schuchardt
> >> Sent: Wednesday, July 29, 2020 11:43 PM
> >> To: Sean Anderson
> >> Cc: Michal Simek; Tom Rini; Simon Glass; Bin Meng; Alexander Graf; 
> >> u-boot@lists.denx.de; Heinrich Schuchardt
> >> Subject: [PATCH 3/6] riscv: load addresses for Sipeed MAIX
> >>
> >> Define default load addresses and the device tree name for the Sipeed MAIX.
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>  include/configs/sipeed-maix.h | 9 +
> >>  1 file changed, 9 insertions(+)
> >
> > Acked-by: Rick Chen 
> >
>
> Thanks for reviewing.
>
> I have reassigned the patch to you in patchwork. The rest of the series
> was already merged via the last EFI pull request.

It is better to be pulled with the whole patch series together via EFI tree.
Because the title of this patch sets is [PATCH 0/6] efi_selftest:
allow UEFI testing on MAIX.

And you said that you still try the address for OpenSBI in previous mail.

Thanks,
Rick

>
> Best regards
>
> Heinrich


Aw: Re: [PATCH] Makefile: fix annoying sunxi hack message

2020-08-12 Thread Frank Wunderlich
> Gesendet: Dienstag, 11. August 2020 um 17:32 Uhr
> Von: "Tom Rini" 

> Um, what environment is this failing on?  Thanks!

sorry forgot data about host where i compile it...i guess this is more 
interesting ;)

$ cat /etc/issue
Ubuntu 20.04.1 LTS \n \l
$ uname -a
Linux frank-G5-U20 5.4.52-custom #1 SMP Thu Jul 16 19:16:51 CEST 2020 x86_64 
x86_64 x86_64 GNU/Linux
$ make -v
GNU Make 4.2.1
$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 
8.4.0-3ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs 
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr 
--with-gcc-major-version-only --program-suffix=-8 --enable-shared 
--enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext 
--enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm 
--disable-libquadmath --disable-libquadmath-support --enable-plugin 
--enable-default-pie --with-system-zlib --without-target-system-zlib 
--enable-multiarch --enable-multilib --disable-sjlj-exceptions 
--with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb 
--disable-werror --enable-multilib --enable-checking=release 
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf 
--program-prefix=arm-linux-gnueabihf- 
--includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 8.4.0 (Ubuntu/Linaro 8.4.0-3ubuntu1)

my config: 
https://github.com/frank-w/u-boot/blob/2020-10-bpi/configs/mt7623n_bpir2_defconfig