Re: [PATCH] efi_loader: round the memory area in efi_add_memory_map()

2020-05-16 Thread Heinrich Schuchardt
On 5/16/20 6:56 PM, Michael Walle wrote:
> Virtually all callers of this function do the rounding on their own.
> Some do it right, some don't. Instead of doing this in each caller,
> do the rounding in efi_add_memory_map(). Change the size parameter
> to bytes instead of pages and remove aligning and size calculation in
> all callers.
>
> There is no more need to make the original efi_add_memory_map() (which
> takes pages as size) available outside the module. Thus rename it to
> efi_add_memory_map_pg() and make it static to prevent further misuse
> outside the module.
>
> Signed-off-by: Michael Walle 
> ---
>
> I split off this patch of the following series because it touches
> many files:
>  https://lists.denx.de/pipermail/u-boot/2020-May/412065.html
>
> This patch supersede patch 2 and patch 3 of said series.
>
>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 10 ++---
>  arch/arm/cpu/armv8/fsl-layerscape/fdt.c |  5 +--
>  arch/arm/mach-meson/board-common.c  |  7 +---
>  arch/x86/lib/e820.c |  6 +--
>  board/raspberrypi/rpi/rpi.c |  2 +-
>  cmd/bootefi.c   |  8 +---
>  drivers/video/meson/meson_vpu.c |  4 +-
>  drivers/video/sunxi/sunxi_de2.c |  6 +--
>  drivers/video/sunxi/sunxi_display.c |  6 +--
>  include/efi_loader.h|  3 +-
>  lib/efi_loader/efi_memory.c | 54 ++---
>  lib/efi_loader/efi_runtime.c|  3 +-
>  12 files changed, 61 insertions(+), 53 deletions(-)
>
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
> b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> index b3f5c2f641..2cf3f4bb98 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> @@ -1529,9 +1529,8 @@ int dram_init_banksize(void)
>  void efi_add_known_memory(void)
>  {
>   int i;
> - phys_addr_t ram_start, start;
> + phys_addr_t ram_start;
>   phys_size_t ram_size;
> - u64 pages;
>
>   /* Add RAM */
>   for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> @@ -1549,11 +1548,8 @@ void efi_add_known_memory(void)
>   gd->arch.resv_ram < ram_start + ram_size)
>   ram_size = gd->arch.resv_ram - ram_start;
>  #endif
> - start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> - pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
> -
> - efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY,
> -false);
> + efi_add_memory_map(ram_start, ram_size,
> +EFI_CONVENTIONAL_MEMORY);
>   }
>  }
>  #endif
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c 
> b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> index 3bbad827cb..0696ea6d35 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> @@ -146,9 +146,8 @@ remove_psci_node:
>   fdt_add_mem_rsv(blob, (uintptr_t)_boot_code,
>   *boot_code_size);
>  #if CONFIG_IS_ENABLED(EFI_LOADER)
> - efi_add_memory_map((uintptr_t)_boot_code,
> -ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> 
> EFI_PAGE_SHIFT,
> -EFI_RESERVED_MEMORY_TYPE, false);
> + efi_add_memory_map((uintptr_t)_boot_code, *boot_code_size,
> +EFI_RESERVED_MEMORY_TYPE);
>  #endif
>  }
>  #endif
> diff --git a/arch/arm/mach-meson/board-common.c 
> b/arch/arm/mach-meson/board-common.c
> index bc4c92074c..747791b10e 100644
> --- a/arch/arm/mach-meson/board-common.c
> +++ b/arch/arm/mach-meson/board-common.c
> @@ -69,11 +69,8 @@ void meson_board_add_reserved_memory(void *fdt, u64 start, 
> u64 size)
>   if (ret)
>   printf("Could not reserve zone @ 0x%llx\n", start);
>
> - if (IS_ENABLED(CONFIG_EFI_LOADER)) {
> - efi_add_memory_map(start,
> -ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
> -EFI_RESERVED_MEMORY_TYPE, false);
> - }
> + if (IS_ENABLED(CONFIG_EFI_LOADER))
> + efi_add_memory_map(start, size, EFI_RESERVED_MEMORY_TYPE);
>  }
>
>  int meson_generate_serial_ethaddr(void)
> diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
> index 26da4d2f27..1f20c5c8c6 100644
> --- a/arch/x86/lib/e820.c
> +++ b/arch/x86/lib/e820.c
> @@ -41,7 +41,7 @@ void efi_add_known_memory(void)
>  {
>   struct e820_entry e820[E820MAX];
>   unsigned int i, num;
> - u64 start, pages, ram_top;
> + u64 start, ram_top;
>   int type;
>
>   num = install_e820_map(ARRAY_SIZE(e820), e820);
> @@ -77,9 +77,7 @@ void efi_add_known_memory(void)
>   start + e820[i].size,
>   ram_top);
>   } else {
> - pages = ALIGN(e820[i].size, EFI_PAGE_SIZE)
> - >> EFI_PAGE_SHIFT;
> -

Re: [PATCH] Azure: Add 'tools-only' build for macOS X hosts

2020-05-16 Thread Jonathan Gray
On Sat, May 16, 2020 at 02:54:39PM -0400, Tom Rini wrote:
> Add building the 'tools-only' target on macOS X 'Catalina'.  Hopefully
> this will catch changes to host tools that are incompatible on BSD style
> environments.
> 
> Signed-off-by: Tom Rini 
> 
> Note that at this time commit 3b4847cbee7c
> ("efi_loader: support building UEFI binaries on sandbox") is causing
> this to fail as non-GNU make does not support 'undefine' and there's not
> gmake nor do we need (seemingly) to use gmake otherwise.  If we must, we
> can look in to 'brew install gmake' I think but I'm trying to have this
> be a typical BSD build environment.

For building U-Boot (with around 70 targets) in OpenBSD ports we depend
on the following additional ports not in the base system:

devel/gmake
devel/bison
devel/dtc
devel/swig
textproc/gsed (with check-config.sh patched to use it over base sed)
lang/python (python3)

for aarch64 targets
devel/arm-none-eabi/gcc-linaro,aarch64
devel/py-elftools
sysutils/arm-trusted-firmware

for arm targets
devel/arm-none-eabi/gcc-linaro

The host/system compiler on most OpenBSD platforms is clang.

I would like to move to doing native builds when building on aarch64 and
armv7 platforms with the system clang.  I wonder how many of the
warnings in doc/README.clang still apply.

> ---
>  .azure-pipelines.yml | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
> index 5d9645451d47..09b79f4241f8 100644
> --- a/.azure-pipelines.yml
> +++ b/.azure-pipelines.yml
> @@ -1,6 +1,7 @@
>  variables:
>windows_vm: vs2017-win2016
>ubuntu_vm: ubuntu-18.04
> +  macos_vm: macOS-10.15
>ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200403-27Apr2020
># Add '-u 0' options for Azure pipelines, otherwise we get "permission
># denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
> @@ -44,6 +45,17 @@ jobs:
># Tell MSYS2 not to ‘cd’ our startup directory to HOME
>CHERE_INVOKING: yes
>  
> +  - job: tools_only_macOS
> +displayName: 'Ensure host tools build for macOS X'
> +pool:
> +  vmImage: $(macos_vm)
> +steps:
> +  - script: |
> +  make tools-only_config tools-only NO_SDL=1 \
> +HOSTCFLAGS="-I/usr/local/opt/openssl@1.1/include" \
> +HOSTLDFLAGS="-L/usr/local/opt/openssl@1.1/lib" \
> +-j$(sysctl -n hw.logicalcpu)
> +
>- job: cppcheck
>  displayName: 'Static code analysis with cppcheck'
>  pool:
> -- 
> 2.17.1
> 
> 


Re: [PATCH] patman: Avoid circular dependency between command and tools

2020-05-16 Thread Simon Glass
Reported-by: Stefan Bosch 

On Sat, 16 May 2020 at 17:02, Simon Glass  wrote:
>
> This seems to cause problems in some cases. Split the dependency by
> copying the code to command.
>
> Signed-off-by: Simon Glass 
> ---
>
>  tools/patman/command.py | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/patman/command.py b/tools/patman/command.py
> index e67ac159e5..bf8ea6c8c3 100644
> --- a/tools/patman/command.py
> +++ b/tools/patman/command.py
> @@ -5,7 +5,6 @@
>  import os
>
>  from patman import cros_subprocess
> -from patman import tools
>
>  """Shell command ease-ups for Python."""
>
> @@ -35,9 +34,9 @@ class CommandResult:
>
>  def ToOutput(self, binary):
>  if not binary:
> -self.stdout = tools.ToString(self.stdout)
> -self.stderr = tools.ToString(self.stderr)
> -self.combined = tools.ToString(self.combined)
> +self.stdout = self.stdout.decode('utf-8')
> +self.stderr = self.stderr.decode('utf-8')
> +self.combined = self.combined.decode('utf-8')
>  return self
>
>
> --
> 2.26.2.761.g0e0b3e54be-goog
>


Re: patman: ImportError

2020-05-16 Thread Simon Glass
Hi Stefan,

On Sat, 16 May 2020 at 05:27, Stefan Bosch  wrote:
>
> Hello,
>
> recently, I updated my local repository (U-Boot master). Last commit is
> c693f212c5b0433b3a49a89d87cbff28bf78eb87 now. Previously it has been
> 4df3578119b043d76b86b50077b06898fc2a4f62 (Date:   Wed Dec 18 18:25:42
> 2019 +0100).
>
> Now I get an "ImportError" if I call patman:
>
> u-boot_master$ ./tools/patman/patman --help
> Traceback (most recent call last):
>File "./tools/patman/patman", line 21, in 
>  from patman import checkpatch
>File
> "/home/stefan/u-boot_master/tools/patman/../patman/checkpatch.py", line
> 10, in 
>  from patman import command
>File "/home/stefan/u-boot_master/tools/patman/../patman/command.py",
> line 8, in 
>  from patman import tools
>File "/home/stefan/u-boot_master/tools/patman/../patman/tools.py",
> line 13, in 
>  from patman import command
> ImportError: cannot import name 'command'
>
> Cause of this 'ImportError' is probably that "from patman import
> command" has already been done before in checkpatch.py (circular
> dependency). I think the error has to do with your your commit
> bf776679a73f3b9eae37aabd2be5754483039cb2 (patman: Move to absolute imports).
>
> My Python version is 3.4.3.

The circular dependency has been there for some time, but perhaps in
Python 2, not Python 3. My Python is 3.6.9 or 3.7.7.

I sent a patch to break the circular dependency. Can you please try it
and see if it helps?

Regards,
Simon


[PATCH] patman: Avoid circular dependency between command and tools

2020-05-16 Thread Simon Glass
This seems to cause problems in some cases. Split the dependency by
copying the code to command.

Signed-off-by: Simon Glass 
---

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

diff --git a/tools/patman/command.py b/tools/patman/command.py
index e67ac159e5..bf8ea6c8c3 100644
--- a/tools/patman/command.py
+++ b/tools/patman/command.py
@@ -5,7 +5,6 @@
 import os
 
 from patman import cros_subprocess
-from patman import tools
 
 """Shell command ease-ups for Python."""
 
@@ -35,9 +34,9 @@ class CommandResult:
 
 def ToOutput(self, binary):
 if not binary:
-self.stdout = tools.ToString(self.stdout)
-self.stderr = tools.ToString(self.stderr)
-self.combined = tools.ToString(self.combined)
+self.stdout = self.stdout.decode('utf-8')
+self.stderr = self.stderr.decode('utf-8')
+self.combined = self.combined.decode('utf-8')
 return self
 
 
-- 
2.26.2.761.g0e0b3e54be-goog



[PATCH 2/2] thermal: imx_scu_thermal: fix getting DT alert property value

2020-05-16 Thread Anatolij Gustschin
Fix boot hang with endless loop outputting:
CPU Temperature (47200C) has beyond alert (0C), close to critical (0C) 
waiting...

Signed-off-by: Anatolij Gustschin 
---
i.MX8QXP is broken again, this should be appied ASAP!

 drivers/thermal/imx_scu_thermal.c | 101 --
 1 file changed, 41 insertions(+), 60 deletions(-)

diff --git a/drivers/thermal/imx_scu_thermal.c 
b/drivers/thermal/imx_scu_thermal.c
index da13121a09..679ce4e244 100644
--- a/drivers/thermal/imx_scu_thermal.c
+++ b/drivers/thermal/imx_scu_thermal.c
@@ -57,7 +57,7 @@ int imx_sc_thermal_get_temp(struct udevice *dev, int *temp)
if (ret)
return ret;
 
-   while (cpu_temp >= pdata->alert) {
+   while (cpu_temp >= pdata->alert && pdata->alert) {
printf("CPU Temperature (%dC) has beyond alert (%dC), close to 
critical (%dC)",
   cpu_temp, pdata->alert, pdata->critical);
puts(" waiting...\n");
@@ -78,7 +78,47 @@ static const struct dm_thermal_ops imx_sc_thermal_ops = {
 
 static int imx_sc_thermal_probe(struct udevice *dev)
 {
+   struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev);
+   struct fdtdec_phandle_args args;
+   ofnode node, trips_np;
+   int ret;
+
debug("%s dev name %s\n", __func__, dev->name);
+
+   trips_np = ofnode_path("/thermal-zones/cpu-thermal0/trips");
+   node = ofnode_get_parent(trips_np);
+   ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, node.of_offset,
+"thermal-sensors",
+"#thermal-sensor-cells",
+0, 0, );
+   if (ret)
+   return ret;
+
+   if (args.args_count >= 1)
+   pdata->id = args.args[0];
+   else
+   pdata->id = 0;
+
+   debug("args.args_count %d, id %d\n", args.args_count, pdata->id);
+
+   pdata->polling_delay = ofnode_read_u32_default(node, "polling-delay",
+  1000);
+   ofnode_for_each_subnode(trips_np, trips_np) {
+   const char *type;
+
+   type = ofnode_get_property(trips_np, "type", NULL);
+   if (!type)
+   continue;
+   if (!strcmp(type, "critical"))
+   pdata->critical =
+   ofnode_read_u32_default(trips_np, "temperature", 85);
+   else if (!strcmp(type, "passive"))
+   pdata->alert =
+   ofnode_read_u32_default(trips_np, "temperature", 80);
+   }
+
+   debug("id %d polling_delay %d, critical %d, alert %d\n",
+ pdata->id, pdata->polling_delay, pdata->critical, pdata->alert);
return 0;
 }
 
@@ -121,64 +161,6 @@ static int imx_sc_thermal_bind(struct udevice *dev)
return 0;
 }
 
-static int imx_sc_thermal_ofdata_to_platdata(struct udevice *dev)
-{
-   struct imx_sc_thermal_plat *pdata = dev_get_platdata(dev);
-   struct fdtdec_phandle_args args;
-   const char *type;
-   int ret;
-   int trips_np;
-
-   debug("%s dev name %s\n", __func__, dev->name);
-
-   if (pdata->zone_node)
-   return 0;
-
-   ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
-"thermal-sensors",
-"#thermal-sensor-cells",
-0, 0, );
-   if (ret)
-   return ret;
-
-   if (args.node != dev_of_offset(dev->parent))
-   return -EFAULT;
-
-   if (args.args_count >= 1)
-   pdata->id = args.args[0];
-   else
-   pdata->id = 0;
-
-   debug("args.args_count %d, id %d\n", args.args_count, pdata->id);
-
-   pdata->polling_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
- "polling-delay", 1000);
-
-   trips_np = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
- "trips");
-   fdt_for_each_subnode(trips_np, gd->fdt_blob, trips_np) {
-   type = fdt_getprop(gd->fdt_blob, trips_np, "type", NULL);
-   if (type) {
-   if (strcmp(type, "critical") == 0) {
-   pdata->critical = fdtdec_get_int(gd->fdt_blob,
-trips_np,
-"temperature",
-85);
-   } else if (strcmp(type, "passive") == 0) {
-   pdata->alert = fdtdec_get_int(gd->fdt_blob,
- trips_np,
- "temperature",
-  

[PATCH 1/2] cpu: imx8: fix type and rate detection

2020-05-16 Thread Anatolij Gustschin
CPU type and rate detection is broken, for A35 cpu we get A53:
...
sc_pm_get_clock_rate: resource:0 clk:2: res:3
Could not read CPU frequency: -22
CPU:   NXP i.MX8QXP RevB A53 at 0 MHz at 47C

Fixes: 55bc96f3b675 ("cpu: imx8: fix get core name and rate")
Signed-off-by: Anatolij Gustschin 
---
 drivers/cpu/imx8_cpu.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c
index 95c14c98d8..896e1ac776 100644
--- a/drivers/cpu/imx8_cpu.c
+++ b/drivers/cpu/imx8_cpu.c
@@ -52,11 +52,11 @@ const char *get_imx8_rev(u32 rev)
 
 const char *get_core_name(struct udevice *dev)
 {
-   if (!device_is_compatible(dev, "arm,cortex-a35"))
+   if (device_is_compatible(dev, "arm,cortex-a35"))
return "A35";
-   else if (!device_is_compatible(dev, "arm,cortex-a53"))
+   else if (device_is_compatible(dev, "arm,cortex-a53"))
return "A53";
-   else if (!device_is_compatible(dev, "arm,cortex-a72"))
+   else if (device_is_compatible(dev, "arm,cortex-a72"))
return "A72";
else
return "?";
@@ -183,11 +183,11 @@ static ulong imx8_get_cpu_rate(struct udevice *dev)
ulong rate;
int ret, type;
 
-   if (!device_is_compatible(dev, "arm,cortex-a35"))
+   if (device_is_compatible(dev, "arm,cortex-a35"))
type = SC_R_A35;
-   else if (!device_is_compatible(dev, "arm,cortex-a53"))
+   else if (device_is_compatible(dev, "arm,cortex-a53"))
type = SC_R_A53;
-   else if (!device_is_compatible(dev, "arm,cortex-a72"))
+   else if (device_is_compatible(dev, "arm,cortex-a72"))
type = SC_R_A72;
else
return 0;
-- 
2.17.1



Re: [PATCH 1/5] libfdt: Export overlay_apply_node() as fdt_overlay_apply_node()

2020-05-16 Thread Marek Vasut
On 4/20/20 1:37 AM, Simon Glass wrote:
> Hi Marek,
> 
> On Sat, 11 Apr 2020 at 14:01, Marek Vasut  wrote:
>>
>> This function is useful to merge a subset of DT into another DT, for
>> example if some prior-stage firmware passes a DT fragment to U-Boot
>> and U-Boot needs to merge it into its own DT. Export this function
>> to permit implementing such functionality.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: Nobuhiro Iwamatsu 
>> Cc: Simon Glass 
>> Cc: Tom Rini 
>> ---
>>  scripts/dtc/libfdt/fdt_overlay.c | 5 +
>>  scripts/dtc/libfdt/libfdt.h  | 7 +++
>>  2 files changed, 12 insertions(+)
> 
> This is fine but please send the patch upstream as we just copy this file.

PR is open here:
https://github.com/dgibson/dtc/pull/35

-- 
Best regards,
Marek Vasut


[PATCH v2] net: tftp: Add client support for RFC 7440

2020-05-16 Thread Ramon Fried
Add support for RFC 7440: "TFTP Windowsize Option".

This optional feature allows the client and server
to negotiate a window size of consecutive blocks to send as an
alternative for replacing the single-block lockstep schema.

windowsize can be defined statically during compilation by
setting CONFIG_TFTP_WINDOWSIZE, or defined in runtime by
setting an environment variable: "tftpwindowsize"
If not defined, the windowsize is set to 1, meaning that it
behaves as it was never defined.

Choosing the appropriate windowsize depends on the specific
network topology, underlying NIC.
You should test various windowsize scenarios and see which
best work for you.

Setting a windowsize too big can actually decreases performance.

Signed-off-by: Ramon Fried 
Reviewed-by: Marek Vasut 
---
v2:
 * Don't send windowsize option on tftpput, as it's not implemented yet.
 * Don't send NACK for every out of order block that arrives, one nack
   is enough.

 README |  5 
 net/tftp.c | 71 ++
 2 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/README b/README
index be9e6391d6..b85b44201f 100644
--- a/README
+++ b/README
@@ -3522,6 +3522,11 @@ List of environment variables (most likely not complete):
  downloads succeed with high packet loss rates, or with
  unreliable TFTP servers or client hardware.
 
+  tftpwindowsize   - if this is set, the value is used for TFTP's
+ window size as described by RFC 7440.
+ This means that count of blocks we can receive before
+ sending ack to server.
+
   vlan - When set to a value < 4095 the traffic over
  Ethernet is encapsulated/received over 802.1q
  VLAN tagged frames.
diff --git a/net/tftp.c b/net/tftp.c
index be24e63075..e2c005da6e 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -5,7 +5,6 @@
  * Copyright 2011 Comelit Group SpA,
  *Luca Ceresoli 
  */
-
 #include 
 #include 
 #include 
@@ -95,6 +94,12 @@ static int   tftp_tsize;
 /* The number of hashes we printed */
 static short   tftp_tsize_num_hash;
 #endif
+/* The window size neogiciated */
+static ushort  tftp_windowsize;
+/* Next block to send ack to */
+static ushort  tftp_next_ack;
+/* Last nack block we send */
+static ushort  tftp_last_nack;
 #ifdef CONFIG_CMD_TFTPPUT
 /* 1 if writing, else 0 */
 static int tftp_put_active;
@@ -134,8 +139,19 @@ static char tftp_filename[MAX_LEN];
  * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg 
file)
  */
 
+/* When windowsize is defined to 1,
+ * tftp behaves the same way as it was
+ * never declared
+ */
+#ifdef CONFIG_TFTP_WINDOWSIZE
+#define TFTP_WINDOWSIZE CONFIG_TFTP_WINDOWSIZE
+#else
+#define TFTP_WINDOWSIZE 1
+#endif
+
 static unsigned short tftp_block_size = TFTP_BLOCK_SIZE;
 static unsigned short tftp_block_size_option = CONFIG_TFTP_BLOCKSIZE;
+static unsigned short tftp_window_size_option = TFTP_WINDOWSIZE;
 
 static inline int store_block(int block, uchar *src, unsigned int len)
 {
@@ -348,6 +364,14 @@ static void tftp_send(void)
/* try for more effic. blk size */
pkt += sprintf((char *)pkt, "blksize%c%d%c",
0, tftp_block_size_option, 0);
+
+   /* try for more effic. window size.
+* Implemented only for tftp get.
+* Don't bother sending if it's 1
+*/
+   if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1)
+   pkt += sprintf((char *)pkt, "windowsize%c%d%c",
+   0, tftp_window_size_option, 0);
len = pkt - xp;
break;
 
@@ -500,6 +524,15 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct 
in_addr sip,
  (char *)pkt + i + 6, tftp_tsize);
}
 #endif
+   if (strcmp((char *)pkt + i,  "windowsize") == 0) {
+   tftp_windowsize =
+   simple_strtoul((char *)pkt + i + 11,
+  NULL, 10);
+   debug("windowsize = %s, %d\n",
+ (char *)pkt + i + 11, tftp_windowsize);
+   }
+
+   tftp_next_ack = tftp_windowsize;
}
 #ifdef CONFIG_CMD_TFTPPUT
if (tftp_put_active) {
@@ -514,6 +547,26 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct 
in_addr sip,
if (len < 2)
return;
len -= 2;
+
+   if (ntohs(*(__be16 *)pkt) != (ushort)(tftp_cur_block + 1)) {
+   debug("Received unexpected block: %d, expected: %d\n",
+ ntohs(*(__be16 *)pkt),
+ (ushort)(tftp_cur_block + 

[PATCH] Azure: Add 'tools-only' build for macOS X hosts

2020-05-16 Thread Tom Rini
Add building the 'tools-only' target on macOS X 'Catalina'.  Hopefully
this will catch changes to host tools that are incompatible on BSD style
environments.

Signed-off-by: Tom Rini 

Note that at this time commit 3b4847cbee7c
("efi_loader: support building UEFI binaries on sandbox") is causing
this to fail as non-GNU make does not support 'undefine' and there's not
gmake nor do we need (seemingly) to use gmake otherwise.  If we must, we
can look in to 'brew install gmake' I think but I'm trying to have this
be a typical BSD build environment.
---
 .azure-pipelines.yml | 12 
 1 file changed, 12 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 5d9645451d47..09b79f4241f8 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -1,6 +1,7 @@
 variables:
   windows_vm: vs2017-win2016
   ubuntu_vm: ubuntu-18.04
+  macos_vm: macOS-10.15
   ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200403-27Apr2020
   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
@@ -44,6 +45,17 @@ jobs:
   # Tell MSYS2 not to ‘cd’ our startup directory to HOME
   CHERE_INVOKING: yes
 
+  - job: tools_only_macOS
+displayName: 'Ensure host tools build for macOS X'
+pool:
+  vmImage: $(macos_vm)
+steps:
+  - script: |
+  make tools-only_config tools-only NO_SDL=1 \
+HOSTCFLAGS="-I/usr/local/opt/openssl@1.1/include" \
+HOSTLDFLAGS="-L/usr/local/opt/openssl@1.1/lib" \
+-j$(sysctl -n hw.logicalcpu)
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
-- 
2.17.1



[PATCH] efi_loader: round the memory area in efi_add_memory_map()

2020-05-16 Thread Michael Walle
Virtually all callers of this function do the rounding on their own.
Some do it right, some don't. Instead of doing this in each caller,
do the rounding in efi_add_memory_map(). Change the size parameter
to bytes instead of pages and remove aligning and size calculation in
all callers.

There is no more need to make the original efi_add_memory_map() (which
takes pages as size) available outside the module. Thus rename it to
efi_add_memory_map_pg() and make it static to prevent further misuse
outside the module.

Signed-off-by: Michael Walle 
---

I split off this patch of the following series because it touches
many files:
 https://lists.denx.de/pipermail/u-boot/2020-May/412065.html

This patch supersede patch 2 and patch 3 of said series.

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 10 ++---
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c |  5 +--
 arch/arm/mach-meson/board-common.c  |  7 +---
 arch/x86/lib/e820.c |  6 +--
 board/raspberrypi/rpi/rpi.c |  2 +-
 cmd/bootefi.c   |  8 +---
 drivers/video/meson/meson_vpu.c |  4 +-
 drivers/video/sunxi/sunxi_de2.c |  6 +--
 drivers/video/sunxi/sunxi_display.c |  6 +--
 include/efi_loader.h|  3 +-
 lib/efi_loader/efi_memory.c | 54 ++---
 lib/efi_loader/efi_runtime.c|  3 +-
 12 files changed, 61 insertions(+), 53 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index b3f5c2f641..2cf3f4bb98 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -1529,9 +1529,8 @@ int dram_init_banksize(void)
 void efi_add_known_memory(void)
 {
int i;
-   phys_addr_t ram_start, start;
+   phys_addr_t ram_start;
phys_size_t ram_size;
-   u64 pages;
 
/* Add RAM */
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
@@ -1549,11 +1548,8 @@ void efi_add_known_memory(void)
gd->arch.resv_ram < ram_start + ram_size)
ram_size = gd->arch.resv_ram - ram_start;
 #endif
-   start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
-   pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
-
-   efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY,
-  false);
+   efi_add_memory_map(ram_start, ram_size,
+  EFI_CONVENTIONAL_MEMORY);
}
 }
 #endif
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c 
b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 3bbad827cb..0696ea6d35 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -146,9 +146,8 @@ remove_psci_node:
fdt_add_mem_rsv(blob, (uintptr_t)_boot_code,
*boot_code_size);
 #if CONFIG_IS_ENABLED(EFI_LOADER)
-   efi_add_memory_map((uintptr_t)_boot_code,
-  ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> 
EFI_PAGE_SHIFT,
-  EFI_RESERVED_MEMORY_TYPE, false);
+   efi_add_memory_map((uintptr_t)_boot_code, *boot_code_size,
+  EFI_RESERVED_MEMORY_TYPE);
 #endif
 }
 #endif
diff --git a/arch/arm/mach-meson/board-common.c 
b/arch/arm/mach-meson/board-common.c
index bc4c92074c..747791b10e 100644
--- a/arch/arm/mach-meson/board-common.c
+++ b/arch/arm/mach-meson/board-common.c
@@ -69,11 +69,8 @@ void meson_board_add_reserved_memory(void *fdt, u64 start, 
u64 size)
if (ret)
printf("Could not reserve zone @ 0x%llx\n", start);
 
-   if (IS_ENABLED(CONFIG_EFI_LOADER)) {
-   efi_add_memory_map(start,
-  ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
-  EFI_RESERVED_MEMORY_TYPE, false);
-   }
+   if (IS_ENABLED(CONFIG_EFI_LOADER))
+   efi_add_memory_map(start, size, EFI_RESERVED_MEMORY_TYPE);
 }
 
 int meson_generate_serial_ethaddr(void)
diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
index 26da4d2f27..1f20c5c8c6 100644
--- a/arch/x86/lib/e820.c
+++ b/arch/x86/lib/e820.c
@@ -41,7 +41,7 @@ void efi_add_known_memory(void)
 {
struct e820_entry e820[E820MAX];
unsigned int i, num;
-   u64 start, pages, ram_top;
+   u64 start, ram_top;
int type;
 
num = install_e820_map(ARRAY_SIZE(e820), e820);
@@ -77,9 +77,7 @@ void efi_add_known_memory(void)
start + e820[i].size,
ram_top);
} else {
-   pages = ALIGN(e820[i].size, EFI_PAGE_SIZE)
-   >> EFI_PAGE_SHIFT;
-   efi_add_memory_map(start, pages, type, false);
+   efi_add_memory_map(start, e820[i].size, type);
}
}
 }
diff --git 

Re: [PATCH 4/4] efi_loader: call smp_kick_all_cpus()

2020-05-16 Thread Michael Walle

[Also adding Tom Rini as ARM maintainer]

Am 2020-05-14 22:17, schrieb Alexander Graf:

On 14.05.20 20:46, Heinrich Schuchardt wrote:

On 5/14/20 2:38 PM, Michael Walle wrote:
On some architectures, specifically the layerscape, the secondary 
cores
wait for an interrupt before entering the spin-tables. This applies 
only
to boards which doesn't have PSCI provided by TF-a and u-boot does 
the

%s/TF-a/TF-A/, %s/u-boot/U-Boot/


secondary cores handling.
bootm/booti already call that function for ARM architecture; also add 
it

to bootelf before switching to EL2. Additionally, provide a weak noop
function so we don't have to have "#ifdef CONFIG_ARM64" guards.

Signed-off-by: Michael Walle 
---
  common/bootm.c | 9 +
  lib/efi_loader/efi_setup.c | 6 ++
  2 files changed, 15 insertions(+)

diff --git a/common/bootm.c b/common/bootm.c
index db4362a643..65adf29329 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -816,6 +816,15 @@ void __weak switch_to_non_secure_mode(void)
  {
  }

+/**
+ * smp_kick_all_cpus() - kick all CPUs
+ *
+ * This routine is overridden by architectures requiring this 
feature.

+ */
+void __weak smp_kick_all_cpus(void)
+{
+}
+
  #else /* USE_HOSTCC */

  #if defined(CONFIG_FIT_SIGNATURE)
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 26a7423203..7e5364adc5 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -132,6 +132,12 @@ efi_status_t efi_init_obj_list(void)
/* Allow unaligned memory access */
allow_unaligned();

+   /*
+* Some architectures need to kick secondary cores to enter their
+* spin table.
+*/
+   smp_kick_all_cpus();

This will not compile with

CONFIG_CMD_BOOTI=n
CONFIG_CMD_BOOTM=n
CONFIG_CMD_BOOTZ=n



Much worse is that in incurs needless overhead on PSCI capable
platforms. Can we move the smp_kick_all_cpus() to the board or soc
level of the few systems that use spin tables please? :)


Ok, I'm not sure where I should put the smp_kick_all_cpus(). In the
bootm/booti path this is done in boot_jump_linux() (unconditionally
in do_nonsec_virt_switch()). Therefore, shouldn't the kick be in
switch_to_non_secure_mode(), too?

Regarding the overhead, isn't it just called once before starting
the OS? Is that really worth adding yet another weak function or
ifdef guards? Isn't it better to behave like the bootm case?

--
-michael


Re: [PATCH V3] usb: ehci-omap: Add Support for DM_USB and OF_CONTROL

2020-05-16 Thread Marek Vasut
On 5/16/20 8:19 AM, Adam Ford wrote:
> The omap3.dtsi file shows the usbhshost node with two sub-nodes
> for ohci and ehci.  This patch file creates the usbhshost, and
> pulls the portX-mode information.  It then locates the EHCI
> sub-node, and initializes the EHCI controller with the info
> pulled from the usbhshost node.
> 
> There is still more to do since there isn't an actual link
> between the 'phys' reference and the corresponding phy driver,
> and there is no nop-xceiv driver yet.
> 
> In the meantime, the older style reference to
> CONFIG_OMAP_EHCI_PHYx_RESET_GPIO is still needed to pull
> the phy out of reset until the phy driver is completed and the
> phandle reference is made.

Applied, thanks.


[PATCH] arm: mach-k3: j721e_init: Add support for backup boot modes

2020-05-16 Thread Faiz Abbas
From: Andreas Dannenberg 

When the boot of J721E devices using the primary bootmode (configured
via device pins) fails a boot using the configured backup bootmode is
attempted. To take advantage of the backup boot mode feature go ahead
and add support to the J721E init code to determine whether the ROM code
performed the boot using the primary or backup boot mode, and if booted
from the backup boot mode, decode the bootmode settings into the
appropriate U-Boot mode accordingly so that the boot can proceed.

Signed-off-by: Andreas Dannenberg 
Signed-off-by: Faiz Abbas 
---
 .../arm/mach-k3/include/mach/j721e_hardware.h |  2 ++
 arch/arm/mach-k3/include/mach/j721e_spl.h | 12 +++
 arch/arm/mach-k3/j721e_init.c | 35 +--
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-k3/include/mach/j721e_hardware.h 
b/arch/arm/mach-k3/include/mach/j721e_hardware.h
index ead136ed63..2efa911a9a 100644
--- a/arch/arm/mach-k3/include/mach/j721e_hardware.h
+++ b/arch/arm/mach-k3/include/mach/j721e_hardware.h
@@ -18,6 +18,8 @@
 #define MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT   1
 #define MAIN_DEVSTAT_PRIM_BOOTMODE_MMC_PORT_MASK   BIT(6)
 #define MAIN_DEVSTAT_PRIM_BOOTMODE_PORT_SHIFT  6
+#define MAIN_DEVSTAT_BKUP_MMC_PORT_MASKBIT(7)
+#define MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT   7
 
 #define WKUP_CTRL_MMR0_BASE0x4300
 #define MCU_CTRL_MMR0_BASE 0x40f0
diff --git a/arch/arm/mach-k3/include/mach/j721e_spl.h 
b/arch/arm/mach-k3/include/mach/j721e_spl.h
index 475278bd04..1cabc01dc4 100644
--- a/arch/arm/mach-k3/include/mach/j721e_spl.h
+++ b/arch/arm/mach-k3/include/mach/j721e_spl.h
@@ -25,7 +25,19 @@
 #define BOOT_DEVICE_MMC2_2 0x16
 #define BOOT_DEVICE_RAM0x17
 
+/* Backup boot modes with MCU Only = 0 */
+#define BACKUP_BOOT_DEVICE_RAM 0x0
+#define BACKUP_BOOT_DEVICE_USB 0x1
+#define BACKUP_BOOT_DEVICE_UART0x3
+#define BACKUP_BOOT_DEVICE_ETHERNET0x4
+#define BACKUP_BOOT_DEVICE_MMC20x5
+#define BACKUP_BOOT_DEVICE_SPI 0x6
+#define BACKUP_BOOT_DEVICE_I2C 0x7
+
 #define BOOT_MODE_B_SHIFT  4
 #define BOOT_MODE_B_MASK   BIT(4)
 
+#define K3_PRIMARY_BOOTMODE0x0
+#define K3_BACKUP_BOOTMODE 0x1
+
 #endif
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 71fc20c30b..18a3c1c052 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -235,6 +235,35 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
}
 }
 
+static u32 __get_backup_bootmedia(u32 main_devstat)
+{
+   u32 bkup_boot = (main_devstat & MAIN_DEVSTAT_BKUP_BOOTMODE_MASK) >>
+   MAIN_DEVSTAT_BKUP_BOOTMODE_SHIFT;
+
+   switch (bkup_boot) {
+   case BACKUP_BOOT_DEVICE_USB:
+   return BOOT_DEVICE_DFU;
+   case BACKUP_BOOT_DEVICE_UART:
+   return BOOT_DEVICE_UART;
+   case BACKUP_BOOT_DEVICE_ETHERNET:
+   return BOOT_DEVICE_ETHERNET;
+   case BACKUP_BOOT_DEVICE_MMC2:
+   {
+   u32 port = (main_devstat & MAIN_DEVSTAT_BKUP_MMC_PORT_MASK) >>
+   MAIN_DEVSTAT_BKUP_MMC_PORT_SHIFT;
+   if (port == 0x0)
+   return BOOT_DEVICE_MMC1;
+   return BOOT_DEVICE_MMC2;
+   }
+   case BACKUP_BOOT_DEVICE_SPI:
+   return BOOT_DEVICE_SPI;
+   case BACKUP_BOOT_DEVICE_I2C:
+   return BOOT_DEVICE_I2C;
+   }
+
+   return BOOT_DEVICE_RAM;
+}
+
 static u32 __get_primary_bootmedia(u32 main_devstat, u32 wkup_devstat)
 {
 
@@ -271,8 +300,10 @@ u32 spl_boot_device(void)
/* MAIN CTRL MMR can only be read if MCU ONLY is 0 */
main_devstat = readl(CTRLMMR_MAIN_DEVSTAT);
 
-   /* ToDo: Add support for backup boot media */
-   return __get_primary_bootmedia(main_devstat, wkup_devstat);
+   if (bootindex == K3_PRIMARY_BOOTMODE)
+   return __get_primary_bootmedia(main_devstat, wkup_devstat);
+   else
+   return __get_backup_bootmedia(main_devstat);
 }
 #endif
 
-- 
2.17.1



Re: [ANN] U-Boot v2020.07-rc2 released

2020-05-16 Thread Tom Rini
On Sat, May 16, 2020 at 08:10:04AM +, Peng Fan wrote:
> Hi Tom,
> 
> > -Original Message-
> > From: U-Boot  On Behalf Of Tom Rini
> > Sent: 2020年5月12日 6:29
> > To: u-boot@lists.denx.de
> > Cc: u-boot-custodi...@lists.denx.de;
> > u-boot-board-maintain...@lists.denx.de
> > Subject: [ANN] U-Boot v2020.07-rc2 released
> > 
> > Hey all,
> > 
> > It's release day and I've tagged v2020.07-rc2.  At this point out we should 
> > be
> > seeing stabilization, clean-up and localized new features.
> > 
> > Once again, for a changelog,
> > git log --merges v2020.07-rc1..v2020.07-rc2 and as always, I ask for more
> > details in the PRs people send me so I can put them in the merge commit.
> > 
> > I'm planning to follow the every-other-week RC schedule and release on July
> > 6th.  I'm also thinking about opening -next again on June 8th as that will 
> > give
> > us a bit more time to focus on stability and regression fixing.
> 
> Will you automatically merge sub-maintainers next tree? Or need 
> sub-maintainers
> to send PR to your next tree? Will your next tree rebase master branch in 
> time?

So, I forget if I had talked about how I'm running -next for now before
or not.  I expect to be sent a PR for my -next branch rather than
automatically grabbing them from people, and then I take care of merging
-next to master after release.

-- 
Tom


signature.asc
Description: PGP signature


patman: ImportError

2020-05-16 Thread Stefan Bosch

Hello,

recently, I updated my local repository (U-Boot master). Last commit is 
c693f212c5b0433b3a49a89d87cbff28bf78eb87 now. Previously it has been 
4df3578119b043d76b86b50077b06898fc2a4f62 (Date:   Wed Dec 18 18:25:42 
2019 +0100).


Now I get an "ImportError" if I call patman:

u-boot_master$ ./tools/patman/patman --help
Traceback (most recent call last):
  File "./tools/patman/patman", line 21, in 
from patman import checkpatch
  File 
"/home/stefan/u-boot_master/tools/patman/../patman/checkpatch.py", line 
10, in 

from patman import command
  File "/home/stefan/u-boot_master/tools/patman/../patman/command.py", 
line 8, in 

from patman import tools
  File "/home/stefan/u-boot_master/tools/patman/../patman/tools.py", 
line 13, in 

from patman import command
ImportError: cannot import name 'command'

Cause of this 'ImportError' is probably that "from patman import 
command" has already been done before in checkpatch.py (circular 
dependency). I think the error has to do with your your commit 
bf776679a73f3b9eae37aabd2be5754483039cb2 (patman: Move to absolute imports).


My Python version is 3.4.3.


Regards
Stefan Bosch


Re: [PATCH 6/6 v3] configs: lx2160a: Add default config for lx2160a using StMM in OP-TEE

2020-05-16 Thread Heinrich Schuchardt
On 5/15/20 9:53 PM, Ilias Apalodimas wrote:
> Previous patches allow UEFI secure variables to be stored in an RPMB
> device using OPTEE. Add a config for the lx2160a hardware so the feature
> gets at least compiled.
>
> Signed-off-by: Ilias Apalodimas 
> ---
>  configs/lx2160ardb_tfa_stmm_defconfig | 78 +++
>  1 file changed, 78 insertions(+)
>  create mode 100644 configs/lx2160ardb_tfa_stmm_defconfig
>
> diff --git a/configs/lx2160ardb_tfa_stmm_defconfig 
> b/configs/lx2160ardb_tfa_stmm_defconfig
> new file mode 100644
> index ..42d0d45ef0f1
> --- /dev/null
> +++ b/configs/lx2160ardb_tfa_stmm_defconfig
> @@ -0,0 +1,78 @@
> +CONFIG_ARM=y
> +CONFIG_TARGET_LX2160ARDB=y
> +CONFIG_TFABOOT=y
> +CONFIG_SYS_TEXT_BASE=0x8200
> +CONFIG_SYS_MALLOC_F_LEN=0x6000
> +CONFIG_DM_GPIO=y
> +CONFIG_EMC2305=y
> +CONFIG_FSPI_AHB_EN_4BYTE=y
> +CONFIG_NR_DRAM_BANKS=3
> +CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT=y
> +CONFIG_SEC_FIRMWARE_ARMV8_PSCI=y
> +CONFIG_AHCI=y
> +CONFIG_FIT_VERBOSE=y
> +CONFIG_OF_BOARD_SETUP=y
> +CONFIG_OF_STDOUT_VIA_ALIAS=y
> +CONFIG_BOOTDELAY=10
> +CONFIG_USE_BOOTARGS=y
> +CONFIG_BOOTARGS="console=ttyAMA0,115200 root=/dev/ram0 
> earlycon=pl011,mmio32,0x21c ramdisk_size=0x200 
> default_hugepagesz=1024m hugepagesz=1024m hugepages=2 pci=pcie_bus_perf"
> +# CONFIG_USE_BOOTCOMMAND is not set
> +CONFIG_CMD_BOOTEFI_SELFTEST=y

This is nothing you would need on a production system.

> +CONFIG_CMD_GREPENV=y
> +CONFIG_CMD_NVEDIT_EFI=y
> +CONFIG_CMD_EEPROM=y
> +CONFIG_CMD_GPT=y
> +CONFIG_CMD_I2C=y
> +CONFIG_CMD_MMC=y
> +# CONFIG_CMD_MMC_RPMB is not set

You have enabled RPMB because the OP-TEE based standalone MM module
stores variables in the RPMB partition. Consider enabling this command.

Compared to lx2160ardb_tfa_defconfig you disabled the following:

> CONFIG_GIC_V3_ITS=y
> CONFIG_ENV_SIZE=0x2000
> CONFIG_ENV_OFFSET=0x50
> CONFIG_ENV_SECT_SIZE=0x2
> CONFIG_MISC_INIT_R=y
> CONFIG_CMD_DM=y
> CONFIG_ENV_IS_IN_MMC=y
> CONFIG_ENV_IS_IN_SPI_FLASH=y
> CONFIG_ENV_ADDR=0x2050
> CONFIG_MTD=y
> CONFIG_DM_ETH=y
> CONFIG_DM_MDIO=y
> CONFIG_FSL_LS_MDIO=y

I would suggest to resync with the current lx2160ardb_tfa_defconfig.

CC: Priyanka Jain as maintainer of LX2160ARDB BOARD (which includes
lx2160ardb_tfa_defconfig).

Best regards

Heinrich

> +CONFIG_CMD_PCI=y
> +CONFIG_CMD_USB=y
> +CONFIG_CMD_CACHE=y
> +CONFIG_CMD_EFIDEBUG=y
> +CONFIG_MP=y
> +CONFIG_OF_CONTROL=y
> +CONFIG_OF_BOARD_FIXUP=y
> +CONFIG_DEFAULT_DEVICE_TREE="fsl-lx2160a-rdb"
> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_TFTP_BLOCKSIZE=512
> +CONFIG_DM=y
> +CONFIG_SATA_CEVA=y
> +CONFIG_FSL_CAAM=y
> +CONFIG_DM_I2C=y
> +CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
> +CONFIG_I2C_DEFAULT_BUS_NUMBER=0
> +CONFIG_DM_MMC=y
> +CONFIG_SUPPORT_EMMC_RPMB=y
> +CONFIG_FSL_ESDHC=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SPI_FLASH_SPANSION=y
> +CONFIG_SPI_FLASH_STMICRO=y
> +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
> +CONFIG_PHYLIB=y
> +CONFIG_PHY_AQUANTIA=y
> +CONFIG_PHY_ATHEROS=y
> +CONFIG_PHY_CORTINA=y
> +CONFIG_E1000=y
> +CONFIG_PCI=y
> +CONFIG_DM_PCI=y
> +CONFIG_DM_PCI_COMPAT=y
> +CONFIG_PCIE_LAYERSCAPE=y
> +CONFIG_PCIE_LAYERSCAPE_GEN4=y
> +CONFIG_DM_RTC=y
> +CONFIG_RTC_PCF2127=y
> +CONFIG_DM_SCSI=y
> +CONFIG_DM_SERIAL=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> +CONFIG_NXP_FSPI=y
> +CONFIG_TEE=y
> +CONFIG_OPTEE=y
> +CONFIG_USB=y
> +CONFIG_DM_USB=y
> +CONFIG_USB_XHCI_HCD=y
> +CONFIG_USB_XHCI_DWC3=y
> +# CONFIG_FAT_WRITE is not set
> +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
> +CONFIG_EFI_MM_COMM_TEE=y
> +CONFIG_OPTEE_TZDRAM_SIZE=0x
>



RE: [ANN] U-Boot v2020.07-rc2 released

2020-05-16 Thread Peng Fan
Hi Tom,

> -Original Message-
> From: U-Boot  On Behalf Of Tom Rini
> Sent: 2020年5月12日 6:29
> To: u-boot@lists.denx.de
> Cc: u-boot-custodi...@lists.denx.de;
> u-boot-board-maintain...@lists.denx.de
> Subject: [ANN] U-Boot v2020.07-rc2 released
> 
> Hey all,
> 
> It's release day and I've tagged v2020.07-rc2.  At this point out we should be
> seeing stabilization, clean-up and localized new features.
> 
> Once again, for a changelog,
> git log --merges v2020.07-rc1..v2020.07-rc2 and as always, I ask for more
> details in the PRs people send me so I can put them in the merge commit.
> 
> I'm planning to follow the every-other-week RC schedule and release on July
> 6th.  I'm also thinking about opening -next again on June 8th as that will 
> give
> us a bit more time to focus on stability and regression fixing.

Will you automatically merge sub-maintainers next tree? Or need sub-maintainers
to send PR to your next tree? Will your next tree rebase master branch in time?

Thanks,
Peng

  Thanks all!
> 
> --
> Tom


[PATCH V3] usb: ehci-omap: Add Support for DM_USB and OF_CONTROL

2020-05-16 Thread Adam Ford
The omap3.dtsi file shows the usbhshost node with two sub-nodes
for ohci and ehci.  This patch file creates the usbhshost, and
pulls the portX-mode information.  It then locates the EHCI
sub-node, and initializes the EHCI controller with the info
pulled from the usbhshost node.

There is still more to do since there isn't an actual link
between the 'phys' reference and the corresponding phy driver,
and there is no nop-xceiv driver yet.

In the meantime, the older style reference to
CONFIG_OMAP_EHCI_PHYx_RESET_GPIO is still needed to pull
the phy out of reset until the phy driver is completed and the
phandle reference is made.

Signed-off-by: Adam Ford 
---
V3:  The omap3 device tree shows a parent node called usbhshost and
 a subnode called usbhsehci.  V3 splits this into two different
 drivers: one for the parent which initializes the HCD, and one
 for the actual EHCI node, which registers the EHCI when
 'start usb' is used.

 This simplifies both drivers so each only has one task,
 eliminates one extra #ifdef by moving some of the code around
 to make it easier to read, refines the code that checks each
 port type, and lets the EHCI probe handle the return code from
 ehci_register.

V2:  Rebase on master.  There was some discussion a year ago, but
 I could not replicate the build issues on Travis, and Heiko
 beleives it was related to a different patch.  I'd like to
 at least get the EHCI working again for device tree enabled
 omap3 boards using the EHCI controller.  We can progressively
 add features/functions as we go.  This as been tested to work
 on both the AM3517-EVM and the Logic PD SOM-LV.

diff --git a/arch/arm/include/asm/ehci-omap.h b/arch/arm/include/asm/ehci-omap.h
index 1549f7bf21..f970bba937 100644
--- a/arch/arm/include/asm/ehci-omap.h
+++ b/arch/arm/include/asm/ehci-omap.h
@@ -123,6 +123,7 @@ struct omap_ehci {
u32 insreg08;   /* 0xb0 */
 };
 
+#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL)
 /*
  * FIXME: forward declaration of this structs needed because omap got the
  * ehci implementation backwards. move out ehci_hcd_x from board files
@@ -133,5 +134,6 @@ struct ehci_hcor;
 int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata,
   struct ehci_hccr **hccr, struct ehci_hcor **hcor);
 int omap_ehci_hcd_stop(void);
+#endif
 
 #endif /* _OMAP_COMMON_EHCI_H_ */
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index ab459c8cc9..ac44010c85 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -18,6 +18,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include "ehci.h"
 
@@ -177,9 +181,17 @@ int omap_ehci_hcd_stop(void)
  * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1
  * See there for additional Copyrights.
  */
+#if !CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL)
+
 int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata,
   struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
+   *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE);
+   *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10);
+#else
+int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata)
+{
+#endif
int ret;
unsigned int i, reg = 0, rev = 0;
 
@@ -286,9 +298,114 @@ int omap_ehci_hcd_init(int index, struct 
omap_usbhs_board_data *usbhs_pdata,
if (is_ehci_phy_mode(usbhs_pdata->port_mode[i]))
omap_ehci_soft_phy_reset(i);
 
-   *hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE);
-   *hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10);
-
debug("OMAP EHCI init done\n");
return 0;
 }
+
+#if CONFIG_IS_ENABLED(DM_USB)
+
+static struct omap_usbhs_board_data usbhs_bdata = {
+   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
+   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
+   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
+};
+
+static void omap_usbhs_set_mode(u8 index, const char *mode)
+{
+   if (!strcmp(mode, "ehci-phy"))
+   usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_PHY;
+   else if (!strcmp(mode, "ehci-tll"))
+   usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_TLL;
+   else if (!strcmp(mode, "ehci-hsic"))
+   usbhs_bdata.port_mode[index] = OMAP_EHCI_PORT_MODE_HSIC;
+}
+
+static int omap_usbhs_probe(struct udevice *dev)
+{
+   u8 i;
+   const char *mode;
+   char prop[11];
+
+   /* Go through each port portX-mode to determing phy mode */
+   for (i = 0; i < OMAP_HS_USB_PORTS; i++) {
+   snprintf(prop, sizeof(prop), "port%d-mode", i + 1);
+   mode = dev_read_string(dev, prop);
+
+   /* If the portX-mode exists, set the mode */
+   if (mode)
+   omap_usbhs_set_mode(i, mode);
+   }
+
+   return 

RE: [PATCH v10 17/18] configs: fu540: Add config options for U-Boot SPL

2020-05-16 Thread Pragnesh Patel
Hi Jagan,

>-Original Message-
>From: Jagan Teki 
>Sent: 15 May 2020 23:05
>To: Pragnesh Patel 
>Cc: U-Boot-Denx ; Atish Patra
>; Palmer Dabbelt ; Bin
>Meng ; Paul Walmsley ;
>Anup Patel ; Sagar Kadam
>; Rick Chen ; Palmer
>Dabbelt 
>Subject: Re: [PATCH v10 17/18] configs: fu540: Add config options for U-Boot
>SPL
>
>[External Email] Do not click links or attachments unless you recognize the
>sender and know the content is safe
>
>On Thu, May 14, 2020 at 5:24 PM Pragnesh Patel
> wrote:
>>
>> With sifive_fu540_defconfig:
>>
>> User can use FSBL or u-boot-spl.bin anyone at a time.
>>
>> For FSBL,
>> fsbl->fw_payload.bin (opensbi + U-Boot)
>>
>> For u-boot-spl.bin,
>> u-boot-spl.bin->FIT image (opensbi + U-Boot proper + dtb)
>>
>> U-Boot SPL will be loaded by ZSBL from SD card (replace fsbl.bin with
>> u-boot-spl.bin) and runs in L2 LIM in machine mode and then load FIT
>> image u-boot.itb from SD card into RAM.
>>
>> U-Boot SPL expects u-boot.itb FIT image at the starting of SD card
>> sector number (0x822) of GUID type "2E54B353-1271-4842-806F-
>E436D6AF6985"
>>
>> Signed-off-by: Pragnesh Patel 
>> Signed-off-by: Jagan Teki 
>> Reviewed-by: Jagan Teki 
>> ---
>>  configs/sifive_fu540_defconfig |   8 ++
>>  doc/board/sifive/fu540.rst | 134 +
>>  2 files changed, 142 insertions(+)
>>
>> diff --git a/configs/sifive_fu540_defconfig
>> b/configs/sifive_fu540_defconfig index f805aacc7a..8d412f8d6a 100644
>> --- a/configs/sifive_fu540_defconfig
>> +++ b/configs/sifive_fu540_defconfig
>> @@ -1,6 +1,11 @@
>>  CONFIG_RISCV=y
>> +CONFIG_SPL_GPIO_SUPPORT=y
>> +CONFIG_SYS_MALLOC_F_LEN=0x3000
>>  CONFIG_ENV_SIZE=0x2
>> +CONFIG_SPL_MMC_SUPPORT=y
>>  CONFIG_NR_DRAM_BANKS=1
>> +CONFIG_SPL=y
>> +CONFIG_SPL_SPI_SUPPORT=y
>>  CONFIG_TARGET_SIFIVE_FU540=y
>>  CONFIG_ARCH_RV64I=y
>>  CONFIG_RISCV_SMODE=y
>> @@ -9,7 +14,10 @@ CONFIG_FIT=y
>>  CONFIG_MISC_INIT_R=y
>>  CONFIG_DISPLAY_CPUINFO=y
>>  CONFIG_DISPLAY_BOARDINFO=y
>> +CONFIG_SPL_SEPARATE_BSS=y
>> +CONFIG_SPL_YMODEM_SUPPORT=y
>>  CONFIG_OF_BOARD_FIXUP=y
>>  CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
>>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>> +CONFIG_SPL_CLK=y
>>  CONFIG_DM_MTD=y
>> diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst
>> index 610ba87074..89e8d66c56 100644
>> --- a/doc/board/sifive/fu540.rst
>> +++ b/doc/board/sifive/fu540.rst
>> @@ -31,6 +31,9 @@ TODO:
>>  stdout-path = "/soc/serial@1001:115200";
>> };
>>
>> +Booting from MMC using FSBL
>> +---
>> +
>>  Building
>>  
>>
>> @@ -421,3 +424,134 @@ as well.
>>
>> Please press Enter to activate this console.
>> / #
>> +
>> +Booting from MMC using U-Boot SPL
>> +-
>> +
>> +Building
>> +
>> +
>> +Before building U-Boot SPL, OpenSBI must be built first. OpenSBI can
>> +be cloned and built for FU540 as below:
>> +
>> +.. code-block:: console
>> +
>> +   git clone https://github.com/riscv/opensbi.git
>> +   cd opensbi
>> +   make PLATFORM=generic FW_DYNAMIC=y
>> +
>> +Copy OpenSBI FW_DYNAMIC image
>> +(build/platform/generic/firmware/fw_dynamic.bin) into U-Boot root
>> +directory
>> +
>> +.. code-block:: console
>> +
>> +   cp build/platform/generic/firmware/fw_dynamic.bin 
>> +
>> +Now build the U-Boot SPL and U-Boot proper
>> +
>> +.. code-block:: console
>> +
>> +   cd 
>> +   make sifive_fu540_defconfig
>> +   make
>> +
>> +This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
>> +
>> +
>> +Flashing
>> +
>> +
>> +ZSBL loads the U-Boot SPL (u-boot-spl.bin) from a partition with GUID
>> +type
>> +5B193300-FC78-40CD-8002-E86C45580B47
>> +
>> +U-Boot SPL expects a U-Boot FIT image (u-boot.itb) from a partition
>> +with GUID type 2E54B353-1271-4842-806F-E436D6AF6985
>> +
>> +FIT image (u-boot.itb) is a combination of fw_dynamic.bin,
>> +u-boot-nodtb.bin and device tree blob (hifive-unleashed-a00.dtb)
>> +
>> +Format the SD card (make sure the disk has GPT, otherwise use gdisk
>> +to switch)
>> +
>> +.. code-block:: none
>> +
>> +   # sudo sgdisk --clear \
>> +   > --set-alignment=2 \
>> +   > --new=1:34:2081 --change-name=1:loader1 --typecode=1:5B193300-
>FC78-40CD-8002-E86C45580B47 \
>> +   > --new=2:2082:10273 --change-name=2:loader2 --
>typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \
>> +   > --new=3:10274: --change-name=3:rootfs --typecode=3:0FC63DAF-
>8483-4772-8E79-3D69D8477DE4 \
>> +   > /dev/sda
>> +
>> +Program the SD card
>> +
>> +.. code-block:: none
>> +
>> +   sudo dd if=spl/u-boot-spl.bin of=/dev/sda seek=34
>> +   sudo dd if=u-boot.itb of=/dev/sda seek=2082
>> +
>> +Booting
>> +---
>> +Once you plugin the sdcard and power up, you should see the U-Boot
>prompt.
>> +
>> +Sample boot log from HiFive Unleashed board
>> +---
>> +
>> +.. code-block:: none
>> +
>> +   U-Boot SPL 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30