Re: [U-Boot] [PATCH 18/25] tpm: Convert to use a device parameter

2018-11-06 Thread Miquel Raynal
Hi Simon,

Simon Glass  wrote on Tue,  6 Nov 2018 15:21:35 -0700:

> At present many TPM calls assume there is only one TPM in the system and
> look up this TPM themselves. This is inconsistent with driver model, which
> expects all driver methods to have a device parameter. Update the code to
> correct this.
> 
> Also move to u8/32 instead of uint8_t/uint32_t to keep checkpatch happy.
> 
> Signed-off-by: Simon Glass 
> ---

Thanks for the cleanup!

Reviewed-by: Miquel Raynal 


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


Re: [U-Boot] [PATCH 17/25] tpm: Export the open/close functions

2018-11-06 Thread Miquel Raynal
Hi Simon,

Simon Glass  wrote on Tue,  6 Nov 2018 15:21:34 -0700:

> At present these functions are not accessible outside the TPM library, but
> in some cases we need to call them.

I was not aware, what is the use case? I don't get it.

> Export them in the header file and add
> a define for the SHA1 digest size.
> 
> Also adjust tpm_open() to call tpm_close() first so that the TPM is in a
> known state before opening (e.g. by a previous phase of U-Boot).
> 
> Signed-off-by: Simon Glass 
> ---
> 

[...]

> @@ -408,29 +435,12 @@ static int tpm_tis_lpc_open(struct udevice *dev)
>   return ret;
>   }
>  
> + /* Certain TPMs need some delay here or they hang */
> + udelay(10);
> +
>   tpm_write_word(priv, TIS_STS_COMMAND_READY,
>  ®s[locality].tpm_status);

This is not in the commit message.

Perhaps, due to the nature of the changes, this patch would be best
split in 2 or 3?


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


Re: [U-Boot] [PATCH v1] fs: ubifs: Fix UBIFS decompression on 64 bit

2018-11-06 Thread Heiko Schocher

Hello Paul,

Am 05.11.2018 um 06:09 schrieb Paul Davey:

Add local size_t variable to crypto_comp_decompress as intermediate
storage for destination length to avoid memory corruption and incorrect
results on 64 bit targets.

This is what linux does for the various lz compression implementations.

Signed-off-by: Paul Davey 
Cc: Heiko Schocher 


Does not break any tests, so

Tested-by: Heiko Schocher 

I start a travis build, and if successful, send a pull request to Tom, as
this should go into current release ...

bye,
Heiko

---

When attempting to use ubifs on a MIPS64 platform I found that it would fail
decompression for the file I was attempting to load.

Further investigation found that this was due to the pointer cast from unsigned
int * to size_t * in the decompression wrapper.  This will cause any big endian
64 bit platform to fail to load any ubifs file that requires decompression and
at least cause little endian 64 bit platforms to silently write 0 over 4 bytes
of stack memory.

  fs/ubifs/ubifs.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 47fa41ad1dd..d5101d3c459 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -125,6 +125,7 @@ crypto_comp_decompress(const struct ubifs_info *c, struct 
crypto_comp *tfm,
  {
struct ubifs_compressor *compr = ubifs_compressors[tfm->compressor];
int err;
+   size_t tmp_len = *dlen;
  
  	if (compr->compr_type == UBIFS_COMPR_NONE) {

memcpy(dst, src, slen);
@@ -132,11 +133,12 @@ crypto_comp_decompress(const struct ubifs_info *c, struct 
crypto_comp *tfm,
return 0;
}
  
-	err = compr->decompress(src, slen, dst, (size_t *)dlen);

+   err = compr->decompress(src, slen, dst, &tmp_len);
if (err)
ubifs_err(c, "cannot decompress %d bytes, compressor %s, "
  "error %d", slen, compr->name, err);
  
+	*dlen = tmp_len;

return err;
  
  	return 0;




--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] arm64: mvebu: a8k: autodetect RAM size

2018-11-06 Thread Baruch Siach
Some Armada 8K boards like Macchiatobin and Clearfog GT-8K use RAM from
external DIMM. Hard coding the RAM size in the device-tree is not
convenient. Fortunately, the ATF that initializes the RAM knows the size
of RAM, and U-Boot can query the ATF using a SMC call.

The ATF maps the lower 3G of RAM starting at address 0. Higher RAM is
mapped at 4G. This leaves a 1G hole between 3G and 4G for IO
peripherals. Use a second bi_dram[] entry to describe the higher RAM
area. As a result, CONFIG_NR_DRAM_BANKS must be set to 2 to use more
than 3GB RAM.

This code in this commit is mostly taken from downstream Marvell U-Boot
code by Grzegorz Jaszczyk.

Cc: Grzegorz Jaszczyk 
Signed-off-by: Baruch Siach 
---
v2:
  Expand memory layout description in code comment and the commit log
  (Stefan)
---
 arch/arm/mach-mvebu/arm64-common.c | 50 +-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-mvebu/arm64-common.c 
b/arch/arm/mach-mvebu/arm64-common.c
index f47273fde9c6..47bbf69944ec 100644
--- a/arch/arm/mach-mvebu/arm64-common.c
+++ b/arch/arm/mach-mvebu/arm64-common.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -45,15 +46,62 @@ const struct mbus_dram_target_info 
*mvebu_mbus_dram_info(void)
 
 /* DRAM init code ... */
 
+#define MV_SIP_DRAM_SIZE   0x8210
+
+static u64 a8k_dram_scan_ap_sz(void)
+{
+   struct pt_regs pregs;
+
+   pregs.regs[0] = MV_SIP_DRAM_SIZE;
+   pregs.regs[1] = SOC_REGS_PHY_BASE;
+   smc_call(&pregs);
+
+   return pregs.regs[0];
+}
+
+static void a8k_dram_init_banksize(void)
+{
+   /*
+* The firmware (ATF) leaves a 1G whole above the 3G mark for IO
+* devices. Higher RAM is mapped at 4G.
+*
+* Config 2 DRAM banks:
+* Bank 0 - max size 4G - 1G
+* Bank 1 - ram size - 4G + 1G
+*/
+   phys_size_t max_bank0_size = SZ_4G - SZ_1G;
+
+   gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+   if (gd->ram_size <= max_bank0_size) {
+   gd->bd->bi_dram[0].size = gd->ram_size;
+   return;
+   }
+
+   gd->bd->bi_dram[0].size = max_bank0_size;
+   if (CONFIG_NR_DRAM_BANKS > 1) {
+   gd->bd->bi_dram[1].start = SZ_4G;
+   gd->bd->bi_dram[1].size = gd->ram_size - max_bank0_size;
+   }
+}
+
 int dram_init_banksize(void)
 {
-   fdtdec_setup_memory_banksize();
+   if (CONFIG_IS_ENABLED(ARMADA_8K))
+   a8k_dram_init_banksize();
+   else
+   fdtdec_setup_memory_banksize();
 
return 0;
 }
 
 int dram_init(void)
 {
+   if (CONFIG_IS_ENABLED(ARMADA_8K)) {
+   gd->ram_size = a8k_dram_scan_ap_sz();
+   if (gd->ram_size != 0)
+   return 0;
+   }
+
if (fdtdec_setup_mem_size_base() != 0)
return -EINVAL;
 
-- 
2.19.1

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


[U-Boot] [PATCH v2 1/2] linux/sizes.h: sync from kernel

2018-11-06 Thread Baruch Siach
The kernel added SZ_4G macro in commit f2b9ba871b (arm64/kernel: kaslr:
reduce module randomization range to 4 GB).

Include common.h for _AC() instead of the kernel linux/const.h header.

Drop a local SZ_4G definition in tegra code.

Cc: Tom Warren 
Signed-off-by: Baruch Siach 
---
v2: No change
---
 arch/arm/mach-tegra/tegra186/nvtboot_mem.c | 3 +--
 include/linux/sizes.h  | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_mem.c 
b/arch/arm/mach-tegra/tegra186/nvtboot_mem.c
index 5c9467bfe8be..62142821a595 100644
--- a/arch/arm/mach-tegra/tegra186/nvtboot_mem.c
+++ b/arch/arm/mach-tegra/tegra186/nvtboot_mem.c
@@ -6,11 +6,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-#define SZ_4G 0x1ULL
-
 /*
  * Size of a region that's large enough to hold the relocated U-Boot and all
  * other allocations made around it (stack, heap, page tables, etc.)
diff --git a/include/linux/sizes.h b/include/linux/sizes.h
index ce3e8150c174..9f3c13ee459b 100644
--- a/include/linux/sizes.h
+++ b/include/linux/sizes.h
@@ -8,6 +8,8 @@
 #ifndef __LINUX_SIZES_H__
 #define __LINUX_SIZES_H__
 
+#include 
+
 #define SZ_1   0x0001
 #define SZ_2   0x0002
 #define SZ_4   0x0004
@@ -44,4 +46,6 @@
 #define SZ_1G  0x4000
 #define SZ_2G  0x8000
 
+#define SZ_4G  _AC(0x1, ULL)
+
 #endif /* __LINUX_SIZES_H__ */
-- 
2.19.1

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


Re: [U-Boot] [PATCH 2/2] efi_loader: enumerate disk devices every time

2018-11-06 Thread Heinrich Schuchardt
On 11/7/18 1:44 AM, AKASHI Takahiro wrote:
> Currently, efi_init_obj_list() scan disk devices only once, and never
> change a list of efi disk devices. This will possibly result in failing
> to find a removable storage which may be added later on. See [1].
>
> In this patch, called is efi_disk_update() which is responsible for
> re-scanning UCLASS_BLK devices and removing/adding efi disks if necessary.
>
> For example,
>
> => efishell devices
> Scanning disk pci_mmc.blk...
> Found 3 disks
> Device Name
> 
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0x086246ba,0x40800,0x3f800)
> => usb start
> starting USB...
> USB0:   USB EHCI 1.00
> scanning bus 0 for devices... 3 USB Device(s) found
>scanning usb for storage devices... 1 Storage Device(s) found
> => efishell devices
> Scanning disk usb_mass_storage.lun0...
> Device Name
> 
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0x086246ba,0x40800,0x3f800)
> /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/USBClass(0,0,9,0,1)/USBClass(46f4,1,0,0,0)/HD(1,0x01,0,0x40,0x14fe4c)
>
> Without this patch, the last device, USB mass storage, won't show up.
>
> [1] https://lists.denx.de/pipermail/u-boot/2018-October/345307.html
>
> Signed-off-by: AKASHI Takahiro 
> ---
>  cmd/bootefi.c |   8 +-
>  include/efi_loader.h  |   2 +
>  lib/efi_loader/efi_disk.c | 150 ++
>  3 files changed, 159 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 3cefb4d0ecaa..493022a09482 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -57,8 +57,14 @@ efi_status_t efi_init_obj_list(void)
>   efi_save_gd();
>
>   /* Initialize once only */
> - if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
> + if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) {

If efi_obj_list_initialized is neither OBJ_LIST_NOT_INITIALIZED nor
EFI_SUCCESS, return efi_obj_list_initialized.

> +#ifdef CONFIG_PARTITIONS
> + ret = efi_disk_update();
> + if (ret != EFI_SUCCESS)
> + printf("+++ updating disks failed\n");
> +#endif
>   return efi_obj_list_initialized;
> + }
>
>   /* Initialize system table */
>   ret = efi_initialize_system_table();
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 5cc3bded03fa..e5a080281dba 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -260,6 +260,8 @@ efi_status_t efi_initialize_system_table(void);
>  efi_status_t efi_console_register(void);
>  /* Called by bootefi to make all disk storage accessible as EFI objects */
>  efi_status_t efi_disk_register(void);
> +/* Called by bootefi to find and update disk storage information */
> +efi_status_t efi_disk_update(void);
>  /* Create handles and protocols for the partitions of a block device */
>  int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
>  const char *if_typename, int diskid,
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index c037526ad2d0..e1d47f34049b 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -14,10 +14,13 @@
>
>  const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
>
> +#define _EFI_DISK_MARK_DELETE 0x1

Plese, add a comment to the code explaining what this constant is used
for. None of our other constants starts with an underscore.

In your coding below you keep handles for deleted drives. What will
happen if a binary tries to access a deleted drive?

> +
>  /**
>   * struct efi_disk_obj - EFI disk object
>   *
>   * @header:  EFI object header
> + * @flags:   control flags
>   * @ops: EFI disk I/O protocol interface
>   * @ifname:  interface name for block device
>   * @dev_index:   device index of block device
> @@ -30,6 +33,7 @@ const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
>   */
>  struct efi_disk_obj {
>   struct efi_object header;
> + int flags;
>   struct efi_block_io ops;
>   const char *ifname;
>   int dev_index;
> @@ -440,3 +444,149 @@ efi_status_t efi_disk_register(void)
>
>   return EFI_SUCCESS;
>  }
> +
> +static void efi_disk_mark_delete(struct efi_disk_obj *disk)

efi_disk_mark_deleted.

> +{
> + disk->flags |= _EFI_DISK_MARK_DELETE;
> +}
> +
> +static void efi_disk_mark_undelete(struct efi_disk_obj *disk)

 efi_disk_mark_not_deleted.

> +{
> + disk->flags &= ~_EFI_DISK_MARK_DELETE;
> +}
> +
> +static bool efi_disk_delete_marked(struct efi_disk_obj *disk)

efi_disk_marked_deleted.

> +{
> + return disk->flags & _EFI_DISK_MARK_DELETE;
> +}
> +


Please, provide a comment describing what the f

Re: [U-Boot] [PATCH 25/25] mmc: Add hardware partition support

2018-11-06 Thread Faiz Abbas
Hi Simon,

On Wednesday 07 November 2018 03:51 AM, Simon Glass wrote:
> MMC devices support multiple partitions, defined by the hardware. At
> present U-Boot can only access partition zero. Add support for selecting
> other partitions.
> 

There is already support to switch to another hardware partition.

See: mmc_select_hwpart()

Is this not the same thing?

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


Re: [U-Boot] [PATCH v6 34/34] imx: add i.MX8QXP MEK board support

2018-11-06 Thread Jon Nettleton
I have been spending some time on this, at least from the lpddr4 side.
There is a good amount of this that can be abstracted out and made
into general initialization routines.  This is all well and good and
you can see that Boundary Devices has already codified some of these
values here.  
https://github.com/boundarydevices/u-boot-imx6/blob/boundary-v2018.07/board/boundary/nitrogen8m/ddr/ddrphy_train.c

However after you generate the script from the spreadsheet you then
need to run it through a calibration routine, which is a Windows
program that takes the values from the spreadsheets and runs them
against the device and provides some tuned phy values based on the
device.  I don't see a good way to get around just having this chunk
of code be a board specific function that runs the register settings
that are spit out by the NXP tool.

As for the initialization I am not sure how much changes depending if
the board is using DDR3, DDR4 or LPDDR4.  It would be great if we
could come up with some general direction on this and move things
forward.
-Jon


On Sat, Oct 27, 2018 at 7:56 PM Fabio Estevam  wrote:
>
> Hi Tim,
>
> On Fri, Oct 26, 2018 at 2:18 PM Tim Harvey  wrote:
>
> > Can you point me to the NXP DDR tool for IMX8? I'm just getting
> > started with the IMX8M and haven't run into it yet. DDR calibration
> > was a huge pain for us for IMX6.
>
> You can find it here:
> https://community.nxp.com/docs/DOC-340179
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/25] spl: Correct malloc debugging in board_init_r()

2018-11-06 Thread Simon Goldschmidt
On Tue, Nov 6, 2018 at 11:22 PM Simon Glass  wrote:
>
> SPL does not support %#x in printf() strings so we must write out the 0x
> explicitly. Update the code for this.
>
> Signed-off-by: Simon Glass 

This has already been covered by my patch here:
https://patchwork.ozlabs.org/patch/992555/

However, my patch fixes three more places of debug printf formatters
not supported in SPL.

Anyway:
Reviewed-by: Simon Goldschmidt 

> ---
>
>  common/spl/spl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 292e659c9ac..c855bb7ca4a 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -554,7 +554,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> debug("Unsupported OS image.. Jumping nevertheless..\n");
> }
>  #if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
> -   debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
> +   debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr,
>   gd->malloc_ptr / 1024);
>  #endif
>  #ifdef CONFIG_BOOTSTAGE_STASH
> --
> 2.19.1.930.g4563a0d9d0-goog
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] serial: ns16550: add setconfig support

2018-11-06 Thread Hannes Schmelzer
> Betreff: [PATCH] serial: ns16550: add setconfig support
> 
> Add possibility to update the serial parity used.
> 
> Signed-off-by: Simon Goldschmidt 
> ---
> 
>  drivers/serial/ns16550.c | 43 ++--
>  1 file changed, 41 insertions(+), 2 deletions(-)

Reviewed-by: Hannes Schmelzer 


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


Re: [U-Boot] [PATCH u-boot] spi: Add Amlogic Meson SPI Flash Controller driver

2018-11-06 Thread jbrunet
On Tue, 2018-11-06 at 10:25 +0100, Neil Armstrong wrote:
> The Amlogic Meson SoCs embeds a Flash oriented SPI Controller name SPIFC.
> This driver, ported from the Linux meson-spi-spifc driver, add support
> for this controller on the Amlogic Meson GX SoCs in U-Boot.
> 
> Signed-off-by: Neil Armstrong 

Tested-by: Jerome Brunet 


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


[U-Boot] [PATCH 00/25] sandbox: Changes and improvements to support verified boot

2018-11-06 Thread Simon Glass
This series compiles a number of fixes and improvement to sandbox,
cros_ec, tpm and a few other pieces. This allows U-Boot to support
Chromium OS verified boot and assist with debugging of this.


Simon Glass (25):
  cros_ec: Use uint instead of u8 for parameters
  cros_ec: Add error logging on a few commands
  cros_ec: Fail if we cannot determine the flash burst size
  cros_ec: Align uclass data to a cache boundary
  cros_ec: Add new features for events and power
  sandbox: tpm: Allow debugging of data packages
  sandbox: log: Add a category for sandbox
  sandbox: Add a function to read a host file
  sandbox: cros_ec: exynos: Drop use of cros_ec_get_error()
  sandbox: Update some drivers to work in SPL/TPL
  spl: Support bootstage, log, hash and early malloc in TPL
  spl: Correct malloc debugging in board_init_r()
  spl: lz4: Allow use of lz4 compression in SPL
  binman: Add a way to enable debugging from the build
  binman: Drop an unnecessary comma in blob handling
  binman: Set the pathname correctly for ELF files
  tpm: Export the open/close functions
  tpm: Convert to use a device parameter
  video: Update video_set_default_colors() to support invert
  efi_loader: Don't enable in SPL/TPL by default
  string: Include the config header
  misc: Update read() and write() methods to return bytes xfered
  test: sf: Add a simple SPI flash test
  sf: Add a method to obtain the block-protect setting
  mmc: Add hardware partition support

 Makefile  |   6 +-
 arch/arm/mach-stm32mp/cpu.c   |   4 +-
 arch/sandbox/cpu/os.c |  44 ++-
 arch/sandbox/dts/sandbox.dts  |  15 ++
 arch/sandbox/include/asm/test.h   |   8 +
 board/gdsys/a38x/controlcenterdc.c|   8 +-
 board/gdsys/p1022/controlcenterd-id.c |  22 +-
 board/samsung/common/board.c  |  10 +-
 board/sandbox/sandbox.c   |   9 +-
 cmd/tpm-common.c  |   8 +-
 cmd/tpm-v1.c  | 122 +++--
 cmd/tpm-v2.c  |  78 +-
 cmd/tpm_test.c| 371 +-
 common/Kconfig|  35 +++
 common/Makefile   |  10 +-
 common/cros_ec.c  |  12 -
 common/spl/spl.c  |   2 +-
 drivers/clk/clk_vexpress_osc.c|   4 +-
 drivers/misc/altera_sysid.c   |   2 +-
 drivers/misc/cros_ec.c| 370 -
 drivers/misc/cros_ec_sandbox.c|   2 +-
 drivers/misc/misc_sandbox.c   |   4 +-
 drivers/misc/rockchip-efuse.c |   2 +-
 drivers/misc/stm32mp_fuse.c   |  12 +
 drivers/mmc/mmc.c |  46 
 drivers/mtd/spi/sandbox.c |  10 +
 drivers/mtd/spi/sf-uclass.c   |   9 +
 drivers/mtd/spi/sf_internal.h |   3 +
 drivers/mtd/spi/sf_probe.c|   8 +
 drivers/mtd/spi/spi_flash.c   |  12 +
 drivers/tpm/tpm_tis_lpc.c |  50 ++--
 drivers/tpm/tpm_tis_sandbox.c |   6 +
 drivers/video/vidconsole-uclass.c |   2 +-
 drivers/video/video-uclass.c  |  27 +-
 include/cros_ec.h |  89 ++
 include/log.h |   1 +
 include/misc.h|   8 +-
 include/mmc.h |  31 +++
 include/os.h  |  14 +
 include/spi_flash.h   |  27 ++
 include/tpm-common.h  |  36 ++-
 include/tpm-v1.h  |  97 ---
 include/tpm-v2.h  |  49 ++--
 include/video.h   |   5 +-
 lib/Kconfig   |   8 +
 lib/Makefile  |  10 +-
 lib/string.c  |   1 +
 lib/tpm-common.c  |  16 +-
 lib/tpm-utils.h   |  21 +-
 lib/tpm-v1.c  | 136 +-
 lib/tpm-v2.c  |  60 +++--
 test/dm/sf.c  |  55 +++-
 tools/binman/README   |   6 +
 tools/binman/etype/blob.py|   2 +-
 tools/binman/etype/u_boot_elf.py  |   5 +-
 55 files changed, 1520 insertions(+), 490 deletions(-)

-- 
2.19.1.930.g4563a0d9d0-goog

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


Re: [U-Boot] [PATCH 1/3] sunxi-mmc: introduce new MMC_SUNXI_HAS_NEW_MODE_SWITCH option

2018-11-06 Thread Chen-Yu Tsai
On Wed, Nov 7, 2018 at 12:21 PM Vasily Khoruzhick  wrote:
>
> On Tue, Nov 6, 2018 at 8:13 PM Chen-Yu Tsai  wrote:
> >
> > On Wed, Nov 7, 2018 at 11:59 AM Vasily Khoruzhick  
> > wrote:
> > >
> > > A64 doesn't have a mode switch in CCM, so introduce new
> > > MMC_SUNXI_HAS_NEW_MODE_SWITCH option to support new clock mode on A64
> > >
> > > Signed-off-by: Vasily Khoruzhick 
> > > Tested-by: Zhaofeng Li 
> >
> > This patch isn't strictly necessary. See
> >
> > 
> > https://elixir.bootlin.com/linux/v4.20-rc1/source/drivers/mmc/host/sunxi-mmc.c#L831
> >
> > If the switch doesn't exist, changes to that bit are ignored.
>
> CCM_MMC_CTRL_MODE_SEL_NEW is not defined on A64, so it won't compile
> unless we define it on A64 which seems to be redundant.

OK. That makes sense then. You should mention that in the commit message,
as that is exactly the reason why this patch is needed.

On the other hand, having hardware device registers defined at the arch level
is kind of hard to keep track of.

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


Re: [U-Boot] [PATCH 1/3] sunxi-mmc: introduce new MMC_SUNXI_HAS_NEW_MODE_SWITCH option

2018-11-06 Thread Vasily Khoruzhick
On Tue, Nov 6, 2018 at 8:13 PM Chen-Yu Tsai  wrote:
>
> On Wed, Nov 7, 2018 at 11:59 AM Vasily Khoruzhick  wrote:
> >
> > A64 doesn't have a mode switch in CCM, so introduce new
> > MMC_SUNXI_HAS_NEW_MODE_SWITCH option to support new clock mode on A64
> >
> > Signed-off-by: Vasily Khoruzhick 
> > Tested-by: Zhaofeng Li 
>
> This patch isn't strictly necessary. See
>
> 
> https://elixir.bootlin.com/linux/v4.20-rc1/source/drivers/mmc/host/sunxi-mmc.c#L831
>
> If the switch doesn't exist, changes to that bit are ignored.

CCM_MMC_CTRL_MODE_SEL_NEW is not defined on A64, so it won't compile
unless we define it on A64 which seems to be redundant.

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


Re: [U-Boot] [PATCH 3/3] sunxi-mmc: use new mode on both controllers on A64

2018-11-06 Thread Chen-Yu Tsai
On Wed, Nov 7, 2018 at 11:59 AM Vasily Khoruzhick  wrote:
>
> Using new mode improves stability of eMMC and SD cards. Without
> it SPl fails to load u-boot from SD on Pinebook.
>
> Signed-off-by: Vasily Khoruzhick 
> Tested-by: Zhaofeng Li 

Reviewed-by: Chen-Yu Tsai 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] sunxi-mmc: don't double clock for new mode unconditionally

2018-11-06 Thread Chen-Yu Tsai
On Wed, Nov 7, 2018 at 11:59 AM Vasily Khoruzhick  wrote:
>
> Comment in Linux driver says that clock needs to be doubled only
> if we use DDR modes, moreover divider has to be set accordingly.
>
> U-boot driver doesn't declare support for any DDR modes and doesn't
> set divider, so it doubles clock unconditionally when new mode

doesn't set the card clock divider, so the card is running at the module
clock's rate. This would be a bit clearer.

ChenYu

> is used.
>
> Some cards can't handle that and as result SPL fails to load u-boot.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/3] sunxi-mmc: introduce new MMC_SUNXI_HAS_NEW_MODE_SWITCH option

2018-11-06 Thread Chen-Yu Tsai
On Wed, Nov 7, 2018 at 11:59 AM Vasily Khoruzhick  wrote:
>
> A64 doesn't have a mode switch in CCM, so introduce new
> MMC_SUNXI_HAS_NEW_MODE_SWITCH option to support new clock mode on A64
>
> Signed-off-by: Vasily Khoruzhick 
> Tested-by: Zhaofeng Li 

This patch isn't strictly necessary. See


https://elixir.bootlin.com/linux/v4.20-rc1/source/drivers/mmc/host/sunxi-mmc.c#L831

If the switch doesn't exist, changes to that bit are ignored.

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


[U-Boot] [PATCH 3/3] sunxi-mmc: use new mode on both controllers on A64

2018-11-06 Thread Vasily Khoruzhick
Using new mode improves stability of eMMC and SD cards. Without
it SPl fails to load u-boot from SD on Pinebook.

Signed-off-by: Vasily Khoruzhick 
Tested-by: Zhaofeng Li 
---
 arch/arm/mach-sunxi/Kconfig |  1 +
 drivers/mmc/sunxi_mmc.c | 10 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 66fff6c6d3..3c54f5106d 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -282,6 +282,7 @@ config MACH_SUN50I
select SUN6I_PRCM
select SUNXI_DE2
select SUNXI_GEN_SUN6I
+   select MMC_SUNXI_HAS_NEW_MODE
select SUPPORT_SPL
select SUNXI_DRAM_DW
select SUNXI_DRAM_DW_32BIT
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index e50b2c3343..2b6f3c2234 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -98,12 +98,16 @@ static int mmc_resource_init(int sdc_no)
 static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 {
unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
-   bool new_mode = false;
+   bool new_mode = true;
bool calibrate = false;
u32 val = 0;
 
-   if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
-   new_mode = true;
+   if (!IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE))
+   new_mode = false;
+
+   /* A83 support new mode only on eMMC */
+   if (IS_ENABLED(CONFIG_MACH_SUN8I_A83T) && priv->mmc_no != 2)
+   new_mode = false;
 
 #if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
calibrate = true;
-- 
2.19.1

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


[U-Boot] [PATCH 1/3] sunxi-mmc: introduce new MMC_SUNXI_HAS_NEW_MODE_SWITCH option

2018-11-06 Thread Vasily Khoruzhick
A64 doesn't have a mode switch in CCM, so introduce new
MMC_SUNXI_HAS_NEW_MODE_SWITCH option to support new clock mode on A64

Signed-off-by: Vasily Khoruzhick 
Tested-by: Zhaofeng Li 
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 drivers/mmc/Kconfig | 4 
 drivers/mmc/sunxi_mmc.c | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 560dc9b25d..66fff6c6d3 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -230,6 +230,7 @@ config MACH_SUN8I_A83T
select PHY_SUN4I_USB
select SUNXI_GEN_SUN6I
select MMC_SUNXI_HAS_NEW_MODE
+   select MMC_SUNXI_HAS_MODE_SWITCH
select SUPPORT_SPL
 
 config MACH_SUN8I_H3
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 27246ee465..3f7458d409 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -569,6 +569,10 @@ config MMC_SUNXI_HAS_NEW_MODE
bool
depends on MMC_SUNXI
 
+config MMC_SUNXI_HAS_MODE_SWITCH
+   bool
+   depends on MMC_SUNXI
+
 config GENERIC_ATMEL_MCI
bool "Atmel Multimedia Card Interface support"
depends on DM_MMC && BLK && ARCH_AT91
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 147eb9b4d5..b3526f5e3f 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -176,7 +176,9 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, 
unsigned int hz)
 
if (new_mode) {
 #ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
+#ifdef CONFIG_MMC_SUNXI_HAS_MODE_SWITCH
val = CCM_MMC_CTRL_MODE_SEL_NEW;
+#endif
setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
 #endif
} else if (!calibrate) {
-- 
2.19.1

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


[U-Boot] [PATCH 2/3] sunxi-mmc: don't double clock for new mode unconditionally

2018-11-06 Thread Vasily Khoruzhick
Comment in Linux driver says that clock needs to be doubled only
if we use DDR modes, moreover divider has to be set accordingly.

U-boot driver doesn't declare support for any DDR modes and doesn't
set divider, so it doubles clock unconditionally when new mode
is used.

Some cards can't handle that and as result SPL fails to load u-boot.

Fixes: de9b1771c3b ("mmc: sunxi: Support new mode")
Signed-off-by: Vasily Khoruzhick 
Tested-by: Zhaofeng Li 
---
 drivers/mmc/sunxi_mmc.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index b3526f5e3f..e50b2c3343 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -109,13 +109,6 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, 
unsigned int hz)
calibrate = true;
 #endif
 
-   /*
-* The MMC clock has an extra /2 post-divider when operating in the new
-* mode.
-*/
-   if (new_mode)
-   hz = hz * 2;
-
if (hz <= 2400) {
pll = CCM_MMC_CTRL_OSCM24;
pll_hz = 2400;
-- 
2.19.1

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


[U-Boot] [PATCH 0/3] sunxi-mmc: enable new clock mode on A64

2018-11-06 Thread Vasily Khoruzhick
A64 requires new clock mode on SD and eMMC controllers. Not using
new clock mode causes stability issues of the driver - SPL may
occasionally fail to load u-boot from SD for some particular SD card
on some particular devices.

This series depends on "sunxi: add support for automatic delay calibration"
from my Pinebook series.

Tested on Pinebook and Pine64-LTS.

Vasily Khoruzhick (3):
  sunxi-mmc: introduce new MMC_SUNXI_HAS_NEW_MODE_SWITCH option
  sunxi-mmc: don't double clock for new mode unconditionally
  sunxi-mmc: use new mode on both controllers on A64

 arch/arm/mach-sunxi/Kconfig |  2 ++
 drivers/mmc/Kconfig |  4 
 drivers/mmc/sunxi_mmc.c | 19 +--
 3 files changed, 15 insertions(+), 10 deletions(-)

-- 
2.19.1

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


Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Tom Rini
On Tue, Nov 06, 2018 at 07:42:39PM -0700, Simon Glass wrote:
> Hi Bin,
> 
> On 6 November 2018 at 19:29, Bin Meng  wrote:
> > Hi Simon,
> >
> > On Wed, Nov 7, 2018 at 10:25 AM Simon Glass  wrote:
> >>
> >> Hi Bin,
> >>
> >> On 6 November 2018 at 19:22, Bin Meng  wrote:
> >> >
> >> > Hi Simon,
> >> >
> >> > On Wed, Nov 7, 2018 at 10:07 AM Simon Glass  wrote:
> >> > >
> >> > > Hi Bin,
> >> > >
> >> > > On 6 November 2018 at 18:04, Bin Meng  wrote:
> >> > > >
> >> > > > Hi Simon,
> >> > > >
> >> > > > On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
> >> > > > >
> >> > > > > Hi Tom,
> >> > > > >
> >> > > > > The following changes since commit 
> >> > > > > 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> >> > > > >
> >> > > > >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 
> >> > > > > 08:12:21 -0500)
> >> > > > >
> >> > > > > are available in the Git repository at:
> >> > > > >
> >> > > > >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
> >> > > > >
> >> > > > > for you to fetch changes up to 
> >> > > > > 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
> >> > > > >
> >> > > > >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes 
> >> > > > > (2018-11-06 13:56:18 -0700)
> >> > > > >
> >> > > > > 
> >> > > > > dm: DM_FLAG_PRE_RELOC fixes for release
> >> > > > > sandbox CPU fixes for release
> >> > > > >
> >> > > >
> >> > > > What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
> >> > > > not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
> >> > > > up series should be a follow-up to that tag.
> >> > >
> >> > > I abandoned that as I think Tom felt that with the flag problem it was
> >> > > a bit to late to fix everything.
> >> > >
> >> > > If your series relies on that then I think we have a problem...
> >> >
> >> > Actually this DM_FLAG_PRE_RELOC clean up series is to make previous
> >> > series complementary, IOW fix potential issues. Previously Tom
> >> > rejected that was because that broken Tegra which Stephen reported,
> >> > and with the clean up series this should be fine.
> >>
> >> We are just a week from the release. What is broken if we apply none
> >> of these patches and pull them in after the release?
> >
> > I suspect we need revert the patch that is causing all these issues
> > ... If that's the way we prefer to do, I will take a look ...
> 
> I am happy to make it work - will await Tom's thoughts also.

I suppose at this point in time, a revert for release is probably best.

-- 
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] Please pull u-boot-dm

2018-11-06 Thread Simon Glass
Hi Bin,

On 6 November 2018 at 19:29, Bin Meng  wrote:
> Hi Simon,
>
> On Wed, Nov 7, 2018 at 10:25 AM Simon Glass  wrote:
>>
>> Hi Bin,
>>
>> On 6 November 2018 at 19:22, Bin Meng  wrote:
>> >
>> > Hi Simon,
>> >
>> > On Wed, Nov 7, 2018 at 10:07 AM Simon Glass  wrote:
>> > >
>> > > Hi Bin,
>> > >
>> > > On 6 November 2018 at 18:04, Bin Meng  wrote:
>> > > >
>> > > > Hi Simon,
>> > > >
>> > > > On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
>> > > > >
>> > > > > Hi Tom,
>> > > > >
>> > > > > The following changes since commit 
>> > > > > 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
>> > > > >
>> > > > >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 
>> > > > > 08:12:21 -0500)
>> > > > >
>> > > > > are available in the Git repository at:
>> > > > >
>> > > > >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
>> > > > >
>> > > > > for you to fetch changes up to 
>> > > > > 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
>> > > > >
>> > > > >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes 
>> > > > > (2018-11-06 13:56:18 -0700)
>> > > > >
>> > > > > 
>> > > > > dm: DM_FLAG_PRE_RELOC fixes for release
>> > > > > sandbox CPU fixes for release
>> > > > >
>> > > >
>> > > > What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
>> > > > not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
>> > > > up series should be a follow-up to that tag.
>> > >
>> > > I abandoned that as I think Tom felt that with the flag problem it was
>> > > a bit to late to fix everything.
>> > >
>> > > If your series relies on that then I think we have a problem...
>> >
>> > Actually this DM_FLAG_PRE_RELOC clean up series is to make previous
>> > series complementary, IOW fix potential issues. Previously Tom
>> > rejected that was because that broken Tegra which Stephen reported,
>> > and with the clean up series this should be fine.
>>
>> We are just a week from the release. What is broken if we apply none
>> of these patches and pull them in after the release?
>
> I suspect we need revert the patch that is causing all these issues
> ... If that's the way we prefer to do, I will take a look ...
>

I am happy to make it work - will await Tom's thoughts also.

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


Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Bin Meng
Hi Simon,

On Wed, Nov 7, 2018 at 10:25 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On 6 November 2018 at 19:22, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Wed, Nov 7, 2018 at 10:07 AM Simon Glass  wrote:
> > >
> > > Hi Bin,
> > >
> > > On 6 November 2018 at 18:04, Bin Meng  wrote:
> > > >
> > > > Hi Simon,
> > > >
> > > > On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
> > > > >
> > > > > Hi Tom,
> > > > >
> > > > > The following changes since commit 
> > > > > 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> > > > >
> > > > >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 
> > > > > 08:12:21 -0500)
> > > > >
> > > > > are available in the Git repository at:
> > > > >
> > > > >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
> > > > >
> > > > > for you to fetch changes up to 
> > > > > 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
> > > > >
> > > > >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes 
> > > > > (2018-11-06 13:56:18 -0700)
> > > > >
> > > > > 
> > > > > dm: DM_FLAG_PRE_RELOC fixes for release
> > > > > sandbox CPU fixes for release
> > > > >
> > > >
> > > > What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
> > > > not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
> > > > up series should be a follow-up to that tag.
> > >
> > > I abandoned that as I think Tom felt that with the flag problem it was
> > > a bit to late to fix everything.
> > >
> > > If your series relies on that then I think we have a problem...
> >
> > Actually this DM_FLAG_PRE_RELOC clean up series is to make previous
> > series complementary, IOW fix potential issues. Previously Tom
> > rejected that was because that broken Tegra which Stephen reported,
> > and with the clean up series this should be fine.
>
> We are just a week from the release. What is broken if we apply none
> of these patches and pull them in after the release?

I suspect we need revert the patch that is causing all these issues
... If that's the way we prefer to do, I will take a look ...

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


Re: [U-Boot] [PATCH 09/25] sandbox: cros_ec: exynos: Drop use of cros_ec_get_error()

2018-11-06 Thread Minkyu Kang
On 07/11/18 07:21, Simon Glass wrote:
> This function is really just a call to uclass_get_device() and there is no
> reason why the caller cannot do it. Update sandbox and snow accordingly.
> 
> Signed-off-by: Simon Glass 
> ---
> 
>  board/samsung/common/board.c | 10 ++
>  board/sandbox/sandbox.c  |  9 ++---
>  common/cros_ec.c | 12 
>  3 files changed, 12 insertions(+), 19 deletions(-)
> 

Acked-by: Minkyu Kang 

Thanks,
Minkyu Kang.

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


Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Simon Glass
Hi Bin,

On 6 November 2018 at 19:22, Bin Meng  wrote:
>
> Hi Simon,
>
> On Wed, Nov 7, 2018 at 10:07 AM Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On 6 November 2018 at 18:04, Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
> > > >
> > > > Hi Tom,
> > > >
> > > > The following changes since commit 
> > > > 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> > > >
> > > >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 
> > > > 08:12:21 -0500)
> > > >
> > > > are available in the Git repository at:
> > > >
> > > >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
> > > >
> > > > for you to fetch changes up to 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
> > > >
> > > >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes 
> > > > (2018-11-06 13:56:18 -0700)
> > > >
> > > > 
> > > > dm: DM_FLAG_PRE_RELOC fixes for release
> > > > sandbox CPU fixes for release
> > > >
> > >
> > > What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
> > > not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
> > > up series should be a follow-up to that tag.
> >
> > I abandoned that as I think Tom felt that with the flag problem it was
> > a bit to late to fix everything.
> >
> > If your series relies on that then I think we have a problem...
>
> Actually this DM_FLAG_PRE_RELOC clean up series is to make previous
> series complementary, IOW fix potential issues. Previously Tom
> rejected that was because that broken Tegra which Stephen reported,
> and with the clean up series this should be fine.

We are just a week from the release. What is broken if we apply none
of these patches and pull them in after the release?

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


Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Bin Meng
Hi Simon,

On Wed, Nov 7, 2018 at 10:07 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On 6 November 2018 at 18:04, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
> > >
> > > Hi Tom,
> > >
> > > The following changes since commit 
> > > 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> > >
> > >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 
> > > 08:12:21 -0500)
> > >
> > > are available in the Git repository at:
> > >
> > >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
> > >
> > > for you to fetch changes up to 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
> > >
> > >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes (2018-11-06 
> > > 13:56:18 -0700)
> > >
> > > 
> > > dm: DM_FLAG_PRE_RELOC fixes for release
> > > sandbox CPU fixes for release
> > >
> >
> > What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
> > not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
> > up series should be a follow-up to that tag.
>
> I abandoned that as I think Tom felt that with the flag problem it was
> a bit to late to fix everything.
>
> If your series relies on that then I think we have a problem...

Actually this DM_FLAG_PRE_RELOC clean up series is to make previous
series complementary, IOW fix potential issues. Previously Tom
rejected that was because that broken Tegra which Stephen reported,
and with the clean up series this should be fine.

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


Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Simon Glass
Hi Bin,

On 6 November 2018 at 18:04, Bin Meng  wrote:
>
> Hi Simon,
>
> On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
> >
> > Hi Tom,
> >
> > The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> >
> >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21 
> > -0500)
> >
> > are available in the Git repository at:
> >
> >   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
> >
> > for you to fetch changes up to 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
> >
> >   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes (2018-11-06 
> > 13:56:18 -0700)
> >
> > 
> > dm: DM_FLAG_PRE_RELOC fixes for release
> > sandbox CPU fixes for release
> >
>
> What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
> not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
> up series should be a follow-up to that tag.

I abandoned that as I think Tom felt that with the flag problem it was
a bit to late to fix everything.

If your series relies on that then I think we have a problem...

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


[U-Boot] [PATCH v3] riscv: cache: Implement i/dcache [status, enable, disable]

2018-11-06 Thread Andes
From: Rick Chen 

AndeStar RISC-V(V5) provide mcache_ctl register which
can configure I/D cache as enabled or disabled.

This CSR will be encapsulated by CONFIG_RISCV_NDS.
If you want to configure cache on AndeStar V5
AE350 platform. YOu can enable [*] AndeStar V5 ISA support
by make menuconfig.

This approach also provide the expansion when the
vender specific features are going to join in.

Signed-off-by: Rick Chen 
Cc: Greentime Hu 
---

Changes in v3

Bin suggested:
 1. Move RISCV_NDS to arch/riscv/cpu/ax25/Kconfig
 
Lukas suggested:
 1. Add CONFIG_SYS_ICACHE_OFF in i/dcache_disable()
 2. Remove duplicate declaration in arch/riscv/include/asm/cache.h
 3. Add s space after "volatile" and ":::" to match the style.
 4. Implement flush_dcache_range() and flush_cache() in arch/riscv/lib/cache.c

 arch/riscv/Kconfig |  6 +++
 arch/riscv/cpu/ax25/Kconfig|  7 
 arch/riscv/cpu/ax25/Makefile   |  1 +
 arch/riscv/cpu/ax25/cache.c| 95 ++
 arch/riscv/cpu/ax25/cpu.c  |  4 ++
 arch/riscv/cpu/qemu/cpu.c  |  2 +-
 arch/riscv/cpu/start.S |  6 +++
 arch/riscv/include/asm/cache.h |  3 ++
 arch/riscv/lib/cache.c | 32 ++
 9 files changed, 146 insertions(+), 10 deletions(-)
 create mode 100644 arch/riscv/cpu/ax25/Kconfig
 create mode 100644 arch/riscv/cpu/ax25/cache.c

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 371921b..6a86e9c 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -16,9 +16,15 @@ config TARGET_QEMU_VIRT
 
 endchoice
 
+# board-specific options below
 source "board/AndesTech/ax25-ae350/Kconfig"
 source "board/emulation/qemu-riscv/Kconfig"
 
+# platform-specific options below
+source "arch/riscv/cpu/ax25/Kconfig"
+
+# architecture-specific options below
+
 choice
prompt "Base ISA"
default ARCH_RV32I
diff --git a/arch/riscv/cpu/ax25/Kconfig b/arch/riscv/cpu/ax25/Kconfig
new file mode 100644
index 000..6c7022f
--- /dev/null
+++ b/arch/riscv/cpu/ax25/Kconfig
@@ -0,0 +1,7 @@
+config RISCV_NDS
+   bool "AndeStar V5 ISA support"
+   default n
+   help
+   Say Y here if you plan to run U-Boot on AndeStar v5
+   platforms and use some specific features which are
+   provided by Andes Technology AndeStar V5 Families.
diff --git a/arch/riscv/cpu/ax25/Makefile b/arch/riscv/cpu/ax25/Makefile
index 2ab0342..318bacc 100644
--- a/arch/riscv/cpu/ax25/Makefile
+++ b/arch/riscv/cpu/ax25/Makefile
@@ -4,3 +4,4 @@
 # Rick Chen, Andes Technology Corporation 
 
 obj-y  := cpu.o
+obj-y  += cache.o
diff --git a/arch/riscv/cpu/ax25/cache.c b/arch/riscv/cpu/ax25/cache.c
new file mode 100644
index 000..6600ac2
--- /dev/null
+++ b/arch/riscv/cpu/ax25/cache.c
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2017 Andes Technology Corporation
+ * Rick Chen, Andes Technology Corporation 
+ */
+
+#include 
+
+void icache_enable(void)
+{
+#ifndef CONFIG_SYS_ICACHE_OFF
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "csrr t1, mcache_ctl\n\t"
+   "ori t0, t1, 0x1\n\t"
+   "csrw mcache_ctl, t0\n\t"
+   );
+#endif
+#endif
+}
+
+void icache_disable(void)
+{
+#ifndef CONFIG_SYS_ICACHE_OFF
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "fence.i\n\t"
+   "csrr t1, mcache_ctl\n\t"
+   "andi t0, t1, ~0x1\n\t"
+   "csrw mcache_ctl, t0\n\t"
+   );
+#endif
+#endif
+}
+
+void dcache_enable(void)
+{
+#ifndef CONFIG_SYS_DCACHE_OFF
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "csrr t1, mcache_ctl\n\t"
+   "ori t0, t1, 0x2\n\t"
+   "csrw mcache_ctl, t0\n\t"
+   );
+#endif
+#endif
+}
+
+void dcache_disable(void)
+{
+#ifndef CONFIG_SYS_DCACHE_OFF
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "fence\n\t"
+   "csrr t1, mcache_ctl\n\t"
+   "andi t0, t1, ~0x2\n\t"
+   "csrw mcache_ctl, t0\n\t"
+   );
+#endif
+#endif
+}
+
+int icache_status(void)
+{
+   int ret = 0;
+
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "csrr t1, mcache_ctl\n\t"
+   "andi   %0, t1, 0x01\n\t"
+   : "=r" (ret)
+   :
+   : "memory"
+   );
+#endif
+
+   return ret;
+}
+
+int dcache_status(void)
+{
+   int ret = 0;
+
+#ifdef CONFIG_RISCV_NDS
+   asm volatile (
+   "csrr t1, mcache_ctl\n\t"
+   "andi   %0, t1, 0x02\n\t"
+   : "=r" (ret)
+   :
+   : "memory"
+   );
+#endif
+
+   return ret;
+}
diff --git a/arch/riscv/cpu/ax25/cpu.c b/arch/riscv/cpu/ax25/cpu.c
index fddcc15..76689b2 100644
--- a/arch/riscv/cpu/ax25/cpu.c
+++ b/arch/riscv/cpu/ax25/cpu.c
@@ -6,6 +6,7 @@
 
 /* CPU specific code */
 #include 
+#include 
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -18,6 +19,9 @@ int cleanup_before_linux(voi

Re: [U-Boot] Please pull u-boot-dm

2018-11-06 Thread Bin Meng
Hi Simon,

On Wed, Nov 7, 2018 at 5:51 AM Simon Glass  wrote:
>
> Hi Tom,
>
> The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
>
>   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21 
> -0500)
>
> are available in the Git repository at:
>
>   git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18
>
> for you to fetch changes up to 9413033c3d5d2bc44eefd1919c60522598cc1bd6:
>
>   cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes (2018-11-06 
> 13:56:18 -0700)
>
> 
> dm: DM_FLAG_PRE_RELOC fixes for release
> sandbox CPU fixes for release
>

What happened to the last PR from u-boot-dm, tag pull-15oct-18? I did
not see that was merged to u-boot/master. The DM_FLAG_PRE_RELOC clean
up series should be a follow-up to that tag.

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


[U-Boot] [PATCH 2/2] efi_loader: enumerate disk devices every time

2018-11-06 Thread AKASHI Takahiro
Currently, efi_init_obj_list() scan disk devices only once, and never
change a list of efi disk devices. This will possibly result in failing
to find a removable storage which may be added later on. See [1].

In this patch, called is efi_disk_update() which is responsible for
re-scanning UCLASS_BLK devices and removing/adding efi disks if necessary.

For example,

=> efishell devices
Scanning disk pci_mmc.blk...
Found 3 disks
Device Name

/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0x086246ba,0x40800,0x3f800)
=> usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
   scanning usb for storage devices... 1 Storage Device(s) found
=> efishell devices
Scanning disk usb_mass_storage.lun0...
Device Name

/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,MBR,0x086246ba,0x40800,0x3f800)
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/USBClass(0,0,9,0,1)/USBClass(46f4,1,0,0,0)/HD(1,0x01,0,0x40,0x14fe4c)

Without this patch, the last device, USB mass storage, won't show up.

[1] https://lists.denx.de/pipermail/u-boot/2018-October/345307.html

Signed-off-by: AKASHI Takahiro 
---
 cmd/bootefi.c |   8 +-
 include/efi_loader.h  |   2 +
 lib/efi_loader/efi_disk.c | 150 ++
 3 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 3cefb4d0ecaa..493022a09482 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -57,8 +57,14 @@ efi_status_t efi_init_obj_list(void)
efi_save_gd();
 
/* Initialize once only */
-   if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
+   if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) {
+#ifdef CONFIG_PARTITIONS
+   ret = efi_disk_update();
+   if (ret != EFI_SUCCESS)
+   printf("+++ updating disks failed\n");
+#endif
return efi_obj_list_initialized;
+   }
 
/* Initialize system table */
ret = efi_initialize_system_table();
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 5cc3bded03fa..e5a080281dba 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -260,6 +260,8 @@ efi_status_t efi_initialize_system_table(void);
 efi_status_t efi_console_register(void);
 /* Called by bootefi to make all disk storage accessible as EFI objects */
 efi_status_t efi_disk_register(void);
+/* Called by bootefi to find and update disk storage information */
+efi_status_t efi_disk_update(void);
 /* Create handles and protocols for the partitions of a block device */
 int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
   const char *if_typename, int diskid,
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index c037526ad2d0..e1d47f34049b 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -14,10 +14,13 @@
 
 const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
 
+#define _EFI_DISK_MARK_DELETE 0x1
+
 /**
  * struct efi_disk_obj - EFI disk object
  *
  * @header:EFI object header
+ * @flags: control flags
  * @ops:   EFI disk I/O protocol interface
  * @ifname:interface name for block device
  * @dev_index: device index of block device
@@ -30,6 +33,7 @@ const efi_guid_t efi_block_io_guid = BLOCK_IO_GUID;
  */
 struct efi_disk_obj {
struct efi_object header;
+   int flags;
struct efi_block_io ops;
const char *ifname;
int dev_index;
@@ -440,3 +444,149 @@ efi_status_t efi_disk_register(void)
 
return EFI_SUCCESS;
 }
+
+static void efi_disk_mark_delete(struct efi_disk_obj *disk)
+{
+   disk->flags |= _EFI_DISK_MARK_DELETE;
+}
+
+static void efi_disk_mark_undelete(struct efi_disk_obj *disk)
+{
+   disk->flags &= ~_EFI_DISK_MARK_DELETE;
+}
+
+static bool efi_disk_delete_marked(struct efi_disk_obj *disk)
+{
+   return disk->flags & _EFI_DISK_MARK_DELETE;
+}
+
+static efi_status_t efi_disk_mark_delete_all(efi_handle_t **handlesp)
+{
+   efi_handle_t *handles = NULL;
+   efi_uintn_t size = 0;
+   int num, i;
+   struct efi_disk_obj *disk;
+   efi_status_t ret;
+
+   ret = efi_locate_handle(BY_PROTOCOL, &efi_block_io_guid, NULL,
+   &size, handles);
+   if (ret == EFI_BUFFER_TOO_SMALL) {
+   handles = calloc(1, size);
+   if (!handles)
+   return EFI_OUT_OF_RESOURCES;
+
+   ret = efi_locate_handle(BY_PROTOCOL, &efi_block_io_guid, NULL,
+   &size, handles);
+   }
+   if (ret != EFI_SUCCESS) {
+   free(handles)

[U-Boot] [PATCH 1/2] efi_loader: export efi_locate_handle() function

2018-11-06 Thread AKASHI Takahiro
This function will be used later to implement efi_disk_update().

Signed-off-by: AKASHI Takahiro 
---
 include/efi_loader.h  | 4 
 lib/efi_loader/efi_boottime.c | 7 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index ce0f420b5004..5cc3bded03fa 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -318,6 +318,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);
+/* locate handles */
+efi_status_t efi_locate_handle(enum efi_locate_search_type search_type,
+  const efi_guid_t *protocol, void *search_key,
+  efi_uintn_t *buffer_size, efi_handle_t *buffer);
 /* 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 8a43a5a84091..a3c56bbab552 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -1309,10 +1309,9 @@ static int efi_search(enum efi_locate_search_type 
search_type,
  *
  * Return: status code
  */
-static efi_status_t efi_locate_handle(
-   enum efi_locate_search_type search_type,
-   const efi_guid_t *protocol, void *search_key,
-   efi_uintn_t *buffer_size, efi_handle_t *buffer)
+efi_status_t efi_locate_handle(enum efi_locate_search_type search_type,
+  const efi_guid_t *protocol, void *search_key,
+  efi_uintn_t *buffer_size, efi_handle_t *buffer)
 {
struct efi_object *efiobj;
efi_uintn_t size = 0;
-- 
2.19.0

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


[U-Boot] [PATCH 1/4] buildman: Only print toolchain probing with -v

2018-11-06 Thread Simon Glass
At present --list-tool-chains prints a lot of information about the
toolchain-probing process. This is generally not very interesting.
Update buildman to print this only if --list-tool-chains is given
with -v.

Signed-off-by: Simon Glass 
---

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

diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index e493b1ac4a0..a5376e1b365 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -64,7 +64,7 @@ def ParseArgs():
 parser.add_option('-l', '--list-error-boards', action='store_true',
   default=False, help='Show a list of boards next to each 
error/warning')
 parser.add_option('--list-tool-chains', action='store_true', default=False,
-  help='List available tool chains')
+  help='List available tool chains (use -v to see probing detail)')
 parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
   default=False, help="Do a dry run (describe actions, but do 
nothing)")
 parser.add_option('-N', '--no-subdirs', action='store_true', 
dest='no_subdirs',
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index bc0819784f8..0c0cf48d3cb 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -159,7 +159,7 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, boards=None,
 
 if no_toolchains:
 toolchains.GetSettings()
-toolchains.Scan(options.list_tool_chains)
+toolchains.Scan(options.list_tool_chains and options.verbose)
 if options.list_tool_chains:
 toolchains.List()
 print
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 4/4] buildman: Show boards with warning with w+

2018-11-06 Thread Simon Glass
At present we should boards with warnings in the same way as those with
errors. This is not ideal. Add a new 'warn' state and show these listed
in yellow to match the actual warning lines printing with -e.

Signed-off-by: Simon Glass 
---

 tools/buildman/builder.py | 17 +---
 tools/buildman/test.py| 56 ---
 2 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index d9d86ef6a39..6a6c83bf336 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -1197,6 +1197,7 @@ class Builder:
 
 
 ok_boards = []  # List of boards fixed since last commit
+warn_boards = []# List of boards with warnings since last commit
 err_boards = [] # List of new broken boards since last commit
 new_boards = [] # List of boards that didn't exist last time
 unknown_boards = [] # List of boards that were not built
@@ -1212,9 +1213,15 @@ class Builder:
 if outcome.rc == OUTCOME_UNKNOWN:
 unknown_boards.append(target)
 elif outcome.rc < base_outcome:
-ok_boards.append(target)
+if outcome.rc == OUTCOME_WARNING:
+warn_boards.append(target)
+else:
+ok_boards.append(target)
 elif outcome.rc > base_outcome:
-err_boards.append(target)
+if outcome.rc == OUTCOME_WARNING:
+warn_boards.append(target)
+else:
+err_boards.append(target)
 else:
 new_boards.append(target)
 
@@ -1225,11 +1232,13 @@ class Builder:
 self._base_warn_line_boards, warn_lines, warn_line_boards, 'w')
 
 # Display results by arch
-if any((ok_boards, err_boards, unknown_boards, new_boards, worse_err,
-better_err, worse_warn, better_warn)):
+if any((ok_boards, warn_boards, err_boards, unknown_boards, new_boards,
+worse_err, better_err, worse_warn, better_warn)):
 arch_list = {}
 self.AddOutcome(board_selected, arch_list, ok_boards, '',
 self.col.GREEN)
+self.AddOutcome(board_selected, arch_list, warn_boards, 'w+',
+self.col.YELLOW)
 self.AddOutcome(board_selected, arch_list, err_boards, '+',
 self.col.RED)
 self.AddOutcome(board_selected, arch_list, new_boards, '*', 
self.col.BLUE)
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 90ab35b1664..4ceb4cceb5a 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -97,6 +97,8 @@ boards = [
 
 BASE_DIR = 'base'
 
+OUTCOME_OK, OUTCOME_WARN, OUTCOME_ERR = range(3)
+
 class Options:
 """Class that holds build options"""
 pass
@@ -166,9 +168,10 @@ class TestBuild(unittest.TestCase):
 result.combined = result.stdout + result.stderr
 return result
 
-def assertSummary(self, text, arch, plus, boards, ok=False):
+def assertSummary(self, text, arch, plus, boards, outcome=OUTCOME_ERR):
 col = self._col
-expected_colour = col.GREEN if ok else col.RED
+expected_colour = (col.GREEN if outcome == OUTCOME_OK else
+   col.YELLOW if outcome == OUTCOME_WARN else col.RED)
 expect = '%10s: ' % arch
 # TODO(s...@chromium.org): If plus is '', we shouldn't need this
 expect += ' ' + col.Color(expected_colour, plus)
@@ -192,6 +195,8 @@ class TestBuild(unittest.TestCase):
 build.do_make = self.Make
 board_selected = self.boards.GetSelectedDict()
 
+# Build the boards for the pre-defined commits and warnings/errors
+# associated with each. This calls our Make() to inject the fake 
output.
 build.BuildBoards(self.commits, board_selected, keep_outputs=False,
   verbose=False)
 lines = terminal.GetPrintTestLines()
@@ -207,33 +212,49 @@ class TestBuild(unittest.TestCase):
 build.ShowSummary(self.commits, board_selected)
 #terminal.EchoPrintTestLines()
 lines = terminal.GetPrintTestLines()
+
+# Upstream commit: no errors
 self.assertEqual(lines[0].text, '01: %s' % commits[0][1])
+
+# Second commit: all archs should fail with warnings
 self.assertEqual(lines[1].text, '02: %s' % commits[1][1])
 
-# We expect all archs to fail
 col = terminal.Color()
-self.assertSummary(lines[2].text, 'sandbox', '+', ['board4'])
-self.assertSummary(lines[3].text, 'arm', '+', ['board1'])
-self.assertSummary(lines[4].text, 'powerpc', '+', ['board2', 'board3'])
-
-# Now we should have the compiler warning
+self.assertSummary(lines[2].text, 'sandbox', 'w+', ['board4'],
+   out

[U-Boot] [PATCH 3/4] buildman: Rename the good, better, worse variables

2018-11-06 Thread Simon Glass
At present we don't distinguish between errors and warnings when printing
the architecture summary. Rename the variables to better describe their
purpose.

'Worse' at present means we got an error, so use that as the name.

Signed-off-by: Simon Glass 
---

 tools/buildman/builder.py | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index fc80705a455..d9d86ef6a39 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -1196,10 +1196,10 @@ class Builder:
 Print('   ' + line, newline=True, colour=col)
 
 
-better = [] # List of boards fixed since last commit
-worse = []  # List of new broken boards since last commit
-new = []# List of boards that didn't exist last time
-unknown = []# List of boards that were not built
+ok_boards = []  # List of boards fixed since last commit
+err_boards = [] # List of new broken boards since last commit
+new_boards = [] # List of boards that didn't exist last time
+unknown_boards = [] # List of boards that were not built
 
 for target in board_dict:
 if target not in board_selected:
@@ -1210,13 +1210,13 @@ class Builder:
 base_outcome = self._base_board_dict[target].rc
 outcome = board_dict[target]
 if outcome.rc == OUTCOME_UNKNOWN:
-unknown.append(target)
+unknown_boards.append(target)
 elif outcome.rc < base_outcome:
-better.append(target)
+ok_boards.append(target)
 elif outcome.rc > base_outcome:
-worse.append(target)
+err_boards.append(target)
 else:
-new.append(target)
+new_boards.append(target)
 
 # Get a list of errors that have appeared, and disappeared
 better_err, worse_err = _CalcErrorDelta(self._base_err_lines,
@@ -1225,16 +1225,16 @@ class Builder:
 self._base_warn_line_boards, warn_lines, warn_line_boards, 'w')
 
 # Display results by arch
-if (better or worse or unknown or new or worse_err or better_err
-or worse_warn or better_warn):
+if any((ok_boards, err_boards, unknown_boards, new_boards, worse_err,
+better_err, worse_warn, better_warn)):
 arch_list = {}
-self.AddOutcome(board_selected, arch_list, better, '',
+self.AddOutcome(board_selected, arch_list, ok_boards, '',
 self.col.GREEN)
-self.AddOutcome(board_selected, arch_list, worse, '+',
+self.AddOutcome(board_selected, arch_list, err_boards, '+',
 self.col.RED)
-self.AddOutcome(board_selected, arch_list, new, '*', self.col.BLUE)
+self.AddOutcome(board_selected, arch_list, new_boards, '*', 
self.col.BLUE)
 if self._show_unknown:
-self.AddOutcome(board_selected, arch_list, unknown, '?',
+self.AddOutcome(board_selected, arch_list, unknown_boards, '?',
 self.col.MAGENTA)
 for arch, target_list in arch_list.iteritems():
 Print('%10s: %s' % (arch, target_list))
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 2/4] buildman: Detect dtc warnings

2018-11-06 Thread Simon Glass
At present messages from the device-tree compiler like this:

  arch/arm/dts/socfpga_arria10_socdk_sdmmc.dtb: Warning
 (avoid_unnecessary_addr_size): /clocks: unnecessary
 #address-cells/#size-cells without "ranges" or child "reg" property

are detected as errors since they don't match the gcc warning regex. Add a
new one for dtc to fix this.

Signed-off-by: Simon Glass 
---

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

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 05f82995416..fc80705a455 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -290,6 +290,7 @@ class Builder:
 self._re_function = re.compile('(.*): In function.*')
 self._re_files = re.compile('In file included from.*')
 self._re_warning = re.compile('(.*):(\d*):(\d*): warning: .*')
+self._re_dtb_warning = re.compile('(.*): Warning .*')
 self._re_note = re.compile('(.*):(\d*):(\d*): note: this is the 
location of the previous.*')
 
 self.queue = Queue.Queue()
@@ -788,7 +789,8 @@ class Builder:
 self._re_files.match(line)):
 last_func = line
 else:
-is_warning = self._re_warning.match(line)
+is_warning = (self._re_warning.match(line) or
+  self._re_dtb_warning.match(line))
 is_note = self._re_note.match(line)
 if is_warning or (last_was_warning and is_note):
 if last_func:
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index e0c9d6da6a0..90ab35b1664 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -46,8 +46,9 @@ make[1]: *** [main.o] Error 1
 make: *** [common/libcommon.o] Error 2
 Make failed
 ''',
-'''main.c: In function 'main_loop3':
-main.c:280:6: warning: unused variable 'mary' [-Wunused-variable]
+'''arch/arm/dts/socfpga_arria10_socdk_sdmmc.dtb: Warning \
+(avoid_unnecessary_addr_size): /clocks: unnecessary #address-cells/#size-cells 
\
+without "ranges" or child "reg" property
 ''',
 '''powerpc-linux-ld: warning: dot moved backwards before `.bss'
 powerpc-linux-ld: warning: dot moved backwards before `.bss'
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH v12 5/6] efi: Create a function to set up for running EFI code

2018-11-06 Thread Simon Glass
There is still duplicated code in efi_loader for tests and normal
operation.

Add a new bootefi_run_prepare() function which holds common code used to
set up U-Boot to run EFI code. Make use of this from the existing
bootefi_test_prepare() function, as well as do_bootefi_exec().

Also shorten a few variable names.

Signed-off-by: Simon Glass 
---

Changes in v12: None
Changes in v11: None
Changes in v9: None
Changes in v7: None
Changes in v5:
- Drop call to efi_init_obj_list() which is now done in do_bootefi()
- Introduce load_options_path to specifyc U-Boot env var for load_options_path

Changes in v4:
- Rebase to master

Changes in v3:
- Add patch to create a function to set up for running EFI code

 cmd/bootefi.c | 85 +--
 1 file changed, 48 insertions(+), 37 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 0dd18d594d5..779c1f63fa8 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -327,6 +327,30 @@ static efi_status_t efi_install_fdt(ulong fdt_addr)
return ret;
 }
 
+static efi_status_t bootefi_run_prepare(const char *load_options_path,
+   struct efi_device_path *device_path,
+   struct efi_device_path *image_path,
+   struct efi_loaded_image **imagep,
+   struct efi_loaded_image_obj **objp)
+{
+   efi_status_t ret;
+
+   ret = efi_setup_loaded_image(device_path, image_path, objp, imagep);
+   if (ret != EFI_SUCCESS)
+   return ret;
+
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+
+   /* Transfer environment variable as load options */
+   set_load_options(*imagep, load_options_path);
+
+   return 0;
+}
+
 /**
  * do_bootefi_exec() - execute EFI binary
  *
@@ -345,8 +369,8 @@ static efi_status_t do_bootefi_exec(void *efi,
efi_handle_t mem_handle = NULL;
struct efi_device_path *memdp = NULL;
efi_status_t ret;
-   struct efi_loaded_image_obj *image_handle = NULL;
-   struct efi_loaded_image *loaded_image_info = NULL;
+   struct efi_loaded_image_obj *obj = NULL;
+   struct efi_loaded_image *image = NULL;
 
EFIAPI efi_status_t (*entry)(efi_handle_t image_handle,
 struct efi_system_table *st);
@@ -376,15 +400,13 @@ static efi_status_t do_bootefi_exec(void *efi,
assert(device_path && image_path);
}
 
-   ret = efi_setup_loaded_image(device_path, image_path, &image_handle,
-&loaded_image_info);
-   if (ret != EFI_SUCCESS)
-   goto exit;
+   ret = bootefi_run_prepare("bootargs", device_path, image_path,
+ &image, &obj);
+   if (ret)
+   return ret;
 
-   /* Transfer environment variable bootargs as load options */
-   set_load_options(loaded_image_info, "bootargs");
/* Load the EFI payload */
-   entry = efi_load_pe(image_handle, efi, loaded_image_info);
+   entry = efi_load_pe(obj, efi, image);
if (!entry) {
ret = EFI_LOAD_ERROR;
goto exit;
@@ -392,10 +414,9 @@ static efi_status_t do_bootefi_exec(void *efi,
 
if (memdp) {
struct efi_device_path_memory *mdp = (void *)memdp;
-   mdp->memory_type = loaded_image_info->image_code_type;
-   mdp->start_address = (uintptr_t)loaded_image_info->image_base;
-   mdp->end_address = mdp->start_address +
-   loaded_image_info->image_size;
+   mdp->memory_type = image->image_code_type;
+   mdp->start_address = (uintptr_t)image->image_base;
+   mdp->end_address = mdp->start_address + image->image_size;
}
 
/* we don't support much: */
@@ -405,8 +426,8 @@ static efi_status_t do_bootefi_exec(void *efi,
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
-   if (setjmp(&image_handle->exit_jmp)) {
-   ret = image_handle->exit_status;
+   if (setjmp(&obj->exit_jmp)) {
+   ret = obj->exit_status;
goto exit;
}
 
@@ -418,7 +439,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 
/* Move into EL2 and keep running there */
armv8_switch_to_el2((ulong)entry,
-   (ulong)image_handle,
+   (ulong)obj,
(ulong)&systab, 0, (ulong)efi_run_in_el2,
ES_TO_AARCH64);
 
@@ -435,7 +456,7 @@ static efi_status_t do_bootefi_exec(void *efi,
secure_ram_addr(_do_nonsec_entry)(
 

[U-Boot] [PATCH v12 4/6] efi: Split out test init/uninit into functions

2018-11-06 Thread Simon Glass
The functions in bootefi are very long because they mix high-level code
and control with the low-level implementation. To help with this, create
functions which handle preparing for running the test and cleaning up
afterwards.

Also shorten the awfully long variable names here.

Signed-off-by: Simon Glass 
---

Changes in v12:
- Rename image to image_prot

Changes in v11: None
Changes in v9:
- Add comments to bootefi_test_prepare() about the memset()s

Changes in v7: None
Changes in v5:
- Drop call to efi_init_obj_list() which is now done in do_bootefi()

Changes in v4: None
Changes in v3:
- Add new patch to split out test init/uninit into functions

 cmd/bootefi.c | 85 +++
 1 file changed, 65 insertions(+), 20 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 4d68d807480..0dd18d594d5 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -455,6 +455,64 @@ exit:
return ret;
 }
 
+#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
+/**
+ * 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.
+ *
+ * @image: Pointer to a struct which will hold the loaded image info.
+ *This struct will be inited by this function before use.
+ * @obj: Pointer to a struct which will hold the loaded image object
+ *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
+ * @return 0 if OK, -ve on error
+ */
+static efi_status_t bootefi_test_prepare(struct efi_loaded_image **imagep,
+struct efi_loaded_image_obj **objp,
+const char *path, ulong test_func)
+{
+   efi_status_t r;
+
+   /* 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_image_path = efi_dp_from_file(NULL, 0, path);
+   r = efi_setup_loaded_image(bootefi_device_path, bootefi_image_path,
+  objp, imagep);
+   if (r)
+   return r;
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+
+   /* Transfer environment variable efi_selftest as load options */
+   set_load_options(*imagep, "efi_selftest");
+
+   return 0;
+}
+
+/**
+ * bootefi_test_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_test_finish(struct efi_loaded_image *image,
+   struct efi_loaded_image_obj *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   efi_delete_handle(&obj->parent);
+}
+#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
+
 static int do_bootefi_bootmgr_exec(void)
 {
struct efi_device_path *device_path, *file_path;
@@ -527,29 +585,16 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
 #endif
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   struct efi_loaded_image_obj *image_handle;
-   struct efi_loaded_image *loaded_image_info;
-
-   /* Construct a dummy device path. */
-   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
- (uintptr_t)&efi_selftest,
- (uintptr_t)&efi_selftest);
-   bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest");
-
-   r = efi_setup_loaded_image(bootefi_device_path,
-  bootefi_image_path, &image_handle,
-  &loaded_image_info);
-   if (r != EFI_SUCCESS)
+   struct efi_loaded_image_obj *obj;
+   struct efi_loaded_image *image_prot;
+
+   if (bootefi_test_prepare(&image_prot, &obj, "\\selftest",
+(uintptr_t)&efi_selftest))
return CMD_RET_FAILURE;
 
-   efi_save_gd();
-   /* Transfer environment variable efi_selftest as load options */
-   set_load_options(loaded_image_info, "efi_selftest");
/* Execute the test */
-   r = efi_selftest(image_handle, &systab);
-   efi_restore_gd();
-   free(loaded_image_info->load_options);
-   efi_delete_hand

[U-Boot] [PATCH v12 6/6] efi: Rename bootefi_test_finish() to bootefi_run_finish()

2018-11-06 Thread Simon Glass
This function can be used from do_bootefi_exec() so that we use mostly the
same code for a normal EFI application and an EFI test.

Rename the function and use it in both places.

Signed-off-by: Simon Glass 
---

Changes in v12: None
Changes in v11:
- Drop patches previously applied

Changes in v9: None
Changes in v7:
- Drop patch "efi: Init the 'rows' and 'cols' variables"
- Drop patches previous applied

Changes in v5:
- Rebase to master

Changes in v4:
- Rebase to master

Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()

 cmd/bootefi.c | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 779c1f63fa8..7a077995dc5 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -351,6 +351,20 @@ static efi_status_t bootefi_run_prepare(const char 
*load_options_path,
return 0;
 }
 
+/**
+ * bootefi_run_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_run_finish(struct efi_loaded_image *image,
+  struct efi_loaded_image_obj *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   efi_delete_handle(&obj->parent);
+}
+
 /**
  * do_bootefi_exec() - execute EFI binary
  *
@@ -468,8 +482,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 
 exit:
/* image has returned, loaded-image obj goes *poof*: */
-   if (obj)
-   efi_delete_handle(&obj->parent);
+   bootefi_run_finish(image, obj);
if (mem_handle)
efi_delete_handle(mem_handle);
 
@@ -507,20 +520,6 @@ static efi_status_t bootefi_test_prepare(struct 
efi_loaded_image **imagep,
return bootefi_run_prepare(load_options_path, bootefi_device_path,
   bootefi_image_path, imagep, objp);
 }
-
-/**
- * bootefi_test_finish() - finish up after running an EFI test
- *
- * @image: Pointer to a struct which holds the loaded image info
- * @obj: Pointer to a struct which holds the loaded image object
- */
-static void bootefi_test_finish(struct efi_loaded_image *image,
-   struct efi_loaded_image_obj *obj)
-{
-   efi_restore_gd();
-   free(image->load_options);
-   efi_delete_handle(&obj->parent);
-}
 #endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
 
 static int do_bootefi_bootmgr_exec(void)
@@ -605,7 +604,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
/* Execute the test */
r = efi_selftest(obj, &systab);
-   bootefi_test_finish(image_prot, obj);
+   bootefi_run_finish(image_prot, obj);
return r != EFI_SUCCESS;
} else
 #endif
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH v12 2/6] efi_loader: Drop setup_ok

2018-11-06 Thread Simon Glass
This value is stored in data which appears to be read-only with sandbox on
my Ubuntu 18.04 machine. In any case it is not good practice to store
run-time data in a build-time linker list.

The value does not seem to be that useful, since tests that fail to setup
are likely to fail to run also. Let's drop it for now.

Signed-off-by: Simon Glass 
---

Changes in v12: None
Changes in v11:
- Add a new patch to drop setup_ok

Changes in v9: None
Changes in v7: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 include/efi_selftest.h  |  2 --
 lib/efi_selftest/efi_selftest.c | 14 +++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/efi_selftest.h b/include/efi_selftest.h
index 56beac305ec..49d3d6d0b47 100644
--- a/include/efi_selftest.h
+++ b/include/efi_selftest.h
@@ -129,7 +129,6 @@ u16 efi_st_get_key(void);
  * @setup: set up the unit test
  * @teardown:  tear down the unit test
  * @execute:   execute the unit test
- * @setup_ok:  setup was successful (set at runtime)
  * @on_request:test is only executed on request
  */
 struct efi_unit_test {
@@ -139,7 +138,6 @@ struct efi_unit_test {
 const struct efi_system_table *systable);
int (*execute)(void);
int (*teardown)(void);
-   int setup_ok;
bool on_request;
 };
 
diff --git a/lib/efi_selftest/efi_selftest.c b/lib/efi_selftest/efi_selftest.c
index dd338db687e..dfd11be2302 100644
--- a/lib/efi_selftest/efi_selftest.c
+++ b/lib/efi_selftest/efi_selftest.c
@@ -74,20 +74,20 @@ void efi_st_exit_boot_services(void)
  */
 static int setup(struct efi_unit_test *test, unsigned int *failures)
 {
-   if (!test->setup) {
-   test->setup_ok = EFI_ST_SUCCESS;
+   int ret;
+
+   if (!test->setup)
return EFI_ST_SUCCESS;
-   }
efi_st_printc(EFI_LIGHTBLUE, "\nSetting up '%s'\n", test->name);
-   test->setup_ok = test->setup(handle, systable);
-   if (test->setup_ok != EFI_ST_SUCCESS) {
+   ret = test->setup(handle, systable);
+   if (ret) {
efi_st_error("Setting up '%s' failed\n", test->name);
++*failures;
} else {
efi_st_printc(EFI_LIGHTGREEN,
  "Setting up '%s' succeeded\n", test->name);
}
-   return test->setup_ok;
+   return ret;
 }
 
 /*
@@ -197,7 +197,7 @@ void efi_st_do_tests(const u16 *testname, unsigned int 
phase,
continue;
if (steps & EFI_ST_SETUP)
setup(test, failures);
-   if (steps & EFI_ST_EXECUTE && test->setup_ok == EFI_ST_SUCCESS)
+   if (steps & EFI_ST_EXECUTE)
execute(test, failures);
if (steps & EFI_ST_TEARDOWN)
teardown(test, failures);
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH v12 3/6] sandbox: smbios: Update to support sandbox

2018-11-06 Thread Simon Glass
At present this code casts addresses to pointers so cannot be used with
sandbox. Update it to use mapmem instead.

Signed-off-by: Simon Glass 
---

Changes in v12: None
Changes in v11:
- Fix the EFI code that has since been added and relies on broken behaviour

Changes in v9: None
Changes in v7: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Drop incorrect map_sysmem() in write_smbios_table()

 lib/efi_loader/efi_smbios.c | 20 +---
 lib/smbios.c| 32 
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 38e42fa2432..a81488495e2 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -7,6 +7,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
@@ -19,17 +20,19 @@ static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
 efi_status_t efi_smbios_register(void)
 {
/* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
-   u64 dmi = U32_MAX;
+   u64 dmi_addr = U32_MAX;
efi_status_t ret;
+   void *dmi;
 
/* Reserve 4kiB page for SMBIOS */
ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
+EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr);
 
if (ret != EFI_SUCCESS) {
/* Could not find space in lowmem, use highmem instead */
ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
-EFI_RUNTIME_SERVICES_DATA, 1, &dmi);
+EFI_RUNTIME_SERVICES_DATA, 1,
+&dmi_addr);
 
if (ret != EFI_SUCCESS)
return ret;
@@ -39,11 +42,14 @@ efi_status_t efi_smbios_register(void)
 * Generate SMBIOS tables - we know that efi_allocate_pages() returns
 * a 4k-aligned address, so it is safe to assume that
 * write_smbios_table() will write the table at that address.
+*
+* Note that on sandbox, efi_allocate_pages() unfortunately returns a
+* pointer even though it uses a uint64_t type. Convert it.
 */
-   assert(!(dmi & 0xf));
-   write_smbios_table(dmi);
+   assert(!(dmi_addr & 0xf));
+   dmi = (void *)(uintptr_t)dmi_addr;
+   write_smbios_table(map_to_sysmem(dmi));
 
/* And expose them to our EFI payload */
-   return efi_install_configuration_table(&smbios_guid,
-  (void *)(uintptr_t)dmi);
+   return efi_install_configuration_table(&smbios_guid, dmi);
 }
diff --git a/lib/smbios.c b/lib/smbios.c
index 326eb00230d..87109d431a2 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -72,9 +73,10 @@ static int smbios_string_table_len(char *start)
 
 static int smbios_write_type0(ulong *current, int handle)
 {
-   struct smbios_type0 *t = (struct smbios_type0 *)*current;
+   struct smbios_type0 *t;
int len = sizeof(struct smbios_type0);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type0));
fill_smbios_header(t, SMBIOS_BIOS_INFORMATION, len, handle);
t->vendor = smbios_add_string(t->eos, "U-Boot");
@@ -101,16 +103,18 @@ static int smbios_write_type0(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type1(ulong *current, int handle)
 {
-   struct smbios_type1 *t = (struct smbios_type1 *)*current;
+   struct smbios_type1 *t;
int len = sizeof(struct smbios_type1);
char *serial_str = env_get("serial#");
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type1));
fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -122,15 +126,17 @@ static int smbios_write_type1(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*current += len;
+   unmap_sysmem(t);
 
return len;
 }
 
 static int smbios_write_type2(ulong *current, int handle)
 {
-   struct smbios_type2 *t = (struct smbios_type2 *)*current;
+   struct smbios_type2 *t;
int len = sizeof(struct smbios_type2);
 
+   t = map_sysmem(*current, len);
memset(t, 0, sizeof(struct smbios_type2));
fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle);
t->manufacturer = smbios_add_string(t->eos, CONFIG_SMBIOS_MANUFACTURER);
@@ -140,15 +146,17 @@ static int smbios_write_type2(ulong *current, int handle)
 
len = t->length + smbios_string_table_len(t->eos);
*curren

[U-Boot] [PATCH v12 1/6] sandbox: Put CPUs under a cpu-bus node

2018-11-06 Thread Simon Glass
The CPU uclass expects that all CPUs have a parent device which is a
cpu-bus. Fix up the sandbox test DT to follow this convention. This allow
the code in smbios_write_type4_dm() to work, since it calls
dev_get_parent_platdata() on each CPU.

Signed-off-by: Simon Glass 
---

Changes in v12:
- Update CPU nodes to comply with the DT spec

Changes in v11:
- Add a new patch to put CPUs under a cpu-bus node

Changes in v9: None
Changes in v7: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 arch/sandbox/dts/test.dts | 38 ++
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 57e0dd76631..bec912f917f 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -344,16 +344,38 @@
mbox-names = "other", "test";
};
 
-   cpu-test1 {
-   compatible = "sandbox,cpu_sandbox";
-   };
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
 
-   cpu-test2 {
-   compatible = "sandbox,cpu_sandbox";
-   };
+   cpu@0 {
+   reg = <0>;
+   compatible = "sandbox,cpu_sandbox";
+   device-type = "cpu";
 
-   cpu-test3 {
-   compatible = "sandbox,cpu_sandbox";
+   /*
+* These are not used by sandbox, but are required by
+* the latest DT spec (v0.2).
+*/
+   clock-frequency = <0>;
+   timebase-frequency = <0>;
+   };
+
+   cpu@1 {
+   reg = <1>;
+   compatible = "sandbox,cpu_sandbox";
+   device-type = "cpu";
+   clock-frequency = <0>;
+   timebase-frequency = <0>;
+   };
+
+   cpu@2 {
+   reg = <2>;
+   compatible = "sandbox,cpu_sandbox";
+   device-type = "cpu";
+   clock-frequency = <0>;
+   timebase-frequency = <0>;
+   };
};
 
misc-test {
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH v12 0/6] efi_loader: Code refactoring and improvement

2018-11-06 Thread Simon Glass
This collects the patches previously sent to break up the very large
functions in efi_loader into smaller pieces. Now that the other sandbox
stuff is applied, perhaps it is time to apply these patches.

This also adds a few new patches to fix more recent breakages.
Unfortunately we still cannot enable the efi loader tests since one of
the tests fails. Thus we should expect additional failures to appear
until that is resolved.

Changes in v12:
- Rename image to image_prot
- Update CPU nodes to comply with the DT spec

Changes in v11:
- Add a new patch to drop setup_ok
- Add a new patch to put CPUs under a cpu-bus node
- Drop patches previously applied
- Fix the EFI code that has since been added and relies on broken behaviour

Changes in v9:
- Add comments to bootefi_test_prepare() about the memset()s

Changes in v7:
- Drop patch "efi: Init the 'rows' and 'cols' variables"
- Drop patches previous applied

Changes in v5:
- Drop call to efi_init_obj_list() which is now done in do_bootefi()
- Introduce load_options_path to specifyc U-Boot env var for load_options_path
- Rebase to master

Changes in v4:
- Rebase to master

Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
- Add new patch to split out test init/uninit into functions
- Add patch to create a function to set up for running EFI code
- Drop incorrect map_sysmem() in write_smbios_table()

Simon Glass (6):
  sandbox: Put CPUs under a cpu-bus node
  efi_loader: Drop setup_ok
  sandbox: smbios: Update to support sandbox
  efi: Split out test init/uninit into functions
  efi: Create a function to set up for running EFI code
  efi: Rename bootefi_test_finish() to bootefi_run_finish()

 arch/sandbox/dts/test.dts   |  38 +++--
 cmd/bootefi.c   | 135 ++--
 include/efi_selftest.h  |   2 -
 lib/efi_loader/efi_smbios.c |  20 +++--
 lib/efi_selftest/efi_selftest.c |  14 ++--
 lib/smbios.c|  32 ++--
 6 files changed, 169 insertions(+), 72 deletions(-)

-- 
2.19.1.930.g4563a0d9d0-goog

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


Re: [U-Boot] Please pull u-boot-x86

2018-11-06 Thread Tom Rini
On Tue, Nov 06, 2018 at 01:38:07PM +0800, Bin Meng wrote:

> Hi Tom,
> 
> This contains a fix to a warning by newer version IASL compiler.
> 
> The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04
> 08:12:21 -0500)
> 
> are available in the git repository at:
> 
>   git://git.denx.de/u-boot-x86.git
> 
> for you to fetch changes up to 24109bba6a4f81774e384c15c2e8a4d47791455f:
> 
>   x86: acpi: Remove redundant Offset (0x00) (2018-11-06 13:35:06 +0800)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PULL] Please pull u-boot-imx: u-boot-imx-20181106

2018-11-06 Thread Tom Rini
On Tue, Nov 06, 2018 at 04:57:46PM +0100, Stefano Babic wrote:

> Hi Tom,
> 
> this solves issue reported by coverity for i.MX8:
> 
> The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04
> 08:12:21 -0500)
> 
> are available in the Git repository at:
> 
>   git://www.denx.de/git/u-boot-imx.git tags/u-boot-imx-20181106
> 
> for you to fetch changes up to 0ea82ba2b082475090e11872ec11409a9fc8d486:
> 
>   MAINTAINERS: add NXP linux team maillist as i.MX reviewer (2018-11-06
> 11:26:21 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PATCH v2 2/2] cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes

2018-11-06 Thread sjg
On 14.10.2018 10:07, Bin Meng wrote:
> To support CONFIG_DISPLAY_CPUINFO, add "u-boot,dm-pre-reloc" for
> all cpu nodes in Sandbox test.dts.
>
> Signed-off-by: Bin Meng 

Reviewed-by: Stefan Roese 

Thanks,
Stefan

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Please pull u-boot/master

2018-11-06 Thread Tom Rini
On Tue, Nov 06, 2018 at 04:12:39PM +0100, Stefan Roese wrote:

> Hi Tom,
> 
> could you please pull these MVEBU fixes for the upcoming release?
> 
> Thanks,
> Stefan
> 
> 
> The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> 
>   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21 
> -0500)
> 
> are available in the Git repository at:
> 
>   git://www.denx.de/git/u-boot-marvell.git
> 
> for you to fetch changes up to ae4c38a5384033c7f5584e33cce1adc511fff333:
> 
>   arm: mvebu: armada-xp-theadorable.dts: Change CS# for 2nd FPGA (2018-11-06 
> 13:21:13 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


Re: [U-Boot] [PATCH 03/13] gpio: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
> From: U-Boot  On Behalf Of Bin Meng
> Sent: mercredi 24 octobre 2018 15:37

> Subject: [U-Boot] [PATCH 03/13] gpio: Remove DM_FLAG_PRE_RELOC flag in
> various drivers
>
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be bound before
> relocation. However due to a bug in the DM core, the flag only takes effect
> when devices are statically declared via U_BOOT_DEVICE(). This bug has been
> fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that all existing 
> drivers that
> declared DM_FLAG_PRE_RELOC flag will be bound before relocation now. This
> may expose potential boot failure on some boards due to insufficient memory
> during the pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/gpio/omap_gpio.c | 2 ++
>  drivers/gpio/stm32f7_gpio.c  | 2 +-
>  drivers/gpio/tegra186_gpio.c | 1 -
>  drivers/gpio/tegra_gpio.c| 1 -
>  4 files changed, 3 insertions(+), 3 deletions(-)
>
Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 04/13] i2c: omap24xx: Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/i2c/omap24xx_i2c.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 02/13] clk: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/clk/altera/clk-arria10.c| 1 -
>  drivers/clk/clk_pic32.c | 1 -
>  drivers/clk/clk_zynq.c  | 1 -
>  drivers/clk/exynos/clk-exynos7420.c | 3 ---
>  drivers/clk/owl/clk_s900.c  | 1 -
>  5 files changed, 7 deletions(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] cpu: Add DM_FLAG_PRE_RELOC flag to various cpu drivers

2018-11-06 Thread sjg
On 14.10.2018 10:07, Bin Meng wrote:
> It turns out commit c0434407b595 broke some boards which have DM CPU
> driver with CONFIG_DISPLAY_CPUINFO option on. These boards just fail
> to boot when print_cpuinfo() is called during boot.
>
> Fixes: c0434407b595 ("board_f: Use static print_cpuinfo if CONFIG_CPU is 
> active")
> Reported-by: Stefan Roese 
> Signed-off-by: Bin Meng 

Reviewed-by: Stefan Roese 
Tested-by: Stefan Roese 

Thanks,
Stefan

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 08/13] timer: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/timer/ag101p_timer.c| 1 -
>  drivers/timer/altera_timer.c| 1 -
>  drivers/timer/arc_timer.c   | 1 -
>  drivers/timer/ast_timer.c   | 1 -
>  drivers/timer/atcpit100_timer.c | 1 -
>  drivers/timer/atmel_pit_timer.c | 1 -
>  drivers/timer/cadence-ttc.c | 1 -
>  drivers/timer/dw-apb-timer.c| 1 -
>  drivers/timer/mpc83xx_timer.c   | 1 -
>  drivers/timer/omap-timer.c  | 1 -
>  drivers/timer/rockchip_timer.c  | 1 -
>  drivers/timer/sti-timer.c   | 1 -
>  drivers/timer/stm32_timer.c | 1 -
>  drivers/timer/tsc_timer.c   | 1 -
>  14 files changed, 14 deletions(-)
>

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 06/13] pinctrl: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/pinctrl/broadcom/pinctrl-bcm283x.c   | 2 ++
>  drivers/pinctrl/exynos/pinctrl-exynos7420.c  | 1 -
>  drivers/pinctrl/nxp/pinctrl-imx5.c   | 2 ++
>  drivers/pinctrl/nxp/pinctrl-imx6.c   | 2 ++
>  drivers/pinctrl/nxp/pinctrl-imx7.c   | 2 ++
>  drivers/pinctrl/nxp/pinctrl-imx7ulp.c| 2 ++
>  drivers/pinctrl/pinctrl-single.c | 1 -
>  drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c | 2 ++
>  drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c | 2 ++
>  9 files changed, 14 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 05/13] mmc: omap: Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/mmc/omap_hsmmc.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 09/13] serial: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/serial/altera_jtag_uart.c | 1 -
>  drivers/serial/altera_uart.c  | 1 -
>  drivers/serial/arm_dcc.c  | 1 -
>  drivers/serial/atmel_usart.c  | 2 ++
>  drivers/serial/ns16550.c  | 2 ++
>  drivers/serial/serial_ar933x.c| 1 -
>  drivers/serial/serial_arc.c   | 1 -
>  drivers/serial/serial_bcm283x_mu.c| 2 ++
>  drivers/serial/serial_bcm283x_pl011.c | 2 ++
>  drivers/serial/serial_bcm6345.c   | 1 -
>  drivers/serial/serial_efi.c   | 1 -
>  drivers/serial/serial_intel_mid.c | 1 -
>  drivers/serial/serial_lpuart.c| 1 -
>  drivers/serial/serial_meson.c | 1 -
>  drivers/serial/serial_mvebu_a3700.c   | 1 -
>  drivers/serial/serial_mxc.c   | 2 ++
>  drivers/serial/serial_omap.c  | 2 ++
>  drivers/serial/serial_owl.c   | 1 -
>  drivers/serial/serial_pic32.c | 1 -
>  drivers/serial/serial_pl01x.c | 2 ++
>  drivers/serial/serial_s5p.c   | 1 -
>  drivers/serial/serial_sh.c| 2 ++
>  drivers/serial/serial_sti_asc.c   | 1 -
>  drivers/serial/serial_stm32.c | 2 ++
>  drivers/serial/serial_xuartlite.c | 1 -
>  drivers/serial/serial_zynq.c  | 1 -
>  26 files changed, 18 insertions(+), 17 deletions(-)
>

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 01/13] arm: stm32mp: Remove DM_FLAG_PRE_RELOC flag

2018-11-06 Thread sjg
> From: U-Boot  On Behalf Of Bin Meng
> Sent: mercredi 24 octobre 2018 15:36
>
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be bound before
> relocation. However due to a bug in the DM core, the flag only takes effect
> when devices are statically declared via U_BOOT_DEVICE(). This bug has been
> fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that all existing 
> drivers that
> declared DM_FLAG_PRE_RELOC flag will be bound before relocation now. This
> may expose potential boot failure on some boards due to insufficient memory
> during the pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  arch/arm/mach-stm32mp/bsec.c | 1 -
>  1 file changed, 1 deletion(-)
>
Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 13/13] dm: doc: Update description of pre-relocation support

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> Add some description about pre-relocation driver binding, including
> usage of DM_FLAG_PRE_RELOC flag and caveats.
>
> Signed-off-by: Bin Meng 
>
> ---
>
>  doc/driver-model/README.txt | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 10/13] sysreset: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  arch/x86/cpu/tangier/sysreset.c | 1 -
>  drivers/sysreset/sysreset_x86.c | 1 -
>  lib/efi/efi_app.c   | 1 -
>  3 files changed, 3 deletions(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 07/13] ram: bmips: Remove DM_FLAG_PRE_RELOC flag

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/ram/bmips_ram.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/13] watchdog: Remove DM_FLAG_PRE_RELOC flag in various drivers

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/watchdog/ast_wdt.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 11/13] video: simplefb: Remove DM_FLAG_PRE_RELOC flag

2018-11-06 Thread sjg
On 24 October 2018 at 07:36, Bin Meng  wrote:
> When a driver declares DM_FLAG_PRE_RELOC flag, it wishes to be
> bound before relocation. However due to a bug in the DM core,
> the flag only takes effect when devices are statically declared
> via U_BOOT_DEVICE(). This bug has been fixed recently by commit
> "dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in
> lists_bind_fdt()", but with the fix, it has a side effect that
> all existing drivers that declared DM_FLAG_PRE_RELOC flag will
> be bound before relocation now. This may expose potential boot
> failure on some boards due to insufficient memory during the
> pre-relocation stage.
>
> To mitigate this potential impact, the following changes are
> implemented:
>
> - Remove DM_FLAG_PRE_RELOC flag in the driver, if the driver
>   only supports configuration from device tree (OF_CONTROL)
> - Keep DM_FLAG_PRE_RELOC flag in the driver only if the device
>   is statically declared via U_BOOT_DEVICE()
> - Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for
>   drivers that support both statically declared devices and
>   configuration from device tree
>
> Signed-off-by: Bin Meng 
> ---
>
>  drivers/video/simplefb.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass 

Applied to u-boot-dm/master, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mmc: dw_mmc: Add RCRC handling

2018-11-06 Thread Marek Vasut
This patch adds check for command response CRC failure. The driver
is currently ignoring CRC check failure on command resposes which
have CRC atteched to it, which can be potentially dangerous. Even
more grueling problem happens when the command response is followed
by data transfer though, as in that case, the dwmci_data_transfer()
function will spin until it reaches the 240s timeout.

Signed-off-by: Marek Vasut 
Cc: Heiko Stuebner 
Cc: Philipp Tomsich 
---
 drivers/mmc/dw_mmc.c | 4 
 include/dwmmc.h  | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index 3c702b3ed8..7544b84ab6 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -317,6 +317,10 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd 
*cmd,
} else if (mask & DWMCI_INTMSK_RE) {
debug("%s: Response Error.\n", __func__);
return -EIO;
+   } else if ((cmd->resp_type & MMC_RSP_CRC) &&
+  (mask & DWMCI_INTMSK_RCRC)) {
+   debug("%s: Response CRC Error.\n", __func__);
+   return -EIO;
}
 
 
diff --git a/include/dwmmc.h b/include/dwmmc.h
index 0f9d51b557..4ceda5e43c 100644
--- a/include/dwmmc.h
+++ b/include/dwmmc.h
@@ -56,6 +56,7 @@
 #define DWMCI_INTMSK_DTO   (1 << 3)
 #define DWMCI_INTMSK_TXDR  (1 << 4)
 #define DWMCI_INTMSK_RXDR  (1 << 5)
+#define DWMCI_INTMSK_RCRC  (1 << 6)
 #define DWMCI_INTMSK_DCRC  (1 << 7)
 #define DWMCI_INTMSK_RTO   (1 << 8)
 #define DWMCI_INTMSK_DRTO  (1 << 9)
-- 
2.18.0

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


[U-Boot] [PATCH 25/25] mmc: Add hardware partition support

2018-11-06 Thread Simon Glass
MMC devices support multiple partitions, defined by the hardware. At
present U-Boot can only access partition zero. Add support for selecting
other partitions.

Also add a way to check if a partition is write-protected.
Signed-off-by: Simon Glass 
---

 drivers/mmc/mmc.c | 46 ++
 include/mmc.h | 31 +++
 2 files changed, 77 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index d6b9cdc9922..5b542524338 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1128,6 +1128,52 @@ int mmc_hwpart_config(struct mmc *mmc,
 
return 0;
 }
+
+int mmc_hwpart_access(struct mmc *mmc, int part)
+{
+   int err;
+   struct mmc_cmd cmd;
+
+   cmd.cmdidx = MMC_CMD_SWITCH;
+   cmd.resp_type = MMC_RSP_R1b;
+
+   /* Clear partition access bits */
+   cmd.cmdarg = (MMC_SWITCH_MODE_CLEAR_BITS << 24) |
+   (EXT_CSD_PART_CONF << 16) |
+   (EXT_CSD_PARTITION_ACCESS(0x7) << 8);
+
+   err = mmc_send_cmd(mmc, &cmd, NULL);
+   if (err) {
+   debug("Failed to clear partition access bits\n");
+   return err;
+   }
+
+   /* Set partition access bits */
+   cmd.cmdarg = (MMC_SWITCH_MODE_SET_BITS << 24) |
+   (EXT_CSD_PART_CONF << 16) |
+   (EXT_CSD_PARTITION_ACCESS(part) << 8);
+
+   err = mmc_send_cmd(mmc, &cmd, NULL);
+   if (err) {
+   debug("Failed to change partition\n");
+   return err;
+   }
+
+   return 0;
+}
+
+int mmc_get_boot_wp(struct mmc *mmc)
+{
+   ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
+   int err;
+
+   err = mmc_send_ext_csd(mmc, ext_csd);
+   if (err)
+   return err;
+
+   return ext_csd[EXT_CSD_BOOT_WP] & (EXT_CSD_BOOT_WP_PWR_WP_EN
+   | EXT_CSD_BOOT_WP_PERM_WP_EN);
+}
 #endif
 
 #if !CONFIG_IS_ENABLED(DM_MMC)
diff --git a/include/mmc.h b/include/mmc.h
index 95548e94c4d..1d0f978f8af 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -215,6 +215,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define EXT_CSD_WR_REL_PARAM   166 /* R */
 #define EXT_CSD_WR_REL_SET 167 /* R/W */
 #define EXT_CSD_RPMB_MULT  168 /* RO */
+#define EXT_CSD_BOOT_WP173 /* R/W */
 #define EXT_CSD_ERASE_GROUP_DEF175 /* R/W */
 #define EXT_CSD_BOOT_BUS_WIDTH 177
 #define EXT_CSD_PART_CONF  179 /* R/W */
@@ -279,6 +280,15 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)
 #define EXT_CSD_EXTRACT_BOOT_PART(x)   (((x) >> 3) & 0x7)
 #define EXT_CSD_EXTRACT_PARTITION_ACCESS(x)((x) & 0x7)
 
+/* Enable boot power-on write protect */
+#define EXT_CSD_BOOT_WP_PWR_WP_EN  BIT(0)
+/* Enable boot permanent write protect */
+#define EXT_CSD_BOOT_WP_PERM_WP_EN BIT(2)
+/* Disable use of boot power-on write protect */
+#define EXT_CSD_BOOT_WP_PWR_WP_DIS BIT(6)
+/* Bit 1 (Power-on) or Bit 3 (Permanent) selects the partition to protect */
+#define EXT_CSD_BOOT_WP_PART_SELECTBIT(7)
+
 #define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3)
 #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)(x << 2)
 #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)(x)
@@ -735,6 +745,27 @@ int mmc_switch_part(struct mmc *mmc, unsigned int 
part_num);
 int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf,
  enum mmc_hwpart_conf_mode mode);
 
+/**
+ * Get boot partition write protect status
+ *
+ * @param mmc  MMC to get status of
+ * @return 0 if WP is not asserted, non-zero if WP is asserted
+ */
+int mmc_get_boot_wp(struct mmc *mmc);
+
+/**
+ * Change MMC Partition
+ *
+ * Switch access to partition specified in part.  Unlike mmc_boot_part_access,
+ * this function will not affect the configured boot partition or boot ack
+ * settings.
+ *
+ * @param mmc  MMC to configure
+ * @param part Partition to access (one of PARTITION_ACCESS from spec)
+ * #return 0 on success, -ve on error
+ */
+int mmc_hwpart_access(struct mmc *mmc, int part);
+
 #if !CONFIG_IS_ENABLED(DM_MMC)
 int mmc_getcd(struct mmc *mmc);
 int board_mmc_getcd(struct mmc *mmc);
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 22/25] misc: Update read() and write() methods to return bytes xfered

2018-11-06 Thread Simon Glass
At present these functions return 0 on success. For some devices we want
to know how many bytes were transferred. It seems useful to adjust the API
to be more like the POSIX read() and write() functions.

Update these two methods, a test and all users.

Signed-off-by: Simon Glass 
---

 arch/arm/mach-stm32mp/cpu.c|  4 ++--
 drivers/clk/clk_vexpress_osc.c |  4 ++--
 drivers/misc/altera_sysid.c|  2 +-
 drivers/misc/misc_sandbox.c|  4 ++--
 drivers/misc/rockchip-efuse.c  |  2 +-
 drivers/misc/stm32mp_fuse.c| 12 
 include/misc.h |  8 
 7 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 0e01f8e6138..b8933587adb 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -306,7 +306,7 @@ static int setup_mac_address(void)
 
ret = misc_read(dev, BSEC_OTP_MAC * 4 + STM32_BSEC_OTP_OFFSET,
otp, sizeof(otp));
-   if (ret)
+   if (ret < 0)
return ret;
 
for (i = 0; i < 6; i++)
@@ -344,7 +344,7 @@ static int setup_serial_number(void)
 
ret = misc_read(dev, BSEC_OTP_SERIAL * 4 + STM32_BSEC_OTP_OFFSET,
otp, sizeof(otp));
-   if (ret)
+   if (ret < 0)
return ret;
 
sprintf(serial_string, "%08x%08x%08x", otp[0], otp[1], otp[2]);
diff --git a/drivers/clk/clk_vexpress_osc.c b/drivers/clk/clk_vexpress_osc.c
index 7fef4b2e312..c692a6d0b89 100644
--- a/drivers/clk/clk_vexpress_osc.c
+++ b/drivers/clk/clk_vexpress_osc.c
@@ -29,7 +29,7 @@ static ulong vexpress_osc_clk_get_rate(struct clk *clk)
 
data = CLK_FUNCTION | priv->osc;
err = misc_read(vexpress_cfg, 0, &data, sizeof(data));
-   if (err)
+   if (err < 0)
return err;
 
return data;
@@ -53,7 +53,7 @@ static ulong vexpress_osc_clk_set_rate(struct clk *clk, ulong 
rate)
buffer[0] = CLK_FUNCTION | priv->osc;
buffer[1] = rate;
err = misc_write(vexpress_cfg, 0, buffer, 2 * sizeof(u32));
-   if (err)
+   if (err < 0)
return err;
 
return rate;
diff --git a/drivers/misc/altera_sysid.c b/drivers/misc/altera_sysid.c
index 883b2a35e07..eff33f7343d 100644
--- a/drivers/misc/altera_sysid.c
+++ b/drivers/misc/altera_sysid.c
@@ -35,7 +35,7 @@ void display_sysid(void)
if (ret)
return;
ret = misc_read(dev, 0, &sysid, sizeof(sysid));
-   if (ret)
+   if (ret < 0)
return;
 
stamp = sysid[1];
diff --git a/drivers/misc/misc_sandbox.c b/drivers/misc/misc_sandbox.c
index e4164f76fba..f7c5b2e25fa 100644
--- a/drivers/misc/misc_sandbox.c
+++ b/drivers/misc/misc_sandbox.c
@@ -20,7 +20,7 @@ int misc_sandbox_read(struct udevice *dev, int offset, void 
*buf, int size)
 
memcpy(buf, priv->mem + offset, size);
 
-   return 0;
+   return size;
 }
 
 int misc_sandbox_write(struct udevice *dev, int offset, const void *buf,
@@ -30,7 +30,7 @@ int misc_sandbox_write(struct udevice *dev, int offset, const 
void *buf,
 
memcpy(priv->mem + offset, buf, size);
 
-   return 0;
+   return size;
 }
 
 int misc_sandbox_ioctl(struct udevice *dev, unsigned long request, void *buf)
diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 8a213c9e270..2520c6a38ed 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -65,7 +65,7 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
}
 
ret = misc_read(dev, 0, &fuses, sizeof(fuses));
-   if (ret) {
+   if (ret < 0) {
printf("%s: misc_read failed\n", __func__);
return 0;
}
diff --git a/drivers/misc/stm32mp_fuse.c b/drivers/misc/stm32mp_fuse.c
index 2d661351a17..33943a231b1 100644
--- a/drivers/misc/stm32mp_fuse.c
+++ b/drivers/misc/stm32mp_fuse.c
@@ -29,6 +29,9 @@ int fuse_read(u32 bank, u32 word, u32 *val)
return ret;
ret = misc_read(dev, word * 4 + STM32_BSEC_SHADOW_OFFSET,
val, 4);
+   if (ret < 0)
+   return ret;
+   ret = 0;
break;
 
default:
@@ -54,6 +57,9 @@ int fuse_prog(u32 bank, u32 word, u32 val)
return ret;
ret = misc_write(dev, word * 4 + STM32_BSEC_OTP_OFFSET,
 &val, 4);
+   if (ret < 0)
+   return ret;
+   ret = 0;
break;
 
default:
@@ -78,6 +84,9 @@ int fuse_sense(u32 bank, u32 word, u32 *val)
if (ret)
return ret;
ret = misc_read(dev, word * 4 + STM32_BSEC_OTP_OFFSET, val, 4);
+   if (ret < 0)
+   return ret;
+   ret = 0;
break;
 
default:
@@ -103,6 +112,9 @@ int fuse_override(u32 b

[U-Boot] [PATCH 18/25] tpm: Convert to use a device parameter

2018-11-06 Thread Simon Glass
At present many TPM calls assume there is only one TPM in the system and
look up this TPM themselves. This is inconsistent with driver model, which
expects all driver methods to have a device parameter. Update the code to
correct this.

Also move to u8/32 instead of uint8_t/uint32_t to keep checkpatch happy.

Signed-off-by: Simon Glass 
---

 board/gdsys/a38x/controlcenterdc.c|   8 +-
 board/gdsys/p1022/controlcenterd-id.c |  22 +-
 cmd/tpm-common.c  |   8 +-
 cmd/tpm-v1.c  | 122 +++--
 cmd/tpm-v2.c  |  78 +-
 cmd/tpm_test.c| 371 +-
 include/tpm-common.h  |  16 +-
 include/tpm-v1.h  |  97 ---
 include/tpm-v2.h  |  49 ++--
 lib/tpm-common.c  |  16 +-
 lib/tpm-utils.h   |   3 +-
 lib/tpm-v1.c  | 136 +-
 lib/tpm-v2.c  |  60 +++--
 13 files changed, 611 insertions(+), 375 deletions(-)

diff --git a/board/gdsys/a38x/controlcenterdc.c 
b/board/gdsys/a38x/controlcenterdc.c
index 824a08f12af..be69f877f03 100644
--- a/board/gdsys/a38x/controlcenterdc.c
+++ b/board/gdsys/a38x/controlcenterdc.c
@@ -266,11 +266,15 @@ int board_fix_fdt(void *rw_fdt_blob)
 
 int last_stage_init(void)
 {
+   struct udevice *tpm;
+   int ret;
+
 #ifndef CONFIG_SPL_BUILD
ccdc_eth_init();
 #endif
-   if (tpm_init() || tpm_startup(TPM_ST_CLEAR) ||
-   tpm_continue_self_test()) {
+   ret = get_tpm(&tpm);
+   if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
+   tpm_continue_self_test(tpm)) {
return 1;
}
 
diff --git a/board/gdsys/p1022/controlcenterd-id.c 
b/board/gdsys/p1022/controlcenterd-id.c
index 7e082dff052..814e4f401de 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -969,19 +969,25 @@ end:
 #ifdef CCDM_FIRST_STAGE
 static int first_stage_init(void)
 {
-   int res = 0;
+   struct udevice *tpm;
+   int ret;
+
puts("CCDM S1\n");
-   if (tpm_init() || tpm_startup(TPM_ST_CLEAR))
+#ifndef CONFIG_SPL_BUILD
+   ccdc_eth_init();
+#endif
+   ret = get_tpm(&tpm);
+   if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR))
return 1;
-   res = first_stage_actions();
+   ret = first_stage_actions();
 #ifndef CCDM_SECOND_STAGE
-   if (!res) {
+   if (!ret) {
if (bl2_entry)
(*bl2_entry)();
-   res = 1;
+   ret = 1;
}
 #endif
-   return res;
+   return ret;
 }
 #endif
 
@@ -1021,10 +1027,12 @@ static int second_stage_init(void)
char *mac_path = NULL;
ulong image_addr;
loff_t image_size;
+   struct udevice *tpm;
uint32_t err;
 
printf("CCDM S2\n");
-   if (tpm_init())
+   ret = get_tpm(&tpm);
+   if (ret || tpm_init(tpm))
return 1;
err = tpm_startup(TPM_ST_CLEAR);
if (err != TPM_INVALID_POSTINIT)
diff --git a/cmd/tpm-common.c b/cmd/tpm-common.c
index 56443862c22..89f2aa001ba 100644
--- a/cmd/tpm-common.c
+++ b/cmd/tpm-common.c
@@ -264,10 +264,16 @@ int do_tpm_info(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[])
 
 int do_tpm_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
+   struct udevice *dev;
+   int rc;
+
if (argc != 1)
return CMD_RET_USAGE;
+   rc = get_tpm(&dev);
+   if (rc)
+   return rc;
 
-   return report_return_code(tpm_init());
+   return report_return_code(tpm_init(dev));
 }
 
 int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index 69870002d4f..465f7400721 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -14,7 +14,12 @@ static int do_tpm_startup(cmd_tbl_t *cmdtp, int flag, int 
argc,
  char * const argv[])
 {
enum tpm_startup_type mode;
+   struct udevice *dev;
+   int rc;
 
+   rc = get_tpm(&dev);
+   if (rc)
+   return rc;
if (argc != 2)
return CMD_RET_USAGE;
if (!strcasecmp("TPM_ST_CLEAR", argv[1])) {
@@ -28,13 +33,19 @@ static int do_tpm_startup(cmd_tbl_t *cmdtp, int flag, int 
argc,
return CMD_RET_FAILURE;
}
 
-   return report_return_code(tpm_startup(mode));
+   return report_return_code(tpm_startup(dev, mode));
 }
 
 static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp, int flag, int argc,
  char * const argv[])
 {
u32 index, perm, size;
+   struct udevice *dev;
+   int rc;
+
+   rc = get_tpm(&dev);
+   if (rc)
+   return rc;
 
if (argc != 4)
return CMD_RET_USAGE;
@@ -42,22 +53,27 @@ static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp

[U-Boot] [PATCH 23/25] test: sf: Add a simple SPI flash test

2018-11-06 Thread Simon Glass
The current test is a functional test, covering all the way from the
command line to the sandbox SPI driver. This is useful, but it is easier
to diagnose failures with a smaller test.

Add a simple test which reads and writes data and checks that it is stored
and retrieved correctly.

Signed-off-by: Simon Glass 
---

 test/dm/sf.c | 46 --
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/test/dm/sf.c b/test/dm/sf.c
index 35241b9f574..b23e7f8edd4 100644
--- a/test/dm/sf.c
+++ b/test/dm/sf.c
@@ -6,6 +6,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -13,8 +15,48 @@
 #include 
 #include 
 
-/* Test that sandbox SPI flash works correctly */
+/* Simple test of sandbox SPI flash */
 static int dm_test_spi_flash(struct unit_test_state *uts)
+{
+   struct udevice *dev, *emul;
+   int full_size = 0x20;
+   int size = 0x1;
+   u8 *src, *dst;
+   int i;
+
+   src = map_sysmem(0x2, full_size);
+   ut_assertok(os_write_file("spi.bin", src, full_size));
+   ut_assertok(uclass_first_device_err(UCLASS_SPI_FLASH, &dev));
+
+   dst = map_sysmem(0x2 + full_size, full_size);
+   ut_assertok(spi_flash_read_dm(dev, 0, size, dst));
+   ut_assertok(memcmp(src, dst, size));
+
+   /* Erase */
+   ut_assertok(spi_flash_erase_dm(dev, 0, size));
+   ut_assertok(spi_flash_read_dm(dev, 0, size, dst));
+   for (i = 0; i < size; i++)
+   ut_asserteq(dst[i], 0xff);
+
+   /* Write some new data */
+   for (i = 0; i < size; i++)
+   src[i] = i;
+   ut_assertok(spi_flash_write_dm(dev, 0, size, src));
+   ut_assertok(spi_flash_read_dm(dev, 0, size, dst));
+   ut_assertok(memcmp(src, dst, size));
+
+   /*
+* Since we are about to destroy all devices, we must tell sandbox
+* to forget the emulation device
+*/
+   sandbox_sf_unbind_emul(state_get_current(), 0, 0);
+
+   return 0;
+}
+DM_TEST(dm_test_spi_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Functional test that sandbox SPI flash works correctly */
+static int dm_test_spi_flash_func(struct unit_test_state *uts)
 {
/*
 * Create an empty test file and run the SPI flash tests. This is a
@@ -39,4 +81,4 @@ static int dm_test_spi_flash(struct unit_test_state *uts)
 
return 0;
 }
-DM_TEST(dm_test_spi_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spi_flash_func, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 11/25] spl: Support bootstage, log, hash and early malloc in TPL

2018-11-06 Thread Simon Glass
At present these features are supported in SPL but not TPL. Update the
Kconfig and Makefile to allow this.

Also add a few Makefile comments to make earier to track what is going on.

Signed-off-by: Simon Glass 
---

 common/Kconfig  | 35 +++
 common/Makefile | 10 +++---
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index d7300c212f5..ba460d9150d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -27,6 +27,15 @@ config SPL_BOOTSTAGE
  information when SPL finishes and load it when U-Boot proper starts
  up.
 
+config TPL_BOOTSTAGE
+   bool "Boot timing and reported in TPL"
+   depends on BOOTSTAGE
+   help
+ Enable recording of boot time in SPL. To make this visible to U-Boot
+ proper, enable BOOTSTAGE_STASH as well. This will stash the timing
+ information when TPL finishes and load it when U-Boot proper starts
+ up.
+
 config BOOTSTAGE_REPORT
bool "Display a detailed boot timing report before booting the OS"
depends on BOOTSTAGE
@@ -444,6 +453,16 @@ config LOG
 
 config SPL_LOG
bool "Enable logging support in SPL"
+   depends on LOG
+   help
+ This enables support for logging of status and debug messages. These
+ can be displayed on the console, recorded in a memory buffer, or
+ discarded if not needed. Logging supports various categories and
+ levels of severity.
+
+config TPL_LOG
+   bool "Enable logging support in TPL"
+   depends on LOG
help
  This enables support for logging of status and debug messages. These
  can be displayed on the console, recorded in a memory buffer, or
@@ -660,6 +679,22 @@ config AVB_VERIFY
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
 
+config SPL_HASH
+   bool # "Support hashing API (SHA1, SHA256, etc.)"
+   help
+ This provides a way to hash data in memory using various supported
+ algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
+ and the algorithms it supports are defined in common/hash.c. See
+ also CMD_HASH for command-line access.
+
+config TPL_HASH
+   bool # "Support hashing API (SHA1, SHA256, etc.)"
+   help
+ This provides a way to hash data in memory using various supported
+ algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
+ and the algorithms it supports are defined in common/hash.c. See
+ also CMD_HASH for command-line access.
+
 endmenu
 
 menu "Update support"
diff --git a/common/Makefile b/common/Makefile
index 7473b850115..d933c8afec7 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -68,6 +68,7 @@ obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 endif
 obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
+obj-$(CONFIG_TPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
@@ -76,7 +77,8 @@ ifdef CONFIG_SPL_USB_HOST_SUPPORT
 obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o
 obj-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
-endif
+endif # CONFIG_SPL_BUILD
+
 #others
 obj-$(CONFIG_DDR_SPD) += ddr_spd.o
 obj-$(CONFIG_SPD_EEPROM) += ddr_spd.o
@@ -90,14 +92,16 @@ obj-$(CONFIG_SPL_SERIAL_SUPPORT) += console.o
 endif
 else
 obj-y += console.o
-endif
+endif # CONFIG_SPL_BUILD
+
 obj-$(CONFIG_CROS_EC) += cros_ec.o
 obj-y += dlmalloc.o
 ifdef CONFIG_SYS_MALLOC_F
-ifneq ($(CONFIG_$(SPL_)SYS_MALLOC_F_LEN),0)
+ifneq ($(CONFIG_$(SPL_TPL_)SYS_MALLOC_F_LEN),0)
 obj-y += malloc_simple.o
 endif
 endif
+
 obj-y += image.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 12/25] spl: Correct malloc debugging in board_init_r()

2018-11-06 Thread Simon Glass
SPL does not support %#x in printf() strings so we must write out the 0x
explicitly. Update the code for this.

Signed-off-by: Simon Glass 
---

 common/spl/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 292e659c9ac..c855bb7ca4a 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -554,7 +554,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
debug("Unsupported OS image.. Jumping nevertheless..\n");
}
 #if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
-   debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
+   debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr,
  gd->malloc_ptr / 1024);
 #endif
 #ifdef CONFIG_BOOTSTAGE_STASH
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 24/25] sf: Add a method to obtain the block-protect setting

2018-11-06 Thread Simon Glass
It is useful to obtain the block-protect setting of the SPI flash, so we
know whether it is fully open or (perhaps partially) write-protected. Add
a method for this. Update the sandbox driver to process this operation and
add a test.

Signed-off-by: Simon Glass 
---

 arch/sandbox/include/asm/test.h |  8 
 drivers/mtd/spi/sandbox.c   | 10 ++
 drivers/mtd/spi/sf-uclass.c |  9 +
 drivers/mtd/spi/sf_internal.h   |  3 +++
 drivers/mtd/spi/sf_probe.c  |  8 
 drivers/mtd/spi/spi_flash.c | 12 
 include/spi_flash.h | 27 +++
 test/dm/sf.c|  9 +
 8 files changed, 86 insertions(+)

diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 8e60f80ae7f..5e818392959 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -113,4 +113,12 @@ int sandbox_osd_get_mem(struct udevice *dev, u8 *buf, 
size_t buflen);
 int sandbox_pwm_get_config(struct udevice *dev, uint channel, uint *period_nsp,
   uint *duty_nsp, bool *enablep, bool *polarityp);
 
+/**
+ * sandbox_sf_set_block_protect() - Set the BP bits of the status register
+ *
+ * @dev: Device to update
+ * @bp_mask: BP bits to set (bits 2:0, so a value of 0 to 7)
+ */
+void sandbox_sf_set_block_protect(struct udevice *dev, int bp_mask);
+
 #endif
diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index 7fef754c634..7b9891cb981 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -57,6 +57,8 @@ static const char *sandbox_sf_state_name(enum 
sandbox_sf_state state)
 /* Bits for the status register */
 #define STAT_WIP   (1 << 0)
 #define STAT_WEL   (1 << 1)
+#define STAT_BP_SHIFT  2
+#define STAT_BP_MASK   (7 << STAT_BP_SHIFT)
 
 /* Assume all SPI flashes have 3 byte addresses since they do atm */
 #define SF_ADDR_LEN3
@@ -102,6 +104,14 @@ struct sandbox_spi_flash_plat_data {
int cs;
 };
 
+void sandbox_sf_set_block_protect(struct udevice *dev, int bp_mask)
+{
+   struct sandbox_spi_flash *sbsf = dev_get_priv(dev);
+
+   sbsf->status &= ~STAT_BP_MASK;
+   sbsf->status |= bp_mask << STAT_BP_SHIFT;
+}
+
 /**
  * This is a very strange probe function. If it has platform data (which may
  * have come from the device tree) then this function gets the filename and
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 662525f016f..719a2fd23ae 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -28,6 +28,15 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, 
size_t len)
return log_ret(sf_get_ops(dev)->erase(dev, offset, len));
 }
 
+int spl_flash_get_sw_write_prot(struct udevice *dev)
+{
+   struct dm_spi_flash_ops *ops = sf_get_ops(dev);
+
+   if (!ops->get_sw_write_prot)
+   return -ENOSYS;
+   return log_ret(ops->get_sw_write_prot(dev));
+}
+
 /*
  * TODO(s...@chromium.org): This is an old-style function. We should remove
  * it when all SPI flash drivers use dm
diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index 26f5c7c995e..46a50444175 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -170,6 +170,9 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 
*cmd, size_t cmd_len,
 /* Flash erase(sectors) operation, support all possible erase commands */
 int spi_flash_cmd_erase_ops(struct spi_flash *flash, u32 offset, size_t len);
 
+/* Get software write-protect value (BP bits) */
+int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash);
+
 /* Lock stmicro spi flash region */
 int stm_lock(struct spi_flash *flash, u32 ofs, size_t len);
 
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index 94fde2ae7a3..5a2e932de8f 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -124,6 +124,13 @@ static int spi_flash_std_erase(struct udevice *dev, u32 
offset, size_t len)
return spi_flash_cmd_erase_ops(flash, offset, len);
 }
 
+static int spi_flash_std_get_sw_write_prot(struct udevice *dev)
+{
+   struct spi_flash *flash = dev_get_uclass_priv(dev);
+
+   return spi_flash_cmd_get_sw_write_prot(flash);
+}
+
 static int spi_flash_std_probe(struct udevice *dev)
 {
struct spi_slave *slave = dev_get_parent_priv(dev);
@@ -141,6 +148,7 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = {
.read = spi_flash_std_read,
.write = spi_flash_std_write,
.erase = spi_flash_std_erase,
+   .get_sw_write_prot = spi_flash_std_get_sw_write_prot,
 };
 
 static const struct udevice_id spi_flash_std_ids[] = {
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index a87bacd4ac7..0c2392f28a4 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -110,6 +110,18 @@ static int write_cr(struct spi_flash *flash, u8 wc)
 }
 #endif
 
+int spi_flash_cmd_get

[U-Boot] [PATCH 17/25] tpm: Export the open/close functions

2018-11-06 Thread Simon Glass
At present these functions are not accessible outside the TPM library, but
in some cases we need to call them. Export them in the header file and add
a define for the SHA1 digest size.

Also adjust tpm_open() to call tpm_close() first so that the TPM is in a
known state before opening (e.g. by a previous phase of U-Boot).

Signed-off-by: Simon Glass 
---

 drivers/tpm/tpm_tis_lpc.c | 50 +++
 include/tpm-common.h  | 20 
 lib/tpm-utils.h   | 18 --
 3 files changed, 50 insertions(+), 38 deletions(-)

diff --git a/drivers/tpm/tpm_tis_lpc.c b/drivers/tpm/tpm_tis_lpc.c
index e993fd9f833..d76d7ca75af 100644
--- a/drivers/tpm/tpm_tis_lpc.c
+++ b/drivers/tpm/tpm_tis_lpc.c
@@ -388,6 +388,27 @@ static int tis_readresponse(struct udevice *dev, u8 
*buffer, size_t len)
return offset;
 }
 
+static int tpm_tis_lpc_close(struct udevice *dev)
+{
+   struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
+   struct tpm_locality *regs = priv->regs;
+   u8 locality = 0;
+
+   if (tpm_read_word(priv, ®s[locality].access) &
+   TIS_ACCESS_ACTIVE_LOCALITY) {
+   tpm_write_word(priv, TIS_ACCESS_ACTIVE_LOCALITY,
+  ®s[locality].access);
+
+   if (tis_wait_reg(priv, ®s[locality].access,
+TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) {
+   printf("%s:%d - failed to release locality %d\n",
+  __FILE__, __LINE__, locality);
+   return -ETIMEDOUT;
+   }
+   }
+   return 0;
+}
+
 static int tpm_tis_lpc_open(struct udevice *dev)
 {
struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
@@ -395,6 +416,12 @@ static int tpm_tis_lpc_open(struct udevice *dev)
u8 locality = 0; /* we use locality zero for everything. */
int ret;
 
+   ret = tpm_tis_lpc_close(dev);
+   if (ret) {
+   printf("%s: Failed to close TPM\n", __func__);
+   return ret;
+   }
+
/* now request access to locality. */
tpm_write_word(priv, TIS_ACCESS_REQUEST_USE, ®s[locality].access);
 
@@ -408,29 +435,12 @@ static int tpm_tis_lpc_open(struct udevice *dev)
return ret;
}
 
+   /* Certain TPMs need some delay here or they hang */
+   udelay(10);
+
tpm_write_word(priv, TIS_STS_COMMAND_READY,
   ®s[locality].tpm_status);
-   return 0;
-}
-
-static int tpm_tis_lpc_close(struct udevice *dev)
-{
-   struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
-   struct tpm_locality *regs = priv->regs;
-   u8 locality = 0;
-
-   if (tpm_read_word(priv, ®s[locality].access) &
-   TIS_ACCESS_ACTIVE_LOCALITY) {
-   tpm_write_word(priv, TIS_ACCESS_ACTIVE_LOCALITY,
-  ®s[locality].access);
 
-   if (tis_wait_reg(priv, ®s[locality].access,
-TIS_ACCESS_ACTIVE_LOCALITY, 0) == -ETIMEDOUT) {
-   printf("%s:%d - failed to release locality %d\n",
-  __FILE__, __LINE__, locality);
-   return -ETIMEDOUT;
-   }
-   }
return 0;
 }
 
diff --git a/include/tpm-common.h b/include/tpm-common.h
index 5f8bc6bc528..f8c5569003e 100644
--- a/include/tpm-common.h
+++ b/include/tpm-common.h
@@ -26,6 +26,8 @@ enum tpm_duration {
 /* Max buffer size supported by our tpm */
 #define TPM_DEV_BUFSIZE1260
 
+#define TPM_PCR_MINIMUM_DIGEST_SIZE 20
+
 /**
  * enum tpm_version - The version of the TPM stack to be used
  * @TPM_V1:Use TPM v1.x stack
@@ -179,6 +181,24 @@ int do_##cmd(cmd_tbl_t *cmdtp, int flag,   \
return report_return_code(cmd());   \
 }
 
+/**
+ * tpm_open() - Request access to locality 0 for the caller
+ *
+ * After all commands have been completed the caller is supposed to
+ * call tpm_close().
+ *
+ * Returns 0 on success, -ve on failure.
+ */
+int tpm_open(struct udevice *dev);
+
+/**
+ * tpm_close() - Close the current session
+ *
+ * Releasing the locked locality. Returns 0 on success, -ve 1 on
+ * failure (in case lock removal did not succeed).
+ */
+int tpm_close(struct udevice *dev);
+
 /**
  * tpm_get_desc() - Get a text description of the TPM
  *
diff --git a/lib/tpm-utils.h b/lib/tpm-utils.h
index a9cb7dc7ee5..ac95f262f56 100644
--- a/lib/tpm-utils.h
+++ b/lib/tpm-utils.h
@@ -18,24 +18,6 @@
 #define tpm_u16(x) __MSB(x), __LSB(x)
 #define tpm_u32(x) tpm_u16((x) >> 16), tpm_u16((x) & 0x)
 
-/**
- * tpm_open() - Request access to locality 0 for the caller
- *
- * After all commands have been completed the caller is supposed to
- * call tpm_close().
- *
- * Returns 0 on success, -ve on failure.
- */
-int tpm_open(struct udevice *dev);
-
-/**
- * tpm_close() - Close the current session
- *
- * Releasing the locked locality. Returns 0 on success

[U-Boot] [PATCH 19/25] video: Update video_set_default_colors() to support invert

2018-11-06 Thread Simon Glass
It is useful to be able to invert the colours in some cases so that the
text matches the background colour. Add a parameter to the function to
support this.

It is strange that function takes a private data structure from another
driver as an argument. It seems better to pass the device and have the
function internally work out how to find its required information.

Signed-off-by: Simon Glass 
---

 drivers/video/vidconsole-uclass.c |  2 +-
 drivers/video/video-uclass.c  | 27 +++
 include/video.h   |  5 +++--
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index 1874887f2f3..d7568bc79a5 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -344,7 +344,7 @@ static void vidconsole_escape_char(struct udevice *dev, 
char ch)
switch (val) {
case 0:
/* all attributes off */
-   video_set_default_colors(vid_priv);
+   video_set_default_colors(dev->parent, false);
break;
case 1:
/* bold */
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 44dfa71b6f4..b6551b69d3a 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -115,18 +115,29 @@ int video_clear(struct udevice *dev)
return 0;
 }
 
-void video_set_default_colors(struct video_priv *priv)
+void video_set_default_colors(struct udevice *dev, bool invert)
 {
+   struct video_priv *priv = dev_get_uclass_priv(dev);
+   int fore, back;
+
 #ifdef CONFIG_SYS_WHITE_ON_BLACK
/* White is used when switching to bold, use light gray here */
-   priv->fg_col_idx = VID_LIGHT_GRAY;
-   priv->colour_fg = vid_console_color(priv, VID_LIGHT_GRAY);
-   priv->colour_bg = vid_console_color(priv, VID_BLACK);
+   fore = VID_LIGHT_GRAY;
+   back = VID_BLACK;
 #else
-   priv->fg_col_idx = VID_BLACK;
-   priv->colour_fg = vid_console_color(priv, VID_BLACK);
-   priv->colour_bg = vid_console_color(priv, VID_WHITE);
+   fore = VID_BLACK;
+   back = VID_WHITE;
 #endif
+   if (invert) {
+   int temp;
+
+   temp = fore;
+   fore = back;
+   back = temp;
+   }
+   priv->fg_col_idx = fore;
+   priv->colour_fg = vid_console_color(priv, fore);
+   priv->colour_bg = vid_console_color(priv, back);
 }
 
 /* Flush video activity to the caches */
@@ -219,7 +230,7 @@ static int video_post_probe(struct udevice *dev)
priv->fb_size = priv->line_length * priv->ysize;
 
/* Set up colors  */
-   video_set_default_colors(priv);
+   video_set_default_colors(dev, false);
 
if (!CONFIG_IS_ENABLED(NO_FB_CLEAR))
video_clear(dev);
diff --git a/include/video.h b/include/video.h
index 75200f0e452..3f9139eea44 100644
--- a/include/video.h
+++ b/include/video.h
@@ -191,9 +191,10 @@ void video_set_flush_dcache(struct udevice *dev, bool 
flush);
 /**
  * Set default colors and attributes
  *
- * @priv   device information
+ * @dev:   video device
+ * @invert true to invert colours
  */
-void video_set_default_colors(struct video_priv *priv);
+void video_set_default_colors(struct udevice *dev, bool invert);
 
 #endif /* CONFIG_DM_VIDEO */
 
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 20/25] efi_loader: Don't enable in SPL/TPL by default

2018-11-06 Thread Simon Glass
Generally this functionality is not useful in SPL or TPL. Update the
Makefile so that it is not built.

Signed-off-by: Simon Glass 
---

 lib/Makefile | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index 4d2e22027d0..4dba3628e78 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -5,10 +5,10 @@
 
 ifndef CONFIG_SPL_BUILD
 
-obj-$(CONFIG_EFI) += efi/
-obj-$(CONFIG_EFI_LOADER) += efi_driver/
-obj-$(CONFIG_EFI_LOADER) += efi_loader/
-obj-$(CONFIG_EFI_LOADER) += efi_selftest/
+obj-$(CONFIG_$(SPL_TPL_)EFI) += efi/
+obj-$(CONFIG_$(SPL_TPL_)EFI_LOADER) += efi_driver/
+obj-$(CONFIG_$(SPL_TPL_)EFI_LOADER) += efi_loader/
+obj-$(CONFIG_$(SPL_TPL_)EFI_LOADER) += efi_selftest/
 obj-$(CONFIG_LZMA) += lzma/
 obj-$(CONFIG_BZIP2) += bzip2/
 obj-$(CONFIG_TIZEN) += tizen/
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 13/25] spl: lz4: Allow use of lz4 compression in SPL

2018-11-06 Thread Simon Glass
In some cases U-Boot is compressed and it is useful to be able to
decompress it in SPL. Add a Kconfig and Makefile change to allow this.
Note that this does not actually implement decompression.

Signed-off-by: Simon Glass 
---

 lib/Kconfig  | 8 
 lib/Makefile | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index 847e797a3a4..0333ab172fa 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -301,6 +301,14 @@ config LZO
help
  This enables support for LZO compression algorithm.r
 
+config SPL_LZ4
+   bool "Enable LZ4 decompression support in SPL"
+   help
+ This enables support for tge LZ4 decompression algorithm in SPL. LZ4
+ is a lossless data compression algorithm that is focused on
+ fast compression and decompression speed. It belongs to the LZ77
+ family of byte-oriented compression schemes.
+
 config SPL_LZO
bool "Enable LZO decompression support in SPL"
help
diff --git a/lib/Makefile b/lib/Makefile
index fb6944128aa..4d2e22027d0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -38,7 +38,6 @@ obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
 obj-y += initcall.o
 obj-$(CONFIG_LMB) += lmb.o
 obj-y += ldiv.o
-obj-$(CONFIG_LZ4) += lz4_wrapper.o
 obj-$(CONFIG_MD5) += md5.o
 obj-y += net_utils.o
 obj-$(CONFIG_PHYSMEM) += physmem.o
@@ -64,6 +63,7 @@ obj-$(CONFIG_SHA256) += sha256.o
 obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
 obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
 obj-$(CONFIG_$(SPL_)LZO) += lzo/
+obj-$(CONFIG_$(SPL_)LZ4) += lz4_wrapper.o
 
 obj-$(CONFIG_LIBAVB) += libavb/
 
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 16/25] binman: Set the pathname correctly for ELF files

2018-11-06 Thread Simon Glass
At present, stripped files don't have the right pathname which means that
blob compression cannot be used. Fix this.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/u_boot_elf.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/binman/etype/u_boot_elf.py b/tools/binman/etype/u_boot_elf.py
index 134b6cc15b4..f83860dc0a8 100644
--- a/tools/binman/etype/u_boot_elf.py
+++ b/tools/binman/etype/u_boot_elf.py
@@ -30,9 +30,8 @@ class Entry_u_boot_elf(Entry_blob):
 out_fname = tools.GetOutputFilename('%s.stripped' % uniq)
 tools.WriteFile(out_fname, tools.ReadFile(self._pathname))
 tools.Run('strip', out_fname)
-self.SetContents(tools.ReadFile(out_fname))
-else:
-self.SetContents(tools.ReadFile(self._pathname))
+self._pathname = out_fname
+Entry_blob.ReadBlobContents(self)
 return True
 
 def GetDefaultFilename(self):
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 09/25] sandbox: cros_ec: exynos: Drop use of cros_ec_get_error()

2018-11-06 Thread Simon Glass
This function is really just a call to uclass_get_device() and there is no
reason why the caller cannot do it. Update sandbox and snow accordingly.

Signed-off-by: Simon Glass 
---

 board/samsung/common/board.c | 10 ++
 board/sandbox/sandbox.c  |  9 ++---
 common/cros_ec.c | 12 
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index c4b6baedf04..fc2a219e384 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -306,14 +306,16 @@ int checkboard(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-   stdio_print_current_devices();
+   struct udevice *dev;
+   int ret;
 
-   if (cros_ec_get_error()) {
+   stdio_print_current_devices();
+   ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+   if (ret) {
/* Force console on */
gd->flags &= ~GD_FLG_SILENT;
 
-   printf("cros-ec communications failure %d\n",
-  cros_ec_get_error());
+   printf("cros-ec communications failure %d\n", ret);
puts("\nPlease reset with Power+Refresh\n\n");
panic("Cannot init cros-ec device");
return -1;
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 0e87674826a..56b1005e374 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -59,12 +59,15 @@ int board_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-   if (cros_ec_get_error()) {
+   struct udevice *dev;
+   int ret;
+
+   ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+   if (ret) {
/* Force console on */
gd->flags &= ~GD_FLG_SILENT;
 
-   printf("cros-ec communications failure %d\n",
-  cros_ec_get_error());
+   printf("cros-ec communications failure %d\n", ret);
puts("\nPlease reset with Power+Refresh\n\n");
panic("Cannot init cros-ec device");
return -1;
diff --git a/common/cros_ec.c b/common/cros_ec.c
index 4ca15e19d5f..e66471ebd1b 100644
--- a/common/cros_ec.c
+++ b/common/cros_ec.c
@@ -25,15 +25,3 @@ struct udevice *board_get_cros_ec_dev(void)
}
return dev;
 }
-
-int cros_ec_get_error(void)
-{
-   struct udevice *dev;
-   int ret;
-
-   ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
-   if (ret && ret != -ENODEV)
-   return ret;
-
-   return 0;
-}
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 21/25] string: Include the config header

2018-11-06 Thread Simon Glass
At present the config header is not included in this file, but it does use
a CONFIG option. Fix it.

Signed-off-by: Simon Glass 
---

 lib/string.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/string.c b/lib/string.c
index c4ca944bb42..af17c16f616 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -15,6 +15,7 @@
  *reentrant and should be faster). Use only strsep() in new code, please.
  */
 
+#include 
 #include 
 #include 
 #include 
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 15/25] binman: Drop an unnecessary comma in blob handling

2018-11-06 Thread Simon Glass
This comma is not needed. Drop it.

Signed-off-by: Simon Glass 
---

 tools/binman/etype/blob.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index 642a0e482a7..ae80bbee530 100644
--- a/tools/binman/etype/blob.py
+++ b/tools/binman/etype/blob.py
@@ -60,7 +60,7 @@ class Entry_blob(Entry):
 except AttributeError:
 data = lz4.compress(data)
 '''
-data = tools.Run('lz4', '-c', self._pathname, )
+data = tools.Run('lz4', '-c', self._pathname)
 self.SetContents(data)
 return True
 
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 10/25] sandbox: Update some drivers to work in SPL/TPL

2018-11-06 Thread Simon Glass
At present sandbox drivers are mostly not used before relocation. Some of
these are needed by Chromium OS verified boot, since it uses sandbox TPL,
so update them accordingly.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/sandbox.dts | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index fb866e88079..1cda911d1f0 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -20,6 +20,7 @@
 
cros_ec: cros-ec {
reg = <0 0>;
+   u-boot,dm-pre-reloc;
compatible = "google,cros-ec-sandbox";
 
/*
@@ -27,6 +28,7 @@
 * that the STM32L flash erases to 0, not 0xff.
 */
flash {
+   u-boot,dm-pre-reloc;
image-pos = <0x0800>;
size = <0x2>;
erase-value = <0>;
@@ -59,6 +61,7 @@
};
 
gpio_a: gpios@0 {
+   u-boot,dm-pre-reloc;
gpio-controller;
compatible = "sandbox,gpio";
#gpio-cells = <1>;
@@ -67,6 +70,7 @@
};
 
gpio_b: gpios@1 {
+   u-boot,dm-pre-reloc;
gpio-controller;
compatible = "sandbox,gpio";
#gpio-cells = <2>;
@@ -178,12 +182,14 @@
};
 
spi@0 {
+   u-boot,dm-pre-reloc;
#address-cells = <1>;
#size-cells = <0>;
reg = <0 0>;
compatible = "sandbox,spi";
cs-gpios = <0>, <&gpio_a 0>;
firmware_storage_spi: flash@0 {
+   u-boot,dm-pre-reloc;
reg = <0>;
compatible = "spansion,m25p16", "sandbox,spi-flash";
spi-max-frequency = <4000>;
@@ -239,6 +245,7 @@
};
 
tpm {
+   u-boot,dm-pre-reloc;
compatible = "google,sandbox-tpm";
};
 
@@ -256,6 +263,7 @@
 
/* Needs to be available prior to relocation */
uart0: serial {
+   u-boot,dm-spl;
compatible = "sandbox,serial";
sandbox,text-colour = "cyan";
pinctrl-names = "default";
@@ -350,3 +358,10 @@
 
 #include "cros-ec-keyboard.dtsi"
 #include "sandbox_pmic.dtsi"
+
+&cros_ec {
+   u-boot,dm-pre-reloc;
+   keyboard-controller {
+   u-boot,dm-pre-reloc;
+   };
+};
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 08/25] sandbox: Add a function to read a host file

2018-11-06 Thread Simon Glass
Add a way to read a file from the host filesystem. This can be useful for
reading test data, for example. Also fix up the writing function which was
not the right version, and drop the debugging lines.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/os.c | 44 ---
 include/os.h  | 14 ++
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 325ded51d8a..3e0f4c30afe 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -98,9 +98,8 @@ void os_exit(int exit_code)
exit(exit_code);
 }
 
-int os_write_file(const char *name, const void *buf, int size)
+int os_write_file(const char *fname, const void *buf, int size)
 {
-   char fname[256];
int fd;
 
fd = os_open(fname, OS_O_WRONLY | OS_O_CREAT | OS_O_TRUNC);
@@ -110,14 +109,53 @@ int os_write_file(const char *name, const void *buf, int 
size)
}
if (os_write(fd, buf, size) != size) {
printf("Cannot write to file '%s'\n", fname);
+   os_close(fd);
return -EIO;
}
os_close(fd);
-   printf("Write '%s', size %#x (%d)\n", name, size, size);
 
return 0;
 }
 
+int os_read_file(const char *fname, void **bufp, int *sizep)
+{
+   off_t size;
+   int ret = -EIO;
+   int fd;
+
+   fd = os_open(fname, OS_O_RDONLY);
+   if (fd < 0) {
+   printf("Cannot open file '%s'\n", fname);
+   goto err;
+   }
+   size = os_lseek(fd, 0, OS_SEEK_END);
+   if (size < 0) {
+   printf("Cannot seek to end of file '%s'\n", fname);
+   goto err;
+   }
+   if (os_lseek(fd, 0, OS_SEEK_SET) < 0) {
+   printf("Cannot seek to start of file '%s'\n", fname);
+   goto err;
+   }
+   *bufp = os_malloc(size);
+   if (!*bufp) {
+   printf("Not enough memory to read file '%s'\n", fname);
+   ret = -ENOMEM;
+   goto err;
+   }
+   if (os_read(fd, *bufp, size) != size) {
+   printf("Cannot read from file '%s'\n", fname);
+   goto err;
+   }
+   os_close(fd);
+   *sizep = size;
+
+   return 0;
+err:
+   os_close(fd);
+   return ret;
+}
+
 /* Restore tty state when we exit */
 static struct termios orig_term;
 static bool term_setup;
diff --git a/include/os.h b/include/os.h
index 28eb6252849..6f33b08cf0b 100644
--- a/include/os.h
+++ b/include/os.h
@@ -350,4 +350,18 @@ int os_mprotect_allow(void *start, size_t len);
  */
 int os_write_file(const char *name, const void *buf, int size);
 
+/**
+ * os_read_file() - Read a file from the host filesystem
+ *
+ * This can be useful when reading test data into sandbox for use by test
+ * routines. The data is allocated using os_malloc() and should be freed by
+ * the caller.
+ *
+ * @name:  File path to read from
+ * @bufp:  Returns buffer containing data read
+ * @sizep: Returns size of data
+ * @return 0 if OK, -ve on error
+ */
+int os_read_file(const char *name, void **bufp, int *sizep);
+
 #endif
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 07/25] sandbox: log: Add a category for sandbox

2018-11-06 Thread Simon Glass
It seems useful to make sandbox its own log category since it is used for
so much testing. Add this as a new category.

Signed-off-by: Simon Glass 
---

 include/log.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/log.h b/include/log.h
index a872fc6ef5f..deab82966bd 100644
--- a/include/log.h
+++ b/include/log.h
@@ -47,6 +47,7 @@ enum log_category_t {
LOGC_DT,/* Device-tree */
LOGC_EFI,   /* EFI implementation */
LOGC_ALLOC, /* Memory allocation */
+   LOGC_SANDBOX,   /* Related to the sandbox board */
 
LOGC_COUNT, /* Number of log categories */
LOGC_END,   /* Sentinel value for a list of log categories */
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 06/25] sandbox: tpm: Allow debugging of data packages

2018-11-06 Thread Simon Glass
This is not normally useful, so change the code to avoid writing out every
data package. This can be enabled with #define DEBUG.

Signed-off-by: Simon Glass 
---

 drivers/tpm/tpm_tis_sandbox.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c
index 79517f015af..3336f559e57 100644
--- a/drivers/tpm/tpm_tis_sandbox.c
+++ b/drivers/tpm/tpm_tis_sandbox.c
@@ -187,9 +187,11 @@ static int sandbox_tpm_xfer(struct udevice *dev, const 
uint8_t *sendbuf,
 
code = get_unaligned_be32(sendbuf + sizeof(uint16_t) +
  sizeof(uint32_t));
+#ifdef DEBUG
printf("tpm: %zd bytes, recv_len %zd, cmd = %x\n", send_size,
   *recv_len, code);
print_buffer(0, sendbuf, 1, send_size, 0);
+#endif
switch (code) {
case TPM_CMD_GET_CAPABILITY:
type = get_unaligned_be32(sendbuf + 14);
@@ -306,6 +308,10 @@ static int sandbox_tpm_xfer(struct udevice *dev, const 
uint8_t *sendbuf,
printf("Unknown tpm command %02x\n", code);
return -ENOSYS;
}
+#ifdef DEBUG
+   printf("tpm: rx recv_len %zd\n", *recv_len);
+   print_buffer(0, recvbuf, 1, *recv_len, 0);
+#endif
 
return 0;
 }
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 03/25] cros_ec: Fail if we cannot determine the flash burst size

2018-11-06 Thread Simon Glass
This value is required for flashing to work correctly. Add a check for
it.

Signed-off-by: Simon Glass 
---

 drivers/misc/cros_ec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index e0f3dfc98e0..7daf16499aa 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -827,6 +827,9 @@ int cros_ec_flash_write(struct udevice *dev, const uint8_t 
*data,
uint32_t end, off;
int ret;
 
+   if (!burst)
+   return -EINVAL;
+
/*
 * TODO: round up to the nearest multiple of write size.  Can get away
 * without that on link right now because its write size is 4 bytes.
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 05/25] cros_ec: Add new features for events and power

2018-11-06 Thread Simon Glass
This adds new commands to the EC related to setting and clearing events
as well as controlling power-related settings.

Signed-off-by: Simon Glass 
---

 drivers/misc/cros_ec.c | 345 -
 drivers/misc/cros_ec_sandbox.c |   2 +-
 include/cros_ec.h  |  89 +
 3 files changed, 429 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 828e50eb1cc..2dcdb3d8d61 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -43,6 +43,54 @@ enum {
CROS_EC_CMD_HASH_TIMEOUT_MS = 2000,
 };
 
+#define INVALID_HCMD 0xFF
+
+/*
+ * Map UHEPI masks to non UHEPI commands in order to support old EC FW
+ * which does not support UHEPI command.
+ */
+static const struct {
+   u8 set_cmd;
+   u8 clear_cmd;
+   u8 get_cmd;
+} event_map[] = {
+   [EC_HOST_EVENT_MAIN] = {
+   INVALID_HCMD, EC_CMD_HOST_EVENT_CLEAR,
+   INVALID_HCMD,
+   },
+   [EC_HOST_EVENT_B] = {
+   INVALID_HCMD, EC_CMD_HOST_EVENT_CLEAR_B,
+   EC_CMD_HOST_EVENT_GET_B,
+   },
+   [EC_HOST_EVENT_SCI_MASK] = {
+   EC_CMD_HOST_EVENT_SET_SCI_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_SCI_MASK,
+   },
+   [EC_HOST_EVENT_SMI_MASK] = {
+   EC_CMD_HOST_EVENT_SET_SMI_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_SMI_MASK,
+   },
+   [EC_HOST_EVENT_ALWAYS_REPORT_MASK] = {
+   INVALID_HCMD, INVALID_HCMD, INVALID_HCMD,
+   },
+   [EC_HOST_EVENT_ACTIVE_WAKE_MASK] = {
+   EC_CMD_HOST_EVENT_SET_WAKE_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_WAKE_MASK,
+   },
+   [EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX] = {
+   EC_CMD_HOST_EVENT_SET_WAKE_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_WAKE_MASK,
+   },
+   [EC_HOST_EVENT_LAZY_WAKE_MASK_S3] = {
+   EC_CMD_HOST_EVENT_SET_WAKE_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_WAKE_MASK,
+   },
+   [EC_HOST_EVENT_LAZY_WAKE_MASK_S5] = {
+   EC_CMD_HOST_EVENT_SET_WAKE_MASK, INVALID_HCMD,
+   EC_CMD_HOST_EVENT_GET_WAKE_MASK,
+   },
+};
+
 void cros_ec_dump_data(const char *name, int cmd, const uint8_t *data, int len)
 {
 #ifdef DEBUG
@@ -570,6 +618,36 @@ int cros_ec_info(struct udevice *dev, struct 
ec_response_mkbp_info *info)
return 0;
 }
 
+int cros_ec_get_event_mask(struct udevice *dev, uint type, uint32_t *mask)
+{
+   struct ec_response_host_event_mask rsp;
+   int ret;
+
+   ret = ec_command(dev, type, 0, NULL, 0, &rsp, sizeof(rsp));
+   if (ret < 0)
+   return ret;
+   else if (ret != sizeof(rsp))
+   return -EINVAL;
+
+   *mask = rsp.mask;
+
+   return 0;
+}
+
+int cros_ec_set_event_mask(struct udevice *dev, uint type, uint32_t mask)
+{
+   struct ec_params_host_event_mask req;
+   int ret;
+
+   req.mask = mask;
+
+   ret = ec_command(dev, type, 0, &req, sizeof(req), NULL, 0);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
 int cros_ec_get_host_events(struct udevice *dev, uint32_t *events_ptr)
 {
struct ec_response_host_event_mask *resp;
@@ -623,6 +701,17 @@ int cros_ec_flash_protect(struct udevice *dev, uint32_t 
set_mask,
return 0;
 }
 
+int cros_ec_entering_mode(struct udevice *dev, int mode)
+{
+   int rc;
+
+   rc = ec_command(dev, EC_CMD_ENTERING_MODE, 0, &mode, sizeof(mode),
+   NULL, 0);
+   if (rc)
+   return -1;
+   return 0;
+}
+
 static int cros_ec_check_version(struct udevice *dev)
 {
struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
@@ -852,6 +941,35 @@ int cros_ec_flash_write(struct udevice *dev, const uint8_t 
*data,
return 0;
 }
 
+/**
+ * Run verification on a slot
+ *
+ * @param me CrosEc instance
+ * @param region Region to run verification on
+ * @return 0 if success or not applicable. Non-zero if verification failed.
+ */
+int cros_ec_efs_verify(struct udevice *dev, enum ec_flash_region region)
+{
+   struct ec_params_efs_verify p;
+   int rv;
+
+   log_info("EFS: EC is verifying updated image...\n");
+   p.region = region;
+
+   rv = ec_command(dev, EC_CMD_EFS_VERIFY, 0, &p, sizeof(p), NULL, 0);
+   if (rv >= 0) {
+   log_info("EFS: Verification success\n");
+   return 0;
+   }
+   if (rv == -EC_RES_INVALID_COMMAND) {
+   log_info("EFS: EC doesn't support EFS_VERIFY command\n");
+   return 0;
+   }
+   log_info("EFS: Verification failed\n");
+
+   return rv;
+}
+
 /**
  * Read a single block from the flash
  *
@@ -942,15 +1060,17 @@ int cros_ec_read_nvdata(struct udevice *dev, uint8_t 
*block, int size)
struct ec_params_vbnvcontext p;
int len;
 
-   if (size != EC_VBNV_BLOCK_SIZE)
+   if (size != EC_VBNV_BLOCK_S

[U-Boot] [PATCH 14/25] binman: Add a way to enable debugging from the build

2018-11-06 Thread Simon Glass
When the build fails due to something wrong in binman it is sometimes
useful to get a full backtrace showing the location of the failure. Add
a BINMAN_DEBUG environment variable to support this along with some
documentation.

Signed-off-by: Simon Glass 
---

 Makefile| 6 --
 tools/binman/README | 6 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 250eb6c3c39..c7df436a161 100644
--- a/Makefile
+++ b/Makefile
@@ -1048,9 +1048,11 @@ u-boot.ldr:  u-boot
 
 # binman
 # ---
+# Use 'make BINMAN_DEBUG=1' to enable debugging
 quiet_cmd_binman = BINMAN  $@
-cmd_binman = $(srctree)/tools/binman/binman -d u-boot.dtb -O . \
-   -I . -I $(srctree)/board/$(BOARDDIR) $<
+cmd_binman = $(srctree)/tools/binman/binman -u -d u-boot.dtb -O . -m \
+   -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \
+   $(if $(BINMAN_DEBUG),-D) $(BINMAN_$(@F)) $<
 
 OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
 
diff --git a/tools/binman/README b/tools/binman/README
index b64dedf2ebc..04ed2b799c8 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -723,6 +723,12 @@ If you need to specify a particular device-tree compiler 
to use, you can define
 the DTC environment variable. This can be useful when the system dtc is too
 old.
 
+To enable a full backtrace and other debugging features in binman, pass
+BINMAN_DEBUG=1 to your build:
+
+   make sandbox_defconfig
+   make BINMAN_DEBUG=1
+
 
 History / Credits
 -
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 04/25] cros_ec: Align uclass data to a cache boundary

2018-11-06 Thread Simon Glass
The LPC driver expects its buffer to be word-aligned. Add the required
flag to the uclass driver to ensure this.

Signed-off-by: Simon Glass 
---

 drivers/misc/cros_ec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 7daf16499aa..828e50eb1cc 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -1152,4 +1152,5 @@ UCLASS_DRIVER(cros_ec) = {
.name   = "cros_ec",
.per_device_auto_alloc_size = sizeof(struct cros_ec_dev),
.post_bind  = dm_scan_fdt_dev,
+   .flags  = DM_UC_FLAG_ALLOC_PRIV_DMA,
 };
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 01/25] cros_ec: Use uint instead of u8 for parameters

2018-11-06 Thread Simon Glass
There is no advantage to using a u8 for function parameters. It forces
the compiler to mask values and can increase code size. Also the command
enum has been extended to 16 bits. Update the functions to use uint
instead.

Signed-off-by: Simon Glass 
---

 drivers/misc/cros_ec.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 190505c11c7..4013f50d592 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -227,7 +227,7 @@ static int send_command_proto3(struct cros_ec_dev *cdev,
return handle_proto3_response(cdev, dinp, din_len);
 }
 
-static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
+static int send_command(struct cros_ec_dev *dev, uint cmd, int cmd_version,
const void *dout, int dout_len,
uint8_t **dinp, int din_len)
 {
@@ -330,7 +330,7 @@ static int ec_command_inptr(struct udevice *dev, uint8_t 
cmd,
  * @param din_len   Maximum size of response in bytes
  * @return number of bytes in response, or -ve on error
  */
-static int ec_command(struct udevice *dev, uint8_t cmd, int cmd_version,
+static int ec_command(struct udevice *dev, uint cmd, int cmd_version,
  const void *dout, int dout_len,
  void *din, int din_len)
 {
@@ -650,16 +650,14 @@ static int cros_ec_check_version(struct udevice *dev)
cdev->protocol_version = 3;
req.in_data = 0;
if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
-(uint8_t **)&resp, sizeof(*resp)) > 0) {
+(uint8_t **)&resp, sizeof(*resp)) > 0)
return 0;
-   }
 
/* Try sending a version 2 packet */
cdev->protocol_version = 2;
if (ec_command_inptr(dev, EC_CMD_HELLO, 0, &req, sizeof(req),
-(uint8_t **)&resp, sizeof(*resp)) > 0) {
+(uint8_t **)&resp, sizeof(*resp)) > 0)
return 0;
-   }
 
/*
 * Fail if we're still here, since the EC doesn't understand any
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] [PATCH 02/25] cros_ec: Add error logging on a few commands

2018-11-06 Thread Simon Glass
Add some more logging to provide more information on failures.

Signed-off-by: Simon Glass 
---

 drivers/misc/cros_ec.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 4013f50d592..e0f3dfc98e0 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -13,6 +13,8 @@
  * is not reset.
  */
 
+#define LOG_CATEGORY UCLASS_CROS_EC
+
 #include 
 #include 
 #include 
@@ -365,10 +367,14 @@ int cros_ec_scan_keyboard(struct udevice *dev, struct 
mbkp_keyscan *scan)
 int cros_ec_read_id(struct udevice *dev, char *id, int maxlen)
 {
struct ec_response_get_version *r;
+   int ret;
 
-   if (ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
-   (uint8_t **)&r, sizeof(*r)) != sizeof(*r))
+   ret = ec_command_inptr(dev, EC_CMD_GET_VERSION, 0, NULL, 0,
+  (uint8_t **)&r, sizeof(*r));
+   if (ret != sizeof(*r)) {
+   log_err("Got rc %d, expected %d\n", ret, sizeof(*r));
return -1;
+   }
 
if (maxlen > (int)sizeof(r->version_string_ro))
maxlen = sizeof(r->version_string_ro);
@@ -381,6 +387,7 @@ int cros_ec_read_id(struct udevice *dev, char *id, int 
maxlen)
memcpy(id, r->version_string_rw, maxlen);
break;
default:
+   log_err("Invalid EC image %d\n", r->current_image);
return -1;
}
 
-- 
2.19.1.930.g4563a0d9d0-goog

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


[U-Boot] Please pull u-boot-dm

2018-11-06 Thread Simon Glass
Hi Tom,

The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:

  Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21
-0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/pull-6-nov-18

for you to fetch changes up to 9413033c3d5d2bc44eefd1919c60522598cc1bd6:

  cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes (2018-11-06
13:56:18 -0700)


dm: DM_FLAG_PRE_RELOC fixes for release
sandbox CPU fixes for release


Bin Meng (15):
  arm: stm32mp: Remove DM_FLAG_PRE_RELOC flag
  clk: Remove DM_FLAG_PRE_RELOC flag in various drivers
  gpio: Remove DM_FLAG_PRE_RELOC flag in various drivers
  i2c: omap24xx: Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check
  mmc: omap: Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check
  pinctrl: Remove DM_FLAG_PRE_RELOC flag in various drivers
  ram: bmips: Remove DM_FLAG_PRE_RELOC flag
  timer: Remove DM_FLAG_PRE_RELOC flag in various drivers
  serial: Remove DM_FLAG_PRE_RELOC flag in various drivers
  sysreset: Remove DM_FLAG_PRE_RELOC flag in various drivers
  video: simplefb: Remove DM_FLAG_PRE_RELOC flag
  watchdog: Remove DM_FLAG_PRE_RELOC flag in various drivers
  dm: doc: Update description of pre-relocation support
  cpu: Add DM_FLAG_PRE_RELOC flag to various cpu drivers
  cpu: sandbox: Add "u-boot, dm-pre-reloc" for all cpu nodes

 arch/arm/mach-stm32mp/bsec.c |  1 -
 arch/sandbox/dts/test.dts|  3 +++
 arch/x86/cpu/baytrail/cpu.c  |  1 +
 arch/x86/cpu/broadwell/cpu.c |  1 +
 arch/x86/cpu/cpu_x86.c   |  1 +
 arch/x86/cpu/ivybridge/model_206ax.c |  1 +
 arch/x86/cpu/tangier/sysreset.c  |  1 -
 doc/driver-model/README.txt  | 16 
 drivers/clk/altera/clk-arria10.c |  1 -
 drivers/clk/clk_pic32.c  |  1 -
 drivers/clk/clk_zynq.c   |  1 -
 drivers/clk/exynos/clk-exynos7420.c  |  3 ---
 drivers/clk/owl/clk_s900.c   |  1 -
 drivers/gpio/omap_gpio.c |  2 ++
 drivers/gpio/stm32f7_gpio.c  |  2 +-
 drivers/gpio/tegra186_gpio.c |  1 -
 drivers/gpio/tegra_gpio.c|  1 -
 drivers/i2c/omap24xx_i2c.c   |  2 ++
 drivers/mmc/omap_hsmmc.c |  2 ++
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c   |  2 ++
 drivers/pinctrl/exynos/pinctrl-exynos7420.c  |  1 -
 drivers/pinctrl/nxp/pinctrl-imx5.c   |  2 ++
 drivers/pinctrl/nxp/pinctrl-imx6.c   |  2 ++
 drivers/pinctrl/nxp/pinctrl-imx7.c   |  2 ++
 drivers/pinctrl/nxp/pinctrl-imx7ulp.c|  2 ++
 drivers/pinctrl/pinctrl-single.c |  1 -
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro4.c |  2 ++
 drivers/pinctrl/uniphier/pinctrl-uniphier-pro5.c |  2 ++
 drivers/ram/bmips_ram.c  |  1 -
 drivers/serial/altera_jtag_uart.c|  1 -
 drivers/serial/altera_uart.c |  1 -
 drivers/serial/arm_dcc.c |  1 -
 drivers/serial/atmel_usart.c |  2 ++
 drivers/serial/ns16550.c |  2 ++
 drivers/serial/serial_ar933x.c   |  1 -
 drivers/serial/serial_arc.c  |  1 -
 drivers/serial/serial_bcm283x_mu.c   |  2 ++
 drivers/serial/serial_bcm283x_pl011.c|  2 ++
 drivers/serial/serial_bcm6345.c  |  1 -
 drivers/serial/serial_efi.c  |  1 -
 drivers/serial/serial_intel_mid.c|  1 -
 drivers/serial/serial_lpuart.c   |  1 -
 drivers/serial/serial_meson.c|  1 -
 drivers/serial/serial_mvebu_a3700.c  |  1 -
 drivers/serial/serial_mxc.c  |  2 ++
 drivers/serial/serial_omap.c |  2 ++
 drivers/serial/serial_owl.c  |  1 -
 drivers/serial/serial_pic32.c|  1 -
 drivers/serial/serial_pl01x.c|  2 ++
 drivers/serial/serial_s5p.c  |  1 -
 drivers/serial/serial_sh.c   |  2 ++
 drivers/serial/serial_sti_asc.c  |  1 -
 drivers/serial/serial_stm32.c|  2 ++
 drivers/serial/serial_xuartlite.c|  1 -
 drivers/serial/serial_zynq.c |  1 -
 drivers/sysreset/sysreset_x86.c  |  1 -
 drivers/timer/ag101p_timer.c |  1 -
 drivers/timer/altera_timer.c |  1 -
 drivers/timer/arc_timer.c|  1 -
 drivers/timer/ast_timer.c 

Re: [U-Boot] Pull request: u-boot-net.git master

2018-11-06 Thread Joe Hershberger
On Mon, Nov 5, 2018 at 10:06 PM Tom Rini  wrote:
>
> On Mon, Nov 05, 2018 at 11:51:41AM -0600, Joe Hershberger wrote:
>
> > Hi Tom,
> >
> > Built successfully on Travis: 
> > https://travis-ci.org/jhershbe/u-boot/builds/450020193
> >
> > The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:
> >
> >   Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21 
> > -0500)
> >
> > are available in the git repository at:
> >
> >
> >   git://git.denx.de/u-boot-net.git master
> >
> > for you to fetch changes up to 79d8127168e211f4745bd2183a3338c6c4e2d003:
> >
> >   driver: net: ti: keystone_net: switch to use common mdio lib (2018-11-05 
> > 10:42:01 -0600)
> >
>
> Given that the release is one week away, rather than sit on this for
> now, applied to u-boot/next, thanks!

Works for me.

Thanks,
-Joe

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


Re: [U-Boot] [PATCH v3] Ability to modify distro boot filename

2018-11-06 Thread Heinrich Schuchardt
On 11/6/18 1:23 PM, Martyn Welch wrote:
> Add in the ability to modify the distro boot filename. Whilst not
> immediately useful in normal usage, it allows an alternative
> configuration to be provided when other u-boot functionality is used, such
> as bootcount limit, to fallback to an alternative boot configuration. In
> this case we can follow the same boot path as for normal boot, just
> using an alternatively named configuration file.
>
> For example, by providing the following `altbootcmd` when bootcount is in
> use:
>
> altbootcmd=setenv boot_extlinx_conf extlinux-rollback.conf; \
>   run distro_bootcmd
>
> Signed-off-by: Martyn Welch 

Reviewed-by: Heinrich Schuchardt 

>
> ---
>
> Changes in v3:
> - Moving path to config variable, rename `boot_syslinux_conf`
>
> Changes in v2:
> - Moving config variable from `boot_config` to `boot_extlinux_conf`
>
>  include/config_distro_bootcmd.h | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
> index 373fee78a9..5838eb3477 100644
> --- a/include/config_distro_bootcmd.h
> +++ b/include/config_distro_bootcmd.h
> @@ -355,15 +355,16 @@
>   "boot_script_dhcp=boot.scr.uimg\0" \
>   BOOTENV_BOOT_TARGETS \
>   \
> + "boot_syslinux_conf=extlinux/extlinux.conf\0" \
>   "boot_extlinux="  \
>   "sysboot ${devtype} ${devnum}:${distro_bootpart} any "\
> - "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
> + "${scriptaddr} ${prefix}${boot_syslinux_conf}\0"  \
>   \
>   "scan_dev_for_extlinux="  \
>   "if test -e ${devtype} "  \
>   "${devnum}:${distro_bootpart} "   \
> - "${prefix}extlinux/extlinux.conf; then "  \
> - "echo Found ${prefix}extlinux/extlinux.conf; "\
> + "${prefix}${boot_syslinux_conf}; then "   \
> + "echo Found ${prefix}${boot_syslinux_conf}; " \
>   "run boot_extlinux; " \
>   "echo SCRIPT FAILED: continuing...; " \
>   "fi\0"\
>

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


[U-Boot] [PATCH] imx: hab: extend hab_auth_img to calculate ivt_offset

2018-11-06 Thread Parthiban Nallathambi
Current implementation of hab_auth_img command needs ivt_offset to
authenticate the image. But ivt header is placed at the end of image
date after padding.

This leaves the usage of hab_auth_img command to fixed size or static
offset for ivt header. New function "get_image_ivt_offset" is introduced
to find the ivt offset during runtime. The case conditional check in this
function is same as boot_get_kernel in common/bootm.c

With this variable length image e.g. FIT image with any random size can
have IVT at the end and ivt_offset option can be left optional

Can be used as "hab_auth_img $loadaddr $filesize" from u-boot script

Signed-off-by: Parthiban Nallathambi 
---
 arch/arm/mach-imx/hab.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index b88acd13da..060d0866b3 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -6,6 +6,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -302,18 +304,41 @@ static int do_hab_status(cmd_tbl_t *cmdtp, int flag, int 
argc,
return 0;
 }
 
+static ulong get_image_ivt_offset(ulong img_addr, ulong length)
+{
+   const void *buf;
+
+   buf = map_sysmem(img_addr, 0);
+   switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+   case IMAGE_FORMAT_LEGACY:
+   return (image_get_image_size((image_header_t *)img_addr)
+   + 0x1000 - 1)  & ~(0x1000 - 1);
+#endif
+#if IMAGE_ENABLE_FIT
+   case IMAGE_FORMAT_FIT:
+   return (fit_get_size(buf) + 0x1000 - 1)  & ~(0x1000 - 1);
+#endif
+   default:
+   return 0;
+   }
+}
+
 static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc,
 char * const argv[])
 {
ulong   addr, length, ivt_offset;
int rcode = 0;
 
-   if (argc < 4)
+   if (argc < 3)
return CMD_RET_USAGE;
 
addr = simple_strtoul(argv[1], NULL, 16);
length = simple_strtoul(argv[2], NULL, 16);
-   ivt_offset = simple_strtoul(argv[3], NULL, 16);
+   if (argc == 3)
+   ivt_offset = get_image_ivt_offset(addr, length);
+   else
+   ivt_offset = simple_strtoul(argv[3], NULL, 16);
 
rcode = imx_hab_authenticate_image(addr, length, ivt_offset);
if (rcode == 0)
-- 
2.17.2

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


Re: [U-Boot] [PATCH v4 17/18] doc: README.mediatek: Add a simple README for MediaTek

2018-11-06 Thread Frank Wunderlich
Apply: doc: README.mediatek: Add a simple README for MediaTek
.git/rebase-apply/patch:194: trailing whitespace.

warning: 1 Line adds Whitespace-Error.
Apply: MAINTAINERS: add an entry for MediaTek

but works so far ;)

https://github.com/frank-w/u-boot/tree/bpi-r2_v4

Tested-by: Frank Wunderlich 

regards Frank


> Gesendet: Dienstag, 06. November 2018 um 09:47 Uhr
> Von: "Ryder Lee" 
> An: "Tom Rini" , "Simon Glass" , 
> "Albert Aribaud" 
> Cc: "Ryder Lee" , "Steven Liu" 
> , "Roy Luo" , 
> u-boot@lists.denx.de
> Betreff: [U-Boot] [PATCH v4 17/18] doc: README.mediatek: Add a simple README 
> for MediaTek
>
> Add a few notes on how to try out the MediaTek support so far.
>
> Signed-off-by: Ryder Lee 
> ---
> Changes since v4:
> -Add instructions on how to prepare SD card and write to SNOR flash.
> -Fix typo.
> ---
>  doc/README.mediatek | 221 
> 
>  1 file changed, 221 insertions(+)
>  create mode 100644 doc/README.mediatek
>
> diff --git a/doc/README.mediatek b/doc/README.mediatek
> new file mode 100644
> index 000..5b8e3e9
> --- /dev/null
> +++ b/doc/README.mediatek
> @@ -0,0 +1,221 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2018 MediaTek Inc.
> +# Ryder Lee 
> +
> +
> +This document describes how to compile the U-Boot and how to change U-Boot
> +configuration about the MediaTek SoCs.
> +
> +
> +Build Procedure
> +===
> + -Set the cross compiler:
> +
> + # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
> +
> + -Clean-up old residuals:
> +
> + # make mrproper
> +
> + -Configure the U-Boot:
> +
> + # make 
> + # make
> +
> + - For the MT7623n bananapi R2 board use 
> "mt7623n_bpir2_defconfig"
> + - For the MT7629 reference board use "mt7629_rfb_defconfig"
> +
> +
> +Boot sequence
> +=
> + -Bootrom -> MTK preloader -> U-Boot
> +
> + - MT7623n
> +
> + This version of U-Boot doesn't implement SPL. So, MTK preloader binary
> + is needed to boot up:
> +
> + 
> https://github.com/BPI-SINOVOIP/BPI-R2-bsp/tree/master/mt-pack/mtk/bpi-r2/bin
> +
> +
> + -Bootrom -> SPL -> U-Boot
> +
> + - MT7629
> +
> +
> +Configuration update
> +
> + To update the U-Boot configuration, please refer to doc/README.kconfig
> +
> +
> +MediaTek image header
> +=
> +Currently there are two image headers used for MediaTek chips:
> +
> + - BootROM image header. This header is used by the first stage 
> bootloader. It records
> +   the desired compatible boot device, integrity information and its 
> load address.
> +
> +   The on-chip BootROM will firstly verify integrity and compatibility 
> of the bootloader.
> +
> +   If verification passed, the BootROM will then load the bootloader 
> into on-chip SRAM,
> +   and pass control to it.
> +
> +   Note that this header is actually a combination of three independent 
> headers:
> +   Device header, BRLYT header and GFH header.
> +
> +   Used by U-Boot SPL of MT7629 and preloader of MT7623.
> +
> +
> + - MediaTek legacy image header. This header was originally used by the 
> legacy image. It
> +   basically records the load address, image size and image name.
> +
> +   After all low level initializations passed, the preloader will locate 
> the LK image and
> +   load it into DRAM, and pass control to it.
> +
> +   Now this header is used by U-Boot of MT7623.
> +
> +
> +To generate these two headers with mkimage:
> +
> + # mkimage -T mtk_image -a  -n  -d 
>  
> +
> + - mtk_image means using MediaTek's header generation method.
> +
> +
> + - load_addr is the load address of this image.
> +   For first stage bootloader like U-Boot SPL or preloader, it usually 
> points to the
> +   on-chip SRAM.
> +
> +   For second stage bootloader like U-Boot, it usually points to the 
> DRAM.
> +
> +
> + - option_string contains options to generate the header.
> +
> +   The option string is using the follow format:
> + key1=value1;key2=value2;...
> +
> +   The following key names are valid:
> + lk: If lk=1, LK image header is used. Otherwise BootROM image 
> header is used.
> +
> + lkname: The name of the LK image header. The maximum length is 
> 32.
> + The default value is "U-Boot".
> +
> + media: Desired boot device. The valid values are:
> + nand : Parallel NAND
> + snand: Serial NAND
> + nor  : Serial NOR
> + emmc : eMMC
> + sdmmc: SD
> +
> +nandinfo: Desired NAND device type, a combination of page size, oob 
> size and
> +  optional device capacity. Valid types are:
> + 2k+64: for Serial NAND, 2KiB page size + 64B oob size
> + 2k+120   : for Serial NAND, 2Ki

[U-Boot] [PULL] Please pull u-boot-imx: u-boot-imx-20181106

2018-11-06 Thread Stefano Babic
Hi Tom,

this solves issue reported by coverity for i.MX8:

The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:

  Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04
08:12:21 -0500)

are available in the Git repository at:

  git://www.denx.de/git/u-boot-imx.git tags/u-boot-imx-20181106

for you to fetch changes up to 0ea82ba2b082475090e11872ec11409a9fc8d486:

  MAINTAINERS: add NXP linux team maillist as i.MX reviewer (2018-11-06
11:26:21 +0100)


Fix coverity issues for i.MX8


Fabio Estevam (2):
  mx8mq_evk: README: Delete file introduced by mistake
  ARM: dts: fsl-imx8qxp-mek: Move regulator outside "simple-bus"

Peng Fan (5):
  tools: imx8image: check lseek return value
  tools: imx8image: fix coverity CID 184234
  tools: imx8image: fix coverity CID 184233
  tools: imx8image: flatten container header only when creating
container
  MAINTAINERS: add NXP linux team maillist as i.MX reviewer

 MAINTAINERS  |  1 +
 arch/arm/dts/fsl-imx8qxp-mek.dts | 20 
 board/freescale/mx8mq_evk/README | 81
-
 tools/imx8image.c| 59
+--
 4 files changed, 54 insertions(+), 107 deletions(-)
 delete mode 100644 board/freescale/mx8mq_evk/README

Best regards,
Stefano

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2] riscv: cache: Implement i/dcache [status, enable, disable]

2018-11-06 Thread Auer, Lukas
Hi Rick,

On Tue, 2018-11-06 at 10:28 +0800, Rick Chen wrote:
> Auer, Lukas  於 2018年11月4日 週日
> 下午10:21寫道:
> > 
> > Hi Rick,
> > 
> > On Thu, 2018-11-01 at 12:08 +0800, Andes wrote:
> > > From: Rick Chen 
> > > 
> > > AndeStar RISC-V(V5) provide mcache_ctl register which
> > > can configure I/D cache as enabled or disabled.
> > > 
> > > This CSR will be encapsulated by CONFIG_RISCV_NDS.
> > > If you want to configure cache on AndeStar V5
> > > AE350 platform. YOu can enable [*] AndeStar V5 ISA support
> > > by make menuconfig.
> > > 
> > > This approach also provide the expansion when the
> > > vender specific features are going to join in.
> > > 
> > > Signed-off-by: Rick Chen 
> > > Cc: Greentime Hu 
> > > ---
> > >  arch/riscv/Kconfig |  8 
> > >  arch/riscv/cpu/ax25/Makefile   |  1 +
> > >  arch/riscv/cpu/ax25/cache.c| 89
> > > ++
> > >  arch/riscv/cpu/ax25/cpu.c  |  4 ++
> > >  arch/riscv/cpu/qemu/cpu.c  |  2 +-
> > >  arch/riscv/cpu/start.S |  6 +++
> > >  arch/riscv/include/asm/cache.h |  9 +
> > >  arch/riscv/lib/cache.c | 30 +-
> > >  8 files changed, 138 insertions(+), 11 deletions(-)
> > >  create mode 100644 arch/riscv/cpu/ax25/cache.c
> > > 
> > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> > > index 371921b..a356729 100644
> > > --- a/arch/riscv/Kconfig
> > > +++ b/arch/riscv/Kconfig
> > > @@ -74,4 +74,12 @@ config 32BIT
> > >  config 64BIT
> > >   bool
> > > 
> > > +config RISCV_NDS
> > > + bool "AndeStar V5 ISA support"
> > > + default n
> > > + help
> > > + Say Y here if you plan to run U-Boot on AndeStar v5
> > > + platforms and use some specific features which are
> > > + provided by Andes Technology AndeStar V5 Families.
> > > +
> > >  endmenu
> > > diff --git a/arch/riscv/cpu/ax25/Makefile
> > > b/arch/riscv/cpu/ax25/Makefile
> > > index 2ab0342..318bacc 100644
> > > --- a/arch/riscv/cpu/ax25/Makefile
> > > +++ b/arch/riscv/cpu/ax25/Makefile
> > > @@ -4,3 +4,4 @@
> > >  # Rick Chen, Andes Technology Corporation 
> > > 
> > >  obj-y:= cpu.o
> > > +obj-y+= cache.o
> > > diff --git a/arch/riscv/cpu/ax25/cache.c
> > > b/arch/riscv/cpu/ax25/cache.c
> > > new file mode 100644
> > > index 000..e0bcaa2
> > > --- /dev/null
> > > +++ b/arch/riscv/cpu/ax25/cache.c
> > > @@ -0,0 +1,89 @@
> > > +// SPDX-License-Identifier: GPL-2.0+
> > > +/*
> > > + * Copyright (C) 2017 Andes Technology Corporation
> > > + * Rick Chen, Andes Technology Corporation 
> > > + */
> > > +
> > > +#include 
> > > +
> > > +void icache_enable(void)
> > > +{
> > > +#ifndef CONFIG_SYS_ICACHE_OFF
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "ori t0, t1, 0x1\n\t"
> > > + "csrw mcache_ctl, t0\n\t"
> > > + );
> > > +#endif
> > > +#endif
> > > +}
> > > +
> > > +void icache_disable(void)
> > 
> > Just wondering, why do you not have the same #ifndef
> > CONFIG_SYS_ICACHE_OFF as above here?
> > 
> 
> I only add CONFIG_SYS_XXX_OFF in enable function, not in disable
> funtion.
> This can control cache enable or disable when u-boot start-up, on
> other reason.
> If you care about this, I can add CONFIG_SYS_XXX_OFF for all.
> 

I was just wondering why, you can leave it as is.

> > > +{
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "andi t0, t1, ~0x1\n\t"
> > > + "csrw mcache_ctl, t0\n\t"
> > > + );
> > > +#endif
> > > +}
> > > +
> > > +void dcache_enable(void)
> > > +{
> > > +#ifndef CONFIG_SYS_ICACHE_OFF
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "ori t0, t1, 0x2\n\t"
> > > + "csrw mcache_ctl, t0\n\t"
> > > + );
> > > +#endif
> > > +#endif
> > > +}
> > > +
> > > +void dcache_disable(void)
> > > +{
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "andi t0, t1, ~0x2\n\t"
> > > + "csrw mcache_ctl, t0\n\t"
> > > + );
> > > +#endif
> > > +}
> > > +
> > > +int icache_status(void)
> > > +{
> > > + int ret = 0;
> > > +
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "andi   %0, t1, 0x01\n\t"
> > > + : "=r" (ret)
> > > + :
> > > + : "memory"
> > > + );
> > > +#endif
> > > +
> > > + return ret;
> > > +}
> > > +
> > > +int dcache_status(void)
> > > +{
> > > + int ret = 0;
> > > +
> > > +#ifdef CONFIG_RISCV_NDS
> > > + asm volatile (
> > > + "csrr t1, mcache_ctl\n\t"
> > > + "andi   %0, t1, 0x02\n\t"
> > > + : "=r" (ret)
> > > + :
> > > + : "memory"
> > > + );
> > > +#endif
> > > +
> > > + return ret;
>

[U-Boot] Please pull u-boot/master

2018-11-06 Thread Stefan Roese

Hi Tom,

could you please pull these MVEBU fixes for the upcoming release?

Thanks,
Stefan


The following changes since commit 5ef76e59c12c79d106ebda70b710468aa6bd8b75:

  Merge branch 'master' of git://git.denx.de/u-boot-sh (2018-11-04 08:12:21 
-0500)

are available in the Git repository at:

  git://www.denx.de/git/u-boot-marvell.git

for you to fetch changes up to ae4c38a5384033c7f5584e33cce1adc511fff333:

  arm: mvebu: armada-xp-theadorable.dts: Change CS# for 2nd FPGA (2018-11-06 
13:21:13 +0100)


Stefan Roese (3):
  arm: mvebu: Move PCI(e) MBUS window to end of RAM
  arm: mvebu: armada-xp-theadorable.dts: Add "spi-flash" compatible property
  arm: mvebu: armada-xp-theadorable.dts: Change CS# for 2nd FPGA

 arch/arm/dts/armada-xp-theadorable.dts |  6 +++---
 arch/arm/mach-mvebu/dram.c | 10 ++
 arch/arm/mach-mvebu/include/mach/cpu.h |  4 +++-
 3 files changed, 12 insertions(+), 8 deletions(-)

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


[U-Boot] SPI in U-Boot on Raspberry Pi for TPM 2.0

2018-11-06 Thread Torben

Hi,

does anyone know, if it is possible to use SPI in U-Boot on a Raspberry 
Pi 3 Model B?


What I'm trying to achieve:
- Connect a TPM 2.0 via SPI to the Raspberry Pi and communicate with it

What I already have:
- Compiled U-Boot with support for Raspberry Pi 3 Model B; I can access 
the console and I can boot Raspbian from the SD-card


Questions / Problems:
- How do I activate SPI support? I have enabled CONFIG_SPI, 
CONFIG_CMD_SPI and CONFIG_DM_SPI. I guess, I'd have also have to enable 
some Raspberry Pi specific SPI driver to make it work?


-> It seems like there is no driver for it, yet? (as far as I understand 
this: there would need to be a bcm2835 SPI driver, right?)


-> Would it be possible to alternatively use the SOFT_SPI driver (maybe 
that's also the easier way?)? (because it seems like one can access the 
GPIOs from U-Boot already, so that seems to be implemented) However, I 
can't find much about how this needs to be setup. BTW the U-Boot README 
references to the file "include/configs/sacsng.h" for an example, but 
that file doesn't exist anymore in the current master.


Thanks!
Torben

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


[U-Boot] CVE-2018-18439, CVE-2018-18440 - U-Boot verified boot bypass vulnerabilities

2018-11-06 Thread Andrea Barisani

Hello everyone, the following advisory has been posted last week to
oss-security, per discussion with Tom Rini, whom helped us in the
pre-notification phase, I also post it here for discussion.

Cheers

---

Security advisory: U-Boot verified boot bypass
==

The Universal Boot Loader - U-Boot [1] verified boot feature allows
cryptographic authentication of signed kernel images, before their execution.

This feature is essential in maintaining a full chain of trust on systems which
are secure booted by means of an hardware anchor.

Multiple techniques have been identified that allow to execute arbitrary code,
within a running U-Boot instance, by means of externally provided
unauthenticated data.

All such techniques spawn from the lack of memory allocation protection within
the U-Boot architecture, which results in several means of providing
excessively large images during the boot process.

Some implementers might find the following issues as an intrinsic
characteristic of the U-Boot memory model, and consequently a mere aspect of
correct U-Boot configuration and command restrictions.

However in our opinion the inability of U-Boot to protect itself when loading
binaries is an unexpected result of non trivial understanding, particularly
important to emphasize in trusted boot scenarios.

This advisory details two specific techniques that allow to exploit U-Boot lack
of memory allocation restrictions, with the most severe case also detailing a
workaround to mitigate the issue.

It must be emphasized that cases detailed in the next sections only represent
two possible occurrences of such architectural limitation, other U-Boot image
loading functions are extremely likely to suffer from the same validation
issues.

To a certain extent the identified issues are similar to one of the findings
reported as CVE-2018-1000205 [2], however they concern different functions
which in some cases are at a lower level, therefore earlier in the boot image
loading stage.

Again all such issues are a symptom of the same core architectural limitation,
being the lack of memory allocation constraints for received images.

It is highly recommended, for implementers of trusted boot schemes, to review
use of all U-Boot booting/loading commands, and not merely the two specific
ones involved in the findings below, to apply limitations (where
applicable/possible) to the size of loaded images in relation to the available
RAM.

It should also be emphasized that any trusted boot scheme must also rely on an
appropriate lockdown of all possibilities for interactive consoles, by boot
process interruption or failure, to ever be prompted.


U-Boot insufficient boundary checks in filesystem image load


The U-Boot bootloader supports kernel loading from a variety of filesystem
formats, through the `load` command or its filesystem specific equivalents
(e.g. `ext2load`, `ext4load`, `fatload`, etc.)

These commands do not protect system memory from being overwritten when loading
files of a length that exceeds the boundaries of the relocated U-Boot memory
region, filled with the loaded file starting from the passed `addr` variable.

Therefore an excessively large boot image, saved on the filesystem, can be
crafted to overwrite all U-Boot static and runtime memory segments, and in
general all device addressable memory starting from the `addr` load address
argument.

The memory overwrite can directly lead to arbitrary code execution, fully
controlled by the contents of the loaded image.

When verified boot is implemented, the issue allows to bypass its intended
validation as the memory overwrite happens before any validation can take
place.

The following example illustrates the issue, triggered with a 129MB file on a
machine with 128MB or RAM:

```
U-Boot 2018.09-rc1 (Oct 10 2018 - 10:52:54 +0200)

DRAM:  128 MiB
Flash: 128 MiB
MMC:   MMC: 0

# print memory information
=> bdinfo
arch_number = 0x08E0
boot_params = 0x60002000
DRAM bank   = 0x
-> start= 0x6000
-> size = 0x0800
DRAM bank   = 0x0001
-> start= 0x8000
-> size = 0x0004
eth0name= smc911x-0
ethaddr = 52:54:00:12:34:56
current eth = smc911x-0
ip_addr = 
baudrate= 38400 bps
TLB addr= 0x67FF
relocaddr   = 0x67F96000
reloc off   = 0x07796000
irq_sp  = 0x67EF5EE0
sp start= 0x67EF5ED0

# load large file
=> ext2load mmc 0 0x6000 fitimage.itb

# In this specific example U-Boot falls in an infinite loop, results vary
# depending on the test case and filesystem/device driver used. A debugging
# session demonstrates memory being overwritten:
(gdb) p gd
$28 = (volatile gd_t *) 0x67ef5ef8
(gdb) p *gd
$27 = {bd = 0x7f7f7f7f, flags = 2139062143, baudrate = 2139062143, ... }
(gdb) x/300x 0x67ef5ef8
0x67ef5ef8: 0x7f7f7f7f  0x7f7f7f7f  0x7

Re: [U-Boot] [PATCH] spi: Zap mpc8xx_spi driver

2018-11-06 Thread Christophe LEROY



Le 05/11/2018 à 11:11, Jagan Teki a écrit :

On Fri, Mar 2, 2018 at 3:17 PM Christophe LEROY  wrote:


Le 26/02/2018 à 15:43, Jagan Teki a écrit :

- Driver not used by any boards

This driver should be used by MCR3000 board. For the time
being SPI is not activated on that board because we are struggling
with u-boot size. I'm working on re-activating SPI soon on this board.

I also have another board that I'm planing to include in the near
future. That board stores ethernet addresses in an SPI E2PROM, so this
driver will be mandatory for it.

Therefore, please do not drop it now. It will be converted to DM before
the deadline.

Any patch for this? planning to merge it on MW



MW stands for ... MittWoch, that is Wednesday ?

See serie https://patchwork.ozlabs.org/project/uboot/list/?series=74249

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


[U-Boot] [PATCH v3] Ability to modify distro boot filename

2018-11-06 Thread Martyn Welch
Add in the ability to modify the distro boot filename. Whilst not
immediately useful in normal usage, it allows an alternative
configuration to be provided when other u-boot functionality is used, such
as bootcount limit, to fallback to an alternative boot configuration. In
this case we can follow the same boot path as for normal boot, just
using an alternatively named configuration file.

For example, by providing the following `altbootcmd` when bootcount is in
use:

altbootcmd=setenv boot_extlinx_conf extlinux-rollback.conf; \
run distro_bootcmd

Signed-off-by: Martyn Welch 

---

Changes in v3:
- Moving path to config variable, rename `boot_syslinux_conf`

Changes in v2:
- Moving config variable from `boot_config` to `boot_extlinux_conf`

 include/config_distro_bootcmd.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 373fee78a9..5838eb3477 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -355,15 +355,16 @@
"boot_script_dhcp=boot.scr.uimg\0" \
BOOTENV_BOOT_TARGETS \
\
+   "boot_syslinux_conf=extlinux/extlinux.conf\0" \
"boot_extlinux="  \
"sysboot ${devtype} ${devnum}:${distro_bootpart} any "\
-   "${scriptaddr} ${prefix}extlinux/extlinux.conf\0" \
+   "${scriptaddr} ${prefix}${boot_syslinux_conf}\0"  \
\
"scan_dev_for_extlinux="  \
"if test -e ${devtype} "  \
"${devnum}:${distro_bootpart} "   \
-   "${prefix}extlinux/extlinux.conf; then "  \
-   "echo Found ${prefix}extlinux/extlinux.conf; "\
+   "${prefix}${boot_syslinux_conf}; then "   \
+   "echo Found ${prefix}${boot_syslinux_conf}; " \
"run boot_extlinux; " \
"echo SCRIPT FAILED: continuing...; " \
"fi\0"\
-- 
2.11.0

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


Re: [U-Boot] [PATCH v2] Ability to modify distro boot filename

2018-11-06 Thread Martyn Welch
On Mon, 2018-11-05 at 20:43 +0100, Heinrich Schuchardt wrote:
> On 11/05/2018 07:13 PM, Martyn Welch wrote:
> > Add in the ability to modify the distro boot filename. Whilst not
> > immediately useful in normal usage, it allows an alternative
> > configuration to be provided when other u-boot functionality is
> > used, such
> > as bootcount limit, to fallback to an alternative boot
> > configuration. In
> > this case we can follow the same boot path as for normal boot, just
> > using an alternatively named configuration file.
> > 
> > For example, by providing the following `altbootcmd` when bootcount
> > is in
> > use:
> > 
> > altbootcmd=setenv boot_extlinx_conf extlinux-rollback.conf; \
> > run distro_bootcmd
> > 
> > Signed-off-by: Martyn Welch 
> > 
> > ---
> > 
> > Changes in v2:
> > - Moving config variable from `boot_config` to `boot_extlinux_conf`
> > 
> >  include/config_distro_bootcmd.h | 10 +++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/config_distro_bootcmd.h
> > b/include/config_distro_bootcmd.h
> > index 373fee78a9..1e9f6cb31a 100644
> > --- a/include/config_distro_bootcmd.h
> > +++ b/include/config_distro_bootcmd.h
> > @@ -355,15 +355,19 @@
> >     "boot_script_dhcp=boot.scr.uimg\0" \
> >     BOOTENV_BOOT_TARGETS \
> >     \
> > +   "boot_extlinux_conf=extlinux.conf\0" \
> 
> 
> Why do you only put "extlinux.conf" into the new variable and not
> "extlinux/extlinux.conf" and call the variable boot_syslinux_conf.
> 
> Wouldn't this provide more flexibility?
> 

Sounds good to me.

Martyn

> Best regards
> 
> >     "boot_extlinux="  
> > \
> >     "sysboot ${devtype} ${devnum}:${distro_bootpart}
> > any "\
> > -   "${scriptaddr}
> > ${prefix}extlinux/extlinux.conf\0" \
> > +   "${scriptaddr}
> > "  \
> > +   "${prefix}extlinux/${boot_extlinux_conf}\0
> > "   \
> >     \
> >     "scan_dev_for_extlinux="  
> > \
> >     "if test -e ${devtype}
> > "  \
> >     "${devnum}:${distro_bootpart}
> > "   \
> > -   "${prefix}extlinux/extlinux.conf;
> > then "  \
> > -   "echo Found
> > ${prefix}extlinux/extlinux.conf; "\
> > +   "${prefix}extlinux/${boot_extlinux
> > _conf}; " \
> > +   "then
> > "   \
> > +   "echo Found
> > " \
> > +   "${prefix}extlinux/${boot_extlinux
> > _conf}; " \
> >     "run boot_extlinux;
> > " \
> >     "echo SCRIPT FAILED: continuing...;
> > " \
> >     "fi\0"
> > \
> > 
> 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >