Re: [U-Boot] [PATCH v5 05/18] arm: MediaTek: add basic support for MT7623 boards

2018-11-15 Thread Weijie Gao
On Thu, 2018-11-15 at 11:21 -0800, Simon Glass wrote:
> Hi,
> 
> On 14 November 2018 at 18:07, Ryder Lee  wrote:
> > From: Weijie Gao 
> >
> > This adds a general board file based on MT7623 SoCs from MediaTek.
> >
> > As this u-boot is loaded by MTK proprietary preloader, there is no
> > low level initializtion codes.
> >
> > Signed-off-by: Weijie Gao 
> > Signed-off-by: Ryder Lee 
> > Tested-by: Matthias Brugger 
> > ---
> > Changes since v5: None
> > Changes since v4:
> > -Add gd->bd->bi_boot_params for legacy method - ATAGs.
> > ---
> >  arch/arm/mach-mediatek/Kconfig| 13 
> >  arch/arm/mach-mediatek/Makefile   |  1 +
> >  arch/arm/mach-mediatek/mt7623/Makefile|  4 ++
> >  arch/arm/mach-mediatek/mt7623/init.c  | 54 +++
> >  arch/arm/mach-mediatek/mt7623/lowlevel_init.S | 22 ++
> >  arch/arm/mach-mediatek/mt7623/preloader.h | 99 
> > +++
> >  board/mediatek/mt7623/Kconfig | 13 
> >  board/mediatek/mt7623/MAINTAINERS |  7 ++
> >  board/mediatek/mt7623/Makefile|  3 +
> >  board/mediatek/mt7623/mt7623_rfb.c| 16 +
> >  configs/mt7623n_bpir2_defconfig   | 54 +++
> >  include/configs/mt7623.h  | 56 +++
> >  12 files changed, 342 insertions(+)
> >  create mode 100644 arch/arm/mach-mediatek/mt7623/Makefile
> >  create mode 100644 arch/arm/mach-mediatek/mt7623/init.c
> >  create mode 100644 arch/arm/mach-mediatek/mt7623/lowlevel_init.S
> >  create mode 100644 arch/arm/mach-mediatek/mt7623/preloader.h
> >  create mode 100644 board/mediatek/mt7623/Kconfig
> >  create mode 100644 board/mediatek/mt7623/MAINTAINERS
> >  create mode 100644 board/mediatek/mt7623/Makefile
> >  create mode 100644 board/mediatek/mt7623/mt7623_rfb.c
> >  create mode 100644 configs/mt7623n_bpir2_defconfig
> >  create mode 100644 include/configs/mt7623.h
> 
> Can this use the bloblist feature which should land soon?
> 
> For now, see dm/spl-working.
> 
> Regards,
> Simon

Hi Simon,

I've read the code for spl handoff. It's a good way though but
unfortunately it cannot be applied to the MT7623 boards.

The reason is that MT7623 uses a MediaTek proprietary preloader which
has the same function as the U-Boot SPL. But the preloader is
close-sourced (by company policy) and only available in binary release.
This means we can't use a real U-Boot SPL to replace the preloader.

At present this chip has already been used in many products. We can't
either release a different preloader which introduces compatibility
issues.

So the conclusion is that we cannot use the bloblist feature for this
SoC.

Best Regards,
Weijie




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


Re: [U-Boot] [PATCH 3/4] fs: prevent overwriting reserved memory

2018-11-15 Thread Simon Goldschmidt

On 14.11.2018 00:03, Heinrich Schuchardt wrote:

On 11/13/18 10:47 PM, Simon Goldschmidt wrote:


Am Di., 13. Nov. 2018, 22:37 hat Heinrich Schuchardt mailto:xypron.g...@gmx.de>> geschrieben:

 On 11/13/18 9:01 PM, Simon Goldschmidt wrote:
 > On 13.11.2018 20:42, Heinrich Schuchardt wrote:
 >> On 11/13/18 6:47 AM, Simon Goldschmidt wrote:
 >>> On Tue, Nov 13, 2018 at 3:23 AM Fabio Estevam
 mailto:feste...@gmail.com>>
 >>> wrote:
  Hi Simon,
 
  On Mon, Nov 12, 2018 at 7:25 PM Simon Goldschmidt
  mailto:simon.k.r.goldschm...@gmail.com>> wrote:
 
 > diff --git a/fs/fs.c b/fs/fs.c
 > index adae98d021..4baf6b1c39 100644
 > --- a/fs/fs.c
 > +++ b/fs/fs.c
 > @@ -428,13 +428,57 @@ int fs_size(const char *filename, loff_t
 *size)
 >  return ret;
 >   }
 >
 > -int fs_read(const char *filename, ulong addr, loff_t offset,
 > loff_t len,
 > -   loff_t *actread)
 > +#ifdef CONFIG_LMB
  Unrelated to your series, but I was wondering if we could get
 rid of
  the CONFIG_LMB option.
 
  As far as I can see all the architectures define it, the only
  exception being arch/sh.
 
  If you agree I can send a patch after your series gets applied that
  removes CONFIG_LMB.
 >>> Sure, that would clean things up.
 >>>
 >>> Simon
 >>>
 >> NAK
 >>
 >> This patch-series does not provide what is needed. With
 >> odroid-c2_defconfig I get
 >>
 >> fdt list /reserved-memory/secmon@1000
 >> reserved-memory {
 >>  secmon@1000 {
 >>  reg = <0x 0x1000 0x 0x0020>;
 >>  no-map;
 >>  };
 >> };
 >>
 >> => load mmc 0:1 0x1000 dtb
 >> 22925 bytes read in 8 ms (2.7 MiB/s)
 >>
 >> So now I have successfully overwritten the secure monitor. Urrgh.
 >>
 >> As you have observed load is still writing into a memory area that is
 >> reserved by the device-tree.
 >>
 >> Please, iterate over the device tree to ensure that nothing is loaded
 >> into a reserved memory area. Do not expect board files to do anything
 >> but create the reserve-memory entry in the device tree.
 >
 > First of all, thanks for testing. I must admit I haven't tested this
 > case, I just had the impression the existing function
 > 'boot_fdt_add_mem_rsv_regions()' (in image-fdt.c) would do that. I'll
 > have to dig into why it doesn't.
 >
 > Or do you have CONFIG_OF_LIBFDT disabled?

 `make odroid-c2_defconfig` sets
 CONFIG_OF_LIBFDT=y

 CONFIG_CMD_FDT depends on it. So without I would not have had the fdt
 command used above.

 The device-tree I was looking at was the one provided by U-Boot at
 ${fdtcontroladdr}.


That might be an explanation. I used 'gd->fdt_blob' only in my patch.

For the Odroid C2 the relevant memory reservations are created in
arch/arm/mach-meson/board.c:61:
void meson_gx_init_reserved_memory(void *fdt)

According to /README ${fdtcontroladdr} and gd->fdt_blob should be the same:

lib/fdtdec.c:1255:
gd->fdt_blob = (void *)env_get_ulong("fdtcontroladdr", 16,
(uintptr_t)gd->fdt_blob);

The boards with CONFIG_OF_PRIOR_STAGE=y set fdtcontroladdr in the board
file (board/broadcom/bcmstb/bcmstb.c).

You should use gd->fdt_blob. Just make sure it is already set.


OK, so it seems U-Boot just cannot handle the "reserved-memory" node 
with its subnodes but only the "memreserve" thing on top level?
I have the rest of the patches in a state I would submit, but I'll need 
some more time to dig into the dts reserved memory reservation...


Simon



Best regards

Heinrich


Are there any more device tree locations to care about?

 We should also think about making this testable. I would be happy if we
 had a test on a QEMU board.


I tried to build the tests but I only got build errors. Is there any
documentation about what I could be missing? I think my Ubuntu should be
up to date, so maybe I am missing some dependencies...?

Simon


 Best regards

 Heinrich

 >
 > In any case, it *was* my intention to include the dts memory
 > reservation! I'll make sure I test that for a v2.
 >
 > Simon
 >



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


Re: [U-Boot] mtd partitions go away

2018-11-15 Thread Heiko Schocher

Hello Boris,

thanks for the fast response.

Am 15.11.2018 um 16:15 schrieb Boris Brezillon:

Hi Heiko,

On Thu, 15 Nov 2018 15:21:31 +0100
Boris Brezillon  wrote:



Looks like spi_flash_mtd_register() is doing something really bad here


Yes!


[1]: memsetting the global sf_mtd_info object without testing if
this object has already been registered, and then registering it again
to the MTD layer. So any partition that had been attached to the mtd
object through mtd_probe_devices() are lost, and mtdparts/mtdids are not
parsed again because they haven't changed since the last time
mtd_probe_devices() was called.


Yep...



[1]https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/mtd/spi/sf_mtd.c#L76


Can you try with the following diff applied?


The patch do not apply for me, so I added it from hand.

But it crashes for me (output with some debug printfs) and
U-Boot Environment in SPI NOR:

U-Boot 2018.11-00042-g48b013532c-dirty (Nov 16 2018 - 06:31:16 +)

CPU:   Freescale i.MX6ULL rev1.0 528 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 45C
Reset cause: WDOG
[...]
DRAM:  128 MiB
NAND:  128 MiB
Loading Environment from SPI Flash... SF: Detected s25f064l with page size 256 Bytes, erase size 64 
KiB, total 8 MiB

spi_flash_mtd_register === start: 749000
spi_flash_mtd_register === name : 
spi_flash_mtd_register === start
spi_flash_mtd_register === ret: 0
spi_flash_read_dm === reloc_offset: 749000 dev:0c00 off: d len: 16384
data abort
pc : [<87f69226>]  lr : [<87f69223>]
reloc pc : [<87820226>]lr : [<87820223>]
sp : 86f44e50  ip :  fp : 0017
r10: 878006cc  r9 : 86f44ee0 r8 : 86f50600
r7 : 87fdb78c  r6 : 4000 r5 : 000d  r4 : 0c00
r3 : 49e2e00d  r2 : 4000 r1 : 86f44c24  r0 : 004e
Flags: Nzcv  IRQs off  FIQs off  Mode SVC_32
Code: e9cd4603 48081600 f02c4908 6823fa66 (6bdb4632)
Resetting CPU ...

It crashes in:

8782018c T board_nand_init
87820200 t spi_flash_post_bind
87820204 T spi_flash_read_dm <-
87820244 T spi_flash_write_dm
87820252 T spi_flash_erase_dm

dev pointer seems bogus to me ...

I try to find out more, but may I have only next week time for it...
sorry.

bye,
Heiko
--
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] net: phy: Add clause 45 identifier to phy_device

2018-11-15 Thread Pankaj Bansal
The phy devices can be accessed via clause 22 or via clause 45.
This information can be deduced when we read phy id. if the phy id
is read without giving any MDIO Manageable Device Address (MMD), then
it conforms to clause 22. otherwise it conforms to clause 45.

Signed-off-by: Pankaj Bansal 

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index e837eb7688..fa08c75f82 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -620,7 +620,7 @@ static struct phy_driver *get_phy_driver(struct phy_device 
*phydev,
 }
 
 static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
-   u32 phy_id,
+   u32 phy_id, bool is_c45,
phy_interface_t interface)
 {
struct phy_device *dev;
@@ -650,6 +650,7 @@ static struct phy_device *phy_device_create(struct mii_dev 
*bus, int addr,
 
dev->addr = addr;
dev->phy_id = phy_id;
+   dev->is_c45 = is_c45;
dev->bus = bus;
 
dev->drv = get_phy_driver(dev, interface);
@@ -701,13 +702,17 @@ static struct phy_device *create_phy_by_mask(struct 
mii_dev *bus,
 phy_interface_t interface)
 {
u32 phy_id = 0x;
+   bool is_c45;
 
while (phy_mask) {
int addr = ffs(phy_mask) - 1;
int r = get_phy_id(bus, addr, devad, _id);
/* If the PHY ID is mostly f's, we didn't find anything */
-   if (r == 0 && (phy_id & 0x1fff) != 0x1fff)
-   return phy_device_create(bus, addr, phy_id, interface);
+   if (r == 0 && (phy_id & 0x1fff) != 0x1fff) {
+   is_c45 = (devad == MDIO_DEVAD_NONE) ? false : true;
+   return phy_device_create(bus, addr, phy_id, is_c45,
+interface);
+   }
phy_mask &= ~(1 << addr);
}
return NULL;
diff --git a/include/phy.h b/include/phy.h
index b86fdfb2ce..f23ca63f3b 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -138,6 +138,7 @@ struct phy_device {
int pause;
int asym_pause;
u32 phy_id;
+   bool is_c45;
u32 flags;
 };
 
-- 
2.17.1

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


Re: [U-Boot] mtd partitions go away

2018-11-15 Thread Heiko Schocher

Hello Boris,

Am 15.11.2018 um 17:47 schrieb Boris Brezillon:

On Thu, 15 Nov 2018 16:15:51 +0100
Boris Brezillon  wrote:


Hi Heiko,

On Thu, 15 Nov 2018 15:21:31 +0100
Boris Brezillon  wrote:



Looks like spi_flash_mtd_register() is doing something really bad here
[1]: memsetting the global sf_mtd_info object without testing if
this object has already been registered, and then registering it again
to the MTD layer. So any partition that had been attached to the mtd
object through mtd_probe_devices() are lost, and mtdparts/mtdids are not
parsed again because they haven't changed since the last time
mtd_probe_devices() was called.

[1]https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/mtd/spi/sf_mtd.c#L76


Can you try with the following diff applied?


If the previous diff did not fix your problem, you can try this one

--->8---
diff --git a/drivers/mtd/mtd_uboot.c b/drivers/mtd/mtd_uboot.c
index 5ca560c96879..af5ad25cc37a 100644
--- a/drivers/mtd/mtd_uboot.c
+++ b/drivers/mtd/mtd_uboot.c
@@ -164,6 +164,7 @@ int mtd_probe_devices(void)
 /* Check if mtdparts/mtdids changed since last call, otherwise: exit */
 if ((!mtdparts && !old_mtdparts && !mtdids && !old_mtdids) ||
 (mtdparts && old_mtdparts && mtdids && old_mtdids &&
+!mtd_dev_list_updated() &&
  !strcmp(mtdparts, old_mtdparts) &&
  !strcmp(mtdids, old_mtdids)))
 return 0;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fb6c779abbfe..7a15ded8c883 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -87,14 +87,17 @@ struct idr_layer {
  
  struct idr {

 struct idr_layer id[MAX_IDR_ID];
+   bool updated;
  };
  
  #define DEFINE_IDR(name)   struct idr name;
  
  void idr_remove(struct idr *idp, int id)

  {
-   if (idp->id[id].used)
+   if (idp->id[id].used) {
 idp->id[id].used = 0;
+   idp->updated = true;
+   }
  
 return;

  }
@@ -134,6 +137,7 @@ int idr_alloc(struct idr *idp, void *ptr, int start, int 
end, gfp_t gfp_mask)
 if (idl->used == 0) {
 idl->used = 1;
 idl->ptr = ptr;
+   idp->updated = true;
 return i;
 }
 i++;
@@ -155,6 +159,16 @@ struct mtd_info *__mtd_next_device(int i)
  }
  EXPORT_SYMBOL_GPL(__mtd_next_device);
  
+bool mtd_dev_list_updated(void)

+{
+   if (mtd_idr.updated) {
+   mtd_idr.updated = false;
+   return true;
+   }
+
+   return false;
+}
+
  #ifndef __UBOOT__
  static LIST_HEAD(mtd_notifiers);
  
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h

index 68e591532492..d20ebd820289 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -581,6 +581,7 @@ int mtd_arg_off_size(int argc, char *const argv[], int 
*idx, loff_t *off,
  void mtd_get_len_incl_bad(struct mtd_info *mtd, uint64_t offset,
   const uint64_t length, uint64_t *len_incl_bad,
   int *truncated);
+bool mtd_dev_list_updated(void);
  
  /* drivers/mtd/mtd_uboot.c */

  int mtd_search_alternate_name(const char *mtdname, char *altname,



This does fix "mtd list"
=> mtd list
List of MTD devices:
* nand0
  - type: NAND flash
  - block size: 0x2 bytes
  - min I/O: 0x800 bytes
  - OOB size: 64 bytes
  - OOB available: 0 bytes
  - ECC strength: 8 bits
  - ECC step size: 512 bytes
  - bitflip threshold: 6 bits
  - 0x-0x0800 : "nand0"
  - 0x-0x0800 : "ubi"
* nor0
  - type: NOR flash
  - block size: 0x1 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0080 : "nor0"
  - 0x-0x0001 : "spl"
  - 0x0001-0x000d : "u-boot"
  - 0x000d-0x000e : "env"
  - 0x000e-0x000f : "env-red"
  - 0x000f-0x0080 : "rescue"
=> sf probe
SF: Detected s25f064l with page size 256 Bytes, erase size 64 KiB, total 8 MiB
=> mtd list
List of MTD devices:
* nand0
  - type: NAND flash
  - block size: 0x2 bytes
  - min I/O: 0x800 bytes
  - OOB size: 64 bytes
  - OOB available: 0 bytes
  - ECC strength: 8 bits
  - ECC step size: 512 bytes
  - bitflip threshold: 6 bits
  - 0x-0x0800 : "nand0"
  - 0x-0x0800 : "ubi"
* nor0
  - type: NOR flash
  - block size: 0x1 bytes
  - min I/O: 0x1 bytes
  - 0x-0x0080 : "nor0"
  - 0x-0x0001 : "spl"
  - 0x0001-0x000d : "u-boot"
  - 0x000d-0x000e : "env"
  - 0x000e-0x000f : "env-red"
  - 0x000f-0x0080 : "rescue"

But problem with "ubi part" remains:

=> ubi part ubi
Partition ubi not found!
=>

Thanks for your help. I try to find time, to dig also into it, but
may 

[U-Boot] [PATCH 3/4] sound: sandbox: Use the correct frequency

2018-11-15 Thread Simon Glass
At present we request a particular frequency but we may not get the exact
same frequency in response. So use the actual frequency for generation of
the square wave. This ensures that the pitch remains accurate on all host
machines.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/sdl.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 36f1bf0c83b..c940a473d7c 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -9,6 +9,10 @@
 #include 
 #include 
 
+enum {
+   SAMPLE_RATE = 22050,
+};
+
 static struct sdl_info {
SDL_Surface *screen;
int width;
@@ -18,6 +22,7 @@ static struct sdl_info {
uint frequency;
uint audio_pos;
uint audio_size;
+   uint sample_rate;
uint8_t *audio_data;
bool audio_active;
bool inited;
@@ -283,7 +288,7 @@ int sandbox_sdl_sound_init(void)
return 0;
 
/* Set the audio format */
-   wanted.freq = 22050;
+   wanted.freq = SAMPLE_RATE;
wanted.format = AUDIO_S16;
wanted.channels = 1;/* 1 = mono, 2 = stereo */
wanted.samples = 1024;  /* Good low-latency value for callback */
@@ -309,6 +314,7 @@ int sandbox_sdl_sound_init(void)
goto err;
}
sdl.audio_active = true;
+   sdl.sample_rate = wanted.freq;
 
return 0;
 
@@ -322,7 +328,8 @@ int sandbox_sdl_sound_start(uint frequency)
if (!sdl.audio_active)
return -1;
sdl.frequency = frequency;
-   sound_create_square_wave(22050, (unsigned short *)sdl.audio_data,
+   sound_create_square_wave(sdl.sample_rate,
+(unsigned short *)sdl.audio_data,
 sdl.audio_size, frequency);
sdl.audio_pos = 0;
SDL_PauseAudio(0);
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH 2/4] sound: Add sample rate as a parameter for square wave

2018-11-15 Thread Simon Glass
At present this value is hard-coded in the function that generates a
square wave. Since sample rates vary between different hardware, it makes
more sense to have this as a parameter.

Update the function and its users.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/sdl.c| 2 +-
 drivers/sound/sound-i2s.c | 3 ++-
 drivers/sound/sound.c | 6 +++---
 include/sound.h   | 4 +++-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index adcb73826fe..36f1bf0c83b 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -322,7 +322,7 @@ int sandbox_sdl_sound_start(uint frequency)
if (!sdl.audio_active)
return -1;
sdl.frequency = frequency;
-   sound_create_square_wave((unsigned short *)sdl.audio_data,
+   sound_create_square_wave(22050, (unsigned short *)sdl.audio_data,
 sdl.audio_size, frequency);
sdl.audio_pos = 0;
SDL_PauseAudio(0);
diff --git a/drivers/sound/sound-i2s.c b/drivers/sound/sound-i2s.c
index 9f09e3bf930..f0f0b79bc52 100644
--- a/drivers/sound/sound-i2s.c
+++ b/drivers/sound/sound-i2s.c
@@ -185,7 +185,8 @@ int sound_play(uint32_t msec, uint32_t frequency)
return -1;
}
 
-   sound_create_square_wave((unsigned short *)data,
+   sound_create_square_wave(g_i2stx_pri.samplingrate,
+(unsigned short *)data,
 data_size / sizeof(unsigned short),
 frequency);
 
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 6c1eb4c19cc..4f0ad0d8f0d 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -7,11 +7,11 @@
 #include 
 #include 
 
-void sound_create_square_wave(unsigned short *data, int size, uint32_t freq)
+void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
+ uint freq)
 {
-   const int sample = 48000;
const unsigned short amplitude = 16000; /* between 1 and 32767 */
-   const int period = freq ? sample / freq : 0;
+   const int period = freq ? sample_rate / freq : 0;
const int half = period / 2;
 
assert(freq);
diff --git a/include/sound.h b/include/sound.h
index 3269f2371c3..77bfe6a93b2 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -31,11 +31,13 @@ struct sound_codec_info {
 /*
  * Generates square wave sound data for 1 second
  *
+ * @param sample_rate   Sample rate in Hz
  * @param data  data buffer pointer
  * @param size  size of the buffer
  * @param freq  frequency of the wave
  */
-void sound_create_square_wave(unsigned short *data, int size, uint32_t freq);
+void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
+ uint freq);
 
 /*
  * Initialises audio sub system
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH 4/4] sandbox: Enable sound

2018-11-15 Thread Simon Glass
Now that the buffer-overflow bug is fixed, we can enable sound on sandbox.
Drop the code which exits early.

Signed-off-by: Simon Glass 
---

 arch/sandbox/cpu/sdl.c | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index c940a473d7c..c7a8d945492 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -268,25 +268,6 @@ int sandbox_sdl_sound_init(void)
if (sdl.audio_active)
return 0;
 
-   /*
-* At present all sandbox sounds crash. This is probably due to
-* symbol name conflicts with U-Boot. We can remove the malloc()
-* probles with:
-*
-* #define USE_DL_PREFIX
-*
-* and get this:
-*
-* Assertion 'e->pollfd->fd == e->fd' failed at pulse/mainloop.c:676,
-*  function dispatch_pollfds(). Aborting.
-*
-* The right solution is probably to make U-Boot's names private or
-* link os.c and sdl.c against their libraries before liking with
-* U-Boot. TBD. For now sound is disabled.
-*/
-   printf("(Warning: sandbox sound disabled)\n");
-   return 0;
-
/* Set the audio format */
wanted.freq = SAMPLE_RATE;
wanted.format = AUDIO_S16;
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH 1/4] sound: Correct data output in sound_create_square_wave()

2018-11-15 Thread Simon Glass
This function currently outputs twice as much data as it should and
overwrites its buffer as a result. Fix it.

Signed-off-by: Simon Glass 
---

 drivers/sound/sound.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 969408186fd..6c1eb4c19cc 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -25,12 +25,10 @@ void sound_create_square_wave(unsigned short *data, int 
size, uint32_t freq)
for (i = 0; size && i < half; i++) {
size -= 2;
*data++ = amplitude;
-   *data++ = amplitude;
}
for (i = 0; size && i < period - half; i++) {
size -= 2;
*data++ = -amplitude;
-   *data++ = -amplitude;
}
}
 }
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH 0/4] sound: Correct sound output on sandbox

2018-11-15 Thread Simon Glass
At present sandbox sound output is disabled due to a bug. This series
fixes that bug, adds a small API adjustment and enables sandbox sound
output again.


Simon Glass (4):
  sound: Correct data output in sound_create_square_wave()
  sound: Add sample rate as a parameter for square wave
  sound: sandbox: Use the correct frequency
  sandbox: Enable sound

 arch/sandbox/cpu/sdl.c| 30 +-
 drivers/sound/sound-i2s.c |  3 ++-
 drivers/sound/sound.c |  8 +++-
 include/sound.h   |  4 +++-
 4 files changed, 17 insertions(+), 28 deletions(-)

-- 
2.19.1.1215.g8438c0b245-goog

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


Re: [U-Boot] [PATCH v2 01/23] log: Correct definition of log_msg_ret()

2018-11-15 Thread Simon Glass
Hi Bin,

On 15 November 2018 at 17:43, Bin Meng  wrote:
>
> Hi Simon,
>
> On Fri, Nov 16, 2018 at 8:08 AM Simon Glass  wrote:
> >
> > Hi Bin,
> >
> > On 4 October 2018 at 02:25, Bin Meng  wrote:
> > >
> > > Hi Simon,
> > >
> > > On Tue, Oct 2, 2018 at 8:25 PM Simon Glass  wrote:
> > > >
> > > > This macro should have two parameters, not one. Fix it so that it
> > > > correctly resolves to _ret when logging is disabled.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > > Changes in v2: None
> > > >
> > > >  include/log.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/include/log.h b/include/log.h
> > > > index 653fb8d853e..75ff1e1160c 100644
> > > > --- a/include/log.h
> > > > +++ b/include/log.h
> > > > @@ -175,7 +175,7 @@ void __assert_fail(const char *assertion, const 
> > > > char *file, unsigned int line,
> > > > })
> > > >  #else
> > > >  #define log_ret(_ret) (_ret)
> > > > -#define log_msg_ret(_ret) (_ret)
> > > > +#define log_msg_ret(_msg, _ret) (_ret)
> > >
> > > This creates a warning still if logging is disabled.
> > >
> > > include/log.h:178:33: warning: statement with no effect [-Wunused-value]
> > >  #define log_msg_ret(_msg, _ret) (_ret)
> >
> > It has to be used in a 'return' statement. I'll add a comment in the
> > first patch of the spl handoff series.
> >
>
> Yes, it seems I have noticed this and see my patch here :)
> http://patchwork.ozlabs.org/patch/996894/

OK good. I'm not sure what I was thinking when I omitted the documentation...

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


Re: [U-Boot] [PATCH V4 7/7] test: vboot: clean its file

2018-11-15 Thread Simon Glass
On 14 November 2018 at 04:51, Philippe Reynes
 wrote:
> This update the its file used in vboot test to respect the new
> node style name defined in doc/uImage.FIT (for example: replace
> kernel@1 by kernel and fdt@1 by fdt-1)
>
> Signed-off-by: Philippe Reynes 
> ---
>  test/py/tests/test_vboot.py |  2 +-
>  test/py/tests/vboot/sign-configs-sha1-pss.its   | 18 +-
>  test/py/tests/vboot/sign-configs-sha1.its   | 18 +-
>  test/py/tests/vboot/sign-configs-sha256-pss.its | 18 +-
>  test/py/tests/vboot/sign-configs-sha256.its | 18 +-
>  test/py/tests/vboot/sign-images-sha1-pss.its| 16 
>  test/py/tests/vboot/sign-images-sha1.its| 16 
>  test/py/tests/vboot/sign-images-sha256-pss.its  | 16 
>  test/py/tests/vboot/sign-images-sha256.its  | 16 
>  9 files changed, 69 insertions(+), 69 deletions(-)
>
> Changelog:
> v4:
> - remove Reviewed-by Clement Peron (added by mistake)
> - remove Reviewed-by Simon Glass (added by mistake)
> v3:
> - new patch in the serie (feedback from Clement Peron)
>

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


Re: [U-Boot] [PATCH v2 1/2] power: regulator: add driver for the FAN53555 family

2018-11-15 Thread Simon Glass
Hi Philipp,

On 27 November 2017 at 12:49, Dr. Philipp Tomsich
 wrote:
>
>> On 27 Nov 2017, at 04:07, Simon Glass  wrote:
>>
>> Hi Philipp,
>>
>> On 26 November 2017 at 07:10, Dr. Philipp Tomsich
>>  wrote:
>>>
 On 26 Nov 2017, at 12:38, Simon Glass  wrote:

 Hi Philipp,

 On 22 November 2017 at 14:13, Philipp Tomsich
  wrote:
> This adds a driver for the FAN53555 family of regulators.
>
> While these devices support a 'normal' and 'suspend' mode (controlled
> via an external pin) to switch between two programmable voltages, this
> incarnation of the driver assumes that the device is always operating
> in 'normal' mode.
>
> Only setting/reading the programmed voltage is supported at this time
> and the following device functionality remains unsupported:
> - switching the selected voltage (via a GPIO)
> - disabling the voltage output via software-control
> This matches the functionality of the Linux driver.
>
> Tested on a RK3399-Q7 (with 'option 5' devices): setting voltages from
> the U-Boot shell and verifying output voltages on the board.
>
> Signed-off-by: Philipp Tomsich 
> Tested-by: Klaus Goger 
>
> ---
>
> Changes in v2:
> - adapted documentation on the device-tree binding from Linux
>
> doc/device-tree-bindings/regulator/fan53555.txt |  23 +++
> drivers/power/regulator/Kconfig |  14 ++
> drivers/power/regulator/Makefile|   1 +
> drivers/power/regulator/fan53555.c  | 255 
> 
> 4 files changed, 293 insertions(+)
> create mode 100644 doc/device-tree-bindings/regulator/fan53555.txt
> create mode 100644 drivers/power/regulator/fan53555.c
>> [...]
>>
> +static int fan53555_write(struct udevice *dev, uint reg, u8 *buff, int 
> len)

 In this file en is only ever 1. How about using pmic_reg_write()?
>>>
>>> pmic_reg_write would require the regulator to be part of a PMIC
>>> device (i.e. have the pmic as a parent).  This is a pure regulator
>>> that is not part of a PMIC.
>>>
>>> If the intent is to not have such devices, I can model this as a
>>> PMIC with a single regulator...
>>
>> Yes I *think* all regulators should have a PMIC as a parent. A PMIC is
>> a type of multi-function device.
>
> I disagree, although the fan53555 (if we ever fully implement support for
> it beyond what Linux supports) might fall into a grey area.
>
> Let’s say, I add the intermediate PMIC (which is a quick change and I was
> tempted to do it instead of keeping this discussion alive, but I think this is
> worthwhile to be discussed a bit further):
> 1.  The DM tree would not correspond to the DTS, as the regulator is
> modelled below the I2C-device for the FAN53555 and (if we assume
> this node becomes the PMIC) there’s no regulators below that.
> 2.  Consequently, I’d need to implement a custom bind() method for this
> PMIC just to bind a single regulator below it.
>
> This sounds very wasteful, as the only thing I’d gain would be the use of
> the pmic_reg_*() family of functions.  Admittedly, I’d like to to have use of
> this IO-abstraction, but it still seems a bit wasteful to do this.
>
> Now, let’s assume we ever implement the advanced functions of the
> regulator, which adds switching between two set voltages (routed to a
> single output); this would give two options of modelling it (if there was
> a PMIC device in the hierarchy):
> A.  create two children for VSEL1 and VSEL2 and provide a set-voltage
> method for each… and not associate the GPIO for switching between
> these with any of them
> B.  use the regulator framework (and manage the GPIO as part of the
> set-mode verb/action) … and have a single child below the PMIC
> again.
>
> Now, in that case, I’d go with option B.
>
> So in summary: we’ll always end up with a single regulator below a
> PMIC that will need to provide a custom bind-op… but I’d be able to
> reuse the pmic_reg_* functions.
>
> I am not convinced yet, but I’ll go with whatever we decide here.

Long delay, but I found this email again.

At present most regulators have a PMIC as a parent, but I don't see
anywhere where it is required. Perhaps we should document what should
be done here?

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


Re: [U-Boot] [RFC] fit: include uncompression into fit_image_load

2018-11-15 Thread Simon Glass
Hi,

On 22 October 2018 at 11:55, Simon Goldschmidt
 wrote:
> On 22.10.2018 19:49, Simon Glass wrote:
>>
>> Hi Simon,
>>
>> On 19 October 2018 at 00:33, Simon Goldschmidt
>>  wrote:
>>>
>>> On 19.10.2018 05:25, Simon Glass wrote:

 Hi Simon,

 On 17 October 2018 at 03:41, Simon Goldschmidt
  wrote:
>
> On Wed, Oct 17, 2018 at 8:54 AM Alexander Graf  wrote:
>>
>>
>>
>> On 16.10.18 21:33, Simon Goldschmidt wrote:
>>>
>>> Currently, only the kernel can be compressed in a FIT image.
>>> By moving the uncompression logic to 'fit_image_load()', all types
>>> of images can be compressed.
>>>
>>> This works perfectly for me when using a gzip'ed FPGA image in
>>> a FIT image on a cyclone5 board (socrates). Also, a gzip'ed initrd
>>> being unzipped by U-Boot (not the kernel) worked.
>>>
>>> To clean this up, the uncompression function would have to be moved
>>> from bootm.c ('bootm_decomp_image()') to a more generic location,
>>> but I decided to keep it for now to make the patch easier to read.
>>> Because of this setup, the kernel is currently uncompressed twice.
>>> which doesn't work...
>>>
>>> There are, however, some more things to discuss:
>>> - The max. size passed to gunzip() (etc.) is not known before, so
>>> we currently configure this to 8 MByte in U-Boot (via
>>> CONFIG_SYS_BOOTM_LEN), which proved too small for my initrd...

 We need the uncompressed size. If the legacy header doesn't have, stop
 using it and use FIT?

 Some compression formats include that in a header I think. But we
 should record it in the U-Boot header.
>>>
>>>
>>> OK, we could embed this information into the FIT by extracting in
>>> 'mkimage'?
>>> That way, we know the uncompressed size...
>>
>> Yes. In fact I don't like the way it works at present. We have to
>> compress the data before putting it in the FIT, since the .its file
>> refers to the compressed data.
>>
>> I think it would be better for the ,its to refer to the original file,
>> and then mkimage do the compression as it generates the FIT. That way
>> it knows the size of the original data, and it is simpler for people
>> to build images, since they don't need to compress everything
>> beforehand.
>
>
> Hmm, OK, I think it should not be a problem to add this to mkimage.
> Only I don't know if this workflow change would be accepted by everyone or
> if the old style of using pre-compressed files would have to be somehow kept
> working?

I suggest supporting the old way with a flag. Also is it possible to
detect an already-compressed file and print an warning?

>
> But what would that mean for CONFIG_SYS_BOOTM_LEN? As I already wrote
> before, this constant is currently used to trim copy-only, too. Now if the
> FIT would embed "uncompressed size", would we limit that to
> CONFIG_SYS_BOOTM_LEN, too? I think it would then make more sense to dump
> this constant and rely on lmb allocation to detect overlapping. (That
> assumes the load address is within lmb, of course.)

Yes that should be the limit I think.

>
>>
>>> - CONFIG_SYS_BOOTM_LEN is set to 64 MByte default in SPL, so it's
>>> a different default for SPL than for U-Boot !?!

 Ick

>>> - CONFIG_SYS_BOOTM_LEN seemed to initially be used for kernel
>>> uncompression but is now used as a copy-only limit, too (no
>>> unzip)

 Yes.
>>>
>>>
>>> Why do we need an extra limit for uncompressed copy-only? Both load
>>> address
>>> and size are known from the FIT.
>>
>> I'm not suggesting separate limit. We don't need that.
>
>
> But bootm_decomp_image() *does* use CONFIG_SYS_BOOTM_LEN already with
> IH_COMP_NONE to limit the size of an uncompressed kernel image.
> Is that a bug then?

I suppose it is just that we have no information about the size of the
kernel, so use this fixed limit?

>
> I don't understand why we need this limit. It seems arbitrary to me given we
> only limit the size but don't know which address we limit...

Perhaps for security reasons, to avoid memory overflow?

>
>>>
>>> - Uncompression only works if a load address is given, what should
>>> happen if the FIT image does not contain a load address?

 Fail.
>
>
> Given correct lmb integration, wouldn't it make more sense to use lmb to
> allocate a block? Especially if we know the uncompressed size?

Yes I think so.

>
>
> Simon
>
>

>>> - The whole memory management around FIT images is a bit messed up
>>> in that memory allocation is a mix of where U-Boot relocates
>>> itself
>>> (and which address ranges it used), the load addresses of the FIT
>>> image and the load addresses of the FIT image contents (and
>>> sizes).
>>> What's the point here to check CONFIG_SYS_BOOTM_LEN? Maybe it
>>> would
>>> be better to keep a memory map of allowed and already used data
>>> to

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

2018-11-15 Thread Simon Glass
Hi Tom,

On 11 October 2018 at 07:10, Tom Rini  wrote:
> On Tue, Oct 09, 2018 at 06:24:13PM -0600, Simon Glass wrote:
>
>> Hi Tom,
>>
>> Here is my attempt at a signed pull request. I've brought in most of the
>> outstanding dm patches. Please let me know if it looks OK. Do you have my
>> public key?
>
> Is it on the public key servers?

Yes, here:

https://pgp.mit.edu/pks/lookup?search=sjg%40chromium=index

>
>>
>>
>> The following changes since commit 0a60a81ba3860946551cb79aa6486aa076e357f3:
>>
>>   Kconfig: sandbox: enable cmd_avb and dependencies (2018-10-07 13:34:19
>> -0400)
>>
>> are available in the Git repository at:
>>
>>   git://git.denx.de/u-boot-dm.git tags/dm-9oct18
>>
>> for you to fetch changes up to 41b781ddf1869f5349e05ace888979f3673fe8c6:
>>
>>   dtoc: Fix the value of SetInt() (2018-10-09 04:40:27 -0600)
>>
>
> Applied to u-boot/master, thanks!
>
> --
> Tom
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] fdt: restore board_fdt_blob_setup() declaration

2018-11-15 Thread Simon Glass
On 28 October 2018 at 05:41, Baruch Siach  wrote:
> Commit 90c08fa038451d (fdt: Add device tree memory bindings) removed the
> prototype declaration of board_fdt_blob_setup(), most likely by mistake.
> This didn't break the build because the only file calling this function
> (lib/fdtdec.c) provides a local weak definition. Restore the
> declaration.
>
> Cc: Michael Pratt 
> Signed-off-by: Baruch Siach 
> ---
>  include/fdtdec.h | 1 +
>  1 file changed, 1 insertion(+)
>

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


[U-Boot] [PATCH v3 10/21] spl: Add a comment to spl_set_bd()

2018-11-15 Thread Simon Glass
There is a strange feature to set global_data to a data-section variable
early in SPL. This only works if SPL actually has access to SRAM which is
not the case on x86, for eaxmple. Add a comment to this effect.

Reviewed-by: Simon Glass 
Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 5a026b844e9..43137105bab 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -378,6 +378,10 @@ static int spl_common_init(bool setup_malloc)
 
 void spl_set_bd(void)
 {
+   /*
+* NOTE: On some platforms (e.g. x86) bdata may be in flash and not
+* writeable.
+*/
if (!gd->bd)
gd->bd = 
 }
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 13/21] sandbox: Add an option to display of-platdata in SPL

2018-11-15 Thread Simon Glass
At present we don't have a test that of-platdata can be accessed in SPL.
Add this in as a command-line option to SPL.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2:
- Drop the wildcard in the .lds file as it is not needed

 arch/sandbox/cpu/spl.c   | 14 ++
 arch/sandbox/cpu/start.c |  9 +
 arch/sandbox/cpu/u-boot-spl.lds  |  2 +-
 arch/sandbox/include/asm/state.h |  1 +
 test/py/tests/test_ofplatdata.py | 31 ++-
 5 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 42c149a4981..49f98644c02 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -44,5 +44,19 @@ SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, 
spl_board_load_image);
 
 void spl_board_init(void)
 {
+   struct sandbox_state *state = state_get_current();
+   struct udevice *dev;
+
preloader_console_init();
+   if (state->show_of_platdata) {
+   /*
+* Scan all the devices so that we can output their platform
+* data. See sandbox_spl_probe().
+*/
+   printf("Scanning misc devices\n");
+   for (uclass_first_device(UCLASS_MISC, );
+dev;
+uclass_next_device())
+   ;
+   }
 }
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 2ee3b485657..28ca35392c9 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -283,6 +283,15 @@ static int sandbox_cmdline_cb_log_level(struct 
sandbox_state *state,
 SANDBOX_CMDLINE_OPT_SHORT(log_level, 'L', 1,
  "Set log level (0=panic, 7=debug)");
 
+static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state,
+  const char *arg)
+{
+   state->show_of_platdata = true;
+
+   return 0;
+}
+SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL");
+
 int board_run_command(const char *cmdline)
 {
printf("## Commands are disabled. Please enable CONFIG_CMDLINE.\n");
diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds
index f97abdfa050..de65b01b33c 100644
--- a/arch/sandbox/cpu/u-boot-spl.lds
+++ b/arch/sandbox/cpu/u-boot-spl.lds
@@ -14,7 +14,7 @@ SECTIONS
}
 
__u_boot_sandbox_option_start = .;
-   _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
+   _u_boot_sandbox_getopt : { KEEP(*(.u_boot_sandbox_getopt)) }
__u_boot_sandbox_option_end = .;
 
__bss_start = .;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index dcb6d5f5683..0a2e3c41ae3 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -89,6 +89,7 @@ struct sandbox_state {
bool skip_delays;   /* Ignore any time delays (for test) */
bool show_test_output;  /* Don't suppress stdout in tests */
int default_log_level;  /* Default log level for sandbox */
+   bool show_of_platdata;  /* Show of-platdata in SPL */
 
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py
index dd8a09f0324..98103ee71a9 100644
--- a/test/py/tests/test_ofplatdata.py
+++ b/test/py/tests/test_ofplatdata.py
@@ -3,11 +3,40 @@
 
 import pytest
 
-OF_PLATDATA_OUTPUT = ''
+OF_PLATDATA_OUTPUT = '''
+of-platdata probe:
+bool 1
+byte 05
+bytearray 06 00 00
+int 1
+intarray 2 3 4 0
+longbytearray 09 0a 0b 0c 0d 0e 0f 10 11
+string message
+stringarray "multi-word" "message" ""
+of-platdata probe:
+bool 0
+byte 08
+bytearray 01 23 34
+int 3
+intarray 5 0 0 0
+longbytearray 09 00 00 00 00 00 00 00 00
+string message2
+stringarray "another" "multi-word" "message"
+of-platdata probe:
+bool 0
+byte 00
+bytearray 00 00 00
+int 0
+intarray 0 0 0 0
+longbytearray 00 00 00 00 00 00 00 00 00
+string 
+stringarray "one" "" ""
+'''
 
 @pytest.mark.buildconfigspec('spl_of_platdata')
 def test_ofplatdata(u_boot_console):
 """Test that of-platdata can be generated and used in sandbox"""
 cons = u_boot_console
+cons.restart_uboot_with_flags(['--show_of_platdata'])
 output = cons.get_spawn_output().replace('\r', '')
 assert OF_PLATDATA_OUTPUT in output
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 16/21] sandbox: Allow puts() output before global_data is set up

2018-11-15 Thread Simon Glass
We support putc() in this case but not puts(), but this is more useful
since it is what printf() uses.

This particularly affects debugging early in SPL, where currently printf()
statements result in no output. Fix this by adding a special case into
puts() for sandbox, just like putc().

Signed-off-by: Simon Glass 
Reviewed-by: Joe Hershberger 
---

Changes in v3: None
Changes in v2: None

 common/console.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/common/console.c b/common/console.c
index 9a94f321922..0b0dd76256c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -535,6 +535,13 @@ void putc(const char c)
 
 void puts(const char *s)
 {
+#ifdef CONFIG_SANDBOX
+   /* sandbox can send characters to stdout before it has a console */
+   if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+   os_puts(s);
+   return;
+   }
+#endif
 #ifdef CONFIG_DEBUG_UART
if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 15/21] sandbox: Add a new 'sb' command

2018-11-15 Thread Simon Glass
The old 'sb' command was deprecated in 2015 and replaced with 'host'. It
is useful to be able to access some internal sandbox state, particularly
for testing.

Resurrect the old command and provide a way to print some basic state
information (currently just the arguments to sandbox).

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/start.c | 10 +++
 arch/sandbox/include/asm/state.h |  7 +
 cmd/Makefile |  1 +
 cmd/sb.c | 46 
 4 files changed, 64 insertions(+)
 create mode 100644 cmd/sb.c

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 28ca35392c9..b1566a81435 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -305,6 +305,16 @@ static void setup_ram_buf(struct sandbox_state *state)
gd->ram_size = state->ram_size;
 }
 
+void state_show(struct sandbox_state *state)
+{
+   char **p;
+
+   printf("Arguments:\n");
+   for (p = state->argv; *p; p++)
+   printf("%s ", *p);
+   printf("\n");
+}
+
 int main(int argc, char *argv[])
 {
struct sandbox_state *state;
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 0a2e3c41ae3..8fabe70a86d 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -242,6 +242,13 @@ bool state_get_skip_delays(void);
  */
 void state_reset_for_test(struct sandbox_state *state);
 
+/**
+ * state_show() - Show information about the sandbox state
+ *
+ * @param stateSandbox state to show
+ */
+void state_show(struct sandbox_state *state);
+
 /**
  * Initialize the test system state
  */
diff --git a/cmd/Makefile b/cmd/Makefile
index 12a1330b062..68f22f1af91 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -114,6 +114,7 @@ obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o
 obj-$(CONFIG_SANDBOX) += host.o
 obj-$(CONFIG_CMD_SATA) += sata.o
 obj-$(CONFIG_CMD_NVME) += nvme.o
+obj-$(CONFIG_SANDBOX) += sb.o
 obj-$(CONFIG_CMD_SF) += sf.o
 obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o
 obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
diff --git a/cmd/sb.c b/cmd/sb.c
new file mode 100644
index 000..6ca3361d7e3
--- /dev/null
+++ b/cmd/sb.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018, Google Inc.
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
+  char * const argv[])
+{
+   struct sandbox_state *state;
+
+   state = state_get_current();
+   state_show(state);
+
+   return 0;
+}
+
+static cmd_tbl_t cmd_sb_sub[] = {
+   U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
+};
+
+static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   cmd_tbl_t *c;
+
+   /* Skip past 'sb' */
+   argc--;
+   argv++;
+
+   c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub));
+   if (c)
+   return c->cmd(cmdtp, flag, argc, argv);
+   else
+   return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+   sb, 8,  1,  do_sb,
+   "Sandbox status commands",
+   "state   - Show sandbox state"
+);
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 19/21] sandbox: Filter arguments when starting U-Boot

2018-11-15 Thread Simon Glass
The current method of starting U-Boot from U-Boot adds arguments to pass
the memory file through, so that memory is preserved. This is fine for a
single call, but if we call from TPL -> SPL -> U-Boot the arguments build
up and we have several memory files in the argument list.

Adjust the implementation to filter out arguments that we want to replace
with new ones. Also print a useful error if the exec() call fails.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d3dc74db4b1..5e55d31be9d 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -538,10 +538,10 @@ static int make_exec(char *fname, const void *data, int 
size)
  */
 static int add_args(char ***argvp, char *add_args[], int count)
 {
-   char **argv;
+   char **argv, **ap;
int argc;
 
-   for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
+   for (argc = 0; (*argvp)[argc]; argc++)
;
 
argv = os_malloc((argc + count + 1) * sizeof(char *));
@@ -549,7 +549,24 @@ static int add_args(char ***argvp, char *add_args[], int 
count)
printf("Out of memory for %d argv\n", count);
return -ENOMEM;
}
-   memcpy(argv, *argvp, argc * sizeof(char *));
+   for (ap = *argvp, argc = 0; *ap; ap++) {
+   char *arg = *ap;
+
+   /* Drop args that we don't want to propagate */
+   if (*arg == '-' && strlen(arg) == 2) {
+   switch (arg[1]) {
+   case 'j':
+   case 'm':
+   ap++;
+   continue;
+   }
+   } else if (!strcmp(arg, "--rm_memory")) {
+   ap++;
+   continue;
+   }
+   argv[argc++] = arg;
+   }
+
memcpy(argv + argc, add_args, count * sizeof(char *));
argv[argc + count] = NULL;
 
@@ -573,6 +590,7 @@ static int os_jump_to_file(const char *fname)
int fd, err;
char *extra_args[5];
char **argv = state->argv;
+   int argc;
 #ifdef DEBUG
int i;
 #endif
@@ -592,11 +610,13 @@ static int os_jump_to_file(const char *fname)
extra_args[1] = (char *)fname;
extra_args[2] = "-m";
extra_args[3] = mem_fname;
-   extra_args[4] = "--rm_memory";
-   err = add_args(, extra_args,
-  sizeof(extra_args) / sizeof(extra_args[0]));
+   argc = 4;
+   if (state->ram_buf_rm)
+   extra_args[argc++] = "--rm_memory";
+   err = add_args(, extra_args, argc);
if (err)
return err;
+   argv[0] = (char *)fname;
 
 #ifdef DEBUG
for (i = 0; argv[i]; i++)
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 05/21] test: Add a simple test for bloblist

2018-11-15 Thread Simon Glass
Add a unit test for the bloblist functionality and enable bloblist for
sandbox.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 arch/Kconfig  |   1 +
 include/test/suites.h |   1 +
 test/Makefile |   1 +
 test/bloblist.c   | 187 ++
 test/cmd_ut.c |   3 +
 5 files changed, 193 insertions(+)
 create mode 100644 test/bloblist.c

diff --git a/arch/Kconfig b/arch/Kconfig
index 9fdd2f7e66a..947070fdd35 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -91,6 +91,7 @@ config SANDBOX
select SPI
select SUPPORT_OF_CONTROL
imply BITREVERSE
+   select BLOBLIST
imply CMD_DM
imply CMD_GETTIME
imply CMD_HASH
diff --git a/include/test/suites.h b/include/test/suites.h
index abb3a4b8169..77d863b4a6a 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -23,6 +23,7 @@ struct unit_test;
 int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents,
int argc, char * const argv[]);
 
+int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[]);
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
diff --git a/test/Makefile b/test/Makefile
index 1e434730b68..2fe41f489c3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -2,6 +2,7 @@
 #
 # (C) Copyright 2012 The Chromium Authors
 
+obj-$(CONFIG_SANDBOX) += bloblist.o
 obj-$(CONFIG_UNIT_TEST) += cmd_ut.o
 obj-$(CONFIG_UNIT_TEST) += ut.o
 obj-$(CONFIG_SANDBOX) += command_ut.o
diff --git a/test/bloblist.c b/test/bloblist.c
new file mode 100644
index 000..89bdb012e35
--- /dev/null
+++ b/test/bloblist.c
@@ -0,0 +1,187 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018, Google Inc. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Declare a new compression test */
+#define BLOBLIST_TEST(_name, _flags) \
+   UNIT_TEST(_name, _flags, bloblist_test)
+
+enum {
+   TEST_TAG= 1,
+   TEST_TAG2   = 2,
+   TEST_TAG_MISSING= 3,
+
+   TEST_SIZE   = 10,
+   TEST_SIZE2  = 20,
+
+   TEST_ADDR   = CONFIG_BLOBLIST_ADDR,
+   TEST_BLOBLIST_SIZE  = 0x100,
+};
+
+static struct bloblist_hdr *clear_bloblist(void)
+{
+   struct bloblist_hdr *hdr;
+
+   /* Clear out any existing bloblist so we have a clean slate */
+   hdr = map_sysmem(CONFIG_BLOBLIST_ADDR, TEST_BLOBLIST_SIZE);
+   memset(hdr, '\0', TEST_BLOBLIST_SIZE);
+
+   return hdr;
+}
+
+static int bloblist_test_init(struct unit_test_state *uts)
+{
+   struct bloblist_hdr *hdr;
+
+   hdr = clear_bloblist();
+   ut_asserteq(-ENOENT, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+   ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+   hdr->version++;
+   ut_asserteq(-EPROTONOSUPPORT, bloblist_check(TEST_ADDR,
+TEST_BLOBLIST_SIZE));
+
+   ut_asserteq(-ENOSPC, bloblist_new(TEST_ADDR, 0x10, 0));
+   ut_asserteq(-EFAULT, bloblist_new(1, TEST_BLOBLIST_SIZE, 0));
+   ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+
+   ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+   ut_assertok(bloblist_finish());
+   ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+   hdr->flags++;
+   ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+
+   return 1;
+}
+BLOBLIST_TEST(bloblist_test_init, 0);
+
+static int bloblist_test_blob(struct unit_test_state *uts)
+{
+   struct bloblist_hdr *hdr;
+   struct bloblist_rec *rec, *rec2;
+   char *data;
+
+   /* At the start there should be no records */
+   hdr = clear_bloblist();
+   ut_assertnull(bloblist_find(TEST_TAG, TEST_BLOBLIST_SIZE));
+   ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+
+   /* Add a record and check that we can find it */
+   data = bloblist_add(TEST_TAG, TEST_SIZE);
+   rec = (void *)(hdr + 1);
+   ut_asserteq_ptr(rec + 1, data);
+   data = bloblist_find(TEST_TAG, TEST_SIZE);
+   ut_asserteq_ptr(rec + 1, data);
+
+   /* Check the 'ensure' method */
+   ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE));
+   ut_assertnull(bloblist_ensure(TEST_TAG, TEST_SIZE2));
+   rec2 = (struct bloblist_rec *)(data + ALIGN(TEST_SIZE, BLOBLIST_ALIGN));
+
+   /* Check for a non-existent record */
+   ut_asserteq_ptr(data, bloblist_ensure(TEST_TAG, TEST_SIZE));
+   ut_asserteq_ptr(rec2 + 1, bloblist_ensure(TEST_TAG2, TEST_SIZE2));
+   ut_assertnull(bloblist_find(TEST_TAG_MISSING, 0));
+
+   return 0;
+}

[U-Boot] [PATCH v3 14/21] sandbox: Drop the deprecated 'sb' command

2018-11-15 Thread Simon Glass
The old 'sb' command was deprecated in 2015 and replaced with 'host'.
Remove the remaining users and the command, so that the name is available
for other purposes.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 cmd/host.c  |  5 -
 doc/README.trace|  2 +-
 test/dm/sf.c|  2 +-
 test/py/tests/test_fit.py   | 12 ++--
 test/py/tests/test_vboot.py |  2 +-
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/cmd/host.c b/cmd/host.c
index 645dba4de83..f7d3eae5b1a 100644
--- a/cmd/host.c
+++ b/cmd/host.c
@@ -167,11 +167,6 @@ static int do_host(cmd_tbl_t *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
 }
 
-U_BOOT_CMD(
-   sb, 8,  1,  do_host,
-   "Deprecated: use 'host' command instead.", ""
-);
-
 U_BOOT_CMD(
host, 8, 1, do_host,
"Miscellaneous host commands",
diff --git a/doc/README.trace b/doc/README.trace
index 74ba26a5a48..2e7ca3319a9 100644
--- a/doc/README.trace
+++ b/doc/README.trace
@@ -88,7 +88,7 @@ stdin=serial
 stdout=serial
 
 Environment size: 117/8188 bytes
-=>sb save host 0 trace 0 ${profoffset}
+=>host save host 0 trace 0 ${profoffset}
 11405888 bytes written in 10 ms (1.1 GiB/s)
 =>reset
 
diff --git a/test/dm/sf.c b/test/dm/sf.c
index 35241b9f574..af49d7a2129 100644
--- a/test/dm/sf.c
+++ b/test/dm/sf.c
@@ -28,7 +28,7 @@ static int dm_test_spi_flash(struct unit_test_state *uts)
 * benefit is worth the extra complexity.
 */
ut_asserteq(0, run_command_list(
-   "sb save hostfs - 0 spi.bin 20;"
+   "host save hostfs - 0 spi.bin 20;"
"sf probe;"
"sf test 0 1", -1,  0));
/*
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index 34696e97679..49d6fea5716 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -99,15 +99,15 @@ base_fdt = '''
 # then run the 'bootm' command, then save out memory from the places where
 # we expect 'bootm' to write things. Then quit.
 base_script = '''
-sb load hostfs 0 %(fit_addr)x %(fit)s
+host load hostfs 0 %(fit_addr)x %(fit)s
 fdt addr %(fit_addr)x
 bootm start %(fit_addr)x
 bootm loados
-sb save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
-sb save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
-sb save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
-sb save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x
-sb save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x
+host save hostfs 0 %(kernel_addr)x %(kernel_out)s %(kernel_size)x
+host save hostfs 0 %(fdt_addr)x %(fdt_out)s %(fdt_size)x
+host save hostfs 0 %(ramdisk_addr)x %(ramdisk_out)s %(ramdisk_size)x
+host save hostfs 0 %(loadables1_addr)x %(loadables1_out)s %(loadables1_size)x
+host save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x
 '''
 
 @pytest.mark.boardspec('sandbox')
diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index e9cbd57fbab..92144d4c1e3 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -74,7 +74,7 @@ def test_vboot(u_boot_console):
 cons.restart_uboot()
 with cons.log.section('Verified boot %s %s' % (sha_algo, test_type)):
 output = cons.run_command_list(
-['sb load hostfs - 100 %stest.fit' % tmpdir,
+['host load hostfs - 100 %stest.fit' % tmpdir,
 'fdt addr 100',
 'bootm 100'])
 assert(expect_string in ''.join(output))
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 11/21] sandbox: Add a memory map to the sandbox README

2018-11-15 Thread Simon Glass
We have a few things in the memory map now, so add documentation for this
to avoid confusion. Also note that it is possible to run all tests now.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 board/sandbox/README.sandbox | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/board/sandbox/README.sandbox b/board/sandbox/README.sandbox
index a28fc9f36c1..6d85901b38d 100644
--- a/board/sandbox/README.sandbox
+++ b/board/sandbox/README.sandbox
@@ -418,7 +418,19 @@ coverage in U-Boot is limited, as we need to work to 
improve it.
 Note that many of these tests are implemented as commands which you can
 run natively on your board if desired (and enabled).
 
-It would be useful to have a central script to run all of these.
+To run all tests use "make check".
+
+
+Memory Map
+--
+
+Sandbox has its own emulated memory starting at 0. Here are some of the things
+that are mapped into that memory:
+
+  0   CONFIG_SYS_FDT_LOAD_ADDR   Device tree
+   e000   CONFIG_BLOBLIST_ADDR   Blob list
+  1   CONFIG_MALLOC_F_ADDR   Early memory allocation
+
 
 --
 Simon Glass 
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 21/21] spl: Add support for passing handoff info to U-Boot proper

2018-11-15 Thread Simon Glass
There is some basic informaton that SPL normally wants to pass through to
U-Boot, such as the SDRAM size and bank information.

Mkae use of the new bloblist structure for this. Add a new 'handoff' blob
which is set up in SPL and passed to U-Boot proper. Also adda  test for
sandbox_spl that checks that this works correctly and a new 'sb' command
to show the information passed from SPL.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3:
- Drop patch 'spl: Print a message if we are unable to load an image'

Changes in v2: None

 arch/powerpc/include/asm/spl.h |  3 --
 arch/sandbox/include/asm/handoff.h | 18 +++
 cmd/sb.c   | 21 +++-
 common/board_f.c   | 15 ++
 common/init/Makefile   |  1 +
 common/init/handoff.c  | 47 ++
 common/spl/Kconfig | 30 
 common/spl/spl.c   | 77 +-
 configs/sandbox_spl_defconfig  |  1 +
 include/asm-generic/global_data.h  |  3 ++
 include/handoff.h  | 36 ++
 include/spl.h  |  1 +
 test/py/tests/test_handoff.py  | 14 ++
 test/run   |  2 +-
 14 files changed, 252 insertions(+), 17 deletions(-)
 create mode 100644 arch/sandbox/include/asm/handoff.h
 create mode 100644 common/init/handoff.c
 create mode 100644 include/handoff.h
 create mode 100644 test/py/tests/test_handoff.py

diff --git a/arch/powerpc/include/asm/spl.h b/arch/powerpc/include/asm/spl.h
index cd6d31c71a7..60a7d37d30b 100644
--- a/arch/powerpc/include/asm/spl.h
+++ b/arch/powerpc/include/asm/spl.h
@@ -8,7 +8,4 @@
 
 #define BOOT_DEVICE_NOR1
 
-/* Linker symbols */
-extern char __bss_start[], __bss_end[];
-
 #endif
diff --git a/arch/sandbox/include/asm/handoff.h 
b/arch/sandbox/include/asm/handoff.h
new file mode 100644
index 000..be4e7b0fae2
--- /dev/null
+++ b/arch/sandbox/include/asm/handoff.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Architecture-specific SPL handoff information for sandbox
+ *
+ * Copyright 2018 Google, Inc
+ * Written by Simon Glass 
+ */
+
+#ifndef __handoff_h
+#define __handoff_h
+
+#define TEST_HANDOFF_MAGIC 0x14f93c7b
+
+struct arch_spl_handoff {
+   ulong   magic;  /* Used for testing */
+};
+
+#endif
diff --git a/cmd/sb.c b/cmd/sb.c
index 6ca3361d7e3..5701e03797c 100644
--- a/cmd/sb.c
+++ b/cmd/sb.c
@@ -9,6 +9,23 @@
 #include 
 #include 
 
+static int do_sb_handoff(cmd_tbl_t *cmdtp, int flag, int argc,
+char *const argv[])
+{
+#if CONFIG_IS_ENABLED(HANDOFF)
+   if (gd->spl_handoff)
+   printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic);
+   else
+   printf("SPL handoff info not received\n");
+
+   return 0;
+#else
+   printf("Command not supported\n");
+
+   return CMD_RET_USAGE;
+#endif
+}
+
 static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
   char * const argv[])
 {
@@ -21,6 +38,7 @@ static int do_sb_state(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 static cmd_tbl_t cmd_sb_sub[] = {
+   U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""),
U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
 };
 
@@ -42,5 +60,6 @@ static int do_sb(cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 U_BOOT_CMD(
sb, 8,  1,  do_sb,
"Sandbox status commands",
-   "state   - Show sandbox state"
+   "handoff - Show handoff data received from SPL\n"
+   "sb state   - Show sandbox state"
 );
diff --git a/common/board_f.c b/common/board_f.c
index 42378537c8d..6516620de6f 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -25,6 +25,9 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_SPL
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -286,6 +289,17 @@ static int setup_mon_len(void)
return 0;
 }
 
+static int setup_spl_handoff(void)
+{
+#if CONFIG_IS_ENABLED(HANDOFF)
+   gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
+   sizeof(struct spl_handoff));
+   debug("Found SPL hand-off info %p\n", gd->spl_handoff);
+#endif
+
+   return 0;
+}
+
 __weak int arch_cpu_init(void)
 {
return 0;
@@ -845,6 +859,7 @@ static const init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_BLOBLIST
bloblist_init,
 #endif
+   setup_spl_handoff,
initf_console_record,
 #if defined(CONFIG_HAVE_FSP)
arch_fsp_init,
diff --git a/common/init/Makefile b/common/init/Makefile
index 4902635f535..853b56d1e57 100644
--- a/common/init/Makefile
+++ b/common/init/Makefile
@@ -5,3 +5,4 @@
 #
 
 obj-y += board_init.o
+obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
diff --git a/common/init/handoff.c b/common/init/handoff.c
new file mode 100644
index 000..e00b43e6a7b
--- /dev/null
+++ b/common/init/handoff.c
@@ -0,0 +1,47 @@
+// 

[U-Boot] [PATCH v3 17/21] sandbox: Refactor code to create os_jump_to_file()

2018-11-15 Thread Simon Glass
At present os_jump_to_image() jumps to a given image, and this is written
to a file. But it is useful to be able to jump to a file also.

To avoid duplicating code, split out the implementation of
os_jump_to_image() into a new function that jumps to a file.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 48 ++-
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 325ded51d8a..b4d7a252b54 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -525,7 +525,18 @@ static int make_exec(char *fname, const void *data, int 
size)
return 0;
 }
 
-static int add_args(char ***argvp, const char *add_args[], int count)
+/**
+ * add_args() - Allocate a new argv with the given args
+ *
+ * This is used to create a new argv array with all the old arguments and some
+ * new ones that are passed in
+ *
+ * @argvp:  Returns newly allocated args list
+ * @add_args: Arguments to add, each a string
+ * @count: Number of arguments in @add_args
+ * @return 0 if OK, -ENOMEM if out of memory
+ */
+static int add_args(char ***argvp, char *add_args[], int count)
 {
char **argv;
int argc;
@@ -546,21 +557,26 @@ static int add_args(char ***argvp, const char 
*add_args[], int count)
return 0;
 }
 
-int os_jump_to_image(const void *dest, int size)
+/**
+ * os_jump_to_file() - Jump to a new program
+ *
+ * This saves the memory buffer, sets up arguments to the new process, then
+ * execs it.
+ *
+ * @fname: Filename to exec
+ * @return does not return on success, any return value is an error
+ */
+static int os_jump_to_file(const char *fname)
 {
struct sandbox_state *state = state_get_current();
-   char fname[30], mem_fname[30];
+   char mem_fname[30];
int fd, err;
-   const char *extra_args[5];
+   char *extra_args[5];
char **argv = state->argv;
 #ifdef DEBUG
-   int argc, i;
+   int i;
 #endif
 
-   err = make_exec(fname, dest, size);
-   if (err)
-   return err;
-
strcpy(mem_fname, "/tmp/u-boot.mem.XX");
fd = mkstemp(mem_fname);
if (fd < 0)
@@ -573,7 +589,7 @@ int os_jump_to_image(const void *dest, int size)
os_fd_restore();
 
extra_args[0] = "-j";
-   extra_args[1] = fname;
+   extra_args[1] = (char *)fname;
extra_args[2] = "-m";
extra_args[3] = mem_fname;
extra_args[4] = "--rm_memory";
@@ -598,6 +614,18 @@ int os_jump_to_image(const void *dest, int size)
return unlink(fname);
 }
 
+int os_jump_to_image(const void *dest, int size)
+{
+   char fname[30];
+   int err;
+
+   err = make_exec(fname, dest, size);
+   if (err)
+   return err;
+
+   return os_jump_to_file(fname);
+}
+
 int os_find_u_boot(char *fname, int maxlen)
 {
struct sandbox_state *state = state_get_current();
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 12/21] test/py: Add a way to pass flags to sandbox

2018-11-15 Thread Simon Glass
It is sometimes useful to restart sandbox with some particular flags to
test certain functionality. Add a new method to ConsoleSandbox to handle
this, without changing the existing APIs.

Signed-off-by: Simon Glass 
Acked-by: Stephen Warren 
---

Changes in v3: None
Changes in v2:
- Add back a blank line, and put one in the new function too

 test/py/u_boot_console_sandbox.py | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/test/py/u_boot_console_sandbox.py 
b/test/py/u_boot_console_sandbox.py
index 778f6d0983d..836f5a9e2b8 100644
--- a/test/py/u_boot_console_sandbox.py
+++ b/test/py/u_boot_console_sandbox.py
@@ -24,6 +24,7 @@ class ConsoleSandbox(ConsoleBase):
 """
 
 super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
+self.sandbox_flags = []
 
 def get_spawn(self):
 """Connect to a fresh U-Boot instance.
@@ -51,8 +52,25 @@ class ConsoleSandbox(ConsoleBase):
 '-d',
 self.config.dtb
 ]
+cmd += self.sandbox_flags
 return Spawn(cmd, cwd=self.config.source_dir)
 
+def restart_uboot_with_flags(self, flags):
+"""Run U-Boot with the given command-line flags
+
+Args:
+flags: List of flags to pass, each a string
+
+Returns:
+A u_boot_spawn.Spawn object that is attached to U-Boot.
+"""
+
+try:
+self.sandbox_flags = flags
+return self.restart_uboot()
+finally:
+self.sandbox_flags = []
+
 def kill(self, sig):
 """Send a specific Unix signal to the sandbox process.
 
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 03/21] spl: Set up the bloblist in SPL

2018-11-15 Thread Simon Glass
The bloblist is normally set up in SPL ready for use by U-Boot. Add
a simple implementation of this to the common SPL code.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c | 18 --
 include/spl.h| 27 +++
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 740182a8be6..eea92ec1f8c 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -7,6 +7,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -343,6 +344,14 @@ static int spl_common_init(bool setup_malloc)
return ret;
}
 #endif
+   if (CONFIG_IS_ENABLED(BLOBLIST)) {
+   ret = bloblist_init();
+   if (ret) {
+   debug("%s: Failed to set up bloblist: ret=%d\n",
+ __func__, ret);
+   return ret;
+   }
+   }
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = fdtdec_setup();
if (ret) {
@@ -481,6 +490,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
BOOT_DEVICE_NONE,
};
struct spl_image_info spl_image;
+   int ret;
 
debug(">>spl:board_init_r()\n");
 
@@ -527,6 +537,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
}
 
spl_perform_fixups(_image);
+   if (CONFIG_IS_ENABLED(BLOBLIST)) {
+   ret = bloblist_finish();
+   if (ret)
+   printf("Warning: Failed to finish bloblist (ret=%d)\n",
+  ret);
+   }
 
 #ifdef CONFIG_CPU_V7M
spl_image.entry_point |= 0x1;
@@ -563,8 +579,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
  gd->malloc_ptr / 1024);
 #endif
 #ifdef CONFIG_BOOTSTAGE_STASH
-   int ret;
-
bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
  CONFIG_BOOTSTAGE_STASH_SIZE);
diff --git a/include/spl.h b/include/spl.h
index 9a439f468b9..a56032ae3eb 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -21,6 +21,33 @@
 #define MMCSD_MODE_FS  2
 #define MMCSD_MODE_EMMCBOOT3
 
+/*
+ * u_boot_first_phase() - check if this is the first U-Boot phase
+ *
+ * U-Boot has up to three phases: TPL, SPL and U-Boot proper. Depending on the
+ * build flags we can determine whether the current build is for the first
+ * phase of U-Boot or not. If there is no SPL, then this is U-Boot proper. If
+ * there is SPL but no TPL, the the first phase is SPL. If there is TPL, then
+ * it is the first phase.
+ *
+ * @returns true if this is the first phase of U-Boot
+ *
+ */
+static inline bool u_boot_first_phase(void)
+{
+   if (IS_ENABLED(CONFIG_TPL)) {
+   if (IS_ENABLED(CONFIG_TPL_BUILD))
+   return true;
+   } else if (IS_ENABLED(CONFIG_SPL)) {
+   if (IS_ENABLED(CONFIG_SPL_BUILD))
+   return true;
+   } else {
+   return true;
+   }
+
+   return false;
+}
+
 struct spl_image_info {
const char *name;
u8 os;
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 18/21] sandbox: Use malloc() and free() from os layer

2018-11-15 Thread Simon Glass
At present sandbox calls malloc() from various places in the OS layer and
this results in calls to U-Boot's malloc() implementation. It is better to
use the on in the OS layer, since it does not mix allocations with the
main U-Boot code.

Fix this by replacing calls with malloc() to os_malloc(), etc.

Signed-off-by: Simon Glass 
Reviewed-by: Joe Hershberger 
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/eth-raw-os.c |  9 ++---
 arch/sandbox/cpu/os.c | 18 +-
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index 75bfaa4c90a..8d05bc2eda0 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,6 +24,8 @@
 #include 
 #include 
 
+#include 
+
 struct sandbox_eth_raw_if_nameindex *sandbox_eth_raw_if_nameindex(void)
 {
return (struct sandbox_eth_raw_if_nameindex *)if_nameindex();
@@ -71,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv 
*priv,
 
/* Prepare device struct */
priv->local_bind_sd = -1;
-   priv->device = malloc(sizeof(struct sockaddr_ll));
+   priv->device = os_malloc(sizeof(struct sockaddr_ll));
if (priv->device == NULL)
return -ENOMEM;
device = priv->device;
@@ -144,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv 
*priv)
/* Prepare device struct */
priv->local_bind_sd = -1;
priv->local_bind_udp_port = 0;
-   priv->device = malloc(sizeof(struct sockaddr_in));
+   priv->device = os_malloc(sizeof(struct sockaddr_in));
if (priv->device == NULL)
return -ENOMEM;
device = priv->device;
@@ -279,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length,
 
 void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
 {
-   free(priv->device);
+   os_free(priv->device);
priv->device = NULL;
close(priv->sd);
priv->sd = -1;
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index b4d7a252b54..d3dc74db4b1 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -343,7 +343,7 @@ void os_dirent_free(struct os_dirent_node *node)
 
while (node) {
next = node->next;
-   free(node);
+   os_free(node);
node = next;
}
 }
@@ -368,7 +368,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
/* Create a buffer upfront, with typically sufficient size */
dirlen = strlen(dirname) + 2;
len = dirlen + 256;
-   fname = malloc(len);
+   fname = os_malloc(len);
if (!fname) {
ret = -ENOMEM;
goto done;
@@ -381,7 +381,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
ret = errno;
break;
}
-   next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+   next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1);
if (!next) {
os_dirent_free(head);
ret = -ENOMEM;
@@ -390,10 +390,10 @@ int os_dirent_ls(const char *dirname, struct 
os_dirent_node **headp)
if (dirlen + strlen(entry->d_name) > len) {
len = dirlen + strlen(entry->d_name);
old_fname = fname;
-   fname = realloc(fname, len);
+   fname = os_realloc(fname, len);
if (!fname) {
-   free(old_fname);
-   free(next);
+   os_free(old_fname);
+   os_free(next);
os_dirent_free(head);
ret = -ENOMEM;
goto done;
@@ -427,7 +427,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node 
**headp)
 
 done:
closedir(dir);
-   free(fname);
+   os_free(fname);
return ret;
 }
 
@@ -544,7 +544,7 @@ static int add_args(char ***argvp, char *add_args[], int 
count)
for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
;
 
-   argv = malloc((argc + count + 1) * sizeof(char *));
+   argv = os_malloc((argc + count + 1) * sizeof(char *));
if (!argv) {
printf("Out of memory for %d argv\n", count);
return -ENOMEM;
@@ -607,7 +607,7 @@ static int os_jump_to_file(const char *fname)
os_exit(2);
 
err = execv(fname, argv);
-   free(argv);
+   os_free(argv);
if (err)
return err;
 
-- 
2.19.1.1215.g8438c0b245-goog

___
U-Boot mailing list
U-Boot@lists.denx.de

[U-Boot] [PATCH v3 04/21] bloblist: Locate bloblist in U-Boot

2018-11-15 Thread Simon Glass
Add support for locating a bloblist in U-Boot that has been set up by SPL.
It is copied into RAM during relocation.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/board_f.c  | 34 +++
 include/asm-generic/global_data.h |  4 
 2 files changed, 38 insertions(+)

diff --git a/common/board_f.c b/common/board_f.c
index 96503ff8d3c..42378537c8d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -560,6 +561,16 @@ static int reserve_stacks(void)
return arch_reserve_stacks();
 }
 
+static int reserve_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+   gd->start_addr_sp -= CONFIG_BLOBLIST_SIZE;
+   gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
+#endif
+
+   return 0;
+}
+
 static int display_new_sp(void)
 {
debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
@@ -666,6 +677,24 @@ static int reloc_bootstage(void)
return 0;
 }
 
+static int reloc_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+   if (gd->flags & GD_FLG_SKIP_RELOC)
+   return 0;
+   if (gd->new_bloblist) {
+   int size = CONFIG_BLOBLIST_SIZE;
+
+   debug("Copying bloblist from %p to %p, size %x\n",
+ gd->bloblist, gd->new_bloblist, size);
+   memcpy(gd->new_bloblist, gd->bloblist, size);
+   gd->bloblist = gd->new_bloblist;
+   }
+#endif
+
+   return 0;
+}
+
 static int setup_reloc(void)
 {
if (gd->flags & GD_FLG_SKIP_RELOC) {
@@ -813,6 +842,9 @@ static const init_fnc_t init_sequence_f[] = {
initf_malloc,
log_init,
initf_bootstage,/* uses its own timer, so does not need DM */
+#ifdef CONFIG_BLOBLIST
+   bloblist_init,
+#endif
initf_console_record,
 #if defined(CONFIG_HAVE_FSP)
arch_fsp_init,
@@ -913,6 +945,7 @@ static const init_fnc_t init_sequence_f[] = {
reserve_global_data,
reserve_fdt,
reserve_bootstage,
+   reserve_bloblist,
reserve_arch,
reserve_stacks,
dram_init_banksize,
@@ -932,6 +965,7 @@ static const init_fnc_t init_sequence_f[] = {
INIT_FUNC_WATCHDOG_RESET
reloc_fdt,
reloc_bootstage,
+   reloc_bloblist,
setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
copy_uboot_to_ram,
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index c83fc01b764..ccf361ed88a 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -122,6 +122,10 @@ typedef struct global_data {
struct list_head log_head;  /* List of struct log_device */
int log_fmt;/* Mask containing log format info */
 #endif
+#if CONFIG_IS_ENABLED(BLOBLIST)
+   struct bloblist_hdr *bloblist;  /* Bloblist information */
+   struct bloblist_hdr *new_bloblist;  /* Relocated blolist info */
+#endif
 } gd_t;
 #endif
 
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 20/21] sandbox: Boot in U-Boot through the standard call

2018-11-15 Thread Simon Glass
Most architectures use jump_to_image_no_args() to jump from SPL to U-Boot.
At present sandbox is special in that it jumps in its
spl_board_load_image() call. This is not strictly correct, and means that
sandbox misses out some parts of board_init_r(), just as calling
bloblist_finish(), for example.

Change spl_board_load_image() to just identify the filename to boot, and
implement jump_to_image_no_args() to actually jump to it.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c  | 17 +
 arch/sandbox/cpu/spl.c | 17 +++--
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 5e55d31be9d..eef4390b294 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -628,8 +628,11 @@ static int os_jump_to_file(const char *fname)
 
err = execv(fname, argv);
os_free(argv);
-   if (err)
+   if (err) {
+   perror("Unable to run image");
+   printf("Image filename '%s'\n", mem_fname);
return err;
+   }
 
return unlink(fname);
 }
@@ -709,17 +712,7 @@ int os_find_u_boot(char *fname, int maxlen)
 
 int os_spl_to_uboot(const char *fname)
 {
-   struct sandbox_state *state = state_get_current();
-   char *argv[state->argc + 1];
-   int ret;
-
-   memcpy(argv, state->argv, sizeof(char *) * (state->argc + 1));
-   argv[0] = (char *)fname;
-   ret = execv(fname, argv);
-   if (ret)
-   return ret;
-
-   return unlink(fname);
+   return os_jump_to_file(fname);
 }
 
 void os_localtime(struct rtc_time *rt)
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 49f98644c02..5005ed2f54a 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -37,8 +37,12 @@ static int spl_board_load_image(struct spl_image_info 
*spl_image,
return ret;
}
 
-   /* Hopefully this will not return */
-   return os_spl_to_uboot(fname);
+   /* Set up spl_image to boot from jump_to_image_no_args() */
+   spl_image->arg = strdup(fname);
+   if (!spl_image->arg)
+   return log_msg_ret("Setup exec filename", -ENOMEM);
+
+   return 0;
 }
 SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
 
@@ -60,3 +64,12 @@ void spl_board_init(void)
;
}
 }
+
+void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+{
+   const char *fname = spl_image->arg;
+
+   os_fd_restore();
+   os_spl_to_uboot(fname);
+   hang();
+}
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 06/21] Add bloblist documentation

2018-11-15 Thread Simon Glass
Add a description of the purpose of bloblist and how to use it.

Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 doc/README.bloblist | 82 +
 1 file changed, 82 insertions(+)
 create mode 100644 doc/README.bloblist

diff --git a/doc/README.bloblist b/doc/README.bloblist
new file mode 100644
index 000..b0e787b97db
--- /dev/null
+++ b/doc/README.bloblist
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+Blob Lists - bloblist
+=
+
+Introduction
+
+
+A bloblist provides a way to store collections of binary information (blobs) in
+a central structure. Each record of information is assigned a tag so that its
+owner can find it and update it. Each record is generally described by a C
+structure defined by the code that owns it.
+
+
+Passing state through the boot process
+--
+
+The bloblist is created when the first U-Boot component runs (often SPL,
+sometimes TPL). It is passed through to each successive part of the boot and
+can be accessed as needed. This provides a way to transfer state from one part
+to the next. For example, TPL may determine that a watchdog reset occurred by
+reading an SoC register. Reading the register may reset the value, so that it
+cannot be read a second time. So TPL can store that in a bloblist record which
+can be passed through to SPL and U-Boot proper, which can print a message
+indicating that something went wrong and the watchdog fired.
+
+
+Blobs
+-
+
+While each blob in the bloblist can be of any length, bloblists are designed to
+hold small amounts of data, typically a few KB at most. It is not possible to
+change the length of a blob once it has been written. Each blob is normally
+created from a C structure which can beused to access its fields.
+
+
+Blob tags
+-
+
+Each blob has a tag which is a 32-bit number. This uniquely identifies the
+owner of the blob. Blob tags are listed in enum blob_tag_t and are named
+with a BLOBT_ prefix.
+
+
+Single structure
+
+
+There is normally only one bloblist in U-Boot. Since a bloblist can store
+multiple blobs it does not seem useful to allow multiple bloblists. Of course
+there could be reasons for this, such as needing to spread the blobs around in
+different memory areas due to fragmented memory, but it is simpler to just have
+a single bloblist.
+
+
+API
+---
+
+Bloblist provides a fairly simple API which allows blobs to be created  and
+found. All access is via the blob's tag.
+
+
+Finishing the bloblist
+--
+
+When a part of U-Boot is about to jump to the next part, it can 'finish' the
+bloblist in preparation for the next stage. This involves adding a checksum so
+that the next stage can make sure that the data arrived safely. While the
+bloblist is in use, changes can be made which will affect the checksum, so it
+is easier to calculate the checksum at the end after all changes are made.
+
+
+Future work
+---
+
+Bootstage has a mechanism to 'stash' its records for passing to the next part.
+This should move to using bloblist, to avoid having its own mechanism for
+passing information between U-Boot parts.
+
+
+Simon Glass
+s...@chromium.org
+12-Aug-2018
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 07/21] spl: Support hash, input, pch, pci, rtc, tpm in SPL

2018-11-15 Thread Simon Glass
At present these subsystems are only supported in U-Boot proper but it is
sometimes necessary to support them in SPL, or even TPL. Update the
Kconfig and Makefile to support this. Also adjust GPIO so that it can be
used in TPL if required.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/spl/Kconfig | 48 +-
 drivers/Makefile   | 11 ++-
 2 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index d0564621d4d..365e692d8b5 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -295,6 +295,16 @@ config SPL_HASH_SUPPORT
  this option to build system-specific drivers for hash acceleration
  as part of an SPL build.
 
+config TPL_HASH_SUPPORT
+   bool "Support hashing drivers in TPL"
+   select SHA1
+   select SHA256
+   help
+ Enable hashing drivers in SPL. These drivers can be used to
+ accelerate secure boot processing in secure applications. Enable
+ this option to build system-specific drivers for hash acceleration
+ as part of an SPL build.
+
 config SPL_DMA_SUPPORT
bool "Support DMA drivers"
help
@@ -376,7 +386,7 @@ config SPL_FPGA_SUPPORT
  within SPL.
 
 config SPL_GPIO_SUPPORT
-   bool "Support GPIO"
+   bool "Support GPIO in SPL"
help
  Enable support for GPIOs (General-purpose Input/Output) in SPL.
  GPIOs allow U-Boot to read the state of an input line (high or
@@ -928,6 +938,17 @@ config TPL_ENV_SUPPORT
help
  Enable environment support in TPL. See SPL_ENV_SUPPORT for details.
 
+config TPL_GPIO_SUPPORT
+   bool "Support GPIO in TPL"
+   help
+ Enable support for GPIOs (General-purpose Input/Output) in TPL.
+ GPIOs allow U-Boot to read the state of an input line (high or
+ low) and set the state of an output line. This can be used to
+ drive LEDs, control power to various system parts and read user
+ input. GPIOs can be useful in TPL to enable a 'sign-of-life' LED,
+ for example. Enable this option to build the drivers in
+ drivers/gpio as part of an TPL build.
+
 config TPL_I2C_SUPPORT
bool "Support I2C"
help
@@ -963,6 +984,22 @@ config TPL_NAND_SUPPORT
help
  Enable support for NAND in TPL. See SPL_NAND_SUPPORT for details.
 
+config TPL_PCI_SUPPORT
+   bool "Support PCI drivers"
+   help
+ Enable support for PCI in TPL. For platforms that need PCI to boot,
+ or must perform some init using PCI in SPL, this provides the
+ necessary driver support. This enables the drivers in drivers/pci
+ as part of a TPL build.
+
+config TPL_PCH_SUPPORT
+   bool "Support PCH drivers"
+   help
+ Enable support for PCH (Platform Controller Hub) devices in TPL.
+ These are used to set up GPIOs and the SPI peripheral early in
+ boot. This enables the drivers in drivers/pch as part of a TPL
+ build.
+
 config TPL_RAM_SUPPORT
bool "Support booting from RAM"
help
@@ -977,6 +1014,15 @@ config TPL_RAM_DEVICE
  be already in memory when TPL takes over, e.g. loaded by the boot
  ROM.
 
+config TPL_RTC_SUPPORT
+   bool "Support RTC drivers"
+   help
+ Enable RTC (Real-time Clock) support in TPL. This includes support
+ for reading and setting the time. Some RTC devices also have some
+ non-volatile (battery-backed) memory which is accessible if
+ needed. This enables the drivers in drivers/rtc as part of an TPL
+ build.
+
 config TPL_SERIAL_SUPPORT
bool "Support serial"
select TPL_PRINTF
diff --git a/drivers/Makefile b/drivers/Makefile
index 4453c62ad33..55de10926ef 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -2,14 +2,19 @@
 
 obj-$(CONFIG_$(SPL_TPL_)CLK) += clk/
 obj-$(CONFIG_$(SPL_TPL_)DM) += core/
+obj-$(CONFIG_$(SPL_TPL_)GPIO_SUPPORT) += gpio/
 obj-$(CONFIG_$(SPL_TPL_)DRIVERS_MISC_SUPPORT) += misc/ sysreset/ firmware/
 obj-$(CONFIG_$(SPL_TPL_)I2C_SUPPORT) += i2c/
+obj-$(CONFIG_$(SPL_TPL_)INPUT) += input/
 obj-$(CONFIG_$(SPL_TPL_)LED) += led/
 obj-$(CONFIG_$(SPL_TPL_)MMC_SUPPORT) += mmc/
 obj-$(CONFIG_$(SPL_TPL_)NAND_SUPPORT) += mtd/nand/raw/
+obj-$(CONFIG_$(SPL_TPL_)PCH_SUPPORT) += pch/
+obj-$(CONFIG_$(SPL_TPL_)PCI_SUPPORT) += pci/
 obj-$(CONFIG_$(SPL_TPL_)PHY) += phy/
 obj-$(CONFIG_$(SPL_TPL_)PINCTRL) += pinctrl/
 obj-$(CONFIG_$(SPL_TPL_)RAM) += ram/
+obj-$(CONFIG_$(SPL_TPL_)RTC_SUPPORT) += rtc/
 obj-$(CONFIG_$(SPL_TPL_)SERIAL_SUPPORT) += serial/
 obj-$(CONFIG_$(SPL_TPL_)SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_$(SPL_TPL_)SPI_SUPPORT) += spi/
@@ -17,6 +22,7 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/
 obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
 obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/

[U-Boot] [PATCH v3 02/21] Add core support for a bloblist to convey data from SPL

2018-11-15 Thread Simon Glass
At present there is no standard way in U-Boot to pass information from SPL
to U-Boot proper. But sometimes SPL wants to convey information to U-Boot
that U-Boot cannot easily figure out. For example, if SPL sets up SDRAM
then it might want to pass the size of SDRAM, or the location of each
bank, to U-Boot proper.

Add a new 'bloblist' feature which provides this. A bloblist is set up in
the first phase of U-Boot that runs (i.e. TPL or SPL). The location of
this info may be in SRAM or CAR (x86 cache-as-RAM) or somewhere else.

Information placed in this region is preserved (with a checksum) through
TPL and SPL and ends up in U-Boot. At this point it is copied into SDRAM
so it can be used after relocation.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
Acked-by: Andreas Dannenberg 
---

Changes in v3:
- Correct CONFIG_BLOBLIST_ADDR to have a default only for sandbox

Changes in v2:
- Fix several typos

 common/Kconfig |  48 +
 common/Makefile|   1 +
 common/bloblist.c  | 239 +
 include/bloblist.h | 195 
 include/log.h  |   1 +
 5 files changed, 484 insertions(+)
 create mode 100644 common/bloblist.c
 create mode 100644 include/bloblist.h

diff --git a/common/Kconfig b/common/Kconfig
index 9bc329a0e61..a44bfdef9f2 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -715,4 +715,52 @@ config UPDATE_TFTP_MSEC_MAX
 
 endmenu
 
+menu "Blob list"
+
+config BLOBLIST
+   bool "Support for a bloblist"
+   help
+ This enables support for a bloblist in U-Boot, which can be passed
+ from TPL to SPL to U-Boot proper (and potentially to Linux). The
+ blob list supports multiple binary blobs of data, each with a tag,
+ so that different U-Boot components can store data which can survive
+ through to the next stage of the boot.
+
+config SPL_BLOBLIST
+   bool "Support for a bloblist in SPL"
+   depends on BLOBLIST
+   default y if SPL
+   help
+ This enables a bloblist in SPL. If this is the first part of U-Boot
+ to run, then the bloblist is set up in SPL and passed to U-Boot
+ proper. If TPL also has a bloblist, then SPL uses the one from there.
+
+config TPL_BLOBLIST
+   bool "Support for a bloblist in TPL"
+   depends on BLOBLIST
+   default y if TPL
+   help
+ This enables a bloblist in TPL. The bloblist is set up in TPL and
+ passed to SPL and U-Boot proper.
+
+config BLOBLIST_SIZE
+   hex "Size of bloblist"
+   depends on BLOBLIST
+   default 0x400
+   help
+ Sets the size of the bloblist in bytes. This must include all
+ overhead (alignment, bloblist header, record header). The bloblist
+ is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
+ proper), and this sane bloblist is used for subsequent stages.
+
+config BLOBLIST_ADDR
+   hex "Address of bloblist"
+   depends on BLOBLIST
+   default 0xe000 if SANDBOX
+   help
+ Sets the address of the bloblist, set up by the first part of U-Boot
+ which runs. Subsequent U-Boot stages typically use the same address.
+
+endmenu
+
 source "common/spl/Kconfig"
diff --git a/common/Makefile b/common/Makefile
index d18897b973b..3d97a0dceae 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
 endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
+obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
 
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_DFU_SUPPORT
diff --git a/common/bloblist.c b/common/bloblist.c
new file mode 100644
index 000..b4cf169b05a
--- /dev/null
+++ b/common/bloblist.c
@@ -0,0 +1,239 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google, Inc
+ * Written by Simon Glass 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr)
+{
+   if (hdr->alloced <= hdr->hdr_size)
+   return NULL;
+   return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size);
+}
+
+struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr,
+   struct bloblist_rec *rec)
+{
+   ulong offset;
+
+   offset = (void *)rec - (void *)hdr;
+   offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN);
+   if (offset >= hdr->alloced)
+   return NULL;
+   return (struct bloblist_rec *)((void *)hdr + offset);
+}
+
+#define foreach_rec(_rec, _hdr) \
+   for (_rec = bloblist_first_blob(_hdr); \
+_rec; \
+_rec = bloblist_next_blob(_hdr, _rec))
+
+static struct bloblist_rec *bloblist_findrec(uint tag)
+{
+   struct bloblist_hdr *hdr = gd->bloblist;
+   struct bloblist_rec *rec;
+
+   if (!hdr)
+   return NULL;
+
+   foreach_rec(rec, hdr) 

[U-Boot] [PATCH v3 09/21] spl: Make SPL_DISABLE_BANNER_PRINT a positive option

2018-11-15 Thread Simon Glass
Rather than having a negative option, make this a positive option and
enable it by default. This makes it easier to understand.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/spl/Kconfig | 17 +
 common/spl/spl.c   |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 365e692d8b5..32fa5758bf6 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -135,12 +135,21 @@ config SPL_SEPARATE_BSS
  location is used. Normally we put the device tree at the end of BSS
  but with this option enabled, it goes at _image_binary_end.
 
-config SPL_DISABLE_BANNER_PRINT
-   bool "Disable output of the SPL banner 'U-Boot SPL ...'"
+config SPL_BANNER_PRINT
+   bool "Enable output of the SPL banner 'U-Boot SPL ...'"
+   default y
+   help
+ If this option is enabled, SPL will print the banner with version
+ info. Disabling this option could be useful to reduce TPL boot time
+ (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
+
+config TPL_BANNER_PRINT
+   bool "Enable output of the TPL banner 'U-Boot TPL ...'"
+   default y
help
  If this option is enabled, SPL will not print the banner with version
- info. Selecting this option could be useful to reduce SPL boot time
- (e.g. approx. 6 ms slower, when output on i.MX6 with 115200 baud).
+ info. Disabling this option could be useful to reduce SPL boot time
+ (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
 
 config SPL_DISPLAY_PRINT
bool "Display a board-specific message in SPL"
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 23be33c5c10..5a026b844e9 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -607,7 +607,7 @@ void preloader_console_init(void)
 
gd->have_console = 1;
 
-#ifndef CONFIG_SPL_DISABLE_BANNER_PRINT
+#if CONFIG_IS_ENABLED(BANNER_PRINT)
puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - "
 U_BOOT_TIME " " U_BOOT_TZ ")\n");
 #endif
-- 
2.19.1.1215.g8438c0b245-goog

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


[U-Boot] [PATCH v3 01/21] spl: Add support for logging in SPL and TPL

2018-11-15 Thread Simon Glass
It is sometimes useful to log information in SPL and TPL. Add support for
this.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3:
- Add comments to the log_ret() functions to indicate usage
- Update log_msg_ret() to make use of the message and avoid a warning

Changes in v2: None

 common/Kconfig   | 36 ++--
 common/Makefile  |  4 ++--
 common/spl/spl.c |  7 +++
 include/log.h| 19 +--
 4 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index d7300c212f5..9bc329a0e61 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -290,6 +290,10 @@ config SPL_LOGLEVEL
int
default LOGLEVEL
 
+config TPL_LOGLEVEL
+   int
+   default LOGLEVEL
+
 config SILENT_CONSOLE
bool "Support a silent console"
help
@@ -486,6 +490,24 @@ config SPL_LOG_MAX_LEVEL
6 - detail
7 - debug
 
+config TPL_LOG_MAX_LEVEL
+   int "Maximum log level to record in TPL"
+   depends on TPL_LOG
+   default 3
+   help
+ This selects the maximum log level that will be recorded. Any value
+ higher than this will be ignored. If possible log statements below
+ this level will be discarded at build time. Levels:
+
+   0 - panic
+   1 - critical
+   2 - error
+   3 - warning
+   4 - note
+   5 - info
+   6 - detail
+   7 - debug
+
 config LOG_CONSOLE
bool "Allow log output to the console"
depends on LOG
@@ -496,9 +518,19 @@ config LOG_CONSOLE
  log message is shown - other details like level, category, file and
  line number are omitted.
 
-config LOG_SPL_CONSOLE
+config SPL_LOG_CONSOLE
+   bool "Allow log output to the console in SPL"
+   depends on SPL_LOG
+   default y
+   help
+ Enables a log driver which writes log records to the console.
+ Generally the console is the serial port or LCD display. Only the
+ log message is shown - other details like level, category, file and
+ line number are omitted.
+
+config TPL_LOG_CONSOLE
bool "Allow log output to the console in SPL"
-   depends on LOG_SPL
+   depends on TPL_LOG
default y
help
  Enables a log driver which writes log records to the console.
diff --git a/common/Makefile b/common/Makefile
index a2388364d9f..d18897b973b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -118,8 +118,8 @@ obj-y += cli.o
 obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
 obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 obj-y += command.o
-obj-$(CONFIG_$(SPL_)LOG) += log.o
-obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
+obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
+obj-$(CONFIG_$(SPL_TPL_)LOG_CONSOLE) += log_console.o
 obj-y += s_record.o
 obj-$(CONFIG_CMD_LOADB) += xyzModem.o
 obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 12f9359c0ac..740182a8be6 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -336,6 +336,13 @@ static int spl_common_init(bool setup_malloc)
return ret;
}
bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
+#if CONFIG_IS_ENABLED(LOG)
+   ret = log_init();
+   if (ret) {
+   debug("%s: Failed to set up logging\n", __func__);
+   return ret;
+   }
+#endif
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = fdtdec_setup();
if (ret) {
diff --git a/include/log.h b/include/log.h
index a872fc6ef5f..ad6870bfed8 100644
--- a/include/log.h
+++ b/include/log.h
@@ -107,6 +107,8 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
 #define log_io(_fmt...)
 #endif
 
+#if CONFIG_IS_ENABLED(LOG)
+
 /* Emit a log record if the level is less that the maximum */
 #define log(_cat, _level, _fmt, _args...) ({ \
int _l = _level; \
@@ -115,6 +117,9 @@ int _log(enum log_category_t cat, enum log_level_t level, 
const char *file,
  __func__, \
  pr_fmt(_fmt), ##_args); \
})
+#else
+#define log(_cat, _level, _fmt, _args...)
+#endif
 
 #ifdef DEBUG
 #define _DEBUG 1
@@ -174,7 +179,16 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
({ if (!(x) && _DEBUG) \
__assert_fail(#x, __FILE__, __LINE__, __func__); })
 
-#ifdef CONFIG_LOG_ERROR_RETURN
+#if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN)
+/*
+ * Log an error return value, possibly with a message. Usage:
+ *
+ * return log_ret(fred_call());
+ *
+ * or:
+ *
+ * return log_msg_ret("fred failed", fred_call());
+ */
 #define log_ret(_ret) ({ \
int __ret = (_ret); \
if (__ret < 0) \
@@ -189,8 +203,9 @@ void __assert_fail(const char *assertion, const char *file, 
unsigned int line,
__ret; \
})

[U-Boot] [PATCH v3 08/21] spl: Add a define for SPL_TPL_PROMPT

2018-11-15 Thread Simon Glass
We should use a macro rather than hard-coding the SPL prompt to 'spl'
since the code can be used by TPL too. Add a macro that works for both
and use it in various places.

This allows TPL to use the same code without printing confusing messages.

Note that the string is lower case ('spl', 'tpl') which is a change from
previously.

Reviewed-by: Tom Rini 
Signed-off-by: Simon Glass 
---

Changes in v3: None
Changes in v2: None

 common/spl/spl.c   | 27 +++
 include/spl.h  | 13 +
 test/py/u_boot_console_base.py |  2 +-
 3 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index eea92ec1f8c..23be33c5c10 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -58,8 +58,9 @@ __weak void show_boot_progress(int val) {}
 #ifdef CONFIG_SPL_OS_BOOT
 __weak int spl_start_uboot(void)
 {
-   puts("SPL: Please implement spl_start_uboot() for your board\n");
-   puts("SPL: Direct Linux boot not active!\n");
+   puts(SPL_TPL_PROMPT
+"Please implement spl_start_uboot() for your board\n");
+   puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n");
return 1;
 }
 
@@ -101,13 +102,13 @@ void spl_fixup_fdt(void)
/* fixup the memory dt node */
err = fdt_shrink_to_minimum(fdt_blob, 0);
if (err == 0) {
-   printf("spl: fdt_shrink_to_minimum err - %d\n", err);
+   printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
return;
}
 
err = arch_fixup_fdt(fdt_blob);
if (err) {
-   printf("spl: arch_fixup_fdt err - %d\n", err);
+   printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err);
return;
}
 #endif
@@ -186,7 +187,7 @@ static int spl_load_fit_image(struct spl_image_info 
*spl_image,
spl_image->os = IH_OS_U_BOOT;
spl_image->name = "U-Boot";
 
-   debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+   debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
  spl_image->name, spl_image->load_addr, spl_image->size);
 
 #ifdef CONFIG_SPL_FIT_SIGNATURE
@@ -256,7 +257,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
}
spl_image->os = image_get_os(header);
spl_image->name = image_get_name(header);
-   debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+   debug(SPL_TPL_PROMPT
+ "payload image: %32s load addr: 0x%lx size: %d\n",
  spl_image->name, spl_image->load_addr, spl_image->size);
 #else
/* LEGACY image not supported */
@@ -285,7 +287,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
spl_image->size = end - start;
-   debug("spl: payload zImage, load addr: 0x%lx size: 
%d\n",
+   debug(SPL_TPL_PROMPT
+ "payload zImage, load addr: 0x%lx size: %d\n",
  spl_image->load_addr, spl_image->size);
return 0;
}
@@ -469,7 +472,7 @@ static int boot_from_devices(struct spl_image_info 
*spl_image,
if (loader)
printf("Trying to boot from %s\n", loader->name);
else
-   puts("SPL: Unsupported Boot Device!\n");
+   puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
 #endif
if (loader && !spl_load_image(spl_image, loader)) {
spl_image->boot_device = spl_boot_list[i];
@@ -492,7 +495,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
struct spl_image_info spl_image;
int ret;
 
-   debug(">>spl:board_init_r()\n");
+   debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
 
spl_set_bd();
 
@@ -532,7 +535,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
if (boot_from_devices(_image, spl_boot_list,
  ARRAY_SIZE(spl_boot_list))) {
-   puts("SPL: failed to boot from all boot devices\n");
+   puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");
hang();
}
 
@@ -605,8 +608,8 @@ void preloader_console_init(void)
gd->have_console = 1;
 
 #ifndef CONFIG_SPL_DISABLE_BANNER_PRINT
-   puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
-   U_BOOT_TIME " " U_BOOT_TZ ")\n");
+   puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - "
+U_BOOT_TIME " " U_BOOT_TZ ")\n");
 #endif
 #ifdef CONFIG_SPL_DISPLAY_PRINT
spl_display_print();
diff --git a/include/spl.h b/include/spl.h
index a56032ae3eb..205aaff4b9d 100644
--- a/include/spl.h

[U-Boot] [PATCH v3 00/21] spl: Add features for passing info from SPL to U-Boot proper

2018-11-15 Thread Simon Glass
At present we have no standard way of passing information from SPL to
U-Boot. Such information may be the size of DRAM banks or some information
about the reset state of the machine,for example.

This series first adds a bloblist, which allows a list of 'blobs' to be
created, each with a tag so that subsystems can store data and retrieve it
later. Then it adds the SPL 'handoff' information, which uses bloblist.

Various minor sandbox enhancements are provided to make this easier, or to
support testing.

Changes in v3:
- Add comments to the log_ret() functions to indicate usage
- Update log_msg_ret() to make use of the message and avoid a warning
- Correct CONFIG_BLOBLIST_ADDR to have a default only for sandbox
- Drop patch 'spl: Print a message if we are unable to load an image'

Changes in v2:
- Fix several typos
- Add back a blank line, and put one in the new function too
- Drop the wildcard in the .lds file as it is not needed

Simon Glass (21):
  spl: Add support for logging in SPL and TPL
  Add core support for a bloblist to convey data from SPL
  spl: Set up the bloblist in SPL
  bloblist: Locate bloblist in U-Boot
  test: Add a simple test for bloblist
  Add bloblist documentation
  spl: Support hash, input, pch, pci, rtc, tpm in SPL
  spl: Add a define for SPL_TPL_PROMPT
  spl: Make SPL_DISABLE_BANNER_PRINT a positive option
  spl: Add a comment to spl_set_bd()
  sandbox: Add a memory map to the sandbox README
  test/py: Add a way to pass flags to sandbox
  sandbox: Add an option to display of-platdata in SPL
  sandbox: Drop the deprecated 'sb' command
  sandbox: Add a new 'sb' command
  sandbox: Allow puts() output before global_data is set up
  sandbox: Refactor code to create os_jump_to_file()
  sandbox: Use malloc() and free() from os layer
  sandbox: Filter arguments when starting U-Boot
  sandbox: Boot in U-Boot through the standard call
  spl: Add support for passing handoff info to U-Boot proper

 arch/Kconfig   |   1 +
 arch/powerpc/include/asm/spl.h |   3 -
 arch/sandbox/cpu/eth-raw-os.c  |   9 +-
 arch/sandbox/cpu/os.c  | 115 +-
 arch/sandbox/cpu/spl.c |  31 +++-
 arch/sandbox/cpu/start.c   |  19 +++
 arch/sandbox/cpu/u-boot-spl.lds|   2 +-
 arch/sandbox/include/asm/handoff.h |  18 +++
 arch/sandbox/include/asm/state.h   |   8 +
 board/sandbox/README.sandbox   |  14 +-
 cmd/Makefile   |   1 +
 cmd/host.c |   5 -
 cmd/sb.c   |  65 
 common/Kconfig |  84 +-
 common/Makefile|   5 +-
 common/bloblist.c  | 239 +
 common/board_f.c   |  49 ++
 common/console.c   |   7 +
 common/init/Makefile   |   1 +
 common/init/handoff.c  |  47 ++
 common/spl/Kconfig |  95 +++-
 common/spl/spl.c   | 135 
 configs/sandbox_spl_defconfig  |   1 +
 doc/README.bloblist|  82 ++
 doc/README.trace   |   2 +-
 drivers/Makefile   |  11 +-
 include/asm-generic/global_data.h  |   7 +
 include/bloblist.h | 195 +++
 include/handoff.h  |  36 +
 include/log.h  |  20 ++-
 include/spl.h  |  41 +
 include/test/suites.h  |   1 +
 test/Makefile  |   1 +
 test/bloblist.c| 187 ++
 test/cmd_ut.c  |   3 +
 test/dm/sf.c   |   2 +-
 test/py/tests/test_fit.py  |  12 +-
 test/py/tests/test_handoff.py  |  14 ++
 test/py/tests/test_ofplatdata.py   |  31 +++-
 test/py/tests/test_vboot.py|   2 +-
 test/py/u_boot_console_base.py |   2 +-
 test/py/u_boot_console_sandbox.py  |  18 +++
 test/run   |   2 +-
 43 files changed, 1516 insertions(+), 107 deletions(-)
 create mode 100644 arch/sandbox/include/asm/handoff.h
 create mode 100644 cmd/sb.c
 create mode 100644 common/bloblist.c
 create mode 100644 common/init/handoff.c
 create mode 100644 doc/README.bloblist
 create mode 100644 include/bloblist.h
 create mode 100644 include/handoff.h
 create mode 100644 test/bloblist.c
 create mode 100644 test/py/tests/test_handoff.py

-- 
2.19.1.1215.g8438c0b245-goog

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


Re: [U-Boot] [PATCH v2 01/23] log: Correct definition of log_msg_ret()

2018-11-15 Thread Bin Meng
Hi Simon,

On Fri, Nov 16, 2018 at 8:08 AM Simon Glass  wrote:
>
> Hi Bin,
>
> On 4 October 2018 at 02:25, Bin Meng  wrote:
> >
> > Hi Simon,
> >
> > On Tue, Oct 2, 2018 at 8:25 PM Simon Glass  wrote:
> > >
> > > This macro should have two parameters, not one. Fix it so that it
> > > correctly resolves to _ret when logging is disabled.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > Changes in v2: None
> > >
> > >  include/log.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/include/log.h b/include/log.h
> > > index 653fb8d853e..75ff1e1160c 100644
> > > --- a/include/log.h
> > > +++ b/include/log.h
> > > @@ -175,7 +175,7 @@ void __assert_fail(const char *assertion, const char 
> > > *file, unsigned int line,
> > > })
> > >  #else
> > >  #define log_ret(_ret) (_ret)
> > > -#define log_msg_ret(_ret) (_ret)
> > > +#define log_msg_ret(_msg, _ret) (_ret)
> >
> > This creates a warning still if logging is disabled.
> >
> > include/log.h:178:33: warning: statement with no effect [-Wunused-value]
> >  #define log_msg_ret(_msg, _ret) (_ret)
>
> It has to be used in a 'return' statement. I'll add a comment in the
> first patch of the spl handoff series.
>

Yes, it seems I have noticed this and see my patch here :)
http://patchwork.ozlabs.org/patch/996894/

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


[U-Boot] [PATCH v2 6/6] efi_selftest: add HII database protocols test

2018-11-15 Thread AKASHI Takahiro
This efi_selftest tests HII database protocol and HII string protocol.

Signed-off-by: AKASHI Takahiro 
---
 lib/efi_selftest/Makefile|1 +
 lib/efi_selftest/efi_selftest_hii.c  | 1046 ++
 lib/efi_selftest/efi_selftest_hii_data.c |  452 ++
 3 files changed, 1499 insertions(+)
 create mode 100644 lib/efi_selftest/efi_selftest_hii.c
 create mode 100644 lib/efi_selftest/efi_selftest_hii_data.c

diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
index 4b1c0bb84b18..1209b54b07cd 100644
--- a/lib/efi_selftest/Makefile
+++ b/lib/efi_selftest/Makefile
@@ -25,6 +25,7 @@ efi_selftest_exception.o \
 efi_selftest_exitbootservices.o \
 efi_selftest_fdt.o \
 efi_selftest_gop.o \
+efi_selftest_hii.o \
 efi_selftest_loaded_image.o \
 efi_selftest_manageprotocols.o \
 efi_selftest_rtc.o \
diff --git a/lib/efi_selftest/efi_selftest_hii.c 
b/lib/efi_selftest/efi_selftest_hii.c
new file mode 100644
index ..16d7b608297e
--- /dev/null
+++ b/lib/efi_selftest/efi_selftest_hii.c
@@ -0,0 +1,1046 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * efi_selftest_hii
+ *
+ * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited
+ *
+ * Test HII database protocols
+ */
+
+#include 
+#include 
+#include "efi_selftest_hii_data.c"
+
+#define PRINT_TESTNAME efi_st_printf("%s:\n", __func__)
+
+static struct efi_boot_services *boottime;
+
+static const efi_guid_t hii_database_protocol_guid =
+   EFI_HII_DATABASE_PROTOCOL_GUID;
+static const efi_guid_t hii_string_protocol_guid =
+   EFI_HII_STRING_PROTOCOL_GUID;
+
+static struct efi_hii_database_protocol *hii_database_protocol;
+static struct efi_hii_string_protocol *hii_string_protocol;
+
+/*
+ * Setup unit test.
+ *
+ * @handle:handle of the loaded image
+ * @systable:  system table
+ *
+ * @return:EFI_ST_SUCCESS for success
+ */
+static int setup(const efi_handle_t handle,
+const struct efi_system_table *systable)
+{
+   efi_status_t ret;
+
+   boottime = systable->boottime;
+
+   /* HII database protocol */
+   ret = boottime->locate_protocol(_database_protocol_guid, NULL,
+   (void **)_database_protocol);
+   if (ret != EFI_SUCCESS) {
+   hii_database_protocol = NULL;
+   efi_st_error("HII database protocol is not available.\n");
+   return EFI_ST_FAILURE;
+   }
+
+   /* HII string protocol */
+   ret = boottime->locate_protocol(_string_protocol_guid, NULL,
+   (void **)_string_protocol);
+   if (ret != EFI_SUCCESS) {
+   hii_string_protocol = NULL;
+   efi_st_error("HII string protocol is not available.\n");
+   return EFI_ST_FAILURE;
+   }
+
+   return EFI_ST_SUCCESS;
+}
+
+/*
+ * HII database protocol tests
+ */
+
+/**
+ * test_hii_database_new_package_list() - test creation and removal of
+ * package list
+ *
+ * This test adds a new package list and then tries to remove it using
+ * the provided handle.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_new_package_list(void)
+{
+   efi_hii_handle_t handle;
+   efi_status_t ret;
+
+   PRINT_TESTNAME;
+   ret = hii_database_protocol->new_package_list(hii_database_protocol,
+   (struct efi_hii_package_list_header *)packagelist1,
+   NULL, );
+   if (ret != EFI_SUCCESS || !handle) {
+   efi_st_error("new_package_list returned %u\n",
+(unsigned int)ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = hii_database_protocol->remove_package_list(hii_database_protocol,
+   handle);
+   if (ret != EFI_SUCCESS) {
+   efi_st_error("remove_package_list returned %u\n",
+(unsigned int)ret);
+   return EFI_ST_FAILURE;
+   }
+
+   return EFI_ST_SUCCESS;
+}
+
+/**
+ * test_hii_database_update_package_list() - test update of package list
+ *
+ * This test adds a new package list and then tries to update it using
+ * another package list.
+ *
+ * @Return: status code
+ */
+static int test_hii_database_update_package_list(void)
+{
+   efi_hii_handle_t handle = NULL;
+   efi_status_t ret;
+   int result = EFI_ST_FAILURE;
+
+   PRINT_TESTNAME;
+   ret = hii_database_protocol->new_package_list(hii_database_protocol,
+   (struct efi_hii_package_list_header *)packagelist1,
+   NULL, );
+   if (ret != EFI_SUCCESS || !handle) {
+   efi_st_error("new_package_list returned %u\n",
+(unsigned int)ret);
+   return EFI_ST_FAILURE;
+   }
+
+   ret = hii_database_protocol->update_package_list(hii_database_protocol,
+   handle,
+   (struct efi_hii_package_list_header *)packagelist2);
+   if 

[U-Boot] [PATCH v2 5/6] efi: hii: add HII config routing/access protocols

2018-11-15 Thread AKASHI Takahiro
This patch is a place holder for HII configuration routing protocol and
HII configuration access protocol.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h   | 157 
 include/efi_loader.h|   4 +
 lib/efi_loader/Makefile |   2 +-
 lib/efi_loader/efi_boottime.c   |   6 ++
 lib/efi_loader/efi_hii_config.c | 146 +
 5 files changed, 314 insertions(+), 1 deletion(-)
 create mode 100644 lib/efi_loader/efi_hii_config.c

diff --git a/include/efi_api.h b/include/efi_api.h
index 76d7377bd2bb..b224afc28ba9 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -699,6 +699,163 @@ struct efi_device_path_utilities_protocol {
 };
 
 typedef u16 efi_string_id_t;
+typedef u16 efi_question_id_t;
+typedef u16 efi_image_id_t;
+typedef u16 efi_form_id_t;
+
+#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
+   EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \
+0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)
+
+struct efi_hii_config_routing_protocol {
+   efi_status_t(EFIAPI *extract_config)(
+   const struct efi_hii_config_routing_protocol *this,
+   const efi_string_t request,
+   efi_string_t *progress,
+   efi_string_t *results);
+   efi_status_t(EFIAPI *export_config)(
+   const struct efi_hii_config_routing_protocol *this,
+   efi_string_t *results);
+   efi_status_t(EFIAPI *route_config)(
+   const struct efi_hii_config_routing_protocol *this,
+   const efi_string_t configuration,
+   efi_string_t *progress);
+   efi_status_t(EFIAPI *block_to_config)(
+   const struct efi_hii_config_routing_protocol *this,
+   const efi_string_t config_request,
+   const uint8_t *block,
+   const efi_uintn_t block_size,
+   efi_string_t *config,
+   efi_string_t *progress);
+   efi_status_t(EFIAPI *config_to_block)(
+   const struct efi_hii_config_routing_protocol *this,
+   const efi_string_t config_resp,
+   const uint8_t *block,
+   const efi_uintn_t *block_size,
+   efi_string_t *progress);
+   efi_status_t(EFIAPI *get_alt_config)(
+   const struct efi_hii_config_routing_protocol *this,
+   const efi_string_t config_resp,
+   const efi_guid_t *guid,
+   const efi_string_t name,
+   const struct efi_device_path *device_path,
+   const efi_string_t alt_cfg_id,
+   efi_string_t *alt_cfg_resp);
+};
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
+   EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \
+0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85)
+
+struct efi_hii_time {
+   u8 hour;
+   u8 minute;
+   u8 second;
+};
+
+struct efi_hii_date {
+   u16 year;
+   u8 month;
+   u8 day;
+};
+
+struct efi_hii_ref {
+   efi_question_id_t question_id;
+   efi_form_id_t form_id;
+   efi_guid_t form_set_guid;
+   efi_string_id_t device_path;
+};
+
+union efi_ifr_type_value {
+   u8 u8;  // EFI_IFR_TYPE_NUM_SIZE_8
+   u16 u16;// EFI_IFR_TYPE_NUM_SIZE_16
+   u32 u32;// EFI_IFR_TYPE_NUM_SIZE_32
+   u64 u64;// EFI_IFR_TYPE_NUM_SIZE_64
+   bool b; // EFI_IFR_TYPE_BOOLEAN
+   struct efi_hii_time time;   // EFI_IFR_TYPE_TIME
+   struct efi_hii_date date;   // EFI_IFR_TYPE_DATE
+   efi_string_id_t string; // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
+   struct efi_hii_ref ref; // EFI_IFR_TYPE_REF
+   // u8 buffer[]; // EFI_IFR_TYPE_BUFFER
+};
+
+#define EFI_IFR_TYPE_NUM_SIZE_80x00
+#define EFI_IFR_TYPE_NUM_SIZE_16   0x01
+#define EFI_IFR_TYPE_NUM_SIZE_32   0x02
+#define EFI_IFR_TYPE_NUM_SIZE_64   0x03
+#define EFI_IFR_TYPE_BOOLEAN   0x04
+#define EFI_IFR_TYPE_TIME  0x05
+#define EFI_IFR_TYPE_DATE  0x06
+#define EFI_IFR_TYPE_STRING0x07
+#define EFI_IFR_TYPE_OTHER 0x08
+#define EFI_IFR_TYPE_UNDEFINED 0x09
+#define EFI_IFR_TYPE_ACTION0x0A
+#define EFI_IFR_TYPE_BUFFER0x0B
+#define EFI_IFR_TYPE_REF   0x0C
+#define EFI_IFR_OPTION_DEFAULT 0x10
+#define EFI_IFR_OPTION_DEFAULT_MFG 0x20
+
+#define EFI_IFR_ONE_OF_OPTION_OP   0x09
+
+struct efi_ifr_op_header {
+   u8 opCode;
+   u8 length:7;
+   u8 scope:1;
+};
+
+struct efi_ifr_one_of_option {
+   struct efi_ifr_op_header header;
+   efi_string_id_t option;
+   u8 flags;
+   u8 type;
+   union efi_ifr_type_value value;
+};
+
+typedef efi_uintn_t efi_browser_action_t;
+
+#define EFI_BROWSER_ACTION_REQUEST_NONE0
+#define 

[U-Boot] [PATCH v2 4/6] efi: hii: add keyboard layout package support

2018-11-15 Thread AKASHI Takahiro
Allow for handling keyboard layout package in HII database protocol.

A package can be added or deleted in HII database protocol, but
we don't set 'current' keyboard layout as there is no driver that
requests a keyboard layout.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h|  11 +++
 lib/efi_loader/efi_hii.c | 141 +--
 2 files changed, 147 insertions(+), 5 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index f3a0b4396b5a..76d7377bd2bb 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -844,6 +844,17 @@ struct efi_hii_guid_package {
char data[];
 } __packed;
 
+/*
+ * Keyboard layout package
+ */
+
+struct efi_hii_keyboard_layout_package {
+   struct efi_hii_package_header header;
+   u8 layout_count;
+   u8 __pad;
+   struct efi_hii_keyboard_layout layout[];
+} __packed;
+
 typedef void *efi_hii_handle_t;
 
 struct efi_hii_database_protocol {
diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
index 036aa8eac956..fefe3a861387 100644
--- a/lib/efi_loader/efi_hii.c
+++ b/lib/efi_loader/efi_hii.c
@@ -17,6 +17,7 @@ const efi_guid_t efi_guid_hii_string_protocol = 
EFI_HII_STRING_PROTOCOL_GUID;
 const u32 hii_package_signature = 0x68696770; /* "higp" */
 
 static LIST_HEAD(efi_package_lists);
+static LIST_HEAD(efi_kb_layout_list);
 
 struct efi_hii_packagelist {
struct list_head link;
@@ -26,6 +27,7 @@ struct efi_hii_packagelist {
u32 max_string_id;
struct list_head string_tables; /* list of efi_string_table */
struct list_head guid_list;
+   struct list_head kb_layout_packages;
 
/* we could also track fonts, images, etc */
 };
@@ -53,6 +55,17 @@ struct efi_guid_data {
struct efi_hii_guid_package package;
 };
 
+struct efi_kb_layout_data {
+   struct list_head link;  /* in package */
+   struct list_head link_sys;  /* in global list */
+   struct efi_hii_keyboard_layout kb_layout;
+};
+
+struct efi_kb_layout_package_data {
+   struct list_head link;  /* in package_list */
+   struct list_head kb_layout_list;
+};
+
 static void free_strings_table(struct efi_string_table *stbl)
 {
int i;
@@ -213,6 +226,74 @@ add_guid_package(struct efi_hii_packagelist *hii,
return EFI_SUCCESS;
 }
 
+static void free_keyboard_layouts(struct efi_kb_layout_package_data *package)
+{
+   struct efi_kb_layout_data *data;
+
+   while (!list_empty(>kb_layout_list)) {
+   data = list_first_entry(>kb_layout_list,
+   struct efi_kb_layout_data,
+   link);
+   list_del(>link);
+   list_del(>link_sys);
+   free(data);
+   }
+}
+
+static void remove_keyboard_layout_package(struct efi_hii_packagelist *hii)
+{
+   struct efi_kb_layout_package_data *package;
+
+   while (!list_empty(>kb_layout_packages)) {
+   package = list_first_entry(>kb_layout_packages,
+  struct efi_kb_layout_package_data,
+  link);
+   free_keyboard_layouts(package);
+   list_del(>link);
+   free(package);
+   }
+}
+
+static efi_status_t
+add_keyboard_layout_package(struct efi_hii_packagelist *hii,
+   struct efi_hii_keyboard_layout_package
+   *kb_layout_package)
+{
+   struct efi_kb_layout_package_data *package;
+   struct efi_hii_keyboard_layout *layout;
+   struct efi_kb_layout_data *data;
+   int i;
+
+   package = malloc(sizeof(*package));
+   if (!package)
+   return EFI_OUT_OF_RESOURCES;
+   INIT_LIST_HEAD(>link);
+   INIT_LIST_HEAD(>kb_layout_list);
+
+   layout = _layout_package->layout[0];
+   for (i = 0; i < kb_layout_package->layout_count; i++) {
+   data = malloc(sizeof(*data) + layout->layout_length);
+   if (!data)
+   goto out;
+
+   memcpy(>kb_layout, layout, layout->layout_length);
+   list_add_tail(>link, >kb_layout_list);
+   list_add_tail(>link_sys, _kb_layout_list);
+
+   layout += layout->layout_length;
+   }
+
+   list_add_tail(>link, >kb_layout_packages);
+
+   return EFI_SUCCESS;
+
+out:
+   free_keyboard_layouts(package);
+   free(package);
+
+   return EFI_OUT_OF_RESOURCES;
+}
+
 static struct efi_hii_packagelist *new_packagelist(void)
 {
struct efi_hii_packagelist *hii;
@@ -222,6 +303,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
hii->max_string_id = 0;
INIT_LIST_HEAD(>string_tables);
INIT_LIST_HEAD(>guid_list);
+   INIT_LIST_HEAD(>kb_layout_packages);
 
return hii;
 }
@@ -230,6 +312,7 @@ static void free_packagelist(struct efi_hii_packagelist 
*hii)
 {

[U-Boot] [PATCH v2 2/6] efi_loader: Initial HII database protocols

2018-11-15 Thread AKASHI Takahiro
From: Leif Lindholm 

This patch provides enough implementation of the following protocols to
run EDKII's Shell.efi and UEFI SCT:

  * EfiHiiDatabaseProtocol
  * EfiHiiStringProtocol

Not implemented are:
  * ExportPackageLists()
  * RegisterPackageNotify()/UnregisterPackageNotify()
  * SetKeyboardLayout() (i.e. *current* keyboard layout)

HII database protocol can handle only:
  * GUID package
  * string package
  * keyboard layout package
  (The other packages, except Device path package, will be necessary
   for interactive and graphical UI.)

We'll fill in the rest once SCT is running properly so we can validate
the implementation against the conformance test suite.

Cc: Leif Lindholm 
Signed-off-by: Rob Clark 
Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h | 242 ++
 include/efi_loader.h  |   4 +
 lib/efi_loader/Makefile   |   1 +
 lib/efi_loader/efi_boottime.c |  12 +
 lib/efi_loader/efi_hii.c  | 886 ++
 5 files changed, 1145 insertions(+)
 create mode 100644 lib/efi_loader/efi_hii.c

diff --git a/include/efi_api.h b/include/efi_api.h
index 88a60070f6ab..427bbba59aed 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -17,6 +17,7 @@
 #define _EFI_API_H
 
 #include 
+#include 
 
 #ifdef CONFIG_EFI_LOADER
 #include 
@@ -697,6 +698,247 @@ struct efi_device_path_utilities_protocol {
uint16_t node_length);
 };
 
+typedef u16 efi_string_id_t;
+
+#define EFI_HII_DATABASE_PROTOCOL_GUID  \
+   EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \
+0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42)
+
+typedef enum {
+   EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR,
+   EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW,
+   EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO,
+   EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0,
+   EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6,
+   EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT,
+   EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE,
+   EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4,
+   EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9,
+   EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE,
+   EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2,
+   EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8,
+   EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13,
+   EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT,
+   EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3,
+   EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9,
+   EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE,
+   EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH,
+   EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2,
+   EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8,
+   EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT,
+   EFI_KEY_SLCK, EFI_KEY_PAUSE,
+} efi_key;
+
+struct efi_key_descriptor {
+   efi_key key;
+   u16 unicode;
+   u16 shifted_unicode;
+   u16 alt_gr_unicode;
+   u16 shifted_alt_gr_unicode;
+   u16 modifier;
+   u16 affected_attribute;
+};
+
+struct efi_hii_keyboard_layout {
+   u16 layout_length;
+   efi_guid_t guid;
+   u32 layout_descriptor_string_offset;
+   u8 descriptor_count;
+   struct efi_key_descriptor descriptors[];
+};
+
+struct efi_hii_package_list_header {
+   efi_guid_t package_list_guid;
+   u32 package_length;
+} __packed;
+
+/**
+ * struct efi_hii_package_header - EFI HII package header
+ *
+ * @fields:'fields' replaces the bit-fields defined in the EFI
+ * specification to to avoid possible compiler incompatibilities::
+ *
+ * u32 length:24;
+ * u32 type:8;
+ */
+struct efi_hii_package_header {
+   u32 fields;
+} __packed;
+
+#define __EFI_HII_PACKAGE_LEN_SHIFT0
+#define __EFI_HII_PACKAGE_TYPE_SHIFT   24
+#define __EFI_HII_PACKAGE_LEN_MASK 0xff
+#define __EFI_HII_PACKAGE_TYPE_MASK0xff
+
+#define EFI_HII_PACKAGE_HEADER(header, field) \
+   (((header)->fields >> __EFI_HII_PACKAGE_##field##_SHIFT) \
+& __EFI_HII_PACKAGE_##field##_MASK)
+#define efi_hii_package_len(header) \
+   EFI_HII_PACKAGE_HEADER(header, LEN)
+#define efi_hii_package_type(header) \
+   EFI_HII_PACKAGE_HEADER(header, TYPE)
+
+#define EFI_HII_PACKAGE_TYPE_ALL  0x00
+#define EFI_HII_PACKAGE_TYPE_GUID 0x01
+#define EFI_HII_PACKAGE_FORMS 0x02
+#define EFI_HII_PACKAGE_STRINGS   0x04
+#define EFI_HII_PACKAGE_FONTS 0x05
+#define EFI_HII_PACKAGE_IMAGES0x06
+#define 

[U-Boot] [PATCH v2 3/6] efi: hii: add guid package support

2018-11-15 Thread AKASHI Takahiro
Allow for handling GUID package in HII database protocol.

Signed-off-by: AKASHI Takahiro 
---
 include/efi_api.h|  9 
 lib/efi_loader/efi_hii.c | 48 +++-
 2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/include/efi_api.h b/include/efi_api.h
index 427bbba59aed..f3a0b4396b5a 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -835,6 +835,15 @@ efi_hii_sibt_string_ucs2_block_next(struct 
efi_hii_sibt_string_ucs2_block *blk)
(u16_strlen(blk->string_text) + 1) * 2;
 }
 
+/*
+ * Guid package
+ */
+struct efi_hii_guid_package {
+   struct efi_hii_package_header header;
+   efi_guid_t guid;
+   char data[];
+} __packed;
+
 typedef void *efi_hii_handle_t;
 
 struct efi_hii_database_protocol {
diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c
index 40034c27473d..036aa8eac956 100644
--- a/lib/efi_loader/efi_hii.c
+++ b/lib/efi_loader/efi_hii.c
@@ -25,6 +25,7 @@ struct efi_hii_packagelist {
efi_handle_t driver_handle;
u32 max_string_id;
struct list_head string_tables; /* list of efi_string_table */
+   struct list_head guid_list;
 
/* we could also track fonts, images, etc */
 };
@@ -47,6 +48,11 @@ struct efi_string_table {
struct efi_string_info *strings;
 };
 
+struct efi_guid_data {
+   struct list_head link;
+   struct efi_hii_guid_package package;
+};
+
 static void free_strings_table(struct efi_string_table *stbl)
 {
int i;
@@ -178,6 +184,35 @@ error:
return ret;
 }
 
+static void remove_guid_package(struct efi_hii_packagelist *hii)
+{
+   struct efi_guid_data *data;
+
+   while (!list_empty(>guid_list)) {
+   data = list_first_entry(>guid_list,
+   struct efi_guid_data, link);
+   list_del(>link);
+   free(data);
+   }
+}
+
+static efi_status_t
+add_guid_package(struct efi_hii_packagelist *hii,
+struct efi_hii_guid_package *package)
+{
+   struct efi_guid_data *data;
+
+   data = calloc(sizeof(*data), 1);
+   if (!data)
+   return EFI_OUT_OF_RESOURCES;
+
+   /* TODO: we don't know any about data field */
+   memcpy(>package, package, sizeof(*package));
+   list_add_tail(>link, >guid_list);
+
+   return EFI_SUCCESS;
+}
+
 static struct efi_hii_packagelist *new_packagelist(void)
 {
struct efi_hii_packagelist *hii;
@@ -186,6 +221,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
hii->signature = hii_package_signature;
hii->max_string_id = 0;
INIT_LIST_HEAD(>string_tables);
+   INIT_LIST_HEAD(>guid_list);
 
return hii;
 }
@@ -193,6 +229,7 @@ static struct efi_hii_packagelist *new_packagelist(void)
 static void free_packagelist(struct efi_hii_packagelist *hii)
 {
remove_strings_package(hii);
+   remove_guid_package(hii);
 
list_del(>link);
free(hii);
@@ -219,8 +256,8 @@ add_packages(struct efi_hii_packagelist *hii,
 
switch (efi_hii_package_type(package)) {
case EFI_HII_PACKAGE_TYPE_GUID:
-   printf("\tGuid package not supported\n");
-   ret = EFI_INVALID_PARAMETER;
+   ret = add_guid_package(hii,
+   (struct efi_hii_guid_package *)package);
break;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
@@ -355,8 +392,7 @@ update_package_list(const struct efi_hii_database_protocol 
*this,
 
switch (efi_hii_package_type(package)) {
case EFI_HII_PACKAGE_TYPE_GUID:
-   printf("\tGuid package not supported\n");
-   ret = EFI_INVALID_PARAMETER;
+   remove_guid_package(hii);
break;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
@@ -442,8 +478,8 @@ list_package_lists(const struct efi_hii_database_protocol 
*this,
case EFI_HII_PACKAGE_TYPE_ALL:
break;
case EFI_HII_PACKAGE_TYPE_GUID:
-   printf("\tGuid package not supported\n");
-   ret = EFI_INVALID_PARAMETER;
+   if (!list_empty(>guid_list))
+   break;
continue;
case EFI_HII_PACKAGE_FORMS:
printf("\tForm package not supported\n");
-- 
2.19.0

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


[U-Boot] [PATCH v2 1/6] lib: add u16_strcpy/strdup functions

2018-11-15 Thread AKASHI Takahiro
From: "Akashi, Takahiro" 

Add u16_strcpy() and u16_strdup(). The latter function will be
used later in implementing efi HII database protocol.

Signed-off-by: Akashi Takahiro 
---
 include/charset.h | 23 +++
 lib/charset.c | 29 +
 2 files changed, 52 insertions(+)

diff --git a/include/charset.h b/include/charset.h
index 4d45e246e515..65087f76d1fc 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -191,6 +191,29 @@ size_t u16_strlen(const u16 *in);
  */
 size_t u16_strnlen(const u16 *in, size_t count);
 
+/**
+ * u16_strcpy() - copy u16 string
+ *
+ * Copy u16 string pointed to by src, including terminating null word, to
+ * the buffer pointed to by dest.
+ *
+ * @dest:  destination buffer
+ * @src:   source buffer (null terminated)
+ * Return: 'dest' address
+ */
+u16 *u16_strcpy(u16 *dest, const u16 *src);
+
+/**
+ * u16_strdup() - duplicate u16 string
+ *
+ * Copy u16 string pointed to by src, including terminating null word, to a
+ * newly allocated buffer.
+ *
+ * @src:   source buffer (null terminated)
+ * Return: allocated new buffer on success, NULL on failure
+ */
+u16 *u16_strdup(const u16 *src);
+
 /**
  * utf16_to_utf8() - Convert an utf16 string to utf8
  *
diff --git a/lib/charset.c b/lib/charset.c
index 10557b9e753d..5e349ed5ee45 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -349,6 +349,35 @@ size_t u16_strnlen(const u16 *in, size_t count)
return i;
 }
 
+u16 *u16_strcpy(u16 *dest, const u16 *src)
+{
+   u16 *tmp = dest;
+
+   for (;; dest++, src++) {
+   *dest = *src;
+   if (!*src)
+   break;
+   }
+
+   return tmp;
+}
+
+u16 *u16_strdup(const u16 *src)
+{
+   u16 *new;
+
+   if (!src)
+   return NULL;
+
+   new = malloc((u16_strlen(src) + 1) * sizeof(u16));
+   if (!new)
+   return NULL;
+
+   u16_strcpy(new, src);
+
+   return new;
+}
+
 /* Convert UTF-16 to UTF-8.  */
 uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
 {
-- 
2.19.0

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


[U-Boot] [PATCH v2 0/6] efi_loader: add HII database protocol

2018-11-15 Thread AKASHI Takahiro
HII database protocol is the last missing (major?) piece of code so that
we can run unmodified EDKII's shell and UEFI SCT on EFI-enabled u-boot.

The original code was initially written by Leif and Rob a year ago[1],
and now I'm reworking it. The implementation has not been much
enhanced from the original, but I tried to give it clearer implementation
to be able to add more functionality easily later on.
I also addressed the comments by Alex[2] and added a self test on
request of Heinrich.

HII configuration routing protocol and access protocol have only
a skeleton and should be implemented when we need to have *drivers*
that require configuration mechanism.

# Please note that a bunch of warnings are generated by checkpatch.pl,
# but there are also good reasons for not fixing them.

Concerns (if any):
* missing features (see the commit log of patch#2)
* unaligned access to *packed* structure in a package list should be
  cared?

Changes in v2 (Nov 16, 2018)
* add some descriptions to newly added functions
* rename EFI_HII_PACKAGE_[TYPE|LEN]_* to __EFI_HII_PACKAGE_[TYPE|LEN]_*
  as they are of internal use only
* cast a return value (of efi_status_t) to "unsigned int" for printing

[1] https://lists.denx.de/pipermail/u-boot/2017-October/308999.html
[2] https://lists.denx.de/pipermail/u-boot/2017-October/309116.html

AKASHI Takahiro (4):
  efi: hii: add guid package support
  efi: hii: add keyboard layout package support
  efi: hii: add HII config routing/access protocols
  efi_selftest: add HII database protocols test

Akashi, Takahiro (1):
  lib: add u16_strcpy/strdup functions

Leif Lindholm (1):
  efi_loader: Initial HII database protocols

 include/charset.h|   23 +
 include/efi_api.h|  419 +
 include/efi_loader.h |8 +
 lib/charset.c|   29 +
 lib/efi_loader/Makefile  |1 +
 lib/efi_loader/efi_boottime.c|   18 +
 lib/efi_loader/efi_hii.c | 1053 ++
 lib/efi_loader/efi_hii_config.c  |  146 +++
 lib/efi_selftest/Makefile|1 +
 lib/efi_selftest/efi_selftest_hii.c  | 1046 +
 lib/efi_selftest/efi_selftest_hii_data.c |  452 ++
 11 files changed, 3196 insertions(+)
 create mode 100644 lib/efi_loader/efi_hii.c
 create mode 100644 lib/efi_loader/efi_hii_config.c
 create mode 100644 lib/efi_selftest/efi_selftest_hii.c
 create mode 100644 lib/efi_selftest/efi_selftest_hii_data.c

-- 
2.19.0

___
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

2018-11-15 Thread Ricardo Salveti
Hi Baruch,

On Wed, Nov 14, 2018 at 5:07 AM Baruch Siach  wrote:
>
> Hi Ricardo,
>
> On Tue, Nov 13, 2018 at 11:42:44AM -0200, Ricardo Salveti wrote:
> > On Thu, Sep 6, 2018 at 12:52 PM Fabio Estevam  wrote:
> > > On Thu, Sep 6, 2018 at 12:42 PM, Baruch Siach  wrote:
> > >
> > > > I tested current master successfully on Hummingboard2 with i.MX6 Solo
> > > > (SOM rev 1.5):
> > >
> > > Thanks for testing.
> > >
> > > It seems we need more information from Peter about the regression he 
> > > reported.
> > >
> > > It would be helpful if Peter could run a bisect so that we could
> > > understand where the regression is coming from.
> >
> > Finally got the time to test u-boot 2018.09 on my hummingboard 2 and I
> > can also confirm the boot issue with imx6q (Hummingboard 2 MicroSOM
> > i2eX iMX6D - rev 1.3).
> >
> > The patch set that introduced this regression was part of another pull
> > request, the one that introduces eMMC booting support (from Jon
> > Nettleton, e.g. 86e5a7fc13 and 19ed6063a5). After doing some more
> > testing it seems that the hang happens when trying to verify if the
> > board has eMMC during runtime (has_emmc -> mmc_get_op_cond(mmc)),
> > which is not the case for this SOM in particular (and probably why it
> > works fine on most rev 1.5-based SOMs, as eMMC is usually available
> > there).
> >
> > Tested with current u-boot master and the issue is still valid.
> >
> > Jon, did you have any issue when testing that patch set on SOMs
> > without eMMC support?
>
> I tested U-Boot successfully with SOM rev 1.3 (no eMMC) on Hummingboard2, as
> shown in my previous message on this thread.

Indeed, you tested with i.MX6Q, only difference is that mine is iMX6D,
but both without eMMC.

> What toolchain are you using?

Using GCC 8.2 from latest OpenEmbedded. Will try building with the
version you used to see if I get any different behavior.

> What do you see on the serial console?

It boots up to the point when it tries to find the emmc, and then it
basically hangs completely (tested with current master):

U-Boot SPL 2018.11+gf6206f8587 (Nov 16 2018 - 00:56:34 +)
Trying to boot from MMC1

U-Boot 2018.11+gf6206f8587 (Nov 16 2018 - 00:56:34 +)

CPU:   Freescale i.MX6D rev1.5 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 33C
Reset cause: POR
Board: MX6 HummingBoard2
DRAM:  1 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

No panel detected: default to HDMI
Display: HDMI (1024x768)
In:serial
Out:   serial
Err:   serial
---> hangs

Cheers,
-- 
Ricardo Salveti de Araujo
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot,v2,04/23] spl: Set up the bloblist in SPL

2018-11-15 Thread Simon Glass
Hi Tom,

On 15 November 2018 at 16:10, Tom Rini  wrote:
> On Thu, Nov 15, 2018 at 04:07:59PM -0800, Simon Glass wrote:
>> Hi Tom,
>>
>> On 9 November 2018 at 10:43, Tom Rini  wrote:
>> > On Tue, Oct 02, 2018 at 05:22:34AM -0600, Simon Glass wrote:
>> >> The bloblist is normally set up in SPL ready for use by U-Boot. Add
>> >> a simple implementation of this to the common SPL code.
>> >>
>> >> Signed-off-by: Simon Glass 
>> >> ---
>> >>
>> >> Changes in v2: None
>> >>
>> >>  common/spl/spl.c | 18 --
>> >>  include/spl.h| 27 +++
>> >>  2 files changed, 43 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> >> index b917624e61d..2ca900ae9ed 100644
>> >> --- a/common/spl/spl.c
>> >> +++ b/common/spl/spl.c
>> >> @@ -7,6 +7,7 @@
>> >>   */
>> >>
>> >>  #include 
>> >> +#include 
>> >>  #include 
>> >>  #include 
>> >>  #include 
>> >> @@ -345,6 +346,14 @@ static int spl_common_init(bool setup_malloc)
>> >>   return ret;
>> >>   }
>> >>  #endif
>> >> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
>> >> + ret = bloblist_init();
>> >> + if (ret) {
>> >> + debug("%s: Failed to set up bloblist: ret=%d\n",
>> >> +   __func__, ret);
>> >> + return ret;
>> >> + }
>> >> + }
>> >>   if (CONFIG_IS_ENABLED(OF_CONTROL) && 
>> >> !CONFIG_IS_ENABLED(OF_PLATDATA)) {
>> >>   ret = fdtdec_setup();
>> >>   if (ret) {
>> >> @@ -483,6 +492,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>> >>   BOOT_DEVICE_NONE,
>> >>   };
>> >>   struct spl_image_info spl_image;
>> >> + int ret;
>> >>
>> >>   debug(">>spl:board_init_r()\n");
>> >>
>> >> @@ -529,6 +539,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>> >>   }
>> >>
>> >>   spl_perform_fixups(_image);
>> >> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
>> >> + ret = bloblist_finish();
>> >> + if (ret)
>> >> + printf("Warning: Failed to finish bloblist 
>> >> (ret=%d)\n",
>> >> +ret);
>> >> + }
>> >>
>> >>  #ifdef CONFIG_CPU_V7M
>> >>   spl_image.entry_point |= 0x1;
>> >> @@ -558,8 +574,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>> >> gd->malloc_ptr / 1024);
>> >>  #endif
>> >>  #ifdef CONFIG_BOOTSTAGE_STASH
>> >> - int ret;
>> >> -
>> >>   bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
>> >>   ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
>> >> CONFIG_BOOTSTAGE_STASH_SIZE);
>> >
>> > I think we'll need a __maybe_unused on ret above for !BOOTSTAGE_STASH &&
>> > !BLOBLIST.
>> >
>>
>> The code for BLOBLIST uses if() rather than #if so it seems OK:
>>
>> if (CONFIG_IS_ENABLED(BLOBLIST)) {
>
> So long as it doesn't warn, OK :)

That's right. One of the benefits of if() is we can avoid #ifdefs
around local variables .

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


Re: [U-Boot] [U-Boot,v2,04/23] spl: Set up the bloblist in SPL

2018-11-15 Thread Simon Glass
Hi Tom,

On 9 November 2018 at 10:43, Tom Rini  wrote:
> On Tue, Oct 02, 2018 at 05:22:34AM -0600, Simon Glass wrote:
>> The bloblist is normally set up in SPL ready for use by U-Boot. Add
>> a simple implementation of this to the common SPL code.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>> Changes in v2: None
>>
>>  common/spl/spl.c | 18 --
>>  include/spl.h| 27 +++
>>  2 files changed, 43 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index b917624e61d..2ca900ae9ed 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -7,6 +7,7 @@
>>   */
>>
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -345,6 +346,14 @@ static int spl_common_init(bool setup_malloc)
>>   return ret;
>>   }
>>  #endif
>> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
>> + ret = bloblist_init();
>> + if (ret) {
>> + debug("%s: Failed to set up bloblist: ret=%d\n",
>> +   __func__, ret);
>> + return ret;
>> + }
>> + }
>>   if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
>>   ret = fdtdec_setup();
>>   if (ret) {
>> @@ -483,6 +492,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>   BOOT_DEVICE_NONE,
>>   };
>>   struct spl_image_info spl_image;
>> + int ret;
>>
>>   debug(">>spl:board_init_r()\n");
>>
>> @@ -529,6 +539,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>   }
>>
>>   spl_perform_fixups(_image);
>> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
>> + ret = bloblist_finish();
>> + if (ret)
>> + printf("Warning: Failed to finish bloblist (ret=%d)\n",
>> +ret);
>> + }
>>
>>  #ifdef CONFIG_CPU_V7M
>>   spl_image.entry_point |= 0x1;
>> @@ -558,8 +574,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>> gd->malloc_ptr / 1024);
>>  #endif
>>  #ifdef CONFIG_BOOTSTAGE_STASH
>> - int ret;
>> -
>>   bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
>>   ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
>> CONFIG_BOOTSTAGE_STASH_SIZE);
>
> I think we'll need a __maybe_unused on ret above for !BOOTSTAGE_STASH &&
> !BLOBLIST.
>

The code for BLOBLIST uses if() rather than #if so it seems OK:

if (CONFIG_IS_ENABLED(BLOBLIST)) {

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


Re: [U-Boot] [U-Boot, v2, 12/23] spl: Print a message if we are unable to load an image

2018-11-15 Thread Simon Glass
Hi Tom,

On 9 November 2018 at 10:43, Tom Rini  wrote:
> On Tue, Oct 02, 2018 at 05:22:42AM -0600, Simon Glass wrote:
>
>> It can confusing when U-Boot SPL hangs for no obvious reason, when it is
>> unable to load U-Boot. Add a message to indicate the cause.
>>
>> Signed-off-by: Simon Glass 
>> ---
>>
>> Changes in v2: None
>>
>>  common/spl/spl.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index 396c42e1e1b..512141c4139 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -485,6 +485,7 @@ static int boot_from_devices(struct spl_image_info 
>> *spl_image,
>>   return 0;
>>   }
>>   }
>> + puts(SPL_TPL_PROMPT "No more boot devices\n");
>>
>>   return -ENODEV;
>>  }
>
> Don't we have a similar debug() statement around this part of the boot
> flow?  It is annoying but I also think we ended up dropping it due to
> binary size issues.

Er yes you are right:

   puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");

I'll drop this patch.

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


Re: [U-Boot] [PATCH v2 01/23] log: Correct definition of log_msg_ret()

2018-11-15 Thread Simon Glass
Hi Bin,

On 4 October 2018 at 02:25, Bin Meng  wrote:
>
> Hi Simon,
>
> On Tue, Oct 2, 2018 at 8:25 PM Simon Glass  wrote:
> >
> > This macro should have two parameters, not one. Fix it so that it
> > correctly resolves to _ret when logging is disabled.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v2: None
> >
> >  include/log.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/log.h b/include/log.h
> > index 653fb8d853e..75ff1e1160c 100644
> > --- a/include/log.h
> > +++ b/include/log.h
> > @@ -175,7 +175,7 @@ void __assert_fail(const char *assertion, const char 
> > *file, unsigned int line,
> > })
> >  #else
> >  #define log_ret(_ret) (_ret)
> > -#define log_msg_ret(_ret) (_ret)
> > +#define log_msg_ret(_msg, _ret) (_ret)
>
> This creates a warning still if logging is disabled.
>
> include/log.h:178:33: warning: statement with no effect [-Wunused-value]
>  #define log_msg_ret(_msg, _ret) (_ret)

It has to be used in a 'return' statement. I'll add a comment in the
first patch of the spl handoff series.

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


Re: [U-Boot] [PATCH] mmc: Parse HS400 DT properties

2018-11-15 Thread Simon Glass
On 13 November 2018 at 15:39, Marek Vasut  wrote:
> Add HS400 properties parsing support to mmc_of_parse().
>
> Signed-off-by: Marek Vasut 
> Cc: Tom Rini 
> Cc: Jaehoon Chung 
> Cc: Jean-Jacques Hiblot 
> Cc: Kishon Vijay Abraham I 
> Cc: Peng Fan 
> Cc: Simon Glass 
> ---
>  drivers/mmc/mmc-uclass.c | 4 
>  1 file changed, 4 insertions(+)

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


Re: [U-Boot] [U-Boot,v2,04/23] spl: Set up the bloblist in SPL

2018-11-15 Thread Tom Rini
On Thu, Nov 15, 2018 at 04:07:59PM -0800, Simon Glass wrote:
> Hi Tom,
> 
> On 9 November 2018 at 10:43, Tom Rini  wrote:
> > On Tue, Oct 02, 2018 at 05:22:34AM -0600, Simon Glass wrote:
> >> The bloblist is normally set up in SPL ready for use by U-Boot. Add
> >> a simple implementation of this to the common SPL code.
> >>
> >> Signed-off-by: Simon Glass 
> >> ---
> >>
> >> Changes in v2: None
> >>
> >>  common/spl/spl.c | 18 --
> >>  include/spl.h| 27 +++
> >>  2 files changed, 43 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/common/spl/spl.c b/common/spl/spl.c
> >> index b917624e61d..2ca900ae9ed 100644
> >> --- a/common/spl/spl.c
> >> +++ b/common/spl/spl.c
> >> @@ -7,6 +7,7 @@
> >>   */
> >>
> >>  #include 
> >> +#include 
> >>  #include 
> >>  #include 
> >>  #include 
> >> @@ -345,6 +346,14 @@ static int spl_common_init(bool setup_malloc)
> >>   return ret;
> >>   }
> >>  #endif
> >> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
> >> + ret = bloblist_init();
> >> + if (ret) {
> >> + debug("%s: Failed to set up bloblist: ret=%d\n",
> >> +   __func__, ret);
> >> + return ret;
> >> + }
> >> + }
> >>   if (CONFIG_IS_ENABLED(OF_CONTROL) && 
> >> !CONFIG_IS_ENABLED(OF_PLATDATA)) {
> >>   ret = fdtdec_setup();
> >>   if (ret) {
> >> @@ -483,6 +492,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> >>   BOOT_DEVICE_NONE,
> >>   };
> >>   struct spl_image_info spl_image;
> >> + int ret;
> >>
> >>   debug(">>spl:board_init_r()\n");
> >>
> >> @@ -529,6 +539,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> >>   }
> >>
> >>   spl_perform_fixups(_image);
> >> + if (CONFIG_IS_ENABLED(BLOBLIST)) {
> >> + ret = bloblist_finish();
> >> + if (ret)
> >> + printf("Warning: Failed to finish bloblist 
> >> (ret=%d)\n",
> >> +ret);
> >> + }
> >>
> >>  #ifdef CONFIG_CPU_V7M
> >>   spl_image.entry_point |= 0x1;
> >> @@ -558,8 +574,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> >> gd->malloc_ptr / 1024);
> >>  #endif
> >>  #ifdef CONFIG_BOOTSTAGE_STASH
> >> - int ret;
> >> -
> >>   bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
> >>   ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
> >> CONFIG_BOOTSTAGE_STASH_SIZE);
> >
> > I think we'll need a __maybe_unused on ret above for !BOOTSTAGE_STASH &&
> > !BLOBLIST.
> >
> 
> The code for BLOBLIST uses if() rather than #if so it seems OK:
> 
> if (CONFIG_IS_ENABLED(BLOBLIST)) {

So long as it doesn't warn, OK :)

-- 
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 v3] cmd, fdt: add subcommand "get" to fdt header

2018-11-15 Thread Simon Glass
On 14 November 2018 at 21:06, Heiko Schocher  wrote:
> store fdt header member with name  in U-Boot
> Environment variable with name .
>
> for example to get the total length of the fdt and store
> it in filesize, call:
>
> fdt header get filesize totalsize
>
> For membernames look into fdt header definition at
> scripts/dtc/libfdt/libfdt.h
>
> Signed-off-by: Heiko Schocher 
> ---
>
> Changes in v3:
> - add comments from Marek
>   simplify for loop, use fdtp[i] -> drop ftdip++
>
> Changes in v2:
> - add obviously missing "static const char *"
>
>  cmd/fdt.c | 40 +++-
>  1 file changed, 39 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 

Should we have a test case for this?
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 3/4] hwspinlock: add stm32 hardware spinlock support

2018-11-15 Thread Simon Glass
On 14 November 2018 at 01:01, Benjamin Gaignard
 wrote:
> Implement hardware spinlock support for STM32MP1.
>
> Signed-off-by: Benjamin Gaignard 
> ---
> version 2:
> - remove useless include
> - add a private structure to store base address
> - be more verbose in configuration flag description
>
>  arch/arm/dts/stm32mp157c-ed1.dts  |  4 ++
>  arch/arm/dts/stm32mp157c.dtsi |  9 
>  configs/stm32mp15_basic_defconfig |  2 +
>  drivers/hwspinlock/Kconfig|  8 +++
>  drivers/hwspinlock/Makefile   |  1 +
>  drivers/hwspinlock/stm32_hwspinlock.c | 92 
> +++
>  6 files changed, 116 insertions(+)
>  create mode 100644 drivers/hwspinlock/stm32_hwspinlock.c

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


Re: [U-Boot] [PATCH v2 4/4] pinctrl: stm32: make pinctrl use hwspinlock

2018-11-15 Thread Simon Glass
On 14 November 2018 at 01:01, Benjamin Gaignard
 wrote:
> From: Benjamin Gaignard 
>
> Protect configuration registers with a hardware spinlock.
>
> If a hwspinlock is defined in the device-tree node used it
> to be sure that none of the others processors on the SoC could
> change the configuration at the same time.
>
> Signed-off-by: Benjamin Gaignard 
> ---
> version 2:
> - be more verbose in commit message
> - log the error after hwspinlock_get_by_index()
>
>  arch/arm/dts/stm32mp157c-ed1.dts |  4 
>  drivers/pinctrl/pinctrl_stm32.c  | 27 +++
>  2 files changed, 31 insertions(+)

Reviewed-by: Simon Glass 

with nit below

>
> diff --git a/arch/arm/dts/stm32mp157c-ed1.dts 
> b/arch/arm/dts/stm32mp157c-ed1.dts
> index fc277dd7d2..7a9b742d36 100644
> --- a/arch/arm/dts/stm32mp157c-ed1.dts
> +++ b/arch/arm/dts/stm32mp157c-ed1.dts
> @@ -369,6 +369,10 @@
> status = "okay";
>  };
>
> + {
> +   hwlocks = < 0>;
> +};
> +
>  _port0 {
> phy-supply = <_usb>;
> vdda1v1-supply = <>;
> diff --git a/drivers/pinctrl/pinctrl_stm32.c b/drivers/pinctrl/pinctrl_stm32.c
> index 31285cdd57..5b63a2de15 100644
> --- a/drivers/pinctrl/pinctrl_stm32.c
> +++ b/drivers/pinctrl/pinctrl_stm32.c
> @@ -1,6 +1,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -19,12 +20,20 @@ static int stm32_gpio_config(struct gpio_desc *desc,
>  {
> struct stm32_gpio_priv *priv = dev_get_priv(desc->dev);
> struct stm32_gpio_regs *regs = priv->regs;
> +   struct hwspinlock *hws = dev_get_priv(desc->dev->parent);

dev_get_parent()

> u32 index;
> +   int ret;
>
> if (!ctl || ctl->af > 15 || ctl->mode > 3 || ctl->otype > 1 ||
> ctl->pupd > 2 || ctl->speed > 3)
> return -EINVAL;
>
> +   ret = hwspinlock_lock_timeout(hws, 1);
> +   if (ret == -ETIME) {
> +   dev_err(desc->dev, "HWSpinlock timeout\n");
> +   return ret;
> +   }
> +
> index = (desc->offset & 0x07) * 4;
> clrsetbits_le32(>afr[desc->offset >> 3], AFR_MASK << index,
> ctl->af << index);
> @@ -39,6 +48,8 @@ static int stm32_gpio_config(struct gpio_desc *desc,
> index = desc->offset;
> clrsetbits_le32(>otyper, OTYPE_MSK << index, ctl->otype << 
> index);
>
> +   hwspinlock_unlock(hws);
> +
> return 0;
>  }
>
> @@ -176,6 +187,20 @@ static int stm32_pinctrl_set_state_simple(struct udevice 
> *dev,
>  }
>  #endif /* PINCTRL_FULL */
>
> +static int stm32_pinctrl_probe(struct udevice *dev)
> +{
> +   struct hwspinlock *hws = dev_get_priv(dev);
> +   int err;
> +
> +   /* hwspinlock property is optional, just log the error */
> +   err = hwspinlock_get_by_index(dev, 0, hws);
> +   if (err)
> +   debug("%s: hwspinlock_get_by_index may have failed (%d)\n",
> + __func__, err);
> +
> +   return 0;
> +}
> +
>  static struct pinctrl_ops stm32_pinctrl_ops = {
>  #if CONFIG_IS_ENABLED(PINCTRL_FULL)
> .set_state  = stm32_pinctrl_set_state,
> @@ -200,4 +225,6 @@ U_BOOT_DRIVER(pinctrl_stm32) = {
> .of_match   = stm32_pinctrl_ids,
> .ops= _pinctrl_ops,
> .bind   = dm_scan_fdt_dev,
> +   .probe  = stm32_pinctrl_probe,
> +   .priv_auto_alloc_size = sizeof(struct hwspinlock),
>  };
> --
> 2.15.0
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/4] clk: stm32: add hardware spinlock clock

2018-11-15 Thread Simon Glass
On 14 November 2018 at 01:01, Benjamin Gaignard
 wrote:
> From: Benjamin Gaignard 
>
> Add hardware spinlock in the list of the clocks.
>
> Signed-off-by: Benjamin Gaignard 
> ---
>  drivers/clk/clk_stm32mp1.c | 3 +++
>  1 file changed, 3 insertions(+)

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


Re: [U-Boot] [PATCH v2 1/4] dm: Add Hardware Spinlock class

2018-11-15 Thread Simon Glass
On 14 November 2018 at 01:01, Benjamin Gaignard
 wrote:
> From: Benjamin Gaignard 
>
> This is uclass for Hardware Spinlocks.
> It implements two mandatory operations: lock and unlock
> and one optional relax operation.
>
> Signed-off-by: Benjamin Gaignard 
> ---
> version 2:
> - use -ETIMEDOUT and -ENOSYS for errors cases
> - do not test if ops is valid
>
>  arch/sandbox/dts/test.dts   |   4 +
>  arch/sandbox/include/asm/state.h|   1 +
>  configs/sandbox_defconfig   |   2 +
>  drivers/Kconfig |   2 +
>  drivers/Makefile|   1 +
>  drivers/hwspinlock/Kconfig  |  16 
>  drivers/hwspinlock/Makefile |   6 ++
>  drivers/hwspinlock/hwspinlock-uclass.c  | 143 
> 
>  drivers/hwspinlock/sandbox_hwspinlock.c |  56 +
>  include/dm/uclass-id.h  |   1 +
>  include/hwspinlock.h| 140 +++
>  test/dm/Makefile|   1 +
>  test/dm/hwspinlock.c|  40 +
>  13 files changed, 413 insertions(+)
>  create mode 100644 drivers/hwspinlock/Kconfig
>  create mode 100644 drivers/hwspinlock/Makefile
>  create mode 100644 drivers/hwspinlock/hwspinlock-uclass.c
>  create mode 100644 drivers/hwspinlock/sandbox_hwspinlock.c
>  create mode 100644 include/hwspinlock.h
>  create mode 100644 test/dm/hwspinlock.c

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


Re: [U-Boot] [PATCH v2 1/1] efi_selftest: don't hang on missing timer

2018-11-15 Thread Auer, Lukas
On Wed, 2018-11-14 at 09:23 +0100, Alexander Graf wrote:
> On 11/12/2018 08:57 PM, Heinrich Schuchardt wrote:
> > qemu-riscv32_defconfig and qemu-riscv64_defconfig do not supply a
> > timer.
> > This causes the EFI selftest to hang on tests which require a
> > timer.
> > 
> > So let's disable CONFIG_TIMER for these boards and use this
> > variable to
> > decide which tests have to be disabled.
> > 
> > Signed-off-by: Heinrich Schuchardt 
> 
> Travis is quite unhappy about this:
> 
> riscv: +qemu-riscv64qemu-riscv32
> +lib/built-in.o: In function `tick_to_time':
> +lib/time.c:119: undefined reference to `get_tbclk'
> +lib/built-in.o: In function `usec_to_tick':
> +lib/time.c:145: undefined reference to `get_tbclk'
> +common/built-in.o: In function `cread_add_str':
> +common/cli_readline.c:239: undefined reference to `get_tbclk'
> 
> 
> 
> 
> Wouldn't it make more sense to just enable timer support for the
> qemu 
> riscv models instead?
> 
> I'll remove the patch from my queue for the time being.
> 
> 
> Alex

I think it makes sense to keep timer support for the RISC-V QEMU
targets enabled. Bin's patch series [1] adds timer support for the
RISC-V QEMU targets, so EFI selftest will not be broken for long.

Lukas

[1]: https://patchwork.ozlabs.org/project/uboot/list/?series=75644

> 
> > ---
> > v2:
> > add missing obj-y += \
> > ---
> >   configs/qemu-riscv32_defconfig |  1 +
> >   configs/qemu-riscv64_defconfig |  1 +
> >   lib/efi_selftest/Makefile  | 10 +++---
> >   3 files changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/configs/qemu-riscv32_defconfig b/configs/qemu-
> > riscv32_defconfig
> > index ff1fb1f30ec..70da323bdc1 100644
> > --- a/configs/qemu-riscv32_defconfig
> > +++ b/configs/qemu-riscv32_defconfig
> > @@ -3,4 +3,5 @@ CONFIG_TARGET_QEMU_VIRT=y
> >   CONFIG_NR_DRAM_BANKS=1
> >   CONFIG_DISPLAY_CPUINFO=y
> >   CONFIG_DISPLAY_BOARDINFO=y
> > +# CONFIG_TIMER is not set
> >   CONFIG_OF_BOARD=y
> > diff --git a/configs/qemu-riscv64_defconfig b/configs/qemu-
> > riscv64_defconfig
> > index d6c1a5d646a..258f395b9d5 100644
> > --- a/configs/qemu-riscv64_defconfig
> > +++ b/configs/qemu-riscv64_defconfig
> > @@ -4,4 +4,5 @@ CONFIG_CPU_RISCV_64=y
> >   CONFIG_NR_DRAM_BANKS=1
> >   CONFIG_DISPLAY_CPUINFO=y
> >   CONFIG_DISPLAY_BOARDINFO=y
> > +# CONFIG_TIMER is not set
> >   CONFIG_OF_BOARD=y
> > diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile
> > index 4b1c0bb84b1..aec498fbcf2 100644
> > --- a/lib/efi_selftest/Makefile
> > +++ b/lib/efi_selftest/Makefile
> > @@ -19,7 +19,6 @@ efi_selftest_console.o \
> >   efi_selftest_crc32.o \
> >   efi_selftest_devicepath.o \
> >   efi_selftest_devicepath_util.o \
> > -efi_selftest_events.o \
> >   efi_selftest_event_groups.o \
> >   efi_selftest_exception.o \
> >   efi_selftest_exitbootservices.o \
> > @@ -32,11 +31,16 @@ efi_selftest_snp.o \
> >   efi_selftest_textinput.o \
> >   efi_selftest_textinputex.o \
> >   efi_selftest_textoutput.o \
> > -efi_selftest_tpl.o \
> >   efi_selftest_unicode_collation.o \
> >   efi_selftest_util.o \
> > -efi_selftest_variables.o \
> > +efi_selftest_variables.o
> > +
> > +ifeq ($(CONFIG_TIMER),)
> > +obj-y += \
> > +efi_selftest_events.o \
> > +efi_selftest_tpl.o \
> >   efi_selftest_watchdog.o
> > +endif
> >   
> >   obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o
> >   
> 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/19] riscv: Do some basic architecture level cpu initialization

2018-11-15 Thread Auer, Lukas
Hi Bin,

On Tue, 2018-11-13 at 00:22 -0800, Bin Meng wrote:
> Implement arch_cpu_init() to do some basic architecture level cpu
> initialization, like FPU enable, etc.
> 
> Signed-off-by: Bin Meng 
> ---
> 
>  arch/riscv/cpu/cpu.c | 21 +
>  1 file changed, 21 insertions(+)
> 
> diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
> index d9f820c..4e508cf 100644
> --- a/arch/riscv/cpu/cpu.c
> +++ b/arch/riscv/cpu/cpu.c
> @@ -5,6 +5,7 @@
>  
>  #include 
>  #include 
> +#include 
>  
>  /*
>   * prior_stage_fdt_address must be stored in the data section since
> it is used
> @@ -53,3 +54,23 @@ int print_cpuinfo(void)
>  
>   return 0;
>  }
> +
> +int arch_cpu_init(void)
> +{
> + /* Enable FPU */
> + if (supports_extension('d') || supports_extension('f')) {
> + csr_write(mstatus, MSTATUS_FS);

This should use csr_set(), so that we don't overwrite the other mstatus
entries.

> + csr_write(fcsr, 0);

BBL also clears the floating point registers before clearing fcsr.
Coreboot does neither of these, I am not sure if they are required.

> + }
> +
> + /* Enable user/supervisor use of perf counters */
> + if (supports_extension('s'))
> + csr_write(scounteren, -1);
> + csr_write(mcounteren, -1);

Should we really enable all counters, and for both user and supervisor
code? I would tend to enable only the ones we need. How about only
enabling the cycle, time, and instret counters (the rest are not
currently used in the kernel) and only for supervisor code (so in
mcounteren)?

> +
> + /* Disable paging */
> + if (supports_extension('s'))
> + csr_write(sptbr, 0);

sptbr has been renamed to satp.

Thanks,
Lukas

> +
> + return 0;
> +}
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Getting rid of board_mtdparts_default()

2018-11-15 Thread Boris Brezillon
On Thu, 15 Nov 2018 23:18:46 +0100
Enric Balletbo Serra  wrote:

> Hello Boris,
> 
> Missatge de Boris Brezillon  del dia dj.,
> 15 de nov. 2018 a les 16:58:
> >
> > Hello Enric,
> >
> > Miquel and I recently reworked drivers/mtd/mtdpart.c to get MTD
> > partitions exposed as MTD devices (as is done in Linux) instead of
> > having yet another abstraction to handle them (see what's currently
> > done in cmd/{mtdparts,nand,sf,...}.c).
> >
> > This lead us to duplicate the mtdparts/mtdids parsing logic we found in
> > cmd/mtdparts.c, and while doing that we noticed that one function is
> > only implemented by igep boards: board_mtdparts_default().
> >
> > We'd like to get rid of this function if possible in order to simplify
> > the mtdparts/mtdids retrieval logic, and there might be an easy
> > solution to do that: use the CONFIG_{MTDPARTS,MTDIDS}_DEFAULT config
> > options
> >
> > CONFIG_MTDPARTS_DEFAULT="omap2-nand:512k(SPL),-(UBI);omap2-onenand:512k(SPL),-(UBI)"
> > CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand,onenand0=omap2-onenand"
> >
> > It seems those defaults were built at runtime, and the only thing I'm
> > not sure about is whether 512k for the SPL is always good. Looks like
> > 4 eraseblocks are reserved for the SPL [1], but is the eraseblock size
> > always 128k?  
> 
> No, there are boards in the field that doesn't have and eraseblock
> size of 128k, as far as I can remember there are at least boards with
> an eraseblock of 64k, I don't remember though, boards with and
> eraseblock size greater than 128k. About the 4 eraseblocks, there is a
> reason for this., the blocks are reserved for the SPL because you can
> flash 4 times (once per block) the SPL, the ROM code looks for an
> image in the first four blocks and it detects the validity status of
> these blocks. So, if the first one is corrupted, boots from the
> second, if the second is corrupted looks for the third, etc.
> 
> Said this, I think that the main question is if it's fine to get rid
> of this code. Ideally, we should cover all the cases, so assuming that
> there aren't devices with an eraseblock size greater than 128k,
> reserve 512k seems a good number. There is, though, a corner case
> where this number is not fine. There are some boards that came with a
> OneNand(DDP), the ROM code is only capable to read the odd blocks (1,
> 3, 5, 7...). So, in this case, you need to reserve 896k (128k NA 128k
> NA 128k NA 128k ). Fwiw that was also not covered with current code.
> 
> To be honest, I wouldn't worry about this latest case, and in my
> opinion, a fixed size of 512k is enough. Also, it's common now that
> the first few blocks of NAND flash are guaranteed to be safe for the
> first N erase cycles. So, I'm fine with the proposed fixed 512k for
> SPL. Btw, good job.

Okay, so next question is, does anyone rely on the default
partitioning? If that's the case we're screwed because using something
different will break things (UBI will be smaller than expected and
complain that blocks are missing).
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] Getting rid of board_mtdparts_default()

2018-11-15 Thread Enric Balletbo Serra
Hello Boris,

Missatge de Boris Brezillon  del dia dj.,
15 de nov. 2018 a les 16:58:
>
> Hello Enric,
>
> Miquel and I recently reworked drivers/mtd/mtdpart.c to get MTD
> partitions exposed as MTD devices (as is done in Linux) instead of
> having yet another abstraction to handle them (see what's currently
> done in cmd/{mtdparts,nand,sf,...}.c).
>
> This lead us to duplicate the mtdparts/mtdids parsing logic we found in
> cmd/mtdparts.c, and while doing that we noticed that one function is
> only implemented by igep boards: board_mtdparts_default().
>
> We'd like to get rid of this function if possible in order to simplify
> the mtdparts/mtdids retrieval logic, and there might be an easy
> solution to do that: use the CONFIG_{MTDPARTS,MTDIDS}_DEFAULT config
> options
>
> CONFIG_MTDPARTS_DEFAULT="omap2-nand:512k(SPL),-(UBI);omap2-onenand:512k(SPL),-(UBI)"
> CONFIG_MTDIDS_DEFAULT="nand0=omap2-nand,onenand0=omap2-onenand"
>
> It seems those defaults were built at runtime, and the only thing I'm
> not sure about is whether 512k for the SPL is always good. Looks like
> 4 eraseblocks are reserved for the SPL [1], but is the eraseblock size
> always 128k?

No, there are boards in the field that doesn't have and eraseblock
size of 128k, as far as I can remember there are at least boards with
an eraseblock of 64k, I don't remember though, boards with and
eraseblock size greater than 128k. About the 4 eraseblocks, there is a
reason for this., the blocks are reserved for the SPL because you can
flash 4 times (once per block) the SPL, the ROM code looks for an
image in the first four blocks and it detects the validity status of
these blocks. So, if the first one is corrupted, boots from the
second, if the second is corrupted looks for the third, etc.

Said this, I think that the main question is if it's fine to get rid
of this code. Ideally, we should cover all the cases, so assuming that
there aren't devices with an eraseblock size greater than 128k,
reserve 512k seems a good number. There is, though, a corner case
where this number is not fine. There are some boards that came with a
OneNand(DDP), the ROM code is only capable to read the odd blocks (1,
3, 5, 7...). So, in this case, you need to reserve 896k (128k NA 128k
NA 128k NA 128k ). Fwiw that was also not covered with current code.

To be honest, I wouldn't worry about this latest case, and in my
opinion, a fixed size of 512k is enough. Also, it's common now that
the first few blocks of NAND flash are guaranteed to be safe for the
first N erase cycles. So, I'm fine with the proposed fixed 512k for
SPL. Btw, good job.

Best regards,
  Enric

> If you don't know about the eraseblock size, maybe you
> know which OneNAND/NAND parts are used on these boards?
>
> Regards,
>
> Boris
>
> [1]https://elixir.bootlin.com/u-boot/latest/source/board/isee/igep00x0/igep00x0.c#L254
>
> --
> Boris Brezillon, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mmc: tmio: Reorder TMIO clock handling

2018-11-15 Thread Marek Vasut
Reorder the tmio_sd_set_clk_rate() function such that it handles all
of the clock requiests correctly. Specifically, before this patch,
clock request with (mmc->clock == 0 && mmc->clk_disable) could leave
the clock enabled, as the function would exit on if (!mmc->clock)
condition on top and will not handle the mmc->clk_disable at all.

Rather than band-aid fixing just that particular problem, reorder
the entire function to make it easier to understand and verify that
all the cases are covered. The function has three sections now:

First, if mmc->clock != 0, we calculate divider for the SD block.
Second, if mmc->clock != 0 and SD block clock are enabled and
   current divider is not equal to the new divider, then
   stop the clock and update the divider.
Third, if mmc->clk_disable is set, disable the clock, otherwise
   enable the clock. This happens independently of divider
   update now.

Signed-off-by: Marek Vasut 
Cc: Masahiro Yamada 
---
 drivers/mmc/tmio-common.c | 105 --
 1 file changed, 54 insertions(+), 51 deletions(-)

diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index fad2816ca5..201492001f 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -560,68 +560,71 @@ static ulong tmio_sd_clk_get_rate(struct tmio_sd_priv 
*priv)
return priv->clk_get_rate(priv);
 }
 
-static void tmio_sd_set_clk_rate(struct tmio_sd_priv *priv,
-struct mmc *mmc)
+static void tmio_sd_set_clk_rate(struct tmio_sd_priv *priv, struct mmc *mmc)
 {
unsigned int divisor;
-   u32 val, tmp;
+   u32 tmp, val = 0;
ulong mclk;
 
-   if (!mmc->clock)
-   return;
-
-   mclk = tmio_sd_clk_get_rate(priv);
-
-   divisor = DIV_ROUND_UP(mclk, mmc->clock);
-
-   /* Do not set divider to 0xff in DDR mode */
-   if (mmc->ddr_mode && (divisor == 1))
-   divisor = 2;
-
-   if (divisor <= 1)
-   val = (priv->caps & TMIO_SD_CAP_RCAR) ?
- TMIO_SD_CLKCTL_RCAR_DIV1 : TMIO_SD_CLKCTL_DIV1;
-   else if (divisor <= 2)
-   val = TMIO_SD_CLKCTL_DIV2;
-   else if (divisor <= 4)
-   val = TMIO_SD_CLKCTL_DIV4;
-   else if (divisor <= 8)
-   val = TMIO_SD_CLKCTL_DIV8;
-   else if (divisor <= 16)
-   val = TMIO_SD_CLKCTL_DIV16;
-   else if (divisor <= 32)
-   val = TMIO_SD_CLKCTL_DIV32;
-   else if (divisor <= 64)
-   val = TMIO_SD_CLKCTL_DIV64;
-   else if (divisor <= 128)
-   val = TMIO_SD_CLKCTL_DIV128;
-   else if (divisor <= 256)
-   val = TMIO_SD_CLKCTL_DIV256;
-   else if (divisor <= 512 || !(priv->caps & TMIO_SD_CAP_DIV1024))
-   val = TMIO_SD_CLKCTL_DIV512;
-   else
-   val = TMIO_SD_CLKCTL_DIV1024;
+   if (mmc->clock) {
+   mclk = tmio_sd_clk_get_rate(priv);
+
+   divisor = DIV_ROUND_UP(mclk, mmc->clock);
+
+   /* Do not set divider to 0xff in DDR mode */
+   if (mmc->ddr_mode && (divisor == 1))
+   divisor = 2;
+
+   if (divisor <= 1)
+   val = (priv->caps & TMIO_SD_CAP_RCAR) ?
+ TMIO_SD_CLKCTL_RCAR_DIV1 : TMIO_SD_CLKCTL_DIV1;
+   else if (divisor <= 2)
+   val = TMIO_SD_CLKCTL_DIV2;
+   else if (divisor <= 4)
+   val = TMIO_SD_CLKCTL_DIV4;
+   else if (divisor <= 8)
+   val = TMIO_SD_CLKCTL_DIV8;
+   else if (divisor <= 16)
+   val = TMIO_SD_CLKCTL_DIV16;
+   else if (divisor <= 32)
+   val = TMIO_SD_CLKCTL_DIV32;
+   else if (divisor <= 64)
+   val = TMIO_SD_CLKCTL_DIV64;
+   else if (divisor <= 128)
+   val = TMIO_SD_CLKCTL_DIV128;
+   else if (divisor <= 256)
+   val = TMIO_SD_CLKCTL_DIV256;
+   else if (divisor <= 512 || !(priv->caps & TMIO_SD_CAP_DIV1024))
+   val = TMIO_SD_CLKCTL_DIV512;
+   else
+   val = TMIO_SD_CLKCTL_DIV1024;
+   }
 
tmp = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
-   if (tmp & TMIO_SD_CLKCTL_SCLKEN &&
-   (tmp & TMIO_SD_CLKCTL_DIV_MASK) == val)
-   return;
-
-   /* stop the clock before changing its rate to avoid a glitch signal */
-   tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
-   tmio_sd_writel(priv, tmp, TMIO_SD_CLKCTL);
+   if (mmc->clock &&
+   !((tmp & TMIO_SD_CLKCTL_SCLKEN) &&
+ ((tmp & TMIO_SD_CLKCTL_DIV_MASK) == val))) {
+   /*
+* Stop the clock before changing its rate
+* to avoid a glitch signal
+*/
+   tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
+  

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

2018-11-15 Thread Simon Glass
On 15 November 2018 at 13:02, Tom Rini  wrote:
>
> On Thu, Nov 15, 2018 at 12:21:15PM -0800, Simon Glass wrote:
> > Hi Tom,
> >
> > On 15 November 2018 at 08:32, Simon Glass  wrote:
> > > Hi Tom,
> > >
> > > The following changes since commit 
> > > 208ecbad2ea8e8f3c9933213867addf16f4a:
> > >
> > >   Merge branch 'next' (2018-11-14 11:30:07 -0500)
> > >
> > > are available in the Git repository at:
> > >
> > >   git://git.denx.de/u-boot-dm.git tags/pull-14nov18
> > >
> > > for you to fetch changes up to 4c6e27f63c88d065a98f438085dfc36af47d3a23:
> > >
> > >   Revert "imx8qxp_mek: Disable CONFIG_DISPLAY_CPUINFO" (2018-11-14
> > > 09:16:28 -0800)
> > >
> > > 
> > > - virtio implementation and supporting patches
> > > - DM_FLAG_PRE_RELOC fixes
> > > - regmap improvements
> > > - minor buildman and sandbox things
> > >
> > > 
> >
> > I am seeing strange failures with travis-ci.
> >
> > https://travis-ci.org/sglass68/u-boot/builds/455582198?utm_medium=notification_source=email
> >
> > I thought it was something strange with travis-ci but the above run is
> > my second attempt and it fails with the same builds. Lots of stuff
> > about the filesystem tests. But they have been there for a while!
> >
> > Do you have any ideas?
>
> Yes: https://patchwork.ozlabs.org/patch/998330/ which I'm pushing
> now'ish, since my WIP branch completed again with that applied.

Thanks Tom, great to hear.

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


Re: [U-Boot] [PATCH] travis: Ensure we use pytest 2.8.7

2018-11-15 Thread Tom Rini
On Thu, Nov 15, 2018 at 08:58:15AM -0500, Tom Rini wrote:

> The latest version of pytest (4.0.0) makes some of the code we have in
> test/py/conftest.py a fatal error that needs to be migrated.
> Unfortunately this in turn requires changes that don't exist in older
> versions of pytest such as 2.8.7 that ships with Ubuntu 16.04.  Force
> travis to use this older version of pytest.
> 
> Signed-off-by: Tom Rini 

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] armv7r: K3: Allow SPL to run only on core 0

2018-11-15 Thread Tom Rini
On Thu, Nov 15, 2018 at 11:04:50AM +0530, Lokesh Vutla wrote:

> Based on the MCU R5 efuse settings, R5F cores in MCU domain
> either work in split mode or in lock step mode.
> 
> If efuse settings are in lockstep mode: ROM release R5 cores
> and SPL continues to run on the R5 core is lockstep mode.
> 
> If efuse settings are in split mode: ROM releases both the R5
> cores simultaneously and allow SPL to run on both the cores.
> In this case it is bootloader's responsibility to detect core
> 1 and park it. Else both the core will be running bootloader
> independently which might result in an unexpected behaviour.
> 
> Signed-off-by: Lokesh Vutla 

Reviewed-by: Tom Rini 

-- 
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 request: u-boot-sunxi/master

2018-11-15 Thread Tom Rini
On Wed, Nov 14, 2018 at 12:49:45AM +0530, Jagan Teki wrote:

> Hi Tom,
> 
> Please pull this PR.
> 
> thanks,
> Jagan.
> 
> The following changes since commit 454cf76184c65426b68033a23da086e73663f2fc:
> 
>   Prepare v2018.11-rc3 (2018-10-29 16:04:26 -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-sunxi.git master
> 
> for you to fetch changes up to 7d121a8ea4e0dbf0d7e105b57c3dbd7d8bd2e729:
> 
>   sunxi: use 6MHz PLL_VIDEO step for DE2 for higher resolution LCD 
> (2018-11-13 22:17:06 +0530)
> 

Applied to u-boot/master, thanks!

-- 
Tom


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


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

2018-11-15 Thread Tom Rini
On Thu, Nov 15, 2018 at 12:21:15PM -0800, Simon Glass wrote:
> Hi Tom,
> 
> On 15 November 2018 at 08:32, Simon Glass  wrote:
> > Hi Tom,
> >
> > The following changes since commit 208ecbad2ea8e8f3c9933213867addf16f4a:
> >
> >   Merge branch 'next' (2018-11-14 11:30:07 -0500)
> >
> > are available in the Git repository at:
> >
> >   git://git.denx.de/u-boot-dm.git tags/pull-14nov18
> >
> > for you to fetch changes up to 4c6e27f63c88d065a98f438085dfc36af47d3a23:
> >
> >   Revert "imx8qxp_mek: Disable CONFIG_DISPLAY_CPUINFO" (2018-11-14
> > 09:16:28 -0800)
> >
> > 
> > - virtio implementation and supporting patches
> > - DM_FLAG_PRE_RELOC fixes
> > - regmap improvements
> > - minor buildman and sandbox things
> >
> > 
> 
> I am seeing strange failures with travis-ci.
> 
> https://travis-ci.org/sglass68/u-boot/builds/455582198?utm_medium=notification_source=email
> 
> I thought it was something strange with travis-ci but the above run is
> my second attempt and it fails with the same builds. Lots of stuff
> about the filesystem tests. But they have been there for a while!
> 
> Do you have any ideas?

Yes: https://patchwork.ozlabs.org/patch/998330/ which I'm pushing
now'ish, since my WIP branch completed again with that applied.

-- 
Tom


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


[U-Boot] [PATCH] arm: ti: boot: Fix U-Boot environment partition address

2018-11-15 Thread Sam Protsenko
Recent removal of obsolete partition led to shifting of starting address
of "reserved" partition (which reflects U-Boot environment). Fix its
start address to keep it in sync with ENV_OFFSET and DFU environment.

This patch also provides fixed start address for "reserved" partition,
so that we can track when it's shifted next time.

While at it, move it before "misc" partition to keep all Android
partitions together.

Signed-off-by: Sam Protsenko 
---
 include/environment/ti/boot.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index 3c9c87f21b..5891009a5a 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -34,9 +34,9 @@
"partitions_android=" \
"uuid_disk=${uuid_gpt_disk};" \
"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
-   "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
+   "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
+   "name=reserved,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
-   "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
-- 
2.19.1

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


Re: [U-Boot] [PATCH 1/1] efi_loader: remove efi_exit_caches()

2018-11-15 Thread Alexander Graf


On 15.11.18 06:34, Jonathan Gray wrote:
> On Sun, Sep 23, 2018 at 02:33:47PM +0200, Heinrich Schuchardt wrote:
>> Since GRUB patch d0c070179d4d ("arm/efi: Switch to arm64 linux loader",
>> 2018-07-09) we do not need a workaround for GRUB on 32bit ARM anymore.
>>
>> So let's eliminate function efi_exit_caches().
>>
>> This will require Linux distributions to update grub-efi-arm to the GRUB
>> git HEAD (a tag containing the aforementioned GRUB patch is not available
>> yet).
> 
> OpenBSD/armv7 can no longer boot with U-Boot after this commit as
> it currently does not explicitly invalidate/flush caches in efiboot.

Shoot. I thought I had included a revert of this patch for 2018.11, but
apparently missed it :(.

I'll revert it for efi-next then. We will have to give this a good bit
more thought.


Alex

> 
>>
>> Signed-off-by: Heinrich Schuchardt 
>> ---
>>  lib/efi_loader/efi_boottime.c | 28 
>>  1 file changed, 28 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
>> index 2496608981..97eb19cd14 100644
>> --- a/lib/efi_loader/efi_boottime.c
>> +++ b/lib/efi_loader/efi_boottime.c
>> @@ -26,14 +26,6 @@ LIST_HEAD(efi_obj_list);
>>  /* List of all events */
>>  LIST_HEAD(efi_events);
>>  
>> -/*
>> - * If we're running on nasty systems (32bit ARM booting into non-EFI Linux)
>> - * we need to do trickery with caches. Since we don't want to break the EFI
>> - * aware boot path, only apply hacks when loading exiting directly (breaking
>> - * direct Linux EFI booting along the way - oh well).
>> - */
>> -static bool efi_is_direct_boot = true;
>> -
>>  #ifdef CONFIG_ARM
>>  /*
>>   * The "gd" pointer lives in a register on ARM and AArch64 that we declare
>> @@ -1686,8 +1678,6 @@ static efi_status_t EFIAPI 
>> efi_start_image(efi_handle_t image_handle,
>>  
>>  EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
>>  
>> -efi_is_direct_boot = false;
>> -
>>  /* call the image! */
>>  if (setjmp(_obj->exit_jmp)) {
>>  /*
>> @@ -1795,21 +1785,6 @@ static efi_status_t EFIAPI 
>> efi_unload_image(efi_handle_t image_handle)
>>  return EFI_EXIT(EFI_SUCCESS);
>>  }
>>  
>> -/**
>> - * efi_exit_caches() - fix up caches for EFI payloads if necessary
>> - */
>> -static void efi_exit_caches(void)
>> -{
>> -#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
>> -/*
>> - * Grub on 32bit ARM needs to have caches disabled before jumping into
>> - * a zImage, but does not know of all cache layers. Give it a hand.
>> - */
>> -if (efi_is_direct_boot)
>> -cleanup_before_linux();
>> -#endif
>> -}
>> -
>>  /**
>>   * efi_exit_boot_services() - stop all boot services
>>   * @image_handle: handle of the loaded image
>> @@ -1863,9 +1838,6 @@ static efi_status_t EFIAPI 
>> efi_exit_boot_services(efi_handle_t image_handle,
>>  
>>  board_quiesce_devices();
>>  
>> -/* Fix up caches for EFI payloads if necessary */
>> -efi_exit_caches();
>> -
>>  /* This stops all lingering devices */
>>  bootm_disable_interrupts();
>>  
>> -- 
>> 2.19.0
>>
>> ___
>> 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 v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Simon Glass
Hi Andy,

On 15 November 2018 at 11:51, Andy Shevchenko  wrote:
> On Thu, Nov 15, 2018 at 9:46 PM Simon Glass  wrote:
>> On 15 November 2018 at 09:58, Andy Shevchenko
>>  wrote:
>> >
>> > New callback will give a necessary information to fill up ACPI SPCR table,
>> > for example. Maybe used later for other purposes.
>
>> Seems useful to me.
>
> Thanks. What do you think about introducing ->getconfig() at some point?

Let's do it.

>
>> Please add a test to test/dm/serial.c
>
> Will do.
>
>> > +int serial_getinfo(struct serial_device_info *info)
>>
>> This should use driver model, so:
>>
>> int serial_getinfo(struct udevice *dev, struct serial_device_info *info)
>
> Oh, sure!
>
>> > +/* REVISIT: ACPI GAS specification implied */
>> > +struct serial_device_info {
>> > +   unsigned int baudrate;
>> > +   u8  addr_space; /* 0 - MMIO, 1 - IO */
>>
>> Please make this an enum
>>
>> > +   u8  reg_width;
>> > +   u8  reg_offset;
>> > +   u8  reg_shift;
>> > +   u64 addr;
>>
>> ulong
>>
>> Needs a struct comment as I don't know what most of these do.
>>
>> What about parity, number of bits, etc?
>
> What about splitting up some parameters structure with U-Boot defined 
> semantics?
> In the acpi_create_spcr() we can convert it to what ACPI expects w/o
> polluting U-Boot generic code.
>
> That's why it has "REVISIT" tag, I would like to hear proposals how
> these data structures should look like. Also I have no clue about
> non-16550 drivers.

Well so long as you document the struct members I think this is fine.
But I think you should add serial-format info (the 8n1 / 7e1 business)
to this.

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-15 Thread Simon Glass
Hi Tom,

On 15 November 2018 at 08:32, Simon Glass  wrote:
> Hi Tom,
>
> The following changes since commit 208ecbad2ea8e8f3c9933213867addf16f4a:
>
>   Merge branch 'next' (2018-11-14 11:30:07 -0500)
>
> are available in the Git repository at:
>
>   git://git.denx.de/u-boot-dm.git tags/pull-14nov18
>
> for you to fetch changes up to 4c6e27f63c88d065a98f438085dfc36af47d3a23:
>
>   Revert "imx8qxp_mek: Disable CONFIG_DISPLAY_CPUINFO" (2018-11-14
> 09:16:28 -0800)
>
> 
> - virtio implementation and supporting patches
> - DM_FLAG_PRE_RELOC fixes
> - regmap improvements
> - minor buildman and sandbox things
>
> 

I am seeing strange failures with travis-ci.

https://travis-ci.org/sglass68/u-boot/builds/455582198?utm_medium=notification_source=email

I thought it was something strange with travis-ci but the above run is
my second attempt and it fails with the same builds. Lots of stuff
about the filesystem tests. But they have been there for a while!

Do you have any ideas?

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


Re: [U-Boot] [PATCH v2 5/5] x86: acpi: Generate SPCR table

2018-11-15 Thread Alexander Graf


On 15.11.18 20:43, Andy Shevchenko wrote:
> On Thu, Nov 15, 2018 at 8:27 PM Alexander Graf  wrote:
>> On 15.11.18 18:58, Andy Shevchenko wrote:
>>> Microsoft specifies a SPCR (Serial Port Console Redirection Table) [1].
>>> Let's provide it in U-Boot.
>>>
>>> [1] 
>>> https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> 
>>> + ret = serial_getinfo();
>>> + if (ret)
>>> + spcr->interface_type = ACPI_DBG2_UNKNOWN;
>>> + else
>>> + spcr->interface_type = ACPI_DBG2_16550_COMPATIBLE;
>>
>> This sounds like pretty subtle semantics. Could you just include the
>> interface type in ?
> 
> It might be another step if you provide a cool way to do so. Otherwise

Define an enum with serial_type where 0 is unknown and 1 is
16550_compatible. Provide that enum in getinfo().

Bonus points for keeping the enum and ACPI_DBG2 IDs in sync, so that we
don't need too much code to copy from one to the other.

> we need first to de-x86 acpi stuff. I won't do it right now since it
> so-o out of the scope of this series.

Well, we will probably want to be able to do that in the future. And
anything that hard codes more x86 assumptions is a step in the wrong
direction.

> 
>> The main problem I'm seeing is that your UART might be a PL011
>> compatible which could still implement getinfo() but then wouldn't be
>> 16660 compatible.
> 
> Yes, I know. Perhaps I forgot to mark it in "Known issues" section.
> 
> Have you seen, btw, PL011 on x86 environment?

I can create one for you in QEMU if you like?

> 
>> Are any higher (and lower) ones specified too? If so, you may want to
>> add them as well.
> 
> There is a link to a specification. Care to read?

A simple "no, the spec only defines the ones above" would've been a
better answer and saved both of us a few seconds of our lives ;).

> 
>>> + default:
>>> + spcr->baud_rate = 0;
>>> + break;
> 
> Going ahead.
> This part actually something to develop through specifications, but I
> need to ping Microsoft and our internal ACPI people for that.
> 
>>> + break;
>>> + default:
>>> + access_size = ACPI_ACCESS_SIZE_UNDEFINED;
>>> + break;
>>> + }
>>> +
>>> + spcr->serial_port.space_id = ACPI_ADDRESS_SPACE_MEMORY;
>>
>> Can you guarantee that? Should probably be part of  as well if addr is.
> 
> Not now.
> As per moving to info, see my comment about de-x86 of ACPI in U-Boot.

I don't understand how describing your address space correctly has
anything to do with de-x86'ing anything? x86 is the only (living) user
of non-MMIO address space out there.

> 
>>> + /* REVISIT: Hard coded values for now */
>>> + spcr->parity = 0;
>>> + spcr->stop_bits = 1;
>>
>> IMHO those should be part of  as well. If you have to hard code
>> them, better hard code them in the driver rather than the generic ACPI
>> generation code.
> 
> Care to read cover letter carefully?

Again, if you think your patch is terrible and shouldn't be applied
anyway, please mark it as RFC. I'll be happy to wait with review until
you've made up your mind then :).


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


Re: [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree

2018-11-15 Thread Alexander Graf


On 15.11.18 20:33, Andy Shevchenko wrote:
> On Thu, Nov 15, 2018 at 8:28 PM Alexander Graf  wrote:
>> On 15.11.18 18:58, Andy Shevchenko wrote:
>>> Cache the value of the reg-io-width property for the future use.
> 
>>>  struct ns16550_platdata {
>>>   unsigned long base;
>>> + int reg_width;
>>>   int reg_shift;
>>> - int clock;
>>>   int reg_offset;
>>> + int clock;
>>
>> Why move clock?
> 
> To group reg_* parameters together as it might make sense in the
> future to have some other struct which would be used inside
> serial_device_info and here.
> If it's a big deal, don't pay attention to it, I would not touch it by 
> request.

Well, there are a few users of "patch" semantics:

  * mainlining process
  * patch review
  * backports (to stable / distro versions)
  * reverts if something broke

While I agree that you could ignore it for the normal mainlining
process, all other users will get hurt by having multiple "things" done
in a single patch. Review gets harder, backports get more confusing and
a revert ends up changing more code, which in turn makes it harder.

So please keep changes isolated to the thing they do :).

> P.S. Why to overquoute?

What do you mean? Why I don't remove useless parts of the quote?
Lazyness I suppose.


Alex

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


Re: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Alexander Graf


On 15.11.18 20:31, Andy Shevchenko wrote:
> On Thu, Nov 15, 2018 at 8:22 PM Alexander Graf  wrote:
>> On 15.11.18 18:58, Andy Shevchenko wrote:
>>> New callback will give a necessary information to fill up ACPI SPCR table,
>>> for example. Maybe used later for other purposes.
> 
>>> +/* REVISIT: ACPI GAS specification implied */
>>
>> What does this REVISIT tag mean?
> 
> Had you chance to read my cover letter?
> There is a section called "Known issues", item 3 there might answer to
> your question.

The usual tag for "not finalized, please don't apply yet" in upstream
patch submissions is "RFC". If you don't think your code is ready to be
applied, just tag the patches with RFC, like this:

  [RFC] serial: Introduce ->getinfo() callback

Then everyone knows that you don't think the patch is good enough yet.
Otherwise, every submission really implies that you think it should get
applied.

As for the data structure itself, I think I gave you a bit of feedback.
I wouldn't worry too much about getting everything right from the start,
as this is a monolithic open source project. So changing the structure
later on is easy.


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


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

2018-11-15 Thread Alexander Graf


On 15.11.18 21:01, Simon Glass wrote:
> Hi Alex,
> 
> On 14 November 2018 at 00:34, Alexander Graf  wrote:
>> On 11/06/2018 11:57 PM, Simon Glass wrote:
>>>
>>> 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 
>>
>>
>> This patch breaks the built-in unit tests:
>>
>> => ut dm cpu
>> Test: dm_test_cpu: cpu.c
>> test/dm/cpu.c:28, dm_test_cpu(): 0 == uclass_get_device_by_name(UCLASS_CPU,
>> "cpu-test1", ): Expected 0, got -19
>> Test: dm_test_cpu: cpu.c (flat tree)
>> test/dm/cpu.c:28, dm_test_cpu(): 0 == uclass_get_device_by_name(UCLASS_CPU,
>> "cpu-test1", ): Expected 0, got -19
>> Failures: 2
>>
>>
>> I'll remove it from my queue again.
> 
> Yes unfortunately there was a revert on master which affected this I think.
> 
> I can pick this one up once things land.

I'd appreciate that, yes, thanks :).


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


Re: [U-Boot] Ping failure

2018-11-15 Thread Marek Vasut
On 11/15/2018 08:47 PM, Alexander Weidinger wrote:
> Hi Paul, hi everyone,
> 
> we had the same problem with our olinuxino-a64, but we were able to
> solve it by using an old patch series proposed by Icenowy Zheng.
> 
> We extended the *.dts with content of the current torvalds/Linux master
> branch to contain an emac configuration, which basically results in the
> same changes you did. [0]
> Additionally We adapted the patch series from [1] for the current
> v2018.11-rc3 branch of denx/U-Boot. [2]
> When not applying the patch series, the 'tx-delay-ps' option seems to
> have no effect on the driver - at least we didn't find reference for
> this in the code.
> 
> After this we are able to use DHCP and boot our board via TFTP.
> 
> The patch series is in the state 'Changes Requested' and it seems there
> was no activity for quite some time. Nonetheless this seems to fix the
> problem for us.
> As a side note - this patch series seems also to be necessary for the
> BananaPi-M3, which uses the same Ethernet driver but a different PHY
> (Realtek instead of Micrel).

Can you repost the series ?

> Best regards
> 
> Alexander Weidinger
> 
> [0]:
> https://github.com/argos-research/u-boot/commit/546105fe859a5199b9533fbc0137b9328935bdba
> [1]:
> https://patchwork.ozlabs.org/project/uboot/list/?series==71295=*=emac=both=
> [2]:
> https://github.com/argos-research/u-boot/commit/f2a8eda9432c2d785ae446509f104de8b1492dd6
> ___
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 


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


[U-Boot] environment reliability after "env default -f -a"

2018-11-15 Thread Sam Protsenko
Hi all,

It was noticed that after resetting the U-Boot environment ("env
default -f -a") some variables are missing, and being added back after
"reset". E.g. in my case it's next variables:

board_name=am57xx_evm_reva3
ethaddr=fc:0f:4b:7b:27:9c
fastboot.board_rev=A.3A
fastboot.cpu=DRA752
fastboot.secure=GP
fastboot.userdata_size=2352351
fdtcontroladdr=fdf0d188
scsidevs=0
serial#=0c0090170f6e0122
stderr=serial@4802
stdin=serial@4802
stdout=serial@4802
ver=U-Boot 2018.11-00028-g3ad6ba7780 (Nov 15 2018 - 21:17:57 +0200)

Most likely those variables are being set on board_late_init(), so we
don't see them after "env default -f -a".

My question is: do we rely on environment to be the same after doing
"env default -f -a", comparing to environment after reboot? If so,
should I provide some sort of env callback to run corresponding
routines on "env default" event (like [1])?

P.S. As I understand, we don't rely on this. But I didn't find this in
documentation, so asking just to be completely sure.

Thanks!

[1] https://pastebin.ubuntu.com/p/z9bhsJ9cTG/
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


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

2018-11-15 Thread Simon Glass
Hi Alex,

On 14 November 2018 at 00:34, Alexander Graf  wrote:
> On 11/06/2018 11:57 PM, Simon Glass wrote:
>>
>> 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 
>
>
> This patch breaks the built-in unit tests:
>
> => ut dm cpu
> Test: dm_test_cpu: cpu.c
> test/dm/cpu.c:28, dm_test_cpu(): 0 == uclass_get_device_by_name(UCLASS_CPU,
> "cpu-test1", ): Expected 0, got -19
> Test: dm_test_cpu: cpu.c (flat tree)
> test/dm/cpu.c:28, dm_test_cpu(): 0 == uclass_get_device_by_name(UCLASS_CPU,
> "cpu-test1", ): Expected 0, got -19
> Failures: 2
>
>
> I'll remove it from my queue again.

Yes unfortunately there was a revert on master which affected this I think.

I can pick this one up once things land.

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


Re: [U-Boot] [PATCH v4 14/18] serial: 16550: allow the driver to support MediaTek serial

2018-11-15 Thread Simon Glass
Hi Ryder,

On 13 November 2018 at 17:32, Ryder Lee  wrote:
> On Tue, 2018-11-13 at 11:53 -0800, Simon Glass wrote:
>> Hi Ryder,
>>
>> On 6 November 2018 at 01:47, Ryder Lee  wrote:
>> > This patch adds an extra operation in ns16550.c to suuport MediaTek
>> > SoCs as we have a highspeed register which influences the calcualtion
>> > of the divisor.
>> >
>> > Note that we don't support the baudrate greater than 115200 currently.
>> >
>> > Signed-off-by: Ryder Lee 
>> > Tested-by: Matthias Brugger 
>> > Reviewed-by: Simon Glass 
>> > ---
>> > Changes since v4: None
>> >
>> > @Simon
>> > We have tried the compatible string, but it made the ns16550 driver more 
>> > complicated.
>> > To use the compatible string we have to add a new field in 
>> > ns16550_platdata, and change
>> > the flow of ns16550_serial_probe().
>> >
>> > Moreover, it's totally useless for debug uart. At present using a macro is 
>> > the easiest way here.
>> >
>> > What do you think?
>> > ---
>> >  drivers/serial/ns16550.c | 10 ++
>> >  1 file changed, 10 insertions(+)
>>
>> Please see my reply to the other thread. We should not have
>> arch-specific code in generic drivers.
>>
>> Sorry for not replying earlier on that.
>>
>
> OK.
>
> BTW, can you (or Tom) please take the other patches through your tree?

I think this is more Tom's domain, but I'm happy to do this if Tom wants me to.

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


Re: [U-Boot] Ping failure

2018-11-15 Thread Alexander Weidinger
Hi Paul, hi everyone,

we had the same problem with our olinuxino-a64, but we were able to
solve it by using an old patch series proposed by Icenowy Zheng.

We extended the *.dts with content of the current torvalds/Linux master
branch to contain an emac configuration, which basically results in the
same changes you did. [0]
Additionally We adapted the patch series from [1] for the current
v2018.11-rc3 branch of denx/U-Boot. [2]
When not applying the patch series, the 'tx-delay-ps' option seems to
have no effect on the driver - at least we didn't find reference for
this in the code.

After this we are able to use DHCP and boot our board via TFTP.

The patch series is in the state 'Changes Requested' and it seems there
was no activity for quite some time. Nonetheless this seems to fix the
problem for us.
As a side note - this patch series seems also to be necessary for the
BananaPi-M3, which uses the same Ethernet driver but a different PHY
(Realtek instead of Micrel).

Best regards

Alexander Weidinger

[0]:
https://github.com/argos-research/u-boot/commit/546105fe859a5199b9533fbc0137b9328935bdba
[1]:
https://patchwork.ozlabs.org/project/uboot/list/?series==71295=*=emac=both=
[2]:
https://github.com/argos-research/u-boot/commit/f2a8eda9432c2d785ae446509f104de8b1492dd6
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 9:47 PM Simon Glass  wrote:
> On 15 November 2018 at 09:58, Andy Shevchenko
>  wrote:
> > Cache the value of the reg-io-width property for the future use.

> > plat->reg_offset = dev_read_u32_default(dev, "reg-offset", 0);
> > plat->reg_shift = dev_read_u32_default(dev, "reg-shift", 0);
> > +   plat->reg_width = dev_read_u32_default(dev, "reg-io-width", 1);
> >
>
> Is your intent to actually use this for something? It sounds good, as
> at present we have all the horrible #ifdefs.

Not in this series.
Here is just an implementation (enough for SPCR case) of Bin's proposal.

> > -   int clock;
> > int reg_offset;
> > +   int clock;
>
> Should be in a separate patch.

Yes, if we conclude something about date structures. Otherwise don't
mind I won't touch it.

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


Re: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 9:46 PM Simon Glass  wrote:
> On 15 November 2018 at 09:58, Andy Shevchenko
>  wrote:
> >
> > New callback will give a necessary information to fill up ACPI SPCR table,
> > for example. Maybe used later for other purposes.

> Seems useful to me.

Thanks. What do you think about introducing ->getconfig() at some point?

> Please add a test to test/dm/serial.c

Will do.

> > +int serial_getinfo(struct serial_device_info *info)
>
> This should use driver model, so:
>
> int serial_getinfo(struct udevice *dev, struct serial_device_info *info)

Oh, sure!

> > +/* REVISIT: ACPI GAS specification implied */
> > +struct serial_device_info {
> > +   unsigned int baudrate;
> > +   u8  addr_space; /* 0 - MMIO, 1 - IO */
>
> Please make this an enum
>
> > +   u8  reg_width;
> > +   u8  reg_offset;
> > +   u8  reg_shift;
> > +   u64 addr;
>
> ulong
>
> Needs a struct comment as I don't know what most of these do.
>
> What about parity, number of bits, etc?

What about splitting up some parameters structure with U-Boot defined semantics?
In the acpi_create_spcr() we can convert it to what ACPI expects w/o
polluting U-Boot generic code.

That's why it has "REVISIT" tag, I would like to hear proposals how
these data structures should look like. Also I have no clue about
non-16550 drivers.

> > +};

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


Re: [U-Boot] [PATCH v2 3/5] serial: ns16550: Provide ->getinfo() implementation

2018-11-15 Thread Simon Glass
HI Andy,

On 15 November 2018 at 11:37, Andy Shevchenko  wrote:
> On Thu, Nov 15, 2018 at 8:30 PM Alexander Graf  wrote:
>> On 15.11.18 18:58, Andy Shevchenko wrote:
>> > New callback will supply necessary information, for example,
>> > to ACPI SPCR table.
>
>> > +static int ns16550_serial_getinfo(struct udevice *dev, struct 
>> > serial_device_info *info)
>>
>> This line is above 80 characters. Please run checkpatch.pl on your patches.
>
> When you saw last time the terminal for 80 character limit?
> I really don't give a crap about 80 characters limit when it uglifies the 
> code.
>
> Okay, here is 87 characters, so, I tend to split line as you suggested.

If you use patman it will check this for you.

I'm going to hold off on reviewing this since I'm not sure about the
struct purpose.

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


Re: [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree

2018-11-15 Thread Simon Glass
Hi Andy,

On 15 November 2018 at 09:58, Andy Shevchenko
 wrote:
> Cache the value of the reg-io-width property for the future use.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/serial/ns16550.c | 1 +
>  include/ns16550.h| 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
> index f9041aa626..b51b56de9f 100644
> --- a/drivers/serial/ns16550.c
> +++ b/drivers/serial/ns16550.c
> @@ -408,6 +408,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
>
> plat->reg_offset = dev_read_u32_default(dev, "reg-offset", 0);
> plat->reg_shift = dev_read_u32_default(dev, "reg-shift", 0);
> +   plat->reg_width = dev_read_u32_default(dev, "reg-io-width", 1);
>

Is your intent to actually use this for something? It sounds good, as
at present we have all the horrible #ifdefs.

> err = clk_get_by_index(dev, 0, );
> if (!err) {
> diff --git a/include/ns16550.h b/include/ns16550.h
> index 5fcbcd2e74..22b89e4d6d 100644
> --- a/include/ns16550.h
> +++ b/include/ns16550.h
> @@ -49,14 +49,16 @@
>   * struct ns16550_platdata - information about a NS16550 port
>   *
>   * @base:  Base register address
> + * @reg_width: IO accesses size of registers (in bytes)
>   * @reg_shift: Shift size of registers (0=byte, 1=16bit, 2=32bit...)
>   * @clock: UART base clock speed in Hz
>   */
>  struct ns16550_platdata {
> unsigned long base;
> +   int reg_width;
> int reg_shift;
> -   int clock;
> int reg_offset;
> +   int clock;

Should be in a separate patch.

> u32 fcr;
>  };
>
> --
> 2.19.1
>

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


Re: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Simon Glass
Hi Andy,

On 15 November 2018 at 09:58, Andy Shevchenko
 wrote:
>
> New callback will give a necessary information to fill up ACPI SPCR table,
> for example. Maybe used later for other purposes.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/serial/serial-uclass.c | 21 +
>  include/common.h   |  3 +++
>  include/serial.h   | 17 +
>  3 files changed, 41 insertions(+)
>

Seems useful to me.

Please add a test to test/dm/serial.c

> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 665cca85cb..274734d059 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -308,6 +308,25 @@ int serial_setconfig(uint config)
> return 0;
>  }
>
> +int serial_getinfo(struct serial_device_info *info)

This should use driver model, so:

int serial_getinfo(struct udevice *dev, struct serial_device_info *info)

> +{
> +   struct dm_serial_ops *ops;
> +
> +   if (!gd->cur_serial_dev)
> +   return -ENODEV;
> +
> +   if (!info)
> +   return -EINVAL;
> +
> +   info->baudrate = gd->baudrate;
> +
> +   ops = serial_get_ops(gd->cur_serial_dev);
> +   if (ops->getinfo)
> +   return ops->getinfo(gd->cur_serial_dev, info);
> +
> +   return -EINVAL;
> +}
> +
>  void serial_stdio_init(void)
>  {
>  }
> @@ -425,6 +444,8 @@ static int serial_post_probe(struct udevice *dev)
> if (ops->loop)
> ops->loop += gd->reloc_off;
>  #endif
> +   if (ops->getinfo)
> +   ops->getinfo += gd->reloc_off;
>  #endif
> /* Set the baud rate */
> if (ops->setbrg) {
> diff --git a/include/common.h b/include/common.h
> index 8b9f859c07..1f9c98e735 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -349,6 +349,8 @@ void smp_set_core_boot_addr(unsigned long addr, int 
> corenr);
>  void smp_kick_all_cpus(void);
>
>  /* $(CPU)/serial.c */
> +struct serial_device_info;
> +
>  intserial_init   (void);
>  void   serial_setbrg (void);
>  void   serial_putc   (const char);
> @@ -357,6 +359,7 @@ voidserial_puts   (const char *);
>  intserial_getc   (void);
>  intserial_tstc   (void);
>  intserial_setconfig(uint config);
> +intserial_getinfo(struct serial_device_info *info);

See above - please don't add any more non-DM functions.

>
>  /* $(CPU)/speed.c */
>  intget_clocks (void);
> diff --git a/include/serial.h b/include/serial.h
> index 020cd392e8..33531b7791 100644
> --- a/include/serial.h
> +++ b/include/serial.h
> @@ -111,6 +111,16 @@ enum serial_stop {
> SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
> SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
>
> +/* REVISIT: ACPI GAS specification implied */
> +struct serial_device_info {
> +   unsigned int baudrate;
> +   u8  addr_space; /* 0 - MMIO, 1 - IO */

Please make this an enum

> +   u8  reg_width;
> +   u8  reg_offset;
> +   u8  reg_shift;
> +   u64 addr;

ulong

Needs a struct comment as I don't know what most of these do.

What about parity, number of bits, etc?

> +};
> +
>  /**
>   * struct struct dm_serial_ops - Driver model serial operations
>   *
> @@ -201,6 +211,13 @@ struct dm_serial_ops {
>  * @return 0 if OK, -ve on error
>  */
> int (*setconfig)(struct udevice *dev, uint serial_config);
> +   /**
> +* getinfo() - Get serial device information
> +*
> +* @dev: Device pointer
> +* @info: struct serial_device_info to fill
> +*/
> +   int (*getinfo)(struct udevice *dev, struct serial_device_info *info);

This bit looks good

>  };
>
>  /**
> --
> 2.19.1
>

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


Re: [U-Boot] efi disks in u-boot

2018-11-15 Thread Simon Glass
Hi Akashi-san,

On 14 November 2018 at 22:57, AKASHI, Takahiro
 wrote:
> Hi Simon,
>
> On Wed, 14 Nov 2018 at 03:52, Simon Glass  wrote:
>>
>> Hi Akahsi,
>>
>> On 5 November 2018 at 20:15, AKASHI Takahiro  
>> wrote:
>> > Hello Simon,
>> >
>> > You said, in efi/lib_loader/efi_disk.c,
>> >
>> > ===8<===
>> >  * TODO(s...@chromium.org): Actually with CONFIG_BLK, U-Boot does have 
>> > this.
>> >  * Consider converting the code to look up devices as needed. The EFI 
>> > device
>> >  * could be a child of the UCLASS_BLK block device, perhaps.
>> >  *
>> >  * This gets called from do_bootefi_exec().
>> >  */
>> > efi_status_t efi_disk_register(void)
>> > {
>> > ===>8===
>> >
>> > What do you mean by this statement?
>> > Is it different from the code under "#if CONFIG_BLK"?
>> >
>> > I guess that you would suggest that some hook function be called
>> > in blk_create_device() and blk_unbind_all(). No?
>>
>> I would actually like EFI to use the U-Boot DM devices directly, with
>> just the minimal amount of plumbing.
>
> Under the current implementation, any u-boot disk device is statically
> associated with device path proctocol as well as block io protocol & file
> system protocol only once in efi_init_obj_list().
> If I understand you correctly, you're suggesting that, for example,
> efi_disk_from_path() should directly search for a u-boot device
> instead of look into a pre-created list of device path protocol objects
> with efi_search_protocol(). Right?
>
> It sounds reasonable and quite straight forward, but I wonder why Alex
> and Rob didn't take this approach. Was there any discussion in the past?

Yes, Alex did not want to limit this to only DM boards. That was an
unfortunate mistake, IMO. We are now starting to get rid of non-DM
boards.

>
> Thanks,
> -Takahiro Akashi
>
>
>> Perhaps an EFI child device that
>> gets created for each block device?
>>
>> Regards,
>> Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/5] x86: acpi: Generate SPCR table

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 8:27 PM Alexander Graf  wrote:
> On 15.11.18 18:58, Andy Shevchenko wrote:
> > Microsoft specifies a SPCR (Serial Port Console Redirection Table) [1].
> > Let's provide it in U-Boot.
> >
> > [1] 
> > https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx

> > + ret = serial_getinfo();
> > + if (ret)
> > + spcr->interface_type = ACPI_DBG2_UNKNOWN;
> > + else
> > + spcr->interface_type = ACPI_DBG2_16550_COMPATIBLE;
>
> This sounds like pretty subtle semantics. Could you just include the
> interface type in ?

It might be another step if you provide a cool way to do so. Otherwise
we need first to de-x86 acpi stuff. I won't do it right now since it
so-o out of the scope of this series.

> The main problem I'm seeing is that your UART might be a PL011
> compatible which could still implement getinfo() but then wouldn't be
> 16660 compatible.

Yes, I know. Perhaps I forgot to mark it in "Known issues" section.

Have you seen, btw, PL011 on x86 environment?

> Are any higher (and lower) ones specified too? If so, you may want to
> add them as well.

There is a link to a specification. Care to read?

> > + default:
> > + spcr->baud_rate = 0;
> > + break;

Going ahead.
This part actually something to develop through specifications, but I
need to ping Microsoft and our internal ACPI people for that.

> > + break;
> > + default:
> > + access_size = ACPI_ACCESS_SIZE_UNDEFINED;
> > + break;
> > + }
> > +
> > + spcr->serial_port.space_id = ACPI_ADDRESS_SPACE_MEMORY;
>
> Can you guarantee that? Should probably be part of  as well if addr is.

Not now.
As per moving to info, see my comment about de-x86 of ACPI in U-Boot.

> > + /* REVISIT: Hard coded values for now */
> > + spcr->parity = 0;
> > + spcr->stop_bits = 1;
>
> IMHO those should be part of  as well. If you have to hard code
> them, better hard code them in the driver rather than the generic ACPI
> generation code.

Care to read cover letter carefully?

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


Re: [U-Boot] [PATCH v2 3/5] serial: ns16550: Provide ->getinfo() implementation

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 8:30 PM Alexander Graf  wrote:
> On 15.11.18 18:58, Andy Shevchenko wrote:
> > New callback will supply necessary information, for example,
> > to ACPI SPCR table.

> > +static int ns16550_serial_getinfo(struct udevice *dev, struct 
> > serial_device_info *info)
>
> This line is above 80 characters. Please run checkpatch.pl on your patches.

When you saw last time the terminal for 80 character limit?
I really don't give a crap about 80 characters limit when it uglifies the code.

Okay, here is 87 characters, so, I tend to split line as you suggested.

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


Re: [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 8:28 PM Alexander Graf  wrote:
> On 15.11.18 18:58, Andy Shevchenko wrote:
> > Cache the value of the reg-io-width property for the future use.

> >  struct ns16550_platdata {
> >   unsigned long base;
> > + int reg_width;
> >   int reg_shift;
> > - int clock;
> >   int reg_offset;
> > + int clock;
>
> Why move clock?

To group reg_* parameters together as it might make sense in the
future to have some other struct which would be used inside
serial_device_info and here.
If it's a big deal, don't pay attention to it, I would not touch it by request.

P.S. Why to overquoute?

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


Re: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Andy Shevchenko
On Thu, Nov 15, 2018 at 8:22 PM Alexander Graf  wrote:
> On 15.11.18 18:58, Andy Shevchenko wrote:
> > New callback will give a necessary information to fill up ACPI SPCR table,
> > for example. Maybe used later for other purposes.

> > +/* REVISIT: ACPI GAS specification implied */
>
> What does this REVISIT tag mean?

Had you chance to read my cover letter?
There is a section called "Known issues", item 3 there might answer to
your question.

> > +struct serial_device_info {
> > + unsigned int baudrate;
> > + u8  addr_space; /* 0 - MMIO, 1 - IO */
> > + u8  reg_width;
> > + u8  reg_offset;
> > + u8  reg_shift;
> > + u64 addr;
> > +};

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


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

2018-11-15 Thread Simon Glass
On 14 November 2018 at 18:08, Ryder Lee  wrote:
> Add a few notes on how to try out the MediaTek support so far.
>
> Signed-off-by: Ryder Lee 
> Tested-by: Frank Wunderlich 
> ---
> Changes since v5:
> -Fix Whitespace-Error.
> 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

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


Re: [U-Boot] [PATCH v5 05/18] arm: MediaTek: add basic support for MT7623 boards

2018-11-15 Thread Simon Glass
Hi,

On 14 November 2018 at 18:07, Ryder Lee  wrote:
> From: Weijie Gao 
>
> This adds a general board file based on MT7623 SoCs from MediaTek.
>
> As this u-boot is loaded by MTK proprietary preloader, there is no
> low level initializtion codes.
>
> Signed-off-by: Weijie Gao 
> Signed-off-by: Ryder Lee 
> Tested-by: Matthias Brugger 
> ---
> Changes since v5: None
> Changes since v4:
> -Add gd->bd->bi_boot_params for legacy method - ATAGs.
> ---
>  arch/arm/mach-mediatek/Kconfig| 13 
>  arch/arm/mach-mediatek/Makefile   |  1 +
>  arch/arm/mach-mediatek/mt7623/Makefile|  4 ++
>  arch/arm/mach-mediatek/mt7623/init.c  | 54 +++
>  arch/arm/mach-mediatek/mt7623/lowlevel_init.S | 22 ++
>  arch/arm/mach-mediatek/mt7623/preloader.h | 99 
> +++
>  board/mediatek/mt7623/Kconfig | 13 
>  board/mediatek/mt7623/MAINTAINERS |  7 ++
>  board/mediatek/mt7623/Makefile|  3 +
>  board/mediatek/mt7623/mt7623_rfb.c| 16 +
>  configs/mt7623n_bpir2_defconfig   | 54 +++
>  include/configs/mt7623.h  | 56 +++
>  12 files changed, 342 insertions(+)
>  create mode 100644 arch/arm/mach-mediatek/mt7623/Makefile
>  create mode 100644 arch/arm/mach-mediatek/mt7623/init.c
>  create mode 100644 arch/arm/mach-mediatek/mt7623/lowlevel_init.S
>  create mode 100644 arch/arm/mach-mediatek/mt7623/preloader.h
>  create mode 100644 board/mediatek/mt7623/Kconfig
>  create mode 100644 board/mediatek/mt7623/MAINTAINERS
>  create mode 100644 board/mediatek/mt7623/Makefile
>  create mode 100644 board/mediatek/mt7623/mt7623_rfb.c
>  create mode 100644 configs/mt7623n_bpir2_defconfig
>  create mode 100644 include/configs/mt7623.h

Can this use the bloblist feature which should land soon?

For now, see dm/spl-working.

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


Re: [U-Boot] [PATCH 02/19] dm: cpu: Add timebase frequency to the platdata

2018-11-15 Thread Simon Glass
Hi Bin,

On 13 November 2018 at 17:14, Bin Meng  wrote:
> Hi Simon,
>
> On Wed, Nov 14, 2018 at 4:02 AM Simon Glass  wrote:
>>
>> On 13 November 2018 at 00:21, Bin Meng  wrote:
>> > This adds a timebase_freq member to the 'struct cpu_platdata', to
>> > hold the "timebase-frequency" value in the cpu or /cpus node.
>> >
>> > Signed-off-by: Bin Meng 
>> > ---
>> >
>> >  include/cpu.h | 3 +++
>> >  1 file changed, 3 insertions(+)
>>
>> Reviewed-by: Simon Glass 
>>
>> Could we have comments for the struct members?
>
> There are already comments added for the struct members. I am not sure
> what additional comments do you want to add?

Yes. I'm not sure what I was thinking there.

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


Re: [U-Boot] [PATCH v5 14/18] serial: MediaTek: add high-speed uart driver for MediaTek SoCs

2018-11-15 Thread Simon Glass
On 14 November 2018 at 18:08, Ryder Lee  wrote:
>
> Many SoCs from MediaTek have a high-speed uart. This UART is compatible
> with the ns16550 in legacy mode. It has extra registers for high-speed
> mode which can reach a maximum baudrate at 921600.
>
> However this UART will no longer be compatible if it's in high-speed mode.
> Some BootROM of MediaTek's SoCs will change the UART into high-speed mode
> and the U-Boot must use this driver to initialize the UART.
>
> Signed-off-by: Weijie Gao 
> Tested-by: Ryder Lee 
> ---
> Changes since v5: Add a specific driver for MTK UART
> Changes since v4: None
> ---
>  drivers/serial/Kconfig  |  20 
>  drivers/serial/Makefile |   1 +
>  drivers/serial/serial_mtk.c | 268 
> 
>  3 files changed, 289 insertions(+)
>  create mode 100644 drivers/serial/serial_mtk.c

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


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

2018-11-15 Thread Vasily Khoruzhick
On Fri, Nov 9, 2018 at 8:41 PM Vasily Khoruzhick  wrote:
>
> 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. Fixes eMMC failures on Olinuxino-A64 [1]

Ping? I've got reports from several users that it fixes issues with
different SD cards on Pinebook and Sopine. It would be nice to have it
merged.

> [1] 
> https://github.com/armbian/build/commit/03199b3879af24c94029460b8cdf0d41048afc92#commitcomment-31028421
>
> Vasily Khoruzhick (3):
>   sunxi-mmc: introduce new MMC_SUNXI_HAS_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] [PATCH v2 3/5] serial: ns16550: Provide ->getinfo() implementation

2018-11-15 Thread Alexander Graf


On 15.11.18 18:58, Andy Shevchenko wrote:
> New callback will supply necessary information, for example,
> to ACPI SPCR table.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/serial/ns16550.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
> index b51b56de9f..698acbfb51 100644
> --- a/drivers/serial/ns16550.c
> +++ b/drivers/serial/ns16550.c
> @@ -334,6 +334,19 @@ static int ns16550_serial_setbrg(struct udevice *dev, 
> int baudrate)
>   return 0;
>  }
>  
> +static int ns16550_serial_getinfo(struct udevice *dev, struct 
> serial_device_info *info)

This line is above 80 characters. Please run checkpatch.pl on your patches.


Alex

> +{
> + struct NS16550 *const com_port = dev_get_priv(dev);
> + struct ns16550_platdata *plat = com_port->plat;
> +
> + info->addr_space = 0;
> + info->reg_width = plat->reg_width * 8;
> + info->reg_shift = plat->reg_shift;
> + info->reg_offset = plat->reg_offset;
> + info->addr = plat->base;
> + return 0;
> +}
> +
>  int ns16550_serial_probe(struct udevice *dev)
>  {
>   struct NS16550 *const com_port = dev_get_priv(dev);
> @@ -441,6 +454,7 @@ const struct dm_serial_ops ns16550_serial_ops = {
>   .pending = ns16550_serial_pending,
>   .getc = ns16550_serial_getc,
>   .setbrg = ns16550_serial_setbrg,
> + .getinfo = ns16550_serial_getinfo,
>  };
>  
>  #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 5/5] x86: acpi: Generate SPCR table

2018-11-15 Thread Alexander Graf


On 15.11.18 18:58, Andy Shevchenko wrote:
> Microsoft specifies a SPCR (Serial Port Console Redirection Table) [1].
> Let's provide it in U-Boot.
> 
> [1] 
> https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  arch/x86/include/asm/acpi_table.h |  2 +
>  arch/x86/lib/acpi_table.c | 85 +++
>  2 files changed, 87 insertions(+)
> 
> diff --git a/arch/x86/include/asm/acpi_table.h 
> b/arch/x86/include/asm/acpi_table.h
> index 51cc806673..e3b65cff66 100644
> --- a/arch/x86/include/asm/acpi_table.h
> +++ b/arch/x86/include/asm/acpi_table.h
> @@ -327,6 +327,8 @@ struct acpi_global_nvs;
>  #define ACPI_DBG2_USB_XHCI   0x
>  #define ACPI_DBG2_USB_EHCI   0x0001
>  
> +#define ACPI_DBG2_UNKNOWN0x00FF
> +
>  /* SPCR (Serial Port Console Redirection table) */
>  struct __packed acpi_spcr {
>   struct acpi_table_header header;
> diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
> index c6b2026613..d8b44aea02 100644
> --- a/arch/x86/lib/acpi_table.c
> +++ b/arch/x86/lib/acpi_table.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -338,6 +339,82 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg)
>   header->checksum = table_compute_checksum((void *)mcfg, header->length);
>  }
>  
> +static void acpi_create_spcr(struct acpi_spcr *spcr)
> +{
> + struct acpi_table_header *header = &(spcr->header);
> + struct serial_device_info info = {0};
> + int access_size;
> + int ret;
> +
> + /* Fill out header fields */
> + acpi_fill_header(header, "SPCR");
> + header->length = sizeof(struct acpi_spcr);
> + header->revision = 2;
> +
> + ret = serial_getinfo();
> + if (ret)
> + spcr->interface_type = ACPI_DBG2_UNKNOWN;
> + else
> + spcr->interface_type = ACPI_DBG2_16550_COMPATIBLE;

This sounds like pretty subtle semantics. Could you just include the
interface type in ?

The main problem I'm seeing is that your UART might be a PL011
compatible which could still implement getinfo() but then wouldn't be
16660 compatible.

> + debug("UART type %u (serial_getinfo() rc=%d)\n", spcr->interface_type, 
> ret);
> +
> + /* Encode baud rate */
> + switch (info.baudrate) {
> + case 9600:
> + spcr->baud_rate = 3;
> + break;
> + case 19200:
> + spcr->baud_rate = 4;
> + break;
> + case 57600:
> + spcr->baud_rate = 6;
> + break;
> + case 115200:
> + spcr->baud_rate = 7;
> + break;

Are any higher (and lower) ones specified too? If so, you may want to
add them as well.

> + default:
> + spcr->baud_rate = 0;
> + break;
> + }
> +
> + /* Encode register access size */
> + switch (info.reg_shift) {
> + case 0:
> + access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS;
> + break;
> + case 1:
> + access_size = ACPI_ACCESS_SIZE_WORD_ACCESS;
> + break;
> + case 2:
> + access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS;
> + break;
> + case 3:
> + access_size = ACPI_ACCESS_SIZE_QWORD_ACCESS;
> + break;
> + default:
> + access_size = ACPI_ACCESS_SIZE_UNDEFINED;
> + break;
> + }
> +
> + spcr->serial_port.space_id = ACPI_ADDRESS_SPACE_MEMORY;

Can you guarantee that? Should probably be part of  as well if addr is.

> + spcr->serial_port.bit_width = info.reg_width;
> + spcr->serial_port.bit_offset = info.reg_offset;
> + spcr->serial_port.access_size = access_size;
> + spcr->serial_port.addrl = info.addr >> 0;
> + spcr->serial_port.addrh = info.addr >> 32;
> +
> + /* REVISIT: Hard coded values for now */
> + spcr->parity = 0;
> + spcr->stop_bits = 1;

IMHO those should be part of  as well. If you have to hard code
them, better hard code them in the driver rather than the generic ACPI
generation code.


Alex

> +
> + /* REVISIT: No PCI devices for now */
> + spcr->pci_device_id = 0x;
> + spcr->pci_vendor_id = 0x;
> +
> + /* Fix checksum */
> + header->checksum = table_compute_checksum((void *)spcr, header->length);
> +}
> +
>  /*
>   * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c
>   */
> @@ -352,6 +429,7 @@ ulong write_acpi_tables(ulong start)
>   struct acpi_fadt *fadt;
>   struct acpi_mcfg *mcfg;
>   struct acpi_madt *madt;
> + struct acpi_spcr *spcr;
>   int i;
>  
>   current = start;
> @@ -440,6 +518,13 @@ ulong write_acpi_tables(ulong start)
>   acpi_add_table(rsdp, mcfg);
>   current = ALIGN(current, 16);
>  
> + debug("ACPI:* SPCR\n");
> + spcr = (struct acpi_spcr *)current;
> + acpi_create_spcr(spcr);
> + current += 

Re: [U-Boot] [PATCH v2 2/5] serial: ns16550: Read reg-io-width from device tree

2018-11-15 Thread Alexander Graf


On 15.11.18 18:58, Andy Shevchenko wrote:
> Cache the value of the reg-io-width property for the future use.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/serial/ns16550.c | 1 +
>  include/ns16550.h| 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
> index f9041aa626..b51b56de9f 100644
> --- a/drivers/serial/ns16550.c
> +++ b/drivers/serial/ns16550.c
> @@ -408,6 +408,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
>  
>   plat->reg_offset = dev_read_u32_default(dev, "reg-offset", 0);
>   plat->reg_shift = dev_read_u32_default(dev, "reg-shift", 0);
> + plat->reg_width = dev_read_u32_default(dev, "reg-io-width", 1);
>  
>   err = clk_get_by_index(dev, 0, );
>   if (!err) {
> diff --git a/include/ns16550.h b/include/ns16550.h
> index 5fcbcd2e74..22b89e4d6d 100644
> --- a/include/ns16550.h
> +++ b/include/ns16550.h
> @@ -49,14 +49,16 @@
>   * struct ns16550_platdata - information about a NS16550 port
>   *
>   * @base:Base register address
> + * @reg_width:   IO accesses size of registers (in bytes)
>   * @reg_shift:   Shift size of registers (0=byte, 1=16bit, 
> 2=32bit...)
>   * @clock:   UART base clock speed in Hz
>   */
>  struct ns16550_platdata {
>   unsigned long base;
> + int reg_width;
>   int reg_shift;
> - int clock;
>   int reg_offset;
> + int clock;

Why move clock?

Alex

>   u32 fcr;
>  };
>  
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/5] serial: Introduce ->getinfo() callback

2018-11-15 Thread Alexander Graf


On 15.11.18 18:58, Andy Shevchenko wrote:
> New callback will give a necessary information to fill up ACPI SPCR table,
> for example. Maybe used later for other purposes.
> 
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/serial/serial-uclass.c | 21 +
>  include/common.h   |  3 +++
>  include/serial.h   | 17 +
>  3 files changed, 41 insertions(+)
> 
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 665cca85cb..274734d059 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -308,6 +308,25 @@ int serial_setconfig(uint config)
>   return 0;
>  }
>  
> +int serial_getinfo(struct serial_device_info *info)
> +{
> + struct dm_serial_ops *ops;
> +
> + if (!gd->cur_serial_dev)
> + return -ENODEV;
> +
> + if (!info)
> + return -EINVAL;
> +
> + info->baudrate = gd->baudrate;
> +
> + ops = serial_get_ops(gd->cur_serial_dev);
> + if (ops->getinfo)
> + return ops->getinfo(gd->cur_serial_dev, info);
> +
> + return -EINVAL;
> +}
> +
>  void serial_stdio_init(void)
>  {
>  }
> @@ -425,6 +444,8 @@ static int serial_post_probe(struct udevice *dev)
>   if (ops->loop)
>   ops->loop += gd->reloc_off;
>  #endif
> + if (ops->getinfo)
> + ops->getinfo += gd->reloc_off;
>  #endif
>   /* Set the baud rate */
>   if (ops->setbrg) {
> diff --git a/include/common.h b/include/common.h
> index 8b9f859c07..1f9c98e735 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -349,6 +349,8 @@ void smp_set_core_boot_addr(unsigned long addr, int 
> corenr);
>  void smp_kick_all_cpus(void);
>  
>  /* $(CPU)/serial.c */
> +struct serial_device_info;
> +
>  int  serial_init   (void);
>  void serial_setbrg (void);
>  void serial_putc   (const char);
> @@ -357,6 +359,7 @@ void  serial_puts   (const char *);
>  int  serial_getc   (void);
>  int  serial_tstc   (void);
>  int  serial_setconfig(uint config);
> +int  serial_getinfo(struct serial_device_info *info);
>  
>  /* $(CPU)/speed.c */
>  int  get_clocks (void);
> diff --git a/include/serial.h b/include/serial.h
> index 020cd392e8..33531b7791 100644
> --- a/include/serial.h
> +++ b/include/serial.h
> @@ -111,6 +111,16 @@ enum serial_stop {
>   SERIAL_8_BITS << SERIAL_BITS_SHIFT | \
>   SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
>  
> +/* REVISIT: ACPI GAS specification implied */

What does this REVISIT tag mean?


Alex

> +struct serial_device_info {
> + unsigned int baudrate;
> + u8  addr_space; /* 0 - MMIO, 1 - IO */
> + u8  reg_width;
> + u8  reg_offset;
> + u8  reg_shift;
> + u64 addr;
> +};
> +
>  /**
>   * struct struct dm_serial_ops - Driver model serial operations
>   *
> @@ -201,6 +211,13 @@ struct dm_serial_ops {
>* @return 0 if OK, -ve on error
>*/
>   int (*setconfig)(struct udevice *dev, uint serial_config);
> + /**
> +  * getinfo() - Get serial device information
> +  *
> +  * @dev: Device pointer
> +  * @info: struct serial_device_info to fill
> +  */
> + int (*getinfo)(struct udevice *dev, struct serial_device_info *info);
>  };
>  
>  /**
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   >