Re: [U-Boot] [PATCH 3/3] pico-imx7d: polish uart clock id definition

2019-10-16 Thread Jun Nie
Stefano Babic  于2019年10月13日周日 下午9:35写道:
>
> Hi Jun,
>
> I am just trying to check if some patch was silently lost, I found yours:
>
> On 16/07/19 09:42, Jun Nie wrote:
> > Polish uart clock id definition. Default IMX7 UART ID is UART1
> > as original parameter in imx_get_uartclk().
> >
> > Signed-off-by: Jun Nie 
> > ---
> >  arch/arm/include/asm/arch-mx7/clock.h | 18 +-
> >  1 file changed, 1 insertion(+), 17 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/arch-mx7/clock.h 
> > b/arch/arm/include/asm/arch-mx7/clock.h
> > index 1d07fde..a8e6097 100644
> > --- a/arch/arm/include/asm/arch-mx7/clock.h
> > +++ b/arch/arm/include/asm/arch-mx7/clock.h
> > @@ -175,23 +175,7 @@ enum clk_root_index {
> >   CLK_ROOT_MAX,
> >  };
> >
> > -#if (CONFIG_CONS_INDEX == 0)
> > -#define UART_CLK_ROOT UART1_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 1)
> > -#define UART_CLK_ROOT UART2_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 2)
> > -#define UART_CLK_ROOT UART3_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 3)
> > -#define UART_CLK_ROOT UART4_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 4)
> > -#define UART_CLK_ROOT UART5_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 5)
> > -#define UART_CLK_ROOT UART6_CLK_ROOT
> > -#elif (CONFIG_CONS_INDEX == 6)
> > -#define UART_CLK_ROOT UART7_CLK_ROOT
> > -#else
> > -#error "Invalid IMX UART ID for serial console is defined"
> > -#endif
> > +#define UART_CLK_ROOT (UART1_CLK_ROOT + CONFIG_CONS_INDEX)
> >
> >  struct clk_root_setting {
> >   enum clk_root_index root;
> >
>
> It looks ok but CONFIG_CONS_INDEX *must* be set, else it breaks boards.
> Patch breaks at least the colibri boards.
>
> Best regards,
> Stefano

Thanks for finding the bug! I will test more boards in next round.
This patch is an independent optimization patch to other patches. So I
will sumit next version later.

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


[PATCH] imx: spl: Add weak reset_cpu()

2022-10-24 Thread Jun Nie
Add weak reset_cpu() to reduce redundant code. And it ease the new platforms
that only need a empty function to pass build without below compiling failure.

arch/arm/lib/reset.o: In function `do_reset':
/git/u-boot/arch/arm/lib/reset.c:42: undefined reference to `reset_cpu'
make[1]: *** [scripts/Makefile.spl:526: spl/u-boot-spl] Error 1
make: *** [Makefile:2087: spl/u-boot-spl] Error 2

Signed-off-by: Jun Nie 
---
 arch/arm/mach-imx/spl.c   | 4 
 board/ronetix/imx7-cm/spl.c   | 4 
 board/technexion/pico-imx6ul/spl.c| 4 
 board/technexion/pico-imx7d/spl.c | 4 
 board/toradex/apalis_imx6/apalis_imx6.c   | 4 
 board/toradex/colibri_imx6/colibri_imx6.c | 4 
 6 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index ef00969a5e..6abbdb8909 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -388,3 +388,7 @@ void *spl_load_simple_fit_fix_load(const void *fit)
 
return (void *)new;
 }
+
+__weak void reset_cpu(void)
+{
+}
diff --git a/board/ronetix/imx7-cm/spl.c b/board/ronetix/imx7-cm/spl.c
index d36f734e49..864e95b187 100644
--- a/board/ronetix/imx7-cm/spl.c
+++ b/board/ronetix/imx7-cm/spl.c
@@ -115,10 +115,6 @@ void board_init_f(ulong dummy)
board_init_r(NULL, 0);
 }
 
-void reset_cpu(void)
-{
-}
-
 #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
PAD_CTL_HYS | PAD_CTL_PUE | \
PAD_CTL_PUS_PU47KOHM)
diff --git a/board/technexion/pico-imx6ul/spl.c 
b/board/technexion/pico-imx6ul/spl.c
index 251f5a1b7d..df01b5f8b5 100644
--- a/board/technexion/pico-imx6ul/spl.c
+++ b/board/technexion/pico-imx6ul/spl.c
@@ -147,10 +147,6 @@ void board_init_f(ulong dummy)
board_init_r(NULL, 0);
 }
 
-void reset_cpu(void)
-{
-}
-
 #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE |\
PAD_CTL_PUS_22K_UP  | PAD_CTL_SPEED_LOW |   \
PAD_CTL_DSE_80ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
diff --git a/board/technexion/pico-imx7d/spl.c 
b/board/technexion/pico-imx7d/spl.c
index df5f058577..75d6aa8445 100644
--- a/board/technexion/pico-imx7d/spl.c
+++ b/board/technexion/pico-imx7d/spl.c
@@ -127,10 +127,6 @@ void board_init_f(ulong dummy)
board_init_r(NULL, 0);
 }
 
-void reset_cpu(void)
-{
-}
-
 #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM)
 
diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 8d2642f25d..b59d7cceea 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -1056,10 +1056,6 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
-void reset_cpu(void)
-{
-}
-
 #endif /* CONFIG_SPL_BUILD */
 
 static struct mxc_serial_plat mxc_serial_plat = {
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index ab2ab587ff..261e46bc35 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -1116,10 +1116,6 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
-void reset_cpu(void)
-{
-}
-
 #endif /* CONFIG_SPL_BUILD */
 
 static struct mxc_serial_plat mxc_serial_plat = {
-- 
2.25.1



[PATCH] imx: syscounter: support timer_get_boot_us

2022-07-21 Thread Jun Nie
With supporting timer_get_boot_us, we can profile boot up time with below
configs and function bootstage_mark_name().

CONFIG_BOOTSTAGE=y
CONFIG_BOOTSTAGE_REPORT=y
CONFIG_CMD_BOOTSTAGE=y

Signed-off-by: Jun Nie 
---
 arch/arm/mach-imx/syscounter.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/mach-imx/syscounter.c b/arch/arm/mach-imx/syscounter.c
index 7c02e199a3..df478a2326 100644
--- a/arch/arm/mach-imx/syscounter.c
+++ b/arch/arm/mach-imx/syscounter.c
@@ -79,6 +79,7 @@ int timer_init(void)
gd->arch.tbl = 0;
gd->arch.tbu = 0;
 
+   gd->arch.timer_rate_hz = freq;
return 0;
 }
 #endif
@@ -100,6 +101,14 @@ ulong get_timer(ulong base)
return tick_to_time(get_ticks()) - base;
 }
 
+ulong timer_get_boot_us(void)
+{
+   if (!gd->arch.timer_rate_hz)
+   timer_init();
+
+   return tick_to_time(get_ticks());
+}
+
 void __udelay(unsigned long usec)
 {
unsigned long long tmp;
-- 
2.25.1



Re: [U-Boot] [RFC][PATCH] spl: vboot: Verify content before using load_addr

2018-06-06 Thread Jun Nie
2018-06-06 9:08 GMT+08:00 Teddy Reed :
> When using verified-boot in the SPL, the FIT content must be
> verified before it can be used.
>
> Currently the load_addr FIT property is read and used as input to
> memcpy before the property is verified.
>
> Signed-off-by: Teddy Reed 
> ---

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


[U-Boot] [PATCH v3] sunxi: add support for Banana Pi M2 Zero board

2018-06-06 Thread Jun Nie
Banana Pi M2 Zero is a board by Sinovoip with Allwinner H2+ SoC, 16-bit
512MiB DDR3 memory, a MicroSD slot, two MicroUSB ports (one OTG and one
powering-only) and a miniHDMI port.

Signed-off-by: Icenowy Zheng 
Signed-off-by: Jun Nie 
---
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 122 
 board/sunxi/MAINTAINERS |   5 +
 configs/bananapi_m2_zero_defconfig  |  15 +++
 4 files changed, 143 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
 create mode 100644 configs/bananapi_m2_zero_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 790571b..5d392e8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -354,6 +354,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-a83t-tbs-a711.dts
 dtb-$(CONFIG_MACH_SUN8I_H3) += \
+   sun8i-h2-plus-bananapi-m2-zero.dtb \
sun8i-h2-plus-libretech-all-h3-cc.dtb \
sun8i-h2-plus-orangepi-zero.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
new file mode 100644
index 000..32a92dc
--- /dev/null
+++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2017 Icenowy Zheng 
+ *
+ * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
+ *   Copyright (C) 2016 Chen-Yu Tsai 
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+#include 
+#include 
+
+/ {
+   model = "Banana Pi BPI-M2-Zero";
+   compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
+
+   aliases {
+   serial0 = &uart0;
+   serial1 = &uart1;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+
+   pwr_led {
+   label = "bananapi-m2-zero:red:pwr";
+   gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+   default-state = "on";
+   };
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+
+   sw4 {
+   label = "power";
+   linux,code = ;
+   gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   wifi_pwrseq: wifi_pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   pinctrl-names = "default";
+   reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */
+   };
+};
+
+&ehci0 {
+   status = "okay";
+};
+
+&mmc0 {
+   vmmc-supply = <®_vcc3v3>;
+   bus-width = <4>;
+   /*
+* On the production batch of this board the card detect GPIO is
+* high active (card inserted), although on the early samples it's
+* low active.
+*/
+   cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
+   status = "okay";
+};
+
+&mmc1 {
+   vmmc-supply = <®_vcc3v3>;
+   vqmmc-supply = <®_vcc3v3>;
+   mmc-pwrseq = <&wifi_pwrseq>;
+   bus-width = <4>;
+   non-removable;
+   status = "okay";
+
+   brcmf: wifi@1 {
+   reg = <1>;
+   compatible = "brcm,bcm4329-fmac";
+   interrupt-parent = <&pio>;
+   interrupts = <6 10 IRQ_TYPE_LEVEL_LOW>; /* PG10 / EINT10 */
+   interrupt-names = "host-wake";
+   };
+};
+
+&ohci0 {
+   status = "okay";
+};
+
+&uart0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&uart0_pins_a>;
+   status = "okay";
+};
+
+&uart1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&uart1_pins_a>;
+   status = "okay";
+};
+
+&usb_otg {
+   dr_mode = "otg";
+   status = "okay";
+};
+
+&usbphy {
+   usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+   /*
+* There're two micro-USB connectors, one is power-only and another is
+* OTG. The Vbus of these two connectors are connected together, so
+* the external USB device will be powered just by the power input
+* from the power-only USB port.
+*/
+   status = "okay";
+};
diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index e90c87b..e199ec9 

[U-Boot] [PATCH] rpi: Do not use dtb loaded by firmware

2018-11-08 Thread Jun Nie
Do not use dtb loaded by firmware if fit image signature is enabled.
So that u-boot.dtb can be used. The u-boot.dtb contains the pulibc key
that is to verify Linux kernel FIT image blob.

The u-boot.dtb can be loaded by Arm Trusted Firmware(ATF) together
with u-boot.bin to make sure the key is protected by ATF.

Signed-off-by: Jun Nie 
---
 board/raspberrypi/rpi/rpi.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 649127c..f7041e3 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -283,6 +283,7 @@ int dram_init(void)
return 0;
 }
 
+#ifndef CONFIG_FIT_SIGNATURE
 static void set_fdtfile(void)
 {
const char *fdtfile;
@@ -318,6 +319,7 @@ unsigned long board_get_usable_ram_top(unsigned long 
total_size)
return gd->ram_top;
return fw_dtb_pointer & ~0x;
 }
+#endif
 
 static void set_usbethaddr(void)
 {
@@ -390,8 +392,10 @@ static void set_serial_number(void)
 
 int misc_init_r(void)
 {
+#ifndef CONFIG_FIT_SIGNATURE
set_fdt_addr();
set_fdtfile();
+#endif
set_usbethaddr();
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
set_board_info();
@@ -467,6 +471,7 @@ int board_init(void)
return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
 }
 
+#ifndef CONFIG_FIT_SIGNATURE
 /*
  * If the firmware passed a device tree use it for U-Boot.
  */
@@ -476,6 +481,7 @@ void *board_fdt_blob_setup(void)
return NULL;
return (void *)fw_dtb_pointer;
 }
+#endif
 
 int ft_board_setup(void *blob, bd_t *bd)
 {
-- 
2.7.4

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


Re: [U-Boot] [PATCH] rpi: Do not use dtb loaded by firmware

2018-11-08 Thread Jun Nie
Alexander Graf  于2018年11月8日周四 下午4:59写道:
>
> On 11/08/2018 09:36 AM, Jun Nie wrote:
> > Do not use dtb loaded by firmware if fit image signature is enabled.
> > So that u-boot.dtb can be used. The u-boot.dtb contains the pulibc key
> > that is to verify Linux kernel FIT image blob.
> >
> > The u-boot.dtb can be loaded by Arm Trusted Firmware(ATF) together
> > with u-boot.bin to make sure the key is protected by ATF.
>
> I don't think I fully understand what you're trying to do here. If ATF
> loads U-Boot as well as the DT, ATF can pass the DT to U-Boot which then
> ends up as $fdtaddr. If you enable CONFIG_OF_BOARD, it even becomes the
> input DT for U-Boot.

Current usage is that pack u-boot.dtb to u-boot-nodtb.bin so that
u-boot can find
device tree in the end if u-boot binary. This saves separate signing
to u-boot.dtb in
ATF. Do you see any benefit to load u-boot.dtb separately and feed
$fdtaddr to u-boot?

Jun

>
> Hiding the fdtfile variable name doesn't sound like it solves anything
> to me?
>
>
> Alex
>
> >
> > Signed-off-by: Jun Nie 
> > ---
> >   board/raspberrypi/rpi/rpi.c | 6 ++
> >   1 file changed, 6 insertions(+)
> >
> > diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> > index 649127c..f7041e3 100644
> > --- a/board/raspberrypi/rpi/rpi.c
> > +++ b/board/raspberrypi/rpi/rpi.c
> > @@ -283,6 +283,7 @@ int dram_init(void)
> >   return 0;
> >   }
> >
> > +#ifndef CONFIG_FIT_SIGNATURE
> >   static void set_fdtfile(void)
> >   {
> >   const char *fdtfile;
> > @@ -318,6 +319,7 @@ unsigned long board_get_usable_ram_top(unsigned long 
> > total_size)
> >   return gd->ram_top;
> >   return fw_dtb_pointer & ~0x;
> >   }
> > +#endif
> >
> >   static void set_usbethaddr(void)
> >   {
> > @@ -390,8 +392,10 @@ static void set_serial_number(void)
> >
> >   int misc_init_r(void)
> >   {
> > +#ifndef CONFIG_FIT_SIGNATURE
> >   set_fdt_addr();
> >   set_fdtfile();
> > +#endif
> >   set_usbethaddr();
> >   #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> >   set_board_info();
> > @@ -467,6 +471,7 @@ int board_init(void)
> >   return bcm2835_power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
> >   }
> >
> > +#ifndef CONFIG_FIT_SIGNATURE
> >   /*
> >* If the firmware passed a device tree use it for U-Boot.
> >*/
> > @@ -476,6 +481,7 @@ void *board_fdt_blob_setup(void)
> >   return NULL;
> >   return (void *)fw_dtb_pointer;
> >   }
> > +#endif
> >
> >   int ft_board_setup(void *blob, bd_t *bd)
> >   {
>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] common: build ymodem and s_record only on need

2018-02-11 Thread Jun Nie
Build ymodem and s_record only on need to shrink
spl image size.

Signed-off-by: Jun Nie 
---
 common/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index c7bde23..8e1569f 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -28,6 +28,8 @@ obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
+obj-$(CONFIG_CMD_LOADS) += s_record.o
+obj-$(CONFIG_CMD_LOADB) += xyzModem.o
 
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
@@ -132,5 +134,3 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-$(CONFIG_$(SPL_)LOG) += log.o
 obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
-obj-y += s_record.o
-obj-y += xyzModem.o
-- 
1.9.1

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


[U-Boot] [PATCH] SPL: Add signature verification when loading image

2018-02-11 Thread Jun Nie
Add signature verification when loading FIT image in SPL.

Signed-off-by: Jun Nie 
---
 common/image-fit.c   | 56 +++-
 common/spl/spl_fit.c | 12 +++
 include/image.h  |  2 ++
 3 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index f6e956a..94d9d4b 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1068,34 +1068,14 @@ static int fit_image_check_hash(const void *fit, int 
noffset, const void *data,
return 0;
 }
 
-/**
- * fit_image_verify - verify data integrity
- * @fit: pointer to the FIT format image header
- * @image_noffset: component image node offset
- *
- * fit_image_verify() goes over component image hash nodes,
- * re-calculates each data hash and compares with the value stored in hash
- * node.
- *
- * returns:
- * 1, if all hashes are valid
- * 0, otherwise (or on error)
- */
-int fit_image_verify(const void *fit, int image_noffset)
+int fit_image_verify_with_data(const void *fit, int image_noffset,
+   const void *data, size_t size)
 {
-   const void  *data;
-   size_t  size;
int noffset = 0;
char*err_msg = "";
int verify_all = 1;
int ret;
 
-   /* Get image data and data length */
-   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
-   err_msg = "Can't get image data/size";
-   goto error;
-   }
-
/* Verify all required signatures */
if (IMAGE_ENABLE_VERIFY &&
fit_image_verify_required_sigs(fit, image_noffset, data, size,
@@ -1153,6 +1133,38 @@ error:
 }
 
 /**
+ * fit_image_verify - verify data integrity
+ * @fit: pointer to the FIT format image header
+ * @image_noffset: component image node offset
+ *
+ * fit_image_verify() goes over component image hash nodes,
+ * re-calculates each data hash and compares with the value stored in hash
+ * node.
+ *
+ * returns:
+ * 1, if all hashes are valid
+ * 0, otherwise (or on error)
+ */
+int fit_image_verify(const void *fit, int image_noffset)
+{
+   const void  *data;
+   size_t  size;
+   int noffset = 0;
+   char*err_msg = "";
+
+   /* Get image data and data length */
+   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
+   err_msg = "Can't get image data/size";
+   printf("error!\n%s for '%s' hash node in '%s' image node\n",
+  err_msg, fit_get_name(fit, noffset, NULL),
+  fit_get_name(fit, image_noffset, NULL));
+   return 0;
+   }
+
+   return fit_image_verify_with_data(fit, image_noffset, data, size);
+}
+
+/**
  * fit_all_image_verify - verify data integrity for all images
  * @fit: pointer to the FIT format image header
  *
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index cc07fbc..8d382eb 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -174,6 +174,9 @@ static int spl_load_fit_image(struct spl_load_info *info, 
ulong sector,
uint8_t image_comp = -1, type = -1;
const void *data;
bool external_data = false;
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+   int ret;
+#endif
 
if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
if (fit_image_get_comp(fit, node, &image_comp))
@@ -252,7 +255,16 @@ static int spl_load_fit_image(struct spl_load_info *info, 
ulong sector,
image_info->entry_point = fdt_getprop_u32(fit, node, "entry");
}
 
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+   printf("## Checking hash(es) for Image %s ...\n",
+  fit_get_name(fit, node, NULL));
+   ret = fit_image_verify_with_data(fit, node,
+(const void *)load_addr, length);
+   printf("\n");
+   return !ret;
+#else
return 0;
+#endif
 }
 
 static int spl_fit_append_fdt(struct spl_image_info *spl_image,
diff --git a/include/image.h b/include/image.h
index 325b014..77c11f8 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1013,6 +1013,8 @@ int fit_add_verification_data(const char *keydir, void 
*keydest, void *fit,
  const char *comment, int require_keys,
  const char *engine_id);
 
+int fit_image_verify_with_data(const void *fit, int image_noffset,
+  const void *data, size_t size);
 int fit_image_verify(const void *fit, int noffset);
 int fit_config_verify(const void *fit, int conf_noffset);
 int fit_all_image_verify(const void *fit);
-- 
1.9.1

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


Re: [U-Boot] [PATCH] common: build ymodem and s_record only on need

2018-02-11 Thread Jun Nie
2018-02-12 8:54 GMT+08:00 André Przywara :
> Hi,
>
> On 11/02/18 09:53, Jun Nie wrote:
>> Build ymodem and s_record only on need to shrink
>> spl image size.
>>
>> Signed-off-by: Jun Nie 
>> ---
>>  common/Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/Makefile b/common/Makefile
>> index c7bde23..8e1569f 100644
>> --- a/common/Makefile
>> +++ b/common/Makefile
>> @@ -28,6 +28,8 @@ obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
>>  obj-$(CONFIG_CMD_BOOTM) += bootm.o bootm_os.o
>>  obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
>>  obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
>> +obj-$(CONFIG_CMD_LOADS) += s_record.o
>
> That sounds like a good idea, and indeed we need s_record.o only for
> CMD_LOADS, but in my case this _increases_ the binary size by 6 bytes.
>
>> +obj-$(CONFIG_CMD_LOADB) += xyzModem.o
>
> I don't believe CMD_LOADB is enough. xyzModem.c exports xyzModem_*
> functions, which are not only used in load.c, but also in
> common/spl/spl_ymodem.c.
> So you would need to check for config options enabling this, too.

Thanks for reminder! I will add more check for this.
>
> But same as above, applying this change does not decrease the size of
> the SPL binary.
> Mine goes from (current master, pine64_plus_defconfig):
>textdata bss dec hex filename
>   30038 360 440   308387876 spl/u-boot-spl
> to:
>textdata bss dec hex filename
>   30044 360 440   30844787c spl/u-boot-spl
>
> It seems like xyzModem_* functions and srec_decode() were removed by the
> linker as dead code already.
>
> So what does this save you? Can you share your numbers?
>
As you said, s_record.o does not impact on SPL size. For xyzModem, SPL
can save 136 bytes on bananapi zero board when I enable FIT
configuration. Otherwise, it does not impact SPL size neither.

No optimization:
   text   databssdechex filename
  24229440268  24937   6169 spl/u-boot-spl

Add optimization for xyzmodem.c
   text   databssdechex filename
  24091440268  24799   60df spl/u-boot-spl



> Cheers,
> Andre.
>
>>
>>  obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
>>  obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
>> @@ -132,5 +134,3 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
>>  obj-y += command.o
>>  obj-$(CONFIG_$(SPL_)LOG) += log.o
>>  obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
>> -obj-y += s_record.o
>> -obj-y += xyzModem.o
>>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] common: build ymodem only on need

2018-02-13 Thread Jun Nie
Build ymodem only on need to shrink spl image size.

Signed-off-by: Jun Nie 
---
 common/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/Makefile b/common/Makefile
index c7bde23..0614348 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -133,4 +133,5 @@ obj-y += command.o
 obj-$(CONFIG_$(SPL_)LOG) += log.o
 obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
 obj-y += s_record.o
-obj-y += xyzModem.o
+obj-$(CONFIG_CMD_LOADB) += xyzModem.o
+obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o
-- 
1.9.1

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


Re: [U-Boot] [PATCH] SPL: Add signature verification when loading image

2018-02-26 Thread Jun Nie
Hi,

Does anyone have comments on this patch?

Thank you!
Jun

2018-02-11 19:56 GMT+08:00 Jun Nie :
> Add signature verification when loading FIT image in SPL.
>
> Signed-off-by: Jun Nie 
> ---
>  common/image-fit.c   | 56 
> +++-
>  common/spl/spl_fit.c | 12 +++
>  include/image.h  |  2 ++
>  3 files changed, 48 insertions(+), 22 deletions(-)
>
> diff --git a/common/image-fit.c b/common/image-fit.c
> index f6e956a..94d9d4b 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -1068,34 +1068,14 @@ static int fit_image_check_hash(const void *fit, int 
> noffset, const void *data,
> return 0;
>  }
>
> -/**
> - * fit_image_verify - verify data integrity
> - * @fit: pointer to the FIT format image header
> - * @image_noffset: component image node offset
> - *
> - * fit_image_verify() goes over component image hash nodes,
> - * re-calculates each data hash and compares with the value stored in hash
> - * node.
> - *
> - * returns:
> - * 1, if all hashes are valid
> - * 0, otherwise (or on error)
> - */
> -int fit_image_verify(const void *fit, int image_noffset)
> +int fit_image_verify_with_data(const void *fit, int image_noffset,
> +   const void *data, size_t size)
>  {
> -   const void  *data;
> -   size_t  size;
> int noffset = 0;
> char*err_msg = "";
> int verify_all = 1;
> int ret;
>
> -   /* Get image data and data length */
> -   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
> -   err_msg = "Can't get image data/size";
> -   goto error;
> -   }
> -
> /* Verify all required signatures */
> if (IMAGE_ENABLE_VERIFY &&
> fit_image_verify_required_sigs(fit, image_noffset, data, size,
> @@ -1153,6 +1133,38 @@ error:
>  }
>
>  /**
> + * fit_image_verify - verify data integrity
> + * @fit: pointer to the FIT format image header
> + * @image_noffset: component image node offset
> + *
> + * fit_image_verify() goes over component image hash nodes,
> + * re-calculates each data hash and compares with the value stored in hash
> + * node.
> + *
> + * returns:
> + * 1, if all hashes are valid
> + * 0, otherwise (or on error)
> + */
> +int fit_image_verify(const void *fit, int image_noffset)
> +{
> +   const void  *data;
> +   size_t  size;
> +   int noffset = 0;
> +   char*err_msg = "";
> +
> +   /* Get image data and data length */
> +   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
> +   err_msg = "Can't get image data/size";
> +   printf("error!\n%s for '%s' hash node in '%s' image node\n",
> +  err_msg, fit_get_name(fit, noffset, NULL),
> +  fit_get_name(fit, image_noffset, NULL));
> +   return 0;
> +   }
> +
> +   return fit_image_verify_with_data(fit, image_noffset, data, size);
> +}
> +
> +/**
>   * fit_all_image_verify - verify data integrity for all images
>   * @fit: pointer to the FIT format image header
>   *
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index cc07fbc..8d382eb 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -174,6 +174,9 @@ static int spl_load_fit_image(struct spl_load_info *info, 
> ulong sector,
> uint8_t image_comp = -1, type = -1;
> const void *data;
> bool external_data = false;
> +#ifdef CONFIG_SPL_FIT_SIGNATURE
> +   int ret;
> +#endif
>
> if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
> if (fit_image_get_comp(fit, node, &image_comp))
> @@ -252,7 +255,16 @@ static int spl_load_fit_image(struct spl_load_info 
> *info, ulong sector,
> image_info->entry_point = fdt_getprop_u32(fit, node, "entry");
> }
>
> +#ifdef CONFIG_SPL_FIT_SIGNATURE
> +   printf("## Checking hash(es) for Image %s ...\n",
> +  fit_get_name(fit, node, NULL));
> +   ret = fit_image_verify_with_data(fit, node,
> +(const void *)load_addr, length);
> +   printf("\n");
> +   return !ret;
> +#else
> return 0;
> +#endif
>  }
>
>  static int spl_fit_append_fdt(struct spl_image_info *spl_image,
> diff --git a/include/image.h b/include/image.h
> index 325b014..77c

Re: [U-Boot] [PATCH] SPL: Add signature verification when loading image

2018-02-26 Thread Jun Nie
2018-02-26 17:56 GMT+08:00 Andre Przywara :
> Hi,
>
> On 11/02/18 11:56, Jun Nie wrote:
>> Add signature verification when loading FIT image in SPL.
>
> this message is very thin. Can you explain WHY you did this change and
> what it's supposed to do and what it improves?
> For my part I am completely clueless what you are after.
>
> Cheers,
> Andre.

There is no support for signature check to u-boot proper in SPL,
except platform specific implementation. This patch add signature
check to u-boot in SPL, that can be shared on most platforms, if not
all.

Jun

>
>> Signed-off-by: Jun Nie 
>> ---
>>  common/image-fit.c   | 56 
>> +++-
>>  common/spl/spl_fit.c | 12 +++
>>  include/image.h  |  2 ++
>>  3 files changed, 48 insertions(+), 22 deletions(-)
>>
>> diff --git a/common/image-fit.c b/common/image-fit.c
>> index f6e956a..94d9d4b 100644
>> --- a/common/image-fit.c
>> +++ b/common/image-fit.c
>> @@ -1068,34 +1068,14 @@ static int fit_image_check_hash(const void *fit, int 
>> noffset, const void *data,
>>   return 0;
>>  }
>>
>> -/**
>> - * fit_image_verify - verify data integrity
>> - * @fit: pointer to the FIT format image header
>> - * @image_noffset: component image node offset
>> - *
>> - * fit_image_verify() goes over component image hash nodes,
>> - * re-calculates each data hash and compares with the value stored in hash
>> - * node.
>> - *
>> - * returns:
>> - * 1, if all hashes are valid
>> - * 0, otherwise (or on error)
>> - */
>> -int fit_image_verify(const void *fit, int image_noffset)
>> +int fit_image_verify_with_data(const void *fit, int image_noffset,
>> + const void *data, size_t size)
>>  {
>> - const void  *data;
>> - size_t  size;
>>   int noffset = 0;
>>   char*err_msg = "";
>>   int verify_all = 1;
>>   int ret;
>>
>> - /* Get image data and data length */
>> - if (fit_image_get_data(fit, image_noffset, &data, &size)) {
>> - err_msg = "Can't get image data/size";
>> - goto error;
>> - }
>> -
>>   /* Verify all required signatures */
>>   if (IMAGE_ENABLE_VERIFY &&
>>   fit_image_verify_required_sigs(fit, image_noffset, data, size,
>> @@ -1153,6 +1133,38 @@ error:
>>  }
>>
>>  /**
>> + * fit_image_verify - verify data integrity
>> + * @fit: pointer to the FIT format image header
>> + * @image_noffset: component image node offset
>> + *
>> + * fit_image_verify() goes over component image hash nodes,
>> + * re-calculates each data hash and compares with the value stored in hash
>> + * node.
>> + *
>> + * returns:
>> + * 1, if all hashes are valid
>> + * 0, otherwise (or on error)
>> + */
>> +int fit_image_verify(const void *fit, int image_noffset)
>> +{
>> + const void  *data;
>> + size_t  size;
>> + int noffset = 0;
>> + char*err_msg = "";
>> +
>> + /* Get image data and data length */
>> + if (fit_image_get_data(fit, image_noffset, &data, &size)) {
>> + err_msg = "Can't get image data/size";
>> + printf("error!\n%s for '%s' hash node in '%s' image node\n",
>> +err_msg, fit_get_name(fit, noffset, NULL),
>> +fit_get_name(fit, image_noffset, NULL));
>> + return 0;
>> + }
>> +
>> + return fit_image_verify_with_data(fit, image_noffset, data, size);
>> +}
>> +
>> +/**
>>   * fit_all_image_verify - verify data integrity for all images
>>   * @fit: pointer to the FIT format image header
>>   *
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index cc07fbc..8d382eb 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -174,6 +174,9 @@ static int spl_load_fit_image(struct spl_load_info 
>> *info, ulong sector,
>>   uint8_t image_comp = -1, type = -1;
>>   const void *data;
>>   bool external_data = false;
>> +#ifdef CONFIG_SPL_FIT_SIGNATURE
>> + int ret;
>> +#endif
>>
>>   if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
>>   if (fit_image_get_comp(fit, node, &image_comp))
>&

Re: [U-Boot] [PATCH] SPL: Add signature verification when loading image

2018-02-26 Thread Jun Nie
2018-02-26 19:02 GMT+08:00 Andre Przywara :
> Hi,
>
> On 26/02/18 10:00, Jun Nie wrote:
>> 2018-02-26 17:56 GMT+08:00 Andre Przywara :
>>> Hi,
>>>
>>> On 11/02/18 11:56, Jun Nie wrote:
>>>> Add signature verification when loading FIT image in SPL.
>>>
>>> this message is very thin. Can you explain WHY you did this change and
>>> what it's supposed to do and what it improves?
>>> For my part I am completely clueless what you are after.
>>>
>>> Cheers,
>>> Andre.
>>
>> There is no support for signature check to u-boot proper in SPL,
>> except platform specific implementation. This patch add signature
>> check to u-boot in SPL, that can be shared on most platforms, if not
>> all.
>
> Thanks, that's a good *first* part of the commit message!
>
> Now it would be good to know how you achieve this, because this is not
> immediately obvious from looking at the patch.
> I guess you make the existing FIT image signature check used in U-Boot
> proper fit for being used in SPL as well? If yes, please state this.
>
> In general for this kind of patch I would structure a commit message
> like this:
> - What is the current situation, and why is it not good enough?
> - What is the change you propose, and how does it overcome the limitation?
> - What does that fix, specifically? (e.g. "Allows SPL signature checks
> on board xyz.")
>
> The last part is a clue to the maintainer why she should merge this patch.
>
> Cheers,
> Andre.

Thanks for sharing experience on this! If you do not have more
comments on these code,
I will prepare version 2 with these commit message.

Jun
>
>>>
>>>> Signed-off-by: Jun Nie 
>>>> ---
>>>>  common/image-fit.c   | 56 
>>>> +++-
>>>>  common/spl/spl_fit.c | 12 +++
>>>>  include/image.h  |  2 ++
>>>>  3 files changed, 48 insertions(+), 22 deletions(-)
>>>>
>>>> diff --git a/common/image-fit.c b/common/image-fit.c
>>>> index f6e956a..94d9d4b 100644
>>>> --- a/common/image-fit.c
>>>> +++ b/common/image-fit.c
>>>> @@ -1068,34 +1068,14 @@ static int fit_image_check_hash(const void *fit, 
>>>> int noffset, const void *data,
>>>>   return 0;
>>>>  }
>>>>
>>>> -/**
>>>> - * fit_image_verify - verify data integrity
>>>> - * @fit: pointer to the FIT format image header
>>>> - * @image_noffset: component image node offset
>>>> - *
>>>> - * fit_image_verify() goes over component image hash nodes,
>>>> - * re-calculates each data hash and compares with the value stored in hash
>>>> - * node.
>>>> - *
>>>> - * returns:
>>>> - * 1, if all hashes are valid
>>>> - * 0, otherwise (or on error)
>>>> - */
>>>> -int fit_image_verify(const void *fit, int image_noffset)
>>>> +int fit_image_verify_with_data(const void *fit, int image_noffset,
>>>> + const void *data, size_t size)
>>>>  {
>>>> - const void  *data;
>>>> - size_t  size;
>>>>   int noffset = 0;
>>>>   char*err_msg = "";
>>>>   int verify_all = 1;
>>>>   int ret;
>>>>
>>>> - /* Get image data and data length */
>>>> - if (fit_image_get_data(fit, image_noffset, &data, &size)) {
>>>> - err_msg = "Can't get image data/size";
>>>> - goto error;
>>>> - }
>>>> -
>>>>   /* Verify all required signatures */
>>>>   if (IMAGE_ENABLE_VERIFY &&
>>>>   fit_image_verify_required_sigs(fit, image_noffset, data, size,
>>>> @@ -1153,6 +1133,38 @@ error:
>>>>  }
>>>>
>>>>  /**
>>>> + * fit_image_verify - verify data integrity
>>>> + * @fit: pointer to the FIT format image header
>>>> + * @image_noffset: component image node offset
>>>> + *
>>>> + * fit_image_verify() goes over component image hash nodes,
>>>> + * re-calculates each data hash and compares with the value stored in hash
>>>> + * node.
>>>> + *
>>>> + * returns:
>>>> + * 1, if all hashes are valid
>>>> + * 0, otherwise (or on error)
>>>> 

[U-Boot] [PATCH v2] SPL: Add signature verification when loading image

2018-02-27 Thread Jun Nie
U-boot proper signature is not verified by SPL on most platforms
even config SPL_FIT_SIGNATURE is enabled. Only fsl-layerscape
platform support secure boot in platform specific code. So
verified boot cannot be achieved if u-boot proper is loaded by
SPL.

This patch add signature verification to u-boot proper images
when loading FIT image in SPL. It is tested on Allwinner bananapi
zero board with H2+ SoC.

Signed-off-by: Jun Nie 
---
 common/image-fit.c   | 56 +++-
 common/spl/spl_fit.c | 12 +++
 include/image.h  |  2 ++
 3 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index f6e956a..4b03390 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1068,34 +1068,14 @@ static int fit_image_check_hash(const void *fit, int 
noffset, const void *data,
return 0;
 }
 
-/**
- * fit_image_verify - verify data integrity
- * @fit: pointer to the FIT format image header
- * @image_noffset: component image node offset
- *
- * fit_image_verify() goes over component image hash nodes,
- * re-calculates each data hash and compares with the value stored in hash
- * node.
- *
- * returns:
- * 1, if all hashes are valid
- * 0, otherwise (or on error)
- */
-int fit_image_verify(const void *fit, int image_noffset)
+int fit_image_verify_with_data(const void *fit, int image_noffset,
+  const void *data, size_t size)
 {
-   const void  *data;
-   size_t  size;
int noffset = 0;
char*err_msg = "";
int verify_all = 1;
int ret;
 
-   /* Get image data and data length */
-   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
-   err_msg = "Can't get image data/size";
-   goto error;
-   }
-
/* Verify all required signatures */
if (IMAGE_ENABLE_VERIFY &&
fit_image_verify_required_sigs(fit, image_noffset, data, size,
@@ -1153,6 +1133,38 @@ error:
 }
 
 /**
+ * fit_image_verify - verify data integrity
+ * @fit: pointer to the FIT format image header
+ * @image_noffset: component image node offset
+ *
+ * fit_image_verify() goes over component image hash nodes,
+ * re-calculates each data hash and compares with the value stored in hash
+ * node.
+ *
+ * returns:
+ * 1, if all hashes are valid
+ * 0, otherwise (or on error)
+ */
+int fit_image_verify(const void *fit, int image_noffset)
+{
+   const void  *data;
+   size_t  size;
+   int noffset = 0;
+   char*err_msg = "";
+
+   /* Get image data and data length */
+   if (fit_image_get_data(fit, image_noffset, &data, &size)) {
+   err_msg = "Can't get image data/size";
+   printf("error!\n%s for '%s' hash node in '%s' image node\n",
+  err_msg, fit_get_name(fit, noffset, NULL),
+  fit_get_name(fit, image_noffset, NULL));
+   return 0;
+   }
+
+   return fit_image_verify_with_data(fit, image_noffset, data, size);
+}
+
+/**
  * fit_all_image_verify - verify data integrity for all images
  * @fit: pointer to the FIT format image header
  *
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index cc07fbc..8d382eb 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -174,6 +174,9 @@ static int spl_load_fit_image(struct spl_load_info *info, 
ulong sector,
uint8_t image_comp = -1, type = -1;
const void *data;
bool external_data = false;
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+   int ret;
+#endif
 
if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
if (fit_image_get_comp(fit, node, &image_comp))
@@ -252,7 +255,16 @@ static int spl_load_fit_image(struct spl_load_info *info, 
ulong sector,
image_info->entry_point = fdt_getprop_u32(fit, node, "entry");
}
 
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+   printf("## Checking hash(es) for Image %s ...\n",
+  fit_get_name(fit, node, NULL));
+   ret = fit_image_verify_with_data(fit, node,
+(const void *)load_addr, length);
+   printf("\n");
+   return !ret;
+#else
return 0;
+#endif
 }
 
 static int spl_fit_append_fdt(struct spl_image_info *spl_image,
diff --git a/include/image.h b/include/image.h
index 325b014..77c11f8 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1013,6 +1013,8 @@ int fit_add_verification_data(const char *keydir, void 
*keydest, void *fit,
  const char *comment, int require_keys,
  const char *engine_id);
 
+int fit_image_verify_with_data(const void *fit, int image_noffset,
+ 

Re: [U-Boot] [PATCH 2/2] image: fit: Show information about OS type in firwmare case too

2018-04-02 Thread Jun Nie
2018-03-26 22:31 GMT+08:00 Michal Simek :
> SPL ATF implementation requires FIT image with partitions where the one
> is Firmware/ATF and another one Firmware/U-Boot. OS field is used for
> recording that difference that's why make sense to show values there for
> Firmware types.
>
> For example:
>  Image 0 (atf)
>   Description:  ATF bl31.bin
>   Created:  Mon Mar 26 15:58:14 2018
>   Type: Firmware
>   Compression:  uncompressed
>   Data Size:51152 Bytes = 49.95 KiB = 0.05 MiB
>   Architecture: ARM
>   OS:   ARM Trusted Firmware
>   Load Address: 0xfffe
>   Hash algo:md5
>   Hash value:   36a4212bbb698126bf5a248f0f4b5336
>  Image 1 (uboot)
>   Description:  u-boot.bin
>   Created:  Mon Mar 26 15:58:14 2018
>   Type: Firmware
>   Compression:  uncompressed
>   Data Size:761216 Bytes = 743.38 KiB = 0.73 MiB
>   Architecture: ARM
>   OS:   U-Boot
>   Load Address: 0x0800
>   Hash algo:md5
>   Hash value:   f22960fe429be72296dc8dc59a47d566
>
> Signed-off-by: Michal Simek 
> ---
>
Reviewed-by: Jun Nie 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] image: fit: Show firmware configuration property if present

2018-04-02 Thread Jun Nie
2018-03-26 22:31 GMT+08:00 Michal Simek :
> SPL ATF support requires to have firmware property which should be also
> listed by mkimage -l when images is created.
>
> The patch is also using this macro in spl_fit to match keyword.
>
> When image is created:
>  Default Configuration: 'config'
>  Configuration 0 (config)
>   Description:  ATF with full u-boot
>   Kernel:   unavailable
>   Firmware: atf
>   FDT:  dtb
>
> Signed-off-by: Michal Simek 
> ---
>
Reviewed-by: Jun Nie 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] uboot support to Allwinner bananapi zero

2018-04-11 Thread Jun Nie
Hi Icenowy & Jagan,

I see bananapi zero patch was posted and discussed in [1], but without
further follow up. Maybe we can decide which name is more maintainable
first, bananapi-*, Bananapi-* or Sinovoip_BPI_*. And add all new
boards with following the rule. Which one do you prefer?

If possible, we can create symbol link or just rename files later as
it may cause issue for end user.

[1] https://patchwork.ozlabs.org/patch/832937/
[2] https://patchwork.kernel.org/patch/9753547/

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


[U-Boot] [PATCH] fit: skip signature verification if board request

2018-04-11 Thread Jun Nie
It may be unnecessary to check signature on unlocked board.
Get the hint from platform specific code to support secure boot
and non-secure boot with the same binary, so that boot is not
blocked if board is not locked and has no key for signature
verification.

Signed-off-by: Jun Nie 
---
 common/image-sig.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/common/image-sig.c b/common/image-sig.c
index d9f712f..f3d1252 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -151,6 +151,11 @@ struct image_region *fit_region_make_list(const void *fit,
return region;
 }
 
+int __attribute__((weak)) fit_board_skip_sig_verification(void)
+{
+   return 0;
+}
+
 static int fit_image_setup_verify(struct image_sign_info *info,
const void *fit, int noffset, int required_keynode,
char **err_msgp)
@@ -188,6 +193,12 @@ int fit_image_check_sig(const void *fit, int noffset, 
const void *data,
uint8_t *fit_value;
int fit_value_len;
 
+   /* Skip verification if board says that */
+   if (fit_board_skip_sig_verification()) {
+   printf("signature check skipped\n");
+   return 0;
+   }
+
*err_msgp = NULL;
if (fit_image_setup_verify(&info, fit, noffset, required_keynode,
   err_msgp))
@@ -438,6 +449,12 @@ int fit_config_verify_required_sigs(const void *fit, int 
conf_noffset,
int noffset;
int sig_node;
 
+   /* Skip verification if board says that */
+   if (fit_board_skip_sig_verification()) {
+   printf("signature check skipped\n");
+   return 0;
+   }
+
/* Work out what we need to verify */
sig_node = fdt_subnode_offset(sig_blob, 0, FIT_SIG_NODENAME);
if (sig_node < 0) {
-- 
2.7.4

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


Re: [U-Boot] [PATCH] fit: skip signature verification if board request

2018-04-13 Thread Jun Nie
2018-04-12 21:53 GMT+08:00 Tom Rini :
> On Wed, Apr 11, 2018 at 11:13:05PM +0800, Jun Nie wrote:
>
>> It may be unnecessary to check signature on unlocked board.
>> Get the hint from platform specific code to support secure boot
>> and non-secure boot with the same binary, so that boot is not
>> blocked if board is not locked and has no key for signature
>> verification.
>>
>> Signed-off-by: Jun Nie 
>> ---
> I'm not sure I like the concept here.  Wouldn't this make it easier to
> break in to a secure setup with some binary editing?  Or is that really
> no worse than today?  Also, can you please follow up with an
> implementation of fit_board_skip_sig_verification?  Thanks!
>
> --
> Tom

SoC boot ROM shall verify signature of SPL before running. Binary
editing shall make signature invalid. If it is possible to run an
edited SPL, the secure boot is already hacked and this patch does not
make it worse. I surely will post implementation, which is just
reading some register to get fuse value for lock status. I post this
patch to get opinions from community first.

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


Re: [U-Boot] [PATCH] fit: skip signature verification if board request

2018-04-13 Thread Jun Nie
2018-04-13 1:24 GMT+08:00 Simon Glass :
> Hi,
>
> On 11 April 2018 at 09:13, Jun Nie  wrote:
>> It may be unnecessary to check signature on unlocked board.
>> Get the hint from platform specific code to support secure boot
>> and non-secure boot with the same binary, so that boot is not
>> blocked if board is not locked and has no key for signature
>> verification.
>>
>> Signed-off-by: Jun Nie 
>> ---
>
> Instead of a weak function can you please add a parameter to this
> function (perhaps a flags word?) and a add test for this case to the
> test?
>
> Regards,
> Simon

Sure, I can add a parameter to the function. But not sure what's the
usage of it in your mind. Maybe "int flag" is enough for you?

Do you mean add implementation of this function for a specific platform
for "add test"?

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


Re: [U-Boot] [PATCH] fit: skip signature verification if board request

2018-04-18 Thread Jun Nie
2018-04-17 20:06 GMT+08:00 Quentin Schulz :
> Hi,
>
> On Wed, Apr 11, 2018 at 11:13:05PM +0800, Jun Nie wrote:
>> It may be unnecessary to check signature on unlocked board.
>> Get the hint from platform specific code to support secure boot
>> and non-secure boot with the same binary, so that boot is not
>> blocked if board is not locked and has no key for signature
>> verification.
>>
>
> Isn't it what the environment variable `verify` is made for?
>
> i.e. setting verify=no will skip checks and boot an image even though it
> isn't signed or hash/signature does not match.
>
> I may be missing some context here, so please ignore if it's not what
> you're after.

Thanks for pointing me for this. I check code and find that this variable
does not cover all signature verification cases, such as fit_image_verify().
There is no variable in SPL neither, I suppose.
>
> BTW, I saw that you were speaking of reading the lock fuse to decide
> whether to check the signature or not. I'd like to have at least a
> bypass option for this as it would be horribly tedious for
> debugging/development purposes. E.g. I want to be able to boot from an
> unverified U-Boot binary a signed (and checked) fitImage so that I can
> validate everything works as it should before locking down the
> bootloader.

For this case, it is OK if you do not detect lock fuse value and use default
weak function to indicate no skipping.

>
> Regards,
> Quentin
>
>> Signed-off-by: Jun Nie 
>> ---
>>  common/image-sig.c | 17 +
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/common/image-sig.c b/common/image-sig.c
>> index d9f712f..f3d1252 100644
>> --- a/common/image-sig.c
>> +++ b/common/image-sig.c
>> @@ -151,6 +151,11 @@ struct image_region *fit_region_make_list(const void 
>> *fit,
>>   return region;
>>  }
>>
>> +int __attribute__((weak)) fit_board_skip_sig_verification(void)
>> +{
>> + return 0;
>> +}
>> +
>>  static int fit_image_setup_verify(struct image_sign_info *info,
>>   const void *fit, int noffset, int required_keynode,
>>   char **err_msgp)
>> @@ -188,6 +193,12 @@ int fit_image_check_sig(const void *fit, int noffset, 
>> const void *data,
>>   uint8_t *fit_value;
>>   int fit_value_len;
>>
>> + /* Skip verification if board says that */
>> + if (fit_board_skip_sig_verification()) {
>> + printf("signature check skipped\n");
>> + return 0;
>> + }
>> +
>>   *err_msgp = NULL;
>>   if (fit_image_setup_verify(&info, fit, noffset, required_keynode,
>>  err_msgp))
>> @@ -438,6 +449,12 @@ int fit_config_verify_required_sigs(const void *fit, 
>> int conf_noffset,
>>   int noffset;
>>   int sig_node;
>>
>> + /* Skip verification if board says that */
>> + if (fit_board_skip_sig_verification()) {
>> + printf("signature check skipped\n");
>> + return 0;
>> + }
>> +
>>   /* Work out what we need to verify */
>>   sig_node = fdt_subnode_offset(sig_blob, 0, FIT_SIG_NODENAME);
>>   if (sig_node < 0) {
>> --
>> 2.7.4
>>
>> ___
>> 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] fit: skip signature verification if board request

2018-04-18 Thread Jun Nie
2018-04-17 3:06 GMT+08:00 Simon Glass :
> Hi Jun,
>
> On 13 April 2018 at 04:05, Jun Nie  wrote:
>> 2018-04-13 1:24 GMT+08:00 Simon Glass :
>>> Hi,
>>>
>>> On 11 April 2018 at 09:13, Jun Nie  wrote:
>>>> It may be unnecessary to check signature on unlocked board.
>>>> Get the hint from platform specific code to support secure boot
>>>> and non-secure boot with the same binary, so that boot is not
>>>> blocked if board is not locked and has no key for signature
>>>> verification.
>>>>
>>>> Signed-off-by: Jun Nie 
>>>> ---
>>>
>>> Instead of a weak function can you please add a parameter to this
>>> function (perhaps a flags word?) and a add test for this case to the
>>> test?
>>>
>>> Regards,
>>> Simon
>>
>> Sure, I can add a parameter to the function. But not sure what's the
>> usage of it in your mind. Maybe "int flag" is enough for you?
>
> Yes a flag is fine if you define an enum in the header file for that
> function. You will likely need to pass the flag around a few other
> functions.

I am still unclear on what the usage of this flag. I mean what variable
from fit_image_setup_verify() and fit_config_verify_required_sigs()
to be feed to this function as a flag. Maybe a void pointer is better
for different platform to pass context data and cost to specific data
structure. For example, pass data of image that to be verified.
fit_board_skip_sig_verification(const void *data)

>>
>> Do you mean add implementation of this function for a specific platform
>> for "add test"?
>
> See test/py/tests/test_vboot.py which you should be able to modify for
> your case.

Will check this file for more modification and test.

Thank you!

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


[U-Boot] [PATCH] mmc: Poll for broken card detection case

2018-01-01 Thread Jun Nie
Poll for broken card detection case instead of return
no card detected.

Signed-off-by: Jun Nie 
---
 drivers/mmc/Kconfig | 5 +
 drivers/mmc/mmc.c   | 4 
 2 files changed, 9 insertions(+)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 8fbeaa7..ed194a3 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -10,6 +10,11 @@ config MMC
  If you want MMC/SD/SDIO support, you should say Y here and
  also to your specific host controller driver.
 
+config MMC_BROKEN_CD
+   bool "Poll for broken card detection case"
+   help
+ If card  detection feature is broken, just poll to detect.
+
 config DM_MMC
bool "Enable MMC controllers using Driver Model"
depends on DM
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 38d2e07..13c5bf5 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1650,8 +1650,12 @@ int mmc_start_init(struct mmc *mmc)
bool no_card;
int err;
 
+#if !defined(CONFIG_MMC_BROKEN_CD)
/* we pretend there's no card when init is NULL */
no_card = mmc_getcd(mmc) == 0;
+#else
+   no_card = 0;
+#endif
 #if !CONFIG_IS_ENABLED(DM_MMC)
no_card = no_card || (mmc->cfg->ops->init == NULL);
 #endif
-- 
1.9.1

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


[U-Boot] [PATCH 0/6] Add Bananapi Zero board with OTG supported

2018-01-04 Thread Jun Nie
Add Bananapi Zero board defconfig and device tree.
OTG device is supported with enabling clock and adding necessary
controller configuration change. USB mass storage is tested as
a test case.

Jun Nie (6):
  sunxi: h3: add usb_otg and OHCI/EHCI for usbc0 on H3
  sunxi: musb: Add fifo config for H3
  sunxi: musb: Enable OTG device clock for H3
  sunxi: musb: Hack dynamic fifo support for H3 OTG
  sunxi: usb_phy: Clear PHYCTL register before writing
  sunxi: Add initial Banana-Pi Zero support

 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 113 
 arch/arm/dts/sun8i-h3.dtsi  |  32 +++
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h   |   2 +
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h |   4 +
 arch/arm/mach-sunxi/usb_phy.c   |   8 +-
 configs/bananapi_zero_defconfig |  17 
 drivers/usb/musb-new/musb_regs.h|   3 +-
 drivers/usb/musb-new/sunxi.c|  51 +++
 9 files changed, 229 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
 create mode 100644 configs/bananapi_zero_defconfig

-- 
1.9.1

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


[U-Boot] [PATCH 1/6] sunxi: h3: add usb_otg and OHCI/EHCI for usbc0 on H3

2018-01-04 Thread Jun Nie
Allwinner H3 have a dual-routed USB PHY0 -- routed to either OHCI/EHCI
or MUSB controller.

Signed-off-by: Jun Nie 
---
 arch/arm/dts/sun8i-h3.dtsi | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/dts/sun8i-h3.dtsi b/arch/arm/dts/sun8i-h3.dtsi
index afa6079..ae1e861 100644
--- a/arch/arm/dts/sun8i-h3.dtsi
+++ b/arch/arm/dts/sun8i-h3.dtsi
@@ -218,6 +218,19 @@
#size-cells = <0>;
};
 
+   usb_otg: usb@01c19000 {
+   compatible = "allwinner,sun8i-h3-musb";
+   reg = <0x01c19000 0x400>;
+   clocks = <&ccu CLK_BUS_OTG>;
+   resets = <&ccu RST_BUS_OTG>;
+   interrupts = ;
+   interrupt-names = "mc";
+   phys = <&usbphy 0>;
+   phy-names = "usb";
+   extcon = <&usbphy 0>;
+   status = "disabled";
+   };
+
usbphy: phy@01c19400 {
compatible = "allwinner,sun8i-h3-usb-phy";
reg = <0x01c19400 0x2c>,
@@ -250,6 +263,25 @@
#phy-cells = <1>;
};
 
+   ehci0: usb@01c1a000 {
+   compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
+   reg = <0x01c1a000 0x100>;
+   interrupts = ;
+   clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;
+   resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
+   status = "disabled";
+   };
+
+   ohci0: usb@01c1a400 {
+   compatible = "allwinner,sun8i-h3-ohci", "generic-ohci";
+   reg = <0x01c1a400 0x100>;
+   interrupts = ;
+   clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,
+<&ccu CLK_USB_OHCI0>;
+   resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
+   status = "disabled";
+   };
+
ehci1: usb@01c1b000 {
compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
reg = <0x01c1b000 0x100>;
-- 
1.9.1

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


[U-Boot] [PATCH 3/6] sunxi: musb: Enable OTG device clock for H3

2018-01-04 Thread Jun Nie
Enable OTG clock and deassert reset

Signed-off-by: Jun Nie 
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |  2 ++
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h   |  4 
 drivers/usb/musb-new/sunxi.c  | 19 +++
 3 files changed, 25 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h 
b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index d328df9..0d81791 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -280,6 +280,8 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_USB_EHCI2  27
 #define AHB_GATE_OFFSET_USB_EHCI1  26
 #define AHB_GATE_OFFSET_USB_EHCI0  25
+#define AHB_GATE_OFFSET_OTG_EHCI   24
+#define AHB_GATE_OFFSET_OTG_DEVICE 23
 #else
 #define AHB_GATE_OFFSET_USB_EHCI1  27
 #define AHB_GATE_OFFSET_USB_EHCI0  26
diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h 
b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
index 2419062..f7050df 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
@@ -64,7 +64,11 @@
 #ifdef CONFIG_SUNXI_GEN_SUN6I
 #if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
 #define SUNXI_USBPHY_BASE  0x01c19000
+#ifndef CONFIG_USB_MUSB_HOST
+#define SUNXI_USB0_BASE0x01c19000
+#else
 #define SUNXI_USB0_BASE0x01c1a000
+#endif
 #define SUNXI_USB1_BASE0x01c1b000
 #define SUNXI_USB2_BASE0x01c1c000
 #define SUNXI_USB3_BASE0x01c1d000
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 0005c1e..6d8242e 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -266,6 +266,16 @@ static int sunxi_musb_init(struct musb *musb)
 #ifdef CONFIG_SUNXI_GEN_SUN6I
setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
 #endif
+
+#ifdef CONFIG_MACH_SUNXI_H3_H5
+#ifdef CONFIG_USB_MUSB_HOST
+   setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_EHCI);
+   setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_OTG_EHCI);
+#else
+   setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
+   setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
+#endif
+#endif
sunxi_usb_phy_init(0);
 
USBC_ConfigFIFO_Base();
@@ -379,6 +389,15 @@ static int musb_usb_remove(struct udevice *dev)
 #endif
clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
 
+#ifdef CONFIG_MACH_SUNXI_H3_H5
+#ifdef CONFIG_USB_MUSB_HOST
+   clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_EHCI);
+   clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_OTG_EHCI);
+#else
+   clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
+   clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
+#endif
+#endif
free(host->host);
host->host = NULL;
 
-- 
1.9.1

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


[U-Boot] [PATCH 2/6] sunxi: musb: Add fifo config for H3

2018-01-04 Thread Jun Nie
Add fifo config for H3 as H3 differ with other SoC
on ep number.

Signed-off-by: Jun Nie 
---
 drivers/usb/musb-new/sunxi.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 7ee44ea..0005c1e 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -290,10 +290,42 @@ static const struct musb_platform_ops sunxi_musb_ops = {
.disable= sunxi_musb_disable,
 };
 
+#if defined(CONFIG_MACH_SUN8I_H3)
+static struct musb_fifo_cfg sunxi_musb_fifo_config[] = {
+   { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
+};
+#else
+static struct musb_fifo_cfg sunxi_musb_fifo_config[] = {
+   { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 5, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 5, .style = FIFO_RX, .maxpacket = 512, },
+};
+#endif
+
 static struct musb_hdrc_config musb_config = {
+   .fifo_cfg   = sunxi_musb_fifo_config,
+   .fifo_cfg_size  = ARRAY_SIZE(sunxi_musb_fifo_config),
.multipoint = 1,
.dyn_fifo   = 1,
+#if defined(CONFIG_MACH_SUN8I_H3)
.num_eps= 6,
+#else
+   .num_eps= 5,
+#endif
.ram_bits   = 11,
 };
 
-- 
1.9.1

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


[U-Boot] [PATCH 5/6] sunxi: usb_phy: Clear PHYCTL register before writing

2018-01-04 Thread Jun Nie
PHYCTL register offset at 0x10 need to be cleared before it's
written. Ported from below Linux patch.
  d699c1d phy: sun4i-usb: change PHYCTL register clearing code

Signed-off-by: Jun Nie 
---
 arch/arm/mach-sunxi/usb_phy.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/usb_phy.c b/arch/arm/mach-sunxi/usb_phy.c
index 2f1cad1..1a6b4b4 100644
--- a/arch/arm/mach-sunxi/usb_phy.c
+++ b/arch/arm/mach-sunxi/usb_phy.c
@@ -156,8 +156,14 @@ __maybe_unused static void usb_phy_write(struct 
sunxi_usb_phy *phy, int addr,
 static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
 {
 #if defined CONFIG_MACH_SUNXI_H3_H5
-   if (phy->id == 0)
+   if (phy->id == 0) {
+#if defined(CONFIG_USB_MUSB_HOST)
clrbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
+#else
+   setbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
+   writel(0, SUNXI_USB0_BASE + SUNXI_USB_CSR);
+#endif
+   }
 #endif
clrbits_le32(phy->base + REG_PMU_UNK_H3, 0x02);
 }
-- 
1.9.1

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


[U-Boot] [PATCH 6/6] sunxi: Add initial Banana-Pi Zero support

2018-01-04 Thread Jun Nie
Banana-Pi Zero is designed for IOT development
using the Allwinner H2+ SOC.

Key features
- Allwinner H2+, Quad-core Cortex-A7
- 512MB DRAM
- microSD slot
- Serial Debug Port
- Combo WiFi/BT
- HDMI

Signed-off-by: Jun Nie 
---
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 113 
 configs/bananapi_zero_defconfig |  17 
 3 files changed, 131 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
 create mode 100644 configs/bananapi_zero_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a895c70..80eec7e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -327,6 +327,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-a83t-tbs-a711.dts
 dtb-$(CONFIG_MACH_SUN8I_H3) += \
+   sun8i-h2-plus-bananapi-m2-zero.dtb \
sun8i-h2-plus-orangepi-zero.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
sun8i-h3-orangepi-2.dtb \
diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
new file mode 100644
index 000..4d96c16
--- /dev/null
+++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2017 Jun Nie 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+#include 
+
+/ {
+   model = "Banana Pi BPI-M2-Zero";
+   compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+
+   pwr_led {
+   label = "bananapi-m2-zero:red:pwr";
+   gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+   default-state = "on";
+   };
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   pinctrl-names = "default";
+
+   sw4 {
+   label = "power";
+   linux,code = ;
+   gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
+   };
+   };
+};
+
+&mmc0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&mmc0_pins_a>;
+   vmmc-supply = <®_vcc3v3>;
+   bus-width = <4>;
+   /*
+* In different revisions the board have different card detect
+* configuration.
+*/
+   broken-cd;
+   status = "okay";
+};
+
+&uart0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&uart0_pins_a>;
+   status = "okay";

[U-Boot] [PATCH 4/6] sunxi: musb: Hack dynamic fifo support for H3 OTG

2018-01-04 Thread Jun Nie
Like other Allwinner SoC, the H3 is missing the config register
from the musb hardware block. Use a known working value for it
like other SoC.

Signed-off-by: Jun Nie 
---
 drivers/usb/musb-new/musb_regs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb-new/musb_regs.h b/drivers/usb/musb-new/musb_regs.h
index a3cc38e..3e51003 100644
--- a/drivers/usb/musb-new/musb_regs.h
+++ b/drivers/usb/musb-new/musb_regs.h
@@ -432,7 +432,8 @@ static inline u8 musb_read_ulpi_buscontrol(void __iomem 
*mbase)
 
 static inline u8 musb_read_configdata(void __iomem *mbase)
 {
-#if defined CONFIG_MACH_SUN8I_A33 || defined CONFIG_MACH_SUN8I_A83T
+#if defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN8I_A83T) || \
+   defined(CONFIG_MACH_SUN8I_H3)
/*  allwinner saves a reg, and we need to hardcode this */
return 0xde;
 #else
-- 
1.9.1

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


Re: [U-Boot] [PATCH 0/6] Add Bananapi Zero board with OTG supported

2018-01-05 Thread Jun Nie
Thank you very much! Will check.

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


Re: [U-Boot] [PATCH 6/6] sunxi: Add initial Banana-Pi Zero support

2018-01-05 Thread Jun Nie
>> +/dts-v1/;
>> +#include "sun8i-h3.dtsi"
>> +#include "sunxi-common-regulators.dtsi"
>> +
>> +#include 
>> +#include 
>
> Where is that DT coming from?
>
> Usually, we'll just merge a DT merged in Linux.

The DT come from Linux but modified with removing necessary nodes.
>
>> +/ {
>> + model = "Banana Pi BPI-M2-Zero";
>> + compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
>> +
>> + aliases {
>> + serial0 = &uart0;
>> + };
>> +
>> + chosen {
>> + stdout-path = "serial0:115200n8";
>> + };
>> +
>> + leds {
>> + compatible = "gpio-leds";
>> + pinctrl-names = "default";
>> +
>> + pwr_led {
>> + label = "bananapi-m2-zero:red:pwr";
>> + gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
>> + default-state = "on";
>> + };
>> + };
>> +
>> + gpio_keys {
>> + compatible = "gpio-keys";
>> + pinctrl-names = "default";
>> +
>> + sw4 {
>> + label = "power";
>> + linux,code = ;
>> + gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
>> + };
>> + };
>> +};
>> +
>> +&mmc0 {
>> + pinctrl-names = "default";
>> + pinctrl-0 = <&mmc0_pins_a>;
>> + vmmc-supply = <®_vcc3v3>;
>> + bus-width = <4>;
>> + /*
>> +  * In different revisions the board have different card detect
>> +  * configuration.
>> +  */
>> + broken-cd;
>> + status = "okay";
>> +};
>> +
>> +&uart0 {
>> + pinctrl-names = "default";
>> + pinctrl-0 = <&uart0_pins_a>;
>> + status = "okay";
>> +};
>> +
>> +&usb_otg {
>> + dr_mode = "otg";
>> + status = "okay";
>> +};
>> +
>> +&usbphy {
>> + usb0_id_det-gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
>> + /* USB OTG VBUS is directly connected to 5V without any regulators */
>
> Then it cannot really do OTG, but rather only peripheral (or host, if
> the power is provided by the board).

Right, and working mode in u-boot is decided in compile time,
CONFIG_USB_MUSB_HOST.

>
>> + status = "okay";
>> +};
>> diff --git a/configs/bananapi_zero_defconfig 
>> b/configs/bananapi_zero_defconfig
>> new file mode 100644
>> index 000..9c78b21
>> --- /dev/null
>> +++ b/configs/bananapi_zero_defconfig
>> @@ -0,0 +1,17 @@
>> +CONFIG_ARM=y
>> +CONFIG_ARCH_SUNXI=y
>> +CONFIG_MACH_SUN8I_H3=y
>> +CONFIG_DRAM_CLK=408
>> +CONFIG_DRAM_ZQ=3881979
>> +CONFIG_DRAM_ODT_EN=y
>> +CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"
>> +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>> +CONFIG_SPL=y
>> +# CONFIG_CMD_FLASH is not set
>> +# CONFIG_CMD_FPGA is not set
>> +CONFIG_CMD_USB_MASS_STORAGE=y
>
> This shouldn't be enabled in the defconfig.

Thanks for pointing out! Is there any guidance, where DTS should come
from, what defconfig shall include, ...?  I am new to u-boot :-)

>
> The rest of the serie looks good, thanks!
> Maxime


Thanks for review!
Jun
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/6] Add Bananapi Zero board with OTG supported

2018-01-05 Thread Jun Nie
>
> a64 on otg have in ML[1] check if any redundant otherwise it's OK., we
> will test these and send next version.
>
>>   sunxi: Add initial Banana-Pi Zero support
>
> similar patch is already in ML [2]
>
> [1] https://patchwork.ozlabs.org/cover/847375/

This serial patches in the link does not introduce any redundant
change with my USB patches. So my patches 1-5 still deserve review.
Conflict should be resolve of course because some change is made in
the same line.

Two points for patches in the link:
- SUNXI_MUSB_BASE is redefined with the patches in the link for H3
configuration in my test.
- Some coding style conflict with u-boot, such as USBC_SelectPhyToDevice.

> [2] https://patchwork.ozlabs.org/patch/832937/

This patch can replace my patch 6 and please ignore my patch 6.

Jun
>
> --
> Jagan Teki
> Free Software Engineer | www.openedev.com
> U-Boot, Linux | Upstream Maintainer
> Hyderabad, India.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 0/6] Add Bananapi Zero board with OTG supported

2018-01-05 Thread Jun Nie
2018-01-05 17:06 GMT+08:00 Chen-Yu Tsai :
> On Fri, Jan 5, 2018 at 5:04 PM, Jun Nie  wrote:
>>>
>>> a64 on otg have in ML[1] check if any redundant otherwise it's OK., we
>>> will test these and send next version.
>>>
>>>>   sunxi: Add initial Banana-Pi Zero support
>>>
>>> similar patch is already in ML [2]
>>>
>>> [1] https://patchwork.ozlabs.org/cover/847375/
>>
>> This serial patches in the link does not introduce any redundant
>> change with my USB patches. So my patches 1-5 still deserve review.
>> Conflict should be resolve of course because some change is made in
>> the same line.
>>
>> Two points for patches in the link:
>> - SUNXI_MUSB_BASE is redefined with the patches in the link for H3
>> configuration in my test.
>> - Some coding style conflict with u-boot, such as USBC_SelectPhyToDevice.
>
> I have some similar patches here:
>
> https://github.com/wens/u-boot-sunxi/commits/libretech-cc
>
> ChenYu

ChenYu,

Are you patches are in review process or merge process? When do you
expected they are merged?

Jun
>
>>> [2] https://patchwork.ozlabs.org/patch/832937/
>>
>> This patch can replace my patch 6 and please ignore my patch 6.
>>
>> Jun
>>>
>>> --
>>> Jagan Teki
>>> Free Software Engineer | www.openedev.com
>>> U-Boot, Linux | Upstream Maintainer
>>> Hyderabad, India.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [[PATCH v2] 0/8] sunxi: Enable OTG peripheral and host mode on H3

2018-01-05 Thread Jun Nie
Changes vs V1:
- Add two patches from Chen-Yu to enable host mode
- split USB0 base address change to separate patch
- revise OTG clock enabling patch

Chen-Yu Tsai (2):
  sunxi: Fix USB PHY index for H3/H5/A64
  sunxi: usb_phy: setup USB PHY passby for USB0 on H3/H5/A64

Jun Nie (6):
  sunxi: h3: Sync OTG and HCI nodes from Linux DT
  sunxi: musb: Add fifo config for H3
  sunxi: musb: Hack dynamic fifo support for H3 OTG
  sunxi: musb: Enable OTG device clock for H3
  sunxi: usb_phy: Clear PHYCTL register before writing
  sunxi: H3: set different otg base address per mode

 arch/arm/dts/sun8i-h3.dtsi| 32 ++
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 31 +++---
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h   |  4 +++
 arch/arm/mach-sunxi/usb_phy.c | 15 +--
 drivers/usb/host/ehci-sunxi.c |  9 ++-
 drivers/usb/host/ohci-sunxi.c |  9 ++-
 drivers/usb/musb-new/musb_regs.h  |  3 ++-
 drivers/usb/musb-new/sunxi.c  | 38 ++-
 8 files changed, 119 insertions(+), 22 deletions(-)

-- 
1.9.1

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


[U-Boot] [[PATCH v2] 3/8] sunxi: Fix USB PHY index for H3/H5/A64

2018-01-05 Thread Jun Nie
From: Chen-Yu Tsai 

On the new chips such as H3, H5, and A64, the USB OTG controller is
paired with a set of proper EHCI/OHCI USB hosts. To enable these hosts,
the USB PHY index count has to be reworked to start from this pair.

This patch reworks the USB clock gate and reset indices, and how the
USB host is mapped to a USB phy, for the newer chips.

Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 30 +--
 drivers/usb/host/ehci-sunxi.c |  9 +++-
 drivers/usb/host/ohci-sunxi.c |  9 +++-
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h 
b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index d328df9..2c82d0a 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -270,17 +270,18 @@ struct sunxi_ccm_reg {
 #define AXI_GATE_OFFSET_DRAM   0
 
 /* ahb_gate0 offsets */
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+#define AHB_GATE_OFFSET_USB_OHCI3  31
+#define AHB_GATE_OFFSET_USB_OHCI2  30
+#define AHB_GATE_OFFSET_USB_OHCI1  29
+#define AHB_GATE_OFFSET_USB_OHCI0  28
+#define AHB_GATE_OFFSET_USB_EHCI3  27
+#define AHB_GATE_OFFSET_USB_EHCI2  26
+#define AHB_GATE_OFFSET_USB_EHCI1  25
+#define AHB_GATE_OFFSET_USB_EHCI0  24
+#else
 #define AHB_GATE_OFFSET_USB_OHCI1  30
 #define AHB_GATE_OFFSET_USB_OHCI0  29
-#ifdef CONFIG_MACH_SUNXI_H3_H5
-/*
- * These are EHCI1 - EHCI3 in the datasheet (EHCI0 is for the OTG) we call
- * them 0 - 2 like they were called on older SoCs.
- */
-#define AHB_GATE_OFFSET_USB_EHCI2  27
-#define AHB_GATE_OFFSET_USB_EHCI1  26
-#define AHB_GATE_OFFSET_USB_EHCI0  25
-#else
 #define AHB_GATE_OFFSET_USB_EHCI1  27
 #define AHB_GATE_OFFSET_USB_EHCI0  26
 #endif
@@ -339,13 +340,10 @@ struct sunxi_ccm_reg {
 #define CCM_USB_CTRL_PHY2_CLK (0x1 << 10)
 #define CCM_USB_CTRL_PHY3_CLK (0x1 << 11)
 #ifdef CONFIG_MACH_SUNXI_H3_H5
-/*
- * These are OHCI1 - OHCI3 in the datasheet (OHCI0 is for the OTG) we call
- * them 0 - 2 like they were called on older SoCs.
- */
-#define CCM_USB_CTRL_OHCI0_CLK (0x1 << 17)
-#define CCM_USB_CTRL_OHCI1_CLK (0x1 << 18)
-#define CCM_USB_CTRL_OHCI2_CLK (0x1 << 19)
+#define CCM_USB_CTRL_OHCI0_CLK (0x1 << 16)
+#define CCM_USB_CTRL_OHCI1_CLK (0x1 << 17)
+#define CCM_USB_CTRL_OHCI2_CLK (0x1 << 18)
+#define CCM_USB_CTRL_OHCI3_CLK (0x1 << 19)
 #else
 #define CCM_USB_CTRL_OHCI0_CLK (0x1 << 16)
 #define CCM_USB_CTRL_OHCI1_CLK (0x1 << 17)
diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c
index 6ecb7c4..f40228e 100644
--- a/drivers/usb/host/ehci-sunxi.c
+++ b/drivers/usb/host/ehci-sunxi.c
@@ -48,10 +48,17 @@ static int ehci_usb_probe(struct udevice *dev)
 #if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0;
 #endif
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+   /* Newer chips have a EHCI/OHCI host pair for OTG host mode */
+   priv->phy_index = ((uintptr_t)hccr - SUNXI_USB0_BASE) / BASE_DIST;
+#else
priv->phy_index = ((uintptr_t)hccr - SUNXI_USB1_BASE) / BASE_DIST;
+#endif
priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
-   priv->phy_index++; /* Non otg phys start at 1 */
+#if !defined(CONFIG_MACH_SUNXI_H3_H5) && !defined(CONFIG_MACH_SUN50I)
+   priv->phy_index++; /* older chips do not have EHCI with OTG */
+#endif
 
setbits_le32(&ccm->ahb_gate0,
 priv->ahb_gate_mask | extra_ahb_gate_mask);
diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c
index 133774f..4b8a403 100644
--- a/drivers/usb/host/ohci-sunxi.c
+++ b/drivers/usb/host/ohci-sunxi.c
@@ -51,11 +51,18 @@ static int ohci_usb_probe(struct udevice *dev)
extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0;
 #endif
priv->usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK;
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+   /* Newer chips have a EHCI/OHCI host pair for OTG host mode */
+   priv->phy_index = ((uintptr_t)regs - (SUNXI_USB0_BASE + 0x400)) / 
BASE_DIST;
+#else
priv->phy_index = ((uintptr_t)regs - (SUNXI_USB1_BASE + 0x400)) / 
BASE_DIST;
+#endif
priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST;
priv->usb_gate_mask <<= priv->phy_index;
-   priv->phy_index++; /* Non otg phys start at 1 */
+#if !defined(CONFIG_MACH_SUNXI_H3_H5) && !defined(CONFIG_MACH_SUN50I)
+   priv->phy_index++; /* older chips do not have OHCI with OTG */
+#endif
 
setbits_le32(&ccm->ahb_gate0,
 priv->ahb_gate_mask | extra_ahb_gate_mask);
-- 
1.9.1

___
U-Boot mailing list
U-

[U-Boot] [[PATCH v2] 1/8] sunxi: h3: Sync OTG and HCI nodes from Linux DT

2018-01-05 Thread Jun Nie
Allwinner H3 have a dual-routed USB PHY0 -- routed to either OHCI/EHCI
or MUSB controller.

Signed-off-by: Jun Nie 
---
 arch/arm/dts/sun8i-h3.dtsi | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/dts/sun8i-h3.dtsi b/arch/arm/dts/sun8i-h3.dtsi
index afa6079..d9728a7 100644
--- a/arch/arm/dts/sun8i-h3.dtsi
+++ b/arch/arm/dts/sun8i-h3.dtsi
@@ -218,6 +218,19 @@
#size-cells = <0>;
};
 
+   usb_otg: usb@1c19000 {
+   compatible = "allwinner,sun8i-h3-musb";
+   reg = <0x01c19000 0x400>;
+   clocks = <&ccu CLK_BUS_OTG>;
+   resets = <&ccu RST_BUS_OTG>;
+   interrupts = ;
+   interrupt-names = "mc";
+   phys = <&usbphy 0>;
+   phy-names = "usb";
+   extcon = <&usbphy 0>;
+   status = "disabled";
+   };
+
usbphy: phy@01c19400 {
compatible = "allwinner,sun8i-h3-usb-phy";
reg = <0x01c19400 0x2c>,
@@ -250,6 +263,25 @@
#phy-cells = <1>;
};
 
+   ehci0: usb@1c1a000 {
+   compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
+   reg = <0x01c1a000 0x100>;
+   interrupts = ;
+   clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;
+   resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
+   status = "disabled";
+   };
+
+   ohci0: usb@1c1a400 {
+   compatible = "allwinner,sun8i-h3-ohci", "generic-ohci";
+   reg = <0x01c1a400 0x100>;
+   interrupts = ;
+   clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,
+<&ccu CLK_USB_OHCI0>;
+   resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
+   status = "disabled";
+   };
+
ehci1: usb@01c1b000 {
compatible = "allwinner,sun8i-h3-ehci", "generic-ehci";
reg = <0x01c1b000 0x100>;
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 2/8] sunxi: musb: Add fifo config for H3

2018-01-05 Thread Jun Nie
Add fifo config for H3 as H3 differ with other SoC
on ep number.

Signed-off-by: Jun Nie 
Reviewed-by: Jagan Teki 
---
 drivers/usb/musb-new/sunxi.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 7ee44ea..0005c1e 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -290,10 +290,42 @@ static const struct musb_platform_ops sunxi_musb_ops = {
.disable= sunxi_musb_disable,
 };
 
+#if defined(CONFIG_MACH_SUN8I_H3)
+static struct musb_fifo_cfg sunxi_musb_fifo_config[] = {
+   { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
+};
+#else
+static struct musb_fifo_cfg sunxi_musb_fifo_config[] = {
+   { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 2, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 3, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 4, .style = FIFO_RX, .maxpacket = 512, },
+   { .hw_ep_num = 5, .style = FIFO_TX, .maxpacket = 512, },
+   { .hw_ep_num = 5, .style = FIFO_RX, .maxpacket = 512, },
+};
+#endif
+
 static struct musb_hdrc_config musb_config = {
+   .fifo_cfg   = sunxi_musb_fifo_config,
+   .fifo_cfg_size  = ARRAY_SIZE(sunxi_musb_fifo_config),
.multipoint = 1,
.dyn_fifo   = 1,
+#if defined(CONFIG_MACH_SUN8I_H3)
.num_eps= 6,
+#else
+   .num_eps= 5,
+#endif
.ram_bits   = 11,
 };
 
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 4/8] sunxi: musb: Hack dynamic fifo support for H3 OTG

2018-01-05 Thread Jun Nie
Like other Allwinner SoC, the H3 is missing the config register
from the musb hardware block. Use a known working value for it
like other SoC.

Signed-off-by: Jun Nie 
---
 drivers/usb/musb-new/musb_regs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb-new/musb_regs.h b/drivers/usb/musb-new/musb_regs.h
index a3cc38e..8a357ed 100644
--- a/drivers/usb/musb-new/musb_regs.h
+++ b/drivers/usb/musb-new/musb_regs.h
@@ -432,7 +432,8 @@ static inline u8 musb_read_ulpi_buscontrol(void __iomem 
*mbase)
 
 static inline u8 musb_read_configdata(void __iomem *mbase)
 {
-#if defined CONFIG_MACH_SUN8I_A33 || defined CONFIG_MACH_SUN8I_A83T
+#if defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN8I_A83T) || \
+   defined(CONFIG_MACH_SUNXI_H3_H5)
/*  allwinner saves a reg, and we need to hardcode this */
return 0xde;
 #else
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 5/8] sunxi: musb: Enable OTG device clock for H3

2018-01-05 Thread Jun Nie
Enable OTG clock and deassert reset

Signed-off-by: Jun Nie 
---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 1 +
 drivers/usb/musb-new/sunxi.c  | 6 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h 
b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index 2c82d0a..624d624 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -279,6 +279,7 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_USB_EHCI2  26
 #define AHB_GATE_OFFSET_USB_EHCI1  25
 #define AHB_GATE_OFFSET_USB_EHCI0  24
+#define AHB_GATE_OFFSET_OTG_DEVICE 23
 #else
 #define AHB_GATE_OFFSET_USB_OHCI1  30
 #define AHB_GATE_OFFSET_USB_OHCI0  29
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 0005c1e..ce7365b 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -264,7 +264,10 @@ static int sunxi_musb_init(struct musb *musb)
 
setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
 #ifdef CONFIG_SUNXI_GEN_SUN6I
-   setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
+   setbits_le32(&ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_OTG_DEVICE));
+   setbits_le32(&ccm->ahb_reset0_cfg,
+BIT(AHB_GATE_OFFSET_USB0) |
+BIT(AHB_GATE_OFFSET_OTG_DEVICE));
 #endif
sunxi_usb_phy_init(0);
 
@@ -376,6 +379,7 @@ static int musb_usb_remove(struct udevice *dev)
sunxi_usb_phy_exit(0);
 #ifdef CONFIG_SUNXI_GEN_SUN6I
clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_GATE_OFFSET_USB0);
+   clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_OTG_DEVICE);
 #endif
clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_USB0);
 
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 6/8] sunxi: usb_phy: Clear PHYCTL register before writing

2018-01-05 Thread Jun Nie
PHYCTL register offset at 0x10 need to be cleared before it's
written. Ported from below Linux patch.
  d699c1d phy: sun4i-usb: change PHYCTL register clearing code

Signed-off-by: Jun Nie 
---
 arch/arm/mach-sunxi/usb_phy.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/usb_phy.c b/arch/arm/mach-sunxi/usb_phy.c
index 2f1cad1..bcf5f15 100644
--- a/arch/arm/mach-sunxi/usb_phy.c
+++ b/arch/arm/mach-sunxi/usb_phy.c
@@ -156,9 +156,15 @@ __maybe_unused static void usb_phy_write(struct 
sunxi_usb_phy *phy, int addr,
 static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
 {
 #if defined CONFIG_MACH_SUNXI_H3_H5
-   if (phy->id == 0)
+   if (phy->id == 0) {
+#ifdef CONFIG_USB_MUSB_GADGET
+   setbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
+   writel(0, SUNXI_USB0_BASE + SUNXI_USB_CSR);
+#else
clrbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
 #endif
+   }
+#endif
clrbits_le32(phy->base + REG_PMU_UNK_H3, 0x02);
 }
 #elif defined CONFIG_MACH_SUN8I_A83T
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 8/8] sunxi: H3: set different otg base address per mode

2018-01-05 Thread Jun Nie
Set different base address per host mode or peripheral mode. Phy
configuration also depends on this address.

Signed-off-by: Jun Nie 
---
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h 
b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
index 2419062..f45f53a 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
@@ -64,7 +64,11 @@
 #ifdef CONFIG_SUNXI_GEN_SUN6I
 #if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
 #define SUNXI_USBPHY_BASE  0x01c19000
+#ifdef CONFIG_USB_MUSB_GADGET
+#define SUNXI_USB0_BASE0x01c19000
+#else
 #define SUNXI_USB0_BASE0x01c1a000
+#endif
 #define SUNXI_USB1_BASE0x01c1b000
 #define SUNXI_USB2_BASE0x01c1c000
 #define SUNXI_USB3_BASE0x01c1d000
-- 
1.9.1

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


[U-Boot] [[PATCH v2] 7/8] sunxi: usb_phy: setup USB PHY passby for USB0 on H3/H5/A64

2018-01-05 Thread Jun Nie
From: Chen-Yu Tsai 

On newer chips, there is a pair of EHCI/OHCI USB hosts for OTG host
mode. USB PHY passby must be configured for its corresponding PHY.

Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/mach-sunxi/usb_phy.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-sunxi/usb_phy.c b/arch/arm/mach-sunxi/usb_phy.c
index bcf5f15..4ae0a77 100644
--- a/arch/arm/mach-sunxi/usb_phy.c
+++ b/arch/arm/mach-sunxi/usb_phy.c
@@ -245,7 +245,12 @@ void sunxi_usb_phy_init(int index)
 
sunxi_usb_phy_config(phy);
 
-   if (phy->id != 0)
+   /*
+* Later SoCs such as the H3, H5, A64 have proper hosts for OTG.
+* As such the passby settings need to be set for them as well.
+*/
+   if (phy->id != 0 || IS_ENABLED(CONFIG_MACH_SUNXI_H3_H5) ||
+   IS_ENABLED(CONFIG_MACH_SUN50I))
sunxi_usb_phy_passby(phy, SUNXI_USB_PASSBY_EN);
 
 #ifdef CONFIG_MACH_SUN8I_A83T
-- 
1.9.1

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


Re: [U-Boot] [PATCH v2] musb: sunxi: Use base address from device tree

2018-01-10 Thread Jun Nie
2017-12-30 20:44 GMT+08:00 Chen-Yu Tsai :
> Now that the musb sunxi glue driver is completely device model / device
> tree driven, we should use the base address from the device tree,
> instead of hard-coding it in the source code.
>
> Fixes: 3a61b080acee ("musb: sunxi: switch to the device model")
> Signed-off-by: Chen-Yu Tsai 
> ---
> Changes since v1:
>
>   - Check return value dev_read_addr_ptr()
>
> IMHO, having NULL represent an error for dev_read_addr_ptr() doesn't
> work so well as in the kernel, because U-boot doesn't acually map
> addresses. So NULL (or 0x0) is in fact a valid address. Something
> like ~0x0 might work better, but that's a whole other changeset.
>
> ---
>  drivers/usb/musb-new/sunxi.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
> index 7ee44ea91900..aedc24b93711 100644
> --- a/drivers/usb/musb-new/sunxi.c
> +++ b/drivers/usb/musb-new/sunxi.c
> @@ -312,13 +312,16 @@ static int musb_usb_probe(struct udevice *dev)
>  {
> struct musb_host_data *host = dev_get_priv(dev);
> struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
> +   void *base = dev_read_addr_ptr(dev);
> int ret;

Chenyu,

I am not familiar with MUSB and not sure whether this driver support
both host and peripheral mode. I suppose it support both mode in
different build config according to macro CONFIG_USB_MUSB_HOST. H3
user manual says register address space is different for the two
modes,  0x1c19000 for device mode and 0x1c1a000 for host mode.
If my understanding is correct, we need different address in dts for
different mode. Or I misunderstand anything? Thank you for explaining
it!

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


Re: [U-Boot] [PATCH v7 00/35] phy: sunxi: Add Allwinner sun4i USB PHY

2018-05-15 Thread Jun Nie
2018-05-07 15:33 GMT+08:00 Jagan Teki :
> This series rework of previous version where it removes legacy
> usb phy handling and added phy driver on generic-phy framework.
>
> Current implementation phy driver is unable to get pinctrl, clock
> and reset details from DT since the dm code on these will add it future.
>
> Changes for v7:
> - rebase on master
>

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


[U-Boot] [PATCH v2] sunxi: add support for Banana Pi M2 Zero board

2018-05-23 Thread Jun Nie
Banana Pi M2 Zero is a board by Sinovoip with Allwinner H2+ SoC, 16-bit
512MiB DDR3 memory, a MicroSD slot, two MicroUSB ports (one OTG and one
powering-only) and a miniHDMI port.

DTS file is from Linux kernel with removing some nodes that are not needed
in u-boot or not merged into u-boot yet.

Signed-off-by: Icenowy Zheng 
Signed-off-by: Jun Nie 
---
 arch/arm/dts/Makefile   |  1 +
 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 68 +
 board/sunxi/MAINTAINERS |  5 ++
 configs/bananapi_m2_zero_defconfig  | 15 ++
 4 files changed, 89 insertions(+)
 create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
 create mode 100644 configs/bananapi_m2_zero_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 20a4c37..8d6fab2 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -338,6 +338,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-a83t-tbs-a711.dts
 dtb-$(CONFIG_MACH_SUN8I_H3) += \
+   sun8i-h2-plus-bananapi-m2-zero.dtb \
sun8i-h2-plus-orangepi-zero.dtb \
sun8i-h3-bananapi-m2-plus.dtb \
sun8i-h3-libretech-all-h3-cc.dtb \
diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
new file mode 100644
index 000..92e8cf4
--- /dev/null
+++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2017 Icenowy Zheng 
+ *
+ * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
+ *   Copyright (C) 2016 Chen-Yu Tsai 
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include 
+#include 
+
+/ {
+   model = "Banana Pi BPI-M2-Zero";
+   compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
+
+   aliases {
+   serial0 = &uart0;
+   serial1 = &uart1;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   pwr_led {
+   label = "bananapi-m2-zero:red:pwr";
+   gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+   default-state = "on";
+   };
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+
+   sw4 {
+   label = "power";
+   linux,code = ;
+   gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
+   };
+   };
+};
+
+&mmc0 {
+   vmmc-supply = <®_vcc3v3>;
+   bus-width = <4>;
+   /*
+* On the production batch of this board the card detect GPIO is
+* high active (card inserted), although on the early samples it's
+* low active.
+*/
+   cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
+   status = "okay";
+};
+
+&uart0 {
+   status = "okay";
+};
+
+&uart1 {
+   status = "okay";
+};
diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index 5eb8bbe..0d904d9 100644
--- a/board/sunxi/MAINTAINERS
+++ b/board/sunxi/MAINTAINERS
@@ -363,6 +363,11 @@ M: Icenowy Zheng 
 S: Maintained
 F: configs/Sinovoip_BPI_M2_Plus_defconfig
 
+SINOVOIP BPI M2 ZERO BOARD
+M: Icenowy Zheng 
+S: Maintained
+F: configs/Sinovoip_BPI_M2_Zero_defconfig
+
 SINOVOIP BPI M3 A83T BOARD
 M: VishnuPatekar 
 S: Maintained
diff --git a/configs/bananapi_m2_zero_defconfig 
b/configs/bananapi_m2_zero_defconfig
new file mode 100644
index 000..b919d8b
--- /dev/null
+++ b/configs/bananapi_m2_zero_defconfig
@@ -0,0 +1,15 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SYS_TEXT_BASE=0x4a00
+CONFIG_MACH_SUN8I_H3=y
+CONFIG_DRAM_CLK=408
+CONFIG_DRAM_ZQ=3881979
+CONFIG_DRAM_ODT_EN=y
+CONFIG_MMC0_CD_PIN=""
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-bananapi-m2-zero"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
-- 
2.7.4

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


Re: [U-Boot] [PATCH v2] sunxi: add support for Banana Pi M2 Zero board

2018-05-24 Thread Jun Nie
2018-05-24 15:54 GMT+08:00 Maxime Ripard :
> Hi,
>
> On Thu, May 24, 2018 at 12:38:19PM +0800, Jun Nie wrote:
>> Banana Pi M2 Zero is a board by Sinovoip with Allwinner H2+ SoC, 16-bit
>> 512MiB DDR3 memory, a MicroSD slot, two MicroUSB ports (one OTG and one
>> powering-only) and a miniHDMI port.
>>
>> DTS file is from Linux kernel with removing some nodes that are not needed
>> in u-boot or not merged into u-boot yet.
>>
>> Signed-off-by: Icenowy Zheng 
>> Signed-off-by: Jun Nie 
>
>
> Don't forget to CC me on the sunxi-related patches.

Sure, will add your email in the script.
>
>> ---
>>  arch/arm/dts/Makefile   |  1 +
>>  arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts | 68 
>> +
>>  board/sunxi/MAINTAINERS |  5 ++
>>  configs/bananapi_m2_zero_defconfig  | 15 ++
>>  4 files changed, 89 insertions(+)
>>  create mode 100644 arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>>  create mode 100644 configs/bananapi_m2_zero_defconfig
>>
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index 20a4c37..8d6fab2 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -338,6 +338,7 @@ dtb-$(CONFIG_MACH_SUN8I_A83T) += \
>>   sun8i-a83t-cubietruck-plus.dtb \
>>   sun8i-a83t-tbs-a711.dts
>>  dtb-$(CONFIG_MACH_SUN8I_H3) += \
>> + sun8i-h2-plus-bananapi-m2-zero.dtb \
>>   sun8i-h2-plus-orangepi-zero.dtb \
>>   sun8i-h3-bananapi-m2-plus.dtb \
>>   sun8i-h3-libretech-all-h3-cc.dtb \
>> diff --git a/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts 
>> b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>> new file mode 100644
>> index 000..92e8cf4
>> --- /dev/null
>> +++ b/arch/arm/dts/sun8i-h2-plus-bananapi-m2-zero.dts
>> @@ -0,0 +1,68 @@
>> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
>> +/*
>> + * Copyright (C) 2017 Icenowy Zheng 
>> + *
>> + * Based on sun8i-h3-bananapi-m2-plus.dts, which is:
>> + *   Copyright (C) 2016 Chen-Yu Tsai 
>> + */
>> +
>> +/dts-v1/;
>> +#include "sun8i-h3.dtsi"
>> +#include "sunxi-common-regulators.dtsi"
>> +
>> +#include 
>> +#include 
>> +
>> +/ {
>> + model = "Banana Pi BPI-M2-Zero";
>> + compatible = "sinovoip,bpi-m2-zero", "allwinner,sun8i-h2-plus";
>> +
>> + aliases {
>> + serial0 = &uart0;
>> + serial1 = &uart1;
>> + };
>> +
>> + chosen {
>> + stdout-path = "serial0:115200n8";
>> + };
>> +
>> + leds {
>> + compatible = "gpio-leds";
>> +
>> + pwr_led {
>> + label = "bananapi-m2-zero:red:pwr";
>> + gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
>> + default-state = "on";
>> + };
>> + };
>> +
>> + gpio_keys {
>> + compatible = "gpio-keys";
>> +
>> + sw4 {
>> + label = "power";
>> + linux,code = ;
>> + gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
>> + };
>> + };
>> +};
>> +
>> +&mmc0 {
>> + vmmc-supply = <®_vcc3v3>;
>> + bus-width = <4>;
>> + /*
>> +  * On the production batch of this board the card detect GPIO is
>> +  * high active (card inserted), although on the early samples it's
>> +  * low active.
>> +  */
>> + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
>> + status = "okay";
>> +};
>> +
>> +&uart0 {
>> + status = "okay";
>> +};
>> +
>> +&uart1 {
>> + status = "okay";
>> +};
>
> Why not using straight the DT from linux here? There's a couple of
> things missing from this one (the pinctrl nodes, for example).

I had thought that pinctrl is not merged yet in u-boot per the
comments for patch V1. Will
keep it in next version.

WIFI is removed because it shall not work in u-boot.

ehci0/ohci0 are removed because they are still missing in h3.dtsi.

>
>> diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
>> index 5eb8bbe..0d904d9 100644
>> --- a/board/sunxi/MAINTAINERS
>> +++ b/board/sunxi/MAINTAINERS
>> @@ 

Re: [U-Boot] [PATCH] mmc: Poll for broken card detection case

2018-01-22 Thread Jun Nie
2018-01-22 13:03 GMT+08:00 Jaehoon Chung :
> Hi,
>
> On 01/02/2018 01:25 PM, Jun Nie wrote:
>> Poll for broken card detection case instead of return
>> no card detected.
>
> Sorry for late. i didn't see this patch in my mailbox.
>
> Does it need to add the new config?

Yes, a new config, CONFIG_MMC_BROKEN_CD is needed for board that does
not support card detection pin. Not sure whether you mean this.
Without this config, the logic is not changed so no board is impacted
by this config.

Jun

>
> Best Regards,
> Jaehoon Chung
>
>>
>> Signed-off-by: Jun Nie 
>> ---
>>  drivers/mmc/Kconfig | 5 +
>>  drivers/mmc/mmc.c   | 4 
>>  2 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>> index 8fbeaa7..ed194a3 100644
>> --- a/drivers/mmc/Kconfig
>> +++ b/drivers/mmc/Kconfig
>> @@ -10,6 +10,11 @@ config MMC
>> If you want MMC/SD/SDIO support, you should say Y here and
>> also to your specific host controller driver.
>>
>> +config MMC_BROKEN_CD
>> + bool "Poll for broken card detection case"
>> + help
>> +   If card  detection feature is broken, just poll to detect.
>> +
>>  config DM_MMC
>>   bool "Enable MMC controllers using Driver Model"
>>   depends on DM
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 38d2e07..13c5bf5 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -1650,8 +1650,12 @@ int mmc_start_init(struct mmc *mmc)
>>   bool no_card;
>>   int err;
>>
>> +#if !defined(CONFIG_MMC_BROKEN_CD)
>>   /* we pretend there's no card when init is NULL */
>>   no_card = mmc_getcd(mmc) == 0;
>> +#else
>> + no_card = 0;
>> +#endif
>>  #if !CONFIG_IS_ENABLED(DM_MMC)
>>   no_card = no_card || (mmc->cfg->ops->init == NULL);
>>  #endif
>>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mmc: Poll for broken card detection case

2018-01-22 Thread Jun Nie
2018-01-23 10:00 GMT+08:00 Jaehoon Chung :
> On 01/22/2018 09:21 PM, Jun Nie wrote:
>> 2018-01-22 13:03 GMT+08:00 Jaehoon Chung :
>>> Hi,
>>>
>>> On 01/02/2018 01:25 PM, Jun Nie wrote:
>>>> Poll for broken card detection case instead of return
>>>> no card detected.
>>>
>>> Sorry for late. i didn't see this patch in my mailbox.
>>>
>>> Does it need to add the new config?
>>
>> Yes, a new config, CONFIG_MMC_BROKEN_CD is needed for board that does
>> not support card detection pin. Not sure whether you mean this.
>> Without this config, the logic is not changed so no board is impacted
>> by this config.
>
> Right, there is no impacted by this config.
> In Kernel, there is "broken-cd" property. So how about using 'broken-cd' 
> property instead of adding config?
>
> Best Regards,
> Jaehoon Chung
>
Some platforms, if not all, do not support DTB in SPL. So a config is
better than dt node property.

Jun
>>
>> Jun
>>
>>>
>>> Best Regards,
>>> Jaehoon Chung
>>>
>>>>
>>>> Signed-off-by: Jun Nie 
>>>> ---
>>>>  drivers/mmc/Kconfig | 5 +
>>>>  drivers/mmc/mmc.c   | 4 
>>>>  2 files changed, 9 insertions(+)
>>>>
>>>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>>>> index 8fbeaa7..ed194a3 100644
>>>> --- a/drivers/mmc/Kconfig
>>>> +++ b/drivers/mmc/Kconfig
>>>> @@ -10,6 +10,11 @@ config MMC
>>>> If you want MMC/SD/SDIO support, you should say Y here and
>>>> also to your specific host controller driver.
>>>>
>>>> +config MMC_BROKEN_CD
>>>> + bool "Poll for broken card detection case"
>>>> + help
>>>> +   If card  detection feature is broken, just poll to detect.
>>>> +
>>>>  config DM_MMC
>>>>   bool "Enable MMC controllers using Driver Model"
>>>>   depends on DM
>>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>>> index 38d2e07..13c5bf5 100644
>>>> --- a/drivers/mmc/mmc.c
>>>> +++ b/drivers/mmc/mmc.c
>>>> @@ -1650,8 +1650,12 @@ int mmc_start_init(struct mmc *mmc)
>>>>   bool no_card;
>>>>   int err;
>>>>
>>>> +#if !defined(CONFIG_MMC_BROKEN_CD)
>>>>   /* we pretend there's no card when init is NULL */
>>>>   no_card = mmc_getcd(mmc) == 0;
>>>> +#else
>>>> + no_card = 0;
>>>> +#endif
>>>>  #if !CONFIG_IS_ENABLED(DM_MMC)
>>>>   no_card = no_card || (mmc->cfg->ops->init == NULL);
>>>>  #endif
>>>>
>>>
>>
>>
>>
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] sunxi: support fuse cmd to read/write fuse

2018-01-27 Thread Jun Nie
Support fuse cmd to read/write fuse. Power supply for fuse
should be ready, name is VDD_EFUSE in some schematic.

Signed-off-by: Jun Nie 
---
 arch/arm/mach-sunxi/cpu_info.c | 60 ++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
index 25a5ec2..30bc2bf 100644
--- a/arch/arm/mach-sunxi/cpu_info.c
+++ b/arch/arm/mach-sunxi/cpu_info.c
@@ -133,6 +133,30 @@ uint32_t sun8i_efuse_read(uint32_t offset)
reg_val = readl(SUNXI_SIDC_BASE + SIDC_RDKEY);
return reg_val;
 }
+
+uint32_t sun8i_efuse_write(u32 offset, u32 val)
+{
+   u32 reg_val;
+
+   writel(val, SUNXI_SIDC_BASE + SIDC_RDKEY);
+
+   reg_val = readl(SUNXI_SIDC_BASE + SIDC_PRCTL);
+   reg_val &= ~(((0x1ff) << 16) | 0x3);
+   reg_val |= (offset << 16);
+   writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
+
+   reg_val &= ~(((0xff) << 8) | 0x3);
+   reg_val |= (SIDC_OP_LOCK << 8) | 0x1;
+   writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
+
+   while (readl(SUNXI_SIDC_BASE + SIDC_PRCTL) & 0x1)
+   ;
+
+   reg_val &= ~(((0x1ff) << 16) | ((0xff) << 8) | 0x3);
+   writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
+
+   return 0;
+}
 #endif
 
 int sunxi_get_sid(unsigned int *sid)
@@ -164,3 +188,39 @@ int sunxi_get_sid(unsigned int *sid)
return -ENODEV;
 #endif
 }
+
+int fuse_read(u32 bank, u32 word, u32 *sid)
+{
+#ifdef CONFIG_MACH_SUN8I_H3
+   *sid = sun8i_efuse_read(word);
+#elif defined SUNXI_SID_BASE
+   *sid = readl((ulong)SUNXI_SID_BASE + word);
+#else
+   return -ENODEV;
+#endif
+   return 0;
+}
+
+int fuse_prog(u32 bank, u32 word, u32 val)
+{
+#ifdef CONFIG_MACH_SUN8I_H3
+   return sun8i_efuse_write(word, val);
+#elif defined SUNXI_SID_BASE
+   writel(val, (ulong)SUNXI_SID_BASE + word);
+#else
+   return -ENODEV;
+#endif
+   return 0;
+}
+
+int fuse_sense(u32 bank, u32 word, u32 *val)
+{
+   /* We do not support sensing :-( */
+   return -EINVAL;
+}
+
+int fuse_override(u32 bank, u32 word, u32 val)
+{
+   /* We do not support overriding :-( */
+   return -EINVAL;
+}
-- 
1.9.1

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


Re: [U-Boot] [PATCH] sunxi: support fuse cmd to read/write fuse

2018-01-28 Thread Jun Nie
2018-01-28 1:45 GMT+08:00 André Przywara :
> On 27/01/18 15:20, Jun Nie wrote:
>> Support fuse cmd to read/write fuse. Power supply for fuse
>> should be ready, name is VDD_EFUSE in some schematic.
>
> Mmh, in general I am not sure it is a good idea to expose this so easily
> to the user. I guess a clueless user can easily brick his board by
> typing something at the "fuse write" command. I understand that one has
> to manually enable the fuse command first to allow access, but this is
> still quite a high risk, especially since a lot of the fuses are not
> documented.
> Would love to hear opinions from others about that topic.

Yes, it is more or less risky for user that do not have much knowledge on fuse.
Let's see what other developers think.
>
> Also I would have hoped for a bit more documentation.
> How do those banks/words from the write command map to the fuses, for
> instance? What fuses are available and useful? What are the implications
> of writing the secure boot fuse, for instance?
>
> And do we know how access to the fuses is affected by the exception
> level / mode we are in? My understanding is that SID access is secure
> only, which would make it inaccessible for the 64-bit boards where
> U-Boot runs in EL2. But then again at least the A64 does not seem to
> care about this (unless the secure boot fuse is set).
>
> More inline ...
>
>> Signed-off-by: Jun Nie 
>> ---
>>  arch/arm/mach-sunxi/cpu_info.c | 60 
>> ++
>>  1 file changed, 60 insertions(+)
>>
>> diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
>> index 25a5ec2..30bc2bf 100644
>> --- a/arch/arm/mach-sunxi/cpu_info.c
>> +++ b/arch/arm/mach-sunxi/cpu_info.c
>> @@ -133,6 +133,30 @@ uint32_t sun8i_efuse_read(uint32_t offset)
>>   reg_val = readl(SUNXI_SIDC_BASE + SIDC_RDKEY);
>>   return reg_val;
>>  }
>> +
>> +uint32_t sun8i_efuse_write(u32 offset, u32 val)
>> +{
>> + u32 reg_val;
>> +
>> + writel(val, SUNXI_SIDC_BASE + SIDC_RDKEY);
>> +
>> + reg_val = readl(SUNXI_SIDC_BASE + SIDC_PRCTL);
>> + reg_val &= ~(((0x1ff) << 16) | 0x3);
>> + reg_val |= (offset << 16);
>
> Would be good to put names to those magic values.
> I understand this is from the code as I sent you ;-), but still ...

The code is from sid_program_key() in this file, but almost identical
with yours. Macro is better than magic number, I can change all these
magic number in next version patch if the patch is needed.
https://github.com/allwinner-zh/bootloader/blob/master/u-boot-2011.09/arch/arm/cpu/armv7/sun8iw6/efuse.c

>
>> + writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
>> +
>> + reg_val &= ~(((0xff) << 8) | 0x3);
>> + reg_val |= (SIDC_OP_LOCK << 8) | 0x1;
>> + writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
>> +
>> + while (readl(SUNXI_SIDC_BASE + SIDC_PRCTL) & 0x1)
>> + ;
>
> shall we have a timeout or limited retries here?

Yeah.
>
>> +
>> + reg_val &= ~(((0x1ff) << 16) | ((0xff) << 8) | 0x3);
>> + writel(reg_val, SUNXI_SIDC_BASE + SIDC_PRCTL);
>> +
>> + return 0;
>> +}
>>  #endif
>>
>>  int sunxi_get_sid(unsigned int *sid)
>> @@ -164,3 +188,39 @@ int sunxi_get_sid(unsigned int *sid)
>>   return -ENODEV;
>>  #endif
>>  }
>> +
>> +int fuse_read(u32 bank, u32 word, u32 *sid)
>> +{
>> +#ifdef CONFIG_MACH_SUN8I_H3
>> + *sid = sun8i_efuse_read(word);
>> +#elif defined SUNXI_SID_BASE
>> + *sid = readl((ulong)SUNXI_SID_BASE + word);
>> +#else
>> + return -ENODEV;
>> +#endif
>> + return 0;
>> +}
>> +
>> +int fuse_prog(u32 bank, u32 word, u32 val)
>> +{
>
> I would feel better if we have the write access protected by a separate
> Kconfig symbol. So without this being defined either nothing happens or
> the user gets a warning.

Good idea.
>
>> +#ifdef CONFIG_MACH_SUN8I_H3
>
> I guess this applies to more than the H3, namely the A64 and A83T,
> possibly also H5 and others?

I do not have that much information. So this depends on more developer's
input.
>
>> + return sun8i_efuse_write(word, val);
>> +#elif defined SUNXI_SID_BASE
>> + writel(val, (ulong)SUNXI_SID_BASE + word);
>
> Are you sure that works? If I read [1] correctly, you always have to use
> a special algorithm to burn a fuse, a simple MMIO write access would not
> suffice.
> The algorithm seems to be different for older SoCs (pre-H3).

This also depen

Re: [U-Boot] [PATCH 1/1] pico-imx7d: Enable DM_USB

2019-06-13 Thread Jun Nie
Joris Offouga  于2019年6月11日周二 下午8:09写道:
>
> This patch enable usb support with device-tree
>
> Signed-off-by: Joris Offouga 
> ---
>  arch/arm/dts/imx7d-pico.dtsi |  2 ++
>  board/technexion/pico-imx7d/pico-imx7d.c | 13 -
>  configs/pico-hobbit-imx7d_defconfig  |  1 +
>  configs/pico-imx7d_bl33_defconfig|  1 +
>  configs/pico-imx7d_defconfig |  1 +
>  configs/pico-pi-imx7d_defconfig  |  1 +
>  6 files changed, 6 insertions(+), 13 deletions(-)
>

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


[U-Boot] [PATCH v3 1/9] Revert "pico-imx7d: Add LCD support"

2019-04-23 Thread Jun Nie
This reverts commit 9e3c0174da842dd88f5feaffbf843ba332233897.
---
 board/technexion/pico-imx7d/pico-imx7d.c | 55 
 configs/pico-hobbit-imx7d_defconfig  |  1 -
 configs/pico-imx7d_defconfig |  1 -
 configs/pico-pi-imx7d_defconfig  |  1 -
 include/configs/pico-imx7d.h | 12 ---
 5 files changed, 70 deletions(-)

diff --git a/board/technexion/pico-imx7d/pico-imx7d.c 
b/board/technexion/pico-imx7d/pico-imx7d.c
index 767d13d..53e1469 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -39,16 +39,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define I2C_PAD_CTRL(PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU100KOHM)
 
-
-#define LCD_PAD_CTRL(PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \
-PAD_CTL_DSE_3P3V_49OHM)
-
-#define LCD_SYNC_PAD_CTRL(PAD_CTL_HYS | PAD_CTL_PUS_PU100KOHM | \
- PAD_CTL_DSE_3P3V_196OHM)
-
 #ifdef CONFIG_SYS_I2C_MXC
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-
 /* I2C4 for PMIC */
 static struct i2c_pads_info i2c_pad_info4 = {
.scl = {
@@ -254,58 +246,11 @@ int board_early_init_f(void)
return 0;
 }
 
-#ifdef CONFIG_VIDEO_MXS
-static iomux_v3_cfg_t const lcd_pads[] = {
-   MX7D_PAD_LCD_CLK__LCD_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_ENABLE__LCD_ENABLE | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
-   MX7D_PAD_LCD_HSYNC__LCD_HSYNC | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
-   MX7D_PAD_LCD_VSYNC__LCD_VSYNC | MUX_PAD_CTRL(LCD_SYNC_PAD_CTRL),
-   MX7D_PAD_LCD_DATA00__LCD_DATA0 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA01__LCD_DATA1 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA02__LCD_DATA2 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA03__LCD_DATA3 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA04__LCD_DATA4 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA05__LCD_DATA5 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA06__LCD_DATA6 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA07__LCD_DATA7 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA08__LCD_DATA8 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA09__LCD_DATA9 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA10__LCD_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA11__LCD_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA12__LCD_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA13__LCD_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA14__LCD_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA15__LCD_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA16__LCD_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA17__LCD_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA18__LCD_DATA18 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA19__LCD_DATA19 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA20__LCD_DATA20 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA21__LCD_DATA21 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA22__LCD_DATA22 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_LCD_DATA23__LCD_DATA23 | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_GPIO1_IO06__GPIO1_IO6  | MUX_PAD_CTRL(LCD_PAD_CTRL),
-   MX7D_PAD_GPIO1_IO11__GPIO1_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL),
-};
-
-void setup_lcd(void)
-{
-   imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
-   /* Set Brightness to high */
-   gpio_direction_output(IMX_GPIO_NR(1, 11) , 1);
-   /* Set LCD enable to high */
-   gpio_direction_output(IMX_GPIO_NR(1, 6) , 1);
-}
-#endif
-
 int board_init(void)
 {
/* address of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-#ifdef CONFIG_VIDEO_MXS
-   setup_lcd();
-#endif
 #ifdef CONFIG_FEC_MXC
setup_fec();
 #endif
diff --git a/configs/pico-hobbit-imx7d_defconfig 
b/configs/pico-hobbit-imx7d_defconfig
index f58d517..cb4a6bf 100644
--- a/configs/pico-hobbit-imx7d_defconfig
+++ b/configs/pico-hobbit-imx7d_defconfig
@@ -57,5 +57,4 @@ CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
-CONFIG_VIDEO=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/pico-imx7d_defconfig b/configs/pico-imx7d_defconfig
index 7e13923..f90d757 100644
--- a/configs/pico-imx7d_defconfig
+++ b/configs/pico-imx7d_defconfig
@@ -57,5 +57,4 @@ CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
-CONFIG_VIDEO=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/pico-pi-imx7d_defconfig b/configs/pico-pi-imx7d_defconfig
index c8ac2ff..8e48ba7 100644
--- a/configs/pico-pi-imx7d_defconfig
+++ b/configs/pico-pi-imx7d_defconfig
@@ -57,5 +57,4 @@ CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa

[U-Boot] [PATCH v3 2/9] mx7_common: Share configs to skip low level init

2019-04-23 Thread Jun Nie
Share configs in mx7 to skip low level init if we are in the case where
OPTEE is loaded already (maybe by ARM Trusted Firmware) and that most of
the low level initialization is already done and that we may/should skip
it doing them here.

Fix the definition detection with size detection to decide whether to skip
it.

Signed-off-by: Jun Nie 
---
 include/configs/mx7_common.h | 11 +++
 include/configs/warp7.h  | 11 ---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index cc7e872..57fbec7 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -54,4 +54,15 @@
 #endif
 #endif
 
+/*
+ * If we have defined the OPTEE ram size and not OPTEE it means that we were
+ * launched by OPTEE, because of that we shall skip all the low level
+ * initialization since it was already done by ATF or OPTEE
+ */
+#if (CONFIG_OPTEE_TZDRAM_SIZE != 0)
+#ifndef CONFIG_OPTEE
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+#endif
+
 #endif
diff --git a/include/configs/warp7.h b/include/configs/warp7.h
index 043f286..80ddd72 100644
--- a/include/configs/warp7.h
+++ b/include/configs/warp7.h
@@ -13,17 +13,6 @@
 
 #define PHYS_SDRAM_SIZESZ_512M
 
-/*
- * If we have defined the OPTEE ram size and not OPTEE it means that we were
- * launched by OPTEE, because of that we shall skip all the low level
- * initialization since it was already done by ATF or OPTEE
- */
-#ifdef CONFIG_OPTEE_TZDRAM_SIZE
-#ifndef CONFIG_OPTEE
-#define CONFIG_SKIP_LOWLEVEL_INIT
-#endif
-#endif
-
 #define CONFIG_MXC_UART_BASE   UART1_IPS_BASE_ADDR
 
 /* Size of malloc() pool */
-- 
2.7.4

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


[U-Boot] [PATCH v3 0/9] pico-imx7d: Add support for BL33 case

2019-04-23 Thread Jun Nie
Add configuration to boot U-boot as BL33 case. The boot flow
is ATF -> OPTEE -> U-boot.

Changes vs V2:
- Revise fix to UART clock ID.
- Add documentation of build and test for BL33 usage case.
- Add device tree to store public key for FIT image verfication usage.
- Add revert patch to LCD support. Pico-pi does not boot with it.
I see it is suggested to be reverted in maillist.

Changes vs V1:
- Remove DCD file.
- Add a patch to fix uart clock root ID.
- Change file name from pico-pi-imx7d_bl33_defconfig to 
pico-imx7d_bl33_defconfig


Jun Nie (9):
  Revert "pico-imx7d: Add LCD support"
  mx7_common: Share configs to skip low level init
  imx: mx7: Add empty arch_cpu_init if skipped
  pico-imx7d: Correct uart clock root
  pico-imx7d: Reserve region of memory to OPTEE
  pico-imx7d: Add boot option for verified boot
  pico-imx7d: Add device tree for pico-imx7d
  pico-imx7d: Add bl33 config
  pico-imx7d: README: Add BL33 usage case

 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/imx7d-pico-pi.dts |  93 
 arch/arm/dts/imx7d-pico.dtsi   | 585 +
 arch/arm/include/asm/arch-mx7/clock.h  |  18 +
 arch/arm/mach-imx/Kconfig  |   7 +
 arch/arm/mach-imx/mx7/clock.c  |   2 +-
 arch/arm/mach-imx/mx7/soc.c|   5 +
 board/technexion/pico-imx7d/README.pico-imx7d_BL33 |  44 ++
 board/technexion/pico-imx7d/pico-imx7d.c   |  60 +--
 configs/pico-hobbit-imx7d_defconfig|   1 -
 ...i-imx7d_defconfig => pico-imx7d_bl33_defconfig} |  40 +-
 configs/pico-imx7d_defconfig   |   1 -
 configs/pico-pi-imx7d_defconfig|   1 -
 include/configs/mx7_common.h   |  11 +
 include/configs/pico-imx7d.h   |  50 +-
 include/configs/warp7.h|  11 -
 16 files changed, 826 insertions(+), 104 deletions(-)
 create mode 100644 arch/arm/dts/imx7d-pico-pi.dts
 create mode 100644 arch/arm/dts/imx7d-pico.dtsi
 create mode 100644 board/technexion/pico-imx7d/README.pico-imx7d_BL33
 copy configs/{pico-pi-imx7d_defconfig => pico-imx7d_bl33_defconfig} (65%)

-- 
2.7.4

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


[U-Boot] [PATCH v3 7/9] pico-imx7d: Add device tree for pico-imx7d

2019-04-23 Thread Jun Nie
Copy device tree files from Linux directly.

Signed-off-by: Jun Nie 
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/imx7d-pico-pi.dts |  93 +++
 arch/arm/dts/imx7d-pico.dtsi   | 585 +
 3 files changed, 679 insertions(+)
 create mode 100644 arch/arm/dts/imx7d-pico-pi.dts
 create mode 100644 arch/arm/dts/imx7d-pico.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0aee8df..e6cb1d3 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -555,6 +555,7 @@ dtb-$(CONFIG_ARCH_MX6) += \
 
 dtb-$(CONFIG_MX7) += imx7d-sdb.dtb \
imx7d-sdb-qspi.dtb \
+   imx7d-pico-pi.dtb \
imx7-colibri-emmc.dtb \
imx7-colibri-rawnand.dtb \
imx7s-warp.dtb
diff --git a/arch/arm/dts/imx7d-pico-pi.dts b/arch/arm/dts/imx7d-pico-pi.dts
new file mode 100644
index 000..70bea95
--- /dev/null
+++ b/arch/arm/dts/imx7d-pico-pi.dts
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+//
+// Copyright 2017 NXP
+
+#include "imx7d-pico.dtsi"
+
+/ {
+   model = "TechNexion PICO-IMX7D Board and PI baseboard";
+   compatible = "technexion,imx7d-pico-pi", "fsl,imx7d";
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_gpio_leds>;
+
+   led {
+   label = "gpio-led";
+   gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   sound {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "imx7-sgtl5000";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <&dailink_master>;
+   simple-audio-card,frame-master = <&dailink_master>;
+   simple-audio-card,cpu {
+   sound-dai = <&sai1>;
+   };
+
+   dailink_master: simple-audio-card,codec {
+   sound-dai = <&sgtl5000>;
+   clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
+   };
+   };
+};
+
+&i2c1 {
+   sgtl5000: codec@a {
+   #sound-dai-cells = <0>;
+   reg = <0x0a>;
+   compatible = "fsl,sgtl5000";
+   clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
+   VDDA-supply = <®_2p5v>;
+   VDDIO-supply = <®_vref_1v8>;
+   };
+};
+
+&i2c4 {
+   polytouch: touchscreen@38 {
+   compatible = "edt,edt-ft5x06";
+   reg = <0x38>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_touchscreen>;
+   interrupt-parent = <&gpio2>;
+   interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+   reset-gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
+   touchscreen-size-x = <800>;
+   touchscreen-size-y = <480>;
+   };
+};
+
+&iomuxc {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_hog>;
+
+   pinctrl_hog: hoggrp {
+   fsl,pins = <
+   MX7D_PAD_EPDC_DATA00__GPIO2_IO0 0x14
+   MX7D_PAD_EPDC_DATA01__GPIO2_IO1 0x14
+   MX7D_PAD_EPDC_DATA02__GPIO2_IO2 0x14
+   MX7D_PAD_EPDC_DATA03__GPIO2_IO3 0x14
+   MX7D_PAD_EPDC_DATA05__GPIO2_IO5 0x14
+   MX7D_PAD_EPDC_DATA12__GPIO2_IO120x14
+   MX7D_PAD_EPDC_DATA07__GPIO2_IO7 0x14
+   >;
+   };
+
+   pinctrl_gpio_leds: gpioledsgrp {
+   fsl,pins = <
+   MX7D_PAD_EPDC_DATA06__GPIO2_IO6 0x14
+   >;
+   };
+
+   pinctrl_touchscreen: touchscreengrp {
+   fsl,pins = <
+   MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14
+   MX7D_PAD_EPDC_DATA13__GPIO2_IO130x14
+   >;
+   };
+
+};
diff --git a/arch/arm/dts/imx7d-pico.dtsi b/arch/arm/dts/imx7d-pico.dtsi
new file mode 100644
index 000..3fd595a
--- /dev/null
+++ b/arch/arm/dts/imx7d-pico.dtsi
@@ -0,0 +1,585 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+//
+// Copyright 2017 NXP
+
+/dts-v1/;
+
+#include "imx7d.dtsi"
+
+/ {
+   /* Will be filled by the bootloader */
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0>;
+   };
+
+   reg_wlreg_on: regulator-wlreg_on {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+ 

[U-Boot] [PATCH v3 5/9] pico-imx7d: Reserve region of memory to OPTEE

2019-04-23 Thread Jun Nie
Subtracts CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size so that
the OPTEE memory is not override during u-boot relocation.

Note the OPTEE boot process will itself subtract the DRAM region it lives
in from the memory map passed to Linux.

Signed-off-by: Jun Nie 
---
 board/technexion/pico-imx7d/pico-imx7d.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/technexion/pico-imx7d/pico-imx7d.c 
b/board/technexion/pico-imx7d/pico-imx7d.c
index 53e1469..7c9e145 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -60,6 +60,11 @@ int dram_init(void)
 {
gd->ram_size = imx_ddr_size();
 
+   /* Subtract the defined OPTEE runtime firmware length */
+#ifdef CONFIG_OPTEE_TZDRAM_SIZE
+   gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
+#endif
+
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH v3 3/9] imx: mx7: Add empty arch_cpu_init if skipped

2019-04-23 Thread Jun Nie
Add empty arch_cpu_init if low level init is skipped. So that
it does not break spl compile though spl is not needed in the
skipped case actually.

Signed-off-by: Jun Nie 
---
 arch/arm/mach-imx/mx7/soc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 7cfdff0..9b04013 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -286,6 +286,11 @@ int arch_cpu_init(void)
 
return 0;
 }
+#else
+int arch_cpu_init(void)
+{
+   return 0;
+}
 #endif
 
 #ifdef CONFIG_ARCH_MISC_INIT
-- 
2.7.4

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


[U-Boot] [PATCH v3 6/9] pico-imx7d: Add boot option for verified boot

2019-04-23 Thread Jun Nie
Add boot option to boot from fitimage to support verified boot.
The boot script plain text file should be packed into fit blob as
image with name of bootscr.

Signed-off-by: Jun Nie 
---
 include/configs/pico-imx7d.h | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 1884c58..8eb9064 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -52,11 +52,29 @@
"/boot/imx7d-pico-pi.dtb ext4 0 1;" \
"rootfs part 0 1\0" \
 
-#define BOOTMENU_ENV \
+/* When booting with FIT specify the node entry containing boot.scr */
+#if defined(CONFIG_FIT)
+#define PICO_BOOT_ENV \
+   "bootscr_fitimage_name=bootscr\0" \
+   "bootscriptaddr=0x8320\0" \
+   "fdtovaddr=0x8310\0" \
+   "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
+   "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
+   "mmcargs=setenv bootargs console=${console},${baudrate} " \
+   "rootwait rw;\0" \
+   "loadbootscript=" \
+   "load mmc ${mmcdev}:${mmcpart} ${bootscriptaddr} ${script};\0" \
+   "bootscript=echo Running bootscript from mmc ...; " \
+   "source ${bootscriptaddr}:${bootscr_fitimage_name}\0"
+#else
+#define PICO_BOOT_ENV \
"bootmenu_0=Boot using PICO-Hobbit baseboard=" \
"setenv fdtfile imx7d-pico-hobbit.dtb\0" \
"bootmenu_1=Boot using PICO-Pi baseboard=" \
"setenv fdtfile imx7d-pico-pi.dtb\0" \
+   BOOTENV
+#endif
+
 
 #define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
 #define CONFIG_SYS_MMC_IMG_LOAD_PART   1
@@ -68,7 +86,6 @@
"fdt_high=0x\0" \
"initrd_high=0x\0" \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   BOOTMENU_ENV \
"fdt_addr=0x8300\0" \
"fdt_addr_r=0x8300\0" \
"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
@@ -88,7 +105,22 @@
"name=rootfs,size=0,uuid=${uuid_gpt_rootfs}\0" \
"fastboot_partition_alias_system=rootfs\0" \
"setup_emmc=mmc dev 0; gpt write mmc 0 $partitions; reset;\0" \
-   BOOTENV
+   PICO_BOOT_ENV
+
+#if defined(CONFIG_FIT)
+#define CONFIG_BOOTCOMMAND \
+   "mmc dev ${mmcdev};" \
+   "mmc dev ${mmcdev}; if mmc rescan; then " \
+   "if run loadbootscript; then " \
+   "iminfo ${bootscriptaddr};" \
+   "if test $? -eq 1; then hab_failsafe; fi;" \
+   "run bootscript; " \
+   "else " \
+   "echo Fail to load fitImage with boot script;" \
+   "hab_failsafe;" \
+   "fi; " \
+   "fi"
+#endif
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
-- 
2.7.4

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


[U-Boot] [PATCH v3 4/9] pico-imx7d: Correct uart clock root

2019-04-23 Thread Jun Nie
Correct uart clock root ID. Incorrect ID may result the
clock is gated because rate value 0 is returned in
imx_get_uartclk()

Signed-off-by: Jun Nie 
---
 arch/arm/include/asm/arch-mx7/clock.h | 18 ++
 arch/arm/mach-imx/Kconfig |  7 +++
 arch/arm/mach-imx/mx7/clock.c |  2 +-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mx7/clock.h 
b/arch/arm/include/asm/arch-mx7/clock.h
index f56564e..dc9 100644
--- a/arch/arm/include/asm/arch-mx7/clock.h
+++ b/arch/arm/include/asm/arch-mx7/clock.h
@@ -175,6 +175,24 @@ enum clk_root_index {
CLK_ROOT_MAX,
 };
 
+#if (CONFIG_IMX_CONSOLE_UART_ID == 1)
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 2)
+#define UART_CLK_ROOT UART2_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 3)
+#define UART_CLK_ROOT UART3_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 4)
+#define UART_CLK_ROOT UART4_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 5)
+#define UART_CLK_ROOT UART5_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 6)
+#define UART_CLK_ROOT UART6_CLK_ROOT
+#elif (CONFIG_IMX_CONSOLE_UART_ID == 7)
+#define UART_CLK_ROOT UART7_CLK_ROOT
+#else
+#error "Invalid IMX UART ID for serial console is defined"
+#endif
+
 struct clk_root_setting {
enum clk_root_index root;
u32 setting;
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index ec09ef2..7c5db30 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -27,6 +27,13 @@ config IMX_BOOTAUX
help
  bootaux [addr] to boot auxiliary core.
 
+config IMX_CONSOLE_UART_ID
+   int "UART ID for console"
+   default 1
+   depends on ARCH_MX7
+   help
+ Specify the UART ID that's for serial console.
+
 config USE_IMXIMG_PLUGIN
bool "Use imximage plugin code"
depends on ARCH_MX7 || ARCH_MX6
diff --git a/arch/arm/mach-imx/mx7/clock.c b/arch/arm/mach-imx/mx7/clock.c
index 8cda71c..e364b16 100644
--- a/arch/arm/mach-imx/mx7/clock.c
+++ b/arch/arm/mach-imx/mx7/clock.c
@@ -53,7 +53,7 @@ static u32 get_ipg_clk(void)
 
 u32 imx_get_uartclk(void)
 {
-   return get_root_clk(UART1_CLK_ROOT);
+   return get_root_clk(UART_CLK_ROOT);
 }
 
 u32 imx_get_fecclk(void)
-- 
2.7.4

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


[U-Boot] [PATCH v3 8/9] pico-imx7d: Add bl33 config

2019-04-23 Thread Jun Nie
Add default configuration to run u-boot as BL33 in the boot flow case
of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.

Signed-off-by: Jun Nie 
---
 configs/pico-imx7d_bl33_defconfig | 63 +++
 1 file changed, 63 insertions(+)
 create mode 100644 configs/pico-imx7d_bl33_defconfig

diff --git a/configs/pico-imx7d_bl33_defconfig 
b/configs/pico-imx7d_bl33_defconfig
new file mode 100644
index 000..a896cb3
--- /dev/null
+++ b/configs/pico-imx7d_bl33_defconfig
@@ -0,0 +1,63 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX7=y
+CONFIG_SYS_TEXT_BASE=0x8780
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SECURE_BOOT=y
+CONFIG_TARGET_PICO_IMX7D=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL=y
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_IMX_CONSOLE_UART_ID=5
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_DEFAULT_FDT_FILE="imx7d-pico-pi.dtb"
+CONFIG_BOUNCE_BUFFER=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTD is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_SPL=y
+CONFIG_CMD_SPL_WRITE_SIZE=0x2
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_DFU_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_PHYLIB=y
+CONFIG_MII=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_ETHER=y
+CONFIG_USB_ETH_CDC=y
+CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00"
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_OPTEE_TZDRAM_SIZE=0x200
-- 
2.7.4

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


[U-Boot] [PATCH v3 9/9] pico-imx7d: README: Add BL33 usage case

2019-04-23 Thread Jun Nie
Add Documentation of BL33 usage case. U-boot is in
non-secure world in this case.

Signed-off-by: Jun Nie 
---
 board/technexion/pico-imx7d/README.pico-imx7d_BL33 | 44 ++
 1 file changed, 44 insertions(+)
 create mode 100644 board/technexion/pico-imx7d/README.pico-imx7d_BL33

diff --git a/board/technexion/pico-imx7d/README.pico-imx7d_BL33 
b/board/technexion/pico-imx7d/README.pico-imx7d_BL33
new file mode 100644
index 000..40324ff
--- /dev/null
+++ b/board/technexion/pico-imx7d/README.pico-imx7d_BL33
@@ -0,0 +1,44 @@
+This document describes the instruction to build and flash ATF/OPTEE/U-Boot on
+pico-imx7d board. U-Boot is loaded as part of FIP image by ATF in this setup.
+The boot sequence is ATF -> OPTEE -> U-Boot -> Linux. U-Boot is in non-secure
+world in this case.
+
+- Build u-boot
+Set environment variable of CROSS_COMPILE for your toolchain and ARCH=arm
+$ make pico-imx7d_bl33_defconfig
+$ make all
+
+- Download and build OPTEE
+$ git clone g...@github.com:OP-TEE/optee_os.git
+$ make PLATFORM=imx PLATFORM_FLAVOR=mx7dpico_mbl 
CFG_BOOT_SECONDARY_REQUEST=y ARCH=arm
+
+- Download and build ATF
+$ git clone 
https://git.linaro.org/landing-teams/working/mbl/arm-trusted-firmware.git -b 
linaro-imx7
+$ make DEBUG=1 PLAT=picopi ARCH=aarch32 ARM_ARCH_MAJOR=7 \
+CROSS_COMPILE=arm-linux-gnueabihf- LOG_LEVEL=50 V=1 \
+CRASH_REPORTING=1 AARCH32_SP=optee all
+Save file content in this link to file pico-imx7d.cfg:
+  
http://git.linaro.org/landing-teams/working/mbl/u-boot.git/tree/board/technexion/pico-imx7d/pico-imx7d.cfg?h=linaro-imx
+$ u-boot/tools/mkimage -n pico-imx7d.cfg -T imximage -e 0x9df0 -d \
+build/picopi/debug/bl2.bin bl2.imx
+
+- Create FIP image
+Create a  fiptool_images/ folder in ATF folder, copy u-boot.bin in u-boot
+folder and tee*.bin in optee out/arm-plat-imx/core/tee/ folder to
+fiptool_images. Run below command in ATF folder to generate FIP image.
+$ make -C tools/fiptool/
+$ tools/fiptool/fiptool create --tos-fw fiptool_images/tee-header_v2.bin \
+  --tos-fw-extra1 fiptool_images/tee-pager_v2.bin \
+  --tos-fw-extra2 fiptool_images/tee-pageable_v2.bin \
+  --nt-fw fiptool_images/u-boot.bin \
+  fip.bin
+
+- Burn the images to eMMC for test.
+Run below command in atf folder:
+$ dd if=build/picopi/debug/bl2.bin.imx of=/dev/disk/by-id/usb-  bs=1024 seek=1;sync
+$ dd if=fip.bin of=/dev/disk/by-id/usb-  bs=1024 seek=1;sync
+
+- Test
+Just boot up your board and wait for u-boot start up after ATF's log.
+For booting Linux in FIT image, please reference the FIT files in
+u-boot doc/uImage.FIT/ folder.
-- 
2.7.4

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


Re: [U-Boot] [PATCH v3 4/9] pico-imx7d: Correct uart clock root

2019-04-23 Thread Jun Nie
Peng Fan  于2019年4月24日周三 下午1:15写道:
>
>
> > Subject: [PATCH v3 4/9] pico-imx7d: Correct uart clock root
> >
> > Correct uart clock root ID. Incorrect ID may result the clock is gated 
> > because
> > rate value 0 is returned in
> > imx_get_uartclk()
>
> Yes. hardcoding to UART1_ROOT_CLK in imx_get_uartclk is not good.
> But actually init_clk_uart configures all the uart with same root clk,
> so it should work as expected.

Right, but init_clk_uart is not called in SKIP_LOWLEVEL_INIT case.
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
cpu_init_crit() ->  lowlevel_init() -> s_init() -> clock_init() ->
init_clk_uart()
#endif

>
> Regards,
> Peng.
>
> >
> > Signed-off-by: Jun Nie 
> > ---
> >  arch/arm/include/asm/arch-mx7/clock.h | 18 ++
> >  arch/arm/mach-imx/Kconfig |  7 +++
> >  arch/arm/mach-imx/mx7/clock.c |  2 +-
> >  3 files changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/include/asm/arch-mx7/clock.h
> > b/arch/arm/include/asm/arch-mx7/clock.h
> > index f56564e..dc9 100644
> > --- a/arch/arm/include/asm/arch-mx7/clock.h
> > +++ b/arch/arm/include/asm/arch-mx7/clock.h
> > @@ -175,6 +175,24 @@ enum clk_root_index {
> >   CLK_ROOT_MAX,
> >  };
> >
> > +#if (CONFIG_IMX_CONSOLE_UART_ID == 1)
> > +#define UART_CLK_ROOT UART1_CLK_ROOT
> > +#elif (CONFIG_IMX_CONSOLE_UART_ID == 2) #define UART_CLK_ROOT
> > +UART2_CLK_ROOT #elif (CONFIG_IMX_CONSOLE_UART_ID == 3) #define
> > +UART_CLK_ROOT UART3_CLK_ROOT #elif
> > (CONFIG_IMX_CONSOLE_UART_ID == 4)
> > +#define UART_CLK_ROOT UART4_CLK_ROOT #elif
> > (CONFIG_IMX_CONSOLE_UART_ID
> > +== 5) #define UART_CLK_ROOT UART5_CLK_ROOT #elif
> > +(CONFIG_IMX_CONSOLE_UART_ID == 6) #define UART_CLK_ROOT
> > UART6_CLK_ROOT
> > +#elif (CONFIG_IMX_CONSOLE_UART_ID == 7) #define UART_CLK_ROOT
> > +UART7_CLK_ROOT #else #error "Invalid IMX UART ID for serial console is
> > +defined"
> > +#endif
> > +
> >  struct clk_root_setting {
> >   enum clk_root_index root;
> >   u32 setting;
> > diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index
> > ec09ef2..7c5db30 100644
> > --- a/arch/arm/mach-imx/Kconfig
> > +++ b/arch/arm/mach-imx/Kconfig
> > @@ -27,6 +27,13 @@ config IMX_BOOTAUX
> >   help
> > bootaux [addr] to boot auxiliary core.
> >
> > +config IMX_CONSOLE_UART_ID
> > + int "UART ID for console"
> > + default 1
> > + depends on ARCH_MX7
> > + help
> > +   Specify the UART ID that's for serial console.
> > +
> >  config USE_IMXIMG_PLUGIN
> >   bool "Use imximage plugin code"
> >   depends on ARCH_MX7 || ARCH_MX6
> > diff --git a/arch/arm/mach-imx/mx7/clock.c
> > b/arch/arm/mach-imx/mx7/clock.c index 8cda71c..e364b16 100644
> > --- a/arch/arm/mach-imx/mx7/clock.c
> > +++ b/arch/arm/mach-imx/mx7/clock.c
> > @@ -53,7 +53,7 @@ static u32 get_ipg_clk(void)
> >
> >  u32 imx_get_uartclk(void)
> >  {
> > - return get_root_clk(UART1_CLK_ROOT);
> > + return get_root_clk(UART_CLK_ROOT);
> >  }
> >
> >  u32 imx_get_fecclk(void)
> > --
> > 2.7.4
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/9] Revert "pico-imx7d: Add LCD support"

2019-04-24 Thread Jun Nie
Fabio Estevam  于2019年4月24日周三 下午6:30写道:
>
> On Wed, Apr 24, 2019 at 1:00 AM Jun Nie  wrote:
> >
> > This reverts commit 9e3c0174da842dd88f5feaffbf843ba332233897.
>
> Why are you reverting it?

It blocks boot up with default defconfig. I see it is suggested to be
reverted in mailist weeks ago. I thought you guys knew about it.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 7/9] pico-imx7d: Add device tree for pico-imx7d

2019-04-24 Thread Jun Nie
Fabio Estevam  于2019年4月24日周三 下午6:31写道:
>
> On Wed, Apr 24, 2019 at 1:00 AM Jun Nie  wrote:
> >
> > Copy device tree files from Linux directly.
> >
> > Signed-off-by: Jun Nie 
>
> There is a series from Joris that does the pico-mx7d DM conversion.

When is that series expected to be merged?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 1/9] Revert "pico-imx7d: Add LCD support"

2019-04-25 Thread Jun Nie
Fabio Estevam  于2019年4月25日周四 上午11:28写道:
>
> Hi Jun,
>
> On Wed, Apr 24, 2019 at 11:53 PM Jun Nie  wrote:
>
> > It blocks boot up with default defconfig. I see it is suggested to be
> > reverted in mailist weeks ago. I thought you guys knew about it.
>
> Please keep in mind that the rationale of a patch must always be provided.
>
> In this case the issue is related to the limit of the current that the
> host PC USB port can provide.

Thank you very much for this info! I did not noticed this patch yet.
So power supply should be changed or disable LCD as a workaround
locally.

Jun

>
> Please see the following commit for detaisl:
>
> commit 00102ae52055e294ac37ae1380f37620f4a8bb26
> Author: Fabio Estevam 
> Date:   Wed Mar 27 20:03:39 2019 -0300
>
> pico-imx7d: README: Recommend the usage of a USB hub
>
> Since commit 9e3c0174da842 ("pico-imx7d: Add LCD support") we started to
> notice some hangs in U-Boot.
>
> There is not an issue on such commit per se, but due to the LCD support
> the current drawn is increased and this may cause issues when powering
> pico-imx7d-pi from USB.
>
> Some computers may be a bit strict with USB current draw and will
> shut down their ports if the draw is too high.
>
> The solution for that is to use an externally powered USB hub between the
> board and the host computer.
>
> Add such recommendation to the README file.
>
> Signed-off-by: Fabio Estevam 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 7/9] pico-imx7d: Add device tree for pico-imx7d

2019-04-25 Thread Jun Nie
>
> I merged Joris' series and build is in progress.
>
> Regards,
> Stefano
>
Great! I will prepare my patch based on that. But I cannot find latest
pico patch on denx master repo. Did you merge it to your own repo and
pulled to denx master later, just like linux work flow? I am not
familiar with u-boot work flow yet. Thanks for point the repo in
advance!

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


Re: [U-Boot] [PATCH v3 3/9] imx: mx7: Add empty arch_cpu_init if skipped

2019-04-25 Thread Jun Nie
> Please describe what ATF/OP-TEE initialization has done
> when booting into uboot.
>
> I think SKIP_LOWLEVEL_INIT is mostly for lowlevel_init,
> not arch_cpu_init.
>
> init_aips/init_csu/isolate_resources/init_snvs might be
> done in your ATF, I am not sure, but imx_enet_mdio_fixup,
> mxs_dma_init, imx_gpcv2_init, are these also done in ATF?
>
> Regards,
> Peng.

Yes, aips/csu/snvs/caam/watchdog are initialized.  Other missing stuff does
not introduce issue in my case so I just added back the empty function to
pass build. Will add them back for safe in next version. Thanks for the
reminder.

>
> >
> >  #ifdef CONFIG_ARCH_MISC_INIT
> > --
> > 2.7.4
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/9] pico-imx7d: Correct uart clock root

2019-04-25 Thread Jun Nie
Fabio Estevam  于2019年4月24日周三 下午6:32写道:
>
> On Wed, Apr 24, 2019 at 1:00 AM Jun Nie  wrote:
>
> > +config IMX_CONSOLE_UART_ID
> > +   int "UART ID for console"
> > +   default 1
> > +   depends on ARCH_MX7
> > +   help
> > + Specify the UART ID that's for serial console.
>
> We don't need this after DM conversion, right?

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


[U-Boot] [PATCH 1/2] serial: add skipping init option

2019-03-22 Thread Jun Nie
add skipping init option to avoid corrupt data in console
if serial is already initilized when u-boot start its excution.

Signed-off-by: Jun Nie 
---
 drivers/serial/Kconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 887cd68..7aeaffb 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -459,6 +459,12 @@ config DEBUG_UART_NS16550_CHECK_ENABLED
  Note that this does not work for every ns16550-compatible UART and
  so has to be enabled carefully or you might notice lost characters.
 
+config UART_SKIP_INIT
+   bool "Skip UART initialization"
+   help
+ Select this if the UART you want to use for output is already
+ initialized by the time U-Boot starts its execution.
+
 config ALTERA_JTAG_UART
bool "Altera JTAG UART support"
depends on DM_SERIAL
-- 
2.7.4

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


[U-Boot] [PATCH 2/2] imx: serial_mxc: skip uart initilization

2019-03-22 Thread Jun Nie
Skip uart initilization if CONFIG_UART_SKIP_INIT is defined.
That's means earlier firmware already initialized the uart.

Signed-off-by: Jun Nie 
---
 drivers/serial/serial_mxc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index 476df25..01c97a4 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -231,9 +231,11 @@ static int mxc_serial_tstc(void)
  */
 static int mxc_serial_init(void)
 {
+#ifndef CONFIG_UART_SKIP_INIT
_mxc_serial_init(mxc_base, false);
 
serial_setbrg();
+#endif
 
return 0;
 }
@@ -276,7 +278,9 @@ static int mxc_serial_probe(struct udevice *dev)
 {
struct mxc_serial_platdata *plat = dev->platdata;
 
+#ifndef CONFIG_UART_SKIP_INIT
_mxc_serial_init(plat->reg, plat->use_dte);
+#endif
 
return 0;
 }
-- 
2.7.4

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


Re: [U-Boot] [PATCH 1/2] serial: add skipping init option

2019-03-22 Thread Jun Nie
Simon Glass  于2019年3月22日周五 下午3:56写道:
>
> Hi Jun,
>
> On Fri, 22 Mar 2019 at 15:20, Jun Nie  wrote:
> >
> > add skipping init option to avoid corrupt data in console
> > if serial is already initilized when u-boot start its excution.
> >
> > Signed-off-by: Jun Nie 
> > ---
> >  drivers/serial/Kconfig | 6 ++
> >  1 file changed, 6 insertions(+)
>
> Could we use a device-tree property for this? Some UARTs have a
> 'skip-init' property.
>
> Regards,
> Simon

Hi Simon,

It is a good suggestion. But device tree is board specific, while the
config is boot flow specific. For ATF -> OPTEE -> U-BOOT case,
initialization should be skipped. Without earlier initialization from
firmware, U-boot should do it by itself. So I need find a solution
that is defconfig specific, instead of device tree specific.

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


[U-Boot] [PATCH 1/5] mx7_common: Share configs to skip low level init

2019-03-26 Thread Jun Nie
Share configs in mx7 to skip low level init if we are in the case where
OPTEE is loaded already (maybe by ARM Trusted Firmware) and that most of
the low level initialization is already done and that we may/should skip
it doing them here.

Fix the definition detection with size detection to decide whether to skip
it.

Signed-off-by: Jun Nie 
---
 include/configs/mx7_common.h | 11 +++
 include/configs/warp7.h  | 11 ---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index a895c93..912fb06 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -57,4 +57,15 @@
 #endif
 #endif
 
+/*
+ * If we have defined the OPTEE ram size and not OPTEE it means that we were
+ * launched by OPTEE, because of that we shall skip all the low level
+ * initialization since it was already done by ATF or OPTEE
+ */
+#if (CONFIG_OPTEE_TZDRAM_SIZE != 0)
+#ifndef CONFIG_OPTEE
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+#endif
+
 #endif
diff --git a/include/configs/warp7.h b/include/configs/warp7.h
index 043f286..80ddd72 100644
--- a/include/configs/warp7.h
+++ b/include/configs/warp7.h
@@ -13,17 +13,6 @@
 
 #define PHYS_SDRAM_SIZESZ_512M
 
-/*
- * If we have defined the OPTEE ram size and not OPTEE it means that we were
- * launched by OPTEE, because of that we shall skip all the low level
- * initialization since it was already done by ATF or OPTEE
- */
-#ifdef CONFIG_OPTEE_TZDRAM_SIZE
-#ifndef CONFIG_OPTEE
-#define CONFIG_SKIP_LOWLEVEL_INIT
-#endif
-#endif
-
 #define CONFIG_MXC_UART_BASE   UART1_IPS_BASE_ADDR
 
 /* Size of malloc() pool */
-- 
2.7.4

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


[U-Boot] [PATCH 0/5] pico-imx7d: Add support for BL33 case

2019-03-26 Thread Jun Nie
Add configuration to boot U-boot as BL33 case. The boot flow
is ATF -> OPTEE -> U-boot.

Jun Nie (5):
  mx7_common: Share configs to skip low level init
  imx: mx7: Add empty arch_cpu_init if skipped
  pico-imx7d: Reserve region of memory to OPTEE
  pico-imx7d: Add boot option for verified boot
  pico-imx7d: Add bl33 config

 arch/arm/mach-imx/mx7/soc.c|  2 +
 board/technexion/pico-imx7d/imximage-512MB.cfg | 95 ++
 board/technexion/pico-imx7d/pico-imx7d.c   |  5 ++
 configs/pico-pi-imx7d_bl33_defconfig   | 62 +
 include/configs/mx7_common.h   | 11 +++
 include/configs/pico-imx7d.h   | 38 ++-
 include/configs/warp7.h| 11 ---
 7 files changed, 210 insertions(+), 14 deletions(-)
 create mode 100644 board/technexion/pico-imx7d/imximage-512MB.cfg
 create mode 100644 configs/pico-pi-imx7d_bl33_defconfig

-- 
2.7.4

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


[U-Boot] [PATCH 2/5] imx: mx7: Add empty arch_cpu_init if skipped

2019-03-26 Thread Jun Nie
Add empty arch_cpu_init if low level init is skipped. So that
it does not break spl compile though spl is not needed in the
skipped case actually.

Signed-off-by: Jun Nie 
---
 arch/arm/mach-imx/mx7/soc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 7cfdff0..8f9fd9d 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -286,6 +286,8 @@ int arch_cpu_init(void)
 
return 0;
 }
+#else
+int arch_cpu_init(void) {}
 #endif
 
 #ifdef CONFIG_ARCH_MISC_INIT
-- 
2.7.4

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


[U-Boot] [PATCH 3/5] pico-imx7d: Reserve region of memory to OPTEE

2019-03-26 Thread Jun Nie
Subtracts CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size so that
the OPTEE memory is not override during u-boot relocation.

Note the OPTEE boot process will itself subtract the DRAM region it lives
in from the memory map passed to Linux.

Signed-off-by: Jun Nie 
---
 board/technexion/pico-imx7d/pico-imx7d.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/technexion/pico-imx7d/pico-imx7d.c 
b/board/technexion/pico-imx7d/pico-imx7d.c
index 53e1469..7c9e145 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -60,6 +60,11 @@ int dram_init(void)
 {
gd->ram_size = imx_ddr_size();
 
+   /* Subtract the defined OPTEE runtime firmware length */
+#ifdef CONFIG_OPTEE_TZDRAM_SIZE
+   gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
+#endif
+
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-26 Thread Jun Nie
Add default configuration to run u-boot as BL33 in the boot flow case
of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.

Signed-off-by: Jun Nie 
---
 board/technexion/pico-imx7d/imximage-512MB.cfg | 95 ++
 configs/pico-pi-imx7d_bl33_defconfig   | 61 +
 2 files changed, 156 insertions(+)
 create mode 100644 board/technexion/pico-imx7d/imximage-512MB.cfg
 create mode 100644 configs/pico-pi-imx7d_bl33_defconfig

diff --git a/board/technexion/pico-imx7d/imximage-512MB.cfg 
b/board/technexion/pico-imx7d/imximage-512MB.cfg
new file mode 100644
index 000..2b7bbbc
--- /dev/null
+++ b/board/technexion/pico-imx7d/imximage-512MB.cfg
@@ -0,0 +1,95 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 Arm Ltd.
+ *
+ * The DCD file for Pico-pi with 512MB DRAM memory.
+ * Refer doc/README.imximage for more details about how-to configure
+ * and create imximage boot image.
+ *
+ * The syntax is taken as close as possible with the kwbimage
+ */
+
+#define __ASSEMBLY__
+#include 
+
+IMAGE_VERSION  2
+#ifdef CONFIG_SECURE_BOOT
+CSF CONFIG_CSF_SIZE
+#endif
+
+BOOT_FROM  sd
+
+/*
+ * Device Configuration Data (DCD)
+ *
+ * Each entry must have the format:
+ * Addr-type   AddressValue
+ *
+ * where:
+ * Addr-type register length (1,2 or 4 bytes)
+ * Address   absolute address of the register
+ * value value to be stored in the register
+ */
+
+DATA 4 0x30340004 0x4F45
+
+DATA 4 0x30391000 0x0002
+DATA 4 0x307a 0x01040001
+DATA 4 0x307a0064 0x00400046
+DATA 4 0x307a0490 0x0001
+DATA 4 0x307a00d4 0x0069
+DATA 4 0x307a00d0 0x00020083
+DATA 4 0x307a00dc 0x0934
+DATA 4 0x307a00e0 0x0408
+DATA 4 0x307a00e4 0x0014
+DATA 4 0x307a00f4 0x033f
+DATA 4 0x307a0100 0x09081109
+DATA 4 0x307a0104 0x0007020d
+DATA 4 0x307a0108 0x03040407
+DATA 4 0x307a010c 0x2006
+DATA 4 0x307a0110 0x04020205
+DATA 4 0x307a0114 0x03030202
+DATA 4 0x307a0120 0x0803
+
+DATA 4 0x307a0180 0x00800020
+DATA 4 0x307a0190 0x02098204
+DATA 4 0x307a0194 0x00030303
+DATA 4 0x307a01a0 0x8043
+DATA 4 0x307a01a4 0x00100020
+DATA 4 0x307a01a8 0x8014
+
+DATA 4 0x307a0200 0x001f
+DATA 4 0x307a0204 0x00080808
+DATA 4 0x307a0210 0x0f0f
+DATA 4 0x307a0214 0x07070707
+DATA 4 0x307a0218 0x0f0f0707
+DATA 4 0x307a0240 0x06000604
+DATA 4 0x307a0244 0x0001
+
+DATA 4 0x30391000 0x
+DATA 4 0x3079 0x17420f40
+DATA 4 0x30790004 0x10210100
+DATA 4 0x30790010 0x00060807
+DATA 4 0x307900b0 0x1010007e
+
+DATA 4 0x3079009c 0x0d6e
+
+DATA 4 0x30790030 0x08080808
+DATA 4 0x30790020 0x08080808
+DATA 4 0x30790050 0x0110
+DATA 4 0x30790050 0x0010
+DATA 4 0x30790018 0x000f
+DATA 4 0x307900c0 0x0e407304
+DATA 4 0x307900c0 0x0e447304
+DATA 4 0x307900c0 0x0e447306
+DATA 4 0x307900c0 0x0e447304
+
+CHECK_BITS_SET 4 0x307900c4 0x1
+
+DATA 4 0x307900c0 0x0e447304
+
+DATA 4 0x30384130 0x
+DATA 4 0x30340020 0x0178
+DATA 4 0x30384130 0x0002
+
+CHECK_BITS_SET 4 0x307a0004 0x1
diff --git a/configs/pico-pi-imx7d_bl33_defconfig 
b/configs/pico-pi-imx7d_bl33_defconfig
new file mode 100644
index 000..7d1ac18
--- /dev/null
+++ b/configs/pico-pi-imx7d_bl33_defconfig
@@ -0,0 +1,61 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX7=y
+CONFIG_SYS_TEXT_BASE=0x8780
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SECURE_BOOT=y
+CONFIG_TARGET_PICO_IMX7D=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL=y
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/technexion/pico-imx7d/imximage-512MB.cfg"
+CONFIG_DEFAULT_FDT_FILE="imx7d-pico-pi.dtb"
+CONFIG_BOUNCE_BUFFER=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTD is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_SPL=y
+CONFIG_CMD_SPL_WRITE_SIZE=0x2
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_DFU_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_PHYLIB=y
+CONFIG_MII=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_ETHER=y
+CONFIG_USB_ETH_CDC=y
+CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00"
+CONFIG_OF_LIBFDT=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_OPTEE_TZDRAM_SIZE=0x200
-- 
2.7.4

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


[U-Boot] [PATCH 4/5] pico-imx7d: Add boot option for verified boot

2019-03-26 Thread Jun Nie
Add boot option to boot from fitimage to support verified boot.
The boot script plain text file should be packed into fit blob as
image with name of bootscr.

Signed-off-by: Jun Nie 
---
 include/configs/pico-imx7d.h | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 1884c58..8eb9064 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -52,11 +52,29 @@
"/boot/imx7d-pico-pi.dtb ext4 0 1;" \
"rootfs part 0 1\0" \
 
-#define BOOTMENU_ENV \
+/* When booting with FIT specify the node entry containing boot.scr */
+#if defined(CONFIG_FIT)
+#define PICO_BOOT_ENV \
+   "bootscr_fitimage_name=bootscr\0" \
+   "bootscriptaddr=0x8320\0" \
+   "fdtovaddr=0x8310\0" \
+   "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
+   "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
+   "mmcargs=setenv bootargs console=${console},${baudrate} " \
+   "rootwait rw;\0" \
+   "loadbootscript=" \
+   "load mmc ${mmcdev}:${mmcpart} ${bootscriptaddr} ${script};\0" \
+   "bootscript=echo Running bootscript from mmc ...; " \
+   "source ${bootscriptaddr}:${bootscr_fitimage_name}\0"
+#else
+#define PICO_BOOT_ENV \
"bootmenu_0=Boot using PICO-Hobbit baseboard=" \
"setenv fdtfile imx7d-pico-hobbit.dtb\0" \
"bootmenu_1=Boot using PICO-Pi baseboard=" \
"setenv fdtfile imx7d-pico-pi.dtb\0" \
+   BOOTENV
+#endif
+
 
 #define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
 #define CONFIG_SYS_MMC_IMG_LOAD_PART   1
@@ -68,7 +86,6 @@
"fdt_high=0x\0" \
"initrd_high=0x\0" \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   BOOTMENU_ENV \
"fdt_addr=0x8300\0" \
"fdt_addr_r=0x8300\0" \
"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
@@ -88,7 +105,22 @@
"name=rootfs,size=0,uuid=${uuid_gpt_rootfs}\0" \
"fastboot_partition_alias_system=rootfs\0" \
"setup_emmc=mmc dev 0; gpt write mmc 0 $partitions; reset;\0" \
-   BOOTENV
+   PICO_BOOT_ENV
+
+#if defined(CONFIG_FIT)
+#define CONFIG_BOOTCOMMAND \
+   "mmc dev ${mmcdev};" \
+   "mmc dev ${mmcdev}; if mmc rescan; then " \
+   "if run loadbootscript; then " \
+   "iminfo ${bootscriptaddr};" \
+   "if test $? -eq 1; then hab_failsafe; fi;" \
+   "run bootscript; " \
+   "else " \
+   "echo Fail to load fitImage with boot script;" \
+   "hab_failsafe;" \
+   "fi; " \
+   "fi"
+#endif
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
-- 
2.7.4

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


Re: [U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-26 Thread Jun Nie
Otavio Salvador  于2019年3月26日周二 下午8:23写道:
>
> On Tue, Mar 26, 2019 at 6:23 AM Jun Nie  wrote:
> >
> > Add default configuration to run u-boot as BL33 in the boot flow case
> > of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.
> >
> > Signed-off-by: Jun Nie 
>
> Please base it on pico-imx7d_defconfig so user is asked for the base
> board to use and it provides more flexibility to test.

Thanks for pointing out this part. I should remove CONFIG_DEFAULT_FDT_FILE
actually. Because environment variable fdt_file does not impact what
fdt to use for
booting OS. The dtb file is specified by the argument of FIT
configuration feed to
bootm command in verified boot case with using FIT, such as
"bootm 0x8320#c...@imx7d-pico.dtb"

>
> --
> Otavio Salvador O.S. Systems
> http://www.ossystems.com.brhttp://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-26 Thread Jun Nie
Otavio Salvador  于2019年3月26日周二 下午8:23写道:
>
> On Tue, Mar 26, 2019 at 6:23 AM Jun Nie  wrote:
> >
> > Add default configuration to run u-boot as BL33 in the boot flow case
> > of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.
> >
> > Signed-off-by: Jun Nie 
>
> Please base it on pico-imx7d_defconfig so user is asked for the base
> board to use and it provides more flexibility to test.

Or I misunderstand you and you suggest file name pico-imx7d_bl33_defconfig ?

Jun
>
> --
> Otavio Salvador O.S. Systems
> http://www.ossystems.com.brhttp://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] serial: add skipping init option

2019-03-27 Thread Jun Nie
Lukasz Majewski  于2019年3月27日周三 下午5:34写道:
>
> Hi Simon, Jun,
>
> > Hi Jun,
> >
> > On Fri, 22 Mar 2019 at 16:02, Jun Nie  wrote:
> > >
> > > Simon Glass  于2019年3月22日周五 下午3:56写道:
> > > >
> > > > Hi Jun,
> > > >
> > > > On Fri, 22 Mar 2019 at 15:20, Jun Nie 
> > > > wrote:
> > > > >
> > > > > add skipping init option to avoid corrupt data in console
> > > > > if serial is already initilized when u-boot start its excution.
> > > > >
> > > > > Signed-off-by: Jun Nie 
> > > > > ---
> > > > >  drivers/serial/Kconfig | 6 ++
> > > > >  1 file changed, 6 insertions(+)
> > > >
> > > > Could we use a device-tree property for this? Some UARTs have a
> > > > 'skip-init' property.
> > > >
> > > > Regards,
> > > > Simon
> > >
> > > Hi Simon,
> > >
> > > It is a good suggestion. But device tree is board specific, while
> > > the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case,
> > > initialization should be skipped. Without earlier initialization
> > > from firmware, U-boot should do it by itself. So I need find a
> > > solution that is defconfig specific, instead of device tree
> > > specific.
> >
> > So you want something that is flow-specific, I think. Your thinking is
> > that the defconfig specifies this. Is that because certain boards
> > require ATF/Optee?
> >
> > Should we consider having a way to tell U-Boot that it is running
> > from Optee?
> >
> > Could the UART driver detect that the UART is already inited?
>
> Isn't this issue similar to:
> http://patchwork.ozlabs.org/patch/820824/
>
> and
>
> http://patchwork.ozlabs.org/patch/865963/
>
My case is that console does not emit any log when OPTEE runs into u-boot.
I already root caused that there is a bug in uart clock handling.
UART1_CLK_ROOT
is hard coded in imx_get_uartclk() of arch/arm/mach-imx/mx7/clock.c
If the console serial is not UART1, 0 may be returned and console does not work.

But when I add an IMX_UART_PORT config option in Kconfig to dynamic configure
the CLK_ROOT ID as below, the expansion result is
UARTCONFIG_IMX_UART_PORT_CLK_ROOT instead of  UART1_CLK_ROOT.
It seems macro expansion happens before the inclusion of defconfig. Do you see
any better idea other than add the definition in
include/configs/pico-imx7d.h directly?

#define IMX_UART_CLK_ROOT UART##CONFIG_IMX_UART_PORT##_CLK_ROOT

Current plan is to add below change so that platform can define
different clock root other
than UART1_CLK_ROOT.

+++ b/arch/arm/mach-imx/mx7/clock.c
@@ -51,9 +51,12 @@ static u32 get_ipg_clk(void)
return get_ahb_clk() / 2;
 }

+#ifndef UART_CLK_ROOT
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#endif
 u32 imx_get_uartclk(void)
 {
-   return get_root_clk(UART1_CLK_ROOT);
+   return get_root_clk(UART_CLK_ROOT);
 }

> >
> > Regards,
> > Simon
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-27 Thread Jun Nie
Fabio Estevam  于2019年3月27日周三 下午7:52写道:
>
> Hi Jun,
>
> On Tue, Mar 26, 2019 at 6:21 AM Jun Nie  wrote:
> >
> > Add default configuration to run u-boot as BL33 in the boot flow case
> > of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.
> >
> > Signed-off-by: Jun Nie 
> > ---
> >  board/technexion/pico-imx7d/imximage-512MB.cfg | 95 
> > ++
>
> This looks like a step in the wrong direction.
>
> We have SPL support that can handle both 512MB and 1GB variants.
>
> Why do we need to to go back to DCD table?

For ATF -> OPTEE -> U-BOOT case, we cannot run SPL.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-27 Thread Jun Nie
Fabio Estevam  于2019年3月27日周三 下午8:03写道:
>
> On Wed, Mar 27, 2019 at 8:59 AM Jun Nie  wrote:
>
> > For ATF -> OPTEE -> U-BOOT case, we cannot run SPL.
>
> Why not? Please provide the details.
>
> What about users that has the 1GB version of the board?

I should say that SPL is not needed, not cannot run. u-boot is loaded
and run by ATF/OPTEE, so we do not need SPL. This is an initial
prototype of verified boot chain from ATF to Linux on ARM32. Only
512MB version is considered at this stage. Maybe we can add 1GB
version later if it is needed.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/5] pico-imx7d: Add bl33 config

2019-03-27 Thread Jun Nie
Fabio Estevam  于2019年3月27日周三 下午10:57写道:
>
> On Wed, Mar 27, 2019 at 11:18 AM Jun Nie  wrote:
>
> > I should say that SPL is not needed, not cannot run. u-boot is loaded
> > and run by ATF/OPTEE, so we do not need SPL. This is an initial
> > prototype of verified boot chain from ATF to Linux on ARM32. Only
> > 512MB version is considered at this stage. Maybe we can add 1GB
> > version later if it is needed.
>
> Sorry, but we cannot accept adding non-SPL code as this impacts maintenance.
>
> Please add OPTEE support with the existing SPL infrastructure.
>
> Thanks

The DCD file is only used by BL33 defconfig and is not coupled with
any other code.
Or you are suggesting to use ATF -> OPTEE -> SPL -> u-boot flow? SPL
is unnecessary
in this case. Could you elaborate more on maintenance impact? Thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/6] mx7_common: Share configs to skip low level init

2019-03-28 Thread Jun Nie
Share configs in mx7 to skip low level init if we are in the case where
OPTEE is loaded already (maybe by ARM Trusted Firmware) and that most of
the low level initialization is already done and that we may/should skip
it doing them here.

Fix the definition detection with size detection to decide whether to skip
it.

Signed-off-by: Jun Nie 
---
 include/configs/mx7_common.h | 11 +++
 include/configs/warp7.h  | 11 ---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index a895c93..912fb06 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -57,4 +57,15 @@
 #endif
 #endif
 
+/*
+ * If we have defined the OPTEE ram size and not OPTEE it means that we were
+ * launched by OPTEE, because of that we shall skip all the low level
+ * initialization since it was already done by ATF or OPTEE
+ */
+#if (CONFIG_OPTEE_TZDRAM_SIZE != 0)
+#ifndef CONFIG_OPTEE
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+#endif
+
 #endif
diff --git a/include/configs/warp7.h b/include/configs/warp7.h
index 043f286..80ddd72 100644
--- a/include/configs/warp7.h
+++ b/include/configs/warp7.h
@@ -13,17 +13,6 @@
 
 #define PHYS_SDRAM_SIZESZ_512M
 
-/*
- * If we have defined the OPTEE ram size and not OPTEE it means that we were
- * launched by OPTEE, because of that we shall skip all the low level
- * initialization since it was already done by ATF or OPTEE
- */
-#ifdef CONFIG_OPTEE_TZDRAM_SIZE
-#ifndef CONFIG_OPTEE
-#define CONFIG_SKIP_LOWLEVEL_INIT
-#endif
-#endif
-
 #define CONFIG_MXC_UART_BASE   UART1_IPS_BASE_ADDR
 
 /* Size of malloc() pool */
-- 
2.7.4

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


[U-Boot] [PATCH v2 0/6] pico-imx7d: Add support for BL33 case

2019-03-28 Thread Jun Nie
Add configuration to boot U-boot as BL33 case. The boot flow
is ATF -> OPTEE -> U-boot.

Changes vs V1:
- Remove DCD file.
- Add a patch to fix uart clock root ID.
- Change file name from pico-pi-imx7d_bl33_defconfig to 
pico-imx7d_bl33_defconfig

Jun Nie (6):
  mx7_common: Share configs to skip low level init
  imx: mx7: Add empty arch_cpu_init if skipped
  pico-imx7d: Reserve region of memory to OPTEE
  pico-imx7d: Add boot option for verified boot
  pico-imx7d: Add bl33 config
  pico-imx7d: Correct uart clock root

 arch/arm/include/asm/arch-mx7/clock.h|  5 +++
 arch/arm/mach-imx/mx7/clock.c|  2 +-
 arch/arm/mach-imx/mx7/soc.c  |  4 +++
 board/technexion/pico-imx7d/pico-imx7d.c |  5 +++
 configs/pico-imx7d_bl33_defconfig| 61 
 include/configs/mx7_common.h | 11 ++
 include/configs/pico-imx7d.h | 39 ++--
 include/configs/warp7.h  | 11 --
 8 files changed, 123 insertions(+), 15 deletions(-)
 create mode 100644 configs/pico-imx7d_bl33_defconfig

-- 
2.7.4

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


[U-Boot] [PATCH v2 5/6] pico-imx7d: Add bl33 config

2019-03-28 Thread Jun Nie
Add default configuration to run u-boot as BL33 in the boot flow case
of ATF(ARM Trusted Firmware) -> OPTEE -> U-boot.

Signed-off-by: Jun Nie 
---
 configs/pico-imx7d_bl33_defconfig | 61 +++
 1 file changed, 61 insertions(+)
 create mode 100644 configs/pico-imx7d_bl33_defconfig

diff --git a/configs/pico-imx7d_bl33_defconfig 
b/configs/pico-imx7d_bl33_defconfig
new file mode 100644
index 000..77e46d5
--- /dev/null
+++ b/configs/pico-imx7d_bl33_defconfig
@@ -0,0 +1,61 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX7=y
+CONFIG_SYS_TEXT_BASE=0x8780
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SECURE_BOOT=y
+CONFIG_TARGET_PICO_IMX7D=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL=y
+CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"
+CONFIG_DEFAULT_FDT_FILE="imx7d-pico-pi.dtb"
+CONFIG_BOUNCE_BUFFER=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+# CONFIG_CMD_BOOTD is not set
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_SPL=y
+CONFIG_CMD_SPL_WRITE_SIZE=0x2
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_SDP=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_DFU_MMC=y
+CONFIG_FSL_ESDHC=y
+CONFIG_PHYLIB=y
+CONFIG_MII=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_USB_ETHER=y
+CONFIG_USB_ETH_CDC=y
+CONFIG_USBNET_HOST_ADDR="de:ad:be:af:00:00"
+CONFIG_OF_LIBFDT=y
+CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_OPTEE_TZDRAM_SIZE=0x200
-- 
2.7.4

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


[U-Boot] [PATCH v2 3/6] pico-imx7d: Reserve region of memory to OPTEE

2019-03-28 Thread Jun Nie
Subtracts CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size so that
the OPTEE memory is not override during u-boot relocation.

Note the OPTEE boot process will itself subtract the DRAM region it lives
in from the memory map passed to Linux.

Signed-off-by: Jun Nie 
---
 board/technexion/pico-imx7d/pico-imx7d.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/technexion/pico-imx7d/pico-imx7d.c 
b/board/technexion/pico-imx7d/pico-imx7d.c
index 53e1469..7c9e145 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -60,6 +60,11 @@ int dram_init(void)
 {
gd->ram_size = imx_ddr_size();
 
+   /* Subtract the defined OPTEE runtime firmware length */
+#ifdef CONFIG_OPTEE_TZDRAM_SIZE
+   gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
+#endif
+
return 0;
 }
 
-- 
2.7.4

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


[U-Boot] [PATCH v2 4/6] pico-imx7d: Add boot option for verified boot

2019-03-28 Thread Jun Nie
Add boot option to boot from fitimage to support verified boot.
The boot script plain text file should be packed into fit blob as
image with name of bootscr.

Signed-off-by: Jun Nie 
---
 include/configs/pico-imx7d.h | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 1884c58..8eb9064 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -52,11 +52,29 @@
"/boot/imx7d-pico-pi.dtb ext4 0 1;" \
"rootfs part 0 1\0" \
 
-#define BOOTMENU_ENV \
+/* When booting with FIT specify the node entry containing boot.scr */
+#if defined(CONFIG_FIT)
+#define PICO_BOOT_ENV \
+   "bootscr_fitimage_name=bootscr\0" \
+   "bootscriptaddr=0x8320\0" \
+   "fdtovaddr=0x8310\0" \
+   "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
+   "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
+   "mmcargs=setenv bootargs console=${console},${baudrate} " \
+   "rootwait rw;\0" \
+   "loadbootscript=" \
+   "load mmc ${mmcdev}:${mmcpart} ${bootscriptaddr} ${script};\0" \
+   "bootscript=echo Running bootscript from mmc ...; " \
+   "source ${bootscriptaddr}:${bootscr_fitimage_name}\0"
+#else
+#define PICO_BOOT_ENV \
"bootmenu_0=Boot using PICO-Hobbit baseboard=" \
"setenv fdtfile imx7d-pico-hobbit.dtb\0" \
"bootmenu_1=Boot using PICO-Pi baseboard=" \
"setenv fdtfile imx7d-pico-pi.dtb\0" \
+   BOOTENV
+#endif
+
 
 #define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
 #define CONFIG_SYS_MMC_IMG_LOAD_PART   1
@@ -68,7 +86,6 @@
"fdt_high=0x\0" \
"initrd_high=0x\0" \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
-   BOOTMENU_ENV \
"fdt_addr=0x8300\0" \
"fdt_addr_r=0x8300\0" \
"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
@@ -88,7 +105,22 @@
"name=rootfs,size=0,uuid=${uuid_gpt_rootfs}\0" \
"fastboot_partition_alias_system=rootfs\0" \
"setup_emmc=mmc dev 0; gpt write mmc 0 $partitions; reset;\0" \
-   BOOTENV
+   PICO_BOOT_ENV
+
+#if defined(CONFIG_FIT)
+#define CONFIG_BOOTCOMMAND \
+   "mmc dev ${mmcdev};" \
+   "mmc dev ${mmcdev}; if mmc rescan; then " \
+   "if run loadbootscript; then " \
+   "iminfo ${bootscriptaddr};" \
+   "if test $? -eq 1; then hab_failsafe; fi;" \
+   "run bootscript; " \
+   "else " \
+   "echo Fail to load fitImage with boot script;" \
+   "hab_failsafe;" \
+   "fi; " \
+   "fi"
+#endif
 
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
-- 
2.7.4

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


[U-Boot] [PATCH v2 2/6] imx: mx7: Add empty arch_cpu_init if skipped

2019-03-28 Thread Jun Nie
Add empty arch_cpu_init if low level init is skipped. So that
it does not break spl compile though spl is not needed in the
skipped case actually.

Signed-off-by: Jun Nie 
---
 arch/arm/mach-imx/mx7/soc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 7cfdff0..9b04013 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -286,6 +286,11 @@ int arch_cpu_init(void)
 
return 0;
 }
+#else
+int arch_cpu_init(void)
+{
+   return 0;
+}
 #endif
 
 #ifdef CONFIG_ARCH_MISC_INIT
-- 
2.7.4

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


[U-Boot] [PATCH v2 6/6] pico-imx7d: Correct uart clock root

2019-03-28 Thread Jun Nie
Correct uart clock root ID. Incorrect ID may result the
clock is gated because rate value 0 is returned in
imx_get_uartclk()

Signed-off-by: Jun Nie 
---
 arch/arm/include/asm/arch-mx7/clock.h | 5 +
 arch/arm/mach-imx/mx7/clock.c | 2 +-
 include/configs/pico-imx7d.h  | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mx7/clock.h 
b/arch/arm/include/asm/arch-mx7/clock.h
index f56564e..b6a1768 100644
--- a/arch/arm/include/asm/arch-mx7/clock.h
+++ b/arch/arm/include/asm/arch-mx7/clock.h
@@ -175,6 +175,11 @@ enum clk_root_index {
CLK_ROOT_MAX,
 };
 
+/* Use UART1_CLK_ROOT as default root clk if platform does define it */
+#ifndef UART_CLK_ROOT
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#endif
+
 struct clk_root_setting {
enum clk_root_index root;
u32 setting;
diff --git a/arch/arm/mach-imx/mx7/clock.c b/arch/arm/mach-imx/mx7/clock.c
index 8cda71c..e364b16 100644
--- a/arch/arm/mach-imx/mx7/clock.c
+++ b/arch/arm/mach-imx/mx7/clock.c
@@ -53,7 +53,7 @@ static u32 get_ipg_clk(void)
 
 u32 imx_get_uartclk(void)
 {
-   return get_root_clk(UART1_CLK_ROOT);
+   return get_root_clk(UART_CLK_ROOT);
 }
 
 u32 imx_get_fecclk(void)
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 8eb9064..9806348 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -28,6 +28,7 @@
 #define CONFIG_SYS_MALLOC_LEN  (32 * SZ_1M)
 
 #define CONFIG_MXC_UART_BASE   UART5_IPS_BASE_ADDR
+#define UART_CLK_ROOT  UART5_CLK_ROOT
 
 /* Network */
 #define CONFIG_FEC_MXC
-- 
2.7.4

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


Re: [U-Boot] [PATCH 1/2] serial: add skipping init option

2019-04-02 Thread Jun Nie
Simon Glass  于2019年3月31日周日 上午5:19写道:
>
> Hi Lukasz,
>
> On Wed, 27 Mar 2019 at 03:34, Lukasz Majewski  wrote:
> >
> > Hi Simon, Jun,
> >
> > > Hi Jun,
> > >
> > > On Fri, 22 Mar 2019 at 16:02, Jun Nie  wrote:
> > > >
> > > > Simon Glass  于2019年3月22日周五 下午3:56写道:
> > > > >
> > > > > Hi Jun,
> > > > >
> > > > > On Fri, 22 Mar 2019 at 15:20, Jun Nie 
> > > > > wrote:
> > > > > >
> > > > > > add skipping init option to avoid corrupt data in console
> > > > > > if serial is already initilized when u-boot start its excution.
> > > > > >
> > > > > > Signed-off-by: Jun Nie 
> > > > > > ---
> > > > > >  drivers/serial/Kconfig | 6 ++
> > > > > >  1 file changed, 6 insertions(+)
> > > > >
> > > > > Could we use a device-tree property for this? Some UARTs have a
> > > > > 'skip-init' property.
> > > > >
> > > > > Regards,
> > > > > Simon
> > > >
> > > > Hi Simon,
> > > >
> > > > It is a good suggestion. But device tree is board specific, while
> > > > the config is boot flow specific. For ATF -> OPTEE -> U-BOOT case,
> > > > initialization should be skipped. Without earlier initialization
> > > > from firmware, U-boot should do it by itself. So I need find a
> > > > solution that is defconfig specific, instead of device tree
> > > > specific.
> > >
> > > So you want something that is flow-specific, I think. Your thinking is
> > > that the defconfig specifies this. Is that because certain boards
> > > require ATF/Optee?
> > >
> > > Should we consider having a way to tell U-Boot that it is running
> > > from Optee?
> > >
> > > Could the UART driver detect that the UART is already inited?
> >
> > Isn't this issue similar to:
> > http://patchwork.ozlabs.org/patch/820824/
> >
> > and
> >
> > http://patchwork.ozlabs.org/patch/865963/
> >
>
> Yes. But in the case of this patch I'm hoping we don't need it.
>
> Regards,
> Simon

Right, we do not need patch here to skip the initialization. I already
add the fix in imx clock side to imx patch set. Thank for suggestion!

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


Re: [U-Boot] [PATCH v2 6/6] pico-imx7d: Correct uart clock root

2019-04-03 Thread Jun Nie
Otavio Salvador  于2019年3月28日周四 下午8:58写道:
>
> On Thu, Mar 28, 2019 at 5:34 AM Jun Nie  wrote:
> >
> > Correct uart clock root ID. Incorrect ID may result the
> > clock is gated because rate value 0 is returned in
> > imx_get_uartclk()
> >
> > Signed-off-by: Jun Nie 
>
> How this could not be defined? couldn't this to be fixed on kconfig to
> use it as default?

Sure, it can be fixed to a default value or string. I had tried to add
an IMX_UART_PORT config
option in Kconfig to dynamic configure the CLK_ROOT ID as below, the
expansion result is
UARTCONFIG_IMX_UART_PORT_CLK_ROOT instead of  UART1_CLK_ROOT.
It seems macro expansion happens before the inclusion of defconfig.

#define IMX_UART_CLK_ROOT UART##CONFIG_IMX_CONS_ID##_CLK_ROOT

Do you see any better idea other than many definition if #if #elif as
below? Below code
is not beautiful, only usable.

+++ b/arch/arm/include/asm/arch-mx7/clock.h
@@ -175,6 +175,24 @@ enum clk_root_index {
CLK_ROOT_MAX,
 };

+#if (CONFIG_IMX_CONS_ID == 1)
+#define UART_CLK_ROOT UART1_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 2)
+#define UART_CLK_ROOT UART2_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 3)
+#define UART_CLK_ROOT UART3_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 4)
+#define UART_CLK_ROOT UART4_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 5)
+#define UART_CLK_ROOT UART5_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 6)
+#define UART_CLK_ROOT UART6_CLK_ROOT
+#elif (CONFIG_IMX_CONS_ID == 7)
+#define UART_CLK_ROOT UART7_CLK_ROOT
+#else
+#error "Invalid IMX console ID is defined"
+#endif

Best Regards.
Jun


>
> --
> Otavio Salvador O.S. Systems
> http://www.ossystems.com.brhttp://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/6] pico-imx7d: Add support for BL33 case

2019-04-03 Thread Jun Nie
Otavio Salvador  于2019年3月28日周四 下午8:57写道:
>
> On Thu, Mar 28, 2019 at 5:30 AM Jun Nie  wrote:
> >
> > Add configuration to boot U-boot as BL33 case. The boot flow
> > is ATF -> OPTEE -> U-boot.
>
> Could you add a README explaining how to use / test it?

Hi Otavio,

Below is draft of README. some of command may not be accurate because I am
on travel and cannot access latest code in my PC in home. If you are
OK with idea
in it, I will polish it later. The SPL is built but not used because
the BL33 is loaded
by ATF while ATF exist in SRAM. ATF cannot load SPL into SRAM to
override itself.


README.pico-imx7d_BL33
This document describes the instruction to build ATF/OPTEE and flash eMMC on
pico-imx7d board.  U-Boot is loaded by ATF/OPTEE in this setup.

- Build u-boot
# set environment variable of CROSS_COMPILE for your toolchain and ARCH=arm
make pico-pi-imx7d-mbl_defconfig
make all

- Download and build OPTEE
git clone https://git.linaro.org/landing-teams/working/mbl/optee_os.git
-b linaro-pico
make PLATFORM=imx PLATFORM_FLAVOR=mx7dpico_mbl ARCH=arm

- Download and build ATF, create FIP image
git clone 
https://git.linaro.org/landing-teams/working/mbl/arm-trusted-firmware.git
-b linaro-imx7
make DEBUG=1 PLAT=picopi ARCH=aarch32 ARM_ARCH_MAJOR=7
CROSS_COMPILE=arm-linux-gnueabihf- LOG_LEVEL=50 V=1 CRASH_REPORTING=1
AARCH32_SP=optee all
wget 
http://git.linaro.org/landing-teams/working/mbl/u-boot.git/tree/board/technexion/pico-imx7d/pico-imx7d.cfg?h=linaro-imx
mkimage -n pico-imx7d.cfg -T imximage -e 0x8780 -d -d
build/picopi/debug/bl2.bin bl2.imx
# create a  fiptool_images/ folder under atf folder, copy
u-boot.bin in u-boot folder and tee*.bin in optee core/tee/ folder to
fiptool_images. Run below command to generate FIP image.
tools/fiptool/fiptool create --tos-fw fiptool_images/tee-header_v2.bin \
--tos-fw-extra1 fiptool_images/tee-pager_v2.bin \
--tos-fw-extra2 fiptool_images/tee-pageable_v2.bin \
--nt-fw fiptool_images/u-boot.bin \
fip.bin

- Burn the images to eMMC for test.
# Run below command in atf folder:
dd if=build/picopi/debug/bl2.bin.imx of=/dev/disk/by-id/usb-  bs=1024 seek=1;sync
dd if=fip.bin of=/dev/disk/by-id/usb-  bs=1024 seek=1;sync

- Test
Just boot up your board and wait for u-boot start up after ATF's
log. For booting Linux in FIT image, please reference the FIT files in
u-boot doc/uImage.FIT/ folder.


>
>
> --
> Otavio Salvador O.S. Systems
> http://www.ossystems.com.brhttp://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 0/6] pico-imx7d: Add support for BL33 case

2019-04-03 Thread Jun Nie
Hi Otavio,

And for the file name pico-imx7d_bl33_defconfig,
pico-pi-imx7d_bl33_defconfig should be better in my later thought.
Because a concrete device tree source file should be specified in
defconfig file, so that public key can be stored in u-boot FDT blob
for kernel/initramfs FIT signature verification. What's your comments?

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


Re: [U-Boot] [PATCH v2 0/6] pico-imx7d: Add support for BL33 case

2019-04-09 Thread Jun Nie
Otavio Salvador  于2019年4月4日周四 下午8:40写道:
>
> On Wed, Apr 3, 2019 at 9:00 AM Jun Nie  wrote:
> > And for the file name pico-imx7d_bl33_defconfig,
> > pico-pi-imx7d_bl33_defconfig should be better in my later thought.
> > Because a concrete device tree source file should be specified in
> > defconfig file, so that public key can be stored in u-boot FDT blob
> > for kernel/initramfs FIT signature verification. What's your comments?
>
> The FIT image might have them all, no? It would allow a single binary
> to work on all baseboards, giving a very nice user experience.

The FIT image have all device trees. I mean the device tree for u-boot should
be specified. As device trees are copied from kernel, while there is
no dts file for
pico-imx7d. It is a bit peculiar if you specify device tree as pico-pi-imx7d in
pico-imx7d_bl33_defconfig.

>
> --
> Otavio Salvador O.S. Systems
> http://www.ossystems.com.brhttp://code.ossystems.com.br
> Mobile: +55 (53) 9 9981-7854  Mobile: +1 (347) 903-9750
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 0/8] pico-imx7d: Add support for BL33 case

2019-05-07 Thread Jun Nie
Add configuration to boot U-boot as BL33 case. The boot flow
is ATF -> OPTEE -> U-boot.

Changes vs V3:
- Remove CONFIG_IMX_CONSOLE_UART_ID.
- Add workaround if PMIC is not probed successfully.
- Add non-secure world cpu initilization for CONFIG_SKIP_LOWLEVEL_INIT case.

Changes vs V2:
- Revise fix to UART clock ID.
- Add documentation of build and test for BL33 usage case.
- Add device tree to store public key for FIT image verfication usage.
- Add revert patch to LCD support. Pico-pi does not boot with it.
I see it is suggested to be reverted in maillist.

Changes vs V1:
- Remove DCD file.
- Add a patch to fix uart clock root ID.
- Change file name from pico-pi-imx7d_bl33_defconfig to 
pico-imx7d_bl33_defconfig


Jun Nie (8):
  mx7_common: Share configs to skip low level init
  imx: mx7: Skip secure init in arch_cpu_init
  pico-imx7d: Correct uart clock root
  pico-imx7d: Reserve region of memory to OPTEE
  pico-imx7d: Add boot option for verified boot
  pico-imx7d: Add bl33 config
  pico-imx7d: README: Add BL33 usage case
  pico-imx7d: enable boot without PMIC

 arch/arm/include/asm/arch-mx7/clock.h  | 18 ++
 arch/arm/mach-imx/mx7/clock.c  |  2 +-
 arch/arm/mach-imx/mx7/soc.c| 43 +-
 board/technexion/pico-imx7d/README.pico-imx7d_BL33 | 44 +++
 board/technexion/pico-imx7d/pico-imx7d.c   | 12 +++-
 configs/pico-imx7d_bl33_defconfig  | 66 ++
 include/configs/mx7_common.h   | 11 
 include/configs/pico-imx7d.h   | 38 -
 include/configs/warp7.h| 11 
 9 files changed, 213 insertions(+), 32 deletions(-)
 create mode 100644 board/technexion/pico-imx7d/README.pico-imx7d_BL33
 create mode 100644 configs/pico-imx7d_bl33_defconfig

-- 
2.7.4

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


[U-Boot] [PATCH v4 1/8] mx7_common: Share configs to skip low level init

2019-05-07 Thread Jun Nie
Share configs in mx7 to skip low level init if we are in the case where
OPTEE is loaded already (maybe by ARM Trusted Firmware) and that most of
the low level initialization is already done and that we may/should skip
it doing them here.

Fix the definition detection with size detection to decide whether to skip
it.

Signed-off-by: Jun Nie 
---
 include/configs/mx7_common.h | 11 +++
 include/configs/warp7.h  | 11 ---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
index cc7e872..57fbec7 100644
--- a/include/configs/mx7_common.h
+++ b/include/configs/mx7_common.h
@@ -54,4 +54,15 @@
 #endif
 #endif
 
+/*
+ * If we have defined the OPTEE ram size and not OPTEE it means that we were
+ * launched by OPTEE, because of that we shall skip all the low level
+ * initialization since it was already done by ATF or OPTEE
+ */
+#if (CONFIG_OPTEE_TZDRAM_SIZE != 0)
+#ifndef CONFIG_OPTEE
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+#endif
+
 #endif
diff --git a/include/configs/warp7.h b/include/configs/warp7.h
index 37649cf..742f390 100644
--- a/include/configs/warp7.h
+++ b/include/configs/warp7.h
@@ -13,17 +13,6 @@
 
 #define PHYS_SDRAM_SIZESZ_512M
 
-/*
- * If we have defined the OPTEE ram size and not OPTEE it means that we were
- * launched by OPTEE, because of that we shall skip all the low level
- * initialization since it was already done by ATF or OPTEE
- */
-#ifdef CONFIG_OPTEE_TZDRAM_SIZE
-#ifndef CONFIG_OPTEE
-#define CONFIG_SKIP_LOWLEVEL_INIT
-#endif
-#endif
-
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN  (35 * SZ_1M)
 
-- 
2.7.4

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


[U-Boot] [PATCH v4 4/8] pico-imx7d: Reserve region of memory to OPTEE

2019-05-07 Thread Jun Nie
Subtracts CONFIG_OPTEE_TZDRAM_SIZE from the available DRAM size so that
the OPTEE memory is not override during u-boot relocation.

Note the OPTEE live in the end part of DRAM and OPTEE boot process will
itself subtract the DRAM region it lives in from the memory map passed
to Linux.

Signed-off-by: Jun Nie 
Reviewed-by: Peng Fan 
---
 board/technexion/pico-imx7d/pico-imx7d.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/board/technexion/pico-imx7d/pico-imx7d.c 
b/board/technexion/pico-imx7d/pico-imx7d.c
index e63b19d..5b357f2 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -63,6 +63,11 @@ int dram_init(void)
 {
gd->ram_size = imx_ddr_size();
 
+   /* Subtract the defined OPTEE runtime firmware length */
+#ifdef CONFIG_OPTEE_TZDRAM_SIZE
+   gd->ram_size -= CONFIG_OPTEE_TZDRAM_SIZE;
+#endif
+
return 0;
 }
 
-- 
2.7.4

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


  1   2   >