Re: [PATCH 11/11] roc-rk3399-pc: Add SPI boot support

2019-12-29 Thread Jagan Teki
On Mon, Dec 30, 2019 at 8:35 AM Kever Yang  wrote:
>
>
> On 2019/12/21 下午3:54, Jagan Teki wrote:
> > Add SPI boot support for ROC-RK3399-PC board.
> >
> > This would add separate config file
>
> What is the key reason to have a new separate config file? I think it
> would be much better
>
> to use the same defconfig, spi boot is one of features like other
> features, it should not need
>
> a separate config.

Problem is env, we don't have dynamic env pickup I guess, don't we?


RE: [EXT] Re: [PATCH 2/3] ata: fsl_sata: Continue probing other sata port when failed current port.

2019-12-29 Thread Peng Ma
Hi Simon,

>-Original Message-
>From: Simon Glass 
>Sent: 2019年12月28日 10:27
>To: Peng Ma 
>Cc: Priyanka Jain ; Marcel Ziswiler
>; Andy Tang ;
>u-boot@lists.denx.de
>Subject: [EXT] Re: [PATCH 2/3] ata: fsl_sata: Continue probing other sata port
>when failed current port.
>
>Caution: EXT Email
>
>Hi Peng,
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma  wrote:
>>
>>  In the initialization of sata driver, we want to initialize all port
>> probes, Therefore, any detection failure between of them should
>> continue  initialization by skipping the current port instead of exit.
>>
>> Signed-off-by: Peng Ma 
>> ---
>>  drivers/ata/fsl_sata.c | 58
>> +-
>>  1 file changed, 51 insertions(+), 7 deletions(-)
>
>Why does this remove/unbind?
>
[Peng Ma] Can I understand that it is the same as patch1?
If not please give me more informations.
Thanks.

Best Regards,
Peng
>Regards,
>Simon


RE: [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.

2019-12-29 Thread Peng Ma
Hi Simon,

I am very sorry to reply late, Please see comments inline.

Best Regards,
Peng
>-Original Message-
>From: Simon Glass 
>Sent: 2019年12月28日 10:27
>To: Peng Ma 
>Cc: Priyanka Jain ; Marcel Ziswiler
>; Andy Tang ;
>u-boot@lists.denx.de
>Subject: [EXT] Re: [PATCH 1/3] ata: sata_sil: Continue probing other sata port
>when failed current port.
>
>Caution: EXT Email
>
>Hi Peng,
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma  wrote:
>>
>>  In the initialization of sata driver, we want to initialize all port
>> probes, Therefore, any detection failure between of them should
>> continue  initialization by skipping the current port instead of exit.
>>
>> Signed-off-by: Peng Ma 
>> ---
>>  drivers/ata/sata_sil.c | 60
>> +++---
>>  1 file changed, 56 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index
>> d06d7a079d..bbba98f9a6 100644
>> --- a/drivers/ata/sata_sil.c
>> +++ b/drivers/ata/sata_sil.c
>> @@ -19,6 +19,7 @@
>>  #if CONFIG_IS_ENABLED(BLK)
>>  #include 
>>  #include 
>> +#include 
>>  #endif
>>
>>  #include "sata_sil.h"
>> @@ -762,15 +763,33 @@ U_BOOT_DRIVER(sata_sil_driver) = {
>> .platdata_auto_alloc_size = sizeof(struct sil_sata_priv),  };
>>
>> +static int (struct udevice *dev)
>> +{
>> +   int ret;
>> +
>> +   ret = device_remove(dev, DM_REMOVE_NORMAL);
>> +   if (ret)
>> +   return ret;
>> +
>> +   ret = device_unbind(dev);
>
>Why are you unbinding the devices? I don't think this is needed.
[Peng Ma] Before sil_init_sata function failed the function blk_create_devicef 
have already be called,
In the blk_create_devicef function it would be bound the silicon sata to block 
device, So we should unbind
this device here once the function sil_init_sata return failed.
>
>> +   if (ret)
>> +   return ret;
>> +
>> +   return 0;
>> +}
>> +
>>  static int sil_pci_probe(struct udevice *dev)  {
>> struct udevice *blk;
>> +   int failed_number;
>> char sata_name[10];
>> pci_dev_t devno;
>> u16 word;
>> int ret;
>> int i;
>>
>> +   failed_number = 0;
>> +
>> /* Get PCI device number */
>> devno = dm_pci_get_bdf(dev);
>> if (devno == -1)
>> @@ -823,12 +842,44 @@ static int sil_pci_probe(struct udevice *dev)
>> }
>>
>> ret = sil_init_sata(blk, i);
>> -   if (ret)
>> -   return -ENODEV;
>> +   if (ret) {
>> +   ret = sil_unbind_device(blk);
>> +   if (ret)
>> +   return ret;
>> +
>> +   failed_number++;
>> +   continue;
>> +   }
>>
>> ret = scan_sata(blk, i);
>> -   if (ret)
>> -   return -ENODEV;
>> +   if (ret) {
>> +   ret = sil_unbind_device(blk);
>> +   if (ret)
>> +   return ret;
>> +
>> +   failed_number++;
>> +   continue;
>> +   }
>> +   }
>> +
>> +   if (failed_number == sata_info.maxport)
>> +   return -ENODEV;
>> +   else
>> +   return 0;
>> +}
>> +
>> +static int sil_pci_remove(struct udevice *dev) {
>> +   int i;
>> +   struct sil_sata *sata;
>> +   struct sil_sata_priv *priv;
>> +
>> +   priv = dev_get_priv(dev);
>> +
>> +   for (i = sata_info.portbase; i < sata_info.maxport; i++) {
>> +   sata = priv->sil_sata_desc[i];
>> +   if (sata)
>> +   free(sata);
>> }
>>
>> return 0;
>> @@ -856,6 +907,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = {
>> .of_match = sil_pci_ids,
>> .ops = _sil_ops,
>> .probe = sil_pci_probe,
>> +   .remove = sil_pci_remove,
>> .priv_auto_alloc_size = sizeof(struct sil_sata_priv),  };
>>
>> --
>> 2.17.1
>>
>
>Regards,
>Simon


RE: [EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function

2019-12-29 Thread Peng Ma
Hi Simon,

>-Original Message-
>From: Simon Glass 
>Sent: 2019年12月28日 10:27
>To: Peng Ma 
>Cc: Priyanka Jain ; Marcel Ziswiler
>; Andy Tang ;
>u-boot@lists.denx.de
>Subject: [EXT] Re: [PATCH 3/3] cmd: sata: Add block unbind device function
>
>Caution: EXT Email
>
>On Wed, 4 Dec 2019 at 03:36, Peng Ma  wrote:
>>
>> If we didn't unbind the sata from block device, the same devices would
>> be added after sata remove, This patch is to resolve this issue as
>> below:
>>
>> => sata info
>> SATA#0:
>> (3.0 Gbps)
>> SATA#1:
>> (3.0 Gbps)
>> Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:
>BTPR247005PY30
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
>> 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#: BTPR247005VX30
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) =>
>sata
>> stop => sata info
>> SATA#0:
>> (3.0 Gbps)
>> SATA#1:
>> (3.0 Gbps)
>> Device 0: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:
>BTPR247005PY300
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
>> 1: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:
>BTPR247005VX300
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
>> 2: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:
>BTPR247005PY300
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512) Device
>> 3: Model: INTEL SSDSA2BW300G3D Firm: 4PC10362 Ser#:
>BTPR247005VX300
>> Type: Hard Disk
>> Supports 48-bit addressing
>> Capacity: 286168.1 MB = 279.4 GB (586072368 x 512)
>>
>> Signed-off-by: Peng Ma 
>> ---
>>  cmd/sata.c | 2 ++
>>  1 file changed, 2 insertions(+)
>
>Reviewed-by: Simon Glass 
[Peng Ma] thanks very much.

Best Regards,
Peng


[PATCH 15/19] dm: devres: Convert to use logging

2019-12-29 Thread Simon Glass
At present when CONFIG_DEBUG_DEVRES is enabled, U-Boot prints log messages
to the console with every devres allocation/free event. This causes most
tests to fail since the console output is not as expected.

In particular this prevents us from adding a device to sandbox which uses
devres in its bind method.

Move devres over to use U-Boot's logging feature instead, and add a new
category for devres.

Signed-off-by: Simon Glass 
---

 drivers/core/devres.c | 6 --
 include/log.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index a3f915dd73..9c04499c6d 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -7,6 +7,8 @@
  * Copyright (c) 2006  Tejun Heo 
  */
 
+#define LOG_CATEGORY LOGC_DEVRES
+
 #include 
 #include 
 #include 
@@ -46,8 +48,8 @@ static void set_node_dbginfo(struct devres *dr, const char 
*name, size_t size)
 static void devres_log(struct udevice *dev, struct devres *dr,
   const char *op)
 {
-   printf("%s: DEVRES %3s %p %s (%lu bytes)\n",
-  dev->name, op, dr, dr->name, (unsigned long)dr->size);
+   log_debug("%s: DEVRES %3s %p %s (%lu bytes)\n", dev->name, op, dr,
+ dr->name, (unsigned long)dr->size);
 }
 #else /* CONFIG_DEBUG_DEVRES */
 #define set_node_dbginfo(dr, n, s) do {} while (0)
diff --git a/include/log.h b/include/log.h
index c6f2f023b1..64b787d0ba 100644
--- a/include/log.h
+++ b/include/log.h
@@ -49,6 +49,7 @@ enum log_category_t {
LOGC_ALLOC, /* Memory allocation */
LOGC_SANDBOX,   /* Related to the sandbox board */
LOGC_BLOBLIST,  /* Bloblist */
+   LOGC_DEVRES,/* Device resources (devres_... functions) */
 
LOGC_COUNT, /* Number of log categories */
LOGC_END,   /* Sentinel value for a list of log categories */
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 16/19] dm: test: Add a test driver for devres

2019-12-29 Thread Simon Glass
Add a driver which does devres allocations so that we can write tests for
devres.

Signed-off-by: Simon Glass 
---

 arch/sandbox/dts/test.dts |  4 
 include/dm/uclass-id.h|  1 +
 include/test/test.h   |  9 
 test/dm/test-fdt.c| 47 +++
 4 files changed, 61 insertions(+)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 57513a449f..3aef40d5ca 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -201,6 +201,10 @@
compatible = "denx,u-boot-fdt-test1";
};
 
+   devres-test {
+   compatible = "denx,u-boot-devres-test";
+   };
+
clocks {
clk_fixed: clk-fixed {
compatible = "fixed-clock";
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index c1bab17ad1..c9f49df3f2 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -19,6 +19,7 @@ enum uclass_id {
UCLASS_TEST_BUS,
UCLASS_TEST_PROBE,
UCLASS_TEST_DUMMY,
+   UCLASS_TEST_DEVRES,
UCLASS_SPI_EMUL,/* sandbox SPI device emulator */
UCLASS_I2C_EMUL,/* sandbox I2C device emulator */
UCLASS_I2C_EMUL_PARENT, /* parent for I2C device emulators */
diff --git a/include/test/test.h b/include/test/test.h
index 98fbcd11f6..5977c59d3f 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -46,5 +46,14 @@ struct unit_test {
.func = _name,  \
}
 
+/* Sizes for devres tests */
+enum {
+   TEST_DEVRES_SIZE= 100,
+   TEST_DEVRES_COUNT   = 10,
+   TEST_DEVRES_TOTAL   = TEST_DEVRES_SIZE * TEST_DEVRES_COUNT,
+
+   /* A different size */
+   TEST_DEVRES_SIZE2   = 15,
+};
 
 #endif /* __TEST_TEST_H */
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 1fb8b5c248..bbac37761d 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -153,6 +153,53 @@ UCLASS_DRIVER(testprobe) = {
.flags  = DM_UC_FLAG_SEQ_ALIAS,
 };
 
+struct dm_testdevres_pdata {
+   void *ptr;
+};
+
+struct dm_testdevres_priv {
+   void *ptr;
+};
+
+static int testdevres_drv_bind(struct udevice *dev)
+{
+   struct dm_testdevres_pdata *pdata = dev_get_platdata(dev);
+
+   pdata->ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE, 0);
+
+   return 0;
+}
+
+static int testdevres_drv_probe(struct udevice *dev)
+{
+   struct dm_testdevres_priv *priv = dev_get_priv(dev);
+
+   priv->ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE2, 0);
+
+   return 0;
+}
+
+static const struct udevice_id testdevres_ids[] = {
+   { .compatible = "denx,u-boot-devres-test" },
+   { }
+};
+
+U_BOOT_DRIVER(testdevres_drv) = {
+   .name   = "testdevres_drv",
+   .of_match   = testdevres_ids,
+   .id = UCLASS_TEST_DEVRES,
+   .bind   = testdevres_drv_bind,
+   .probe  = testdevres_drv_probe,
+   .platdata_auto_alloc_size   = sizeof(struct dm_testdevres_pdata),
+   .priv_auto_alloc_size   = sizeof(struct dm_testdevres_priv),
+};
+
+UCLASS_DRIVER(testdevres) = {
+   .name   = "testdevres",
+   .id = UCLASS_TEST_DEVRES,
+   .flags  = DM_UC_FLAG_SEQ_ALIAS,
+};
+
 int dm_check_devices(struct unit_test_state *uts, int num_devices)
 {
struct udevice *dev;
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 17/19] dm: devres: Add tests

2019-12-29 Thread Simon Glass
The devres functionality has very few users in U-Boot, but it still should
have tests. Add a few basic tests of the main functions.

Signed-off-by: Simon Glass 
---

 drivers/core/devres.c |  13 +++
 include/dm/devres.h   |  20 +
 test/dm/Makefile  |   1 +
 test/dm/devres.c  | 178 ++
 4 files changed, 212 insertions(+)
 create mode 100644 test/dm/devres.c

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 9c04499c6d..36a8b1eb5f 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -223,6 +223,19 @@ void dm_dump_devres(void)
if (root)
dump_resources(root, 0);
 }
+
+void devres_get_stats(const struct udevice *dev, struct devres_stats *stats)
+{
+   struct devres *dr;
+
+   stats->allocs = 0;
+   stats->total_size = 0;
+   list_for_each_entry(dr, >devres_head, entry) {
+   stats->allocs++;
+   stats->total_size += dr->size;
+   }
+}
+
 #endif
 
 /*
diff --git a/include/dm/devres.h b/include/dm/devres.h
index 32fbf38054..9c69196054 100644
--- a/include/dm/devres.h
+++ b/include/dm/devres.h
@@ -15,6 +15,17 @@
 typedef void (*dr_release_t)(struct udevice *dev, void *res);
 typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
 
+/**
+ * struct devres_stats - Information about devres allocations for a device
+ *
+ * @allocs: Number of allocations
+ * @total_size: Total size of allocations in bytes
+ */
+struct devres_stats {
+   int allocs;
+   int total_size;
+};
+
 #ifdef CONFIG_DEVRES
 
 #ifdef CONFIG_DEBUG_DEVRES
@@ -189,6 +200,9 @@ static inline void *devm_kcalloc(struct udevice *dev,
  */
 void devm_kfree(struct udevice *dev, void *ptr);
 
+/* Get basic stats on allocations */
+void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);
+
 #else /* ! CONFIG_DEVRES */
 
 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
@@ -265,5 +279,11 @@ static inline void devm_kfree(struct udevice *dev, void 
*ptr)
 {
kfree(ptr);
 }
+
+static inline void devres_get_stats(const struct udevice *dev,
+   struct devres_stats *stats)
+{
+}
+
 #endif /* DEVRES */
 #endif /* _DM_DEVRES_H */
diff --git a/test/dm/Makefile b/test/dm/Makefile
index a268783169..85cc0f7fb8 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_BLK) += blk.o
 obj-$(CONFIG_BOARD) += board.o
 obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o
 obj-$(CONFIG_CLK) += clk.o clk_ccf.o
+obj-$(CONFIG_DEVRES) += devres.o
 obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
 obj-$(CONFIG_DM_ETH) += eth.o
 obj-$(CONFIG_FIRMWARE) += firmware.o
diff --git a/test/dm/devres.c b/test/dm/devres.c
new file mode 100644
index 00..c351844db9
--- /dev/null
+++ b/test/dm/devres.c
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for the devres (
+ *
+ * Copyright 2019 Google LLC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Test that devm_kmalloc() allocates memory, free when device is removed */
+static int dm_test_devres_alloc(struct unit_test_state *uts)
+{
+   ulong mem_start, mem_dev, mem_kmalloc;
+   struct udevice *dev;
+   void *ptr;
+
+   mem_start = ut_check_delta(0);
+   ut_assertok(uclass_first_device_err(UCLASS_TEST, ));
+   mem_dev = ut_check_delta(mem_start);
+   ut_assert(mem_dev > 0);
+
+   /* This should increase allocated memory */
+   ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE, 0);
+   ut_assert(ptr != NULL);
+   mem_kmalloc = ut_check_delta(mem_dev);
+   ut_assert(mem_kmalloc > 0);
+
+   /* Check that ptr is freed */
+   device_remove(dev, DM_REMOVE_NORMAL);
+   ut_asserteq(0, ut_check_delta(mem_start));
+
+   return 0;
+}
+DM_TEST(dm_test_devres_alloc, DM_TESTF_SCAN_PDATA);
+
+/* Test devm_kfree() can be used to free memory too */
+static int dm_test_devres_free(struct unit_test_state *uts)
+{
+   ulong mem_start, mem_dev, mem_kmalloc;
+   struct udevice *dev;
+   void *ptr;
+
+   mem_start = ut_check_delta(0);
+   ut_assertok(uclass_first_device_err(UCLASS_TEST, ));
+   mem_dev = ut_check_delta(mem_start);
+   ut_assert(mem_dev > 0);
+
+   ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE, 0);
+   ut_assert(ptr != NULL);
+   mem_kmalloc = ut_check_delta(mem_dev);
+   ut_assert(mem_kmalloc > 0);
+
+   /* Free the ptr and check that memory usage goes down */
+   devm_kfree(dev, ptr);
+   ut_assert(ut_check_delta(mem_kmalloc) < 0);
+
+   device_remove(dev, DM_REMOVE_NORMAL);
+   ut_asserteq(0, ut_check_delta(mem_start));
+
+   return 0;
+}
+DM_TEST(dm_test_devres_free, DM_TESTF_SCAN_PDATA);
+
+
+/* Test that kzalloc() returns memory that is zeroed */
+static int dm_test_devres_kzalloc(struct unit_test_state *uts)
+{
+   struct udevice *dev;
+   u8 *ptr, val;
+   int i;
+

[PATCH 13/19] dm: devres: Create a new devres header file

2019-12-29 Thread Simon Glass
At present these functions are lumped in with the core device functions.
They have their own #ifdef to control their availability, so it seems
better to split them out.

Move them into their own header file.

Signed-off-by: Simon Glass 
---

 include/dm/device.h | 255 +
 include/dm/devres.h | 269 
 2 files changed, 270 insertions(+), 254 deletions(-)
 create mode 100644 include/dm/devres.h

diff --git a/include/dm/device.h b/include/dm/device.h
index 9ebfd0a34e..1138a09149 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -720,260 +720,7 @@ static inline bool device_is_on_pci_bus(struct udevice 
*dev)
  */
 int dm_scan_fdt_dev(struct udevice *dev);
 
-/* device resource management */
-typedef void (*dr_release_t)(struct udevice *dev, void *res);
-typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
-
-#ifdef CONFIG_DEVRES
-
-#ifdef CONFIG_DEBUG_DEVRES
-void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
-const char *name);
-#define _devres_alloc(release, size, gfp) \
-   __devres_alloc(release, size, gfp, #release)
-#else
-void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
-#endif
-
-/**
- * devres_alloc() - Allocate device resource data
- * @release: Release function devres will be associated with
- * @size: Allocation size
- * @gfp: Allocation flags
- *
- * Allocate devres of @size bytes.  The allocated area is associated
- * with @release.  The returned pointer can be passed to
- * other devres_*() functions.
- *
- * RETURNS:
- * Pointer to allocated devres on success, NULL on failure.
- */
-#define devres_alloc(release, size, gfp) \
-   _devres_alloc(release, size, gfp | __GFP_ZERO)
-
-/**
- * devres_free() - Free device resource data
- * @res: Pointer to devres data to free
- *
- * Free devres created with devres_alloc().
- */
-void devres_free(void *res);
-
-/**
- * devres_add() - Register device resource
- * @dev: Device to add resource to
- * @res: Resource to register
- *
- * Register devres @res to @dev.  @res should have been allocated
- * using devres_alloc().  On driver detach, the associated release
- * function will be invoked and devres will be freed automatically.
- */
-void devres_add(struct udevice *dev, void *res);
-
-/**
- * devres_find() - Find device resource
- * @dev: Device to lookup resource from
- * @release: Look for resources associated with this release function
- * @match: Match function (optional)
- * @match_data: Data for the match function
- *
- * Find the latest devres of @dev which is associated with @release
- * and for which @match returns 1.  If @match is NULL, it's considered
- * to match all.
- *
- * @return pointer to found devres, NULL if not found.
- */
-void *devres_find(struct udevice *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-
-/**
- * devres_get() - Find devres, if non-existent, add one atomically
- * @dev: Device to lookup or add devres for
- * @new_res: Pointer to new initialized devres to add if not found
- * @match: Match function (optional)
- * @match_data: Data for the match function
- *
- * Find the latest devres of @dev which has the same release function
- * as @new_res and for which @match return 1.  If found, @new_res is
- * freed; otherwise, @new_res is added atomically.
- *
- * @return ointer to found or added devres.
- */
-void *devres_get(struct udevice *dev, void *new_res,
-dr_match_t match, void *match_data);
-
-/**
- * devres_remove() - Find a device resource and remove it
- * @dev: Device to find resource from
- * @release: Look for resources associated with this release function
- * @match: Match function (optional)
- * @match_data: Data for the match function
- *
- * Find the latest devres of @dev associated with @release and for
- * which @match returns 1.  If @match is NULL, it's considered to
- * match all.  If found, the resource is removed atomically and
- * returned.
- *
- * @return ointer to removed devres on success, NULL if not found.
- */
-void *devres_remove(struct udevice *dev, dr_release_t release,
-   dr_match_t match, void *match_data);
-
-/**
- * devres_destroy() - Find a device resource and destroy it
- * @dev: Device to find resource from
- * @release: Look for resources associated with this release function
- * @match: Match function (optional)
- * @match_data: Data for the match function
- *
- * Find the latest devres of @dev associated with @release and for
- * which @match returns 1.  If @match is NULL, it's considered to
- * match all.  If found, the resource is removed atomically and freed.
- *
- * Note that the release function for the resource will not be called,
- * only the devres-allocated data will be freed.  The caller becomes
- * responsible for freeing any other data.
- *
- * @return 0 if devres is found and freed, -ENOENT if not found.
- */
-int 

[PATCH 19/19] dm: devres: Add a new OFDATA phase

2019-12-29 Thread Simon Glass
Since the ofdata_to_platdata() method can allocate resources, add it as a
new devres phase.

Signed-off-by: Simon Glass 
---

 drivers/core/devres.c | 18 +-
 include/test/test.h   |  3 ++-
 test/dm/devres.c  | 14 +++---
 test/dm/test-fdt.c| 11 +++
 4 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 5376118f12..237b42653c 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -20,10 +20,12 @@
 /** enum devres_phase - Shows where resource was allocated
  *
  * DEVRES_PHASE_BIND: In the bind() method
+ * DEVRES_PHASE_OFDATA: In the ofdata_to_platdata() method
  * DEVRES_PHASE_PROBE: In the probe() method
  */
 enum devres_phase {
DEVRES_PHASE_BIND,
+   DEVRES_PHASE_OFDATA,
DEVRES_PHASE_PROBE,
 };
 
@@ -102,8 +104,12 @@ void devres_add(struct udevice *dev, void *res)
 
devres_log(dev, dr, "ADD");
assert_noisy(list_empty(>entry));
-   dr->phase = dev->flags & DM_FLAG_BOUND ? DEVRES_PHASE_PROBE :
-   DEVRES_PHASE_BIND;
+   if (dev->flags & DM_FLAG_PLATDATA_VALID)
+   dr->phase = DEVRES_PHASE_PROBE;
+   else if (dev->flags & DM_FLAG_BOUND)
+   dr->phase = DEVRES_PHASE_OFDATA;
+   else
+   dr->phase = DEVRES_PHASE_BIND;
list_add_tail(>entry, >devres_head);
 }
 
@@ -184,12 +190,12 @@ int devres_release(struct udevice *dev, dr_release_t 
release,
 }
 
 static void release_nodes(struct udevice *dev, struct list_head *head,
- bool probe_only)
+ bool probe_and_ofdata_only)
 {
struct devres *dr, *tmp;
 
list_for_each_entry_safe_reverse(dr, tmp, head, entry)  {
-   if (probe_only && dr->phase != DEVRES_PHASE_PROBE)
+   if (probe_and_ofdata_only && dr->phase == DEVRES_PHASE_BIND)
break;
devres_log(dev, dr, "REL");
dr->release(dev, dr->data);
@@ -209,6 +215,8 @@ void devres_release_all(struct udevice *dev)
 }
 
 #ifdef CONFIG_DEBUG_DEVRES
+static char *const devres_phase_name[] = {"BIND", "OFDATA", "PROBE"};
+
 static void dump_resources(struct udevice *dev, int depth)
 {
struct devres *dr;
@@ -219,7 +227,7 @@ static void dump_resources(struct udevice *dev, int depth)
list_for_each_entry(dr, >devres_head, entry)
printf("%p (%lu byte) %s  %s\n", dr,
   (unsigned long)dr->size, dr->name,
-  dr->phase == DEVRES_PHASE_PROBE ? "PROBE" : "BIND");
+  devres_phase_name[dr->phase]);
 
list_for_each_entry(child, >child_head, sibling_node)
dump_resources(child, depth + 1);
diff --git a/include/test/test.h b/include/test/test.h
index 5977c59d3f..e5bef4759a 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -52,8 +52,9 @@ enum {
TEST_DEVRES_COUNT   = 10,
TEST_DEVRES_TOTAL   = TEST_DEVRES_SIZE * TEST_DEVRES_COUNT,
 
-   /* A different size */
+   /* A few different sizes */
TEST_DEVRES_SIZE2   = 15,
+   TEST_DEVRES_SIZE3   = 37,
 };
 
 #endif /* __TEST_TEST_H */
diff --git a/test/dm/devres.c b/test/dm/devres.c
index c351844db9..e7331897de 100644
--- a/test/dm/devres.c
+++ b/test/dm/devres.c
@@ -140,6 +140,7 @@ static int dm_test_devres_kcalloc(struct unit_test_state 
*uts)
 }
 DM_TEST(dm_test_devres_kcalloc, DM_TESTF_SCAN_PDATA);
 
+/* Test devres releases resources automatically as expected */
 static int dm_test_devres_phase(struct unit_test_state *uts)
 {
struct devres_stats stats;
@@ -154,14 +155,21 @@ static int dm_test_devres_phase(struct unit_test_state 
*uts)
ut_asserteq(1, stats.allocs);
ut_asserteq(TEST_DEVRES_SIZE, stats.total_size);
 
+   /* Getting platdata should add one allocation */
+   ut_assertok(device_ofdata_to_platdata(dev));
+   devres_get_stats(dev, );
+   ut_asserteq(2, stats.allocs);
+   ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE3, stats.total_size);
+
/* Probing the device should add one allocation */
ut_assertok(uclass_first_device(UCLASS_TEST_DEVRES, ));
ut_assert(dev != NULL);
devres_get_stats(dev, );
-   ut_asserteq(2, stats.allocs);
-   ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE2, stats.total_size);
+   ut_asserteq(3, stats.allocs);
+   ut_asserteq(TEST_DEVRES_SIZE + TEST_DEVRES_SIZE2 + TEST_DEVRES_SIZE3,
+   stats.total_size);
 
-   /* Removing the device should drop one allocation */
+   /* Removing the device should drop both those allocations */
device_remove(dev, DM_REMOVE_NORMAL);
devres_get_stats(dev, );
ut_asserteq(1, stats.allocs);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index bbac37761d..d59c449ce0 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -159,6 +159,7 @@ struct 

[PATCH 18/19] dm: devres: Use an enum for the allocation phase

2019-12-29 Thread Simon Glass
At present we only support two phases where devres can be used:
bind and probe. This is handled with a boolean. We want to add a new
phase (platdata), so change this to an enum.

Signed-off-by: Simon Glass 
---

 drivers/core/devres.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 36a8b1eb5f..5376118f12 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -17,12 +17,21 @@
 #include 
 #include 
 
+/** enum devres_phase - Shows where resource was allocated
+ *
+ * DEVRES_PHASE_BIND: In the bind() method
+ * DEVRES_PHASE_PROBE: In the probe() method
+ */
+enum devres_phase {
+   DEVRES_PHASE_BIND,
+   DEVRES_PHASE_PROBE,
+};
+
 /**
  * struct devres - Bookkeeping info for managed device resource
  * @entry: List to associate this structure with a device
  * @release: Callback invoked when this resource is released
- * @probe: Flag to show when this resource was allocated
-  (true = probe, false = bind)
+ * @probe: Show where this resource was allocated
  * @name: Name of release function
  * @size: Size of resource data
  * @data: Resource data
@@ -30,7 +39,7 @@
 struct devres {
struct list_headentry;
dr_release_trelease;
-   boolprobe;
+   enum devres_phase   phase;
 #ifdef CONFIG_DEBUG_DEVRES
const char  *name;
size_t  size;
@@ -93,7 +102,8 @@ void devres_add(struct udevice *dev, void *res)
 
devres_log(dev, dr, "ADD");
assert_noisy(list_empty(>entry));
-   dr->probe = dev->flags & DM_FLAG_BOUND ? true : false;
+   dr->phase = dev->flags & DM_FLAG_BOUND ? DEVRES_PHASE_PROBE :
+   DEVRES_PHASE_BIND;
list_add_tail(>entry, >devres_head);
 }
 
@@ -179,7 +189,7 @@ static void release_nodes(struct udevice *dev, struct 
list_head *head,
struct devres *dr, *tmp;
 
list_for_each_entry_safe_reverse(dr, tmp, head, entry)  {
-   if (probe_only && !dr->probe)
+   if (probe_only && dr->phase != DEVRES_PHASE_PROBE)
break;
devres_log(dev, dr, "REL");
dr->release(dev, dr->data);
@@ -209,7 +219,7 @@ static void dump_resources(struct udevice *dev, int depth)
list_for_each_entry(dr, >devres_head, entry)
printf("%p (%lu byte) %s  %s\n", dr,
   (unsigned long)dr->size, dr->name,
-  dr->probe ? "PROBE" : "BIND");
+  dr->phase == DEVRES_PHASE_PROBE ? "PROBE" : "BIND");
 
list_for_each_entry(child, >child_head, sibling_node)
dump_resources(child, depth + 1);
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 08/19] dm: core: Move ofdata_to_platdata() call earlier

2019-12-29 Thread Simon Glass
This method is supposed to extract platform data from the device tree. It
should be done before the device itself is probed. Move it earlier in the
device_probe() function.

Signed-off-by: Simon Glass 
---

 drivers/core/device.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 2442b5834d..45754ead8f 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -375,6 +375,13 @@ int device_probe(struct udevice *dev)
return 0;
}
 
+   if (drv->ofdata_to_platdata &&
+   (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
+   ret = drv->ofdata_to_platdata(dev);
+   if (ret)
+   goto fail;
+   }
+
seq = uclass_resolve_seq(dev);
if (seq < 0) {
ret = seq;
@@ -411,13 +418,6 @@ int device_probe(struct udevice *dev)
goto fail;
}
 
-   if (drv->ofdata_to_platdata &&
-   (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
-   ret = drv->ofdata_to_platdata(dev);
-   if (ret)
-   goto fail;
-   }
-
/* Only handle devices that have a valid ofnode */
if (dev_of_valid(dev)) {
/*
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 11/19] dm: core: Export a new function to read platdata

2019-12-29 Thread Simon Glass
Add a new internal function, device_ofdata_to_platdata() to handle
allocating private space associated with each device and reading the
platform data from the device tree.

Call this new function from device_probe().

Signed-off-by: Simon Glass 
---

 drivers/core/device.c| 29 +++--
 include/dm/device-internal.h | 16 
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index f0c23053eb..9506c7df8d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -311,12 +311,11 @@ static void *alloc_priv(int size, uint flags)
return priv;
 }
 
-int device_probe(struct udevice *dev)
+int device_ofdata_to_platdata(struct udevice *dev)
 {
const struct driver *drv;
int size = 0;
int ret;
-   int seq;
 
if (!dev)
return -EINVAL;
@@ -369,6 +368,32 @@ int device_probe(struct udevice *dev)
goto fail;
}
 
+   return 0;
+fail:
+   device_free(dev);
+
+   return ret;
+}
+
+int device_probe(struct udevice *dev)
+{
+   const struct driver *drv;
+   int ret;
+   int seq;
+
+   if (!dev)
+   return -EINVAL;
+
+   if (dev->flags & DM_FLAG_ACTIVATED)
+   return 0;
+
+   drv = dev->driver;
+   assert(drv);
+
+   ret = device_ofdata_to_platdata(dev);
+   if (ret)
+   goto fail;
+
/* Ensure all parents are probed */
if (dev->parent) {
ret = device_probe(dev->parent);
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index ee2b24a62a..294d6c1810 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -83,6 +83,22 @@ int device_bind_with_driver_data(struct udevice *parent,
 int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
const struct driver_info *info, struct udevice **devp);
 
+/**
+ * device_ofdata_to_platdata() - Read platform data for a device
+ *
+ * Read platform data for a device (typically from the device tree) so that
+ * the information needed to probe the device is present.
+ *
+ * This may cause some others devices to be probed if this one depends on them,
+ * e.g. a GPIO line will cause a GPIO device to be probed.
+ *
+ * All private data associated with the device is allocated.
+ *
+ * @dev: Pointer to device to process
+ * @return 0 if OK, -ve on error
+ */
+int device_ofdata_to_platdata(struct udevice *dev);
+
 /**
  * device_probe() - Probe a device, activating it
  *
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 09/19] dm: core: Allocate parent data separate from probing parent

2019-12-29 Thread Simon Glass
At present the parent is probed before the child's ofdata_to_platdata()
method is called. Adjust the logic slightly so that probing parents is
not done until afterwards.

Signed-off-by: Simon Glass 
---

 drivers/core/device.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 45754ead8f..f0c23053eb 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -346,7 +346,7 @@ int device_probe(struct udevice *dev)
}
}
 
-   /* Ensure all parents are probed */
+   /* Allocate parent data for this child */
if (dev->parent) {
size = dev->parent->driver->per_child_auto_alloc_size;
if (!size) {
@@ -360,7 +360,17 @@ int device_probe(struct udevice *dev)
goto fail;
}
}
+   }
+
+   if (drv->ofdata_to_platdata &&
+   (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
+   ret = drv->ofdata_to_platdata(dev);
+   if (ret)
+   goto fail;
+   }
 
+   /* Ensure all parents are probed */
+   if (dev->parent) {
ret = device_probe(dev->parent);
if (ret)
goto fail;
@@ -375,13 +385,6 @@ int device_probe(struct udevice *dev)
return 0;
}
 
-   if (drv->ofdata_to_platdata &&
-   (CONFIG_IS_ENABLED(OF_PLATDATA) || dev_has_of_node(dev))) {
-   ret = drv->ofdata_to_platdata(dev);
-   if (ret)
-   goto fail;
-   }
-
seq = uclass_resolve_seq(dev);
if (seq < 0) {
ret = seq;
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 10/19] dm: core: Add a comment for DM_FLAG_OF_PLATDATA

2019-12-29 Thread Simon Glass
This flag is missing a comment. Add one.

Signed-off-by: Simon Glass 
---

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

diff --git a/include/dm/device.h b/include/dm/device.h
index d7ad9d6728..21774708e7 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -45,6 +45,7 @@ struct driver_info;
 /* Device name is allocated and should be freed on unbind() */
 #define DM_FLAG_NAME_ALLOCED   (1 << 7)
 
+/* Device has platform data provided by of-platdata */
 #define DM_FLAG_OF_PLATDATA(1 << 8)
 
 /*
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 14/19] test: Add functions to find the amount of allocated memory

2019-12-29 Thread Simon Glass
The malloc() implementations provides a way of finding out the approximate
amount of memory that is allocated. Add helper functions to make it easier
to access this and see changes over time. This is useful for tests that
want to check if memory has been allocated or freed.

Signed-off-by: Simon Glass 
---

 include/test/ut.h | 16 
 test/ut.c | 14 ++
 2 files changed, 30 insertions(+)

diff --git a/include/test/ut.h b/include/test/ut.h
index fbfde10719..f616c202f3 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -149,4 +149,20 @@ void ut_failf(struct unit_test_state *uts, const char 
*fname, int line,
 /* Assert that an operation succeeds (returns 0) */
 #define ut_assertok(cond)  ut_asserteq(0, cond)
 
+/**
+ * ut_check_free() - Return the number of bytes free in the malloc() pool
+ *
+ * @return bytes free
+ */
+ulong ut_check_free(void);
+
+/**
+ * ut_check_delta() - Return the number of bytes allocated/freed
+ *
+ * @last: Last value from ut_check_free
+ * @return free memory delta from @last; positive means more memory has been
+ * allocated, negative means less has been allocated (i.e. some is freed)
+ */
+long ut_check_delta(ulong last);
+
 #endif
diff --git a/test/ut.c b/test/ut.c
index 55798041ba..265da4a0d8 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -32,3 +33,16 @@ void ut_failf(struct unit_test_state *uts, const char 
*fname, int line,
putc('\n');
uts->fail_count++;
 }
+
+ulong ut_check_free(void)
+{
+   struct mallinfo info = mallinfo();
+
+   return info.uordblks;
+}
+
+long ut_check_delta(ulong last)
+{
+   return ut_check_free() - last;
+}
+
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 07/19] dm: core: Don't clear active flag twice when probe() fails

2019-12-29 Thread Simon Glass
Remove this duplicated code, since the 'fail' label does this immediately.

Signed-off-by: Simon Glass 
---

 drivers/core/device.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 4e037083a6..2442b5834d 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -431,10 +431,8 @@ int device_probe(struct udevice *dev)
 
if (drv->probe) {
ret = drv->probe(dev);
-   if (ret) {
-   dev->flags &= ~DM_FLAG_ACTIVATED;
+   if (ret)
goto fail;
-   }
}
 
ret = uclass_post_probe_device(dev);
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 12/19] dm: core: Add a new flag to track platform data

2019-12-29 Thread Simon Glass
We want to avoid allocating platform data twice. This could happen if
device_probe() is called after device_ofdata_to_platdata() for the same
device.

Add a flag to track whether device_ofdata_to_platdata() has been called on
a device. Check the flag to make sure it doesn't happen twice, and clear
the flag when the data is freed.

Signed-off-by: Simon Glass 
---

 drivers/core/device-remove.c | 1 +
 drivers/core/device.c| 4 +++-
 include/dm/device.h  | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index 5c8dc4ad70..444e34b492 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -140,6 +140,7 @@ void device_free(struct udevice *dev)
dev->parent_priv = NULL;
}
}
+   dev->flags &= ~DM_FLAG_PLATDATA_VALID;
 
devres_release_probe(dev);
 }
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 9506c7df8d..9f39218423 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -320,7 +320,7 @@ int device_ofdata_to_platdata(struct udevice *dev)
if (!dev)
return -EINVAL;
 
-   if (dev->flags & DM_FLAG_ACTIVATED)
+   if (dev->flags & DM_FLAG_PLATDATA_VALID)
return 0;
 
drv = dev->driver;
@@ -368,6 +368,8 @@ int device_ofdata_to_platdata(struct udevice *dev)
goto fail;
}
 
+   dev->flags |= DM_FLAG_PLATDATA_VALID;
+
return 0;
 fail:
device_free(dev);
diff --git a/include/dm/device.h b/include/dm/device.h
index 21774708e7..9ebfd0a34e 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -65,6 +65,9 @@ struct driver_info;
 /* DM does not enable/disable the power domains corresponding to this device */
 #define DM_FLAG_DEFAULT_PD_CTRL_OFF(1 << 11)
 
+/* Driver platdata has been read. Cleared when the device is removed */
+#define DM_FLAG_PLATDATA_VALID (1 << 12)
+
 /*
  * One or multiple of these flags are passed to device_remove() so that
  * a selective device removal as specified by the remove-stage and the
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 06/19] aspeed: ast2500: Read clock ofdata in the correct method

2019-12-29 Thread Simon Glass
At present the clock driver reads its ofdata in the probe() method. This
is not correct although it is often harmless.

However in this case it causes a problem, something like this:

- ast_get_scu() is called (from somewhere) to get the SCI address
- this probes the clock
   - first sets up ofdata (which does nothing at present)
   - DM marks clock device as active
   - DM calls pinctrl
  - pinctrl probes and calls ast_get_scu() in ast2500_pinctrl_probe()
  - ast_get_scu() probes the clock, but sees it already marked as
   probed
  - ast_get_scu() accesses the clock's private data, with scu as NULL
   - DM calls clock probe function ast2500_clk_probe() which reads scu

By putting the read of scu into the correct method, scu is read as part of
ofdata setup, and everything is OK.

Note: This problem did not matter until now since DM always probed all
parents before reading a child's ofdata. The fact that pinctrl is a child
of clock seems to trigger this strange bug.

Signed-off-by: Simon Glass 
---

 drivers/clk/aspeed/clk_ast2500.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
index 9249cf9cdf..b3a3f3d4dd 100644
--- a/drivers/clk/aspeed/clk_ast2500.c
+++ b/drivers/clk/aspeed/clk_ast2500.c
@@ -490,7 +490,7 @@ struct clk_ops ast2500_clk_ops = {
.enable = ast2500_clk_enable,
 };
 
-static int ast2500_clk_probe(struct udevice *dev)
+static int ast2500_clk_ofdata_to_platdata(struct udevice *dev)
 {
struct ast2500_clk_priv *priv = dev_get_priv(dev);
 
@@ -525,5 +525,5 @@ U_BOOT_DRIVER(aspeed_ast2500_scu) = {
.priv_auto_alloc_size = sizeof(struct ast2500_clk_priv),
.ops= _clk_ops,
.bind   = ast2500_clk_bind,
-   .probe  = ast2500_clk_probe,
+   .ofdata_to_platdata = ast2500_clk_ofdata_to_platdata,
 };
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 04/19] x86: apl: Avoid accessing the PCI bus before it is probed

2019-12-29 Thread Simon Glass
The PCI bus is not actually probed by the time the ofdata_to_platdata()
method is called since that happens in the uclass's post_probe() method.
Update the PMC and P2SB drivers to access the bus in its probe() method.

Signed-off-by: Simon Glass 
---

 arch/x86/cpu/apollolake/p2sb.c | 20 
 arch/x86/cpu/apollolake/pmc.c  | 20 +---
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/arch/x86/cpu/apollolake/p2sb.c b/arch/x86/cpu/apollolake/p2sb.c
index eb27861b7a..b72f50a627 100644
--- a/arch/x86/cpu/apollolake/p2sb.c
+++ b/arch/x86/cpu/apollolake/p2sb.c
@@ -106,11 +106,6 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev)
if (plat->bdf < 0)
return log_msg_ret("Cannot get p2sb PCI address",
   plat->bdf);
-   } else {
-   plat->mmio_base = dev_read_addr_pci(dev);
-   /* Don't set BDF since it should not be used */
-   if (!plat->mmio_base || plat->mmio_base == FDT_ADDR_T_NONE)
-   return -EINVAL;
}
 #else
plat->mmio_base = plat->dtplat.early_regs[0];
@@ -124,10 +119,19 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev)
 
 static int apl_p2sb_probe(struct udevice *dev)
 {
-   if (spl_phase() == PHASE_TPL)
+   if (spl_phase() == PHASE_TPL) {
return apl_p2sb_early_init(dev);
-   else if (spl_phase() == PHASE_SPL)
-   return apl_p2sb_spl_init(dev);
+   } else {
+   struct p2sb_platdata *plat = dev_get_platdata(dev);
+
+   plat->mmio_base = dev_read_addr_pci(dev);
+   /* Don't set BDF since it should not be used */
+   if (!plat->mmio_base || plat->mmio_base == FDT_ADDR_T_NONE)
+   return -EINVAL;
+
+   if (spl_phase() == PHASE_SPL)
+   return apl_p2sb_spl_init(dev);
+   }
 
return 0;
 }
diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c
index 683c6082f2..aec0c8394c 100644
--- a/arch/x86/cpu/apollolake/pmc.c
+++ b/arch/x86/cpu/apollolake/pmc.c
@@ -119,8 +119,16 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev)
ret = dev_read_u32_array(dev, "early-regs", base, ARRAY_SIZE(base));
if (ret)
return log_msg_ret("Missing/short early-regs", ret);
-   upriv->pmc_bar0 = (void *)base[0];
-   upriv->pmc_bar2 = (void *)base[2];
+   if (spl_phase() == PHASE_TPL) {
+   upriv->pmc_bar0 = (void *)base[0];
+   upriv->pmc_bar2 = (void *)base[2];
+
+   /* Since PCI is not enabled, we must get the BDF manually */
+   plat->bdf = pci_get_devfn(dev);
+   if (plat->bdf < 0)
+   return log_msg_ret("Cannot get PMC PCI address",
+  plat->bdf);
+   }
upriv->acpi_base = base[4];
 
/* Since PCI is not enabled, we must get the BDF manually */
@@ -187,8 +195,14 @@ static int enable_pmcbar(struct udevice *dev)
 
 static int apl_pmc_probe(struct udevice *dev)
 {
-   if (spl_phase() == PHASE_TPL)
+   if (spl_phase() == PHASE_TPL) {
return enable_pmcbar(dev);
+   } else {
+   struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev);
+
+   upriv->pmc_bar0 = (void *)dm_pci_read_bar32(dev, 0);
+   upriv->pmc_bar2 = (void *)dm_pci_read_bar32(dev, 2);
+   }
 
return 0;
 }
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 05/19] pci: Print a warning if the bus is accessed before probing

2019-12-29 Thread Simon Glass
It is not possible to access a device on a PCI bus that has not yet been
probed, since the bus number is not known. Add a warning to catch this
error.

Signed-off-by: Simon Glass 
---

 drivers/pci/pci-uclass.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 7308f612b6..5be2dfd0bf 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -48,6 +48,19 @@ pci_dev_t dm_pci_get_bdf(struct udevice *dev)
struct pci_child_platdata *pplat = dev_get_parent_platdata(dev);
struct udevice *bus = dev->parent;
 
+   /*
+* This error indicates that @dev is a device on an unprobed PCI bus.
+* The bus likely has bus=seq == -1, so the PCI_ADD_BUS() macro below
+* will produce a bad BDF>
+*
+* A common cause of this problem is that this function is called in the
+* ofdata_to_platdata() method of @dev. Accessing the PCI bus in that
+* method is not allowed, since it has not yet been probed. To fix this,
+* move that access to the probe() method of @dev instead.
+*/
+   if (!device_active(bus))
+   log_err("PCI: Device '%s' on unprobed bus '%s'\n", dev->name,
+   bus->name);
return PCI_ADD_BUS(bus->seq, pplat->devfn);
 }
 
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 03/19] usb: Drop use of BUG_ON() and WARN_ON()

2019-12-29 Thread Simon Glass
These macros use __FILE__ which inserts the full path of the object file
into U-Boot, thus increasing file size. Drop these usages.

An older version of this patch was submitted here:

http://patchwork.ozlabs.org/patch/1205784/

Signed-off-by: Simon Glass 
---

 drivers/usb/gadget/composite.c | 4 
 drivers/usb/gadget/f_mass_storage.c| 4 
 drivers/usb/musb-new/musb_core.c   | 4 
 drivers/usb/musb-new/musb_gadget_ep0.c | 2 +-
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index c98a444245..4a6f4271d5 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1003,7 +1003,11 @@ static void composite_unbind(struct usb_gadget *gadget)
 * so there's no i/o concurrency that could affect the
 * state protected by cdev->lock.
 */
+#ifdef __UBOOT__
+   assert_noisy(!cdev->config);
+#else
BUG_ON(cdev->config);
+#endif
 
while (!list_empty(>configs)) {
c = list_first_entry(>configs,
diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index 45c7b58eed..c1e6506659 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -390,7 +390,11 @@ static inline int __fsg_is_set(struct fsg_common *common,
if (common->fsg)
return 1;
ERROR(common, "common->fsg is NULL in %s at %u\n", func, line);
+#ifdef __UBOOT__
+   assert_noisy(false);
+#else
WARN_ON(1);
+#endif
return 0;
 }
 
diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
index afea9fbcef..ab5e3aa9d1 100644
--- a/drivers/usb/musb-new/musb_core.c
+++ b/drivers/usb/musb-new/musb_core.c
@@ -1859,7 +1859,11 @@ allocate_instance(struct device *dev,
musb->ctrl_base = mbase;
musb->nIrq = -ENODEV;
musb->config = config;
+#ifdef __UBOOT__
+   assert_noisy(musb->config->num_eps <= MUSB_C_NUM_EPS);
+#else
BUG_ON(musb->config->num_eps > MUSB_C_NUM_EPS);
+#endif
for (epnum = 0, ep = musb->endpoints;
epnum < musb->config->num_eps;
epnum++, ep++) {
diff --git a/drivers/usb/musb-new/musb_gadget_ep0.c 
b/drivers/usb/musb-new/musb_gadget_ep0.c
index 9835a2e2bf..3ef8fe1373 100644
--- a/drivers/usb/musb-new/musb_gadget_ep0.c
+++ b/drivers/usb/musb-new/musb_gadget_ep0.c
@@ -882,7 +882,7 @@ finish:
 
default:
/* "can't happen" */
-   WARN_ON(1);
+   assert_noisy(false);
musb_writew(regs, MUSB_CSR0, MUSB_CSR0_P_SENDSTALL);
musb->ep0_state = MUSB_EP0_STAGE_IDLE;
break;
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 02/19] dm: core: Use assert_noisy() in devres

2019-12-29 Thread Simon Glass
Use this macros instead of the linux ones, as the output is smaller.

Signed-off-by: Simon Glass 
---

 drivers/core/devres.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index f2a19ec61b..a3f915dd73 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -80,7 +80,7 @@ void devres_free(void *res)
if (res) {
struct devres *dr = container_of(res, struct devres, data);
 
-   BUG_ON(!list_empty(>entry));
+   assert_noisy(list_empty(>entry));
kfree(dr);
}
 }
@@ -90,7 +90,7 @@ void devres_add(struct udevice *dev, void *res)
struct devres *dr = container_of(res, struct devres, data);
 
devres_log(dev, dr, "ADD");
-   BUG_ON(!list_empty(>entry));
+   assert_noisy(list_empty(>entry));
dr->probe = dev->flags & DM_FLAG_BOUND ? true : false;
list_add_tail(>entry, >devres_head);
 }
@@ -254,5 +254,5 @@ void devm_kfree(struct udevice *dev, void *p)
int rc;
 
rc = devres_destroy(dev, devm_kmalloc_release, devm_kmalloc_match, p);
-   WARN_ON(rc);
+   assert_noisy(!rc);
 }
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 01/19] common: Add a noisy assert()

2019-12-29 Thread Simon Glass
Some U-Boot code uses BUG_ON() and WARN_ON() macros. These use __FILE__
which can include quite a large path, depending on how U-Boot is built.

The existing assert() is only checked if DEBUG is enabled. Add a new one
which is always checked, and prints a (smaller) error in that case.

Signed-off-by: Simon Glass 
---

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

diff --git a/include/log.h b/include/log.h
index d8f18a6afd..c6f2f023b1 100644
--- a/include/log.h
+++ b/include/log.h
@@ -218,6 +218,20 @@ void __assert_fail(const char *assertion, const char 
*file, unsigned int line,
({ if (!(x) && _DEBUG) \
__assert_fail(#x, __FILE__, __LINE__, __func__); })
 
+/*
+ * This one actually gets compiled in even without DEBUG. It doesn't include 
the
+ * full pathname as it may be huge. Only use this when the user should be
+ * warning, similar to BUG_ON() in linux.
+ *
+ * @return true if assertion succeeded (condition is true), else false
+ */
+#define assert_noisy(x) \
+   ({ bool _val = (x); \
+   if (!_val) \
+   __assert_fail(#x, "?", __LINE__, __func__); \
+   _val; \
+   })
+
 #if CONFIG_IS_ENABLED(LOG) && defined(CONFIG_LOG_ERROR_RETURN)
 /*
  * Log an error return value, possibly with a message. Usage:
-- 
2.24.1.735.g03f4e72817-goog



[PATCH 00/19] dm: core: Fully separate ofdata_to_platdata() from probe()

2019-12-29 Thread Simon Glass
At present ofdata_to_platdata() is done as part of device_probe(). Drivers
are supposed to read their platdata in the ofdata_to_platdata method() but
this requirement is not always followed.

Having these methods separate helps deal with of-platdata, where the
probe() method is common to both DT/of-platdata operation, but the
ofdata_to_platdata() method is implemented differently.

Another case has come up where this separate is useful. Generation of ACPI
tables uses the of-platdata but does not want to probe the device. Probing
would cause U-Boot to violate one of its design principles, viz that it
should only probe devices that are used. For ACPI we want to generate a
table for each device, even if U-Boot does not use it. In fact it may not
even be possible to probe the device - e.g. an SD card which is not
present will cause an error on probe, yet we still must tell Linux about
the SD card connector in case it is used while Linux is running.

This series splits out the ofdata_to_platdata() part of device_probe() so
that it can be used separately from device_probe(). Thus devices now go
through two distinct states when probing: reading platform data and
actually touching the hardware to bring the device up.

This should not break existing boards since the operations still happen in
mostly the same order. The main change is that parents and uclasses are
probed after ofdata_to_platdata() is called.

HOWEVER it is quite possible that some boards break the rules and due to
a series of unfortunate events, something will break. Two boards were
found in this category already. SO this series may require some tidying up
from board maintainers, if problems arise.

Note that there are cases where devices must be probed in the
ofdata_to_platdata() method. An example is where a GPIO is selected - this
obviously requires that the GPIO device is probed.

One board was found to burst its size limit with this series, despite the
very small size increase. The patches to remove use of BUG_ON() are to
ensure that this series passes tests.


Simon Glass (19):
  common: Add a noisy assert()
  dm: core: Use assert_noisy() in devres
  usb: Drop use of BUG_ON() and WARN_ON()
  x86: apl: Avoid accessing the PCI bus before it is probed
  pci: Print a warning if the bus is accessed before probing
  aspeed: ast2500: Read clock ofdata in the correct method
  dm: core: Don't clear active flag twice when probe() fails
  dm: core: Move ofdata_to_platdata() call earlier
  dm: core: Allocate parent data separate from probing parent
  dm: core: Add a comment for DM_FLAG_OF_PLATDATA
  dm: core: Export a new function to read platdata
  dm: core: Add a new flag to track platform data
  dm: devres: Create a new devres header file
  test: Add functions to find the amount of allocated memory
  dm: devres: Convert to use logging
  dm: test: Add a test driver for devres
  dm: devres: Add tests
  dm: devres: Use an enum for the allocation phase
  dm: devres: Add a new OFDATA phase

 arch/sandbox/dts/test.dts  |   4 +
 arch/x86/cpu/apollolake/p2sb.c |  20 +-
 arch/x86/cpu/apollolake/pmc.c  |  20 +-
 drivers/clk/aspeed/clk_ast2500.c   |   4 +-
 drivers/core/device-remove.c   |   1 +
 drivers/core/device.c  |  56 +++--
 drivers/core/devres.c  |  57 -
 drivers/pci/pci-uclass.c   |  13 ++
 drivers/usb/gadget/composite.c |   4 +
 drivers/usb/gadget/f_mass_storage.c|   4 +
 drivers/usb/musb-new/musb_core.c   |   4 +
 drivers/usb/musb-new/musb_gadget_ep0.c |   2 +-
 include/dm/device-internal.h   |  16 ++
 include/dm/device.h| 259 +-
 include/dm/devres.h| 289 +
 include/dm/uclass-id.h |   1 +
 include/log.h  |  15 ++
 include/test/test.h|  10 +
 include/test/ut.h  |  16 ++
 test/dm/Makefile   |   1 +
 test/dm/devres.c   | 186 
 test/dm/test-fdt.c |  58 +
 test/ut.c  |  14 ++
 23 files changed, 760 insertions(+), 294 deletions(-)
 create mode 100644 include/dm/devres.h
 create mode 100644 test/dm/devres.c

-- 
2.24.1.735.g03f4e72817-goog



Re: [PATCH 02/11] distro_bootcmd: Add SF support

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Add distro boot command support for SPI flash.

This distro boot will read the boot script at specific
location at the flash and start sourcing the same.

The common macro like BOOTENV_SHARED_FLASH would help
to extend the support for nand flash in future.

Cc: Tom Rini 
Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  include/config_distro_bootcmd.h | 35 +
  1 file changed, 35 insertions(+)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index fc0935fa21..d68b79e290 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -43,6 +43,22 @@
  #define BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance) \
#devtypel #instance " "
  
+#define BOOTENV_SHARED_SF_BODY(devtypel) \

+   "if " #devtypel " probe ${devnum}; then " \
+   "devtype=" #devtypel "; " \
+   "run scan_flash_for_scripts; "  \
+   "fi\0"
+
+#define BOOTENV_SHARED_FLASH(devtypel) \
+   #devtypel "_boot=" \
+   BOOTENV_SHARED_SF_BODY(devtypel)
+
+#define BOOTENV_DEV_FLASH(devtypeu, devtypel, instance) \
+   BOOTENV_DEV_BLKDEV(devtypeu, devtypel, instance)
+
+#define BOOTENV_DEV_NAME_FLASH(devtypeu, devtypel, instance) \
+   BOOTENV_DEV_NAME_BLKDEV(devtypeu, devtypel, instance)
+
  #ifdef CONFIG_SANDBOX
  #define BOOTENV_SHARED_HOST   BOOTENV_SHARED_BLKDEV(host)
  #define BOOTENV_DEV_HOST  BOOTENV_DEV_BLKDEV
@@ -398,6 +414,18 @@
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
  #endif
  
+#if defined(CONFIG_CMD_SF)

+#define BOOTENV_SHARED_SF  BOOTENV_SHARED_FLASH(sf)
+#define BOOTENV_DEV_SF BOOTENV_DEV_FLASH
+#define BOOTENV_DEV_NAME_SFBOOTENV_DEV_NAME_FLASH
+#else
+#define BOOTENV_SHARED_SF
+#define BOOTENV_DEV_SF \
+   BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF
+#define BOOTENV_DEV_NAME_SF \
+   BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF
+#endif
+
  #define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \
BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance)
  #define BOOTENV_BOOT_TARGETS \
@@ -412,6 +440,7 @@
BOOTENV_SHARED_USB \
BOOTENV_SHARED_SATA \
BOOTENV_SHARED_SCSI \
+   BOOTENV_SHARED_SF \
BOOTENV_SHARED_NVME \
BOOTENV_SHARED_IDE \
BOOTENV_SHARED_UBIFS \
@@ -436,6 +465,12 @@
"echo SCRIPT FAILED: continuing...; " \
"fi\0"\
\
+   "scan_flash_for_scripts=" \
+   "${devtype} read ${scriptaddr} "  \
+   "${script_offset_f} ${script_size_f}; " 
\
+   "source ${scriptaddr}; "\
+   "echo SCRIPT FAILED: continuing...\0"   \
+   \
"boot_a_script="  \
"load ${devtype} ${devnum}:${distro_bootpart} "   \
"${scriptaddr} ${prefix}${script}; "  \





Re: [PATCH 05/11] rk3399: Check MMC env while defining it

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

rk3399 do support SPI flash as well, so there is
a possibility of using flash environment for those
usecases.

So define env device for MMC only when it is used
by specific configuration.

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  include/configs/evb_rk3399.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/configs/evb_rk3399.h b/include/configs/evb_rk3399.h
index b9c4d683f4..c0b0358893 100644
--- a/include/configs/evb_rk3399.h
+++ b/include/configs/evb_rk3399.h
@@ -8,7 +8,9 @@
  
  #include 
  
-#define CONFIG_SYS_MMC_ENV_DEV 0

+#if defined(CONFIG_ENV_IS_IN_MMC)
+# define CONFIG_SYS_MMC_ENV_DEV0
+#endif
  
  #define SDRAM_BANK_SIZE			(2UL << 30)
  





Re: [PATCH 04/11] rk3399: Add boot flash script offet, size

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Most of the SPI flash devices in rockchip (rk3399)
are 16MiB size. So, let's use the script offset at
the end of 8K.

This way it cannot overlap any offsets being used
by software components in flash layout.

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  include/configs/rk3399_common.h | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 127ca1f09c..92eb5cb750 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -48,6 +48,8 @@
  
  #define ENV_MEM_LAYOUT_SETTINGS \

"scriptaddr=0x0050\0" \
+   "script_offset_f=0xffe000\0" \
+   "script_size_f=0x2000\0" \
"pxefile_addr_r=0x0060\0" \
"fdt_addr_r=0x01f0\0" \
"kernel_addr_r=0x0208\0" \





Re: [PATCH 11/11] roc-rk3399-pc: Add SPI boot support

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Add SPI boot support for ROC-RK3399-PC board.

This would add separate config file


What is the key reason to have a new separate config file? I think it 
would be much better


to use the same defconfig, spi boot is one of features like other 
features, it should not need


a separate config.


Thanks,

- Kever


  for SPI along
with dts changes.

Signed-off-by: Jagan Teki 
---
  arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 12 -
  board/rockchip/evb_rk3399/MAINTAINERS  |  2 +
  configs/roc-pc-rk3399-spi_defconfig| 62 ++
  3 files changed, 75 insertions(+), 1 deletion(-)
  create mode 100644 configs/roc-pc-rk3399-spi_defconfig

diff --git a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi 
b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
index 5746442981..6e43c7c71b 100644
--- a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
@@ -11,8 +11,18 @@
spi0 = 
};
  
+	config {

+   u-boot,spl-payload-offset = <0x4>; /* @ 256KB */
+   };
+
chosen {
-   u-boot,spl-boot-order = "same-as-spl", , 
+   u-boot,spl-boot-order = "same-as-spl", _flash, , 

+   };
+};
+
+ {
+   spi_flash: flash@0 {
+   u-boot,dm-pre-reloc;
};
  };
  
diff --git a/board/rockchip/evb_rk3399/MAINTAINERS b/board/rockchip/evb_rk3399/MAINTAINERS

index eab4c4c525..8de6ec88f1 100644
--- a/board/rockchip/evb_rk3399/MAINTAINERS
+++ b/board/rockchip/evb_rk3399/MAINTAINERS
@@ -57,8 +57,10 @@ F:   arch/arm/dts/rk3399-orangepi-u-boot.dtsi
  
  ROC-RK3399-PC

  M:Levin Du 
+M: Jagan Teki 
  S:Maintained
  F:configs/roc-pc-rk3399_defconfig
+F: configs/roc-pc-rk3399-spi_defconfig
  F:arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
  
  ROCK-PI-4

diff --git a/configs/roc-pc-rk3399-spi_defconfig 
b/configs/roc-pc-rk3399-spi_defconfig
new file mode 100644
index 00..1fdfb10101
--- /dev/null
+++ b/configs/roc-pc-rk3399-spi_defconfig
@@ -0,0 +1,62 @@
+CONFIG_ARM=y
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_SYS_TEXT_BASE=0x0020
+CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEBUG_UART_BASE=0xFF1A
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_DEBUG_UART=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+# CONFIG_SPL_MMC_SUPPORT is not set
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SPL_TEXT_BASE=0xff8c2000
+CONFIG_SPL_STACK_R=y
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x4000
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_TIME=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc"
+CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent 
assigned-clocks assigned-clock-rates assigned-clock-parents"
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ROCKCHIP_GPIO=y
+CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_ROCKCHIP=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ROCKCHIP=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_GMAC_ROCKCHIP=y
+CONFIG_PMIC_RK8XX=y
+CONFIG_REGULATOR_PWM=y
+CONFIG_REGULATOR_RK8XX=y
+CONFIG_PWM_ROCKCHIP=y
+CONFIG_RAM_RK3399_LPDDR4=y
+CONFIG_BAUDRATE=150
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYSRESET=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_ROCKCHIP_SPI=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_USB_ETHER_ASIX88179=y
+CONFIG_USB_ETHER_MCS7830=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_ERRNO_STR=y





Re: [PATCH 06/11] env: kconfig: Restrict rockchip env for MMC

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Rockchip do support SPI flash as well, so there is
a possibility of using flash environment for those
use cases.

So, restrict the current env offset, size for MMC.

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  env/Kconfig | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index ed12609f6a..9416a70022 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -488,7 +488,7 @@ config ENV_OFFSET
hex "Environment offset"
depends on ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
ENV_IS_IN_SPI_FLASH
-   default 0x3f8000 if ARCH_ROCKCHIP
+   default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
default 0x88000 if ARCH_SUNXI
default 0xE if ARCH_ZYNQ
default 0x1E0 if ARCH_ZYNQMP
@@ -511,7 +511,8 @@ config ENV_SIZE
hex "Environment Size"
default 0x4 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
default 0x2 if ARCH_SUNXI || ARCH_ZYNQ || ARCH_OMAP2PLUS || 
ARCH_AT91
-   default 0x8000 if ARCH_ROCKCHIP || ARCH_ZYNQMP || ARCH_VERSAL
+   default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
+   default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL
default 0x4000 if ARC
default 0x1f000
help





Re: [PATCH 07/11] env: Enable SPI flash env for rockchip

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Most of the SPI flash devices in rockchip are 16MiB size.

So, keeping U-Boot proper offset start from 128MiB with 1MiB
size and then start env of 8KiB would be a compatible location
between all variants of flash sizes.

This patch add env start from 0x14000 with a size of 8KiB.


You can add my review tag after update this 0x14 typo.

Reviewed-by: Kever Yang 


Thanks,
- Kever


Signed-off-by: Jagan Teki 
---
  env/Kconfig | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/env/Kconfig b/env/Kconfig
index 9416a70022..1bb3e1078e 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -489,6 +489,7 @@ config ENV_OFFSET
depends on ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
ENV_IS_IN_SPI_FLASH
default 0x3f8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
+   default 0x14 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
default 0x88000 if ARCH_SUNXI
default 0xE if ARCH_ZYNQ
default 0x1E0 if ARCH_ZYNQMP
@@ -512,6 +513,7 @@ config ENV_SIZE
default 0x4 if ENV_IS_IN_SPI_FLASH && ARCH_ZYNQMP
default 0x2 if ARCH_SUNXI || ARCH_ZYNQ || ARCH_OMAP2PLUS || 
ARCH_AT91
default 0x8000 if ARCH_ROCKCHIP && ENV_IS_IN_MMC
+   default 0x2000 if ARCH_ROCKCHIP && ENV_IS_IN_SPI_FLASH
default 0x8000 if ARCH_ZYNQMP || ARCH_VERSAL
default 0x4000 if ARC
default 0x1f000
@@ -521,6 +523,7 @@ config ENV_SIZE
  config ENV_SECT_SIZE
hex "Environment Sector-Size"
depends on ENV_IS_IN_FLASH || ENV_IS_IN_SPI_FLASH
+   default 0x2000 if ARCH_ROCKCHIP
default 0x4 if ARCH_ZYNQMP || ARCH_VERSAL
default 0x2 if ARCH_ZYNQ || ARCH_OMAP2PLUS || ARCH_AT91
help


Re: [PATCH 09/11] roc-pc-rk3399: Enable SPI Flash

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Enable winbond SPI flash for ROC-PC-RK3399 board.

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 4 
  configs/roc-pc-rk3399_defconfig| 2 ++
  2 files changed, 6 insertions(+)

diff --git a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi 
b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
index 77d5cf5d3c..5746442981 100644
--- a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
@@ -7,6 +7,10 @@
  #include "rk3399-sdram-lpddr4-100.dtsi"
  
  / {

+   aliases {
+   spi0 = 
+   };
+
chosen {
u-boot,spl-boot-order = "same-as-spl", , 
};
diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig
index 305baa712c..f37a7bda00 100644
--- a/configs/roc-pc-rk3399_defconfig
+++ b/configs/roc-pc-rk3399_defconfig
@@ -42,6 +42,8 @@ CONFIG_RAM_RK3399_LPDDR4=y
  CONFIG_BAUDRATE=150
  CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYSRESET=y
+CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_ROCKCHIP_SPI=y
  CONFIG_USB=y
  CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_XHCI_DWC3=y





Re: [PATCH 08/11] rockchip: dts: Sync ROC-RK3399-PC changes from Linux

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Sync the ROC-RK3399-PC device tree changes from Linux
with below commit details:

commit  ("arm64: dts:
rockchip: Enable MTD Flash on rk3399-roc-pc")

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-roc-pc.dts  | 673 +-
  arch/arm/dts/rk3399-roc-pc.dtsi | 813 
  2 files changed, 816 insertions(+), 670 deletions(-)
  create mode 100644 arch/arm/dts/rk3399-roc-pc.dtsi

diff --git a/arch/arm/dts/rk3399-roc-pc.dts b/arch/arm/dts/rk3399-roc-pc.dts
index 257543d069..6a909e4eef 100644
--- a/arch/arm/dts/rk3399-roc-pc.dts
+++ b/arch/arm/dts/rk3399-roc-pc.dts
@@ -4,677 +4,10 @@
   */
  
  /dts-v1/;

-#include 
-#include "rk3399.dtsi"
-#include "rk3399-opp.dtsi"
+#include "rk3399-roc-pc.dtsi"
  
  / {

model = "Firefly ROC-RK3399-PC Board";
-   compatible = "firefly,roc-rk3399-pc", "rockchip,rk3399";
-
-   chosen {
-   stdout-path = "serial2:150n8";
-   };
-
-   backlight: backlight {
-   compatible = "pwm-backlight";
-   pwms = < 0 25000 0>;
-   };
-
-   clkin_gmac: external-gmac-clock {
-   compatible = "fixed-clock";
-   clock-frequency = <12500>;
-   clock-output-names = "clkin_gmac";
-   #clock-cells = <0>;
-   };
-
-   sdio_pwrseq: sdio-pwrseq {
-   compatible = "mmc-pwrseq-simple";
-   clocks = < 1>;
-   clock-names = "ext_clock";
-   pinctrl-names = "default";
-   pinctrl-0 = <_enable_h>;
-
-   /*
-* On the module itself this is one of these (depending
-* on the actual card populated):
-* - SDIO_RESET_L_WL_REG_ON
-* - PDN (power down when low)
-*/
-   reset-gpios = < RK_PB2 GPIO_ACTIVE_LOW>;
-   };
-
-   vcc_vbus_typec0: vcc-vbus-typec0 {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc_vbus_typec0";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   };
-
-   /*
-* should be placed inside mp8859, but not until mp8859 has
-* its own dt-binding.
-*/
-   dc_12v: mp8859-dcdc1 {
-   compatible = "regulator-fixed";
-   regulator-name = "dc_12v";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <1200>;
-   regulator-max-microvolt = <1200>;
-   vin-supply = <_vbus_typec0>;
-   };
-
-   /* switched by pmic_sleep */
-   vcc1v8_s3: vcca1v8_s3: vcc1v8-s3 {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc1v8_s3";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <180>;
-   regulator-max-microvolt = <180>;
-   vin-supply = <_1v8>;
-   };
-
-   vcc3v3_sys: vcc3v3-sys {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc3v3_sys";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <330>;
-   regulator-max-microvolt = <330>;
-   vin-supply = <_sys>;
-   };
-
-   /* Actually 3 regulators (host0, 1, 2) controlled by the same gpio */
-   vcc5v0_host: vcc5v0-host-regulator {
-   compatible = "regulator-fixed";
-   enable-active-high;
-   gpio = < RK_PA0 GPIO_ACTIVE_HIGH>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_host_en _rst>;
-   regulator-name = "vcc5v0_host";
-   regulator-always-on;
-   vin-supply = <_sys>;
-   };
-
-   vcc_vbus_typec1: vcc-vbus-typec1 {
-   compatible = "regulator-fixed";
-   enable-active-high;
-   gpio = < RK_PB5 GPIO_ACTIVE_HIGH>;
-   pinctrl-names = "default";
-   pinctrl-0 = <_vbus_typec1_en>;
-   regulator-name = "vcc_vbus_typec1";
-   regulator-always-on;
-   vin-supply = <_sys>;
-   };
-
-   vcc_sys: vcc-sys {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc_sys";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   vin-supply = <_12v>;
-   };
-
-   vdd_log: vdd-log {
-   compatible = "pwm-regulator";
-   pwms = < 0 25000 1>;
-   regulator-name = "vdd_log";
-   regulator-always-on;
-   

Re: [PATCH 10/11] rockpro-rk3399: Enable SPI Flash

2019-12-29 Thread Kever Yang



On 2019/12/21 下午3:54, Jagan Teki wrote:

Enable winbond SPI flash for ROC-PC-RK3399 board.

Signed-off-by: Jagan Teki 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 
  configs/rockpro64-rk3399_defconfig| 2 ++
  2 files changed, 6 insertions(+)

diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi 
b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
index 4648513ea9..deaa3efd39 100644
--- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi
@@ -6,6 +6,10 @@
  #include "rk3399-u-boot.dtsi"
  #include "rk3399-sdram-lpddr4-100.dtsi"
  / {
+   aliases {
+   spi0 = 
+   };
+
chosen {
u-boot,spl-boot-order = "same-as-spl", , 
};
diff --git a/configs/rockpro64-rk3399_defconfig 
b/configs/rockpro64-rk3399_defconfig
index 49e27c91cb..6a50ec7dbc 100644
--- a/configs/rockpro64-rk3399_defconfig
+++ b/configs/rockpro64-rk3399_defconfig
@@ -46,6 +46,8 @@ CONFIG_RAM_RK3399_LPDDR4=y
  CONFIG_BAUDRATE=150
  CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYSRESET=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
+CONFIG_ROCKCHIP_SPI=y
  CONFIG_USB=y
  CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_XHCI_DWC3=y





[PATCH v5 1/5] image: Add IH_OS_EFI for EFI chain-load boot

2019-12-29 Thread Cristian Ciocaltea
Add a new OS type to be used for chain-loading an EFI compatible
firmware or boot loader like GRUB2, possibly in a verified boot
scenario.

Bellow is sample ITS file that generates a FIT image supporting
secure boot. Please note the presence of 'os = "efi";' line, which
identifies the currently introduced OS type:

/ {
#address-cells = <1>;

images {
efi-grub {
description = "GRUB EFI";
data = /incbin/("bootarm.efi");
type = "kernel_noload";
arch = "arm";
os = "efi";
compression = "none";
load = <0x0>;
entry = <0x0>;
hash-1 {
algo = "sha256";
};
};
};

configurations {
default = "config-grub";
config-grub {
kernel = "efi-grub";
signature-1 {
algo = "sha256,rsa2048";
sign-images = "kernel";
};
};
};
};

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
 common/image-fit.c | 3 ++-
 common/image.c | 1 +
 include/image.h| 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index c52f945120..231612ff5f 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1926,7 +1926,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
image_type == IH_TYPE_FPGA ||
fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
fit_image_check_os(fit, noffset, IH_OS_U_BOOT) ||
-   fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);
+   fit_image_check_os(fit, noffset, IH_OS_OPENRTOS) ||
+   fit_image_check_os(fit, noffset, IH_OS_EFI);
 
/*
 * If either of the checks fail, we should report an error, but
diff --git a/common/image.c b/common/image.c
index eb626dcac9..75d5dd944f 100644
--- a/common/image.c
+++ b/common/image.c
@@ -137,6 +137,7 @@ static const table_entry_t uimage_os[] = {
{   IH_OS_OPENRTOS, "openrtos", "OpenRTOS", },
 #endif
{   IH_OS_OPENSBI,  "opensbi",  "RISC-V OpenSBI",   },
+   {   IH_OS_EFI,  "efi",  "EFI Firmware" },
 
{   -1, "", "", },
 };
diff --git a/include/image.h b/include/image.h
index f4d2aaf53e..4a280b78e7 100644
--- a/include/image.h
+++ b/include/image.h
@@ -157,6 +157,7 @@ enum {
IH_OS_ARM_TRUSTED_FIRMWARE, /* ARM Trusted Firmware */
IH_OS_TEE,  /* Trusted Execution Environment */
IH_OS_OPENSBI,  /* RISC-V OpenSBI */
+   IH_OS_EFI,  /* EFI Firmware (e.g. GRUB2) */
 
IH_OS_COUNT,
 };
-- 
2.17.1



[PATCH v5 5/5] test/py: Create a test for launching UEFI binaries from FIT images

2019-12-29 Thread Cristian Ciocaltea
This test verifies the implementation of the 'bootm' extension that
handles UEFI binaries inside FIT images (enabled via CONFIG_BOOTM_EFI).

Signed-off-by: Cristian Ciocaltea 
---
 test/py/tests/test_efi_fit.py | 458 ++
 1 file changed, 458 insertions(+)
 create mode 100644 test/py/tests/test_efi_fit.py

diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py
new file mode 100644
index 00..6986b2d35c
--- /dev/null
+++ b/test/py/tests/test_efi_fit.py
@@ -0,0 +1,458 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019, Cristian Ciocaltea 
+#
+# Work based on:
+# - test_net.py
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+# - test_fit.py
+# Copyright (c) 2013, Google Inc.
+#
+# Test launching UEFI binaries from FIT images.
+
+import os.path
+import pytest
+import u_boot_utils as util
+
+"""
+Note: This test relies on boardenv_* containing configuration values to define
+which network environment is available for testing. Without this, the parts
+that rely on network will be automatically skipped.
+
+For example:
+
+# Boolean indicating whether the Ethernet device is attached to USB, and hence
+# USB enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_usb = False
+
+# Boolean indicating whether the Ethernet device is attached to PCI, and hence
+# PCI enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_pci = True
+
+# True if a DHCP server is attached to the network, and should be tested.
+# If DHCP testing is not possible or desired, this variable may be omitted or
+# set to False.
+env__net_dhcp_server = True
+
+# A list of environment variables that should be set in order to configure a
+# static IP. If solely relying on DHCP, this variable may be omitted or set to
+# an empty list.
+env__net_static_env_vars = [
+('ipaddr', '10.0.0.100'),
+('netmask', '255.255.255.0'),
+('serverip', '10.0.0.1'),
+]
+
+# Details regarding a file that may be read from a TFTP server. This variable
+# may be omitted or set to None if TFTP testing is not possible or desired.
+# Additionally, when the 'size' is not available, the file will be generated
+# automatically in the TFTP root directory, as specified by the 'dn' field.
+env__efi_fit_tftp_file = {
+'fn': 'test-efi-fit.img',   # File path relative to TFTP root
+'size': 3831,   # File size
+'crc32': '9fa3f79c',# Checksum using CRC-32 algorithm, optional
+'addr': 0x4040, # Loading address, integer, optional
+'dn': 'tftp/root/dir',  # TFTP root directory path, optional
+}
+"""
+
+# Define the parametrized ITS data to be used for FIT images generation.
+its_data = '''
+/dts-v1/;
+
+/ {
+description = "EFI image with FDT blob";
+#address-cells = <1>;
+
+images {
+efi {
+description = "Test EFI";
+data = /incbin/("%(efi-bin)s");
+type = "%(kernel-type)s";
+arch = "%(sys-arch)s";
+os = "efi";
+compression = "%(efi-comp)s";
+load = <0x0>;
+entry = <0x0>;
+};
+fdt {
+description = "Test FDT";
+data = /incbin/("%(fdt-bin)s");
+type = "flat_dt";
+arch = "%(sys-arch)s";
+compression = "%(fdt-comp)s";
+};
+};
+
+configurations {
+default = "config-efi-fdt";
+config-efi-fdt {
+description = "EFI FIT w/ FDT";
+kernel = "efi";
+fdt = "fdt";
+};
+config-efi-nofdt {
+description = "EFI FIT w/o FDT";
+kernel = "efi";
+};
+};
+};
+'''
+
+# Define the parametrized FDT data to be used for DTB images generation.
+fdt_data = '''
+/dts-v1/;
+
+/ {
+#address-cells = <1>;
+#size-cells = <0>;
+
+model = "%(sys-arch)s %(fdt_type)s EFI FIT Boot Test";
+compatible = "%(sys-arch)s";
+
+reset@0 {
+compatible = "%(sys-arch)s,reset";
+reg = <0>;
+};
+};
+'''
+
+@pytest.mark.buildconfigspec('bootm_efi')
+@pytest.mark.buildconfigspec('cmd_bootefi_hello_compile')
+@pytest.mark.buildconfigspec('fit')
+@pytest.mark.notbuildconfigspec('generate_acpi_table')
+@pytest.mark.requiredtool('dtc')
+def test_efi_fit_launch(u_boot_console):
+"""Test handling of UEFI binaries inside FIT images.
+
+The tests are trying to launch U-Boot's helloworld.efi embedded into
+FIT images, in uncompressed or gzip compressed format.
+
+Additionally, a sample FDT blob is created and embedded into the above
+mentioned FIT images, in uncompressed or gzip compressed format.
+
+For more details, see launch_efi().
+
+The following test cases are currently defined and enabled:
+ - Launch uncompressed FIT EFI & internal FDT
+ - Launch uncompressed FIT EFI & FIT 

[PATCH v5 4/5] doc: uefi.rst: Document launching UEFI binaries from FIT images

2019-12-29 Thread Cristian Ciocaltea
This patch adds a new section "Launching a UEFI binary from a FIT image"
documenting the usage of the CONFIG_BOOTM_EFI extension to bootm command
that offers a verified boot alternative for UEFI binaries such as GRUB2.

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
 doc/uefi/uefi.rst | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/doc/uefi/uefi.rst b/doc/uefi/uefi.rst
index db942df694..a8fd886d6b 100644
--- a/doc/uefi/uefi.rst
+++ b/doc/uefi/uefi.rst
@@ -63,6 +63,40 @@ The environment variable 'bootargs' is passed as load 
options in the UEFI system
 table. The Linux kernel EFI stub uses the load options as command line
 arguments.
 
+Launching a UEFI binary from a FIT image
+
+
+A signed FIT image can be used to securely boot a UEFI image via the
+bootm command. This feature is available if U-Boot is configured with::
+
+CONFIG_BOOTM_EFI=y
+
+A sample configuration is provided as file doc/uImage.FIT/uefi.its.
+
+Below you find the output of an example session starting GRUB::
+
+=> load mmc 0:1 ${kernel_addr_r} image.fit
+4620426 bytes read in 83 ms (53.1 MiB/s)
+=> bootm ${kernel_addr_r}#config-grub-nofdt
+## Loading kernel from FIT Image at 4040 ...
+   Using 'config-grub-nofdt' configuration
+   Verifying Hash Integrity ... sha256,rsa2048:dev+ OK
+   Trying 'efi-grub' kernel subimage
+ Description:  GRUB EFI Firmware
+ Created:  2019-11-20   8:18:16 UTC
+ Type: Kernel Image (no loading done)
+ Compression:  uncompressed
+ Data Start:   0x404000d0
+ Data Size:450560 Bytes = 440 KiB
+ Hash algo:sha256
+ Hash value:   
4dbee00021112df618f58b3f7cf5e1595533d543094064b9ce991e8b054a9eec
+   Verifying Hash Integrity ... sha256+ OK
+   XIP Kernel Image (no loading done)
+## Transferring control to EFI (at address 404000d0) ...
+Welcome to GRUB!
+
+See doc/uImage.FIT/howto.txt for an introduction to FIT images.
+
 Executing the boot manager
 ~~
 
-- 
2.17.1



[PATCH v5 2/5] bootm: Add a bootm command for type IH_OS_EFI

2019-12-29 Thread Cristian Ciocaltea
Add support for booting EFI binaries contained in FIT images.
A typical usage scenario is chain-loading GRUB2 in a verified
boot environment.

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
 cmd/Kconfig   |  7 ++
 common/bootm_os.c | 56 +++
 2 files changed, 63 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1e4cf146c5..4394bb8e51 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -251,6 +251,13 @@ config CMD_BOOTM
help
  Boot an application image from the memory.
 
+config BOOTM_EFI
+   bool "Support booting UEFI FIT images"
+   depends on CMD_BOOTEFI && CMD_BOOTM && FIT
+   default y
+   help
+ Support booting UEFI FIT images via the bootm command.
+
 config CMD_BOOTZ
bool "bootz"
help
diff --git a/common/bootm_os.c b/common/bootm_os.c
index d89ddc32b0..1d58462509 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -7,10 +7,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -498,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char * const 
argv[],
 }
 #endif
 
+#ifdef CONFIG_BOOTM_EFI
+static int do_bootm_efi(int flag, int argc, char * const argv[],
+   bootm_headers_t *images)
+{
+   int ret;
+   efi_status_t efi_ret;
+   void *image_buf;
+
+   if (flag != BOOTM_STATE_OS_GO)
+   return 0;
+
+   /* Locate FDT, if provided */
+   ret = bootm_find_images(flag, argc, argv);
+   if (ret)
+   return ret;
+
+   /* Initialize EFI drivers */
+   efi_ret = efi_init_obj_list();
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to initialize UEFI sub-system: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   /* Install device tree */
+   efi_ret = efi_install_fdt(images->ft_len
+ ? images->ft_addr : EFI_FDT_USE_INTERNAL);
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to install device tree: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   /* Run EFI image */
+   printf("## Transferring control to EFI (at address %08lx) ...\n",
+  images->ep);
+   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+   image_buf = map_sysmem(images->ep, images->os.image_len);
+
+   efi_ret = efi_run_image(image_buf, images->os.image_len);
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to run EFI image: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   return 0;
+}
+#endif
+
 static boot_os_fn *boot_os[] = {
[IH_OS_U_BOOT] = do_bootm_standalone,
 #ifdef CONFIG_BOOTM_LINUX
@@ -534,6 +587,9 @@ static boot_os_fn *boot_os[] = {
 #ifdef CONFIG_BOOTM_OPTEE
[IH_OS_TEE] = do_bootm_tee,
 #endif
+#ifdef CONFIG_BOOTM_EFI
+   [IH_OS_EFI] = do_bootm_efi,
+#endif
 };
 
 /* Allow for arch specific config before we boot */
-- 
2.17.1



[PATCH v5 0/5] Add support for booting EFI FIT images

2019-12-29 Thread Cristian Ciocaltea
Currently the only way to run an EFI binary like GRUB2 is via the
'bootefi' command, which cannot be used in a verified boot scenario.

The obvious solution to this limitation is to add support for
booting FIT images containing those EFI binaries.

The implementation relies on a new image type - IH_OS_EFI - which
can be created by using 'os = "efi"' inside an ITS file:

/ {
#address-cells = <1>;

images {
efi-grub {
description = "GRUB EFI";
data = /incbin/("bootarm.efi");
type = "kernel_noload";
arch = "arm";
os = "efi";
compression = "none";
load = <0x0>;
entry = <0x0>;
hash-1 {
algo = "sha256";
};
};
};

configurations {
default = "config-grub";
config-grub {
kernel = "efi-grub";
signature-1 {
algo = "sha256,rsa2048";
sign-images = "kernel";
};
};
};
};

The bootm command has been extended to handle the IH_OS_EFI images.
To enable this feature, a new configuration option has been added:
BOOTM_EFI

I tested the solution using the 'qemu_arm' board:

=> load scsi 0:1 ${kernel_addr_r} efi-image.fit
=> bootm ${kernel_addr_r}#config-grub

Changes in v5:
* Update the definition of BOOTM_EFI: move content right after
  CMD_BOOTM, improve description and help text, fix dependency
* Change the type of the 'addr' field inside 'env__efi_fit_tftp_file'
  dictionary from string to integer, currently tested on: sandbox,
  qemu_arm, qemu_arm64

Changes in v4:
* Extend the python test to also run on real hardware, currently
  tested on qemu_arm

Changes in v3:
* Rebase patches on Heinrich Schuchardt's patch series v3:
   efi_loader: prepare for FIT images
   https://lists.denx.de/pipermail/u-boot/2019-December/393677.html
   This fixes implicitly the sandbox issue 'phys_to_virt: Cannot map
   sandbox address' since efi_install_fdt() is now expecting a pointer
   to addressable memory instead of a physical address.
* Get rid of 'EFI/BOOT/' prefix used in ITS samples
* Add a python test to verify the implementation in sandbox environment

Changes in v2:
* Rebase patches on Heinrich Schuchardt's patch series:
   efi_loader: prepare for FIT images
   https://lists.denx.de/pipermail/u-boot/2019-December/393192.html
* Add sample configuration: doc/uImage.FIT/uefi.its
* Update uefi documentation: doc/uefi/uefi.rst

Cristian Ciocaltea (5):
  image: Add IH_OS_EFI for EFI chain-load boot
  bootm: Add a bootm command for type IH_OS_EFI
  doc: Add sample uefi.its image description file
  doc: uefi.rst: Document launching UEFI binaries from FIT images
  test/py: Create a test for launching UEFI binaries from FIT images

 cmd/Kconfig   |   7 +
 common/bootm_os.c |  56 +
 common/image-fit.c|   3 +-
 common/image.c|   1 +
 doc/uImage.FIT/uefi.its   |  67 +
 doc/uefi/uefi.rst |  34 +++
 include/image.h   |   1 +
 test/py/tests/test_efi_fit.py | 458 ++
 8 files changed, 626 insertions(+), 1 deletion(-)
 create mode 100644 doc/uImage.FIT/uefi.its
 create mode 100644 test/py/tests/test_efi_fit.py

-- 
2.17.1



[PATCH v5 3/5] doc: Add sample uefi.its image description file

2019-12-29 Thread Cristian Ciocaltea
This patch adds an example FIT image description file demonstrating
the usage of bootm command to securely launch UEFI binaries.

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
 doc/uImage.FIT/uefi.its | 67 +
 1 file changed, 67 insertions(+)
 create mode 100644 doc/uImage.FIT/uefi.its

diff --git a/doc/uImage.FIT/uefi.its b/doc/uImage.FIT/uefi.its
new file mode 100644
index 00..378ca4ed8d
--- /dev/null
+++ b/doc/uImage.FIT/uefi.its
@@ -0,0 +1,67 @@
+/*
+ * Example FIT image description file demonstrating the usage of the
+ * bootm command to launch UEFI binaries.
+ *
+ * Two boot configurations are available to enable booting GRUB2 on QEMU,
+ * the former uses a FDT blob contained in the FIT image, while the later
+ * relies on the FDT provided by the board emulator.
+ */
+
+/dts-v1/;
+
+/ {
+   description = "GRUB2 EFI and QEMU FDT blob";
+   #address-cells = <1>;
+
+   images {
+   efi-grub {
+   description = "GRUB EFI Firmware";
+   data = /incbin/("bootarm.efi");
+   type = "kernel_noload";
+   arch = "arm";
+   os = "efi";
+   compression = "none";
+   load = <0x0>;
+   entry = <0x0>;
+   hash-1 {
+   algo = "sha256";
+   };
+   };
+
+   fdt-qemu {
+   description = "QEMU DTB";
+   data = /incbin/("qemu-arm.dtb");
+   type = "flat_dt";
+   arch = "arm";
+   compression = "none";
+   hash-1 {
+   algo = "sha256";
+   };
+   };
+   };
+
+   configurations {
+   default = "config-grub-fdt";
+
+   config-grub-fdt {
+   description = "GRUB EFI Boot w/ FDT";
+   kernel = "efi-grub";
+   fdt = "fdt-qemu";
+   signature-1 {
+   algo = "sha256,rsa2048";
+   key-name-hint = "dev";
+   sign-images = "kernel", "fdt";
+   };
+   };
+
+   config-grub-nofdt {
+   description = "GRUB EFI Boot w/o FDT";
+   kernel = "efi-grub";
+   signature-1 {
+   algo = "sha256,rsa2048";
+   key-name-hint = "dev";
+   sign-images = "kernel";
+   };
+   };
+   };
+};
-- 
2.17.1



Re: [PATCH PATCH v6 00/13] Add support for applications of overlays in SPL

2019-12-29 Thread Simon Glass
Hi Jean-Jacques,

On Mon, 23 Dec 2019 at 09:25, Jean-Jacques Hiblot  wrote:
>
> Tom, Simon,
>
> gentle ping on this series. It has been posted for a long time and I did
> not push for it because I was working on other stuff. am654x and J7x
> SOCs will need this kind of feature.
>
> Before sending a version rebased on latest u-boot, I would have liked to
> have your feeling on the series as a whole.

It looks fine from my point of view, but does need tests.


- Simon


Re: [PATCH PATCH v6 12/13] dts: Add support for adding DT overlays in u-boot.img

2019-12-29 Thread Simon Glass
On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot  wrote:
>
> If u-boot.img is a FIT image, CONFIG_OF_OVERLAY_LIST can be used to add
> DT overlays to u-boot.img.
>
> Signed-off-by: Jean-Jacques Hiblot 
> ---
>
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  Makefile| 3 ++-
>  dts/Kconfig | 8 
>  2 files changed, 10 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass 

nit below

>
> diff --git a/Makefile b/Makefile
> index 6fda3268e7..46c5bd4753 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1262,7 +1262,8 @@ MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T 
> firmware -C none -O u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> -p $(CONFIG_FIT_EXTERNAL_OFFSET) \
> -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
> -   $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
> +   $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) 
> \
> +   $(patsubst %,-b arch/$(ARCH)/dts/%.dtbo,$(subst 
> ",,$(CONFIG_OF_OVERLAY_LIST)))
>  else
>  MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
> -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
> diff --git a/dts/Kconfig b/dts/Kconfig
> index c9ab66..c150a9b2af 100644
> --- a/dts/Kconfig
> +++ b/dts/Kconfig
> @@ -130,6 +130,14 @@ config OF_LIST
>   device tree files (without the directory or .dtb suffix)
>   separated by .
>
> +config OF_OVERLAY_LIST
> +   string "List of device tree overlays to include for DT control"
> +   depends on SPL_LOAD_FIT_APPLY_OVERLAY
> +   help
> + This option specifies a list of device tree overlaysto use for DT

missing space

> + control. This option can then be used a FIT generator to include

by a FIT generator?


> + the overlays in the FIT image
> +
>  choice
> prompt "SPL OF LIST compression"
> depends on MULTI_DTB_FIT
> --
> 2.17.1
>


Re: [PATCH 1/2] menu: Make some parts of the menu available to other components

2019-12-29 Thread Simon Glass
Hi Schrempf,

On Tue, 10 Dec 2019 at 08:47, Schrempf Frieder
 wrote:
>
> From: Frieder Schrempf 
>
> In order to iterate over the menu entries and match for a specific
> name in the pxe boot, we need to properly export the needed structs
> and functions.
>
> Signed-off-by: Frieder Schrempf 
> ---
>  common/menu.c  | 31 +--
>  include/menu.h | 34 +-
>  2 files changed, 34 insertions(+), 31 deletions(-)
>
> diff --git a/common/menu.c b/common/menu.c
> index 7b66d199a9..82b03f17f7 100644
> --- a/common/menu.c
> +++ b/common/menu.c
> @@ -12,36 +12,7 @@
>
>  #include "menu.h"
>
> -/*
> - * Internally, each item in a menu is represented by a struct menu_item.
> - *
> - * These items will be alloc'd and initialized by menu_item_add and destroyed
> - * by menu_item_destroy, and the consumer of the interface never sees that
> - * this struct is used at all.
> - */
> -struct menu_item {
> -   char *key;
> -   void *data;
> -   struct list_head list;
> -};
>
> -/*
> - * The menu is composed of a list of items along with settings and callbacks
> - * provided by the user. An incomplete definition of this struct is available
> - * in menu.h, but the full definition is here to prevent consumers from
> - * relying on its contents.
> - */
> -struct menu {
> -   struct menu_item *default_item;
> -   int timeout;
> -   char *title;
> -   int prompt;
> -   void (*item_data_print)(void *);
> -   char *(*item_choice)(void *);
> -   void *item_choice_data;
> -   struct list_head items;
> -   int item_cnt;
> -};
>
>  /*
>   * An iterator function for menu items. callback will be called for each item
> @@ -51,7 +22,7 @@ struct menu {
>   * used for search type operations. It is also safe for callback to remove 
> the
>   * item from the list of items.
>   */
> -static inline void *menu_items_iter(struct menu *m,
> +inline void *menu_items_iter(struct menu *m,
> void *(*callback)(struct menu *, struct menu_item *, void *),
> void *extra)
>  {
> diff --git a/include/menu.h b/include/menu.h
> index 2d227c20bd..b3f8db87e4 100644
> --- a/include/menu.h
> +++ b/include/menu.h
> @@ -6,8 +6,40 @@
>  #ifndef __MENU_H__
>  #define __MENU_H__
>
> -struct menu;
> +/*
> + * Internally, each item in a menu is represented by a struct menu_item.
> + *
> + * These items will be alloc'd and initialized by menu_item_add and destroyed
> + * by menu_item_destroy, and the consumer of the interface never sees that
> + * this struct is used at all.
> + */
> +struct menu_item {
> +   char *key;
> +   void *data;
> +   struct list_head list;
> +};
> +
> +/*
> + * The menu is composed of a list of items along with settings and callbacks
> + * provided by the user. An incomplete definition of this struct is available
> + * in menu.h, but the full definition is here to prevent consumers from
> + * relying on its contents.

This comment doesn't seem to be true anymore.

Is it possible to add a function to get the info you need from the menu?

> + */
> +struct menu {
> +   struct menu_item *default_item;
> +   int timeout;
> +   char *title;
> +   int prompt;
> +   void (*item_data_print)(void *);
> +   char *(*item_choice)(void *);
> +   void *item_choice_data;
> +   struct list_head items;
> +   int item_cnt;
> +};
>
> +void *menu_items_iter(struct menu *m,
> +   void *(*callback)(struct menu *, struct menu_item *, void *),
> +   void *extra);
>  struct menu *menu_create(char *title, int timeout, int prompt,
> void (*item_data_print)(void *),
> char *(*item_choice)(void *),
> --
> 2.17.1

Regards,
Simon


Re: [PATCH PATCH v6 10/13] drivers: board: Add get_fit_loadable()

2019-12-29 Thread Simon Glass
On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot  wrote:
>
> This function will be used by the SPL to get the names of images to load
> from the FIT. This allows to load different images based on runtime HW
> detection.
>
> Signed-off-by: Jean-Jacques Hiblot 
>
> ---
>
> Changes in v6: None
> Changes in v5:
> - board_get_fit_loadable() returns an error code instead of a NULL string
>   in case of failure
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/board/board-uclass.c | 11 +++
>  include/board.h  | 37 
>  2 files changed, 48 insertions(+)

Reviewed-by: Simon Glass 


Re: [U-Boot] [PATCH v4 4/5] dm: core: Don't include ofnode functions with of-platdata

2019-12-29 Thread Simon Glass
Hi Walter,

On Thu, 7 Nov 2019 at 12:47, Walter Lozano  wrote:
>
> Hi Simon,
>
> Thanks for your patch.
>
> On 7/11/19 12:53, Simon Glass wrote:
> > These functions cannot work with of-platdata since libfdt is not
> > available. At present when dev_read_...() functions are used it produces
> > error messages about ofnode which is confusing.
> >
> > Adjust the Makefile and header to produce an error message for the actual
> > dev_read...() function which is called. This makes it easier to see what
> > code needs to be converted for use with of-platdata.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v4: None
> > Changes in v3:
> > - Fix eth_dev_get_mac_address() call dev_read...() only when available
> >
> >   drivers/core/Makefile | 4 +++-
> >   include/dm/read.h | 3 +--
> >   net/eth-uclass.c  | 2 +-
> >   3 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/core/Makefile b/drivers/core/Makefile
> > index bce7467da1..b9e4a2aab1 100644
> > --- a/drivers/core/Makefile
> > +++ b/drivers/core/Makefile
> > @@ -13,6 +13,8 @@ obj-$(CONFIG_OF_LIVE) += of_access.o of_addr.o
> >   ifndef CONFIG_DM_DEV_READ_INLINE
> >   obj-$(CONFIG_OF_CONTROL) += read.o
> >   endif
> > -obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o read_extra.o
> > +ifdef CONFIG_$(SPL_TPL_)OF_LIBFDT
> > +obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += of_extra.o ofnode.o read_extra.o
> > +endif
> >
> >   ccflags-$(CONFIG_DM_DEBUG) += -DDEBUG
> > diff --git a/include/dm/read.h b/include/dm/read.h
> > index d37fcb504d..4f02d07d00 100644
> > --- a/include/dm/read.h
> > +++ b/include/dm/read.h
> > @@ -43,8 +43,7 @@ static inline bool dev_of_valid(struct udevice *dev)
> >   return ofnode_valid(dev_ofnode(dev));
> >   }
> >
> > -#ifndef CONFIG_DM_DEV_READ_INLINE
> > -
> > +#if !defined(CONFIG_DM_DEV_READ_INLINE) || CONFIG_IS_ENABLED(OF_PLATDATA)
> >   /**
> >* dev_read_u32() - read a 32-bit integer from a device's DT property
> >*
>
>
> I don't know if it has much sense, but as I understand it should be
> possible to use DM without OF_CONTROL by adding U_BOOT_DEVICE entries
> manually in a board file. Probably this won't be useful in mainline but
> still could be useful in some contexts. If this is true maybe this
> condition should be changed. In other words why not use
> !CONFIG_IS_ENABLED(CONFIG_OF_LIBFDT) instead of
> CONFIG_IS_ENABLED(OF_PLATDATA)?

Well if a U_BOOT_DEVICE is used (as you say, not in mainline), then
dev_read_...() cannot be used anyway, since there is no device-tree
node.

My goal here is to cause a compile/link error showing the code that
calls dev_read_...(). At present the error shows up in this header
instead, which is not very helpful.

>
>
> > diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> > index 3bd98b01ad..e3bfcdb6cc 100644
> > --- a/net/eth-uclass.c
> > +++ b/net/eth-uclass.c
> > @@ -462,7 +462,7 @@ static int eth_pre_unbind(struct udevice *dev)
> >
> >   static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN])
> >   {
> > -#if IS_ENABLED(CONFIG_OF_CONTROL)
> > +#if CONFIG_IS_ENABLED(OF_CONTROL)
> >   const uint8_t *p;
> >
> >   p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN);
>
>
> Should this kind of #if be changed to
>
> #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)

Here's my thinking:

It is an error to call it with of-platdata, so my cause is to cause an
error (due to the unavailability of dev_read...() functions).

That way people see at build-time that they are doing something wrong.

If we change these to avoid the problem at build time, then it becomes
a runtime problem

Regards,
Simon


Re: [PATCH] spl_fit.c: enable loading compressed u-boot from fit image

2019-12-29 Thread Simon Glass
Hi Rasmus,

On Wed, 11 Dec 2019 at 04:03, Rasmus Villemoes
 wrote:
>
> From: "Klaus H. Sorensen" 
>
> Allow reading compressed content from fit image, even if
> CONFIG_SPL_OS_BOOT is not set.
>
> This allow booting compressed 2nd stage u-boot from fit image.
>
> Additionally, do not print warning message if compression node is not
> found, since it simply implies the content is uncompressed.
>
> Signed-off-by: Klaus H. Sorensen 
> Signed-off-by: Rasmus Villemoes 
> ---
>  common/spl/spl_fit.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index b3e3ccd5a2..98271eb878 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -195,11 +195,9 @@ static int spl_load_fit_image(struct spl_load_info 
> *info, ulong sector,
> debug("%s ", genimg_get_type_name(type));
> }
>
> -   if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
> -   if (fit_image_get_comp(fit, node, _comp))
> -   puts("Cannot get image compression format.\n");

You dropped this error, which seems necessary.

> -   else
> -   debug("%s ", genimg_get_comp_name(image_comp));
> +   if (IS_ENABLED(CONFIG_SPL_GZIP)) {
> +   fit_image_get_comp(fit, node, _comp);
> +   debug("%s ", genimg_get_comp_name(image_comp));
> }
>
> if (fit_image_get_load(fit, node, _addr))
> --
> 2.23.0
>

Regards,
Simon


Re: [PATCH 14/20] serial_lpuart: add clock enable if CONFIG_CLK is defined

2019-12-29 Thread Simon Glass
Hi Giulio,

On Tue, 17 Dec 2019 at 11:37, Giulio Benetti
 wrote:
>
> Hi Lukasz and all,
>
> On 12/10/19 12:48 AM, Lukasz Majewski wrote:
> > On Mon, 9 Dec 2019 16:20:10 +0100
> > Giulio Benetti  wrote:
> >
> >> Hi Lukasz,
> >>
> >> On 12/8/19 3:52 PM, Lukasz Majewski wrote:
> >>> On Wed,  4 Dec 2019 18:44:33 +0100
> >>> Giulio Benetti  wrote:
> >>>
>  This driver assumes that lpuart clock is already enabled before
>  probing but using DM only lpuart won't be automatically enabled so
>  add clk_enable() when probing if CONFIG_CLK is defined.
> 
>  Signed-off-by: Giulio Benetti
>   ---
> drivers/serial/serial_lpuart.c | 13 +
> 1 file changed, 13 insertions(+)
> 
>  diff --git a/drivers/serial/serial_lpuart.c
>  b/drivers/serial/serial_lpuart.c index 4b0a964d1b..52bd2baf7d
>  100644 --- a/drivers/serial/serial_lpuart.c
>  +++ b/drivers/serial/serial_lpuart.c
>  @@ -483,6 +483,19 @@ static int lpuart_serial_pending(struct
>  udevice *dev, bool input)
> static int lpuart_serial_probe(struct udevice *dev)
> {
>  +#if CONFIG_IS_ENABLED(CLK)
>  +  struct clk per_clk;
>  +  int ret;
>  +
>  +  ret = clk_get_by_name(dev, "per", _clk);
>
> While adding support for OF_PLATDATA, I've realized that when using
> OF_PLATDATA I can only use clk_get_by_index_platdata() but often imx
> peripheral drivers(as done in Linux) get clock by name("per" clock)
> instead of other clock sources. So here the problem is that I can't know
> for sure which id "per" clock source will have. I wouldn't use 0 as
> default clock-id since it's not sure "per" will be the 0 index.
> And this will occur for fsl_esdhc_imx.c driver too.
>
> Do you have any suggestions?

I can't think of anything other than defining the values perhaps in a
header, then asserting that they are valid in the non-OF_PLATDATA
code.

I'm not sure how we could enhance of-platdata to support this. Of
course, adding the strings would be bad since we are trying to
minimise overhere.

Regards,
Simon


Re: [PATCH PATCH v6 04/13] spl: fit: allocate a temporary buffer to load the overlays

2019-12-29 Thread Simon Glass
On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot  wrote:
>
> If the node describing an overlay does not specify a load address, it will
> be loaded at the address previously used.
> Fixing it by allocating a temporary buffer that will be used as a
> default load address. By default, the size of the buffer is 64kB which
> should be plenty for most use cases.
>
> Signed-off-by: Jean-Jacques Hiblot 
>
> ---
>
> Changes in v6: None
> Changes in v5:
> - Do not allocate the buffer if not needed (no overlay).
> - Add a Kconfig option for the buffer size
>
> Changes in v4:
> - make sure that the temp buffer is freed in all cases
>
> Changes in v3: None
> Changes in v2: None
>
>  Kconfig  |  9 +
>  common/spl/spl_fit.c | 34 +-
>  2 files changed, 38 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 14/14] test: pinmux: add pincontrol-gpio for pin configuration

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Add a simple pincontrol associated to the sandbox gpio driver,
> that allows to check pin configuration with the command pinmux.
>
> The pmux test is also updated to test behavior with 2 pincontrols.
>
> Example to check LED pin configuration:
>
> => pinmux list
> | Device| Driver| Parent
> | pinctrl-gpio  | sandbox_pinctrl_gpio  | root_driver
> | pinctrl   | sandbox_pinctrl   | root_driver
>
> => pinmux dev pinctrl-gpio
>
> => pinmux status
>
> a0: gpio input .
> a1: gpio input .
> a2: gpio input .
> a3: gpio input .
> a4: gpio input .
> a5: gpio output .
> a6: gpio output .
> ...
>
> Serie-cc: Heiko Schocher 
> Serie-cc: Simon Glass 

Series-cc :-)

>
> Signed-off-by: Patrick Delaunay 
>
> ---
>
> Changes in v2:
> - Adapt sandbox_pinctrl_gpio driver with the saved dir_flags in
>   sandbox gpio driver
> - rebase on v2020.01-rc3
>
>  arch/sandbox/dts/test.dts|  48 +
>  drivers/gpio/sandbox.c   | 195 +++
>  test/py/tests/test_pinmux.py |  10 ++
>  3 files changed, 231 insertions(+), 22 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 13/14] test: dm: update test for pins configuration in gpio

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Add tests for new API set_dir_flags and set_dir_flags and associated
> code in gpio uclass.
>
> Test support for new flags GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE
> GPIO_PULL_UP and GPIO_PULL_DOWN.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - simplify sandbox GPIO driver: save dir_flags (GPIOD_...)
>   and remove internal flags (GPIOF_...); the previous path
>   "gpio: sandbox: cleanup flag support" is no more needed
> - add unitary test in dm_test_gpio for set_dir_flags
> - add some function check in dm_test_gpio_phandles
> - dm_test_gpio_pin_config change to dm_test_gpio_get_dir_flags
>
>  arch/sandbox/dts/test.dts   | 16 ++
>  arch/sandbox/include/asm/gpio.h | 20 
>  drivers/gpio/sandbox.c  | 86 +
>  test/dm/gpio.c  | 66 ++---
>  test/dm/test-fdt.c  |  2 +-
>  5 files changed, 163 insertions(+), 27 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 08/14] gpio: add ops for configuration with dir flags

2019-12-29 Thread Simon Glass
Hi Patrick,

On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> This commit manages the dir flags that can be used in gpio specifiers
> to indicate if a pull-up resistor or pull-down resistor should be
> enabled for output gpio (GPIO_PULL_UP, GPIO_PULL_DOWN) and the
> Open Drain/Open Source configuration for input gpio
> (GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE).
>
> These flags are already supported in Linux kernel in gpiolib;
> this patch provides the same support in U-Boot.
>
> The dir flags are managed in gpio drivers with two optional ops in gpio
> uclass: set_dir_flags and get_dir_flags.
>
> - ops set_dir_flags() set the direction and configuration of each GPIO
>   with a only call to dm_gpio_set_dir_flags() / dm_gpio_set_dir()
>   and respecting the configuration provided by device tree
>   (saved in desc->flags).
>
> - ops get_dir_flags() return dynamically the current gpio configuration,
>   it is used by the new API dm_gpio_get_dir_flags().
>
> When these optional ops are absent, the gpio uclass use the mandatory ops
> (direction_output, direction_input, get_value) and desc->flags to manage
> only the main dir flags:
> - GPIOD_IS_IN
> - GPIOD_IS_OUT
> - GPIOD_IS_OUT_ACTIVE
> - GPIOD_ACTIVE_LOW
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - change the proposed ops for pin config to set_dir_flags/get_dir_flags
> - reused the existing API dm_gpio_set_dir_flags/dm_gpio_set_dir
> - add a new API dm_gpio_get_dir_flags
>
>  drivers/gpio/gpio-uclass.c | 157 +++--
>  include/asm-generic/gpio.h |  65 +--
>  2 files changed, 192 insertions(+), 30 deletions(-)

Reviewed-by: Simon Glass 

>
> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
> index 0870458e96..241293f4b4 100644
> --- a/drivers/gpio/gpio-uclass.c
> +++ b/drivers/gpio/gpio-uclass.c
> @@ -140,8 +140,27 @@ int gpio_xlate_offs_flags(struct udevice *dev, struct 
> gpio_desc *desc,
> if (args->args_count < 2)
> return 0;
>
> +   desc->flags = 0;
> if (args->args[1] & GPIO_ACTIVE_LOW)
> -   desc->flags = GPIOD_ACTIVE_LOW;
> +   desc->flags |= GPIOD_ACTIVE_LOW;
> +
> +   /*
> +* need to test 2 bits for gpio output binding:
> +* OPEN_DRAIN (0x6) = SINGLE_ENDED (0x2) | LINE_OPEN_DRAIN (0x4)
> +* OPEN_SOURCE (0x2) = SINGLE_ENDED (0x2) | LINE_OPEN_SOURCE (0x0)
> +*/
> +   if (args->args[1] & GPIO_SINGLE_ENDED) {
> +   if (args->args[1] & GPIO_LINE_OPEN_DRAIN)
> +   desc->flags |= GPIOD_OPEN_DRAIN;
> +   else
> +   desc->flags |= GPIOD_OPEN_SOURCE;
> +   }
> +
> +   if (args->args[1] & GPIO_PULL_UP)
> +   desc->flags |= GPIOD_PULL_UP;
> +
> +   if (args->args[1] & GPIO_PULL_DOWN)
> +   desc->flags |= GPIOD_PULL_DOWN;
>
> return 0;
>  }
> @@ -476,18 +495,24 @@ int gpio_direction_output(unsigned gpio, int value)
> desc.offset, value);
>  }
>
> -int dm_gpio_get_value(const struct gpio_desc *desc)
> +static int _gpio_get_value(const struct gpio_desc *desc)
>  {
> int value;
> +
> +   value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
> +
> +   return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
> +}
> +
> +int dm_gpio_get_value(const struct gpio_desc *desc)
> +{
> int ret;
>
> ret = check_reserved(desc, "get_value");
> if (ret)
> return ret;
>
> -   value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
> -
> -   return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
> +   return _gpio_get_value(desc);
>  }
>
>  int dm_gpio_set_value(const struct gpio_desc *desc, int value)
> @@ -504,39 +529,119 @@ int dm_gpio_set_value(const struct gpio_desc *desc, 
> int value)
> return 0;
>  }
>
> -int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
> +/* check dir flags invalid configuration */
> +static int check_dir_flags(ulong flags)
> +{
> +   if ((flags & GPIOD_IS_OUT) && (flags & GPIOD_IS_IN))
> +   return -EINVAL;
> +
> +   if ((flags & GPIOD_PULL_UP) && (flags & GPIOD_PULL_DOWN))
> +   return -EINVAL;
> +
> +   if ((flags & GPIOD_OPEN_DRAIN) && (flags & GPIOD_OPEN_SOURCE))
> +   return -EINVAL;

Can we use different error numbers here, so that people can figure out
what is going on?

> +
> +   return 0;
> +}
> +
> +static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
>  {
> struct udevice *dev = desc->dev;
> struct dm_gpio_ops *ops = gpio_get_ops(dev);
> +   struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> int ret;
>
> -   ret = check_reserved(desc, "set_dir");
> -   if (ret)
> -   return ret;
> +   ret = check_dir_flags(flags);
> +   if (ret) {
> +   

Re: [PATCH v1 1/2] Makefile: Fix CONFIG_SYS_UBOOT_START default value

2019-12-29 Thread Simon Glass
On Fri, 6 Dec 2019 at 07:01, Patrice Chotard  wrote:
>
> This patches restores boot on boards which rely on
> CONFIG_SYS_UBOOT_START equal to CONFIG_SYS_TEXT_BASE when using SPL
>
> Fixes: d3e97b53c1f2 ("spl: fix entry_point equal to load_addr")
>
> Signed-off-by: Patrice Chotard 
> ---
>
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 03/14] dm: pinctrl: migrate pinctrl-generic to livetree

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Migrate pinctrl-generic to livetree:
> - dev_for_each_property
> - dev_read_prop_by_prop
> - dev_read_string_count
> - dev_read_string_index
> and get rid of DECLARE_GLOBAL_DATA_PTR.
>
> This patch solves the parsing issue during sandbox tests for pin
> configuration (OF_LIVE is activated in sandbox_defconfig
> and sub node are not correctly parsed in
> pinctrl_generic_set_state_subnode with fdt lib API).
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - Change dev_ functions in pinctrl-generic
>
>  drivers/pinctrl/pinctrl-generic.c | 30 +++---
>  1 file changed, 11 insertions(+), 19 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 07/14] gpio: add gpio descriptor initialization helper

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Add a helper function gpio_desc_init() to initialize the gpio descriptor;
> with this function the flags will be always set to 0.
>
> It wasn't the case before this patch in dm_gpio_lookup_name.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - add gpio descriptor initialization helper
>
>  drivers/gpio/gpio-uclass.c | 27 +++
>  1 file changed, 19 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 02/14] dm: core: add ofnode and dev function to iterate on node property

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Add functions to iterate on all property with livetree
> - dev_read_first_prop
> - dev_read_next_prop
> - dev_read_prop_by_prop
> and
> - ofnode_get_first_property
> - ofnode_get_next_property
> - ofnode_get_property_by_prop
>
> For example:
> struct ofprop property;
>
> dev_for_each_property(property, config) {
> value = dev_read_prop_by_prop(, , );
>
> or:
> for (prop = ofnode_get_first_property(dev_ofnode(dev));
>  prop;
>  prop = ofnode_get_next_property(dev_ofnode(dev),prop))
> {
>  value = ofnode_get_property_by_prop(dev_ofnode(dev), prop,
>  , );
> 
> }
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - Identify property with a new struct ofprop as proposed
>   by Simon Glass
> - Add dev_ iterate functions
>
>  drivers/core/of_access.c | 32 +++
>  drivers/core/ofnode.c| 48 
>  drivers/core/read.c  | 16 ++
>  include/dm/of_access.h   | 40 
>  include/dm/ofnode.h  | 63 -
>  include/dm/read.h| 67 
>  6 files changed, 265 insertions(+), 1 deletion(-)

These look good, but please add a few simple tests like in your commit message.

See test/dm/ofnode.c, or you could add test/dm/read.c and just use the
read interface which would be good enough It think, since tests run
with and without livetree.

Regards,
Simon


Re: [PATCH v2 01/14] dm: pinctrl: convert pinctrl-single to livetree

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> Convert 'pinctrl-single' using livetree functions
> - dev_read_prop
> - dev_read_u32_default
> - dev_read_u32_array
> - dev_read_bool
> - dev_read_addr
> and get rid of DECLARE_GLOBAL_DATA_PTR.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - use the dev_ API instead of ofnode_ function.
>
>  drivers/pinctrl/pinctrl-single.c | 27 +--
>  1 file changed, 9 insertions(+), 18 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v4 0/7] usb: kbd: implement special keys

2019-12-29 Thread Simon Glass
Hi Heinrich,

On Fri, 27 Dec 2019 at 21:54, Heinrich Schuchardt  wrote:
>
> On 12/28/19 3:26 AM, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Fri, 27 Dec 2019 at 11:21, Heinrich Schuchardt  
> > wrote:
> >>
> >> On 12/27/19 5:41 PM, Simon Glass wrote:
> >>> Hi,
> >>>
> >>> On Sat, 23 Nov 2019 at 13:05, Marek Vasut  wrote:
> 
>  On 11/23/19 6:15 PM, Heinrich Schuchardt wrote:
> > GRUB uses function keys. So we should support these with an USB 
> > keyboard.
> > Provide support for F1-F12, Insert, Delete, Home, End, Page Up, Page 
> > Down.
> > Simplify the code beforehand.
> >
> > Enhance the keyboard unit test.
> >
> > In total I could not see any increase of u-boot.img on the TBS2910 but
> > as the special keys are only needed in the context of the UEFI subsystem
> > it makes sense to save several hundred bytes on other boards.
> 
>  Applied all to usb/next, thanks, so let's see what CI has to say.
> >>>
> >>> I notice that pressing F1 at the prompt now shows P and then pressing
> >>> backspace a few times makes a bit of a mess. If U-Boot itself doesn't
> >>> understand these keys, could they be ignored?
> >>
> >> Hello Simon,
> >>
> >> Thanks for reporting your test results. Could you, please, describe your
> >> scenario in detail.
> >>
> >> Was USB_KEYBOARD_FN_KEYS enabled?
> >> Which output device did you use?
> >
> > I ran U-Boot sandbox with -D and then pressed F1, followed by a few
> > backspaces, on the command line. I did not change any options.
>
> The same behavior can be seen with v2019.10.
>
> `./u-boot -D` uses sandbox_serial_getc() and not the USB driver as you
> can verify by putting a breakpoint here and into usb_kbd_put_queue(). So
> your observation seems to be unrelated to the patch series.
>
> If you want to test the USB driver, you have to emulate USB keyboard
> strokes.

OK I see, thanks. I misunderstood the effect of this series I think.

Regards,
Simon


Re: [PATCH v6 6/8] configs: sandbox: Enable random number generator(rng) device

2019-12-29 Thread Simon Glass
Hi,

On Sat, 28 Dec 2019 at 06:21, Heinrich Schuchardt  wrote:
>
> On 12/28/19 12:07 PM, Sughosh Ganu wrote:
> >
> > On Sat, 28 Dec 2019 at 11:55, Heinrich Schuchardt  > > wrote:
> >
> > On 12/27/19 3:23 PM, Sughosh Ganu wrote:
> >  > Enable support for random number generator on sandbox configs.
> > This is
> >  > aimed primarily at adding unit test support for rng uclass.
> >  >
> >  > Signed-off-by: Sughosh Ganu  > >
> >  > Reviewed-by: Patrice Chotard  > >
> >  > Reviewed-by: Patrick Delaunay  > >
> >
> > Why do you exclude:
> >
> > * configs/sandbox_flattree_defconfig,
> > * configs/sandbox_spl_defconfig?
> >
> >
> > This was primarily aimed at adding a unit test for rng on a 32 bit and
> > 64 bit target. Do you think adding support for rng on the two additional
> > targets is adding any value. I don't have a strong opinion on this. If
> > you think that i should enable rng on the two additional targets as
> > well, i will do so.
> >
> > Also, can you also review the patch for adding efi_rng_protocol support
> > on qemu arm64 platform[1]. Once you have, i will make the changes and
> > send  the updated version.
> >
> > -sughosh
>
> I think we should add the RNT device to all configs so that we can test
> in any of the contexts. But is nothing that would stop me from accepting
> the patch series. We can add this later too.

I don't really mind either way. But sandbox_flattree and sandbox_spl
are there to check specific things:

sandbox_flattree - checks operation without live device tree
sandbox_spl - checks a few SPL-related things

They are often excluded when new options are added.

Regards,
Simon


Re: [PATCH v2 06/14] gpio: remove the open_drain API and ops

2019-12-29 Thread Simon Glass
On Tue, 26 Nov 2019 at 01:49, Patrick Delaunay  wrote:
>
> This patch removes the ops get_open_drain/set_open_drain
> and the API dm_gpio_get_open_drain/dm_gpio_set_open_drain.
>
> The ops only provided in one driver (mpc8xxx gpio) and the
> associated API is never called in boards.
>
> This patch prepare a more generic set/get_dir_flags ops,
> including the open drain property.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
> Changes in v2:
> - remove the open_drain API and ops
>
>  arch/sandbox/include/asm/gpio.h | 20 --
>  drivers/gpio/gpio-uclass.c  | 36 -
>  drivers/gpio/mpc8xxx_gpio.c | 22 
>  drivers/gpio/sandbox.c  | 35 
>  include/asm-generic/gpio.h  | 34 ---
>  test/dm/gpio.c  |  7 ---
>  6 files changed, 154 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH PATCH v6 13/13] spl: fit: Allow the board to tell if more images must be loaded from FIT

2019-12-29 Thread Simon Glass
On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot  wrote:
>
> spl_fit_get_image_name() is used to get the names of the images that the
> SPL must load from the FIT. It relies on the content of a property present
> in the FIT. The list of images is thus statically defined in the FIT.
> With this scheme, it quickly becomes hard to manage combinations of more
> than a handful of images.
> To address this problem, give the board driver code the opportunity to
> add to the list of images. The images from the FIT property are loaded
> first, and then the board_get_fit_loadable() is called to get more image
> names.
>
> Signed-off-by: Jean-Jacques Hiblot 
>
> ---
>
> Changes in v6:
> - Instead of matching a overlay by the name of it's node. Try to match it
>   first with the description, and then with the node's name. This allows
>   to use makeimg to add the overlays to u-boot.img and not use a custom
>   SPL_FIT_GENERATOR script
>
> Changes in v5:
> -reword commit log
>
> Changes in v4:
> - Use the board driver infrastructure to get the image names from the
> board code.
> - Remove a patch that passed the board name to the FIT generator. If needed
> the generator can get it from elsewhere
> - Add a fix to not load the firmware twice (once as a firmware and once as
> a loadable)
>
> Changes in v3:
> - removed the RFC prefix. This work will be needed soon by TI's AM65x
> platform. and can probably benefit other modular platforms
> - removed the last patch that provided an example of how to use this with
> on a DRA76.
> - removed the patch that made u-boot.img a symlink to u-boot.itb because
> it breaks the build of many platforms (because files required to build the
> ITB are missing)
> - removed the patch to reduce the footprint of the am335x SPL. (already
> merged)
> - Made the boot flow more permissive (don't fail immediately if an overlay
> is not present) and more verbose when an error occures
> - handle the dependencies of the FIT generation in a more generic way
> - use a dedicated kconfig option to enable the application of the overlays
> by the SPL.
>
> Changes in v2:
> - reworked board_fit_get_additionnal_images() and how it used in spl_fit.c
> - removed dtbo generation from dtso files and use .dts extension for the
>   overlays
> - add dynamic allocation usage in a separate patch
> - defconfig change for the am335x_evm
>
>  common/spl/spl_fit.c | 65 ++--
>  1 file changed, 62 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 

Can you add a test for this to sandbox_spl?


[PATCH v1 1/1] travis-ci: Fix "ResourceWarning: unclosed file"

2019-12-29 Thread Cristian Ciocaltea
This patch gets rid of the warning messages like:

uboot-test-hooks/py/travis-ci/travis_tftp.py:43: ResourceWarning:
unclosed file <_io.BufferedReader name='.bm-work/qemu_arm/u-boot.bin'>

Signed-off-by: Cristian Ciocaltea 
---
 py/travis-ci/travis_tftp.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/py/travis-ci/travis_tftp.py b/py/travis-ci/travis_tftp.py
index 4ea5c06..3e1f11d 100644
--- a/py/travis-ci/travis_tftp.py
+++ b/py/travis-ci/travis_tftp.py
@@ -20,8 +20,11 @@ def file2env(file_name, addr=None):
 ret = {
 "fn": file_name,
 "size": os.path.getsize(file_full),
-"crc32": hex(binascii.crc32(open(file_full, 'rb').read()) & 
0x)[2:],
 }
+
+with open(file_full, 'rb') as fd:
+ret["crc32"] = hex(binascii.crc32(fd.read()) & 0x)[2:]
+
 if addr is not None:
 ret['addr'] = addr
 
-- 
2.17.1



Re: [PATCH v4 5/5] test/py: Create a test for launching UEFI binaries from FIT images

2019-12-29 Thread Cristian Ciocaltea
On Sun, Dec 29, 2019 at 08:11:10PM +0100, Heinrich Schuchardt wrote:
> On 12/29/19 7:39 PM, Cristian Ciocaltea wrote:
> > On Sun, Dec 29, 2019 at 11:22:08AM +0100, Heinrich Schuchardt wrote:
> > > On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:
> > > > This test verifies the implementation of the 'bootm' extension that
> > > > handles UEFI binaries inside FIT images (enabled via CONFIG_BOOTM_EFI).
> > > > 
> > > > Signed-off-by: Cristian Ciocaltea 
> > > 
> > > Thanks a lot for devising this test.
> > > 
> > > ---
> > > 
> > > You are using variable env__efi_fit_tftp_file. To run the test on Gitlab
> > > and Travis CI a patch will be needed for:
> > > 
> > >   https://github.com/swarren/uboot-test-hooks.git
> > > 
> > > I hope
> > > 
> > > https://github.com/xypron/uboot-test-hooks/commit/20dcd721437dd5f7d7d3d235f7112246f43305d2
> > > 
> > > will do the job.
> > > 
> > > Once we have this applied we will have to adjust the config files for 
> > > QEMU.
> > > 
> > > ---
> > > 
> > > I have been trying to run the test on qemu_arm64_defconfig using the
> > > following lines in u_boot_boardenv_qemu_arm64.py:
> > > 
> > > env__efi_fit_tftp_file = {
> > >  "fn": "helloworld.efi",
> > >  "size": 4480,
> > >  "crc32": "19f9c0ab",
> > > }
> > > 
> > > I got an error:
> > > 
> > > test/py/tests/test_efi_fit.py:417: in launch_efi
> > >  addr = load_fit_from_host(fit) if is_sandbox else
> > > load_fit_from_tftp(fit)
> > > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> > >  addr = f.get('addr', None)
> > >  if not addr:
> > > >addr = u_boot_utils.find_ram_base(cons)
> > > E   NameError: name 'u_boot_utils' is not defined
> > > 
> > > 
> > > When I provided addr:
> > > 
> > > env__efi_fit_tftp_file = {
> > >  "fn": "helloworld.efi",
> > >  "size": 4480,
> > >  "crc32": "19f9c0ab",
> > >  "addr": 0x4040,
> > > }
> > > 
> > > I got the following error:
> > > 
> > > => tftpboot 1073741824 helloworld.efi
> > > TFTP error: trying to overwrite reserved memory...
> > > 
> > > I would have expected a command
> > > 
> > >   tftpboot 4040 helloworld.efi
> > > 
> > > to be issued.
> > > 
> > > Same error with bootm:
> > > 
> > > => bootm 1077936128#config-efi-nofdt
> > > "Synchronous Abort" handler, esr 0x9610
> > > elr: 0001c36c lr : 000140f4 (reloc)
> > > 
> > > Please, fix the lines indicated below and verify that you can actually
> > > execute this test on the QEMU platform.
> > 
> > Thank you for the detailed report!
> > 
> > Unfortunately I have only tested on qemu_arm and somehow I missed the
> > check of having the address computed by the test suite. It used to work
> > before I changed the address data type to string - the reason was to
> > allow for more flexibility, e.g. providing values like '$kernel_addr_r'
> > instead of just precomputed numbers.
> > 
> > I'm going to extend the tests on qemu_arm64 as well.
> > 
> > > 
> > > https://github.com/xypron/u-boot-build/tree/qemu-arm64/u-boot-test
> > > 
> > > contains the files I use to run Python tests on qemu_arm64_defconfig.
> > > 
> > > > ---
> > > >test/py/tests/test_efi_fit.py | 459 
> > > > ++
> > > >1 file changed, 459 insertions(+)
> > > >create mode 100644 test/py/tests/test_efi_fit.py
> > > > 
> > > > diff --git a/test/py/tests/test_efi_fit.py 
> > > > b/test/py/tests/test_efi_fit.py
> > > > new file mode 100644
> > > > index 00..e1f0e42694
> > > > --- /dev/null
> > > > +++ b/test/py/tests/test_efi_fit.py
> > > > @@ -0,0 +1,459 @@
> > > > +# SPDX-License-Identifier: GPL-2.0
> > > > +# Copyright (c) 2019, Cristian Ciocaltea 
> > > > +#
> > > > +# Work based on:
> > > > +# - test_net.py
> > > > +# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> > > > +# - test_fit.py
> > > > +# Copyright (c) 2013, Google Inc.
> > > > +#
> > > > +# Test launching UEFI binaries from FIT images.
> > > > +
> > > > +import os.path
> > > > +import pytest
> > > > +import u_boot_utils as util
> > > 
> > > "as util" causes an error if you use u_boot_utils.* below. Below I
> > > indicate the places to change.
> > 
> > Fixed, thanks.
> > 
> > > > +
> > > > +"""
> > > > +Note: This test relies on boardenv_* containing configuration values 
> > > > to define
> > > > +which network environment is available for testing. Without this, the 
> > > > parts
> > > > +that rely on network will be automatically skipped.
> > > > +
> > > > +For example:
> > > > +
> > > > +# Boolean indicating whether the Ethernet device is attached to USB, 
> > > > and hence
> > > > +# USB enumeration needs to be performed prior to network tests.
> > > > +# This variable may be omitted if its value is False.
> > > > +env__net_uses_usb = False
> > > > +
> > > > +# Boolean indicating whether the Ethernet device is attached to PCI, 
> > > > and hence
> > > > +# PCI enumeration needs to be performed prior to network tests.
> > > > +# This 

SUNXI : DE2 : H3 : Add support for setenv video-mode

2019-12-29 Thread Arjan van Vught
Is it on the roadmap adding support for setenv video-mode?

Please advice. 

Many thanks in advance, Arjan 

http://www.orangepi-dmx.org/allwinner-h3



Re: [PATCH v4 5/5] test/py: Create a test for launching UEFI binaries from FIT images

2019-12-29 Thread Heinrich Schuchardt

On 12/29/19 7:39 PM, Cristian Ciocaltea wrote:

On Sun, Dec 29, 2019 at 11:22:08AM +0100, Heinrich Schuchardt wrote:

On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:

This test verifies the implementation of the 'bootm' extension that
handles UEFI binaries inside FIT images (enabled via CONFIG_BOOTM_EFI).

Signed-off-by: Cristian Ciocaltea 


Thanks a lot for devising this test.

---

You are using variable env__efi_fit_tftp_file. To run the test on Gitlab
and Travis CI a patch will be needed for:

https://github.com/swarren/uboot-test-hooks.git

I hope

https://github.com/xypron/uboot-test-hooks/commit/20dcd721437dd5f7d7d3d235f7112246f43305d2

will do the job.

Once we have this applied we will have to adjust the config files for QEMU.

---

I have been trying to run the test on qemu_arm64_defconfig using the
following lines in u_boot_boardenv_qemu_arm64.py:

env__efi_fit_tftp_file = {
 "fn": "helloworld.efi",
 "size": 4480,
 "crc32": "19f9c0ab",
}

I got an error:

test/py/tests/test_efi_fit.py:417: in launch_efi
 addr = load_fit_from_host(fit) if is_sandbox else
load_fit_from_tftp(fit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 addr = f.get('addr', None)
 if not addr:

   addr = u_boot_utils.find_ram_base(cons)

E   NameError: name 'u_boot_utils' is not defined


When I provided addr:

env__efi_fit_tftp_file = {
 "fn": "helloworld.efi",
 "size": 4480,
 "crc32": "19f9c0ab",
 "addr": 0x4040,
}

I got the following error:

=> tftpboot 1073741824 helloworld.efi
TFTP error: trying to overwrite reserved memory...

I would have expected a command

tftpboot 4040 helloworld.efi

to be issued.

Same error with bootm:

=> bootm 1077936128#config-efi-nofdt
"Synchronous Abort" handler, esr 0x9610
elr: 0001c36c lr : 000140f4 (reloc)

Please, fix the lines indicated below and verify that you can actually
execute this test on the QEMU platform.


Thank you for the detailed report!

Unfortunately I have only tested on qemu_arm and somehow I missed the
check of having the address computed by the test suite. It used to work
before I changed the address data type to string - the reason was to
allow for more flexibility, e.g. providing values like '$kernel_addr_r'
instead of just precomputed numbers.

I'm going to extend the tests on qemu_arm64 as well.



https://github.com/xypron/u-boot-build/tree/qemu-arm64/u-boot-test

contains the files I use to run Python tests on qemu_arm64_defconfig.


---
   test/py/tests/test_efi_fit.py | 459 ++
   1 file changed, 459 insertions(+)
   create mode 100644 test/py/tests/test_efi_fit.py

diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py
new file mode 100644
index 00..e1f0e42694
--- /dev/null
+++ b/test/py/tests/test_efi_fit.py
@@ -0,0 +1,459 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019, Cristian Ciocaltea 
+#
+# Work based on:
+# - test_net.py
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+# - test_fit.py
+# Copyright (c) 2013, Google Inc.
+#
+# Test launching UEFI binaries from FIT images.
+
+import os.path
+import pytest
+import u_boot_utils as util


"as util" causes an error if you use u_boot_utils.* below. Below I
indicate the places to change.


Fixed, thanks.


+
+"""
+Note: This test relies on boardenv_* containing configuration values to define
+which network environment is available for testing. Without this, the parts
+that rely on network will be automatically skipped.
+
+For example:
+
+# Boolean indicating whether the Ethernet device is attached to USB, and hence
+# USB enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_usb = False
+
+# Boolean indicating whether the Ethernet device is attached to PCI, and hence
+# PCI enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_pci = True
+
+# True if a DHCP server is attached to the network, and should be tested.
+# If DHCP testing is not possible or desired, this variable may be omitted or
+# set to False.
+env__net_dhcp_server = True
+
+# A list of environment variables that should be set in order to configure a
+# static IP. If solely relying on DHCP, this variable may be omitted or set to
+# an empty list.
+env__net_static_env_vars = [
+('ipaddr', '10.0.0.100'),
+('netmask', '255.255.255.0'),
+('serverip', '10.0.0.1'),
+]
+
+# Details regarding a file that may be read from a TFTP server. This variable
+# may be omitted or set to None if TFTP testing is not possible or desired.
+# Additionally, when the 'size' is not available, the file will be generated
+# automatically in the TFTP root directory, as specified by the 'dn' field.
+env__efi_fit_tftp_file = {
+'fn': 'test-efi-fit.img',   # File path relative to TFTP root
+'size': 

[PATCH 1/1] configs: qemu: enable FIT images on qemu_arm(64)_defconfig

2019-12-29 Thread Heinrich Schuchardt
For testing UEFI FIT images we need FIT image support on QEMU.

Cf. "test/py: Create a test for launching UEFI binaries from FIT images"
https://lists.denx.de/pipermail/u-boot/2019-December/394516.html

Signed-off-by: Heinrich Schuchardt 
---
 configs/qemu_arm64_defconfig | 5 +
 configs/qemu_arm_defconfig   | 5 +
 2 files changed, 10 insertions(+)

diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
index b7c320743a..50d0aa5bf5 100644
--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -6,6 +6,11 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SECT_SIZE=0x4
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_BEST_MATCH=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="pci enum"
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
index 521c6793a3..ff97d6bd83 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -7,6 +7,11 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SECT_SIZE=0x4
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_BEST_MATCH=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="pci enum"
 # CONFIG_DISPLAY_CPUINFO is not set
--
2.24.1



[PATCH v3 5/5] rockchip: rk3399: Add bootcount support

2019-12-29 Thread Jagan Teki
Add bootcount support for Rockchip rk3399.

The bootcount value is preserved in PMU_SYS_REG0 register,
this would help to support redundent boot.

Once the redundant boot triggers, the altboot command
will look for extlinux-rollback.conf on particular
bootable partition which supposed to be a recovery
partition where redundant boot required.

Signed-off-by: Jagan Teki 
---
 arch/arm/mach-rockchip/Kconfig|  2 ++
 arch/arm/mach-rockchip/rk3399/Kconfig | 10 ++
 include/configs/rk3399_common.h   |  5 -
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index d8d68ba447..9a3c65ec58 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -244,6 +244,8 @@ config ROCKCHIP_RK3399
imply TPL_CLK
imply TPL_TINY_MEMSET
imply TPL_ROCKCHIP_COMMON_BOARD
+   imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT
+   imply CMD_BOOTCOUNT if BOOTCOUNT_LIMIT
help
  The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
  and quad-core Cortex-A53.
diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig 
b/arch/arm/mach-rockchip/rk3399/Kconfig
index 868e85fc2a..f994152803 100644
--- a/arch/arm/mach-rockchip/rk3399/Kconfig
+++ b/arch/arm/mach-rockchip/rk3399/Kconfig
@@ -113,6 +113,16 @@ config TPL_TEXT_BASE
 config SPL_STACK_R_ADDR
default 0x0400
 
+if BOOTCOUNT_LIMIT
+
+config BOOTCOUNT_BOOTLIMIT
+   default 3
+
+config SYS_BOOTCOUNT_ADDR
+   default 0xff3100f0  # PMU_SYS_REG0
+
+endif # BOOTCOUNT_LIMIT
+
 source "board/rockchip/evb_rk3399/Kconfig"
 source "board/theobroma-systems/puma_rk3399/Kconfig"
 source "board/vamrs/rock960_rk3399/Kconfig"
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 127ca1f09c..89a8a44bbe 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -63,7 +63,10 @@
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   BOOTENV \
+   "altbootcmd=" \
+   "setenv boot_syslinux_conf extlinux/extlinux-rollback.conf;" \
+   "run distro_bootcmd\0"
 
 #endif
 
-- 
2.18.0.321.gffc6fa0e3



[PATCH v3 3/5] arm: rockchip: Add common cru.h

2019-12-29 Thread Jagan Teki
Few of the rockchip family SoC atleast rk3288,
rk3399 are sharing some cru register bits so
adding common code between these SoC families
would require to include both cru include files
that indeed resulting function declarations error.

So, create a common cru include as cru.h then
include the rk3399 arch cru include file and move
the common cru register bit definitions into it.

The rest of rockchip cru files will add it in future.

Signed-off-by: Jagan Teki 
---
 arch/arm/include/asm/arch-rockchip/clock.h|  4 +-
 arch/arm/include/asm/arch-rockchip/cru.h  | 16 +++
 .../include/asm/arch-rockchip/cru_rk3288.h|  6 +--
 .../include/asm/arch-rockchip/cru_rk3399.h| 10 ++---
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c|  2 +-
 arch/arm/mach-rockchip/rk3288/rk3288.c|  4 +-
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c|  2 +-
 arch/arm/mach-rockchip/rk3399/rk3399.c|  2 +-
 drivers/clk/rockchip/clk_rk3288.c | 42 +--
 drivers/clk/rockchip/clk_rk3399.c | 36 
 drivers/ram/rockchip/sdram_rk3288.c   | 10 ++---
 drivers/ram/rockchip/sdram_rk3399.c   | 10 ++---
 drivers/video/rockchip/rk3288_mipi.c  |  2 +-
 drivers/video/rockchip/rk3399_mipi.c  |  2 +-
 drivers/video/rockchip/rk_mipi.c  |  2 +-
 15 files changed, 83 insertions(+), 67 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru.h

diff --git a/arch/arm/include/asm/arch-rockchip/clock.h 
b/arch/arm/include/asm/arch-rockchip/clock.h
index 8f7fc86a9e..22de0aef8d 100644
--- a/arch/arm/include/asm/arch-rockchip/clock.h
+++ b/arch/arm/include/asm/arch-rockchip/clock.h
@@ -153,10 +153,10 @@ void *rockchip_get_cru(void);
  */
 void *rockchip_get_pmucru(void);
 
-struct rk3288_cru;
+struct rockchip_cru;
 struct rk3288_grf;
 
-void rk3288_clk_configure_cpu(struct rk3288_cru *cru, struct rk3288_grf *grf);
+void rk3288_clk_configure_cpu(struct rockchip_cru *cru, struct rk3288_grf 
*grf);
 
 int rockchip_get_clk(struct udevice **devp);
 
diff --git a/arch/arm/include/asm/arch-rockchip/cru.h 
b/arch/arm/include/asm/arch-rockchip/cru.h
new file mode 100644
index 00..5ed3fbfd07
--- /dev/null
+++ b/arch/arm/include/asm/arch-rockchip/cru.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * (C) Copyright 2019 Amarula Solutions.
+ * Author: Jagan Teki 
+ */
+
+#ifndef _ROCKCHIP_CLOCK_H
+#define _ROCKCHIP_CLOCK_H
+
+#if defined(CONFIG_ROCKCHIP_RK3288)
+# include 
+#elif defined(CONFIG_ROCKCHIP_RK3399)
+# include 
+#endif
+
+#endif /* _ROCKCHIP_CLOCK_H */
diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
index e891f20b37..7aa6efe46c 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
@@ -27,11 +27,11 @@
 /* Private data for the clock driver - used by rockchip_get_cru() */
 struct rk3288_clk_priv {
struct rk3288_grf *grf;
-   struct rk3288_cru *cru;
+   struct rockchip_cru *cru;
ulong rate;
 };
 
-struct rk3288_cru {
+struct rockchip_cru {
struct rk3288_pll {
u32 con0;
u32 con1;
@@ -58,7 +58,7 @@ struct rk3288_cru {
u32 cru_sdio1_con[2];
u32 cru_emmc_con[2];
 };
-check_member(rk3288_cru, cru_emmc_con[1], 0x021c);
+check_member(rockchip_cru, cru_emmc_con[1], 0x021c);
 
 /* CRU_CLKSEL11_CON */
 enum {
diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
index 15eeb9c440..33ce190434 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3399.h
@@ -10,7 +10,7 @@
 
 /* Private data for the clock driver - used by rockchip_get_cru() */
 struct rk3399_clk_priv {
-   struct rk3399_cru *cru;
+   struct rockchip_cru *cru;
 };
 
 struct rk3399_pmuclk_priv {
@@ -33,7 +33,7 @@ struct rk3399_pmucru {
 };
 check_member(rk3399_pmucru, pmucru_gatedis_con[1], 0x134);
 
-struct rk3399_cru {
+struct rockchip_cru {
u32 apll_l_con[6];
u32 reserved[2];
u32 apll_b_con[6];
@@ -65,7 +65,7 @@ struct rk3399_cru {
u32 sdio0_con[2];
u32 sdio1_con[2];
 };
-check_member(rk3399_cru, sdio1_con[1], 0x594);
+check_member(rockchip_cru, sdio1_con[1], 0x594);
 #define MHz100
 #define KHz1000
 #define OSC_HZ (24*MHz)
@@ -107,9 +107,9 @@ enum apll_b_frequencies {
APLL_B_600_MHZ,
 };
 
-void rk3399_configure_cpu_l(struct rk3399_cru *cru,
+void rk3399_configure_cpu_l(struct rockchip_cru *cru,
enum apll_l_frequencies apll_l_freq);
-void rk3399_configure_cpu_b(struct rk3399_cru *cru,
+void rk3399_configure_cpu_b(struct rockchip_cru *cru,
enum apll_b_frequencies apll_b_freq);
 
 #endif /* __ASM_ARCH_CRU_RK3399_H_ */
diff --git a/arch/arm/mach-rockchip/rk3288/clk_rk3288.c 

[PATCH v3 4/5] rockchip: Add common reset cause

2019-12-29 Thread Jagan Teki
Add cpu reset cause in common cpu-info file.

This would help to print the reset cause for
various resets.

Right now it support rk3288, rk3399. rest of rockchip
platforms doesn't have reset cause support ye but this
code is more feasible to extend the same.

Signed-off-by: Jagan Teki 
---
 arch/arm/include/asm/arch-rockchip/cru.h  | 12 +
 .../include/asm/arch-rockchip/cru_rk3288.h| 14 +-
 arch/arm/mach-rockchip/cpu-info.c | 49 +++
 arch/arm/mach-rockchip/rk3288/rk3288.c| 39 ---
 4 files changed, 62 insertions(+), 52 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/cru.h 
b/arch/arm/include/asm/arch-rockchip/cru.h
index 5ed3fbfd07..e1dd9a89c2 100644
--- a/arch/arm/include/asm/arch-rockchip/cru.h
+++ b/arch/arm/include/asm/arch-rockchip/cru.h
@@ -13,4 +13,16 @@
 # include 
 #endif
 
+/* CRU_GLB_RST_ST */
+enum {
+   GLB_POR_RST,
+   FST_GLB_RST_ST  = BIT(0),
+   SND_GLB_RST_ST  = BIT(1),
+   FST_GLB_TSADC_RST_ST= BIT(2),
+   SND_GLB_TSADC_RST_ST= BIT(3),
+   FST_GLB_WDT_RST_ST  = BIT(4),
+   SND_GLB_WDT_RST_ST  = BIT(5),
+   GLB_RST_ST_MASK = GENMASK(5, 0),
+};
+
 #endif /* _ROCKCHIP_CLOCK_H */
diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h 
b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
index 7aa6efe46c..412b73e55f 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
@@ -51,7 +51,7 @@ struct rockchip_cru {
u32 cru_glb_cnt_th;
u32 cru_glb_rst_con;
u32 reserved3;
-   u32 cru_glb_rst_st;
+   u32 glb_rst_st;
u32 reserved4;
u32 cru_sdmmc_con[2];
u32 cru_sdio0_con[2];
@@ -227,16 +227,4 @@ enum {
CLKF_MASK   = 0x1fff << CLKF_SHIFT,
 };
 
-/* CRU_GLB_RST_ST */
-enum {
-   GLB_POR_RST,
-   FST_GLB_RST_ST  = BIT(0),
-   SND_GLB_RST_ST  = BIT(1),
-   FST_GLB_TSADC_RST_ST= BIT(2),
-   SND_GLB_TSADC_RST_ST= BIT(3),
-   FST_GLB_WDT_RST_ST  = BIT(4),
-   SND_GLB_WDT_RST_ST  = BIT(5),
-   GLB_RST_ST_MASK = GENMASK(5, 0),
-};
-
 #endif
diff --git a/arch/arm/mach-rockchip/cpu-info.c 
b/arch/arm/mach-rockchip/cpu-info.c
index 9bccbd4f68..4b0e99299a 100644
--- a/arch/arm/mach-rockchip/cpu-info.c
+++ b/arch/arm/mach-rockchip/cpu-info.c
@@ -5,10 +5,59 @@
  */
 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static char *get_reset_cause(void)
+{
+   struct rockchip_cru *cru = rockchip_get_cru();
+   char *cause = NULL;
+
+   if (IS_ERR(cru))
+   return cause;
+
+   switch (cru->glb_rst_st) {
+   case GLB_POR_RST:
+   cause = "POR";
+   break;
+   case FST_GLB_RST_ST:
+   case SND_GLB_RST_ST:
+   cause = "RST";
+   break;
+   case FST_GLB_TSADC_RST_ST:
+   case SND_GLB_TSADC_RST_ST:
+   cause = "THERMAL";
+   break;
+   case FST_GLB_WDT_RST_ST:
+   case SND_GLB_WDT_RST_ST:
+   cause = "WDOG";
+   break;
+   default:
+   cause = "unknown reset";
+   }
+
+   /**
+* reset_reason env is used by rk3288, due to special use case
+* to figure it the boot behavior. so keep this as it is.
+*/
+   env_set("reset_reason", cause);
+
+   /*
+* Clear glb_rst_st, so we can determine the last reset cause
+* for following resets.
+*/
+   rk_clrreg(>glb_rst_st, GLB_RST_ST_MASK);
+
+   return cause;
+}
 
 int print_cpuinfo(void)
 {
printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
+   printf("Reset cause: %s\n", get_reset_cause());
 
/* TODO print operating temparature and clock */
 
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 47ee5d440b..18ea7f35fb 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -102,43 +102,6 @@ void board_debug_uart_init(void)
 }
 #endif
 
-static void rk3288_detect_reset_reason(void)
-{
-   struct rockchip_cru *cru = rockchip_get_cru();
-   const char *reason;
-
-   if (IS_ERR(cru))
-   return;
-
-   switch (cru->cru_glb_rst_st) {
-   case GLB_POR_RST:
-   reason = "POR";
-   break;
-   case FST_GLB_RST_ST:
-   case SND_GLB_RST_ST:
-   reason = "RST";
-   break;
-   case FST_GLB_TSADC_RST_ST:
-   case SND_GLB_TSADC_RST_ST:
-   reason = "THERMAL";
-   break;
-   case FST_GLB_WDT_RST_ST:
-   case SND_GLB_WDT_RST_ST:
-   reason = "WDOG";
-   break;
-   default:
-   reason = "unknown reset";
-   }
-
-   env_set("reset_reason", reason);
-
-   /*
-* Clear cru_glb_rst_st, so we can determine the last 

[PATCH v3 2/5] rockchip: rk3399: Enable DISPLAY_CPUINFO

2019-12-29 Thread Jagan Teki
RK3288, RK3399 are now support cpu-info, so enable
DISPLAY_CPUINFO by default.

Signed-off-by: Jagan Teki 
---
 configs/evb-rk3288_defconfig | 1 -
 configs/evb-rk3399_defconfig | 1 -
 configs/ficus-rk3399_defconfig   | 1 -
 configs/firefly-rk3288_defconfig | 1 -
 configs/firefly-rk3399_defconfig | 1 -
 configs/khadas-edge-captain-rk3399_defconfig | 1 -
 configs/khadas-edge-rk3399_defconfig | 1 -
 configs/khadas-edge-v-rk3399_defconfig   | 1 -
 configs/leez-rk3399_defconfig| 1 -
 configs/miqi-rk3288_defconfig| 1 -
 configs/nanopc-t4-rk3399_defconfig   | 1 -
 configs/nanopi-m4-rk3399_defconfig   | 1 -
 configs/nanopi-neo4-rk3399_defconfig | 1 -
 configs/orangepi-rk3399_defconfig| 1 -
 configs/phycore-rk3288_defconfig | 1 -
 configs/popmetal-rk3288_defconfig| 1 -
 configs/puma-rk3399_defconfig| 1 -
 configs/roc-pc-rk3399_defconfig  | 1 -
 configs/rock-pi-4-rk3399_defconfig   | 1 -
 configs/rock960-rk3399_defconfig | 1 -
 configs/rockpro64-rk3399_defconfig   | 1 -
 configs/tinker-rk3288_defconfig  | 1 -
 configs/tinker-s-rk3288_defconfig| 1 -
 configs/vyasa-rk3288_defconfig   | 1 -
 24 files changed, 24 deletions(-)

diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig
index 1fa4054f5d..59c909e10d 100644
--- a/configs/evb-rk3288_defconfig
+++ b/configs/evb-rk3288_defconfig
@@ -14,7 +14,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_USE_PREBOOT=y
 CONFIG_SILENT_CONSOLE=y
 CONFIG_DEFAULT_FDT_FILE="rk3288-evb-rk808.dtb"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
diff --git a/configs/evb-rk3399_defconfig b/configs/evb-rk3399_defconfig
index 8b8cdc5109..896a6050eb 100644
--- a/configs/evb-rk3399_defconfig
+++ b/configs/evb-rk3399_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART_BASE=0xFF1A
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_DEBUG_UART=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-evb.dtb"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
diff --git a/configs/ficus-rk3399_defconfig b/configs/ficus-rk3399_defconfig
index 6bb030acc1..5b49fe0b7b 100644
--- a/configs/ficus-rk3399_defconfig
+++ b/configs/ficus-rk3399_defconfig
@@ -9,7 +9,6 @@ CONFIG_DEBUG_UART_BASE=0xFF1A
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_DEBUG_UART=y
 CONFIG_SPL_TEXT_BASE=0xff8c2000
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig
index 0c0a51c54f..41a6fc3edd 100644
--- a/configs/firefly-rk3288_defconfig
+++ b/configs/firefly-rk3288_defconfig
@@ -14,7 +14,6 @@ CONFIG_DEBUG_UART=y
 CONFIG_USE_PREBOOT=y
 CONFIG_SILENT_CONSOLE=y
 CONFIG_DEFAULT_FDT_FILE="rk3288-firefly.dtb"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
diff --git a/configs/firefly-rk3399_defconfig b/configs/firefly-rk3399_defconfig
index b84d7b9ff0..5d197f5f8a 100644
--- a/configs/firefly-rk3399_defconfig
+++ b/configs/firefly-rk3399_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART_BASE=0xFF1A
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_DEBUG_UART=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-firefly.dtb"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
diff --git a/configs/khadas-edge-captain-rk3399_defconfig 
b/configs/khadas-edge-captain-rk3399_defconfig
index c408a1a59b..379e21e28d 100644
--- a/configs/khadas-edge-captain-rk3399_defconfig
+++ b/configs/khadas-edge-captain-rk3399_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART_BASE=0xFF1A
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_DEBUG_UART=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-khadas-edge-captain.dtbi"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
diff --git a/configs/khadas-edge-rk3399_defconfig 
b/configs/khadas-edge-rk3399_defconfig
index 796f94f8d7..9086018cd0 100644
--- a/configs/khadas-edge-rk3399_defconfig
+++ b/configs/khadas-edge-rk3399_defconfig
@@ -8,7 +8,6 @@ CONFIG_DEBUG_UART_BASE=0xFF1A
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_DEBUG_UART=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-khadas-edge.dtb"
-# CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
diff --git a/configs/khadas-edge-v-rk3399_defconfig 
b/configs/khadas-edge-v-rk3399_defconfig
index e70e1ec2e6..261d75526b 100644
--- a/configs/khadas-edge-v-rk3399_defconfig
+++ 

[PATCH v3 1/5] rockchip: Add cpu-info

2019-12-29 Thread Jagan Teki
Add cpu information for rockchip soc.

This would help to print the SoC family number, with
associated temparature, clock and reason for reset etc.

Signed-off-by: Jagan Teki 
Reviewed-by: Kever Yang 
---
 arch/arm/mach-rockchip/Makefile   |  1 +
 arch/arm/mach-rockchip/cpu-info.c | 16 
 2 files changed, 17 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/cpu-info.c

diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index a728acda24..5b38526fe0 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -22,6 +22,7 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 # we can have the preprocessor correctly recognise both 0x0 and 0
 # meaning "turn it off".
 obj-y += boot_mode.o
+obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o
 obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
 obj-$(CONFIG_MISC_INIT_R) += misc.o
 endif
diff --git a/arch/arm/mach-rockchip/cpu-info.c 
b/arch/arm/mach-rockchip/cpu-info.c
new file mode 100644
index 00..9bccbd4f68
--- /dev/null
+++ b/arch/arm/mach-rockchip/cpu-info.c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * (C) Copyright 2019 Amarula Solutions(India)
+ * Author: Jagan Teki 
+ */
+
+#include 
+
+int print_cpuinfo(void)
+{
+   printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
+
+   /* TODO print operating temparature and clock */
+
+   return 0;
+}
-- 
2.18.0.321.gffc6fa0e3



[PATCH v3 0/5] rk3399: Add redundant boot support

2019-12-29 Thread Jagan Teki
Boot redundancy is one of the key criteria for switch
recovery or golden partition based on the bootcount 
value, which indeed very much needed in production 
systems on the fields.

This is v3 patchset support redundant boot on Rockchip 
rk3399.

This series skip wdt changes as Marek patches support 
the same.

Changes for v3:
- rework of cru.h to include rk3288
- rebase on master
Changes for v2:
- Handle TPL build for watchdog, if TPL won't enable
- Fix comments for dw_wdt driver-model comments from Andy
- Add Kconfig items for WDT_TPL
- Support WDT on TPL as well
- Use SYS_SOC for cpu-info

Any inputs?
Jagan.

Jagan Teki (5):
  rockchip: Add cpu-info
  rockchip: rk3399: Enable DISPLAY_CPUINFO
  arm: rockchip: Add common cru.h
  rockchip: Add common reset cause
  rockchip: rk3399: Add bootcount support

 arch/arm/include/asm/arch-rockchip/clock.h|  4 +-
 arch/arm/include/asm/arch-rockchip/cru.h  | 28 
 .../include/asm/arch-rockchip/cru_rk3288.h| 20 ++
 .../include/asm/arch-rockchip/cru_rk3399.h| 10 +--
 arch/arm/mach-rockchip/Kconfig|  2 +
 arch/arm/mach-rockchip/Makefile   |  1 +
 arch/arm/mach-rockchip/cpu-info.c | 65 +++
 arch/arm/mach-rockchip/rk3288/clk_rk3288.c|  2 +-
 arch/arm/mach-rockchip/rk3288/rk3288.c| 41 +---
 arch/arm/mach-rockchip/rk3399/Kconfig | 10 +++
 arch/arm/mach-rockchip/rk3399/clk_rk3399.c|  2 +-
 arch/arm/mach-rockchip/rk3399/rk3399.c|  2 +-
 configs/evb-rk3288_defconfig  |  1 -
 configs/evb-rk3399_defconfig  |  1 -
 configs/ficus-rk3399_defconfig|  1 -
 configs/firefly-rk3288_defconfig  |  1 -
 configs/firefly-rk3399_defconfig  |  1 -
 configs/khadas-edge-captain-rk3399_defconfig  |  1 -
 configs/khadas-edge-rk3399_defconfig  |  1 -
 configs/khadas-edge-v-rk3399_defconfig|  1 -
 configs/leez-rk3399_defconfig |  1 -
 configs/miqi-rk3288_defconfig |  1 -
 configs/nanopc-t4-rk3399_defconfig|  1 -
 configs/nanopi-m4-rk3399_defconfig|  1 -
 configs/nanopi-neo4-rk3399_defconfig  |  1 -
 configs/orangepi-rk3399_defconfig |  1 -
 configs/phycore-rk3288_defconfig  |  1 -
 configs/popmetal-rk3288_defconfig |  1 -
 configs/puma-rk3399_defconfig |  1 -
 configs/roc-pc-rk3399_defconfig   |  1 -
 configs/rock-pi-4-rk3399_defconfig|  1 -
 configs/rock960-rk3399_defconfig  |  1 -
 configs/rockpro64-rk3399_defconfig|  1 -
 configs/tinker-rk3288_defconfig   |  1 -
 configs/tinker-s-rk3288_defconfig |  1 -
 configs/vyasa-rk3288_defconfig|  1 -
 drivers/clk/rockchip/clk_rk3288.c | 42 ++--
 drivers/clk/rockchip/clk_rk3399.c | 36 +-
 drivers/ram/rockchip/sdram_rk3288.c   | 10 +--
 drivers/ram/rockchip/sdram_rk3399.c   | 10 +--
 drivers/video/rockchip/rk3288_mipi.c  |  2 +-
 drivers/video/rockchip/rk3399_mipi.c  |  2 +-
 drivers/video/rockchip/rk_mipi.c  |  2 +-
 include/configs/rk3399_common.h   |  5 +-
 44 files changed, 177 insertions(+), 143 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-rockchip/cru.h
 create mode 100644 arch/arm/mach-rockchip/cpu-info.c

-- 
2.18.0.321.gffc6fa0e3



Re: [PATCH v4 5/5] test/py: Create a test for launching UEFI binaries from FIT images

2019-12-29 Thread Cristian Ciocaltea
On Sun, Dec 29, 2019 at 11:22:08AM +0100, Heinrich Schuchardt wrote:
> On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:
> > This test verifies the implementation of the 'bootm' extension that
> > handles UEFI binaries inside FIT images (enabled via CONFIG_BOOTM_EFI).
> > 
> > Signed-off-by: Cristian Ciocaltea 
> 
> Thanks a lot for devising this test.
> 
> ---
> 
> You are using variable env__efi_fit_tftp_file. To run the test on Gitlab
> and Travis CI a patch will be needed for:
> 
>   https://github.com/swarren/uboot-test-hooks.git
> 
> I hope
> 
> https://github.com/xypron/uboot-test-hooks/commit/20dcd721437dd5f7d7d3d235f7112246f43305d2
> 
> will do the job.
> 
> Once we have this applied we will have to adjust the config files for QEMU.
> 
> ---
> 
> I have been trying to run the test on qemu_arm64_defconfig using the
> following lines in u_boot_boardenv_qemu_arm64.py:
> 
> env__efi_fit_tftp_file = {
> "fn": "helloworld.efi",
> "size": 4480,
> "crc32": "19f9c0ab",
> }
> 
> I got an error:
> 
> test/py/tests/test_efi_fit.py:417: in launch_efi
> addr = load_fit_from_host(fit) if is_sandbox else
> load_fit_from_tftp(fit)
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> addr = f.get('addr', None)
> if not addr:
> >   addr = u_boot_utils.find_ram_base(cons)
> E   NameError: name 'u_boot_utils' is not defined
> 
> 
> When I provided addr:
> 
> env__efi_fit_tftp_file = {
> "fn": "helloworld.efi",
> "size": 4480,
> "crc32": "19f9c0ab",
> "addr": 0x4040,
> }
> 
> I got the following error:
> 
> => tftpboot 1073741824 helloworld.efi
> TFTP error: trying to overwrite reserved memory...
> 
> I would have expected a command
> 
>   tftpboot 4040 helloworld.efi
> 
> to be issued.
> 
> Same error with bootm:
> 
> => bootm 1077936128#config-efi-nofdt
> "Synchronous Abort" handler, esr 0x9610
> elr: 0001c36c lr : 000140f4 (reloc)
> 
> Please, fix the lines indicated below and verify that you can actually
> execute this test on the QEMU platform.

Thank you for the detailed report!

Unfortunately I have only tested on qemu_arm and somehow I missed the
check of having the address computed by the test suite. It used to work
before I changed the address data type to string - the reason was to
allow for more flexibility, e.g. providing values like '$kernel_addr_r'
instead of just precomputed numbers.

I'm going to extend the tests on qemu_arm64 as well.

> 
> https://github.com/xypron/u-boot-build/tree/qemu-arm64/u-boot-test
> 
> contains the files I use to run Python tests on qemu_arm64_defconfig.
> 
> > ---
> >   test/py/tests/test_efi_fit.py | 459 ++
> >   1 file changed, 459 insertions(+)
> >   create mode 100644 test/py/tests/test_efi_fit.py
> > 
> > diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py
> > new file mode 100644
> > index 00..e1f0e42694
> > --- /dev/null
> > +++ b/test/py/tests/test_efi_fit.py
> > @@ -0,0 +1,459 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2019, Cristian Ciocaltea 
> > +#
> > +# Work based on:
> > +# - test_net.py
> > +# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> > +# - test_fit.py
> > +# Copyright (c) 2013, Google Inc.
> > +#
> > +# Test launching UEFI binaries from FIT images.
> > +
> > +import os.path
> > +import pytest
> > +import u_boot_utils as util
> 
> "as util" causes an error if you use u_boot_utils.* below. Below I
> indicate the places to change.

Fixed, thanks.

> > +
> > +"""
> > +Note: This test relies on boardenv_* containing configuration values to 
> > define
> > +which network environment is available for testing. Without this, the parts
> > +that rely on network will be automatically skipped.
> > +
> > +For example:
> > +
> > +# Boolean indicating whether the Ethernet device is attached to USB, and 
> > hence
> > +# USB enumeration needs to be performed prior to network tests.
> > +# This variable may be omitted if its value is False.
> > +env__net_uses_usb = False
> > +
> > +# Boolean indicating whether the Ethernet device is attached to PCI, and 
> > hence
> > +# PCI enumeration needs to be performed prior to network tests.
> > +# This variable may be omitted if its value is False.
> > +env__net_uses_pci = True
> > +
> > +# True if a DHCP server is attached to the network, and should be tested.
> > +# If DHCP testing is not possible or desired, this variable may be omitted 
> > or
> > +# set to False.
> > +env__net_dhcp_server = True
> > +
> > +# A list of environment variables that should be set in order to configure 
> > a
> > +# static IP. If solely relying on DHCP, this variable may be omitted or 
> > set to
> > +# an empty list.
> > +env__net_static_env_vars = [
> > +('ipaddr', '10.0.0.100'),
> > +('netmask', '255.255.255.0'),
> > +('serverip', '10.0.0.1'),
> > +]
> > +
> > +# Details regarding a file that may be read from a TFTP 

[PATCH 1/1] travis-ci: provide env__efi_fit_tftp_file

2019-12-29 Thread Heinrich Schuchardt
Provide dictionary env__efi_fit_tftp_file describing the file used for the
UEFI FIT image test.

Cf. "test/py: Create a test for launching UEFI binaries from FIT images"
https://lists.denx.de/pipermail/u-boot/2019-December/394516.html

Signed-off-by: Heinrich Schuchardt 
---
 py/travis-ci/travis_tftp.py   | 20 +++
 py/travis-ci/u_boot_boardenv_qemu_arm64_na.py |  1 +
 py/travis-ci/u_boot_boardenv_qemu_arm_na.py   |  1 +
 .../u_boot_boardenv_qemu_x86_64_na.py |  2 ++
 py/travis-ci/u_boot_boardenv_qemu_x86_na.py   |  2 ++
 .../u_boot_boardenv_vexpress_ca15_tc2_qemu.py |  1 +
 .../u_boot_boardenv_vexpress_ca9x4_qemu.py|  1 +
 7 files changed, 28 insertions(+)

diff --git a/py/travis-ci/travis_tftp.py b/py/travis-ci/travis_tftp.py
index 4ea5c06..2ab7740 100644
--- a/py/travis-ci/travis_tftp.py
+++ b/py/travis-ci/travis_tftp.py
@@ -1,6 +1,26 @@
 import os
 import binascii

+def efifit2env(addr=None):
+"""Create dictionary describing file for UEFI FIT image test
+
+@addr:  address used for loading the file as int (e.g. 0x4040)
+Return: dictionary describing the file with entries
+* fn- filename
+* addr  - loading address, optional
+* dn- tftp directory
+"""
+tftp_dir = os.environ['UBOOT_TRAVIS_BUILD_DIR'] + "/"
+
+ret = {
+"fn": "test-efi-fit.img",
+"dn": "tftp_dir",
+}
+if addr is not None:
+ret['addr'] = addr
+
+return ret
+
 def file2env(file_name, addr=None):
 """Create dictionary describing file

diff --git a/py/travis-ci/u_boot_boardenv_qemu_arm64_na.py 
b/py/travis-ci/u_boot_boardenv_qemu_arm64_na.py
index 2986115..98ce873 100644
--- a/py/travis-ci/u_boot_boardenv_qemu_arm64_na.py
+++ b/py/travis-ci/u_boot_boardenv_qemu_arm64_na.py
@@ -6,3 +6,4 @@ env__net_dhcp_server = True
 env__net_tftp_readable_file = travis_tftp.file2env('u-boot.bin', 0x4040)
 env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworld.efi', 0x4040)
 env__efi_loader_grub_file = travis_tftp.file2env('grub_arm64.efi', 0x4040)
+env__efi_fit_tftp_file = travis_tftp.efifit2env(0x4040)
diff --git a/py/travis-ci/u_boot_boardenv_qemu_arm_na.py 
b/py/travis-ci/u_boot_boardenv_qemu_arm_na.py
index 391e3c4..3dbedde 100644
--- a/py/travis-ci/u_boot_boardenv_qemu_arm_na.py
+++ b/py/travis-ci/u_boot_boardenv_qemu_arm_na.py
@@ -6,3 +6,4 @@ env__net_dhcp_server = True
 env__net_tftp_readable_file = travis_tftp.file2env('u-boot.bin', 0x4040)
 env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworld.efi', 0x4040)
 env__efi_loader_grub_file = travis_tftp.file2env('grub_arm.efi', 0x4040)
+env__efi_fit_tftp_file = travis_tftp.efifit2env(0x4040)
diff --git a/py/travis-ci/u_boot_boardenv_qemu_x86_64_na.py 
b/py/travis-ci/u_boot_boardenv_qemu_x86_64_na.py
index 6f7c593..2fe72c8 100644
--- a/py/travis-ci/u_boot_boardenv_qemu_x86_64_na.py
+++ b/py/travis-ci/u_boot_boardenv_qemu_x86_64_na.py
@@ -8,3 +8,5 @@ env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworl

 env__efi_loader_check_smbios = True
 env__efi_loader_grub_file = travis_tftp.file2env('grub_x64.efi')
+
+env__efi_fit_tftp_file = travis_tftp.efifit2env()
diff --git a/py/travis-ci/u_boot_boardenv_qemu_x86_na.py 
b/py/travis-ci/u_boot_boardenv_qemu_x86_na.py
index 70dc0ae..62cc279 100644
--- a/py/travis-ci/u_boot_boardenv_qemu_x86_na.py
+++ b/py/travis-ci/u_boot_boardenv_qemu_x86_na.py
@@ -8,3 +8,5 @@ env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworl

 env__efi_loader_check_smbios = True
 env__efi_loader_grub_file = travis_tftp.file2env('grub_x86.efi')
+
+env__efi_fit_tftp_file = travis_tftp.efifit2env()
diff --git a/py/travis-ci/u_boot_boardenv_vexpress_ca15_tc2_qemu.py 
b/py/travis-ci/u_boot_boardenv_vexpress_ca15_tc2_qemu.py
index 7437ae6..75f287c 100644
--- a/py/travis-ci/u_boot_boardenv_vexpress_ca15_tc2_qemu.py
+++ b/py/travis-ci/u_boot_boardenv_vexpress_ca15_tc2_qemu.py
@@ -5,3 +5,4 @@ env__net_dhcp_server = True
 env__net_tftp_readable_file = travis_tftp.file2env('u-boot')
 env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworld.efi')
 env__efi_loader_grub_file = travis_tftp.file2env('grub_arm.efi')
+env__efi_fit_tftp_file = travis_tftp.efifit2env()
diff --git a/py/travis-ci/u_boot_boardenv_vexpress_ca9x4_qemu.py 
b/py/travis-ci/u_boot_boardenv_vexpress_ca9x4_qemu.py
index 7437ae6..75f287c 100644
--- a/py/travis-ci/u_boot_boardenv_vexpress_ca9x4_qemu.py
+++ b/py/travis-ci/u_boot_boardenv_vexpress_ca9x4_qemu.py
@@ -5,3 +5,4 @@ env__net_dhcp_server = True
 env__net_tftp_readable_file = travis_tftp.file2env('u-boot')
 env__efi_loader_helloworld_file = 
travis_tftp.file2env('lib/efi_loader/helloworld.efi')
 env__efi_loader_grub_file = travis_tftp.file2env('grub_arm.efi')
+env__efi_fit_tftp_file = travis_tftp.efifit2env()
--
2.24.1



Re: [PATCH v4 2/5] bootm: Add a bootm command for type IH_OS_EFI

2019-12-29 Thread Cristian Ciocaltea
On Sun, Dec 29, 2019 at 11:56:01AM +0100, Heinrich Schuchardt wrote:
> On 12/29/19 11:34 AM, Heinrich Schuchardt wrote:
> > On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:
> > > Add support for booting EFI binaries contained in FIT images.
> > > A typical usage scenario is chain-loading GRUB2 in a verified
> > > boot environment.
> > > 
> > > Signed-off-by: Cristian Ciocaltea 
> > > Reviewed-by: Heinrich Schuchardt 
> > > ---
> > >   cmd/Kconfig   |  7 ++
> > >   common/bootm_os.c | 56 +++
> > >   2 files changed, 63 insertions(+)
> > > 
> > > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > > index 1e4cf146c5..87f2335a3c 100644
> > > --- a/cmd/Kconfig
> > > +++ b/cmd/Kconfig
> > > @@ -263,6 +263,13 @@ config CMD_BOOTI
> > >   help
> > >     Boot an AArch64 Linux Kernel image from memory.
> > > 
> > > +config BOOTM_EFI
> > > +    bool "Support booting EFI OS images"
> > 
> > Shouldn't this be "Support booting UEFI FIT images"?
> > 
> > > +    depends on CMD_BOOTEFI
> > 
> > depends on BOOTM
> 
> depends on CMD_BOOTM
> 
> The patch series compiles without CONFIG_FIT. But shouldn't this also be
> a dependency?

Indeed, thanks.

> If we place the definition directly after CMD_BOOTM, it will be indented
> so that it is evident that this is a sub-feature of CMD_BOOTM.
> 
> So how about the following?
> 
> config CMD_BOOTM
> bool "bootm"
> default y
> help
>   Boot an application image from the memory.
> 
> config BOOTM_EFI
> bool "Support booting UEFI FIT images"
> depends on CMD_BOOTEFI && CMD_BOOTM && FIT
> default y
> help
>   Support booting UEFI FIT images via the bootm command.

In this case, we should probably also move CMD_BOOTZ, CMD_BOOTI and
BOOTM_LINUX right after CMD_BOOTEFI_HELLO, since those commands do not
depend on CMD_BOOTM, while all BOOTM_* features, except BOOTM_LINUX,
depend exclusively on CMD_BOOTM.

> Best regards
> 
> Heinrich
> 
> > 
> > is missing here.
> > 
> > > +    default y
> > > +    help
> > > +  Support booting EFI images via the bootm command.
> > 
> > Should we say:
> > 
> > Support booting UEFI FIT images via the bootm command.
> > 
> > Best regards
> > 
> > Heinrich
> > 
> > > +
> > >   config BOOTM_LINUX
> > >   bool "Support booting Linux OS images"
> > >   depends on CMD_BOOTM || CMD_BOOTZ || CMD_BOOTI
> > > diff --git a/common/bootm_os.c b/common/bootm_os.c
> > > index d89ddc32b0..1d58462509 100644
> > > --- a/common/bootm_os.c
> > > +++ b/common/bootm_os.c
> > > @@ -7,10 +7,12 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > >   #include 
> > > 
> > > @@ -498,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char
> > > * const argv[],
> > >   }
> > >   #endif
> > > 
> > > +#ifdef CONFIG_BOOTM_EFI
> > > +static int do_bootm_efi(int flag, int argc, char * const argv[],
> > > +    bootm_headers_t *images)
> > > +{
> > > +    int ret;
> > > +    efi_status_t efi_ret;
> > > +    void *image_buf;
> > > +
> > > +    if (flag != BOOTM_STATE_OS_GO)
> > > +    return 0;
> > > +
> > > +    /* Locate FDT, if provided */
> > > +    ret = bootm_find_images(flag, argc, argv);
> > > +    if (ret)
> > > +    return ret;
> > > +
> > > +    /* Initialize EFI drivers */
> > > +    efi_ret = efi_init_obj_list();
> > > +    if (efi_ret != EFI_SUCCESS) {
> > > +    printf("## Failed to initialize UEFI sub-system: r = %lu\n",
> > > +   efi_ret & ~EFI_ERROR_MASK);
> > > +    return 1;
> > > +    }
> > > +
> > > +    /* Install device tree */
> > > +    efi_ret = efi_install_fdt(images->ft_len
> > > +  ? images->ft_addr : EFI_FDT_USE_INTERNAL);
> > > +    if (efi_ret != EFI_SUCCESS) {
> > > +    printf("## Failed to install device tree: r = %lu\n",
> > > +   efi_ret & ~EFI_ERROR_MASK);
> > > +    return 1;
> > > +    }
> > > +
> > > +    /* Run EFI image */
> > > +    printf("## Transferring control to EFI (at address %08lx) ...\n",
> > > +   images->ep);
> > > +    bootstage_mark(BOOTSTAGE_ID_RUN_OS);
> > > +
> > > +    image_buf = map_sysmem(images->ep, images->os.image_len);
> > > +
> > > +    efi_ret = efi_run_image(image_buf, images->os.image_len);
> > > +    if (efi_ret != EFI_SUCCESS) {
> > > +    printf("## Failed to run EFI image: r = %lu\n",
> > > +   efi_ret & ~EFI_ERROR_MASK);
> > > +    return 1;
> > > +    }
> > > +
> > > +    return 0;
> > > +}
> > > +#endif
> > > +
> > >   static boot_os_fn *boot_os[] = {
> > >   [IH_OS_U_BOOT] = do_bootm_standalone,
> > >   #ifdef CONFIG_BOOTM_LINUX
> > > @@ -534,6 +587,9 @@ static boot_os_fn *boot_os[] = {
> > >   #ifdef CONFIG_BOOTM_OPTEE
> > >   [IH_OS_TEE] = do_bootm_tee,
> > >   #endif
> > > +#ifdef CONFIG_BOOTM_EFI
> > > +    [IH_OS_EFI] = do_bootm_efi,
> > 

Re: [PATCH v4 2/5] bootm: Add a bootm command for type IH_OS_EFI

2019-12-29 Thread Cristian Ciocaltea
On Sun, Dec 29, 2019 at 11:34:09AM +0100, Heinrich Schuchardt wrote:
> On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:
> > Add support for booting EFI binaries contained in FIT images.
> > A typical usage scenario is chain-loading GRUB2 in a verified
> > boot environment.
> > 
> > Signed-off-by: Cristian Ciocaltea 
> > Reviewed-by: Heinrich Schuchardt 
> > ---
> >   cmd/Kconfig   |  7 ++
> >   common/bootm_os.c | 56 +++
> >   2 files changed, 63 insertions(+)
> > 
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 1e4cf146c5..87f2335a3c 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -263,6 +263,13 @@ config CMD_BOOTI
> > help
> >   Boot an AArch64 Linux Kernel image from memory.
> > 
> > +config BOOTM_EFI
> > +   bool "Support booting EFI OS images"
> 
> Shouldn't this be "Support booting UEFI FIT images"?

Done.

> > +   depends on CMD_BOOTEFI
> 
> depends on BOOTM
> 
> is missing here.

Right, thanks. Added 'CMD_BOOTEFI && CMD_BOOTM'.

> > +   default y
> > +   help
> > + Support booting EFI images via the bootm command.
> 
> Should we say:
> 
> Support booting UEFI FIT images via the bootm command.

Done.

> Best regards
> 
> Heinrich
> 
> > +
> >   config BOOTM_LINUX
> > bool "Support booting Linux OS images"
> > depends on CMD_BOOTM || CMD_BOOTZ || CMD_BOOTI
> > diff --git a/common/bootm_os.c b/common/bootm_os.c
> > index d89ddc32b0..1d58462509 100644
> > --- a/common/bootm_os.c
> > +++ b/common/bootm_os.c
> > @@ -7,10 +7,12 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> > 
> > @@ -498,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char * 
> > const argv[],
> >   }
> >   #endif
> > 
> > +#ifdef CONFIG_BOOTM_EFI
> > +static int do_bootm_efi(int flag, int argc, char * const argv[],
> > +   bootm_headers_t *images)
> > +{
> > +   int ret;
> > +   efi_status_t efi_ret;
> > +   void *image_buf;
> > +
> > +   if (flag != BOOTM_STATE_OS_GO)
> > +   return 0;
> > +
> > +   /* Locate FDT, if provided */
> > +   ret = bootm_find_images(flag, argc, argv);
> > +   if (ret)
> > +   return ret;
> > +
> > +   /* Initialize EFI drivers */
> > +   efi_ret = efi_init_obj_list();
> > +   if (efi_ret != EFI_SUCCESS) {
> > +   printf("## Failed to initialize UEFI sub-system: r = %lu\n",
> > +  efi_ret & ~EFI_ERROR_MASK);
> > +   return 1;
> > +   }
> > +
> > +   /* Install device tree */
> > +   efi_ret = efi_install_fdt(images->ft_len
> > + ? images->ft_addr : EFI_FDT_USE_INTERNAL);
> > +   if (efi_ret != EFI_SUCCESS) {
> > +   printf("## Failed to install device tree: r = %lu\n",
> > +  efi_ret & ~EFI_ERROR_MASK);
> > +   return 1;
> > +   }
> > +
> > +   /* Run EFI image */
> > +   printf("## Transferring control to EFI (at address %08lx) ...\n",
> > +  images->ep);
> > +   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
> > +
> > +   image_buf = map_sysmem(images->ep, images->os.image_len);
> > +
> > +   efi_ret = efi_run_image(image_buf, images->os.image_len);
> > +   if (efi_ret != EFI_SUCCESS) {
> > +   printf("## Failed to run EFI image: r = %lu\n",
> > +  efi_ret & ~EFI_ERROR_MASK);
> > +   return 1;
> > +   }
> > +
> > +   return 0;
> > +}
> > +#endif
> > +
> >   static boot_os_fn *boot_os[] = {
> > [IH_OS_U_BOOT] = do_bootm_standalone,
> >   #ifdef CONFIG_BOOTM_LINUX
> > @@ -534,6 +587,9 @@ static boot_os_fn *boot_os[] = {
> >   #ifdef CONFIG_BOOTM_OPTEE
> > [IH_OS_TEE] = do_bootm_tee,
> >   #endif
> > +#ifdef CONFIG_BOOTM_EFI
> > +   [IH_OS_EFI] = do_bootm_efi,
> > +#endif
> >   };
> > 
> >   /* Allow for arch specific config before we boot */
> > 
> 


Re: [PATCH v4 5/5] test/py: Create a test for launching UEFI binaries from FIT images

2019-12-29 Thread Heinrich Schuchardt

On 12/29/19 11:22 AM, Heinrich Schuchardt wrote:

On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:

This test verifies the implementation of the 'bootm' extension that
handles UEFI binaries inside FIT images (enabled via CONFIG_BOOTM_EFI).

Signed-off-by: Cristian Ciocaltea 


Thanks a lot for devising this test.

---

You are using variable env__efi_fit_tftp_file. To run the test on Gitlab
and Travis CI a patch will be needed for:

 https://github.com/swarren/uboot-test-hooks.git

I hope

https://github.com/xypron/uboot-test-hooks/commit/20dcd721437dd5f7d7d3d235f7112246f43305d2 



will do the job.

Once we have this applied we will have to adjust the config files for QEMU.

---

I have been trying to run the test on qemu_arm64_defconfig using the
following lines in u_boot_boardenv_qemu_arm64.py:

env__efi_fit_tftp_file = {
     "fn": "helloworld.efi",
     "size": 4480,
     "crc32": "19f9c0ab",
}

I got an error:

test/py/tests/test_efi_fit.py:417: in launch_efi
     addr = load_fit_from_host(fit) if is_sandbox else
load_fit_from_tftp(fit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
     addr = f.get('addr', None)
     if not addr:
 >   addr = u_boot_utils.find_ram_base(cons)
E   NameError: name 'u_boot_utils' is not defined


When I provided addr:

env__efi_fit_tftp_file = {
     "fn": "helloworld.efi",
     "size": 4480,
     "crc32": "19f9c0ab",
     "addr": 0x4040,
}

I got the following error:

=> tftpboot 1073741824 helloworld.efi
TFTP error: trying to overwrite reserved memory...

I would have expected a command

 tftpboot 4040 helloworld.efi

to be issued.

Same error with bootm:

=> bootm 1077936128#config-efi-nofdt
"Synchronous Abort" handler, esr 0x9610
elr: 0001c36c lr : 000140f4 (reloc)

Please, fix the lines indicated below and verify that you can actually
execute this test on the QEMU platform.

https://github.com/xypron/u-boot-build/tree/qemu-arm64/u-boot-test

contains the files I use to run Python tests on qemu_arm64_defconfig.


---
  test/py/tests/test_efi_fit.py | 459 ++
  1 file changed, 459 insertions(+)
  create mode 100644 test/py/tests/test_efi_fit.py

diff --git a/test/py/tests/test_efi_fit.py 
b/test/py/tests/test_efi_fit.py

new file mode 100644
index 00..e1f0e42694
--- /dev/null
+++ b/test/py/tests/test_efi_fit.py
@@ -0,0 +1,459 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019, Cristian Ciocaltea 
+#
+# Work based on:
+# - test_net.py
+# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+# - test_fit.py
+# Copyright (c) 2013, Google Inc.
+#
+# Test launching UEFI binaries from FIT images.
+
+import os.path
+import pytest
+import u_boot_utils as util


"as util" causes an error if you use u_boot_utils.* below. Below I
indicate the places to change.


+
+"""
+Note: This test relies on boardenv_* containing configuration values 
to define
+which network environment is available for testing. Without this, the 
parts

+that rely on network will be automatically skipped.
+
+For example:
+
+# Boolean indicating whether the Ethernet device is attached to USB, 
and hence

+# USB enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_usb = False
+
+# Boolean indicating whether the Ethernet device is attached to PCI, 
and hence

+# PCI enumeration needs to be performed prior to network tests.
+# This variable may be omitted if its value is False.
+env__net_uses_pci = True
+
+# True if a DHCP server is attached to the network, and should be 
tested.
+# If DHCP testing is not possible or desired, this variable may be 
omitted or

+# set to False.
+env__net_dhcp_server = True
+
+# A list of environment variables that should be set in order to 
configure a
+# static IP. If solely relying on DHCP, this variable may be omitted 
or set to

+# an empty list.
+env__net_static_env_vars = [
+    ('ipaddr', '10.0.0.100'),
+    ('netmask', '255.255.255.0'),
+    ('serverip', '10.0.0.1'),
+]
+
+# Details regarding a file that may be read from a TFTP server. This 
variable
+# may be omitted or set to None if TFTP testing is not possible or 
desired.
+# Additionally, when the 'size' is not available, the file will be 
generated
+# automatically in the TFTP root directory, as specified by the 'dn' 
field.

+env__efi_fit_tftp_file = {
+    'fn': 'test-efi-fit.img',   # File path relative to TFTP root
+    'size': 3831,   # File size
+    'crc32': '9fa3f79c',    # Checksum using CRC-32 algorithm, 
optional

+    'addr': '$kernel_addr_r',   # Loading address, optional


addr must be an integer not a string. Otherwise this does not match your 
function call


addr = util.find_ram_base(cons)

Best regards

Heinrich



+    'dn': 'tftp/root/dir',  # TFTP root directory path, optional
+}
+"""
+
+# Define the parametrized ITS data to be used for FIT images generation.

Re: [PATCH] tools: .gitignore: add asn1_compiler

2019-12-29 Thread Bin Meng
On Sun, Dec 29, 2019 at 8:44 PM Dario Binacchi  wrote:
>
> Add the tool to the ignore list to prevent being marked as unversioned.
>
> Signed-off-by: Dario Binacchi 
> ---
>
>  tools/.gitignore | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Bin Meng 


[PATCH] .gitignore: ignore files generated by asn1 compiler

2019-12-29 Thread Dario Binacchi
As described in doc/README.asn1 document the tools/asn1_compiler is used
to "generate bytecode as a C file (*.asn1.[ch]) from *.asn1 file".

Signed-off-by: Dario Binacchi 
---

 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index f980ae6f70..2e1c8bf2bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
 #
 .*
 *.a
+*.asn1.[ch]
 *.bin
 *.cfgout
 *.dtb
-- 
2.24.0



[PATCH] tools: .gitignore: add asn1_compiler

2019-12-29 Thread Dario Binacchi
Add the tool to the ignore list to prevent being marked as unversioned.

Signed-off-by: Dario Binacchi 
---

 tools/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/.gitignore b/tools/.gitignore
index d0176a7283..82bdce2782 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -1,3 +1,4 @@
+/asn1_compiler
 /atmel_pmecc_params
 /bin2header
 /bmp_logo
-- 
2.24.0



Re: [PATCH v4 2/5] bootm: Add a bootm command for type IH_OS_EFI

2019-12-29 Thread Heinrich Schuchardt

On 12/29/19 11:34 AM, Heinrich Schuchardt wrote:

On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:

Add support for booting EFI binaries contained in FIT images.
A typical usage scenario is chain-loading GRUB2 in a verified
boot environment.

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
  cmd/Kconfig   |  7 ++
  common/bootm_os.c | 56 +++
  2 files changed, 63 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1e4cf146c5..87f2335a3c 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -263,6 +263,13 @@ config CMD_BOOTI
  help
    Boot an AArch64 Linux Kernel image from memory.

+config BOOTM_EFI
+    bool "Support booting EFI OS images"


Shouldn't this be "Support booting UEFI FIT images"?


+    depends on CMD_BOOTEFI


depends on BOOTM


depends on CMD_BOOTM

The patch series compiles without CONFIG_FIT. But shouldn't this also be
a dependency?

If we place the definition directly after CMD_BOOTM, it will be indented
so that it is evident that this is a sub-feature of CMD_BOOTM.

So how about the following?

config CMD_BOOTM
bool "bootm"
default y
help
  Boot an application image from the memory.

config BOOTM_EFI
bool "Support booting UEFI FIT images"
depends on CMD_BOOTEFI && CMD_BOOTM && FIT
default y
help
  Support booting UEFI FIT images via the bootm command.

Best regards

Heinrich



is missing here.


+    default y
+    help
+  Support booting EFI images via the bootm command.


Should we say:

Support booting UEFI FIT images via the bootm command.

Best regards

Heinrich


+
  config BOOTM_LINUX
  bool "Support booting Linux OS images"
  depends on CMD_BOOTM || CMD_BOOTZ || CMD_BOOTI
diff --git a/common/bootm_os.c b/common/bootm_os.c
index d89ddc32b0..1d58462509 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -7,10 +7,12 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 

@@ -498,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char
* const argv[],
  }
  #endif

+#ifdef CONFIG_BOOTM_EFI
+static int do_bootm_efi(int flag, int argc, char * const argv[],
+    bootm_headers_t *images)
+{
+    int ret;
+    efi_status_t efi_ret;
+    void *image_buf;
+
+    if (flag != BOOTM_STATE_OS_GO)
+    return 0;
+
+    /* Locate FDT, if provided */
+    ret = bootm_find_images(flag, argc, argv);
+    if (ret)
+    return ret;
+
+    /* Initialize EFI drivers */
+    efi_ret = efi_init_obj_list();
+    if (efi_ret != EFI_SUCCESS) {
+    printf("## Failed to initialize UEFI sub-system: r = %lu\n",
+   efi_ret & ~EFI_ERROR_MASK);
+    return 1;
+    }
+
+    /* Install device tree */
+    efi_ret = efi_install_fdt(images->ft_len
+  ? images->ft_addr : EFI_FDT_USE_INTERNAL);
+    if (efi_ret != EFI_SUCCESS) {
+    printf("## Failed to install device tree: r = %lu\n",
+   efi_ret & ~EFI_ERROR_MASK);
+    return 1;
+    }
+
+    /* Run EFI image */
+    printf("## Transferring control to EFI (at address %08lx) ...\n",
+   images->ep);
+    bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+    image_buf = map_sysmem(images->ep, images->os.image_len);
+
+    efi_ret = efi_run_image(image_buf, images->os.image_len);
+    if (efi_ret != EFI_SUCCESS) {
+    printf("## Failed to run EFI image: r = %lu\n",
+   efi_ret & ~EFI_ERROR_MASK);
+    return 1;
+    }
+
+    return 0;
+}
+#endif
+
  static boot_os_fn *boot_os[] = {
  [IH_OS_U_BOOT] = do_bootm_standalone,
  #ifdef CONFIG_BOOTM_LINUX
@@ -534,6 +587,9 @@ static boot_os_fn *boot_os[] = {
  #ifdef CONFIG_BOOTM_OPTEE
  [IH_OS_TEE] = do_bootm_tee,
  #endif
+#ifdef CONFIG_BOOTM_EFI
+    [IH_OS_EFI] = do_bootm_efi,
+#endif
  };

  /* Allow for arch specific config before we boot */








Re: [PATCH v4 2/5] bootm: Add a bootm command for type IH_OS_EFI

2019-12-29 Thread Heinrich Schuchardt

On 12/24/19 5:05 PM, Cristian Ciocaltea wrote:

Add support for booting EFI binaries contained in FIT images.
A typical usage scenario is chain-loading GRUB2 in a verified
boot environment.

Signed-off-by: Cristian Ciocaltea 
Reviewed-by: Heinrich Schuchardt 
---
  cmd/Kconfig   |  7 ++
  common/bootm_os.c | 56 +++
  2 files changed, 63 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1e4cf146c5..87f2335a3c 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -263,6 +263,13 @@ config CMD_BOOTI
help
  Boot an AArch64 Linux Kernel image from memory.

+config BOOTM_EFI
+   bool "Support booting EFI OS images"


Shouldn't this be "Support booting UEFI FIT images"?


+   depends on CMD_BOOTEFI


depends on BOOTM

is missing here.


+   default y
+   help
+ Support booting EFI images via the bootm command.


Should we say:

Support booting UEFI FIT images via the bootm command.

Best regards

Heinrich


+
  config BOOTM_LINUX
bool "Support booting Linux OS images"
depends on CMD_BOOTM || CMD_BOOTZ || CMD_BOOTI
diff --git a/common/bootm_os.c b/common/bootm_os.c
index d89ddc32b0..1d58462509 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -7,10 +7,12 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 

@@ -498,6 +500,57 @@ static int do_bootm_tee(int flag, int argc, char * const 
argv[],
  }
  #endif

+#ifdef CONFIG_BOOTM_EFI
+static int do_bootm_efi(int flag, int argc, char * const argv[],
+   bootm_headers_t *images)
+{
+   int ret;
+   efi_status_t efi_ret;
+   void *image_buf;
+
+   if (flag != BOOTM_STATE_OS_GO)
+   return 0;
+
+   /* Locate FDT, if provided */
+   ret = bootm_find_images(flag, argc, argv);
+   if (ret)
+   return ret;
+
+   /* Initialize EFI drivers */
+   efi_ret = efi_init_obj_list();
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to initialize UEFI sub-system: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   /* Install device tree */
+   efi_ret = efi_install_fdt(images->ft_len
+ ? images->ft_addr : EFI_FDT_USE_INTERNAL);
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to install device tree: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   /* Run EFI image */
+   printf("## Transferring control to EFI (at address %08lx) ...\n",
+  images->ep);
+   bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+   image_buf = map_sysmem(images->ep, images->os.image_len);
+
+   efi_ret = efi_run_image(image_buf, images->os.image_len);
+   if (efi_ret != EFI_SUCCESS) {
+   printf("## Failed to run EFI image: r = %lu\n",
+  efi_ret & ~EFI_ERROR_MASK);
+   return 1;
+   }
+
+   return 0;
+}
+#endif
+
  static boot_os_fn *boot_os[] = {
[IH_OS_U_BOOT] = do_bootm_standalone,
  #ifdef CONFIG_BOOTM_LINUX
@@ -534,6 +587,9 @@ static boot_os_fn *boot_os[] = {
  #ifdef CONFIG_BOOTM_OPTEE
[IH_OS_TEE] = do_bootm_tee,
  #endif
+#ifdef CONFIG_BOOTM_EFI
+   [IH_OS_EFI] = do_bootm_efi,
+#endif
  };

  /* Allow for arch specific config before we boot */





[U-Boot] [PATCH v1 28/29] imx6: aristainetos: add aristainetos 2b csl

2019-12-29 Thread sbabic
> add aristainetso board version CSL.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2 1/5] colibri_imx7: add update_uboot wrapper

2019-12-29 Thread sbabic
> From: Igor Opaniuk 
> Add universal update_uboot wrapper that helps to update
> U-Boot image on internal storage.
> Usage example:
> > tftpboot ${loadaddr} ${board_name}/u-boot-dtb.imx
> > run update_uboot
> Signed-off-by: Igor Opaniuk 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 16/29] imx6: aristainetos: add DM_VIDEO support

2019-12-29 Thread sbabic
> add DM_VIDEO support and remove now unneeded board
> code. As we show a bmp logo on boot, call now
> bmp_display() from board code and do not use
> cfb_console anymore.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [RESEND PATCH 09/10] board: ge: bx50v3: use imx wdt

2019-12-29 Thread sbabic
> Enable DM imx WDT
> Enable SYSRESET_WATCHDOG to maintain WDT based reset ability
> Signed-off-by: Robert Beckett 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 6/6] colibri_imx7: migrate to DM_ETH

2019-12-29 Thread sbabic
> From: Igor Opaniuk 
> Migrate to DM_ETH and remove hardcoded pinmux configuration.
> Signed-off-by: Igor Opaniuk 
> Reviewed-by: Oleksandr Suvorov 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 12/29] imx6: aristainetos: convert gpio pins to DM and DTS

2019-12-29 Thread sbabic
> Enable DM_GPIO, GPIO_HOG, LED and LED_GPIO as gpio
> and LEDs are now defined in DTS. Enable also here
> the pinctrl driver, so pinmux setup is also done.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 1/6] ARM: dts: imx6_colibri: introduce fec node

2019-12-29 Thread sbabic
> From: Igor Opaniuk 
> Sync DTS with the mainline Linux and introduce fec node.
> Signed-off-by: Igor Opaniuk 
> Reviewed-by: Oleksandr Suvorov 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 20/29] imx6: aristainetos: add i2c eeprom support

2019-12-29 Thread sbabic
> add support for i2c eeprom and add parsing "Rescue"
> or "DefEnv" at offset 0x1ff0.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH 2/2] board: cm_fx6: Enable CONFIG_DM_ETH

2019-12-29 Thread sbabic
> From: Suniel Mahesh 
> Enable CONFIG_DM_ETH to remove compile warning on CM-FX6
> SOM based target:
> = WARNING ==
> This board does not use CONFIG_DM_ETH (Driver Model
> for Ethernet drivers). Please update the board to use
> CONFIG_DM_ETH before the v2020.07 release.
> 
> Signed-off-by: Suniel Mahesh 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [RESEND PATCH 08/10] board: ge: pass rtc_status via device tree

2019-12-29 Thread sbabic
> From: Ian Ray 
> Pass rtc_status via the device tree, instead of on kernel command line.
> Additionally, the 2038 mitigation is reported, if applied successfully.
> Signed-off-by: Ian Ray 
> Signed-off-by: Robert Beckett 
> Reviewed-by: Simon Glass 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH 2/4] imx: cx9020: migrate cx9020 to CONFIG_DM_USB

2019-12-29 Thread sbabic
> From: Steffen Dirkwinkel 
> Note: gpio7_8 was never used for usb power regulator so we remove it here
> Acked-by: Patrick Bruenn 
> Signed-off-by: Steffen Dirkwinkel 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 21/29] imx6: aristainetos: add AUTOBOOT_KEYED

2019-12-29 Thread sbabic
> add stop autobooting via SHA256 encrypted password.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 06/29] imx6: aristainetos: add device tree from linux

2019-12-29 Thread sbabic
> Add device trees from Linux in preparation for driver model
> conversions.
> device tree files taken from Linux:
> 71ae5fc87c34: "Merge tag 'linux-kselftest-5.2-rc1' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest"
> and added SPDX license identifier.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH 4/4] imx: cx9020: use distro boot

2019-12-29 Thread sbabic
> From: Steffen Dirkwinkel 
> We switch from custom boot commands relying on uEnv.txt to distro boot.
> This removes the automatic fpga bitstream loading in favor of loading
> bitstreams via custom bootscripts (boot.scr) or after booting the
> kernel.
> Acked-by: Patrick Bruenn 
> Signed-off-by: Steffen Dirkwinkel 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v6] imx: Add support for i.MX28 based XEA board

2019-12-29 Thread sbabic
> This patch introduces support for i.MX28 based XEA board.
> This board supports DM/DTS in U-Boot proper as well as DM aware drivers
> in SPL (u-boot.sb) by using OF_PLATDATA.
> More detailed information regarding usage of it can be found in
> ./board/liebherr/xea/README file.
> U-Boot SPL 2019.10-rc1-00233-g6aa549f05c (Aug 12 2019 - 09:23:36 +0200)
> Trying to boot from MMC1
> MMC0: Command 8 timeout (status 0xf0344020)
> mmc_load_image_raw_sector: mmc block read error
> U-Boot 2019.10-rc1-00233-g6aa549f05c (Aug 12 2019 - 09:23:36 +0200)
> CPU:   Freescale i.MX28 rev1.2 at 454 MHz
> BOOT:  SSP SPI #3, master, 3V3 NOR
> Model: Liebherr (LWE) XEA i.MX28 Board
> DRAM:  128 MiB
> MMC:   MXS MMC: 0
> Loading Environment from SPI Flash... SF: Detected n25q128a13 with page size 
> 256 Bytes, erase size 64 KiB, total 16 MiB
> OK
> In:serial
> Out:   serial
> Err:   serial
> Net:
> Warning: ethernet@800f (eth0) using random MAC address - ce:e1:9e:46:f3:a2
> eth0: ethernet@800f
> Hit any key to stop autoboot:  0
> Signed-off-by: Lukasz Majewski 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 25/29] imx6: aristainetos: cleanup default Environment

2019-12-29 Thread sbabic
> sync defaut Envoronment with customer changes.
> Unfortunately they are not changeable, as already
> board is in production mode.
> Get rid of the big bootcommand and set bootcommand
> through Kconfig option.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH 2/3] mx7dsabre: Enable DM_ETH

2019-12-29 Thread sbabic
> Also sync device tree with v5.5-rc1
> Signed-off-by: Joris Offouga 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 11/29] imx6: aristainetos: convert to DM_MMC

2019-12-29 Thread sbabic
> Enable DM_MMC support.
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 1/2] MAINTAINERS: change apalis_imx6/colibri_imx6 maintainers

2019-12-29 Thread sbabic
> From: Igor Opaniuk 
> Take over maintainership for apalis_imx6 and colibri_imx6 modules.
> Signed-off-by: Igor Opaniuk 
> Acked-by: Max Krummenacher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[U-Boot] [PATCH v1 14/29] imx6: aristainetos: convert CONFIG_DM_SPI

2019-12-29 Thread sbabic
> enable CONFIG_DM_SPI and CONFIG_DM_SPI_FLASH
> and get rid of build removal warnings.
> define CONFIG_GPIO_ENABLE_SPI_FLASH is not longer
> needed, so remove it from config_whitelist.txt
> Signed-off-by: Heiko Schocher 
Applied to u-boot-imx, -next, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


  1   2   >