[PATCH 12/12] configs: ls208xa: Enable GIC_V3_ITS config

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
---
 configs/ls2080aqds_SECURE_BOOT_defconfig  | 1 +
 configs/ls2080aqds_defconfig  | 1 +
 configs/ls2080aqds_nand_defconfig | 1 +
 configs/ls2080aqds_qspi_defconfig | 1 +
 configs/ls2080aqds_sdcard_defconfig   | 1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  | 1 +
 configs/ls2080ardb_defconfig  | 1 +
 configs/ls2080ardb_nand_defconfig | 1 +
 configs/ls2081ardb_defconfig  | 1 +
 configs/ls2088aqds_tfa_defconfig  | 1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls2088ardb_qspi_defconfig | 1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  | 1 +
 configs/ls2088ardb_tfa_defconfig  | 1 +
 14 files changed, 14 insertions(+)

diff --git a/configs/ls2080aqds_SECURE_BOOT_defconfig 
b/configs/ls2080aqds_SECURE_BOOT_defconfig
index 8a792e449a..9039b252c1 100644
--- a/configs/ls2080aqds_SECURE_BOOT_defconfig
+++ b/configs/ls2080aqds_SECURE_BOOT_defconfig
@@ -62,3 +62,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_defconfig b/configs/ls2080aqds_defconfig
index bc4c218c21..b14b3ca5e7 100644
--- a/configs/ls2080aqds_defconfig
+++ b/configs/ls2080aqds_defconfig
@@ -63,3 +63,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_nand_defconfig 
b/configs/ls2080aqds_nand_defconfig
index e840cbf0ef..fac2b04068 100644
--- a/configs/ls2080aqds_nand_defconfig
+++ b/configs/ls2080aqds_nand_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_qspi_defconfig 
b/configs/ls2080aqds_qspi_defconfig
index 861e652f7f..343c7675e0 100644
--- a/configs/ls2080aqds_qspi_defconfig
+++ b/configs/ls2080aqds_qspi_defconfig
@@ -62,3 +62,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080aqds_sdcard_defconfig 
b/configs/ls2080aqds_sdcard_defconfig
index 864e70d334..dd2862ffe0 100644
--- a/configs/ls2080aqds_sdcard_defconfig
+++ b/configs/ls2080aqds_sdcard_defconfig
@@ -69,3 +69,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_SECURE_BOOT_defconfig 
b/configs/ls2080ardb_SECURE_BOOT_defconfig
index 4abfc64705..743e25f7b7 100644
--- a/configs/ls2080ardb_SECURE_BOOT_defconfig
+++ b/configs/ls2080ardb_SECURE_BOOT_defconfig
@@ -64,3 +64,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_defconfig b/configs/ls2080ardb_defconfig
index 0102e14ecb..e9dfc3603e 100644
--- a/configs/ls2080ardb_defconfig
+++ b/configs/ls2080ardb_defconfig
@@ -65,3 +65,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2080ardb_nand_defconfig 
b/configs/ls2080ardb_nand_defconfig
index 448e0fe58d..68ec26e405 100644
--- a/configs/ls2080ardb_nand_defconfig
+++ b/configs/ls2080ardb_nand_defconfig
@@ -70,3 +70,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2081ardb_defconfig b/configs/ls2081ardb_defconfig
index e446a1120b..4036ed94e5 100644
--- a/configs/ls2081ardb_defconfig
+++ b/configs/ls2081ardb_defconfig
@@ -62,3 +62,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088aqds_tfa_defconfig b/configs/ls2088aqds_tfa_defconfig
index 9f49736b4f..d3ee37cabe 100644
--- a/configs/ls2088aqds_tfa_defconfig
+++ b/configs/ls2088aqds_tfa_defconfig
@@ -74,3 +74,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
index ae4a6820ff..9b06bf4257 100644
--- a/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls2088ardb_qspi_SECURE_BOOT_defconfig
@@ -59,3 +59,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls2088ardb_qspi_defconfig 
b/configs/ls2088ardb_qspi_defconfig
index 1ad5f3b367..3203384c5b 100644
--- a/configs/ls2088ardb_qspi_defconfig
+++ b/configs/ls2088ardb_qspi_defconfig
@@ -63,3 +63,4 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff 

[PATCH 11/12] board: fsl: ls2080a: Initialize the GIC redistributor tables

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Fixup kernel DT to reserve memory for GIC redistributor tables,
and initialize the redistributor configuration and pending
tables using the reserved memory.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/ls2080aqds/ls2080aqds.c | 14 ++
 board/freescale/ls2080ardb/ls2080ardb.c | 14 ++
 2 files changed, 28 insertions(+)

diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index 4034bdee28..fd63e6bc76 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -3,6 +3,7 @@
  * Copyright 2015 Freescale Semiconductor
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -12,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,12 +23,14 @@
 #include 
 #include 
 #include 
+#include 
 
 
 #include "../common/qixis.h"
 #include "ls2080aqds_qixis.h"
 #include "../common/vid.h"
 
+#define GIC_LPI_SIZE   0x20
 #define PIN_MUX_SEL_SDHC   0x00
 #define PIN_MUX_SEL_DSPI   0x0a
 #define SCFG_QSPICLKCTRL_DIV_20(5 << 27)
@@ -323,6 +327,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 {
u64 base[CONFIG_NR_DRAM_BANKS];
u64 size[CONFIG_NR_DRAM_BANKS];
+   u64 gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -333,6 +339,14 @@ int ft_board_setup(void *blob, bd_t *bd)
size[1] = gd->bd->bi_dram[1].size;
 
 #ifdef CONFIG_RESV_RAM
+#ifdef CONFIG_GIC_V3_ITS
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (!ret) {
+   if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+   }
+#endif
/* reduce size if reserved memory is within this bank */
if (gd->arch.resv_ram >= base[0] &&
gd->arch.resv_ram < base[0] + size[0])
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 282aaf47fb..45e645f8de 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -4,6 +4,7 @@
  * Copyright 2017 NXP
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_FSL_QIXIS
 #include "../common/qixis.h"
@@ -30,6 +33,7 @@
 #endif
 #include "../common/vid.h"
 
+#define GIC_LPI_SIZE   0x20
 #define PIN_MUX_SEL_SDHC   0x00
 #define PIN_MUX_SEL_DSPI   0x0a
 
@@ -421,6 +425,8 @@ int ft_board_setup(void *blob, bd_t *bd)
u64 mc_memory_base = 0;
u64 mc_memory_size = 0;
u16 total_memory_banks;
+   u64 gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -441,6 +447,14 @@ int ft_board_setup(void *blob, bd_t *bd)
size[1] = gd->bd->bi_dram[1].size;
 
 #ifdef CONFIG_RESV_RAM
+#ifdef CONFIG_GIC_V3_ITS
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (!ret) {
+   if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+   }
+#endif
/* reduce size if reserved memory is within this bank */
if (gd->arch.resv_ram >= base[0] &&
gd->arch.resv_ram < base[0] + size[0])
-- 
2.17.1



[PATCH 09/12] board: fsl: ls1028a: Initialize the GIC redistributor tables

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Fixup kernel DT to reserve memory for GIC redistributor tables,
and initialize the redistributor configuration and pending
tables using the reserved memory.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/ls1028a/ls1028a.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/board/freescale/ls1028a/ls1028a.c 
b/board/freescale/ls1028a/ls1028a.c
index aa93534ac6..5a89d37629 100644
--- a/board/freescale/ls1028a/ls1028a.c
+++ b/board/freescale/ls1028a/ls1028a.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -11,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,6 +21,7 @@
 #ifdef CONFIG_FSL_LS_PPA
 #include 
 #endif
+#include 
 #include 
 #include 
 
@@ -29,6 +32,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define GIC_LPI_SIZE   0x20
 int config_board_mux(void)
 {
 #if defined(CONFIG_TARGET_LS1028AQDS) && defined(CONFIG_FSL_QIXIS)
@@ -140,6 +144,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 {
u64 base[CONFIG_NR_DRAM_BANKS];
u64 size[CONFIG_NR_DRAM_BANKS];
+   u64 gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -150,6 +156,14 @@ int ft_board_setup(void *blob, bd_t *bd)
size[1] = gd->bd->bi_dram[1].size;
 
 #ifdef CONFIG_RESV_RAM
+#ifdef CONFIG_GIC_V3_ITS
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (!ret) {
+   if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+   }
+#endif
/* reduce size if reserved memory is within this bank */
if (gd->arch.resv_ram >= base[0] &&
gd->arch.resv_ram < base[0] + size[0])
-- 
2.17.1



[PATCH 10/12] configs: ls1028a: Enable GIC_V3_ITS config

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
---
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1028aqds_tfa_defconfig | 1 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1028ardb_tfa_defconfig | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
index c5f0bd85da..92b944f426 100644
--- a/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028aqds_tfa_SECURE_BOOT_defconfig
@@ -79,3 +79,4 @@ CONFIG_WDT_SP805=y
 CONFIG_RSA=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028aqds_tfa_defconfig b/configs/ls1028aqds_tfa_defconfig
index 7085be77fe..66d3ee1761 100644
--- a/configs/ls1028aqds_tfa_defconfig
+++ b/configs/ls1028aqds_tfa_defconfig
@@ -84,3 +84,4 @@ CONFIG_WDT=y
 CONFIG_WDT_SP805=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
index 6fa14af6af..c999f3e6ef 100644
--- a/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1028ardb_tfa_SECURE_BOOT_defconfig
@@ -76,3 +76,4 @@ CONFIG_WDT_SP805=y
 CONFIG_RSA=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1028ardb_tfa_defconfig b/configs/ls1028ardb_tfa_defconfig
index 3ef5520969..150123bc7b 100644
--- a/configs/ls1028ardb_tfa_defconfig
+++ b/configs/ls1028ardb_tfa_defconfig
@@ -86,3 +86,4 @@ CONFIG_WDT=y
 CONFIG_WDT_SP805=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
-- 
2.17.1



[PATCH 07/12] board: fsl: ls1088a: Initialize the GIC redistributor tables

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Fixup kernel DT to reserve memory for GIC redistributor tables,
and initialize the redistributor configuration and pending
tables using the reserved memory.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/ls1088a/ls1088a.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/board/freescale/ls1088a/ls1088a.c 
b/board/freescale/ls1088a/ls1088a.c
index 0bd397a0be..24663f5598 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -3,6 +3,7 @@
  * Copyright 2017-2018 NXP
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -14,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -22,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../common/qixis.h"
 #include "ls1088a_qixis.h"
@@ -30,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define GIC_LPI_SIZE   0x20
 #ifdef CONFIG_TARGET_LS1088AQDS
 #ifdef CONFIG_TFABOOT
 struct ifc_regs ifc_cfg_ifc_nor_boot[CONFIG_SYS_FSL_IFC_BANK_COUNT] = {
@@ -914,6 +918,8 @@ int ft_board_setup(void *blob, bd_t *bd)
u64 mc_memory_base = 0;
u64 mc_memory_size = 0;
u16 total_memory_banks;
+   u64 gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -934,6 +940,15 @@ int ft_board_setup(void *blob, bd_t *bd)
}
 
 #ifdef CONFIG_RESV_RAM
+#ifdef CONFIG_GIC_V3_ITS
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (!ret) {
+   if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+   }
+#endif
+
/* reduce size if reserved memory is within this bank */
if (gd->arch.resv_ram >= base[0] &&
gd->arch.resv_ram < base[0] + size[0])
-- 
2.17.1



[PATCH 06/12] fsl-layerscape: Kconfig: Select RESV_RAM config if GIC_V3_ITS is enabled

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The GIC redistributor tables initialization depends on RESV_RAM config,
so select RESV_RAM if GIC_V3_ITS is enabled.

Signed-off-by: Hou Zhiqiang 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 275c66d992..af1c148c26 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -46,6 +46,7 @@ config ARCH_LS1028A
select SYS_FSL_ERRATUM_A009663 if !TFABOOT
select SYS_FSL_ERRATUM_A009942 if !TFABOOT
select SYS_FSL_ERRATUM_A050382
+   select RESV_RAM if GIC_V3_ITS
imply PANIC_HANG
 
 config ARCH_LS1043A
@@ -152,6 +153,7 @@ config ARCH_LS1088A
select SYS_I2C_MXC_I2C2 if !TFABOOT
select SYS_I2C_MXC_I2C3 if !TFABOOT
select SYS_I2C_MXC_I2C4 if !TFABOOT
+   select RESV_RAM if GIC_V3_ITS
imply SCSI
imply PANIC_HANG
 
@@ -202,6 +204,7 @@ config ARCH_LS2080A
select SYS_I2C_MXC_I2C2 if !TFABOOT
select SYS_I2C_MXC_I2C3 if !TFABOOT
select SYS_I2C_MXC_I2C4 if !TFABOOT
+   select RESV_RAM if GIC_V3_ITS
imply DISTRO_DEFAULTS
imply PANIC_HANG
 
@@ -229,6 +232,7 @@ config ARCH_LX2160A
select ARCH_EARLY_INIT_R
select BOARD_EARLY_INIT_F
select SYS_I2C_MXC
+   select RESV_RAM if GIC_V3_ITS
imply DISTRO_DEFAULTS
imply PANIC_HANG
imply SCSI
-- 
2.17.1



[PATCH 08/12] configs: ls1088a: Enable GIC_V3_ITS config

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Enable GIC_V3_ITS config to initialize the GIC redistributor
tables.

Signed-off-by: Hou Zhiqiang 
---
 configs/ls1088aqds_defconfig | 1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088aqds_qspi_defconfig| 1 +
 configs/ls1088aqds_sdcard_ifc_defconfig  | 1 +
 configs/ls1088aqds_sdcard_qspi_defconfig | 1 +
 configs/ls1088aqds_tfa_defconfig | 1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig| 1 +
 configs/ls1088ardb_qspi_defconfig| 1 +
 configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 1 +
 configs/ls1088ardb_sdcard_qspi_defconfig | 1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1088ardb_tfa_defconfig | 1 +
 12 files changed, 12 insertions(+)

diff --git a/configs/ls1088aqds_defconfig b/configs/ls1088aqds_defconfig
index 7713e58bbe..b1b74f9af4 100644
--- a/configs/ls1088aqds_defconfig
+++ b/configs/ls1088aqds_defconfig
@@ -59,3 +59,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
index 242c40b8b5..943b914e01 100644
--- a/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088aqds_qspi_SECURE_BOOT_defconfig
@@ -60,3 +60,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_qspi_defconfig 
b/configs/ls1088aqds_qspi_defconfig
index 3649b06a75..490782ebfc 100644
--- a/configs/ls1088aqds_qspi_defconfig
+++ b/configs/ls1088aqds_qspi_defconfig
@@ -61,3 +61,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_sdcard_ifc_defconfig 
b/configs/ls1088aqds_sdcard_ifc_defconfig
index 815ea5ce4a..a4c6b27a3d 100644
--- a/configs/ls1088aqds_sdcard_ifc_defconfig
+++ b/configs/ls1088aqds_sdcard_ifc_defconfig
@@ -67,3 +67,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_sdcard_qspi_defconfig 
b/configs/ls1088aqds_sdcard_qspi_defconfig
index 275dbf9e0e..435f704eb3 100644
--- a/configs/ls1088aqds_sdcard_qspi_defconfig
+++ b/configs/ls1088aqds_sdcard_qspi_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088aqds_tfa_defconfig b/configs/ls1088aqds_tfa_defconfig
index 1144cba983..5c2a699849 100644
--- a/configs/ls1088aqds_tfa_defconfig
+++ b/configs/ls1088aqds_tfa_defconfig
@@ -78,3 +78,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
index 3f654e2e1d..89e9a46c4f 100644
--- a/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_qspi_SECURE_BOOT_defconfig
@@ -61,3 +61,4 @@ CONFIG_USB_GADGET=y
 CONFIG_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_qspi_defconfig 
b/configs/ls1088ardb_qspi_defconfig
index 935d76b4be..3c2fda4593 100644
--- a/configs/ls1088ardb_qspi_defconfig
+++ b/configs/ls1088ardb_qspi_defconfig
@@ -62,3 +62,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
index 562cbdd3ab..da41ccaa29 100644
--- a/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
@@ -70,3 +70,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_sdcard_qspi_defconfig 
b/configs/ls1088ardb_sdcard_qspi_defconfig
index 1e6fdceca1..0483e5d8d2 100644
--- a/configs/ls1088ardb_sdcard_qspi_defconfig
+++ b/configs/ls1088ardb_sdcard_qspi_defconfig
@@ -71,3 +71,4 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_GADGET=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig 
b/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
index 0086039e52..079e6c53fb 100644
--- a/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1088ardb_tfa_SECURE_BOOT_defconfig
@@ -71,3 +71,4 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_GIC_V3_ITS=y
diff --git a/configs/ls1088ardb_tfa_defconfig b/configs/ls1088ardb_tfa_defconfig
index a7908e95b5..e3d4b02d21 100644
--- a/configs/ls1088ardb_tfa_defconfig
+++ b/configs/ls1088ardb_tfa_defconfig
@@ -77,3 +77,4 @@ CONFIG_USB_

[PATCH 04/12] board: lx2160a: Don't program the GIC RD tables if failed to reserve memory

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Program the GIC redistributor tables only when succeeded to reserve memory
for them, otherwise kernel will lose the chance to program them using
allocated memory.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/lx2160a/lx2160a.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 290d80db90..30b18a75c5 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -642,6 +642,7 @@ int ft_board_setup(void *blob, bd_t *bd)
u64 mc_memory_size = 0;
u16 total_memory_banks;
u64 gic_lpi_base;
+   int ret;
 
ft_cpu_setup(blob, bd);
 
@@ -663,8 +664,11 @@ int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_GIC_V3_ITS
gic_lpi_base = gd->arch.resv_ram - GIC_LPI_SIZE;
-   gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
-   fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+   if (!ret) {
+   if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
+   debug("%s: failed to init gic-lpi-tables\n", __func__);
+   }
 #endif
 
 #ifdef CONFIG_RESV_RAM
-- 
2.17.1



[PATCH 05/12] board: lx2160a: Make sure the RD tables address align to 64KB

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

As the lower 16bit of the redistributor pending table is reserved
for describing the memory attributes, we must give a 64KB aligned
address to the GIC LPI initialization function.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/lx2160a/lx2160a.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 30b18a75c5..f38c45ada5 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -663,7 +664,7 @@ int ft_board_setup(void *blob, bd_t *bd)
}
 
 #ifdef CONFIG_GIC_V3_ITS
-   gic_lpi_base = gd->arch.resv_ram - GIC_LPI_SIZE;
+   gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
if (!ret) {
if (gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
-- 
2.17.1



[PATCH 03/12] arm64: layerscape: Move the GIC tables reserve memory function to soc.c

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

Move the function of reserving memory for GIC redistributor tables
to soc.c, such that other Layerscape platform can leverage it, and
add a argument for the memory size to reserve.
And rename the function so that it is more readable.

Signed-off-by: Hou Zhiqiang 
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c| 18 ++
 arch/arm/include/asm/arch-fsl-layerscape/soc.h |  4 
 board/freescale/lx2160a/lx2160a.c  | 17 +
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index d0e10cb007..eef282909c 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -33,6 +33,24 @@
 DECLARE_GLOBAL_DATA_PTR;
 #endif
 
+#ifdef CONFIG_GIC_V3_ITS
+int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
+{
+   u32 phandle;
+   int err;
+   struct fdt_memory gic_rd_tables;
+
+   gic_rd_tables.start = base;
+   gic_rd_tables.end = base + size - 1;
+   err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
+&phandle);
+   if (err < 0)
+   debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+   return err;
+}
+#endif
+
 bool soc_has_dp_ddr(void)
 {
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h 
b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
index c62d414aac..2081b71cd7 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -158,6 +158,10 @@ void erratum_a010315(void);
 
 bool soc_has_dp_ddr(void);
 bool soc_has_aiop(void);
+
+#ifdef CONFIG_GIC_V3_ITS
+int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size);
+#endif
 #endif
 
 #endif /* _ASM_ARMV8_FSL_LAYERSCAPE_SOC_H_ */
diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 595c774b42..290d80db90 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -630,21 +630,6 @@ void board_quiesce_devices(void)
 }
 #endif
 
-#ifdef CONFIG_GIC_V3_ITS
-void fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
-{
-   u32 phandle;
-   int err;
-   struct fdt_memory gic_lpi;
-
-   gic_lpi.start = gic_lpi_base;
-   gic_lpi.end = gic_lpi_base + GIC_LPI_SIZE - 1;
-   err = fdtdec_add_reserved_memory(blob, "gic-lpi", &gic_lpi, &phandle);
-   if (err < 0)
-   debug("failed to add reserved memory: %d\n", err);
-}
-#endif
-
 #ifdef CONFIG_OF_BOARD_SETUP
 int ft_board_setup(void *blob, bd_t *bd)
 {
@@ -679,7 +664,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 #ifdef CONFIG_GIC_V3_ITS
gic_lpi_base = gd->arch.resv_ram - GIC_LPI_SIZE;
gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
-   fdt_fixup_gic_lpi_memory(blob, gic_lpi_base);
+   fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
 #endif
 
 #ifdef CONFIG_RESV_RAM
-- 
2.17.1



[PATCH 01/12] board: lx2160a: Add header file cpu_func.h

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The declaration of the function cpu_numcores() has been moved to
cpu_func.h, so add including of the header file to avoid build
error.

Signed-off-by: Hou Zhiqiang 
---
 board/freescale/lx2160a/lx2160a.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index 134ae22f85..595c774b42 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.17.1



[PATCH 00/12] fsl: layerscape: Initialize the GIC redistributor

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

This patch set is to initialize the GIC redistributor tables and add the
tables to kernel DT's reserved memeory node.

Hou Zhiqiang (12):
  board: lx2160a: Add header file cpu_func.h
  arm64: fsl-layerscape: Assign addr to resv_ram if enabled RESV_RAM
config
  arm64: layerscape: Move the GIC tables reserve memory function to
soc.c
  board: lx2160a: Don't program the GIC RD tables if failed to reserve
memory
  board: lx2160a: Make sure the RD tables address align to 64KB
  fsl-layerscape: Kconfig: Select RESV_RAM config if GIC_V3_ITS is
enabled
  board: fsl: ls1088a: Initialize the GIC redistributor tables
  configs: ls1088a: Enable GIC_V3_ITS config
  board: fsl: ls1028a: Initialize the GIC redistributor tables
  configs: ls1028a: Enable GIC_V3_ITS config
  board: fsl: ls2080a: Initialize the GIC redistributor tables
  configs: ls208xa: Enable GIC_V3_ITS config

Depends on:
 https://patchwork.ozlabs.org/project/uboot/list/?series=158486

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig |  4 +++
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |  8 +++---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 18 +
 .../arm/include/asm/arch-fsl-layerscape/soc.h |  4 +++
 board/freescale/ls1028a/ls1028a.c | 14 ++
 board/freescale/ls1088a/ls1088a.c | 15 +++
 board/freescale/ls2080aqds/ls2080aqds.c   | 14 ++
 board/freescale/ls2080ardb/ls2080ardb.c   | 14 ++
 board/freescale/lx2160a/lx2160a.c | 27 +++
 configs/ls1028aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1028aqds_tfa_defconfig  |  1 +
 configs/ls1028ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1028ardb_tfa_defconfig  |  1 +
 configs/ls1088aqds_defconfig  |  1 +
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088aqds_qspi_defconfig |  1 +
 configs/ls1088aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1088aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1088aqds_tfa_defconfig  |  1 +
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_qspi_defconfig |  1 +
 ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls1088ardb_sdcard_qspi_defconfig  |  1 +
 configs/ls1088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1088ardb_tfa_defconfig  |  1 +
 configs/ls2080aqds_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080aqds_defconfig  |  1 +
 configs/ls2080aqds_nand_defconfig |  1 +
 configs/ls2080aqds_qspi_defconfig |  1 +
 configs/ls2080aqds_sdcard_defconfig   |  1 +
 configs/ls2080ardb_SECURE_BOOT_defconfig  |  1 +
 configs/ls2080ardb_defconfig  |  1 +
 configs/ls2080ardb_nand_defconfig |  1 +
 configs/ls2081ardb_defconfig  |  1 +
 configs/ls2088aqds_tfa_defconfig  |  1 +
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig |  1 +
 configs/ls2088ardb_qspi_defconfig |  1 +
 configs/ls2088ardb_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls2088ardb_tfa_defconfig  |  1 +
 39 files changed, 126 insertions(+), 22 deletions(-)

-- 
2.17.1



[PATCH 02/12] arm64: fsl-layerscape: Assign addr to resv_ram if enabled RESV_RAM config

2020-03-18 Thread Zhiqiang Hou
From: Hou Zhiqiang 

The initialization of gd->arch.resv_ram pointer should depend on if the
RESV_RAM config is enabled.

Signed-off-by: Hou Zhiqiang 
---
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index b443894453..1b7729c046 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -1379,7 +1379,7 @@ static int tfa_dram_init_banksize(void)
if (i > 0)
ret = 0;
 
-#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_RESV_RAM) && !defined(CONFIG_SPL_BUILD)
/* Assign memory for MC */
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
if (gd->bd->bi_dram[2].size >=
@@ -1402,7 +1402,7 @@ static int tfa_dram_init_banksize(void)
board_reserve_ram_top(gd->bd->bi_dram[0].size);
}
}
-#endif /* CONFIG_FSL_MC_ENET */
+#endif /* CONFIG_RESV_RAM */
 
return ret;
 }
@@ -1465,7 +1465,7 @@ int dram_init_banksize(void)
}
 #endif /* CONFIG_SYS_MEM_RESERVE_SECURE */
 
-#if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_RESV_RAM) && !defined(CONFIG_SPL_BUILD)
/* Assign memory for MC */
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
if (gd->bd->bi_dram[2].size >=
@@ -1488,7 +1488,7 @@ int dram_init_banksize(void)
board_reserve_ram_top(gd->bd->bi_dram[0].size);
}
}
-#endif /* CONFIG_FSL_MC_ENET */
+#endif /* CONFIG_RESV_RAM */
 
 #ifdef CONFIG_SYS_DP_DDR_BASE_PHY
 #ifdef CONFIG_SYS_DDR_BLOCK3_BASE
-- 
2.17.1



Re: [PATCH v2 1/8] mmc: ca_dw_mmc: add DesignWare based DM support for CAxxxx SoCs

2020-03-18 Thread Jaehoon Chung
On 3/19/20 10:52 AM, Alex Nemirovsky wrote:
> From: Arthur Li 
> 
> Initial DesignWare based DM support for Cortina Access CA SoCs.
> 
> Signed-off-by: Arthur Li 
> Signed-off-by: Alex Nemirovsky 
> 
> ---
> 
> Changes in v3: None
> Changes in v2:
> - Add I2C controller
> - Add LED controller
> - Add SPI NAND and NOR controller
> 
>  MAINTAINERS |   2 +
>  drivers/mmc/Kconfig |  11 +++
>  drivers/mmc/Makefile|   1 +
>  drivers/mmc/ca_dw_mmc.c | 181 
> 
>  4 files changed, 195 insertions(+)
>  create mode 100644 drivers/mmc/ca_dw_mmc.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 82e4159..bb45d3c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -180,6 +180,7 @@ F:board/cortina/common/
>  F:   drivers/gpio/cortina_gpio.c
>  F:   drivers/watchdog/cortina_wdt.c
>  F:   drivers/serial/serial_cortina.c
> +F:   drivers/mmc/ca_dw_mmc.c
>  
>  ARM/CZ.NIC TURRIS MOX SUPPORT
>  M:   Marek Behun 
> @@ -670,6 +671,7 @@ F:board/cortina/common/
>  F:   drivers/gpio/cortina_gpio.c
>  F:   drivers/watchdog/cortina_wdt.c
>  F:   drivers/serial/serial_cortina.c
> +F:   drivers/mmc/ca_dw_mmc.c
>  
>  MIPS MSCC
>  M:   Gregory CLEMENT 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index 2f0eedc..bb38787 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -205,6 +205,17 @@ config MMC_DW
> block, this provides host support for SD and MMC interfaces, in both
> PIO, internal DMA mode and external DMA mode.
>  
> +config MMC_DW_CORTINA
> + bool "Cortina specific extensions for Synopsys DW Memory Card Interface"
> + depends on DM_MMC
> + depends on MMC_DW
> + depends on BLK
> + default n
> + help
> +   This selects support for Cortina SoC specific extensions to the
> +   Synopsys DesignWare Memory Card Interface driver. Select this option
> +   for platforms based on Cortina CA Soc's.
> +
>  config MMC_DW_EXYNOS
>   bool "Exynos specific extensions for Synopsys DW Memory Card Interface"
>   depends on ARCH_EXYNOS
> diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
> index 9c1f8e5..615b724 100644
> --- a/drivers/mmc/Makefile
> +++ b/drivers/mmc/Makefile
> @@ -20,6 +20,7 @@ endif
>  obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
>  obj-$(CONFIG_MMC_DAVINCI)+= davinci_mmc.o
>  obj-$(CONFIG_MMC_DW) += dw_mmc.o
> +obj-$(CONFIG_MMC_DW_CORTINA) += ca_dw_mmc.o
>  obj-$(CONFIG_MMC_DW_EXYNOS)  += exynos_dw_mmc.o
>  obj-$(CONFIG_MMC_DW_K3)  += hi6220_dw_mmc.o
>  obj-$(CONFIG_MMC_DW_ROCKCHIP)+= rockchip_dw_mmc.o
> diff --git a/drivers/mmc/ca_dw_mmc.c b/drivers/mmc/ca_dw_mmc.c
> new file mode 100644
> index 000..acbc850
> --- /dev/null
> +++ b/drivers/mmc/ca_dw_mmc.c
> @@ -0,0 +1,181 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2019 Cortina Access
> + * Arthur Li 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define SD_CLK_SEL_MASK (0x3)
> +#define SD_DLL_DEFAULT  (0x143000)
> +#define SD_SCLK_MAX (2)
> +
> +#define SD_CLK_SEL_200MHZ (0x2)
> +#define SD_CLK_SEL_100MHZ (0x1)
> +
> +#define IO_DRV_SD_DS_OFFSET (16)
> +#define IO_DRV_SD_DS_MASK   (0xff << IO_DRV_SD_DS_OFFSET)
> +
> +#define MIN_FREQ (40)
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct ca_mmc_plat {
> + struct mmc_config cfg;
> + struct mmc mmc;
> +};
> +
> +struct ca_dwmmc_priv_data {
> + struct dwmci_host host;
> + void __iomem *sd_dll_reg;
> + void __iomem *io_drv_reg;
> + u8 ds;
> +};
> +
> +static void ca_dwmci_clksel(struct dwmci_host *host)
> +{
> + struct ca_dwmmc_priv_data *priv = host->priv;
> + u32 val = readl(priv->sd_dll_reg);
> +

How about below?

val &= ~SD_CLK_SEL_MASK;

if (..) {
val |= ..
} else if (...) {
val |= ...
}

> + if (host->bus_hz >= 2) {
> + val &= ~SD_CLK_SEL_MASK;
> + val |= SD_CLK_SEL_200MHZ;
> + } else if (host->bus_hz >= 1) {
> + val &= ~SD_CLK_SEL_MASK;
> + val |= SD_CLK_SEL_100MHZ;
> + } else {
> + val &= ~SD_CLK_SEL_MASK;
> + }
> +
> + writel(val, priv->sd_dll_reg);
> +}
> +
> +static void ca_dwmci_board_init(struct dwmci_host *host)
> +{
> + struct ca_dwmmc_priv_data *priv = host->priv;
> + u32 val = readl(priv->io_drv_reg);
> +
> + writel(SD_DLL_DEFAULT, priv->sd_dll_reg);
> +
> + val &= ~IO_DRV_SD_DS_MASK;
> + if (priv && priv->ds)
> + val |= priv->ds << IO_DRV_SD_DS_OFFSET;
> + writel(val, priv->io_drv_reg);
> +}
> +
> +unsigned int ca_dwmci_get_mmc_clock(struct dwmci_host *host, uint freq)
> +{
> + struct ca_dwmmc_priv_data *priv = host->priv;
> + u8 sd_clk_sel = readl(priv->sd_dll_reg) & SD_CLK_SEL_MASK;
> + u8 clk_div;
> +
> + switch (sd_clk_sel) {
> + ca

Re: [PATCH 1/1] efi_loader: create reservations after ft_board_setup

2020-03-18 Thread Heinrich Schuchardt

On 3/18/20 8:26 PM, Atish Patra wrote:

On Sat, Mar 14, 2020 at 3:12 AM Heinrich Schuchardt  wrote:


Some memory reservations are made in ft_board_setup(). Ensure that we
create reserved memory map entries after ft_board_setup().

The downside of this patch is that if bootefi is called multiple times with
an devicetree argument superfluous reservations for the old copies of the
device tree will exist. But that is still better than missing a reservation.

Deleting the superfluous reservations is not possible because reservations
in the memory map are rounded to page size and may be coallesced.

Signed-off-by: Heinrich Schuchardt 
---
  cmd/bootefi.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 485f4b408a..9990959fe7 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -293,9 +293,6 @@ efi_status_t efi_install_fdt(void *fdt)
 return EFI_LOAD_ERROR;
 }

-   /* Create memory reservations as indicated by the device tree */
-   efi_carve_out_dt_rsv(fdt);
-
 /* Prepare device tree for payload */
 ret = copy_fdt(&fdt);
 if (ret) {
@@ -303,6 +300,9 @@ efi_status_t efi_install_fdt(void *fdt)
 return EFI_OUT_OF_RESOURCES;
 }

+   /* Create memory reservations as indicated by the device tree */
+   efi_carve_out_dt_rsv(fdt);
+
 /* Install device tree as UEFI table */
 ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
 if (ret != EFI_SUCCESS) {
--
2.25.1


As per my understanding, copy_fdt tries allocate efi memory below dram
start + 127MB
for device tree. If efi_carve_out_dt_rsv is called after copy_fdt, it
may overwrite
a reserved-memory region. No ?


Hello Alex,

in commit ad0c1a3d2cea03011091b07e9e066bf261d1556e you wrote:

"The uEFI spec doesn't dictate where the device tree should live at, but
legacy 32bit ARM grub2 has some assumptions that it may stay at its
place when it's already loaded by the firmware.

So let's put it somewhere where Linux that comes after would happily
find it - around the recommended 128MB line."

https://www.kernel.org/doc/Documentation/devicetree/booting-without-of.txt
says:
"Device tree can be located anywhere in system RAM, but it should be
aligned on a 64 bit boundary."

Do you remember from where you took the 128 MiB value?

Best regards

Heinrich


Re: [PATCH v3 1/5] riscv: Add boot hartid to Device tree

2020-03-18 Thread Bin Meng
On Thu, Mar 19, 2020 at 11:10 AM Bin Meng  wrote:
>
> On Wed, Mar 18, 2020 at 5:19 AM Atish Patra  wrote:
> >
> > Linux booting protocol mandates that register "a0" contains the hartid.
> > However, U-boot can not pass the hartid via a0 during via standard UEFI
>
> nits: U-Boot
>
> remove "during" ?
>
> > protocol. DT nodes are commonly used to pass such information to the OS.
> >
> > Add a DT node under chosen node to indicate the boot hartid. EFI stub
> > in Linux kernel will parse this node and pass it to the real kernel
> > in "a0" before jumping to it.
> >
> > Signed-off-by: Atish Patra 
> > Reviewed-by: Rick Chen 
> > ---
> >  arch/riscv/lib/bootm.c | 22 ++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
> > index fad16901c5f2..f927694ae32f 100644
> > --- a/arch/riscv/lib/bootm.c
> > +++ b/arch/riscv/lib/bootm.c
> > @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void)
> >
> >  int arch_fixup_fdt(void *blob)
> >  {

One additional note, do have need to guard the "boot-hartid" fix-up with

#ifdef CONFIG_EFI_LOADER

#endif

?

> > +   u32 size;
> > +   int chosen_offset, err;
> > +
> > +   size = fdt_totalsize(blob);
> > +   err  = fdt_open_into(blob, blob, size + 32);
> > +   if (err < 0) {
> > +   printf("Device Tree can't be expanded to accommodate new 
> > node");
> > +   return -1;
>
> return err
>
> > +   }
> > +   chosen_offset = fdt_path_offset(blob, "/chosen");
> > +   if (chosen_offset < 0) {
> > +   err = fdt_add_subnode(blob, 0, "chosen");
> > +   if (err < 0) {
> > +   printf("chosen node can not be added\n");
> > +   return -1;
>
> return err
>
> > +   }
> > +   }
> > +
> > +   /* Overwrite the boot-hartid as U-Boot is the last state BL */
>
> typo: stage
>
> > +   fdt_setprop_u32(blob, chosen_offset, "boot-hartid",
> > +  gd->arch.boot_hart);
> > +
> > return 0;
> >  }
> >
> > --

Regards,
Bin


Re: [PATCH v3 1/5] riscv: Add boot hartid to Device tree

2020-03-18 Thread Bin Meng
On Wed, Mar 18, 2020 at 5:19 AM Atish Patra  wrote:
>
> Linux booting protocol mandates that register "a0" contains the hartid.
> However, U-boot can not pass the hartid via a0 during via standard UEFI

nits: U-Boot

remove "during" ?

> protocol. DT nodes are commonly used to pass such information to the OS.
>
> Add a DT node under chosen node to indicate the boot hartid. EFI stub
> in Linux kernel will parse this node and pass it to the real kernel
> in "a0" before jumping to it.
>
> Signed-off-by: Atish Patra 
> Reviewed-by: Rick Chen 
> ---
>  arch/riscv/lib/bootm.c | 22 ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
> index fad16901c5f2..f927694ae32f 100644
> --- a/arch/riscv/lib/bootm.c
> +++ b/arch/riscv/lib/bootm.c
> @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void)
>
>  int arch_fixup_fdt(void *blob)
>  {
> +   u32 size;
> +   int chosen_offset, err;
> +
> +   size = fdt_totalsize(blob);
> +   err  = fdt_open_into(blob, blob, size + 32);
> +   if (err < 0) {
> +   printf("Device Tree can't be expanded to accommodate new 
> node");
> +   return -1;

return err

> +   }
> +   chosen_offset = fdt_path_offset(blob, "/chosen");
> +   if (chosen_offset < 0) {
> +   err = fdt_add_subnode(blob, 0, "chosen");
> +   if (err < 0) {
> +   printf("chosen node can not be added\n");
> +   return -1;

return err

> +   }
> +   }
> +
> +   /* Overwrite the boot-hartid as U-Boot is the last state BL */

typo: stage

> +   fdt_setprop_u32(blob, chosen_offset, "boot-hartid",
> +  gd->arch.boot_hart);
> +
> return 0;
>  }
>
> --

Regards,
Bin


Re: [PATCH 2/2] tegra: Enable CONFIG_BOOTP_PREFER_SERVERIP for all boards

2020-03-18 Thread Stephen Warren
On 3/18/20 5:52 PM, Tom Warren wrote:
> -Original Message-
> From: Stephen Warren  
> Sent: Wednesday, March 18, 2020 4:31 PM
> To: Tom Warren 
> Cc: u-boot@lists.denx.de; Stephen Warren ; Thierry Reding 
> ; Jonathan Hunter ; 
> tomcwarren3...@gmail.com
> Subject: Re: [PATCH 2/2] tegra: Enable CONFIG_BOOTP_PREFER_SERVERIP for all 
> boards
> 
> External email: Use caution opening links or attachments
> 
> 
> On 3/17/20 2:07 PM, twar...@nvidia.com wrote:
>> From: Tom Warren 
>>
>> This allows the user to set $serverip in the environment before 
>> executing a DHCP request. If they do, U-Boot will use that IP rather 
>> than using the IP in the DHCP response.
> 
> Acked-by: Stephen Warren 
> 
> I wonder if this should be applied to more Tegra boards, so they all work 
> consistently? E.g. T20/30/114/124 boards.
> [Tom] I can certainly do that, but I don't really test on anything  anymore, especially not net boot. Do you test for that in your Jenkins test 
> harness?

The oldest hardware that's tested in Jenkins is Jetson TK1. In total I
have TK1, TX1, TX2 automated.


[PATCH v2 7/8] spi: ca_sflash: Add CAxxxx SPI Flash Controller

2020-03-18 Thread Alex Nemirovsky
From: Pengpeng Chen 

Add SPI Flash controller driver for Cortina Access
CA SoCs

Signed-off-by: Pengpeng Chen 
Signed-off-by: Alex Nemirovsky 

---

Changes in v3:
- Fixup syntax issues related to checkpatch.pl cleanup

Changes in v2: None

 MAINTAINERS |   2 +
 drivers/spi/Kconfig |   8 +
 drivers/spi/Makefile|   1 +
 drivers/spi/ca_sflash.c | 576 
 4 files changed, 587 insertions(+)
 create mode 100644 drivers/spi/ca_sflash.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 24a2655..8509779 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -184,6 +184,7 @@ F:  drivers/mmc/ca_dw_mmc.c
 F: drivers/i2c/i2c-cortina.c
 F: drivers/i2c/i2c-cortina.h
 F: drivers/led/led_cortina.c
+F: drivers/spi/ca_sflash.c
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M: Marek Behun 
@@ -678,6 +679,7 @@ F:  drivers/mmc/ca_dw_mmc.c
 F: drivers/i2c/i2c-cortina.c
 F: drivers/i2c/i2c-cortina.h
 F: drivers/led/led_cortina.c
+F: drivers/spi/ca_sflash.c
 
 MIPS MSCC
 M: Gregory CLEMENT 
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 4166c61..8a244f1 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -106,6 +106,14 @@ config BCMSTB_SPI
  be used to access the SPI flash on platforms embedding this
  Broadcom SPI core.
 
+config CORTINA_SFLASH
+   bool "Cortina-Access Serial Flash controller driver"
+   depends on DM_SPI && SPI_MEM
+   help
+ Enable the Cortina-Access Serial Flash controller driver. This driver
+ can be used to access the SPI NOR/NAND flash on platforms embedding 
this
+ Cortina-Access IP core.
+
 config CADENCE_QSPI
bool "Cadence QSPI driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 52462e1..32b98b4 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_BCM63XX_SPI) += bcm63xx_spi.o
 obj-$(CONFIG_BCMSTB_SPI) += bcmstb_spi.o
 obj-$(CONFIG_CADENCE_QSPI) += cadence_qspi.o cadence_qspi_apb.o
 obj-$(CONFIG_CF_SPI) += cf_spi.o
+obj-$(CONFIG_CORTINA_SFLASH) += ca_sflash.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
 obj-$(CONFIG_DESIGNWARE_SPI) += designware_spi.o
 obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
diff --git a/drivers/spi/ca_sflash.c b/drivers/spi/ca_sflash.c
new file mode 100644
index 000..0709650
--- /dev/null
+++ b/drivers/spi/ca_sflash.c
@@ -0,0 +1,576 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for Cortina SPI-FLASH Controller
+ *
+ * Copyright (C) 2020 Cortina Access Inc. All Rights Reserved.
+ *
+ * Author: PengPeng Chen 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct ca_sflash_regs {
+   u32 idr;/* 0x00:Flash word ID Register */
+   u32 tc; /* 0x04:Flash Timeout Counter Register */
+   u32 sr; /* 0x08:Flash Status Register */
+   u32 tr; /* 0x0C:Flash Type Register */
+   u32 asr;/* 0x10:Flash ACCESS START/BUSY Register */
+   u32 isr;/* 0x14:Flash Interrupt Status Register */
+   u32 imr;/* 0x18:Flash Interrupt Mask Register */
+   u32 fcr;/* 0x1C:NAND Flash FIFO Control Register */
+   u32 ffsr;   /* 0x20:Flash FIFO Status Register */
+   u32 ffar;   /* 0x24:Flash FIFO ADDRESS Register */
+   u32 ffmar;  /* 0x28:Flash FIFO MATCHING ADDRESS Register */
+   u32 ffdr;   /* 0x2C:Flash FIFO Data Register */
+   u32 ar; /* 0x30:Serial Flash Access Register */
+   u32 ear;/* 0x34:Serial Flash Extend Access Register */
+   u32 adr;/* 0x38:Serial Flash ADdress Register */
+   u32 dr; /* 0x3C:Serial Flash Data Register */
+   u32 tmr;/* 0x40:Serial Flash Timing Register */
+};
+
+/*
+ * FLASH_TYPE
+ */
+#define CA_FLASH_TR_PINBIT(15)
+#define CA_FLASH_TR_TYPE_MASK  GENMASK(14, 12)
+#define CA_FLASH_TR_TYPE(tp)   (((tp) << 12) & CA_FLASH_TR_TYPE_MASK)
+#define CA_FLASH_TR_WIDTH  BIT(11)
+#define CA_FLASH_TR_SIZE_MASK  GENMASK(10, 9)
+#define CA_FLASH_TR_SIZE(sz)   (((sz) << 9) & CA_FLASH_TR_SIZE_MASK)
+
+/*
+ * FLASH_FLASH_ACCESS_START
+ */
+#define CA_FLASH_ASR_IND_START_EN  BIT(1)
+#define CA_FLASH_ASR_DMA_START_EN  BIT(3)
+#define CA_FLASH_ASR_WR_ACCESS_EN  BIT(9)
+
+/*
+ * FLASH_FLASH_INTERRUPT
+ */
+#define CA_FLASH_ISR_REG_IRQ   BIT(1)
+#define CA_FLASH_ISR_FIFO_IRQ  BIT(2)
+
+/*
+ * FLASH_SF_ACCESS
+ */
+#define CA_SF_AR_OPCODE_MASK   GENMASK(7, 0)
+#define CA_SF_AR_OPCODE(op)((op) << 0 & CA_SF_AR_OPCODE_MASK)
+#define CA_SF_AR_ACCODE_MASK   GENMASK(11, 8

[PATCH v2 3/8] i2c: i2c-cortina: added CAxxxx I2C support

2020-03-18 Thread Alex Nemirovsky
From: Arthur Li 

Add I2C controller support for Cortina Access CA SoCs

Signed-off-by: Arthur Li 
Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 MAINTAINERS   |   4 +
 drivers/i2c/Kconfig   |   7 +
 drivers/i2c/Makefile  |   1 +
 drivers/i2c/i2c-cortina.c | 346 ++
 drivers/i2c/i2c-cortina.h |  92 
 5 files changed, 450 insertions(+)
 create mode 100644 drivers/i2c/i2c-cortina.c
 create mode 100644 drivers/i2c/i2c-cortina.h

diff --git a/MAINTAINERS b/MAINTAINERS
index bb45d3c..b147faa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -181,6 +181,8 @@ F:  drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
 F: drivers/mmc/ca_dw_mmc.c
+F: drivers/i2c/i2c-cortina.c
+F: drivers/i2c/i2c-cortina.h
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M: Marek Behun 
@@ -672,6 +674,8 @@ F:  drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
 F: drivers/mmc/ca_dw_mmc.c
+F: drivers/i2c/i2c-cortina.c
+F: drivers/i2c/i2c-cortina.h
 
 MIPS MSCC
 M: Gregory CLEMENT 
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 03d2fed..b98a4aa 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -85,6 +85,13 @@ config SYS_I2C_CADENCE
  Say yes here to select Cadence I2C Host Controller. This controller is
  e.g. used by Xilinx Zynq.
 
+config SYS_I2C_CA
+   tristate "Cortina-Access I2C Controller"
+   depends on DM_I2C && CORTINA_PLATFORM
+   default n
+   help
+ Say yes here to select Cortina-Access I2C Host Controller.
+
 config SYS_I2C_DAVINCI
bool "Davinci I2C Controller"
depends on (ARCH_KEYSTONE || ARCH_DAVINCI)
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index f5a471f..5d18cf7 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_SYS_I2C) += i2c_core.o
 obj-$(CONFIG_SYS_I2C_ASPEED) += ast_i2c.o
 obj-$(CONFIG_SYS_I2C_AT91) += at91_i2c.o
 obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o
+obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
 ifdef CONFIG_DM_PCI
diff --git a/drivers/i2c/i2c-cortina.c b/drivers/i2c/i2c-cortina.c
new file mode 100644
index 000..99c63f3
--- /dev/null
+++ b/drivers/i2c/i2c-cortina.c
@@ -0,0 +1,346 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020
+ * Arthur Li, Cortina Access, arthur...@cortina-access.com.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "i2c-cortina.h"
+
+static void set_speed(struct i2c_regs *regs, int i2c_spd)
+{
+   union ca_biw_cfg i2c_cfg;
+
+   i2c_cfg.wrd = readl(®s->i2c_cfg);
+   i2c_cfg.bf.core_en = 0;
+   writel(i2c_cfg.wrd, ®s->i2c_cfg);
+
+   switch (i2c_spd) {
+   case IC_SPEED_MODE_MAX:
+   i2c_cfg.bf.prer =
+   CORTINA_PER_IO_FREQ / (5 * I2C_MAX_SPEED) - 1;
+   break;
+
+   case IC_SPEED_MODE_STANDARD:
+   i2c_cfg.bf.prer =
+   CORTINA_PER_IO_FREQ / (5 * I2C_STANDARD_SPEED) - 1;
+   break;
+
+   case IC_SPEED_MODE_FAST:
+   default:
+   i2c_cfg.bf.prer =
+   CORTINA_PER_IO_FREQ / (5 * I2C_FAST_SPEED) - 1;
+   break;
+   }
+
+   i2c_cfg.bf.core_en = 1;
+   writel(i2c_cfg.wrd, ®s->i2c_cfg);
+}
+
+static int ca_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
+{
+   struct ca_i2c *priv = dev_get_priv(bus);
+   int i2c_spd;
+
+   if (speed >= I2C_MAX_SPEED) {
+   i2c_spd = IC_SPEED_MODE_MAX;
+   priv->speed = I2C_MAX_SPEED;
+   } else if (speed >= I2C_FAST_SPEED) {
+   i2c_spd = IC_SPEED_MODE_FAST;
+   priv->speed = I2C_FAST_SPEED;
+   } else {
+   i2c_spd = IC_SPEED_MODE_STANDARD;
+   priv->speed = I2C_STANDARD_SPEED;
+   }
+
+   set_speed(priv->regs, i2c_spd);
+
+   return 0;
+}
+
+static int ca_i2c_get_bus_speed(struct udevice *bus)
+{
+   struct ca_i2c *priv = dev_get_priv(bus);
+
+   return priv->speed;
+}
+
+static void ca_i2c_init(struct i2c_regs *regs)
+{
+   union ca_biw_cfg i2c_cfg;
+
+   i2c_cfg.wrd = readl(®s->i2c_cfg);
+   i2c_cfg.bf.core_en = 0;
+   i2c_cfg.bf.biw_soft_reset = 1;
+   writel(i2c_cfg.wrd, ®s->i2c_cfg);
+   mdelay(10);
+   i2c_cfg.bf.biw_soft_reset = 0;
+   writel(i2c_cfg.wrd, ®s->i2c_cfg);
+
+   set_speed(regs, IC_SPEED_MODE_STANDARD);
+
+   i2c_cfg.wrd = readl(®s->i2c_cfg);
+   i2c_cfg.bf.core_en = 1;
+   writel(i2c_cfg.wrd, ®s->i2c_cfg);
+}
+
+static int i2c_wait_complete(struct i2c_regs *regs)
+{
+   union ca_biw_ctrl i2c_ctrl;
+   unsigned long start_time_bb = get_timer(0);
+
+   i2c_ctrl.wrd = readl(®s->i2c_c

[PATCH v2 4/8] board: presidio-asic: Add I2C support

2020-03-18 Thread Alex Nemirovsky
Add I2C board support for Cortina Access Presidio Engineering Board

Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 configs/cortina_presidio-asic-emmc_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cortina_presidio-asic-emmc_defconfig 
b/configs/cortina_presidio-asic-emmc_defconfig
index e10008a..e45e23c 100644
--- a/configs/cortina_presidio-asic-emmc_defconfig
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -10,6 +10,7 @@ CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_BOOTDELAY=3
 CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_WDT=y
@@ -24,6 +25,8 @@ CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
 # CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_CORTINA_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_CA=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_CORTINA=y
-- 
2.7.4



[PATCH v2 6/8] board: presidio: add LED support

2020-03-18 Thread Alex Nemirovsky
From: Jway Lin 

Add LED support for Cortina Access Presidio Engineering Board

Signed-off-by: Jway Lin 
Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 arch/arm/dts/ca-presidio-engboard.dts| 31 
 configs/cortina_presidio-asic-emmc_defconfig |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/arch/arm/dts/ca-presidio-engboard.dts 
b/arch/arm/dts/ca-presidio-engboard.dts
index c03dacc..ae897e8 100644
--- a/arch/arm/dts/ca-presidio-engboard.dts
+++ b/arch/arm/dts/ca-presidio-engboard.dts
@@ -66,4 +66,35 @@
spi-max-frequency = <10800>;
};
};
+
+   leds: led-controller@f43200f0 {
+   compatible = "cortina,ca-leds";
+   reg = <0x0 0xf43200f0 0x40>;
+
+   cortina,blink_rate1 = <256>;
+   cortina,blink_rate2 = <512>;
+
+   led@0 {
+   pin = <0>;
+   active-low;
+   blink-sel =<0>;
+   port = <0>;
+   off-event = <0>;
+   label = "led0";
+   };
+
+   led@1 {
+   pin = <1>;
+   active-low;
+   blink-sel =<1>;
+   label = "led1";
+   };
+
+   led@2 {
+   pin = <2>;
+   active-low;
+   label = "led2";
+   };
+
+   };
 };
diff --git a/configs/cortina_presidio-asic-emmc_defconfig 
b/configs/cortina_presidio-asic-emmc_defconfig
index e45e23c..3c6bd6b 100644
--- a/configs/cortina_presidio-asic-emmc_defconfig
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -27,6 +27,8 @@ CONFIG_DM=y
 CONFIG_CORTINA_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_CA=y
+CONFIG_LED=y
+CONFIG_LED_CORTINA=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_CORTINA=y
-- 
2.7.4



[PATCH v2 5/8] led: led_cortina: Add CAxxx LED support

2020-03-18 Thread Alex Nemirovsky
From: Jway Lin 

Add Cortina Access LED controller support for CA SOCs

Signed-off-by: Jway Lin 
Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 MAINTAINERS   |   2 +
 drivers/led/Kconfig   |   8 ++
 drivers/led/Makefile  |   1 +
 drivers/led/led_cortina.c | 308 ++
 4 files changed, 319 insertions(+)
 create mode 100644 drivers/led/led_cortina.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b147faa..24a2655 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -183,6 +183,7 @@ F:  drivers/serial/serial_cortina.c
 F: drivers/mmc/ca_dw_mmc.c
 F: drivers/i2c/i2c-cortina.c
 F: drivers/i2c/i2c-cortina.h
+F: drivers/led/led_cortina.c
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M: Marek Behun 
@@ -676,6 +677,7 @@ F:  drivers/serial/serial_cortina.c
 F: drivers/mmc/ca_dw_mmc.c
 F: drivers/i2c/i2c-cortina.c
 F: drivers/i2c/i2c-cortina.h
+F: drivers/led/led_cortina.c
 
 MIPS MSCC
 M: Gregory CLEMENT 
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 6675934..cc87fbf 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -35,6 +35,14 @@ config LED_BCM6858
  This option enables support for LEDs connected to the BCM6858
  HW has blinking capabilities and up to 32 LEDs can be controlled.
 
+config LED_CORTINA
+   bool "LED Support for Cortina Access CA SoCs"
+   depends on LED && (CORTINA_PLATFORM)
+   help
+ This option enables support for LEDs connected to the Cortina
+ Access CA SOCs.
+
+
 config LED_BLINK
bool "Support LED blinking"
depends on LED
diff --git a/drivers/led/Makefile b/drivers/led/Makefile
index 3654dd3..8e3ae7f 100644
--- a/drivers/led/Makefile
+++ b/drivers/led/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_LED_BCM6328) += led_bcm6328.o
 obj-$(CONFIG_LED_BCM6358) += led_bcm6358.o
 obj-$(CONFIG_LED_BCM6858) += led_bcm6858.o
 obj-$(CONFIG_$(SPL_)LED_GPIO) += led_gpio.o
+obj-$(CONFIG_LED_CORTINA) += led_cortina.o
diff --git a/drivers/led/led_cortina.c b/drivers/led/led_cortina.c
new file mode 100644
index 000..53435e8
--- /dev/null
+++ b/drivers/led/led_cortina.c
@@ -0,0 +1,308 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Copyright (C) 2020 Cortina-Access
+ * Author: Jway Lin 
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CORTINA_LED_NUM16
+
+#define BIT(nr)(1UL << (nr))
+
+#define cortina_LED_CONTROL0x00
+#define cortina_LED_CONFIG_0   0x04
+#define cortina_LED_CONFIG_1   0x08
+#define cortina_LED_CONFIG_2   0x0c
+#define cortina_LED_CONFIG_3   0x10
+#define cortina_LED_CONFIG_4   0x14
+#define cortina_LED_CONFIG_5   0x18
+#define cortina_LED_CONFIG_6   0x1c
+#define cortina_LED_CONFIG_7   0x20
+#define cortina_LED_CONFIG_8   0x24
+#define cortina_LED_CONFIG_9   0x28
+#define cortina_LED_CONFIG_10  0x2c
+#define cortina_LED_CONFIG_11  0x30
+#define cortina_LED_CONFIG_12  0x34
+#define cortina_LED_CONFIG_13  0x38
+#define cortina_LED_CONFIG_14  0x3c
+#define cortina_LED_CONFIG_15  0x40
+
+#define cortina_LED_MAX_HW_BLINK   127
+#define cortina_LED_MAX_COUNT  CORTINA_LED_NUM
+#define cortina_LED_MAX_PORT   8
+
+/* LED_CONTROL fields */
+#define cortina_LED_BLINK_RATE1_OFFSET 0
+#define cortina_LED_BLINK_RATE1_MASK   0xFF
+#define cortina_LED_BLINK_RATE2_OFFSET 8
+#define cortina_LED_BLINK_RATE2_MASK   0xFF
+#define cortina_LED_CLK_TEST   BIT(16)
+#define cortina_LED_CLK_POLARITY   BIT(17)
+#define cortina_LED_CLK_TEST_MODE  BIT(16)
+#define cortina_LED_CLK_TEST_RX_TEST   BIT(30)
+#define cortina_LED_CLK_TEST_TX_TEST   BIT(31)
+
+/* LED_CONFIG fields */
+#define cortina_LED_EVENT_ON_OFFSET0
+#define cortina_LED_EVENT_ON_MASK  0x7
+#define cortina_LED_EVENT_BLINK_OFFSET 3
+#define cortina_LED_EVENT_BLINK_MASK   0x7
+#define cortina_LED_EVENT_OFF_OFFSET   6
+#define cortina_LED_EVENT_OFF_MASK 0x7
+#define cortina_LED_OFF_ON_OFFSET  9
+#define cortina_LED_OFF_ON_MASK0x3
+#define cortina_LED_PORT_OFFSET11
+#define cortina_LED_PORT_MASK  0x7
+#define cortina_LED_OFF_VALBIT(14)
+#define cortina_LED_SW_EVENT   BIT(15)
+#define cortina_LED_BLINK_SEL  BIT(16)
+
+struct cortina_led_cfg {
+   void __iomem *regs;
+   spinlock_t *lock;   /* protect LED resource access */
+   int idx;
+   bool active_low;
+
+   int off_event;
+   int blink_event;
+   int on_event;
+   int port;
+   int blink;
+   int enable;
+};
+
+struct cortina_led_top_cfg {
+   void __iomem *regs;
+   u16 blink_rate1;
+   u16 blink_rate2;
+};
+
+static struct cortina_led_top_cfg glb_led_ctrl;
+
+static void cortina_led_write(voi

[PATCH v2 8/8] board: presidio-asic: Add SPI NAND and NOR support

2020-03-18 Thread Alex Nemirovsky
Add SPI NAND and NOR support for Cortina Access
Presidio Engineering Board

Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 arch/arm/dts/ca-presidio-engboard.dts|  8 ++--
 board/cortina/presidio-asic/presidio.c   | 16 ++-
 configs/cortina_presidio-asic-spi-nand_defconfig | 48 +++
 configs/cortina_presidio-asic-spi-nor_defconfig  | 59 
 4 files changed, 125 insertions(+), 6 deletions(-)
 create mode 100644 configs/cortina_presidio-asic-spi-nand_defconfig
 create mode 100644 configs/cortina_presidio-asic-spi-nor_defconfig

diff --git a/arch/arm/dts/ca-presidio-engboard.dts 
b/arch/arm/dts/ca-presidio-engboard.dts
index ae897e8..8c73eb6 100644
--- a/arch/arm/dts/ca-presidio-engboard.dts
+++ b/arch/arm/dts/ca-presidio-engboard.dts
@@ -55,15 +55,13 @@
};
 
sflash: sflash-controller@f4324000 {
-   #address-cells = <2>;
-   #size-cells = <1>;
compatible = "cortina,ca-sflash";
reg = <0x0 0xf4324000 0x50>;
reg-names = "sflash-regs";
flash@0 {
-   compatible = "jedec,spi-nor";
-   spi-rx-bus-width = <1>;
-   spi-max-frequency = <10800>;
+   compatible = "spi-nand", "jedec,spi-nor";
+   spi-rx-bus-width = <4>;
+   spi-tx-bus-width = <4>;
};
};
 
diff --git a/board/cortina/presidio-asic/presidio.c 
b/board/cortina/presidio-asic/presidio.c
index b4fa01f..d547b60 100644
--- a/board/cortina/presidio-asic/presidio.c
+++ b/board/cortina/presidio-asic/presidio.c
@@ -14,7 +14,7 @@
 #include 
 #include 
 #include 
-
+#include 
 DECLARE_GLOBAL_DATA_PTR;
 
 #define CA_PERIPH_BASE  0xE000UL
@@ -70,9 +70,23 @@ static noinline int invoke_psci_fn_smc(u64 function_id, u64 
arg0, u64 arg1,
return function_id;
 }
 
+#ifdef CONFIG_CORTINA_SFLASH
+static int init_sflash(void)
+{
+   struct udevice *dev;
+
+   uclass_first_device(UCLASS_SPI, &dev);
+
+   return 0;
+}
+#endif
+
 int board_early_init_r(void)
 {
dcache_disable();
+#ifdef CONFIG_CORTINA_SFLASH
+   init_sflash();
+#endif
return 0;
 }
 
diff --git a/configs/cortina_presidio-asic-spi-nand_defconfig 
b/configs/cortina_presidio-asic-spi-nand_defconfig
new file mode 100644
index 000..515ad22
--- /dev/null
+++ b/configs/cortina_presidio-asic-spi-nand_defconfig
@@ -0,0 +1,48 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x0400
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_LOGLEVEL=7
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_CA=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_CORTINA=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_MTD_SPI_NAND=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_CORTINA_SFLASH=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
diff --git a/configs/cortina_presidio-asic-spi-nor_defconfig 
b/configs/cortina_presidio-asic-spi-nor_defconfig
new file mode 100644
index 000..d7ecec3
--- /dev/null
+++ b/configs/cortina_presidio-asic-spi-nor_defconfig
@@ -0,0 +1,59 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x0400
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_CA=y
+CONFIG_LED=y
+CONFIG_LED_CORTINA=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_CORTINA=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_SPI_FLASH_EON=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_SPI_FLASH_ISSI=y
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_SST=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG

[PATCH v2 2/8] board: presidio-asic: Add eMMC board support

2020-03-18 Thread Alex Nemirovsky
Add initial eMMC support for Cortina Access Presidio
Engineering Board

Signed-off-by: Alex Nemirovsky 
---

Changes in v3: None
Changes in v2: None

 configs/cortina_presidio-asic-emmc_defconfig | 33 
 1 file changed, 33 insertions(+)
 create mode 100644 configs/cortina_presidio-asic-emmc_defconfig

diff --git a/configs/cortina_presidio-asic-emmc_defconfig 
b/configs/cortina_presidio-asic-emmc_defconfig
new file mode 100644
index 000..e10008a
--- /dev/null
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -0,0 +1,33 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x0400
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_CORTINA=y
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
-- 
2.7.4



[PATCH v2 0/8] Cortina Access Drivers Package 2

2020-03-18 Thread Alex Nemirovsky


This release adds the following drivers and
integrates support  into the Cortina Access
Presidio Engineering Board:

CA SoC eMMC/SD controller
CA SoC I2C controller
CA Soc LED controller
CA SPI NAND and NOR controller

Changes in v3:
- Fixup syntax issues related to checkpatch.pl cleanup

Changes in v2:
- Add I2C controller
- Add LED controller
- Add SPI NAND and NOR controller

Alex Nemirovsky (3):
  board: presidio-asic: Add eMMC board support
  board: presidio-asic: Add I2C support
  board: presidio-asic: Add SPI NAND and NOR support

Arthur Li (2):
  mmc: ca_dw_mmc: add DesignWare based DM support for CA SoCs
  i2c: i2c-cortina: added CA I2C support

Jway Lin (2):
  led: led_cortina: Add CAxxx LED support
  board: presidio: add LED support

Pengpeng Chen (1):
  spi: ca_sflash: Add CA SPI Flash Controller

 MAINTAINERS  |  10 +
 arch/arm/dts/ca-presidio-engboard.dts|  39 +-
 board/cortina/presidio-asic/presidio.c   |  16 +-
 configs/cortina_presidio-asic-emmc_defconfig |  38 ++
 configs/cortina_presidio-asic-spi-nand_defconfig |  48 ++
 configs/cortina_presidio-asic-spi-nor_defconfig  |  59 +++
 drivers/i2c/Kconfig  |   7 +
 drivers/i2c/Makefile |   1 +
 drivers/i2c/i2c-cortina.c| 346 ++
 drivers/i2c/i2c-cortina.h|  92 
 drivers/led/Kconfig  |   8 +
 drivers/led/Makefile |   1 +
 drivers/led/led_cortina.c| 308 
 drivers/mmc/Kconfig  |  11 +
 drivers/mmc/Makefile |   1 +
 drivers/mmc/ca_dw_mmc.c  | 181 +++
 drivers/spi/Kconfig  |   8 +
 drivers/spi/Makefile |   1 +
 drivers/spi/ca_sflash.c  | 576 +++
 19 files changed, 1745 insertions(+), 6 deletions(-)
 create mode 100644 configs/cortina_presidio-asic-emmc_defconfig
 create mode 100644 configs/cortina_presidio-asic-spi-nand_defconfig
 create mode 100644 configs/cortina_presidio-asic-spi-nor_defconfig
 create mode 100644 drivers/i2c/i2c-cortina.c
 create mode 100644 drivers/i2c/i2c-cortina.h
 create mode 100644 drivers/led/led_cortina.c
 create mode 100644 drivers/mmc/ca_dw_mmc.c
 create mode 100644 drivers/spi/ca_sflash.c

-- 
2.7.4



[PATCH v2 1/8] mmc: ca_dw_mmc: add DesignWare based DM support for CAxxxx SoCs

2020-03-18 Thread Alex Nemirovsky
From: Arthur Li 

Initial DesignWare based DM support for Cortina Access CA SoCs.

Signed-off-by: Arthur Li 
Signed-off-by: Alex Nemirovsky 

---

Changes in v3: None
Changes in v2:
- Add I2C controller
- Add LED controller
- Add SPI NAND and NOR controller

 MAINTAINERS |   2 +
 drivers/mmc/Kconfig |  11 +++
 drivers/mmc/Makefile|   1 +
 drivers/mmc/ca_dw_mmc.c | 181 
 4 files changed, 195 insertions(+)
 create mode 100644 drivers/mmc/ca_dw_mmc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 82e4159..bb45d3c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -180,6 +180,7 @@ F:  board/cortina/common/
 F: drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
+F: drivers/mmc/ca_dw_mmc.c
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M: Marek Behun 
@@ -670,6 +671,7 @@ F:  board/cortina/common/
 F: drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
+F: drivers/mmc/ca_dw_mmc.c
 
 MIPS MSCC
 M: Gregory CLEMENT 
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 2f0eedc..bb38787 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -205,6 +205,17 @@ config MMC_DW
  block, this provides host support for SD and MMC interfaces, in both
  PIO, internal DMA mode and external DMA mode.
 
+config MMC_DW_CORTINA
+   bool "Cortina specific extensions for Synopsys DW Memory Card Interface"
+   depends on DM_MMC
+   depends on MMC_DW
+   depends on BLK
+   default n
+   help
+ This selects support for Cortina SoC specific extensions to the
+ Synopsys DesignWare Memory Card Interface driver. Select this option
+ for platforms based on Cortina CA Soc's.
+
 config MMC_DW_EXYNOS
bool "Exynos specific extensions for Synopsys DW Memory Card Interface"
depends on ARCH_EXYNOS
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 9c1f8e5..615b724 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -20,6 +20,7 @@ endif
 obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
 obj-$(CONFIG_MMC_DAVINCI)  += davinci_mmc.o
 obj-$(CONFIG_MMC_DW)   += dw_mmc.o
+obj-$(CONFIG_MMC_DW_CORTINA)   += ca_dw_mmc.o
 obj-$(CONFIG_MMC_DW_EXYNOS)+= exynos_dw_mmc.o
 obj-$(CONFIG_MMC_DW_K3)+= hi6220_dw_mmc.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)  += rockchip_dw_mmc.o
diff --git a/drivers/mmc/ca_dw_mmc.c b/drivers/mmc/ca_dw_mmc.c
new file mode 100644
index 000..acbc850
--- /dev/null
+++ b/drivers/mmc/ca_dw_mmc.c
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2019 Cortina Access
+ * Arthur Li 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SD_CLK_SEL_MASK (0x3)
+#define SD_DLL_DEFAULT  (0x143000)
+#define SD_SCLK_MAX (2)
+
+#define SD_CLK_SEL_200MHZ (0x2)
+#define SD_CLK_SEL_100MHZ (0x1)
+
+#define IO_DRV_SD_DS_OFFSET (16)
+#define IO_DRV_SD_DS_MASK   (0xff << IO_DRV_SD_DS_OFFSET)
+
+#define MIN_FREQ (40)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct ca_mmc_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
+struct ca_dwmmc_priv_data {
+   struct dwmci_host host;
+   void __iomem *sd_dll_reg;
+   void __iomem *io_drv_reg;
+   u8 ds;
+};
+
+static void ca_dwmci_clksel(struct dwmci_host *host)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u32 val = readl(priv->sd_dll_reg);
+
+   if (host->bus_hz >= 2) {
+   val &= ~SD_CLK_SEL_MASK;
+   val |= SD_CLK_SEL_200MHZ;
+   } else if (host->bus_hz >= 1) {
+   val &= ~SD_CLK_SEL_MASK;
+   val |= SD_CLK_SEL_100MHZ;
+   } else {
+   val &= ~SD_CLK_SEL_MASK;
+   }
+
+   writel(val, priv->sd_dll_reg);
+}
+
+static void ca_dwmci_board_init(struct dwmci_host *host)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u32 val = readl(priv->io_drv_reg);
+
+   writel(SD_DLL_DEFAULT, priv->sd_dll_reg);
+
+   val &= ~IO_DRV_SD_DS_MASK;
+   if (priv && priv->ds)
+   val |= priv->ds << IO_DRV_SD_DS_OFFSET;
+   writel(val, priv->io_drv_reg);
+}
+
+unsigned int ca_dwmci_get_mmc_clock(struct dwmci_host *host, uint freq)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u8 sd_clk_sel = readl(priv->sd_dll_reg) & SD_CLK_SEL_MASK;
+   u8 clk_div;
+
+   switch (sd_clk_sel) {
+   case 2:
+   clk_div = 1;
+   break;
+   case 1:
+   clk_div = 2;
+   break;
+   default:
+   clk_div = 4;
+   }
+
+   return SD_SCLK_MAX / clk_div / (host->div + 1);
+}
+
+static int ca_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+   struct ca_dwmmc_priv_data *priv = dev_get_priv(dev);
+   struct d

Re: [PATCH v2 0/8] Cortina Access Drivers Package 2

2020-03-18 Thread Alex Nemirovsky
Hi Tom,
Are we still blocked on this set until the upcoming 2020.4 release?  

> On Feb 26, 2020, at 11:58 PM, Alex Nemirovsky 
>  wrote:
> 
> 
> This release adds the following drivers and
> integrates support  into the Cortina Access
> Presidio Engineering Board:
> 
> CA SoC eMMC/SD controller
> CA SoC I2C controller
> CA Soc LED controller
> CA SPI NAND and NOR controller
> 
> Changes in v2:
> - Add I2C controller
> - Add LED controller
> - Add SPI NAND and NOR controller
> 
> Alex Nemirovsky (3):
>  board: presidio-asic: Add eMMC board support
>  board: presidio-asic: Add I2C support
>  board: presidio-asic: Add SPI NAND and NOR support
> 
> Arthur Li (2):
>  mmc: ca_dw_mmc: add DesignWare based DM support for CA SoCs
>  i2c: i2c-cortina: added CA I2C support
> 
> Jway Lin (2):
>  led: led_cortina: Add CAxxx LED support
>  board: presidio: add LED support
> 
> Pengpeng Chen (1):
>  spi: ca_sflash: Add CA SPI Flash Controller
> 
> MAINTAINERS  |  10 +
> arch/arm/dts/ca-presidio-engboard.dts|  39 +-
> board/cortina/presidio-asic/presidio.c   |  16 +-
> configs/cortina_presidio-asic-emmc_defconfig |  38 ++
> configs/cortina_presidio-asic-spi-nand_defconfig |  48 ++
> configs/cortina_presidio-asic-spi-nor_defconfig  |  59 +++
> drivers/i2c/Kconfig  |   7 +
> drivers/i2c/Makefile |   1 +
> drivers/i2c/i2c-cortina.c| 346 ++
> drivers/i2c/i2c-cortina.h|  92 
> drivers/led/Kconfig  |   8 +
> drivers/led/Makefile |   1 +
> drivers/led/led_cortina.c| 308 
> drivers/mmc/Kconfig  |  11 +
> drivers/mmc/Makefile |   1 +
> drivers/mmc/ca_dw_mmc.c  | 181 +++
> drivers/spi/Kconfig  |   8 +
> drivers/spi/Makefile |   1 +
> drivers/spi/ca_sflash.c  | 575 +++
> 19 files changed, 1744 insertions(+), 6 deletions(-)
> create mode 100644 configs/cortina_presidio-asic-emmc_defconfig
> create mode 100644 configs/cortina_presidio-asic-spi-nand_defconfig
> create mode 100644 configs/cortina_presidio-asic-spi-nor_defconfig
> create mode 100644 drivers/i2c/i2c-cortina.c
> create mode 100644 drivers/i2c/i2c-cortina.h
> create mode 100644 drivers/led/led_cortina.c
> create mode 100644 drivers/mmc/ca_dw_mmc.c
> create mode 100644 drivers/spi/ca_sflash.c
> 
> -- 
> 2.7.4
> 



RE: [PATCH 2/2] tegra: Enable CONFIG_BOOTP_PREFER_SERVERIP for all boards

2020-03-18 Thread Tom Warren
-Original Message-
From: Stephen Warren  
Sent: Wednesday, March 18, 2020 4:31 PM
To: Tom Warren 
Cc: u-boot@lists.denx.de; Stephen Warren ; Thierry Reding 
; Jonathan Hunter ; 
tomcwarren3...@gmail.com
Subject: Re: [PATCH 2/2] tegra: Enable CONFIG_BOOTP_PREFER_SERVERIP for all 
boards

External email: Use caution opening links or attachments


On 3/17/20 2:07 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
>
> This allows the user to set $serverip in the environment before 
> executing a DHCP request. If they do, U-Boot will use that IP rather 
> than using the IP in the DHCP response.

Acked-by: Stephen Warren 

I wonder if this should be applied to more Tegra boards, so they all work 
consistently? E.g. T20/30/114/124 boards.
[Tom] I can certainly do that, but I don't really test on anything 

RE: [PATCH 1/2] net: rt8169: WAR for DHCP not getting IP after kernel boot/reboot

2020-03-18 Thread Tom Warren
-Original Message-
From: Stephen Warren  
Sent: Wednesday, March 18, 2020 4:30 PM
To: Tom Warren 
Cc: u-boot@lists.denx.de; Stephen Warren ; Thierry Reding 
; Jonathan Hunter ; 
tomcwarren3...@gmail.com
Subject: Re: [PATCH 1/2] net: rt8169: WAR for DHCP not getting IP after kernel 
boot/reboot

External email: Use caution opening links or attachments


On 3/17/20 2:07 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
>
> This is a WAR for DHCP failure after rebooting from the L4T kernel. 
> The r8169.c kernel driver is setting bit 19 of the rt816x HW register 
> 0xF0, which goes by FuncEvent and MISC in various driver source/datasheets.
> That bit is called RxDv_Gated_En in the r8169.c kernel driver. Clear 
> it here at the end of probe to ensure that U-Boot can get an IP 
> assigned via DHCP.

Is there a way to reset the entire chip back to power-on state instead, just to 
make sure there aren't any other register bits that might cause issues in the 
future?
[Tom] Maybe, I'll have to look at the RTL spec, it's been awhile since I came 
up with this WAR.

Does this bit exist in all the different chips that the driver supports?
IIRC at least the Linux r8169 driver supports many different similar chips; I'm 
not sure if the U-Boot driver does too. Since this driver is shared between 
many boards in U-Boot, we need to make sure this change doesn't break anyone 
using a different Realtek chip to the exact one we use on Jetson.
[Tom] I'll look into it after I get Nano patches all in place upstream. If 
anyone runs into the problem described here w/no IP on net boot, they can use 
this as a WAR until I try for a more robust fix.

We need to send this patch to the network maintainers so they're aware of it, 
and they'll probably want to apply it.
[Tom] Will do.

> @@ -1207,6 +1210,19 @@ static int rtl8169_eth_probe(struct udevice 
> *dev)

> + u32 val = RTL_R32(FuncEvent);
> + debug("%s: FuncEvent/Misc (0xF0) = 0x%08X\n", __func__, val);
> + val &= ~RxDv_Gated_En;
> + RTL_W32(FuncEvent, val);

I vagueley recall that U-Boot coding style wants variables declared at the 
start of the block, but perhaps that's no longer true. What does 
scripts/checkpatch.pl say?
[Tom] I don't recall, I'll run it again and see.


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


RE: [PATCH] t210: pinmux: Remove pinmux/GPIO init from T210 boards

2020-03-18 Thread Tom Warren
-Original Message-
From: Stephen Warren  
Sent: Wednesday, March 18, 2020 4:14 PM
To: Tom Warren 
Cc: u-boot@lists.denx.de; Stephen Warren ; Thierry Reding 
; Jonathan Hunter ; 
tomcwarren3...@gmail.com
Subject: Re: [PATCH] t210: pinmux: Remove pinmux/GPIO init from T210 boards

External email: Use caution opening links or attachments


On 3/17/20 3:55 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
>
> T210 CBoot is now doing the full pinmux and GPIO init, based on the 
> DTB tables. Remove pinmux/GPIO init tables & code from all T210-based 
> builds
> below:
>
> p2371-2180 aka TX1
> p2371-
> e2220-1170
> p2571

Acked-by: Stephen Warren 

It may be worth updating the commit description to mention explicitly which L4T 
release's FW is required when using a U-Boot that has this patch applied.
[Tom] I'll do that for v2, thanks.

Can we remove the T210 pinmux driver from U-Boot with this patch applied?
[Tom] Good idea, I'll look at it. Seems like it should work if I excise 
arch/arm/mach-tegra/pinmux.c.


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


Re: [PATCH 2/2] tegra: Enable CONFIG_BOOTP_PREFER_SERVERIP for all boards

2020-03-18 Thread Stephen Warren
On 3/17/20 2:07 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
> 
> This allows the user to set $serverip in the environment before
> executing a DHCP request. If they do, U-Boot will use that IP rather
> than using the IP in the DHCP response.

Acked-by: Stephen Warren 

I wonder if this should be applied to more Tegra boards, so they all
work consistently? E.g. T20/30/114/124 boards.


Re: [PATCH 1/2] net: rt8169: WAR for DHCP not getting IP after kernel boot/reboot

2020-03-18 Thread Stephen Warren
On 3/17/20 2:07 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
> 
> This is a WAR for DHCP failure after rebooting from the L4T kernel. The
> r8169.c kernel driver is setting bit 19 of the rt816x HW register 0xF0,
> which goes by FuncEvent and MISC in various driver source/datasheets.
> That bit is called RxDv_Gated_En in the r8169.c kernel driver. Clear it
> here at the end of probe to ensure that U-Boot can get an IP assigned
> via DHCP.

Is there a way to reset the entire chip back to power-on state instead,
just to make sure there aren't any other register bits that might cause
issues in the future?

Does this bit exist in all the different chips that the driver supports?
IIRC at least the Linux r8169 driver supports many different similar
chips; I'm not sure if the U-Boot driver does too. Since this driver is
shared between many boards in U-Boot, we need to make sure this change
doesn't break anyone using a different Realtek chip to the exact one we
use on Jetson.

We need to send this patch to the network maintainers so they're aware
of it, and they'll probably want to apply it.

> @@ -1207,6 +1210,19 @@ static int rtl8169_eth_probe(struct udevice *dev)

> + u32 val = RTL_R32(FuncEvent);
> + debug("%s: FuncEvent/Misc (0xF0) = 0x%08X\n", __func__, val);
> + val &= ~RxDv_Gated_En;
> + RTL_W32(FuncEvent, val);

I vagueley recall that U-Boot coding style wants variables declared at
the start of the block, but perhaps that's no longer true. What does
scripts/checkpatch.pl say?


Re: [PATCH 2/5] t210: do not enable PLLE and UPHY PLL HW PWRSEQ

2020-03-18 Thread Stephen Warren
On 3/17/20 7:44 PM, JC Kuo wrote:
> Please refer to "Notes" section in p1337 of Tegra_X1_TRM_DP07225001_v1.3p.pdf.
> There are some implementation considerations for boot software.

OK, I assume you mean this note:

Boot loader should not enable hardware power sequencer. Boot loader
should enable the required PLLs in software controlled state.

That's interesting, since I explicitly added the code to program PLLE in
HW controlled mode after discussing with the relevant HW engineers the
need to clean up the programming sequence in the following pages, and it
was clearly communicated that this was in the context of a bootloader,
and they pointed out that the bootloader needed to enable HW control but
didn't. Sigh. I guess I should have read the sections prior to the
programming sequence too.

So I guess this change is OK, and since we have it downstream it seems
to operate OK in practice too.

Acked-by: Stephen Warren 

> Thanks,
> JC
> 
> On 3/18/20 1:44 AM, Tom Warren wrote:
>> -Original Message-
>> From: Stephen Warren  
>> Sent: Tuesday, March 17, 2020 10:30 AM
>> To: Tom Warren 
>> Cc: u-boot@lists.denx.de; Jui Chang Kuo 
>> Subject: Re: [PATCH 2/5] t210: do not enable PLLE and UPHY PLL HW PWRSEQ
>>
>> External email: Use caution opening links or attachments
>>
>>
>> On 3/16/20 1:40 PM, twar...@nvidia.com wrote:
>>> From: JC Kuo 
>>>
>>> This commit removes the programming sequence that enables PLLE and 
>>> UPHY PLL hardware power sequencers. Per TRM, boot software should 
>>> enable PLLE and UPHY PLLs in software controlled power-on state and 
>>> should power down PLL before jumping into kernel or the next stage boot 
>>> software.
>>>
>>> Adds call to board_cleanup_before_linux to facilitate this.
>>
>> This directly contradicts what's in Tegra_X1_TRM_DP07225001_v1.3p.pdf,
>> pages 1340/1341, which is what the code currently implements. Was a newer 
>> internal-only TRM published that changed the recommended programming flow?
>> [Tom] JC wrote this, I'll let him answer, but I'll check my TRM to see what 
>> the most recent version is. This code is exactly what we have in downstream 
>> T210 U-Boot.
>>
> 
> ---
> This email message is for the sole use of the intended recipient(s) and may 
> contain
> confidential information.  Any unauthorized review, use, disclosure or 
> distribution
> is prohibited.  If you are not the intended recipient, please contact the 
> sender by
> reply email and destroy all copies of the original message.
> ---
> 



Re: [PATCH] ARM: tegra: p2371-2180: add I2C nodes to DT

2020-03-18 Thread Stephen Warren
On 3/18/20 4:18 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
> 
> This adds to the DT the I2C controllers that connect to the board ID 
> EEPROM, camera board EEPROM, etc. With this change, you can now probe 
> all I2C devices on a TX1 board.

Acked-by: Stephen Warren 


Re: [PATCH] t210: pinmux: Remove pinmux/GPIO init from T210 boards

2020-03-18 Thread Stephen Warren
On 3/17/20 3:55 PM, twar...@nvidia.com wrote:
> From: Tom Warren 
> 
> T210 CBoot is now doing the full pinmux and GPIO init, based on the DTB
> tables. Remove pinmux/GPIO init tables & code from all T210-based builds
> below:
> 
> p2371-2180 aka TX1
> p2371-
> e2220-1170
> p2571

Acked-by: Stephen Warren 

It may be worth updating the commit description to mention explicitly
which L4T release's FW is required when using a U-Boot that has this
patch applied.

Can we remove the T210 pinmux driver from U-Boot with this patch applied?


[PATCH] ARM: tegra: p2371-2180: add I2C nodes to DT

2020-03-18 Thread twarren
From: Tom Warren 

This adds to the DT the I2C controllers that connect to the board ID 
EEPROM, camera board EEPROM, etc. With this change, you can now probe 
all I2C devices on a TX1 board.

Signed-off-by: Tom Warren 
---
 arch/arm/dts/tegra210-p2371-2180.dts | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/dts/tegra210-p2371-2180.dts 
b/arch/arm/dts/tegra210-p2371-2180.dts
index c2f497c..d982b5f 100644
--- a/arch/arm/dts/tegra210-p2371-2180.dts
+++ b/arch/arm/dts/tegra210-p2371-2180.dts
@@ -12,6 +12,9 @@
 
aliases {
i2c0 = "/i2c@7000d000";
+   i2c2 = "/i2c@7000c400";
+   i2c3 = "/i2c@7000c500";
+   i2c5 = "/i2c@546c0c00";
mmc0 = "/sdhci@700b0600";
mmc1 = "/sdhci@700b";
usb0 = "/usb@7d00";
@@ -33,6 +36,11 @@
};
};
 
+   i2c@546c0c00 {
+   status = "okay";
+   clock-frequency = <40>;
+   };
+
padctl@7009f000 {
pinctrl-0 = <&padctl_default>;
pinctrl-names = "default";
@@ -85,6 +93,16 @@
non-removable;
};
 
+   i2c@7000c400 {
+   status = "okay";
+   clock-frequency = <40>;
+   };
+
+   i2c@7000c500 {
+   status = "okay";
+   clock-frequency = <40>;
+   };
+
i2c@7000d000 {
status = "okay";
clock-frequency = <40>;
-- 
1.8.2.1.610.g562af5b


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


[PATCH 1/2 v2] mmc: t210: Add autocal and tap/trim updates for SDMMC1/3

2020-03-18 Thread twarren
From: Tom Warren 

As per the T210 TRM, when running at 3.3v, the SDMMC1 tap/trim and
autocal values need to be set to condition the signals correctly before
talking to the SD-card. This is the same as what's being done in CBoot,
but it gets reset when the SDMMC1 HW is soft-reset during SD driver
init, so needs to be repeated here. Also set autocal and tap/trim for
SDMMC3, although no T210 boards use it for SD-card at this time.

Signed-off-by: Tom Warren 
---
Changes for v2:
   - Added clocks.h include for TEGRA30 to fix T30 32-bit builds

 arch/arm/include/asm/arch-tegra/tegra_mmc.h | 20 +--
 drivers/mmc/tegra_mmc.c | 84 ++---
 2 files changed, 92 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/tegra_mmc.h 
b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
index a2b6f63..a8bfa46 100644
--- a/arch/arm/include/asm/arch-tegra/tegra_mmc.h
+++ b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
@@ -2,7 +2,7 @@
 /*
  * (C) Copyright 2009 SAMSUNG Electronics
  * Minkyu Kang 
- * Portions Copyright (C) 2011-2012 NVIDIA Corporation
+ * Portions Copyright (C) 2011-2012,2019 NVIDIA Corporation
  */
 
 #ifndef __TEGRA_MMC_H_
@@ -52,7 +52,7 @@ struct tegra_mmc {
unsigned char   admaerr;/* offset 54h */
unsigned char   res4[3];/* RESERVED, offset 55h-57h */
unsigned long   admaaddr;   /* offset 58h-5Fh */
-   unsigned char   res5[0xa0]; /* RESERVED, offset 60h-FBh */
+   unsigned char   res5[0x9c]; /* RESERVED, offset 60h-FBh */
unsigned short  slotintstatus;  /* offset FCh */
unsigned short  hcver;  /* HOST Version */
unsigned intvenclkctl;  /* _VENDOR_CLOCK_CNTRL_0,100h */
@@ -127,11 +127,23 @@ struct tegra_mmc {
 
 #define TEGRA_MMC_NORINTSIGEN_XFER_COMPLETE(1 << 1)
 
-/* SDMMC1/3 settings from section 24.6 of T30 TRM */
+/* SDMMC1/3 settings from SDMMCx Initialization Sequence of TRM */
 #define MEMCOMP_PADCTRL_VREF   7
-#define AUTO_CAL_ENABLED   (1 << 29)
+#define AUTO_CAL_ENABLE(1 << 29)
+#if defined(CONFIG_TEGRA210)
+#define AUTO_CAL_ACTIVE(1 << 31)
+#define AUTO_CAL_START (1 << 31)
+#define AUTO_CAL_PD_OFFSET (0x7D << 8)
+#define AUTO_CAL_PU_OFFSET (0 << 0)
+#define IO_TRIM_BYPASS_MASK(1 << 2)
+#define TRIM_VAL_SHIFT 24
+#define TRIM_VAL_MASK  (0x1F << TRIM_VAL_SHIFT)
+#define TAP_VAL_SHIFT  16
+#define TAP_VAL_MASK   (0xFF << TAP_VAL_SHIFT)
+#else
 #define AUTO_CAL_PD_OFFSET (0x70 << 8)
 #define AUTO_CAL_PU_OFFSET (0x62 << 0)
+#endif
 
 #endif /* __ASSEMBLY__ */
 #endif /* __TEGRA_MMC_H_ */
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index f022e93..73ac58c 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -3,7 +3,7 @@
  * (C) Copyright 2009 SAMSUNG Electronics
  * Minkyu Kang 
  * Jaehoon Chung 
- * Portions Copyright 2011-2016 NVIDIA Corporation
+ * Portions Copyright 2011-2019 NVIDIA Corporation
  */
 
 #include 
@@ -15,6 +15,9 @@
 #include 
 #include 
 #include 
+#if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA210)
+#include 
+#endif
 
 struct tegra_mmc_plat {
struct mmc_config cfg;
@@ -30,6 +33,7 @@ struct tegra_mmc_priv {
struct gpio_desc wp_gpio;   /* Write Protect GPIO */
unsigned int version;   /* SDHCI spec. version */
unsigned int clock; /* Current clock (MHz) */
+   int mmc_id; /* peripheral id */
 };
 
 static void tegra_mmc_set_power(struct tegra_mmc_priv *priv,
@@ -446,16 +450,19 @@ static int tegra_mmc_set_ios(struct udevice *dev)
 
 static void tegra_mmc_pad_init(struct tegra_mmc_priv *priv)
 {
-#if defined(CONFIG_TEGRA30)
+#if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA210)
u32 val;
+   u16 clk_con;
+   int timeout;
+   int id = priv->mmc_id;
 
-   debug("%s: sdmmc address = %08x\n", __func__, (unsigned int)priv->reg);
+   debug("%s: sdmmc address = %p, id = %d\n", __func__,
+   priv->reg, id);
 
/* Set the pad drive strength for SDMMC1 or 3 only */
-   if (priv->reg != (void *)0x7800 &&
-   priv->reg != (void *)0x78000400) {
+   if (id != PERIPH_ID_SDMMC1 && id != PERIPH_ID_SDMMC3) {
debug("%s: settings are only valid for SDMMC1/SDMMC3!\n",
- __func__);
+   __func__);
return;
}
 
@@ -464,11 +471,65 @@ static void tegra_mmc_pad_init(struct tegra_mmc_priv 
*priv)
val |= MEMCOMP_PADCTRL_VREF;
writel(val, &priv->reg->sdmemcmppadctl);
 
+   /* Disable SD Clock Enable before running auto-cal as per TRM */
+   clk_con = readw(&priv->reg->clkcon);
+   debug("%s: CLOCK_CONTROL = 0x%04X\n", __func__, clk_con);
+   clk_con &= ~TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE;
+   writew(clk_con, &priv->reg->clkcon);
+
val = readl(&priv->reg->autoc

Re: [PATCH 1/1] efi_loader: create reservations after ft_board_setup

2020-03-18 Thread Atish Patra
On Sat, Mar 14, 2020 at 3:12 AM Heinrich Schuchardt  wrote:
>
> Some memory reservations are made in ft_board_setup(). Ensure that we
> create reserved memory map entries after ft_board_setup().
>
> The downside of this patch is that if bootefi is called multiple times with
> an devicetree argument superfluous reservations for the old copies of the
> device tree will exist. But that is still better than missing a reservation.
>
> Deleting the superfluous reservations is not possible because reservations
> in the memory map are rounded to page size and may be coallesced.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/bootefi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 485f4b408a..9990959fe7 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -293,9 +293,6 @@ efi_status_t efi_install_fdt(void *fdt)
> return EFI_LOAD_ERROR;
> }
>
> -   /* Create memory reservations as indicated by the device tree */
> -   efi_carve_out_dt_rsv(fdt);
> -
> /* Prepare device tree for payload */
> ret = copy_fdt(&fdt);
> if (ret) {
> @@ -303,6 +300,9 @@ efi_status_t efi_install_fdt(void *fdt)
> return EFI_OUT_OF_RESOURCES;
> }
>
> +   /* Create memory reservations as indicated by the device tree */
> +   efi_carve_out_dt_rsv(fdt);
> +
> /* Install device tree as UEFI table */
> ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
> if (ret != EFI_SUCCESS) {
> --
> 2.25.1
>
As per my understanding, copy_fdt tries allocate efi memory below dram
start + 127MB
for device tree. If efi_carve_out_dt_rsv is called after copy_fdt, it
may overwrite
a reserved-memory region. No ?



-- 
Regards,
Atish


Re: [PATCH v3 2/5] cmd: bootefi: Parse reserved-memory node from DT

2020-03-18 Thread Atish Patra
On Tue, Mar 17, 2020 at 3:02 PM Heinrich Schuchardt  wrote:
>
> On 3/17/20 10:19 PM, Atish Patra wrote:
> > Currently, bootefi only parses memory reservation block to setup
> > EFI reserved memory mappings. However, it doesn't parse the
> > reserved-memory[1] device tree node that also can contain the
> > reserved memory regions.
> >
> > Add capability to parse reserved-memory node and update the EFI memory
> > mappings accordingly.
> >
> > 1.  > source>/doc/device-tree-bindings/reserved-memory/reserved-memory.txt]
> >
> > Signed-off-by: Atish Patra 
> > ---
> >   cmd/bootefi.c | 44 +++-
> >   1 file changed, 35 insertions(+), 9 deletions(-)
> >
> > diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> > index 24fc42ae898e..291cb2d69ff6 100644
> > --- a/cmd/bootefi.c
> > +++ b/cmd/bootefi.c
> > @@ -149,6 +149,20 @@ done:
> >   return ret;
> >   }
> >
> > +static void efi_reserve_memory(uint64_t addr, uint64_t size)
> > +{
> > + uint64_t pages;
> > +
> > + /* Convert from sandbox address space. */
> > + addr = (uintptr_t)map_sysmem(addr, 0);
> > + pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
> > + addr &= ~EFI_PAGE_MASK;
> > + if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
> > +false) != EFI_SUCCESS)
> > + printf("Reserved memory mapping failed addr %llx size %llx\n",
> > +   (unsigned long long)addr, (unsigned long long)size);
> > +}
> > +
> >   /**
> >* efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
> >*
> > @@ -161,7 +175,8 @@ done:
> >   static void efi_carve_out_dt_rsv(void *fdt)
> >   {
> >   int nr_rsv, i;
> > - uint64_t addr, size, pages;
> > + uint64_t addr, size;
> > + int nodeoffset, subnode;
> >
> >   nr_rsv = fdt_num_mem_rsv(fdt);
> >
> > @@ -169,15 +184,26 @@ static void efi_carve_out_dt_rsv(void *fdt)
> >   for (i = 0; i < nr_rsv; i++) {
> >   if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
> >   continue;
> > + efi_reserve_memory(addr, size);
> > + }
> >
> > - /* Convert from sandbox address space. */
> > - addr = (uintptr_t)map_sysmem(addr, 0);
> > -
> > - pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
> > - addr &= ~EFI_PAGE_MASK;
> > - if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
> > -false) != EFI_SUCCESS)
> > - printf("FDT memrsv map %d: Failed to add to map\n", 
> > i);
> > + /* process reserved-memory */
> > + nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory");
> > + if (nodeoffset < 0)
> > + return;
> > + subnode = fdt_first_subnode(fdt, nodeoffset);
> > + while (subnode >= 0) {
> > + /* check if this subnode has a reg property */
> > + addr = fdtdec_get_addr_size_auto_noparent(fdt, subnode,
> > +   "reg", 0,
> > +   (fdt_size_t *)&size,
> > +   true);
> > + if (addr == FDT_ADDR_T_NONE) {
> > + debug("failed to read address/size\n");
> > + continue;
>
> As you do not update subnode you never leave the loop, cf.
> https://lists.denx.de/pipermail/u-boot/2020-March/402891.html
>


Thanks for the fix. I have verified your sandbox patches as well with
bootefi hello
and efidebug memmap as well.

> Best regards
>
> Heinrich
>
> > + }
> > + efi_reserve_memory(addr, size);
> > + subnode = fdt_next_subnode(fdt, subnode);
> >   }
> >   }
> >
> >
>


-- 
Regards,
Atish


[PATCH] menu: add support for client defined statusline function

2020-03-18 Thread Thirupathaiah Annapureddy
Currently displaying status line is done in a weak function
menu_display_statusline().

bootmenu.c overrides the weak default function.
It calls menu_default_choice() and interprets the data as
struct bootmenu_entry.

pxe boot also uses common menu code for pxe menus.
If there is a system that enables both bootmenu and pxe,
menu_display_statusline() defined in bootmenu.c will be called
and it will interpret struct pxe_label as struct bootmenu_entry.
This leads to data aborts and pxe menu corruptions.

This patch adds support for client defined statusline function
to resolve the above bug.

Signed-off-by: Thirupathaiah Annapureddy 
---
 cmd/bootmenu.c  | 61 +
 cmd/pxe_utils.c |  2 +-
 common/menu.c   | 13 +++
 include/menu.h  |  2 +-
 4 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 3dc2c854ac..f1562883f5 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -365,6 +365,34 @@ cleanup:
return NULL;
 }
 
+static void menu_display_statusline(struct menu *m)
+{
+   struct bootmenu_entry *entry;
+   struct bootmenu_data *menu;
+
+   if (menu_default_choice(m, (void *)&entry) < 0)
+   return;
+
+   menu = entry->menu;
+
+   printf(ANSI_CURSOR_POSITION, 1, 1);
+   puts(ANSI_CLEAR_LINE);
+   printf(ANSI_CURSOR_POSITION, 2, 1);
+   puts("  *** U-Boot Boot Menu ***");
+   puts(ANSI_CLEAR_LINE_TO_END);
+   printf(ANSI_CURSOR_POSITION, 3, 1);
+   puts(ANSI_CLEAR_LINE);
+
+   /* First 3 lines are bootmenu header + 2 empty lines between entries */
+   printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
+   puts(ANSI_CLEAR_LINE);
+   printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
+   puts("  Press UP/DOWN to move, ENTER to select");
+   puts(ANSI_CLEAR_LINE_TO_END);
+   printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
+   puts(ANSI_CLEAR_LINE);
+}
+
 static void bootmenu_show(int delay)
 {
int init = 0;
@@ -396,8 +424,9 @@ static void bootmenu_show(int delay)
if (!bootmenu)
return;
 
-   menu = menu_create(NULL, bootmenu->delay, 1, bootmenu_print_entry,
-  bootmenu_choice_entry, bootmenu);
+   menu = menu_create(NULL, bootmenu->delay, 1, menu_display_statusline,
+  bootmenu_print_entry, bootmenu_choice_entry,
+  bootmenu);
if (!menu) {
bootmenu_destroy(bootmenu);
return;
@@ -445,34 +474,6 @@ cleanup:
 #endif
 }
 
-void menu_display_statusline(struct menu *m)
-{
-   struct bootmenu_entry *entry;
-   struct bootmenu_data *menu;
-
-   if (menu_default_choice(m, (void *)&entry) < 0)
-   return;
-
-   menu = entry->menu;
-
-   printf(ANSI_CURSOR_POSITION, 1, 1);
-   puts(ANSI_CLEAR_LINE);
-   printf(ANSI_CURSOR_POSITION, 2, 1);
-   puts("  *** U-Boot Boot Menu ***");
-   puts(ANSI_CLEAR_LINE_TO_END);
-   printf(ANSI_CURSOR_POSITION, 3, 1);
-   puts(ANSI_CLEAR_LINE);
-
-   /* First 3 lines are bootmenu header + 2 empty lines between entries */
-   printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
-   puts(ANSI_CLEAR_LINE);
-   printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
-   puts("  Press UP/DOWN to move, ENTER to select");
-   puts(ANSI_CLEAR_LINE_TO_END);
-   printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
-   puts(ANSI_CLEAR_LINE);
-}
-
 #ifdef CONFIG_AUTOBOOT_MENU_SHOW
 int menu_show(int bootdelay)
 {
diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 53af04d7dc..c244bfb10d 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -1237,7 +1237,7 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
 * Create a menu and add items for all the labels.
 */
m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10),
-   cfg->prompt, label_print, NULL, NULL);
+   cfg->prompt, NULL, label_print, NULL, NULL);
 
if (!m)
return NULL;
diff --git a/common/menu.c b/common/menu.c
index 7b66d199a9..5fb2ffbd06 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -36,6 +36,7 @@ struct menu {
int timeout;
char *title;
int prompt;
+   void (*display_statusline)(struct menu *);
void (*item_data_print)(void *);
char *(*item_choice)(void *);
void *item_choice_data;
@@ -106,10 +107,6 @@ static inline void *menu_item_destroy(struct menu *m,
return NULL;
 }
 
-__weak void menu_display_statusline(struct menu *m)
-{
-}
-
 /*
  * Display a menu so the user can make a choice of an item. First display its
  * title, if any, and then each item in the menu.
@@ -120,7 +117,8 @@ static inline void menu_display(struct menu *m)
puts(m->title);
putc('\n');
}
-   menu_display_statusline(m);
+   if (m->display_statusline)

[PATCH v6 12/12] doc: boards: add Cubieboard7 documentation

2020-03-18 Thread Amit Singh Tomar
This adds build and flash steps for Actions S700
based Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Convert plain text documentation to reStructuredText format.
Changes since v2:
* No Change.
Changes since v1:
* No Change.
---
 doc/board/actions/cubieboard7.rst | 115 ++
 doc/board/actions/index.rst   |  10 
 doc/board/index.rst   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst

diff --git a/doc/board/actions/cubieboard7.rst 
b/doc/board/actions/cubieboard7.rst
new file mode 100644
index 000..ce39e6b
--- /dev/null
+++ b/doc/board/actions/cubieboard7.rst
@@ -0,0 +1,115 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2020 Amit Singh Tomar 
+
+ACTIONS
+
+
+About this
+--
+
+This document describes build and flash steps for Actions S700 SoC based 
Cubieboard7
+board.
+
+Cubieboard7 initial configuration
+-
+
+Default Cubieboard7 comes with pre-installed Android where U-Boot is 
configured with
+a bootdelay of 0, entering a prompt by pressing keys does not seem to work.
+
+Though, one can enter ADFU mode and flash debian image(from host machine) where
+getting into u-boot prompt is easy.
+
+Enter ADFU Mode
+
+
+Before write the firmware, let the development board entering the ADFU mode: 
insert
+one end of the USB cable to the PC, press and hold the ADFU button, and then 
connect
+the other end of the USB cable to the Mini USB port of the development board, 
release
+the ADFU button, after connecting it will enter the ADFU mode.
+
+Check whether entered ADFU Mode
+
+
+The user needs to run the following command on the PC side to check if the ADFU
+device is detected. ID realted to "Actions Semiconductor Co., Ltd"  means that
+the PC side has been correctly detected ADFU device, the development board
+also enter into the ADFU mode.
+
+.. code-block:: none
+
+   $ lsusb
+   Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd
+   Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 
[ThinkPad]
+   Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
+   Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
+   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+   Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
+   Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd
+   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+
+Flashing debian image
+-
+
+.. code-block:: none
+
+   $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw
+   ActionsFWU.py   : 1.0.150828.0830
+   libScript.so: 2.3.150825.0951
+   libFileSystem.so: 2.3.150825.0952
+   libProduction.so: 2.3.150915.1527
+   =burn all partition
+   FW_VER: 3.10.37.180608
+   3% DOWNLOAD ADFUDEC ...
+   5% DOWNLOAD BOOT PARA ...
+   7% SWITCH ADFUDEC ...
+   12% DOWNLOAD BL31 ...
+   13% DOWNLOAD BL32 ...
+   15% DOWNLOAD VMLINUX ...
+   20% DOWNLOAD INITRD ...
+   24% DOWNLOAD FDT ...
+   27% DOWNLOAD ADFUS ...
+   30% SWITCH ADFUS ...
+   32% DOWNLOAD MBR ...
+   35% DOWNLOAD PARTITIONS ...
+   WRITE_MBRC_PARTITION
+   35% write p0 size = 2048 : ok
+   WRITE_BOOT_PARTITION
+   35% write p1 size = 2048 : ok
+   WRITE_MISC_PARTITION
+   36% write p2 size = 98304 : ok
+   WRITE_SYSTEM_PARTITION
+   94% write p3 size = 4608000 : ok
+   FORMAT_SWAP_PARTITION
+   94% write p4 size = 20480 : ok
+   95% TRANSFER OVER ...
+   Firmware upgrade successfully!
+
+Debian image can be downloaded from here[1].
+
+Once debian image is flashed, one can get into u-boot prompt by pressing any 
key and from
+there run ums command(make sure, usb cable is connected between host and 
target):
+
+.. code-block:: none
+
+   owl> ums 0 mmc 1
+
+Above command would mount debian image partition on host machine.
+
+Building U-BOOT proper image
+
+
+.. code-block:: none
+
+   $ make clean
+   $ export CROSS_COMPILE=aarch64-linux-gnu-
+   $ make ARCH=arm cubieboard7_defconfig
+   $ make -j16
+   $ mkimage -A arm -T firmware -C none -O u-boot -a 0x1100 -e 0x1100 
-d u-boot-dtb.bin u-boot-dtb.img  >/dev/null
+
+u-boot-dtb.img can now be flashed to debian image partition mounted on host 
machine.
+
+.. code-block:: none
+
+   $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072
+
+[1]: 
https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FCubieBoard_Download%2FBoard%2FCubieBoard7%2F%E6%96%B9%E7%B3%96%E6%96%B9%E6%A1%88%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99%2FImage%2FDebian%2FV2.1-test&parentPath=%2F
diff --git a/doc/board/actions/index.rst b/doc/board/actions/index.rst
new file mode 100644
index 0

Re: [PATCH v2 12/14] image: Use constants for 'required' and 'key-name-hint'

2020-03-18 Thread Philippe REYNES



> Objet: [PATCH v2 12/14] image: Use constants for 'required' and 
> 'key-name-hint'

> These are used in multiple places so update them to use a shared #define.
> 
> Signed-off-by: Simon Glass 

Reviewed-by: Philippe Reynes 

> ---
> 
> Changes in v2: None
> 
> common/image-cipher.c | 2 +-
> common/image-fit.c | 6 +++---
> common/image-sig.c | 8 +---
> include/image.h | 4 +++-
> lib/rsa/rsa-sign.c | 6 +++---
> tools/image-host.c | 8 
> 6 files changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/common/image-cipher.c b/common/image-cipher.c
> index cee3b03ee5..f50c3d31bd 100644
> --- a/common/image-cipher.c
> +++ b/common/image-cipher.c
> @@ -88,7 +88,7 @@ static int fit_image_setup_decrypt(struct image_cipher_info
> *info,
> return -1;
> }
> 
> - info->keyname = fdt_getprop(fit, cipher_noffset, "key-name-hint", NULL);
> + info->keyname = fdt_getprop(fit, cipher_noffset, FIT_KEY_HINT, NULL);
> if (!info->keyname) {
> printf("Can't get key name\n");
> return -1;
> diff --git a/common/image-fit.c b/common/image-fit.c
> index a5c85ede8d..c8ff77526c 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -168,7 +168,7 @@ static void fit_image_print_data(const void *fit, int
> noffset, const char *p,
> int value_len;
> char *algo;
> const char *padding;
> - int required;
> + bool required;
> int ret, i;
> 
> debug("%s %s node: '%s'\n", p, type,
> @@ -179,8 +179,8 @@ static void fit_image_print_data(const void *fit, int
> noffset, const char *p,
> return;
> }
> printf("%s", algo);
> - keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
> - required = fdt_getprop(fit, noffset, "required", NULL) != NULL;
> + keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
> + required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL) != NULL;
> if (keyname)
> printf(":%s", keyname);
> if (required)
> diff --git a/common/image-sig.c b/common/image-sig.c
> index 03143a4040..6563effcf3 100644
> --- a/common/image-sig.c
> +++ b/common/image-sig.c
> @@ -229,7 +229,7 @@ static int fit_image_setup_verify(struct image_sign_info
> *info,
> padding_name = RSA_DEFAULT_PADDING_NAME;
> 
> memset(info, '\0', sizeof(*info));
> - info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
> + info->keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
> info->fit = (void *)fit;
> info->node_offset = noffset;
> info->name = algo_name;
> @@ -340,7 +340,8 @@ int fit_image_verify_required_sigs(const void *fit, int
> image_noffset,
> const char *required;
> int ret;
> 
> - required = fdt_getprop(sig_blob, noffset, "required", NULL);
> + required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
> + NULL);
> if (!required || strcmp(required, "image"))
> continue;
> ret = fit_image_verify_sig(fit, image_noffset, data, size,
> @@ -557,7 +558,8 @@ int fit_config_verify_required_sigs(const void *fit, int
> conf_noffset,
> const char *required;
> int ret;
> 
> - required = fdt_getprop(sig_blob, noffset, "required", NULL);
> + required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
> + NULL);
> if (!required || strcmp(required, "conf"))
> continue;
> ret = fit_config_verify_sig(fit, conf_noffset, sig_blob,
> diff --git a/include/image.h b/include/image.h
> index 512243f159..3ffc0fdd68 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -939,12 +939,14 @@ int booti_setup(ulong image, ulong *relocated_addr, 
> ulong
> *size,
> #define FIT_IMAGES_PATH "/images"
> #define FIT_CONFS_PATH "/configurations"
> 
> -/* hash/signature node */
> +/* hash/signature/key node */
> #define FIT_HASH_NODENAME "hash"
> #define FIT_ALGO_PROP "algo"
> #define FIT_VALUE_PROP "value"
> #define FIT_IGNORE_PROP "uboot-ignore"
> #define FIT_SIG_NODENAME "signature"
> +#define FIT_KEY_REQUIRED "required"
> +#define FIT_KEY_HINT "key-name-hint"
> 
> /* cipher node */
> #define FIT_CIPHER_NODENAME "cipher"
> diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
> index 6400ef63d6..580c744709 100644
> --- a/lib/rsa/rsa-sign.c
> +++ b/lib/rsa/rsa-sign.c
> @@ -792,8 +792,8 @@ int rsa_add_verify_data(struct image_sign_info *info, void
> *keydest)
> }
> 
> if (!ret) {
> - ret = fdt_setprop_string(keydest, node, "key-name-hint",
> - info->keyname);
> + ret = fdt_setprop_string(keydest, node, FIT_KEY_HINT,
> + info->keyname);
> }
> if (!ret)
> ret = fdt_setprop_u32(keydest, node, "rsa,num-bits", bits);
> @@ -815,7 +815,7 @@ int rsa_add_verify_data(struct image_sign_info *info, void
> *keydest)
> info->name);
> }
> if (!ret && info->require_keys) {
> - ret = fdt_setprop_string(keydest, node, "required",
> + ret = fdt_setprop_string(keydest, node, FIT_KEY_REQUIRED,
> info->require_keys);
> }
> done:
> diff --git a/tools/image-host.c b/tools/image-host.c
> index dfea48e894..4e57ddea96 100644
> --- a/tools/image-host.c
> +++ b/tools/image-host.c
> @@ -170,7 +170,7 @@ static int fit_image_setup_sig(struct image_sign_info 
> *info,
> 
> memset(info, '\0', sizeof(*info));
> info->keydir = keydir;
> - info->keyname = fdt_getprop

[PATCH v6 10/12] actions: Move defconfig options to Kconfig

2020-03-18 Thread Amit Singh Tomar
This patch moves some of the config options from bubblegum_96_defconfig
to platform specific Kconfig file.

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Newly added patch, was not there in earlier versions. 
---
 arch/arm/mach-owl/Kconfig  | 16 
 configs/bubblegum_96_defconfig |  5 -
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 1d59d8f..0bd02e2 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -25,4 +25,20 @@ config SYS_SOC
 default "s900" if MACH_S900
 default "s700" if MACH_S700
 
+config DISTRO_DEFAULTS
+   default y
+
+config NR_DRAM_BANKS
+   default 1
+
+config SYS_RELOC_GD_ENV_ADDR
+   default y
+
+config SYS_PROMPT
+   string "Shell prompt"
+   default "U-Boot => "
+
+config DISPLAY_BOARDINFO
+   default n
+
 endif
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index e76e9a2..0883167 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,19 +1,14 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OWL=y
 CONFIG_ENV_SIZE=0x2000
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_MACH_S900=y
 CONFIG_IDENT_STRING="\nBubblegum-96"
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=5
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyOWL5,115200n8"
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_SYS_PROMPT="U-Boot => "
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.7.4



[PATCH v6 09/12] arm: add support Actions Semi S700

2020-03-18 Thread Amit Singh Tomar
This patch adds basic support for Actions Semi based S700
SoC, which is driven by common owl framework.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Added reviewed-by tag.
Changes since v4:
* Moved it to 09/11 to 04/11.
Changes since v3:
* Added "SoC" keyword to Actions Semi S700.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/mach-owl/Kconfig |  6 ++
 include/configs/s700.h| 13 +
 2 files changed, 19 insertions(+)
 create mode 100644 include/configs/s700.h

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index d0be2b5..1d59d8f 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -8,6 +8,10 @@ config MACH_S900
 bool "Actions Semi S900 SoC"
 select ARM64
 
+config MACH_S700
+bool "Actions Semi S700 SoC"
+select ARM64
+
 endchoice
 
 config SYS_TEXT_BASE
@@ -15,8 +19,10 @@ config SYS_TEXT_BASE
 
 config SYS_CONFIG_NAME
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 config SYS_SOC
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 endif
diff --git a/include/configs/s700.h b/include/configs/s700.h
new file mode 100644
index 000..fab0d04
--- /dev/null
+++ b/include/configs/s700.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ */
+
+#ifndef _CONFIG_S700_H_
+#define _CONFIG_S700_H_
+
+/*
+ * Include common owl configuration where most the settings are
+ */
+#include 
+
+#endif
-- 
2.7.4



[PATCH v6 11/12] arm: add Cubieboard7 board support

2020-03-18 Thread Amit Singh Tomar
The Cubieboard is a single board computer containing a
Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores).

This patch adds respective defconfig alongwith .dts(copied
from Linux v5.5-rc6 with hash "b3a987b0264d").

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Trimmed of the cubieboard7_defconfig.
Changes since v4:
* No changes.
Changes since v3:
* added reviewed-by: tag.
Changes since v2:
* No changes.   
Changes since v1:
* No changes.   
---
 arch/arm/dts/s700-cubieboard7.dts | 92 +++
 configs/cubieboard7_defconfig |  9 
 2 files changed, 101 insertions(+)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 configs/cubieboard7_defconfig

diff --git a/arch/arm/dts/s700-cubieboard7.dts 
b/arch/arm/dts/s700-cubieboard7.dts
new file mode 100644
index 000..63e375c
--- /dev/null
+++ b/arch/arm/dts/s700-cubieboard7.dts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "s700.dtsi"
+
+/ {
+   compatible = "cubietech,cubieboard7", "actions,s700";
+   model = "CubieBoard7";
+
+   aliases {
+   serial3 = &uart3;
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   memory@1,e000 {
+   device_type = "memory";
+   reg = <0x1 0xe000 0x0 0x0>;
+   };
+};
+
+&i2c0 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c0_default>;
+};
+
+&i2c1 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_default>;
+};
+
+&i2c2 {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c2_default>;
+};
+
+&pinctrl {
+   i2c0_default: i2c0_default {
+   pinmux {
+   groups = "i2c0_mfp";
+   function = "i2c0";
+   };
+   pinconf {
+   pins = "i2c0_sclk", "i2c0_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c1_default: i2c1_default {
+   pinmux {
+   groups = "i2c1_dummy";
+   function = "i2c1";
+   };
+   pinconf {
+   pins = "i2c1_sclk", "i2c1_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c2_default: i2c2_default {
+   pinmux {
+   groups = "i2c2_dummy";
+   function = "i2c2";
+   };
+   pinconf {
+   pins = "i2c2_sclk", "i2c2_sdata";
+   bias-pull-up;
+   };
+   };
+};
+
+&timer {
+   clocks = <&hosc>;
+};
+
+&uart3 {
+   status = "okay";
+};
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
new file mode 100644
index 000..d12c293
--- /dev/null
+++ b/configs/cubieboard7_defconfig
@@ -0,0 +1,9 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OWL=y
+CONFIG_MACH_S700=y
+CONFIG_IDENT_STRING="\ncubieboard7"
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
-- 
2.7.4



[PATCH v6 05/12] arm: dts: actions: s900: add u-boot specific dtsi file

2020-03-18 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
This patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900-u-boot.dtsi | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi

diff --git a/arch/arm/dts/s900-u-boot.dtsi b/arch/arm/dts/s900-u-boot.dtsi
new file mode 100644
index 000..a95f2cc
--- /dev/null
+++ b/arch/arm/dts/s900-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart5 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v6 07/12] arm: actions: add S700 SoC device tree

2020-03-18 Thread Amit Singh Tomar
This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d")
and required binding for S700 SoC that is a 64-bit Quad-core ARM
Cortex-A53 cores.

It also provisions dts file to be built based on selected
platform(CONFIG_MACH_S900/S700).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Move it to 07/11 from 05/11.
Changes since v3:
* Updated commit message to the Linux tag to
  which the dtsi file is synced.   
Changes since v2:
* Synced DTS bindings with Linux 5.5.
Changes since v1:
* Moved the u-boot specific changes to s700-u-boot.dtsi, now
  s700.dtsi is in complete sync with Linux 4.20.
---
 arch/arm/dts/Makefile  |   6 +-
 arch/arm/dts/s700.dtsi | 248 +
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 
 include/dt-bindings/reset/actions,s700-reset.h |  34 
 4 files changed, 404 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s700-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9c593b2..308c76b 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -64,8 +64,10 @@ dtb-$(CONFIG_KIRKWOOD) += \
kirkwood-pogo_e02.dtb \
kirkwood-sheevaplug.dtb
 
-dtb-$(CONFIG_ARCH_OWL) += \
-   bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S900) += \
+bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S700) += \
+s700-cubieboard7.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
px30-evb.dtb \
diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
new file mode 100644
index 000..2006ad5
--- /dev/null
+++ b/arch/arm/dts/s700.dtsi
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "actions,s700";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   gic: interrupt-controller@e00f1000 {
+   compatible = "arm,gic-400";
+   reg = <0x0 0xe00f1000 0x0 0x1000>,
+ <0x0 0xe00f2000 0x0 0x2000>,
+ <0x0 0xe00f4000 0x0 0x2000>,
+ <0x0 0xe00f6000 0x0 0x2000>;
+   interrupts = ;
+   interrupt-controller;
+

[PATCH v6 08/12] arm: dts: actions: s700: add u-boot specific dtsi file

2020-03-18 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Moved it to 08/11 to 06/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
Changes since v2:
* Added License.
Changes since v1:
* This is newly added file that was *not* present in v1 and
  contains u-boot specific changes. 
---
 arch/arm/dts/s700-u-boot.dtsi | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
new file mode 100644
index 000..a527ccc
--- /dev/null
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart3 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v6 06/12] clk: actions: Add common clock driver

2020-03-18 Thread Amit Singh Tomar
This patch converts S900 clock driver to something common that can
be used for other SoCs, for instance S700(few of clk registers are same).

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Removed the white space errors from "clk_owl.h".
Changes since v4:
* Removed parentheses from "regs_s700.h"
* Moved this patch, from 03/11 to 05/11.
* Merged owl_uart_clk_enable() into owl_clk_enable.
Changes since v3:
* Fixed register spelling.
* Removed the ethernet related clocks.
* Returned -EINVAL instead 0.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/Kconfig  |   2 +
 arch/arm/include/asm/arch-owl/clk_s900.h  |  57 ---
 arch/arm/include/asm/arch-owl/regs_s700.h |  56 +++
 configs/bubblegum_96_defconfig|   3 -
 drivers/clk/owl/Kconfig   |   8 +-
 drivers/clk/owl/Makefile  |   2 +-
 drivers/clk/owl/clk_owl.c | 152 ++
 drivers/clk/owl/clk_owl.h |  65 +
 drivers/clk/owl/clk_s900.c| 137 ---
 9 files changed, 278 insertions(+), 204 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644 drivers/clk/owl/clk_s900.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1cfdcb6..dba4d8c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -876,6 +876,8 @@ config ARCH_OWL
select DM
select DM_SERIAL
select OWL_SERIAL
+   select CLK
+   select CLK_OWL
select OF_CONTROL
imply CMD_DM
 
diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h 
b/arch/arm/include/asm/arch-owl/clk_s900.h
deleted file mode 100644
index 88e88f7..000
--- a/arch/arm/include/asm/arch-owl/clk_s900.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Actions Semi S900 Clock Definitions
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- *
- */
-
-#ifndef _OWL_CLK_S900_H_
-#define _OWL_CLK_S900_H_
-
-#include 
-
-struct owl_clk_priv {
-   phys_addr_t base;
-};
-
-/* BUSCLK register definitions */
-#define CMU_PDBGDIV_8  7
-#define CMU_PDBGDIV_SHIFT  26
-#define CMU_PDBGDIV_DIV(CMU_PDBGDIV_8 << CMU_PDBGDIV_SHIFT)
-#define CMU_PERDIV_8   7
-#define CMU_PERDIV_SHIFT   20
-#define CMU_PERDIV_DIV (CMU_PERDIV_8 << CMU_PERDIV_SHIFT)
-#define CMU_NOCDIV_2   1
-#define CMU_NOCDIV_SHIFT   19
-#define CMU_NOCDIV_DIV (CMU_NOCDIV_2 << CMU_NOCDIV_SHIFT)
-#define CMU_DMMCLK_SRC_APLL2
-#define CMU_DMMCLK_SRC_SHIFT   10
-#define CMU_DMMCLK_SRC (CMU_DMMCLK_SRC_APLL << CMU_DMMCLK_SRC_SHIFT)
-#define CMU_APBCLK_DIV BIT(8)
-#define CMU_NOCCLK_SRC BIT(7)
-#define CMU_AHBCLK_DIV BIT(4)
-#define CMU_CORECLK_MASK   3
-#define CMU_CORECLK_CPLL   BIT(1)
-#define CMU_CORECLK_HOSC   BIT(0)
-
-/* COREPLL register definitions */
-#define CMU_COREPLL_EN BIT(9)
-#define CMU_COREPLL_HOSC_ENBIT(8)
-#define CMU_COREPLL_OUT(1104 / 24)
-
-/* DEVPLL register definitions */
-#define CMU_DEVPLL_CLK BIT(12)
-#define CMU_DEVPLL_EN  BIT(8)
-#define CMU_DEVPLL_OUT (660 / 6)
-
-/* UARTCLK register definitions */
-#define CMU_UARTCLK_SRC_DEVPLL BIT(16)
-
-/* DEVCLKEN1 register definitions */
-#define CMU_DEVCLKEN1_UART5BIT(21)
-
-#define PLL_STABILITY_WAIT_US  50
-
-#endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
new file mode 100644
index 000..2f21c15
--- /dev/null
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Actions Semi S700 Register Definitions
+ *
+ */
+
+#ifndef _OWL_REGS_S700_H_
+#define _OWL_REGS_S700_H_
+
+#define CMU_COREPLL0x
+#define CMU_DEVPLL 0x0004
+#define CMU_DDRPLL 0x0008
+#define CMU_NANDPLL0x000C
+#define CMU_DISPLAYPLL 0x0010
+#define CMU_AUDIOPLL   0x0014
+#define CMU_TVOUTPLL   0x0018
+#define CMU_BUSCLK 0x001C
+#define CMU_SENSORCLK  0x0020
+#define CMU_LCDCLK 0x0024
+#define CMU_DSIPLLCLK  0x0028
+#define CMU_CSICLK 0x002C
+#define CMU_DECLK  0x0030
+#define CMU_SICLK  0x0034
+#define CMU_BUSCLK10x0038
+#define CMU_HDECLK 0x003C
+#define CMU_VDECLK 0x0040
+#define CMU_VCECLK 

[PATCH v6 01/12] arm: actions: Add common framework for Actions Owl Semi SoCs

2020-03-18 Thread Amit Singh Tomar
This commit adds common arch support for Actions Semi Owl
series SoCs and removes the Bubblegum96 board files.

Signed-off-by: Amit Singh Tomar 
---
Chanes since v5:
* No change.
Chanes since v4:
* No change.
Changes since v3:
* Corrected the file list entry in MAINTAINERS file.
Changes since v2:
* Moved the file list details to root MAINTAINERS file.
* Updated the commit message as suggested by Mani.
* Used the "Owl" keyword to describe SoC family.
Changes since v1:
* Moved S700 specific changes to patch 4 of 9.
* Moved couple of symbols from defconfig to arch/arm/Kconfig
  and platform owl Kconfig.
---
 MAINTAINERS  |  2 +
 arch/arm/Kconfig |  3 +-
 arch/arm/mach-owl/Kconfig| 29 ++
 arch/arm/mach-owl/Makefile   |  1 +
 arch/arm/mach-owl/soc.c  | 57 
 board/ucRobotics/bubblegum_96/Kconfig| 15 
 board/ucRobotics/bubblegum_96/MAINTAINERS|  6 ---
 board/ucRobotics/bubblegum_96/Makefile   |  3 --
 board/ucRobotics/bubblegum_96/bubblegum_96.c | 57 
 configs/bubblegum_96_defconfig   |  4 +-
 include/configs/bubblegum_96.h   | 40 ---
 include/configs/owl-common.h | 40 +++
 include/configs/s900.h   | 16 
 13 files changed, 130 insertions(+), 143 deletions(-)
 create mode 100644 arch/arm/mach-owl/soc.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 delete mode 100644 include/configs/bubblegum_96.h
 create mode 100644 include/configs/owl-common.h
 create mode 100644 include/configs/s900.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 92dda40..e1c03cb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -275,6 +275,8 @@ F:  arch/arm/mach-owl/
 F: board/ucRobotics/
 F: drivers/clk/owl/
 F: drivers/serial/serial_owl.c
+F: include/configs/owl-common.h
+F: configs/bubblegum_96_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5d36788..1cfdcb6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -873,9 +873,9 @@ config ARCH_MX5
 
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
-   select ARM64
select DM
select DM_SERIAL
+   select OWL_SERIAL
select OF_CONTROL
imply CMD_DM
 
@@ -1865,7 +1865,6 @@ source "board/spear/spear600/Kconfig"
 source "board/spear/x600/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
-source "board/ucRobotics/bubblegum_96/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 199e772..d0be2b5 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -1,27 +1,22 @@
 if ARCH_OWL
 
-config SYS_SOC
-   default "owl"
-
 choice
-prompt "Actions Semi OWL SoCs board select"
+prompt "Actions Semi Owl SoC Variant"
 optional
 
-config TARGET_BUBBLEGUM_96
-   bool "96Boards Bubblegum-96"
-   help
- Support for 96Boards Bubblegum-96. This board complies with
- 96Board Consumer Edition Specification. Features:
- - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU)
- - 2GiB RAM
- - 8GiB eMMC, uSD slot
- - WiFi, Bluetooth and GPS module
- - 2x Host, 1x Device USB port
- - HDMI
- - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons
+config MACH_S900
+bool "Actions Semi S900 SoC"
+select ARM64
 
 endchoice
 
-source "board/ucRobotics/bubblegum_96/Kconfig"
+config SYS_TEXT_BASE
+default 0x1100
+
+config SYS_CONFIG_NAME
+default "s900" if MACH_S900
+
+config SYS_SOC
+default "s900" if MACH_S900
 
 endif
diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 1b43dc2..0b181c6 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-y += soc.o
 obj-y += sysmap-s900.o
diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
new file mode 100644
index 000..409cbd3
--- /dev/null
+++ b/arch/arm/mach-owl/soc.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Actions Semi Owl SoCs platform support.
+ *
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * dram_init - sets uboots idea of sdram size
+ */
+int dram_init(void)
+{
+

[PATCH v6 04/12] arm: dts: sync dts for Action Semi S900

2020-03-18 Thread Amit Singh Tomar
Synchronize device tree bindings with v5.5-rc6 tag with commit id
"b3a987b0264d".

Also, it removes older clock binding defined for S900 along with undocumented
compatible string "actions,s900-serial" from serial driver and adapts clock
driver to cater to new bindings.

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Moved it 04/11 from 03/11.
* removed the undocumented compatible string "actions,s900-serial".
* removed the reviewed-by tag. 
Changes since v4:
* This patch is re-ordered, moved from 07/11 to 03/11.
* Used the commit-id(12 chars long) in commit message.
Changes since v3:
* Added Reviewed-by: tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900.dtsi | 322 +++--
 drivers/clk/owl/clk_s900.c |   6 +-
 drivers/serial/serial_owl.c|   1 -
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 6 files changed, 498 insertions(+), 102 deletions(-)
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h
 delete mode 100644 include/dt-bindings/clock/s900_cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s900-reset.h

diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi
index 2bbb30a..eb35cf7 100644
--- a/arch/arm/dts/s900.dtsi
+++ b/arch/arm/dts/s900.dtsi
@@ -1,17 +1,94 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Device Tree Source for Actions Semi S900 SoC
-//
-// Copyright (C) 2015 Actions Semi Co., Ltd.
-// Copyright (C) 2018 Manivannan Sadhasivam 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
 
-/dts-v1/;
-#include 
+#include 
+#include 
+#include 
+#include 
 
 / {
compatible = "actions,s900";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
 
losc: losc {
compatible = "fixed-clock";
@@ -26,28 +103,231 @@
};
 
soc {
-   u-boot,dm-pre-reloc;
compatible = "simple-bus";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   #address-cells = <2>;
+   #size-cells = <2>;
ranges;
 
+   gic: interrupt-controller@e00f1000 {
+   compatible = "arm,gic-400";
+   reg = <0x0 0xe00f1000 0x0 0x1000>,
+ <0x0 0xe00f2000 0x0 0x2000>,
+ <0x0 0xe00f4000 0x0 0x2000>,
+ <0x0 0xe00f6000 0x0 0x2000>;
+   interrupts = ;
+   interrupt-controller;
+   #int

[PATCH v6 03/12] serial: actions: add compatible string

2020-03-18 Thread Amit Singh Tomar
This patch adds "actions,owl-uart" string to the owl uart driver. It
is also defined in Linux kernel.

Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* Moved it to from 06/11 to 03/11.
* Used appropriate commit message.
* Removed the reviwed-by tag.
Changes since v4:
* Moved it to from 09/11 to 06/11.
Changes since v3:
* Used only owl-uart for compatible string.
Changes since v2:
* No changes.   
Changes since v1:
* No changes.
---
 drivers/serial/serial_owl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c
index 7ead73e..539acdc 100644
--- a/drivers/serial/serial_owl.c
+++ b/drivers/serial/serial_owl.c
@@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = {
 
 static const struct udevice_id owl_serial_ids[] = {
{ .compatible = "actions,s900-serial" },
+   { .compatible = "actions,owl-uart" },
{ }
 };
 
-- 
2.7.4



[PATCH v6 02/12] arm: actions: rename sysmap-s900 to sysmap-owl

2020-03-18 Thread Amit Singh Tomar
Now that memory maps(for both S700 and S900 SoCs) can be managed using
a common file, rename sysmap-s900 to sysmap-owl to reflect the same.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Added reviewed-by tag.
Changes since v2:
* Fixed the commit message and header.
Changes since v1:
* compile sysmap-owl.c against CONFIG_ARM64 now.
---
 arch/arm/mach-owl/Makefile  |  2 +-
 arch/arm/mach-owl/sysmap-owl.c  | 32 
 arch/arm/mach-owl/sysmap-s900.c | 32 
 3 files changed, 33 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c

diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 0b181c6..f3a69eb 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += soc.o
-obj-y += sysmap-s900.o
+obj-$(CONFIG_ARM64) += sysmap-owl.o
diff --git a/arch/arm/mach-owl/sysmap-owl.c b/arch/arm/mach-owl/sysmap-owl.c
new file mode 100644
index 000..81f6ca2
--- /dev/null
+++ b/arch/arm/mach-owl/sysmap-owl.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory map for Actions Semi Owl series SoCs.
+ *
+ * Copyright (C) 2015 Actions Semi Co., Ltd.
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+
+static struct mm_region owl_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DDR */
+   .phys = 0x0UL, /* DDR */
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0xE000UL, /* Peripheral block */
+   .phys = 0xE000UL, /* Peripheral block */
+   .size = 0x0800UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = owl_mem_map;
diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-s900.c
deleted file mode 100644
index f78b639..000
--- a/arch/arm/mach-owl/sysmap-s900.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Actions Semi S900 Memory map
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- */
-
-#include 
-#include 
-
-static struct mm_region s900_mem_map[] = {
-   {
-   .virt = 0x0UL, /* DDR */
-   .phys = 0x0UL, /* DDR */
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   .virt = 0xE000UL, /* Peripheral block */
-   .phys = 0xE000UL, /* Peripheral block */
-   .size = 0x0800UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = s900_mem_map;
-- 
2.7.4



Re: [PATCH v3 2/5] cmd: bootefi: Parse reserved-memory node from DT

2020-03-18 Thread Heinrich Schuchardt

On 3/17/20 11:01 PM, Heinrich Schuchardt wrote:

On 3/17/20 10:19 PM, Atish Patra wrote:

Currently, bootefi only parses memory reservation block to setup
EFI reserved memory mappings. However, it doesn't parse the
reserved-memory[1] device tree node that also can contain the
reserved memory regions.

Add capability to parse reserved-memory node and update the EFI memory
mappings accordingly.

1. source>/doc/device-tree-bindings/reserved-memory/reserved-memory.txt]


Signed-off-by: Atish Patra 
---
  cmd/bootefi.c | 44 +++-
  1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 24fc42ae898e..291cb2d69ff6 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -149,6 +149,20 @@ done:
  return ret;
  }

+static void efi_reserve_memory(uint64_t addr, uint64_t size)
+{
+    uint64_t pages;
+
+    /* Convert from sandbox address space. */
+    addr = (uintptr_t)map_sysmem(addr, 0);
+    pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
+    addr &= ~EFI_PAGE_MASK;
+    if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
+   false) != EFI_SUCCESS)
+    printf("Reserved memory mapping failed addr %llx size %llx\n",
+  (unsigned long long)addr, (unsigned long long)size);
+}
+
  /**
   * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
   *
@@ -161,7 +175,8 @@ done:
  static void efi_carve_out_dt_rsv(void *fdt)
  {
  int nr_rsv, i;
-    uint64_t addr, size, pages;
+    uint64_t addr, size;
+    int nodeoffset, subnode;

  nr_rsv = fdt_num_mem_rsv(fdt);

@@ -169,15 +184,26 @@ static void efi_carve_out_dt_rsv(void *fdt)
  for (i = 0; i < nr_rsv; i++) {
  if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
  continue;
+    efi_reserve_memory(addr, size);
+    }

-    /* Convert from sandbox address space. */
-    addr = (uintptr_t)map_sysmem(addr, 0);
-
-    pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
-    addr &= ~EFI_PAGE_MASK;
-    if (efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
-   false) != EFI_SUCCESS)
-    printf("FDT memrsv map %d: Failed to add to map\n", i);
+    /* process reserved-memory */
+    nodeoffset = fdt_subnode_offset(fdt, 0, "reserved-memory");
+    if (nodeoffset < 0)
+    return;
+    subnode = fdt_first_subnode(fdt, nodeoffset);
+    while (subnode >= 0) {
+    /* check if this subnode has a reg property */
+    addr = fdtdec_get_addr_size_auto_noparent(fdt, subnode,
+  "reg", 0,
+  (fdt_size_t *)&size,
+  true);
+    if (addr == FDT_ADDR_T_NONE) {
+    debug("failed to read address/size\n");
+    continue;


As you do not update subnode you never leave the loop, cf.
https://lists.denx.de/pipermail/u-boot/2020-March/402891.html

Best regards

Heinrich


Corrected and merged into origin/master.

Best regards

Heinrich




+    }
+    efi_reserve_memory(addr, size);
+    subnode = fdt_next_subnode(fdt, subnode);
  }
  }








[PATCH v6 00/12] Actions S700 SoC support

2020-03-18 Thread Amit Singh Tomar
This adds Cubieboard7[1] support based on Action Semi's S700 SoC[2], It's 
Quad-core ARMv8 SoC
with Cortex-A53 cores. Peripheral like UART seems to be compatible with S900 
SoC(basic support
for it is alreay present in u-boot).

This series(v6) does following changes:

* [PATCH v5 06/11] becomes [PATCH v6 03/11]
* [PATCH v5 03/11] becomes [PATCH v6 04/11]
* Introduce a new patch to move defconfig options to Kconfig which is [PATCH v6 
10/12]

Previous series(v5)[3] just re-orders the patches so that U-BOOT(with 
bubblegum96_defconfig) builds
after every patch of the series(suggested by Andre).

S700 support is tested[4] on Cubieboard7 board and S900 support is just 
compiled tested.

This patch series can be tested using below tree:
https://github.com/Atomar25/u-boot/commits/s700_v6

[1]: http://www.cubietech.com/product-detail/cubieboard7/
[2]: http://www.actions-semi.com/en/productview.aspx?id=225
[3]: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-00-11-Actions-S700-SoC-support-td402752.html#a402762
[4]: https://paste.ubuntu.com/p/xK9pWTy5Hc/

Amit Singh Tomar (12):
  arm: actions: Add common framework for Actions Owl Semi SoCs
  arm: actions: rename sysmap-s900 to sysmap-owl
  serial: actions: add compatible string
  arm: dts: sync dts for Action Semi S900
  arm: dts: actions: s900: add u-boot specific dtsi file
  clk: actions: Add common clock driver
  arm: actions: add S700 SoC device tree
  arm: dts: actions: s700: add u-boot specific dtsi file
  arm: add support Actions Semi S700
  actions: Move defconfig options to Kconfig
  arm: add Cubieboard7 board support
  doc: boards: add Cubieboard7 documentation

 MAINTAINERS|   2 +
 arch/arm/Kconfig   |   5 +-
 arch/arm/dts/Makefile  |   6 +-
 arch/arm/dts/s700-cubieboard7.dts  |  92 +++
 arch/arm/dts/s700-u-boot.dtsi  |  18 ++
 arch/arm/dts/s700.dtsi | 248 +++
 arch/arm/dts/s900-u-boot.dtsi  |  17 ++
 arch/arm/dts/s900.dtsi | 322 +++--
 arch/arm/include/asm/arch-owl/clk_s900.h   |  57 -
 arch/arm/include/asm/arch-owl/regs_s700.h  |  56 +
 arch/arm/mach-owl/Kconfig  |  51 ++--
 arch/arm/mach-owl/Makefile |   3 +-
 arch/arm/mach-owl/soc.c|  57 +
 arch/arm/mach-owl/sysmap-owl.c |  32 +++
 arch/arm/mach-owl/sysmap-s900.c|  32 ---
 board/ucRobotics/bubblegum_96/Kconfig  |  15 --
 board/ucRobotics/bubblegum_96/MAINTAINERS  |   6 -
 board/ucRobotics/bubblegum_96/Makefile |   3 -
 board/ucRobotics/bubblegum_96/bubblegum_96.c   |  57 -
 configs/bubblegum_96_defconfig |  12 +-
 configs/cubieboard7_defconfig  |   9 +
 doc/board/actions/cubieboard7.rst  | 115 +
 doc/board/actions/index.rst|  10 +
 doc/board/index.rst|   1 +
 drivers/clk/owl/Kconfig|   8 +-
 drivers/clk/owl/Makefile   |   2 +-
 drivers/clk/owl/clk_owl.c  | 152 
 drivers/clk/owl/clk_owl.h  |  65 +
 drivers/clk/owl/clk_s900.c | 137 ---
 drivers/serial/serial_owl.c|   2 +-
 include/configs/bubblegum_96.h |  40 ---
 include/configs/owl-common.h   |  40 +++
 include/configs/s700.h |  13 +
 include/configs/s900.h |  16 ++
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 +
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s700-reset.h |  34 +++
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 39 files changed, 1638 insertions(+), 486 deletions(-)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 arch/arm/mach-owl/soc.c
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 create mode 100644 configs/cubieboard7_defconfig
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644

Re: [RFC 00/14] efi_loader: add capsule update support

2020-03-18 Thread Sughosh Ganu
On Tue, 17 Mar 2020 at 07:42, AKASHI Takahiro 
wrote:

> Summary
> ===
> 'UpdateCapsule' is one of runtime services defined in UEFI specification
> and its aim is to allow a caller to pass information to the firmware.
> This is mostly used to update firmware binary on devices by instructions
> from OS.
>
> In this patch series, all the related definitions and structures are given
> as UEFI specification describes and basic framework for capsule support is
> implemented. Currently supported types of capsule are
>  * firmware update (Firmware Management Protocol or simply FMP)
>  * variable update
>
> UpdateCapsule is a runtime services function, but is, at least initially,
> provided only before exiting boot services alike other runtime functions.
> This is because modifying storage which may be shared with OS must be
> carefully designed and there is no general assumption to do that as in
> the case of [Get/]SetVariable.
> Instead, any capsule can be handed over to the firmware as a file on
> a specific file system. In other words, we only support "capsules on disk"
> for now.
>
> Regarding firmware update, most of functionality is provided by FMP
> driver and it will be by nature system/platform-specific. So you can and
> should implement FMP drivers based on your system requirements.
> In this patch series, only a simple FMP driver based on FIT image for
> a single region is supported.  (So it is "for reference only")
> See more details in "efi_loader: capsule: add simple firmware management
> protocol."
>
> Regarding variable update, the implementation here is based on a draft
> proposal[1] by Peter in Boot-arch ML. The specification should be discussed
> and finalized first. So the code doesn't fully implement Peter's idea.
>
> [1]
> https://lists.linaro.org/pipermail/boot-architecture/2018-October/000883.html
>
> Patch structure
> ===
> Patch#1-#4: preparatory patches
> Patch#5-#11: main part of implementation
> Patch#12-#14: utilities and tests
>
>
With the changes that I suggested in a couple of patches, I am able to test
the capsule-on-disk update of the u-boot firmware image on the qemu arm64
platform. I have also tested the capsule update functionality via the
'efidebug capsule update -v ' command. Thanks!

-sughosh


Re: [RFC 04/14] efi_loader: correct a definition of struct efi_capsule_header

2020-03-18 Thread Heinrich Schuchardt

On 3/17/20 3:12 AM, AKASHI Takahiro wrote:

See UEFI specification, section 8.5.3.
In addition, the structure, efi_capsule_header, should be "packed"
as it is a serialized binary format in a capsule file.

Signed-off-by: AKASHI Takahiro 


Merged into U-Boot master.

Best regards

Heinrich


Re: [RFC 03/14] efi_loader: export a couple of protocol related functions

2020-03-18 Thread Heinrich Schuchardt

On 3/17/20 3:12 AM, AKASHI Takahiro wrote:

This is a preparatory patch.
Those functions will be used in an implementation of UEFI firmware
management protocol as part of my capsule update patch.

Signed-off-by: AKASHI Takahiro 


Merged into U-Boot master

Best regards

Heinrich


Re: [RFC 02/14] efi_loader: define System Resource Table macros

2020-03-18 Thread Heinrich Schuchardt

On 3/17/20 8:06 AM, Heinrich Schuchardt wrote:

On 3/17/20 3:12 AM, AKASHI Takahiro wrote:

Some of those values will be used in an implementation of UEFI firmware
management protocol as part of my capsule update patch.

Signed-off-by: AKASHI Takahiro 


Reviewed-by: Heinrich Schuchardt 


Merged into u-boot master

Best regards

Heinrich


Re: [RFC 01/14] efi_loader: define OsIndicationsSupported flags

2020-03-18 Thread Heinrich Schuchardt

On 3/18/20 2:18 AM, AKASHI Takahiro wrote:

On Tue, Mar 17, 2020 at 08:03:21AM +0100, Heinrich Schuchardt wrote:

On 3/17/20 3:12 AM, AKASHI Takahiro wrote:

These flags are expected to be set in OsIndicationsSupported variable
if corresponding features are supported. See UEFI specification,
section 8.5.4.

In particular, capsule-related flags will be used in my capsule
update patch.

Signed-off-by: AKASHI Takahiro 
---
   include/efi_api.h | 11 +++
   1 file changed, 11 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 22396172e15f..73c0722b0168 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -57,6 +57,17 @@ typedef u16 efi_form_id_t;

   struct efi_event;

+/* OsIndicationsSupported flags */
+#define EFI_OS_INDICATIONS_BOOT_TO_RW_UI   0x0001

This is called
EFI_OS_INDICATIONS_BOOT_TO_FW_UI
in the spec.


Yes, it's a typo.

Thanks,
-Takahiro Akashi


Corrected and merged into u-boot/master.

Best regards

Heinrich


[PATCH v2 13/14] test: vboot: Move key creation into a function

2020-03-18 Thread Simon Glass
This code is repeated so move it into a function with a parameter.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 39 +
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 0b8bd9ac0b..91305a4f0f 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -138,6 +138,22 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 handle.write(struct.pack(">I", size))
 return struct.unpack(">I", total_size)[0]
 
+def create_rsa_pair(name):
+"""Generate a new RSA key paid and certificate
+
+Args:
+name: Name of of the key (e.g. 'dev')
+"""
+public_exponent = 65537
+util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %s%s.key '
+ '-pkeyopt rsa_keygen_bits:2048 '
+ '-pkeyopt rsa_keygen_pubexp:%d' %
+ (tmpdir, name, public_exponent))
+
+# Create a certificate containing the public key
+util.run_and_log(cons, 'openssl req -batch -new -x509 -key %s%s.key '
+ '-out %s%s.crt' % (tmpdir, name, tmpdir, name))
+
 def test_with_algo(sha_algo, padding):
 """Test verified boot with the given hash algorithm.
 
@@ -268,27 +284,8 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 dtb = '%ssandbox-u-boot.dtb' % tmpdir
 sig_node = '/configurations/conf-1/signature'
 
-# Create an RSA key pair
-public_exponent = 65537
-util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %sdev.key '
- '-pkeyopt rsa_keygen_bits:2048 '
- '-pkeyopt rsa_keygen_pubexp:%d' %
- (tmpdir, public_exponent))
-
-# Create a certificate containing the public key
-util.run_and_log(cons, 'openssl req -batch -new -x509 -key %sdev.key -out '
- '%sdev.crt' % (tmpdir, tmpdir))
-
-# Create an RSA key pair (prod)
-public_exponent = 65537
-util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %sprod.key '
- '-pkeyopt rsa_keygen_bits:2048 '
- '-pkeyopt rsa_keygen_pubexp:%d' %
- (tmpdir, public_exponent))
-
-# Create a certificate containing the public key (prod)
-util.run_and_log(cons, 'openssl req -batch -new -x509 -key %sprod.key -out 
'
- '%sprod.crt' % (tmpdir, tmpdir))
+create_rsa_pair('dev')
+create_rsa_pair('prod')
 
 # Create a number kernel image with zeroes
 with open('%stest-kernel.bin' % tmpdir, 'w') as fd:
-- 
2.25.1.481.gfbce0eb801-goog



Re: [PATCH v2 1/2] cmd: Add command to display or save Linux PStore dumps

2020-03-18 Thread Frédéric Danis

Hi Heinrich,

On 17/03/2020 20:57, Heinrich Schuchardt wrote:

On 2/26/20 10:42 AM, Frédéric Danis wrote:


+Ramoops is an oops/panic logger that writes its logs to RAM before 
the system
+crashes. It works by logging oopses and panics in a circular buffer. 
Ramoops
+needs a system with persistent RAM so that the content of that area 
can survive

+after a restart.
+
+Ramoops uses a predefined memory area to store the dump.
+
+Ramoops parameters can be passed as kernel parameters or through 
Device Tree,


Please, add the node in image_setup_libfdt() as described in Linux's
Documentation/device-tree/bindings/reserved-memory/admin-guide/ramoops.rst. 



I'm not sure to understand what you expect here.
Can you please give me more info about it?



+i.e.::
+ ramoops.mem_address=0x3000 ramoops.mem_size=0x10 
ramoops.record_size=0x2000 ramoops.console_size=0x2000 
memmap=0x10$0x3000


Using the command line seems to be rather error prone.


Best regards,

Frédéric Danis


[PATCH v2 10/14] test: vboot: Tidy up the code a little

2020-03-18 Thread Simon Glass
Fix some long lines and comments. Use a distinct name for the
'required key' test.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index b1badaad73..817f2a99d2 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -91,7 +91,8 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 if boots:
 assert('sandbox: continuing, as we cannot run' in ''.join(output))
 else:
-assert('sandbox: continuing, as we cannot run' not in 
''.join(output))
+assert('sandbox: continuing, as we cannot run'
+   not in ''.join(output))
 
 def make_fit(its):
 """Make a new FIT from the .its source file.
@@ -211,7 +212,8 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 bcfg = u_boot_console.config.buildconfig
 max_size = int(bcfg.get('config_fit_signature_max_size', 0x1000), 
0)
 existing_size = replace_fit_totalsize(max_size + 1)
-run_bootm(sha_algo, 'Signed config with bad hash', 'Bad Data Hash', 
False)
+run_bootm(sha_algo, 'Signed config with bad hash', 'Bad Data Hash',
+  False)
 cons.log.action('%s: Check overflowed FIT header totalsize' % sha_algo)
 
 # Replace with existing header bytes
@@ -229,7 +231,8 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 util.run_and_log(cons, 'fdtput -t bx %s %s value %s' %
  (fit, sig_node, sig))
 
-run_bootm(sha_algo, 'Signed config with bad hash', 'Bad Data Hash', 
False)
+run_bootm(sha_algo, 'Signed config with bad hash', 'Bad Data Hash',
+  False)
 
 cons.log.action('%s: Check bad config on the host' % sha_algo)
 util.run_and_log_expect_exception(cons, [fit_check_sign, '-f', fit,
@@ -238,12 +241,11 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 def test_required_key(sha_algo, padding):
 """Test verified boot with the given hash algorithm.
 
-This function test if u-boot reject an image when a required
-key isn't used to sign a FIT.
+This function tests if U-Boot rejects an image when a required key 
isn't
+used to sign a FIT.
 
 Args:
-sha_algo: Either 'sha1' or 'sha256', to select the algorithm to
-use.
+sha_algo: Either 'sha1' or 'sha256', to select the algorithm to use
 """
 # Compile our device tree files for kernel and U-Boot. These are
 # regenerated here since mkimage will modify them (by adding a
@@ -251,18 +253,24 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 dtc('sandbox-kernel.dts')
 dtc('sandbox-u-boot.dts')
 
-# Build the FIT with prod key (keys required)
-# Build the FIT with dev key (keys NOT required)
-# The dtb contain the key prod and dev and the key prod are set as 
required.
-# Then try to boot the FIT with dev key
-# This FIT should not be accepted by u-boot because the key prod is 
required
 cons.log.action('%s: Test FIT with configs images' % sha_algo)
+
+# Build the FIT with prod key (keys required) and sign it. This puts 
the
+# signature into sandbox-u-boot.dtb, marked 'required'
 make_fit('sign-configs-%s%s-prod.its' % (sha_algo , padding))
 sign_fit(sha_algo)
+
+# Build the FIT with dev key (keys NOT required). This adds the
+# signature into sandbox-u-boot.dtb, NOT marked 'required'.
 make_fit('sign-configs-%s%s.its' % (sha_algo , padding))
 sign_fit(sha_algo)
 
-run_bootm(sha_algo, 'signed configs', '', False)
+# So now sandbox-u-boot.dtb two signatures, for the prod and dev keys.
+# Only the prod key is set as 'required'. But FIT we just built has
+# a dev signature only (sign_fit() overwrites the FIT).
+# Try to boot the FIT with dev key. This FIT should not be accepted by
+# U-Boot because the prod key is required.
+run_bootm(sha_algo, 'required key', '', False)
 
 cons = u_boot_console
 tmpdir = cons.config.result_dir + '/'
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 14/14] test: vboot: Reduce fake kernel size to 500 bytes

2020-03-18 Thread Simon Glass
We don't need 5KB to test things out. A smaller size makes it easier to
look at the FIT with fdtdump.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 91305a4f0f..e67f2b3d0f 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -289,7 +289,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 
 # Create a number kernel image with zeroes
 with open('%stest-kernel.bin' % tmpdir, 'w') as fd:
-fd.write(5000 * chr(0))
+fd.write(500 * chr(0))
 
 try:
 # We need to use our own device tree file. Remember to restore it
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 12/14] image: Use constants for 'required' and 'key-name-hint'

2020-03-18 Thread Simon Glass
These are used in multiple places so update them to use a shared #define.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/image-cipher.c | 2 +-
 common/image-fit.c| 6 +++---
 common/image-sig.c| 8 +---
 include/image.h   | 4 +++-
 lib/rsa/rsa-sign.c| 6 +++---
 tools/image-host.c| 8 
 6 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/common/image-cipher.c b/common/image-cipher.c
index cee3b03ee5..f50c3d31bd 100644
--- a/common/image-cipher.c
+++ b/common/image-cipher.c
@@ -88,7 +88,7 @@ static int fit_image_setup_decrypt(struct image_cipher_info 
*info,
return -1;
}
 
-   info->keyname = fdt_getprop(fit, cipher_noffset, "key-name-hint", NULL);
+   info->keyname = fdt_getprop(fit, cipher_noffset, FIT_KEY_HINT, NULL);
if (!info->keyname) {
printf("Can't get key name\n");
return -1;
diff --git a/common/image-fit.c b/common/image-fit.c
index a5c85ede8d..c8ff77526c 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -168,7 +168,7 @@ static void fit_image_print_data(const void *fit, int 
noffset, const char *p,
int value_len;
char *algo;
const char *padding;
-   int required;
+   bool required;
int ret, i;
 
debug("%s  %s node:'%s'\n", p, type,
@@ -179,8 +179,8 @@ static void fit_image_print_data(const void *fit, int 
noffset, const char *p,
return;
}
printf("%s", algo);
-   keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
-   required = fdt_getprop(fit, noffset, "required", NULL) != NULL;
+   keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
+   required = fdt_getprop(fit, noffset, FIT_KEY_REQUIRED, NULL) != NULL;
if (keyname)
printf(":%s", keyname);
if (required)
diff --git a/common/image-sig.c b/common/image-sig.c
index 03143a4040..6563effcf3 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -229,7 +229,7 @@ static int fit_image_setup_verify(struct image_sign_info 
*info,
padding_name = RSA_DEFAULT_PADDING_NAME;
 
memset(info, '\0', sizeof(*info));
-   info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
+   info->keyname = fdt_getprop(fit, noffset, FIT_KEY_HINT, NULL);
info->fit = (void *)fit;
info->node_offset = noffset;
info->name = algo_name;
@@ -340,7 +340,8 @@ int fit_image_verify_required_sigs(const void *fit, int 
image_noffset,
const char *required;
int ret;
 
-   required = fdt_getprop(sig_blob, noffset, "required", NULL);
+   required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
+  NULL);
if (!required || strcmp(required, "image"))
continue;
ret = fit_image_verify_sig(fit, image_noffset, data, size,
@@ -557,7 +558,8 @@ int fit_config_verify_required_sigs(const void *fit, int 
conf_noffset,
const char *required;
int ret;
 
-   required = fdt_getprop(sig_blob, noffset, "required", NULL);
+   required = fdt_getprop(sig_blob, noffset, FIT_KEY_REQUIRED,
+  NULL);
if (!required || strcmp(required, "conf"))
continue;
ret = fit_config_verify_sig(fit, conf_noffset, sig_blob,
diff --git a/include/image.h b/include/image.h
index 512243f159..3ffc0fdd68 100644
--- a/include/image.h
+++ b/include/image.h
@@ -939,12 +939,14 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong 
*size,
 #define FIT_IMAGES_PATH"/images"
 #define FIT_CONFS_PATH "/configurations"
 
-/* hash/signature node */
+/* hash/signature/key node */
 #define FIT_HASH_NODENAME  "hash"
 #define FIT_ALGO_PROP  "algo"
 #define FIT_VALUE_PROP "value"
 #define FIT_IGNORE_PROP"uboot-ignore"
 #define FIT_SIG_NODENAME   "signature"
+#define FIT_KEY_REQUIRED   "required"
+#define FIT_KEY_HINT   "key-name-hint"
 
 /* cipher node */
 #define FIT_CIPHER_NODENAME"cipher"
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 6400ef63d6..580c744709 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -792,8 +792,8 @@ int rsa_add_verify_data(struct image_sign_info *info, void 
*keydest)
}
 
if (!ret) {
-   ret = fdt_setprop_string(keydest, node, "key-name-hint",
-info->keyname);
+   ret = fdt_setprop_string(keydest, node, FIT_KEY_HINT,
+info->keyname);
}
if (!ret)
ret = fdt_setprop_u32(keydest, node, "rsa,num-bits", bits);
@@ -815,7 +815,7 @@ int rsa_add_verify_data(struct image_sign_info *info, void 
*keydest)
 info->name);

[PATCH v2 07/14] image: Check hash-nodes when checking configurations

2020-03-18 Thread Simon Glass
It is currently possible to use a different configuration's signature and
thus bypass the configuration check. Make sure that the configuration node
that was hashed matches the one being checked, to catch this problem.

Also add a proper function comment to fit_config_check_sig() and make it
static.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/image-sig.c | 36 +---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/common/image-sig.c b/common/image-sig.c
index 13ccd50bc5..03143a4040 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -359,20 +359,39 @@ int fit_image_verify_required_sigs(const void *fit, int 
image_noffset,
return 0;
 }
 
-int fit_config_check_sig(const void *fit, int noffset, int required_keynode,
-char **err_msgp)
+/**
+ * fit_config_check_sig() - Check the signature of a config
+ *
+ * @fit: FIT to check
+ * @noffset: Offset of configuration node (e.g. /configurations/conf-1)
+ * @required_keynode:  Offset in the control FDT of the required key node,
+ * if any. If this is given, then the configuration wil not
+ * pass verification unless that key is used. If this is
+ * -1 then any signature will do.
+ * @conf_noffset: Offset of the configuration subnode being checked (e.g.
+ *  /configurations/conf-1/kernel)
+ * @err_msgp:  In the event of an error, this will be pointed to a
+ * help error string to display to the user.
+ * @return 0 if all verified ok, <0 on error
+ */
+static int fit_config_check_sig(const void *fit, int noffset,
+   int required_keynode, int conf_noffset,
+   char **err_msgp)
 {
char * const exc_prop[] = {"data"};
const char *prop, *end, *name;
struct image_sign_info info;
const uint32_t *strings;
+   const char *config_name;
uint8_t *fit_value;
int fit_value_len;
+   bool found_config;
int max_regions;
int i, prop_len;
char path[200];
int count;
 
+   config_name = fit_get_name(fit, conf_noffset, NULL);
debug("%s: fdt=%p, conf='%s', sig='%s'\n", __func__, gd_fdt_blob(),
  fit_get_name(fit, noffset, NULL),
  fit_get_name(gd_fdt_blob(), required_keynode, NULL));
@@ -413,9 +432,20 @@ int fit_config_check_sig(const void *fit, int noffset, int 
required_keynode,
char *node_inc[count];
 
debug("Hash nodes (%d):\n", count);
+   found_config = false;
for (name = prop, i = 0; name < end; name += strlen(name) + 1, i++) {
debug("   '%s'\n", name);
node_inc[i] = (char *)name;
+   if (!strncmp(FIT_CONFS_PATH, name, strlen(FIT_CONFS_PATH)) &&
+   name[sizeof(FIT_CONFS_PATH) - 1] == '/' &&
+   !strcmp(name + sizeof(FIT_CONFS_PATH), config_name)) {
+   debug("  (found config node %s)", config_name);
+   found_config = true;
+   }
+   }
+   if (!found_config) {
+   *err_msgp = "Selected config not in hashed nodes";
+   return -1;
}
 
/*
@@ -483,7 +513,7 @@ static int fit_config_verify_sig(const void *fit, int 
conf_noffset,
if (!strncmp(name, FIT_SIG_NODENAME,
 strlen(FIT_SIG_NODENAME))) {
ret = fit_config_check_sig(fit, noffset, sig_offset,
-  &err_msg);
+  conf_noffset, &err_msg);
if (ret) {
puts("- ");
} else {
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 08/14] image: Load the correct configuration in fit_check_sign

2020-03-18 Thread Simon Glass
At present bootm_host_load_images() is passed the configuration that has
been verified, but ignores it and just uses the default configuration.
This may not be the same.

Update this function to use the selected configuration.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/bootm.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 902c13880d..db4362a643 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -819,7 +819,8 @@ void __weak switch_to_non_secure_mode(void)
 #else /* USE_HOSTCC */
 
 #if defined(CONFIG_FIT_SIGNATURE)
-static int bootm_host_load_image(const void *fit, int req_image_type)
+static int bootm_host_load_image(const void *fit, int req_image_type,
+int cfg_noffset)
 {
const char *fit_uname_config = NULL;
ulong data, len;
@@ -831,6 +832,7 @@ static int bootm_host_load_image(const void *fit, int 
req_image_type)
void *load_buf;
int ret;
 
+   fit_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
memset(&images, '\0', sizeof(images));
images.verify = 1;
noffset = fit_image_load(&images, (ulong)fit,
@@ -878,7 +880,7 @@ int bootm_host_load_images(const void *fit, int cfg_noffset)
for (i = 0; i < ARRAY_SIZE(image_types); i++) {
int ret;
 
-   ret = bootm_host_load_image(fit, image_types[i]);
+   ret = bootm_host_load_image(fit, image_types[i], cfg_noffset);
if (!err && ret && ret != -ENOENT)
err = ret;
}
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 11/14] test: vboot: Fix pylint errors

2020-03-18 Thread Simon Glass
Fix various minor things noticed by pylint.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 53 +
 1 file changed, 19 insertions(+), 34 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 817f2a99d2..0b8bd9ac0b 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -24,9 +24,8 @@ For configuration verification:
 Tests run with both SHA1 and SHA256 hashing.
 """
 
-import pytest
-import sys
 import struct
+import pytest
 import u_boot_utils as util
 import vboot_forge
 
@@ -85,11 +84,11 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)):
 output = cons.run_command_list(
 ['host load hostfs - 100 %stest.fit' % tmpdir,
-'fdt addr 100',
-'bootm 100'])
-assert(expect_string in ''.join(output))
+ 'fdt addr 100',
+ 'bootm 100'])
+assert expect_string in ''.join(output)
 if boots:
-assert('sandbox: continuing, as we cannot run' in ''.join(output))
+assert 'sandbox: continuing, as we cannot run' in ''.join(output)
 else:
 assert('sandbox: continuing, as we cannot run'
not in ''.join(output))
@@ -119,20 +118,6 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 util.run_and_log(cons, [mkimage, '-F', '-k', tmpdir, '-K', dtb,
 '-r', fit])
 
-def sign_fit_norequire(sha_algo):
-"""Sign the FIT
-
-Signs the FIT and writes the signature into it. It also writes the
-public key into the dtb.
-
-Args:
-sha_algo: Either 'sha1' or 'sha256', to select the algorithm to
-use.
-"""
-cons.log.action('%s: Sign images' % sha_algo)
-util.run_and_log(cons, [mkimage, '-F', '-k', tmpdir, '-K', dtb,
-fit])
-
 def replace_fit_totalsize(size):
 """Replace FIT header's totalsize with something greater.
 
@@ -171,7 +156,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 
 # Build the FIT, but don't sign anything yet
 cons.log.action('%s: Test FIT with signed images' % sha_algo)
-make_fit('sign-images-%s%s.its' % (sha_algo , padding))
+make_fit('sign-images-%s%s.its' % (sha_algo, padding))
 run_bootm(sha_algo, 'unsigned images', 'dev-', True)
 
 # Sign images with our dev keys
@@ -182,7 +167,7 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
 dtc('sandbox-u-boot.dts')
 
 cons.log.action('%s: Test FIT with signed configuration' % sha_algo)
-make_fit('sign-configs-%s%s.its' % (sha_algo , padding))
+make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
 run_bootm(sha_algo, 'unsigned config', '%s+ OK' % sha_algo, True)
 
 # Sign images with our dev keys
@@ -195,14 +180,14 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 
 # Make sure that U-Boot checks that the config is in the list of hashed
 # nodes. If it isn't, a security bypass is possible.
-with open(fit, 'rb') as fp:
-root, strblock = vboot_forge.read_fdt(fp)
+with open(fit, 'rb') as fd:
+root, strblock = vboot_forge.read_fdt(fd)
 root, strblock = vboot_forge.manipulate(root, strblock)
-with open(fit, 'w+b') as fp:
-vboot_forge.write_fdt(root, strblock, fp)
-util.run_and_log_expect_exception(cons,
-[fit_check_sign, '-f', fit, '-k', dtb],
-1, 'Failed to verify required signature')
+with open(fit, 'w+b') as fd:
+vboot_forge.write_fdt(root, strblock, fd)
+util.run_and_log_expect_exception(
+cons, [fit_check_sign, '-f', fit, '-k', dtb],
+1, 'Failed to verify required signature')
 
 run_bootm(sha_algo, 'forged config', 'Bad Data Hash', False)
 
@@ -235,8 +220,9 @@ def test_vboot(u_boot_console, sha_algo, padding, required):
   False)
 
 cons.log.action('%s: Check bad config on the host' % sha_algo)
-util.run_and_log_expect_exception(cons, [fit_check_sign, '-f', fit,
-'-k', dtb], 1, 'Failed to verify required signature')
+util.run_and_log_expect_exception(
+cons, [fit_check_sign, '-f', fit, '-k', dtb],
+1, 'Failed to verify required signature')
 
 def test_required_key(sha_algo, padding):
 """Test verified boot with the given hash algorithm.
@@ -257,12 +243,12 @@ def test_vboot(u_boot_console, sha_algo, padding, 
required):
 
 # Build the FIT with prod key (keys required) and sign it. This puts 
the
 # signature into sandbox-u-boot.dtb, marked 'required'
-make_fit('sign-conf

[PATCH v2 09/14] fit_check_sign: Allow selecting the configuration to verify

2020-03-18 Thread Simon Glass
This tool always verifies the default configuration. It is useful to be
able to verify a specific one. Add a command-line flag for this and plumb
the logic through.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 tools/fdt_host.h   | 3 ++-
 tools/fit_check_sign.c | 8 ++--
 tools/image-host.c | 6 --
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/fdt_host.h b/tools/fdt_host.h
index 99b009b221..15c07c7a96 100644
--- a/tools/fdt_host.h
+++ b/tools/fdt_host.h
@@ -27,6 +27,7 @@
  */
 int fdt_remove_unused_strings(const void *old, void *new);
 
-int fit_check_sign(const void *working_fdt, const void *key);
+int fit_check_sign(const void *fit, const void *key,
+  const char *fit_uname_config);
 
 #endif /* __FDT_HOST_H__ */
diff --git a/tools/fit_check_sign.c b/tools/fit_check_sign.c
index 4528743792..9375d5cf72 100644
--- a/tools/fit_check_sign.c
+++ b/tools/fit_check_sign.c
@@ -41,6 +41,7 @@ int main(int argc, char **argv)
void *fit_blob;
char *fdtfile = NULL;
char *keyfile = NULL;
+   char *config_name = NULL;
char cmdname[256];
int ret;
void *key_blob;
@@ -48,7 +49,7 @@ int main(int argc, char **argv)
 
strncpy(cmdname, *argv, sizeof(cmdname) - 1);
cmdname[sizeof(cmdname) - 1] = '\0';
-   while ((c = getopt(argc, argv, "f:k:")) != -1)
+   while ((c = getopt(argc, argv, "f:k:c:")) != -1)
switch (c) {
case 'f':
fdtfile = optarg;
@@ -56,6 +57,9 @@ int main(int argc, char **argv)
case 'k':
keyfile = optarg;
break;
+   case 'c':
+   config_name = optarg;
+   break;
default:
usage(cmdname);
break;
@@ -78,7 +82,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
 
image_set_host_blob(key_blob);
-   ret = fit_check_sign(fit_blob, key_blob);
+   ret = fit_check_sign(fit_blob, key_blob, config_name);
if (!ret) {
ret = EXIT_SUCCESS;
fprintf(stderr, "Signature check OK\n");
diff --git a/tools/image-host.c b/tools/image-host.c
index b3ec197dc9..dfea48e894 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -1025,12 +1025,13 @@ int fit_add_verification_data(const char *keydir, void 
*keydest, void *fit,
 }
 
 #ifdef CONFIG_FIT_SIGNATURE
-int fit_check_sign(const void *fit, const void *key)
+int fit_check_sign(const void *fit, const void *key,
+  const char *fit_uname_config)
 {
int cfg_noffset;
int ret;
 
-   cfg_noffset = fit_conf_get_node(fit, NULL);
+   cfg_noffset = fit_conf_get_node(fit, fit_uname_config);
if (!cfg_noffset)
return -1;
 
@@ -1039,6 +1040,7 @@ int fit_check_sign(const void *fit, const void *key)
ret = fit_config_verify(fit, cfg_noffset);
if (ret)
return ret;
+   printf("Verified OK, loading images\n");
ret = bootm_host_load_images(fit, cfg_noffset);
 
return ret;
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 05/14] test: vboot: Add a test for a forged configuration

2020-03-18 Thread Simon Glass
Add a check to make sure that it is not possible to add a new
configuration and use the hashed nodes and hash of another configuration.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Bring in new vboot_forge file from the authors

 test/py/tests/test_vboot.py  |  18 +-
 test/py/tests/vboot_forge.py | 423 +++
 2 files changed, 440 insertions(+), 1 deletion(-)
 create mode 100644 test/py/tests/vboot_forge.py

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 3dd8e3cb66..22c79ef313 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -28,6 +28,7 @@ import pytest
 import sys
 import struct
 import u_boot_utils as util
+import vboot_forge
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('fit_signature')
@@ -182,7 +183,22 @@ def test_vboot(u_boot_console):
 
 util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb])
 
-# Replace header bytes
+# Make sure that U-Boot checks that the config is in the list of hashed
+# nodes. If it isn't, a security bypass is possible.
+with open(fit, 'rb') as fp:
+root, strblock = vboot_forge.read_fdt(fp)
+root, strblock = vboot_forge.manipulate(root, strblock)
+with open(fit, 'w+b') as fp:
+vboot_forge.write_fdt(root, strblock, fp)
+util.run_and_log_expect_exception(cons,
+[fit_check_sign, '-f', fit, '-k', dtb],
+1, 'Failed to verify required signature')
+
+run_bootm(sha_algo, 'forged config', 'Bad Data Hash', False)
+
+# Create a new properly signed fit and replace header bytes
+make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
+sign_fit(sha_algo)
 bcfg = u_boot_console.config.buildconfig
 max_size = int(bcfg.get('config_fit_signature_max_size', 0x1000), 
0)
 existing_size = replace_fit_totalsize(max_size + 1)
diff --git a/test/py/tests/vboot_forge.py b/test/py/tests/vboot_forge.py
new file mode 100644
index 00..0fb7ef4024
--- /dev/null
+++ b/test/py/tests/vboot_forge.py
@@ -0,0 +1,423 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020, F-Secure Corporation, https://foundry.f-secure.com
+#
+# pylint: disable=E1101,W0201,C0103
+
+"""
+Verified boot image forgery tools and utilities
+
+This module provides services to both take apart and regenerate FIT images
+in a way that preserves all existing verified boot signatures, unless you
+manipulate nodes in the process.
+"""
+
+import struct
+import binascii
+from io import BytesIO
+
+#
+# struct parsing helpers
+#
+
+class BetterStructMeta(type):
+"""
+Preprocesses field definitions and creates a struct.Struct instance from 
them
+"""
+def __new__(cls, clsname, superclasses, attributedict):
+if clsname != 'BetterStruct':
+fields = attributedict['__fields__']
+field_types = [_[0] for _ in fields]
+field_names = [_[1] for _ in fields if _[1] is not None]
+attributedict['__names__'] = field_names
+s = struct.Struct(attributedict.get('__endian__', '') + 
''.join(field_types))
+attributedict['__struct__'] = s
+attributedict['size'] = s.size
+return type.__new__(cls, clsname, superclasses, attributedict)
+
+class BetterStruct(metaclass=BetterStructMeta):
+"""
+Base class for better structures
+"""
+def __init__(self):
+for t, n in self.__fields__:
+if 's' in t:
+setattr(self, n, '')
+elif t in ('Q', 'I', 'H', 'B'):
+setattr(self, n, 0)
+
+@classmethod
+def unpack_from(cls, buffer, offset=0):
+"""
+Unpack structure instance from a buffer
+"""
+fields = cls.__struct__.unpack_from(buffer, offset)
+instance = cls()
+for n, v in zip(cls.__names__, fields):
+setattr(instance, n, v)
+return instance
+
+def pack(self):
+"""
+Pack structure instance into bytes
+"""
+return self.__struct__.pack(*[getattr(self, n) for n in 
self.__names__])
+
+def __str__(self):
+items = ["'%s': %s" % (n, repr(getattr(self, n))) for n in 
self.__names__ if n is not None]
+return '(' + ', '.join(items) + ')'
+
+#
+# some defs for flat DT data
+#
+
+class HeaderV17(BetterStruct):
+__endian__ = '>'
+__fields__ = [
+('I', 'magic'),
+('I', 'totalsize'),
+('I', 'off_dt_struct'),
+('I', 'off_dt_strings'),
+('I', 'off_mem_rsvmap'),
+('I', 'version'),
+('I', 'last_comp_version'),
+('I', 'boot_cpuid_phys'),
+('I', 'size_dt_strings'),
+('I', 'size_dt_struct'),
+]
+
+class RRHeader(BetterStruct):
+__endian__ = '>'
+__fields__ = [
+('Q', 'address'),
+('Q', 'size'),
+]
+
+class PropHeader(BetterStruct):
+__en

[PATCH v2 04/14] test: vboot: Drop unnecessary parameter for fit_check_sign

2020-03-18 Thread Simon Glass
This tool only uses the last -k parameter provided. Drop the earlier one
since it has no effect.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 9c41ee56b1..3dd8e3cb66 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -180,8 +180,7 @@ def test_vboot(u_boot_console):
 
 cons.log.action('%s: Check signed config on the host' % sha_algo)
 
-util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', tmpdir,
-'-k', dtb])
+util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb])
 
 # Replace header bytes
 bcfg = u_boot_console.config.buildconfig
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 06/14] test: vboot: Parameterise the test

2020-03-18 Thread Simon Glass
This test is actually made up of five separate tests. Split them out so
that they appear as separate tests.

Unfortunately this restarts U-Boot multiple times which adds about a
second to the already-long vboot test, about 8 seconds total on my
machine. We could add a special 'teardown' test afterwards but if the
tests are executed out of order that would not work.

Changing test_vboot into a class causes it not to be discovered and makes
it different from all other tests.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 test/py/tests/test_vboot.py | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 22c79ef313..b1badaad73 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -30,13 +30,22 @@ import struct
 import u_boot_utils as util
 import vboot_forge
 
+TESTDATA = [
+['sha1', '', False],
+['sha1', '-pss', False],
+['sha256', '', False],
+['sha256', '-pss', False],
+['sha256', '-pss', True],
+]
+
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('fit_signature')
 @pytest.mark.requiredtool('dtc')
 @pytest.mark.requiredtool('fdtget')
 @pytest.mark.requiredtool('fdtput')
 @pytest.mark.requiredtool('openssl')
-def test_vboot(u_boot_console):
+@pytest.mark.parametrize("sha_algo,padding,required", TESTDATA)
+def test_vboot(u_boot_console, sha_algo, padding, required):
 """Test verified boot signing with mkimage and verification with 'bootm'.
 
 This works using sandbox only as it needs to update the device tree used
@@ -297,11 +306,10 @@ def test_vboot(u_boot_console):
 # afterwards.
 old_dtb = cons.config.dtb
 cons.config.dtb = dtb
-test_with_algo('sha1','')
-test_with_algo('sha1','-pss')
-test_with_algo('sha256','')
-test_with_algo('sha256','-pss')
-test_required_key('sha256','-pss')
+if required:
+test_required_key(sha_algo, padding)
+else:
+test_with_algo(sha_algo, padding)
 finally:
 # Go back to the original U-Boot with the correct dtb.
 cons.config.dtb = old_dtb
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 03/14] image: Return an error message from fit_config_verify_sig()

2020-03-18 Thread Simon Glass
This function only returns an error message sometimes. Update it to always
return an error message if one is available. This makes it easier to see
what went wrong.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/image-sig.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/image-sig.c b/common/image-sig.c
index 639a112450..13ccd50bc5 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -499,13 +499,14 @@ static int fit_config_verify_sig(const void *fit, int 
conf_noffset,
goto error;
}
 
-   return verified ? 0 : -EPERM;
+   if (verified)
+   return 0;
 
 error:
printf(" error!\n%s for '%s' hash node in '%s' config node\n",
   err_msg, fit_get_name(fit, noffset, NULL),
   fit_get_name(fit, conf_noffset, NULL));
-   return -1;
+   return -EPERM;
 }
 
 int fit_config_verify_required_sigs(const void *fit, int conf_noffset,
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 02/14] image: Be a little more verbose when checking signatures

2020-03-18 Thread Simon Glass
It is useful to be a little more specific about what is being checked.
Update a few messages to help with this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/image-fit.c | 2 +-
 tools/image-host.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 7cf02b4574..a5c85ede8d 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1951,7 +1951,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
fit_uname = fit_get_name(fit, noffset, NULL);
}
if (noffset < 0) {
-   puts("Could not find subimage node\n");
+   printf("Could not find subimage node type '%s'\n", prop_name);
bootstage_error(bootstage_id + BOOTSTAGE_SUB_SUBNODE);
return -ENOENT;
}
diff --git a/tools/image-host.c b/tools/image-host.c
index 76a361b9d6..b3ec197dc9 100644
--- a/tools/image-host.c
+++ b/tools/image-host.c
@@ -1034,7 +1034,8 @@ int fit_check_sign(const void *fit, const void *key)
if (!cfg_noffset)
return -1;
 
-   printf("Verifying Hash Integrity ... ");
+   printf("Verifying Hash Integrity for node '%s'... ",
+  fdt_get_name(fit, cfg_noffset, NULL));
ret = fit_config_verify(fit, cfg_noffset);
if (ret)
return ret;
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 01/14] image: Correct comment for fit_conf_get_node()

2020-03-18 Thread Simon Glass
This should mention that conf_uname can be NULL and should be in the
header file. Fix this.

Signed-off-by: Simon Glass 
---

Changes in v2: None

 common/image-fit.c | 18 --
 include/image.h| 20 
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 4435bc4f1d..7cf02b4574 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1712,24 +1712,6 @@ int fit_conf_find_compat(const void *fit, const void 
*fdt)
return best_match_offset;
 }
 
-/**
- * fit_conf_get_node - get node offset for configuration of a given unit name
- * @fit: pointer to the FIT format image header
- * @conf_uname: configuration node unit name
- *
- * fit_conf_get_node() finds a configuration (within the '/configurations'
- * parent node) of a provided unit name. If configuration is found its node
- * offset is returned to the caller.
- *
- * When NULL is provided in second argument fit_conf_get_node() will search
- * for a default configuration node instead. Default configuration node unit
- * name is retrieved from FIT_DEFAULT_PROP property of the '/configurations'
- * node.
- *
- * returns:
- * configuration node offset when found (>=0)
- * negative number on failure (FDT_ERR_* code)
- */
 int fit_conf_get_node(const void *fit, const char *conf_uname)
 {
int noffset, confs_noffset;
diff --git a/include/image.h b/include/image.h
index b316d167d8..512243f159 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1092,7 +1092,27 @@ int fit_image_check_comp(const void *fit, int noffset, 
uint8_t comp);
 int fit_check_format(const void *fit);
 
 int fit_conf_find_compat(const void *fit, const void *fdt);
+
+/**
+ * fit_conf_get_node - get node offset for configuration of a given unit name
+ * @fit: pointer to the FIT format image header
+ * @conf_uname: configuration node unit name (NULL to use default)
+ *
+ * fit_conf_get_node() finds a configuration (within the '/configurations'
+ * parent node) of a provided unit name. If configuration is found its node
+ * offset is returned to the caller.
+ *
+ * When NULL is provided in second argument fit_conf_get_node() will search
+ * for a default configuration node instead. Default configuration node unit
+ * name is retrieved from FIT_DEFAULT_PROP property of the '/configurations'
+ * node.
+ *
+ * returns:
+ * configuration node offset when found (>=0)
+ * negative number on failure (FDT_ERR_* code)
+ */
 int fit_conf_get_node(const void *fit, const char *conf_uname);
+
 int fit_conf_get_prop_node_count(const void *fit, int noffset,
const char *prop_name);
 int fit_conf_get_prop_node_index(const void *fit, int noffset,
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v2 00/14] vboot: Fix forged-configuration vulnerability

2020-03-18 Thread Simon Glass
When booting a FIT, if 'bootm' is used without a specified configuration,
U-Boot will use the default one provided in the FIT. But it does not
actually check that the signature is for that configuration.

This means that it is possible to duplicate a configuration conf-1 to
produce conf-2 (with all the signatures intact), set the default
configuration to conf-2 and then boot the image. U-Boot will verify conf-2
(in fact since hashed-nodes specifies the conf-1 nodes it will effectively
verify conf-1). Then it will happily boot conf-2 even though it might have
a different kernel.

This series corrects this problem and adds a test to verify it. It also
updates fit_check_sign to allow the configuration to be specified.

This vulnerability was found by Dmitry Janushkevich and Andrea Barisani of
F-Secure, who also wrote the vboot_forge script included here.

This is CVE-2020-10648

Changes in v2:
- Bring in new vboot_forge file from the authors

Simon Glass (14):
  image: Correct comment for fit_conf_get_node()
  image: Be a little more verbose when checking signatures
  image: Return an error message from fit_config_verify_sig()
  test: vboot: Drop unnecessary parameter for fit_check_sign
  test: vboot: Add a test for a forged configuration
  test: vboot: Parameterise the test
  image: Check hash-nodes when checking configurations
  image: Load the correct configuration in fit_check_sign
  fit_check_sign: Allow selecting the configuration to verify
  test: vboot: Tidy up the code a little
  test: vboot: Fix pylint errors
  image: Use constants for 'required' and 'key-name-hint'
  test: vboot: Move key creation into a function
  test: vboot: Reduce fake kernel size to 500 bytes

 common/bootm.c   |   6 +-
 common/image-cipher.c|   2 +-
 common/image-fit.c   |  26 +--
 common/image-sig.c   |  49 +++-
 include/image.h  |  24 +-
 lib/rsa/rsa-sign.c   |   6 +-
 test/py/tests/test_vboot.py  | 155 +++--
 test/py/tests/vboot_forge.py | 423 +++
 tools/fdt_host.h |   3 +-
 tools/fit_check_sign.c   |   8 +-
 tools/image-host.c   |  17 +-
 11 files changed, 601 insertions(+), 118 deletions(-)
 create mode 100644 test/py/tests/vboot_forge.py

-- 
2.25.1.481.gfbce0eb801-goog



Antwort: [PATCH v2 33/39] acpi: Add support for SSDT generation

2020-03-18 Thread Wolfgang Wallner
Hi Simon,

"Simon Glass"  schrieb am 09.03.2020 04:44:57:

> Betreff: [PATCH v2 33/39] acpi: Add support for SSDT generation
> 
> Some devices need to generate code for the Secondary System Descriptor
> Table (SSDT). Add a method to handle this.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Switch parameter order of _acpi_fill_ssdt() and make it static
> 
>  arch/sandbox/dts/test.dts |  2 ++
>  drivers/core/acpi.c   | 14 +
>  include/dm/acpi.h | 23 ++
>  test/dm/acpi.c| 41 ++-
>  4 files changed, 79 insertions(+), 1 deletion(-)
> 

[snip]

> diff --git a/test/dm/acpi.c b/test/dm/acpi.c
> index feb380b26c..305d8395ff 100644
> --- a/test/dm/acpi.c
> +++ b/test/dm/acpi.c
> @@ -7,6 +7,7 @@

[snip]

>  static const struct udevice_id testacpi_ids[] = {
> @@ -313,3 +325,30 @@ static int dm_test_acpi_cmd_dump(struct 
unit_test_state *uts)
> return 0;
>  }
>  DM_TEST(dm_test_acpi_cmd_dump, DM_TESTF_SCAN_PDATA | 
DM_TESTF_SCAN_FDT);
> +
> +/* Test acpi_fill_ssdt() */
> +static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)
> +{
> +   struct acpi_ctx ctx;
> +   u8 *buf;
> +
> +   buf = malloc(BUF_SIZE);
> +   ut_assertnonnull(buf);
> +
> +   ctx.current = buf;
> +   buf[4] = 'z';   /* sentinal */

nit: sentinel ?

> +   ut_assertok(acpi_fill_ssdt(&ctx));
> +
> +   /* These values come from acpi-test's acpi-ssdt-test-data property 
*/
> +   ut_asserteq('a', buf[0]);
> +   ut_asserteq('b', buf[1]);
> +
> +   /* These values come from acpi-test2's acpi-ssdt-test-data property 
*/
> +   ut_asserteq('c', buf[2]);
> +   ut_asserteq('d', buf[3]);
> +
> +   ut_asserteq('z', buf[4]);
> +
> +   return 0;
> +}
> +DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | 
DM_TESTF_SCAN_FDT);
> -- 
> 2.25.1.481.gfbce0eb801-goog
> 

Reviewed-by: Wolfgang Wallner 




U-CLASS SPI Bus and Devices

2020-03-18 Thread Rudolf J Streif

I ran into an issue today with a U-CLASS SPI NOR flash device on a NXP
FlexSPI controller. U-Boot started correctly from the flash device but
using 'sf probe 0:0' would always return 'Invalid bus 0 (err=-19)'. This
error message is emitted by spi_get_bus_and_cs() in
drivers/spi/spi-uclass.c. I traced the issue to
uclass_get_device_by_seq() in drivers/core/uclass.c.

The function first searches the device list for a device that already
claimed the sequence number (dev->seq). If not found it would look if a
device requested that sequence number (dev->seq_req). That would always
fail for my device. The bus had not been probed yet and hence dev->seq
was -1 and the device also had dev->req_seq set to -1.

The board is using a device tree hence it would only make sense to set
the requested sequence number via the device tree. However, there is no
such thing and even if there was it might not be specified.

Consequently, the device was never probed although the driver was
correctly set up via device tree.

I worked around it by simply setting dev->req_seq of the first device
that had it set to -1 to the sequence number the search function was
looking for (see patch below). It solved my problem but I don't know if
that is the right way of addressing it. I could not find any other
solution for this particular problem anywhere.

Rudi



From 0f05ab964fcc7d29d8d467e663d7daa72328cf66 Mon Sep 17 00:00:00 2001
From: Rudolf J Streif 
Date: Tue, 17 Mar 2020 17:13:07 -0700
Subject: [PATCH] Fix issue with SPI device sequence number

If the requested sequence number for a SPI device was -1 (any)
then the device would never be probed. This fix simply assigns
the sequence number asked for at probing to the device if it has
not been probed yet and the requested sequence number is -1.

Signed-off-by: Rudolf J Streif 
---
 drivers/core/uclass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index fc3157de39..e791103153 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -310,6 +310,8 @@ int uclass_find_device_by_seq(enum uclass_id id, int
seq_or_req_seq,

    uclass_foreach_dev(dev, uc) {
    debug("   - %d %d '%s'\n", dev->req_seq, dev->seq,
dev->name);
+   if (find_req_seq && dev->req_seq == -1)
+   dev->req_seq = seq_or_req_seq;
    if ((find_req_seq ? dev->req_seq : dev->seq) ==
    seq_or_req_seq) {
    *devp = dev;

-- 
2.23.0







signature.asc
Description: OpenPGP digital signature


RE: [PATCH 1/2] mmc: t210: Add autocal and tap/trim updates for SDMMC1/3

2020-03-18 Thread Tom Warren
[Tom] see below

-Original Message-
From: Jaehoon Chung  
Sent: Tuesday, March 17, 2020 4:48 PM
To: Tom Warren ; u-boot@lists.denx.de
Subject: Re: [PATCH 1/2] mmc: t210: Add autocal and tap/trim updates for 
SDMMC1/3

External email: Use caution opening links or attachments


On 3/17/20 6:59 AM, twar...@nvidia.com wrote:
> From: Tom Warren 
>
> As per the T210 TRM, when running at 3.3v, the SDMMC1 tap/trim and 
> autocal values need to be set to condition the signals correctly 
> before talking to the SD-card. This is the same as what's being done 
> in CBoot, but it gets reset when the SDMMC1 HW is soft-reset during SD 
> driver init, so needs to be repeated here. Also set autocal and 
> tap/trim for SDMMC3, although no T210 boards use it for SD-card at this time.
>
> Signed-off-by: Tom Warren 
> ---
>  arch/arm/include/asm/arch-tegra/tegra_mmc.h | 20 +--
>  drivers/mmc/tegra_mmc.c | 84 
> ++---
>  2 files changed, 92 insertions(+), 12 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-tegra/tegra_mmc.h 
> b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
> index a2b6f63..a8bfa46 100644
> --- a/arch/arm/include/asm/arch-tegra/tegra_mmc.h
> +++ b/arch/arm/include/asm/arch-tegra/tegra_mmc.h
> @@ -2,7 +2,7 @@
>  /*
>   * (C) Copyright 2009 SAMSUNG Electronics
>   * Minkyu Kang 
> - * Portions Copyright (C) 2011-2012 NVIDIA Corporation
> + * Portions Copyright (C) 2011-2012,2019 NVIDIA Corporation
>   */
>
>  #ifndef __TEGRA_MMC_H_
> @@ -52,7 +52,7 @@ struct tegra_mmc {
>   unsigned char   admaerr;/* offset 54h */
>   unsigned char   res4[3];/* RESERVED, offset 55h-57h */
>   unsigned long   admaaddr;   /* offset 58h-5Fh */
> - unsigned char   res5[0xa0]; /* RESERVED, offset 60h-FBh */
> + unsigned char   res5[0x9c]; /* RESERVED, offset 60h-FBh */

Is comment right? "RESERVED, offset 60h-FBh"..
[Tom] yes, the comment was/is correct, it's the number of reserved bytes that 
was wrong - 0x9C is correct.

>   unsigned short  slotintstatus;  /* offset FCh */
>   unsigned short  hcver;  /* HOST Version */
>   unsigned intvenclkctl;  /* _VENDOR_CLOCK_CNTRL_0,100h */
> @@ -127,11 +127,23 @@ struct tegra_mmc {
>
>  #define TEGRA_MMC_NORINTSIGEN_XFER_COMPLETE  (1 << 1)
>
> -/* SDMMC1/3 settings from section 24.6 of T30 TRM */
> +/* SDMMC1/3 settings from SDMMCx Initialization Sequence of TRM */
>  #define MEMCOMP_PADCTRL_VREF 7
> -#define AUTO_CAL_ENABLED (1 << 29)
> +#define AUTO_CAL_ENABLE  (1 << 29)
> +#if defined(CONFIG_TEGRA210)
> +#define AUTO_CAL_ACTIVE  (1 << 31)
> +#define AUTO_CAL_START   (1 << 31)
> +#define AUTO_CAL_PD_OFFSET   (0x7D << 8)
> +#define AUTO_CAL_PU_OFFSET   (0 << 0)
> +#define IO_TRIM_BYPASS_MASK  (1 << 2)
> +#define TRIM_VAL_SHIFT   24
> +#define TRIM_VAL_MASK(0x1F << TRIM_VAL_SHIFT)
> +#define TAP_VAL_SHIFT16
> +#define TAP_VAL_MASK (0xFF << TAP_VAL_SHIFT)
> +#else
>  #define AUTO_CAL_PD_OFFSET   (0x70 << 8)
>  #define AUTO_CAL_PU_OFFSET   (0x62 << 0)
> +#endif
>
>  #endif   /* __ASSEMBLY__ */
>  #endif   /* __TEGRA_MMC_H_ */
> diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c index 
> f022e93..a4bd679 100644
> --- a/drivers/mmc/tegra_mmc.c
> +++ b/drivers/mmc/tegra_mmc.c
> @@ -3,7 +3,7 @@
>   * (C) Copyright 2009 SAMSUNG Electronics
>   * Minkyu Kang 
>   * Jaehoon Chung 
> - * Portions Copyright 2011-2016 NVIDIA Corporation
> + * Portions Copyright 2011-2019 NVIDIA Corporation
>   */
>
>  #include 
> @@ -15,6 +15,9 @@
>  #include 
>  #include   #include 
> +#if defined(CONFIG_TEGRA210)
> +#include 
> +#endif
>
>  struct tegra_mmc_plat {
>   struct mmc_config cfg;
> @@ -30,6 +33,7 @@ struct tegra_mmc_priv {
>   struct gpio_desc wp_gpio;   /* Write Protect GPIO */
>   unsigned int version;   /* SDHCI spec. version */
>   unsigned int clock; /* Current clock (MHz) */
> + int mmc_id; /* peripheral id */
>  };
>
>  static void tegra_mmc_set_power(struct tegra_mmc_priv *priv, @@ 
> -446,16 +450,19 @@ static int tegra_mmc_set_ios(struct udevice *dev)
>
>  static void tegra_mmc_pad_init(struct tegra_mmc_priv *priv)  { -#if 
> defined(CONFIG_TEGRA30)
> +#if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA210)
>   u32 val;
> + u16 clk_con;
> + int timeout;
> + int id = priv->mmc_id;
>
> - debug("%s: sdmmc address = %08x\n", __func__, (unsigned int)priv->reg);
> + debug("%s: sdmmc address = %p, id = %d\n", __func__,
> + priv->reg, id);
>
>   /* Set the pad drive strength for SDMMC1 or 3 only */
> - if (priv->reg != (void *)0x7800 &&
> - priv->reg != (void *)0x78000400) {
> + if (id != PERIPH_ID_SDMMC1 && id != PERIPH_ID_SDMMC3) {
>   debug("%s: settings are only valid for SDMMC1/SDMMC3!\n",
> -   __func__);
> +

[PATCH] rockchip: mkimage: Use an existing macro instead of a decimal value

2020-03-18 Thread Miquel Raynal
Depending on the SoC, a header of four characters is prepended to the
image. There is already a macro defining the number of characters:
RK_SPL_HDR_SIZE, so use it instead of hardcoding "4".

Signed-off-by: Miquel Raynal 
---
 tools/rkcommon.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/rkcommon.c b/tools/rkcommon.c
index 0d908daee80..a80899e2806 100644
--- a/tools/rkcommon.c
+++ b/tools/rkcommon.c
@@ -246,11 +246,13 @@ static int rkcommon_parse_header(const void *buf, struct 
header0_info *header0,
   rkcommon_offset_to_spi(hdr1_offset));
 
for (i = 0; i < ARRAY_SIZE(spl_infos); i++) {
-   if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr, 4)) {
+   if (!memcmp(&hdr1_sdmmc->magic, spl_infos[i].spl_hdr,
+   RK_SPL_HDR_SIZE)) {
if (spl_info)
*spl_info = &spl_infos[i];
return IH_TYPE_RKSD;
-   } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr, 4)) {
+   } else if (!memcmp(&hdr1_spi->magic, spl_infos[i].spl_hdr,
+  RK_SPL_HDR_SIZE)) {
if (spl_info)
*spl_info = &spl_infos[i];
return IH_TYPE_RKSPI;
-- 
2.20.1



Antwort: [PATCH v2 32/39] irq: Add a method to convert an interrupt to ACPI

2020-03-18 Thread Wolfgang Wallner
Hi Simon,

I'm resending this mail, as my email client has broken the formating
in the first attempt, sorry.


"Simon Glass"  schrieb am 09.03.2020 04:44:56:

> Von: "Simon Glass" 
> An: "U-Boot Mailing List" , 
> Kopie: "Bin Meng" , "Wolfgang Wallner" 
> , "Andy Shevchenko" 
> , "Simon Glass" 
> Datum: 09.03.2020 04:46
> Betreff: [PATCH v2 32/39] irq: Add a method to convert an interrupt to 
ACPI
> 
> When generating ACPI tables we need to convert IRQs in U-Boot to the 
ACPI
> structures required by ACPI. This is a SoC-specific conversion and 
cannot
> be handled by generic code, so add a new IRQ method to do the 
conversion.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2: None
> 
>  drivers/misc/irq-uclass.c | 18 +++-
>  include/acpi_device.h | 27 +++
>  include/irq.h | 41 +
>  lib/acpi/acpi_device.c| 94 +++
>  4 files changed, 178 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
> index 61aa10e465..b4a8b7b429 100644
> --- a/drivers/misc/irq-uclass.c
> +++ b/drivers/misc/irq-uclass.c
> @@ -153,8 +153,6 @@ int irq_request(struct udevice *dev, struct irq 
*irq)
> const struct irq_ops *ops;
> 
> log_debug("(dev=%p, irq=%p)\n", dev, irq);
> -   if (!irq)
> -  return 0;

Why is this code dropped?

> ops = irq_get_ops(dev);
> 
> irq->dev = dev;
> @@ -176,6 +174,22 @@ int irq_first_device_type(enum irq_dev_t type, 
> struct udevice **devp)
> return 0;
>  }
> 
> +#if CONFIG_IS_ENABLED(ACPIGEN)
> +int irq_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq)
> +{
> +   struct irq_ops *ops;
> +
> +   if (!irq_is_valid(irq))
> +  return -EINVAL;
> +
> +   ops = irq_get_ops(irq->dev);
> +   if (!ops->get_acpi)
> +  return -ENOSYS;
> +
> +   return ops->get_acpi(irq, acpi_irq);
> +}
> +#endif
> +
>  UCLASS_DRIVER(irq) = {
> .id  = UCLASS_IRQ,
> .name  = "irq",
> diff --git a/include/acpi_device.h b/include/acpi_device.h
> index acd26c0f54..50ba9b66aa 100644
> --- a/include/acpi_device.h
> +++ b/include/acpi_device.h
> @@ -545,6 +545,33 @@ int acpi_dp_write(struct acpi_ctx *ctx, struct 
> acpi_dp *table);
>  int acpi_device_write_gpio_desc(struct acpi_ctx *ctx,
>  const struct gpio_desc *desc);
> 
> +/**
> + * acpi_device_write_interrupt_irq() - Write an interrupt to ACPI
> + *
> + * This creates an interrupt descriptor for an interrupt, including
> information
> + * ACPI needs to use it.
> + *
> + * @req_irq: Interrupt to write
> + * @return 0 if OK, -ve on error
> + */
> +int acpi_device_write_interrupt_irq(struct acpi_ctx *ctx,
> +const struct irq *req_irq);
> +
> +/**
> + * acpi_device_write_interrupt_or_gpio() - Write interrupt or GPIO to 
ACPI
> + *
> + * This reads the an interrupt from the device tree, if available. If 
not it

typo: "the an"

The description of what this function should do is rather vague.
At least I'm not sure how it is meant to work.

> + * reads the first GPIO with the name @prop.
> + *
> + * If an interrupt is found, that is written to ACPI. If not, but an 
GPIO is
> + * found, that is written.
> + *
> + * @return 0 if OK, -ve if neither an interrupt nor a GPIO could 
befound, or
> + * some other error occurred
> + */
> +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx,
> +   struct udevice *dev, const char *prop);
> +
>  /**
>   * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including
>   * information ACPI needs to use it.
> diff --git a/include/irq.h b/include/irq.h
> index d4948e6dc4..8527e4dd79 100644
> --- a/include/irq.h
> +++ b/include/irq.h
> @@ -8,6 +8,7 @@
>  #ifndef __irq_H
>  #define __irq_H
> 
> +struct acpi_irq;
>  struct ofnode_phandle_args;
> 
>  /*
> @@ -26,10 +27,12 @@ enum irq_dev_t {
>   *
>   * @dev: IRQ device that handles this irq
>   * @id: ID to identify this irq with the device
> + * @flags: Flags associated with this interrupt (IRQ_TYPE_...)
>   */
>  struct irq {
> struct udevice *dev;
> ulong id;
> +   ulong flags;
>  };
> 
>  /**
> @@ -121,10 +124,36 @@ struct irq_ops {
>  * @return 0 if OK, or a negative error code.
>  */
> int (*free)(struct irq *irq);
> +
> +#if CONFIG_IS_ENABLED(ACPIGEN)
> +   /**
> +* get_acpi() - Get the ACPI info for an irq
> +*
> +* This converts a irq to an ACPI structure for adding to the ACPI
> +* tables.
> +*
> +* @irq:   irq to convert
> +* @acpi_irq:   Output ACPI interrupt information
> +* @return ACPI pin number or -ve on error
> +*/
> +   int (*get_acpi)(const struct irq *irq, struct acpi_irq *acpi_irq);
> +#endif
>  };
> 
>  #define irq_get_ops(dev)   ((struct irq_ops *)(dev)->driver->ops)
> 
> +/**
> + * irq_is_valid() - Check if an IRQ is valid
> + *
> + * @irq:   IRQ description containing device and ID, e.g. previously
> + *  returned by irq_get_by_index()
> + * @return true if valid, false if not
>

Antwort: [PATCH v2 32/39] irq: Add a method to convert an interrupt to ACPI

2020-03-18 Thread Wolfgang Wallner
Hi Simon,

"Simon Glass"  schrieb am 09.03.2020 04:44:56:

> Von: "Simon Glass" 
> An: "U-Boot Mailing List" , 
> Kopie: "Bin Meng" , "Wolfgang Wallner" 
> , "Andy Shevchenko" 
> , "Simon Glass" 
> Datum: 09.03.2020 04:46
> Betreff: [PATCH v2 32/39] irq: Add a method to convert an interrupt to 
ACPI
> 
> When generating ACPI tables we need to convert IRQs in U-Boot to the 
ACPI
> structures required by ACPI. This is a SoC-specific conversion and 
cannot
> be handled by generic code, so add a new IRQ method to do the 
conversion.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2: None
> 
>  drivers/misc/irq-uclass.c | 18 +++-
>  include/acpi_device.h | 27 +++
>  include/irq.h | 41 +
>  lib/acpi/acpi_device.c| 94 +++
>  4 files changed, 178 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
> index 61aa10e465..b4a8b7b429 100644
> --- a/drivers/misc/irq-uclass.c
> +++ b/drivers/misc/irq-uclass.c
> @@ -153,8 +153,6 @@ int irq_request(struct udevice *dev, struct irq 
*irq)
> const struct irq_ops *ops;
> 
> log_debug("(dev=%p, irq=%p)\n", dev, irq);
> -   if (!irq)
> -  return 0;

Why is this code dropped?

> ops = irq_get_ops(dev);
> 
> irq->dev = dev;
> @@ -176,6 +174,22 @@ int irq_first_device_type(enum irq_dev_t type, 
> struct udevice **devp)
> return 0;
>  }
> 
> +#if CONFIG_IS_ENABLED(ACPIGEN)
> +int irq_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq)
> +{
> +   struct irq_ops *ops;
> +
> +   if (!irq_is_valid(irq))
> +  return -EINVAL;
> +
> +   ops = irq_get_ops(irq->dev);
> +   if (!ops->get_acpi)
> +  return -ENOSYS;
> +
> +   return ops->get_acpi(irq, acpi_irq);
> +}
> +#endif
> +
>  UCLASS_DRIVER(irq) = {
> .id  = UCLASS_IRQ,
> .name  = "irq",
> diff --git a/include/acpi_device.h b/include/acpi_device.h
> index acd26c0f54..50ba9b66aa 100644
> --- a/include/acpi_device.h
> +++ b/include/acpi_device.h
> @@ -545,6 +545,33 @@ int acpi_dp_write(struct acpi_ctx *ctx, struct 
> acpi_dp *table);
>  int acpi_device_write_gpio_desc(struct acpi_ctx *ctx,
>  const struct gpio_desc *desc);
> 
> +/**
> + * acpi_device_write_interrupt_irq() - Write an interrupt to ACPI
> + *
> + * This creates an interrupt descriptor for an interrupt, including
> information
> + * ACPI needs to use it.
> + *
> + * @req_irq: Interrupt to write
> + * @return 0 if OK, -ve on error
> + */
> +int acpi_device_write_interrupt_irq(struct acpi_ctx *ctx,
> +const struct irq *req_irq);
> +
> +/**
> + * acpi_device_write_interrupt_or_gpio() - Write interrupt or GPIO to 
ACPI
> + *
> + * This reads the an interrupt from the device tree, if available. If 
not it

typo: "the an"

The description of what this function should do is rather vague.
At least I'm not sure how it is meant to work.

> + * reads the first GPIO with the name @prop.
> + *
> + * If an interrupt is found, that is written to ACPI. If not, but an 
GPIO is
> + * found, that is written.
> + *
> + * @return 0 if OK, -ve if neither an interrupt nor a GPIO could 
befound, or
> + * some other error occurred
> + */
> +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx,
> +   struct udevice *dev, const char *prop);
> +
>  /**
>   * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including
>   * information ACPI needs to use it.
> diff --git a/include/irq.h b/include/irq.h
> index d4948e6dc4..8527e4dd79 100644
> --- a/include/irq.h
> +++ b/include/irq.h
> @@ -8,6 +8,7 @@
>  #ifndef __irq_H
>  #define __irq_H
> 
> +struct acpi_irq;
>  struct ofnode_phandle_args;
> 
>  /*
> @@ -26,10 +27,12 @@ enum irq_dev_t {
>   *
>   * @dev: IRQ device that handles this irq
>   * @id: ID to identify this irq with the device
> + * @flags: Flags associated with this interrupt (IRQ_TYPE_...)
>   */
>  struct irq {
> struct udevice *dev;
> ulong id;
> +   ulong flags;
>  };
> 
>  /**
> @@ -121,10 +124,36 @@ struct irq_ops {
>  * @return 0 if OK, or a negative error code.
>  */
> int (*free)(struct irq *irq);
> +
> +#if CONFIG_IS_ENABLED(ACPIGEN)
> +   /**
> +* get_acpi() - Get the ACPI info for an irq
> +*
> +* This converts a irq to an ACPI structure for adding to the ACPI
> +* tables.
> +*
> +* @irq:   irq to convert
> +* @acpi_irq:   Output ACPI interrupt information
> +* @return ACPI pin number or -ve on error
> +*/
> +   int (*get_acpi)(const struct irq *irq, struct acpi_irq *acpi_irq);
> +#endif
>  };
> 
>  #define irq_get_ops(dev)   ((struct irq_ops *)(dev)->driver->ops)
> 
> +/**
> + * irq_is_valid() - Check if an IRQ is valid
> + *
> + * @irq:   IRQ description containing device and ID, e.g. previously
> + *  returned by irq_get_by_index()
> + * @return true if valid, false if not
> + */
> +static inline bool irq_is_valid(const struct irq *irq)
> +{
> +   return irq->dev != NULL;

RE: [PATCH v4 3/3] env: Add CONFIG_ENV_FULL_SUPPORT

2020-03-18 Thread Patrick DELAUNAY
Hi,

> From: Patrick DELAUNAY 
> Sent: jeudi 3 octobre 2019 09:24
> To: u-boot@lists.denx.de
> 
> Add a new flag CONFIG_ENV_FULL_SUPPORT to compile all
> the environment features (attributes, callbacks
> and flags) in U-Boot, TPL and SPL.
> 
> This flag replace the existing flags for SPL and TPL
> (CONFIG_SPL_ENV_SUPPORT / CONFIG_TPL_ENV_SUPPORT), because
> the same support of environment features is mandatory for U-Boot,
> SPL and TPL.
> 
> To deactivate the load/save environment support in SPL / TPL,
> the board need to activate CONFIG_SPL_ENV_IS_NOWHERE or
> CONFIG_TPL_ENV_IS_NOWHERE.
> 
> With this patch, the environment is activated by default in SPL
> and TPL, which include the content of default_environment[] as
> U-boot. To avoid to increase their size, this patch also add
> 3 new confif : CONFIG_$(SPL_TPL_)ENV_DEFAULT.
> It is deactivated by default for SPL/TPL and activated by
> default for U-Boot, the default environment for SPL/TPL is empty
> and it will be populated only when it will be loaded from storage
> medium.
> 
> All the test on CONFIG_SPL_ENV_SUPPORT are replaced by the
> ENV_IS_SOMEWHERE macro, which tests if the environment is
> storage medium.
> 
> Signed-off-by: Patrick Delaunay 
> ---
Hi Tom,

I try to solve default environment size issue in patch =

http://patchwork.ozlabs.org/patch/1257545/
[RFC RFT PATCH] env: spl: filter the variables in default environment of SPL or 
TPL

But as it is not acceptable and I don't see other solution, 
I won't push v5 and I considere this serie abandoned.

http://patchwork.ozlabs.org/patch/1171180/

Thanks

Patrick


RE: [PATCH v4 2/3] env: introduce macro ENV_IS_IN_SOMEWHERE

2020-03-18 Thread Patrick DELAUNAY
Hi,

> From: Patrick DELAUNAY 
> Sent: jeudi 3 octobre 2019 09:24
> 
> This patch introduce a macro ENV_IS_IN_SOMEWHERE to check if the the
> environment can be saved somewhere, in a storage medium, without assumption
> on CONFIG$(SPL_TPL_)ENV_IS_NOWHERE.
> 
> Since the commit 208bd2b85ecc ("env: allow ENV_IS_NOWHERE with other
> storage target"), it is allowed to activated ENV_IS_NOWHERE with other
> CONFIG_IS_IN... in U-Boot.
> It is only allowed for U-Boot but the remaining restriction in Kconfig could 
> also
> removed for SPL and TPL (depends on !SPL_ENV_IS_NOWHERE / depends on
> !TPL_ENV_IS_NOWHERE).
> 
> This macro ENV_IS_IN_SOMEWHERE can be used in code to check if the
> environment for U-Boot / SPL / TPL is really managed (at least one
> CONFIG$(SPL_TPL_)ENV_IS_IN_.. is activated).
> 
> Signed-off-by: Patrick Delaunay 
> ---

Hi Tom,

I try to solve default environment size issue in patch =

http://patchwork.ozlabs.org/patch/1257545/
[RFC RFT PATCH] env: spl: filter the variables in default environment of SPL or 
TPL

But as it is not acceptable and I don't see other solution for this serie.

I won't push v5 for this serie and I considere this serie abandoned.

http://patchwork.ozlabs.org/patch/1171098/

Thanks

Patrick


RE: [RFC RFT PATCH] env: spl: filter the variables in default environment of SPL or TPL

2020-03-18 Thread Patrick DELAUNAY
Hi Wolfgang,

> From: Wolfgang Denk 
> Sent: mercredi 18 mars 2020 15:51
> To: Patrick DELAUNAY 
> Cc: u-boot@lists.denx.de; Bin Meng ; Fabio Estevam
> ; Heinrich Schuchardt ; Jagan
> Teki ; Joe Hershberger
> ; Kever Yang ; Marek
> Vasut ; Simon Glass ; U-Boot STM32
> 
> Subject: Re: [RFC RFT PATCH] env: spl: filter the variables in default
> environment of SPL or TPL
> 
> Dear Patrick,
> 
> In message <20200318143602.23253-1-patrick.delau...@st.com> you wrote:
> > Use a new option CONFIG_SPL_ENV_VARS to filter the variables included
> > in the default environment used in SPL (and TPL).
> >
> > That allows to reduce the size of default_environment[].
> 
> Sorry, but NAK.  we had this discussion a couple of times before.
> It is mandatory that both SPL and U-Boot proper will use the _same_ 
> environment,
> including the same default environment, or all kind of havoc may result.  
> Just think
> of situations where Falcon Mode is being used and SPL and U-Boot proper would
> be using different settings.
> 
> If your default environment is too big for the SPL, then make it smaller.  If 
> you
> need additional settings in U-Boot, there are many ways to load thise there.

Thanks for the answer, 
so it was clearly not an option and I abandon this patch.

To complete my answer, today I don't have issue with SPL environment size on 
the stm32 targets,

I propose this patch only to solve issue with my previous proposed patch on 
other target

- [U-Boot,v4,3/3] env: Add CONFIG_ENV_FULL_SUPPORT
- [U-Boot,v4,2/3] env: introduce macro ENV_IS_IN_SOMEWHERE

This proposal raise many size issue for other boards when I activated
CONFIG_SPL_ENV_SUPPORT and CONFIG_SPL_ENV_IS_NOWHERE by default

Today I don’t see solution except accept the current situation:
for some target, the environment isn't supported/activated in SPL, even default 
one
(when CONFIG_SPL_ENV_SUPPORT not activated, the env source files aren't 
compiled)

So I will also abandon the previous patchset
- http://patchwork.ozlabs.org/patch/1171180/ 
- http://patchwork.ozlabs.org/patch/1171098/

Patrick

> Best regards,
> 
> Wolfgang Denk
> 
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de "If
> that makes any sense to you, you have a big problem."
>   -- C. Durance, Computer Science 234


[PATCH v3 23/23] test/py: Allow using buildman to build U-Boot

2020-03-18 Thread Simon Glass
It is a pain to have to set the CROSS_COMPILE environment variable when
using test.py's --build option. It is possible to get this using the -A
option from buildman. But it seems better to just use buildman to do the
build when it is available.

However using buildman adds a new dependency to the test system which we
want to avoid. So leave the default as is and add a flag to make it use
buildman.

Note that most of these changes relate to test.py and the parts of the
travis/gitlab/azure scripts which relate to running test and building a
suitable U-Boot to run the tests on.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Convert this into an option, leaving the default as is

 test/py/README.md   | 13 -
 test/py/conftest.py | 30 +-
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/test/py/README.md b/test/py/README.md
index 3cbe01b73e..2e5025258d 100644
--- a/test/py/README.md
+++ b/test/py/README.md
@@ -138,6 +138,9 @@ command-line option; see the next section.
   before running the tests. If using this option, make sure that any
   environment variables required by the build process are already set, such as
   `$CROSS_COMPILE`.
+- `--buildman` indicates that `--build` should use buildman to build U-Boot.
+  There is no need to set $CROSS_COMPILE` in this case since buildman handles
+  it.
 - `--build-dir` sets the directory containing the compiled U-Boot binaries.
   If omitted, this is `${source_dir}/build-${board_type}`.
 - `--result-dir` sets the directory to write results, such as log files,
@@ -333,7 +336,7 @@ PATH=$HOME/ubtest/bin:$PATH \
 
 If you want the test script to compile U-Boot for you too, then you likely
 need to set `$CROSS_COMPILE` to allow this, and invoke the test script as
-follow:
+follows:
 
 ```bash
 CROSS_COMPILE=arm-none-eabi- \
@@ -342,6 +345,14 @@ CROSS_COMPILE=arm-none-eabi- \
 ./test/py/test.py --bd seaboard --build
 ```
 
+or, using buildman to handle it:
+
+```bash
+PATH=$HOME/ubtest/bin:$PATH \
+PYTHONPATH=${HOME}/ubtest/py/${HOSTNAME}:${PYTHONPATH} \
+./test/py/test.py --bd seaboard --build --buildman
+```
+
 ## Writing tests
 
 Please refer to the pytest documentation for details of writing pytest tests.
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 34ac4fb062..e3392ff6bc 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -70,6 +70,8 @@ def pytest_addoption(parser):
 help='U-Boot board identity/instance')
 parser.addoption('--build', default=False, action='store_true',
 help='Compile U-Boot before running tests')
+parser.addoption('--buildman', default=False, action='store_true',
+help='Use buildman to build U-Boot (assuming --build is given)')
 parser.addoption('--gdbserver', default=None,
 help='Run sandbox under gdbserver. The argument is the channel '+
 'over which gdbserver should communicate, e.g. localhost:1234')
@@ -140,16 +142,26 @@ def pytest_configure(config):
 log = multiplexed_log.Logfile(result_dir + '/test-log.html')
 
 if config.getoption('build'):
-if build_dir != source_dir:
-o_opt = 'O=%s' % build_dir
+if config.getoption('buildman'):
+if build_dir != source_dir:
+dest_args = ['-o', build_dir, '-w']
+else:
+dest_args = ['-i']
+cmds = (['buildman', '--board', board_type] + dest_args,)
+name = 'buildman'
 else:
-o_opt = ''
-cmds = (
-['make', o_opt, '-s', board_type + '_defconfig'],
-['make', o_opt, '-s', '-j8'],
-)
-with log.section('make'):
-runner = log.get_runner('make', sys.stdout)
+if build_dir != source_dir:
+o_opt = 'O=%s' % build_dir
+else:
+o_opt = ''
+cmds = (
+['make', o_opt, '-s', board_type + '_defconfig'],
+['make', o_opt, '-s', '-j8'],
+)
+name = 'make'
+
+with log.section(name):
+runner = log.get_runner(name, sys.stdout)
 for cmd in cmds:
 runner.run(cmd, cwd=source_dir)
 runner.close()
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 21/23] travis/gitlab/azure: Simplify the exit code for test.py

2020-03-18 Thread Simon Glass
It seems unnecessary to read the exit code and then check it again. Drop
this and just let the test.py provide the exit code directly.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update travis, azure also

 .azure-pipelines.yml | 4 
 .gitlab-ci.yml   | 6 +-
 .travis.yml  | 6 +-
 3 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 612e645d0a..28a6583319 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -259,10 +259,6 @@ jobs:
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
   # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if 
not
   ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} 
${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"} --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
-  ret=$?;
-  if [[ $ret -ne 0 ]]; then
-  exit $ret;
-  fi
   # the below corresponds to .gitlab-ci.yml "after_script"
   rm -rf /tmp/uboot-test-hooks /tmp/venv
   EOF
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 065ac769f9..64d8b1bdfc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,11 +45,7 @@ stages:
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
   ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
 ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
---build-dir "$UBOOT_TRAVIS_BUILD_DIR";
-  ret=$?;
-  if [[ $ret -ne 0 ]]; then
-exit $ret;
-  fi
+--build-dir "$UBOOT_TRAVIS_BUILD_DIR"
 
 build all 32bit ARM platforms:
   tags: [ 'all' ]
diff --git a/.travis.yml b/.travis.yml
index 5be4c54403..757e425467 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -147,11 +147,7 @@ script:
  pip install -r test/py/requirements.txt;
  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
-   --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
- ret=$?;
- if [[ $ret -ne 0 ]]; then
-   exit $ret;
- fi;
+   --build-dir "$UBOOT_TRAVIS_BUILD_DIR" || exit;
  if [[ -n "${TEST_PY_TOOLS}" ]]; then
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 19/23] travis/gitlab/azure: Use -W to avoid warnings check

2020-03-18 Thread Simon Glass
We can use the -W flag to tell buildman to ignore warnings. Since we also
have -E defined, compiler warnings are promoted to errors, so they will
still cause a failure. But migration warnings of the form:

= WARNING ==
This board does not use CONFIG_DM. CONFIG_DM will be
compulsory starting with the v2020.01 release.
Failure to update may result in board removal.
See doc/driver-model/migration.rst for more info.

will now be ignored.

Signed-off-by: Simon Glass 
Fixes: 329f5ef51d2 (travis.yml: run buildman with option -E)
---

Changes in v3:
- Bring back the -E flag and add -W
- Rewrite the commit message

Changes in v2:
- Add Fixes tag
- Just drop the -E flag
- Update travis, azure also

 .azure-pipelines.yml |  8 
 .gitlab-ci.yml   | 23 +++
 .travis.yml  | 13 ++---
 3 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 50d00fa899..a97a3f8b19 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -247,8 +247,8 @@ jobs:
   cd ${WORK_DIR}
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD};
   ret=0;
-  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E --board 
${TEST_PY_BD} ${OVERRIDE} || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W 
--board ${TEST_PY_BD} ${OVERRIDE} || ret=$?;
+  if [[ $ret -ne 0 ]]; then
   tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se 
--board ${TEST_PY_BD};
   exit $ret;
   fi
@@ -396,8 +396,8 @@ jobs:
   cat << "EOF" >> build.sh
   if [[ "${BUILDMAN}" != "" ]]; then
   ret=0;
-  tools/buildman/buildman -o /tmp -P -E ${BUILDMAN} ${OVERRIDE} || 
ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  tools/buildman/buildman -o /tmp -P -W ${BUILDMAN} ${OVERRIDE} || 
ret=$?;
+  if [[ $ret -ne 0 ]]; then
   tools/buildman/buildman -o /tmp -seP ${BUILDMAN};
   exit $ret;
   fi;
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 48b90b2ba3..501e3ff3ab 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,13 +27,12 @@ stages:
   after_script:
 - rm -rf /tmp/uboot-test-hooks /tmp/venv
   script:
-# From buildman, exit code 129 means warnings only.  If we've been asked to
-# use clang only do one configuration.
+# If we've been asked to use clang only do one configuration.
 - export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD}
 - ret=0;
-  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W
 --board ${TEST_PY_BD} ${OVERRIDE} || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  if [[ $ret -ne 0 ]]; then
 tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se
--board ${TEST_PY_BD};
 exit $ret;
@@ -57,8 +56,8 @@ build all 32bit ARM platforms:
   stage: world build
   script:
 - ret=0;
-  ./tools/buildman/buildman -o /tmp -P -E arm -x aarch64 || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  ./tools/buildman/buildman -o /tmp -P -E -W arm -x aarch64 || ret=$?;
+  if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
@@ -71,8 +70,8 @@ build all 64bit ARM platforms:
 - . /tmp/venv/bin/activate
 - pip install pyelftools
 - ret=0;
-  ./tools/buildman/buildman -o /tmp -P -E aarch64 || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  ./tools/buildman/buildman -o /tmp -P -E -W aarch64 || ret=$?;
+  if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
@@ -82,8 +81,8 @@ build all PowerPC platforms:
   stage: world build
   script:
 - ret=0;
-  ./tools/buildman/buildman -o /tmp -P -E powerpc || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  ./tools/buildman/buildman -o /tmp -P -E -W powerpc || ret=$?;
+  if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
@@ -93,8 +92,8 @@ build all other platforms:
   stage: world build
   script:
 - ret=0;
-  ./tools/buildman/buildman -o /tmp -P -E -x arm,powerpc || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  ./tools/buildman/buildman -o /tmp -P -E -W -x arm,powerpc || ret=$?;
+  if [[ $ret -ne 0 ]]; then
 ./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
diff --git a/.travis.yml b/.travis.yml
index 887654ca96..bf3ef4860b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -116,13 +116,12 @@ script:
  # Comments must be outside the command strings below, or the Travis parser
  # will get confused.
  #
- # From buildman, exit code 129 means warni

[PATCH v3 20/23] travis/gitlab/azure: Enable test_handoff

2020-03-18 Thread Simon Glass
Ensure that this SPL test runs on gitlab.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update travis, azure also

 .azure-pipelines.yml | 2 +-
 .gitlab-ci.yml   | 2 +-
 .travis.yml  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index a97a3f8b19..612e645d0a 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -163,7 +163,7 @@ jobs:
   OVERRIDE: "-O clang-7"
 sandbox_spl:
   TEST_PY_BD: "sandbox_spl"
-  TEST_PY_TEST_SPEC: "test_ofplatdata"
+  TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff"
 sandbox_flattree:
   TEST_PY_BD: "sandbox_flattree"
 evb_ast2500:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 501e3ff3ab..065ac769f9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -188,7 +188,7 @@ sandbox_spl test.py:
   tags: [ 'all' ]
   variables:
 TEST_PY_BD: "sandbox_spl"
-TEST_PY_TEST_SPEC: "test_ofplatdata"
+TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff"
   <<: *buildman_and_testpy_dfn
 
 evb-ast2500 test.py:
diff --git a/.travis.yml b/.travis.yml
index bf3ef4860b..5be4c54403 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -404,7 +404,7 @@ matrix:
 - name: "test/py sandbox_spl"
   env:
 - TEST_PY_BD="sandbox_spl"
-  TEST_PY_TEST_SPEC="test_ofplatdata"
+  TEST_PY_TEST_SPEC="test_ofplatdata or test_handoff"
   TOOLCHAIN="i386"
   TEST_PY_TOOLS="yes"
 - name: "test/py sandbox_flattree"
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 22/23] travis/gitlab/azure: Drop repeated buildman call with test.py

2020-03-18 Thread Simon Glass
It does not seem to be necessary to run buildman again to show errors,
since any errors can be shown by the first invocation and there is only
a single board being built. Update this to simplify the code, using the
-e flag to make sure errors are shown.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Add new patch to drop the repeated buildman call

 .azure-pipelines.yml | 10 +++---
 .gitlab-ci.yml   | 10 ++
 .travis.yml  | 10 ++
 3 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 28a6583319..27bc249629 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -246,13 +246,9 @@ jobs:
   # the below corresponds to .gitlab-ci.yml "script"
   cd ${WORK_DIR}
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD};
-  ret=0;
-  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W 
--board ${TEST_PY_BD} ${OVERRIDE} || ret=$?;
-  if [[ $ret -ne 0 ]]; then
-  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se 
--board ${TEST_PY_BD};
-  exit $ret;
-  fi
-  virtualenv -p /usr/bin/python3 /tmp/venv
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e 
--board ${TEST_PY_BD} ${OVERRIDE}
+
+virtualenv -p /usr/bin/python3 /tmp/venv
   . /tmp/venv/bin/activate
   pip install -r test/py/requirements.txt
   export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 64d8b1bdfc..d171641576 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,14 +29,8 @@ stages:
   script:
 # If we've been asked to use clang only do one configuration.
 - export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD}
-- ret=0;
-  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W
---board ${TEST_PY_BD} ${OVERRIDE} || ret=$?;
-  if [[ $ret -ne 0 ]]; then
-tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se
-   --board ${TEST_PY_BD};
-exit $ret;
-  fi
+- tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
+--board ${TEST_PY_BD} ${OVERRIDE}
 - virtualenv -p /usr/bin/python3 /tmp/venv
 - . /tmp/venv/bin/activate
 - pip install -r test/py/requirements.txt
diff --git a/.travis.yml b/.travis.yml
index 757e425467..37fd8e483a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -134,14 +134,8 @@ script:
  cp ~/grub_x64.efi $UBOOT_TRAVIS_BUILD_DIR/;
  cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi 
$UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi;
  cp ~/grub2-arm64/usr/lib/grub2/arm64-efi/grub.efi 
$UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi;
- ret=0;
- tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W
-   --board ${TEST_PY_BD} ${OVERRIDE}|| ret=$?;
- if [[ $ret -ne 0 ]]; then
-   tools/buildman/buildman -se -o ${UBOOT_TRAVIS_BUILD_DIR} -w
- --board ${TEST_PY_BD};
-   exit $ret;
- fi;
+ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
+   --board ${TEST_PY_BD} ${OVERRIDE} || exit;
  virtualenv -p /usr/bin/python3 /tmp/venv;
  . /tmp/venv/bin/activate;
  pip install -r test/py/requirements.txt;
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 18/23] travis/gitlab/azure: Use bash to avoid a_test_which_does_not_exist

2020-03-18 Thread Simon Glass
Bash allows for variables to expand only if non-empty:

$ var=test
$ echo ${var:+"$var"}
test
$ echo ${var:+"-k $var"}
-k test
$ var=
$ echo ${var:+"-k $var"}

Use this feature to avoid the workaround.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Add a comment about the obscure bash feature
- Update travis, azure also

 .azure-pipelines.yml | 3 ++-
 .gitlab-ci.yml   | 7 ++-
 .travis.yml  | 7 ++-
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index b7222db97f..50d00fa899 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -257,7 +257,8 @@ jobs:
   pip install -r test/py/requirements.txt
   export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
-  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} -k 
"${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}" --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
+  # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if 
not
+  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} 
${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"} --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
   ret=$?;
   if [[ $ret -ne 0 ]]; then
   exit $ret;
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 38f2cba69f..48b90b2ba3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -38,17 +38,14 @@ stages:
--board ${TEST_PY_BD};
 exit $ret;
   fi
-# "not a_test_which_does_not_exist" is a dummy -k parameter which will
-# never prevent any test from running. That way, we can always pass
-# "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
-# value.
 - virtualenv -p /usr/bin/python3 /tmp/venv
 - . /tmp/venv/bin/activate
 - pip install -r test/py/requirements.txt
+# "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not
 - export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
   ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
--k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
+${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
 --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
   ret=$?;
   if [[ $ret -ne 0 ]]; then
diff --git a/.travis.yml b/.travis.yml
index d7c16326ff..887654ca96 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -127,11 +127,8 @@ script:
exit $ret;
  fi;
fi
- # "not a_test_which_does_not_exist" is a dummy -k parameter which will
- # never prevent any test from running. That way, we can always pass
- # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
- # value.
  # Build just the one board needed for testing, if TEST_PY_BD is non-empty
+ # Note: "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not
  - if [[ "${TEST_PY_BD}" != "" ]]; then
  export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/${TEST_PY_BD};
  cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/;
@@ -150,7 +147,7 @@ script:
  . /tmp/venv/bin/activate;
  pip install -r test/py/requirements.txt;
  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
-   -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
+   ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
--build-dir "$UBOOT_TRAVIS_BUILD_DIR";
  ret=$?;
  if [[ $ret -ne 0 ]]; then
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 14/23] travis/gitlab/azure: Drop BUILDMAN variable with test.py

2020-03-18 Thread Simon Glass
This is not needed in the test.py part of the config, now since we use the
same name as the pytests.

Drop BUILDMAN, retaining it only for the 'build' parts of the config, i.e.
where we build multiple boards and don't run any tests.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update travis, azure also

 .azure-pipelines.yml | 28 +++-
 .gitlab-ci.yml   | 27 +++
 .travis.yml  | 27 +++
 3 files changed, 9 insertions(+), 73 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 8092545642..3d5b12ba3e 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -158,90 +158,69 @@ jobs:
   matrix:
 sandbox:
   TEST_PY_BD: "sandbox"
-  BUILDMAN: "sandbox"
 sandbox_clang:
   TEST_PY_BD: "sandbox"
-  BUILDMAN: "sandbox"
   OVERRIDE: "-O clang-7"
 sandbox_spl:
   TEST_PY_BD: "sandbox_spl"
   TEST_PY_TEST_SPEC: "test_ofplatdata"
-  BUILDMAN: "sandbox_spl"
 sandbox_flattree:
   TEST_PY_BD: "sandbox_flattree"
-  BUILDMAN: "sandbox_flattree"
 evb_ast2500:
   TEST_PY_BD: "evb-ast2500"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "evb-ast2500"
 vexpress_ca15_tc2:
   TEST_PY_BD: "vexpress_ca15_tc2"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "vexpress_ca15_tc2"
 vexpress_ca9x4:
   TEST_PY_BD: "vexpress_ca9x4"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "vexpress_ca9x4"
 integratorcp_cm926ejs:
   TEST_PY_BD: "integratorcp_cm926ejs"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "integratorcp_cm926ejs"
 qemu_arm:
   TEST_PY_BD: "qemu_arm"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_arm"
 qemu_arm64:
   TEST_PY_BD: "qemu_arm64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_arm64"
 qemu_mips:
   TEST_PY_BD: "qemu_mips"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_mips"
 qemu_mipsel:
   TEST_PY_BD: "qemu_mipsel"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_mipsel"
 qemu_mips64:
   TEST_PY_BD: "qemu_mips64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_mips64"
 qemu_mips64el:
   TEST_PY_BD: "qemu_mips64el"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu_mips64el"
 qemu_ppce500:
   TEST_PY_BD: "qemu-ppce500"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu-ppce500"
 qemu_riscv64:
   TEST_PY_BD: "qemu-riscv64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu-riscv64"
 qemu_x86:
   TEST_PY_BD: "qemu-x86"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu-x86"
 qemu_x86_64:
   TEST_PY_BD: "qemu-x86_64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "qemu-x86_64"
 zynq_zc702:
   TEST_PY_BD: "zynq_zc702"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "zynq_zc702"
 xilinx_versal_virt:
   TEST_PY_BD: "xilinx_versal_virt"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "xilinx_versal_virt"
 xtfpga:
   TEST_PY_BD: "xtfpga"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "xtfpga"
 steps:
   - script: |
   cat << EOF > test.sh
@@ -251,7 +230,6 @@ jobs:
   export TEST_PY_BD="${TEST_PY_BD}"
   export TEST_PY_ID="${TEST_PY_ID}"
   export TEST_PY_TEST_SPEC="${TEST_PY_TEST_SPEC}"
-  export BUILDMAN="${BUILDMAN}"
   export OVERRIDE="${OVERRIDE}"
   EOF
   cat << "EOF" >> test.sh
@@ -267,11 +245,11 @@ jobs:
   cp /opt/grub/grubarm.efi ~/grub_arm.efi
   # the below corresponds to .gitlab-ci.yml "script"
   cd ${WORK_DIR}
-  if [[ "${BUILDMAN}" != "" ]]; then
+  if [[ "${TEST_PY_BD}" != "" ]]; then
   ret=0;
-  tools/buildman/buildman -o /tmp -P -E --board ${BUILDMAN} 
${OVERRIDE} || ret=$?;
+  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} 
${OVERRIDE} || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -sdeP --board ${BUILDMAN};
+  tools/buildman/buildman -o /tmp -sdeP --board ${TEST_PY_BD};
   exit $ret;
   fi;
   fi
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3f48cad752..2cd6209222 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,12 +29,12 @@ stages:
   script:
 # From buildman, exit code 129 mean

[PATCH v3 17/23] gitlab/azure: Use -w flag for all test.py builds

2020-03-18 Thread Simon Glass
Avoid needing to know about the internal .bm-work directory, by passing
the -w flag to buildman.

This is not needed on travis since the -w flag is already used (from a
previous patch).

Drop the -P flag since this has no effect if -w is used.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Leave in the repeated call to buildman
- Update azure also

 .azure-pipelines.yml |  6 +++---
 .gitlab-ci.yml   | 11 ++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 96f279853e..b7222db97f 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -245,16 +245,16 @@ jobs:
   cp /opt/grub/grubarm.efi ~/grub_arm.efi
   # the below corresponds to .gitlab-ci.yml "script"
   cd ${WORK_DIR}
+  export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD};
   ret=0;
-  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} 
${OVERRIDE} || ret=$?;
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E --board 
${TEST_PY_BD} ${OVERRIDE} || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se 
--board ${TEST_PY_BD};
   exit $ret;
   fi
   virtualenv -p /usr/bin/python3 /tmp/venv
   . /tmp/venv/bin/activate
   pip install -r test/py/requirements.txt
-  export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/${TEST_PY_BD};
   export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
   ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} -k 
"${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}" --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b29d59d942..38f2cba69f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,11 +29,13 @@ stages:
   script:
 # From buildman, exit code 129 means warnings only.  If we've been asked to
 # use clang only do one configuration.
+- export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD}
 - ret=0;
-  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} ${OVERRIDE}
-|| ret=$?;
+  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E
+--board ${TEST_PY_BD} ${OVERRIDE} || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
+tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -se
+   --board ${TEST_PY_BD};
 exit $ret;
   fi
 # "not a_test_which_does_not_exist" is a dummy -k parameter which will
@@ -43,8 +45,7 @@ stages:
 - virtualenv -p /usr/bin/python3 /tmp/venv
 - . /tmp/venv/bin/activate
 - pip install -r test/py/requirements.txt
-- export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/${TEST_PY_BD};
-  export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
+- export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
   ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
 -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 16/23] gitlab/azure: Drop unnecessary if..fi when using test.py

2020-03-18 Thread Simon Glass
Since TEST_PY_BD is always defined we can drop this check.

This does not affect travis since it has a single, unified script.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update azure also

 .azure-pipelines.yml | 22 +-
 .gitlab-ci.yml   | 30 +-
 2 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 684359b88b..96f279853e 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -245,13 +245,11 @@ jobs:
   cp /opt/grub/grubarm.efi ~/grub_arm.efi
   # the below corresponds to .gitlab-ci.yml "script"
   cd ${WORK_DIR}
-  if [[ "${TEST_PY_BD}" != "" ]]; then
-  ret=0;
-  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} 
${OVERRIDE} || ret=$?;
-  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
-  exit $ret;
-  fi;
+  ret=0;
+  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} 
${OVERRIDE} || ret=$?;
+  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
+  exit $ret;
   fi
   virtualenv -p /usr/bin/python3 /tmp/venv
   . /tmp/venv/bin/activate
@@ -259,12 +257,10 @@ jobs:
   export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/${TEST_PY_BD};
   export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
-  if [[ "${TEST_PY_BD}" != "" ]]; then
-  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} -k 
"${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}" --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
-  ret=$?;
-  if [[ $ret -ne 0 ]]; then
-  exit $ret;
-  fi;
+  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} -k 
"${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}" --build-dir 
"$UBOOT_TRAVIS_BUILD_DIR";
+  ret=$?;
+  if [[ $ret -ne 0 ]]; then
+  exit $ret;
   fi
   # the below corresponds to .gitlab-ci.yml "after_script"
   rm -rf /tmp/uboot-test-hooks /tmp/venv
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 36c2ecfa43..b29d59d942 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -29,14 +29,12 @@ stages:
   script:
 # From buildman, exit code 129 means warnings only.  If we've been asked to
 # use clang only do one configuration.
-- if [[ "${TEST_PY_BD}" != "" ]]; then
-ret=0;
-tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} ${OVERRIDE}
-  || ret=$?;
-if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
-  exit $ret;
-fi;
+- ret=0;
+  tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} ${OVERRIDE}
+|| ret=$?;
+  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
+exit $ret;
   fi
 # "not a_test_which_does_not_exist" is a dummy -k parameter which will
 # never prevent any test from running. That way, we can always pass
@@ -48,15 +46,13 @@ stages:
 - export UBOOT_TRAVIS_BUILD_DIR=/tmp/.bm-work/${TEST_PY_BD};
   export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
   export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
-  if [[ "${TEST_PY_BD}" != "" ]]; then
-./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
-  -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
-  --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
-ret=$?;
-if [[ $ret -ne 0 ]]; then
-  exit $ret;
-fi;
-  fi;
+  ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID}
+-k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"
+--build-dir "$UBOOT_TRAVIS_BUILD_DIR";
+  ret=$?;
+  if [[ $ret -ne 0 ]]; then
+exit $ret;
+  fi
 
 build all 32bit ARM platforms:
   tags: [ 'all' ]
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 15/23] travis/gitlab/azure: Drop the buildman -d flag

2020-03-18 Thread Simon Glass
This has no effect since -S is not given also. Drop it.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update travis, azure also

 .azure-pipelines.yml |  4 ++--
 .gitlab-ci.yml   | 10 +-
 .travis.yml  |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 3d5b12ba3e..684359b88b 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -249,7 +249,7 @@ jobs:
   ret=0;
   tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} 
${OVERRIDE} || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -sdeP --board ${TEST_PY_BD};
+  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
   exit $ret;
   fi;
   fi
@@ -401,7 +401,7 @@ jobs:
   ret=0;
   tools/buildman/buildman -o /tmp -P -E ${BUILDMAN} ${OVERRIDE} || 
ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -sdeP ${BUILDMAN};
+  tools/buildman/buildman -o /tmp -seP ${BUILDMAN};
   exit $ret;
   fi;
   fi
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2cd6209222..36c2ecfa43 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -34,7 +34,7 @@ stages:
 tools/buildman/buildman -o /tmp -P -E --board ${TEST_PY_BD} ${OVERRIDE}
   || ret=$?;
 if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -sdeP --board ${TEST_PY_BD};
+  tools/buildman/buildman -o /tmp -seP --board ${TEST_PY_BD};
   exit $ret;
 fi;
   fi
@@ -65,7 +65,7 @@ build all 32bit ARM platforms:
 - ret=0;
   ./tools/buildman/buildman -o /tmp -P -E arm -x aarch64 || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-./tools/buildman/buildman -o /tmp -sdeP;
+./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
 
@@ -79,7 +79,7 @@ build all 64bit ARM platforms:
 - ret=0;
   ./tools/buildman/buildman -o /tmp -P -E aarch64 || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-./tools/buildman/buildman -o /tmp -sdeP;
+./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
 
@@ -90,7 +90,7 @@ build all PowerPC platforms:
 - ret=0;
   ./tools/buildman/buildman -o /tmp -P -E powerpc || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-./tools/buildman/buildman -o /tmp -sdeP;
+./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
 
@@ -101,7 +101,7 @@ build all other platforms:
 - ret=0;
   ./tools/buildman/buildman -o /tmp -P -E -x arm,powerpc || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-./tools/buildman/buildman -o /tmp -sdeP;
+./tools/buildman/buildman -o /tmp -seP;
 exit $ret;
   fi;
 
diff --git a/.travis.yml b/.travis.yml
index 42a3923565..d7c16326ff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -123,7 +123,7 @@ script:
  ret=0;
  tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-   tools/buildman/buildman -sdeP ${BUILDMAN};
+   tools/buildman/buildman -seP ${BUILDMAN};
exit $ret;
  fi;
fi
@@ -142,7 +142,7 @@ script:
  tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E
--board ${TEST_PY_BD} ${OVERRIDE}|| ret=$?;
  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-   tools/buildman/buildman -sde -o ${UBOOT_TRAVIS_BUILD_DIR} -w
+   tools/buildman/buildman -se -o ${UBOOT_TRAVIS_BUILD_DIR} -w
  --board ${TEST_PY_BD};
exit $ret;
  fi;
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 13/23] travis/gitlab/azure: Use --board buildman flag with test.py

2020-03-18 Thread Simon Glass
The current method of selecting the board to build with test.py is a bit
error-prone, e.g. with "^sandbox$" it actually builds 5 boards (all of
those in the sandbox architecture).

Use the (newish) --board flag instead, to get the same result.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Update travis, azure also

 .azure-pipelines.yml | 46 -
 .gitlab-ci.yml   | 47 +-
 .travis.yml  | 49 ++--
 3 files changed, 72 insertions(+), 70 deletions(-)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 182482a93a..8092545642 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -158,90 +158,90 @@ jobs:
   matrix:
 sandbox:
   TEST_PY_BD: "sandbox"
-  BUILDMAN: "^sandbox$"
+  BUILDMAN: "sandbox"
 sandbox_clang:
   TEST_PY_BD: "sandbox"
-  BUILDMAN: "^sandbox$"
+  BUILDMAN: "sandbox"
   OVERRIDE: "-O clang-7"
 sandbox_spl:
   TEST_PY_BD: "sandbox_spl"
   TEST_PY_TEST_SPEC: "test_ofplatdata"
-  BUILDMAN: "^sandbox_spl$"
+  BUILDMAN: "sandbox_spl"
 sandbox_flattree:
   TEST_PY_BD: "sandbox_flattree"
-  BUILDMAN: "^sandbox_flattree$"
+  BUILDMAN: "sandbox_flattree"
 evb_ast2500:
   TEST_PY_BD: "evb-ast2500"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "^evb-ast2500$"
+  BUILDMAN: "evb-ast2500"
 vexpress_ca15_tc2:
   TEST_PY_BD: "vexpress_ca15_tc2"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "^vexpress_ca15_tc2$"
+  BUILDMAN: "vexpress_ca15_tc2"
 vexpress_ca9x4:
   TEST_PY_BD: "vexpress_ca9x4"
   TEST_PY_ID: "--id qemu"
-  BUILDMAN: "^vexpress_ca9x4$"
+  BUILDMAN: "vexpress_ca9x4"
 integratorcp_cm926ejs:
   TEST_PY_BD: "integratorcp_cm926ejs"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^integratorcp_cm926ejs$"
+  BUILDMAN: "integratorcp_cm926ejs"
 qemu_arm:
   TEST_PY_BD: "qemu_arm"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_arm$"
+  BUILDMAN: "qemu_arm"
 qemu_arm64:
   TEST_PY_BD: "qemu_arm64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_arm64$"
+  BUILDMAN: "qemu_arm64"
 qemu_mips:
   TEST_PY_BD: "qemu_mips"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_mips$"
+  BUILDMAN: "qemu_mips"
 qemu_mipsel:
   TEST_PY_BD: "qemu_mipsel"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_mipsel$"
+  BUILDMAN: "qemu_mipsel"
 qemu_mips64:
   TEST_PY_BD: "qemu_mips64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_mips64$"
+  BUILDMAN: "qemu_mips64"
 qemu_mips64el:
   TEST_PY_BD: "qemu_mips64el"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu_mips64el$"
+  BUILDMAN: "qemu_mips64el"
 qemu_ppce500:
   TEST_PY_BD: "qemu-ppce500"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu-ppce500$"
+  BUILDMAN: "qemu-ppce500"
 qemu_riscv64:
   TEST_PY_BD: "qemu-riscv64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu-riscv64$"
+  BUILDMAN: "qemu-riscv64"
 qemu_x86:
   TEST_PY_BD: "qemu-x86"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu-x86$"
+  BUILDMAN: "qemu-x86"
 qemu_x86_64:
   TEST_PY_BD: "qemu-x86_64"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^qemu-x86_64$"
+  BUILDMAN: "qemu-x86_64"
 zynq_zc702:
   TEST_PY_BD: "zynq_zc702"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^zynq_zc702$"
+  BUILDMAN: "zynq_zc702"
 xilinx_versal_virt:
   TEST_PY_BD: "xilinx_versal_virt"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^xilinx_versal_virt$"
+  BUILDMAN: "xilinx_versal_virt"
 xtfpga:
   TEST_PY_BD: "xtfpga"
   TEST_PY_ID: "--id qemu"
   TEST_PY_TEST_SPEC: "not sleep"
-  BUILDMAN: "^xtfpga$"
+  BUILDMAN: "xtfpga"
 steps:
   - script: |
   cat << EOF > test.sh
@@ -269,9 +269,9 @@ jobs:
   cd ${WORK_DIR}
   if [[ "${BUILDMAN}" != "" ]]; then
   ret=0;
-  tools/buildman/buildman -o /tmp -P -E ${BUILDMAN} ${OVERRIDE} || 
ret=$?;
+  tools/buildman/buildman -o /tmp -P -E --board ${BUILDMAN} 
${OVERRIDE} || ret=$?;
   if [[ $ret -ne 0 && $ret -ne 129 ]]; then
-  tools/buildman/buildman -o /tmp -sdeP 

[PATCH v3 09/23] buildman: Drop the -a option

2020-03-18 Thread Simon Glass
There is no point in setting the ARCH environment variable since the
U-Boot build system no-longer uses it.

It seems safe to drop this feature since it was only recently added.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop mention of -a in the README also

Changes in v2:
- Add a new patch to drop the -a option

 tools/buildman/README |  4 ++--
 tools/buildman/cmdline.py |  2 --
 tools/buildman/control.py | 17 ++---
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/tools/buildman/README b/tools/buildman/README
index 116a0ee545..4cf0114157 100644
--- a/tools/buildman/README
+++ b/tools/buildman/README
@@ -1072,8 +1072,8 @@ Other options
 
 Buildman has various other command-line options. Try --help to see them.
 
-To find out what architecture or toolchain prefix buildman will use for a 
build,
-see the -a and -A options.
+To find out what toolchain prefix buildman will use for a build, use the -A
+option.
 
 To request that compiler warnings be promoted to errors, use -E. This passes 
the
 -Werror flag to the compiler. Note that the build can still produce warnings
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index f387aeb1cf..17ea015a95 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -13,8 +13,6 @@ def ParseArgs():
 args: command lin arguments
 """
 parser = OptionParser()
-parser.add_option('-a', '--print-arch', action='store_true',
-  help='Print the architecture for a board (ARCH=)')
 parser.add_option('-A', '--print-prefix', action='store_true',
   help='Print the tool-chain prefix for a board (CROSS_COMPILE=)')
 parser.add_option('-b', '--branch', type='string',
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 7d31863c63..5ddc598c95 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -85,16 +85,15 @@ def ShowActions(series, why_selected, boards_selected, 
builder, options,
 for warning in board_warnings:
 print(col.Color(col.YELLOW, warning))
 
-def ShowToolchainInfo(boards, toolchains, print_arch, print_prefix):
+def ShowToolchainPrefix(boards, toolchains):
 """Show information about a the tool chain used by one or more boards
 
-The function checks that all boards use the same toolchain.
+The function checks that all boards use the same toolchain, then prints
+the correct value for CROSS_COMPILE.
 
 Args:
 boards: Boards object containing selected boards
 toolchains: Toolchains object containing available toolchains
-print_arch: True to print ARCH value
-print_prefix: True to print CROSS_COMPILE value
 
 Return:
 None on success, string error message otherwise
@@ -107,10 +106,7 @@ def ShowToolchainInfo(boards, toolchains, print_arch, 
print_prefix):
 return 'Supplied boards must share one toolchain'
 return False
 tc = tc_set.pop()
-if print_arch:
-print(tc.GetEnvArgs(toolchain.VAR_ARCH))
-if print_prefix:
-print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
+print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
 return None
 
 def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
@@ -206,9 +202,8 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, boards=None,
 if not len(selected):
 sys.exit(col.Color(col.RED, 'No matching boards found'))
 
-if options.print_arch or options.print_prefix:
-err = ShowToolchainInfo(boards, toolchains, options.print_arch,
-options.print_prefix)
+if options.print_prefix:
+err = ShowToolchainInfo(boards, toolchains)
 if err:
 sys.exit(col.Color(col.RED, err))
 return 0
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 11/23] travis: Split the building into two parts

2020-03-18 Thread Simon Glass
Buildman is used in two ways:

- to build a selection of boards (with no testing)
- to build a single board (and run pytest)

The gitlab and azure scrips do this in separate places, but travis does
not. To aid the refactoring process and keep the following patches in sync
across all three environments, split the code out in travis as well.

Use the buildman -w option for the single board. It is easier to
understand since it specifies the output directory directly. Also it
avoids needing to look at the internal .bm-work directory.

This initially creates some duplicate code, but by the end of the series
we have two completely different build paths with different arguments.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Add a new patch to split travis building into two parts

 .travis.yml | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f6e3a5d3af..f3703085ba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -118,7 +118,8 @@ script:
  #
  # From buildman, exit code 129 means warnings only.  If we've been asked to
  # use clang only do one configuration.
- - if [[ "${BUILDMAN}" != "" ]]; then
+ # Build a selection of boards if TEST_PY_BD is empty
+ - if [[ "${BUILDMAN}" != "" ]] && [[ "${TEST_PY_BD}" == "" ]]; then
  ret=0;
  tools/buildman/buildman -P -E ${BUILDMAN} ${OVERRIDE}|| ret=$?;
  if [[ $ret -ne 0 && $ret -ne 129 ]]; then
@@ -130,12 +131,20 @@ script:
  # never prevent any test from running. That way, we can always pass
  # "-k something" even when $TEST_PY_TEST_SPEC doesnt need a custom
  # value.
+ # Build just the one board needed for testing, if TEST_PY_BD is non-empty
  - if [[ "${TEST_PY_BD}" != "" ]]; then
- export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD};
+ export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/${TEST_PY_BD};
  cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/;
  cp ~/grub_x64.efi $UBOOT_TRAVIS_BUILD_DIR/;
  cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi 
$UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi;
  cp ~/grub2-arm64/usr/lib/grub2/arm64-efi/grub.efi 
$UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi;
+ ret=0;
+ tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E ${BUILDMAN}
+   ${OVERRIDE}|| ret=$?;
+ if [[ $ret -ne 0 && $ret -ne 129 ]]; then
+   tools/buildman/buildman -sde -o ${UBOOT_TRAVIS_BUILD_DIR} -w 
${BUILDMAN};
+   exit $ret;
+ fi;
  virtualenv -p /usr/bin/python3 /tmp/venv;
  . /tmp/venv/bin/activate;
  pip install -r test/py/requirements.txt;
-- 
2.25.1.481.gfbce0eb801-goog



[PATCH v3 05/23] buildman: Update help for -d

2020-03-18 Thread Simon Glass
This help is a bit ambiguous. It only does anything if asked to show size
changes with -S. Update the help and the function comments.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Reword the commit message for clarity

 tools/buildman/builder.py | 6 +++---
 tools/buildman/cmdline.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 081c1d0901..a41d0b316e 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -337,7 +337,7 @@ class Builder:
 
 show_errors: True to show summarised error/warning info
 show_sizes: Show size deltas
-show_detail: Show detail for each board
+show_detail: Show size delta detail for each board if show_sizes
 show_bloat: Show detail for each function
 list_error_boards: Show the boards which caused each error/warning
 show_config: Show config deltas
@@ -1000,7 +1000,7 @@ class Builder:
 board.target
 board_dict: Dict containing boards for which we built this
 commit, keyed by board.target. The value is an Outcome object.
-show_detail: Show detail for each board
+show_detail: Show size delta detail for each board
 show_bloat: Show detail for each function
 """
 arch_list = {}
@@ -1117,7 +1117,7 @@ class Builder:
 environment: Dictionary keyed by environment variable, Each
  value is the value of environment variable.
 show_sizes: Show image size deltas
-show_detail: Show detail for each board
+show_detail: Show size delta detail for each board if show_sizes
 show_bloat: Show detail for each function
 show_config: Show config changes
 show_environment: Show environment changes
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index c7b4bf6b4a..74b410010d 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -31,7 +31,7 @@ def ParseArgs():
   help='Reconfigure for every commit (disable incremental build)')
 parser.add_option('-d', '--detail', dest='show_detail',
   action='store_true', default=False,
-  help='Show detailed information for each board in summary')
+  help='Show detailed size delta for each board in the -S summary')
 parser.add_option('-D', '--config-only', action='store_true', 
default=False,
   help="Don't build, just configure each commit")
 parser.add_option('-e', '--show_errors', action='store_true',
-- 
2.25.1.481.gfbce0eb801-goog



  1   2   3   >