[U-Boot] [PATCH v6 13/16] cpu: Bind timer driver for boot hart

2019-02-08 Thread Anup Patel
From: Atish Patra 

Currently, timer driver is bound only for hart0.

There is no mandatory requirement that hart0 should always
come up. In fact, HiFive Unleashed SoC hart0 doesn't boot
in S-mode because it only has M-mode.

The timer driver should be bound for boot hart.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
Reviewed-by: Bin Meng 
---
 drivers/cpu/riscv_cpu.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c
index 5e15df590e..f77c126499 100644
--- a/drivers/cpu/riscv_cpu.c
+++ b/drivers/cpu/riscv_cpu.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)
 {
const char *isa;
@@ -62,7 +64,6 @@ static int riscv_cpu_bind(struct udevice *dev)
 
/* save the hart id */
plat->cpu_id = dev_read_addr(dev);
-
/* first examine the property in current cpu node */
ret = dev_read_u32(dev, "timebase-frequency", >timebase_freq);
/* if not found, then look at the parent /cpus node */
@@ -71,7 +72,7 @@ static int riscv_cpu_bind(struct udevice *dev)
 >timebase_freq);
 
/*
-* Bind riscv-timer driver on hart 0
+* Bind riscv-timer driver on boot hart.
 *
 * We only instantiate one timer device which is enough for U-Boot.
 * Pass the "timebase-frequency" value as the driver data for the
@@ -80,7 +81,7 @@ static int riscv_cpu_bind(struct udevice *dev)
 * Return value is not checked since it's possible that the timer
 * driver is not included.
 */
-   if (!plat->cpu_id && plat->timebase_freq) {
+   if (plat->cpu_id == gd->arch.boot_hart && plat->timebase_freq) {
drv = lists_driver_lookup_name("riscv_timer");
if (!drv) {
debug("Cannot find the timer driver, not included?\n");
-- 
2.17.1

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


[U-Boot] [PATCH v6 16/16] riscv: Enable CONFIG_SYS_BOOT_RAMDISK_HIGH for using initrd

2019-02-08 Thread Anup Patel
This patch enables CONFIG_SYS_BOOT_RAMDISK_HIGH for RISC-V
because bootm will update initrd location in DTB only if
CONFIG_SYS_BOOT_RAMDISK_HIGH is enabled. If we don't enable
this option then bootm assumes DTB already has initrd details
which is not the case most of the time.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
---
 arch/riscv/include/asm/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/asm/config.h b/arch/riscv/include/asm/config.h
index 81bc975d2e..156cb94dc0 100644
--- a/arch/riscv/include/asm/config.h
+++ b/arch/riscv/include/asm/config.h
@@ -8,5 +8,6 @@
 #define _ASM_CONFIG_H_
 
 #define CONFIG_LMB
+#define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
 #endif
-- 
2.17.1

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


[U-Boot] [PATCH v6 14/16] riscv: Add SiFive FU540 board support

2019-02-08 Thread Anup Patel
This patch adds SiFive FU540 board support. For now, only
SiFive serial, SiFive PRCI, and Cadance MACB drivers are
only enabled. The SiFive FU540 defconfig by default builds
U-Boot for S-Mode because U-Boot on SiFive FU540 will run
in S-Mode as payload of BBL or OpenSBI.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
Reviewed-by: Bin Meng 
---
 arch/riscv/Kconfig |  4 
 board/sifive/fu540/Kconfig | 42 +
 board/sifive/fu540/MAINTAINERS |  9 +++
 board/sifive/fu540/Makefile|  5 
 board/sifive/fu540/fu540.c | 17 ++
 configs/sifive_fu540_defconfig | 11 +
 include/configs/sifive-fu540.h | 43 ++
 7 files changed, 131 insertions(+)
 create mode 100644 board/sifive/fu540/Kconfig
 create mode 100644 board/sifive/fu540/MAINTAINERS
 create mode 100644 board/sifive/fu540/Makefile
 create mode 100644 board/sifive/fu540/fu540.c
 create mode 100644 configs/sifive_fu540_defconfig
 create mode 100644 include/configs/sifive-fu540.h

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 6879047ff7..36512a8995 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -14,11 +14,15 @@ config TARGET_AX25_AE350
 config TARGET_QEMU_VIRT
bool "Support QEMU Virt Board"
 
+config TARGET_SIFIVE_FU540
+   bool "Support SiFive FU540 Board"
+
 endchoice
 
 # board-specific options below
 source "board/AndesTech/ax25-ae350/Kconfig"
 source "board/emulation/qemu-riscv/Kconfig"
+source "board/sifive/fu540/Kconfig"
 
 # platform-specific options below
 source "arch/riscv/cpu/ax25/Kconfig"
diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig
new file mode 100644
index 00..6be3d88144
--- /dev/null
+++ b/board/sifive/fu540/Kconfig
@@ -0,0 +1,42 @@
+if TARGET_SIFIVE_FU540
+
+config SYS_BOARD
+   default "fu540"
+
+config SYS_VENDOR
+   default "sifive"
+
+config SYS_CPU
+   default "generic"
+
+config SYS_CONFIG_NAME
+   default "sifive-fu540"
+
+config SYS_TEXT_BASE
+   default 0x8000 if !RISCV_SMODE
+   default 0x8020 if RISCV_SMODE
+
+config BOARD_SPECIFIC_OPTIONS # dummy
+   def_bool y
+   select GENERIC_RISCV
+   imply CMD_DHCP
+   imply CMD_EXT2
+   imply CMD_EXT4
+   imply CMD_FAT
+   imply CMD_FS_GENERIC
+   imply CMD_NET
+   imply CMD_PING
+   imply CLK_SIFIVE
+   imply CLK_SIFIVE_FU540_PRCI
+   imply DOS_PARTITION
+   imply EFI_PARTITION
+   imply IP_DYN
+   imply ISO_PARTITION
+   imply MACB
+   imply MII
+   imply NET_RANDOM_ETHADDR
+   imply PHY_LIB
+   imply PHY_MSCC
+   imply SIFIVE_SERIAL
+
+endif
diff --git a/board/sifive/fu540/MAINTAINERS b/board/sifive/fu540/MAINTAINERS
new file mode 100644
index 00..702d803ad8
--- /dev/null
+++ b/board/sifive/fu540/MAINTAINERS
@@ -0,0 +1,9 @@
+SiFive FU540 BOARD
+M: Paul Walmsley 
+M: Palmer Dabbelt 
+M: Anup Patel 
+M: Atish Patra 
+S: Maintained
+F: board/sifive/fu540/
+F: include/configs/sifive-fu540.h
+F: configs/sifive_fu540_defconfig
diff --git a/board/sifive/fu540/Makefile b/board/sifive/fu540/Makefile
new file mode 100644
index 00..6e1862c475
--- /dev/null
+++ b/board/sifive/fu540/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2019 Western Digital Corporation or its affiliates.
+
+obj-y  += fu540.o
diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c
new file mode 100644
index 00..5adc4a3d4a
--- /dev/null
+++ b/board/sifive/fu540/fu540.c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel 
+ */
+
+#include 
+#include 
+
+int board_init(void)
+{
+   /* For now nothing to do here. */
+
+   return 0;
+}
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
new file mode 100644
index 00..2f8cca9de0
--- /dev/null
+++ b/configs/sifive_fu540_defconfig
@@ -0,0 +1,11 @@
+CONFIG_RISCV=y
+CONFIG_TARGET_SIFIVE_FU540=y
+CONFIG_RISCV_SMODE=y
+CONFIG_ARCH_RV64I=y
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_CMD_MII=y
+CONFIG_OF_PRIOR_STAGE=y
diff --git a/include/configs/sifive-fu540.h b/include/configs/sifive-fu540.h
new file mode 100644
index 00..7007b5f6af
--- /dev/null
+++ b/include/configs/sifive-fu540.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel 
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include 
+
+#define CONFIG_SYS_SDRAM_BASE  0x8000
+#define CONFIG_SYS_INIT_SP_ADDR(CONFIG_SYS_SDRAM_BASE + SZ_2M)
+
+#define CONFIG_SYS_LOAD_ADDR   

[U-Boot] [PATCH v6 12/16] drivers: serial_sifive: Skip baudrate config if no input clock

2019-02-08 Thread Anup Patel
From: Atish Patra 

It is possible that input clock is not available because clk
device was not available and 'clock-frequency' DT property is
also not available.

In this case, instead of failing we should just skip baudrate
config by returning zero.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
---
 drivers/serial/serial_sifive.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c
index ea4d35d48c..537bc7a975 100644
--- a/drivers/serial/serial_sifive.c
+++ b/drivers/serial/serial_sifive.c
@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs)
 
 static int sifive_serial_setbrg(struct udevice *dev, int baudrate)
 {
-   int err;
+   int ret;
struct clk clk;
struct sifive_uart_platdata *platdata = dev_get_platdata(dev);
+   u32 clock = 0;
 
-   err = clk_get_by_index(dev, 0, );
-   if (!err) {
-   err = clk_get_rate();
-   if (!IS_ERR_VALUE(err))
-   platdata->clock = err;
-   } else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS) {
+   ret = clk_get_by_index(dev, 0, );
+   if (IS_ERR_VALUE(ret)) {
debug("SiFive UART failed to get clock\n");
-   return err;
-   }
-
-   if (!platdata->clock)
-   platdata->clock = dev_read_u32_default(dev, "clock-frequency", 
0);
-   if (!platdata->clock) {
-   debug("SiFive UART clock not defined\n");
-   return -EINVAL;
+   ret = dev_read_u32(dev, "clock-frequency", );
+   if (IS_ERR_VALUE(ret)) {
+   debug("SiFive UART clock not defined\n");
+   return 0;
+   }
+   } else {
+   clock = clk_get_rate();
+   if (IS_ERR_VALUE(clock)) {
+   debug("SiFive UART clock get rate failed\n");
+   return 0;
+   }
}
-
+   platdata->clock = clock;
_sifive_serial_setbrg(platdata->regs, platdata->clock, baudrate);
 
return 0;
-- 
2.17.1

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


[U-Boot] [PATCH v6 10/16] clk: Add fixed-factor clock driver

2019-02-08 Thread Anup Patel
This patch adds fixed-factor clock driver which derives clock
rate by dividing (div) and multiplying (mult) fixed factors
to a parent clock.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
---
 arch/sandbox/dts/test.dts  |  8 
 drivers/clk/Makefile   |  4 +-
 drivers/clk/clk_fixed_factor.c | 72 ++
 test/dm/clk.c  |  5 ++-
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/clk_fixed_factor.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 1d011ded7c..cb8d686e46 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -203,6 +203,14 @@
#clock-cells = <0>;
clock-frequency = <1234>;
};
+
+   clk_fixed_factor: clk-fixed-factor {
+   compatible = "fixed-factor-clock";
+   #clock-cells = <0>;
+   clock-div = <3>;
+   clock-mult = <2>;
+   clocks = <_fixed>;
+   };
};
 
clk_sandbox: clk-sbox {
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 2f4446568c..fa59259ea3 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -4,7 +4,9 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 #
 
-obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o
+obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o
+obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o
 
 obj-y += imx/
 obj-y += tegra/
diff --git a/drivers/clk/clk_fixed_factor.c b/drivers/clk/clk_fixed_factor.c
new file mode 100644
index 00..3487c11729
--- /dev/null
+++ b/drivers/clk/clk_fixed_factor.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Author: Anup Patel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+struct clk_fixed_factor {
+   struct clk parent;
+   unsigned int div;
+   unsigned int mult;
+};
+
+#define to_clk_fixed_factor(dev)   \
+   ((struct clk_fixed_factor *)dev_get_platdata(dev))
+
+static ulong clk_fixed_factor_get_rate(struct clk *clk)
+{
+   uint64_t ret;
+   struct clk_fixed_factor *ff = to_clk_fixed_factor(clk->dev);
+
+   if (clk->id != 0)
+   return -EINVAL;
+
+   ret = clk_get_rate(>parent);
+   if (IS_ERR_VALUE(ret))
+   return ret;
+
+   do_div(ret, ff->div);
+
+   return ret * ff->mult;
+}
+
+const struct clk_ops clk_fixed_factor_ops = {
+   .get_rate = clk_fixed_factor_get_rate,
+};
+
+static int clk_fixed_factor_ofdata_to_platdata(struct udevice *dev)
+{
+   int err;
+   struct clk_fixed_factor *ff = to_clk_fixed_factor(dev);
+
+   err = clk_get_by_index(dev, 0, >parent);
+   if (err)
+   return err;
+
+   ff->div = dev_read_u32_default(dev, "clock-div", 1);
+   ff->mult = dev_read_u32_default(dev, "clock-mult", 1);
+
+   return 0;
+}
+
+static const struct udevice_id clk_fixed_factor_match[] = {
+   {
+   .compatible = "fixed-factor-clock",
+   },
+   { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(clk_fixed_factor) = {
+   .name = "fixed_factor_clock",
+   .id = UCLASS_CLK,
+   .of_match = clk_fixed_factor_match,
+   .ofdata_to_platdata = clk_fixed_factor_ofdata_to_platdata,
+   .platdata_auto_alloc_size = sizeof(struct clk_fixed_factor),
+   .ops = _fixed_factor_ops,
+};
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 898c034e27..112d5cbbc9 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -12,12 +12,15 @@
 
 static int dm_test_clk(struct unit_test_state *uts)
 {
-   struct udevice *dev_fixed, *dev_clk, *dev_test;
+   struct udevice *dev_fixed, *dev_fixed_factor, *dev_clk, *dev_test;
ulong rate;
 
ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-fixed",
  _fixed));
 
+   ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-fixed-factor",
+ _fixed_factor));
+
ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
  _clk));
ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
-- 
2.17.1

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


[U-Boot] [PATCH v6 15/16] doc: Add a readme guide for SiFive FU540

2019-02-08 Thread Anup Patel
From: Atish Patra 

The readme guide describes the procedure to build, flash and boot Linux
using U-boot on HiFive Unleashed. It also explains the current state of
U-boot support and future action items.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
---
 doc/README.sifive-fu540 | 302 
 1 file changed, 302 insertions(+)
 create mode 100644 doc/README.sifive-fu540

diff --git a/doc/README.sifive-fu540 b/doc/README.sifive-fu540
new file mode 100644
index 00..b19ca2af04
--- /dev/null
+++ b/doc/README.sifive-fu540
@@ -0,0 +1,302 @@
+FU540-C000 RISC-V SoC
+=
+The FU540-C000 is the world’s first 4+1 64-bit RISC‑V SoC from SiFive.
+
+The HiFive Unleashed development platform is based on FU540-C000 and capable
+of running Linux.
+
+Mainline support
+
+The support for following drivers are already enabled:
+1. SiFive UART Driver.
+2. SiFive PRCI Driver for clock.
+3. Cadence MACB ethernet driver for networking support.
+
+TODO:
+1. SPI driver is still missing. So MMC card can't be used in U-Boot as of now.
+2. U-Boot expects the serial console device entry to be present under /chosen
+   DT node. Example:
+   chosen {
+stdout-path = "/soc/serial@1001:115200";
+   };
+
+   Without the above DT entry, U-Boot will not find serial console device and
+   nothing will be printed in console.
+
+Building
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation enviornment variable.
+   a. export ARCH=riscv
+   b. export CROSS_COMPILE=
+3. make sifive_fu540_defconfig
+4. make
+
+Flashing
+
+The current U-Boot port is supported in S-mode only and loaded from DRAM.
+
+A prior stage (M-mode) firmware/bootloader (e.g OpenSBI or BBL) is required to
+load the u-boot.bin into memory and provide runtime services. The u-boot.bin
+can be given as a payload to the prior stage (M-mode) firmware/bootloader.
+
+The description of steps required to build the firmware is beyond the scope of
+this document. Please refer OpenSBI or BBL documenation.
+
+Once the prior stage firmware/bootloader binary is generated, it should be
+copied to the first partition of the sdcard.
+
+sudo dd if= of=/dev/disk2s1 bs=1024
+
+Booting
+===
+Once you plugin the sdcard and power up, you should see the U-Boot prompt.
+
+Sample boot log from HiFive Unleashed board
+===
+U-Boot 2019.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+CPU:   rv64imafdc
+Model: sifive,hifive-unleashed-a00
+DRAM:  8 GiB
+In:serial@1001
+Out:   serial@1001
+Err:   serial@1001
+Net:
+Warning: ethernet@1009 (eth0) using random MAC address - b6:75:4d:48:50:94
+eth0: ethernet@1009
+Hit any key to stop autoboot:  0
+=> version
+U-Boot 2019.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+riscv64-linux-gcc.br_real (Buildroot 2018.11-rc2-3-ga0787e9) 8.2.0
+GNU ld (GNU Binutils) 2.31.1
+=>
+===
+
+Now you can configure your networking, tftp server and use tftp boot method to
+load uImage.
+
+==
+=> setenv ethaddr 70:B3:D5:92:F0:C2
+=> setenv ipaddr 10.196.157.189
+=> setenv serverip 10.11.143.218
+=> setenv gatewayip 10.196.156.1
+=> setenv netmask 255.255.252.0
+=> bdinfo
+boot_params = 0x
+DRAM bank   = 0x
+-> start= 0x8000
+-> size = 0x0002
+relocaddr   = 0xfff9
+reloc off   = 0x7fd9
+ethaddr = 70:B3:D5:92:F0:C2
+IP addr = 10.196.157.189
+baudrate= 115200 bps
+=> tftpboot uImage
+ethernet@1009: PHY present at 0
+ethernet@1009: Starting autonegotiation...
+ethernet@1009: Autonegotiation complete
+ethernet@1009: link up, 1000Mbps full-duplex (lpa: 0x3800)
+Using ethernet@1009 device
+TFTP from server 10.11.143.218; our IP address is 10.196.157.189; sending 
through gateway 10.196.156.1
+Filename 'uImage'.
+Load address: 0x8020
+Loading: #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ #
+ 

[U-Boot] [PATCH v6 08/16] net: macb: Fix GEM hardware detection

2019-02-08 Thread Anup Patel
From: Atish Patra 

Fix MID bit field check to correctly identify all GEM hardwares.

The check is updated as per macb driver in Linux location:
/drivers/net/ethernet/cadence/macb_main.c:259

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
Acked-by: Joe Hershberger 
---
 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index a5d21731b6..117f54c1b1 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -143,7 +143,7 @@ struct macb_device {
 
 static int macb_is_gem(struct macb_device *macb)
 {
-   return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) == 0x2;
+   return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) >= 0x2;
 }
 
 #ifndef cpu_is_sama5d2
-- 
2.17.1

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


[U-Boot] [PATCH v6 11/16] drivers: serial_sifive: Fix baud rate calculation

2019-02-08 Thread Anup Patel
From: Atish Patra 

Compute the baud rate multipler with more precision.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
---
 drivers/serial/serial_sifive.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_sifive.c b/drivers/serial/serial_sifive.c
index 341728a690..ea4d35d48c 100644
--- a/drivers/serial/serial_sifive.c
+++ b/drivers/serial/serial_sifive.c
@@ -33,16 +33,40 @@ struct uart_sifive {
 };
 
 struct sifive_uart_platdata {
-   unsigned int clock;
+   unsigned long clock;
int saved_input_char;
struct uart_sifive *regs;
 };
 
+/**
+ * Find minimum divisor divides in_freq to max_target_hz;
+ * Based on uart driver n SiFive FSBL.
+ *
+ * f_baud = f_in / (div + 1) => div = (f_in / f_baud) - 1
+ * The nearest integer solution requires rounding up as to not exceed
+ * max_target_hz.
+ * div  = ceil(f_in / f_baud) - 1
+ * = floor((f_in - 1 + f_baud) / f_baud) - 1
+ * This should not overflow as long as (f_in - 1 + f_baud) does not exceed
+ * 2^32 - 1, which is unlikely since we represent frequencies in kHz.
+ */
+static inline unsigned int uart_min_clk_divisor(unsigned long in_freq,
+   unsigned long max_target_hz)
+{
+   unsigned long quotient =
+   (in_freq + max_target_hz - 1) / (max_target_hz);
+   /* Avoid underflow */
+   if (quotient == 0)
+   return 0;
+   else
+   return quotient - 1;
+}
+
 /* Set up the baud rate in gd struct */
 static void _sifive_serial_setbrg(struct uart_sifive *regs,
  unsigned long clock, unsigned long baud)
 {
-   writel((u32)((clock / baud) - 1), >div);
+   writel((uart_min_clk_divisor(clock, baud)), >div);
 }
 
 static void _sifive_serial_init(struct uart_sifive *regs)
-- 
2.17.1

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


[U-Boot] [PATCH v6 09/16] clk: Add SiFive FU540 PRCI clock driver

2019-02-08 Thread Anup Patel
Add driver code for the SiFive FU540 PRCI IP block.  This IP block
handles reset and clock control for the SiFive FU540 device and
implements SoC-level clock tree controls and dividers.

Based on code written by Wesley Terpstra 
found in commit 999529edf517ed75b56659d456d221b2ee56bb60 of:
https://github.com/riscv/riscv-linux

Boot and PLL rate change were tested on a SiFive HiFive Unleashed
board.

Signed-off-by: Paul Walmsley 
Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
---
 drivers/clk/Kconfig   |   1 +
 drivers/clk/Makefile  |   1 +
 drivers/clk/sifive/Kconfig|  19 +
 drivers/clk/sifive/Makefile   |   5 +
 .../clk/sifive/analogbits-wrpll-cln28hpc.h| 101 +++
 drivers/clk/sifive/fu540-prci.c   | 604 ++
 drivers/clk/sifive/wrpll-cln28hpc.c   | 390 +++
 include/dt-bindings/clk/sifive-fu540-prci.h   |  29 +
 8 files changed, 1150 insertions(+)
 create mode 100644 drivers/clk/sifive/Kconfig
 create mode 100644 drivers/clk/sifive/Makefile
 create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h
 create mode 100644 drivers/clk/sifive/fu540-prci.c
 create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c
 create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.h

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index eadf7f8250..ce462f5717 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
 source "drivers/clk/renesas/Kconfig"
+source "drivers/clk/sifive/Kconfig"
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/uniphier/Kconfig"
 
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 9acbb1a650..2f4446568c 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o
 obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o
 obj-$(CONFIG_CLK_OWL) += owl/
 obj-$(CONFIG_CLK_RENESAS) += renesas/
+obj-$(CONFIG_CLK_SIFIVE) += sifive/
 obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
 obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o
 obj-$(CONFIG_CLK_UNIPHIER) += uniphier/
diff --git a/drivers/clk/sifive/Kconfig b/drivers/clk/sifive/Kconfig
new file mode 100644
index 00..81fc9f8fda
--- /dev/null
+++ b/drivers/clk/sifive/Kconfig
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config CLK_ANALOGBITS_WRPLL_CLN28HPC
+   bool
+
+config CLK_SIFIVE
+   bool "SiFive SoC driver support"
+   depends on CLK
+   help
+ SoC drivers for SiFive Linux-capable SoCs.
+
+config CLK_SIFIVE_FU540_PRCI
+   bool "PRCI driver for SiFive FU540 SoCs"
+   depends on CLK_SIFIVE
+   select CLK_ANALOGBITS_WRPLL_CLN28HPC
+   help
+ Supports the Power Reset Clock interface (PRCI) IP block found in
+ FU540 SoCs.  If this kernel is meant to run on a SiFive FU540 SoC,
+ enable this driver.
diff --git a/drivers/clk/sifive/Makefile b/drivers/clk/sifive/Makefile
new file mode 100644
index 00..1155e07e37
--- /dev/null
+++ b/drivers/clk/sifive/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_CLK_ANALOGBITS_WRPLL_CLN28HPC)+= wrpll-cln28hpc.o
+
+obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI)+= fu540-prci.o
diff --git a/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h 
b/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h
new file mode 100644
index 00..4432e24749
--- /dev/null
+++ b/drivers/clk/sifive/analogbits-wrpll-cln28hpc.h
@@ -0,0 +1,101 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Copyright (C) 2018 SiFive, Inc.
+ * Wesley Terpstra
+ * Paul Walmsley
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program 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.
+ */
+
+#ifndef __LINUX_CLK_ANALOGBITS_WRPLL_CLN28HPC_H
+#define __LINUX_CLK_ANALOGBITS_WRPLL_CLN28HPC_H
+
+#include 
+
+/* DIVQ_VALUES: number of valid DIVQ values */
+#define DIVQ_VALUES6
+
+/*
+ * Bit definitions for struct analogbits_wrpll_cfg.flags
+ *
+ * WRPLL_FLAGS_BYPASS_FLAG: if set, the PLL is either in bypass, or should be
+ * programmed to enter bypass
+ * WRPLL_FLAGS_RESET_FLAG: if set, the PLL is in reset
+ * WRPLL_FLAGS_INT_FEEDBACK_FLAG: if set, the PLL is configured for internal
+ * feedback mode
+ * WRPLL_FLAGS_EXT_FEEDBACK_FLAG: if set, the PLL is configured for external
+ * feedback mode (not yet supported by this driver)
+ *
+ * The flags 

[U-Boot] [PATCH v6 07/16] net: macb: Fix clk API usage for RISC-V systems

2019-02-08 Thread Anup Patel
Don't fail in macb_enable_clk() if clk_enable() returns
-ENOSYS because we get -ENOSYS for fixed-rate clocks.

Signed-off-by: Anup Patel 
Reviewed-by: Bin Meng 
---
 drivers/net/macb.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 94c89c762b..a5d21731b6 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1061,14 +1061,13 @@ static int macb_enable_clk(struct udevice *dev)
return -EINVAL;
 
/*
-* Zynq clock driver didn't support for enable or disable
-* clock. Hence, clk_enable() didn't apply for Zynq
+* If clock driver didn't support enable or disable then
+* we get -ENOSYS from clk_enable(). To handle this, we
+* don't fail for ret == -ENOSYS.
 */
-#ifndef CONFIG_MACB_ZYNQ
ret = clk_enable();
-   if (ret)
+   if (ret && ret != -ENOSYS)
return ret;
-#endif
 
clk_rate = clk_get_rate();
if (!clk_rate)
-- 
2.17.1

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


[U-Boot] [PATCH v6 04/16] riscv: Add asm/dma-mapping.h for DMA mappings

2019-02-08 Thread Anup Patel
This patch adds asm/dma-mapping.h for Linux-like DMA mappings
APIs required by some of the drivers (such as, Cadance MACB
Ethernet driver).

Signed-off-by: Anup Patel 
Reviewed-by: Bin Meng 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
---
 arch/riscv/include/asm/dma-mapping.h | 38 
 1 file changed, 38 insertions(+)
 create mode 100644 arch/riscv/include/asm/dma-mapping.h

diff --git a/arch/riscv/include/asm/dma-mapping.h 
b/arch/riscv/include/asm/dma-mapping.h
new file mode 100644
index 00..3d930c90ec
--- /dev/null
+++ b/arch/riscv/include/asm/dma-mapping.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel 
+ */
+
+#ifndef __ASM_RISCV_DMA_MAPPING_H
+#define __ASM_RISCV_DMA_MAPPING_H
+
+#include 
+
+#define dma_mapping_error(x, y)0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+   *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+   return (void *)*handle;
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+   free(addr);
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+  enum dma_data_direction dir)
+{
+   return (unsigned long)vaddr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+   unsigned long paddr)
+{
+}
+
+#endif /* __ASM_RISCV_DMA_MAPPING_H */
-- 
2.17.1

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


[U-Boot] [PATCH v6 06/16] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems

2019-02-08 Thread Anup Patel
On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot
DMA mapping APIs will generate DMA addresses beyond 4GB. This
breaks DMA programming in 32bit DMA capable devices (such as
Cadence MACB ethernet). For example, If DRAM is more then 2GB
on QEMU sifive_u machine then Cadence MACB ethernet stops working
for U-Boot because it is a 32bit DMA capable device.

To handle 32bit DMA capable devices on 64bit systems, we provide
custom implementation of board_get_usable_ram_top() which ensures
that usable ram top is not more then 4GB. This in-turn ensures
that U-Boot always runs within 4GB hence DMA addresses generated
by DMA mapping APIs will be within 4GB too.

Signed-off-by: Atish Patra 
Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
Reviewed-by: Bin Meng 
---
 arch/riscv/cpu/generic/dram.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
index 84d87d2a7f..b7b1207235 100644
--- a/arch/riscv/cpu/generic/dram.c
+++ b/arch/riscv/cpu/generic/dram.c
@@ -5,6 +5,9 @@
 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
@@ -15,3 +18,20 @@ int dram_init_banksize(void)
 {
return fdtdec_setup_memory_banksize();
 }
+
+ulong board_get_usable_ram_top(ulong total_size)
+{
+#ifdef CONFIG_64BIT
+   /*
+* Ensure that we run from first 4GB so that all
+* addresses used by U-Boot are 32bit addresses.
+*
+* This in-turn ensures that 32bit DMA capable
+* devices work fine because DMA mapping APIs will
+* provide 32bit DMA addresses only.
+*/
+   if (gd->ram_top > SZ_4G)
+   return SZ_4G;
+#endif
+   return gd->ram_top;
+}
-- 
2.17.1

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


[U-Boot] [PATCH v6 05/16] riscv: Add place-holder asm/arch/clk.h for driver compilation

2019-02-08 Thread Anup Patel
Some of the drivers expect asm/arch/clk.h to be provided by
arch support code so we add place-holder asm/arch/clk.h for
RISC-V support.

Signed-off-by: Anup Patel 
---
 arch/riscv/include/asm/arch/clk.h | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 arch/riscv/include/asm/arch/clk.h

diff --git a/arch/riscv/include/asm/arch/clk.h 
b/arch/riscv/include/asm/arch/clk.h
new file mode 100644
index 00..1631f5f0bd
--- /dev/null
+++ b/arch/riscv/include/asm/arch/clk.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel 
+ */
+
+#ifndef __ASM_RISCV_ARCH_CLK_H
+#define __ASM_RISCV_ARCH_CLK_H
+
+/* Note: This is a placeholder header for driver compilation. */
+
+#endif
-- 
2.17.1

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


[U-Boot] [PATCH v6 03/16] riscv: Rename cpu/qemu to cpu/generic

2019-02-08 Thread Anup Patel
The QEMU CPU support under arch/riscv is pretty much generic
and works fine for SiFive Unleashed as well. In fact, there
will be quite a few RISC-V SOCs for which QEMU CPU support
will work fine.

This patch renames cpu/qemu to cpu/generic to indicate the
above fact. If there are SOC specific errata workarounds
required in cpu/generic then those can be done at runtime
in cpu/generic based on CPU vendor specific DT compatible
string.

Signed-off-by: Anup Patel 
Reviewed-by: Alexander Graf 
Reviewed-by: Lukas Auer 
Reviewed-by: Bin Meng 
---
 arch/riscv/Kconfig| 2 +-
 arch/riscv/cpu/{qemu => generic}/Kconfig  | 2 +-
 arch/riscv/cpu/{qemu => generic}/Makefile | 0
 arch/riscv/cpu/{qemu => generic}/cpu.c| 0
 arch/riscv/cpu/{qemu => generic}/dram.c   | 0
 board/emulation/qemu-riscv/Kconfig| 4 ++--
 6 files changed, 4 insertions(+), 4 deletions(-)
 rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
 rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
 rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
 rename arch/riscv/cpu/{qemu => generic}/dram.c (100%)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index c45e4d73a8..6879047ff7 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -22,7 +22,7 @@ source "board/emulation/qemu-riscv/Kconfig"
 
 # platform-specific options below
 source "arch/riscv/cpu/ax25/Kconfig"
-source "arch/riscv/cpu/qemu/Kconfig"
+source "arch/riscv/cpu/generic/Kconfig"
 
 # architecture-specific options below
 
diff --git a/arch/riscv/cpu/qemu/Kconfig b/arch/riscv/cpu/generic/Kconfig
similarity index 91%
rename from arch/riscv/cpu/qemu/Kconfig
rename to arch/riscv/cpu/generic/Kconfig
index f48751e6de..1d6ab5032d 100644
--- a/arch/riscv/cpu/qemu/Kconfig
+++ b/arch/riscv/cpu/generic/Kconfig
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2018, Bin Meng 
 
-config QEMU_RISCV
+config GENERIC_RISCV
bool
select ARCH_EARLY_INIT_R
imply CPU
diff --git a/arch/riscv/cpu/qemu/Makefile b/arch/riscv/cpu/generic/Makefile
similarity index 100%
rename from arch/riscv/cpu/qemu/Makefile
rename to arch/riscv/cpu/generic/Makefile
diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/generic/cpu.c
similarity index 100%
rename from arch/riscv/cpu/qemu/cpu.c
rename to arch/riscv/cpu/generic/cpu.c
diff --git a/arch/riscv/cpu/qemu/dram.c b/arch/riscv/cpu/generic/dram.c
similarity index 100%
rename from arch/riscv/cpu/qemu/dram.c
rename to arch/riscv/cpu/generic/dram.c
diff --git a/board/emulation/qemu-riscv/Kconfig 
b/board/emulation/qemu-riscv/Kconfig
index 0d865acf10..88d07d568e 100644
--- a/board/emulation/qemu-riscv/Kconfig
+++ b/board/emulation/qemu-riscv/Kconfig
@@ -7,7 +7,7 @@ config SYS_VENDOR
default "emulation"
 
 config SYS_CPU
-   default "qemu"
+   default "generic"
 
 config SYS_CONFIG_NAME
default "qemu-riscv"
@@ -18,7 +18,7 @@ config SYS_TEXT_BASE
 
 config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
-   select QEMU_RISCV
+   select GENERIC_RISCV
imply SYS_NS16550
imply VIRTIO_MMIO
imply VIRTIO_NET
-- 
2.17.1

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


[U-Boot] [PATCH v6 02/16] Makefile: Fix mrproper make target

2019-02-08 Thread Anup Patel
Currently, the mrproper make target tries to force remove all
"arch/*/include/asm/arch" paths assuming they are symlinks but
this prevents us from adding place-holder headers under the
arch/riscv/include/asm/arch directory.

To solve this, we fix mrproper make target to only remove
"arch/*/include/asm/arch" paths which are symlinks and do
nothing for paths which are directory.

Signed-off-by: Anup Patel 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index cf7b2b10bc..2d05b8da9a 100644
--- a/Makefile
+++ b/Makefile
@@ -1782,7 +1782,7 @@ $(mrproper-dirs):
 mrproper: clean $(mrproper-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles)
-   @rm -f arch/*/include/asm/arch
+   @for d in `dirname arch/*/include/asm/arch`; do if [ -L $$d/arch ]; 
then echo "  CLEAN   "$$d/arch; rm -f $$d/arch; fi; done
 
 # distclean
 #
-- 
2.17.1

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


[U-Boot] [PATCH v6 00/16] SiFive FU540 Support

2019-02-08 Thread Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support
to RISC-V U-Boot.

The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id
91882c472d8c0aef4db699d3f2de55bf43d4ae4b

All drivers namely: SiFive PRCI, SiFive Serial, and Cadance
MACB Ethernet work fine on actual SiFive Unleashed board and
QEMU sifive_u machine.

Changes since v5:
 - Added PATCH16 to fix INITRD passing to Linux using bootm
   for U-Boot RISC-V

Changes since v4:
 - Removed #ifndef from macb_enable_clk() in PATCH7
 - Updated test/dm/clk.c in PATCH10 to test fixed factor clock
   using sandbox

Changes since v3:
 - Added patch to un-ignore arch/riscv/include/asm/arch
 - Added patch to fix mrproper make target to only remove
   arch/*/include/asm/arch paths which are symlinks
 - Added patch to have place-holder asm/arch/clk.h for RISC-V
 - Removed "#ifndef CONFIG_RISCV" from macb clk API patch

Changes since v2:
 - Fixed typo in PATCH3 comments
 - Removed "#if" from clk_fixed_factor_ofdata_to_platdata() in PATCH7
 - Added PATCH12 for SiFive FU540 README guide

Changes since v1:
 - Re-ordered SoB in patches with multiple SoB
 - Simplified board_get_usable_ram_top() added by PATCH3

Anup Patel (11):
  .gitignore: Don't ignore arch/riscv/include/asm/arch
  Makefile: Fix mrproper make target
  riscv: Rename cpu/qemu to cpu/generic
  riscv: Add asm/dma-mapping.h for DMA mappings
  riscv: Add place-holder asm/arch/clk.h for driver compilation
  riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
  net: macb: Fix clk API usage for RISC-V systems
  clk: Add SiFive FU540 PRCI clock driver
  clk: Add fixed-factor clock driver
  riscv: Add SiFive FU540 board support
  riscv: Enable CONFIG_SYS_BOOT_RAMDISK_HIGH for using initrd

Atish Patra (5):
  net: macb: Fix GEM hardware detection
  drivers: serial_sifive: Fix baud rate calculation
  drivers: serial_sifive: Skip baudrate config if no input clock
  cpu: Bind timer driver for boot hart
  doc: Add a readme guide for SiFive FU540

 Makefile  |   2 +-
 arch/.gitignore   |   1 +
 arch/riscv/Kconfig|   6 +-
 arch/riscv/cpu/{qemu => generic}/Kconfig  |   2 +-
 arch/riscv/cpu/{qemu => generic}/Makefile |   0
 arch/riscv/cpu/{qemu => generic}/cpu.c|   0
 arch/riscv/cpu/generic/dram.c |  37 ++
 arch/riscv/cpu/qemu/dram.c|  17 -
 arch/riscv/include/asm/arch/clk.h |  14 +
 arch/riscv/include/asm/config.h   |   1 +
 arch/riscv/include/asm/dma-mapping.h  |  38 ++
 arch/sandbox/dts/test.dts |   8 +
 board/emulation/qemu-riscv/Kconfig|   4 +-
 .../qemu-riscv => sifive/fu540}/Kconfig   |  36 +-
 board/sifive/fu540/MAINTAINERS|   9 +
 board/sifive/fu540/Makefile   |   5 +
 board/sifive/fu540/fu540.c|  17 +
 configs/sifive_fu540_defconfig|  11 +
 doc/README.sifive-fu540   | 302 +
 drivers/clk/Kconfig   |   1 +
 drivers/clk/Makefile  |   5 +-
 drivers/clk/clk_fixed_factor.c|  72 +++
 drivers/clk/sifive/Kconfig|  19 +
 drivers/clk/sifive/Makefile   |   5 +
 .../clk/sifive/analogbits-wrpll-cln28hpc.h| 101 +++
 drivers/clk/sifive/fu540-prci.c   | 604 ++
 drivers/clk/sifive/wrpll-cln28hpc.c   | 390 +++
 drivers/cpu/riscv_cpu.c   |   7 +-
 drivers/net/macb.c|  11 +-
 drivers/serial/serial_sifive.c|  60 +-
 include/configs/sifive-fu540.h|  43 ++
 include/dt-bindings/clk/sifive-fu540-prci.h   |  29 +
 test/dm/clk.c |   5 +-
 33 files changed, 1795 insertions(+), 67 deletions(-)
 rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
 rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
 rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
 create mode 100644 arch/riscv/cpu/generic/dram.c
 delete mode 100644 arch/riscv/cpu/qemu/dram.c
 create mode 100644 arch/riscv/include/asm/arch/clk.h
 create mode 100644 arch/riscv/include/asm/dma-mapping.h
 copy board/{emulation/qemu-riscv => sifive/fu540}/Kconfig (57%)
 create mode 100644 board/sifive/fu540/MAINTAINERS
 create mode 100644 board/sifive/fu540/Makefile
 create mode 100644 board/sifive/fu540/fu540.c
 create mode 100644 configs/sifive_fu540_defconfig
 create mode 100644 doc/README.sifive-fu540
 create mode 100644 drivers/clk/clk_fixed_factor.c
 create mode 100644 drivers/clk/sifive/Kconfig
 create mode 100644 drivers/clk/sifive/Makefile
 create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h
 create mode 100644 drivers/clk/sifive/fu540-prci.c
 create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c
 create mode 100644 

[U-Boot] [PATCH v6 01/16] .gitignore: Don't ignore arch/riscv/include/asm/arch

2019-02-08 Thread Anup Patel
We will be adding place-holder headers under include/asm/arch
for RISC-V so this patch updates .gitignore to not consider
files under arch/riscv/include/asm/arch

Signed-off-by: Anup Patel 
---
 arch/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/.gitignore b/arch/.gitignore
index 2714b86ff3..f75a0ace2d 100644
--- a/arch/.gitignore
+++ b/arch/.gitignore
@@ -1 +1,2 @@
 /*/include/asm/arch
+!/riscv/include/asm/arch
-- 
2.17.1

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


Re: [U-Boot] [PATCH v5 00/15] SiFive FU540 Support

2019-02-08 Thread Anup Patel


> -Original Message-
> From: Anup Patel
> Sent: Tuesday, February 5, 2019 6:34 PM
> To: Rick Chen ; Bin Meng ;
> Joe Hershberger ; Michal Simek
> ; Michal Simek ; Lukas Auer
> ; Masahiro Yamada
> ; Simon Glass 
> Cc: Alexander Graf ; Palmer Dabbelt ;
> Paul Walmsley ; Atish Patra
> ; Anup Patel ; Christoph
> Hellwig ; U-Boot Mailing List 
> Subject: [PATCH v5 00/15] SiFive FU540 Support
> 
> This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-
> Boot.
> 
> The patches are based upon latest RISC-V U-Boot tree
> (git://git.denx.de/u-boot-riscv.git) at commit id
> 91882c472d8c0aef4db699d3f2de55bf43d4ae4b
> 
> All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet
> work fine on actual SiFive Unleashed board and QEMU sifive_u machine.
> 
> Changes since v4:
>  - Removed #ifndef from macb_enable_clk() in PATCH7
>  - Updated test/dm/clk.c in PATCH10 to test fixed factor clock
>using sandbox
> 
> Changes since v3:
>  - Added patch to un-ignore arch/riscv/include/asm/arch
>  - Added patch to fix mrproper make target to only remove
>arch/*/include/asm/arch paths which are symlinks
>  - Added patch to have place-holder asm/arch/clk.h for RISC-V
>  - Removed "#ifndef CONFIG_RISCV" from macb clk API patch
> 
> Changes since v2:
>  - Fixed typo in PATCH3 comments
>  - Removed "#if" from clk_fixed_factor_ofdata_to_platdata() in PATCH7
>  - Added PATCH12 for SiFive FU540 README guide
> 
> Changes since v1:
>  - Re-ordered SoB in patches with multiple SoB
>  - Simplified board_get_usable_ram_top() added by PATCH3
> 
> Anup Patel (10):
>   .gitignore: Don't ignore arch/riscv/include/asm/arch
>   Makefile: Fix mrproper make target
>   riscv: Rename cpu/qemu to cpu/generic
>   riscv: Add asm/dma-mapping.h for DMA mappings
>   riscv: Add place-holder asm/arch/clk.h for driver compilation
>   riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
>   net: macb: Fix clk API usage for RISC-V systems
>   clk: Add SiFive FU540 PRCI clock driver
>   clk: Add fixed-factor clock driver
>   riscv: Add SiFive FU540 board support
> 
> Atish Patra (5):
>   net: macb: Fix GEM hardware detection
>   drivers: serial_sifive: Fix baud rate calculation
>   drivers: serial_sifive: Skip baudrate config if no input clock
>   cpu: Bind timer driver for boot hart
>   doc: Add a readme guide for SiFive FU540
> 
>  Makefile  |   2 +-
>  arch/.gitignore   |   1 +
>  arch/riscv/Kconfig|   6 +-
>  arch/riscv/cpu/{qemu => generic}/Kconfig  |   2 +-
>  arch/riscv/cpu/{qemu => generic}/Makefile |   0
>  arch/riscv/cpu/{qemu => generic}/cpu.c|   0
>  arch/riscv/cpu/generic/dram.c |  37 ++
>  arch/riscv/cpu/qemu/dram.c|  17 -
>  arch/riscv/include/asm/arch/clk.h |  14 +
>  arch/riscv/include/asm/dma-mapping.h  |  38 ++
>  arch/sandbox/dts/test.dts |   8 +
>  board/emulation/qemu-riscv/Kconfig|   4 +-
>  .../qemu-riscv => sifive/fu540}/Kconfig   |  36 +-
>  board/sifive/fu540/MAINTAINERS|   9 +
>  board/sifive/fu540/Makefile   |   5 +
>  board/sifive/fu540/fu540.c|  17 +
>  configs/sifive_fu540_defconfig|  11 +
>  doc/README.sifive-fu540   | 302 +
>  drivers/clk/Kconfig   |   1 +
>  drivers/clk/Makefile  |   5 +-
>  drivers/clk/clk_fixed_factor.c|  72 +++
>  drivers/clk/sifive/Kconfig|  19 +
>  drivers/clk/sifive/Makefile   |   5 +
>  .../clk/sifive/analogbits-wrpll-cln28hpc.h| 101 +++
>  drivers/clk/sifive/fu540-prci.c   | 604 ++
>  drivers/clk/sifive/wrpll-cln28hpc.c   | 390 +++
>  drivers/cpu/riscv_cpu.c   |   7 +-
>  drivers/net/macb.c|  11 +-
>  drivers/serial/serial_sifive.c|  60 +-
>  include/configs/sifive-fu540.h|  43 ++
>  include/dt-bindings/clk/sifive-fu540-prci.h   |  29 +
>  test/dm/clk.c |   5 +-
>  32 files changed, 1794 insertions(+), 67 deletions(-)  rename
> arch/riscv/cpu/{qemu => generic}/Kconfig (91%)  rename
> arch/riscv/cpu/{qemu => generic}/Makefile (100%)  rename
> arch/riscv/cpu/{qemu => generic}/cpu.c (100%)  create mode 100644
> arch/riscv/cpu/generic/dram.c  delete mode 100644
> arch/riscv/cpu/qemu/dram.c  create mode 100644
> arch/riscv/include/asm/arch/clk.h  create mode 100644
> arch/riscv/include/asm/dma-mapping.h
>  copy board/{emulation/qemu-riscv => sifive/fu540}/Kconfig (57%)  create
> mode 100644 board/sifive/fu540/MAINTAINERS  create mode 100644
> board/sifive/fu540/Makefile  create mode 100644 board/sifive/fu540/fu540.c
> create mode 100644 configs/sifive_fu540_defconfig  create mode 100644
> 

Re: [U-Boot] [PULL] u-boot-sh/master

2019-02-08 Thread Tom Rini
On Fri, Feb 08, 2019 at 11:19:46AM +0100, Marek Vasut wrote:

> SD/MMC and filesystem fixes below ...
> 
> The following changes since commit e5fd39c886485e3dec77f4438a6e364c2987cf5f:
> 
>   Merge tag 'for-master-20190201' of git://git.denx.de/u-boot-rockchip
> (2019-02-02 10:11:20 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sh.git master
> 
> for you to fetch changes up to 49f331023e1d6f804c4226b862af1f2a05a2ea2e:
> 
>   fs: ext4: Unmount FS in do_fs_type() (2019-02-06 14:07:12 +0100)
> 

NAK.  The change:
commit 09a89b86d48a19598750f05f69412ec9ddbefba4
Author: Marek Vasut 
Date:   Tue Jan 29 04:45:51 2019 +0100

mmc: Export {sd,mmc}_select_mode_and_width()

breaks pine_h64 as SPL now overflows sram by 104 bytes.

-- 
Tom


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


Re: [U-Boot] [U-Boot, 2/3] net: add higmacv300 Ethernet driver for HiSilicon platform

2019-02-08 Thread Tom Rini
On Mon, Jan 28, 2019 at 05:13:55PM +0800, Shawn Guo wrote:

> It adds the driver for HIGMACV300 Ethernet controller found on HiSilicon
> SoCs like Hi3798CV200.  It's based on a downstream U-Boot driver, but
> quite a lot of code gets rewritten and cleaned up to adopt driver model
> and PHY API.
> 
> Signed-off-by: Shawn Guo 

Please note that you forgot drivers/net/ocelot_switch.c with this patch.

-- 
Tom


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


Re: [U-Boot] [PATCH] arm: socfpga: move gen5 SDR driver to DM

2019-02-08 Thread Dalon L Westergreen
On Fri, 2019-02-08 at 21:36 +0100, Simon Goldschmidt wrote:
> 
> 
> Am Fr., 8. Feb. 2019, 21:28 hat Dalon L Westergreen <
> dalon.westergr...@linux.intel.com> geschrieben:
> > On Thu, 2019-02-07 at 22:23 +0100, Simon Goldschmidt wrote:
> > > To clean up reset handling for socfpga gen5, let's move the code snippet
> > > taking the DDR controller out of reset from SPL to the DDR driver.
> > > 
> > > While at it, port the ddr driver to UCLASS_RAM and use dts.
> > > 
> > > Signed-off-by: Simon Goldschmidt 
> > > ---
> > > 
> > > This is an RFC to show what the SDRAM driver moved to DM (UCLASS_RAM)
> > would
> > > look like. It's RFC both because Dinh did not seem too fond of changing
> > the
> > > register address of the SDR in devicetree to include what the undocumented
> > > registers 'sequencer.c' uses as well as because of my observed code
> > growth.
> > > 
> > > Basically, I want to move this to UCLASS_RAM and I want to read the reset
> > > property for SDR from devicetree. What remains RFC is: do we want/need to
> > > read the base address from devicetree, or can we live with it being hard-
> > > coded (and maybe sanity-checked during probe)?
> > > 
> > 
> > My 2 cents, i love the idea of moving all of the socfgpa sdram code to DM.
> > Looking at the code, i would suggest that we should handle the case where
> > there is no HPS sdram controller, and instead an FPGA based controller is
> > used.  Although not common, it is a use case i have seen repeatedly.
> 
> While I haven't used it like that (I did use an FPGA RAM controller, but that
> was with a NIOS and not Linux, not HPS), I guess it should work with my
> changed. Just disable the 'sdr' node in the devicetree. You'll need a driver
> for the FPGA based RAM controller though.
> 
> Or, in the setup you mentioned, would the existing driver be the same? I.e.
> just use a different base address? Or is it a different IP?

All you need is to have the h2f bridge enabled during the boot.  We used to do
this for you if spl found that the FPGA was already configured.  On the FPGA
side, a nios in the ddr controller runs the ddr calibration code.

-dalon

> 
> Regards,
> Simon

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


Re: [U-Boot] [PATCH v1 24/26] colibri_imx6: switch to zimage

2019-02-08 Thread Marcel Ziswiler
Hi Lukasz

On Fri, 2019-02-08 at 22:42 +0100, Lukasz Majewski wrote:
> Hi Marcel,
> 
> > From: Bhuvanchandra DV 
> > 
> > Switch to the generic compressed Kernel image type (zImage) instead
> > of
> > the U-Boot specific uImage format.
> > 
> 
> I would recommend switching to use fitImage instead of zImage.

Thanks, we are, of course, aware of fitImage and we do use it e.g. for
the Toradex Easy Installer. However, while our former BSPs still booted
from uImage our current BSPs now boot from zImage. In the future, we
plan to fully integrate distroboot which basically makes this choice
here obsolete anyway.

> You can look on display5 board for a reference.
> 
> > While at it also fix device tree naming for MMC DFU.
> > 
> > Signed-off-by: Bhuvanchandra DV 
> > Acked-by: Marcel Ziswiler 
> > 
> > ---
> > 
> >  include/configs/colibri_imx6.h | 22 +++---
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> > 
> > diff --git a/include/configs/colibri_imx6.h
> > b/include/configs/colibri_imx6.h index 6e056aab31..a6a823ee1f
> > 100644
> > --- a/include/configs/colibri_imx6.h
> > +++ b/include/configs/colibri_imx6.h
> > @@ -108,17 +108,17 @@
> >  #include 
> >  #undef BOOTENV_RUN_NET_USB_START
> >  #define BOOTENV_RUN_NET_USB_START ""
> > -#else
> > +#else /* CONFIG_SPL_BUILD */
> >  #define BOOTENV
> > -#endif
> > +#endif /* CONFIG_SPL_BUILD */
> >  
> >  #define DFU_ALT_EMMC_INFO \
> > "u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
> > "boot part 0 1;" \
> > "rootfs part 0 2;" \
> > -   "uImage fat 0 1;" \
> > -   "imx6q-colibri-eval-v3.dtb fat 0 1;" \
> > -   "imx6q-colibri-cam-eval-v3.dtb fat 0 1"
> > +   "zImage fat 0 1;" \
> > +   "imx6dl-colibri-eval-v3.dtb fat 0 1;" \
> > +   "imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
> >  
> >  #define EMMC_BOOTCMD \
> > "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime
> > rootfstype=ext4 " \ @@ -128,7 +128,7 @@
> > "${vidargs}; echo Booting from internal eMMC
> > chip...; "  \ "run emmcdtbload; load mmc 0:1 ${kernel_addr_r} "
> > \ "${boot_file} && run fdt_fixup && " \
> > -   "bootm ${kernel_addr_r} ${dtbparam}\0" \
> > +   "bootz ${kernel_addr_r} ${dtbparam}\0" \
> > "emmcdtbload=setenv dtbparam; load mmc 0:1 ${fdt_addr_r} " \
> > "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> > && true\0" 
> > @@ -148,11 +148,11 @@
> > "setenv bootargs ${defargs} ${nfsargs} ${setupargs}
> > " \ "${vidargs}; echo Booting via DHCP/TFTP/NFS...; " \
> > "run nfsdtbload; dhcp ${kernel_addr_r} " \
> > -   "&& run fdt_fixup && bootm ${kernel_addr_r}
> > ${dtbparam}\0" \
> > +   "&& run fdt_fixup && bootz ${kernel_addr_r}
> > ${dtbparam}\0" \ "nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r}
> > ${fdt_file} " \ "&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
> >  
> > -#define SD_BOOTCMD \
> > +#define SD_BOOTCMD \
> > "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime
> > rootfstype=ext4 " \ "rootwait\0" \
> > "sdboot=run setup; " \
> > @@ -160,7 +160,7 @@
> > "${vidargs}; echo Booting from SD card; " \
> > "run sddtbload; load mmc 1:1 ${kernel_addr_r} " \
> > "${boot_file} && run fdt_fixup && " \
> > -   "bootm ${kernel_addr_r} ${dtbparam}\0" \
> > +   "bootz ${kernel_addr_r} ${dtbparam}\0" \
> > "sddtbload=setenv dtbparam; load mmc 1:1 ${fdt_addr_r} " \
> > "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> > && true\0" 
> > @@ -171,7 +171,7 @@
> > "${usbargs} ${vidargs}; echo Booting from USB
> > stick...; " \ "usb start && run usbdtbload; load usb 0:1
> > ${kernel_addr_r} " \ "${boot_file} && run fdt_fixup && " \
> > -   "bootm ${kernel_addr_r} ${dtbparam}\0" \
> > +   "bootz ${kernel_addr_r} ${dtbparam}\0" \
> > "usbdtbload=setenv dtbparam; load usb 0:1 ${fdt_addr_r} " \
> > "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> > && true\0" 
> > @@ -182,7 +182,7 @@
> > "run distro_bootcmd ; " \
> > "usb start ; " \
> > "setenv stdout serial,vga ; setenv stdin
> > serial,usbkbd\0" \
> > -   "boot_file=uImage\0" \
> > +   "boot_file=zImage\0" \
> > "console=ttymxc0\0" \
> > "defargs=enable_wait_mode=off
> > galcore.contiguousSize=50331648\0" \ "dfu_alt_info="
> > DFU_ALT_EMMC_INFO "\0" \
> 
> 
> 
> 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
 
Best regards - Mit freundlichen Grüssen - Meilleures salutations

Marcel Ziswiler
Platform Manager Embedded Linux

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500 48 00
(main line) | Direct: +41 41 500 48 10
___
U-Boot mailing list

Re: [U-Boot] [PATCH v1 24/26] colibri_imx6: switch to zimage

2019-02-08 Thread Lukasz Majewski
Hi Marcel,

> From: Bhuvanchandra DV 
> 
> Switch to the generic compressed Kernel image type (zImage) instead of
> the U-Boot specific uImage format.
> 

I would recommend switching to use fitImage instead of zImage.

You can look on display5 board for a reference.

> While at it also fix device tree naming for MMC DFU.
> 
> Signed-off-by: Bhuvanchandra DV 
> Acked-by: Marcel Ziswiler 
> 
> ---
> 
>  include/configs/colibri_imx6.h | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/include/configs/colibri_imx6.h
> b/include/configs/colibri_imx6.h index 6e056aab31..a6a823ee1f 100644
> --- a/include/configs/colibri_imx6.h
> +++ b/include/configs/colibri_imx6.h
> @@ -108,17 +108,17 @@
>  #include 
>  #undef BOOTENV_RUN_NET_USB_START
>  #define BOOTENV_RUN_NET_USB_START ""
> -#else
> +#else /* CONFIG_SPL_BUILD */
>  #define BOOTENV
> -#endif
> +#endif /* CONFIG_SPL_BUILD */
>  
>  #define DFU_ALT_EMMC_INFO \
>   "u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
>   "boot part 0 1;" \
>   "rootfs part 0 2;" \
> - "uImage fat 0 1;" \
> - "imx6q-colibri-eval-v3.dtb fat 0 1;" \
> - "imx6q-colibri-cam-eval-v3.dtb fat 0 1"
> + "zImage fat 0 1;" \
> + "imx6dl-colibri-eval-v3.dtb fat 0 1;" \
> + "imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
>  
>  #define EMMC_BOOTCMD \
>   "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime
> rootfstype=ext4 " \ @@ -128,7 +128,7 @@
>   "${vidargs}; echo Booting from internal eMMC
> chip...; "\ "run emmcdtbload; load mmc 0:1 ${kernel_addr_r} "
> \ "${boot_file} && run fdt_fixup && " \
> - "bootm ${kernel_addr_r} ${dtbparam}\0" \
> + "bootz ${kernel_addr_r} ${dtbparam}\0" \
>   "emmcdtbload=setenv dtbparam; load mmc 0:1 ${fdt_addr_r} " \
>   "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> && true\0" 
> @@ -148,11 +148,11 @@
>   "setenv bootargs ${defargs} ${nfsargs} ${setupargs}
> " \ "${vidargs}; echo Booting via DHCP/TFTP/NFS...; " \
>   "run nfsdtbload; dhcp ${kernel_addr_r} " \
> - "&& run fdt_fixup && bootm ${kernel_addr_r}
> ${dtbparam}\0" \
> + "&& run fdt_fixup && bootz ${kernel_addr_r}
> ${dtbparam}\0" \ "nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r}
> ${fdt_file} " \ "&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
>  
> -#define SD_BOOTCMD   \
> +#define SD_BOOTCMD \
>   "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime
> rootfstype=ext4 " \ "rootwait\0" \
>   "sdboot=run setup; " \
> @@ -160,7 +160,7 @@
>   "${vidargs}; echo Booting from SD card; " \
>   "run sddtbload; load mmc 1:1 ${kernel_addr_r} " \
>   "${boot_file} && run fdt_fixup && " \
> - "bootm ${kernel_addr_r} ${dtbparam}\0" \
> + "bootz ${kernel_addr_r} ${dtbparam}\0" \
>   "sddtbload=setenv dtbparam; load mmc 1:1 ${fdt_addr_r} " \
>   "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> && true\0" 
> @@ -171,7 +171,7 @@
>   "${usbargs} ${vidargs}; echo Booting from USB
> stick...; " \ "usb start && run usbdtbload; load usb 0:1
> ${kernel_addr_r} " \ "${boot_file} && run fdt_fixup && " \
> - "bootm ${kernel_addr_r} ${dtbparam}\0" \
> + "bootz ${kernel_addr_r} ${dtbparam}\0" \
>   "usbdtbload=setenv dtbparam; load usb 0:1 ${fdt_addr_r} " \
>   "${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\"
> && true\0" 
> @@ -182,7 +182,7 @@
>   "run distro_bootcmd ; " \
>   "usb start ; " \
>   "setenv stdout serial,vga ; setenv stdin
> serial,usbkbd\0" \
> - "boot_file=uImage\0" \
> + "boot_file=zImage\0" \
>   "console=ttymxc0\0" \
>   "defargs=enable_wait_mode=off
> galcore.contiguousSize=50331648\0" \ "dfu_alt_info="
> DFU_ALT_EMMC_INFO "\0" \




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


pgpr0xejli1wq.pgp
Description: OpenPGP digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v2] spl: implement CRC check on U-Boot uImage

2019-02-08 Thread Tom Rini
On Fri, Feb 08, 2019 at 10:05:41PM +0100, Simon Goldschmidt wrote:
> On Fri, Feb 8, 2019 at 8:46 PM Tom Rini  wrote:
> >
> > On Wed, Nov 28, 2018 at 09:52:45PM +0100, Simon Goldschmidt wrote:
> >
> > > SPL currently does not check uImage CRCs when loading U-Boot.
> > >
> > > This patch adds checking the uImage CRC when SPL loads U-Boot. It does
> > > this by reusing the existing config option SPL_CRC32_SUPPORT to allow
> > > leaving out the CRC check on boards where the additional code size or
> > > boot time is a problem (adding the CRC check currently adds ~1.4 kByte
> > > to flash).
> > >
> > > The SPL_CRC32_SUPPORT config option now gets enabled by default if SPL
> > > support for legacy images is enabled to check the CRC on all boards
> > > that don't actively take countermeasures.
> > >
> > > Signed-off-by: Simon Goldschmidt 
> > > Reviewed-by: Simon Glass 
> >
> > Really sorry for the delay on this, especially as I've found one or two
> > problems.  The first problem is that with this vyasa-rk3288 and a few
> > others fail to build due to a number of errors such as:
> > ../common/spl/spl.c:269:12: error: 'struct spl_image_info' has no member
> > named 'dcrc_data'
> 
> Hmm, let me check what's wrong there.
> 
> >
> > Second, I believe this is causing a number of platforms with very tight
> > SPL constraints, namely all of 64bit sunxi, to fail to link as they
> > overflow SRAM now.  This can be fixed at least by making the new
> > behavior opt-in, but I would fix the vyasa-rk3288 problem first.  Thanks
> > in advance!
> 
> Well, I thought it would be better to have it default to 'y' since I think it
> is what is expected. Shouldn't we explicitly work on those platforms?
> I must say I was pretty shocked to see that SPL did not detect an invalid
> CRC...
> 
> Can you point me to a config that fails?

In general, pine64_plus_defconfig is one that might (as I re-run my
build without this patch, I still see some failures but they've scrolled
off screen, but 64bit sunxi _is_ very sensitive to SPL growth).

-- 
Tom


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


Re: [U-Boot] [U-Boot,v2] spl: implement CRC check on U-Boot uImage

2019-02-08 Thread Simon Goldschmidt
On Fri, Feb 8, 2019 at 8:46 PM Tom Rini  wrote:
>
> On Wed, Nov 28, 2018 at 09:52:45PM +0100, Simon Goldschmidt wrote:
>
> > SPL currently does not check uImage CRCs when loading U-Boot.
> >
> > This patch adds checking the uImage CRC when SPL loads U-Boot. It does
> > this by reusing the existing config option SPL_CRC32_SUPPORT to allow
> > leaving out the CRC check on boards where the additional code size or
> > boot time is a problem (adding the CRC check currently adds ~1.4 kByte
> > to flash).
> >
> > The SPL_CRC32_SUPPORT config option now gets enabled by default if SPL
> > support for legacy images is enabled to check the CRC on all boards
> > that don't actively take countermeasures.
> >
> > Signed-off-by: Simon Goldschmidt 
> > Reviewed-by: Simon Glass 
>
> Really sorry for the delay on this, especially as I've found one or two
> problems.  The first problem is that with this vyasa-rk3288 and a few
> others fail to build due to a number of errors such as:
> ../common/spl/spl.c:269:12: error: 'struct spl_image_info' has no member
> named 'dcrc_data'

Hmm, let me check what's wrong there.

>
> Second, I believe this is causing a number of platforms with very tight
> SPL constraints, namely all of 64bit sunxi, to fail to link as they
> overflow SRAM now.  This can be fixed at least by making the new
> behavior opt-in, but I would fix the vyasa-rk3288 problem first.  Thanks
> in advance!

Well, I thought it would be better to have it default to 'y' since I think it
is what is expected. Shouldn't we explicitly work on those platforms?
I must say I was pretty shocked to see that SPL did not detect an invalid
CRC...

Can you point me to a config that fails?

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


Re: [U-Boot] [PATCH] arm: socfpga: move gen5 SDR driver to DM

2019-02-08 Thread Simon Goldschmidt
Am Fr., 8. Feb. 2019, 21:28 hat Dalon L Westergreen <
dalon.westergr...@linux.intel.com> geschrieben:

> On Thu, 2019-02-07 at 22:23 +0100, Simon Goldschmidt wrote:
> > To clean up reset handling for socfpga gen5, let's move the code snippet
> > taking the DDR controller out of reset from SPL to the DDR driver.
> >
> > While at it, port the ddr driver to UCLASS_RAM and use dts.
> >
> > Signed-off-by: Simon Goldschmidt 
> > ---
> >
> > This is an RFC to show what the SDRAM driver moved to DM (UCLASS_RAM)
> would
> > look like. It's RFC both because Dinh did not seem too fond of changing
> the
> > register address of the SDR in devicetree to include what the
> undocumented
> > registers 'sequencer.c' uses as well as because of my observed code
> growth.
> >
> > Basically, I want to move this to UCLASS_RAM and I want to read the reset
> > property for SDR from devicetree. What remains RFC is: do we want/need to
> > read the base address from devicetree, or can we live with it being hard-
> > coded (and maybe sanity-checked during probe)?
> >
>
> My 2 cents, i love the idea of moving all of the socfgpa sdram code to DM.
> Looking at the code, i would suggest that we should handle the case where
> there is no HPS sdram controller, and instead an FPGA based controller is
> used.  Although not common, it is a use case i have seen repeatedly.
>

While I haven't used it like that (I did use an FPGA RAM controller, but
that was with a NIOS and not Linux, not HPS), I guess it should work with
my changed. Just disable the 'sdr' node in the devicetree. You'll need a
driver for the FPGA based RAM controller though.

Or, in the setup you mentioned, would the existing driver be the same? I.e.
just use a different base address? Or is it a different IP?

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


Re: [U-Boot] [PATCH] drivers: net: ldpaa_eth: fix resource leak

2019-02-08 Thread Joe Hershberger
On Fri, Feb 8, 2019 at 2:46 AM Pankaj Bansal  wrote:
>
> if an error occurs in ldpaa_eth_init, need to free all resources
> before returning the error.
>
> Threfore, free net_dev before returning from ldpaa_eth_init.
>
> Signed-off-by: Pankaj Bansal 
>

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


Re: [U-Boot] [U-Boot,v2] spl: implement CRC check on U-Boot uImage

2019-02-08 Thread Tom Rini
On Wed, Nov 28, 2018 at 09:52:45PM +0100, Simon Goldschmidt wrote:

> SPL currently does not check uImage CRCs when loading U-Boot.
> 
> This patch adds checking the uImage CRC when SPL loads U-Boot. It does
> this by reusing the existing config option SPL_CRC32_SUPPORT to allow
> leaving out the CRC check on boards where the additional code size or
> boot time is a problem (adding the CRC check currently adds ~1.4 kByte
> to flash).
> 
> The SPL_CRC32_SUPPORT config option now gets enabled by default if SPL
> support for legacy images is enabled to check the CRC on all boards
> that don't actively take countermeasures.
> 
> Signed-off-by: Simon Goldschmidt 
> Reviewed-by: Simon Glass 

Really sorry for the delay on this, especially as I've found one or two
problems.  The first problem is that with this vyasa-rk3288 and a few
others fail to build due to a number of errors such as:
../common/spl/spl.c:269:12: error: 'struct spl_image_info' has no member
named 'dcrc_data'

Second, I believe this is causing a number of platforms with very tight
SPL constraints, namely all of 64bit sunxi, to fail to link as they
overflow SRAM now.  This can be fixed at least by making the new
behavior opt-in, but I would fix the vyasa-rk3288 problem first.  Thanks
in advance!

-- 
Tom


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


[U-Boot] [PATCH v2 3/4] efi_loader: use efi_start_image() for bootefi

2019-02-08 Thread Heinrich Schuchardt
Remove the duplicate code in efi_do_enter() and use efi_start_image() to
start the image invoked by the bootefi command.

Signed-off-by: Heinrich Schuchardt 
---
v2
use EFI_CALL
---
 cmd/bootefi.c | 22 +-
 include/efi_loader.h  |  4 
 lib/efi_loader/efi_boottime.c |  6 +++---
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 7f9913c0ee..a2d38256e9 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -133,20 +133,6 @@ done:
return ret;
 }
 
-static efi_status_t efi_do_enter(
-   efi_handle_t image_handle, struct efi_system_table *st,
-   EFIAPI efi_status_t (*entry)(
-   efi_handle_t image_handle,
-   struct efi_system_table *st))
-{
-   efi_status_t ret = EFI_LOAD_ERROR;
-
-   if (entry)
-   ret = entry(image_handle, st);
-   st->boottime->exit(image_handle, ret, 0, NULL);
-   return ret;
-}
-
 /*
  * efi_carve_out_dt_rsv() - Carve out DT reserved memory ranges
  *
@@ -315,13 +301,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 
/* Call our payload! */
debug("%s: Jumping to 0x%p\n", __func__, image_obj->entry);
-
-   if (setjmp(_obj->exit_jmp)) {
-   ret = image_obj->exit_status;
-   goto err_prepare;
-   }
-
-   ret = efi_do_enter(_obj->header, , image_obj->entry);
+   ret = EFI_CALL(efi_start_image(_obj->header, NULL, NULL));
 
 err_prepare:
/* image has returned, loaded-image obj goes *poof*: */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 3ce43f7a6f..512880ab8f 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -320,6 +320,10 @@ efi_status_t efi_create_handle(efi_handle_t *handle);
 void efi_delete_handle(efi_handle_t obj);
 /* Call this to validate a handle and find the EFI object for it */
 struct efi_object *efi_search_obj(const efi_handle_t handle);
+/* Start image */
+efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
+   efi_uintn_t *exit_data_size,
+   u16 **exit_data);
 /* Find a protocol on a handle */
 efi_status_t efi_search_protocol(const efi_handle_t handle,
 const efi_guid_t *protocol_guid,
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 7a61a905f4..6c4e2f82ba 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1770,9 +1770,9 @@ error:
  *
  * Return: status code
  */
-static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
-  efi_uintn_t *exit_data_size,
-  u16 **exit_data)
+efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
+   efi_uintn_t *exit_data_size,
+   u16 **exit_data)
 {
struct efi_loaded_image_obj *image_obj =
(struct efi_loaded_image_obj *)image_handle;
-- 
2.20.1

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


[U-Boot] [PATCH v2 1/4] efi_loader: LoadImage: always allocate new pages

2019-02-08 Thread Heinrich Schuchardt
If we want to properly unload images in Exit() the memory should always be
allocated in the same way. As we allocate memory when reading from file we
should do the same when the original image is in memory.

A further patch will be needed to free the memory when Exit() is called.

Signed-off-by: Heinrich Schuchardt 
---
v2
fix errors
- missing parameters efi_size_in_pages(
- inconsistent error handling
- missing comments
---
 include/efi_loader.h  |   2 +-
 lib/efi_loader/efi_bootmgr.c  |   2 +-
 lib/efi_loader/efi_boottime.c | 100 --
 3 files changed, 72 insertions(+), 32 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 9dd933dae7..6a98981ebb 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -397,7 +397,7 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path 
*device_path,
struct efi_loaded_image_obj **handle_ptr,
struct efi_loaded_image **info_ptr);
 efi_status_t efi_load_image_from_path(struct efi_device_path *file_path,
- void **buffer);
+ void **buffer, efi_uintn_t *size);
 /* Print information about all loaded images */
 void efi_print_image_infos(void *pc);
 
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index a095df3f54..196116b547 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -150,7 +150,7 @@ static void *try_load_entry(uint16_t n, struct 
efi_device_path **device_path,
debug("%s: trying to load \"%ls\" from %pD\n",
  __func__, lo.label, lo.file_path);
 
-   ret = efi_load_image_from_path(lo.file_path, );
+   ret = efi_load_image_from_path(lo.file_path, , );
 
if (ret != EFI_SUCCESS)
goto error;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 6df20649c4..7abdcf6da6 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1593,50 +1593,72 @@ failure:
 
 /**
  * efi_load_image_from_path() - load an image using a file path
- * @file_path: the path of the image to load
- * @buffer:buffer containing the loaded image
  *
- * Return: status code
+ * Read a file into a buffer allocated as EFI_BOOT_SERVICES_DATA. It is the
+ * callers obligation to update the memory type as needed.
+ *
+ * @file_path: the path of the image to load
+ * @buffer:buffer containing the loaded image
+ * @size:  size of the loaded image
+ * Return: status code
  */
 efi_status_t efi_load_image_from_path(struct efi_device_path *file_path,
- void **buffer)
+ void **buffer, efi_uintn_t *size)
 {
struct efi_file_info *info = NULL;
struct efi_file_handle *f;
static efi_status_t ret;
+   u64 addr;
efi_uintn_t bs;
 
+   /* In case of failure nothing is returned */
+   *buffer = NULL;
+   *size = 0;
+
+   /* Open file */
f = efi_file_from_path(file_path);
if (!f)
return EFI_DEVICE_ERROR;
 
+   /* Get file size */
bs = 0;
EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)_file_info_guid,
  , info));
-   if (ret == EFI_BUFFER_TOO_SMALL) {
-   info = malloc(bs);
-   EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)_file_info_guid,
- , info));
-   }
-   if (ret != EFI_SUCCESS)
+   if (ret != EFI_BUFFER_TOO_SMALL) {
+   ret =  EFI_DEVICE_ERROR;
goto error;
+   }
 
-   ret = efi_allocate_pool(EFI_LOADER_DATA, info->file_size, buffer);
-   if (ret)
+   info = malloc(bs);
+   EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)_file_info_guid, ,
+ info));
+   if (ret != EFI_SUCCESS)
goto error;
 
+   /*
+* When reading the file we do not yet know if it contains an
+* application, a boottime driver, or a runtime driver. So here we
+* allocate a buffer as EFI_BOOT_SERVICES_DATA. The caller has to
+* update the reservation according to the image type.
+*/
bs = info->file_size;
-   EFI_CALL(ret = f->read(f, , *buffer));
-
-error:
-   free(info);
-   EFI_CALL(f->close(f));
-
+   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+EFI_BOOT_SERVICES_DATA,
+efi_size_in_pages(bs), );
if (ret != EFI_SUCCESS) {
-   efi_free_pool(*buffer);
-   *buffer = NULL;
+   ret = EFI_OUT_OF_RESOURCES;
+   goto error;
}
 
+   /* Read file */
+   EFI_CALL(ret = f->read(f, , (void *)(uintptr_t)addr));
+   if (ret != 

[U-Boot] [PATCH v2 2/4] efi_loader: set entry point in efi_load_pe()

2019-02-08 Thread Heinrich Schuchardt
Up to now efi_load_pe() returns the entry point or NULL in case of an
error. This does not allow to return correct error codes from LoadImage().

Let efi_load_pe() return a status code and fill in the entry point in the
corresponding field of the image object.

Signed-off-by: Heinrich Schuchardt 
---
v2
correct a comment
---
 cmd/bootefi.c | 13 ---
 include/efi_loader.h  |  4 ++--
 lib/efi_loader/efi_boottime.c |  6 ++---
 lib/efi_loader/efi_image_loader.c | 37 ++-
 4 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index ee685d8644..7f9913c0ee 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -266,9 +266,6 @@ static efi_status_t do_bootefi_exec(void *efi,
struct efi_loaded_image_obj *image_obj = NULL;
struct efi_loaded_image *loaded_image_info = NULL;
 
-   EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
-struct efi_system_table *st);
-
/*
 * Special case for efi payload not loaded from disk, such as
 * 'bootefi hello' or for example payload loaded directly into
@@ -300,11 +297,9 @@ static efi_status_t do_bootefi_exec(void *efi,
goto err_prepare;
 
/* Load the EFI payload */
-   entry = efi_load_pe(image_obj, efi, loaded_image_info);
-   if (!entry) {
-   ret = EFI_LOAD_ERROR;
+   ret = efi_load_pe(image_obj, efi, loaded_image_info);
+   if (ret != EFI_SUCCESS)
goto err_prepare;
-   }
 
if (memdp) {
struct efi_device_path_memory *mdp = (void *)memdp;
@@ -319,14 +314,14 @@ static efi_status_t do_bootefi_exec(void *efi,
"{ro,boot}(blob)");
 
/* Call our payload! */
-   debug("%s: Jumping to 0x%p\n", __func__, entry);
+   debug("%s: Jumping to 0x%p\n", __func__, image_obj->entry);
 
if (setjmp(_obj->exit_jmp)) {
ret = image_obj->exit_status;
goto err_prepare;
}
 
-   ret = efi_do_enter(_obj->header, , entry);
+   ret = efi_do_enter(_obj->header, , image_obj->entry);
 
 err_prepare:
/* image has returned, loaded-image obj goes *poof*: */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 6a98981ebb..3ce43f7a6f 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -301,8 +301,8 @@ efi_status_t efi_set_watchdog(unsigned long timeout);
 /* Called from places to check whether a timer expired */
 void efi_timer_check(void);
 /* PE loader implementation */
-void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
- struct efi_loaded_image *loaded_image_info);
+efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
+struct efi_loaded_image *loaded_image_info);
 /* Called once to store the pristine gd pointer */
 void efi_save_gd(void);
 /* Special case handler for error/abort that just tries to dtrt to get
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 7abdcf6da6..7a61a905f4 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1736,11 +1736,9 @@ static efi_status_t EFIAPI efi_load_image(bool 
boot_policy,
ret = efi_setup_loaded_image(dp, fp, image_obj, );
if (ret != EFI_SUCCESS)
goto error_invalid_image;
-   (*image_obj)->entry = efi_load_pe(*image_obj, source_buffer, info);
-   if (!(*image_obj)->entry) {
-   ret = EFI_UNSUPPORTED;
+   ret = efi_load_pe(*image_obj, source_buffer, info);
+   if (ret != EFI_SUCCESS)
goto error_invalid_image;
-   }
/* Update the type of the allocated memory */
efi_add_memory_map((uintptr_t)source_buffer,
   efi_size_in_pages(source_size),
diff --git a/lib/efi_loader/efi_image_loader.c 
b/lib/efi_loader/efi_image_loader.c
index a18ce0a570..b55c2840e8 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -193,13 +193,19 @@ static void efi_set_code_and_data_type(
}
 }
 
-/*
+/**
+ * efi_load_pe() - relocate EFI binary
+ *
  * This function loads all sections from a PE binary into a newly reserved
- * piece of memory. On successful load it then returns the entry point for
- * the binary. Otherwise NULL.
+ * piece of memory. On success the entry point is returned as handle->entry.
+ *
+ * @handle:loaded image handle
+ * @efi:   pointer to the EFI binary
+ * @loaded_image_info: loaded image protocol
+ * Return: status code
  */
-void *efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
- struct efi_loaded_image *loaded_image_info)
+efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle, void *efi,
+struct efi_loaded_image *loaded_image_info)
 {
IMAGE_NT_HEADERS32 *nt;
   

[U-Boot] [PATCH v2 0/4] efi_loader: rework loading and starting of images

2019-02-08 Thread Heinrich Schuchardt
This patch series starts the necessary changes needed to correctly
implement the unloading of images in Exit().

If we want to properly unload images in Exit() the memory should always be
allocated in the same way. As we allocate memory when reading from file we
should do the same when the original image is in memory.

Up to now efi_load_pe() returns the entry point or NULL in case of an
error. This does not allow to return correct error codes from LoadImage().

Let efi_load_pe() return a status code and fill in the entry point in the
corresponding field of the image object.

Remove the duplicate code in efi_do_enter() and use efi_start_image() to
start the image invoked by the bootefi command.

Clean up bootefi_test_prepare().

Further patches will be needed:
- use LoadImage() in bootefi and bootmgr
- implement correct unloading of images in Exit()

Heinrich Schuchardt (4):
  efi_loader: LoadImage: always allocate new pages
  efi_loader: set entry point in efi_load_pe()
  efi_loader: use efi_start_image() for bootefi
  efi_loader: clean up bootefi_test_prepare()

 cmd/bootefi.c |  91 ++--
 include/efi_loader.h  |  10 ++-
 lib/efi_loader/efi_bootmgr.c  |   2 +-
 lib/efi_loader/efi_boottime.c | 112 --
 lib/efi_loader/efi_image_loader.c |  37 +-
 5 files changed, 141 insertions(+), 111 deletions(-)

-- 
2.20.1

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


[U-Boot] [PATCH v2 4/4] efi_loader: clean up bootefi_test_prepare()

2019-02-08 Thread Heinrich Schuchardt
Free resources upon failure.

Correct the function description.

As there is no need for any special address in the dummy memory device
path passed via the EFI_LOADED_IMAGE_PROTOCOL simply use 0 as address.

Signed-off-by: Heinrich Schuchardt 
---
v2
new patch
---
 cmd/bootefi.c | 58 +--
 1 file changed, 33 insertions(+), 25 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index a2d38256e9..9d9ccdd31a 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -318,38 +318,46 @@ err_add_protocol:
 /**
  * bootefi_test_prepare() - prepare to run an EFI test
  *
- * This sets things up so we can call EFI functions. This involves preparing
- * the 'gd' pointer and setting up the load ed image data structures.
+ * Prepare to run a test as if it were provided by a loaded image.
  *
- * @image_objp: loaded_image_infop: Pointer to a struct which will hold the
- *loaded image object. This struct will be inited by this function before
- *use.
- * @loaded_image_infop: Pointer to a struct which will hold the loaded image
- *info. This struct will be inited by this function before use.
- * @path: File path to the test being run (often just the test name with a
- *backslash before it
- * @test_func: Address of the test function that is being run
- * @load_options_path: U-Boot environment variable to use as load options
- * @return 0 if OK, -ve on error
+ * @image_objp:pointer to be set to the loaded image handle
+ * @loaded_image_infop:pointer to be set to the loaded image protocol
+ * @path:  dummy file path used to construct the device path
+ * set in the loaded image protocol
+ * @load_options_path: name of a U-Boot environment variable. Its value is
+ * set as load options in the loaded image protocol.
+ * Return: status code
  */
 static efi_status_t bootefi_test_prepare
(struct efi_loaded_image_obj **image_objp,
-   struct efi_loaded_image **loaded_image_infop, const char *path,
-   ulong test_func, const char *load_options_path)
+struct efi_loaded_image **loaded_image_infop, const char *path,
+const char *load_options_path)
 {
+   efi_status_t ret;
+
/* Construct a dummy device path */
-   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
- (uintptr_t)test_func,
- (uintptr_t)test_func);
+   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, 0, 0);
if (!bootefi_device_path)
return EFI_OUT_OF_RESOURCES;
+
bootefi_image_path = efi_dp_from_file(NULL, 0, path);
-   if (!bootefi_image_path)
-   return EFI_OUT_OF_RESOURCES;
+   if (!bootefi_image_path) {
+   ret = EFI_OUT_OF_RESOURCES;
+   goto failure;
+   }
 
-   return bootefi_run_prepare(load_options_path, bootefi_device_path,
-  bootefi_image_path, image_objp,
-  loaded_image_infop);
+   ret = bootefi_run_prepare(load_options_path, bootefi_device_path,
+ bootefi_image_path, image_objp,
+ loaded_image_infop);
+   if (ret == EFI_SUCCESS)
+   return ret;
+
+   efi_free_pool(bootefi_image_path);
+   bootefi_image_path = NULL;
+failure:
+   efi_free_pool(bootefi_device_path);
+   bootefi_device_path = NULL;
+   return ret;
 }
 
 #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
@@ -431,9 +439,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
struct efi_loaded_image_obj *image_obj;
struct efi_loaded_image *loaded_image_info;
 
-   if (bootefi_test_prepare(_obj, _image_info,
-"\\selftest", (uintptr_t)_selftest,
-"efi_selftest"))
+   r = bootefi_test_prepare(_obj, _image_info,
+"\\selftest", "efi_selftest");
+   if (r != EFI_SUCCESS)
return CMD_RET_FAILURE;
 
/* Execute the test */
-- 
2.20.1

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


Re: [U-Boot] [RFC v2 02/15] efi_loader: boottime: convert efi_loaded_image_obj to DM

2019-02-08 Thread Heinrich Schuchardt
On 2/8/19 9:15 AM, AKASHI Takahiro wrote:
> Signed-off-by: AKASHI Takahiro 
> ---
>  include/efi_loader.h  |  2 +-
>  lib/efi_loader/efi_boottime.c | 61 +++
>  2 files changed, 35 insertions(+), 28 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 4d5e22564a72..5882cd7dd3b0 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -367,7 +367,7 @@ efi_status_t efi_install_configuration_table(const 
> efi_guid_t *guid, void *table
>  /* Sets up a loaded image */
>  efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
>   struct efi_device_path *file_path,
> - struct efi_loaded_image_obj **handle_ptr,
> + efi_handle_t *handle_ptr,
>   struct efi_loaded_image **info_ptr);
>  efi_status_t efi_load_image_from_path(struct efi_device_path *file_path,
> void **buffer);
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index d23e4fbbdf23..624156d4578b 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -1690,29 +1690,29 @@ static efi_status_t EFIAPI 
> efi_install_configuration_table_ext(efi_guid_t *guid,
>   */
>  efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
>   struct efi_device_path *file_path,
> - struct efi_loaded_image_obj **handle_ptr,
> + efi_handle_t *handle_ptr,
>   struct efi_loaded_image **info_ptr)
>  {
>   efi_status_t ret;
>   struct efi_loaded_image *info;
> - struct efi_loaded_image_obj *obj;
> + struct udevice *dev;
>  
>   info = calloc(1, sizeof(*info));
>   if (!info)
>   return EFI_OUT_OF_RESOURCES;
> - obj = calloc(1, sizeof(*obj));
> - if (!obj) {
> +
> + ret = device_bind_driver(dm_root(), "efi_loaded_image", "(IMG)", );

A loaded image is not a device. There is nothing in the EFI world
relating the loaded image directly to the root of the device tree.

We should not create a meaningless link here.

Best regards

Heinrich


> + if (ret) {
>   free(info);
>   return EFI_OUT_OF_RESOURCES;
>   }
>  
> - /* Add internal object to object list */
> - efi_add_handle(>header);
> + efi_add_handle(dev);
>  
>   if (info_ptr)
>   *info_ptr = info;
>   if (handle_ptr)
> - *handle_ptr = obj;
> + *handle_ptr = dev;
>  
>   info->revision =  EFI_LOADED_IMAGE_PROTOCOL_REVISION;
>   info->file_path = file_path;
> @@ -1724,7 +1724,7 @@ efi_status_t efi_setup_loaded_image(struct 
> efi_device_path *device_path,
>* When asking for the device path interface, return
>* bootefi_device_path
>*/
> - ret = efi_add_protocol(>header,
> + ret = efi_add_protocol(dev,
>  _guid_device_path, device_path);
>   if (ret != EFI_SUCCESS)
>   goto failure;
> @@ -1734,24 +1734,24 @@ efi_status_t efi_setup_loaded_image(struct 
> efi_device_path *device_path,
>* When asking for the loaded_image interface, just
>* return handle which points to loaded_image_info
>*/
> - ret = efi_add_protocol(>header,
> + ret = efi_add_protocol(dev,
>  _guid_loaded_image, info);
>   if (ret != EFI_SUCCESS)
>   goto failure;
>  
> - ret = efi_add_protocol(>header,
> + ret = efi_add_protocol(dev,
>  _guid_hii_string_protocol,
>  (void *)_hii_string);
>   if (ret != EFI_SUCCESS)
>   goto failure;
>  
> - ret = efi_add_protocol(>header,
> + ret = efi_add_protocol(dev,
>  _guid_hii_database_protocol,
>  (void *)_hii_database);
>   if (ret != EFI_SUCCESS)
>   goto failure;
>  
> - ret = efi_add_protocol(>header,
> + ret = efi_add_protocol(dev,
>  _guid_hii_config_routing_protocol,
>  (void *)_hii_config_routing);
>   if (ret != EFI_SUCCESS)
> @@ -1835,9 +1835,8 @@ static efi_status_t EFIAPI efi_load_image(bool 
> boot_policy,
> efi_uintn_t source_size,
> efi_handle_t *image_handle)
>  {
> + struct efi_loaded_image_obj *obj;
>   struct efi_loaded_image *info = NULL;
> - struct efi_loaded_image_obj **image_obj =
> - (struct efi_loaded_image_obj **)image_handle;
>   efi_status_t ret;
>  
>   EFI_ENTRY("%d, %p, %pD, %p, %zd, %p", boot_policy, parent_image,
> @@ -1864,24 +1863,29 @@ static 

Re: [U-Boot] [RFC v2 01/15] efi_loader: efi objects and protocols as DM devices

2019-02-08 Thread Heinrich Schuchardt
On 2/8/19 9:15 AM, AKASHI Takahiro wrote:
> All efi objects are presented as DM devices, either existing device types
> or efi-specific, and efi_handle_t is an opaque pointer to "struct udevice."
> 
> We still maintain efi_obj_list as it is quite inefficient to traverse
> the DM hierarchy to find any efi objects, which are just part of it.
> 
> All efi protocols are also presented as DM devices, replacing
> "struct efi_handler" with "struct udevice." So searching for an efi
> protocol is nothing but traversing child nodes under a device.
> 
> Signed-off-by: AKASHI Takahiro 
> ---
>  include/dm/device.h   |   3 +
>  include/dm/uclass-id.h|   2 +
>  include/efi.h |   4 +-
>  include/efi_loader.h  |  37 +--
>  lib/efi_loader/efi_boottime.c | 544 --
>  5 files changed, 400 insertions(+), 190 deletions(-)
> 
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 27a6d7b9fdb0..0d82402c8e70 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -146,6 +146,9 @@ struct udevice {
>  #ifdef CONFIG_DEVRES
>   struct list_head devres_head;
>  #endif
> +#ifdef CONFIG_EFI_LOADER
> + void *efi_obj;
> +#endif
>  };
>  
>  /* Maximum sequence number supported */
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index f3bafb3c6353..fb0ab40891c8 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -40,6 +40,8 @@ enum uclass_id {
>   UCLASS_DISPLAY, /* Display (e.g. DisplayPort, HDMI) */
>   UCLASS_DMA, /* Direct Memory Access */
>   UCLASS_EFI, /* EFI managed devices */
> + UCLASS_EFI_OBJECT,  /* EFI managed objects */
> + UCLASS_EFI_PROTOCOL,/* EFI managed protocols */
>   UCLASS_ETH, /* Ethernet device */
>   UCLASS_FIRMWARE,/* Firmware */
>   UCLASS_FS_FIRMWARE_LOADER,  /* Generic loader */
> diff --git a/include/efi.h b/include/efi.h
> index b5e2c64f38b5..58902299a9a0 100644
> --- a/include/efi.h
> +++ b/include/efi.h
> @@ -96,7 +96,9 @@ typedef struct {
>  typedef unsigned long efi_status_t;
>  typedef u64 efi_physical_addr_t;
>  typedef u64 efi_virtual_addr_t;
> -typedef struct efi_object *efi_handle_t;
> +/* Eventually this should be 'void *' */
> +struct udevice;
> +typedef struct udevice *efi_handle_t;
>  
>  #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
>   {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 3077a1e9d58b..4d5e22564a72 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -167,38 +167,12 @@ struct efi_open_protocol_info_item {
>   * protocol GUID to the respective protocol interface
>   */
>  struct efi_handler {
> - /* Link to the list of protocols of a handle */
> - struct list_head link;
>   const efi_guid_t *guid;
>   void *protocol_interface;
>   /* Link to the list of open protocol info items */
>   struct list_head open_infos;
>  };
>  
> -/**
> - * struct efi_object - dereferenced EFI handle
> - *
> - * @link:pointers to put the handle into a linked list
> - * @protocols:   linked list with the protocol interfaces installed on 
> this
> - *   handle
> - *
> - * UEFI offers a flexible and expandable object model. The objects in the 
> UEFI
> - * API are devices, drivers, and loaded images. struct efi_object is our 
> storage
> - * structure for these objects.
> - *
> - * When including this structure into a larger structure always put it first 
> so
> - * that when deleting a handle the whole encompassing structure can be freed.
> - *
> - * A pointer to this structure is referred to as a handle. Typedef 
> efi_handle_t
> - * has been created for such pointers.
> - */
> -struct efi_object {
> - /* Every UEFI object is part of a global object list */
> - struct list_head link;
> - /* The list of protocols */
> - struct list_head protocols;
> -};
> -
>  /**
>   * struct efi_loaded_image_obj - handle of a loaded image
>   *
> @@ -209,7 +183,6 @@ struct efi_object {
>   * @entry:   entry address of the relocated image
>   */
>  struct efi_loaded_image_obj {
> - struct efi_object header;
>   void *reloc_base;
>   aligned_u64 reloc_size;
>   efi_status_t exit_status;
> @@ -312,18 +285,18 @@ void efi_restore_gd(void);
>  void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
>  /* Call this to set the current device name */
>  void efi_set_bootdev(const char *dev, const char *devnr, const char *path);
> +/* Go through all the efi objects and call func() for each */
> +efi_status_t efi_foreach_dev(int (*func)(struct udevice *, void *), void 
> *arg);
>  /* Add a new object to the object list. */
> -void efi_add_handle(efi_handle_t obj);
> +efi_status_t efi_add_handle(struct udevice *dev);
>  /* Create handle */
> -efi_status_t efi_create_handle(efi_handle_t *handle);
> 

[U-Boot] [PATCH v1 26/26] board: colibri_imx6: check for and report ecc errors in fuses

2019-02-08 Thread Marcel Ziswiler
From: Gerard Salvatella 

The PMIC on the Colibri iMX6 may have ECC errors in fuses that will
prevent correct settings. Up to one bit error per fuse bank can be
reported and corrected by the ECC logic. Two bit errors can only be
reported.

Signed-off-by: Gerard Salvatella 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/pf0100.c | 51 +
 board/toradex/colibri_imx6/pf0100.h | 59 -
 2 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/board/toradex/colibri_imx6/pf0100.c 
b/board/toradex/colibri_imx6/pf0100.c
index 09c3cc950a..e744243297 100644
--- a/board/toradex/colibri_imx6/pf0100.c
+++ b/board/toradex/colibri_imx6/pf0100.c
@@ -21,6 +21,8 @@
 /* define for PMIC register dump */
 /*#define DEBUG */
 
+#define WARNBAR "@\n"
+
 /* use GPIO: EXT_IO1 to switch on VPGM, ON: 1 */
 static __maybe_unused iomux_v3_cfg_t const pmic_prog_pads[] = {
MX6_PAD_NANDF_D3__GPIO2_IO03 | MUX_PAD_CTRL(NO_PAD_CTRL),
@@ -42,6 +44,55 @@ unsigned pmic_init(void)
   PFUZE100_I2C_ADDR);
return 0;
}
+
+   /* check for errors in PMIC fuses */
+   if (dm_i2c_read(dev, PFUZE100_INTSTAT3, , 1) < 0) {
+   puts("i2c pmic INTSTAT3 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BIT_OTP_ECCI) {
+   puts("\n" WARNBAR);
+   puts("WARNING: ecc errors found in pmic fuse banks\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_SE1, , 1) < 0) {
+   puts("i2c pmic ECC_SE1 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_SE1) {
+   puts(WARNBAR);
+   puts("WARNING: ecc has made bit corrections in banks 1 to 5\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_SE2, , 1) < 0) {
+   puts("i2c pmic ECC_SE2 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_SE2) {
+   puts(WARNBAR);
+   puts("WARNING: ecc has made bit corrections in banks 6 to 10\n"
+   );
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_DE1, , 1) < 0) {
+   puts("i2c pmic ECC_DE register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_DE1) {
+   puts(WARNBAR);
+   puts("ERROR: banks 1 to 5 have uncorrectable bits\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_DE2, , 1) < 0) {
+   puts("i2c pmic ECC_DE register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_DE2) {
+   puts(WARNBAR);
+   puts("ERROR: banks 6 to 10 have uncorrectable bits\n");
+   puts(WARNBAR);
+   }
+
/* get device ident */
if (dm_i2c_read(dev, PFUZE100_DEVICEID, , 1) < 0) {
puts("i2c pmic devid read failed\n");
diff --git a/board/toradex/colibri_imx6/pf0100.h 
b/board/toradex/colibri_imx6/pf0100.h
index c0efb79bbc..9257620511 100644
--- a/board/toradex/colibri_imx6/pf0100.h
+++ b/board/toradex/colibri_imx6/pf0100.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2014-2016, Toradex AG
+ * Copyright (C) 2014-2019, Toradex AG
  */
 
 /*
@@ -10,11 +10,23 @@
 #ifndef PF0100_H_
 #define PF0100_H_
 
+/* bit definitions */
+#define PFUZE100_BIT_0 (0x01 << 0)
+#define PFUZE100_BIT_1 (0x01 << 1)
+#define PFUZE100_BIT_2 (0x01 << 2)
+#define PFUZE100_BIT_3 (0x01 << 3)
+#define PFUZE100_BIT_4 (0x01 << 4)
+#define PFUZE100_BIT_5 (0x01 << 5)
+#define PFUZE100_BIT_6 (0x01 << 6)
+#define PFUZE100_BIT_7 (0x01 << 7)
+
 /* 7-bit I2C bus slave address */
 #define PFUZE100_I2C_ADDR  (0x08)
 /* Register Addresses */
 #define PFUZE100_DEVICEID  (0x0)
 #define PFUZE100_REVID (0x3)
+#define PFUZE100_INTSTAT3  (0xe)
+#define PFUZE100_BIT_OTP_ECCI  PFUZE100_BIT_7
 #define PFUZE100_SW1AMODE  (0x23)
 #define PFUZE100_SW1ACON   36
 #define PFUZE100_SW1ACON_SPEED_VAL (0x1<<6)/*default */
@@ -39,12 +51,55 @@
 #define PFUZE100_PAGE_REGISTER_PAGE2   (0x02 & PFUZE100_PAGE_REGISTER_PAGE_M)
 
 /* extended page 1 */
+#define PFUZE100_OTP_ECC_SE1   0x8a
+#define PFUZE100_BIT_ECC1_SE   PFUZE100_BIT_0
+#define PFUZE100_BIT_ECC2_SE   PFUZE100_BIT_1
+#define PFUZE100_BIT_ECC3_SE   PFUZE100_BIT_2
+#define PFUZE100_BIT_ECC4_SE   PFUZE100_BIT_3
+#define PFUZE100_BIT_ECC5_SE   PFUZE100_BIT_4
+#define PFUZE100_BITS_ECC_SE1  ((PFUZE100_BIT_ECC1_SE) | \
+  

[U-Boot] [PATCH v1 14/26] colibri_imx6: print also 64-bit IT

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

Print also for Colibri iMX6 512MB IT with 64-bit RAM bus.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 83ecd20b3d..439d38bc29 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -1019,6 +1019,7 @@ static void spl_dram_init(void)
case TEMP_AUTOMOTIVE:
default:
if (is_cpu_type(MXC_CPU_MX6DL)) {
+   puts("Industrial temperature grade DDR3 timings, 64bit 
bus width.\n");
ddr_init(mx6dl_dcd_table, ARRAY_SIZE(mx6dl_dcd_table));
} else {
puts("Industrial temperature grade DDR3 timings, 32bit 
bus width.\n");
-- 
2.20.1

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


[U-Boot] [PATCH v1 15/26] colibri_imx6: add distroboot support

2019-02-08 Thread Marcel Ziswiler
From: Stefan Agner 

Add support for distro boot. This is especially helpful for external
devices. There is a global boot command which scans a predefined
list of boot targets:
  run distro_bootcmd

As well as direct boot commands such as:
  run bootcmd_mmc1
  run bootcmd_usb
  run bootcmd_dhcp
  ...

Refer to doc/README.distro fo details.

While at it, remove the CONFIG_DRIVE_TYPES define which has not
been used and was meant to be used for multi device boot support
which is now provided by distroboot.

Signed-off-by: Stefan Agner 
Acked-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 include/configs/colibri_imx6.h | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index c782b2924c..77f884f341 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -100,14 +100,18 @@
 
 #define CONFIG_LOADADDR0x1200
 
-#ifdef CONFIG_CMD_MMC
-#define CONFIG_DRIVE_MMC "mmc "
+#ifndef CONFIG_SPL_BUILD
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, 1) \
+   func(USB, usb, 0) \
+   func(DHCP, dhcp, na)
+#include 
+#undef BOOTENV_RUN_NET_USB_START
+#define BOOTENV_RUN_NET_USB_START ""
 #else
-#define CONFIG_DRIVE_MMC
+#define BOOTENV
 #endif
 
-#define CONFIG_DRIVE_TYPES CONFIG_DRIVE_MMC
-
 #define DFU_ALT_EMMC_INFO \
"u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
"boot part 0 1;" \
@@ -134,7 +138,9 @@
"fdt_high=0x\0" \
"initrd_high=0x\0" \
"kernel_addr_r=0x1100\0" \
-   "ramdisk_addr_r=0x1210\0"
+   "pxefile_addr_r=0x1710\0" \
+   "ramdisk_addr_r=0x1210\0" \
+   "scriptaddr=0x1700\0"
 
 #define NFS_BOOTCMD \
"nfsargs=ip=:eth0:on root=/dev/nfs rw\0" \
@@ -171,9 +177,10 @@
 
 #define FDT_FILE "imx6dl-colibri-eval-v3.dtb"
 #define CONFIG_EXTRA_ENV_SETTINGS \
+   BOOTENV \
"bootcmd=run emmcboot ; echo ; echo emmcboot failed ; " \
-   "run nfsboot ; echo ; echo nfsboot failed ; " \
-   "usb start ;" \
+   "run distro_bootcmd ; " \
+   "usb start ; " \
"setenv stdout serial,vga ; setenv stdin serial,usbkbd\0" \
"boot_file=uImage\0" \
"console=ttymxc0\0" \
-- 
2.20.1

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


[U-Boot] [PATCH v1 22/26] configs: colibri_imx6: Use ext4 file system by default

2019-02-08 Thread Marcel Ziswiler
From: Sanchayan Maity 

Use ext4 file system by default.

Signed-off-by: Sanchayan Maity 
Acked-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 include/configs/colibri_imx6.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 77f884f341..6e056aab31 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -121,7 +121,7 @@
"imx6q-colibri-cam-eval-v3.dtb fat 0 1"
 
 #define EMMC_BOOTCMD \
-   "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext3 " \
+   "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"emmcboot=run setup; " \
"setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
@@ -153,7 +153,7 @@
"&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
 #define SD_BOOTCMD \
-   "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext3 " \
+   "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"sdboot=run setup; " \
"setenv bootargs ${defargs} ${sdargs} ${setupargs} " \
@@ -165,7 +165,7 @@
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
 #define USB_BOOTCMD \
-   "usbargs=ip=off root=/dev/sda2 rw,noatime rootfstype=ext3 " \
+   "usbargs=ip=off root=/dev/sda2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"usbboot=run setup; setenv bootargs ${defargs} ${setupargs} " \
"${usbargs} ${vidargs}; echo Booting from USB stick...; " \
-- 
2.20.1

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


[U-Boot] [PATCH v1 13/26] colibri_imx6: drop CONFIG_OF_SYSTEM_SETUP

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

This doesn't do anything anymore, probably never did.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 7 ---
 include/configs/colibri_imx6.h| 2 --
 2 files changed, 9 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index adb5a3df4c..83ecd20b3d 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -646,13 +646,6 @@ int board_late_init(void)
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
 
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_SYSTEM_SETUP)
-int ft_system_setup(void *blob, bd_t *bd)
-{
-   return 0;
-}
-#endif
-
 int checkboard(void)
 {
char it[] = " IT";
diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index e51ec8516f..c782b2924c 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -237,8 +237,6 @@
 #define CONFIG_SYS_MMC_ENV_PART1
 #endif
 
-#define CONFIG_OF_SYSTEM_SETUP
-
 #define CONFIG_CMD_TIME
 
 #endif /* __CONFIG_H */
-- 
2.20.1

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


[U-Boot] [PATCH v1 23/26] colibri_imx6: use SDP if USB serial downloader has been used

2019-02-08 Thread Marcel Ziswiler
From: Stefan Agner 

In case USB serial downloader has been used to load U-Boot start the
serial download protocol (SDP) emulation. This allows to download
complete images such as Toradex Easy Installer over USB SDP as well.
This code uses the boot ROM provided boot information to reliably
detect USB serial downloader.

Signed-off-by: Stefan Agner 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index fd988bd2b0..4d9032419a 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -654,6 +654,14 @@ int board_late_init(void)
env_set("board_rev", env_str);
 #endif
 
+#ifdef CONFIG_CMD_USB_SDP
+   if (is_boot_from_usb()) {
+   printf("Serial Downloader recovery mode, using sdp command\n");
+   env_set("bootdelay", "0");
+   env_set("bootcmd", "sdp 0");
+   }
+#endif /* CONFIG_CMD_USB_SDP */
+
return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
@@ -684,7 +692,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 
ft_common_board_setup(blob, bd);
 
-   cma_size = getenv_ulong("cma-size", 10, 320 * 1024 * 1024);
+   cma_size = env_get_ulong("cma-size", 10, 320 * 1024 * 1024);
cma_size = min((u32)(gd->ram_size >> 1), cma_size);
 
fdt_setprop_u32(blob,
-- 
2.20.1

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


[U-Boot] [PATCH v1 25/26] colibri_imx6: added nreset gpio on reboot

2019-02-08 Thread Marcel Ziswiler
From: Gerard Salvatella 

RGMII_RD1 pin (active high, GPIO6_IO27) is triggered on reboot during
the SPL phase. This asserts (active low) nReset_Out from the PMIC.
Only V1.1 and later Colibri iMX6 modules implement this in hw. Previous
versions do not use this pin, so it is safe to leave it enabled at all
times.

Signed-off-by: Gerard Salvatella 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 4d9032419a..98ad87af19 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../common/tdx-cfg-block.h"
 #ifdef CONFIG_TDX_CMD_IMX_MFGR
@@ -1061,6 +1062,26 @@ static void spl_dram_init(void)
udelay(100);
 }
 
+static iomux_v3_cfg_t const gpio_reset_pad[] = {
+   MX6_PAD_RGMII_RD1__GPIO6_IO27 | MUX_PAD_CTRL(NO_PAD_CTRL) |
+   MUX_MODE_SION
+#define GPIO_NRESET IMX_GPIO_NR(6, 27)
+};
+
+#define IMX_RESET_CAUSE_POR 0x00011
+static void nreset_out(void)
+{
+   int reset_cause = get_imx_reset_cause();
+
+   if (reset_cause != IMX_RESET_CAUSE_POR) {
+   imx_iomux_v3_setup_multiple_pads(gpio_reset_pad,
+ARRAY_SIZE(gpio_reset_pad));
+   gpio_direction_output(GPIO_NRESET, 1);
+   udelay(100);
+   gpio_direction_output(GPIO_NRESET, 0);
+   }
+}
+
 void board_init_f(ulong dummy)
 {
/* setup AIPS and disable watchdog */
@@ -1087,6 +1108,9 @@ void board_init_f(ulong dummy)
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
 
+   /* Assert nReset_Out */
+   nreset_out();
+
/* load/boot image from boot device */
board_init_r(NULL, 0);
 }
-- 
2.20.1

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


[U-Boot] [PATCH v1 24/26] colibri_imx6: switch to zimage

2019-02-08 Thread Marcel Ziswiler
From: Bhuvanchandra DV 

Switch to the generic compressed Kernel image type (zImage) instead of
the U-Boot specific uImage format.

While at it also fix device tree naming for MMC DFU.

Signed-off-by: Bhuvanchandra DV 
Acked-by: Marcel Ziswiler 

---

 include/configs/colibri_imx6.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 6e056aab31..a6a823ee1f 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -108,17 +108,17 @@
 #include 
 #undef BOOTENV_RUN_NET_USB_START
 #define BOOTENV_RUN_NET_USB_START ""
-#else
+#else /* CONFIG_SPL_BUILD */
 #define BOOTENV
-#endif
+#endif /* CONFIG_SPL_BUILD */
 
 #define DFU_ALT_EMMC_INFO \
"u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
"boot part 0 1;" \
"rootfs part 0 2;" \
-   "uImage fat 0 1;" \
-   "imx6q-colibri-eval-v3.dtb fat 0 1;" \
-   "imx6q-colibri-cam-eval-v3.dtb fat 0 1"
+   "zImage fat 0 1;" \
+   "imx6dl-colibri-eval-v3.dtb fat 0 1;" \
+   "imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
 
 #define EMMC_BOOTCMD \
"emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext4 " \
@@ -128,7 +128,7 @@
"${vidargs}; echo Booting from internal eMMC chip...; " \
"run emmcdtbload; load mmc 0:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"emmcdtbload=setenv dtbparam; load mmc 0:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -148,11 +148,11 @@
"setenv bootargs ${defargs} ${nfsargs} ${setupargs} " \
"${vidargs}; echo Booting via DHCP/TFTP/NFS...; " \
"run nfsdtbload; dhcp ${kernel_addr_r} " \
-   "&& run fdt_fixup && bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "&& run fdt_fixup && bootz ${kernel_addr_r} ${dtbparam}\0" \
"nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r} ${fdt_file} " \
"&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
-#define SD_BOOTCMD \
+#define SD_BOOTCMD \
"sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"sdboot=run setup; " \
@@ -160,7 +160,7 @@
"${vidargs}; echo Booting from SD card; " \
"run sddtbload; load mmc 1:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"sddtbload=setenv dtbparam; load mmc 1:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -171,7 +171,7 @@
"${usbargs} ${vidargs}; echo Booting from USB stick...; " \
"usb start && run usbdtbload; load usb 0:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"usbdtbload=setenv dtbparam; load usb 0:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -182,7 +182,7 @@
"run distro_bootcmd ; " \
"usb start ; " \
"setenv stdout serial,vga ; setenv stdin serial,usbkbd\0" \
-   "boot_file=uImage\0" \
+   "boot_file=zImage\0" \
"console=ttymxc0\0" \
"defargs=enable_wait_mode=off galcore.contiguousSize=50331648\0" \
"dfu_alt_info=" DFU_ALT_EMMC_INFO "\0" \
-- 
2.20.1

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


[U-Boot] [PATCH v1 00/26] colibri imx6 fixes, device tree enablement and driver model conversion

2019-02-08 Thread Marcel Ziswiler

This series addresses some shortcomings, enables/introduces device tree
support and converts all except video to using the driver model. This is
fully tested both running our latest downstream BSP as well as the
mainline Linux kernel.


Bhuvanchandra DV (2):
  toradex: colibri_imx6: overwrite CMA memory set in device tree
  colibri_imx6: switch to zimage

Gerard Salvatella (2):
  colibri_imx6: added nreset gpio on reboot
  board: colibri_imx6: check for and report ecc errors in fuses

Marcel Ziswiler (12):
  colibri_imx6: get rid of obsolete nospl configurations
  colibri_imx6: use distro defaults
  colibri_imx6: move console in env from header file to defconfig
  colibri_imx6: enable fit image, gpt, imx thermal, efi loader support
  colibri_imx6: remove obsolete USB_GADGET_MASS_STORAGE configuration
  colibri_imx6: migrate to using device tree
  colibri_imx6: clean-up and migrate gpios to using driver model
  colibri_imx6: enable pin control driver
  colibri_imx6: migrate i2c to using driver model
  colibri_imx6: migrate pmic and regulator to using driver model
  colibri_imx6: migrate mmc to using driver model
  colibri_imx6: migrate usb to using driver model

Max Krummenacher (7):
  colibri_imx6: drop CONFIG_OF_SYSTEM_SETUP
  colibri_imx6: print also 64-bit IT
  colibri_imx6: unify sd/mmc drive strenght with linux kernel settings
  colibri imx6: pf0100: reorder and cleanup message printing
  colibri imx6: disable ri and dcd irq in uarts
  colibri_imx6: change pmic fusing according to hw 1.1 requirements
  colibri_imx6: revert fuse value set in mfgr_fuse

Sanchayan Maity (1):
  configs: colibri_imx6: Use ext4 file system by default

Stefan Agner (2):
  colibri_imx6: add distroboot support
  colibri_imx6: use SDP if USB serial downloader has been used

 arch/arm/dts/imx6-colibri.dts | 411 ++
 .../toradex/colibri_imx6/800mhz_2x64mx16.cfg  |  58 ---
 .../toradex/colibri_imx6/800mhz_4x64mx16.cfg  |  58 ---
 board/toradex/colibri_imx6/MAINTAINERS|   3 +-
 board/toradex/colibri_imx6/clocks.cfg |  41 --
 board/toradex/colibri_imx6/colibri_imx6.c | 395 +
 board/toradex/colibri_imx6/colibri_imx6.cfg   |  37 --
 board/toradex/colibri_imx6/ddr-setup.cfg  |  97 -
 board/toradex/colibri_imx6/do_fuse.c  |   2 +-
 board/toradex/colibri_imx6/pf0100.c   | 177 +---
 board/toradex/colibri_imx6/pf0100.h   |  59 ++-
 board/toradex/colibri_imx6/pf0100_otp.inc |  16 +-
 configs/colibri_imx6_defconfig|  33 +-
 configs/colibri_imx6_nospl_defconfig  |  63 ---
 include/configs/colibri_imx6.h|  66 +--
 15 files changed, 853 insertions(+), 663 deletions(-)
 create mode 100644 arch/arm/dts/imx6-colibri.dts
 delete mode 100644 board/toradex/colibri_imx6/800mhz_2x64mx16.cfg
 delete mode 100644 board/toradex/colibri_imx6/800mhz_4x64mx16.cfg
 delete mode 100644 board/toradex/colibri_imx6/clocks.cfg
 delete mode 100644 board/toradex/colibri_imx6/colibri_imx6.cfg
 delete mode 100644 board/toradex/colibri_imx6/ddr-setup.cfg
 delete mode 100644 configs/colibri_imx6_nospl_defconfig

-- 
2.20.1

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


[U-Boot] [PATCH v1 20/26] colibri_imx6: revert fuse value set in mfgr_fuse

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

We have two commands to change the bootmode fuses:
mfgr_fuse which set fuse 0/5 and 0/6
and
updt_fuse which burns bit 4 of 0/5.

Before Image 2.6 we fused in mfgr_fuse 0x5062, which boots
from the user partition of the eMMC.
To workaround certain hangs we moved to fastboot mode and
using the first bootpartition of the eMMC requiring a fuse
value of 0x5072 which could be achived by the then added
updt_fuse command. At the same time the mfgr_fuse command
was changed to also fuse 0x5072, revert that second change
so that one can fuse both values, one with just mfgr_fuse
and the later with mfgr_fuse;updt_fuse.

Note that the mfgr_fuse command is only needed at module
production time, a customer might need to use updt_fuse
when upgrading an older module to be compatible with a
newer image. The command is integrated into the image
update scripts.

Signed-off-by: Max Krummenacher 
Acked-by: Stefan Agner 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/do_fuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/toradex/colibri_imx6/do_fuse.c 
b/board/toradex/colibri_imx6/do_fuse.c
index e6793e366a..22d191f52a 100644
--- a/board/toradex/colibri_imx6/do_fuse.c
+++ b/board/toradex/colibri_imx6/do_fuse.c
@@ -29,7 +29,7 @@ static int mfgr_fuse(void)
return CMD_RET_FAILURE;
}
/* boot cfg */
-   fuse_prog(0, 5, 0x5072);
+   fuse_prog(0, 5, 0x5062);
/* BT_FUSE_SEL */
fuse_prog(0, 6, 0x0010);
return CMD_RET_SUCCESS;
-- 
2.20.1

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


[U-Boot] [PATCH v1 09/26] colibri_imx6: migrate i2c to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate I2C to using driver model.

Signed-off-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 50 +
 board/toradex/colibri_imx6/pf0100.c   | 54 ---
 configs/colibri_imx6_defconfig|  1 +
 include/configs/colibri_imx6.h|  8 ++--
 4 files changed, 36 insertions(+), 77 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 1f5de2f5f6..f5cfeb30bc 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -20,13 +20,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -50,16 +48,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
 
-#define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED |\
-   PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
-
-#define BUTTON_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
-
-#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP |  \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-   PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
 #define WEAK_PULLUP(PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
PAD_CTL_SRE_SLOW)
@@ -72,8 +60,6 @@ DECLARE_GLOBAL_DATA_PTR;
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
PAD_CTL_HYS | PAD_CTL_SRE_SLOW)
 
-#define OUTPUT_40OHM (PAD_CTL_SPEED_MED|PAD_CTL_DSE_40ohm)
-
 #define OUTPUT_RGB (PAD_CTL_SPEED_MED|PAD_CTL_DSE_60ohm|PAD_CTL_SRE_FAST)
 
 int dram_init(void)
@@ -91,36 +77,7 @@ iomux_v3_cfg_t const uart1_pads[] = {
MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
-#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-/* Colibri I2C */
-struct i2c_pads_info i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6_PAD_GPIO_3__I2C3_SCL | PC,
-   .gpio_mode = MX6_PAD_GPIO_3__GPIO1_IO03 | PC,
-   .gp = IMX_GPIO_NR(1, 3)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_GPIO_6__I2C3_SDA | PC,
-   .gpio_mode = MX6_PAD_GPIO_6__GPIO1_IO06 | PC,
-   .gp = IMX_GPIO_NR(1, 6)
-   }
-};
-
-/* Colibri local, PMIC, SGTL5000, STMPE811 */
-struct i2c_pads_info i2c_pad_info_loc = {
-   .scl = {
-   .i2c_mode = MX6_PAD_EIM_EB2__I2C2_SCL | PC,
-   .gpio_mode = MX6_PAD_EIM_EB2__GPIO2_IO30 | PC,
-   .gp = IMX_GPIO_NR(2, 30)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_EIM_D16__I2C2_SDA | PC,
-   .gpio_mode = MX6_PAD_EIM_D16__GPIO3_IO16 | PC,
-   .gp = IMX_GPIO_NR(3, 16)
-   }
-};
-
-/* Apalis MMC */
+/* Colibri MMC */
 iomux_v3_cfg_t const usdhc1_pads[] = {
MX6_PAD_SD1_CLK__SD1_CLK| MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD1_CMD__SD1_CMD| MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -706,9 +663,6 @@ int board_init(void)
/* address of boot parameters */
gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
 
-   setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, _pad_info1);
-   setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _pad_info_loc);
-
 #if defined(CONFIG_VIDEO_IPUV3)
setup_display();
 #endif
@@ -1141,7 +1095,7 @@ void board_init_f(ulong dummy)
ccgr_init();
gpr_init();
 
-   /* iomux and setup of i2c */
+   /* iomux */
board_early_init_f();
 
/* setup GP timer */
diff --git a/board/toradex/colibri_imx6/pf0100.c 
b/board/toradex/colibri_imx6/pf0100.c
index fa63865670..5e411f1743 100644
--- a/board/toradex/colibri_imx6/pf0100.c
+++ b/board/toradex/colibri_imx6/pf0100.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2014-2016, Toradex AG
+ * Copyright (C) 2014-2019, Toradex AG
  */
 
 /*
@@ -29,22 +29,25 @@ static __maybe_unused iomux_v3_cfg_t const pmic_prog_pads[] 
= {
 
 unsigned pmic_init(void)
 {
+   int rc;
+   struct udevice *dev = NULL;
unsigned programmed = 0;
uchar bus = 1;
uchar devid, revid, val;
 
puts("PMIC: ");
-   if (!((0 == i2c_set_bus_num(bus)) &&
- (0 == i2c_probe(PFUZE100_I2C_ADDR {
-   puts("i2c bus failed\n");
+   rc = i2c_get_chip_for_busnum(bus, PFUZE100_I2C_ADDR, 1, );
+   if (rc) {
+   printf("failed to get device for PMIC at address 0x%x\n",
+  PFUZE100_I2C_ADDR);
return 0;
}
/* get device ident */
-   if (i2c_read(PFUZE100_I2C_ADDR, PFUZE100_DEVICEID, 1, , 1) < 0) {
+   if (dm_i2c_read(dev, PFUZE100_DEVICEID, , 1) < 0) {
puts("i2c pmic devid read failed\n");
return 0;
}
-   

[U-Boot] [PATCH v1 18/26] colibri imx6: disable ri and dcd irq in uarts

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

If the UART is used in DTE mode the RI and DCD bits in UCR3 become
irq enable bits. Both are set to enabled after reset and both likely
are pending.

Disable the bits also on UARTs not used in the boot loader to prevent
an interrupt storm when Linux enables the UART interrupts.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 3d72a315b4..76b776e17e 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -271,14 +271,21 @@ iomux_v3_cfg_t const usb_pads[] = {
  * UARTs are used in DTE mode, switch the mode on all UARTs before
  * any pinmuxing connects a (DCE) output to a transceiver output.
  */
+#define UCR3   0x88/* FIFO Control Register */
+#define UCR3_RIBIT(8)  /* RIDELT DTE mode */
+#define UCR3_DCD   BIT(9)  /* DCDDELT DTE mode */
 #define UFCR   0x90/* FIFO Control Register */
-#define UFCR_DCEDTE(1<<6)  /* DCE=0 */
+#define UFCR_DCEDTEBIT(6)  /* DCE=0 */
 
 static void setup_dtemode_uart(void)
 {
setbits_le32((u32 *)(UART1_BASE + UFCR), UFCR_DCEDTE);
setbits_le32((u32 *)(UART2_BASE + UFCR), UFCR_DCEDTE);
setbits_le32((u32 *)(UART3_BASE + UFCR), UFCR_DCEDTE);
+
+   clrbits_le32((u32 *)(UART1_BASE + UCR3), UCR3_DCD | UCR3_RI);
+   clrbits_le32((u32 *)(UART2_BASE + UCR3), UCR3_DCD | UCR3_RI);
+   clrbits_le32((u32 *)(UART3_BASE + UCR3), UCR3_DCD | UCR3_RI);
 }
 
 static void setup_iomux_uart(void)
-- 
2.20.1

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


[U-Boot] [PATCH v1 16/26] colibri_imx6: unify sd/mmc drive strenght with linux kernel settings

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

In the linux device tree we use 40Ohm drive strenght. So use the same
value in U-Boot.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 24 +--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 439d38bc29..3d72a315b4 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -42,6 +42,10 @@ DECLARE_GLOBAL_DATA_PTR;
PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
 
 #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP |   \
+   PAD_CTL_SPEED_LOW | PAD_CTL_DSE_40ohm | \
+   PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
+
+#define USDHC_EMMC_PAD_CTRL (PAD_CTL_PUS_47K_UP |  \
PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
 
@@ -92,16 +96,16 @@ iomux_v3_cfg_t const usdhc1_pads[] = {
 
 /* eMMC */
 iomux_v3_cfg_t const usdhc3_pads[] = {
-   MX6_PAD_SD3_CLK__SD3_CLK| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_CMD__SD3_CMD| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+   MX6_PAD_SD3_CLK__SD3_CLK| MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_CMD__SD3_CMD| MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
MX6_PAD_SD3_RST__SD3_RESET  | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 };
 #endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
-- 
2.20.1

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


[U-Boot] [PATCH v1 11/26] colibri_imx6: migrate mmc to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate MMC to using driver model.

Signed-off-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 38 +++
 configs/colibri_imx6_defconfig|  1 +
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index f5cfeb30bc..ef4dd0c87c 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -77,6 +77,7 @@ iomux_v3_cfg_t const uart1_pads[] = {
MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
 /* Colibri MMC */
 iomux_v3_cfg_t const usdhc1_pads[] = {
MX6_PAD_SD1_CLK__SD1_CLK| MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -103,6 +104,7 @@ iomux_v3_cfg_t const usdhc3_pads[] = {
MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_RST__SD3_RESET  | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 };
+#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
 
 iomux_v3_cfg_t const enet_pads[] = {
MX6_PAD_ENET_MDC__ENET_MDC  | MUX_PAD_CTRL(ENET_PAD_CTRL),
@@ -310,7 +312,7 @@ int board_ehci_power(int port, int on)
 }
 #endif /* CONFIG_USB_EHCI_MX6 */
 
-#ifdef CONFIG_FSL_ESDHC
+#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
 /* use the following sequence: eMMC, MMC */
 struct fsl_esdhc_cfg usdhc_cfg[CONFIG_SYS_FSL_USDHC_NUM] = {
{USDHC3_BASE_ADDR},
@@ -335,37 +337,6 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
-#ifndef CONFIG_SPL_BUILD
-   s32 status = 0;
-   u32 index = 0;
-
-   usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
-   usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
-
-   usdhc_cfg[0].max_bus_width = 8;
-   usdhc_cfg[1].max_bus_width = 4;
-
-   for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
-   switch (index) {
-   case 0:
-   imx_iomux_v3_setup_multiple_pads(
-   usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
-   break;
-   case 1:
-   imx_iomux_v3_setup_multiple_pads(
-   usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
-   break;
-   default:
-   printf("Warning: you configured more USDHC controllers 
(%d) then supported by the board (%d)\n",
-  index + 1, CONFIG_SYS_FSL_USDHC_NUM);
-   return status;
-   }
-
-   status |= fsl_esdhc_initialize(bis, _cfg[index]);
-   }
-
-   return status;
-#else /* !CONFIG_SPL_BUILD */
struct src *psrc = (struct src *)SRC_BASE_ADDR;
unsigned reg = readl(>sbmr1) >> 11;
/*
@@ -397,9 +368,8 @@ int board_mmc_init(bd_t *bis)
}
 
return fsl_esdhc_initialize(bis, _cfg[0]);
-#endif /* !CONFIG_SPL_BUILD */
 }
-#endif /* CONFIG_FSL_ESDHC */
+#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
 
 int board_phy_config(struct phy_device *phydev)
 {
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 6fd050a99f..2ab7db44a8 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -54,6 +54,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DFU_MMC=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_I2C=y
+CONFIG_DM_MMC=y
 CONFIG_FSL_ESDHC=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
-- 
2.20.1

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


[U-Boot] [PATCH v1 19/26] colibri_imx6: change pmic fusing according to hw 1.1 requirements

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

Colibri iMX6 V1.1 HW can use the PMIC GEN3 to power the NVCC_SD1.
Change the settings fused into the PMIC's OTP to powerup with
GEN3 set to output 3.3V.

Signed-off-by: Max Krummenacher 
Acked-by: Stefan Agner 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/pf0100_otp.inc | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/board/toradex/colibri_imx6/pf0100_otp.inc 
b/board/toradex/colibri_imx6/pf0100_otp.inc
index ce29b95ae2..c3b1f67f81 100644
--- a/board/toradex/colibri_imx6/pf0100_otp.inc
+++ b/board/toradex/colibri_imx6/pf0100_otp.inc
@@ -5,16 +5,17 @@
 
 // Register Output for PF0100 programmer
 // Customer: Toradex AG
-// Program: Colibri iMX6
+// Program: Colibri iMX6 V1.1
 // Sample marking:
-// Date: 24.07.2015
-// Time: 10:52:58
+// Date: 01.05.2017
+// Time: 16:22:32
 // Generated from Spreadsheet Revision: P1.8
 
-/* sed commands to get from programmer script to struct */
+/* sed commands to get from programmer script to struct content */
 /* sed -e 's/^WRITE_I2C:\(..\):\(..\)/\{pmic_i2c, 0x\1, 0x\2\},/g' -e 
's/^DELAY:\([0-9]*\)/\{pmic_delay, 0, \1\},/g' pf0100_otp_Colibri_iMX6.txt > 
pf0100_otp.inc
sed -i -e 's/^VPGM:ON/\{pmic_vpgm, 0, 1},/g' -e 's/^VPGM:OFF/\{pmic_vpgm, 
0, 0},/g' pf0100_otp.inc
-   sed -i -e 's/^PWRON: HIGH/\{pmic_pwr, 0, 1},/g' -e 
's/^PWRON:LOW/\{pmic_pwr, 0, 0},/g' pf0100_otp.inc */
+   sed -i -e 's/^PWRON: HIGH/\{pmic_pwr, 0, 1},/g' -e 
's/^PWRON:LOW/\{pmic_pwr, 0, 0},/g' pf0100_otp.inc
+*/
 
 enum { pmic_i2c, pmic_delay, pmic_vpgm, pmic_pwr };
 struct pmic_otp_prog_t{
@@ -47,7 +48,8 @@ struct pmic_otp_prog_t pmic_otp_prog[] = {
 {pmic_i2c, 0xC8, 0x0E}, // Auto gen from Row134
 {pmic_i2c, 0xCC, 0x0E}, // Auto gen from Row138
 {pmic_i2c, 0xCD, 0x05}, // Auto gen from Row139
-{pmic_i2c, 0xD0, 0x0C}, // Auto gen from Row142
+{pmic_i2c, 0xD0, 0x0F}, // Auto gen from Row142
+{pmic_i2c, 0xD1, 0x05}, // Auto gen from Row143
 {pmic_i2c, 0xD5, 0x07}, // Auto gen from Row147
 {pmic_i2c, 0xD8, 0x07}, // Auto gen from Row150
 {pmic_i2c, 0xD9, 0x06}, // Auto gen from Row151
@@ -185,4 +187,4 @@ struct pmic_otp_prog_t pmic_otp_prog[] = {
 {pmic_delay, 0, 500},
 {pmic_pwr, 0, 1},
 #endif
-};
\ No newline at end of file
+};
-- 
2.20.1

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


[U-Boot] [PATCH v1 17/26] colibri imx6: pf0100: reorder and cleanup message printing

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

Keep debug code at the end of the function.
Use a one line informational message for the PMIC only.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/pf0100.c | 82 ++---
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/board/toradex/colibri_imx6/pf0100.c 
b/board/toradex/colibri_imx6/pf0100.c
index 5e411f1743..09c3cc950a 100644
--- a/board/toradex/colibri_imx6/pf0100.c
+++ b/board/toradex/colibri_imx6/pf0100.c
@@ -35,7 +35,7 @@ unsigned pmic_init(void)
uchar bus = 1;
uchar devid, revid, val;
 
-   puts("PMIC: ");
+   puts("PMIC:  ");
rc = i2c_get_chip_for_busnum(bus, PFUZE100_I2C_ADDR, 1, );
if (rc) {
printf("failed to get device for PMIC at address 0x%x\n",
@@ -51,7 +51,46 @@ unsigned pmic_init(void)
puts("i2c pmic revid read failed\n");
return 0;
}
-   printf("device id: 0x%.2x, revision id: 0x%.2x\n", devid, revid);
+   printf("device id: 0x%.2x, revision id: 0x%.2x, ", devid, revid);
+
+   /* get device programmed state */
+   val = PFUZE100_PAGE_REGISTER_PAGE1;
+   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
+   puts("i2c write failed\n");
+   return 0;
+   }
+   if (dm_i2c_read(dev, PFUZE100_FUSE_POR1, , 1) < 0) {
+   puts("i2c fuse_por read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_FUSE_POR_M)
+   programmed++;
+
+   if (dm_i2c_read(dev, PFUZE100_FUSE_POR2, , 1) < 0) {
+   puts("i2c fuse_por read failed\n");
+   return programmed;
+   }
+   if (val & PFUZE100_FUSE_POR_M)
+   programmed++;
+
+   if (dm_i2c_read(dev, PFUZE100_FUSE_POR3, , 1) < 0) {
+   puts("i2c fuse_por read failed\n");
+   return programmed;
+   }
+   if (val & PFUZE100_FUSE_POR_M)
+   programmed++;
+
+   switch (programmed) {
+   case 0:
+   puts("not programmed\n");
+   break;
+   case 3:
+   puts("programmed\n");
+   break;
+   default:
+   puts("undefined programming state\n");
+   break;
+   }
 
 #ifdef DEBUG
{
@@ -103,45 +142,6 @@ unsigned pmic_init(void)
}
 #endif /* DEBUG */
 
-   /* get device programmed state */
-   val = PFUZE100_PAGE_REGISTER_PAGE1;
-   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
-   puts("i2c write failed\n");
-   return 0;
-   }
-   if (dm_i2c_read(dev, PFUZE100_FUSE_POR1, , 1) < 0) {
-   puts("i2c fuse_por read failed\n");
-   return 0;
-   }
-   if (val & PFUZE100_FUSE_POR_M)
-   programmed++;
-
-   if (dm_i2c_read(dev, PFUZE100_FUSE_POR2, , 1) < 0) {
-   puts("i2c fuse_por read failed\n");
-   return programmed;
-   }
-   if (val & PFUZE100_FUSE_POR_M)
-   programmed++;
-
-   if (dm_i2c_read(dev, PFUZE100_FUSE_POR3, , 1) < 0) {
-   puts("i2c fuse_por read failed\n");
-   return programmed;
-   }
-   if (val & PFUZE100_FUSE_POR_M)
-   programmed++;
-
-   switch (programmed) {
-   case 0:
-   printf("PMIC: not programmed\n");
-   break;
-   case 3:
-   printf("PMIC: programmed\n");
-   break;
-   default:
-   printf("PMIC: undefined programming state\n");
-   break;
-   }
-
return programmed;
 }
 
-- 
2.20.1

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


[U-Boot] [PATCH v1 08/26] colibri_imx6: enable pin control driver

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Enable pin control driver as required for further driver model
migration.

Signed-off-by: Marcel Ziswiler 

---

 configs/colibri_imx6_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 27b85c61dc..481d65329f 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -55,6 +55,8 @@ CONFIG_FSL_ESDHC=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_MII=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_IMX6=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
-- 
2.20.1

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


[U-Boot] [PATCH v1 06/26] colibri_imx6: migrate to using device tree

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate to using device tree required for further driver model
integration.

Signed-off-by: Marcel Ziswiler 

---

 arch/arm/dts/imx6-colibri.dts  | 411 +
 board/toradex/colibri_imx6/MAINTAINERS |   2 +
 configs/colibri_imx6_defconfig |   3 +-
 3 files changed, 415 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx6-colibri.dts

diff --git a/arch/arm/dts/imx6-colibri.dts b/arch/arm/dts/imx6-colibri.dts
new file mode 100644
index 00..5c9f1f0d2b
--- /dev/null
+++ b/arch/arm/dts/imx6-colibri.dts
@@ -0,0 +1,411 @@
+// SPDX-License-Identifier: GPL-2.0+ OR X11
+/*
+ * Copyright 2019 Toradex AG
+ */
+
+/dts-v1/;
+#include 
+#include "imx6dl.dtsi"
+
+/ {
+   model = "Toradex Colibri iMX6DL/S";
+   compatible = "toradex,colibri_imx6dl", "fsl,imx6dl";
+
+   /* Will be filled by the bootloader */
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0>;
+   };
+
+   aliases {
+   mmc0 = 
+   mmc1 = 
+   usb0 =  /* required for ums */
+   };
+
+   chosen {
+   stdout-path = 
+   };
+
+   reg_module_3v3: regulator-module-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "+V3.3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   reg_usb_host_vbus: regulator-usb-host-vbus {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_regulator_usbh_pwr>;
+   regulator-name = "usb_host_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = < 31 GPIO_ACTIVE_LOW>; /* USBH_PEN */
+   };
+};
+
+/*
+ * PWR_I2C: power I2C to audio codec, PMIC, temperature sensor and
+ * touch screen controller
+ */
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c2>;
+   status = "okay";
+
+   pmic: pfuze100@8 {
+   compatible = "fsl,pfuze100";
+   reg = <0x08>;
+
+   regulators {
+   sw1a_reg: sw1ab {
+   regulator-min-microvolt = <30>;
+   regulator-max-microvolt = <1875000>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <6250>;
+   };
+
+   sw1c_reg: sw1c {
+   regulator-min-microvolt = <30>;
+   regulator-max-microvolt = <1875000>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <6250>;
+   };
+
+   sw3a_reg: sw3a {
+   regulator-min-microvolt = <40>;
+   regulator-max-microvolt = <1975000>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   swbst_reg: swbst {
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <515>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   snvs_reg: vsnvs {
+   regulator-min-microvolt = <100>;
+   regulator-max-microvolt = <300>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   vref_reg: vrefddr {
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   /* vgen1: unused */
+
+   vgen2_reg: vgen2 {
+   regulator-min-microvolt = <80>;
+   regulator-max-microvolt = <155>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   /* vgen3: unused */
+
+   vgen4_reg: vgen4 {
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   vgen5_reg: vgen5 {
+   regulator-min-microvolt = <180>;
+

[U-Boot] [PATCH v1 01/26] colibri_imx6: get rid of obsolete nospl configurations

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Now with SPL long since being in place even for recovery using SDP
finally get rid of those nospl configurations.

Signed-off-by: Marcel Ziswiler 

---

 .../toradex/colibri_imx6/800mhz_2x64mx16.cfg  | 58 ---
 .../toradex/colibri_imx6/800mhz_4x64mx16.cfg  | 58 ---
 board/toradex/colibri_imx6/MAINTAINERS|  1 -
 board/toradex/colibri_imx6/clocks.cfg | 41 
 board/toradex/colibri_imx6/colibri_imx6.cfg   | 37 ---
 board/toradex/colibri_imx6/ddr-setup.cfg  | 97 ---
 configs/colibri_imx6_nospl_defconfig  | 63 
 7 files changed, 355 deletions(-)
 delete mode 100644 board/toradex/colibri_imx6/800mhz_2x64mx16.cfg
 delete mode 100644 board/toradex/colibri_imx6/800mhz_4x64mx16.cfg
 delete mode 100644 board/toradex/colibri_imx6/clocks.cfg
 delete mode 100644 board/toradex/colibri_imx6/colibri_imx6.cfg
 delete mode 100644 board/toradex/colibri_imx6/ddr-setup.cfg
 delete mode 100644 configs/colibri_imx6_nospl_defconfig

diff --git a/board/toradex/colibri_imx6/800mhz_2x64mx16.cfg 
b/board/toradex/colibri_imx6/800mhz_2x64mx16.cfg
deleted file mode 100644
index c9407143d2..00
--- a/board/toradex/colibri_imx6/800mhz_2x64mx16.cfg
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2013 Boundary Devices
- * Copyright (C) 2014-2016, Toradex AG
- */
-
-DATA 4, MX6_MMDC_P0_MDPDC, 0x0002002D
-DATA 4, MX6_MMDC_P0_MDCFG0, 0x2C305503
-DATA 4, MX6_MMDC_P0_MDCFG1, 0xB66D8D63
-DATA 4, MX6_MMDC_P0_MDCFG2, 0x01FF00DB
-DATA 4, MX6_MMDC_P0_MDRWD, 0x26D2
-DATA 4, MX6_MMDC_P0_MDOR, 0x00301023
-DATA 4, MX6_MMDC_P0_MDOTC, 0x00333030
-DATA 4, MX6_MMDC_P0_MDPDC, 0x0002556D
-/* CS0 End: 7MSB of ((0x1000 + 512M) -1) >> 25 */
-DATA 4, MX6_MMDC_P0_MDASP, 0x0017
-/* DDR3 DATA BUS SIZE: 64BIT */
-/* DATA 4, MX6_MMDC_P0_MDCTL, 0x821A */
-/* DDR3 DATA BUS SIZE: 32BIT */
-DATA 4, MX6_MMDC_P0_MDCTL, 0x8219
-
-/* Write commands to DDR */
-/* Load Mode Registers */
-/* TODO Use Auto Self-Refresh mode (Extended Temperature)*/
-/* DATA 4, MX6_MMDC_P0_MDSCR, 0x04408032 */
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008032
-DATA 4, MX6_MMDC_P0_MDSCR, 0x8033
-DATA 4, MX6_MMDC_P0_MDSCR, 0x00048031
-DATA 4, MX6_MMDC_P0_MDSCR, 0x13208030
-/* ZQ calibration */
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008040
-
-DATA 4, MX6_MMDC_P0_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P1_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P0_MDREF, 0x5800
-
-DATA 4, MX6_MMDC_P0_MPODTCTRL, 0x
-DATA 4, MX6_MMDC_P1_MPODTCTRL, 0x
-
-DATA 4, MX6_MMDC_P0_MPDGCTRL0, 0x42360232
-DATA 4, MX6_MMDC_P0_MPDGCTRL1, 0x021F022A
-DATA 4, MX6_MMDC_P1_MPDGCTRL0, 0x421E0224
-DATA 4, MX6_MMDC_P1_MPDGCTRL1, 0x02110218
-
-DATA 4, MX6_MMDC_P0_MPRDDLCTL, 0x41434344
-DATA 4, MX6_MMDC_P1_MPRDDLCTL, 0x4345423E
-DATA 4, MX6_MMDC_P0_MPWRDLCTL, 0x39383339
-DATA 4, MX6_MMDC_P1_MPWRDLCTL, 0x3E363930
-
-DATA 4, MX6_MMDC_P0_MPWLDECTRL0, 0x00340039
-DATA 4, MX6_MMDC_P0_MPWLDECTRL1, 0x002C002D
-DATA 4, MX6_MMDC_P1_MPWLDECTRL0, 0x00120019
-DATA 4, MX6_MMDC_P1_MPWLDECTRL1, 0x0012002D
-
-DATA 4, MX6_MMDC_P0_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P1_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P0_MDSCR, 0x
-DATA 4, MX6_MMDC_P0_MAPSR, 0x00011006
diff --git a/board/toradex/colibri_imx6/800mhz_4x64mx16.cfg 
b/board/toradex/colibri_imx6/800mhz_4x64mx16.cfg
deleted file mode 100644
index c319d2a729..00
--- a/board/toradex/colibri_imx6/800mhz_4x64mx16.cfg
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2013 Boundary Devices
- * Copyright (C) 2014-2016, Toradex AG
- */
-
-DATA 4, MX6_MMDC_P0_MDPDC, 0x0002002D
-DATA 4, MX6_MMDC_P0_MDCFG0, 0x2C305503
-DATA 4, MX6_MMDC_P0_MDCFG1, 0xB66D8D63
-DATA 4, MX6_MMDC_P0_MDCFG2, 0x01FF00DB
-DATA 4, MX6_MMDC_P0_MDRWD, 0x26D2
-DATA 4, MX6_MMDC_P0_MDOR, 0x00301023
-DATA 4, MX6_MMDC_P0_MDOTC, 0x00333030
-DATA 4, MX6_MMDC_P0_MDPDC, 0x0002556D
-/* CS0 End: 7MSB of ((0x1000 + 512M) -1) >> 25 */
-DATA 4, MX6_MMDC_P0_MDASP, 0x0017
-/* DDR3 DATA BUS SIZE: 64BIT */
-DATA 4, MX6_MMDC_P0_MDCTL, 0x821A
-/* DDR3 DATA BUS SIZE: 32BIT */
-/* DATA 4, MX6_MMDC_P0_MDCTL, 0x8219 */
-
-/* Write commands to DDR */
-/* Load Mode Registers */
-/* TODO Use Auto Self-Refresh mode (Extended Temperature)*/
-/* DATA 4, MX6_MMDC_P0_MDSCR, 0x04408032 */
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008032
-DATA 4, MX6_MMDC_P0_MDSCR, 0x8033
-DATA 4, MX6_MMDC_P0_MDSCR, 0x00048031
-DATA 4, MX6_MMDC_P0_MDSCR, 0x13208030
-/* ZQ calibration */
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008040
-
-DATA 4, MX6_MMDC_P0_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P1_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P0_MDREF, 0x5800
-
-DATA 4, MX6_MMDC_P0_MPODTCTRL, 0x
-DATA 4, MX6_MMDC_P1_MPODTCTRL, 0x
-
-DATA 4, MX6_MMDC_P0_MPDGCTRL0, 0x42360232
-DATA 4, MX6_MMDC_P0_MPDGCTRL1, 0x021F022A
-DATA 4, MX6_MMDC_P1_MPDGCTRL0, 0x421E0224
-DATA 4, MX6_MMDC_P1_MPDGCTRL1, 0x02110218
-
-DATA 4, MX6_MMDC_P0_MPRDDLCTL, 

[U-Boot] [PATCH v1 21/26] toradex: colibri_imx6: overwrite CMA memory set in device tree

2019-02-08 Thread Marcel Ziswiler
From: Bhuvanchandra DV 

Make sure CMA memory is not greater than 50% of available physical
memory.

Allow user to change the CMA memory via 'cma-size' U-Boot environment
variable.

Signed-off-by: Bhuvanchandra DV 
Acked-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 76b776e17e..fd988bd2b0 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -679,7 +680,18 @@ int checkboard(void)
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, bd_t *bd)
 {
-   return ft_common_board_setup(blob, bd);
+   u32 cma_size;
+
+   ft_common_board_setup(blob, bd);
+
+   cma_size = getenv_ulong("cma-size", 10, 320 * 1024 * 1024);
+   cma_size = min((u32)(gd->ram_size >> 1), cma_size);
+
+   fdt_setprop_u32(blob,
+   fdt_path_offset(blob, "/reserved-memory/linux,cma"),
+   "size",
+   cma_size);
+   return 0;
 }
 #endif
 
-- 
2.20.1

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


[U-Boot] [PATCH v1 04/26] colibri_imx6: enable fit image, gpt, imx thermal, efi loader support

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Enbale FIT image, GPT command, i.MX thermal and EFI loader support.

Signed-off-by: Marcel Ziswiler 

---

 configs/colibri_imx6_defconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 0b31a46cc9..84fa427c8c 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -11,6 +11,7 @@ CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6DL"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
@@ -36,6 +37,7 @@ CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_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
@@ -50,6 +52,7 @@ CONFIG_FSL_ESDHC=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_MII=y
+CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
@@ -63,4 +66,3 @@ CONFIG_VIDEO=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-# CONFIG_EFI_LOADER is not set
-- 
2.20.1

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


[U-Boot] [PATCH v1 10/26] colibri_imx6: migrate pmic and regulator to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate PMIC and regulator to using driver model.

Signed-off-by: Marcel Ziswiler 

---

 configs/colibri_imx6_defconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index dea6ca6270..6fd050a99f 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -45,6 +45,8 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6-colibri"
 CONFIG_ENV_IS_IN_MMC=y
@@ -58,6 +60,11 @@ CONFIG_PHY_MICREL=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_DM_PMIC=y
+CONFIG_DM_PMIC_PFUZE100=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_PFUZE100=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
-- 
2.20.1

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


[U-Boot] [PATCH v1 12/26] colibri_imx6: migrate usb to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate USB to using driver model.

Signed-off-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 23 +--
 configs/colibri_imx6_defconfig|  1 +
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index ef4dd0c87c..adb5a3df4c 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -289,28 +289,7 @@ int board_ehci_hcd_init(int port)
imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads));
return 0;
 }
-
-int board_ehci_power(int port, int on)
-{
-   switch (port) {
-   case 0:
-   /* control OTG power */
-   /* No special PE for USBC, always on when ID pin signals
-  host mode */
-   break;
-   case 1:
-   /* Control MXM USBH */
-   /* Set MXM USBH power enable, '0' means on */
-   gpio_request(GPIO_USBH_EN, "USBH_EN");
-   gpio_direction_output(GPIO_USBH_EN, !on);
-   mdelay(100);
-   break;
-   default:
-   break;
-   }
-   return 0;
-}
-#endif /* CONFIG_USB_EHCI_MX6 */
+#endif
 
 #if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
 /* use the following sequence: eMMC, MMC */
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 2ab7db44a8..df5a7be39f 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -68,6 +68,7 @@ CONFIG_DM_REGULATOR_PFUZE100=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Toradex"
-- 
2.20.1

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


[U-Boot] [PATCH v1 05/26] colibri_imx6: remove obsolete USB_GADGET_MASS_STORAGE configuration

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Remove obsolete USB_GADGET_MASS_STORAGE configuration.

Signed-off-by: Marcel Ziswiler 

---

 include/configs/colibri_imx6.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 9e45d63245..f029a885d2 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -70,8 +70,6 @@
 /* Client */
 #define CONFIG_USBD_HS
 
-#define CONFIG_USB_GADGET_MASS_STORAGE
-
 /* Framebuffer and LCD */
 #define CONFIG_VIDEO_IPUV3
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
-- 
2.20.1

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


[U-Boot] [PATCH v1 07/26] colibri_imx6: clean-up and migrate gpios to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate GPIOs to using driver model, properly request backlight, MMC/SD
card detect and USB power enable GPIOs and also enable SION bit in pin
muxing for auxiliary, backlight and USB power enable GPIOs.

While at it also update copyright year, clean-up/re-order includes, add
some comments clarifying ifdef scope and do some white-space clean-up.

Signed-off-by: Marcel Ziswiler 

---

 board/toradex/colibri_imx6/colibri_imx6.c | 209 ++
 configs/colibri_imx6_defconfig|   1 +
 2 files changed, 135 insertions(+), 75 deletions(-)

diff --git a/board/toradex/colibri_imx6/colibri_imx6.c 
b/board/toradex/colibri_imx6/colibri_imx6.c
index 68c0c02a8a..1f5de2f5f6 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -2,39 +2,34 @@
 /*
  * Copyright (C) 2010-2013 Freescale Semiconductor, Inc.
  * Copyright (C) 2013, Boundary Devices 
- * Copyright (C) 2014-2016, Toradex AG
+ * Copyright (C) 2014-2019, Toradex AG
  * copied from nitrogen6x
  */
 
 #include 
 #include 
+
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
-#include 
 #include 
 
 #include "../common/tdx-cfg-block.h"
@@ -173,68 +168,123 @@ static void setup_iomux_enet(void)
 /* mux auxiliary pins to GPIO, so they can be used from the U-Boot cmdline */
 iomux_v3_cfg_t const gpio_pads[] = {
/* ADDRESS[17:18] [25] used as GPIO */
-   MX6_PAD_KEY_ROW2__GPIO4_IO11| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_KEY_COL2__GPIO4_IO10| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_D1__GPIO2_IO01| MUX_PAD_CTRL(WEAK_PULLUP),
+   MX6_PAD_KEY_ROW2__GPIO4_IO11| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_KEY_COL2__GPIO4_IO10| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_D1__GPIO2_IO01| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
/* ADDRESS[19:24] used as GPIO */
-   MX6_PAD_DISP0_DAT23__GPIO5_IO17 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_DISP0_DAT22__GPIO5_IO16 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_DISP0_DAT21__GPIO5_IO15 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_DISP0_DAT20__GPIO5_IO14 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_DISP0_DAT19__GPIO5_IO13 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_DISP0_DAT18__GPIO5_IO12 | MUX_PAD_CTRL(WEAK_PULLUP),
+   MX6_PAD_DISP0_DAT23__GPIO5_IO17 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_DISP0_DAT22__GPIO5_IO16 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_DISP0_DAT21__GPIO5_IO15 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_DISP0_DAT20__GPIO5_IO14 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_DISP0_DAT19__GPIO5_IO13 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_DISP0_DAT18__GPIO5_IO12 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
/* DATA[16:29] [31]  used as GPIO */
-   MX6_PAD_EIM_LBA__GPIO2_IO27 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_EIM_BCLK__GPIO6_IO31| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_CS3__GPIO6_IO16   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_CS1__GPIO6_IO14   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_RB0__GPIO6_IO10   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_ALE__GPIO6_IO08   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_WP_B__GPIO6_IO09  | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_CS0__GPIO6_IO11   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_CLE__GPIO6_IO07   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_19__GPIO4_IO05 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_CSI0_MCLK__GPIO5_IO19   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_CSI0_PIXCLK__GPIO5_IO18 | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_4__GPIO1_IO04  | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_5__GPIO1_IO05  | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_2__GPIO1_IO02  | MUX_PAD_CTRL(WEAK_PULLUP),
+   MX6_PAD_EIM_LBA__GPIO2_IO27 | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_EIM_BCLK__GPIO6_IO31| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_CS3__GPIO6_IO16   | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_CS1__GPIO6_IO14   | 

[U-Boot] [PATCH v1 02/26] colibri_imx6: use distro defaults

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Use distro defaults and minimise default configuration again using
savedefconfig.

Signed-off-by: Marcel Ziswiler 

---

 configs/colibri_imx6_defconfig | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 2072281354..699eb70088 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -9,12 +9,11 @@ CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
-CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6DL"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
-CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
@@ -26,9 +25,7 @@ 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_SYS_PROMPT="Colibri iMX6 # "
-CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_ELF is not set
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
@@ -43,14 +40,8 @@ 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_MII=y
-CONFIG_CMD_PING=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DFU_MMC=y
@@ -59,7 +50,6 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_MII=y
 CONFIG_USB=y
-CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Toradex"
-- 
2.20.1

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


[U-Boot] [PATCH v1 03/26] colibri_imx6: move console in env from header file to defconfig

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Move console in env from header file to defconfig.

While at it also update copyright year.

Signed-off-by: Marcel Ziswiler 

---

 configs/colibri_imx6_defconfig | 1 +
 include/configs/colibri_imx6.h | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 699eb70088..0b31a46cc9 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -14,6 +14,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6DL"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 2d40ceb24e..9e45d63245 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright 2013-2015 Toradex, Inc.
+ * Copyright 2013-2019 Toradex, Inc.
  *
  * Configuration settings for the Toradex Colibri iMX6
  */
@@ -74,7 +74,6 @@
 
 /* Framebuffer and LCD */
 #define CONFIG_VIDEO_IPUV3
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_VIDEO_BMP_RLE8
 #define CONFIG_SPLASH_SCREEN
-- 
2.20.1

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


[U-Boot] [PATCH v3 0/3] stm32mp1: add trusted boot with TF-A

2019-02-08 Thread Patrick Delaunay

This patch serie add a new configuration
stm32mp15_trusted_defconfig to handle STM32MP157 boards
with TF-A as secure first stage bootloader.

TF-A code is available in GitHub
https://github.com/ARM-software/arm-trusted-firmware

With platform stm32mp1 platform
https://github.com/ARM-software/arm-trusted-firmware/tree/master/plat/st/stm32mp1

For details, see documentation
https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/stm32mp1.rst

PS: upstream of trusted boot for TF-A is still in progress.


Changes in v3:
- Remove patch 4/4 added by error in v2 and sent by other serie
  http://patchwork.ozlabs.org/patch/1033475/

Changes in v2:
- Rebase and solve conflict on arch/arm/mach-stm32mp/config.mk

Patrick Delaunay (3):
  stm32mp1: add trusted boot with TF-A
  stm32mp1: bsec: access with SMC for trusted boot
  stm32mp1: display board information

 arch/arm/Kconfig  |  6 ++-
 arch/arm/mach-stm32mp/Kconfig | 17 --
 arch/arm/mach-stm32mp/bsec.c  | 28 ++
 arch/arm/mach-stm32mp/config.mk   | 15 +-
 arch/arm/mach-stm32mp/cpu.c   |  9 +++-
 arch/arm/mach-stm32mp/include/mach/stm32.h|  4 ++
 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h | 64 +++
 board/st/stm32mp1/MAINTAINERS |  5 +-
 board/st/stm32mp1/README  | 56 ++--
 board/st/stm32mp1/stm32mp1.c  | 44 +++-
 configs/stm32mp15_trusted_defconfig   | 57 
 drivers/clk/clk_stm32mp1.c|  2 +
 drivers/ram/stm32mp1/stm32mp1_ram.c   |  3 +-
 include/configs/stm32mp1.h|  2 +
 14 files changed, 282 insertions(+), 30 deletions(-)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
 create mode 100644 configs/stm32mp15_trusted_defconfig

-- 
2.7.4

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


[U-Boot] [PATCH v5 2/3] net: phy: ti: use generic helpers to access MMD registers

2019-02-08 Thread Carlo Caione
Now that generic helpers are available, use those instead of relying on
ti specific functions.

Signed-off-by: Carlo Caione 
Signed-off-by: Vladimir Oltean 
Acked-by: Joe Hershberger 
---
 drivers/net/phy/ti.c | 130 +--
 1 file changed, 25 insertions(+), 105 deletions(-)

diff --git a/drivers/net/phy/ti.c b/drivers/net/phy/ti.c
index 6db6edd0d0..6ac890a7f5 100644
--- a/drivers/net/phy/ti.c
+++ b/drivers/net/phy/ti.c
@@ -73,16 +73,6 @@
 #define MII_DP83867_CFG2_SPEEDOPT_INTLOW   0x2000
 #define MII_DP83867_CFG2_MASK  0x003F
 
-#define MII_MMD_CTRL   0x0d /* MMD Access Control Register */
-#define MII_MMD_DATA   0x0e /* MMD Access Data Register */
-
-/* MMD Access Control register fields */
-#define MII_MMD_CTRL_DEVAD_MASK0x1f /* Mask MMD DEVAD*/
-#define MII_MMD_CTRL_ADDR  0x /* Address */
-#define MII_MMD_CTRL_NOINCR0x4000 /* no post increment */
-#define MII_MMD_CTRL_INCR_RDWT 0x8000 /* post increment on reads & writes */
-#define MII_MMD_CTRL_INCR_ON_WT0xC000 /* post increment on writes only 
*/
-
 /* User setting - can be taken from DTS */
 #define DEFAULT_RX_ID_DELAYDP83867_RGMIIDCTL_2_25_NS
 #define DEFAULT_TX_ID_DELAYDP83867_RGMIIDCTL_2_75_NS
@@ -116,88 +106,20 @@ struct dp83867_private {
int clk_output_sel;
 };
 
-/**
- * phy_read_mmd_indirect - reads data from the MMD registers
- * @phydev: The PHY device bus
- * @prtad: MMD Address
- * @devad: MMD DEVAD
- * @addr: PHY address on the MII bus
- *
- * Description: it reads data from the MMD registers (clause 22 to access to
- * clause 45) of the specified phy address.
- * To read these registers we have:
- * 1) Write reg 13 // DEVAD
- * 2) Write reg 14 // MMD Address
- * 3) Write reg 13 // MMD Data Command for MMD DEVAD
- * 3) Read  reg 14 // Read MMD data
- */
-int phy_read_mmd_indirect(struct phy_device *phydev, int prtad,
- int devad, int addr)
-{
-   int value = -1;
-
-   /* Write the desired MMD Devad */
-   phy_write(phydev, addr, MII_MMD_CTRL, devad);
-
-   /* Write the desired MMD register address */
-   phy_write(phydev, addr, MII_MMD_DATA, prtad);
-
-   /* Select the Function : DATA with no post increment */
-   phy_write(phydev, addr, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
-
-   /* Read the content of the MMD's selected register */
-   value = phy_read(phydev, addr, MII_MMD_DATA);
-   return value;
-}
-
-/**
- * phy_write_mmd_indirect - writes data to the MMD registers
- * @phydev: The PHY device
- * @prtad: MMD Address
- * @devad: MMD DEVAD
- * @addr: PHY address on the MII bus
- * @data: data to write in the MMD register
- *
- * Description: Write data from the MMD registers of the specified
- * phy address.
- * To write these registers we have:
- * 1) Write reg 13 // DEVAD
- * 2) Write reg 14 // MMD Address
- * 3) Write reg 13 // MMD Data Command for MMD DEVAD
- * 3) Write reg 14 // Write MMD data
- */
-void phy_write_mmd_indirect(struct phy_device *phydev, int prtad,
-   int devad, int addr, u32 data)
-{
-   /* Write the desired MMD Devad */
-   phy_write(phydev, addr, MII_MMD_CTRL, devad);
-
-   /* Write the desired MMD register address */
-   phy_write(phydev, addr, MII_MMD_DATA, prtad);
-
-   /* Select the Function : DATA with no post increment */
-   phy_write(phydev, addr, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
-
-   /* Write the data into MMD's selected register */
-   phy_write(phydev, addr, MII_MMD_DATA, data);
-}
-
 static int dp83867_config_port_mirroring(struct phy_device *phydev)
 {
struct dp83867_private *dp83867 =
(struct dp83867_private *)phydev->priv;
u16 val;
 
-   val = phy_read_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR,
-   phydev->addr);
+   val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4);
 
if (dp83867->port_mirroring == DP83867_PORT_MIRRORING_EN)
val |= DP83867_CFG4_PORT_MIRROR_EN;
else
val &= ~DP83867_CFG4_PORT_MIRROR_EN;
 
-   phy_write_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR,
-  phydev->addr, val);
+   phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4, val);
 
return 0;
 }
@@ -257,13 +179,13 @@ static int dp83867_of_init(struct phy_device *phydev)
 
/* Clock output selection if muxing property is set */
if (dp83867->clk_output_sel != DP83867_CLK_O_SEL_REF_CLK) {
-   val = phy_read_mmd_indirect(phydev, DP83867_IO_MUX_CFG,
-   DP83867_DEVADDR, phydev->addr);
+   val = phy_read_mmd(phydev, DP83867_DEVADDR,
+  DP83867_IO_MUX_CFG);
val &= ~DP83867_IO_MUX_CFG_CLK_O_SEL_MASK;
val |= (dp83867->clk_output_sel <<

[U-Boot] [PATCH v5 3/3] cmd: mdio: Switch to generic helpers when accessing the registers

2019-02-08 Thread Carlo Caione
Switch to use the generic helpers to access the MMD registers so that we
can used the same command also for C45 PHYs, C22 PHYs with direct and
indirect access and PHYs implementing a custom way to access the
registers.

Signed-off-by: Carlo Caione 
---
 cmd/mdio.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/cmd/mdio.c b/cmd/mdio.c
index 184868063a..efe8c9ef09 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -39,21 +39,24 @@ static int extract_range(char *input, int *plo, int *phi)
return 0;
 }
 
-static int mdio_write_ranges(struct phy_device *phydev, struct mii_dev *bus,
+static int mdio_write_ranges(struct mii_dev *bus,
 int addrlo,
 int addrhi, int devadlo, int devadhi,
 int reglo, int reghi, unsigned short data,
 int extended)
 {
+   struct phy_device *phydev;
int addr, devad, reg;
int err = 0;
 
for (addr = addrlo; addr <= addrhi; addr++) {
+   phydev = bus->phymap[addr];
+
for (devad = devadlo; devad <= devadhi; devad++) {
for (reg = reglo; reg <= reghi; reg++) {
if (!extended)
-   err = bus->write(bus, addr, devad,
-reg, data);
+   err = phy_write_mmd(phydev, devad,
+   reg, data);
else
err = phydev->drv->writeext(phydev,
addr, devad, reg, data);
@@ -68,15 +71,17 @@ err_out:
return err;
 }
 
-static int mdio_read_ranges(struct phy_device *phydev, struct mii_dev *bus,
+static int mdio_read_ranges(struct mii_dev *bus,
int addrlo,
int addrhi, int devadlo, int devadhi,
int reglo, int reghi, int extended)
 {
int addr, devad, reg;
+   struct phy_device *phydev;
 
printf("Reading from bus %s\n", bus->name);
for (addr = addrlo; addr <= addrhi; addr++) {
+   phydev = bus->phymap[addr];
printf("PHY at address %x:\n", addr);
 
for (devad = devadlo; devad <= devadhi; devad++) {
@@ -84,7 +89,7 @@ static int mdio_read_ranges(struct phy_device *phydev, struct 
mii_dev *bus,
int val;
 
if (!extended)
-   val = bus->read(bus, addr, devad, reg);
+   val = phy_read_mmd(phydev, devad, reg);
else
val = phydev->drv->readext(phydev, addr,
devad, reg);
@@ -222,14 +227,14 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
bus = phydev->bus;
extended = 1;
} else {
-   return -1;
+   return CMD_RET_FAILURE;
}
 
if (!phydev->drv ||
(!phydev->drv->writeext && (op[0] == 'w')) ||
(!phydev->drv->readext && (op[0] == 'r'))) {
puts("PHY does not have extended functions\n");
-   return -1;
+   return CMD_RET_FAILURE;
}
}
}
@@ -242,13 +247,13 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
if (pos > 1)
if (extract_reg_range(argv[pos--], , ,
  , ))
-   return -1;
+   return CMD_RET_FAILURE;
 
default:
if (pos > 1)
if (extract_phy_range([2], pos - 1, ,
  , , ))
-   return -1;
+   return CMD_RET_FAILURE;
 
break;
}
@@ -264,12 +269,12 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
switch (op[0]) {
case 'w':
-   mdio_write_ranges(phydev, bus, addrlo, addrhi, devadlo, devadhi,
+   mdio_write_ranges(bus, addrlo, addrhi, devadlo, devadhi,
  reglo, reghi, data, extended);
break;
 
case 'r':
-   mdio_read_ranges(phydev, bus, addrlo, addrhi, devadlo, devadhi,
+   mdio_read_ranges(bus, addrlo, addrhi, devadlo, devadhi,
 

[U-Boot] [PATCH v3 3/3] stm32mp1: display board information

2019-02-08 Thread Patrick Delaunay
Implement checkboard() function to display
- the boot chain used: basic or trusted
- the board compatible in device tree
- the board identifier and revision, saved in OTP59 for ST boards

Signed-off-by: Patrick Delaunay 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-stm32mp/include/mach/stm32.h |  4 +++
 board/st/stm32mp1/stm32mp1.c   | 44 --
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h 
b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 5d0bdca..85d783c 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -98,7 +98,11 @@ enum boot_device {
 
 /* offset used for BSEC driver: misc_read and misc_write */
 #define STM32_BSEC_SHADOW_OFFSET   0x0
+#define STM32_BSEC_SHADOW(id)  (STM32_BSEC_SHADOW_OFFSET + (id) * 4)
 #define STM32_BSEC_OTP_OFFSET  0x8000
+#define STM32_BSEC_OTP(id) (STM32_BSEC_OTP_OFFSET + (id) * 4)
+
+#define BSEC_OTP_BOARD 59
 
 #endif /* __ASSEMBLY__*/
 #endif /* _MACH_STM32_H_ */
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 54feca0..07d1add 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -3,11 +3,12 @@
  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  */
 #include 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +27,45 @@ DECLARE_GLOBAL_DATA_PTR;
 #define STM32MP_GGPIO 0x38
 #define STM32MP_GGPIO_VBUS_SENSING BIT(21)
 
+int checkboard(void)
+{
+   int ret;
+   char *mode;
+   u32 otp;
+   struct udevice *dev;
+   const char *fdt_compat;
+   int fdt_compat_len;
+
+   if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+   mode = "trusted";
+   else
+   mode = "basic";
+
+   printf("Board: stm32mp1 in %s mode", mode);
+   fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
+_compat_len);
+   if (fdt_compat && fdt_compat_len)
+   printf(" (%s)", fdt_compat);
+   puts("\n");
+
+   ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ );
+
+   if (!ret)
+   ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
+   , sizeof(otp));
+   if (!ret && otp) {
+   printf("Board: MB%04x Var%d Rev.%c-%02d\n",
+  otp >> 16,
+  (otp >> 12) & 0xF,
+  ((otp >> 8) & 0xF) - 1 + 'A',
+  otp & 0xF);
+   }
+
+   return 0;
+}
+
 static struct dwc2_plat_otg_data stm32mp_otg_data = {
.usb_gusbcfg = STM32MP_GUSBCFG,
 };
-- 
2.7.4

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


[U-Boot] [PATCH v5 1/3] net: phy: Add generic helpers to access MMD PHY registers

2019-02-08 Thread Carlo Caione
Two new helper functions (phy_read_mmd() and phy_write_mmd()) are added
to allow access to the MMD PHY registers.

The MMD PHY registers can be accessed by several means:

1. Using two new MMD access function hooks in the PHY driver. These
functions can be implemented when the PHY driver does not support the
standard IEEE Compatible clause 45 access mechanism described in clause
22 or if the PHY uses its own non-standard access mechanism.

2. Direct access for C45 PHYs and C22 PHYs when accessing the reachable
DEVADs.

3. The standard clause 45 access extensions to the MMD registers through
the indirection registers (clause 22) in all the other cases.

Signed-off-by: Carlo Caione 
---
 drivers/net/phy/phy.c |  4 +++
 include/phy.h | 70 +++
 2 files changed, 74 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index cda4caa803..6769047407 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -549,6 +549,10 @@ int phy_register(struct phy_driver *drv)
drv->readext += gd->reloc_off;
if (drv->writeext)
drv->writeext += gd->reloc_off;
+   if (drv->read_mmd)
+   drv->read_mmd += gd->reloc_off;
+   if (drv->write_mmd)
+   drv->write_mmd += gd->reloc_off;
 #endif
return 0;
 }
diff --git a/include/phy.h b/include/phy.h
index b86fdfb2ce..7ec2b4e86c 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -101,6 +101,14 @@ struct phy_driver {
int (*readext)(struct phy_device *phydev, int addr, int devad, int reg);
int (*writeext)(struct phy_device *phydev, int addr, int devad, int reg,
u16 val);
+
+   /* Phy specific driver override for reading a MMD register */
+   int (*read_mmd)(struct phy_device *phydev, int devad, int reg);
+
+   /* Phy specific driver override for writing a MMD register */
+   int (*write_mmd)(struct phy_device *phydev, int devad, int reg,
+u16 val);
+
struct list_head list;
 };
 
@@ -164,6 +172,68 @@ static inline int phy_write(struct phy_device *phydev, int 
devad, int regnum,
return bus->write(bus, phydev->addr, devad, regnum, val);
 }
 
+static inline void phy_mmd_start_indirect(struct phy_device *phydev, int devad,
+ int regnum)
+{
+   /* Write the desired MMD Devad */
+   phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_CTRL, devad);
+
+   /* Write the desired MMD register address */
+   phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, regnum);
+
+   /* Select the Function : DATA with no post increment */
+   phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_CTRL,
+ (devad | MII_MMD_CTRL_NOINCR));
+}
+
+static inline int phy_read_mmd(struct phy_device *phydev, int devad,
+  int regnum)
+{
+   struct phy_driver *drv = phydev->drv;
+
+   if (regnum > (u16)~0 || devad > 32)
+   return -EINVAL;
+
+   /* driver-specific access */
+   if (drv->read_mmd)
+   return drv->read_mmd(phydev, devad, regnum);
+
+   /* direct C45 / C22 access */
+   if ((drv->features & PHY_10G_FEATURES) == PHY_10G_FEATURES ||
+   devad == MDIO_DEVAD_NONE || !devad)
+   return phy_read(phydev, devad, regnum);
+
+   /* indirect C22 access */
+   phy_mmd_start_indirect(phydev, devad, regnum);
+
+   /* Read the content of the MMD's selected register */
+   return phy_read(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA);
+}
+
+static inline int phy_write_mmd(struct phy_device *phydev, int devad,
+   int regnum, u16 val)
+{
+   struct phy_driver *drv = phydev->drv;
+
+   if (regnum > (u16)~0 || devad > 32)
+   return -EINVAL;
+
+   /* driver-specific access */
+   if (drv->write_mmd)
+   return drv->write_mmd(phydev, devad, regnum, val);
+
+   /* direct C45 / C22 access */
+   if ((drv->features & PHY_10G_FEATURES) == PHY_10G_FEATURES ||
+   devad == MDIO_DEVAD_NONE || !devad)
+   return phy_write(phydev, devad, regnum, val);
+
+   /* indirect C22 access */
+   phy_mmd_start_indirect(phydev, devad, regnum);
+
+   /* Write the data into MMD's selected register */
+   return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val);
+}
+
 #ifdef CONFIG_PHYLIB_10G
 extern struct phy_driver gen10g_driver;
 
-- 
2.19.1

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


[U-Boot] [PATCH v5 0/3] Add MMD PHY helpers

2019-02-08 Thread Carlo Caione
Introduce phy_{read|write}_mmd() helpers and modify the mdio command to 
make good use of them. Fix the ti driver in the same patchset.

Carlo Caione (3):
  net: phy: Add generic helpers to access MMD PHY registers
  net: phy: ti: use generic helpers to access MMD registers
  cmd: mdio: Switch to generic helpers when accessing the registers

 cmd/mdio.c|  27 +
 drivers/net/phy/phy.c |   4 ++
 drivers/net/phy/ti.c  | 130 --
 include/phy.h |  70 +++
 4 files changed, 115 insertions(+), 116 deletions(-)

-- 
2.19.1

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


[U-Boot] [PATCH v3 1/3] stm32mp1: add trusted boot with TF-A

2019-02-08 Thread Patrick Delaunay
Add support of trusted boot, using TF-A as first stage bootloader,
The boot sequence is
  BootRom >=> TF-A.stm32 (clock & DDR) >=> U-Boot.stm32

The TF-A monitor provides secure monitor with support of SMC
- proprietary to manage secure devices (BSEC for example)
- PSCI for power

The same device tree is used for STMicroelectronics boards with
basic boot and with trusted boot.

Signed-off-by: Patrick Delaunay 
---

Changes in v3:
- Remove patch 4/4 added by error in v2 and sent by other serie
  http://patchwork.ozlabs.org/patch/1033475/

Changes in v2:
- Rebase and solve conflict on arch/arm/mach-stm32mp/config.mk

 arch/arm/Kconfig|  6 ++--
 arch/arm/mach-stm32mp/Kconfig   | 17 +--
 arch/arm/mach-stm32mp/config.mk | 15 +-
 arch/arm/mach-stm32mp/cpu.c |  9 --
 board/st/stm32mp1/MAINTAINERS   |  5 ++--
 board/st/stm32mp1/README| 56 +---
 configs/stm32mp15_trusted_defconfig | 57 +
 drivers/clk/clk_stm32mp1.c  |  2 ++
 drivers/ram/stm32mp1/stm32mp1_ram.c |  3 +-
 include/configs/stm32mp1.h  |  2 ++
 10 files changed, 144 insertions(+), 28 deletions(-)
 create mode 100644 configs/stm32mp15_trusted_defconfig

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cefa8f4..9526cd2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1360,8 +1360,10 @@ config ARCH_STM32MP
help
  Support for STM32MP SoC family developed by STMicroelectronics,
  MPUs based on ARM cortex A core
- U-BOOT is running in DDR and SPL support is the unsecure First Stage
- BootLoader (FSBL)
+ U-BOOT is running in DDR, loaded by the First Stage BootLoader (FSBL).
+ FSBL can be TF-A: Trusted Firmware for Cortex A, for trusted boot
+ chain.
+ SPL is the unsecure FSBL for the basic boot chain.
 
 config ARCH_ROCKCHIP
bool "Support Rockchip SoCs"
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index 8a929fa..3101d80 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -25,19 +25,30 @@ config SYS_SOC
 
 config TARGET_STM32MP1
bool "Support stm32mp1xx"
-   select ARCH_SUPPORT_PSCI
+   select ARCH_SUPPORT_PSCI if !STM32MP1_TRUSTED
select CPU_V7A
-   select CPU_V7_HAS_NONSEC
+   select CPU_V7_HAS_NONSEC if !STM32MP1_TRUSTED
select CPU_V7_HAS_VIRT
select PINCTRL_STM32
select STM32_RCC
select STM32_RESET
select SYS_ARCH_TIMER
-   select SYSRESET_SYSCON
+   imply SYSRESET_PSCI if STM32MP1_TRUSTED
+   imply SYSRESET_SYSCON if !STM32MP1_TRUSTED
help
target STMicroelectronics SOC STM32MP1 family
STMicroelectronics MPU with core ARMv7
 
+config STM32MP1_TRUSTED
+   bool "Support trusted boot with TF-A"
+   default y if !SPL
+   select ARM_SMCCC
+   help
+   Say Y here to enable boot with TF-A
+   Trusted boot chain is :
+   BootRom => TF-A.stm32 (clock & DDR) => U-Boot.stm32
+   TF-A monitor provides proprietary smc to manage secure devices
+
 config SYS_TEXT_BASE
prompt "U-Boot base address"
default 0xC010
diff --git a/arch/arm/mach-stm32mp/config.mk b/arch/arm/mach-stm32mp/config.mk
index f371aac..403af2a 100644
--- a/arch/arm/mach-stm32mp/config.mk
+++ b/arch/arm/mach-stm32mp/config.mk
@@ -3,7 +3,20 @@
 # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 #
 
-ALL-$(CONFIG_SPL_BUILD) += u-boot-spl.stm32
+ifndef CONFIG_SPL
+ALL-y += u-boot.stm32
+else
+ifdef CONFIG_SPL_BUILD
+ALL-y += u-boot-spl.stm32
+endif
+endif
+
+MKIMAGEFLAGS_u-boot.stm32 = -T stm32image -a $(CONFIG_SYS_TEXT_BASE) -e 
$(CONFIG_SYS_TEXT_BASE)
+
+u-boot.stm32: MKIMAGEOUTPUT = u-boot.stm32.log
+
+u-boot.stm32: u-boot.bin FORCE
+   $(call if_changed,mkimage)
 
 MKIMAGEFLAGS_u-boot-spl.stm32 = -T stm32image -a $(CONFIG_SPL_TEXT_BASE) -e 
$(CONFIG_SPL_TEXT_BASE)
 
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index b893358..b96720f 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -59,6 +59,7 @@
 #define BSEC_OTP_MAC   57
 
 #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
+#ifndef CONFIG_STM32MP1_TRUSTED
 static void security_init(void)
 {
/* Disable the backup domain write protection */
@@ -114,6 +115,7 @@ static void security_init(void)
 */
writel(0x0, TAMP_CR1);
 }
+#endif /* CONFIG_STM32MP1_TRUSTED */
 
 /*
  * Debug init
@@ -130,7 +132,8 @@ static void dbgmcu_init(void)
 static u32 get_bootmode(void)
 {
u32 boot_mode;
-#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_STM32MP1_TRUSTED) && \
+   (!defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD))
u32 bootrom_itf = readl(BOOTROM_PARAM_ADDR);
u32 bootrom_device, bootrom_instance;
 

[U-Boot] [PATCH v3 2/3] stm32mp1: bsec: access with SMC for trusted boot

2019-02-08 Thread Patrick Delaunay
As BSEC is secure aware, all register access need to be done
by TF-A for TRUSTED boot chain, when U-Boot is executed in
normal world.

Signed-off-by: Patrick Delaunay 
---

Changes in v3: None
Changes in v2: None

 arch/arm/mach-stm32mp/bsec.c  | 28 ++
 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h | 64 +++
 2 files changed, 92 insertions(+)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h

diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index d087a31..920a6c9 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -8,9 +8,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define BSEC_OTP_MAX_VALUE 95
 
+#ifndef CONFIG_STM32MP1_TRUSTED
 #define BSEC_TIMEOUT_US1
 
 /* BSEC REGISTER OFFSET (base relative) */
@@ -270,6 +273,7 @@ static int bsec_program_otp(long base, u32 val, u32 otp)
 
return ret;
 }
+#endif /* CONFIG_STM32MP1_TRUSTED */
 
 /* BSEC MISC driver ***/
 struct stm32mp_bsec_platdata {
@@ -278,6 +282,11 @@ struct stm32mp_bsec_platdata {
 
 static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc(STM32_SMC_BSEC,
+STM32_SMC_READ_OTP,
+otp, 0, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
u32 tmp_data = 0;
int ret;
@@ -299,27 +308,46 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 
*val, u32 otp)
/* restore shadow value */
ret = bsec_write_shadow(plat->base, tmp_data, otp);
return ret;
+#endif
 }
 
 static int stm32mp_bsec_read_shadow(struct udevice *dev, u32 *val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc(STM32_SMC_BSEC,
+STM32_SMC_READ_SHADOW,
+otp, 0, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_read_shadow(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_write_otp(struct udevice *dev, u32 val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc_exec(STM32_SMC_BSEC,
+ STM32_SMC_PROG_OTP,
+ otp, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_program_otp(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_write_shadow(struct udevice *dev, u32 val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc_exec(STM32_SMC_BSEC,
+ STM32_SMC_WRITE_SHADOW,
+ otp, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_write_shadow(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_read(struct udevice *dev, int offset,
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h 
b/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
new file mode 100644
index 000..8130546
--- /dev/null
+++ b/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+
+#ifndef __STM32MP1_SMC_H__
+#define __STM32MP1_SMC_H__
+
+#include 
+
+/*
+ * SMC function IDs for STM32 Service queries
+ * STM32 SMC services use the space between 0x8200 and 0x8200
+ * like this is defined in SMC calling Convention by ARM
+ * for SiP (silicon Partner)
+ * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
+ */
+#define STM32_SMC_VERSION  0x8200
+
+/* Secure Service access from Non-secure */
+#define STM32_SMC_BSEC 0x82001003
+
+/* Service for BSEC */
+#define STM32_SMC_READ_SHADOW  0x01
+#define STM32_SMC_PROG_OTP 0x02
+#define STM32_SMC_WRITE_SHADOW 0x03
+#define STM32_SMC_READ_OTP 0x04
+#define STM32_SMC_READ_ALL 0x05
+#define STM32_SMC_WRITE_ALL0x06
+
+/* SMC error codes */
+#define STM32_SMC_OK   0x0
+#define STM32_SMC_NOT_SUPPORTED-1
+#define STM32_SMC_FAILED   -2
+#define STM32_SMC_INVALID_PARAMS   -3
+
+#define stm32_smc_exec(svc, op, data1, data2) \
+   stm32_smc(svc, op, data1, data2, NULL)
+
+#ifdef CONFIG_ARM_SMCCC
+static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
+{
+   struct arm_smccc_res res;
+
+   arm_smccc_smc(svc, op, data1, data2, 0, 0, 0, 0, );
+
+   if (res.a0) {
+   pr_err("%s: Failed to exec in secure mode (err = %ld)\n",
+  __func__, res.a0);
+   return -EINVAL;
+   }
+   if (result)
+   *result = (u32)res.a1;
+
+   return 0;
+}
+#else
+static inline u32 

[U-Boot] [PATCH v2 1/4] stm32mp1: add trusted boot with TF-A

2019-02-08 Thread Patrick Delaunay
Add support of trusted boot, using TF-A as first stage bootloader,
The boot sequence is
  BootRom >=> TF-A.stm32 (clock & DDR) >=> U-Boot.stm32

The TF-A monitor provides secure monitor with support of SMC
- proprietary to manage secure devices (BSEC for example)
- PSCI for power

The same device tree is used for STMicroelectronics boards with
basic boot and with trusted boot.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- Rebase and solve conflict on arch/arm/mach-stm32mp/config.mk

 arch/arm/Kconfig|  6 ++--
 arch/arm/mach-stm32mp/Kconfig   | 17 +--
 arch/arm/mach-stm32mp/config.mk | 15 +-
 arch/arm/mach-stm32mp/cpu.c |  9 --
 board/st/stm32mp1/MAINTAINERS   |  5 ++--
 board/st/stm32mp1/README| 56 +---
 configs/stm32mp15_trusted_defconfig | 57 +
 drivers/clk/clk_stm32mp1.c  |  2 ++
 drivers/ram/stm32mp1/stm32mp1_ram.c |  3 +-
 include/configs/stm32mp1.h  |  2 ++
 10 files changed, 144 insertions(+), 28 deletions(-)
 create mode 100644 configs/stm32mp15_trusted_defconfig

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index cefa8f4..9526cd2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1360,8 +1360,10 @@ config ARCH_STM32MP
help
  Support for STM32MP SoC family developed by STMicroelectronics,
  MPUs based on ARM cortex A core
- U-BOOT is running in DDR and SPL support is the unsecure First Stage
- BootLoader (FSBL)
+ U-BOOT is running in DDR, loaded by the First Stage BootLoader (FSBL).
+ FSBL can be TF-A: Trusted Firmware for Cortex A, for trusted boot
+ chain.
+ SPL is the unsecure FSBL for the basic boot chain.
 
 config ARCH_ROCKCHIP
bool "Support Rockchip SoCs"
diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
index 8a929fa..3101d80 100644
--- a/arch/arm/mach-stm32mp/Kconfig
+++ b/arch/arm/mach-stm32mp/Kconfig
@@ -25,19 +25,30 @@ config SYS_SOC
 
 config TARGET_STM32MP1
bool "Support stm32mp1xx"
-   select ARCH_SUPPORT_PSCI
+   select ARCH_SUPPORT_PSCI if !STM32MP1_TRUSTED
select CPU_V7A
-   select CPU_V7_HAS_NONSEC
+   select CPU_V7_HAS_NONSEC if !STM32MP1_TRUSTED
select CPU_V7_HAS_VIRT
select PINCTRL_STM32
select STM32_RCC
select STM32_RESET
select SYS_ARCH_TIMER
-   select SYSRESET_SYSCON
+   imply SYSRESET_PSCI if STM32MP1_TRUSTED
+   imply SYSRESET_SYSCON if !STM32MP1_TRUSTED
help
target STMicroelectronics SOC STM32MP1 family
STMicroelectronics MPU with core ARMv7
 
+config STM32MP1_TRUSTED
+   bool "Support trusted boot with TF-A"
+   default y if !SPL
+   select ARM_SMCCC
+   help
+   Say Y here to enable boot with TF-A
+   Trusted boot chain is :
+   BootRom => TF-A.stm32 (clock & DDR) => U-Boot.stm32
+   TF-A monitor provides proprietary smc to manage secure devices
+
 config SYS_TEXT_BASE
prompt "U-Boot base address"
default 0xC010
diff --git a/arch/arm/mach-stm32mp/config.mk b/arch/arm/mach-stm32mp/config.mk
index f371aac..403af2a 100644
--- a/arch/arm/mach-stm32mp/config.mk
+++ b/arch/arm/mach-stm32mp/config.mk
@@ -3,7 +3,20 @@
 # Copyright (C) 2018, STMicroelectronics - All Rights Reserved
 #
 
-ALL-$(CONFIG_SPL_BUILD) += u-boot-spl.stm32
+ifndef CONFIG_SPL
+ALL-y += u-boot.stm32
+else
+ifdef CONFIG_SPL_BUILD
+ALL-y += u-boot-spl.stm32
+endif
+endif
+
+MKIMAGEFLAGS_u-boot.stm32 = -T stm32image -a $(CONFIG_SYS_TEXT_BASE) -e 
$(CONFIG_SYS_TEXT_BASE)
+
+u-boot.stm32: MKIMAGEOUTPUT = u-boot.stm32.log
+
+u-boot.stm32: u-boot.bin FORCE
+   $(call if_changed,mkimage)
 
 MKIMAGEFLAGS_u-boot-spl.stm32 = -T stm32image -a $(CONFIG_SPL_TEXT_BASE) -e 
$(CONFIG_SPL_TEXT_BASE)
 
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index b893358..b96720f 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -59,6 +59,7 @@
 #define BSEC_OTP_MAC   57
 
 #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
+#ifndef CONFIG_STM32MP1_TRUSTED
 static void security_init(void)
 {
/* Disable the backup domain write protection */
@@ -114,6 +115,7 @@ static void security_init(void)
 */
writel(0x0, TAMP_CR1);
 }
+#endif /* CONFIG_STM32MP1_TRUSTED */
 
 /*
  * Debug init
@@ -130,7 +132,8 @@ static void dbgmcu_init(void)
 static u32 get_bootmode(void)
 {
u32 boot_mode;
-#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_STM32MP1_TRUSTED) && \
+   (!defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD))
u32 bootrom_itf = readl(BOOTROM_PARAM_ADDR);
u32 bootrom_device, bootrom_instance;
 
@@ -167,9 +170,10 @@ int arch_cpu_init(void)
 
 #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
dbgmcu_init();
-

[U-Boot] [PATCH v2 0/4] stm32mp1: add trusted boot with TF-A

2019-02-08 Thread Patrick Delaunay

This patch serie add a new configuration
stm32mp15_trusted_defconfig to handle STM32MP157 boards
with TF-A as secure first stage bootloader.

TF-A code is available in GitHub
https://github.com/ARM-software/arm-trusted-firmware

With platform stm32mp1 platform
https://github.com/ARM-software/arm-trusted-firmware/tree/master/plat/st/stm32mp1

For details, see documentation
https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/stm32mp1.rst

PS: upstream of trusted boot for TF-A is still in progress.


Changes in v2:
- Rebase and solve conflict on arch/arm/mach-stm32mp/config.mk

Patrick Delaunay (4):
  stm32mp1: add trusted boot with TF-A
  stm32mp1: bsec: access with SMC for trusted boot
  stm32mp1: display board information
  clk: stm32m1: add debug information

 arch/arm/Kconfig  |  6 +-
 arch/arm/mach-stm32mp/Kconfig | 17 -
 arch/arm/mach-stm32mp/bsec.c  | 28 
 arch/arm/mach-stm32mp/config.mk   | 15 +++-
 arch/arm/mach-stm32mp/cpu.c   |  9 ++-
 arch/arm/mach-stm32mp/include/mach/stm32.h|  4 ++
 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h | 64 +
 board/st/stm32mp1/MAINTAINERS |  5 +-
 board/st/stm32mp1/README  | 56 ++-
 board/st/stm32mp1/stm32mp1.c  | 44 +++-
 configs/stm32mp15_basic_defconfig |  1 +
 configs/stm32mp15_trusted_defconfig   | 58 
 drivers/clk/clk_stm32mp1.c| 85 +--
 drivers/ram/stm32mp1/stm32mp1_ram.c   |  3 +-
 include/configs/stm32mp1.h|  2 +
 15 files changed, 363 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
 create mode 100644 configs/stm32mp15_trusted_defconfig

-- 
2.7.4

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


[U-Boot] [PATCH v2 22/23] apalis_imx6: switch to zimage

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Switch to the generic compressed Kernel image type (zImage) instead of
the U-Boot specific uImage format.

While at it also fix device tree naming for MMC DFU.

Signed-off-by: Bhuvanchandra DV 
Acked-by: Marcel Ziswiler 

---

Changes in v2:
- Also fix device tree naming for MMC DFU.

 include/configs/apalis_imx6.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index a49b08ba45..c8aa1bdddf 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -118,17 +118,17 @@
 #include 
 #undef BOOTENV_RUN_NET_USB_START
 #define BOOTENV_RUN_NET_USB_START ""
-#else
+#else /* CONFIG_SPL_BUILD */
 #define BOOTENV
-#endif
+#endif /* CONFIG_SPL_BUILD */
 
 #define DFU_ALT_EMMC_INFO \
"u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
"boot part 0 1;" \
"rootfs part 0 2;" \
-   "uImage fat 0 1;" \
-   "imx6q-colibri-eval-v3.dtb fat 0 1;" \
-   "imx6q-colibri-cam-eval-v3.dtb fat 0 1"
+   "zImage fat 0 1;" \
+   "imx6q-apalis-eval.dtb fat 0 1;" \
+   "imx6q-apalis-cam-eval.dtb fat 0 1"
 
 #define EMMC_BOOTCMD \
"emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext4 " \
@@ -138,7 +138,7 @@
"${vidargs}; echo Booting from internal eMMC chip...; " \
"run emmcdtbload; load mmc 0:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"emmcdtbload=setenv dtbparam; load mmc 0:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -158,11 +158,11 @@
"setenv bootargs ${defargs} ${nfsargs} ${setupargs} " \
"${vidargs}; echo Booting via DHCP/TFTP/NFS...; " \
"run nfsdtbload; dhcp ${kernel_addr_r} " \
-   "&& run fdt_fixup && bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "&& run fdt_fixup && bootz ${kernel_addr_r} ${dtbparam}\0" \
"nfsdtbload=setenv dtbparam; tftp ${fdt_addr_r} ${fdt_file} " \
"&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
-#define SD_BOOTCMD \
+#define SD_BOOTCMD \
"sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"sdboot=run setup; " \
@@ -170,7 +170,7 @@
"${vidargs}; echo Booting from SD card; " \
"run sddtbload; load mmc 1:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"sddtbload=setenv dtbparam; load mmc 1:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -181,7 +181,7 @@
"${usbargs} ${vidargs}; echo Booting from USB stick...; " \
"usb start && run usbdtbload; load usb 0:1 ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
-   "bootm ${kernel_addr_r} ${dtbparam}\0" \
+   "bootz ${kernel_addr_r} ${dtbparam}\0" \
"usbdtbload=setenv dtbparam; load usb 0:1 ${fdt_addr_r} " \
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
@@ -197,7 +197,7 @@
"run distro_bootcmd ; " \
"usb start ; " \
"setenv stdout serial,vga ; setenv stdin serial,usbkbd\0" \
-   "boot_file=uImage\0" \
+   "boot_file=zImage\0" \
"console=ttymxc0\0" \
"defargs=enable_wait_mode=off vmalloc=400M\0" \
"dfu_alt_info=" DFU_ALT_EMMC_INFO "\0" \
-- 
2.20.1

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


[U-Boot] [PATCH v2 3/4] stm32mp1: display board information

2019-02-08 Thread Patrick Delaunay
Implement checkboard() function to display
- the boot chain used: basic or trusted
- the board compatible in device tree
- the board identifier and revision, saved in OTP59 for ST boards

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 arch/arm/mach-stm32mp/include/mach/stm32.h |  4 +++
 board/st/stm32mp1/stm32mp1.c   | 44 --
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h 
b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 5d0bdca..85d783c 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -98,7 +98,11 @@ enum boot_device {
 
 /* offset used for BSEC driver: misc_read and misc_write */
 #define STM32_BSEC_SHADOW_OFFSET   0x0
+#define STM32_BSEC_SHADOW(id)  (STM32_BSEC_SHADOW_OFFSET + (id) * 4)
 #define STM32_BSEC_OTP_OFFSET  0x8000
+#define STM32_BSEC_OTP(id) (STM32_BSEC_OTP_OFFSET + (id) * 4)
+
+#define BSEC_OTP_BOARD 59
 
 #endif /* __ASSEMBLY__*/
 #endif /* _MACH_STM32_H_ */
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 54feca0..07d1add 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -3,11 +3,12 @@
  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  */
 #include 
-#include 
-#include 
 #include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -26,6 +27,45 @@ DECLARE_GLOBAL_DATA_PTR;
 #define STM32MP_GGPIO 0x38
 #define STM32MP_GGPIO_VBUS_SENSING BIT(21)
 
+int checkboard(void)
+{
+   int ret;
+   char *mode;
+   u32 otp;
+   struct udevice *dev;
+   const char *fdt_compat;
+   int fdt_compat_len;
+
+   if (IS_ENABLED(CONFIG_STM32MP1_TRUSTED))
+   mode = "trusted";
+   else
+   mode = "basic";
+
+   printf("Board: stm32mp1 in %s mode", mode);
+   fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
+_compat_len);
+   if (fdt_compat && fdt_compat_len)
+   printf(" (%s)", fdt_compat);
+   puts("\n");
+
+   ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ );
+
+   if (!ret)
+   ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
+   , sizeof(otp));
+   if (!ret && otp) {
+   printf("Board: MB%04x Var%d Rev.%c-%02d\n",
+  otp >> 16,
+  (otp >> 12) & 0xF,
+  ((otp >> 8) & 0xF) - 1 + 'A',
+  otp & 0xF);
+   }
+
+   return 0;
+}
+
 static struct dwc2_plat_otg_data stm32mp_otg_data = {
.usb_gusbcfg = STM32MP_GUSBCFG,
 };
-- 
2.7.4

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


[U-Boot] [PATCH v2 20/23] configs: apalis_imx6: Use ext4 file system by default

2019-02-08 Thread Marcel Ziswiler
From: Sanchayan Maity 

Use ext4 file system by default.

Signed-off-by: Sanchayan Maity 
Acked-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 include/configs/apalis_imx6.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index 7df32feb0d..a49b08ba45 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -131,7 +131,7 @@
"imx6q-colibri-cam-eval-v3.dtb fat 0 1"
 
 #define EMMC_BOOTCMD \
-   "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext3 " \
+   "emmcargs=ip=off root=/dev/mmcblk0p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"emmcboot=run setup; " \
"setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
@@ -163,7 +163,7 @@
"&& setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
 #define SD_BOOTCMD \
-   "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext3 " \
+   "sdargs=ip=off root=/dev/mmcblk1p2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"sdboot=run setup; " \
"setenv bootargs ${defargs} ${sdargs} ${setupargs} " \
@@ -175,7 +175,7 @@
"${fdt_file} && setenv dtbparam \" - ${fdt_addr_r}\" && true\0"
 
 #define USB_BOOTCMD \
-   "usbargs=ip=off root=/dev/sda2 rw,noatime rootfstype=ext3 " \
+   "usbargs=ip=off root=/dev/sda2 rw,noatime rootfstype=ext4 " \
"rootwait\0" \
"usbboot=run setup; setenv bootargs ${defargs} ${setupargs} " \
"${usbargs} ${vidargs}; echo Booting from USB stick...; " \
-- 
2.20.1

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


[U-Boot] [PATCH v2 4/4] clk: stm32m1: add debug information

2019-02-08 Thread Patrick Delaunay
Add support of clk dump command and
display information during probe (under CONFIG_DISPLAY_CPUINFO).

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_trusted_defconfig |  1 +
 drivers/clk/clk_stm32mp1.c  | 83 +++--
 3 files changed, 81 insertions(+), 4 deletions(-)

diff --git a/configs/stm32mp15_basic_defconfig 
b/configs/stm32mp15_basic_defconfig
index 304688e..d20b2ab 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -19,6 +19,7 @@ CONFIG_SYS_PROMPT="STM32MP> "
 # CONFIG_CMD_IMPORTENV is not set
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_ADC=y
+CONFIG_CMD_CLK=y
 CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
diff --git a/configs/stm32mp15_trusted_defconfig 
b/configs/stm32mp15_trusted_defconfig
index e905ae1..62ab010 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -13,6 +13,7 @@ CONFIG_SYS_PROMPT="STM32MP> "
 # CONFIG_CMD_IMPORTENV is not set
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_ADC=y
+CONFIG_CMD_CLK=y
 CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_GPT=y
diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c
index 9e9c667..c100c57 100644
--- a/drivers/clk/clk_stm32mp1.c
+++ b/drivers/clk/clk_stm32mp1.c
@@ -667,8 +667,8 @@ static const u8 stm32mp1_axi_div[8] = {
1, 2, 3, 4, 4, 4, 4, 4
 };
 
-#ifdef DEBUG
-static const char * const stm32mp1_clk_parent_name[_PARENT_NB] = {
+static const __maybe_unused
+char * const stm32mp1_clk_parent_name[_PARENT_NB] = {
[_HSI] = "HSI",
[_HSE] = "HSE",
[_CSI] = "CSI",
@@ -706,7 +706,8 @@ static const char * const 
stm32mp1_clk_parent_name[_PARENT_NB] = {
[_DSI_PHY] = "DSI_PHY_PLL",
 };
 
-static const char * const stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
+static const __maybe_unused
+char * const stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
[_I2C12_SEL] = "I2C12",
[_I2C35_SEL] = "I2C35",
[_I2C46_SEL] = "I2C46",
@@ -725,7 +726,6 @@ static const char * const 
stm32mp1_clk_parent_sel_name[_PARENT_SEL_NB] = {
[_DSI_SEL] = "DSI",
[_ADC12_SEL] = "ADC12",
 };
-#endif
 
 static const struct stm32mp1_clk_data stm32mp1_data = {
.gate = stm32mp1_clk_gate,
@@ -1869,6 +1869,54 @@ static void stm32mp1_osc_init(struct udevice *dev)
}
 }
 
+static void  __maybe_unused stm32mp1_clk_dump(struct stm32mp1_clk_priv *priv)
+{
+   char buf[32];
+   int i, s, p;
+
+   printf("Clocks:\n");
+   for (i = 0; i < _PARENT_NB; i++) {
+   printf("- %s : %s MHz\n",
+  stm32mp1_clk_parent_name[i],
+  strmhz(buf, stm32mp1_clk_get(priv, i)));
+   }
+   printf("Source Clocks:\n");
+   for (i = 0; i < _PARENT_SEL_NB; i++) {
+   p = (readl(priv->base + priv->data->sel[i].offset) >>
+priv->data->sel[i].src) & priv->data->sel[i].msk;
+   if (p < priv->data->sel[i].nb_parent) {
+   s = priv->data->sel[i].parent[p];
+   printf("- %s(%d) => parent %s(%d)\n",
+  stm32mp1_clk_parent_sel_name[i], i,
+  stm32mp1_clk_parent_name[s], s);
+   } else {
+   printf("- %s(%d) => parent index %d is invalid\n",
+  stm32mp1_clk_parent_sel_name[i], i, p);
+   }
+   }
+}
+
+#ifdef CONFIG_CMD_CLK
+int soc_clk_dump(void)
+{
+   struct udevice *dev;
+   struct stm32mp1_clk_priv *priv;
+   int ret;
+
+   ret = uclass_get_device_by_driver(UCLASS_CLK,
+ DM_GET_DRIVER(stm32mp1_clock),
+ );
+   if (ret)
+   return ret;
+
+   priv = dev_get_priv(dev);
+
+   stm32mp1_clk_dump(priv);
+
+   return 0;
+}
+#endif
+
 static int stm32mp1_clk_probe(struct udevice *dev)
 {
int result = 0;
@@ -1892,6 +1940,33 @@ static int stm32mp1_clk_probe(struct udevice *dev)
result = stm32mp1_clktree(dev);
 #endif
 
+#ifndef CONFIG_SPL_BUILD
+#if defined(DEBUG)
+   /* display debug information for probe after relocation */
+   if (gd->flags & GD_FLG_RELOC)
+   stm32mp1_clk_dump(priv);
+#endif
+
+#if defined(CONFIG_DISPLAY_CPUINFO)
+   if (gd->flags & GD_FLG_RELOC) {
+   char buf[32];
+
+   printf("Clocks:\n");
+   printf("- MPU : %s MHz\n",
+  strmhz(buf, stm32mp1_clk_get(priv, _CK_MPU)));
+   printf("- MCU : %s MHz\n",
+  strmhz(buf, stm32mp1_clk_get(priv, _CK_MCU)));
+   printf("- AXI : %s MHz\n",
+  strmhz(buf, stm32mp1_clk_get(priv, _ACLK)));
+   printf("- PER : %s MHz\n",
+  strmhz(buf, stm32mp1_clk_get(priv, _CK_PER)));
+

[U-Boot] [PATCH v2 21/23] apalis_imx6: use SDP if USB serial downloader has been used

2019-02-08 Thread Marcel Ziswiler
From: Stefan Agner 

In case USB serial downloader has been used to load U-Boot start the
serial download protocol (SDP) emulation. This allows to download
complete images such as Toradex Easy Installer over USB SDP as well.
This code uses the boot ROM provided boot information to reliably
detect USB serial downloader.

Signed-off-by: Stefan Agner 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 2c90a40042..ce54638c4c 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -714,6 +714,14 @@ int board_late_init(void)
 #endif /* CONFIG_TDX_APALIS_IMX6_V1_0 */
 #endif /* CONFIG_REVISION_TAG */
 
+#ifdef CONFIG_CMD_USB_SDP
+   if (is_boot_from_usb()) {
+   printf("Serial Downloader recovery mode, using sdp command\n");
+   env_set("bootdelay", "0");
+   env_set("bootcmd", "sdp 0");
+   }
+#endif /* CONFIG_CMD_USB_SDP */
+
return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
-- 
2.20.1

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


[U-Boot] [PATCH v2 19/23] apalis_imx6: revert fuse value set in mfgr_fuse

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

We have two commands to change the bootmode fuses:
mfgr_fuse which set fuse 0/5 and 0/6
and
updt_fuse which burns bit 4 of 0/5.

Before BSP 2.6 we fused in mfgr_fuse 0x5062, which boots
from the user partition of the eMMC.
To workaround certain hangs we moved to fastboot mode and
using the first bootpartition of the eMMC requiring a fuse
value of 0x5072 which could be achieved by the then added
updt_fuse command. At the same time the mfgr_fuse command
was changed to also fuse 0x5072, revert that second change
so that one can fuse both values, one with just mfgr_fuse
and the later with mfgr_fuse;updt_fuse.

Note that the mfgr_fuse command is only needed at module
production time, a customer might need to use updt_fuse
when upgrading an older module to be compatible with a
newer image. The command is integrated into the image
update scripts.

Signed-off-by: Max Krummenacher 
Acked-by: Stefan Agner 
Acked-by: Marcel Ziswiler 

---

Changes in v2:
- Remove Colibri iMX6 change which inadvertently slipped in here.

 board/toradex/apalis_imx6/do_fuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/toradex/apalis_imx6/do_fuse.c 
b/board/toradex/apalis_imx6/do_fuse.c
index e6793e366a..22d191f52a 100644
--- a/board/toradex/apalis_imx6/do_fuse.c
+++ b/board/toradex/apalis_imx6/do_fuse.c
@@ -29,7 +29,7 @@ static int mfgr_fuse(void)
return CMD_RET_FAILURE;
}
/* boot cfg */
-   fuse_prog(0, 5, 0x5072);
+   fuse_prog(0, 5, 0x5062);
/* BT_FUSE_SEL */
fuse_prog(0, 6, 0x0010);
return CMD_RET_SUCCESS;
-- 
2.20.1

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


[U-Boot] [PATCH v2 01/23] apalis_imx6: get rid of obsolete nospl configurations

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Now with SPL long since being in place even for recovery using SDP
finally get rid of those nospl configurations.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 .../toradex/apalis_imx6/1066mhz_4x128mx16.cfg | 47 -
 .../toradex/apalis_imx6/1066mhz_4x256mx16.cfg | 47 -
 board/toradex/apalis_imx6/MAINTAINERS |  2 -
 board/toradex/apalis_imx6/apalis_imx6q.cfg| 33 ---
 board/toradex/apalis_imx6/clocks.cfg  | 41 
 board/toradex/apalis_imx6/ddr-setup.cfg   | 96 ---
 configs/apalis_imx6_nospl_com_defconfig   | 65 -
 configs/apalis_imx6_nospl_it_defconfig| 65 -
 8 files changed, 396 deletions(-)
 delete mode 100644 board/toradex/apalis_imx6/1066mhz_4x128mx16.cfg
 delete mode 100644 board/toradex/apalis_imx6/1066mhz_4x256mx16.cfg
 delete mode 100644 board/toradex/apalis_imx6/apalis_imx6q.cfg
 delete mode 100644 board/toradex/apalis_imx6/clocks.cfg
 delete mode 100644 board/toradex/apalis_imx6/ddr-setup.cfg
 delete mode 100644 configs/apalis_imx6_nospl_com_defconfig
 delete mode 100644 configs/apalis_imx6_nospl_it_defconfig

diff --git a/board/toradex/apalis_imx6/1066mhz_4x128mx16.cfg 
b/board/toradex/apalis_imx6/1066mhz_4x128mx16.cfg
deleted file mode 100644
index 29d1c3126c..00
--- a/board/toradex/apalis_imx6/1066mhz_4x128mx16.cfg
+++ /dev/null
@@ -1,47 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2013 Boundary Devices
- * Copyright (C) 2014-2016 Toradex AG
- */
-
-DATA 4, MX6_MMDC_P0_MDPDC, 0x00020036
-DATA 4, MX6_MMDC_P0_MDCFG0, 0x555A7954
-DATA 4, MX6_MMDC_P0_MDCFG1, 0xDB328F64
-DATA 4, MX6_MMDC_P0_MDCFG2, 0x01FF00DB
-DATA 4, MX6_MMDC_P0_MDRWD, 0x26D2
-DATA 4, MX6_MMDC_P0_MDOR, 0x005A1023
-DATA 4, MX6_MMDC_P0_MDOTC, 0x09555050
-DATA 4, MX6_MMDC_P0_MDPDC, 0x00025576
-DATA 4, MX6_MMDC_P0_MDASP, 0x0027
-DATA 4, MX6_MMDC_P0_MDCTL, 0x831A
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04088032
-DATA 4, MX6_MMDC_P0_MDSCR, 0x8033
-DATA 4, MX6_MMDC_P0_MDSCR, 0x00428031
-DATA 4, MX6_MMDC_P0_MDSCR, 0x19308030
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008040
-DATA 4, MX6_MMDC_P0_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P1_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P0_MDREF, 0x5800
-DATA 4, MX6_MMDC_P0_MPODTCTRL, 0x
-DATA 4, MX6_MMDC_P1_MPODTCTRL, 0x
-
-DATA 4, MX6_MMDC_P0_MPDGCTRL0, 0x432A0338
-DATA 4, MX6_MMDC_P0_MPDGCTRL1, 0x03260324
-DATA 4, MX6_MMDC_P1_MPDGCTRL0, 0x43340344
-DATA 4, MX6_MMDC_P1_MPDGCTRL1, 0x031E027C
-
-DATA 4, MX6_MMDC_P0_MPRDDLCTL, 0x33272D2E
-DATA 4, MX6_MMDC_P1_MPRDDLCTL, 0x2F312B37
-
-DATA 4, MX6_MMDC_P0_MPWRDLCTL, 0x3A35433C
-DATA 4, MX6_MMDC_P1_MPWRDLCTL, 0x4336453F
-
-DATA 4, MX6_MMDC_P0_MPWLDECTRL0, 0x0009000E
-DATA 4, MX6_MMDC_P0_MPWLDECTRL1, 0x0018000B
-DATA 4, MX6_MMDC_P1_MPWLDECTRL0, 0x00060015
-DATA 4, MX6_MMDC_P1_MPWLDECTRL1, 0x0006000E
-
-DATA 4, MX6_MMDC_P0_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P1_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P0_MDSCR, 0x
-DATA 4, MX6_MMDC_P0_MAPSR, 0x00011006
diff --git a/board/toradex/apalis_imx6/1066mhz_4x256mx16.cfg 
b/board/toradex/apalis_imx6/1066mhz_4x256mx16.cfg
deleted file mode 100644
index 02e90dd5e6..00
--- a/board/toradex/apalis_imx6/1066mhz_4x256mx16.cfg
+++ /dev/null
@@ -1,47 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2013 Boundary Devices
- * Copyright (C) 2014-2016 Toradex AG
- */
-
-DATA 4, MX6_MMDC_P0_MDPDC, 0x00020036
-DATA 4, MX6_MMDC_P0_MDCFG0, 0x898E78f5
-DATA 4, MX6_MMDC_P0_MDCFG1, 0xff328f64
-DATA 4, MX6_MMDC_P0_MDCFG2, 0x01FF00DB
-DATA 4, MX6_MMDC_P0_MDRWD, 0x26D2
-DATA 4, MX6_MMDC_P0_MDOR, 0x008E1023
-DATA 4, MX6_MMDC_P0_MDOTC, 0x09444040
-DATA 4, MX6_MMDC_P0_MDPDC, 0x00025576
-DATA 4, MX6_MMDC_P0_MDASP, 0x0047
-DATA 4, MX6_MMDC_P0_MDCTL, 0x841A
-DATA 4, MX6_MMDC_P0_MDSCR, 0x02888032
-DATA 4, MX6_MMDC_P0_MDSCR, 0x8033
-DATA 4, MX6_MMDC_P0_MDSCR, 0x00048031
-DATA 4, MX6_MMDC_P0_MDSCR, 0x19408030
-DATA 4, MX6_MMDC_P0_MDSCR, 0x04008040
-DATA 4, MX6_MMDC_P0_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P1_MPZQHWCTRL, 0xA1390003
-DATA 4, MX6_MMDC_P0_MDREF, 0x7800
-DATA 4, MX6_MMDC_P0_MPODTCTRL, 0x0007
-DATA 4, MX6_MMDC_P1_MPODTCTRL, 0x0007
-
-DATA 4, MX6_MMDC_P0_MPDGCTRL0, 0x03300338
-DATA 4, MX6_MMDC_P0_MPDGCTRL1, 0x03240324
-DATA 4, MX6_MMDC_P1_MPDGCTRL0, 0x03440350
-DATA 4, MX6_MMDC_P1_MPDGCTRL1, 0x032C0308
-
-DATA 4, MX6_MMDC_P0_MPRDDLCTL, 0x40363C3E
-DATA 4, MX6_MMDC_P1_MPRDDLCTL, 0x3C3E3C46
-
-DATA 4, MX6_MMDC_P0_MPWRDLCTL, 0x403E463E
-DATA 4, MX6_MMDC_P1_MPWRDLCTL, 0x4A384C46
-
-DATA 4, MX6_MMDC_P0_MPWLDECTRL0, 0x0009000E
-DATA 4, MX6_MMDC_P0_MPWLDECTRL1, 0x0018000B
-DATA 4, MX6_MMDC_P1_MPWLDECTRL0, 0x00060015
-DATA 4, MX6_MMDC_P1_MPWLDECTRL1, 0x0006000E
-
-DATA 4, MX6_MMDC_P0_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P1_MPMUR0, 0x0800
-DATA 4, MX6_MMDC_P0_MDSCR, 0x
-DATA 4, MX6_MMDC_P0_MAPSR, 0x00011006
diff --git a/board/toradex/apalis_imx6/MAINTAINERS 

[U-Boot] [PATCH v2 14/23] apalis_imx6: add distroboot support

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Add support for distro boot. This is especially helpful for external
devices. There is a global boot command which scans a predefined
list of boot targets:
  run distro_bootcmd

As well as direct boot commands such as:
  run bootcmd_mmc1
  run bootcmd_mmc2
  run bootcmd_usb
  run bootcmd_dhcp
  ...

Refer to doc/README.distro for details.

While at it, remove the CONFIG_DRIVE_TYPES define which has not
been used and was meant to be used for multi device boot support
which is now provided by distroboot.

Signed-off-by: Stefan Agner 
Acked-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 include/configs/apalis_imx6.h | 30 --
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index 382048d2ef..5f865e1f08 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -109,20 +109,19 @@
 
 #define CONFIG_LOADADDR0x1200
 
-#ifdef CONFIG_CMD_SATA
-#define CONFIG_DRIVE_SATA "sata "
+#ifndef CONFIG_SPL_BUILD
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, 1) \
+   func(MMC, mmc, 2) \
+   func(USB, usb, 0) \
+   func(DHCP, dhcp, na)
+#include 
+#undef BOOTENV_RUN_NET_USB_START
+#define BOOTENV_RUN_NET_USB_START ""
 #else
-#define CONFIG_DRIVE_SATA
+#define BOOTENV
 #endif
 
-#ifdef CONFIG_CMD_MMC
-#define CONFIG_DRIVE_MMC "mmc "
-#else
-#define CONFIG_DRIVE_MMC
-#endif
-
-#define CONFIG_DRIVE_TYPES CONFIG_DRIVE_SATA CONFIG_DRIVE_MMC
-
 #define DFU_ALT_EMMC_INFO \
"u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
"boot part 0 1;" \
@@ -149,7 +148,9 @@
"fdt_high=0x\0" \
"initrd_high=0x\0" \
"kernel_addr_r=0x1100\0" \
-   "ramdisk_addr_r=0x1210\0"
+   "pxefile_addr_r=0x1710\0" \
+   "ramdisk_addr_r=0x1210\0" \
+   "scriptaddr=0x1700\0"
 
 #define NFS_BOOTCMD \
"nfsargs=ip=:eth0:on root=/dev/nfs rw\0" \
@@ -191,9 +192,10 @@
 #define FDT_FILE "imx6q-apalis_v1_0-eval.dtb"
 #endif
 #define CONFIG_EXTRA_ENV_SETTINGS \
+   BOOTENV \
"bootcmd=run emmcboot ; echo ; echo emmcboot failed ; " \
-   "run nfsboot ; echo ; echo nfsboot failed ; " \
-   "usb start ;" \
+   "run distro_bootcmd ; " \
+   "usb start ; " \
"setenv stdout serial,vga ; setenv stdin serial,usbkbd\0" \
"boot_file=uImage\0" \
"console=ttymxc0\0" \
-- 
2.20.1

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


[U-Boot] [PATCH v2 10/23] apalis_imx6: migrate pmic and regulator to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate PMIC and regulator to using driver model.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 configs/apalis_imx6_defconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 60c4d9720d..7e973ded74 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -45,6 +45,8 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
+CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6-apalis"
 CONFIG_ENV_IS_IN_MMC=y
@@ -60,6 +62,11 @@ CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_DM_PMIC=y
+CONFIG_DM_PMIC_PFUZE100=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_PFUZE100=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
-- 
2.20.1

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


[U-Boot] [PATCH v2 18/23] apalis_imx6: disable ri and dcd irq in uarts

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

If the UART is used in DTE mode the RI and DCD bits in UCR3 become
irq enable bits. Both are set to enabled after reset and both likely
are pending.

Disable the bits also on UARTs not used in the boot loader to prevent
an interrupt storm when Linux enables the UART interrupts.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index cfdadda939..2c90a40042 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -238,8 +238,11 @@ iomux_v3_cfg_t const usb_pads[] = {
  * UARTs are used in DTE mode, switch the mode on all UARTs before
  * any pinmuxing connects a (DCE) output to a transceiver output.
  */
+#define UCR3   0x88/* FIFO Control Register */
+#define UCR3_RIBIT(8)  /* RIDELT DTE mode */
+#define UCR3_DCD   BIT(9)  /* DCDDELT DTE mode */
 #define UFCR   0x90/* FIFO Control Register */
-#define UFCR_DCEDTE(1<<6)  /* DCE=0 */
+#define UFCR_DCEDTEBIT(6)  /* DCE=0 */
 
 static void setup_dtemode_uart(void)
 {
@@ -247,6 +250,11 @@ static void setup_dtemode_uart(void)
setbits_le32((u32 *)(UART2_BASE + UFCR), UFCR_DCEDTE);
setbits_le32((u32 *)(UART4_BASE + UFCR), UFCR_DCEDTE);
setbits_le32((u32 *)(UART5_BASE + UFCR), UFCR_DCEDTE);
+
+   clrbits_le32((u32 *)(UART1_BASE + UCR3), UCR3_DCD | UCR3_RI);
+   clrbits_le32((u32 *)(UART2_BASE + UCR3), UCR3_DCD | UCR3_RI);
+   clrbits_le32((u32 *)(UART4_BASE + UCR3), UCR3_DCD | UCR3_RI);
+   clrbits_le32((u32 *)(UART5_BASE + UCR3), UCR3_DCD | UCR3_RI);
 }
 static void setup_dcemode_uart(void)
 {
-- 
2.20.1

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


[U-Boot] [PATCH v2 00/23] apalis imx6 fixes, device tree enablement and driver model conversion

2019-02-08 Thread Marcel Ziswiler

This series addresses some shortcomings, enables/introduces device tree
support and converts all except video to using the driver model. This is
fully tested both running our latest downstream BSP as well as the
mainline Linux kernel.

Changes in v2:
- Remove spurious mentioning of DFU MMC both in subject as well as
  description.
- Use GPL-2.0+ OR X11 instead of GPL-2.0 OR MIT to be more consistent
  with all our other device trees.
- Further comments and white-space clean-up.
- Also add SION bit for Apalis, backlight, eMMC reset and Ethernet PHY
  reset GPIOs.
- Also request MMC/SD CD and USB power GPIOs.
- Clean-up and re-order includes.
- White-space clean-up.
- Also update copyright year in PMIC header file.
- And drop compiler.h include.
- Remove Colibri iMX6 change which inadvertently slipped in here.
- Also fix device tree naming for MMC DFU.

Gerard Salvatella (1):
  board: apalis_imx6: check for and report ecc errors in fuses

Marcel Ziswiler (16):
  apalis_imx6: get rid of obsolete nospl configurations
  apalis_imx6: use distro defaults
  apalis_imx6: move console in env from header file to defconfig
  apalis_imx6: enable fit image, gpt, imx thermal, efi loader support
  apalis_imx6: remove obsolete USB_GADGET_MASS_STORAGE configuration
  apalis_imx6: migrate to using device tree
  apalis_imx6: clean-up and migrate gpios to using driver model
  apalis_imx6: enable pin control driver
  apalis_imx6: migrate i2c to using driver model
  apalis_imx6: migrate pmic and regulator to using driver model
  apalis_imx6: migrate mmc and sata to using driver model
  apalis_imx6: migrate usb to using driver model
  apalis_imx6: drop CONFIG_OF_SYSTEM_SETUP
  apalis_imx6: add distroboot support
  apalis_imx6: pf0100: reorder and cleanup message printing
  apalis_imx6: switch to zimage

Max Krummenacher (4):
  apalis_imx6: use both sd/mmc interfaces for setsdupdate
  apalis_imx6: unify sd/mmc drive strength with linux kernel settings
  apalis_imx6: disable ri and dcd irq in uarts
  apalis_imx6: revert fuse value set in mfgr_fuse

Sanchayan Maity (1):
  configs: apalis_imx6: Use ext4 file system by default

Stefan Agner (1):
  apalis_imx6: use SDP if USB serial downloader has been used

 arch/arm/dts/imx6-apalis.dts  | 730 ++
 .../toradex/apalis_imx6/1066mhz_4x128mx16.cfg |  47 --
 .../toradex/apalis_imx6/1066mhz_4x256mx16.cfg |  47 --
 board/toradex/apalis_imx6/MAINTAINERS |   4 +-
 board/toradex/apalis_imx6/apalis_imx6.c   | 341 
 board/toradex/apalis_imx6/apalis_imx6q.cfg|  33 -
 board/toradex/apalis_imx6/clocks.cfg  |  41 -
 board/toradex/apalis_imx6/ddr-setup.cfg   |  96 ---
 board/toradex/apalis_imx6/do_fuse.c   |   2 +-
 board/toradex/apalis_imx6/pf0100.c| 206 +++--
 board/toradex/apalis_imx6/pf0100.h|  59 +-
 configs/apalis_imx6_defconfig |  35 +-
 configs/apalis_imx6_nospl_com_defconfig   |  65 --
 configs/apalis_imx6_nospl_it_defconfig|  65 --
 include/configs/apalis_imx6.h |  83 +-
 15 files changed, 1119 insertions(+), 735 deletions(-)
 create mode 100644 arch/arm/dts/imx6-apalis.dts
 delete mode 100644 board/toradex/apalis_imx6/1066mhz_4x128mx16.cfg
 delete mode 100644 board/toradex/apalis_imx6/1066mhz_4x256mx16.cfg
 delete mode 100644 board/toradex/apalis_imx6/apalis_imx6q.cfg
 delete mode 100644 board/toradex/apalis_imx6/clocks.cfg
 delete mode 100644 board/toradex/apalis_imx6/ddr-setup.cfg
 delete mode 100644 configs/apalis_imx6_nospl_com_defconfig
 delete mode 100644 configs/apalis_imx6_nospl_it_defconfig

-- 
2.20.1

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


[U-Boot] [PATCH v2 2/4] stm32mp1: bsec: access with SMC for trusted boot

2019-02-08 Thread Patrick Delaunay
As BSEC is secure aware, all register access need to be done
by TF-A for TRUSTED boot chain, when U-Boot is executed in
normal world.

Signed-off-by: Patrick Delaunay 
---

Changes in v2: None

 arch/arm/mach-stm32mp/bsec.c  | 28 ++
 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h | 64 +++
 2 files changed, 92 insertions(+)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h

diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index d087a31..920a6c9 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -8,9 +8,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define BSEC_OTP_MAX_VALUE 95
 
+#ifndef CONFIG_STM32MP1_TRUSTED
 #define BSEC_TIMEOUT_US1
 
 /* BSEC REGISTER OFFSET (base relative) */
@@ -270,6 +273,7 @@ static int bsec_program_otp(long base, u32 val, u32 otp)
 
return ret;
 }
+#endif /* CONFIG_STM32MP1_TRUSTED */
 
 /* BSEC MISC driver ***/
 struct stm32mp_bsec_platdata {
@@ -278,6 +282,11 @@ struct stm32mp_bsec_platdata {
 
 static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc(STM32_SMC_BSEC,
+STM32_SMC_READ_OTP,
+otp, 0, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
u32 tmp_data = 0;
int ret;
@@ -299,27 +308,46 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 
*val, u32 otp)
/* restore shadow value */
ret = bsec_write_shadow(plat->base, tmp_data, otp);
return ret;
+#endif
 }
 
 static int stm32mp_bsec_read_shadow(struct udevice *dev, u32 *val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc(STM32_SMC_BSEC,
+STM32_SMC_READ_SHADOW,
+otp, 0, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_read_shadow(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_write_otp(struct udevice *dev, u32 val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc_exec(STM32_SMC_BSEC,
+ STM32_SMC_PROG_OTP,
+ otp, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_program_otp(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_write_shadow(struct udevice *dev, u32 val, u32 otp)
 {
+#ifdef CONFIG_STM32MP1_TRUSTED
+   return stm32_smc_exec(STM32_SMC_BSEC,
+ STM32_SMC_WRITE_SHADOW,
+ otp, val);
+#else
struct stm32mp_bsec_platdata *plat = dev_get_platdata(dev);
 
return bsec_write_shadow(plat->base, val, otp);
+#endif
 }
 
 static int stm32mp_bsec_read(struct udevice *dev, int offset,
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h 
b/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
new file mode 100644
index 000..8130546
--- /dev/null
+++ b/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+
+#ifndef __STM32MP1_SMC_H__
+#define __STM32MP1_SMC_H__
+
+#include 
+
+/*
+ * SMC function IDs for STM32 Service queries
+ * STM32 SMC services use the space between 0x8200 and 0x8200
+ * like this is defined in SMC calling Convention by ARM
+ * for SiP (silicon Partner)
+ * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
+ */
+#define STM32_SMC_VERSION  0x8200
+
+/* Secure Service access from Non-secure */
+#define STM32_SMC_BSEC 0x82001003
+
+/* Service for BSEC */
+#define STM32_SMC_READ_SHADOW  0x01
+#define STM32_SMC_PROG_OTP 0x02
+#define STM32_SMC_WRITE_SHADOW 0x03
+#define STM32_SMC_READ_OTP 0x04
+#define STM32_SMC_READ_ALL 0x05
+#define STM32_SMC_WRITE_ALL0x06
+
+/* SMC error codes */
+#define STM32_SMC_OK   0x0
+#define STM32_SMC_NOT_SUPPORTED-1
+#define STM32_SMC_FAILED   -2
+#define STM32_SMC_INVALID_PARAMS   -3
+
+#define stm32_smc_exec(svc, op, data1, data2) \
+   stm32_smc(svc, op, data1, data2, NULL)
+
+#ifdef CONFIG_ARM_SMCCC
+static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
+{
+   struct arm_smccc_res res;
+
+   arm_smccc_smc(svc, op, data1, data2, 0, 0, 0, 0, );
+
+   if (res.a0) {
+   pr_err("%s: Failed to exec in secure mode (err = %ld)\n",
+  __func__, res.a0);
+   return -EINVAL;
+   }
+   if (result)
+   *result = (u32)res.a1;
+
+   return 0;
+}
+#else
+static inline u32 stm32_smc(u32 svc, u8 

[U-Boot] [PATCH v2 16/23] apalis_imx6: unify sd/mmc drive strength with linux kernel settings

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

In the Linux device tree we use 40Ohm drive strength. So use the same
value in U-Boot.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 254fa4ddfb..cfdadda939 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -45,6 +45,10 @@ DECLARE_GLOBAL_DATA_PTR;
PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
 
 #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP |   \
+   PAD_CTL_SPEED_LOW | PAD_CTL_DSE_40ohm | \
+   PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
+
+#define USDHC_EMMC_PAD_CTRL (PAD_CTL_PUS_47K_UP |  \
PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
 
@@ -115,16 +119,16 @@ iomux_v3_cfg_t const usdhc2_pads[] = {
 
 /* eMMC */
 iomux_v3_cfg_t const usdhc3_pads[] = {
-   MX6_PAD_SD3_CLK__SD3_CLK| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_CMD__SD3_CMD| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+   MX6_PAD_SD3_CLK__SD3_CLK| MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_CMD__SD3_CMD| MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
+   MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_EMMC_PAD_CTRL),
MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(WEAK_PULLUP) | MUX_MODE_SION,
 };
 #endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
-- 
2.20.1

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


[U-Boot] [PATCH v2 13/23] apalis_imx6: drop CONFIG_OF_SYSTEM_SETUP

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

This doesn't do anything anymore, probably never did.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 7 ---
 include/configs/apalis_imx6.h   | 2 --
 2 files changed, 9 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 1faa94f99d..254fa4ddfb 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -706,13 +706,6 @@ int board_late_init(void)
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
 
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_SYSTEM_SETUP)
-int ft_system_setup(void *blob, bd_t *bd)
-{
-   return 0;
-}
-#endif
-
 int checkboard(void)
 {
char it[] = " IT";
diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index 6b20d1e104..382048d2ef 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -259,8 +259,6 @@
 #define CONFIG_SYS_MMC_ENV_PART1
 #endif
 
-#define CONFIG_OF_SYSTEM_SETUP
-
 #define CONFIG_CMD_TIME
 
 #endif /* __CONFIG_H */
-- 
2.20.1

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


[U-Boot] [PATCH v2 12/23] apalis_imx6: migrate usb to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate USB to using driver model.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 22 --
 configs/apalis_imx6_defconfig   |  1 +
 2 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index db06c4e064..1faa94f99d 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -271,28 +271,6 @@ int board_ehci_hcd_init(int port)
imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads));
return 0;
 }
-
-int board_ehci_power(int port, int on)
-{
-   switch (port) {
-   case 0:
-   /* control OTG power */
-   gpio_direction_output(GPIO_USBO_EN, on);
-   mdelay(100);
-   break;
-   case 1:
-   /* Control MXM USBH */
-   gpio_direction_output(GPIO_USBH_EN, on);
-   mdelay(2);
-   /* Control onboard USB Hub VBUS */
-   gpio_direction_output(GPIO_USB_VBUS_DET, on);
-   mdelay(100);
-   break;
-   default:
-   break;
-   }
-   return 0;
-}
 #endif
 
 #if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 510161ad32..1ab5edc966 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -72,6 +72,7 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_SCSI=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Toradex"
-- 
2.20.1

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


[U-Boot] [PATCH v2 23/23] board: apalis_imx6: check for and report ecc errors in fuses

2019-02-08 Thread Marcel Ziswiler
From: Gerard Salvatella 

The PMIC on Apalis iMX6 may have ECC errors in fuses that will prevent
correct settings. Up to one bit error per fuse bank may be reported and
corrected by the ECC logic. Two bit errors can only be reported.

Signed-off-by: Gerard Salvatella 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/pf0100.c | 51 ++
 board/toradex/apalis_imx6/pf0100.h | 57 +-
 2 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/board/toradex/apalis_imx6/pf0100.c 
b/board/toradex/apalis_imx6/pf0100.c
index 8106abf89a..ebd6418fd4 100644
--- a/board/toradex/apalis_imx6/pf0100.c
+++ b/board/toradex/apalis_imx6/pf0100.c
@@ -21,6 +21,8 @@
 /* define for PMIC register dump */
 /*#define DEBUG */
 
+#define WARNBAR "@\n"
+
 /* use Apalis GPIO1 to switch on VPGM, ON: 1 */
 static __maybe_unused iomux_v3_cfg_t const pmic_prog_pads[] = {
MX6_PAD_NANDF_D4__GPIO2_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL),
@@ -42,6 +44,55 @@ unsigned pmic_init(void)
   PFUZE100_I2C_ADDR);
return 0;
}
+
+   /* check for errors in PMIC fuses */
+   if (dm_i2c_read(dev, PFUZE100_INTSTAT3, , 1) < 0) {
+   puts("i2c pmic INTSTAT3 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BIT_OTP_ECCI) {
+   puts("\n" WARNBAR);
+   puts("WARNING: ecc errors found in pmic fuse banks\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_SE1, , 1) < 0) {
+   puts("i2c pmic ECC_SE1 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_SE1) {
+   puts(WARNBAR);
+   puts("WARNING: ecc has made bit corrections in banks 1 to 5\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_SE2, , 1) < 0) {
+   puts("i2c pmic ECC_SE2 register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_SE2) {
+   puts(WARNBAR);
+   puts("WARNING: ecc has made bit corrections in banks 6 to 10\n"
+   );
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_DE1, , 1) < 0) {
+   puts("i2c pmic ECC_DE register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_DE1) {
+   puts(WARNBAR);
+   puts("ERROR: banks 1 to 5 have uncorrectable bits\n");
+   puts(WARNBAR);
+   }
+   if (dm_i2c_read(dev, PFUZE100_OTP_ECC_DE2, , 1) < 0) {
+   puts("i2c pmic ECC_DE register read failed\n");
+   return 0;
+   }
+   if (val & PFUZE100_BITS_ECC_DE2) {
+   puts(WARNBAR);
+   puts("ERROR: banks 6 to 10 have uncorrectable bits\n");
+   puts(WARNBAR);
+   }
+
/* get device ident */
if (dm_i2c_read(dev, PFUZE100_DEVICEID, , 1) < 0) {
puts("i2c pmic devid read failed\n");
diff --git a/board/toradex/apalis_imx6/pf0100.h 
b/board/toradex/apalis_imx6/pf0100.h
index b854fe8c54..9257620511 100644
--- a/board/toradex/apalis_imx6/pf0100.h
+++ b/board/toradex/apalis_imx6/pf0100.h
@@ -10,11 +10,23 @@
 #ifndef PF0100_H_
 #define PF0100_H_
 
+/* bit definitions */
+#define PFUZE100_BIT_0 (0x01 << 0)
+#define PFUZE100_BIT_1 (0x01 << 1)
+#define PFUZE100_BIT_2 (0x01 << 2)
+#define PFUZE100_BIT_3 (0x01 << 3)
+#define PFUZE100_BIT_4 (0x01 << 4)
+#define PFUZE100_BIT_5 (0x01 << 5)
+#define PFUZE100_BIT_6 (0x01 << 6)
+#define PFUZE100_BIT_7 (0x01 << 7)
+
 /* 7-bit I2C bus slave address */
 #define PFUZE100_I2C_ADDR  (0x08)
 /* Register Addresses */
 #define PFUZE100_DEVICEID  (0x0)
 #define PFUZE100_REVID (0x3)
+#define PFUZE100_INTSTAT3  (0xe)
+#define PFUZE100_BIT_OTP_ECCI  PFUZE100_BIT_7
 #define PFUZE100_SW1AMODE  (0x23)
 #define PFUZE100_SW1ACON   36
 #define PFUZE100_SW1ACON_SPEED_VAL (0x1<<6)/*default */
@@ -39,12 +51,55 @@
 #define PFUZE100_PAGE_REGISTER_PAGE2   (0x02 & PFUZE100_PAGE_REGISTER_PAGE_M)
 
 /* extended page 1 */
+#define PFUZE100_OTP_ECC_SE1   0x8a
+#define PFUZE100_BIT_ECC1_SE   PFUZE100_BIT_0
+#define PFUZE100_BIT_ECC2_SE   PFUZE100_BIT_1
+#define PFUZE100_BIT_ECC3_SE   PFUZE100_BIT_2
+#define PFUZE100_BIT_ECC4_SE   PFUZE100_BIT_3
+#define PFUZE100_BIT_ECC5_SE   PFUZE100_BIT_4
+#define PFUZE100_BITS_ECC_SE1  ((PFUZE100_BIT_ECC1_SE) | \
+   (PFUZE100_BIT_ECC2_SE) | \
+   (PFUZE100_BIT_ECC3_SE) | \
+  

[U-Boot] [PATCH v2 11/23] apalis_imx6: migrate mmc and sata to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate MMC and SATA to using driver model.

While at it also enable SCSI driver model.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/apalis_imx6.c | 98 +++--
 configs/apalis_imx6_defconfig   |  3 +
 include/configs/apalis_imx6.h   |  3 -
 3 files changed, 61 insertions(+), 43 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 2c16c31021..db06c4e064 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -22,7 +23,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -60,6 +63,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define OUTPUT_RGB (PAD_CTL_SPEED_MED|PAD_CTL_DSE_60ohm|PAD_CTL_SRE_FAST)
 
+#define APALIS_IMX6_SATA_INIT_RETRIES  10
+
 int dram_init(void)
 {
/* use the DDR controllers configured size */
@@ -79,6 +84,7 @@ iomux_v3_cfg_t const uart1_pads_dte[] = {
MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
 /* Apalis MMC1 */
 iomux_v3_cfg_t const usdhc1_pads[] = {
MX6_PAD_SD1_CLK__SD1_CLK   | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -121,6 +127,7 @@ iomux_v3_cfg_t const usdhc3_pads[] = {
MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(WEAK_PULLUP) | MUX_MODE_SION,
 };
+#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
 
 int mx6_rgmii_rework(struct phy_device *phydev)
 {
@@ -288,7 +295,7 @@ int board_ehci_power(int port, int on)
 }
 #endif
 
-#ifdef CONFIG_FSL_ESDHC
+#if defined(CONFIG_FSL_ESDHC) && defined(CONFIG_SPL_BUILD)
 /* use the following sequence: eMMC, MMC1, SD1 */
 struct fsl_esdhc_cfg usdhc_cfg[CONFIG_SYS_FSL_USDHC_NUM] = {
{USDHC3_BASE_ADDR},
@@ -319,43 +326,6 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
-#ifndef CONFIG_SPL_BUILD
-   s32 status = 0;
-   u32 index = 0;
-
-   usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
-   usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
-   usdhc_cfg[2].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
-
-   usdhc_cfg[0].max_bus_width = 8;
-   usdhc_cfg[1].max_bus_width = 8;
-   usdhc_cfg[2].max_bus_width = 4;
-
-   for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
-   switch (index) {
-   case 0:
-   imx_iomux_v3_setup_multiple_pads(
-   usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
-   break;
-   case 1:
-   imx_iomux_v3_setup_multiple_pads(
-   usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
-   break;
-   case 2:
-   imx_iomux_v3_setup_multiple_pads(
-   usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
-   break;
-   default:
-   printf("Warning: you configured more USDHC controllers 
(%d) then supported by the board (%d)\n",
-  index + 1, CONFIG_SYS_FSL_USDHC_NUM);
-   return status;
-   }
-
-   status |= fsl_esdhc_initialize(bis, _cfg[index]);
-   }
-
-   return status;
-#else /* CONFIG_SPL_BUILD */
struct src *psrc = (struct src *)SRC_BASE_ADDR;
unsigned reg = readl(>sbmr1) >> 11;
/*
@@ -394,9 +364,8 @@ int board_mmc_init(bd_t *bis)
}
 
return fsl_esdhc_initialize(bis, _cfg[0]);
-#endif /* CONFIG_SPL_BUILD */
 }
-#endif /* CONFIG_FSL_ESDHC */
+#endif /* CONFIG_FSL_ESDHC & CONFIG_SPL_BUILD */
 
 int board_phy_config(struct phy_device *phydev)
 {
@@ -1162,3 +1131,52 @@ U_BOOT_DEVICE(mxc_serial) = {
.name = "serial_mxc",
.platdata = _serial_plat,
 };
+
+#if CONFIG_IS_ENABLED(AHCI)
+static int sata_imx_probe(struct udevice *dev)
+{
+   int i, err;
+
+   for (i = 0; i < APALIS_IMX6_SATA_INIT_RETRIES; i++) {
+   err = setup_sata();
+   if (err) {
+   printf("SATA setup failed: %d\n", err);
+   return err;
+   }
+
+   udelay(100);
+
+   err = dwc_ahsata_probe(dev);
+   if (!err)
+   break;
+
+   /* There is no device on the SATA port */
+   if (sata_dm_port_status(0, 0) == 0)
+   break;
+
+   /* There's a device, but link not established. Retry */
+   device_remove(dev, DM_REMOVE_NORMAL);
+   }
+
+   return 0;
+}
+
+struct ahci_ops sata_imx_ops = {
+   .port_status = dwc_ahsata_port_status,
+   .reset  = dwc_ahsata_bus_reset,
+   .scan   = 

[U-Boot] [PATCH v2 15/23] apalis_imx6: use both sd/mmc interfaces for setsdupdate

2019-02-08 Thread Marcel Ziswiler
From: Max Krummenacher 

During porting to 2016.11 the check of a SD (mmc2) interface
was dropped, this was unintended.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 include/configs/apalis_imx6.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index 5f865e1f08..7df32feb0d 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -210,8 +210,10 @@
"setethupdate=if env exists ethaddr; then; else setenv ethaddr " \
"00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
"flash_eth.img && source ${loadaddr}\0" \
-   "setsdupdate=setenv interface mmc; setenv drive 1; mmc rescan; load " \
-   "${interface} ${drive}:1 ${loadaddr} flash_blk.img && " \
+   "setsdupdate=setenv interface mmc; setenv drive 1; mmc rescan; " \
+   "load ${interface} ${drive}:1 ${loadaddr} flash_blk.img " \
+   "|| setenv drive 2; mmc rescan; load ${interface} ${drive}:1" \
+   " ${loadaddr} flash_blk.img && " \
"source ${loadaddr}\0" \
"setup=setenv setupargs fec_mac=${ethaddr} " \
"consoleblank=0 no_console_suspend=1 console=tty1 " \
-- 
2.20.1

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


[U-Boot] [PATCH v2 06/23] apalis_imx6: migrate to using device tree

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate to using device tree required for further driver model
integration.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2:
- Use GPL-2.0+ OR X11 instead of GPL-2.0 OR MIT to be more consistent
  with all our other device trees.
- Further comments and white-space clean-up.

 arch/arm/dts/imx6-apalis.dts  | 730 ++
 board/toradex/apalis_imx6/MAINTAINERS |   2 +
 configs/apalis_imx6_defconfig |   3 +-
 3 files changed, 734 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx6-apalis.dts

diff --git a/arch/arm/dts/imx6-apalis.dts b/arch/arm/dts/imx6-apalis.dts
new file mode 100644
index 00..b2fdfa1af4
--- /dev/null
+++ b/arch/arm/dts/imx6-apalis.dts
@@ -0,0 +1,730 @@
+// SPDX-License-Identifier: GPL-2.0+ OR X11
+/*
+ * Copyright 2019 Toradex AG
+ */
+
+/dts-v1/;
+#include 
+#include "imx6q.dtsi"
+
+/ {
+   model = "Toradex Apalis iMX6Q/D";
+   compatible = "toradex,apalis_imx6q", "fsl,imx6q";
+
+   /* Will be filled by the bootloader */
+   memory@1000 {
+   device_type = "memory";
+   reg = <0x1000 0>;
+   };
+
+   aliases {
+   mmc0 = 
+   mmc1 = 
+   mmc2 = 
+   usb0 =  /* required for ums */
+   };
+
+   chosen {
+   stdout-path = 
+   };
+
+   reg_module_3v3: regulator-module-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "+V3.3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-always-on;
+   };
+
+   reg_usb_otg_vbus: regulator-usb-otg-vbus {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_regulator_usbotg_pwr>;
+   regulator-name = "usb_otg_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = < 22 GPIO_ACTIVE_HIGH>; /* USBO1_EN */
+   enable-active-high;
+   };
+
+   /* on-module USB hub */
+   reg_usb_host_vbus_hub: regulator-usb-host-vbus-hub {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_regulator_usbhub_pwr>;
+   regulator-name = "usb_host_vbus_hub";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = < 28 GPIO_ACTIVE_HIGH>;
+   startup-delay-us = <2000>;
+   enable-active-high;
+   };
+
+   reg_usb_host_vbus: regulator-usb-host-vbus {
+   compatible = "regulator-fixed";
+   pinctrl-names = "default";
+   pinctrl-0 = <_regulator_usbh_pwr>;
+   regulator-name = "usb_host_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = < 0 GPIO_ACTIVE_HIGH>; /* USBH_EN */
+   enable-active-high;
+   vin-supply = <_usb_host_vbus_hub>;
+   };
+};
+
+/* I2C1_SDA/SCL on MXM3 209/211 (e.g. RTC on carrier board) */
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c1>;
+   status = "okay";
+};
+
+/*
+ * PWR_I2C: power I2C to audio codec, PMIC, temperature sensor and
+ * touch screen controller
+ */
+ {
+   clock-frequency = <10>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c2>;
+   status = "okay";
+
+   pmic: pfuze100@8 {
+   compatible = "fsl,pfuze100";
+   reg = <0x08>;
+
+   regulators {
+   sw1a_reg: sw1ab {
+   regulator-min-microvolt = <30>;
+   regulator-max-microvolt = <1875000>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <6250>;
+   };
+
+   sw1c_reg: sw1c {
+   regulator-min-microvolt = <30>;
+   regulator-max-microvolt = <1875000>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <6250>;
+   };
+
+   sw3a_reg: sw3a {
+   regulator-min-microvolt = <40>;
+   regulator-max-microvolt = <1975000>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   swbst_reg: swbst {
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <515>;
+  

[U-Boot] [PATCH v2 17/23] apalis_imx6: pf0100: reorder and cleanup message printing

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Keep debug code at the end of the function.
Use a one line informational message for the PMIC only.

Signed-off-by: Max Krummenacher 
Acked-by: Marcel Ziswiler 

---

Changes in v2: None

 board/toradex/apalis_imx6/pf0100.c | 110 +++--
 1 file changed, 56 insertions(+), 54 deletions(-)

diff --git a/board/toradex/apalis_imx6/pf0100.c 
b/board/toradex/apalis_imx6/pf0100.c
index 3a944b3699..8106abf89a 100644
--- a/board/toradex/apalis_imx6/pf0100.c
+++ b/board/toradex/apalis_imx6/pf0100.c
@@ -35,7 +35,7 @@ unsigned pmic_init(void)
uchar bus = 1;
uchar devid, revid, val;
 
-   puts("PMIC: ");
+   puts("PMIC:  ");
rc = i2c_get_chip_for_busnum(bus, PFUZE100_I2C_ADDR, 1, );
if (rc) {
printf("failed to get device for PMIC at address 0x%x\n",
@@ -51,57 +51,8 @@ unsigned pmic_init(void)
puts("i2c pmic revid read failed\n");
return 0;
}
-   printf("device id: 0x%.2x, revision id: 0x%.2x\n", devid, revid);
+   printf("device id: 0x%.2x, revision id: 0x%.2x, ", devid, revid);
 
-#ifdef DEBUG
-   {
-   unsigned i, j;
-
-   for (i = 0; i < 16; i++)
-   printf("\t%x", i);
-   for (j = 0; j < 0x80; ) {
-   printf("\n%2x", j);
-   for (i = 0; i < 16; i++) {
-   dm_i2c_read(dev, j + i, , 1);
-   printf("\t%2x", val);
-   }
-   j += 0x10;
-   }
-   printf("\nEXT Page 1");
-
-   val = PFUZE100_PAGE_REGISTER_PAGE1;
-   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
-   puts("i2c write failed\n");
-   return 0;
-   }
-
-   for (j = 0x80; j < 0x100; ) {
-   printf("\n%2x", j);
-   for (i = 0; i < 16; i++) {
-   dm_i2c_read(dev, j + i, , 1);
-   printf("\t%2x", val);
-   }
-   j += 0x10;
-   }
-   printf("\nEXT Page 2");
-
-   val = PFUZE100_PAGE_REGISTER_PAGE2;
-   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
-   puts("i2c write failed\n");
-   return 0;
-   }
-
-   for (j = 0x80; j < 0x100; ) {
-   printf("\n%2x", j);
-   for (i = 0; i < 16; i++) {
-   dm_i2c_read(dev, j + i, , 1);
-   printf("\t%2x", val);
-   }
-   j += 0x10;
-   }
-   printf("\n");
-   }
-#endif /* DEBUG */
/* get device programmed state */
val = PFUZE100_PAGE_REGISTER_PAGE1;
if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
@@ -131,13 +82,13 @@ unsigned pmic_init(void)
 
switch (programmed) {
case 0:
-   printf("PMIC: not programmed\n");
+   puts("not programmed\n");
break;
case 3:
-   printf("PMIC: programmed\n");
+   puts("programmed\n");
break;
default:
-   printf("PMIC: undefined programming state\n");
+   puts("undefined programming state\n");
break;
}
 
@@ -155,6 +106,57 @@ unsigned pmic_init(void)
if (dm_i2c_write(dev, PFUZE100_SWBSTCTL, , 1))
puts("i2c write failed\n");
}
+
+#ifdef DEBUG
+   {
+   unsigned int i, j;
+
+   for (i = 0; i < 16; i++)
+   printf("\t%x", i);
+   for (j = 0; j < 0x80; ) {
+   printf("\n%2x", j);
+   for (i = 0; i < 16; i++) {
+   dm_i2c_read(dev, j + i, , 1);
+   printf("\t%2x", val);
+   }
+   j += 0x10;
+   }
+   printf("\nEXT Page 1");
+
+   val = PFUZE100_PAGE_REGISTER_PAGE1;
+   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
+   puts("i2c write failed\n");
+   return 0;
+   }
+
+   for (j = 0x80; j < 0x100; ) {
+   printf("\n%2x", j);
+   for (i = 0; i < 16; i++) {
+   dm_i2c_read(dev, j + i, , 1);
+   printf("\t%2x", val);
+   }
+   j += 0x10;
+   }
+   printf("\nEXT Page 2");
+
+   val = PFUZE100_PAGE_REGISTER_PAGE2;
+   if (dm_i2c_write(dev, PFUZE100_PAGE_REGISTER, , 1)) {
+   puts("i2c write 

[U-Boot] [PATCH v2 05/23] apalis_imx6: remove obsolete USB_GADGET_MASS_STORAGE configuration

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Remove obsolete USB_GADGET_MASS_STORAGE configuration.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 include/configs/apalis_imx6.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index a1ba16fc79..785ab3 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -82,8 +82,6 @@
 /* Client */
 #define CONFIG_USBD_HS
 
-#define CONFIG_USB_GADGET_MASS_STORAGE
-
 /* Framebuffer and LCD */
 #define CONFIG_VIDEO_IPUV3
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
-- 
2.20.1

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


[U-Boot] [PATCH v2 07/23] apalis_imx6: clean-up and migrate gpios to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate GPIOs to using driver model, properly request backlight,
Ethernet PHY reset, MMC/SD card detect and USB power GPIOs and also
enable SION bit in pin muxing for Apalis, backlight, eMMC reset,
Ethernet PHY reset and USB power enable GPIOs.

While at it also update copyright year, clean-up/re-order includes,
add some comments clarifying ifdef scope and do some White-space
clean-up.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2:
- Also add SION bit for Apalis, backlight, eMMC reset and Ethernet PHY
  reset GPIOs.
- Also request MMC/SD CD and USB power GPIOs.
- Clean-up and re-order includes.
- White-space clean-up.

 board/toradex/apalis_imx6/apalis_imx6.c | 90 ++---
 configs/apalis_imx6_defconfig   |  1 +
 2 files changed, 53 insertions(+), 38 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 368db9c488..0a60b36447 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -2,38 +2,32 @@
 /*
  * Copyright (C) 2010-2013 Freescale Semiconductor, Inc.
  * Copyright (C) 2013, Boundary Devices 
- * Copyright (C) 2014-2016, Toradex AG
+ * Copyright (C) 2014-2019, Toradex AG
  * copied from nitrogen6x
  */
 
 #include 
 #include 
-#include 
+
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -200,7 +194,7 @@ iomux_v3_cfg_t const usdhc3_pads[] = {
MX6_PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
MX6_PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
-   MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(WEAK_PULLUP),
+   MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(WEAK_PULLUP) | MUX_MODE_SION,
 };
 
 int mx6_rgmii_rework(struct phy_device *phydev)
@@ -241,7 +235,8 @@ iomux_v3_cfg_t const enet_pads[] = {
MX6_PAD_RGMII_RD3__RGMII_RD3| MUX_PAD_CTRL(ENET_PAD_CTRL),
MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL  | MUX_PAD_CTRL(ENET_PAD_CTRL),
/* KSZ9031 PHY Reset */
-   MX6_PAD_ENET_CRS_DV__GPIO1_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL),
+   MX6_PAD_ENET_CRS_DV__GPIO1_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL) |
+ MUX_MODE_SION,
 #  define GPIO_ENET_PHY_RESET IMX_GPIO_NR(1, 25)
 };
 
@@ -253,6 +248,7 @@ static void setup_iomux_enet(void)
 static int reset_enet_phy(struct mii_dev *bus)
 {
/* Reset KSZ9031 PHY */
+   gpio_request(GPIO_ENET_PHY_RESET, "ETH_RESET#");
gpio_direction_output(GPIO_ENET_PHY_RESET, 0);
mdelay(10);
gpio_set_value(GPIO_ENET_PHY_RESET, 1);
@@ -263,15 +259,24 @@ static int reset_enet_phy(struct mii_dev *bus)
 /* mux the Apalis GPIO pins, so they can be used from the U-Boot cmdline */
 iomux_v3_cfg_t const gpio_pads[] = {
/* Apalis GPIO1 - GPIO8 */
-   MX6_PAD_NANDF_D4__GPIO2_IO04| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_D5__GPIO2_IO05| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_D6__GPIO2_IO06| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_D7__GPIO2_IO07| MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_RB0__GPIO6_IO10   | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_NANDF_WP_B__GPIO6_IO09  | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_2__GPIO1_IO02  | MUX_PAD_CTRL(WEAK_PULLDOWN),
-   MX6_PAD_GPIO_6__GPIO1_IO06  | MUX_PAD_CTRL(WEAK_PULLUP),
-   MX6_PAD_GPIO_4__GPIO1_IO04  | MUX_PAD_CTRL(WEAK_PULLUP),
+   MX6_PAD_NANDF_D4__GPIO2_IO04| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_D5__GPIO2_IO05| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_D6__GPIO2_IO06| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_D7__GPIO2_IO07| MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_RB0__GPIO6_IO10   | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_NANDF_WP_B__GPIO6_IO09  | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_GPIO_2__GPIO1_IO02  | MUX_PAD_CTRL(WEAK_PULLDOWN) |
+ MUX_MODE_SION,
+   MX6_PAD_GPIO_6__GPIO1_IO06  | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
+   MX6_PAD_GPIO_4__GPIO1_IO04  | MUX_PAD_CTRL(WEAK_PULLUP) |
+ MUX_MODE_SION,
 };
 
 static 

[U-Boot] [PATCH v2 09/23] apalis_imx6: migrate i2c to using driver model

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Migrate I2C to using driver model.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2:
- Also update copyright year in PMIC header file.
- And drop compiler.h include.

 board/toradex/apalis_imx6/apalis_imx6.c | 88 +
 board/toradex/apalis_imx6/pf0100.c  | 59 -
 board/toradex/apalis_imx6/pf0100.h  |  2 +-
 configs/apalis_imx6_defconfig   |  1 +
 include/configs/apalis_imx6.h   |  8 +--
 5 files changed, 36 insertions(+), 122 deletions(-)

diff --git a/board/toradex/apalis_imx6/apalis_imx6.c 
b/board/toradex/apalis_imx6/apalis_imx6.c
index 0a60b36447..2c16c31021 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -20,13 +20,11 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -50,32 +48,16 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
 
-#define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED |\
-   PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
-
-#define BUTTON_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
-
-#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP |  \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-   PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
 #define WEAK_PULLUP(PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
PAD_CTL_SRE_SLOW)
 
-#define NO_PULLUP  (   \
-   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-   PAD_CTL_SRE_SLOW)
-
 #define WEAK_PULLDOWN  (PAD_CTL_PUS_100K_DOWN |\
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
PAD_CTL_HYS | PAD_CTL_SRE_SLOW)
 
 #define TRISTATE   (PAD_CTL_HYS | PAD_CTL_SPEED_MED)
 
-#define OUTPUT_40OHM (PAD_CTL_SPEED_MED|PAD_CTL_DSE_40ohm)
-
 #define OUTPUT_RGB (PAD_CTL_SPEED_MED|PAD_CTL_DSE_60ohm|PAD_CTL_SRE_FAST)
 
 int dram_init(void)
@@ -97,63 +79,6 @@ iomux_v3_cfg_t const uart1_pads_dte[] = {
MX6_PAD_CSI0_DAT11__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
-#define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
-/* Apalis I2C1 */
-struct i2c_pads_info i2c_pad_info1 = {
-   .scl = {
-   .i2c_mode = MX6_PAD_CSI0_DAT9__I2C1_SCL | PC,
-   .gpio_mode = MX6_PAD_CSI0_DAT9__GPIO5_IO27 | PC,
-   .gp = IMX_GPIO_NR(5, 27)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_CSI0_DAT8__I2C1_SDA | PC,
-   .gpio_mode = MX6_PAD_CSI0_DAT8__GPIO5_IO26 | PC,
-   .gp = IMX_GPIO_NR(5, 26)
-   }
-};
-
-/* Apalis local, PMIC, SGTL5000, STMPE811 */
-struct i2c_pads_info i2c_pad_info_loc = {
-   .scl = {
-   .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | PC,
-   .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 | PC,
-   .gp = IMX_GPIO_NR(4, 12)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | PC,
-   .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 | PC,
-   .gp = IMX_GPIO_NR(4, 13)
-   }
-};
-
-/* Apalis I2C3 / CAM */
-struct i2c_pads_info i2c_pad_info3 = {
-   .scl = {
-   .i2c_mode = MX6_PAD_EIM_D17__I2C3_SCL | PC,
-   .gpio_mode = MX6_PAD_EIM_D17__GPIO3_IO17 | PC,
-   .gp = IMX_GPIO_NR(3, 17)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_EIM_D18__I2C3_SDA | PC,
-   .gpio_mode = MX6_PAD_EIM_D18__GPIO3_IO18 | PC,
-   .gp = IMX_GPIO_NR(3, 18)
-   }
-};
-
-/* Apalis I2C2 / DDC */
-struct i2c_pads_info i2c_pad_info_ddc = {
-   .scl = {
-   .i2c_mode = MX6_PAD_EIM_EB2__HDMI_TX_DDC_SCL | PC,
-   .gpio_mode = MX6_PAD_EIM_EB2__GPIO2_IO30 | PC,
-   .gp = IMX_GPIO_NR(2, 30)
-   },
-   .sda = {
-   .i2c_mode = MX6_PAD_EIM_D16__HDMI_TX_DDC_SDA | PC,
-   .gpio_mode = MX6_PAD_EIM_D16__GPIO3_IO16 | PC,
-   .gp = IMX_GPIO_NR(3, 16)
-   }
-};
-
 /* Apalis MMC1 */
 iomux_v3_cfg_t const usdhc1_pads[] = {
MX6_PAD_SD1_CLK__SD1_CLK   | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -583,12 +508,6 @@ static void do_enable_hdmi(struct display_info_t const 
*dev)
imx_enable_hdmi_phy();
 }
 
-static int detect_i2c(struct display_info_t const *dev)
-{
-   return (0 == i2c_set_bus_num(dev->bus)) &&
-  (0 == i2c_probe(dev->addr));
-}
-
 static void enable_lvds(struct display_info_t const *dev)
 {
struct iomuxc *iomux = (struct iomuxc *)
@@ -682,7 +601,6 @@ struct display_info_t const displays[] = {{
.bus= -1,
.addr   = 0,
.pixfmt = IPU_PIX_FMT_LVDS666,
-   .detect = detect_i2c,
.enable = 

[U-Boot] [PATCH v2 08/23] apalis_imx6: enable pin control driver

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Enable pin control driver as required for further driver model
migration.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 configs/apalis_imx6_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 0f6119bef5..0763b1d986 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -57,6 +57,8 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_MII=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_IMX6=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
-- 
2.20.1

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


[U-Boot] [PATCH v2 03/23] apalis_imx6: move console in env from header file to defconfig

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Move console in env from header file to defconfig.

While at it also update copyright year and remove spurious comments and
new lines.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2:
- Remove spurious mentioning of DFU MMC both in subject as well as
  description.

 configs/apalis_imx6_defconfig | 1 +
 include/configs/apalis_imx6.h | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index f7fb7a5f8a..098d791a62 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -14,6 +14,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index ba4e96da50..a1ba16fc79 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright 2013-2015 Toradex, Inc.
+ * Copyright 2013-2019 Toradex, Inc.
  *
  * Configuration settings for the Toradex Apalis iMX6
  */
@@ -86,7 +86,6 @@
 
 /* Framebuffer and LCD */
 #define CONFIG_VIDEO_IPUV3
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 #define CONFIG_VIDEO_BMP_RLE8
 #define CONFIG_SPLASH_SCREEN
@@ -255,7 +254,6 @@
(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* environment organization */
-
 #define CONFIG_ENV_SIZE(8 * 1024)
 
 #if defined(CONFIG_ENV_IS_IN_MMC)
-- 
2.20.1

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


[U-Boot] [PATCH v2 02/23] apalis_imx6: use distro defaults

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Use distro defaults and minimise default configuration again using
savedefconfig.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 configs/apalis_imx6_defconfig | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 86dabd3736..f7fb7a5f8a 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -9,12 +9,11 @@ CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
-CONFIG_ENV_VARS_UBOOT_CONFIG=y
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
-CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_MISC_INIT_R=y
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
@@ -26,9 +25,7 @@ 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_SYS_PROMPT="Apalis iMX6 # "
-CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_ELF is not set
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_XIMG is not set
@@ -43,14 +40,8 @@ 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_MII=y
-CONFIG_CMD_PING=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DWC_AHSATA=y
@@ -61,7 +52,6 @@ CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_MII=y
 CONFIG_USB=y
-CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Toradex"
-- 
2.20.1

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


[U-Boot] [PATCH v2 04/23] apalis_imx6: enable fit image, gpt, imx thermal, efi loader support

2019-02-08 Thread Marcel Ziswiler
From: Marcel Ziswiler 

Enbale FIT image, GPT command, i.MX thermal and EFI loader support.

Signed-off-by: Marcel Ziswiler 

---

Changes in v2: None

 configs/apalis_imx6_defconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 098d791a62..b262bb88b9 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -11,6 +11,7 @@ CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q"
 CONFIG_BOOTDELAY=1
 # CONFIG_CONSOLE_MUX is not set
@@ -36,6 +37,7 @@ CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_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
@@ -52,6 +54,7 @@ CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_MII=y
+CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
@@ -65,4 +68,3 @@ CONFIG_VIDEO=y
 CONFIG_FAT_WRITE=y
 CONFIG_OF_LIBFDT=y
 CONFIG_OF_LIBFDT_OVERLAY=y
-# CONFIG_EFI_LOADER is not set
-- 
2.20.1

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


[U-Boot] [PATCH] configs: am57xx_evm: define CONFIG_SPL_LOAD_FIT_ADDRESS for SPL-DFU

2019-02-08 Thread Bin Liu
Define CONFIG_SPL_LOAD_FIT_ADDRESS to enable SPL-DFU for am57x platform.

Signed-off-by: Bin Liu 
---
 include/configs/am57xx_evm.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/include/configs/am57xx_evm.h b/include/configs/am57xx_evm.h
index d61fdf9f7a36..70aa4250605b 100644
--- a/include/configs/am57xx_evm.h
+++ b/include/configs/am57xx_evm.h
@@ -35,11 +35,22 @@
 
 #define CONFIG_SYS_OMAP_ABE_SYSCK
 
+#ifdef CONFIG_SPL_DFU
+#ifndef CONFIG_SPL_BUILD
 #define DFUARGS \
"dfu_bufsiz=0x1\0" \
DFU_ALT_INFO_MMC \
DFU_ALT_INFO_EMMC \
DFU_ALT_INFO_RAM \
+   DFU_ALT_INFO_QSPI
+#else
+#undef CONFIG_CMD_BOOTD
+#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x8020
+#define DFUARGS \
+   "dfu_bufsiz=0x1\0" \
+   DFU_ALT_INFO_RAM
+#endif
+#endif
 
 #include 
 
-- 
2.17.1

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


  1   2   >