[U-Boot] [PATCH v1 7/8] armv8: ls1046a: add eSDHC node

2018-07-17 Thread Yinbo Zhu
This patch is to add eSDHC node for ls1046a.

Signed-off-by: Yinbo Zhu 
---
 arch/arm/dts/fsl-ls1046a.dtsi |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/fsl-ls1046a.dtsi b/arch/arm/dts/fsl-ls1046a.dtsi
index 4acbaf7..7687d12 100644
--- a/arch/arm/dts/fsl-ls1046a.dtsi
+++ b/arch/arm/dts/fsl-ls1046a.dtsi
@@ -70,6 +70,14 @@
status = "disabled";
};
 
+   esdhc: esdhc@156 {
+   compatible = "fsl,esdhc";
+   reg = <0x0 0x156 0x0 0x1>;
+   interrupts = <0 62 0x4>;
+   big-endian;
+   bus-width = <4>;
+   };
+
ifc: ifc@153 {
compatible = "fsl,ifc", "simple-bus";
reg = <0x0 0x153 0x0 0x1>;
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1 8/8] armv7: ls1021a: enable esdhc

2018-07-17 Thread Yinbo Zhu
This patch is to enable eSDHC for ls1021a.

Signed-off-by: Yinbo Zhu 
---
 arch/arm/dts/ls1021a.dtsi |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/arm/dts/ls1021a.dtsi b/arch/arm/dts/ls1021a.dtsi
index 5b3fc6a..59c97d5 100644
--- a/arch/arm/dts/ls1021a.dtsi
+++ b/arch/arm/dts/ls1021a.dtsi
@@ -96,7 +96,6 @@
sdhci,auto-cmd12;
big-endian;
bus-width = <4>;
-   status = "disabled";
};
 
scfg: scfg@157 {
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1 6/8] armv8: ls1043a: add eSDHC node

2018-07-17 Thread Yinbo Zhu
This patch is to add eSDHC node for ls1043a.

Signed-off-by: Yinbo Zhu 
---
 arch/arm/dts/fsl-ls1043a.dtsi |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/fsl-ls1043a.dtsi b/arch/arm/dts/fsl-ls1043a.dtsi
index ff40122..a804f51 100644
--- a/arch/arm/dts/fsl-ls1043a.dtsi
+++ b/arch/arm/dts/fsl-ls1043a.dtsi
@@ -70,6 +70,14 @@
status = "disabled";
};
 
+   esdhc: esdhc@156 {
+   compatible = "fsl,esdhc";
+   reg = <0x0 0x156 0x0 0x1>;
+   interrupts = <0 62 0x4>;
+   big-endian;
+   bus-width = <4>;
+   };
+
ifc: ifc@153 {
compatible = "fsl,ifc", "simple-bus";
reg = <0x0 0x153 0x0 0x1>;
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v1 5/8] armv8: ls1088a: add eSDHC node

2018-07-17 Thread Yinbo Zhu
This patch is to add eSDHC node for ls1088a.

Signed-off-by: Yinbo Zhu 
---
 arch/arm/dts/fsl-ls1088a.dtsi |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/fsl-ls1088a.dtsi b/arch/arm/dts/fsl-ls1088a.dtsi
index 077caf3..72d755a 100644
--- a/arch/arm/dts/fsl-ls1088a.dtsi
+++ b/arch/arm/dts/fsl-ls1088a.dtsi
@@ -74,6 +74,15 @@
reg-names = "QuadSPI", "QuadSPI-memory";
num-cs = <4>;
};
+
+   esdhc: esdhc@214 {
+   compatible = "fsl,esdhc";
+   reg = <0x0 0x214 0x0 0x1>;
+   interrupts = <0 28 0x4>; /* Level high type */
+   little-endian;
+   bus-width = <4>;
+   };
+
ifc: ifc@153 {
compatible = "fsl,ifc", "simple-bus";
reg = <0x0 0x224 0x0 0x2>;
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 3/8] Enable CONFIG_BLK and CONFIG_DM_MMC to Kconfig

2018-07-17 Thread Yinbo Zhu
This enables the folowing to Kconfig:
CONFIG_BLK
CONFIG_DM_MMC

Signed-off-by: Yinbo Zhu 
---
Change in v3:
Changed this patch's order  

 configs/ls1021atwr_nor_SECURE_BOOT_defconfig   |2 ++
 configs/ls1021atwr_nor_defconfig   |2 ++
 configs/ls1021atwr_nor_lpuart_defconfig|2 ++
 configs/ls1021atwr_qspi_defconfig  |2 ++
 .../ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig|2 ++
 configs/ls1021atwr_sdcard_ifc_defconfig|2 ++
 configs/ls1021atwr_sdcard_qspi_defconfig   |2 ++
 configs/ls1043aqds_defconfig   |2 ++
 configs/ls1043aqds_lpuart_defconfig|2 ++
 configs/ls1043aqds_nand_defconfig  |2 ++
 configs/ls1043aqds_nor_ddr3_defconfig  |2 ++
 configs/ls1043aqds_qspi_defconfig  |2 ++
 configs/ls1043aqds_sdcard_ifc_defconfig|2 ++
 configs/ls1043aqds_sdcard_qspi_defconfig   |2 ++
 configs/ls1043ardb_SECURE_BOOT_defconfig   |2 ++
 configs/ls1043ardb_defconfig   |2 ++
 configs/ls1043ardb_nand_SECURE_BOOT_defconfig  |2 ++
 configs/ls1043ardb_nand_defconfig  |2 ++
 configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig|2 ++
 configs/ls1043ardb_sdcard_defconfig|2 ++
 configs/ls1046aqds_SECURE_BOOT_defconfig   |2 ++
 configs/ls1046aqds_defconfig   |2 ++
 configs/ls1046aqds_lpuart_defconfig|2 ++
 configs/ls1046aqds_nand_defconfig  |2 ++
 configs/ls1046aqds_qspi_defconfig  |2 ++
 configs/ls1046aqds_sdcard_ifc_defconfig|2 ++
 configs/ls1046aqds_sdcard_qspi_defconfig   |2 ++
 configs/ls1046ardb_emmc_defconfig  |2 ++
 configs/ls1046ardb_qspi_SECURE_BOOT_defconfig  |2 ++
 configs/ls1046ardb_qspi_defconfig  |2 ++
 configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig|2 ++
 configs/ls1046ardb_sdcard_defconfig|2 ++
 configs/ls1088aqds_defconfig   |2 ++
 configs/ls1088aqds_qspi_SECURE_BOOT_defconfig  |2 ++
 configs/ls1088aqds_qspi_defconfig  |2 ++
 configs/ls1088aqds_sdcard_ifc_defconfig|2 ++
 configs/ls1088aqds_sdcard_qspi_defconfig   |2 ++
 configs/ls1088ardb_qspi_SECURE_BOOT_defconfig  |2 ++
 configs/ls1088ardb_qspi_defconfig  |2 ++
 .../ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig   |2 ++
 configs/ls1088ardb_sdcard_qspi_defconfig   |2 ++
 configs/ls2080a_emu_defconfig  |2 ++
 configs/ls2080a_simu_defconfig |2 ++
 configs/ls2080aqds_SECURE_BOOT_defconfig   |2 ++
 configs/ls2080aqds_defconfig   |2 ++
 configs/ls2080aqds_nand_defconfig  |2 ++
 configs/ls2080aqds_qspi_defconfig  |2 ++
 configs/ls2080aqds_sdcard_defconfig|2 ++
 configs/ls2080ardb_SECURE_BOOT_defconfig   |2 ++
 configs/ls2080ardb_defconfig   |2 ++
 configs/ls2080ardb_nand_defconfig  |2 ++
 configs/ls2088ardb_qspi_SECURE_BOOT_defconfig  |2 ++
 configs/ls2088ardb_qspi_defconfig  |2 ++
 53 files changed, 106 insertions(+), 0 deletions(-)

diff --git a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig 
b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
index 17a202d..4d85983 100644
--- a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
@@ -48,3 +48,5 @@ CONFIG_VIDEO=y
 # CONFIG_VIDEO_SW_CURSOR is not set
 CONFIG_RSA=y
 CONFIG_SPL_RSA=y
+CONFIG_BLK=y
+CONFIG_DM_MMC=y
diff --git a/configs/ls1021atwr_nor_defconfig b/configs/ls1021atwr_nor_defconfig
index a18426e..f4f7998 100644
--- a/configs/ls1021atwr_nor_defconfig
+++ b/configs/ls1021atwr_nor_defconfig
@@ -48,3 +48,5 @@ CONFIG_USB_STORAGE=y
 CONFIG_VIDEO_FSL_DCU_FB=y
 CONFIG_VIDEO=y
 # CONFIG_VIDEO_SW_CURSOR is not set
+CONFIG_BLK=y
+CONFIG_DM_MMC=y
diff --git a/configs/ls1021atwr_nor_lpuart_defconfig 
b/configs/ls1021atwr_nor_lpuart_defconfig
index 83ffa19..037f56c 100644
--- a/configs/ls1021atwr_nor_lpuart_defconfig
+++ b/configs/ls1021atwr_nor_lpuart_defconfig
@@ -49,3 +49,5 @@ CONFIG_USB_STORAGE=y
 CONFIG_VIDEO_FSL_DCU_FB=y
 CONFIG_VIDEO=y
 # CONFIG_VIDEO_SW_CURSOR is not set
+CONFIG_BLK=y
+CONFIG_DM_MMC=y
diff --git a/configs/ls1021atwr_qspi_defconfig 
b/configs/ls1021atwr_qspi_defconfig
index 46d8dbb..084bd27 100644
--- a/configs/ls1021atwr_qspi_defconfig
+++ b/configs/ls1021atwr_qspi_defconfig
@@ -55,3 +55,5 @@ CONFIG_USB_STORAGE=y
 CONFIG_VIDEO_FSL_DCU_FB=y
 CONFIG_VIDEO=y
 # CONFIG_VIDEO_SW_CURSOR is not set
+CONFIG_BLK=y
+CONFIG_DM_MMC=y
diff --git 

[U-Boot] [PATCH v1 4/8] armv8: ls2088a: add eSDHC node

2018-07-17 Thread Yinbo Zhu
This patch is to add eSDHC node for ls2088a.

Signed-off-by: Yinbo Zhu 
---
 arch/arm/dts/fsl-ls2080a.dtsi |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/fsl-ls2080a.dtsi b/arch/arm/dts/fsl-ls2080a.dtsi
index b0f8517..2d537ae 100644
--- a/arch/arm/dts/fsl-ls2080a.dtsi
+++ b/arch/arm/dts/fsl-ls2080a.dtsi
@@ -75,6 +75,14 @@
num-cs = <4>;
};
 
+   esdhc: esdhc@0 {
+   compatible = "fsl,esdhc";
+   reg = <0x0 0x214 0x0 0x1>;
+   interrupts = <0 28 0x4>; /* Level high type */
+   little-endian;
+   bus-width = <4>;
+   };
+
usb0: usb3@310 {
compatible = "fsl,layerscape-dwc3";
reg = <0x0 0x310 0x0 0x1>;
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/8] armv8/ls1088a/ls2088a: esdhc: Add esdhc clock support

2018-07-17 Thread Yinbo Zhu
This patch adds esdhc clock support for ls1088a and ls2088a.

Signed-off-by: Yinbo Zhu 
---
Change in v2:
Changed this patch's order

 .../arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
index 653c6dd..bc268e2 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch3_speed.c
@@ -192,6 +192,16 @@ int get_dspi_freq(ulong dummy)
return get_bus_freq(0) / CONFIG_SYS_FSL_DSPI_CLK_DIV;
 }
 
+#ifdef CONFIG_FSL_ESDHC
+int get_sdhc_freq(ulong dummy)
+{
+   if (!gd->arch.sdhc_clk)
+   get_clocks();
+
+   return gd->arch.sdhc_clk;
+}
+#endif
+
 int get_serial_clock(void)
 {
return get_bus_freq(0) / CONFIG_SYS_FSL_DUART_CLK_DIV;
@@ -202,6 +212,10 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
switch (clk) {
case MXC_I2C_CLK:
return get_i2c_freq(0);
+#if defined(CONFIG_FSL_ESDHC)
+   case MXC_ESDHC_CLK:
+   return get_sdhc_freq(0);
+#endif
case MXC_DSPI_CLK:
return get_dspi_freq(0);
default:
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/8] armv8: ls1088a: fix sd boot config compile issue

2018-07-17 Thread Yinbo Zhu
This patch is to fix sd boot config compile issue for ls1088a.

Signed-off-by: Yinbo Zhu 
---
Change in v2:
Changed this patch's order

 include/mmc.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/mmc.h b/include/mmc.h
index 534c317..66e69b7 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -604,7 +604,7 @@ struct mmc {
u64 enh_user_start;
u64 enh_user_size;
 #endif
-#if !CONFIG_IS_ENABLED(BLK)
+#if CONFIG_IS_ENABLED(BLK)
struct blk_desc block_dev;
 #endif
char op_cond_pending;   /* 1 if we are waiting on an op_cond command */
-- 
1.7.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 29/32] fsl_esdhc: Update usdhc driver to support i.MX8

2018-07-17 Thread Peng Fan
From: Ye Li 

Add CONFIG_ARCH_IMX8 to use the 64bits support in usdhc driver.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
Cc: Jaehoon Chung 
---
 drivers/mmc/fsl_esdhc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 4528345c67..785b9e87a6 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -257,7 +257,7 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, 
struct mmc *mmc,
int timeout;
struct fsl_esdhc *regs = priv->esdhc_regs;
 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_ARCH_IMX8) || defined(CONFIG_MX8M)
dma_addr_t addr;
 #endif
uint wml_value;
@@ -271,7 +271,7 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, 
struct mmc *mmc,
esdhc_clrsetbits32(>wml, WML_RD_WML_MASK, wml_value);
 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_ARCH_IMX8) || defined(CONFIG_MX8M)
addr = virt_to_phys((void *)(data->dest));
if (upper_32_bits(addr))
printf("Error found for upper 32 bits\n");
@@ -301,7 +301,7 @@ static int esdhc_setup_data(struct fsl_esdhc_priv *priv, 
struct mmc *mmc,
wml_value << 16);
 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_ARCH_IMX8) || defined(CONFIG_MX8M)
addr = virt_to_phys((void *)(data->src));
if (upper_32_bits(addr))
printf("Error found for upper 32 bits\n");
@@ -367,7 +367,7 @@ static void check_and_invalidate_dcache_range
unsigned size = roundup(ARCH_DMA_MINALIGN,
data->blocks*data->blocksize);
 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_ARCH_IMX8) || defined(CONFIG_MX8M)
dma_addr_t addr;
 
addr = virt_to_phys((void *)(data->dest));
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 23/32] pinctrl: Add pinctrl driver for i.MX8

2018-07-17 Thread Peng Fan
Add pinctrl driver for i.MX8. The pads configuration is controlled
by SCU, so need to ask SCU to configure pads through scfw API.
Add pinctrl-scu to invoke sc_pad_set to configue pads.
Add a new flag IMX8_USE_SCU to differentiate i.MX8 from other platforms
which could directly configure pads from Acore side.
Add CONFIG_PINCTRL_IMX8 as the built gate.

Signed-off-by: Peng Fan 
---
 drivers/pinctrl/nxp/Kconfig|  18 
 drivers/pinctrl/nxp/Makefile   |   2 +
 drivers/pinctrl/nxp/pinctrl-imx.c  | 209 -
 drivers/pinctrl/nxp/pinctrl-imx.h  |  16 +++
 drivers/pinctrl/nxp/pinctrl-imx8.c |  40 +++
 drivers/pinctrl/nxp/pinctrl-scu.c  |  66 
 6 files changed, 258 insertions(+), 93 deletions(-)
 create mode 100644 drivers/pinctrl/nxp/pinctrl-imx8.c
 create mode 100644 drivers/pinctrl/nxp/pinctrl-scu.c

diff --git a/drivers/pinctrl/nxp/Kconfig b/drivers/pinctrl/nxp/Kconfig
index b668359a0b..449ad47ebc 100644
--- a/drivers/pinctrl/nxp/Kconfig
+++ b/drivers/pinctrl/nxp/Kconfig
@@ -1,6 +1,9 @@
 config PINCTRL_IMX
bool
 
+config PINCTRL_IMX_SCU
+   bool
+
 config PINCTRL_IMX5
bool "IMX5 pinctrl driver"
depends on ARCH_MX5 && PINCTRL_FULL
@@ -56,3 +59,18 @@ config PINCTRL_IMX7ULP
  is different from the linux one, this is a simple implementation,
  only parses the 'fsl,pins' property and configure related
  registers.
+
+config PINCTRL_IMX8
+   bool "IMX8 pinctrl driver"
+   depends on ARCH_IMX8 && PINCTRL_FULL
+   select DEVRES
+   select PINCTRL_IMX
+   select PINCTRL_IMX_SCU
+   help
+ Say Y here to enable the imx8 pinctrl driver
+
+ This provides a simple pinctrl driver for i.MX8 SoC familiy.
+ This feature depends on device tree configuration. This driver
+ is different from the linux one, this is a simple implementation,
+ only parses the 'fsl,pins' property and configure related
+ registers.
diff --git a/drivers/pinctrl/nxp/Makefile b/drivers/pinctrl/nxp/Makefile
index c763948376..310b3b3a2e 100644
--- a/drivers/pinctrl/nxp/Makefile
+++ b/drivers/pinctrl/nxp/Makefile
@@ -3,3 +3,5 @@ obj-$(CONFIG_PINCTRL_IMX5)  += pinctrl-imx5.o
 obj-$(CONFIG_PINCTRL_IMX6) += pinctrl-imx6.o
 obj-$(CONFIG_PINCTRL_IMX7) += pinctrl-imx7.o
 obj-$(CONFIG_PINCTRL_IMX7ULP)  += pinctrl-imx7ulp.o
+obj-$(CONFIG_PINCTRL_IMX_SCU)  += pinctrl-scu.o
+obj-$(CONFIG_PINCTRL_IMX8) += pinctrl-imx8.o
diff --git a/drivers/pinctrl/nxp/pinctrl-imx.c 
b/drivers/pinctrl/nxp/pinctrl-imx.c
index 36e1e8983c..04ea82aba5 100644
--- a/drivers/pinctrl/nxp/pinctrl-imx.c
+++ b/drivers/pinctrl/nxp/pinctrl-imx.c
@@ -28,7 +28,9 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct 
udevice *config)
 
dev_dbg(dev, "%s: %s\n", __func__, config->name);
 
-   if (info->flags & SHARE_MUX_CONF_REG)
+   if (info->flags & IMX8_USE_SCU)
+   pin_size = SHARE_IMX8_PIN_SIZE;
+   else if (info->flags & SHARE_MUX_CONF_REG)
pin_size = SHARE_FSL_PIN_SIZE;
else
pin_size = FSL_PIN_SIZE;
@@ -58,112 +60,127 @@ static int imx_pinctrl_set_state(struct udevice *dev, 
struct udevice *config)
 
npins = size / pin_size;
 
-   /*
-* Refer to linux documentation for details:
-* Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt
-*/
-   for (i = 0; i < npins; i++) {
-   mux_reg = pin_data[j++];
-
-   if (!(info->flags & ZERO_OFFSET_VALID) && !mux_reg)
-   mux_reg = -1;
-
-   if (info->flags & SHARE_MUX_CONF_REG) {
-   conf_reg = mux_reg;
-   } else {
-   conf_reg = pin_data[j++];
-   if (!(info->flags & ZERO_OFFSET_VALID) && !conf_reg)
-   conf_reg = -1;
-   }
+   if (info->flags & IMX8_USE_SCU) {
+   imx_pinctrl_scu_conf_pins(info, pin_data, npins);
+   } else {
+   /*
+* Refer to linux documentation for details:
+* Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt
+*/
+   for (i = 0; i < npins; i++) {
+   mux_reg = pin_data[j++];
 
-   if ((mux_reg == -1) || (conf_reg == -1)) {
-   dev_err(dev, "Error mux_reg or conf_reg\n");
-   devm_kfree(dev, pin_data);
-   return -EINVAL;
-   }
+   if (!(info->flags & ZERO_OFFSET_VALID) && !mux_reg)
+   mux_reg = -1;
 
-   input_reg = pin_data[j++];
-   mux_mode = pin_data[j++];
-   input_val = pin_data[j++];
-   config_val = pin_data[j++];
+   if (info->flags & SHARE_MUX_CONF_REG) {
+ 

[U-Boot] [PATCH V2 26/32] serial_lpuart: Update lpuart driver to support i.MX8

2018-07-17 Thread Peng Fan
Add i.MX8 compatible string and cpu type support to lpuart driver,
to use little endian 32 bits configurations.

Also, accroding to RM, the Receive FIFO Enable (RXFE) field in LPUART
FIFO register is bit 3, so the definition should change to 0x08 not 0x40
for i.MX8, otherwise the Receive FIFO is not disabled.

Signed-off-by: Peng Fan 
Signed-off-by: Ye Li 
---
 drivers/serial/serial_lpuart.c | 15 ---
 include/fsl_lpuart.h   |  2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index 1212b72676..c14a8105c9 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -41,7 +41,11 @@
 #define CTRL_RE(1 << 18)
 
 #define FIFO_TXFE  0x80
+#ifdef CONFIG_ARCH_IMX8
+#define FIFO_RXFE  0x08
+#else
 #define FIFO_RXFE  0x40
+#endif
 
 #define WATER_TXWATER_OFF  1
 #define WATER_RXWATER_OFF  16
@@ -54,7 +58,8 @@ DECLARE_GLOBAL_DATA_PTR;
 enum lpuart_devtype {
DEV_VF610 = 1,
DEV_LS1021A,
-   DEV_MX7ULP
+   DEV_MX7ULP,
+   DEV_IMX8
 };
 
 struct lpuart_serial_platdata {
@@ -325,7 +330,7 @@ static int _lpuart32_serial_init(struct 
lpuart_serial_platdata *plat)
 
lpuart_write32(plat->flags, >match, 0);
 
-   if (plat->devtype == DEV_MX7ULP) {
+   if (plat->devtype == DEV_MX7ULP || plat->devtype == DEV_IMX8) {
_lpuart32_serial_setbrg_7ulp(plat, gd->baudrate);
} else {
/* provide data bits, parity, stop bit, etc */
@@ -342,7 +347,7 @@ static int lpuart_serial_setbrg(struct udevice *dev, int 
baudrate)
struct lpuart_serial_platdata *plat = dev->platdata;
 
if (is_lpuart32(dev)) {
-   if (plat->devtype == DEV_MX7ULP)
+   if (plat->devtype == DEV_MX7ULP || plat->devtype == DEV_IMX8)
_lpuart32_serial_setbrg_7ulp(plat, baudrate);
else
_lpuart32_serial_setbrg(plat, baudrate);
@@ -427,6 +432,8 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice 
*dev)
plat->devtype = DEV_MX7ULP;
else if (!fdt_node_check_compatible(blob, node, "fsl,vf610-lpuart"))
plat->devtype = DEV_VF610;
+   else if (!fdt_node_check_compatible(blob, node, "fsl,imx8qm-lpuart"))
+   plat->devtype = DEV_IMX8;
 
return 0;
 }
@@ -444,6 +451,8 @@ static const struct udevice_id lpuart_serial_ids[] = {
{ .compatible = "fsl,imx7ulp-lpuart",
.data = LPUART_FLAG_REGMAP_32BIT_REG },
{ .compatible = "fsl,vf610-lpuart"},
+   { .compatible = "fsl,imx8qm-lpuart",
+   .data = LPUART_FLAG_REGMAP_32BIT_REG },
{ }
 };
 
diff --git a/include/fsl_lpuart.h b/include/fsl_lpuart.h
index 02ebfefc74..fc517d4b7f 100644
--- a/include/fsl_lpuart.h
+++ b/include/fsl_lpuart.h
@@ -4,7 +4,7 @@
  *
  */
 
-#ifdef CONFIG_ARCH_MX7ULP
+#if defined(CONFIG_ARCH_MX7ULP) || defined(CONFIG_ARCH_IMX8)
 struct lpuart_fsl_reg32 {
u32 verid;
u32 param;
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 19/32] imx8: add arch_cpu_init arch_cpu_init_dm

2018-07-17 Thread Peng Fan
Add arch_cpu_init(_dm) mainly to open the channel between ACore and SCU.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/sys_proto.h |  9 ++
 arch/arm/mach-imx/imx8/cpu.c   | 51 ++
 2 files changed, 60 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8/sys_proto.h 
b/arch/arm/include/asm/arch-imx8/sys_proto.h
index f9a3016132..73ffaba7d5 100644
--- a/arch/arm/include/asm/arch-imx8/sys_proto.h
+++ b/arch/arm/include/asm/arch-imx8/sys_proto.h
@@ -6,5 +6,14 @@
 #include 
 #include 
 
+struct pass_over_info_t {
+   u16 barker;
+   u16 len;
+   u32 g_bt_cfg_shadow;
+   u32 card_address_mode;
+   u32 bad_block_count_met;
+   u32 g_ap_mu;
+};
+
 enum boot_device get_boot_device(void);
 int print_bootinfo(void);
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index 389f422be7..e461fcfcd6 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -95,6 +95,57 @@ int print_cpuinfo(void)
 }
 #endif
 
+#define BT_PASSOVER_TAG0x504F
+struct pass_over_info_t *get_pass_over_info(void)
+{
+   struct pass_over_info_t *p =
+   (struct pass_over_info_t *)PASS_OVER_INFO_ADDR;
+
+   if (p->barker != BT_PASSOVER_TAG ||
+   p->len != sizeof(struct pass_over_info_t))
+   return NULL;
+
+   return p;
+}
+
+int arch_cpu_init(void)
+{
+   struct pass_over_info_t *pass_over = get_pass_over_info();
+
+   if (pass_over && pass_over->g_ap_mu == 0) {
+   /*
+* When ap_mu is 0, means the u-boot is boot
+* from first container
+*/
+   sc_misc_boot_status(-1, SC_MISC_BOOT_STATUS_SUCCESS);
+   }
+
+   return 0;
+}
+
+int arch_cpu_init_dm(void)
+{
+   struct udevice *devp;
+   int node, ret;
+
+   node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,imx8-mu");
+   ret = device_bind_driver_to_node(gd->dm_root, "imx8_scu", "imx8_scu",
+offset_to_ofnode(node), );
+
+   if (ret) {
+   printf("could not find scu %d\n", ret);
+   return ret;
+   }
+
+   ret = device_probe(devp);
+   if (ret) {
+   printf("could not find scu %d\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+
 int print_bootinfo(void)
 {
enum boot_device bt_dev = get_boot_device();
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 31/32] arm: dts: introduce dtsi for i.MX8QXP

2018-07-17 Thread Peng Fan
Introduce dtsi for i.MX8QXP, since there is other variants i.MX8DX(P),
so add them there, because i.MX8QXP includes the dtsi of them.

Signed-off-by: Peng Fan 
---
 arch/arm/dts/fsl-imx8-ca35.dtsi |  66 ++
 arch/arm/dts/fsl-imx8dx.dtsi| 444 
 arch/arm/dts/fsl-imx8dxp.dtsi   |  11 +
 arch/arm/dts/fsl-imx8qxp.dtsi   |  51 +
 4 files changed, 572 insertions(+)
 create mode 100644 arch/arm/dts/fsl-imx8-ca35.dtsi
 create mode 100644 arch/arm/dts/fsl-imx8dx.dtsi
 create mode 100644 arch/arm/dts/fsl-imx8dxp.dtsi
 create mode 100644 arch/arm/dts/fsl-imx8qxp.dtsi

diff --git a/arch/arm/dts/fsl-imx8-ca35.dtsi b/arch/arm/dts/fsl-imx8-ca35.dtsi
new file mode 100644
index 00..28bc32c8b7
--- /dev/null
+++ b/arch/arm/dts/fsl-imx8-ca35.dtsi
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+
+/{
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   /* We have 1 clusters having 4 Cortex-A35 cores */
+   A35_0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a35";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   next-level-cache = <_L2>;
+   };
+
+   A35_1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a35";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   next-level-cache = <_L2>;
+   };
+
+   A35_2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a35";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   next-level-cache = <_L2>;
+   };
+
+   A35_3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a35";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   next-level-cache = <_L2>;
+   };
+
+   A35_L2: l2-cache0 {
+   compatible = "cache";
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = ;
+   interrupt-affinity = <_0>, <_1>, <_2>, <_3>;
+   };
+
+   psci {
+   compatible = "arm,psci-1.0";
+   method = "smc";
+   cpu_suspend   = <0xc401>;
+   cpu_off   = <0xc402>;
+   cpu_on= <0xc403>;
+   };
+};
diff --git a/arch/arm/dts/fsl-imx8dx.dtsi b/arch/arm/dts/fsl-imx8dx.dtsi
new file mode 100644
index 00..e84f7cf000
--- /dev/null
+++ b/arch/arm/dts/fsl-imx8dx.dtsi
@@ -0,0 +1,444 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include "fsl-imx8-ca35.dtsi"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   model = "Freescale i.MX8DX";
+   compatible = "fsl,imx8dx", "fsl,imx8qxp";
+   interrupt-parent = <>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   aliases {
+   serial0 = 
+   mmc0 = 
+   mmc1 = 
+   mmc2 = 
+   i2c0 = 
+   i2c1 = 
+   i2c2 = 
+   i2c3 = 
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x 0x8000 0 0x4000>;
+ /* DRAM space - 1, size : 1 GB DRAM */
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   /*
+* reserved-memory layout
+* 0x8800_ ~ 0x8FFF_ is reserved for M4
+* Shouldn't be used at A core and Linux side.
+*
+*/
+   decoder_boot: decoder_boot@0x8400 {
+   no-map;
+   reg = <0 0x8400 0 0x200>;
+   };
+   encoder_boot: encoder_boot@0x8600 {
+   no-map;
+   reg = <0 0x8600 0 0x200>;
+   };
+   rpmsg_reserved: rpmsg@0x9000 {
+   no-map;
+   reg = <0 0x9000 0 0x40>;
+   };
+   decoder_rpc: decoder_rpc@0x9040 {
+   no-map;
+   reg = <0 0x9040 0 0x100>;
+   };
+   encoder_rpc: encoder_rpc@0x9140 {
+   no-map;
+   reg = <0 0x9140 0 0x100>;
+   };
+   dsp_reserved: dsp@0x9240 {
+   no-map;
+ 

[U-Boot] [PATCH V2 28/32] serial: lpuart: support uclass clk api

2018-07-17 Thread Peng Fan
Modify most APIs to use udevice as the first param, then
it will be easy to get the clk reference by using udevice pointer.
Use uclass api to get lpuart clk when CONFIG_CLK enabled.

Signed-off-by: Peng Fan 
---
 drivers/serial/serial_lpuart.c | 78 --
 1 file changed, 59 insertions(+), 19 deletions(-)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index b28f7cf68d..3887c3d1c8 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -104,6 +105,27 @@ u32 __weak get_lpuart_clk(void)
return CONFIG_SYS_CLK_FREQ;
 }
 
+ulong get_lpuart_clk_rate(struct udevice *dev)
+{
+   struct clk per_clk;
+   ulong rate;
+   int ret;
+
+   ret = clk_get_by_name(dev, "per", _clk);
+   if (ret) {
+   dev_err(dev, "Failed to get per clk: %d\n", ret);
+   return ret;
+   }
+
+   rate = clk_get_rate(_clk);
+   if ((long)rate <= 0) {
+   dev_err(dev, "Failed to get per clk rate: %ld\n", (long)rate);
+   return ret;
+   }
+
+   return  rate;
+}
+
 static bool is_lpuart32(struct udevice *dev)
 {
struct lpuart_serial_platdata *plat = dev->platdata;
@@ -111,13 +133,19 @@ static bool is_lpuart32(struct udevice *dev)
return plat->flags & LPUART_FLAG_REGMAP_32BIT_REG;
 }
 
-static void _lpuart_serial_setbrg(struct lpuart_serial_platdata *plat,
+static void _lpuart_serial_setbrg(struct udevice *dev,
  int baudrate)
 {
+   struct lpuart_serial_platdata *plat = dev_get_platdata(dev);
struct lpuart_fsl *base = plat->reg;
-   u32 clk = get_lpuart_clk();
+   u32 clk;
u16 sbr;
 
+   if (IS_ENABLED(CONFIG_CLK))
+   clk = get_lpuart_clk_rate(dev);
+   else
+   clk = get_lpuart_clk();
+
sbr = (u16)(clk / (16 * baudrate));
 
/* place adjustment later - n/32 BRFA */
@@ -162,8 +190,9 @@ static int _lpuart_serial_tstc(struct 
lpuart_serial_platdata *plat)
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
  */
-static int _lpuart_serial_init(struct lpuart_serial_platdata *plat)
+static int _lpuart_serial_init(struct udevice *dev)
 {
+   struct lpuart_serial_platdata *plat = dev_get_platdata(dev);
struct lpuart_fsl *base = (struct lpuart_fsl *)plat->reg;
u8 ctrl;
 
@@ -182,19 +211,25 @@ static int _lpuart_serial_init(struct 
lpuart_serial_platdata *plat)
__raw_writeb(CFIFO_TXFLUSH | CFIFO_RXFLUSH, >ucfifo);
 
/* provide data bits, parity, stop bit, etc */
-   _lpuart_serial_setbrg(plat, gd->baudrate);
+   _lpuart_serial_setbrg(dev, gd->baudrate);
 
__raw_writeb(UC2_RE | UC2_TE, >uc2);
 
return 0;
 }
 
-static void _lpuart32_serial_setbrg_7ulp(struct lpuart_serial_platdata *plat,
+static void _lpuart32_serial_setbrg_7ulp(struct udevice *dev,
 int baudrate)
 {
+   struct lpuart_serial_platdata *plat = dev_get_platdata(dev);
struct lpuart_fsl_reg32 *base = plat->reg;
u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp;
-   u32 clk = get_lpuart_clk();
+   u32 clk;
+
+   if (IS_ENABLED(CONFIG_CLK))
+   clk = get_lpuart_clk_rate(dev);
+   else
+   clk = get_lpuart_clk();
 
baud_diff = baudrate;
osr = 0;
@@ -248,13 +283,19 @@ static void _lpuart32_serial_setbrg_7ulp(struct 
lpuart_serial_platdata *plat,
out_le32(>baud, tmp);
 }
 
-static void _lpuart32_serial_setbrg(struct lpuart_serial_platdata *plat,
+static void _lpuart32_serial_setbrg(struct udevice *dev,
int baudrate)
 {
+   struct lpuart_serial_platdata *plat = dev_get_platdata(dev);
struct lpuart_fsl_reg32 *base = plat->reg;
-   u32 clk = get_lpuart_clk();
+   u32 clk;
u32 sbr;
 
+   if (IS_ENABLED(CONFIG_CLK))
+   clk = get_lpuart_clk_rate(dev);
+   else
+   clk = get_lpuart_clk();
+
sbr = (clk / (16 * baudrate));
 
/* place adjustment later - n/32 BRFA */
@@ -321,8 +362,9 @@ static int _lpuart32_serial_tstc(struct 
lpuart_serial_platdata *plat)
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
  */
-static int _lpuart32_serial_init(struct lpuart_serial_platdata *plat)
+static int _lpuart32_serial_init(struct udevice *dev)
 {
+   struct lpuart_serial_platdata *plat = dev_get_platdata(dev);
struct lpuart_fsl_reg32 *base = (struct lpuart_fsl_reg32 *)plat->reg;
u32 val, tx_fifo_size;
 
@@ -350,10 +392,10 @@ static int _lpuart32_serial_init(struct 
lpuart_serial_platdata *plat)
lpuart_write32(plat->flags, >match, 0);
 

[U-Boot] [PATCH V2 17/32] imx8: implement mmc_get_env_dev

2018-07-17 Thread Peng Fan
Implement mmc_get_env_dev for i.MX8.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/mach-imx/imx8/cpu.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index 90b6ea4211..0cacaa895c 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -176,3 +176,35 @@ enum boot_device get_boot_device(void)
 
return boot_dev;
 }
+
+#ifdef CONFIG_ENV_IS_IN_MMC
+__weak int board_mmc_get_env_dev(int devno)
+{
+   return CONFIG_SYS_MMC_ENV_DEV;
+}
+
+int mmc_get_env_dev(void)
+{
+   sc_rsrc_t dev_rsrc;
+   int devno;
+
+   sc_misc_get_boot_dev(-1, _rsrc);
+
+   switch (dev_rsrc) {
+   case SC_R_SDHC_0:
+   devno = 0;
+   break;
+   case SC_R_SDHC_1:
+   devno = 1;
+   break;
+   case SC_R_SDHC_2:
+   devno = 2;
+   break;
+   default:
+   /* If not boot from sd/mmc, use default value */
+   return CONFIG_SYS_MMC_ENV_DEV;
+   }
+
+   return board_mmc_get_env_dev(devno);
+}
+#endif
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 16/32] imx8: add boot device detection

2018-07-17 Thread Peng Fan
Add get_boot_device to detect boot device.
Add print_bootinfo to print the boot device info.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/sys_proto.h | 10 
 arch/arm/mach-imx/imx8/cpu.c   | 85 ++
 2 files changed, 95 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/sys_proto.h

diff --git a/arch/arm/include/asm/arch-imx8/sys_proto.h 
b/arch/arm/include/asm/arch-imx8/sys_proto.h
new file mode 100644
index 00..f9a3016132
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/sys_proto.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+
+enum boot_device get_boot_device(void);
+int print_bootinfo(void);
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index 0b841e291d..90b6ea4211 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -11,8 +11,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -91,3 +93,86 @@ int print_cpuinfo(void)
return 0;
 }
 #endif
+
+int print_bootinfo(void)
+{
+   enum boot_device bt_dev = get_boot_device();
+
+   puts("Boot:  ");
+   switch (bt_dev) {
+   case SD1_BOOT:
+   puts("SD0\n");
+   break;
+   case SD2_BOOT:
+   puts("SD1\n");
+   break;
+   case SD3_BOOT:
+   puts("SD2\n");
+   break;
+   case MMC1_BOOT:
+   puts("MMC0\n");
+   break;
+   case MMC2_BOOT:
+   puts("MMC1\n");
+   break;
+   case MMC3_BOOT:
+   puts("MMC2\n");
+   break;
+   case FLEXSPI_BOOT:
+   puts("FLEXSPI\n");
+   break;
+   case SATA_BOOT:
+   puts("SATA\n");
+   break;
+   case NAND_BOOT:
+   puts("NAND\n");
+   break;
+   case USB_BOOT:
+   puts("USB\n");
+   break;
+   default:
+   printf("Unknown device %u\n", bt_dev);
+   break;
+   }
+
+   return 0;
+}
+
+enum boot_device get_boot_device(void)
+{
+   enum boot_device boot_dev = SD1_BOOT;
+
+   sc_rsrc_t dev_rsrc;
+
+   sc_misc_get_boot_dev(-1, _rsrc);
+
+   switch (dev_rsrc) {
+   case SC_R_SDHC_0:
+   boot_dev = MMC1_BOOT;
+   break;
+   case SC_R_SDHC_1:
+   boot_dev = SD2_BOOT;
+   break;
+   case SC_R_SDHC_2:
+   boot_dev = SD3_BOOT;
+   break;
+   case SC_R_NAND:
+   boot_dev = NAND_BOOT;
+   break;
+   case SC_R_FSPI_0:
+   boot_dev = FLEXSPI_BOOT;
+   break;
+   case SC_R_SATA_0:
+   boot_dev = SATA_BOOT;
+   break;
+   case SC_R_USB_0:
+   case SC_R_USB_1:
+   case SC_R_USB_2:
+   boot_dev = USB_BOOT;
+   break;
+   default:
+   break;
+   }
+
+   return boot_dev;
+}
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 27/32] serial: lpuart: Enable RX and TX FIFO

2018-07-17 Thread Peng Fan
From: Ye Li 

Enable the RX and TX FIFO in LPUART driver to avoid the input lost
during u-boot boot up.

Signed-off-by: Ye Li 
Acked-by: Peng Fan 
---
 drivers/serial/serial_lpuart.c | 33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
index c14a8105c9..b28f7cf68d 100644
--- a/drivers/serial/serial_lpuart.c
+++ b/drivers/serial/serial_lpuart.c
@@ -40,6 +40,12 @@
 #define CTRL_TE(1 << 19)
 #define CTRL_RE(1 << 18)
 
+#define FIFO_RXFLUSH   BIT(14)
+#define FIFO_TXFLUSH   BIT(15)
+#define FIFO_TXSIZE_MASK   0x70
+#define FIFO_TXSIZE_OFF4
+#define FIFO_RXSIZE_MASK   0x7
+#define FIFO_RXSIZE_OFF0
 #define FIFO_TXFE  0x80
 #ifdef CONFIG_ARCH_IMX8
 #define FIFO_RXFE  0x08
@@ -47,7 +53,7 @@
 #define FIFO_RXFE  0x40
 #endif
 
-#define WATER_TXWATER_OFF  1
+#define WATER_TXWATER_OFF  0
 #define WATER_RXWATER_OFF  16
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -318,15 +324,28 @@ static int _lpuart32_serial_tstc(struct 
lpuart_serial_platdata *plat)
 static int _lpuart32_serial_init(struct lpuart_serial_platdata *plat)
 {
struct lpuart_fsl_reg32 *base = (struct lpuart_fsl_reg32 *)plat->reg;
-   u32 ctrl;
+   u32 val, tx_fifo_size;
 
-   lpuart_read32(plat->flags, >ctrl, );
-   ctrl &= ~CTRL_RE;
-   ctrl &= ~CTRL_TE;
-   lpuart_write32(plat->flags, >ctrl, ctrl);
+   lpuart_read32(plat->flags, >ctrl, );
+   val &= ~CTRL_RE;
+   val &= ~CTRL_TE;
+   lpuart_write32(plat->flags, >ctrl, val);
 
lpuart_write32(plat->flags, >modir, 0);
-   lpuart_write32(plat->flags, >fifo, ~(FIFO_TXFE | FIFO_RXFE));
+
+   lpuart_read32(plat->flags, >fifo, );
+   tx_fifo_size = (val & FIFO_TXSIZE_MASK) >> FIFO_TXSIZE_OFF;
+   /* Set the TX water to half of FIFO size */
+   if (tx_fifo_size > 1)
+   tx_fifo_size = tx_fifo_size >> 1;
+
+   /* Set RX water to 0, to be triggered by any receive data */
+   lpuart_write32(plat->flags, >water,
+  (tx_fifo_size << WATER_TXWATER_OFF));
+
+   /* Enable TX and RX FIFO */
+   val |= (FIFO_TXFE | FIFO_RXFE | FIFO_TXFLUSH | FIFO_RXFLUSH);
+   lpuart_write32(plat->flags, >fifo, val);
 
lpuart_write32(plat->flags, >match, 0);
 
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 09/32] arm: global_data: add scu_dev for i.MX8

2018-07-17 Thread Peng Fan
Add scu_dev for i.MX8, this will be used as a handle
to communite with SCU from A35.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/global_data.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/global_data.h 
b/arch/arm/include/asm/global_data.h
index 287a7bd5b1..c3ee5f0c7b 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -74,6 +74,10 @@ struct arch_global_data {
 #if defined(CONFIG_FSL_LSCH3) && defined(CONFIG_SYS_FSL_HAS_DP_DDR)
unsigned long mem2_clk;
 #endif
+
+#ifdef CONFIG_ARCH_IMX8
+   struct udevice *scu_dev;
+#endif
 };
 
 #include 
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 24/32] power: Add power domain driver for i.MX8

2018-07-17 Thread Peng Fan
Add the power domain DM driver for i.MX8, that it depends on the DTB
power domain trees to generate the power domain provider devices. Users
needs add power domain trees with property "compatible = "nxp,imx8-pd";"

When power on one PD device, the driver will power on its ancestor PD
devices in power domain tree.

When power off on PD device, the driver will check its child PD devices
first, only all child PD devices are off, then power off the current PD
device. Then the driver checks sibling PD devices. If sibling PD devices
are off, then it will power off parent PD device.

There is no counter maintained in this driver, but a state to hold current
on/off state. So the request and free functions are empty.

The power domain implementation in i.MX8 DTB set the "#power-domain-cells"
to 0, so there is no ID binding with each PD device. We don't use "id"
variable in struct power_domain. At same time, we have to set of_xlate to
empty to bypass standard of_xlate in uclass driver.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/power-domain.h |  15 ++
 drivers/power/domain/Kconfig  |   6 +
 drivers/power/domain/Makefile |   1 +
 drivers/power/domain/imx8-power-domain.c  | 312 ++
 4 files changed, 334 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/power-domain.h
 create mode 100644 drivers/power/domain/imx8-power-domain.c

diff --git a/arch/arm/include/asm/arch-imx8/power-domain.h 
b/arch/arm/include/asm/arch-imx8/power-domain.h
new file mode 100644
index 00..1396008877
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/power-domain.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2017 NXP
+ */
+
+#ifndef _ASM_ARCH_IMX8_POWER_DOMAIN_H
+#define _ASM_ARCH_IMX8_POWER_DOMAIN_H
+
+#include 
+
+struct imx8_power_domain_platdata {
+   sc_rsrc_t resource_id;
+};
+
+#endif
diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 7cfa761498..2a72642a26 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -31,4 +31,10 @@ config TEGRA186_POWER_DOMAIN
  Enable support for manipulating Tegra's on-SoC power domains via IPC
  requests to the BPMP (Boot and Power Management Processor).
 
+config IMX8_POWER_DOMAIN
+   bool "Enable i.MX8 power domain driver"
+depends on ARCH_IMX8
+help
+  Enable support for manipulating NXP i.MX8 on-SoC power domains via 
IPC
+  requests to the SCU.
 endmenu
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index c7d7644402..c6ad7ff447 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
 obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain-test.o
 obj-$(CONFIG_TEGRA186_POWER_DOMAIN) += tegra186-power-domain.o
+obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain.o
diff --git a/drivers/power/domain/imx8-power-domain.c 
b/drivers/power/domain/imx8-power-domain.c
new file mode 100644
index 00..be91d626ad
--- /dev/null
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2017 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct imx8_power_domain_priv {
+   bool state_on;
+};
+
+static int imx8_power_domain_request(struct power_domain *power_domain)
+{
+   debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+   return 0;
+}
+
+static int imx8_power_domain_free(struct power_domain *power_domain)
+{
+   debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+   return 0;
+}
+
+static int imx8_power_domain_on(struct power_domain *power_domain)
+{
+   struct udevice *dev = power_domain->dev;
+   struct imx8_power_domain_platdata *pdata;
+   struct imx8_power_domain_priv *ppriv;
+   sc_err_t ret;
+
+   struct power_domain parent_domain;
+   struct udevice *parent = dev_get_parent(dev);
+
+   /* Need to power on parent node first */
+   if (device_get_uclass_id(parent) == UCLASS_POWER_DOMAIN) {
+   parent_domain.dev = parent;
+   imx8_power_domain_on(_domain);
+   }
+
+   pdata = (struct imx8_power_domain_platdata *)dev_get_platdata(dev);
+   ppriv = (struct imx8_power_domain_priv *)dev_get_priv(dev);
+
+   debug("%s(power_domain=%s) resource_id %d\n", __func__, dev->name,
+ pdata->resource_id);
+
+   /* Already powered on */
+   if (ppriv->state_on)
+   return 0;
+
+   if (pdata->resource_id != SC_R_LAST) {
+   ret = sc_pm_set_resource_power_mode(-1, pdata->resource_id,
+   SC_PM_PW_MODE_ON);
+  

[U-Boot] [PATCH V2 14/32] armv8: add cpu core helper functions

2018-07-17 Thread Peng Fan
Add helper functions to identify different armv8 variants.

Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/armv8/cpu.h | 26 ++
 1 file changed, 26 insertions(+)
 create mode 100644 arch/arm/include/asm/armv8/cpu.h

diff --git a/arch/arm/include/asm/armv8/cpu.h b/arch/arm/include/asm/armv8/cpu.h
new file mode 100644
index 00..40d54dc85a
--- /dev/null
+++ b/arch/arm/include/asm/armv8/cpu.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#define MIDR_PARTNUM_CORTEX_A350xD04
+#define MIDR_PARTNUM_CORTEX_A530xD03
+#define MIDR_PARTNUM_CORTEX_A720xD08
+#define MIDR_PARTNUM_SHIFT 0x4
+#define MIDR_PARTNUM_MASK  (0xFFF << 0x4)
+
+static inline unsigned int read_midr(void)
+{
+   unsigned long val;
+
+   asm volatile("mrs %0, midr_el1" : "=r" (val));
+
+   return val;
+}
+
+#define is_cortex_a35() (((read_midr() & MIDR_PARTNUM_MASK) >> \
+MIDR_PARTNUM_SHIFT) == MIDR_PARTNUM_CORTEX_A35)
+#define is_cortex_a53() (((read_midr() & MIDR_PARTNUM_MASK) >> \
+MIDR_PARTNUM_SHIFT) == MIDR_PARTNUM_CORTEX_A53)
+#define is_cortex_a72() (((read_midr() & MIDR_PARTNUM_MASK) >>\
+MIDR_PARTNUM_SHIFT) == MIDR_PARTNUM_CORTEX_A72)
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 21/32] imx8: add dummy clock

2018-07-17 Thread Peng Fan
This driver is mostly used to avoid build error.
We use uclass clk driver to clk related operations.

Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/arch-imx8/clock.h | 27 +++
 arch/arm/mach-imx/imx8/clock.c | 21 +
 2 files changed, 48 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/clock.h
 create mode 100644 arch/arm/mach-imx/imx8/clock.c

diff --git a/arch/arm/include/asm/arch-imx8/clock.h 
b/arch/arm/include/asm/arch-imx8/clock.h
new file mode 100644
index 00..bea157171f
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/clock.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_CLOCK_H__
+#define __ASM_ARCH_IMX8_CLOCK_H__
+
+/* Mainly for compatible to imx common code. */
+enum mxc_clock {
+   MXC_ARM_CLK = 0,
+   MXC_AHB_CLK,
+   MXC_IPG_CLK,
+   MXC_UART_CLK,
+   MXC_CSPI_CLK,
+   MXC_AXI_CLK,
+   MXC_DDR_CLK,
+   MXC_ESDHC_CLK,
+   MXC_ESDHC2_CLK,
+   MXC_ESDHC3_CLK,
+   MXC_I2C_CLK,
+   MXC_FEC_CLK,
+};
+
+u32 mxc_get_clock(enum mxc_clock clk);
+
+#endif /* __ASM_ARCH_IMX8_CLOCK_H__ */
diff --git a/arch/arm/mach-imx/imx8/clock.c b/arch/arm/mach-imx/imx8/clock.c
new file mode 100644
index 00..d747e1332f
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/clock.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+u32 mxc_get_clock(enum mxc_clock clk)
+{
+   switch (clk) {
+   default:
+   printf("Unsupported mxc_clock %d\n", clk);
+   break;
+   }
+
+   return 0;
+}
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 30/32] mmc: fsl_esdhc: add uclass clk support

2018-07-17 Thread Peng Fan
When CONIFG_CLK is enabled, use uclass clk api to handle
the clock.

Signed-off-by: Peng Fan 
Cc: Jaehoon Chung 
Cc: Stefano Babic 
---
 drivers/mmc/fsl_esdhc.c | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 785b9e87a6..283b03bf0f 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -121,6 +122,7 @@ struct esdhc_soc_data {
 struct fsl_esdhc_priv {
struct fsl_esdhc *esdhc_regs;
unsigned int sdhc_clk;
+   struct clk per_clk;
unsigned int clock;
unsigned int mode;
unsigned int bus_width;
@@ -1462,10 +1464,22 @@ static int fsl_esdhc_probe(struct udevice *dev)
 
init_clk_usdhc(dev->seq);
 
-   priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
-   if (priv->sdhc_clk <= 0) {
-   dev_err(dev, "Unable to get clk for %s\n", dev->name);
-   return -EINVAL;
+   if (IS_ENABLED(CONFIG_CLK)) {
+   /* Assigned clock already set clock */
+   ret = clk_get_by_name(dev, "per", >per_clk);
+   if (ret)
+   printf("Failed to get per_clk\n");
+   ret = clk_enable(>per_clk);
+   if (ret)
+   printf("Failed to enable per_clk\n");
+
+   priv->sdhc_clk = clk_get_rate(>per_clk);
+   } else {
+   priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
+   if (priv->sdhc_clk <= 0) {
+   dev_err(dev, "Unable to get clk for %s\n", dev->name);
+   return -EINVAL;
+   }
}
 
ret = fsl_esdhc_init(priv, plat);
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 32/32] imx: add i.MX8QXP MEK board support

2018-07-17 Thread Peng Fan
Add i.MX8QXP MEK board support
Enabled pinctrl/clk/power domain/mmc/i2c driver.

Signed-off-by: Peng Fan 
---
 arch/arm/dts/Makefile |   2 +
 arch/arm/dts/fsl-imx8qxp-mek.dts  | 136 ++
 arch/arm/mach-imx/imx8/Kconfig|  13 +++
 board/freescale/imx8qxp_mek/Kconfig   |  14 +++
 board/freescale/imx8qxp_mek/MAINTAINERS   |   6 ++
 board/freescale/imx8qxp_mek/Makefile  |   7 ++
 board/freescale/imx8qxp_mek/imx8qxp_mek.c | 152 +
 configs/imx8qxp_mek_defconfig |  37 +++
 include/configs/imx8qxp_mek.h | 157 ++
 9 files changed, 524 insertions(+)
 create mode 100644 arch/arm/dts/fsl-imx8qxp-mek.dts
 create mode 100644 board/freescale/imx8qxp_mek/Kconfig
 create mode 100644 board/freescale/imx8qxp_mek/MAINTAINERS
 create mode 100644 board/freescale/imx8qxp_mek/Makefile
 create mode 100644 board/freescale/imx8qxp_mek/imx8qxp_mek.c
 create mode 100644 configs/imx8qxp_mek_defconfig
 create mode 100644 include/configs/imx8qxp_mek.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 946023093d..4a4959f0c0 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -438,6 +438,8 @@ dtb-$(CONFIG_MX7) += imx7-colibri.dtb \
 
 dtb-$(CONFIG_ARCH_MX7ULP) += imx7ulp-evk.dtb
 
+dtb-$(CONFIG_ARCH_IMX8) += fsl-imx8qxp-mek.dtb
+
 dtb-$(CONFIG_RCAR_GEN3) += \
r8a7795-h3ulcb.dtb \
r8a7795-salvator-x.dtb \
diff --git a/arch/arm/dts/fsl-imx8qxp-mek.dts b/arch/arm/dts/fsl-imx8qxp-mek.dts
new file mode 100644
index 00..5443ef7e4e
--- /dev/null
+++ b/arch/arm/dts/fsl-imx8qxp-mek.dts
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2017-2018 NXP
+ */
+
+/dts-v1/;
+
+#include "fsl-imx8qxp.dtsi"
+
+/ {
+   model = "Freescale i.MX8QXP MEK";
+   compatible = "fsl,imx8qxp-mek", "fsl,imx8qxp";
+
+   chosen {
+   bootargs = "console=ttyLP0,115200 
earlycon=lpuart32,0x5a06,115200";
+   stdout-path = 
+   };
+
+   regulators {
+   compatible = "simple-bus";
+
+   reg_usdhc2_vmmc: usdhc2_vmmc {
+   compatible = "regulator-fixed";
+   regulator-name = "SD1_SPWR";
+   regulator-min-microvolt = <300>;
+   regulator-max-microvolt = <300>;
+   gpio = < 19 GPIO_ACTIVE_HIGH>;
+   off-on-delay = <3480>;
+   enable-active-high;
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_hog>;
+
+   imx8qxp-mek {
+   pinctrl_hog: hoggrp {
+   fsl,pins = <
+   SC_P_MCLK_OUT0_ADMA_ACM_MCLK_OUT0   
0x064c
+   SC_P_COMP_CTL_GPIO_1V8_3V3_GPIORHB_PAD  
0x000514a0
+   >;
+   };
+
+   pinctrl_ioexp_rst: ioexp_rst_grp {
+   fsl,pins = <
+   SC_P_SPI2_SDO_LSIO_GPIO1_IO01   0x0621
+   >;
+   };
+
+   pinctrl_lpi2c1: lpi1cgrp {
+   fsl,pins = <
+   SC_P_USB_SS3_TC1_ADMA_I2C1_SCL  0x0621
+   SC_P_USB_SS3_TC3_ADMA_I2C1_SDA  0x0621
+   >;
+   };
+
+   pinctrl_lpuart0: lpuart0grp {
+   fsl,pins = <
+   SC_P_UART0_RX_ADMA_UART0_RX 0x0620
+   SC_P_UART0_TX_ADMA_UART0_TX 0x0620
+   >;
+   };
+
+   pinctrl_usdhc1: usdhc1grp {
+   fsl,pins = <
+   SC_P_EMMC0_CLK_CONN_EMMC0_CLK   
0x0641
+   SC_P_EMMC0_CMD_CONN_EMMC0_CMD   
0x0021
+   SC_P_EMMC0_DATA0_CONN_EMMC0_DATA0   
0x0021
+   SC_P_EMMC0_DATA1_CONN_EMMC0_DATA1   
0x0021
+   SC_P_EMMC0_DATA2_CONN_EMMC0_DATA2   
0x0021
+   SC_P_EMMC0_DATA3_CONN_EMMC0_DATA3   
0x0021
+   SC_P_EMMC0_DATA4_CONN_EMMC0_DATA4   
0x0021
+   SC_P_EMMC0_DATA5_CONN_EMMC0_DATA5   
0x0021
+   SC_P_EMMC0_DATA6_CONN_EMMC0_DATA6   
0x0021
+   SC_P_EMMC0_DATA7_CONN_EMMC0_DATA7   
0x0021
+   SC_P_EMMC0_STROBE_CONN_EMMC0_STROBE 
0x0041
+   >;
+   };
+
+   pinctrl_usdhc2_gpio: usdhc2gpiogrp {
+   fsl,pins = <
+   SC_P_USDHC1_RESET_B_LSIO_GPIO4_IO19 
0x0021
+ 

[U-Boot] [PATCH V2 20/32] imx8: add iomux configuration api

2018-07-17 Thread Peng Fan
Add iomux configuration api.

Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/arch-imx8/iomux.h | 40 +++
 arch/arm/mach-imx/imx8/Makefile|  2 +-
 arch/arm/mach-imx/imx8/iomux.c | 43 ++
 3 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/arch-imx8/iomux.h
 create mode 100644 arch/arm/mach-imx/imx8/iomux.c

diff --git a/arch/arm/include/asm/arch-imx8/iomux.h 
b/arch/arm/include/asm/arch-imx8/iomux.h
new file mode 100644
index 00..bedd01bfd8
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/iomux.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_IOMUX_H__
+#define __ASM_ARCH_IMX8_IOMUX_H__
+
+/*
+ * We use 64bits value for iomux settings.
+ * High 32bits are used for padring register value,
+ * low 16bits are used for pin index.
+ */
+typedef u64 iomux_cfg_t;
+
+#define PADRING_IFMUX_EN_SHIFT 31
+#define PADRING_IFMUX_EN_MASK  BIT(31)
+#define PADRING_GP_EN_SHIFT30
+#define PADRING_GP_EN_MASK BIT(30)
+#define PADRING_IFMUX_SHIFT27
+#define PADRING_IFMUX_MASK GENMASK(29, 27)
+#define PADRING_CONFIG_SHIFT   25
+#define PADRING_LPCONFIG_SHIFT 23
+#define PADRING_PULL_SHIFT 5
+#define PADRING_DSE_SHIFT  0
+
+#define MUX_PAD_CTRL_SHIFT 32
+#define MUX_PAD_CTRL_MASK  ((iomux_cfg_t)0x << MUX_PAD_CTRL_SHIFT)
+#define MUX_PAD_CTRL(x)((iomux_cfg_t)(x) << MUX_PAD_CTRL_SHIFT)
+#define MUX_MODE_SHIFT (PADRING_IFMUX_SHIFT + MUX_PAD_CTRL_SHIFT)
+#define MUX_MODE_MASK  ((iomux_cfg_t)0x7 << MUX_MODE_SHIFT)
+#define PIN_ID_MASK((iomux_cfg_t)0x)
+
+/* Valid mux alt0 to alt7 */
+#define MUX_MODE_ALT(x)(((iomux_cfg_t)(x) << MUX_MODE_SHIFT) & 
\
+MUX_MODE_MASK)
+
+void imx8_iomux_setup_pad(iomux_cfg_t pad);
+void imx8_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count);
+#endif /* __ASM_ARCH_IMX8_IOMUX_H__ */
diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile
index 57876139a1..31ad169ccf 100644
--- a/arch/arm/mach-imx/imx8/Makefile
+++ b/arch/arm/mach-imx/imx8/Makefile
@@ -4,4 +4,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-y += cpu.o
+obj-y += cpu.o iomux.o
diff --git a/arch/arm/mach-imx/imx8/iomux.c b/arch/arm/mach-imx/imx8/iomux.c
new file mode 100644
index 00..0ade85fb8f
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/iomux.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * configures a single pad in the iomuxer
+ */
+void imx8_iomux_setup_pad(iomux_cfg_t pad)
+{
+   sc_pad_t pin_id = pad & PIN_ID_MASK;
+   int ret;
+
+   u32 val = (u32)((pad & MUX_PAD_CTRL_MASK) >> MUX_PAD_CTRL_SHIFT);
+
+   val |= PADRING_IFMUX_EN_MASK;
+   val |= PADRING_GP_EN_MASK;
+
+   ret = sc_pad_set(-1, pin_id, val);
+   if (ret)
+   printf("sc_pad_set failed!, pin: %u, val: 0x%x\n", pin_id, val);
+
+   debug("iomux: pin %d, val = 0x%x\n", pin_id, val);
+}
+
+/* configures a list of pads within declared with IOMUX_PADS macro */
+void imx8_iomux_setup_multiple_pads(iomux_cfg_t const *pad_list, u32 count)
+{
+   iomux_cfg_t const *p = pad_list;
+   int i;
+
+   for (i = 0; i < count; i++) {
+   imx8_iomux_setup_pad(*p);
+   p++;
+   }
+}
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 22/32] gpio: mxc_gpio: add support for i.MX8

2018-07-17 Thread Peng Fan
Add i.MX8 support, there are 8 GPIO banks.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/gpio.h | 21 +
 drivers/gpio/mxc_gpio.c   | 30 +-
 2 files changed, 42 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-imx8/gpio.h

diff --git a/arch/arm/include/asm/arch-imx8/gpio.h 
b/arch/arm/include/asm/arch-imx8/gpio.h
new file mode 100644
index 00..24cfde3c29
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/gpio.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_GPIO_H
+#define __ASM_ARCH_IMX8_GPIO_H
+
+#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
+/* GPIO registers */
+struct gpio_regs {
+   u32 gpio_dr;/* data */
+   u32 gpio_dir;   /* direction */
+   u32 gpio_psr;   /* pad satus */
+};
+#endif
+
+/* IMX8 the GPIO index is from 0 not 1 */
+#define IMX_GPIO_NR(port, index)   (((port) * 32) + ((index) & 31))
+
+#endif /* __ASM_ARCH_IMX8_GPIO_H */
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index d8e72ada19..b820160ae7 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -40,21 +40,27 @@ static unsigned long gpio_ports[] = {
[2] = GPIO3_BASE_ADDR,
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX7) || defined(CONFIG_MX8M)
+   defined(CONFIG_MX7) || defined(CONFIG_MX8M) || \
+   defined(CONFIG_ARCH_IMX8)
[3] = GPIO4_BASE_ADDR,
 #endif
 #if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX7) || defined(CONFIG_MX8M)
+   defined(CONFIG_MX7) || defined(CONFIG_MX8M) || \
+   defined(CONFIG_ARCH_IMX8)
[4] = GPIO5_BASE_ADDR,
 #if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) || defined(CONFIG_MX8M))
[5] = GPIO6_BASE_ADDR,
 #endif
 #endif
-#if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_MX7)
+#if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_MX7) || \
+   defined(CONFIG_ARCH_IMX8)
 #if !(defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL))
[6] = GPIO7_BASE_ADDR,
 #endif
 #endif
+#if defined(CONFIG_ARCH_IMX8)
+   [7] = GPIO8_BASE_ADDR,
+#endif
 };
 
 static int mxc_gpio_direction(unsigned int gpio,
@@ -347,19 +353,22 @@ static const struct mxc_gpio_plat mxc_plat[] = {
{ 2, (struct gpio_regs *)GPIO3_BASE_ADDR },
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_MX8M) || defined(CONFIG_ARCH_IMX8)
{ 3, (struct gpio_regs *)GPIO4_BASE_ADDR },
 #endif
 #if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_MX8M) || defined(CONFIG_ARCH_IMX8)
{ 4, (struct gpio_regs *)GPIO5_BASE_ADDR },
 #ifndef CONFIG_MX8M
{ 5, (struct gpio_regs *)GPIO6_BASE_ADDR },
 #endif
 #endif
-#if defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_ARCH_IMX8)
{ 6, (struct gpio_regs *)GPIO7_BASE_ADDR },
 #endif
+#if defined(CONFIG_ARCH_IMX8)
+   { 7, (struct gpio_regs *)GPIO8_BASE_ADDR },
+#endif
 };
 
 U_BOOT_DEVICES(mxc_gpios) = {
@@ -368,19 +377,22 @@ U_BOOT_DEVICES(mxc_gpios) = {
{ "gpio_mxc", _plat[2] },
 #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX51) || \
defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_MX8M) || defined(CONFIG_ARCH_IMX8)
{ "gpio_mxc", _plat[3] },
 #endif
 #if defined(CONFIG_MX27) || defined(CONFIG_MX53) || defined(CONFIG_MX6) || \
-   defined(CONFIG_MX8M)
+   defined(CONFIG_MX8M) || defined(CONFIG_ARCH_IMX8)
{ "gpio_mxc", _plat[4] },
 #ifndef CONFIG_MX8M
{ "gpio_mxc", _plat[5] },
 #endif
 #endif
-#if defined(CONFIG_MX53) || defined(CONFIG_MX6)
+#if defined(CONFIG_MX53) || defined(CONFIG_MX6) || defined(CONFIG_ARCH_IMX8)
{ "gpio_mxc", _plat[6] },
 #endif
+#if defined(CONFIG_ARCH_IMX8)
+   { "gpio_mxc", _plat[7] },
+#endif
 };
 #endif
 #endif
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 25/32] clk: imx: add clk driver for i.MX8QXP

2018-07-17 Thread Peng Fan
Add clk driver for i.MX8QXP, support clk
enable/disable/get_rate/set_rate operations.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 drivers/clk/Kconfig|   1 +
 drivers/clk/Makefile   |   1 +
 drivers/clk/imx/Kconfig|   6 ++
 drivers/clk/imx/Makefile   |   5 ++
 drivers/clk/imx/clk-imx8.c | 212 +
 5 files changed, 225 insertions(+)
 create mode 100644 drivers/clk/imx/Kconfig
 create mode 100644 drivers/clk/imx/Makefile
 create mode 100644 drivers/clk/imx/clk-imx8.c

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 18bf8a6d28..c2f2a99b40 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -86,6 +86,7 @@ config CLK_STM32MP1
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/uniphier/Kconfig"
 source "drivers/clk/exynos/Kconfig"
+source "drivers/clk/imx/Kconfig"
 source "drivers/clk/at91/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 146283c723..2a3c83b597 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -8,6 +8,7 @@
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o
 
 obj-y += tegra/
+obj-y += imx/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MESON) += clk_meson.o
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig
new file mode 100644
index 00..a6fb58d6cf
--- /dev/null
+++ b/drivers/clk/imx/Kconfig
@@ -0,0 +1,6 @@
+config CLK_IMX8
+   bool "Clock support for i.MX8"
+   depends on ARCH_IMX8
+   select CLK
+   help
+ This enables support clock driver for i.MX8 platforms.
diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
new file mode 100644
index 00..5505ae52e2
--- /dev/null
+++ b/drivers/clk/imx/Makefile
@@ -0,0 +1,5 @@
+# Copyright 2018 NXP
+#
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_CLK_IMX8) += clk-imx8.o
diff --git a/drivers/clk/imx/clk-imx8.c b/drivers/clk/imx/clk-imx8.c
new file mode 100644
index 00..ba87ad6964
--- /dev/null
+++ b/drivers/clk/imx/clk-imx8.c
@@ -0,0 +1,212 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 NXP
+ * Peng Fan 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static ulong imx8_clk_get_rate(struct clk *clk)
+{
+   sc_pm_clk_t pm_clk;
+   ulong rate;
+   u16 resource;
+   int ret;
+
+   debug("%s(#%ld)\n", __func__, clk->id);
+
+   switch (clk->id) {
+   case IMX8QXP_A35_DIV:
+   resource = SC_R_A35;
+   pm_clk = SC_PM_CLK_CPU;
+   break;
+   case IMX8QXP_SDHC0_IPG_CLK:
+   case IMX8QXP_SDHC0_CLK:
+   case IMX8QXP_SDHC0_DIV:
+   resource = SC_R_SDHC_0;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_SDHC1_IPG_CLK:
+   case IMX8QXP_SDHC1_CLK:
+   case IMX8QXP_SDHC1_DIV:
+   resource = SC_R_SDHC_1;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_UART0_IPG_CLK:
+   case IMX8QXP_UART0_CLK:
+   resource = SC_R_UART_0;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   default:
+   dev_err(dev, "%s(Invalid #%ld)\n", __func__, clk->id);
+   return -EINVAL;
+   };
+
+   ret = sc_pm_get_clock_rate(-1, resource, pm_clk,
+  (sc_pm_clock_rate_t *));
+   if (ret)
+   printf("%s err %d\n", __func__, ret);
+
+   return rate;
+}
+
+static ulong imx8_clk_set_rate(struct clk *clk, unsigned long rate)
+{
+   sc_pm_clk_t pm_clk;
+   u32 new_rate = rate;
+   u16 resource;
+   int ret;
+
+   debug("%s(#%ld), rate: %lu\n", __func__, clk->id, rate);
+
+   switch (clk->id) {
+   case IMX8QXP_UART0_CLK:
+   resource = SC_R_UART_0;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_UART1_CLK:
+   resource = SC_R_UART_1;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_UART2_CLK:
+   resource = SC_R_UART_2;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_UART3_CLK:
+   resource = SC_R_UART_3;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_SDHC0_IPG_CLK:
+   case IMX8QXP_SDHC0_CLK:
+   case IMX8QXP_SDHC0_DIV:
+   resource = SC_R_SDHC_0;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   case IMX8QXP_SDHC1_SEL:
+   case IMX8QXP_SDHC0_SEL:
+   return 0;
+   case IMX8QXP_SDHC1_IPG_CLK:
+   case IMX8QXP_SDHC1_CLK:
+   case IMX8QXP_SDHC1_DIV:
+   resource = SC_R_SDHC_1;
+   pm_clk = SC_PM_CLK_PER;
+   break;
+   default:
+   printf("%s %ld\n", __func__, clk->id);
+  

[U-Boot] [PATCH V2 18/32] imx8: add mmu and dram related functiions

2018-07-17 Thread Peng Fan
Add mmu memmap, some memory regions are reserved by M4, Arm Trusted
Firmware, so need to get memreg using SCFW API and setup the memmap.

Add dram_init, dram_init_banksize, get_effective_memsize functions,
according to the memreg.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/mach-imx/imx8/cpu.c | 283 +++
 1 file changed, 283 insertions(+)

diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
index 0cacaa895c..389f422be7 100644
--- a/arch/arm/mach-imx/imx8/cpu.c
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -208,3 +209,285 @@ int mmc_get_env_dev(void)
return board_mmc_get_env_dev(devno);
 }
 #endif
+
+#define MEMSTART_ALIGNMENT  SZ_2M /* Align the memory start with 2MB */
+
+static int get_owned_memreg(sc_rm_mr_t mr, sc_faddr_t *addr_start,
+   sc_faddr_t *addr_end)
+{
+   sc_faddr_t start, end;
+   int ret;
+   bool owned;
+
+   owned = sc_rm_is_memreg_owned(-1, mr);
+   if (owned) {
+   ret = sc_rm_get_memreg_info(-1, mr, , );
+   if (ret) {
+   printf("Memreg get info failed, %d\n", ret);
+   return -EINVAL;
+   }
+   debug("0x%llx -- 0x%llx\n", start, end);
+   *addr_start = start;
+   *addr_end = end;
+
+   return 0;
+   }
+
+   return -EINVAL;
+}
+
+phys_size_t get_effective_memsize(void)
+{
+   sc_rm_mr_t mr;
+   sc_faddr_t start, end, end1;
+   int err;
+
+   end1 = (sc_faddr_t)PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE;
+
+   for (mr = 0; mr < 64; mr++) {
+   err = get_owned_memreg(mr, , );
+   if (!err) {
+   start = roundup(start, MEMSTART_ALIGNMENT);
+   /* Too small memory region, not use it */
+   if (start > end)
+   continue;
+
+   /* Find the memory region runs the u-boot */
+   if (start >= PHYS_SDRAM_1 && start <= end1 &&
+   (start <= CONFIG_SYS_TEXT_BASE &&
+   end >= CONFIG_SYS_TEXT_BASE)) {
+   if ((end + 1) <= ((sc_faddr_t)PHYS_SDRAM_1 +
+   PHYS_SDRAM_1_SIZE))
+   return (end - PHYS_SDRAM_1 + 1);
+   else
+   return PHYS_SDRAM_1_SIZE;
+   }
+   }
+   }
+
+   return PHYS_SDRAM_1_SIZE;
+}
+
+int dram_init(void)
+{
+   sc_rm_mr_t mr;
+   sc_faddr_t start, end, end1, end2;
+   int err;
+
+   end1 = (sc_faddr_t)PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE;
+   end2 = (sc_faddr_t)PHYS_SDRAM_2 + PHYS_SDRAM_2_SIZE;
+   for (mr = 0; mr < 64; mr++) {
+   err = get_owned_memreg(mr, , );
+   if (!err) {
+   start = roundup(start, MEMSTART_ALIGNMENT);
+   /* Too small memory region, not use it */
+   if (start > end)
+   continue;
+
+   if (start >= PHYS_SDRAM_1 && start <= end1) {
+   if ((end + 1) <= end1)
+   gd->ram_size += end - start + 1;
+   else
+   gd->ram_size += end1 - start;
+   } else if (start >= PHYS_SDRAM_2 && start <= end2) {
+   if ((end + 1) <= end2)
+   gd->ram_size += end - start + 1;
+   else
+   gd->ram_size += end2 - start;
+   }
+   }
+   }
+
+   /* If error, set to the default value */
+   if (!gd->ram_size) {
+   gd->ram_size = PHYS_SDRAM_1_SIZE;
+   gd->ram_size += PHYS_SDRAM_2_SIZE;
+   }
+   return 0;
+}
+
+static void dram_bank_sort(int current_bank)
+{
+   phys_addr_t start;
+   phys_size_t size;
+
+   while (current_bank > 0) {
+   if (gd->bd->bi_dram[current_bank - 1].start >
+   gd->bd->bi_dram[current_bank].start) {
+   start = gd->bd->bi_dram[current_bank - 1].start;
+   size = gd->bd->bi_dram[current_bank - 1].size;
+
+   gd->bd->bi_dram[current_bank - 1].start =
+   gd->bd->bi_dram[current_bank].start;
+   gd->bd->bi_dram[current_bank - 1].size =
+   gd->bd->bi_dram[current_bank].size;
+
+   gd->bd->bi_dram[current_bank].start = start;
+   gd->bd->bi_dram[current_bank].size = size;
+   }
+

[U-Boot] [PATCH V2 07/32] misc: add i.MX8 misc driver

2018-07-17 Thread Peng Fan
Add i.MX8 MISC driver to handle the communication between
A35 Core and SCU.

Signed-off-by: Peng Fan 
---
 drivers/misc/Makefile  |   1 +
 drivers/misc/imx8/Makefile |   3 +
 drivers/misc/imx8/scu.c| 247 +
 3 files changed, 251 insertions(+)
 create mode 100644 drivers/misc/imx8/Makefile
 create mode 100644 drivers/misc/imx8/scu.c

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 4ce9d213f0..c0de02c30d 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -6,6 +6,7 @@
 obj-$(CONFIG_MISC) += misc-uclass.o
 obj-$(CONFIG_ALI152X) += ali512x.o
 obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o
+obj-$(CONFIG_ARCH_IMX8) += imx8/
 obj-$(CONFIG_ATSHA204A) += atsha204a-i2c.o
 obj-$(CONFIG_DS4510)  += ds4510.o
 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
diff --git a/drivers/misc/imx8/Makefile b/drivers/misc/imx8/Makefile
new file mode 100644
index 00..3395340d22
--- /dev/null
+++ b/drivers/misc/imx8/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += scu.o
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c
new file mode 100644
index 00..f12c7a96f2
--- /dev/null
+++ b/drivers/misc/imx8/scu.c
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 NXP
+ *
+ * Peng Fan 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct mu_type {
+   u32 tr[4];
+   u32 rr[4];
+   u32 sr;
+   u32 cr;
+};
+
+struct imx8_scu {
+   struct mu_type *base;
+   struct udevice *clk;
+   struct udevice *pinclk;
+};
+
+#define MU_CR_GIE_MASK 0xF000u
+#define MU_CR_RIE_MASK 0xF00u
+#define MU_CR_GIR_MASK 0xFu
+#define MU_CR_TIE_MASK 0xF0u
+#define MU_CR_F_MASK   0x7u
+#define MU_SR_TE0_MASK BIT(23)
+#define MU_SR_RF0_MASK BIT(27)
+#define MU_TR_COUNT4
+#define MU_RR_COUNT4
+static inline void mu_hal_init(struct mu_type *base)
+{
+   /* Clear GIEn, RIEn, TIEn, GIRn and ABFn. */
+   clrbits_le32(>cr, MU_CR_GIE_MASK | MU_CR_RIE_MASK |
+MU_CR_TIE_MASK | MU_CR_GIR_MASK | MU_CR_F_MASK);
+}
+
+static int mu_hal_sendmsg(struct mu_type *base, u32 reg_index, u32 msg)
+{
+   u32 mask = MU_SR_TE0_MASK >> reg_index;
+   u32 val;
+   int ret;
+
+   assert(reg_index < MU_TR_COUNT);
+
+   /* Wait TX register to be empty. */
+   ret = readl_poll_timeout(>sr, val, val & mask, 1);
+   if (ret < 0) {
+   printf("%s timeout\n", __func__);
+   return -ETIMEDOUT;
+   }
+
+   writel(msg, >tr[reg_index]);
+
+   return 0;
+}
+
+static int mu_hal_receivemsg(struct mu_type *base, u32 reg_index, u32 *msg)
+{
+   u32 mask = MU_SR_RF0_MASK >> reg_index;
+   u32 val;
+   int ret;
+
+   assert(reg_index < MU_TR_COUNT);
+
+   /* Wait RX register to be full. */
+   ret = readl_poll_timeout(>sr, val, val & mask, 1);
+   if (ret < 0) {
+   printf("%s timeout\n", __func__);
+   return -ETIMEDOUT;
+   }
+
+   *msg = readl(>rr[reg_index]);
+
+   return 0;
+}
+
+static void sc_ipc_read(struct mu_type *base, void *data)
+{
+   struct sc_rpc_msg_s *msg = (struct sc_rpc_msg_s *)data;
+   u8 count = 0;
+
+   /* Check parms */
+   if (!base || !msg)
+   return;
+
+   /* Read first word */
+   mu_hal_receivemsg(base, 0, (u32 *)msg);
+   count++;
+
+   /* Check size */
+   if (msg->size > SC_RPC_MAX_MSG) {
+   *((u32 *)msg) = 0;
+   return;
+   }
+
+   /* Read remaining words */
+   while (count < msg->size) {
+   mu_hal_receivemsg(base, count % MU_RR_COUNT,
+ >DATA.u32[count - 1]);
+   count++;
+   }
+}
+
+static void sc_ipc_write(struct mu_type *base, void *data)
+{
+   struct sc_rpc_msg_s *msg = (struct sc_rpc_msg_s *)data;
+   u8 count = 0;
+
+   /* Check parms */
+   if (!base || !msg)
+   return;
+
+   /* Check size */
+   if (msg->size > SC_RPC_MAX_MSG)
+   return;
+
+   /* Write first word */
+   mu_hal_sendmsg(base, 0, *((u32 *)msg));
+   count++;
+
+   /* Write remaining words */
+   while (count < msg->size) {
+   mu_hal_sendmsg(base, count % MU_TR_COUNT,
+  msg->DATA.u32[count - 1]);
+   count++;
+   }
+}
+
+/*
+ * Note the function prototype use msgid as the 2nd parameter, here
+ * we take it as no_resp.
+ */
+static int imx8_scu_call(struct udevice *dev, int no_resp, void *tx_msg,
+int tx_size, void *rx_msg, int rx_size)
+{
+   struct imx8_scu *priv = dev_get_priv(dev);
+   sc_err_t result;
+
+   /* Expect tx_msg, rx_msg are the same value */
+   if 

[U-Boot] [PATCH V2 13/32] imx: add i.MX8 cpu type

2018-07-17 Thread Peng Fan
Add i.MX8 cpu type and is_imx8/is_imx8qxp help macros.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx/cpu.h   | 5 +
 arch/arm/include/asm/mach-imx/sys_proto.h | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx/cpu.h 
b/arch/arm/include/asm/arch-imx/cpu.h
index 62df1b9ad2..cf6303c3f5 100644
--- a/arch/arm/include/asm/arch-imx/cpu.h
+++ b/arch/arm/include/asm/arch-imx/cpu.h
@@ -25,12 +25,14 @@
 #define MXC_CPU_MX7S   0x71 /* dummy ID */
 #define MXC_CPU_MX7D   0x72
 #define MXC_CPU_MX8MQ  0x82
+#define MXC_CPU_IMX8QXP0x92 /* dummy ID */
 #define MXC_CPU_MX7ULP 0xE1 /* Temporally hard code */
 #define MXC_CPU_VF610  0xF6 /* dummy ID */
 
 #define MXC_SOC_MX60x60
 #define MXC_SOC_MX70x70
 #define MXC_SOC_MX8M   0x80
+#define MXC_SOC_IMX8   0x90 /* dummy */
 #define MXC_SOC_MX7ULP 0xE0 /* dummy */
 
 #define CHIP_REV_1_00x10
@@ -41,6 +43,9 @@
 #define CHIP_REV_2_50x25
 #define CHIP_REV_3_00x30
 
+#define CHIP_REV_A 0x0
+#define CHIP_REV_B 0x1
+
 #define BOARD_REV_1_0   0x0
 #define BOARD_REV_2_0   0x1
 #define BOARD_VER_OFFSET0x8
diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h 
b/arch/arm/include/asm/mach-imx/sys_proto.h
index d1d6cbc462..f8890b57da 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -27,6 +27,7 @@
 #define is_mx6() (is_soc_type(MXC_SOC_MX6))
 #define is_mx7() (is_soc_type(MXC_SOC_MX7))
 #define is_mx8m() (is_soc_type(MXC_SOC_MX8M))
+#define is_imx8() (is_soc_type(MXC_SOC_IMX8))
 
 #define is_mx6dqp() (is_cpu_type(MXC_CPU_MX6QP) || is_cpu_type(MXC_CPU_MX6DP))
 #define is_mx6dq() (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
@@ -41,6 +42,8 @@
 
 #define is_mx7ulp() (is_cpu_type(MXC_CPU_MX7ULP))
 
+#define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
+
 #ifdef CONFIG_MX6
 #define IMX6_SRC_GPR10_BMODE   BIT(28)
 
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 10/32] imx: boot_mode: Add FLEXSPI boot entry

2018-07-17 Thread Peng Fan
i.MX8 support FLEXSPI boot support. So add FLEXSPI boot entry.

Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/mach-imx/boot_mode.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/mach-imx/boot_mode.h 
b/arch/arm/include/asm/mach-imx/boot_mode.h
index 8766e9d180..3a483b6afa 100644
--- a/arch/arm/include/asm/mach-imx/boot_mode.h
+++ b/arch/arm/include/asm/mach-imx/boot_mode.h
@@ -25,6 +25,7 @@ enum boot_device {
MMC4_BOOT,
NAND_BOOT,
QSPI_BOOT,
+   FLEXSPI_BOOT,
USB_BOOT,
UNKNOWN_BOOT,
BOOT_DEV_NUM = UNKNOWN_BOOT,
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 12/32] imx8: pins: include i.MX8QXP pin header when CONFIG_IMX8QXP defined

2018-07-17 Thread Peng Fan
Include i.MX8QXP pin header when CONFIG_IMX8QXP defined,
if no SoC macro defined, report error.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/imx8-pins.h | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/imx8-pins.h

diff --git a/arch/arm/include/asm/arch-imx8/imx8-pins.h 
b/arch/arm/include/asm/arch-imx8/imx8-pins.h
new file mode 100644
index 00..dcced1010b
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/imx8-pins.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_PINS_H__
+#define __ASM_ARCH_IMX8_PINS_H__
+
+#if defined(CONFIG_IMX8QXP)
+#include 
+#else
+#error "No pin header"
+#endif
+
+#endif /* __ASM_ARCH_IMX8_PINS_H__ */
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 15/32] imx8: add basic cpu support

2018-07-17 Thread Peng Fan
Add basic cpu support, including cpu revision, cpu type,
cpu core detection.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/mach-imx/imx8/Makefile |  7 
 arch/arm/mach-imx/imx8/cpu.c| 93 +
 2 files changed, 100 insertions(+)
 create mode 100644 arch/arm/mach-imx/imx8/Makefile
 create mode 100644 arch/arm/mach-imx/imx8/cpu.c

diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile
new file mode 100644
index 00..57876139a1
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright 2018 NXP
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-y += cpu.o
diff --git a/arch/arm/mach-imx/imx8/cpu.c b/arch/arm/mach-imx/imx8/cpu.c
new file mode 100644
index 00..0b841e291d
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/cpu.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+u32 get_cpu_rev(void)
+{
+   u32 id = 0, rev = 0;
+   int ret;
+
+   ret = sc_misc_get_control(-1, SC_R_SYSTEM, SC_C_ID, );
+   if (ret)
+   return 0;
+
+   rev = (id >> 5)  & 0xf;
+   id = (id & 0x1f) + MXC_SOC_IMX8;  /* Dummy ID for chip */
+
+   return (id << 12) | rev;
+}
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+const char *get_imx8_type(u32 imxtype)
+{
+   switch (imxtype) {
+   case MXC_CPU_IMX8QXP:
+   return "8QXP";
+   default:
+   return "??";
+   }
+}
+
+const char *get_imx8_rev(u32 rev)
+{
+   switch (rev) {
+   case CHIP_REV_A:
+   return "A";
+   case CHIP_REV_B:
+   return "B";
+   default:
+   return "?";
+   }
+}
+
+const char *get_core_name(void)
+{
+   if (is_cortex_a35())
+   return "A35";
+   else
+   return "?";
+}
+
+int print_cpuinfo(void)
+{
+   struct udevice *dev;
+   struct clk cpu_clk;
+   int ret;
+
+   ret = uclass_get_device(UCLASS_CPU, 0, );
+   if (ret)
+   return 0;
+
+   ret = clk_get_by_index(dev, 0, _clk);
+   if (ret) {
+   dev_err(dev, "failed to clk\n");
+   return 0;
+   }
+
+   u32 cpurev;
+
+   cpurev = get_cpu_rev();
+
+   printf("CPU:   Freescale i.MX%s rev%s %s at %ld MHz\n",
+  get_imx8_type((cpurev & 0xFF000) >> 12),
+  get_imx8_rev((cpurev & 0xFFF)),
+  get_core_name(),
+  clk_get_rate(_clk) / 100);
+
+   return 0;
+}
+#endif
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 08/32] misc: imx8: add scfw api impementation

2018-07-17 Thread Peng Fan
Add clk/misc/pad/pm/rm scfw api implementaion for different
drivers to invoke. The low level code is using misc_call
to invoke imx8_scu driver.

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/sci/sci.h | 31 +-
 drivers/misc/imx8/Makefile   |  2 +-
 drivers/misc/imx8/clk.c  | 93 ++
 drivers/misc/imx8/misc.c | 88 +
 drivers/misc/imx8/pad.c  | 39 +
 drivers/misc/imx8/pm.c   | 38 +
 drivers/misc/imx8/rm.c   | 97 
 7 files changed, 386 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/imx8/clk.c
 create mode 100644 drivers/misc/imx8/misc.c
 create mode 100644 drivers/misc/imx8/pad.c
 create mode 100644 drivers/misc/imx8/pm.c
 create mode 100644 drivers/misc/imx8/rm.c

diff --git a/arch/arm/include/asm/arch-imx8/sci/sci.h 
b/arch/arm/include/asm/arch-imx8/sci/sci.h
index b7280aee05..4704ba9699 100644
--- a/arch/arm/include/asm/arch-imx8/sci/sci.h
+++ b/arch/arm/include/asm/arch-imx8/sci/sci.h
@@ -46,7 +46,8 @@ static inline int sc_err_to_linux(sc_err_t err)
ret = -EIO;
break;
default:
-   panic("Invalid sc_err_t value\n");
+   ret = 0;
+   break;
}
 
debug("%s %d %d\n", __func__, err, ret);
@@ -54,4 +55,32 @@ static inline int sc_err_to_linux(sc_err_t err)
return ret;
 }
 
+/* PM API*/
+int sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
+ sc_pm_power_mode_t mode);
+int sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate);
+int sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate);
+int sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate);
+int sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate);
+int sc_pm_clock_enable(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+  sc_bool_t enable, sc_bool_t autog);
+
+/* MISC API */
+int sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, sc_ctrl_t ctrl,
+   u32 *val);
+void sc_misc_get_boot_dev(sc_ipc_t ipc, sc_rsrc_t *boot_dev);
+void sc_misc_boot_status(sc_ipc_t ipc, sc_misc_boot_status_t status);
+
+/* RM API */
+sc_bool_t sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr);
+int sc_rm_get_memreg_info(sc_ipc_t ipc, sc_rm_mr_t mr, sc_faddr_t *addr_start,
+ sc_faddr_t *addr_end);
+sc_bool_t sc_rm_is_resource_owned(sc_ipc_t ipc, sc_rsrc_t resource);
+
+/* PAD API */
+int sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, u32 val);
 #endif
diff --git a/drivers/misc/imx8/Makefile b/drivers/misc/imx8/Makefile
index 3395340d22..4fc08ade50 100644
--- a/drivers/misc/imx8/Makefile
+++ b/drivers/misc/imx8/Makefile
@@ -1,3 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0+
 
-obj-y += scu.o
+obj-y += pm.o clk.o misc.o pad.o rm.o scu.o
diff --git a/drivers/misc/imx8/clk.c b/drivers/misc/imx8/clk.c
new file mode 100644
index 00..618b2c386f
--- /dev/null
+++ b/drivers/misc/imx8/clk.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2018 NXP
+ *
+ * Peng Fan 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate)
+{
+   struct udevice *dev = gd->arch.scu_dev;
+   int size = sizeof(sc_rpc_msg_t);
+   sc_rpc_msg_t msg;
+   int ret;
+
+   RPC_VER() = SC_RPC_VERSION;
+   RPC_SVC() = (u8)SC_RPC_SVC_PM;
+   RPC_FUNC() = (u8)PM_FUNC_SET_CLOCK_RATE;
+   RPC_U32(, 0U) = *(u32 *)rate;
+   RPC_U16(, 4U) = (u16)resource;
+   RPC_U8(, 6U) = (u8)clk;
+   RPC_SIZE() = 3U;
+
+   ret = misc_call(dev, SC_FALSE, , size, , size);
+   if (ret)
+   printf("%s: rate:%u resource:%u: clk:%u res:%d\n",
+  __func__, *rate, resource, clk, RPC_R8());
+
+   *rate = RPC_U32(, 0U);
+
+   return ret;
+}
+
+int sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
+sc_pm_clock_rate_t *rate)
+{
+   struct udevice *dev = gd->arch.scu_dev;
+   int size = sizeof(sc_rpc_msg_t);
+   sc_rpc_msg_t msg;
+   int ret;
+
+   RPC_VER() = SC_RPC_VERSION;
+   RPC_SVC() = (u8)SC_RPC_SVC_PM;
+   RPC_FUNC() = (u8)PM_FUNC_GET_CLOCK_RATE;
+   RPC_U16(, 0U) = (u16)resource;
+   RPC_U8(, 2U) = (u8)clk;
+   RPC_SIZE() = 2U;
+
+   ret = misc_call(dev, SC_FALSE, , size, , size);
+   if (ret) {
+   printf("%s: resource:%d clk:%d: 

[U-Boot] [PATCH V2 11/32] imx8: add imx-regs header file

2018-07-17 Thread Peng Fan
Add imx-regs header file to include the register base definition

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/include/asm/arch-imx8/imx-regs.h | 46 +++
 1 file changed, 46 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/imx-regs.h

diff --git a/arch/arm/include/asm/arch-imx8/imx-regs.h 
b/arch/arm/include/asm/arch-imx8/imx-regs.h
new file mode 100644
index 00..af0fb5154b
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/imx-regs.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __ASM_ARCH_IMX8_REGS_H__
+#define __ASM_ARCH_IMX8_REGS_H__
+
+#define LPUART_BASE0x5A06
+
+#define GPT1_BASE_ADDR 0x5D14
+#define SCU_LPUART_BASE0x3322
+#define GPIO1_BASE_ADDR0x5D08
+#define GPIO2_BASE_ADDR0x5D09
+#define GPIO3_BASE_ADDR0x5D0A
+#define GPIO4_BASE_ADDR0x5D0B
+#define GPIO5_BASE_ADDR0x5D0C
+#define GPIO6_BASE_ADDR0x5D0D
+#define GPIO7_BASE_ADDR0x5D0E
+#define GPIO8_BASE_ADDR0x5D0F
+#define LPI2C1_BASE_ADDR   0x5A80
+#define LPI2C2_BASE_ADDR   0x5A81
+#define LPI2C3_BASE_ADDR   0x5A82
+#define LPI2C4_BASE_ADDR   0x5A83
+#define LPI2C5_BASE_ADDR   0x5A84
+
+#ifdef CONFIG_IMX8QXP
+#define LVDS0_PHYCTRL_BASE 0x56221000
+#define LVDS1_PHYCTRL_BASE 0x56241000
+#define MIPI0_SS_BASE  0x5622
+#define MIPI1_SS_BASE  0x5624
+#endif
+
+#define APBH_DMA_ARB_BASE_ADDR 0x5B81
+#define APBH_DMA_ARB_END_ADDR  0x5B81
+#define MXS_APBH_BASE  APBH_DMA_ARB_BASE_ADDR
+
+#define MXS_GPMI_BASE  (APBH_DMA_ARB_BASE_ADDR + 0x02000)
+#define MXS_BCH_BASE   (APBH_DMA_ARB_BASE_ADDR + 0x04000)
+
+#define PASS_OVER_INFO_ADDR0x0010fe00
+
+#define USB_BASE_ADDR  0x5b0d
+#define USB_PHY0_BASE_ADDR 0x5b10
+
+#endif /* __ASM_ARCH_IMX8_REGS_H__ */
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 06/32] arm: build mach-imx for i.MX8

2018-07-17 Thread Peng Fan
Build mach-imx for i.MX8

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index cac58bdc4d..40c8f6fe13 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -104,7 +104,7 @@ ifneq (,$(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_MX35)$(filter 
$(SOC), mx25 mx5 mx6
 libs-y += arch/arm/mach-imx/
 endif
 else
-ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs mx8m 
vf610))
+ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx7 mx7ulp mx31 mx35 mxs mx8m imx8 
vf610))
 libs-y += arch/arm/mach-imx/
 endif
 endif
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 05/32] imx: add Kconfig entry for i.MX8QXP

2018-07-17 Thread Peng Fan
Add Kconfig entry for i.MX8QXP

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 arch/arm/Kconfig   | 8 
 arch/arm/mach-imx/Makefile | 1 +
 arch/arm/mach-imx/imx8/Kconfig | 9 +
 3 files changed, 18 insertions(+)
 create mode 100644 arch/arm/mach-imx/imx8/Kconfig

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5b3746c80b..9fab3b8466 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -655,6 +655,12 @@ config ARCH_MESON
  targeted at media players and tablet computers. We currently
  support the S905 (GXBaby) 64-bit SoC.
 
+config ARCH_IMX8
+   bool "NXP i.MX8 platform"
+   select ARM64
+   select DM
+   select OF_CONTROL
+
 config ARCH_MX8M
bool "NXP i.MX8M platform"
select ARM64
@@ -1368,6 +1374,8 @@ source "arch/arm/mach-imx/mx7/Kconfig"
 
 source "arch/arm/mach-imx/mx7ulp/Kconfig"
 
+source "arch/arm/mach-imx/imx8/Kconfig"
+
 source "arch/arm/mach-imx/mx8m/Kconfig"
 
 source "arch/arm/mach-imx/mxs/Kconfig"
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 733c308670..375789efb2 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -141,3 +141,4 @@ obj-$(CONFIG_MX6) += mx6/
 obj-$(CONFIG_MX7) += mx7/
 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
 obj-$(CONFIG_MX8M) += mx8m/
+obj-$(CONFIG_ARCH_IMX8) += imx8/
diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig
new file mode 100644
index 00..4117b39da9
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/Kconfig
@@ -0,0 +1,9 @@
+if ARCH_IMX8
+
+config IMX8QXP
+   bool
+
+config SYS_SOC
+   default "imx8"
+
+endif
-- 
2.14.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH V2 04/32] imx8: add scfw macro definition

2018-07-17 Thread Peng Fan
Add SCFW macro definition.

Signed-off-by: Peng Fan 
---
 arch/arm/include/asm/arch-imx8/sci/rpc.h  | 159 
 arch/arm/include/asm/arch-imx8/sci/sci.h  |  57 ++
 arch/arm/include/asm/arch-imx8/sci/svc/misc/api.h |  30 +++
 arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h  |  57 ++
 arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h   |  44 +
 arch/arm/include/asm/arch-imx8/sci/svc/rm/api.h   |  69 +++
 arch/arm/include/asm/arch-imx8/sci/types.h| 220 ++
 7 files changed, 636 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/rpc.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/sci.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/svc/misc/api.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/svc/rm/api.h
 create mode 100644 arch/arm/include/asm/arch-imx8/sci/types.h

diff --git a/arch/arm/include/asm/arch-imx8/sci/rpc.h 
b/arch/arm/include/asm/arch-imx8/sci/rpc.h
new file mode 100644
index 00..26f6b9dd97
--- /dev/null
+++ b/arch/arm/include/asm/arch-imx8/sci/rpc.h
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2017-2018 NXP
+ *
+ */
+
+#ifndef SC_RPC_H
+#define SC_RPC_H
+
+/* Note: Check SCFW API Released DOC before you want to modify something */
+#define SC_RPC_VERSION  1U
+
+#define SC_RPC_MAX_MSG  8U
+
+#define RPC_VER(MSG)((MSG)->version)
+#define RPC_SIZE(MSG)   ((MSG)->size)
+#define RPC_SVC(MSG)((MSG)->svc)
+#define RPC_FUNC(MSG)   ((MSG)->func)
+#define RPC_R8(MSG) ((MSG)->func)
+#define RPC_I32(MSG, IDX)   ((MSG)->DATA.i32[(IDX) / 4U])
+#define RPC_I16(MSG, IDX)   ((MSG)->DATA.i16[(IDX) / 2U])
+#define RPC_I8(MSG, IDX)((MSG)->DATA.i8[(IDX)])
+#define RPC_U32(MSG, IDX)   ((MSG)->DATA.u32[(IDX) / 4U])
+#define RPC_U16(MSG, IDX)   ((MSG)->DATA.u16[(IDX) / 2U])
+#define RPC_U8(MSG, IDX)((MSG)->DATA.u8[(IDX)])
+
+#define SC_RPC_SVC_UNKNOWN  0U
+#define SC_RPC_SVC_RETURN   1U
+#define SC_RPC_SVC_PM   2U
+#define SC_RPC_SVC_RM   3U
+#define SC_RPC_SVC_TIMER5U
+#define SC_RPC_SVC_PAD  6U
+#define SC_RPC_SVC_MISC 7U
+#define SC_RPC_SVC_IRQ  8U
+#define SC_RPC_SVC_ABORT9U
+
+/* Types */
+
+typedef struct sc_rpc_msg_s {
+   u8 version;
+   u8 size;
+   u8 svc;
+   u8 func;
+   union {
+   s32 i32[(SC_RPC_MAX_MSG - 1U)];
+   s16 i16[(SC_RPC_MAX_MSG - 1U) * 2U];
+   s8 i8[(SC_RPC_MAX_MSG - 1U) * 4U];
+   u32 u32[(SC_RPC_MAX_MSG - 1U)];
+   u16 u16[(SC_RPC_MAX_MSG - 1U) * 2U];
+   u8 u8[(SC_RPC_MAX_MSG - 1U) * 4U];
+   } DATA;
+} sc_rpc_msg_t;
+
+/* PM RPC */
+#define PM_FUNC_UNKNOWN0
+#define PM_FUNC_SET_SYS_POWER_MODE 19U
+#define PM_FUNC_SET_PARTITION_POWER_MODE   1U
+#define PM_FUNC_GET_SYS_POWER_MODE 2U
+#define PM_FUNC_SET_RESOURCE_POWER_MODE3U
+#define PM_FUNC_GET_RESOURCE_POWER_MODE4U
+#define PM_FUNC_REQ_LOW_POWER_MODE 16U
+#define PM_FUNC_REQ_CPU_LOW_POWER_MODE 20U
+#define PM_FUNC_SET_CPU_RESUME_ADDR17U
+#define PM_FUNC_SET_CPU_RESUME 21U
+#define PM_FUNC_REQ_SYS_IF_POWER_MODE  18U
+#define PM_FUNC_SET_CLOCK_RATE 5U
+#define PM_FUNC_GET_CLOCK_RATE 6U
+#define PM_FUNC_CLOCK_ENABLE   7U
+#define PM_FUNC_SET_CLOCK_PARENT   14U
+#define PM_FUNC_GET_CLOCK_PARENT   15U
+#define PM_FUNC_RESET  13U
+#define PM_FUNC_RESET_REASON   10U
+#define PM_FUNC_BOOT   8U
+#define PM_FUNC_REBOOT 9U
+#define PM_FUNC_REBOOT_PARTITION   12U
+#define PM_FUNC_CPU_START  11U
+
+/* MISC RPC */
+#define MISC_FUNC_UNKNOWN  0
+#define MISC_FUNC_SET_CONTROL  1U
+#define MISC_FUNC_GET_CONTROL  2U
+#define MISC_FUNC_SET_MAX_DMA_GROUP4U
+#define MISC_FUNC_SET_DMA_GROUP5U
+#define MISC_FUNC_SECO_IMAGE_LOAD  8U
+#define MISC_FUNC_SECO_AUTHENTICATE9U
+#define MISC_FUNC_SECO_FUSE_WRITE  20U
+#define MISC_FUNC_SECO_ENABLE_DEBUG21U
+#define MISC_FUNC_SECO_FORWARD_LIFECYCLE   22U
+#define MISC_FUNC_SECO_RETURN_LIFECYCLE23U
+#define MISC_FUNC_SECO_BUILD_INFO  24U
+#define MISC_FUNC_DEBUG_OUT10U
+#define MISC_FUNC_WAVEFORM_CAPTURE 6U
+#define MISC_FUNC_BUILD_INFO   15U
+#define MISC_FUNC_UNIQUE_ID19U
+#define MISC_FUNC_SET_ARI

[U-Boot] [PATCH V2 03/32] dt-bindings: soc: add i.MX8QXP pm and rsrc definition

2018-07-17 Thread Peng Fan
Add i.MX8QXP power and resource definition

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 include/dt-bindings/soc/imx8_pd.h  | 188 +
 include/dt-bindings/soc/imx_rsrc.h | 557 +
 2 files changed, 745 insertions(+)
 create mode 100644 include/dt-bindings/soc/imx8_pd.h
 create mode 100644 include/dt-bindings/soc/imx_rsrc.h

diff --git a/include/dt-bindings/soc/imx8_pd.h 
b/include/dt-bindings/soc/imx8_pd.h
new file mode 100644
index 00..682b608eef
--- /dev/null
+++ b/include/dt-bindings/soc/imx8_pd.h
@@ -0,0 +1,188 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __DT_BINDINGS_IMX8_PD_H
+#define __DT_BINDINGS_IMX8_PD_H
+
+/*!
+ * These defines are used to indicate a resource. Resources include peripherals
+ * and bus masters (but not memory regions). Note items from list should
+ * never be changed or removed (only added to at the end of the list).
+ */
+#define PD_DC_0 dc0_power_domain
+#define PD_DC_0_PLL_0   dc0_pll0
+#define PD_DC_0_PLL_1   dc0_pll1
+#define PD_LVDS0lvds0_power_domain
+#define PD_LVDS0_I2C0   lvds0_i2c0
+#define PD_LVDS0_I2C1   lvds0_i2c1
+#define PD_LVDS0_PWMlvds0_pwm
+#define PD_LVDS0_PWMlvds0_pwm
+#define PD_LVDS0_GPIO   lvds0_gpio
+#define PD_DC_1 dc1_power_domain
+#define PD_DC_1_PLL_0   dc1_pll0
+#define PD_DC_1_PLL_1   dc1_pll1
+#define PD_LVDS1lvds1_power_domain
+#define PD_LVDS1_I2C0   lvds1_i2c0
+#define PD_LVDS1_I2C1   lvds1_i2c1
+#define PD_LVDS1_PWMlvds1_pwm
+#define PD_LVDS1_GPIO   lvds1_gpio
+
+#define PD_DMA  dma_power_domain
+#define PD_DMA_SPI_0dma_spi0
+#define PD_DMA_SPI_1dma_spi1
+#define PD_DMA_SPI_2dma_spi2
+#define PD_DMA_SPI_3dma_spi3
+#define PD_DMA_UART0dma_lpuart0
+#define PD_DMA_UART1dma_lpuart1
+#define PD_DMA_UART2dma_lpuart2
+#define PD_DMA_UART3dma_lpuart3
+#define PD_DMA_UART4dma_lpuart4
+#define PD_DMA_EMVSIM_0 dma_emvsim0
+#define PD_DMA_EMVSIM_1 dma_emvsim1
+#define PD_DMA_I2C_0dma_lpi2c0
+#define PD_DMA_I2C_1dma_lpi2c1
+#define PD_DMA_I2C_2dma_lpi2c2
+#define PD_DMA_I2C_3dma_lpi2c3
+#define PD_DMA_I2C_4dma_lpi2c4
+#define PD_DMA_ADC_0dma_adc0
+#define PD_DMA_ADC_1dma_adc1
+#define PD_DMA_FTM_0dma_ftm0
+#define PD_DMA_FTM_1dma_ftm1
+#define PD_DMA_CAN_0dma_flexcan0
+#define PD_DMA_CAN_1dma_flexcan1
+#define PD_DMA_CAN_2dma_flexcan2
+#define PD_DMA_PWM_0dma_pwm0
+#define PD_DMA_LCD_0dma_lcd0
+
+#define PD_HSIO hsio_power_domain
+#define PD_HSIO_PCIE_A  hsio_pcie0
+#define PD_HSIO_PCIE_B  hsio_pcie1
+#define PD_HSIO_SATA_0  hsio_sata0
+#define PD_HSIO_GPIOhsio_gpio
+
+#define PD_LCD_0lcd0_power_domain
+#define PD_LCD_0_I2C_0  lcd0_i2c0
+#define PD_LCD_0_I2C_1  lcd0_i2c1
+#define PD_LCD_PWM_0lcd0_pwm0
+
+#define PD_LSIO lsio_power_domain
+#define PD_LSIO_GPIO_0  lsio_gpio0
+#define PD_LSIO_GPIO_1  lsio_gpio1
+#define PD_LSIO_GPIO_2  lsio_gpio2
+#define PD_LSIO_GPIO_3  lsio_gpio3
+#define PD_LSIO_GPIO_4  lsio_gpio4
+#define PD_LSIO_GPIO_5  lsio_gpio5
+#define PD_LSIO_GPIO_6  lsio_gpio6
+#define PD_LSIO_GPIO_7  lsio_gpio7
+#define PD_LSIO_GPT_0   lsio_gpt0
+#define PD_LSIO_GPT_1   lsio_gpt1
+#define PD_LSIO_GPT_2   lsio_gpt2
+#define PD_LSIO_GPT_3   lsio_gpt3
+#define PD_LSIO_GPT_4   lsio_gpt4
+#define PD_LSIO_KPP lsio_kpp
+#define PD_LSIO_FSPI_0  lsio_fspi0
+#define PD_LSIO_FSPI_1  lsio_fspi1
+#define PD_LSIO_PWM_0   lsio_pwm0
+#define PD_LSIO_PWM_1   lsio_pwm1
+#define PD_LSIO_PWM_2   lsio_pwm2
+#define PD_LSIO_PWM_3   lsio_pwm3
+#define PD_LSIO_PWM_4   lsio_pwm4
+#define PD_LSIO_PWM_5   lsio_pwm5
+#define PD_LSIO_PWM_6   lsio_pwm6
+#define PD_LSIO_PWM_7   lsio_pwm7
+
+#define PD_CONN connectivity_power_domain
+#define PD_CONN_SDHC_0  conn_sdhc0
+#define PD_CONN_SDHC_1  conn_sdhc1
+#define PD_CONN_SDHC_2  conn_sdhc2
+#define PD_CONN_ENET_0  conn_enet0
+#define PD_CONN_ENET_1  conn_enet1
+#define 

[U-Boot] [PATCH V2 02/32] dt-bindings: clock: dt-bindings: pinctrl: add i.MX8QXP clocks definition

2018-07-17 Thread Peng Fan
Add i.MX8QXP clocks definition

Signed-off-by: Peng Fan 
---
 include/dt-bindings/clock/imx8qxp-clock.h | 583 ++
 1 file changed, 583 insertions(+)
 create mode 100644 include/dt-bindings/clock/imx8qxp-clock.h

diff --git a/include/dt-bindings/clock/imx8qxp-clock.h 
b/include/dt-bindings/clock/imx8qxp-clock.h
new file mode 100644
index 00..d0334ea398
--- /dev/null
+++ b/include/dt-bindings/clock/imx8qxp-clock.h
@@ -0,0 +1,583 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_IMX8QXP_H
+#define __DT_BINDINGS_CLOCK_IMX8QXP_H
+
+#define IMX8QXP_CLK_DUMMY  0
+
+#define IMX8QXP_UART0_IPG_CLK  1
+#define IMX8QXP_UART0_DIV  2
+#define IMX8QXP_UART0_CLK  3
+
+#define IMX8QXP_IPG_DMA_CLK_ROOT   4
+
+/* GPU Clocks. */
+#define IMX8QXP_GPU0_CORE_DIV  5
+#define IMX8QXP_GPU0_CORE_CLK  6
+#define IMX8QXP_GPU0_SHADER_DIV7
+#define IMX8QXP_GPU0_SHADER_CLK8
+
+#define IMX8QXP_24MHZ  9
+#define IMX8QXP_GPT_3M 10
+#define IMX8QXP_32KHZ  11
+
+/* LSIO SS */
+#define IMX8QXP_LSIO_MEM_CLK   12
+#define IMX8QXP_LSIO_BUS_CLK   13
+#define IMX8QXP_LSIO_PWM0_DIV  14
+#define IMX8QXP_LSIO_PWM0_IPG_S_CLK15
+#define IMX8QXP_LSIO_PWM0_IPG_SLV_CLK  16
+#define IMX8QXP_LSIO_PWM0_IPG_MSTR_CLK 17
+#define IMX8QXP_LSIO_PWM0_HF_CLK   18
+#define IMX8QXP_LSIO_PWM0_CLK  19
+#define IMX8QXP_LSIO_PWM1_DIV  20
+#define IMX8QXP_LSIO_PWM1_IPG_S_CLK21
+#define IMX8QXP_LSIO_PWM1_IPG_SLV_CLK  22
+#define IMX8QXP_LSIO_PWM1_IPG_MSTR_CLK 23
+#define IMX8QXP_LSIO_PWM1_HF_CLK   24
+#define IMX8QXP_LSIO_PWM1_CLK  25
+#define IMX8QXP_LSIO_PWM2_DIV  26
+#define IMX8QXP_LSIO_PWM2_IPG_S_CLK27
+#define IMX8QXP_LSIO_PWM2_IPG_SLV_CLK  28
+#define IMX8QXP_LSIO_PWM2_IPG_MSTR_CLK 29
+#define IMX8QXP_LSIO_PWM2_HF_CLK   30
+#define IMX8QXP_LSIO_PWM2_CLK  31
+#define IMX8QXP_LSIO_PWM3_DIV  32
+#define IMX8QXP_LSIO_PWM3_IPG_S_CLK33
+#define IMX8QXP_LSIO_PWM3_IPG_SLV_CLK  34
+#define IMX8QXP_LSIO_PWM3_IPG_MSTR_CLK 35
+#define IMX8QXP_LSIO_PWM3_HF_CLK   36
+#define IMX8QXP_LSIO_PWM3_CLK  37
+#define IMX8QXP_LSIO_PWM4_DIV  38
+#define IMX8QXP_LSIO_PWM4_IPG_S_CLK39
+#define IMX8QXP_LSIO_PWM4_IPG_SLV_CLK  40
+#define IMX8QXP_LSIO_PWM4_IPG_MSTR_CLK 42
+#define IMX8QXP_LSIO_PWM4_HF_CLK   43
+#define IMX8QXP_LSIO_PWM4_CLK  44
+#define IMX8QXP_LSIO_PWM5_DIV  45
+#define IMX8QXP_LSIO_PWM5_IPG_S_CLK46
+#define IMX8QXP_LSIO_PWM5_IPG_SLV_CLK  47
+#define IMX8QXP_LSIO_PWM5_IPG_MSTR_CLK 48
+#define IMX8QXP_LSIO_PWM5_HF_CLK   49
+#define IMX8QXP_LSIO_PWM5_CLK  50
+#define IMX8QXP_LSIO_PWM6_DIV  51
+#define IMX8QXP_LSIO_PWM6_IPG_S_CLK52
+#define IMX8QXP_LSIO_PWM6_IPG_SLV_CLK  53
+#define IMX8QXP_LSIO_PWM6_IPG_MSTR_CLK 54
+#define IMX8QXP_LSIO_PWM6_HF_CLK   55
+#define IMX8QXP_LSIO_PWM6_CLK  56
+#define IMX8QXP_LSIO_PWM7_DIV  57
+#define IMX8QXP_LSIO_PWM7_IPG_S_CLK58
+#define IMX8QXP_LSIO_PWM7_IPG_SLV_CLK  59
+#define IMX8QXP_LSIO_PWM7_IPG_MSTR_CLK 60
+#define IMX8QXP_LSIO_PWM7_HF_CLK   61
+#define IMX8QXP_LSIO_PWM7_CLK  62
+#define IMX8QXP_LSIO_GPT0_DIV  63
+#define IMX8QXP_LSIO_GPT0_IPG_S_CLK64
+#define 

[U-Boot] [PATCH V2 01/32] dt-bindings: pinctrl: add i.MX8QXP pads definition

2018-07-17 Thread Peng Fan
Add i.MX8QXP pads definition

Signed-off-by: Peng Fan 
Cc: Stefano Babic 
---
 include/dt-bindings/pinctrl/pads-imx8qxp.h | 757 +
 1 file changed, 757 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/pads-imx8qxp.h

diff --git a/include/dt-bindings/pinctrl/pads-imx8qxp.h 
b/include/dt-bindings/pinctrl/pads-imx8qxp.h
new file mode 100644
index 00..41f4fe564c
--- /dev/null
+++ b/include/dt-bindings/pinctrl/pads-imx8qxp.h
@@ -0,0 +1,757 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef _SC_PADS_H
+#define _SC_PADS_H
+
+#define SC_P_PCIE_CTRL0_PERST_B  0 /* HSIO.PCIE0.PERST_B, 
LSIO.GPIO4.IO00 */
+#define SC_P_PCIE_CTRL0_CLKREQ_B 1 /* HSIO.PCIE0.CLKREQ_B, 
LSIO.GPIO4.IO01 */
+#define SC_P_PCIE_CTRL0_WAKE_B   2 /* HSIO.PCIE0.WAKE_B, 
LSIO.GPIO4.IO02 */
+#define SC_P_COMP_CTL_GPIO_1V8_3V3_PCIESEP   3 /*  */
+#define SC_P_USB_SS3_TC0 4 /* ADMA.I2C1.SCL, 
CONN.USB_OTG1.PWR, CONN.USB_OTG2.PWR, LSIO.GPIO4.IO03 */
+#define SC_P_USB_SS3_TC1 5 /* ADMA.I2C1.SCL, 
CONN.USB_OTG2.PWR, LSIO.GPIO4.IO04 */
+#define SC_P_USB_SS3_TC2 6 /* ADMA.I2C1.SDA, 
CONN.USB_OTG1.OC, CONN.USB_OTG2.OC, LSIO.GPIO4.IO05 */
+#define SC_P_USB_SS3_TC3 7 /* ADMA.I2C1.SDA, 
CONN.USB_OTG2.OC, LSIO.GPIO4.IO06 */
+#define SC_P_COMP_CTL_GPIO_3V3_USB3IO8 /*  */
+#define SC_P_EMMC0_CLK   9 /* CONN.EMMC0.CLK, 
CONN.NAND.READY_B, LSIO.GPIO4.IO07 */
+#define SC_P_EMMC0_CMD   10/* CONN.EMMC0.CMD, 
CONN.NAND.DQS, LSIO.GPIO4.IO08 */
+#define SC_P_EMMC0_DATA0 11/* CONN.EMMC0.DATA0, 
CONN.NAND.DATA00, LSIO.GPIO4.IO09 */
+#define SC_P_EMMC0_DATA1 12/* CONN.EMMC0.DATA1, 
CONN.NAND.DATA01, LSIO.GPIO4.IO10 */
+#define SC_P_EMMC0_DATA2 13/* CONN.EMMC0.DATA2, 
CONN.NAND.DATA02, LSIO.GPIO4.IO11 */
+#define SC_P_EMMC0_DATA3 14/* CONN.EMMC0.DATA3, 
CONN.NAND.DATA03, LSIO.GPIO4.IO12 */
+#define SC_P_COMP_CTL_GPIO_1V8_3V3_SD1FIX0   15/*  */
+#define SC_P_EMMC0_DATA4 16/* CONN.EMMC0.DATA4, 
CONN.NAND.DATA04, CONN.EMMC0.WP, LSIO.GPIO4.IO13 */
+#define SC_P_EMMC0_DATA5 17/* CONN.EMMC0.DATA5, 
CONN.NAND.DATA05, CONN.EMMC0.VSELECT, LSIO.GPIO4.IO14 */
+#define SC_P_EMMC0_DATA6 18/* CONN.EMMC0.DATA6, 
CONN.NAND.DATA06, CONN.MLB.CLK, LSIO.GPIO4.IO15 */
+#define SC_P_EMMC0_DATA7 19/* CONN.EMMC0.DATA7, 
CONN.NAND.DATA07, CONN.MLB.SIG, LSIO.GPIO4.IO16 */
+#define SC_P_EMMC0_STROBE20/* CONN.EMMC0.STROBE, 
CONN.NAND.CLE, CONN.MLB.DATA, LSIO.GPIO4.IO17 */
+#define SC_P_EMMC0_RESET_B   21/* CONN.EMMC0.RESET_B, 
CONN.NAND.WP_B, LSIO.GPIO4.IO18 */
+#define SC_P_COMP_CTL_GPIO_1V8_3V3_SD1FIX1   22/*  */
+#define SC_P_USDHC1_RESET_B  23/* CONN.USDHC1.RESET_B, 
CONN.NAND.RE_N, ADMA.SPI2.SCK, LSIO.GPIO4.IO19 */
+#define SC_P_USDHC1_VSELECT  24/* CONN.USDHC1.VSELECT, 
CONN.NAND.RE_P, ADMA.SPI2.SDO, CONN.NAND.RE_B, LSIO.GPIO4.IO20 */
+#define SC_P_CTL_NAND_RE_P_N 25/*  */
+#define SC_P_USDHC1_WP   26/* CONN.USDHC1.WP, 
CONN.NAND.DQS_N, ADMA.SPI2.SDI, LSIO.GPIO4.IO21 */
+#define SC_P_USDHC1_CD_B 27/* CONN.USDHC1.CD_B, 
CONN.NAND.DQS_P, ADMA.SPI2.CS0, CONN.NAND.DQS, LSIO.GPIO4.IO22 */
+#define SC_P_CTL_NAND_DQS_P_N28/*  */
+#define SC_P_COMP_CTL_GPIO_1V8_3V3_VSELSEP   29/*  */
+#define SC_P_USDHC1_CLK  30/* CONN.USDHC1.CLK, 
ADMA.UART3.RX, LSIO.GPIO4.IO23 */
+#define SC_P_USDHC1_CMD  31/* CONN.USDHC1.CMD, 
CONN.NAND.CE0_B, ADMA.MQS.R, LSIO.GPIO4.IO24 */
+#define SC_P_USDHC1_DATA032/* CONN.USDHC1.DATA0, 
CONN.NAND.CE1_B, ADMA.MQS.L, LSIO.GPIO4.IO25 */
+#define SC_P_USDHC1_DATA133/* CONN.USDHC1.DATA1, 
CONN.NAND.RE_B, ADMA.UART3.TX, LSIO.GPIO4.IO26 */
+#define SC_P_USDHC1_DATA234/* CONN.USDHC1.DATA2, 
CONN.NAND.WE_B, ADMA.UART3.CTS_B, LSIO.GPIO4.IO27 */
+#define SC_P_USDHC1_DATA335/* CONN.USDHC1.DATA3, 
CONN.NAND.ALE, ADMA.UART3.RTS_B, LSIO.GPIO4.IO28 */
+#define SC_P_COMP_CTL_GPIO_1V8_3V3_VSEL3 36/*  */
+#define SC_P_ENET0_RGMII_TXC 37/* 
CONN.ENET0.RGMII_TXC, CONN.ENET0.RCLK50M_OUT, CONN.ENET0.RCLK50M_IN, 
CONN.NAND.CE1_B, LSIO.GPIO4.IO29 */
+#define SC_P_ENET0_RGMII_TX_CTL  38/* 
CONN.ENET0.RGMII_TX_CTL, CONN.USDHC1.RESET_B, LSIO.GPIO4.IO30 */
+#define SC_P_ENET0_RGMII_TXD039   

[U-Boot] [PATCH V2 00/32] i.MX: Add i.MX8QXP support

2018-07-17 Thread Peng Fan
This patchset is to upstream i.MX8QXP and mek board support, with some
drivers update to support i.MX8QXP. The information about the processor
could be found
https://www.nxp.com/products/processors-and-microcontrollers/applications-processors/i.mx-applications-processors/i.mx-8-processors/i.mx-8x-family-arm-cortex-a35-3d-graphics-4k-video-dsp-error-correcting-code-on-ddr:i.MX8X

The architecture of i.MX8QXP is different from i.MX6/7/8M, inside i.MX8QXP,
there is a dedicated processor(SCU) used for power/clock/pin/
pad/resource management/thermal and etc.

V2:
In this V2 patchset, the SCFW API is replaced by uclass driver
implementation, but the api name is not changed from scfw api.
The related macro definitions are kept in different api.h file
following SCFW API file structure.

Impelemnted scu misc driver to handle the low level communication
between Acore and SCU.
Implemented rm/pm/pad/misc protocol code to invoke misc_call for
different functionality.
The dm clk/pinctrl/power and others will invokde the protocol api
to communicate with SCU.

The arch/arm/mach-imx/imx8/clock.c currently is only a dummy
file to avoid build break for mxc_get_clock.

The i2c patch and common power domain patches are removed
from this patchset.

The imx8 name still kept, this is because NXP marketing
requires to use this name for i.MX branding.

Peng Fan (30):
  dt-bindings: pinctrl: add i.MX8QXP pads definition
  dt-bindings: clock: dt-bindings: pinctrl: add i.MX8QXP clocks
definition
  dt-bindings: soc: add i.MX8QXP pm and rsrc definition
  imx8: add scfw macro definition
  imx: add Kconfig entry for i.MX8QXP
  arm: build mach-imx for i.MX8
  misc: add i.MX8 misc driver
  misc: imx8: add scfw api impementation
  arm: global_data: add scu_dev for i.MX8
  imx: boot_mode: Add FLEXSPI boot entry
  imx8: add imx-regs header file
  imx8: pins: include i.MX8QXP pin header when CONFIG_IMX8QXP defined
  imx: add i.MX8 cpu type
  armv8: add cpu core helper functions
  imx8: add basic cpu support
  imx8: add boot device detection
  imx8: implement mmc_get_env_dev
  imx8: add mmu and dram related functiions
  imx8: add arch_cpu_init arch_cpu_init_dm
  imx8: add iomux configuration api
  imx8: add dummy clock
  gpio: mxc_gpio: add support for i.MX8
  pinctrl: Add pinctrl driver for i.MX8
  power: Add power domain driver for i.MX8
  clk: imx: add clk driver for i.MX8QXP
  serial_lpuart: Update lpuart driver to support i.MX8
  serial: lpuart: support uclass clk api
  mmc: fsl_esdhc: add uclass clk support
  arm: dts: introduce dtsi for i.MX8QXP
  imx: add i.MX8QXP MEK board support

Ye Li (2):
  serial: lpuart: Enable RX and TX FIFO
  fsl_esdhc: Update usdhc driver to support i.MX8

 arch/arm/Kconfig  |   8 +
 arch/arm/Makefile |   2 +-
 arch/arm/dts/Makefile |   2 +
 arch/arm/dts/fsl-imx8-ca35.dtsi   |  66 ++
 arch/arm/dts/fsl-imx8dx.dtsi  | 444 +
 arch/arm/dts/fsl-imx8dxp.dtsi |  11 +
 arch/arm/dts/fsl-imx8qxp-mek.dts  | 136 
 arch/arm/dts/fsl-imx8qxp.dtsi |  51 ++
 arch/arm/include/asm/arch-imx/cpu.h   |   5 +
 arch/arm/include/asm/arch-imx8/clock.h|  27 +
 arch/arm/include/asm/arch-imx8/gpio.h |  21 +
 arch/arm/include/asm/arch-imx8/imx-regs.h |  46 ++
 arch/arm/include/asm/arch-imx8/imx8-pins.h|  15 +
 arch/arm/include/asm/arch-imx8/iomux.h|  40 ++
 arch/arm/include/asm/arch-imx8/power-domain.h |  15 +
 arch/arm/include/asm/arch-imx8/sci/rpc.h  | 159 +
 arch/arm/include/asm/arch-imx8/sci/sci.h  |  86 +++
 arch/arm/include/asm/arch-imx8/sci/svc/misc/api.h |  30 +
 arch/arm/include/asm/arch-imx8/sci/svc/pad/api.h  |  57 ++
 arch/arm/include/asm/arch-imx8/sci/svc/pm/api.h   |  44 ++
 arch/arm/include/asm/arch-imx8/sci/svc/rm/api.h   |  69 ++
 arch/arm/include/asm/arch-imx8/sci/types.h| 220 +++
 arch/arm/include/asm/arch-imx8/sys_proto.h|  19 +
 arch/arm/include/asm/armv8/cpu.h  |  26 +
 arch/arm/include/asm/global_data.h|   4 +
 arch/arm/include/asm/mach-imx/boot_mode.h |   1 +
 arch/arm/include/asm/mach-imx/sys_proto.h |   3 +
 arch/arm/mach-imx/Makefile|   1 +
 arch/arm/mach-imx/imx8/Kconfig|  22 +
 arch/arm/mach-imx/imx8/Makefile   |   7 +
 arch/arm/mach-imx/imx8/clock.c|  21 +
 arch/arm/mach-imx/imx8/cpu.c  | 544 
 arch/arm/mach-imx/imx8/iomux.c|  43 ++
 board/freescale/imx8qxp_mek/Kconfig   |  14 +
 board/freescale/imx8qxp_mek/MAINTAINERS   |   6 +
 board/freescale/imx8qxp_mek/Makefile  |   7 +
 board/freescale/imx8qxp_mek/imx8qxp_mek.c | 152 +
 configs/imx8qxp_mek_defconfig |  

Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Tuesday, July 17, 2018 10:24 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: tr...@konsulko.com; fabio.este...@nxp.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> On Mon, 2018-07-16 at 23:56 +, Henry Beberman wrote:
> > >
> > > >
> > > > I need to revise the commit message for this patch. The script is
> > > > not fixed
> > >
> > > to the first partition of the selected MMC, it scans the disk for
> > > partitions marked bootable, then checks each one of those until it
> > > finds the imxboard_efi.fd binary.
> > >
> > > That is indeed very different from first FAT partition.  Does
> > > bootable only apply legacy MBR partition tables?  I didn't think
> > > bootable was typically used with GPT tables.  There is a bit, but it's not
> used to mark EFI partitions.
> > >
> > > Which brings me back to the partition type.  Isn't that the right
> > > way to find the EFI?
> >
> > The is_bootable function in disk/part_efi.c marks a partition as bootable if
> the partition_type_guid on disk matches the EFI PARTITION_SYSTEM_GUID.
> > The part command with the -bootable flag will return the EFI partition
> > on both GPT and MBR partition schemes. This method is also used by
> > config_distro_bootcmd.h
> 
> But it also finds any partitions with the legacy bios bootable flag set in a 
> GPT
> table or the active partition bit set in a MBR table, or any future reason a
> partition might be considered bootable.  Someone trying to add a new type
> of bootable partition to distro bootcmd will be forced to deal with your
> windows nt boot command as it tries to boot any bootable partition, even
> ones it can't boot.
> 
> The distro boot command is designed to boot anything, so it searches for
> partitions beyond EFI.  But what you've done is just for EFI.
> That's why it's different.

It doesn’t matter if someone adds a new type of bootable partition in the 
future, the UEFI boot command will fail to find the imxboard_efi.fd binary then 
move along to check the next bootable partition.

Adding this boot command will not increase maintenance on 
config_distro_bootcmd.h. The UEFI boot command is only used when the defconfig 
selects CONFIG_UEFI_BOOT, and the board's include/configs header has been 
modified to include config_uefi_bootcmd.h instead of config_distro_bootcmd.h 
when the config is set.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-sunxi/master

2018-07-17 Thread Tom Rini
On Tue, Jul 17, 2018 at 09:15:22PM +0530, Jagan Teki wrote:

> Hi Tom,
> 
> Please pull this PR.
> 
> thanks,
> Jagan.
> 
> The following changes since commit 5e9a9645816edcc68c09729f257e0c863292bf26:
> 
>   mach-stm32: Rename CONFIG_SPL_RESET_SUPPORT to CONFIG_SPL_DM_RESET 
> (2018-07-13 14:47:29 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sunxi.git master
> 
> for you to fetch changes up to 32f67bb7a15cec4afa117bd168265ece2107b0d6:
> 
>   sunxi: Enable eMMC on Libre Computer Board ALL-H3-CC boards (2018-07-17 
> 21:07:34 +0530)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [ANN] U-Boot v2018.07 released

2018-07-17 Thread Tom Rini
On Tue, Jul 17, 2018 at 05:54:56PM +0200, Wolfgang Denk wrote:
> Dear Tom,
> 
> In message <20180717134154.GC3196@bill-the-cat> you wrote:
> > 
> > > >> looks good. I expect there was consideration to keep these config files
> > > >> out of the main repo.
> > > > 
> > > > I can't remember clearly. I think there was.
> > > > 
> > > > I have no real preferences.
> > > 
> > > Tom: What do you think?
> >
> > It's Wolfgang's thing :)
> 
> Full circle, nice.
> 
> So has anybody any suggestions what to do?
> 
> The problem I see is that we need yet another non-standard tool
> (gitdm) which AFAICT is not part of the standard distros. Including
> this into U-Boot seems not attractive to me; keeping it outside (as
> I'm doing it now) means you need the config files outside the U-Boot
> tree as well.

OK, sorry, let me try and be smarter.  Can we "just" store the gitdm
config file in U-Boot proper?  Would that be OK with you if we can?

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition()

2018-07-17 Thread Eugeniu Rosca
On Tue, Jul 17, 2018 at 02:44:17PM +0300, Igor Opaniuk wrote:
> Implement get_size_of_partition() operation,
> which is required by the latest upstream libavb [1].

FWIW, any living repository is a moving target, so there is nothing more
volatile than the "latest" state of such repository. Kind request to use
specific revision/commit next time. Thank you.

> 
> [1] https://android.googlesource.com/platform/external/avb/+/master/README.md

Best regards,
Eugeniu.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/2] avb2.0: use block API in AVB ops

2018-07-17 Thread Eugeniu Rosca
On Tue, Jul 17, 2018 at 02:33:26PM +0300, Igor Opaniuk wrote:
> Use blk_dread()/blk_dwrite() in mmc_read()/mmc_write() AVB operation
> implementations. This fixes compilation issues when CONFIG_BLK is
> enabled.
> 
> Signed-off-by: Igor Opaniuk 
> ---
>  common/avb_verify.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index f9a00f8..20e35ad 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -5,6 +5,7 @@
>   */
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -288,8 +289,8 @@ static unsigned long mmc_read_and_flush(struct mmc_part 
> *part,
>   tmp_buf = buffer;
>   }
>  
> - blks = part->mmc->block_dev.block_read(part->mmc_blk,
> - start, sectors, tmp_buf);
> + blks = blk_dread(part->mmc_blk,
> +  start, sectors, tmp_buf);
>   /* flush cache after read */
>   flush_cache((ulong)tmp_buf, sectors * part->info.blksz);
>  
> @@ -327,8 +328,8 @@ static unsigned long mmc_write(struct mmc_part *part, 
> lbaint_t start,
>   tmp_buf = buffer;
>   }
>  
> - return part->mmc->block_dev.block_write(part->mmc_blk,
> - start, sectors, tmp_buf);
> + return blk_dwrite(part->mmc_blk,
> +   start, sectors, tmp_buf);
>  }
>  
>  static struct mmc_part *get_partition(AvbOps *ops, const char *partition)
> -- 
> 2.7.4
> 

I confirm this patch fixes below compilation failure on sandbox
(LIBAVB=y, AVB_VERIFY=y, FASTBOOT=y, BLK=y):

common/avb_verify.c: In function ‘mmc_read_and_flush’:
common/avb_verify.c:291:18: error: ‘struct mmc’ has no member named ‘block_dev’
  blks = part->mmc->block_dev.block_read(part->mmc_blk,
  ^~
common/avb_verify.c: In function ‘mmc_write’:
common/avb_verify.c:330:18: error: ‘struct mmc’ has no member named ‘block_dev’
  return part->mmc->block_dev.block_write(part->mmc_blk,

With this patch, avb_verify compiles equally well with BLK=y and BLK=n.

Tested-by: Eugeniu Rosca 

Thanks,
Eugeniu.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC] Make U-Boot log great again

2018-07-17 Thread Sam Protsenko
On Tue, Jul 10, 2018 at 5:38 PM, Tom Rini  wrote:
> On Tue, Jul 10, 2018 at 11:01:14AM +0800, Bin Meng wrote:
>> Hello,
>>
>> On Fri, Mar 23, 2018 at 1:44 PM, Bin Meng  wrote:
>> > Hi,
>> >
>> > On Sat, Feb 17, 2018 at 3:49 AM, Robert Nelson  
>> > wrote:
>> >> On Fri, Feb 16, 2018 at 1:01 PM, Sam Protsenko
>> >>  wrote:
>> >>> Hi guys,
>> >>>
>> >>> TL;DR This is a suggestion about fixing U-Boot log, which has got
>> >>> worse recently.
>> >>>
>> >>> Right now U-Boot and SPL logs are cluttered with bogus warnings like
>> >>> these (on X15 board, but I'm pretty sure it should appear on many
>> >>> others):
>> >>>
>> >>> Loading Environment from FAT...
>> >>> *** Warning - bad CRC, using default environment
>> >>> Failed (-5)
>> >>
>> >
>> > Do we plan to fix this "Failed (-5)" message? It's very confusing.
>> > Like previous U-Boot just printing "*** Warning - bad CRC, using
>> > default environment" is enough I think.
>> >
>>
>> The v2018.07 release still has this "Failed (-5)" message on boot.
>> When do we plan to fix this?
>
> I don't mean for this to sound glib, but I was expecting patches to get
> posted to change this particular area at least.  I thought it had been
> talked to the point where it was understood what the next steps should
> look like?  Thanks/sorry!
>

Just to have something specific to discuss, I've sent two RFC patches:
[1,2]. I suggest we start with messages beautifying first, as this
seems to be main concern for most people.

Tom, what do you think about [1,2]? Does it have right to exist at
all, or should we go some other way?

Thanks.

[1] https://lists.denx.de/pipermail/u-boot/2018-July/335071.html
[2] https://lists.denx.de/pipermail/u-boot/2018-July/335072.html

> --
> Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC 2/2] env: Add prefix to error messages when loading env

2018-07-17 Thread Sam Protsenko
This is just a draft to discuss ideas related to "Make U-Boot log great
again" thread.

With this patch we will see something like:

Loading Environment from FAT...
   --> MMC: no card present
   --> ** Bad device mmc 0 **
   --> Failed (-5)
Loading Environment from MMC...
   --> OK

instead of:

Loading Environment from FAT... MMC: no card present
** Bad device mmc 0 **
Failed (-5)
Loading Environment from MMC... OK

Signed-off-by: Sam Protsenko 
---
 common/console.c  | 8 
 env/env.c | 4 +++-
 include/asm-generic/global_data.h | 1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/common/console.c b/common/console.c
index 2ba33dc574..1bbafa33a1 100644
--- a/common/console.c
+++ b/common/console.c
@@ -533,6 +533,14 @@ void putc(const char c)
 
 void puts(const char *s)
 {
+   if (gd->pr_prefix) {
+   const char *prefix = gd->pr_prefix;
+
+   gd->pr_prefix = NULL;
+   puts(prefix);
+   gd->pr_prefix = prefix;
+   }
+
 #ifdef CONFIG_DEBUG_UART
if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
diff --git a/env/env.c b/env/env.c
index 5c0842ac07..56a105ea55 100644
--- a/env/env.c
+++ b/env/env.c
@@ -194,12 +194,14 @@ int env_load(void)
if (!env_has_inited(drv->location))
continue;
 
-   printf("Loading Environment from %s... ", drv->name);
+   printf("Loading Environment from %s...\n", drv->name);
+   gd->pr_prefix = "   --> ";
ret = drv->load();
if (ret)
printf("Failed (%d)\n", ret);
else
printf("OK\n");
+   gd->pr_prefix = NULL;
 
if (!ret)
return 0;
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 0fd4900392..32b80db96b 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -44,6 +44,7 @@ typedef struct global_data {
unsigned long board_type;
 #endif
unsigned long have_console; /* serial_init() was called */
+   const char *pr_prefix;  /* print prefix before message */
 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
unsigned long precon_buf_idx;   /* Pre-Console buffer index */
 #endif
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [RFC 1/2] env: Drop error messages when loading environment

2018-07-17 Thread Sam Protsenko
This is just a draft to discuss ideas related to "Make U-Boot log great
again" thread.

With this patch we will have something like this:

Loading Environment from FAT... Failed (-5)
Loading Environment from MMC... OK

instead of this:

Loading Environment from FAT... MMC: no card present
** Bad device mmc 0 **
Failed (-5)
Loading Environment from MMC... OK

Signed-off-by: Sam Protsenko 
---
 env/env.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/env/env.c b/env/env.c
index 5c0842ac07..85598fa5d4 100644
--- a/env/env.c
+++ b/env/env.c
@@ -187,6 +187,7 @@ int env_load(void)
 
for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) {
int ret;
+   unsigned long have_console = gd->have_console;
 
if (!drv->load)
continue;
@@ -195,7 +196,11 @@ int env_load(void)
continue;
 
printf("Loading Environment from %s... ", drv->name);
+
+   /* Suppress console output for drv->load() */
+   gd->have_console = 0;
ret = drv->load();
+   gd->have_console = have_console;
if (ret)
printf("Failed (%d)\n", ret);
else
-- 
2.18.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] avb2.0: add proper dependencies

2018-07-17 Thread Eugeniu Rosca
Hi Igor,

On Tue, Jul 17, 2018 at 02:33:25PM +0300, Igor Opaniuk wrote:
> 1. Since libavb library alone is highly portable, introduce dedicated
> Kconfig symbol for AVB bootloader-dependent operations, so it's possible
> to build libavb separately. AVB bootloader-dependent operations include:
>   * Helpers to process strings in order to build OS bootargs.
>   * Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
>   * Helpers to alloc/init/free avb ops.
> 2. Add CONFIG_FASTBOOT dependency, as fastboot buffer is
> re-used in partition verification operations.
> 
> Reported-by: Eugeniu Rosca 
> Signed-off-by: Igor Opaniuk 
> ---
>  cmd/Kconfig |  2 +-
>  common/Kconfig  | 10 ++
>  common/Makefile |  2 +-
>  doc/README.avb2 |  1 +
>  4 files changed, 13 insertions(+), 2 deletions(-)

With this patch I am now able to compile libavb natively for x86_64,
as well as cross-compile it for arm and aarch64, w/o the avb_verify
wrapper. Thanks for the improvements in the patch/Kconfig description.

Reviewed-by: Eugeniu Rosca 
Tested-by: Eugeniu Rosca 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/1] net: Store waiting packet in a different buffer when making ARP requests

2018-07-17 Thread Joe Hershberger
On Mon, Jul 9, 2018 at 11:48 AM, Joe Hershberger  wrote:
> On Wed, Jul 4, 2018 at 9:13 PM, Tran Tien Dat
>  wrote:
>> U-Boot has 1 common buffer to send Ethernet frames, pointed to by
>> net_tx_packet.  When sending to an IP address without knowing the MAC
>> address, U-Boot makes an ARP request (using the arp_tx_packet buffer) to
>> find out the MAC address of the IP addressr. When a matching ARP reply is
>> received, U-Boot continues sending the frame stored in the net_tx_packet
>> buffer.
>>
>> However, in the mean time, if U-Boot needs to send out any network packets
>> (e.g. replying ping packets or ARP requests for its own IP address etc.),
>> it will use the net_tx_packet buffer to prepare the new packet. Thus this
>> buffer is no longer the original packet meant to be transmitted after the
>> ARP reply. The original packet will be lost.
>>
>> U-Boot has another buffer, pointed to by arp_tx_packet which is used to
>> prepare ARP requests. ARP requests use this buffer instead of the normal
>> net_tx_packet in order to avoid modifying the waiting packet to be sent.
>> However, this approach does not prevent other parts of the codes from
>> modifying the waiting packet to be sent, as explained above. This patch
>> repurposes the arp_tx_packet buffer to be used to store the waiting packet
>> to be sent, and use the normal net_tx_packet buffer to send ARP request
>> instead.
>>
>> Signed-off-by: Tran Tien Dat 
>
> Seems good, thanks!
>
> Acked-by: Joe Hershberger 

Upon testing and looking into this further, I don't like it. It adds a
copy and breaks the network stack. Most network tests fail after
applying this patch. so...

Nacked-by: Joe Hershberger 

I think the buffer to use should be selected at the point of an async
reply instead of preparing for something that probably will not
happen.

Sorry,
-Joe

>
>> ---
>>
>> Changes in v2:
>> - Provide more detailed description
>>
>>  net/arp.c | 18 ++
>>  net/arp.h |  1 +
>>  net/net.c |  3 +++
>>  3 files changed, 14 insertions(+), 8 deletions(-)
>>
>> diff --git a/net/arp.c b/net/arp.c
>> index b8a71684cd..f5e2c0b0cf 100644
>> --- a/net/arp.c
>> +++ b/net/arp.c
>> @@ -35,8 +35,8 @@ int   arp_wait_tx_packet_size;
>>  ulong  arp_wait_timer_start;
>>  intarp_wait_try;
>>
>> -static uchar   *arp_tx_packet; /* THE ARP transmit packet */
>> -static uchar   arp_tx_packet_buf[PKTSIZE_ALIGN + PKTALIGN];
>> +uchar   *arp_wait_tx_packet;   /* THE waiting transmit packet after ARP */
>> +static uchar   arp_wait_tx_packet_buf[PKTSIZE_ALIGN + PKTALIGN];
>>
>>  void arp_init(void)
>>  {
>> @@ -45,8 +45,8 @@ void arp_init(void)
>> net_arp_wait_packet_ip.s_addr = 0;
>> net_arp_wait_reply_ip.s_addr = 0;
>> arp_wait_tx_packet_size = 0;
>> -   arp_tx_packet = _tx_packet_buf[0] + (PKTALIGN - 1);
>> -   arp_tx_packet -= (ulong)arp_tx_packet % PKTALIGN;
>> +   arp_wait_tx_packet = _wait_tx_packet_buf[0] + (PKTALIGN - 1);
>> +   arp_wait_tx_packet -= (ulong)arp_wait_tx_packet % PKTALIGN;
>>  }
>>
>>  void arp_raw_request(struct in_addr source_ip, const uchar *target_ethaddr,
>> @@ -58,7 +58,7 @@ void arp_raw_request(struct in_addr source_ip, const uchar 
>> *target_ethaddr,
>>
>> debug_cond(DEBUG_DEV_PKT, "ARP broadcast %d\n", arp_wait_try);
>>
>> -   pkt = arp_tx_packet;
>> +   pkt = net_tx_packet;
>>
>> eth_hdr_size = net_set_ether(pkt, net_bcast_ethaddr, PROT_ARP);
>> pkt += eth_hdr_size;
>> @@ -76,7 +76,7 @@ void arp_raw_request(struct in_addr source_ip, const uchar 
>> *target_ethaddr,
>> memcpy(>ar_tha, target_ethaddr, ARP_HLEN); /* target ET addr */
>> net_write_ip(>ar_tpa, target_ip);  /* target IP addr */
>>
>> -   net_send_packet(arp_tx_packet, eth_hdr_size + ARP_HDR_SIZE);
>> +   net_send_packet(net_tx_packet, eth_hdr_size + ARP_HDR_SIZE);
>>  }
>>
>>  void arp_request(void)
>> @@ -217,9 +217,11 @@ void arp_receive(struct ethernet_hdr *et, struct 
>> ip_udp_hdr *ip, int len)
>>
>> /* set the mac address in the waiting packet's header
>>and transmit it */
>> -   memcpy(((struct ethernet_hdr 
>> *)net_tx_packet)->et_dest,
>> +   memcpy(((struct ethernet_hdr *)arp_wait_tx_packet)
>> +   ->et_dest,
>>>ar_sha, ARP_HLEN);
>> -   net_send_packet(net_tx_packet, 
>> arp_wait_tx_packet_size);
>> +   net_send_packet(arp_wait_tx_packet,
>> +   arp_wait_tx_packet_size);
>>
>> /* no arp request pending now */
>> net_arp_wait_packet_ip.s_addr = 0;
>> diff --git a/net/arp.h b/net/arp.h
>> index afb86958f3..65d73927a7 100644
>> --- a/net/arp.h
>> +++ b/net/arp.h
>> @@ -20,6 +20,7 @@ extern uchar *arp_wait_packet_ethaddr;
>>  extern int 

Re: [U-Boot] [PATCH] serial: ns16550: Add register shift variable

2018-07-17 Thread Andy Shevchenko
On Wed, Jul 18, 2018 at 12:30 AM, Adam Ford  wrote:
> On Tue, Jul 17, 2018 at 4:24 PM Andy Shevchenko
>  wrote:

>> https://elixir.bootlin.com/linux/v4.18-rc5/source/drivers/tty/serial/8250/8250_omap.c

> Can we omap2+ users patch the 8250_omap.c code in Linux to make use of
> the reg-shift, then do the same from u-boot so they are in sync and
> clean out any #defines that could be replaced by the device tree?

It's possible, but it doesn't mean you now fully on DT, b/c Linux must
support old DTBs as I already told in this thread.

So, the code in the driver will look like

ret = of_property_read_u32(..., _shift);
if (ret)
 reg_shift = 2;

-- 
With Best Regards,
Andy Shevchenko
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre

2018-07-17 Thread Henry Beberman
> -Original Message-
> From: Trent Piepho 
> Sent: Tuesday, July 17, 2018 10:03 AM
> To: Henry Beberman ; u-
> b...@lists.denx.de
> Cc: fabio.este...@nxp.com; adrian.alo...@nxp.com
> Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> support for iMX7 Sabre
> 
> On Tue, 2018-07-17 at 01:41 +, Henry Beberman wrote:
> > > -Original Message-
> > > From: Trent Piepho 
> > > Sent: Monday, July 16, 2018 11:22 AM
> > > To: Henry Beberman ; u-
> > > b...@lists.denx.de
> > > Cc: fabio.este...@nxp.com; adrian.alo...@nxp.com
> > > Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> > > support for iMX7 Sabre
> > >
> > > On Sat, 2018-07-14 at 00:11 +, Henry Beberman wrote:
> > > > From: Henry Beberman 
> > > >
> > > > This patch adds a new bootable configuration for Windows 10 IoT
> > > > Core on the i.MX7 Dual Sabre board.
> > > >
> > > > It enables SPL on the i.MX7 Sabre in order to support the FIT load
> > > > of OP-TEE and U-Boot proper.
> > > >
> > > > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index
> > > > f186120684..3fb9b72703 100644
> > > > --- a/drivers/gpio/Makefile
> > > > +++ b/drivers/gpio/Makefile
> > > > @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
> > > >  obj-$(CONFIG_DWAPB_GPIO)   += dwapb_gpio.o
> > > >  obj-$(CONFIG_AXP_GPIO) += axp_gpio.o
> > > >  endif
> > > > +
> > > > +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
> > > >  obj-$(CONFIG_DM_GPIO)  += gpio-uclass.o
> > > >
> > > >  obj-$(CONFIG_DM_PCA953X)   += pca953x_gpio.o
> > > >  obj-$(CONFIG_DM_74X164)+= 74x164_gpio.o
> > > > +endif
> > >
> > > It doesn't look like this patch is specific to mx7 or Windows.
> > > Perhaps it should be in a different commit?
> >
> > I agree that this change probably belongs in its own patch.
> > I've left it in this patch so far because it's required to build the new
> mx7dsabresd_nt_defconfig.
> 
> Easy enough to split out and put first.  The person on different hardware
> trying to figure out the u-boot build spaghetti it's helped much knowing the
> person who added it was working on windows 10 support, but nothing about
> the reason for this change.
> 
> > > Also, the help text for SPL_DM says it turns on basic DM support in
> > > SPL.  But not any specific hardware drivers.  Those all have
> > > additional config options to turn them on.  It doesn't seems right
> > > to bundle a selection of GPIO drivers along with CONFIG_SPL_DM.
> >
> > This issue has cropped up because this patch adds SPL support to
> mx7dsabresd, but intentionally does not enable SPL_DM.
> > The defconfig contains CONFIG_DM_74X164 for use in U-Boot Proper, but
> because drivers/gpio/Makefile also runs during the SPL portion of the build
> that config still pulls in the 74X164 driver which fails to build due to 
> missing
> dependencies.
> >
> > Wrapping the DM objects in CONFIG_$(SPL_TPL_)DM ensures that DM is
> actually enabled for the current portion of the build when deciding to build
> the DM drivers.
> 
> But isn't it odd that not a single other driver is wrapped this way?
> What's special here?
> 
> I think the underlying flaw is the the kbuild system doesn't support the
> concept of building multiple times in different modes, e.g. main, SPL, TPL.
> And rather than design something, one gets layers of board specific hacks.

There are a few other instances of omitting DM drivers from SPL due to size 
concerns, see drivers/power/regulator/Makefile (commit a35332f) and 
drivers/mmc/Makefile (commit c4d660d)

However instead of wrapping the block in CONFIG_$(SPL_TPL_)DM, the intended way 
is to include $(SPL_) in line with the driver you need to disable for SPL.
- obj-$(CONFIG_DM_74X164)  += 74x164_gpio.o
+ obj-$(CONFIG_$(SPL_)DM_74X164)  += 74x164_gpio.o

I'll switch to this in-line method and split out this change into a separate 
patch so the commit message explains it in isolation.

Thanks,
Henry
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] serial: ns16550: Add register shift variable

2018-07-17 Thread Adam Ford
On Tue, Jul 17, 2018 at 4:24 PM Andy Shevchenko
 wrote:
>
> On Tue, Jul 17, 2018 at 4:34 PM, Alexey Brodkin
>  wrote:
>
> >> Linux has a completely separate driver for omap3 (which is wrong too).
>
> This is not (fully) correct,
>
> >> But in a nutshell, it basically determines the shift value by the
> >> "compatible" string, so we should too.
> >
> > Here's the driver:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/omap-serial.c
>
> I dunno why it's still in the tree. The modern one is (check
> compatible strings for both):
>
> https://elixir.bootlin.com/linux/v4.18-rc5/source/drivers/tty/serial/8250/8250_omap.c
>
>
Can we omap2+ users patch the 8250_omap.c code in Linux to make use of
the reg-shift, then do the same from u-boot so they are in sync and
clean out any #defines that could be replaced by the device tree?

(I am not volunteering anyone or myself, it's more of a hypothetical question)

adam

>
>
> --
> With Best Regards,
> Andy Shevchenko
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] serial: ns16550: Add register shift variable

2018-07-17 Thread Andy Shevchenko
On Tue, Jul 17, 2018 at 4:34 PM, Alexey Brodkin
 wrote:

>> Linux has a completely separate driver for omap3 (which is wrong too).

This is not (fully) correct,

>> But in a nutshell, it basically determines the shift value by the
>> "compatible" string, so we should too.
>
> Here's the driver:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/omap-serial.c

I dunno why it's still in the tree. The modern one is (check
compatible strings for both):

https://elixir.bootlin.com/linux/v4.18-rc5/source/drivers/tty/serial/8250/8250_omap.c




-- 
With Best Regards,
Andy Shevchenko
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] imx: iomux-v3: fix IOMUX_PADS for single-CPU variant

2018-07-17 Thread Eric Nelson
When compiling for a single CPU variant (e.g. MX6Q or MX6DL),
the IOMUX constants are named MX6_PAD_blah, not MX6Q_PAD_blah.

Fix the macros IOMUX_PADS and SETUP_IOMUX_PAD to reflect this.

Signed-off-by: Eric Nelson 
---
 arch/arm/include/asm/mach-imx/iomux-v3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/mach-imx/iomux-v3.h 
b/arch/arm/include/asm/mach-imx/iomux-v3.h
index bb93058..4be1c53 100644
--- a/arch/arm/include/asm/mach-imx/iomux-v3.h
+++ b/arch/arm/include/asm/mach-imx/iomux-v3.h
@@ -267,9 +267,9 @@ if (is_mx6dq() || is_mx6dqp()) {
\
 #define SETUP_IOMUX_PADS(x)\
imx_iomux_v3_setup_multiple_pads(x, ARRAY_SIZE(x)/2)
 #elif defined(CONFIG_MX6Q) || defined(CONFIG_MX6D)
-#define IOMUX_PADS(x) MX6Q_##x
+#define IOMUX_PADS(x) MX6_##x
 #define SETUP_IOMUX_PAD(def)   \
-   imx_iomux_v3_setup_pad(MX6Q_##def);
+   imx_iomux_v3_setup_pad(MX6_##def);
 #define SETUP_IOMUX_PADS(x)\
imx_iomux_v3_setup_multiple_pads(x, ARRAY_SIZE(x))
 #elif defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL)
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/29] binman: Update the device-tree file on exit

2018-07-17 Thread Simon Glass
Hi,

On 17 July 2018 at 13:25, Simon Glass  wrote:
> Binman can make additions to the device tree which are useful to U-Boot
> when it runs (e.g. the position of each entry in the image). Write the
> changes back so that they are easily accessible.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/binman/control.py | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/binman/control.py b/tools/binman/control.py
> index 17c6d7a2d2..97652334e0 100644
> --- a/tools/binman/control.py
> +++ b/tools/binman/control.py
> @@ -168,8 +168,12 @@ def Binman(options, args):
>  image.BuildImage()
>  if options.map:
>  image.WriteMap()
> +# Write the updated FDT to our output file, and also back to the
> +# input file, so it is visible after binman exits.
>  with open(fname, 'wb') as outfd:
>  outfd.write(dtb.GetContents())
> +with open(dtb_fname, 'wb') as outfd:
> +outfd.write(dtb.GetContents())
>  finally:
>  tools.FinaliseOutputDir()
>  finally:
> --
> 2.18.0.203.gfac676dfb9-goog
>

Actually I think this patch is a bad idea since it can cause race
conditions. U-Boot's Makefile builds the .dtb, someone changes the
source, then binman updates the .dtb, causing the Makefile to think
that it does not need updating next time. I'll drop this patch.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 28/29] binman: Add a test to catch use of the old 'pos' property

2018-07-17 Thread Simon Glass
This property has been changed to 'offset'. To help downstream users who
might still be using 'pos', add a check that this is not used by mistake.

Signed-off-by: Simon Glass 
---

 tools/binman/entry.py |  2 ++
 tools/binman/ftest.py |  7 +++
 tools/binman/test/79_uses_pos.dts | 10 ++
 3 files changed, 19 insertions(+)
 create mode 100644 tools/binman/test/79_uses_pos.dts

diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 6ce5dbdc90..77cfab9c5d 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -143,6 +143,8 @@ class Entry(object):
 
 This reads all the fields we recognise from the node, ready for use.
 """
+if 'pos' in self._node.props:
+self.Raise("Please use 'offset' instead of 'pos'")
 self.offset = fdt_util.GetInt(self._node, 'offset')
 self.size = fdt_util.GetInt(self._node, 'size')
 self.align = fdt_util.GetInt(self._node, 'align')
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index ce473dfaff..3d5f23558c 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1361,6 +1361,13 @@ class TestFunctional(unittest.TestCase):
 data = self._DoReadFile('78_u_boot_tpl.dts')
 self.assertEqual(U_BOOT_TPL_DATA + U_BOOT_TPL_DTB_DATA, data)
 
+def testUsesPos(self):
+"""Test that the 'pos' property cannot be used anymore"""
+with self.assertRaises(ValueError) as e:
+   data = self._DoReadFile('79_uses_pos.dts')
+self.assertIn("Node '/binman/u-boot': Please use 'offset' instead of "
+  "'pos'", str(e.exception))
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/79_uses_pos.dts 
b/tools/binman/test/79_uses_pos.dts
new file mode 100644
index 00..7638b9b5e0
--- /dev/null
+++ b/tools/binman/test/79_uses_pos.dts
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+   binman {
+   u-boot {
+   pos = <10>;
+   };
+   };
+};
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: remove dependency to "asm/utils.h"

2018-07-17 Thread Paulo Zaneti
Header file "asm/utils.h" is not required to compile "spl_ymodem.c".
So, removing this dependency allows other architectures to use this
booting device as "asm/utils.h" is only present in "arm" architecture.

Signed-off-by: Paulo Zaneti 
---

 common/spl/spl_ymodem.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 35f8f80..3b1bd71 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #define BUF_SIZE 1024
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 21/29] binman: Add support for Chromium GBB

2018-07-17 Thread Simon Glass
This entry contains a Google Binary Block, used to store keys and bitmaps
in a Chromium image.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries| 19 +
 tools/binman/etype/gbb.py  | 96 ++
 tools/binman/ftest.py  | 56 +++
 tools/binman/test/71_gbb.dts   | 31 +
 tools/binman/test/72_gbb_too_small.dts | 10 +++
 tools/binman/test/73_gbb_no_size.dts   |  9 +++
 6 files changed, 221 insertions(+)
 create mode 100644 tools/binman/etype/gbb.py
 create mode 100644 tools/binman/test/71_gbb.dts
 create mode 100644 tools/binman/test/72_gbb_too_small.dts
 create mode 100644 tools/binman/test/73_gbb_no_size.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 6f09626b24..41b70192c0 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -91,6 +91,25 @@ FMAP does not support this.
 
 
 
+Entry: gbb: An entry which contains a Chromium OS Google Binary Block
+-
+
+Properties / Entry arguments:
+- hardware-id: Hardware ID to use for this build (a string)
+- keydir: Directory containing the public keys to use
+- bmpblk: Filename containing images used by recovery
+
+Chromium OS uses a GBB to store various pieces of information, in particular
+the root and recovery keys that are used to verify the boot process. Some
+more details are here:
+
+https://www.chromium.org/chromium-os/firmware-porting-guide/2-concepts
+
+but note that the page dates from 2013 so is quite out of date. See
+README.chromium for how to obtain the required keys and tools.
+
+
+
 Entry: intel-cmc: Entry containing an Intel Chipset Micro Code (CMC) file
 -
 
diff --git a/tools/binman/etype/gbb.py b/tools/binman/etype/gbb.py
new file mode 100644
index 00..8fe10f4713
--- /dev/null
+++ b/tools/binman/etype/gbb.py
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+
+# Support for a Chromium OS Google Binary Block, used to record read-only
+# information mostly used by firmware.
+
+from collections import OrderedDict
+
+import command
+from entry import Entry, EntryArg
+
+import fdt_util
+import tools
+
+# Build GBB flags.
+# (src/platform/vboot_reference/firmware/include/gbb_header.h)
+gbb_flag_properties = {
+  'dev-screen-short-delay': 0x1,
+  'load-option-roms': 0x2,
+  'enable-alternate-os': 0x4,
+  'force-dev-switch-on': 0x8,
+  'force-dev-boot-usb': 0x10,
+  'disable-fw-rollback-check': 0x20,
+  'enter-triggers-tonorm': 0x40,
+  'force-dev-boot-legacy': 0x80,
+  'faft-key-override': 0x100,
+  'disable-ec-software-sync': 0x200,
+  'default-dev-boot-legacy': 0x400,
+  'disable-pd-software-sync': 0x800,
+  'disable-lid-shutdown': 0x1000,
+  'force-dev-boot-fastboot-full-cap': 0x2000,
+  'enable-serial': 0x4000,
+  'disable-dwmp': 0x8000,
+}
+
+
+class Entry_gbb(Entry):
+"""An entry which contains a Chromium OS Google Binary Block
+
+Properties / Entry arguments:
+- hardware-id: Hardware ID to use for this build (a string)
+- keydir: Directory containing the public keys to use
+- bmpblk: Filename containing images used by recovery
+
+Chromium OS uses a GBB to store various pieces of information, in 
particular
+the root and recovery keys that are used to verify the boot process. Some
+more details are here:
+
+https://www.chromium.org/chromium-os/firmware-porting-guide/2-concepts
+
+but note that the page dates from 2013 so is quite out of date. See
+README.chromium for how to obtain the required keys and tools.
+"""
+def __init__(self, section, etype, node):
+Entry.__init__(self, section, etype, node)
+self.hardware_id, self.keydir, self.bmpblk = self.GetEntryArgsOrProps(
+[EntryArg('hardware-id', str),
+ EntryArg('keydir', str),
+ EntryArg('bmpblk', str)])
+
+# Read in the GBB flags from the config
+self.gbb_flags = 0
+flags_node = node.FindNode('flags')
+if flags_node:
+for flag, value in gbb_flag_properties.iteritems():
+if fdt_util.GetBool(flags_node, flag):
+self.gbb_flags |= value
+
+def ObtainContents(self):
+gbb = 'gbb.bin'
+fname = tools.GetOutputFilename(gbb)
+if not self.size:
+self.Raise('GBB must have a fixed size')
+gbb_size = self.size
+bmpfv_size = gbb_size - 0x2180
+if bmpfv_size < 0:
+self.Raise('GBB is too small (minimum 0x2180 bytes)')
+sizes = [0x100, 0x1000, bmpfv_size, 0x1000]
+sizes = ['%#x' % size for size in sizes]
+keydir = tools.GetInputFilename(self.keydir)
+gbb_set_command = [
+'gbb_utility', '-s',
+'--hwid=%s' % 

[U-Boot] [PATCH 29/29] binman: Adjust _GetPropTree() parameters

2018-07-17 Thread Simon Glass
At present this function takes a filename, but it is better to use an Fdt
object so that the caller can control this, perhaps obtainint the device
tree from a bytearray. Update the method accordingly and also fix a
confusing parameter name.

Signed-off-by: Simon Glass 
---

 tools/binman/ftest.py | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 3d5f23558c..a8456c2615 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -353,21 +353,19 @@ class TestFunctional(unittest.TestCase):
 """
 return struct.unpack('>L', dtb[4:8])[0]
 
-def _GetPropTree(self, dtb_data, node_names):
+def _GetPropTree(self, dtb, prop_names):
 def AddNode(node, path):
 if node.name != '/':
 path += '/' + node.name
 for subnode in node.subnodes:
 for prop in subnode.props.values():
-if prop.name in node_names:
+if prop.name in prop_names:
 prop_path = path + '/' + subnode.name + ':' + prop.name
 tree[prop_path[len('/binman/'):]] = 
fdt_util.fdt32_to_cpu(
 prop.value)
 AddNode(subnode, path)
 
 tree = {}
-dtb = fdt.Fdt(dtb_data)
-dtb.Scan()
 AddNode(dtb.GetRoot(), '')
 return tree
 
@@ -1092,11 +1090,9 @@ class TestFunctional(unittest.TestCase):
 """Test that we can update the device tree with offset/size info"""
 _, _, _, out_dtb_fname = self._DoReadFileDtb('60_fdt_update.dts',
  update_dtb=True)
-props = self._GetPropTree(out_dtb_fname, ['offset', 'size',
-  'image-pos'])
-with open('/tmp/x.dtb', 'wb') as outf:
-with open(out_dtb_fname) as inf:
-outf.write(inf.read())
+dtb = fdt.Fdt(out_dtb_fname)
+dtb.Scan()
+props = self._GetPropTree(dtb, ['offset', 'size', 'image-pos'])
 self.assertEqual({
 'image-pos': 0,
 'offset': 0,
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 24/29] binman: Add an entry for a Chromium vblock

2018-07-17 Thread Simon Glass
This adds support for a Chromium verified boot block, used to sign a
read-write section of the image.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries | 17 +
 tools/binman/bsection.py| 24 +++
 tools/binman/entry.py   |  2 +-
 tools/binman/etype/vblock.py| 74 +
 tools/binman/ftest.py   | 41 
 tools/binman/test/74_vblock.dts | 28 
 tools/binman/test/75_vblock_no_content.dts  | 23 +++
 tools/binman/test/76_vblock_bad_phandle.dts | 24 +++
 tools/binman/test/77_vblock_bad_entry.dts   | 27 
 9 files changed, 259 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/etype/vblock.py
 create mode 100644 tools/binman/test/74_vblock.dts
 create mode 100644 tools/binman/test/75_vblock_no_content.dts
 create mode 100644 tools/binman/test/76_vblock_bad_phandle.dts
 create mode 100644 tools/binman/test/77_vblock_bad_entry.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 41b70192c0..1b75ca0052 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -496,6 +496,23 @@ complicated. Otherwise it is the same as the u_boot entry.
 
 
 
+Entry: vblock: An entry which contains a Chromium OS verified boot block
+
+
+Properties / Entry arguments:
+- keydir: Directory containing the public keys to use
+- keyblock: Name of the key file to use (inside keydir)
+- signprivate: Name of provide key file to use (inside keydir)
+- version: Version number of the vblock (typically 1)
+- kernelkey: Name of the kernel key to use (inside keydir)
+- preamble-flags: Value of the vboot preamble flags (typically 0)
+
+Chromium OS  signs the read-write firmware and kernel, writing the signature
+in this block. This allows U-Boot to verify that the next firmware stage
+and kernel are genuine.
+
+
+
 Entry: x86-start16: x86 16-bit start-up code for U-Boot
 ---
 
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 47fe37ccb9..f3a95fda8e 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -379,3 +379,27 @@ class Section(object):
 Entry.WriteMapLine(fd, indent, self._name, self._offset, self._size)
 for entry in self._entries.values():
 entry.WriteMap(fd, indent + 1)
+
+def GetContentsByPhandle(self, phandle, source_entry):
+"""Get the data contents of an entry specified by a phandle
+
+This uses a phandle to look up a node and and find the entry
+associated with it. Then it returnst he contents of that entry.
+
+Args:
+phandle: Phandle to look up (integer)
+source_entry: Entry containing that phandle (used for error
+reporting)
+
+Returns:
+data from associated entry (as a string), or None if not found
+"""
+node = self._node.GetFdt().LookupPhandle(phandle)
+if not node:
+source_entry.Raise("Cannot find node for phandle %d" % phandle)
+for entry in self._entries.values():
+if entry._node == node:
+if entry.data is None:
+return None
+return entry.data
+source_entry.Raise("Cannot find entry for node '%s'" % node.name)
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 8b910feff6..996f03e3a6 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -65,7 +65,7 @@ class Entry(object):
 self.name = node and (name_prefix + node.name) or 'none'
 self.offset = None
 self.size = None
-self.data = ''
+self.data = None
 self.contents_size = 0
 self.align = None
 self.align_size = None
diff --git a/tools/binman/etype/vblock.py b/tools/binman/etype/vblock.py
new file mode 100644
index 00..595af5456d
--- /dev/null
+++ b/tools/binman/etype/vblock.py
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+
+# Support for a Chromium OS verified boot block, used to sign a read-write
+# section of the image.
+
+from collections import OrderedDict
+import os
+
+from entry import Entry, EntryArg
+
+import fdt_util
+import tools
+
+class Entry_vblock(Entry):
+"""An entry which contains a Chromium OS verified boot block
+
+Properties / Entry arguments:
+- keydir: Directory containing the public keys to use
+- keyblock: Name of the key file to use (inside keydir)
+- signprivate: Name of provide key file to use (inside keydir)
+- version: Version number of the vblock (typically 1)
+- kernelkey: Name of the kernel key to use (inside keydir)
+- preamble-flags: Value of the vboot preamble flags (typically 0)
+
+ 

[U-Boot] [PATCH 18/29] dtoc: Export the _FindNode() function

2018-07-17 Thread Simon Glass
This is useful for clients that want to find a node. Export it so it can
be used by others.

Signed-off-by: Simon Glass 
---

 tools/dtoc/fdt.py  | 4 ++--
 tools/dtoc/test_fdt.py | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 9d69b426c1..01e39b8a2a 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -181,7 +181,7 @@ class Node:
 self.subnodes = []
 self.props = {}
 
-def _FindNode(self, name):
+def FindNode(self, name):
 """Find a node given its name
 
 Args:
@@ -349,7 +349,7 @@ class Fdt:
 if len(parts) < 2:
 return None
 for part in parts[1:]:
-node = node._FindNode(part)
+node = node.FindNode(part)
 if not node:
 return None
 return node
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 38e1732f52..abec9e57e1 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -155,12 +155,12 @@ class TestNode(unittest.TestCase):
 self.assertEqual(prop.value, value)
 
 def testFindNode(self):
-"""Tests that we can find a node using the _FindNode() functoin"""
-node = self.dtb.GetRoot()._FindNode('i2c@0')
+"""Tests that we can find a node using the FindNode() functoin"""
+node = self.dtb.GetRoot().FindNode('i2c@0')
 self.assertEqual('i2c@0', node.name)
-subnode = node._FindNode('pmic@9')
+subnode = node.FindNode('pmic@9')
 self.assertEqual('pmic@9', subnode.name)
-self.assertEqual(None, node._FindNode('missing'))
+self.assertEqual(None, node.FindNode('missing'))
 
 def testRefreshMissingNode(self):
 """Test refreshing offsets when an extra node is present in dtb"""
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 27/29] binman: Rename ReadContents() to ReadBlobContents()

2018-07-17 Thread Simon Glass
This function name is too generic for its purpose and is therefore
confusing. It actually only applies to blobs, so rename it to indicate
this.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/blob.py  | 4 ++--
 tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +-
 tools/binman/etype/u_boot_ucode.py  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 692d8683c3..3f46eecf30 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -29,10 +29,10 @@ class Entry_blob(Entry):
 def ObtainContents(self):
 self._filename = self.GetDefaultFilename()
 self._pathname = tools.GetInputFilename(self._filename)
-self.ReadContents()
+self.ReadBlobContents()
 return True
 
-def ReadContents(self):
+def ReadBlobContents(self):
 with open(self._pathname) as fd:
 # We assume the data is small enough to fit into memory. If this
 # is used for large filesystem image that might not be true.
diff --git a/tools/binman/etype/u_boot_dtb_with_ucode.py 
b/tools/binman/etype/u_boot_dtb_with_ucode.py
index adcb898a7b..285a28dd1e 100644
--- a/tools/binman/etype/u_boot_dtb_with_ucode.py
+++ b/tools/binman/etype/u_boot_dtb_with_ucode.py
@@ -71,7 +71,7 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob):
 # Call the base class just in case it does something important.
 Entry_blob.ObtainContents(self)
 self._pathname = control.GetFdtPath(self._filename)
-self.ReadContents()
+self.ReadBlobContents()
 if self.ucode:
 for node in self.ucode.subnodes:
 data_prop = node.props.get('data')
diff --git a/tools/binman/etype/u_boot_ucode.py 
b/tools/binman/etype/u_boot_ucode.py
index 0f1761afc8..6acf94d8cb 100644
--- a/tools/binman/etype/u_boot_ucode.py
+++ b/tools/binman/etype/u_boot_ucode.py
@@ -92,6 +92,6 @@ class Entry_u_boot_ucode(Entry_blob):
 fd.write(fdt_entry.ucode_data)
 
 self._pathname = fname
-self.ReadContents()
+self.ReadBlobContents()
 
 return True
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 23/29] dtoc: Add a function to obtain a list of phandles

2018-07-17 Thread Simon Glass
Add a function which can decode a property containing a list of phandles.
This is useful for finding nodes linked to a property. Also provide a way
to look up a single phandle and get the Fdt object from a Node.

Signed-off-by: Simon Glass 
---

 tools/dtoc/fdt.py  | 19 +++
 tools/dtoc/fdt_util.py | 18 ++
 tools/dtoc/test_fdt.py | 20 
 3 files changed, 57 insertions(+)

diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index 01e39b8a2a..d36179bad3 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -181,6 +181,14 @@ class Node:
 self.subnodes = []
 self.props = {}
 
+def GetFdt(self):
+"""Get the Fdt object for this node
+
+Returns:
+Fdt object
+"""
+return self._fdt
+
 def FindNode(self, name):
 """Find a node given its name
 
@@ -314,6 +322,17 @@ class Fdt:
 with open(self._fname) as fd:
 self._fdt_obj = libfdt.Fdt(fd.read())
 
+def LookupPhandle(self, phandle):
+"""Look up a phandle
+
+Args:
+phandle: Phandle to look up (int)
+
+Returns:
+Node object the phandle points to
+"""
+return self.phandle_to_node.get(phandle)
+
 def Scan(self, root='/'):
 """Scan a device tree, building up a tree of Node objects
 
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index d762f93a9a..5fbfc8877b 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -171,6 +171,24 @@ def GetByte(node, propname, default=None):
  (node.name, propname, len(value), 1))
 return ord(value[0])
 
+def GetPhandleList(node, propname):
+"""Get a list of phandles from a property
+
+Args:
+node: Node object to read from
+propname: property name to read
+
+Returns:
+List of phandles read, each an integer
+"""
+prop = node.props.get(propname)
+if not prop:
+return None
+value = prop.value
+if not isinstance(value, list):
+value = [value]
+return [fdt32_to_cpu(v) for v in value]
+
 def GetDatatype(node, propname, datatype):
 """Get a value of a given type from a property
 
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index abec9e57e1..6fe03ac53d 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -115,6 +115,9 @@ class TestFdt(unittest.TestCase):
 fdt.CheckErr(-libfdt.NOTFOUND, 'hello')
 self.assertIn('FDT_ERR_NOTFOUND: hello', str(e.exception))
 
+def testGetFdt(self):
+node = self.dtb.GetNode('/spl-test')
+self.assertEqual(self.dtb, node.GetFdt())
 
 class TestNode(unittest.TestCase):
 """Test operation of the Node class"""
@@ -188,6 +191,14 @@ class TestNode(unittest.TestCase):
 self.assertIn("Internal error, property 'notstring' missing, offset ",
   str(e.exception))
 
+def testLookupPhandle(self):
+"""Test looking up a single phandle"""
+dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
+node = dtb.GetNode('/phandle-source2')
+prop = node.props['clocks']
+target = dtb.GetNode('/phandle-target')
+self.assertEqual(target, dtb.LookupPhandle(fdt32_to_cpu(prop.value)))
+
 
 class TestProp(unittest.TestCase):
 """Test operation of the Prop class"""
@@ -394,6 +405,15 @@ class TestFdtUtil(unittest.TestCase):
 self.assertIn("property 'intval' has length 4, expecting 1",
   str(e.exception))
 
+def testGetPhandleList(self):
+dtb = fdt.FdtScan('tools/dtoc/dtoc_test_phandle.dts')
+node = dtb.GetNode('/phandle-source2')
+self.assertEqual([1], fdt_util.GetPhandleList(node, 'clocks'))
+node = dtb.GetNode('/phandle-source')
+self.assertEqual([1, 2, 11, 3, 12, 13, 1],
+ fdt_util.GetPhandleList(node, 'clocks'))
+self.assertEqual(None, fdt_util.GetPhandleList(node, 'missing'))
+
 def testGetDataType(self):
 self.assertEqual(1, fdt_util.GetDatatype(self.node, 'intval', int))
 self.assertEqual('message', fdt_util.GetDatatype(self.node, 
'stringval',
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 25/29] binman: Add support for adding TPL binaries

2018-07-17 Thread Simon Glass
Add support for U-Boot's TPL and TPL device tree. Also fix a few comments
in the other device-tree entries.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries  | 38 +++-
 tools/binman/etype/u_boot_spl.py |  2 +-
 tools/binman/etype/u_boot_spl_dtb.py |  2 +-
 tools/binman/etype/u_boot_tpl.py | 43 
 tools/binman/etype/u_boot_tpl_dtb.py | 25 
 tools/binman/ftest.py| 22 --
 tools/binman/test/78_u_boot_tpl.dts  | 11 +++
 7 files changed, 137 insertions(+), 6 deletions(-)
 create mode 100644 tools/binman/etype/u_boot_tpl.py
 create mode 100644 tools/binman/etype/u_boot_tpl_dtb.py
 create mode 100644 tools/binman/test/78_u_boot_tpl.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 1b75ca0052..c6e7b22609 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -365,7 +365,7 @@ This is the U-Boot SPL (Secondary Program Loader) binary. 
This is a small
 binary which loads before U-Boot proper, typically into on-chip SRAM. It is
 responsible for locating, loading and jumping to U-Boot. Note that SPL is
 not relocatable so must be loaded to the correct address in SRAM, or written
-to run from the correct address is direct flash execution is possible (e.g.
+to run from the correct address if direct flash execution is possible (e.g.
 on x86 devices).
 
 SPL can access binman symbols at runtime. See:
@@ -433,6 +433,42 @@ process.
 
 
 
+Entry: u-boot-tpl: U-Boot TPL binary
+
+
+Properties / Entry arguments:
+- filename: Filename of u-boot-tpl.bin (default 'tpl/u-boot-tpl.bin')
+
+This is the U-Boot TPL (Tertiary Program Loader) binary. This is a small
+binary which loads before SPL, typically into on-chip SRAM. It is
+responsible for locating, loading and jumping to SPL, the next-stage
+loader. Note that SPL is not relocatable so must be loaded to the correct
+address in SRAM, or written to run from the correct address if direct
+flash execution is possible (e.g. on x86 devices).
+
+SPL can access binman symbols at runtime. See:
+
+'Access to binman entry offsets at run time (symbols)'
+
+in the binman README for more information.
+
+The ELF file 'tpl/u-boot-tpl' must also be available for this to work, since
+binman uses that to look up symbols to write into the TPL binary.
+
+
+
+Entry: u-boot-tpl-dtb: U-Boot TPL device tree
+-
+
+Properties / Entry arguments:
+- filename: Filename of u-boot.dtb (default 'tpl/u-boot-tpl.dtb')
+
+This is the TPL device tree, containing configuration information for
+TPL. TPL needs this to know what devices are present and which drivers
+to activate.
+
+
+
 Entry: u-boot-ucode: U-Boot microcode block
 ---
 
diff --git a/tools/binman/etype/u_boot_spl.py b/tools/binman/etype/u_boot_spl.py
index 0e99a2d2a7..ab78714c8d 100644
--- a/tools/binman/etype/u_boot_spl.py
+++ b/tools/binman/etype/u_boot_spl.py
@@ -20,7 +20,7 @@ class Entry_u_boot_spl(Entry_blob):
 binary which loads before U-Boot proper, typically into on-chip SRAM. It is
 responsible for locating, loading and jumping to U-Boot. Note that SPL is
 not relocatable so must be loaded to the correct address in SRAM, or 
written
-to run from the correct address is direct flash execution is possible (e.g.
+to run from the correct address if direct flash execution is possible (e.g.
 on x86 devices).
 
 SPL can access binman symbols at runtime. See:
diff --git a/tools/binman/etype/u_boot_spl_dtb.py 
b/tools/binman/etype/u_boot_spl_dtb.py
index 6a30edc83c..cb29ba3fd8 100644
--- a/tools/binman/etype/u_boot_spl_dtb.py
+++ b/tools/binman/etype/u_boot_spl_dtb.py
@@ -2,7 +2,7 @@
 # Copyright (c) 2016 Google, Inc
 # Written by Simon Glass 
 #
-# Entry-type module for U-Boot device tree
+# Entry-type module for U-Boot device tree in SPL (Secondary Program Loader)
 #
 
 from entry import Entry
diff --git a/tools/binman/etype/u_boot_tpl.py b/tools/binman/etype/u_boot_tpl.py
new file mode 100644
index 00..4d4bb92596
--- /dev/null
+++ b/tools/binman/etype/u_boot_tpl.py
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass 
+#
+# Entry-type module for tpl/u-boot-tpl.bin
+#
+
+import elf
+
+from entry import Entry
+from blob import Entry_blob
+
+class Entry_u_boot_tpl(Entry_blob):
+"""U-Boot TPL binary
+
+Properties / Entry arguments:
+- filename: Filename of u-boot-tpl.bin (default 'tpl/u-boot-tpl.bin')
+
+This is the U-Boot TPL (Tertiary Program Loader) binary. This is a small
+binary which loads before SPL, typically into on-chip SRAM. It is
+responsible for locating, loading and jumping to SPL, the next-stage
+loader. Note that SPL is not relocatable so must be loaded to the correct
+address in SRAM, or written to run 

[U-Boot] [PATCH 22/29] patman: Show the current directory in GetInputFilename()

2018-07-17 Thread Simon Glass
When this fails it is useful to see the current directory, since U-Boot's
build system will typically change into the output directory during the
build. Add this information to the error.

Signed-off-by: Simon Glass 
---

 tools/patman/tools.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 006306bd60..e80481438b 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -116,8 +116,8 @@ def GetInputFilename(fname):
 if os.path.exists(pathname):
 return pathname
 
-raise ValueError("Filename '%s' not found in input path (%s)" %
- (fname, ','.join(indir)))
+raise ValueError("Filename '%s' not found in input path (%s) (cwd='%s')" %
+ (fname, ','.join(indir), os.getcwd()))
 
 def Align(pos, align):
 if align:
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 17/29] binman: Add an entry filled with a repeating byte

2018-07-17 Thread Simon Glass
It is sometimes useful to have an area of the image which is all zeroes,
or all 0xff. This can often be achieved by padding the size of an an
existing entry and setting the pad byte for an entry or image.

But it is useful to have an explicit means of adding blocks of repeating
data to the image. Add a 'fill' entry type to handle this.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries   | 16 ++
 tools/binman/etype/fill.py| 32 +++
 tools/binman/ftest.py | 13 +++
 tools/binman/test/69_fill.dts | 15 +
 tools/binman/test/70_fill_no_size.dts | 14 
 tools/dtoc/fdt_util.py| 23 +++
 tools/dtoc/test_fdt.py| 15 -
 7 files changed, 127 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/etype/fill.py
 create mode 100644 tools/binman/test/69_fill.dts
 create mode 100644 tools/binman/test/70_fill_no_size.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 147dd40bff..6f09626b24 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -55,6 +55,22 @@ updating the EC on startup via software sync.
 
 
 
+Entry: fill: An entry which is filled to a particular byte value
+
+
+Properties / Entry arguments:
+- fill-byte: Byte to use to fill the entry
+
+Note that the size property must be set since otherwise this entry does not
+know how large it should be.
+
+You can often achieve the same effect using the pad-byte property of the
+overall image, in that the space between entries will then be padded with
+that byte. But this entry is sometimes useful for explicitly setting the
+byte value of a region.
+
+
+
 Entry: fmap: An entry which contains an Fmap section
 
 
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
new file mode 100644
index 00..7210a8324a
--- /dev/null
+++ b/tools/binman/etype/fill.py
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+
+from entry import Entry
+import fdt_util
+
+
+class Entry_fill(Entry):
+"""An entry which is filled to a particular byte value
+
+Properties / Entry arguments:
+- fill-byte: Byte to use to fill the entry
+
+Note that the size property must be set since otherwise this entry does not
+know how large it should be.
+
+You can often achieve the same effect using the pad-byte property of the
+overall image, in that the space between entries will then be padded with
+that byte. But this entry is sometimes useful for explicitly setting the
+byte value of a region.
+"""
+def __init__(self, section, etype, node):
+Entry.__init__(self, section, etype, node)
+if not self.size:
+self.Raise("'fill' entry must have a size property")
+self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
+
+def ObtainContents(self):
+self.SetContents(chr(self.fill_value) * self.size)
+return True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5428ee651a..4e467145d7 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1235,6 +1235,19 @@ class TestFunctional(unittest.TestCase):
 data, _, _, _ = self._DoReadFileDtb('68_blob_named_by_arg.dts',
 entry_args=entry_args)
 
+def testFill(self):
+"""Test for an fill entry type"""
+data = self._DoReadFile('69_fill.dts')
+expected = 8 * chr(0xff) + 8 * chr(0)
+self.assertEqual(expected, data)
+
+def testFillNoSize(self):
+"""Test for an fill entry type with no size"""
+with self.assertRaises(ValueError) as e:
+self._DoReadFile('70_fill_no_size.dts')
+self.assertIn("'fill' entry must have a size property",
+  str(e.exception))
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/69_fill.dts b/tools/binman/test/69_fill.dts
new file mode 100644
index 00..e372ea37aa
--- /dev/null
+++ b/tools/binman/test/69_fill.dts
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   size = <16>;
+   fill {
+   size = <8>;
+   fill-byte = [ff];
+   };
+   };
+};
diff --git a/tools/binman/test/70_fill_no_size.dts 
b/tools/binman/test/70_fill_no_size.dts
new file mode 100644
index 00..7b1fcf1b68
--- /dev/null
+++ b/tools/binman/test/70_fill_no_size.dts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   size = <16>;
+

[U-Boot] [PATCH 26/29] binman: Show the image position in the map

2018-07-17 Thread Simon Glass
At present the map only shows the offset and size for each region. The
image position provides the actual position of each entry in the image,
regardless of the section hierarchy.

Add the image position to the map.

Signed-off-by: Simon Glass 
---

 tools/binman/bsection.py |  3 ++-
 tools/binman/entry.py|  8 +---
 tools/binman/ftest.py| 28 ++--
 tools/binman/image.py|  3 ++-
 4 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index f3a95fda8e..30c8f307a8 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -376,7 +376,8 @@ class Section(object):
 Args:
 fd: File to write the map to
 """
-Entry.WriteMapLine(fd, indent, self._name, self._offset, self._size)
+Entry.WriteMapLine(fd, indent, self._name, self._offset, self._size,
+   self._image_pos)
 for entry in self._entries.values():
 entry.WriteMap(fd, indent + 1)
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 996f03e3a6..6ce5dbdc90 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -349,8 +349,9 @@ class Entry(object):
 pass
 
 @staticmethod
-def WriteMapLine(fd, indent, name, offset, size):
-print('%s%08x  %08x  %s' % (' ' * indent, offset, size, name), file=fd)
+def WriteMapLine(fd, indent, name, offset, size, image_pos):
+print('%08x  %s%08x  %08x  %s' % (image_pos, ' ' * indent, offset,
+  size, name), file=fd)
 
 def WriteMap(self, fd, indent):
 """Write a map of the entry to a .map file
@@ -359,7 +360,8 @@ class Entry(object):
 fd: File to write the map to
 indent: Curent indent level of map (0=none, 1=one level, etc.)
 """
-self.WriteMapLine(fd, indent, self.name, self.offset, self.size)
+self.WriteMapLine(fd, indent, self.name, self.offset, self.size,
+  self.image_pos)
 
 def GetEntries(self):
 """Return a list of entries contained by this entry
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index d09868588c..ce473dfaff 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1052,25 +1052,25 @@ class TestFunctional(unittest.TestCase):
 def testMap(self):
 """Tests outputting a map of the images"""
 _, _, map_data, _ = self._DoReadFileDtb('55_sections.dts', map=True)
-self.assertEqual('''  Offset  Size  Name
-  0028  main-section
-   0010  section@0
-    0004  u-boot
- 0010  0010  section@1
-    0004  u-boot
- 0020  0004  section@2
-    0004  u-boot
+self.assertEqual('''ImagePosOffset  Size  Name
+    0028  main-section
+     0010  section@0
+  0004  u-boot
+0010   0010  0010  section@1
+0010  0004  u-boot
+0020   0020  0004  section@2
+0020  0004  u-boot
 ''', map_data)
 
 def testNamePrefix(self):
 """Tests that name prefixes are used"""
 _, _, map_data, _ = self._DoReadFileDtb('56_name_prefix.dts', map=True)
-self.assertEqual('''  Offset  Size  Name
-  0028  main-section
-   0010  section@0
-    0004  ro-u-boot
- 0010  0010  section@1
-    0004  rw-u-boot
+self.assertEqual('''ImagePosOffset  Size  Name
+    0028  main-section
+     0010  section@0
+  0004  ro-u-boot
+0010   0010  0010  section@1
+0010  0004  rw-u-boot
 ''', map_data)
 
 def testUnknownContents(self):
diff --git a/tools/binman/image.py b/tools/binman/image.py
index 4debc73451..68126bc3e6 100644
--- a/tools/binman/image.py
+++ b/tools/binman/image.py
@@ -124,5 +124,6 @@ class Image:
 filename = '%s.map' % self._name
 fname = tools.GetOutputFilename(filename)
 with open(fname, 'w') as fd:
-print('%8s  %8s  %s' % ('Offset', 'Size', 'Name'), file=fd)
+print('%8s  %8s  %8s  %s' % ('ImagePos', 'Offset', 'Size', 'Name'),
+  file=fd)
 self._section.WriteMap(fd, 0)
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 19/29] patman: Allow test commands to fall back to real ones

2018-07-17 Thread Simon Glass
Tests use the 'test_result' feature to return a predetermined command
result for particular commands. The avoids needing to have the real
command available just to run a test. It works by calling the function
provided by the test, to get the value.

However sometimes the test does need to run the real command. Allow it to
fall back to do this when the function does not return a result.

Signed-off-by: Simon Glass 
---

 tools/patman/command.py | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/patman/command.py b/tools/patman/command.py
index 598bfdcd90..14edcdaffd 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -61,8 +61,12 @@ def RunPipe(pipe_list, infile=None, outfile=None,
 """
 if test_result:
 if hasattr(test_result, '__call__'):
-return test_result(pipe_list=pipe_list)
-return test_result
+result = test_result(pipe_list=pipe_list)
+if result:
+return result
+else:
+return test_result
+# No result: fall through to normal processing
 result = CommandResult()
 last_pipe = None
 pipeline = list(pipe_list)
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 16/29] binman: Add support for a cros_ec image

2018-07-17 Thread Simon Glass
Add an entry type which can hold a Chrome OS EC.

To make this work a new entry type is created, which supports getting a
blob filename from the command line.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries| 29 ++
 tools/binman/etype/blob_named_by_arg.py| 34 ++
 tools/binman/etype/cros_ec_rw.py   | 22 ++
 tools/binman/ftest.py  | 11 +++
 tools/binman/test/68_blob_named_by_arg.dts | 12 
 5 files changed, 108 insertions(+)
 create mode 100644 tools/binman/etype/blob_named_by_arg.py
 create mode 100644 tools/binman/etype/cros_ec_rw.py
 create mode 100644 tools/binman/test/68_blob_named_by_arg.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 0b3be69f5e..147dd40bff 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -26,6 +26,35 @@ example the 'u_boot' entry which provides the filename 
'u-boot.bin'.
 
 
 
+Entry: blob-named-by-arg: A blob entry which gets its filename property from 
its subclass
+-
+
+Properties / Entry arguments:
+- -path: Filename containing the contents of this entry (optional,
+defaults to 0)
+
+where  is the blob_fname argument to the constructor.
+
+This entry cannot be used directly. Instead, it is used as a parent class
+for another entry, which defined blob_fname. This parameter is used to
+set the entry-arg or property containing the filename. The entry-arg or
+property is in turn used to set the actual filename.
+
+See cros_ec_rw for an example of this.
+
+
+
+Entry: cros-ec-rw: A blob entry which contains a Chromium OS read-write EC 
image
+
+
+Properties / Entry arguments:
+- cros-ec-rw-path: Filename containing the EC image
+
+This entry holds a Chromium OS EC (embedded controller) image, for use in
+updating the EC on startup via software sync.
+
+
+
 Entry: fmap: An entry which contains an Fmap section
 
 
diff --git a/tools/binman/etype/blob_named_by_arg.py 
b/tools/binman/etype/blob_named_by_arg.py
new file mode 100644
index 00..344112bc42
--- /dev/null
+++ b/tools/binman/etype/blob_named_by_arg.py
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+# Entry-type module for a blob where the filename comes from a property in the
+# node or an entry argument. The property is called '-path' where
+#  is provided by the subclass using this entry type.
+
+from collections import OrderedDict
+
+from blob import Entry_blob
+from entry import EntryArg
+
+
+class Entry_blob_named_by_arg(Entry_blob):
+"""A blob entry which gets its filename property from its subclass
+
+Properties / Entry arguments:
+- -path: Filename containing the contents of this entry (optional,
+defaults to 0)
+
+where  is the blob_fname argument to the constructor.
+
+This entry cannot be used directly. Instead, it is used as a parent class
+for another entry, which defined blob_fname. This parameter is used to
+set the entry-arg or property containing the filename. The entry-arg or
+property is in turn used to set the actual filename.
+
+See cros_ec_rw for an example of this.
+"""
+def __init__(self, section, etype, node, blob_fname):
+Entry_blob.__init__(self, section, etype, node)
+self._filename, = self.GetEntryArgsOrProps(
+[EntryArg('%s-path' % blob_fname, str)])
diff --git a/tools/binman/etype/cros_ec_rw.py b/tools/binman/etype/cros_ec_rw.py
new file mode 100644
index 00..261f8657a6
--- /dev/null
+++ b/tools/binman/etype/cros_ec_rw.py
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+# Entry-type module for a Chromium OS EC image (read-write section)
+#
+
+from blob_named_by_arg import Entry_blob_named_by_arg
+
+
+class Entry_cros_ec_rw(Entry_blob_named_by_arg):
+"""A blob entry which contains a Chromium OS read-write EC image
+
+Properties / Entry arguments:
+- cros-ec-rw-path: Filename containing the EC image
+
+This entry holds a Chromium OS EC (embedded controller) image, for use in
+updating the EC on startup via software sync.
+"""
+def __init__(self, section, etype, node):
+Entry_blob_named_by_arg.__init__(self, section, etype, node,
+ 'cros-ec-rw')
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index bd4de4e287..5428ee651a 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -46,6 +46,8 @@ MRC_DATA  = 'mrc'
 TEXT_DATA = 'text'
 TEXT_DATA2= 'text2'
 TEXT_DATA3= 'text3'
+CROS_EC_RW_DATA   = 'ecrw'
+
 

[U-Boot] [PATCH 20/29] patman: Add a few more helpers to the tools library

2018-07-17 Thread Simon Glass
Add functions to read and write a file, looking through a list of search
paths to find it.

Signed-off-by: Simon Glass 
---

 tools/patman/tools.py | 76 ++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 700cb4505d..006306bd60 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -3,16 +3,26 @@
 # Copyright (c) 2016 Google, Inc
 #
 
+import command
 import os
 import shutil
 import tempfile
 
 import tout
 
+# Output directly (generally this is temporary)
 outdir = None
-indirs = None
+
+# True to keep the output directory around after exiting
 preserve_outdir = False
 
+# Path to the Chrome OS chroot, if we know it
+chroot_path = None
+
+# Search paths to use for Filename(), used to find files
+search_paths = []
+
+
 def PrepareOutputDir(dirname, preserve=False):
 """Select an output directory, ensuring it exists.
 
@@ -117,3 +127,67 @@ def Align(pos, align):
 
 def NotPowerOfTwo(num):
 return num and (num & (num - 1))
+
+def Run(name, *args):
+command.Run(name, *args, cwd=outdir)
+
+def Filename(fname):
+"""Resolve a file path to an absolute path.
+
+If fname starts with ##/ and chroot is available, ##/ gets replaced with
+the chroot path. If chroot is not available, this file name can not be
+resolved, `None' is returned.
+
+If fname is not prepended with the above prefix, and is not an existing
+file, the actual file name is retrieved from the passed in string and the
+search_paths directories (if any) are searched to for the file. If found -
+the path to the found file is returned, `None' is returned otherwise.
+
+Args:
+  fname: a string,  the path to resolve.
+
+Returns:
+  Absolute path to the file or None if not found.
+"""
+if fname.startswith('##/'):
+  if chroot_path:
+fname = os.path.join(chroot_path, fname[3:])
+  else:
+return None
+
+# Search for a pathname that exists, and return it if found
+if fname and not os.path.exists(fname):
+for path in search_paths:
+pathname = os.path.join(path, os.path.basename(fname))
+if os.path.exists(pathname):
+return pathname
+
+# If not found, just return the standard, unchanged path
+return fname
+
+def ReadFile(fname):
+"""Read and return the contents of a file.
+
+Args:
+  fname: path to filename to read, where ## signifiies the chroot.
+
+Returns:
+  data read from file, as a string.
+"""
+with open(Filename(fname), 'rb') as fd:
+data = fd.read()
+#self._out.Info("Read file '%s' size %d (%#0x)" %
+   #(fname, len(data), len(data)))
+return data
+
+def WriteFile(fname, data):
+"""Write data into a file.
+
+Args:
+fname: path to filename to write
+data: data to write to file, as a string
+"""
+#self._out.Info("Write file '%s' size %d (%#0x)" %
+   #(fname, len(data), len(data)))
+with open(Filename(fname), 'wb') as fd:
+fd.write(data)
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 14/29] binman: Create README.entries

2018-07-17 Thread Simon Glass
Create a new README containing documentation for the entry types supported
by binman. This provides an easy reference in one place. It is
automatically generated from the source-code documentation.

Add a reference to this from the binman README.

Signed-off-by: Simon Glass 
---

 tools/binman/README |   9 +
 tools/binman/README.entries | 448 
 2 files changed, 457 insertions(+)
 create mode 100644 tools/binman/README.entries

diff --git a/tools/binman/README b/tools/binman/README
index d60c7fd6a3..cb34171e5f 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -453,6 +453,15 @@ name-prefix:
distinguish binaries with otherwise identical names.
 
 
+Entry Documentation
+---
+
+For details on the various entry types supported by binman and how to use them,
+see README.entries. This is generated from the source code using:
+
+   binman -E >tools/binman/README.entries
+
+
 Special properties
 --
 
diff --git a/tools/binman/README.entries b/tools/binman/README.entries
new file mode 100644
index 00..60cb2488c0
--- /dev/null
+++ b/tools/binman/README.entries
@@ -0,0 +1,448 @@
+Binman Entry Documentation
+===
+
+This file describes the entry types supported by binman. These entry types can
+be placed in an image one by one to build up a final firmware image. It is
+fairly easy to create new entry types. Just add a new file to the 'etype'
+directory. You can use the existing entries as examples.
+
+Note that some entries are subclasses of others, using and extending their
+features to produce new behaviours.
+
+
+
+Entry: blob: Entry containing an arbitrary binary blob
+--
+
+Note: This should not be used by itself. It is normally used as a parent
+class by other entry types.
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry
+
+This entry reads data from a file and places it in the entry. The
+default filename is often specified specified by the subclass. See for
+example the 'u_boot' entry which provides the filename 'u-boot.bin'.
+
+
+
+Entry: intel-cmc: Entry containing an Intel Chipset Micro Code (CMC) file
+-
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry
+
+This file contains microcode for some devices in a special format. An
+example filename is 'Microcode/C0_22211.BIN'.
+
+See README.x86 for information about x86 binary blobs.
+
+
+
+Entry: intel-descriptor: Intel flash descriptor block (4KB)
+---
+
+Properties / Entry arguments:
+filename: Filename of file containing the descriptor. This is typically
+a 4KB binary file, sometimes called 'descriptor.bin'
+
+This entry is placed at the start of flash and provides information about
+the SPI flash regions. In particular it provides the base address and
+size of the ME (Management Engine) region, allowing us to place the ME
+binary in the right place.
+
+With this entry in your image, the position of the 'intel-me' entry will be
+fixed in the image, which avoids you needed to specify an offset for that
+region. This is useful, because it is not possible to change the position
+of the ME region without updating the descriptor.
+
+See README.x86 for information about x86 binary blobs.
+
+
+
+Entry: intel-fsp: Entry containing an Intel Firmware Support Package (FSP) file
+---
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry
+
+This file contains binary blobs which are used on some devices to make the
+platform work. U-Boot executes this code since it is not possible to set up
+the hardware using U-Boot open-source code. Documentation is typically not
+available in sufficient detail to allow this.
+
+An example filename is 'FSP/QUEENSBAY_FSP_GOLD_001_20-DECEMBER-2013.fd'
+
+See README.x86 for information about x86 binary blobs.
+
+
+
+Entry: intel-me: Entry containing an Intel Management Engine (ME) file
+--
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry
+
+This file contains code used by the SoC that is required to make it work.
+The Management Engine is like a background task that runs things that are
+not clearly documented, but may include keyboard, deplay and network
+access. For platform that use ME it is not possible to disable it. U-Boot
+does not directly execute code in the ME binary.
+
+A typical filename is 'me.bin'.
+
+See README.x86 for information about x86 binary blobs.
+
+
+
+Entry: intel-mrc: Entry containing an Intel Memory Reference Code (MRC) file
+
+
+Properties / 

[U-Boot] [PATCH 11/29] binman: Allow help to work without libfdt

2018-07-17 Thread Simon Glass
At present binman needs libfdt.py to be available before it will do
anything, even print help. Import those modules later to avoid this, as it
is bad practice to fail to even show help on startup.

Signed-off-by: Simon Glass 
---

 tools/binman/control.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 4fa505da81..3e5eac2c52 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -13,8 +13,6 @@ import tools
 
 import command
 import elf
-import fdt
-import fdt_util
 from image import Image
 import tout
 
@@ -129,6 +127,11 @@ def Binman(options, args):
 options.indir.append(board_pathname)
 
 try:
+# Import these here in case libfdt.py is not available, in which case
+# the above help option still works.
+import fdt
+import fdt_util
+
 tout.Init(options.verbosity)
 elf.debug = options.debug
 try:
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 12/29] binman: Expand documentation for entries

2018-07-17 Thread Simon Glass
At present only the more complex entries are documented. It is useful to
have documentation for all entries in one place.

As a first step, add and expand the documentation to cover all entries.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/_testing.py  | 26 -
 tools/binman/etype/blob.py  | 12 ++
 tools/binman/etype/intel_cmc.py | 10 
 tools/binman/etype/intel_descriptor.py  | 18 +++---
 tools/binman/etype/intel_fsp.py | 14 +++
 tools/binman/etype/intel_me.py  | 15 
 tools/binman/etype/intel_mrc.py | 11 +
 tools/binman/etype/intel_vbt.py | 10 
 tools/binman/etype/intel_vga.py | 12 ++
 tools/binman/etype/section.py   | 17 ++
 tools/binman/etype/text.py  |  9 ++-
 tools/binman/etype/u_boot.py| 16 +
 tools/binman/etype/u_boot_dtb.py|  9 +++
 tools/binman/etype/u_boot_dtb_with_ucode.py | 12 --
 tools/binman/etype/u_boot_img.py| 11 +
 tools/binman/etype/u_boot_nodtb.py  | 11 +
 tools/binman/etype/u_boot_spl.py| 21 +
 tools/binman/etype/u_boot_spl_bss_pad.py| 16 +
 tools/binman/etype/u_boot_spl_dtb.py|  9 +++
 tools/binman/etype/u_boot_spl_nodtb.py  | 12 ++
 tools/binman/etype/u_boot_ucode.py  |  6 +
 tools/binman/etype/u_boot_with_ucode_ptr.py |  9 +--
 tools/binman/etype/x86_start16.py   | 14 +++
 tools/binman/etype/x86_start16_spl.py   | 14 +++
 24 files changed, 305 insertions(+), 9 deletions(-)

diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 3eeec72b36..02c165c0c3 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -15,8 +15,30 @@ import tools
 class Entry__testing(Entry):
 """A fake entry used for testing
 
+This entry should not be used in normal images. It is a special entry with
+strange features used for testing.
+
+Properties / Entry arguments
+test-str-fdt: Test string, normally in the node
+test-int-fdt: Test integer, normally in the node
+test-str-arg: Test string, normally in the entry arguments
+test-int-arg: Test integer, normally in the entry arguments
+
+The entry has a single 'a' byte as its contents. Operation is controlled by
+a number of properties in the node, as follows:
+
 Properties:
-return_invalid_entry: Return an invalid entry from GetOffsets()
+return-invalid-entry: Return an invalid entry from GetOffsets()
+return-unknown-contents: Refuse to provide any contents (to cause a
+failure)
+bad-update-contents: Implement ProcessContents() incorrectly so as to
+cause a failure
+never-complete-process-fdt: Refund to process the FDT (to cause a
+failure)
+require-args: Require that all used args are present (generating an
+error if not)
+force-bad-datatype: Force a call to GetEntryArgsOrProps() with a bad
+data type (generating an error)
 """
 def __init__(self, section, etype, node):
 Entry.__init__(self, section, etype, node)
@@ -26,6 +48,8 @@ class Entry__testing(Entry):
  'return-unknown-contents')
 self.bad_update_contents = fdt_util.GetBool(self._node,
 'bad-update-contents')
+
+# Set to True when the entry is ready to process the FDT.
 self.process_fdt_ready = False
 self.never_complete_process_fdt = fdt_util.GetBool(self._node,
 'never-complete-process-fdt')
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 28e6651a93..692d8683c3 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -10,6 +10,18 @@ import fdt_util
 import tools
 
 class Entry_blob(Entry):
+"""Entry containing an arbitrary binary blob
+
+Note: This should not be used by itself. It is normally used as a parent
+class by other entry types.
+
+Properties / Entry arguments:
+- filename: Filename of file to read into entry
+
+This entry reads data from a file and places it in the entry. The
+default filename is often specified specified by the subclass. See for
+example the 'u_boot' entry which provides the filename 'u-boot.bin'.
+"""
 def __init__(self, section, etype, node):
 Entry.__init__(self, section, etype, node)
 self._filename = fdt_util.GetString(self._node, "filename", self.etype)
diff --git a/tools/binman/etype/intel_cmc.py b/tools/binman/etype/intel_cmc.py
index b8621e0cc5..fa6f7793c6 100644
--- a/tools/binman/etype/intel_cmc.py

[U-Boot] [PATCH 13/29] binman: Allow creation of entry documentation

2018-07-17 Thread Simon Glass
Binman supports quite a number of different entries now. The operation of
these is not always obvious but at present the source code is the only
reference for understanding how an entry works.

Add a way to create documentation (from the source code) which can be put
in a new 'README.entries' file.

Signed-off-by: Simon Glass 
---

 tools/binman/binman.py  | 22 +++--
 tools/binman/cmdline.py |  2 +
 tools/binman/control.py |  4 +
 tools/binman/entry.py   | 93 ++---
 tools/binman/etype/u_boot_dtb_with_ucode.py |  4 +-
 tools/binman/ftest.py   | 15 
 6 files changed, 118 insertions(+), 22 deletions(-)

diff --git a/tools/binman/binman.py b/tools/binman/binman.py
index 52e02ed91b..1536e95651 100755
--- a/tools/binman/binman.py
+++ b/tools/binman/binman.py
@@ -77,9 +77,20 @@ def RunTests(debug, args):
   return 1
 return 0
 
+def GetEntryModules(include_testing=True):
+"""Get a set of entry class implementations
+
+Returns:
+Set of paths to entry class filenames
+"""
+glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
+return set([os.path.splitext(os.path.basename(item))[0]
+for item in glob_list
+if include_testing or '_testing' not in item])
+
 def RunTestCoverage():
 """Run the tests and check that we get 100% coverage"""
-glob_list = glob.glob(os.path.join(our_path, 'etype/*.py'))
+glob_list = GetEntryModules(False)
 all_set = set([os.path.splitext(os.path.basename(item))[0]
for item in glob_list if '_testing' not in item])
 test_util.RunTestCoverage('tools/binman/binman.py', None,
@@ -107,13 +118,8 @@ def RunBinman(options, args):
 elif options.test_coverage:
 RunTestCoverage()
 
-elif options.full_help:
-pager = os.getenv('PAGER')
-if not pager:
-pager = 'more'
-fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
-'README')
-command.Run(pager, fname)
+elif options.entry_docs:
+control.WriteEntryDocs(GetEntryModules())
 
 else:
 try:
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 54e4fb13dc..f0de4ded44 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -28,6 +28,8 @@ def ParseArgs(argv):
 help='Configuration file (.dtb) to use')
 parser.add_option('-D', '--debug', action='store_true',
 help='Enabling debugging (provides a full traceback on error)')
+parser.add_option('-E', '--entry-docs', action='store_true',
+help='Write out entry documentation (see README.entries)')
 parser.add_option('-I', '--indir', action='append',
 help='Add a path to a directory to use for input files')
 parser.add_option('-H', '--full-help', action='store_true',
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 3e5eac2c52..188a52b72b 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -92,6 +92,10 @@ def SetEntryArgs(args):
 def GetEntryArg(name):
 return entry_args.get(name)
 
+def WriteEntryDocs(modules, test_missing=None):
+from entry import Entry
+Entry.WriteDocs(modules, test_missing)
+
 def Binman(options, args):
 """The main control code for binman
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index de07f27215..dc09b81677 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -78,20 +78,18 @@ class Entry(object):
 self.ReadNode()
 
 @staticmethod
-def Create(section, node, etype=None):
-"""Create a new entry for a node.
+def Lookup(section, node_path, etype):
+"""Look up the entry class for a node.
 
 Args:
-section:  Section object containing this node
-node:   Node object containing information about the entry to 
create
-etype:  Entry type to use, or None to work it out (used for tests)
+section:   Section object containing this node
+node_node: Path name of Node object containing information about
+   the entry to create (used for errors)
+etype:   Entry type to use
 
 Returns:
-A new Entry object of the correct type (a subclass of Entry)
+The entry class object if found, else None
 """
-if not etype:
-etype = fdt_util.GetString(node, 'type', node.name)
-
 # Convert something like 'u-boot@0' to 'u_boot' since we are only
 # interested in the type.
 module_name = etype.replace('-', '_')
@@ -110,15 +108,34 @@ class Entry(object):
 module = importlib.import_module(module_name)
 else:
 module = __import__(module_name)
-except ImportError:
-raise ValueError("Unknown entry type '%s' 

[U-Boot] [PATCH 15/29] binman: Add support for flashrom FMAP

2018-07-17 Thread Simon Glass
Add an entry which can hold an FMAP region as used by flashrom, an
open-source flashing tool used on Linux x86 machines. This provides a
simplified non-hierarchical view of the entries in the image and has a
signature at the start to allow flashrom to find it in the image.

Signed-off-by: Simon Glass 
---

 tools/binman/README.entries   |  20 +++
 tools/binman/entry.py |   9 +++
 tools/binman/etype/fmap.py|  61 +++
 tools/binman/etype/section.py |   7 ++-
 tools/binman/fmap_util.py | 109 ++
 tools/binman/ftest.py |  32 ++
 tools/binman/test/67_fmap.dts |  29 +
 7 files changed, 265 insertions(+), 2 deletions(-)
 create mode 100644 tools/binman/etype/fmap.py
 create mode 100644 tools/binman/fmap_util.py
 create mode 100644 tools/binman/test/67_fmap.dts

diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 60cb2488c0..0b3be69f5e 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -26,6 +26,26 @@ example the 'u_boot' entry which provides the filename 
'u-boot.bin'.
 
 
 
+Entry: fmap: An entry which contains an Fmap section
+
+
+Properties / Entry arguments:
+None
+
+FMAP is a simple format used by flashrom, an open-source utility for
+reading and writing the SPI flash, typically on x86 CPUs. The format
+provides flashrom with a list of areas, so it knows what it in the flash.
+It can then read or write just a single area, instead of the whole flash.
+
+The format is defined by the flashrom project, in the file lib/fmap.h -
+see www.flashrom.org/Flashrom for more information.
+
+When used, this entry will be populated with an FMAP which reflects the
+entries in the current image. Note that any hierarchy is squashed, since
+FMAP does not support this.
+
+
+
 Entry: intel-cmc: Entry containing an Intel Chipset Micro Code (CMC) file
 -
 
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index dc09b81677..8b910feff6 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -361,6 +361,15 @@ class Entry(object):
 """
 self.WriteMapLine(fd, indent, self.name, self.offset, self.size)
 
+def GetEntries(self):
+"""Return a list of entries contained by this entry
+
+Returns:
+List of entries, or None if none. A normal entry has no entries
+within it so will return None
+"""
+return None
+
 def GetArg(self, name, datatype=str):
 """Get the value of an entry argument or device-tree-node property
 
diff --git a/tools/binman/etype/fmap.py b/tools/binman/etype/fmap.py
new file mode 100644
index 00..f1dd81ec49
--- /dev/null
+++ b/tools/binman/etype/fmap.py
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+# Entry-type module for a Flash map, as used by the flashrom SPI flash tool
+#
+
+from entry import Entry
+import fmap_util
+
+
+class Entry_fmap(Entry):
+"""An entry which contains an Fmap section
+
+Properties / Entry arguments:
+None
+
+FMAP is a simple format used by flashrom, an open-source utility for
+reading and writing the SPI flash, typically on x86 CPUs. The format
+provides flashrom with a list of areas, so it knows what it in the flash.
+It can then read or write just a single area, instead of the whole flash.
+
+The format is defined by the flashrom project, in the file lib/fmap.h -
+see www.flashrom.org/Flashrom for more information.
+
+When used, this entry will be populated with an FMAP which reflects the
+entries in the current image. Note that any hierarchy is squashed, since
+FMAP does not support this.
+"""
+def __init__(self, section, etype, node):
+Entry.__init__(self, section, etype, node)
+
+def _GetFmap(self):
+"""Build an FMAP from the entries in the current image
+
+Returns:
+FMAP binary data
+"""
+def _AddEntries(areas, entry):
+entries = entry.GetEntries()
+if entries:
+for subentry in entries.values():
+_AddEntries(areas, subentry)
+else:
+areas.append(fmap_util.FmapArea(entry.image_pos or 0,
+entry.size or 0, entry.name, 
0))
+
+entries = self.section.GetEntries()
+areas = []
+for entry in entries.values():
+_AddEntries(areas, entry)
+return fmap_util.EncodeFmap(self.section.GetSize() or 0, self.name,
+areas)
+
+def ObtainContents(self):
+"""Obtain a placeholder for the fmap contents"""
+self.SetContents(self._GetFmap())
+return True
+
+def ProcessContents(self):
+

[U-Boot] [PATCH 07/29] binman: Add a new 'image-pos' property

2018-07-17 Thread Simon Glass
At present each entry has an offset within its parent section. This is
useful for figuring out how entries relate to one another. However it
is sometimes necessary to locate an entry within an image, regardless
of which sections it is nested inside.

Add a new 'image-pos' property to provide this information. Also add
some documentation for the -u option binman provides, which updates the
device tree with final entry information.

Signed-off-by: Simon Glass 
---

 tools/binman/README   | 22 --
 tools/binman/bsection.py  |  8 +++-
 tools/binman/control.py   |  1 +
 tools/binman/entry.py | 12 +++-
 tools/binman/etype/section.py |  4 
 tools/binman/ftest.py |  9 -
 tools/binman/image.py |  3 +++
 7 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/tools/binman/README b/tools/binman/README
index 4b13776ffa..df88819a1c 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -324,6 +324,12 @@ offset-unset:
property is present, binman will give an error if another entry does
not set the offset (with the GetOffsets() method).
 
+image-pos:
+   This cannot be set on entry (or at least it is ignored if it is), but
+   with the -u option, binman will set it to the absolute image position
+   for each entry. This makes it easy to find out exactly where the entry
+   ended up in the image, regardless of parent sections, etc.
+
 
 The attributes supported for images are described below. Several are similar
 to those for entries.
@@ -550,8 +556,8 @@ the 'warning' line in scripts/Makefile.lib to see what it 
has found:
# u_boot_dtsi_options_debug = $(u_boot_dtsi_options_raw)
 
 
-Access to binman entry offsets at run time
---
+Access to binman entry offsets at run time (symbols)
+
 
 Binman assembles images and determines where each entry is placed in the image.
 This information may be useful to U-Boot at run time. For example, in SPL it
@@ -577,6 +583,18 @@ At present this feature is only supported in SPL. In 
principle it is possible
 to fill in such symbols in U-Boot proper, as well.
 
 
+Access to binman entry offsets at run time (fdt)
+
+
+Binman can update the U-Boot FDT to include the final position and size of
+each entry in the images it processes. The option to enable this is -u and it
+causes binman to make sure that the 'offset', 'image-pos' and 'size' properties
+are set correctly for every entry. Since it is not necessary to specify these 
in
+the image definition, binman calculates the final values and writes these to
+the device tree. These can be used by U-Boot at run-time to find the location
+of each entry.
+
+
 Map files
 -
 
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index 1604b9915e..47fe37ccb9 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -96,7 +96,7 @@ class Section(object):
 
 def AddMissingProperties(self):
 """Add new properties to the device tree as needed for this entry"""
-for prop in ['offset', 'size']:
+for prop in ['offset', 'size', 'image-pos']:
 if not prop in self._node.props:
 self._node.AddZeroProp(prop)
 for entry in self._entries.values():
@@ -105,6 +105,7 @@ class Section(object):
 def SetCalculatedProperties(self):
 self._node.SetInt('offset', self._offset)
 self._node.SetInt('size', self._size)
+self._node.SetInt('image-pos', self._image_pos)
 for entry in self._entries.values():
 entry.SetCalculatedProperties()
 
@@ -260,6 +261,11 @@ class Section(object):
 offset = entry.offset + entry.size
 prev_name = entry.GetPath()
 
+def SetImagePos(self, image_pos):
+self._image_pos = image_pos
+for entry in self._entries.values():
+entry.SetImagePos(image_pos)
+
 def ProcessEntryContents(self):
 """Call the ProcessContents() method for each entry
 
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 97652334e0..43d192c9a7 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -161,6 +161,7 @@ def Binman(options, args):
 image.PackEntries()
 image.CheckSize()
 image.CheckEntries()
+image.SetImagePos()
 if options.update_fdt:
 image.SetCalculatedProperties()
 image.ProcessEntryContents()
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index cb693c9382..8004918eb5 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -64,6 +64,7 @@ class Entry(object):
 self.pad_before = 0
 self.pad_after = 0
 self.offset_unset = False
+self.image_pos = None
 if read_node:
 

[U-Boot] [PATCH 10/29] binman: Support an entry that holds text

2018-07-17 Thread Simon Glass
It is useful to able to write an identifying string to the image within an
entry. Add a 'text' entry type to handle this. The actual text is
typically passed to binman on the command line. The text is not itself
nul-terminated but this can be achieved if required by setting the size of
the entry to something larger than the text.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/text.py| 50 +++
 tools/binman/ftest.py | 16 +++
 tools/binman/test/66_text.dts | 28 
 3 files changed, 94 insertions(+)
 create mode 100644 tools/binman/etype/text.py
 create mode 100644 tools/binman/test/66_text.dts

diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py
new file mode 100644
index 00..1c69afa72e
--- /dev/null
+++ b/tools/binman/etype/text.py
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass 
+#
+
+from collections import OrderedDict
+
+from entry import Entry, EntryArg
+import fdt_util
+
+
+class Entry_text(Entry):
+"""An entry which contains text
+
+The text can be provided either in the node itself or by a command-line
+argument.
+
+Example node:
+
+text {
+size = <50>;
+text-label = "message";
+};
+
+You can then use:
+
+binman -amessage="this is my message"
+
+and binman will insert that string into the entry.
+
+It is also possible to put the string directly in the node:
+
+text {
+size = <8>;
+text-label = "message";
+message = "a message directly in the node"
+};
+
+The text is not itself nul-terminated. This can be achieved, if required,
+by setting the size of the entry to something larger than the text.
+"""
+def __init__(self, section, etype, node):
+Entry.__init__(self, section, etype, node)
+self.text_label, = self.GetEntryArgsOrProps(
+[EntryArg('text-label', str)])
+self.value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, 
str)])
+
+def ObtainContents(self):
+self.SetContents(self.value)
+return True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index c54cd12e71..696889601e 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -41,6 +41,9 @@ FSP_DATA  = 'fsp'
 CMC_DATA  = 'cmc'
 VBT_DATA  = 'vbt'
 MRC_DATA  = 'mrc'
+TEXT_DATA = 'text'
+TEXT_DATA2= 'text2'
+TEXT_DATA3= 'text3'
 
 class TestFunctional(unittest.TestCase):
 """Functional tests for binman
@@ -1161,6 +1164,19 @@ class TestFunctional(unittest.TestCase):
 self.assertIn('GetArg() internal error: Unknown data type ',
   str(e.exception))
 
+def testText(self):
+"""Test for a text entry type"""
+entry_args = {
+'test-id': TEXT_DATA,
+'test-id2': TEXT_DATA2,
+'test-id3': TEXT_DATA3,
+}
+data, _, _, _ = self._DoReadFileDtb('66_text.dts',
+entry_args=entry_args)
+expected = (TEXT_DATA + chr(0) * (8 - len(TEXT_DATA)) + TEXT_DATA2 +
+TEXT_DATA3 + 'some text')
+self.assertEqual(expected, data)
+
 
 if __name__ == "__main__":
 unittest.main()
diff --git a/tools/binman/test/66_text.dts b/tools/binman/test/66_text.dts
new file mode 100644
index 00..59b1fed0ef
--- /dev/null
+++ b/tools/binman/test/66_text.dts
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   binman {
+   text {
+   size = <8>;
+   text-label = "test-id";
+   };
+   text2 {
+   type = "text";
+   text-label = "test-id2";
+   };
+   text3 {
+   type = "text";
+   text-label = "test-id3";
+   };
+   /* This one does not use command-line args */
+   text4 {
+   type = "text";
+   text-label = "test-id4";
+   test-id4 = "some text";
+   };
+   };
+};
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 09/29] binman: Add support for passing arguments to entries

2018-07-17 Thread Simon Glass
Sometimes it is useful to pass binman the value of an entry property from
the command line. For example some entries need access to files and it is
not always convenient to put these filenames in the image definition
(device tree).

Add a -a option which can be used like this:

   -a=

where

is the property to set
is the value to set it to

Signed-off-by: Simon Glass 
---

 tools/binman/README   | 20 +
 tools/binman/cmdline.py   |  2 +
 tools/binman/control.py   | 19 +
 tools/binman/entry.py | 69 +++
 tools/binman/etype/_testing.py| 19 -
 tools/binman/ftest.py | 83 ++-
 tools/binman/test/62_entry_args.dts   | 14 
 tools/binman/test/63_entry_args_missing.dts   | 13 +++
 tools/binman/test/64_entry_args_required.dts  | 14 
 .../test/65_entry_args_unknown_datatype.dts   | 15 
 tools/dtoc/fdt_util.py| 21 +
 tools/dtoc/test_fdt.py|  8 ++
 12 files changed, 293 insertions(+), 4 deletions(-)
 create mode 100644 tools/binman/test/62_entry_args.dts
 create mode 100644 tools/binman/test/63_entry_args_missing.dts
 create mode 100644 tools/binman/test/64_entry_args_required.dts
 create mode 100644 tools/binman/test/65_entry_args_unknown_datatype.dts

diff --git a/tools/binman/README b/tools/binman/README
index df88819a1c..d60c7fd6a3 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -615,6 +615,26 @@ each entry is also shown, in bytes (hex). The indentation 
shows the entries
 nested inside their sections.
 
 
+Passing command-line arguments to entries
+-
+
+Sometimes it is useful to pass binman the value of an entry property from the
+command line. For example some entries need access to files and it is not
+always convenient to put these filenames in the image definition (device tree).
+
+The-a option supports this:
+
+-a=
+
+where
+
+ is the property to set
+ is the value to set it to
+
+Not all properties can be provided this way. Only some entries support it,
+typically for filenames.
+
+
 Code coverage
 -
 
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 5c9b4dfead..54e4fb13dc 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -18,6 +18,8 @@ def ParseArgs(argv):
 args is a list of string arguments
 """
 parser = OptionParser()
+parser.add_option('-a', '--entry-arg', type='string', action='append',
+help='Set argument value arg=value')
 parser.add_option('-b', '--board', type='string',
 help='Board name to build')
 parser.add_option('-B', '--build-dir', type='string', default='b',
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 43d192c9a7..4fa505da81 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -7,6 +7,7 @@
 
 from collections import OrderedDict
 import os
+import re
 import sys
 import tools
 
@@ -25,6 +26,9 @@ images = OrderedDict()
 # 'u-boot-spl.dtb')
 fdt_files = {}
 
+# Arguments passed to binman to provide arguments to entries
+entry_args = {}
+
 
 def _ReadImageDesc(binman_node):
 """Read the image descriptions from the /binman node
@@ -76,6 +80,20 @@ def GetFdt(fname):
 def GetFdtPath(fname):
 return fdt_files[fname]._fname
 
+def SetEntryArgs(args):
+global entry_args
+
+entry_args = {}
+if args:
+for arg in args:
+m = re.match('([^=]*)=(.*)', arg)
+if not m:
+raise ValueError("Invalid entry arguemnt '%s'" % arg)
+entry_args[m.group(1)] = m.group(2)
+
+def GetEntryArg(name):
+return entry_args.get(name)
+
 def Binman(options, args):
 """The main control code for binman
 
@@ -116,6 +134,7 @@ def Binman(options, args):
 try:
 tools.SetInputDirs(options.indir)
 tools.PrepareOutputDir(options.outdir, options.preserve)
+SetEntryArgs(options.entry_arg)
 
 # Get the device tree ready by compiling it and copying the 
compiled
 # output into a file in our output directly. Then scan it for use
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 8004918eb5..de07f27215 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -6,6 +6,8 @@
 
 from __future__ import print_function
 
+from collections import namedtuple
+
 # importlib was introduced in Python 2.7 but there was a report of it not
 # working in 2.7.12, so we work around this:
 # http://lists.denx.de/pipermail/u-boot/2016-October/269729.html
@@ -16,6 +18,7 @@ except:
 have_importlib = False
 
 import fdt_util
+import control
 import os
 import sys
 import tools
@@ -24,6 +27,12 @@ modules = {}
 
 our_path = os.path.dirname(os.path.realpath(__file__))
 
+
+# An argument which can be passed to entries on the command line, 

[U-Boot] [PATCH 08/29] dtoc: Add missing comments to fdt_util

2018-07-17 Thread Simon Glass
This module has a few missing comments. Add them.

Signed-off-by: Simon Glass 
---

 tools/dtoc/fdt_util.py | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 5b631419a9..05cb9c0775 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -5,6 +5,9 @@
 # Written by Simon Glass 
 #
 
+# Utility functions for reading from a device tree. Once the upstream pylibfdt
+# implementation advances far enough, we should be able to drop these.
+
 import os
 import struct
 import sys
@@ -90,6 +93,16 @@ def EnsureCompiled(fname, capture_stderr=False):
 return dtb_output
 
 def GetInt(node, propname, default=None):
+"""Get an integer from a property
+
+Args:
+node: Node object to read from
+propname: property name to read
+default: Default value to use if the node/property do not exist
+
+Returns:
+Integer value read, or default if none
+"""
 prop = node.props.get(propname)
 if not prop:
 return default
@@ -100,6 +113,16 @@ def GetInt(node, propname, default=None):
 return value
 
 def GetString(node, propname, default=None):
+"""Get a string from a property
+
+Args:
+node: Node object to read from
+propname: property name to read
+default: Default value to use if the node/property do not exist
+
+Returns:
+String value read, or default if none
+"""
 prop = node.props.get(propname)
 if not prop:
 return default
@@ -110,6 +133,17 @@ def GetString(node, propname, default=None):
 return value
 
 def GetBool(node, propname, default=False):
+"""Get an boolean from a property
+
+Args:
+node: Node object to read from
+propname: property name to read
+default: Default value to use if the node/property do not exist
+
+Returns:
+Boolean value read, or default if none (if you set this to True the
+function will always return True)
+"""
 if propname in node.props:
 return True
 return default
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 05/29] binman: Enhance the map and fdt-update output

2018-07-17 Thread Simon Glass
At present the .map file produced for each image does not include the
overall image size. This is useful information.

Update the code to generate it in the .map file as well as the updated
FDT. Also fix a few comments while we are here.

Signed-off-by: Simon Glass 
---

 tools/binman/README   |  9 +
 tools/binman/bsection.py  | 32 +--
 tools/binman/entry.py | 13 -
 tools/binman/etype/section.py |  6 +++---
 tools/binman/ftest.py | 24 ++-
 tools/binman/test/55_sections.dts |  4 
 6 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/tools/binman/README b/tools/binman/README
index 5ff20f15c6..4b13776ffa 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -584,10 +584,11 @@ The -m option causes binman to output a .map file for 
each image that it
 generates. This shows the offset and size of each entry. For example:
 
   Offset  Size  Name
-  0010  section@0
-   0004  u-boot
-0010  0010  section@1
-   0004  u-boot
+  0028  main-section
+   0010  section@0
+    0004  u-boot
+ 0010  0010  section@1
+    0004  u-boot
 
 This shows a hierarchical image with two sections, each with a single entry. 
The
 offsets of the sections are absolute hex byte offsets within the image. The
diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py
index d78a25e83d..1604b9915e 100644
--- a/tools/binman/bsection.py
+++ b/tools/binman/bsection.py
@@ -50,6 +50,7 @@ class Section(object):
 import entry
 from entry import Entry
 
+self._name = name
 self._node = node
 self._offset = 0
 self._size = None
@@ -90,11 +91,20 @@ class Section(object):
 entry.SetPrefix(self._name_prefix)
 self._entries[node.name] = entry
 
+def SetOffset(self, offset):
+self._offset = offset
+
 def AddMissingProperties(self):
+"""Add new properties to the device tree as needed for this entry"""
+for prop in ['offset', 'size']:
+if not prop in self._node.props:
+self._node.AddZeroProp(prop)
 for entry in self._entries.values():
 entry.AddMissingProperties()
 
 def SetCalculatedProperties(self):
+self._node.SetInt('offset', self._offset)
+self._node.SetInt('size', self._size)
 for entry in self._entries.values():
 entry.SetCalculatedProperties()
 
@@ -269,7 +279,7 @@ class Section(object):
 fd.write(self.GetData())
 
 def GetData(self):
-"""Write the section to a file"""
+"""Get the contents of the section"""
 section_data = chr(self._pad_byte) * self._size
 
 for entry in self._entries.values():
@@ -335,13 +345,31 @@ class Section(object):
 raise ValueError("%s: No such property '%s'" % (msg, prop_name))
 
 def GetEntries(self):
+"""Get the number of entries in a section
+
+Returns:
+Number of entries in a section
+"""
 return self._entries
 
+def GetSize(self):
+"""Get the size of a section in bytes
+
+This is only meaningful if the section has a pre-defined size, or the
+entries within it have been packed, so that the size has been
+calculated.
+
+Returns:
+Entry size in bytes
+"""
+return self._size
+
 def WriteMap(self, fd, indent):
 """Write a map of the section to a .map file
 
 Args:
 fd: File to write the map to
 """
+Entry.WriteMapLine(fd, indent, self._name, self._offset, self._size)
 for entry in self._entries.values():
-entry.WriteMap(fd, indent)
+entry.WriteMap(fd, indent + 1)
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index c9529d8322..cb693c9382 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -36,7 +36,7 @@ class Entry(object):
 Entry.
 
 Attributes:
-section: The section containing this entry
+section: Section object containing this entry
 node: The node that created this entry
 offset: Offset of entry within the section, None if not known yet (in
 which case it will be calculated by Pack())
@@ -72,7 +72,7 @@ class Entry(object):
 """Create a new entry for a node.
 
 Args:
-section:  Image object containing this node
+section:  Section object containing this node
 node:   Node object containing information about the entry to 
create
 etype:  Entry type to use, or None to work it out (used for tests)
 
@@ -133,7 +133,7 @@ class Entry(object):
 
 def AddMissingProperties(self):
 """Add new properties to the device tree as needed for this entry"""
-

[U-Boot] [PATCH 06/29] binman: Update the device-tree file on exit

2018-07-17 Thread Simon Glass
Binman can make additions to the device tree which are useful to U-Boot
when it runs (e.g. the position of each entry in the image). Write the
changes back so that they are easily accessible.

Signed-off-by: Simon Glass 
---

 tools/binman/control.py | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 17c6d7a2d2..97652334e0 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -168,8 +168,12 @@ def Binman(options, args):
 image.BuildImage()
 if options.map:
 image.WriteMap()
+# Write the updated FDT to our output file, and also back to the
+# input file, so it is visible after binman exits.
 with open(fname, 'wb') as outfd:
 outfd.write(dtb.GetContents())
+with open(dtb_fname, 'wb') as outfd:
+outfd.write(dtb.GetContents())
 finally:
 tools.FinaliseOutputDir()
 finally:
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 04/29] binman: Tidy up some comments in the tests

2018-07-17 Thread Simon Glass
A few lines are commented out and can be removed. Also fix return-value
docs for _DoReadFile() and _DoReadFileDtb().

Signed-off-by: Simon Glass 
---

 tools/binman/ftest.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 1efedc2ec3..91b59f84ea 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -212,6 +212,7 @@ class TestFunctional(unittest.TestCase):
 Resulting image contents
 Device tree contents
 Map data showing contents of image (or None if none)
+Output device tree binary filename ('u-boot.dtb' path)
 """
 dtb_data = None
 # Use the compiled test file as the u-boot-dtb input
@@ -249,6 +250,9 @@ class TestFunctional(unittest.TestCase):
 the u-boot-dtb entry. Normally this is not needed and the
 test contents (the U_BOOT_DTB_DATA string) can be used.
 But in some test we need the real contents.
+
+Returns:
+Resulting image contents
 """
 return self._DoReadFileDtb(fname, use_real_dtb)[0]
 
@@ -312,7 +316,6 @@ class TestFunctional(unittest.TestCase):
 def AddNode(node, path):
 if node.name != '/':
 path += '/' + node.name
-#print 'path', path
 for subnode in node.subnodes:
 for prop in subnode.props.values():
 if prop.name in node_names:
@@ -408,7 +411,6 @@ class TestFunctional(unittest.TestCase):
 with self.assertRaises(Exception) as e:
 result = self._RunBinman('-d',
  self.TestFile('04_invalid_entry.dts'))
-#print e.exception
 self.assertIn("Unknown entry type 'not-a-valid-type' in node "
 "'/binman/not-a-valid-type'", str(e.exception))
 
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 02/29] binman: Rename 'position' to 'offset'

2018-07-17 Thread Simon Glass
After some thought, I believe there is an unfortunate naming flaw in
binman. Entries have a position and size, but now that we support
hierarchical sections it is unclear whether a position should be an
absolute position within the image, or a relative position within its
parent section.

At present 'position' actually means the relative position. This indicates
a need for an 'image position' for code that wants to find the location of
an entry without having to do calculations back through parents to
discover this image position.

A better name for the current 'position' or 'pos' is 'offset'. It is not
always an absolute position, but it is always an offset from its parent
offset.

It is unfortunate to rename this concept now, 18 months after binman was
introduced. However I believe it is the right thing to do. The impact is
mostly limited to binman itself and a few changes to in-tree users to
binman:

   tegra
   sunxi
   x86

The change makes old binman definitions (e.g. downstream or out-of-tree)
incompatible if they use the 'pos = <...>' property. Later work will
adjust binman to generate an error when it is used.

Signed-off-by: Simon Glass 
---

 arch/arm/dts/sunxi-u-boot.dtsi|   2 +-
 arch/arm/dts/tegra-u-boot.dtsi|   6 +-
 arch/x86/dts/u-boot.dtsi  |  24 ++---
 tools/binman/README   |  79 
 tools/binman/bsection.py  |  88 +-
 tools/binman/cmdline.py   |   2 +-
 tools/binman/control.py   |   4 +-
 tools/binman/elf.py   |   6 +-
 tools/binman/entry.py |  73 ---
 tools/binman/etype/_testing.py|   4 +-
 tools/binman/etype/intel_descriptor.py|   8 +-
 tools/binman/etype/section.py |  14 +--
 tools/binman/etype/u_boot_dtb_with_ucode.py   |   4 +-
 tools/binman/etype/u_boot_ucode.py|   4 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  35 +++
 tools/binman/ftest.py |  85 +
 tools/binman/image.py |  12 +--
 tools/binman/test/08_pack.dts |   2 +-
 tools/binman/test/12_pack_inv_align.dts   |   2 +-
 tools/binman/test/14_pack_overlap.dts |   2 +-
 tools/binman/test/21_image_pad.dts|   2 +-
 tools/binman/test/24_sorted.dts   |   6 +-
 tools/binman/test/25_pack_zero_size.dts   |   2 +-
 tools/binman/test/27_pack_4gb_no_size.dts |   6 +-
 tools/binman/test/28_pack_4gb_outside.dts |   6 +-
 tools/binman/test/29_x86-rom.dts  |   6 +-
 tools/binman/test/30_x86-rom-me-no-desc.dts   |   4 +-
 tools/binman/test/31_x86-rom-me.dts   |   4 +-
 tools/binman/test/34_x86_ucode.dts|   2 +-
 tools/binman/test/35_x86_single_ucode.dts |   2 +-
 tools/binman/test/37_x86_no_ucode.dts |   2 +-
 .../binman/test/38_x86_ucode_missing_node.dts |   2 +-
 .../test/39_x86_ucode_missing_node2.dts   |   2 +-
 .../binman/test/40_x86_ucode_not_in_image.dts |   2 +-
 tools/binman/test/44_x86_optional_ucode.dts   |   2 +-
 tools/binman/test/45_prop_test.dts|   4 +-
 tools/binman/test/49_x86_ucode_spl.dts|   2 +-
 tools/binman/test/53_symbols.dts  |   2 +-
 .../test/58_x86_ucode_spl_needs_retry.dts |   2 +-
 tools/binman/test/u_boot_binman_syms  | Bin 4921 -> 4916 bytes
 tools/binman/test/u_boot_binman_syms.c|   6 +-
 41 files changed, 263 insertions(+), 259 deletions(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 5adfd9bca2..8a9f2a6417 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -8,7 +8,7 @@
filename = "spl/sunxi-spl.bin";
};
u-boot-img {
-   pos = ;
+   offset = ;
};
};
 };
diff --git a/arch/arm/dts/tegra-u-boot.dtsi b/arch/arm/dts/tegra-u-boot.dtsi
index 4f692ee975..fe19619919 100644
--- a/arch/arm/dts/tegra-u-boot.dtsi
+++ b/arch/arm/dts/tegra-u-boot.dtsi
@@ -15,7 +15,7 @@
u-boot-spl {
};
u-boot {
-   pos = <(U_BOOT_OFFSET)>;
+   offset = <(U_BOOT_OFFSET)>;
};
};
 
@@ -26,7 +26,7 @@
u-boot-spl {
};
u-boot {
-   pos = <(U_BOOT_OFFSET)>;
+   offset = <(U_BOOT_OFFSET)>;
};
};
 
@@ -36,7 +36,7 @@
u-boot-spl {
};
u-boot-nodtb {
-   pos = <(U_BOOT_OFFSET)>;
+   offset = 

[U-Boot] [PATCH 03/29] binman: Add comments to elf_test

2018-07-17 Thread Simon Glass
The purpose of some of the tests is not obvious from the function names.
Add a few comments to help with understanding.

Signed-off-by: Simon Glass 
---

 tools/binman/elf_test.py | 33 +
 1 file changed, 33 insertions(+)

diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py
index 9c8f1feca8..c16f71401d 100644
--- a/tools/binman/elf_test.py
+++ b/tools/binman/elf_test.py
@@ -15,6 +15,10 @@ binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
 
 
 class FakeEntry:
+"""A fake Entry object, usedfor testing
+
+This supports an entry with a given size.
+"""
 def __init__(self, contents_size):
 self.contents_size = contents_size
 self.data = 'a' * contents_size
@@ -22,7 +26,14 @@ class FakeEntry:
 def GetPath(self):
 return 'entry_path'
 
+
 class FakeSection:
+"""A fake Section object, used for testing
+
+This has the minimum feature set needed to support testing elf functions.
+A LookupSymbol() function is provided which returns a fake value for amu
+symbol requested.
+"""
 def __init__(self, sym_value=1):
 self.sym_value = sym_value
 
@@ -30,15 +41,19 @@ class FakeSection:
 return 'section_path'
 
 def LookupSymbol(self, name, weak, msg):
+"""Fake implementation which returns the same value for all symbols"""
 return self.sym_value
 
+
 class TestElf(unittest.TestCase):
 def testAllSymbols(self):
+"""Test that we can obtain a symbol from the ELF file"""
 fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr')
 syms = elf.GetSymbols(fname, [])
 self.assertIn('.ucode', syms)
 
 def testRegexSymbols(self):
+"""Test that we can obtain from the ELF file by regular expression"""
 fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr')
 syms = elf.GetSymbols(fname, ['ucode'])
 self.assertIn('.ucode', syms)
@@ -48,6 +63,7 @@ class TestElf(unittest.TestCase):
 self.assertIn('.ucode', syms)
 
 def testMissingFile(self):
+"""Test that a missing file is detected"""
 entry = FakeEntry(10)
 section = FakeSection()
 with self.assertRaises(ValueError) as e:
@@ -56,6 +72,7 @@ class TestElf(unittest.TestCase):
   str(e.exception))
 
 def testOutsideFile(self):
+"""Test a symbol which extends outside the entry area is detected"""
 entry = FakeEntry(10)
 section = FakeSection()
 elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
@@ -65,6 +82,11 @@ class TestElf(unittest.TestCase):
   'is a', str(e.exception))
 
 def testMissingImageStart(self):
+"""Test that we detect a missing __image_copy_start symbol
+
+This is needed to mark the start of the image. Without it we cannot
+locate the offset of a binman symbol within the image.
+"""
 entry = FakeEntry(10)
 section = FakeSection()
 elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms_bad')
@@ -72,6 +94,11 @@ class TestElf(unittest.TestCase):
  None)
 
 def testBadSymbolSize(self):
+"""Test that an attempt to use an 8-bit symbol are detected
+
+Only 32 and 64 bits are supported, since we need to store an offset
+into the image.
+"""
 entry = FakeEntry(10)
 section = FakeSection()
 elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms_size')
@@ -81,6 +108,11 @@ class TestElf(unittest.TestCase):
   str(e.exception))
 
 def testNoValue(self):
+"""Test the case where we have no value for the symbol
+
+This should produce -1 values for all thress symbols, taking up the
+first 16 bytes of the image.
+"""
 entry = FakeEntry(20)
 section = FakeSection(sym_value=None)
 elf_fname = os.path.join(binman_dir, 'test', 'u_boot_binman_syms')
@@ -88,6 +120,7 @@ class TestElf(unittest.TestCase):
 self.assertEqual(chr(255) * 16 + 'a' * 4, entry.data)
 
 def testDebug(self):
+"""Check that enabling debug in the elf module produced debug output"""
 elf.debug = True
 entry = FakeEntry(20)
 section = FakeSection()
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 01/29] binman: Don't depend on dict order in ELF testOutsideFile()

2018-07-17 Thread Simon Glass
At present this test assumes that the symbols are returned in address
order. However, objdump can list symbols in any order and dictionaries do
not guarantee any particular order when iterating through item.

Update elf.GetSymbols() to return an OrderedDict, sorted by address, to
avoid any problems.

Signed-off-by: Simon Glass 
---

 tools/binman/elf.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/binman/elf.py b/tools/binman/elf.py
index 0ae3b611ba..8c23040d8c 100644
--- a/tools/binman/elf.py
+++ b/tools/binman/elf.py
@@ -57,7 +57,9 @@ def GetSymbols(fname, patterns):
 name = parts[2]
 syms[name] = Symbol(section, int(value, 16), int(size,16),
 flags[1] == 'w')
-return syms
+
+# Sort dict by address
+return OrderedDict(sorted(syms.iteritems(), key=lambda x: x[1].address))
 
 def GetSymbolAddress(fname, sym_name):
 """Get a value of a symbol from an ELF file
-- 
2.18.0.203.gfac676dfb9-goog

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 00/29] binman: Expand feature set and documentation

2018-07-17 Thread Simon Glass
This series adds various new features to binman to round out its
capabilities. It also adds documentation of each entry type since there are
quite a few now.

Noteably this series changes the 'pos' property to be called 'offset'. The
'pos' name is a misnomer with hierarchical images since the position is
always relative to the parent. A new 'image-pos' property (calculated by
binman) is introduced instead, with a clear meaning.

This is a fairy major change since all source .dts files need to be
updated to accommodate it. I believe that doing this rename now (without
using the old name for anything else) is the best approach. See the rename
patch for motivation and more details.

Changes:

- Passing arguments for entries in via the command line
- Entries filled with a repeated byte
- Putting text in an entry
- TPL
- Chromium entries
- Add README.entries to document entries
- An 'image-pos' property which provides the position of an entry within
an image


Simon Glass (29):
  binman: Don't depend on dict order in ELF testOutsideFile()
  binman: Rename 'position' to 'offset'
  binman: Add comments to elf_test
  binman: Tidy up some comments in the tests
  binman: Enhance the map and fdt-update output
  binman: Update the device-tree file on exit
  binman: Add a new 'image-pos' property
  dtoc: Add missing comments to fdt_util
  binman: Add support for passing arguments to entries
  binman: Support an entry that holds text
  binman: Allow help to work without libfdt
  binman: Expand documentation for entries
  binman: Allow creation of entry documentation
  binman: Create README.entries
  binman: Add support for flashrom FMAP
  binman: Add support for a cros_ec image
  binman: Add an entry filled with a repeating byte
  dtoc: Export the _FindNode() function
  patman: Allow test commands to fall back to real ones
  patman: Add a few more helpers to the tools library
  binman: Add support for Chromium GBB
  patman: Show the current directory in GetInputFilename()
  dtoc: Add a function to obtain a list of phandles
  binman: Add an entry for a Chromium vblock
  binman: Add support for adding TPL binaries
  binman: Show the image position in the map
  binman: Rename ReadContents() to ReadBlobContents()
  binman: Add a test to catch use of the old 'pos' property
  binman: Adjust _GetPropTree() parameters

 arch/arm/dts/sunxi-u-boot.dtsi|   2 +-
 arch/arm/dts/tegra-u-boot.dtsi|   6 +-
 arch/x86/dts/u-boot.dtsi  |  24 +-
 tools/binman/README   | 135 ++--
 tools/binman/README.entries   | 585 ++
 tools/binman/binman.py|  22 +-
 tools/binman/bsection.py  | 151 +++--
 tools/binman/cmdline.py   |   6 +-
 tools/binman/control.py   |  39 +-
 tools/binman/elf.py   |  10 +-
 tools/binman/elf_test.py  |  33 +
 tools/binman/entry.py | 267 ++--
 tools/binman/etype/_testing.py|  47 +-
 tools/binman/etype/blob.py|  16 +-
 tools/binman/etype/blob_named_by_arg.py   |  34 +
 tools/binman/etype/cros_ec_rw.py  |  22 +
 tools/binman/etype/fill.py|  32 +
 tools/binman/etype/fmap.py|  61 ++
 tools/binman/etype/gbb.py |  96 +++
 tools/binman/etype/intel_cmc.py   |  10 +
 tools/binman/etype/intel_descriptor.py|  26 +-
 tools/binman/etype/intel_fsp.py   |  14 +
 tools/binman/etype/intel_me.py|  15 +
 tools/binman/etype/intel_mrc.py   |  11 +
 tools/binman/etype/intel_vbt.py   |  10 +
 tools/binman/etype/intel_vga.py   |  12 +
 tools/binman/etype/section.py |  48 +-
 tools/binman/etype/text.py|  57 ++
 tools/binman/etype/u_boot.py  |  16 +
 tools/binman/etype/u_boot_dtb.py  |   9 +
 tools/binman/etype/u_boot_dtb_with_ucode.py   |  22 +-
 tools/binman/etype/u_boot_img.py  |  11 +
 tools/binman/etype/u_boot_nodtb.py|  11 +
 tools/binman/etype/u_boot_spl.py  |  21 +
 tools/binman/etype/u_boot_spl_bss_pad.py  |  16 +
 tools/binman/etype/u_boot_spl_dtb.py  |  11 +-
 tools/binman/etype/u_boot_spl_nodtb.py|  12 +
 tools/binman/etype/u_boot_tpl.py  |  43 ++
 tools/binman/etype/u_boot_tpl_dtb.py  |  25 +
 tools/binman/etype/u_boot_ucode.py|  12 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  44 +-
 tools/binman/etype/vblock.py  |  74 +++
 tools/binman/etype/x86_start16.py |  14 +
 tools/binman/etype/x86_start16_spl.py |  14 +
 tools/binman/fmap_util.py | 109 
 tools/binman/ftest.py | 428 +++--
 tools/binman/image.py |  16 +-
 

Re: [U-Boot] [linux-sunxi] [PATCH 1/8] usb: musb-new: Fix improper musb host pointer

2018-07-17 Thread Julian Calaby
Hi,

Sorry, please ignore this, I didn't realise this patch was for u-boot.

On Tue, Jul 17, 2018 at 10:45 PM Julian Calaby  wrote:
>
> Hi Jagan,
>
> On Tue, Jul 10, 2018 at 5:17 AM Jagan Teki  wrote:
> >
> > When MUSB is operating in peripheral mode, probe registering
> > musb core using musb_register which intern return int value
> > for validation. so there is no scope to preserve struct musb
> > pointer but the same can be used in .remove musb_stop.
> > So fix this by return musb_register with struct musb pointer.
> >
> > Signed-off-by: Jagan Teki 
> > ---
> >  board/compulab/cm_t3517/cm_t3517.c |  4 ++--
> >  drivers/usb/musb-new/musb_uboot.c  | 10 +-
> >  drivers/usb/musb-new/pic32.c   |  6 --
> >  drivers/usb/musb-new/sunxi.c   |  8 +---
> >  include/linux/usb/musb.h   |  4 ++--
> >  5 files changed, 18 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/usb/musb-new/musb_uboot.c 
> > b/drivers/usb/musb-new/musb_uboot.c
> > index 2b04fbd046..3cd89793c9 100644
> > --- a/drivers/usb/musb-new/musb_uboot.c
> > +++ b/drivers/usb/musb-new/musb_uboot.c
> > @@ -436,14 +436,14 @@ int musb_register(struct musb_hdrc_platform_data 
> > *plat, void *bdata,
> > break;
> >  #endif
> > default:
> > -   return -EINVAL;
> > +   return NULL;
>
> These error constants appear to have been chosen specifically, so
> would it be nicer to preserve them and use ERR_PTR() and friends to
> return them?
>
> (I know nothing checks them today, but they might be useful in the future)
>
> > }
> >
> > *musbp = musb_init_controller(plat, (struct device *)bdata, 
> > ctl_regs);
> > if (!*musbp) {
> > printf("Failed to init the controller\n");
> > -   return -EIO;
> > +   return NULL;
> > }
> >
> > -   return 0;
> > +   return *musbp;
> >  }

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v6 0/5] Add support for reading memory configuration from DT at run-time

2018-07-17 Thread Michal Simek

Hi,

this is series which was send by Siva. I have just put there missing
Tom's tag which we got and adding more people to TO.

Thanks,
Michal

Changes in v6:
- Fix socfpga misc, bcmstb, ebisu which were recently added

Changes in v5:
- Add Tom's tag -
  https://lists.denx.de/pipermail/u-boot/2018-June/332810.html
- Add Tom's tag -
  https://lists.denx.de/pipermail/u-boot/2018-June/332810.html

Changes in v4:
- Rebased on latest master and used
  available ram_base
- Separate the rename patch
- Rebased on latest master
- None, rebased on latest master

Changes in v3:
- Used new varibale ram_start
- Rename fdtdec_setup_memory_size

Changes in v2:
- Removed commit reference from description as per comment
- Update memory node as per comment
- Removed intc and fclk as per comment

Siva Durga Prasad Paladugu (5):
  lib: fdtdec: Update ram_base to store ram start adddress
  lib: fdtdec: Rename routine fdtdec_setup_memory_size()
  arm: zynq: Dont define SDRAM_BASE and SDRAM_SIZE in .h
  arm: zynq: Add Nand flash mini u-boot configuration for zynq
  arm: zynq: Add parallel NOR flash mini u-boot configuration for zynq

 arch/arm/dts/Makefile  |  2 +
 arch/arm/dts/zynq-cse-nand.dts | 80 
 arch/arm/dts/zynq-cse-nor.dts  | 88 ++
 arch/arm/mach-mvebu/arm64-common.c |  2 +-
 arch/arm/mach-socfpga/misc.c   |  2 +-
 board/broadcom/bcmstb/bcmstb.c |  2 +-
 board/emulation/qemu-arm/qemu-arm.c|  2 +-
 board/renesas/alt/alt.c|  2 +-
 board/renesas/blanche/blanche.c|  2 +-
 board/renesas/draak/draak.c|  2 +-
 board/renesas/eagle/eagle.c|  2 +-
 board/renesas/ebisu/ebisu.c|  2 +-
 board/renesas/gose/gose.c  |  2 +-
 board/renesas/koelsch/koelsch.c|  2 +-
 board/renesas/lager/lager.c|  2 +-
 board/renesas/porter/porter.c  |  2 +-
 board/renesas/salvator-x/salvator-x.c  |  2 +-
 board/renesas/silk/silk.c  |  2 +-
 board/renesas/stout/stout.c|  2 +-
 board/renesas/ulcb/ulcb.c  |  2 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c |  2 +-
 .../st/stm32f429-evaluation/stm32f429-evaluation.c |  2 +-
 board/st/stm32f469-discovery/stm32f469-discovery.c |  2 +-
 board/st/stm32h743-disco/stm32h743-disco.c |  2 +-
 board/st/stm32h743-eval/stm32h743-eval.c   |  2 +-
 board/xilinx/zynq/board.c  |  2 +-
 board/xilinx/zynqmp/zynqmp.c   |  2 +-
 board/xilinx/zynqmp_r5/board.c |  2 +-
 common/board_f.c   |  4 +-
 configs/zynq_cse_nand_defconfig| 50 
 configs/zynq_cse_nor_defconfig | 50 
 include/configs/zynq_cse.h |  3 -
 include/fdtdec.h   | 16 ++--
 lib/fdtdec.c   |  3 +-
 tools/patman/func_test.py  |  2 +-
 tools/patman/test/-cover-letter.patch  |  2 +-
 ...-cast-for-sandbox-in-fdtdec_setup_memory_.patch |  4 +-
 tools/patman/test/test01.txt   |  2 +-
 38 files changed, 313 insertions(+), 43 deletions(-)
 create mode 100644 arch/arm/dts/zynq-cse-nand.dts
 create mode 100644 arch/arm/dts/zynq-cse-nor.dts
 create mode 100644 configs/zynq_cse_nand_defconfig
 create mode 100644 configs/zynq_cse_nor_defconfig

-- 
1.9.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] hashtable: Fix length calculation in hexport_r

2018-07-17 Thread Zubair Lutfullah Kakakhel
The length returned by hexport_r has a few redundant characters.
This appears as NULL characters at the end so seems harmless.

Remove the surplus counts in two places

totlen += strlen(ep->key) + 2;
I'm guessing the +2 here is for = and sep char. But there is another
totlen += 2; line that does that.

size = totletn + 1;
Doesn't make sense and isn't justified with any comment.

Signed-off-by: Zubair Lutfullah Kakakhel 
---
 lib/hashtable.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 52aab6d..64faa63 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -622,7 +622,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char 
sep, int flag,
 
list[n++] = ep;
 
-   totlen += strlen(ep->key) + 2;
+   totlen += strlen(ep->key);
 
if (sep == '\0') {
totlen += strlen(ep->data);
@@ -662,7 +662,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char 
sep, int flag,
return (-1);
}
} else {
-   size = totlen + 1;
+   size = totlen;
}
 
/* Check if the user provided a buffer */
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [linux-sunxi] [PATCH 1/8] usb: musb-new: Fix improper musb host pointer

2018-07-17 Thread Julian Calaby
Hi Jagan,

On Tue, Jul 10, 2018 at 5:17 AM Jagan Teki  wrote:
>
> When MUSB is operating in peripheral mode, probe registering
> musb core using musb_register which intern return int value
> for validation. so there is no scope to preserve struct musb
> pointer but the same can be used in .remove musb_stop.
> So fix this by return musb_register with struct musb pointer.
>
> Signed-off-by: Jagan Teki 
> ---
>  board/compulab/cm_t3517/cm_t3517.c |  4 ++--
>  drivers/usb/musb-new/musb_uboot.c  | 10 +-
>  drivers/usb/musb-new/pic32.c   |  6 --
>  drivers/usb/musb-new/sunxi.c   |  8 +---
>  include/linux/usb/musb.h   |  4 ++--
>  5 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/usb/musb-new/musb_uboot.c 
> b/drivers/usb/musb-new/musb_uboot.c
> index 2b04fbd046..3cd89793c9 100644
> --- a/drivers/usb/musb-new/musb_uboot.c
> +++ b/drivers/usb/musb-new/musb_uboot.c
> @@ -436,14 +436,14 @@ int musb_register(struct musb_hdrc_platform_data *plat, 
> void *bdata,
> break;
>  #endif
> default:
> -   return -EINVAL;
> +   return NULL;

These error constants appear to have been chosen specifically, so
would it be nicer to preserve them and use ERR_PTR() and friends to
return them?

(I know nothing checks them today, but they might be useful in the future)

> }
>
> *musbp = musb_init_controller(plat, (struct device *)bdata, ctl_regs);
> if (!*musbp) {
> printf("Failed to init the controller\n");
> -   return -EIO;
> +   return NULL;
> }
>
> -   return 0;
> +   return *musbp;
>  }

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Question: Frescale imx board repositories

2018-07-17 Thread Fernando AE
Hello all,

I'd like to know what's the difference between the Frescale imx board
repositories from:

1) https://source.codeaurora.org/external/imx/uboot-imx
2) https://github.com/Freescale/u-boot-fslc

It seems that #2 is rebased more often and is referenced by yocto. I
was wordering if the differece could be in stability or board support.

Thanks for your help,
Fernando
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Trent Piepho
On Mon, 2018-07-16 at 23:56 +, Henry Beberman wrote:
> > 
> > > 
> > > I need to revise the commit message for this patch. The script is not 
> > > fixed
> > 
> > to the first partition of the selected MMC, it scans the disk for partitions
> > marked bootable, then checks each one of those until it finds the
> > imxboard_efi.fd binary.
> > 
> > That is indeed very different from first FAT partition.  Does bootable only
> > apply legacy MBR partition tables?  I didn't think bootable was typically 
> > used
> > with GPT tables.  There is a bit, but it's not used to mark EFI partitions.
> > 
> > Which brings me back to the partition type.  Isn't that the right way to 
> > find
> > the EFI?
> 
> The is_bootable function in disk/part_efi.c marks a partition as bootable if 
> the partition_type_guid on disk matches the EFI PARTITION_SYSTEM_GUID.
> The part command with the -bootable flag will return the EFI partition on 
> both GPT and MBR partition schemes. This method is also used by 
> config_distro_bootcmd.h

But it also finds any partitions with the legacy bios bootable flag set
in a GPT table or the active partition bit set in a MBR table, or any
future reason a partition might be considered bootable.  Someone trying
to add a new type of bootable partition to distro bootcmd will be
forced to deal with your windows nt boot command as it tries to boot
any bootable partition, even ones it can't boot.

The distro boot command is designed to boot anything, so it searches
for partitions beyond EFI.  But what you've done is just for EFI. 
That's why it's different.

> > > We could switch over to using the generic load from
> > 
> > CONFIG_CMD_FS_GENERIC if there's demand for non-FAT filesystems.
> > We're currently using fatload because the EFI partitions in our Windows
> > images are always FAT formatted.
> > 
> > You're original search method required the partition be FAT.
> 
> I'm happy to switch from the fatload command over to the load command if it 
> will make CONFIG_UEFI_BOOT more widely useful.

My comment was addressing the incorrect commit message that indicated
boot partition selection was linked to the FAT filesystem.  I don't
know if loading EFI from non-FAT partitions will be useful.  I'm not
planning on using EFI but I like to avoid FAT in my products.  If you
had linked the boot partition selection to FAT, it would cut off future
options.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Henry Beberman
Hi Fabio,

> -Original Message-
> From: Fabio Estevam 
> Sent: Tuesday, July 17, 2018 10:09 AM
> To: Trent Piepho 
> Cc: Henry Beberman ; u-
> b...@lists.denx.de; fabio.este...@nxp.com; tr...@konsulko.com
> Subject: Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI
> from mmc
> 
> Hi Henry,
> 
> On Mon, Jul 16, 2018 at 2:16 PM, Trent Piepho  wrote:
> > On Sat, 2018-07-14 at 00:11 +, Henry Beberman wrote:
> >> From: Henry Beberman 
> >>
> >> This patch enables i.MX platforms to easily add a boot script to
> >> their U-Boot Proper environment to automatically load and execute an
> >> EFI firmware from the first FAT partition of an MMC device.
> 
> Have you subscribed to the U-Boot list?
> 
> I don't see this series in the list archives, only on my NXP account.

I'm subscribed to the U-Boot list and I included the mailing list when sending 
out the series, but I got a notice that they were held until moderator approval.
I saw the patches in the archive here 
https://lists.denx.de/pipermail/u-boot/2018-July/thread.html#334680 and on the 
patch tracker so I assumed they went out successfully.

Thanks,
Henry

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/11] imx: Add bootcmd to load and run UEFI from mmc

2018-07-17 Thread Fabio Estevam
Hi Henry,

On Mon, Jul 16, 2018 at 2:16 PM, Trent Piepho  wrote:
> On Sat, 2018-07-14 at 00:11 +, Henry Beberman wrote:
>> From: Henry Beberman 
>>
>> This patch enables i.MX platforms to easily add a boot script to their
>> U-Boot Proper environment to automatically load and execute an EFI
>> firmware from the first FAT partition of an MMC device.

Have you subscribed to the U-Boot list?

I don't see this series in the list archives, only on my NXP account.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot support for iMX7 Sabre

2018-07-17 Thread Trent Piepho
On Tue, 2018-07-17 at 01:41 +, Henry Beberman wrote:
> > -Original Message-
> > From: Trent Piepho 
> > Sent: Monday, July 16, 2018 11:22 AM
> > To: Henry Beberman ; u-
> > b...@lists.denx.de
> > Cc: fabio.este...@nxp.com; adrian.alo...@nxp.com
> > Subject: Re: [U-Boot] [PATCH 06/11] mx7dsabresd: Add Windows boot
> > support for iMX7 Sabre
> > 
> > On Sat, 2018-07-14 at 00:11 +, Henry Beberman wrote:
> > > From: Henry Beberman 
> > > 
> > > This patch adds a new bootable configuration for Windows 10 IoT Core
> > > on the i.MX7 Dual Sabre board.
> > > 
> > > It enables SPL on the i.MX7 Sabre in order to support the FIT load of
> > > OP-TEE and U-Boot proper.
> > > 
> > > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index
> > > f186120684..3fb9b72703 100644
> > > --- a/drivers/gpio/Makefile
> > > +++ b/drivers/gpio/Makefile
> > > @@ -7,10 +7,13 @@ ifndef CONFIG_SPL_BUILD
> > >  obj-$(CONFIG_DWAPB_GPIO) += dwapb_gpio.o
> > >  obj-$(CONFIG_AXP_GPIO)   += axp_gpio.o
> > >  endif
> > > +
> > > +ifeq ($(CONFIG_$(SPL_TPL_)DM),y)
> > >  obj-$(CONFIG_DM_GPIO)+= gpio-uclass.o
> > > 
> > >  obj-$(CONFIG_DM_PCA953X) += pca953x_gpio.o
> > >  obj-$(CONFIG_DM_74X164)  += 74x164_gpio.o
> > > +endif
> > 
> > It doesn't look like this patch is specific to mx7 or Windows.  Perhaps it 
> > should
> > be in a different commit?
> 
> I agree that this change probably belongs in its own patch.
> I've left it in this patch so far because it's required to build the new 
> mx7dsabresd_nt_defconfig.

Easy enough to split out and put first.  The person on different
hardware trying to figure out the u-boot build spaghetti it's helped
much knowing the person who added it was working on windows 10 support,
but nothing about the reason for this change.

> > Also, the help text for SPL_DM says it turns on basic DM support in SPL.  
> > But
> > not any specific hardware drivers.  Those all have additional config 
> > options to
> > turn them on.  It doesn't seems right to bundle a selection of GPIO drivers
> > along with CONFIG_SPL_DM.
> 
> This issue has cropped up because this patch adds SPL support to mx7dsabresd, 
> but intentionally does not enable SPL_DM.
> The defconfig contains CONFIG_DM_74X164 for use in U-Boot Proper, but because 
> drivers/gpio/Makefile also runs during the SPL portion of the build that 
> config still pulls in the 74X164 driver which fails to build due to missing 
> dependencies.
> 
> Wrapping the DM objects in CONFIG_$(SPL_TPL_)DM ensures that DM is actually 
> enabled for the current portion of the build when deciding to build the DM 
> drivers. 

But isn't it odd that not a single other driver is wrapped this way? 
What's special here?

I think the underlying flaw is the the kbuild system doesn't support
the concept of building multiple times in different modes, e.g. main,
SPL, TPL.  And rather than design something, one gets layers of board
specific hacks.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [RFC 17/35] clk: sunxi: Add initial CLK driver for H3_H5

2018-07-17 Thread Jagan Teki
On Tue, Jul 17, 2018 at 6:06 PM, Maxime Ripard
 wrote:
> On Mon, Jul 16, 2018 at 05:55:25PM +0100, Andre Przywara wrote:
>> Hi,
>>
>> On 16/07/18 13:59, Maxime Ripard wrote:
>> > On Mon, Jul 16, 2018 at 04:58:32PM +0530, Jagan Teki wrote:
>> >> Add initial clock driver Allwinner for H3_H5.
>> >>
>> >> Implemented clock enable and disable functions for
>> >> USB OHCI, EHCI, OTG and PHY gate and clock registers.
>> >>
>> >> Signed-off-by: Jagan Teki 
>> >> ---
>> >>  drivers/clk/sunxi/Kconfig  |   7 ++
>> >>  drivers/clk/sunxi/Makefile |   2 +
>> >>  drivers/clk/sunxi/clk_h3.c | 131 +
>> >>  3 files changed, 140 insertions(+)
>> >>  create mode 100644 drivers/clk/sunxi/clk_h3.c
>> >>
>> >> diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
>> >> index 3a86c91e75..065cadf2fe 100644
>> >> --- a/drivers/clk/sunxi/Kconfig
>> >> +++ b/drivers/clk/sunxi/Kconfig
>> >> @@ -8,6 +8,13 @@ config CLK_SUNXI
>> >>
>> >>  if CLK_SUNXI
>> >>
>> >> +config CLK_SUN8I_H3
>> >> +  bool "Clock driver for Allwinner H3/H5"
>> >> +  default MACH_SUNXI_H3_H5
>> >> +  help
>> >> +This enables common clock driver support for platforms based
>> >> +on Allwinner H3/H5 SoC.
>> >> +
>> >>  config CLK_SUN50I_A64
>> >>bool "Clock driver for Allwinner A64"
>> >>default MACH_SUN50I
>> >> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
>> >> index 860bb6dfea..37e6bcb147 100644
>> >> --- a/drivers/clk/sunxi/Makefile
>> >> +++ b/drivers/clk/sunxi/Makefile
>> >> @@ -5,4 +5,6 @@
>> >>  #
>> >>
>> >>  obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
>> >> +
>> >> +obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
>> >>  obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
>> >> diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
>> >> new file mode 100644
>> >> index 00..e924017717
>> >> --- /dev/null
>> >> +++ b/drivers/clk/sunxi/clk_h3.c
>> >> @@ -0,0 +1,131 @@
>> >> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> >> +/*
>> >> + * Copyright (C) 2018 Amarula Solutions B.V.
>> >> + * Author: Jagan Teki 
>> >> + */
>> >> +
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +#include 
>> >> +
>> >> +struct h3_clk_priv {
>> >> +  void *base;
>> >> +};
>> >> +
>> >> +static int h3_clk_enable(struct clk *clk)
>> >> +{
>> >> +  struct h3_clk_priv *priv = dev_get_priv(clk->dev);
>> >> +
>> >> +  debug("%s(#%ld)\n", __func__, clk->id);
>> >> +
>> >> +  switch (clk->id) {
>> >> +  case CLK_BUS_OTG:
>> >> +  case CLK_BUS_EHCI0:
>> >> +  case CLK_BUS_EHCI1:
>> >> +  case CLK_BUS_EHCI2:
>> >> +  case CLK_BUS_EHCI3:
>> >> +  case CLK_BUS_OHCI0:
>> >> +  case CLK_BUS_OHCI1:
>> >> +  case CLK_BUS_OHCI2:
>> >> +  case CLK_BUS_OHCI3:
>> >> +  setbits_le32(priv->base + 0x60,
>> >> +   BIT(23 + (clk->id - CLK_BUS_OTG)));
>> >> +  return 0;
>> >> +  case CLK_USB_PHY0:
>> >> +  case CLK_USB_PHY1:
>> >> +  case CLK_USB_PHY2:
>> >> +  case CLK_USB_PHY3:
>> >> +  setbits_le32(priv->base + 0xcc,
>> >> +   BIT(8 + (clk->id - CLK_USB_PHY0)));
>> >> +  return 0;
>> >> +  case CLK_USB_OHCI0:
>> >> +  case CLK_USB_OHCI1:
>> >> +  case CLK_USB_OHCI2:
>> >> +  case CLK_USB_OHCI3:
>> >> +  setbits_le32(priv->base + 0xcc,
>> >> +   BIT(16 + (clk->id - CLK_USB_OHCI0)));
>> >> +  return 0;
>> >> +  default:
>> >> +  debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
>> >> +  return -ENODEV;
>> >> +  }
>> >> +}
>> >> +
>> >> +static int h3_clk_disable(struct clk *clk)
>> >> +{
>> >> +  struct h3_clk_priv *priv = dev_get_priv(clk->dev);
>> >> +
>> >> +  debug("%s(#%ld)\n", __func__, clk->id);
>> >> +
>> >> +  switch (clk->id) {
>> >> +  case CLK_BUS_OTG:
>> >> +  case CLK_BUS_EHCI0:
>> >> +  case CLK_BUS_EHCI1:
>> >> +  case CLK_BUS_EHCI2:
>> >> +  case CLK_BUS_EHCI3:
>> >> +  case CLK_BUS_OHCI0:
>> >> +  case CLK_BUS_OHCI1:
>> >> +  case CLK_BUS_OHCI2:
>> >> +  case CLK_BUS_OHCI3:
>> >> +  clrbits_le32(priv->base + 0x60,
>> >> +   BIT(23 + (clk->id - CLK_BUS_OTG)));
>> >> +  return 0;
>> >> +  case CLK_USB_PHY0:
>> >> +  case CLK_USB_PHY1:
>> >> +  case CLK_USB_PHY2:
>> >> +  case CLK_USB_PHY3:
>> >> +  clrbits_le32(priv->base + 0xcc,
>> >> +   BIT(8 + (clk->id - CLK_USB_PHY0)));
>> >> +  return 0;
>> >> +  case CLK_USB_OHCI0:
>> >> +  case CLK_USB_OHCI1:
>> >> +  case CLK_USB_OHCI2:
>> >> +  case CLK_USB_OHCI3:
>> >> +  clrbits_le32(priv->base + 0xcc,
>> >> +   BIT(16 + (clk->id - CLK_USB_OHCI0)));
>> >> +  return 0;
>> >> +  default:
>> >> +  debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
>> >> +  return -ENODEV;
>> >> +  }
>> >> +}
>> >> +
>> >> +static struct clk_ops h3_clk_ops = {
>> >> +  .enable = h3_clk_enable,
>> >> +  .disable = h3_clk_disable,
>> >> +};
>> >> +
>> >> +static int 

Re: [U-Boot] [ANN] U-Boot v2018.07 released

2018-07-17 Thread Wolfgang Denk
Dear Tom,

In message <20180717134154.GC3196@bill-the-cat> you wrote:
> 
> > >> looks good. I expect there was consideration to keep these config files
> > >> out of the main repo.
> > > 
> > > I can't remember clearly. I think there was.
> > > 
> > > I have no real preferences.
> > 
> > Tom: What do you think?
>
> It's Wolfgang's thing :)

Full circle, nice.

So has anybody any suggestions what to do?

The problem I see is that we need yet another non-standard tool
(gitdm) which AFAICT is not part of the standard distros. Including
this into U-Boot seems not attractive to me; keeping it outside (as
I'm doing it now) means you need the config files outside the U-Boot
tree as well.

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
Contrary to popular belief, thinking does not cause brain damage.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] Pull request: u-boot-sunxi/master

2018-07-17 Thread Jagan Teki
Hi Tom,

Please pull this PR.

thanks,
Jagan.

The following changes since commit 5e9a9645816edcc68c09729f257e0c863292bf26:

  mach-stm32: Rename CONFIG_SPL_RESET_SUPPORT to CONFIG_SPL_DM_RESET 
(2018-07-13 14:47:29 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-sunxi.git master

for you to fetch changes up to 32f67bb7a15cec4afa117bd168265ece2107b0d6:

  sunxi: Enable eMMC on Libre Computer Board ALL-H3-CC boards (2018-07-17 
21:07:34 +0530)


Adam Sampson (2):
  dm: mmc: sunxi: Add A10/A20 compatible strings
  dm: sunxi: Use DM for MMC and SATA on all A10 boards

Andre Przywara (6):
  sunxi: DT: A64: update device tree file for Allwinner A64 SoC
  sunxi: DT: A64: update board .dts files from Linux
  sunxi: DT: update device tree files for Allwinner H3 and H5 SoCs
  sunxi: DT: H5: update board .dts files from Linux
  sunxi: DT: H3: update board .dts files from Linux
  sunxi: DT: A64: add proper SoPine baseboard device tree

Chen-Yu Tsai (1):
  sunxi: Enable eMMC on Libre Computer Board ALL-H3-CC boards

Lothar Felten (6):
  sunxi: R40: add gigabit ethernet clocks
  net: sun8i-emac: fix printing NULL character
  net: sun8i-emac: set mux and clock by driver data
  net: sun8i-emac: support R40 GMAC
  sunxi: R40: add gigabit ethernet devicetree node
  configs: Bananapi_M2_Ultra: enable gigabit ethernet

 arch/arm/dts/Makefile   |   3 +-
 arch/arm/dts/axp803.dtsi| 155 +
 arch/arm/dts/sun50i-a64-bananapi-m64.dts| 195 +-
 arch/arm/dts/sun50i-a64-nanopi-a64.dts  | 111 ++-
 arch/arm/dts/sun50i-a64-olinuxino.dts   | 153 -
 arch/arm/dts/sun50i-a64-orangepi-win.dts| 135 +++-
 arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi |  59 --
 arch/arm/dts/sun50i-a64-pine64-plus.dts |  17 +-
 arch/arm/dts/sun50i-a64-pine64.dts  | 186 -
 arch/arm/dts/sun50i-a64-sopine-baseboard.dts| 150 +
 arch/arm/dts/sun50i-a64-sopine.dtsi | 142 
 arch/arm/dts/sun50i-a64.dtsi| 305 -
 arch/arm/dts/sun50i-h5-libretech-all-h3-cc.dts  |   5 +-
 arch/arm/dts/sun50i-h5-nanopi-neo-plus2.dts | 122 +++-
 arch/arm/dts/sun50i-h5-nanopi-neo2.dts  |  91 ++-
 arch/arm/dts/sun50i-h5-orangepi-pc2.dts | 151 -
 arch/arm/dts/sun50i-h5-orangepi-prime.dts   | 176 -
 arch/arm/dts/sun50i-h5-orangepi-zero-plus2.dts  |  64 +-
 arch/arm/dts/sun50i-h5.dtsi |  38 +-
 arch/arm/dts/sun8i-h2-plus-orangepi-zero.dts|  55 +-
 arch/arm/dts/sun8i-h3-bananapi-m2-plus.dts  |  96 ++-
 arch/arm/dts/sun8i-h3-libretech-all-h3-cc.dts   |   3 +-
 arch/arm/dts/sun8i-h3-nanopi-m1-plus.dts|  78 +++
 arch/arm/dts/sun8i-h3-nanopi-m1.dts |  42 ++
 arch/arm/dts/sun8i-h3-nanopi-neo-air.dts|  28 +-
 arch/arm/dts/sun8i-h3-nanopi-neo.dts|  17 +
 arch/arm/dts/sun8i-h3-nanopi.dtsi   |  13 +-
 arch/arm/dts/sun8i-h3-orangepi-2.dts|  92 ++-
 arch/arm/dts/sun8i-h3-orangepi-lite.dts |  57 +-
 arch/arm/dts/sun8i-h3-orangepi-one.dts  | 116 +++-
 arch/arm/dts/sun8i-h3-orangepi-pc-plus.dts  |  11 +-
 arch/arm/dts/sun8i-h3-orangepi-pc.dts   | 141 +++-
 arch/arm/dts/sun8i-h3-orangepi-plus.dts |  29 +-
 arch/arm/dts/sun8i-h3-orangepi-plus2e.dts   |  15 +-
 arch/arm/dts/sun8i-h3.dtsi  | 602 +++--
 arch/arm/dts/sun8i-r40-bananapi-m2-ultra.dts|  16 +
 arch/arm/dts/sun8i-r40.dtsi |  34 +
 arch/arm/dts/sunxi-h3-h5.dtsi   | 860 
 arch/arm/dts/sunxi-libretech-all-h3-cc.dtsi |  11 +-
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h   |  10 +-
 arch/arm/mach-sunxi/Kconfig |   2 +
 configs/Bananapi_M2_Ultra_defconfig |   4 +
 configs/libretech_all_h3_cc_h2_plus_defconfig   |   1 +
 configs/libretech_all_h3_cc_h3_defconfig|   1 +
 configs/libretech_all_h3_cc_h5_defconfig|   1 +
 configs/sopine_baseboard_defconfig  |   2 +-
 drivers/mmc/sunxi_mmc.c |   2 +
 drivers/net/sun8i_emac.c| 115 ++--
 include/dt-bindings/clock/sun8i-de2.h   |  18 +
 include/dt-bindings/clock/sun8i-r-ccu.h |  59 ++
 include/dt-bindings/reset/sun8i-de2.h   |  14 +
 include/dt-bindings/reset/sun8i-r-ccu.h |  53 ++
 52 files changed, 3893 insertions(+), 963 deletions(-)
 create mode 100644 arch/arm/dts/axp803.dtsi
 delete mode 100644 arch/arm/dts/sun50i-a64-pine64-plus-u-boot.dtsi
 create mode 100644 arch/arm/dts/sun50i-a64-sopine-baseboard.dts
 create mode 100644 arch/arm/dts/sun50i-a64-sopine.dtsi
 create mode 100644 arch/arm/dts/sunxi-h3-h5.dtsi
 create mode 100644 include/dt-bindings/clock/sun8i-de2.h
 create mode 100644 

  1   2   >