Re: [U-Boot] [PATCH 2/5] arm: socfpga: fix device trees to work with DM serial

2018-08-08 Thread Simon Goldschmidt
On Mon, Aug 6, 2018 at 4:41 PM Simon Goldschmidt
 wrote:
>
>
>
> Emmanuel Vadot  schrieb am Mo., 6. Aug. 2018, 15:48:
>>
>> On Mon, 6 Aug 2018 15:42:01 +0200
>> Simon Goldschmidt  wrote:
>>
>> > Marek Vasut  schrieb am Mo., 6. Aug. 2018, 15:19:
>> >
>> > > On 08/05/2018 09:34 PM, Simon Goldschmidt wrote:
>> > > > Device trees need to have the serial console device available
>> > > > before relocation and require a stdout-path in chosen at least
>> > > > for SPL to have a console.
>> > > >
>> > > > Signed-off-by: Simon Goldschmidt 
>> > >
>> > > This should be upstreamed to Linux too ?
>> > >
>> >
>> > Hmm, I'm not sure. Does Linux use the stdout-path too? I always use
>> > bootargs only...
>>
>>  Linux is the standard repo where other project (like FreeBSD) pull the
>> DTS and stdout-path is standard, so it should be upstreamed.
>
>
> Ok then, I can upstream them. How is the workflow, via which repository or 
> list so socfpga device trees get pushed?

Ignore that question.

I had a look at the current socfpga device trees in Linux and only
socrates and vining seem to be missing the stdout-path. I'll send a
patch to add these.
The rest of the device trees, however, is very different to the U-Boot
ones. What's the procedure here, shall we just copy them from Linux or
do we keep ours?

In any case, we do need this patch to get U-Boot and SPL running
correctly on gen5, which is has been broken since v2018.07.

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


Re: [U-Boot] [PATCH 1/4 v2] spi: spi-mem: Use 2 SPI messages instead of a single full-duplex one

2018-08-08 Thread Miquel Raynal
Hi Stefan, Jagan,

Boris Brezillon  wrote on Tue, 7 Aug 2018
15:28:02 +0200:

> On Tue,  7 Aug 2018 14:16:52 +0200
> Stefan Roese  wrote:
> 
> > Some SPI controller do not support full-duplex SPI transfers. This patch
> > changes the SPI transfer into 2 separate transfers - or 1, if no data is
> > to transmitted.
> > 
> > With this change, no buffers need to be allocated anymore. We use the
> > TX and RX buffers that are passed to spi_mem_exec_op() directly.
> > 
> > Signed-off-by: Stefan Roese 
> > Suggested-by: Boris Brezillon 
> > Cc: Miquel Raynal 
> > Cc: Boris Brezillon 
> > Cc: Jagan Teki   
> 
> Looks good overall, just a few comments (that you might chose to ignore
> if you disagree).
> 
> Reviewed-by: Boris Brezillon 
> 

Sorry for being a bit late on the discussion, but while I do agree with
the change, I'm not sure about its implementation : I think SPI
controllers are supposed to be abstracted by the SPI layer.
Addressing the controller's limitations in the SPI-mem layer would
not be appropriate.

Would it be possible to adapt spi_xfer() to handle such case? 

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


Re: [U-Boot] [RESEND PATCH V2 3/3] imx: mx7: add system suspend/resume support

2018-08-08 Thread Stefan Agner
Hi Anson,

On 08.08.2018 03:17, Anson Huang wrote:
> This patch adds system suspend/resume support,
> when linux kernel enters deep sleep mode, SoC will go
> into below mode:
> 
>  - CA7 platform goes into STOP mode;
>  - SoC goes into DSM mode;
>  - DDR goes into self-refresh mode;
>  - CPU0/SCU will be powered down.
> 
> When wake up event arrives:
> 
>  - SoC DSM mdoe exits;
>  - CA7 platform exit STOP mode, SCU/CPU0 power up;
>  - Invalidate L1 cache;
>  - DDR exit self-refresh mode;
>  - Do secure monitor mode related initialization;
>  - Jump to linux kernel resume entry.
> 
> Belwo is the log of 1 iteration of system suspend/resume:
> 
> [  338.824862] PM: suspend entry (deep)
> [  338.828853] PM: Syncing filesystems ... done.
> [  338.834433] Freezing user space processes ... (elapsed 0.001 seconds) done.
> [  338.842939] OOM killer disabled.
> [  338.846182] Freezing remaining freezable tasks ... (elapsed 0.001
> seconds) done.
> [  338.869717] PM: suspend devices took 0.010 seconds
> [  338.877846] Disabling non-boot CPUs ...
> [  338.960301] Retrying again to check for CPU kill
> [  338.964953] CPU1 killed.
> [  338.968104] Enabling non-boot CPUs ...
> [  338.973598] CPU1 is up
> [  339.267155] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
> [  339.275833] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
> [  339.284158] mmc1: queuing unknown CIS tuple 0x80 (6 bytes)
> [  339.385065] PM: resume devices took 0.400 seconds
> [  339.389836] OOM killer enabled.
> [  339.392986] Restarting tasks ... done.
> [  339.398990] PM: suspend exit

Gave this a try with a 3.18-rc6 kernel today on our Colibri iMX7, I
could successfully suspend and resume using RTC wakealarm.

What is a bit weird is that sometimes the SoC seems to consume more
power than other times (sometimes 135mW, sometimes 60mW). Any idea where
that could come from?

In any case, the system seems to wakeup just fine.

--
Stefan

> 
> The resume entry function has to initialize stack pointer before calling
> C code, otherwise there will be an external abort occur, in additional,
> invalidate L1 cache must be done in secure section as well, so this
> patch also adds assembly code back and keep it as simple as possible.
> 
> Signed-off-by: Anson Huang 
> ---
>  arch/arm/mach-imx/mx7/Makefile   |   2 +-
>  arch/arm/mach-imx/mx7/psci-mx7.c | 449 
> ++-
>  arch/arm/mach-imx/mx7/psci-suspend.S |  67 ++
>  3 files changed, 515 insertions(+), 3 deletions(-)
>  create mode 100644 arch/arm/mach-imx/mx7/psci-suspend.S
> 
> diff --git a/arch/arm/mach-imx/mx7/Makefile b/arch/arm/mach-imx/mx7/Makefile
> index 94a0e64..f1436e2 100644
> --- a/arch/arm/mach-imx/mx7/Makefile
> +++ b/arch/arm/mach-imx/mx7/Makefile
> @@ -4,4 +4,4 @@
>  #
>  
>  obj-y:= soc.o clock.o clock_slice.o ddr.o snvs.o
> -obj-$(CONFIG_ARMV7_PSCI)  += psci-mx7.o
> +obj-$(CONFIG_ARMV7_PSCI)  += psci-mx7.o psci-suspend.o
> diff --git a/arch/arm/mach-imx/mx7/psci-mx7.c 
> b/arch/arm/mach-imx/mx7/psci-mx7.c
> index d6c4263..34ba0a9 100644
> --- a/arch/arm/mach-imx/mx7/psci-mx7.c
> +++ b/arch/arm/mach-imx/mx7/psci-mx7.c
> @@ -8,20 +8,77 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
>  
> -#define GPC_CPU_PGC_SW_PDN_REQ   0xfc
> +#define GPC_LPCR_A7_BSC  0x0
> +#define GPC_LPCR_A7_AD   0x4
> +#define GPC_SLPCR0x14
> +#define GPC_PGC_ACK_SEL_A7   0x24
> +#define GPC_IMR1_CORE0   0x30
> +#define GPC_SLOT0_CFG0xb0
>  #define GPC_CPU_PGC_SW_PUP_REQ   0xf0
> +#define GPC_CPU_PGC_SW_PDN_REQ   0xfc
> +#define GPC_PGC_C0   0x800
>  #define GPC_PGC_C0   0x800
>  #define GPC_PGC_C1   0x840
> +#define GPC_PGC_SCU  0x880
> +
> +#define BM_LPCR_A7_BSC_CPU_CLK_ON_LPM0x4000
> +#define BM_LPCR_A7_BSC_LPM1  0xc
> +#define BM_LPCR_A7_BSC_LPM0  0x3
> +#define BP_LPCR_A7_BSC_LPM0  0
> +#define BM_SLPCR_EN_DSM  0x8000
> +#define BM_SLPCR_RBC_EN  0x4000
> +#define BM_SLPCR_REG_BYPASS_COUNT0x3f00
> +#define BM_SLPCR_VSTBY   0x4
> +#define BM_SLPCR_SBYOS   0x2
> +#define BM_SLPCR_BYPASS_PMIC_READY   0x1
> +#define BM_LPCR_A7_AD_L2PGE  0x1
> +#define BM_LPCR_A7_AD_EN_C1_PUP  0x800
> +#define BM_LPCR_A7_AD_EN_C0_PUP  0x200
> +#define BM_LPCR_A7_AD_EN_PLAT_PDN0x10
> +#define BM_LPCR_A7_AD_EN_C1_PDN  0x8
> +#define BM_LPCR_A7_AD_EN_C0_PDN  0x2
>  
>  #define BM_CPU_PGC_SW_PDN_PUP_REQ_CORE0_A7   0x1
>  #define BM_CPU_PGC_SW_PDN_PUP_REQ_CORE1_A7   0x2
>  
> -/* below is for i.MX7D */
> +#define BM_GPC_PGC_ACK_SEL_A7_PD_DUMMY_ACK   0x8000
> +#define BM_GPC_PGC_ACK_SEL_A7_PU_DUMMY_ACK   0x8000
> +
> +

[U-Boot] [PATCH v7 0/8] NXP LS1046A SMMU enabling patches

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

This patch series adds the required devices setup and device tree
fixups for SMMU enablement on NXP LS1046A chips. The approach taken
tries to mimic the implementation of PAMU LIODN setup on booke powerpc.

First 4 patches contain some fixes and add some missing bits & pieces.
Last 4 patches add the actual infrastructure for ICID setup, qman
portals, fman ICID and SEC configuration.

Changes in v7:
 - fix this build breakage introduced by patch [6/8] on booke ppc
   appearing with certain tool chain versions:
"drivers/misc/fsl_portals.c: In function 'fdt_fixup_qportals':
drivers/misc/fsl_portals.c:256:3: error: 'for' loop initial
declarations are only allowed in C99 or C11 mode"
 - fixed linker error on LS1012A targets:
"arch/arm/cpu/armv8/built-in.o: In function
`fsl_lsch2_early_init_f':
arch/arm/cpu/armv8/fsl-layerscape/soc.c:691:
undefined reference to `set_icids'"

Changes in v6:
 - distinct ICIDs for all SEC blocks (Horia, Bharat)

Changes in v5:
 - use distinct ICID for SEC JRs (Horia, Bharat)
 - moved an #include in the file it's used (Horia)
 - fix broken compilation of multiple targets due to removal of SEC
   related config (Horia)
 - add a missing #include in qds board file
 - drop few uses of CONFIG_SYS_FMAN_V3 and consistently use
   CONFIG_SYS_DPAA_FMAN everywhere

Changes in v4:
 - added missing SEC ICID config
 - updated macro params to match arguments
 - supplemental comments

Changes in v3:
 - cleaner QMAN_BAR setup
 - moved SoC specific bits from generic ICID arch setup to board code

Changes in v2:
 - drop CONFIG_SYS_ prefix from newly introduced defines in patch [1/8]

Laurentiu Tudor (8):
  armv8: fsl-layerscape: add missing register blocks base address
defines
  armv8: ls1046a: advertise QMan v3 in configuration
  misc: fsl_portals: setup QMAN_BAR{E} also on ARM platforms
  armv8: fsl-layerscape: add missing debug stream ID
  armv8: ls1046a: initial icid setup support
  armv8: ls1046a: add icid setup for qman portals
  armv8: ls1046a: setup fman ports ICIDs and device tree
  armv8: ls1046a: setup SEC ICIDs and fix up device tree

 arch/arm/cpu/armv8/fsl-layerscape/Makefile|   1 +
 arch/arm/cpu/armv8/fsl-layerscape/icid.c  | 192 ++
 .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c |  89 
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   |   5 +
 .../include/asm/arch-fsl-layerscape/config.h  |   1 +
 .../asm/arch-fsl-layerscape/fsl_icid.h| 115 +++
 .../asm/arch-fsl-layerscape/fsl_portals.h |  24 +++
 .../asm/arch-fsl-layerscape/immap_lsch2.h |  15 +-
 .../asm/arch-fsl-layerscape/stream_id_lsch2.h |   1 +
 board/freescale/ls1046aqds/ls1046aqds.c   |   3 +
 board/freescale/ls1046ardb/ls1046ardb.c   |   3 +
 drivers/misc/fsl_portals.c|  44 +++-
 12 files changed, 482 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/icid.c
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
 create mode 100644 arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h
 create mode 100644 arch/arm/include/asm/arch-fsl-layerscape/fsl_portals.h

-- 
2.17.1

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


[U-Boot] [PATCH v7 1/8] armv8: fsl-layerscape: add missing register blocks base address defines

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add defines for the edma and qdma register block base addresses.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
index 5b4767e0fe..644a16dd30 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
@@ -88,8 +88,12 @@
 
 #define LPUART_BASE(CONFIG_SYS_IMMR + 0x0195)
 
+#define EDMA_BASE_ADDR (CONFIG_SYS_IMMR + 0x01c0)
+
 #define AHCI_BASE_ADDR (CONFIG_SYS_IMMR + 0x0220)
 
+#define QDMA_BASE_ADDR (CONFIG_SYS_IMMR + 0x0738)
+
 #define CONFIG_SYS_PCIE1_PHYS_ADDR 0x40ULL
 #define CONFIG_SYS_PCIE2_PHYS_ADDR 0x48ULL
 #define CONFIG_SYS_PCIE3_PHYS_ADDR 0x50ULL
-- 
2.17.1

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


[U-Boot] [PATCH v7 5/8] armv8: ls1046a: initial icid setup support

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add infrastructure for ICID setup and device tree fixup on ARM
platforms. This include basic ICID setup for several devices.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/cpu/armv8/fsl-layerscape/Makefile|   1 +
 arch/arm/cpu/armv8/fsl-layerscape/icid.c  | 110 ++
 .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c |  29 +
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   |   5 +
 .../asm/arch-fsl-layerscape/fsl_icid.h|  80 +
 board/freescale/ls1046aqds/ls1046aqds.c   |   3 +
 board/freescale/ls1046ardb/ls1046ardb.c   |   3 +
 7 files changed, 231 insertions(+)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/icid.c
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
 create mode 100644 arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Makefile 
b/arch/arm/cpu/armv8/fsl-layerscape/Makefile
index 1e9e4680fe..5d6f68aad6 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Makefile
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Makefile
@@ -37,6 +37,7 @@ endif
 
 ifneq ($(CONFIG_ARCH_LS1046A),)
 obj-$(CONFIG_SYS_HAS_SERDES) += ls1046a_serdes.o
+obj-y += icid.o ls1046_ids.o
 endif
 
 ifneq ($(CONFIG_ARCH_LS1088A),)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/icid.c 
b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
new file mode 100644
index 00..ae3b8daa95
--- /dev/null
+++ b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static void set_icid(struct icid_id_table *tbl, int size)
+{
+   int i;
+
+   for (i = 0; i < size; i++)
+   out_be32((u32 *)(tbl[i].reg_addr), tbl[i].reg);
+}
+
+void set_icids(void)
+{
+   /* setup general icid offsets */
+   set_icid(icid_tbl, icid_tbl_sz);
+}
+
+int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids)
+{
+   int i, ret;
+   u32 prop[8];
+
+   /*
+* Note: The "iommus" property definition mentions Stream IDs while
+* this code handles ICIDs. The current implementation assumes that
+* ICIDs and Stream IDs are equal.
+*/
+   for (i = 0; i < num_ids; i++) {
+   prop[i * 2] = cpu_to_fdt32(smmu_ph);
+   prop[i * 2 + 1] = cpu_to_fdt32(ids[i]);
+   }
+   ret = fdt_setprop(blob, off, "iommus",
+ prop, sizeof(u32) * num_ids * 2);
+   if (ret) {
+   printf("WARNING unable to set iommus: %s\n", fdt_strerror(ret));
+   return ret;
+   }
+
+   return 0;
+}
+
+int fdt_fixup_icid_tbl(void *blob, int smmu_ph,
+  struct icid_id_table *tbl, int size)
+{
+   int i, err, off;
+
+   for (i = 0; i < size; i++) {
+   if (!tbl[i].compat)
+   continue;
+
+   off = fdt_node_offset_by_compat_reg(blob,
+   tbl[i].compat,
+   tbl[i].compat_addr);
+   if (off > 0) {
+   err = fdt_set_iommu_prop(blob, off, smmu_ph,
+&tbl[i].id, 1);
+   if (err)
+   return err;
+   } else {
+   printf("WARNING could not find node %s: %s.\n",
+  tbl[i].compat, fdt_strerror(off));
+   }
+   }
+
+   return 0;
+}
+
+int fdt_get_smmu_phandle(void *blob)
+{
+   int noff, smmu_ph;
+
+   noff = fdt_node_offset_by_compatible(blob, -1, "arm,mmu-500");
+   if (noff < 0) {
+   printf("WARNING failed to get smmu node: %s\n",
+  fdt_strerror(noff));
+   return noff;
+   }
+
+   smmu_ph = fdt_get_phandle(blob, noff);
+   if (!smmu_ph) {
+   smmu_ph = fdt_create_phandle(blob, noff);
+   if (!smmu_ph) {
+   printf("WARNING failed to get smmu phandle\n");
+   return -1;
+   }
+   }
+
+   return smmu_ph;
+}
+
+void fdt_fixup_icid(void *blob)
+{
+   int smmu_ph;
+
+   smmu_ph = fdt_get_smmu_phandle(blob);
+   if (smmu_ph < 0)
+   return;
+
+   fdt_fixup_icid_tbl(blob, smmu_ph, icid_tbl, icid_tbl_sz);
+}
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
new file mode 100644
index 00..1c528ab751
--- /dev/null
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 NXP
+ */
+
+#include 
+#include 
+#include 
+
+struct icid_id_table icid_tbl[] = {
+#ifdef CONFIG_SYS_DPAA_QBMAN
+   SET_QMAN_ICID(FSL_DPAA1_STREAM_ID_START),
+   SET_BMAN_ICID(FSL_DPAA1_STREAM_ID_START + 1),
+#endif
+
+

[U-Boot] [PATCH v7 3/8] misc: fsl_portals: setup QMAN_BAR{E} also on ARM platforms

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

QMAN_BAR{E} register setup was disabled on ARM platforms, however the
register does need to be set. Enable the code also on ARMs and fix the
CONFIG_SYS_QMAN_MEM_PHYS define to the correct value so that the newly
enabled code works.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h | 3 +--
 drivers/misc/fsl_portals.c | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
index 644a16dd30..d22ec70aa5 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
@@ -57,8 +57,7 @@
 #define CONFIG_SYS_BMAN_SWP_ISDR_REG0x3E80
 #define CONFIG_SYS_QMAN_NUM_PORTALS10
 #define CONFIG_SYS_QMAN_MEM_BASE   0x5
-#define CONFIG_SYS_QMAN_MEM_PHYS   (0xfull + \
-   CONFIG_SYS_QMAN_MEM_BASE)
+#define CONFIG_SYS_QMAN_MEM_PHYS   CONFIG_SYS_QMAN_MEM_BASE
 #define CONFIG_SYS_QMAN_MEM_SIZE   0x0800
 #define CONFIG_SYS_QMAN_SP_CENA_SIZE0x1
 #define CONFIG_SYS_QMAN_SP_CINH_SIZE0x1
diff --git a/drivers/misc/fsl_portals.c b/drivers/misc/fsl_portals.c
index 7c22b8d209..22faf16751 100644
--- a/drivers/misc/fsl_portals.c
+++ b/drivers/misc/fsl_portals.c
@@ -24,7 +24,6 @@ void setup_qbman_portals(void)
CONFIG_SYS_BMAN_SWP_ISDR_REG;
void __iomem *qpaddr = (void *)CONFIG_SYS_QMAN_CINH_BASE +
CONFIG_SYS_QMAN_SWP_ISDR_REG;
-#ifdef CONFIG_PPC
struct ccsr_qman *qman = (void *)CONFIG_SYS_FSL_QMAN_ADDR;
 
/* Set the Qman initiator BAR to match the LAW (for DQRR stashing) */
@@ -32,7 +31,6 @@ void setup_qbman_portals(void)
out_be32(&qman->qcsp_bare, (u32)(CONFIG_SYS_QMAN_MEM_PHYS >> 32));
 #endif
out_be32(&qman->qcsp_bar, (u32)CONFIG_SYS_QMAN_MEM_PHYS);
-#endif
 #ifdef CONFIG_FSL_CORENET
int i;
 
-- 
2.17.1

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


[U-Boot] [PATCH v7 2/8] armv8: ls1046a: advertise QMan v3 in configuration

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

The QMan IP block in this SoC is version 3.2 so advertise
this in the SoC configuration header.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/include/asm/arch-fsl-layerscape/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h 
b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index 23faffd9fc..8a05148136 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -257,6 +257,7 @@
 
 #elif defined(CONFIG_ARCH_LS1046A)
 #define CONFIG_SYS_FMAN_V3
+#define CONFIG_SYS_FSL_QMAN_V3
 #define CONFIG_SYS_NUM_FMAN1
 #define CONFIG_SYS_NUM_FM1_DTSEC   8
 #define CONFIG_SYS_NUM_FM1_10GEC   2
-- 
2.17.1

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


[U-Boot] [PATCH v7 4/8] armv8: fsl-layerscape: add missing debug stream ID

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add a define with a value for the missing debug stream ID.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch2.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch2.h 
b/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch2.h
index 61c6e533c6..1b02d484d9 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch2.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/stream_id_lsch2.h
@@ -50,6 +50,7 @@
 #define FSL_QDMA_STREAM_ID 7
 #define FSL_EDMA_STREAM_ID 8
 #define FSL_ETR_STREAM_ID  9
+#define FSL_DEBUG_STREAM_ID10
 
 /* PCI - programmed in PEXn_LUT */
 #define FSL_PEX_STREAM_ID_START11
-- 
2.17.1

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


[U-Boot] [PATCH v7 7/8] armv8: ls1046a: setup fman ports ICIDs and device tree

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add support for ICID setting of fman ports and the required device
tree fixups.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/cpu/armv8/fsl-layerscape/icid.c  | 82 +++
 .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c | 30 +++
 .../asm/arch-fsl-layerscape/fsl_icid.h| 10 +++
 3 files changed, 122 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/icid.c 
b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
index ae3b8daa95..b1a950e7f9 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/icid.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static void set_icid(struct icid_id_table *tbl, int size)
 {
@@ -19,10 +20,27 @@ static void set_icid(struct icid_id_table *tbl, int size)
out_be32((u32 *)(tbl[i].reg_addr), tbl[i].reg);
 }
 
+#ifdef CONFIG_SYS_DPAA_FMAN
+void set_fman_icids(struct fman_icid_id_table *tbl, int size)
+{
+   int i;
+   ccsr_fman_t *fm = (void *)CONFIG_SYS_FSL_FM1_ADDR;
+
+   for (i = 0; i < size; i++) {
+   out_be32(&fm->fm_bmi_common.fmbm_ppid[tbl[i].port_id - 1],
+tbl[i].icid);
+   }
+}
+#endif
+
 void set_icids(void)
 {
/* setup general icid offsets */
set_icid(icid_tbl, icid_tbl_sz);
+
+#ifdef CONFIG_SYS_DPAA_FMAN
+   set_fman_icids(fman_icid_tbl, fman_icid_tbl_sz);
+#endif
 }
 
 int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 *ids, int num_ids)
@@ -75,6 +93,66 @@ int fdt_fixup_icid_tbl(void *blob, int smmu_ph,
return 0;
 }
 
+#ifdef CONFIG_SYS_DPAA_FMAN
+int get_fman_port_icid(int port_id, struct fman_icid_id_table *tbl,
+  const int size)
+{
+   int i;
+
+   for (i = 0; i < size; i++) {
+   if (tbl[i].port_id == port_id)
+   return tbl[i].icid;
+   }
+
+   return -1;
+}
+
+void fdt_fixup_fman_port_icid_by_compat(void *blob, int smmu_ph,
+   const char *compat)
+{
+   int noff, len, icid;
+   const u32 *prop;
+
+   noff = fdt_node_offset_by_compatible(blob, -1, compat);
+   while (noff > 0) {
+   prop = fdt_getprop(blob, noff, "cell-index", &len);
+   if (!prop) {
+   printf("WARNING missing cell-index for fman port\n");
+   continue;
+   }
+   if (len != 4) {
+   printf("WARNING bad cell-index size for fman port\n");
+   continue;
+   }
+
+   icid = get_fman_port_icid(fdt32_to_cpu(*prop),
+ fman_icid_tbl, fman_icid_tbl_sz);
+   if (icid < 0) {
+   printf("WARNING unknown ICID for fman port %d\n",
+  *prop);
+   continue;
+   }
+
+   fdt_set_iommu_prop(blob, noff, smmu_ph, (u32 *)&icid, 1);
+
+   noff = fdt_node_offset_by_compatible(blob, noff, compat);
+   }
+}
+
+void fdt_fixup_fman_icids(void *blob, int smmu_ph)
+{
+   static const char * const compats[] = {
+   "fsl,fman-v3-port-oh",
+   "fsl,fman-v3-port-rx",
+   "fsl,fman-v3-port-tx",
+   };
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(compats); i++)
+   fdt_fixup_fman_port_icid_by_compat(blob, smmu_ph, compats[i]);
+}
+#endif
+
 int fdt_get_smmu_phandle(void *blob)
 {
int noff, smmu_ph;
@@ -107,4 +185,8 @@ void fdt_fixup_icid(void *blob)
return;
 
fdt_fixup_icid_tbl(blob, smmu_ph, icid_tbl, icid_tbl_sz);
+
+#ifdef CONFIG_SYS_DPAA_FMAN
+   fdt_fixup_fman_icids(blob, smmu_ph);
+#endif
 }
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
index 80e1ceadc0..30c7d8d28a 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
@@ -43,3 +43,33 @@ struct icid_id_table icid_tbl[] = {
 };
 
 int icid_tbl_sz = ARRAY_SIZE(icid_tbl);
+
+#ifdef CONFIG_SYS_DPAA_FMAN
+struct fman_icid_id_table fman_icid_tbl[] = {
+   /* port id, icid */
+   SET_FMAN_ICID_ENTRY(0x02, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x03, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x04, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x05, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x06, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x07, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x08, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x09, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x0a, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x0b, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x0c, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x0d, FSL_DPAA1_STREAM_ID_END),
+   SET_FMAN_ICID_ENTRY(0x28, FSL_DPAA1_STR

[U-Boot] [PATCH v7 8/8] armv8: ls1046a: setup SEC ICIDs and fix up device tree

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add support for SEC ICID configuration and apply it for ls1046a.
Also add code to make the necessary device tree fixups.

Signed-off-by: Laurentiu Tudor 
---
 .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c | 14 +++
 .../asm/arch-fsl-layerscape/fsl_icid.h| 25 +++
 .../asm/arch-fsl-layerscape/immap_lsch2.h |  8 ++
 3 files changed, 47 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
index 30c7d8d28a..2da9adab5b 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
@@ -40,6 +40,20 @@ struct icid_id_table icid_tbl[] = {
SET_EDMA_ICID(FSL_EDMA_STREAM_ID),
SET_ETR_ICID(FSL_ETR_STREAM_ID),
SET_DEBUG_ICID(FSL_DEBUG_STREAM_ID),
+#ifdef CONFIG_FSL_CAAM
+   SET_SEC_QI_ICID(FSL_DPAA1_STREAM_ID_START + 2),
+   SET_SEC_JR_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 3),
+   SET_SEC_JR_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 4),
+   SET_SEC_JR_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 5),
+   SET_SEC_JR_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 6),
+   SET_SEC_RTIC_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 7),
+   SET_SEC_RTIC_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 8),
+   SET_SEC_RTIC_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 9),
+   SET_SEC_RTIC_ICID_ENTRY(3, FSL_DPAA1_STREAM_ID_START + 10),
+   SET_SEC_DECO_ICID_ENTRY(0, FSL_DPAA1_STREAM_ID_START + 11),
+   SET_SEC_DECO_ICID_ENTRY(1, FSL_DPAA1_STREAM_ID_START + 12),
+   SET_SEC_DECO_ICID_ENTRY(2, FSL_DPAA1_STREAM_ID_START + 13),
+#endif
 };
 
 int icid_tbl_sz = ARRAY_SIZE(icid_tbl);
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h 
b/arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h
index 5be50a17ab..a70c866651 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/fsl_icid.h
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 
 struct icid_id_table {
const char *compat;
@@ -82,6 +83,30 @@ void fdt_fixup_icid(void *blob);
 #define SET_FMAN_ICID_ENTRY(_port_id, streamid) \
{ .port_id = (_port_id), .icid = (streamid) }
 
+#define SET_SEC_QI_ICID(streamid) \
+   SET_ICID_ENTRY("fsl,sec-v4.0", streamid, \
+   (((streamid) << 16) | (streamid)), \
+   offsetof(ccsr_sec_t, qilcr_ls) + \
+   CONFIG_SYS_FSL_SEC_ADDR, \
+   CONFIG_SYS_FSL_SEC_ADDR)
+
+#define SET_SEC_JR_ICID_ENTRY(jr_num, streamid) \
+   SET_ICID_ENTRY("fsl,sec-v4.0-job-ring", streamid, \
+   (((streamid) << 16) | (streamid)), \
+   offsetof(ccsr_sec_t, jrliodnr[jr_num].ls) + \
+   CONFIG_SYS_FSL_SEC_ADDR, \
+   FSL_SEC_JR##jr_num##_BASE_ADDR)
+
+#define SET_SEC_DECO_ICID_ENTRY(deco_num, streamid) \
+   SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
+   offsetof(ccsr_sec_t, decoliodnr[deco_num].ls) + \
+   CONFIG_SYS_FSL_SEC_ADDR, 0)
+
+#define SET_SEC_RTIC_ICID_ENTRY(rtic_num, streamid) \
+   SET_ICID_ENTRY(NULL, streamid, (((streamid) << 16) | (streamid)), \
+   offsetof(ccsr_sec_t, rticliodnr[rtic_num].ls) + \
+   CONFIG_SYS_FSL_SEC_ADDR, 0)
+
 extern struct icid_id_table icid_tbl[];
 extern struct fman_icid_id_table fman_icid_tbl[];
 extern int icid_tbl_sz;
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
index d22ec70aa5..be0a6ae363 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
@@ -200,10 +200,18 @@ struct sys_info {
 
 #define CONFIG_SYS_FSL_SEC_OFFSET  0x70ull
 #define CONFIG_SYS_FSL_JR0_OFFSET  0x71ull
+#define FSL_SEC_JR0_OFFSET CONFIG_SYS_FSL_JR0_OFFSET
+#define FSL_SEC_JR1_OFFSET 0x72ull
+#define FSL_SEC_JR2_OFFSET 0x73ull
+#define FSL_SEC_JR3_OFFSET 0x74ull
 #define CONFIG_SYS_FSL_SEC_ADDR \
(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_SEC_OFFSET)
 #define CONFIG_SYS_FSL_JR0_ADDR \
(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_JR0_OFFSET)
+#define FSL_SEC_JR0_BASE_ADDR (CONFIG_SYS_IMMR + FSL_SEC_JR0_OFFSET)
+#define FSL_SEC_JR1_BASE_ADDR (CONFIG_SYS_IMMR + FSL_SEC_JR1_OFFSET)
+#define FSL_SEC_JR2_BASE_ADDR (CONFIG_SYS_IMMR + FSL_SEC_JR2_OFFSET)
+#define FSL_SEC_JR3_BASE_ADDR (CONFIG_SYS_IMMR + FSL_SEC_JR3_OFFSET)
 
 /* Device Configuration and Pin Control */
 #define DCFG_DCSR_PORCR1   0x0
-- 
2.17.1

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


[U-Boot] [PATCH v7 6/8] armv8: ls1046a: add icid setup for qman portals

2018-08-08 Thread laurentiu . tudor
From: Laurentiu Tudor 

Add support for ICID setting of qman portals and the required device
tree fixups. Also fix an endiness issue in portal setup code.

Signed-off-by: Laurentiu Tudor 
---
 .../arm/cpu/armv8/fsl-layerscape/ls1046_ids.c | 16 +++
 .../asm/arch-fsl-layerscape/fsl_portals.h | 24 +++
 drivers/misc/fsl_portals.c| 42 +++
 3 files changed, 75 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-fsl-layerscape/fsl_portals.h

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c 
b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
index 1c528ab751..80e1ceadc0 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1046_ids.c
@@ -6,6 +6,22 @@
 #include 
 #include 
 #include 
+#include 
+
+#ifdef CONFIG_SYS_DPAA_QBMAN
+struct qportal_info qp_info[CONFIG_SYS_QMAN_NUM_PORTALS] = {
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+   SET_QP_INFO(FSL_DPAA1_STREAM_ID_END, 0),
+};
+#endif
 
 struct icid_id_table icid_tbl[] = {
 #ifdef CONFIG_SYS_DPAA_QBMAN
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/fsl_portals.h 
b/arch/arm/include/asm/arch-fsl-layerscape/fsl_portals.h
new file mode 100644
index 00..1577e935a6
--- /dev/null
+++ b/arch/arm/include/asm/arch-fsl-layerscape/fsl_portals.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 NXP
+ */
+
+#ifndef _FSL_PORTALS_H_
+#define _FSL_PORTALS_H_
+
+struct qportal_info {
+   u16 dicid;  /* DQRR ICID */
+   u16 ficid;  /* frame data ICID */
+   u16 icid;
+   u8  sdest;
+};
+
+#define SET_QP_INFO(streamid, dest) \
+   { .dicid = (streamid), .ficid = (streamid), .icid = (streamid), \
+   .sdest = (dest) }
+
+extern struct qportal_info qp_info[];
+void fdt_portal(void *blob, const char *compat, const char *container,
+   u64 addr, u32 size);
+
+#endif
diff --git a/drivers/misc/fsl_portals.c b/drivers/misc/fsl_portals.c
index 22faf16751..fc4f0f6696 100644
--- a/drivers/misc/fsl_portals.c
+++ b/drivers/misc/fsl_portals.c
@@ -13,6 +13,9 @@
 #ifdef CONFIG_PPC
 #include 
 #include 
+#else
+#include 
+#include 
 #endif
 #include 
 
@@ -45,6 +48,22 @@ void setup_qbman_portals(void)
/* set frame liodn */
out_be32(&qman->qcsp[i].qcsp_io_cfg, (sdest << 16) | fliodn);
}
+#else
+#ifdef CONFIG_ARM
+   int i;
+
+   for (i = 0; i < CONFIG_SYS_QMAN_NUM_PORTALS; i++) {
+   u8 sdest = qp_info[i].sdest;
+   u16 ficid = qp_info[i].ficid;
+   u16 dicid = qp_info[i].dicid;
+   u16 icid = qp_info[i].icid;
+
+   out_be32(&qman->qcsp[i].qcsp_lio_cfg, (icid << 16) |
+   dicid);
+   /* set frame icid */
+   out_be32(&qman->qcsp[i].qcsp_io_cfg, (sdest << 16) | ficid);
+   }
+#endif
 #endif
 
/* Change default state of BMan ISDR portals to all 1s */
@@ -178,6 +197,10 @@ void fdt_fixup_qportals(void *blob)
char compat[64];
int compat_len;
 
+#ifndef CONFIG_PPC
+   int smmu_ph = fdt_get_smmu_phandle(blob);
+#endif
+
maj = (rev_1 >> 8) & 0xff;
min = rev_1 & 0xff;
ip_cfg = rev_2 & 0xff;
@@ -188,9 +211,9 @@ void fdt_fixup_qportals(void *blob)
 
off = fdt_node_offset_by_compatible(blob, -1, "fsl,qman-portal");
while (off != -FDT_ERR_NOTFOUND) {
-#ifdef CONFIG_PPC
 #ifdef CONFIG_FSL_CORENET
u32 liodns[2];
+   int j;
 #endif
const int *ci = fdt_getprop(blob, off, "cell-index", &err);
int i;
@@ -198,12 +221,7 @@ void fdt_fixup_qportals(void *blob)
if (!ci)
goto err;
 
-   i = *ci;
-#ifdef CONFIG_SYS_DPAA_FMAN
-   int j;
-#endif
-
-#endif /* CONFIG_PPC */
+   i = fdt32_to_cpu(*ci);
err = fdt_setprop(blob, off, "compatible", compat, compat_len);
if (err < 0)
goto err;
@@ -251,6 +269,16 @@ void fdt_fixup_qportals(void *blob)
if (err < 0)
goto err;
 #endif
+#else
+   if (smmu_ph >= 0) {
+   u32 icids[3];
+
+   icids[0] = qp_info[i].icid;
+   icids[1] = qp_info[i].dicid;
+   icids[2] = qp_info[i].ficid;
+
+   fdt_set_iommu_prop(blob, off, smmu_ph, icids, 3);
+   }
 #endif /* CONFIG_PPC */
 
 err:
-- 
2.17.1

_

Re: [U-Boot] [RESEND PATCH V2 3/3] imx: mx7: add system suspend/resume support

2018-08-08 Thread Anson Huang
Hi, Stefan

Anson Huang
Best Regards!


> -Original Message-
> From: Stefan Agner [mailto:ste...@agner.ch]
> Sent: Wednesday, August 8, 2018 5:03 PM
> To: Anson Huang 
> Cc: sba...@denx.de; Fabio Estevam ;
> albert.u.b...@aribaud.net; bryan.odonog...@linaro.org;
> uri.mashi...@compulab.co.il; Stefan Agner ;
> Peng Fan ; Ye Li ; s...@chromium.org;
> u-boot@lists.denx.de; dl-linux-imx 
> Subject: Re: [U-Boot] [RESEND PATCH V2 3/3] imx: mx7: add system
> suspend/resume support
> 
> Hi Anson,
> 
> On 08.08.2018 03:17, Anson Huang wrote:
> > This patch adds system suspend/resume support, when linux kernel
> > enters deep sleep mode, SoC will go into below mode:
> >
> >  - CA7 platform goes into STOP mode;
> >  - SoC goes into DSM mode;
> >  - DDR goes into self-refresh mode;
> >  - CPU0/SCU will be powered down.
> >
> > When wake up event arrives:
> >
> >  - SoC DSM mdoe exits;
> >  - CA7 platform exit STOP mode, SCU/CPU0 power up;
> >  - Invalidate L1 cache;
> >  - DDR exit self-refresh mode;
> >  - Do secure monitor mode related initialization;
> >  - Jump to linux kernel resume entry.
> >
> > Belwo is the log of 1 iteration of system suspend/resume:
> >
> > [  338.824862] PM: suspend entry (deep) [  338.828853] PM: Syncing
> > filesystems ... done.
> > [  338.834433] Freezing user space processes ... (elapsed 0.001 seconds)
> done.
> > [  338.842939] OOM killer disabled.
> > [  338.846182] Freezing remaining freezable tasks ... (elapsed 0.001
> > seconds) done.
> > [  338.869717] PM: suspend devices took 0.010 seconds [  338.877846]
> > Disabling non-boot CPUs ...
> > [  338.960301] Retrying again to check for CPU kill [  338.964953]
> > CPU1 killed.
> > [  338.968104] Enabling non-boot CPUs ...
> > [  338.973598] CPU1 is up
> > [  339.267155] mmc1: queuing unknown CIS tuple 0x80 (2 bytes) [
> > 339.275833] mmc1: queuing unknown CIS tuple 0x80 (7 bytes) [
> > 339.284158] mmc1: queuing unknown CIS tuple 0x80 (6 bytes) [
> > 339.385065] PM: resume devices took 0.400 seconds [  339.389836] OOM
> > killer enabled.
> > [  339.392986] Restarting tasks ... done.
> > [  339.398990] PM: suspend exit
> 
> Gave this a try with a 3.18-rc6 kernel today on our Colibri iMX7, I could
> successfully suspend and resume using RTC wakealarm.
> 
> What is a bit weird is that sometimes the SoC seems to consume more power
> than other times (sometimes 135mW, sometimes 60mW). Any idea where that
> could come from?
> 
> In any case, the system seems to wakeup just fine.
 
I ONLY tried the function with latest 4.18 kernel and did NOT measure the 
power, if the power you saw
is a board level total power, then I have no idea, maybe you can disable all 
peripheral devices
in dtb to have another try, could be some peripherals' different state 
consuming different 
power, if you can break down the power rails to VDD_ARM, VDD_SOC and VDDA_1P8,
then I think you should be able to see the benefit, and from each power rails' 
number,
maybe we can figure out why, but I think this patch set is mainly for function 
level, for
power number optimization, we can have patch later, I think.

Noted that latest kernel's PCIe driver has resume issue, you have to disable 
PCIe if using 4.18 kernel.
I suggest you to break down power rails first.

Anson.
> 
> --
> Stefan
> 
> >
> > The resume entry function has to initialize stack pointer before
> > calling C code, otherwise there will be an external abort occur, in
> > additional, invalidate L1 cache must be done in secure section as
> > well, so this patch also adds assembly code back and keep it as simple as
> possible.
> >
> > Signed-off-by: Anson Huang 
> > ---
> >  arch/arm/mach-imx/mx7/Makefile   |   2 +-
> >  arch/arm/mach-imx/mx7/psci-mx7.c | 449
> ++-
> >  arch/arm/mach-imx/mx7/psci-suspend.S |  67 ++
> >  3 files changed, 515 insertions(+), 3 deletions(-)  create mode
> > 100644 arch/arm/mach-imx/mx7/psci-suspend.S
> >
> > diff --git a/arch/arm/mach-imx/mx7/Makefile
> > b/arch/arm/mach-imx/mx7/Makefile index 94a0e64..f1436e2 100644
> > --- a/arch/arm/mach-imx/mx7/Makefile
> > +++ b/arch/arm/mach-imx/mx7/Makefile
> > @@ -4,4 +4,4 @@
> >  #
> >
> >  obj-y  := soc.o clock.o clock_slice.o ddr.o snvs.o
> > -obj-$(CONFIG_ARMV7_PSCI)  += psci-mx7.o
> > +obj-$(CONFIG_ARMV7_PSCI)  += psci-mx7.o psci-suspend.o
> > diff --git a/arch/arm/mach-imx/mx7/psci-mx7.c
> > b/arch/arm/mach-imx/mx7/psci-mx7.c
> > index d6c4263..34ba0a9 100644
> > --- a/arch/arm/mach-imx/mx7/psci-mx7.c
> > +++ b/arch/arm/mach-imx/mx7/psci-mx7.c
> > @@ -8,20 +8,77 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> >
> > -#define GPC_CPU_PGC_SW_PDN_REQ 0xfc
> > +#define GPC_LPCR_A7_BSC0x0
> > +#define GPC_LPCR_A7_AD 0x4
> > +#define GPC_SLPCR  0x14
> > +#define GPC_PGC_ACK_SEL_A7 0x24
> > +#define GPC_IMR1_CORE0 0x30
> > +#define GPC_SLOT0_CFG  0xb0
> >  #def

Re: [U-Boot] [PATCH v6 00/27] SPI-NAND support

2018-08-08 Thread Miquel Raynal
Hi Daniel,

Daniel Schwierzeck  wrote on Tue, 7 Aug
2018 16:39:34 +0200:

> 2018-08-04 9:23 GMT+02:00 Miquel Raynal :
> > Hi Jagan,
> >
> > Jagan Teki  wrote on Fri, 3 Aug 2018
> > 17:38:33 +0530:
> >  
> >> On Fri, Aug 3, 2018 at 3:20 PM, Jagan Teki  
> >> wrote:  
> >> > On Fri, Aug 3, 2018 at 1:57 PM, Miquel Raynal 
> >> >  wrote:  
> >> >> Hi Jagan, Tom,
> >> >>
> >> >> Miquel Raynal  wrote on Wed,  1 Aug 2018
> >> >> 10:18:21 +0200:
> >> >>  
> >> >>> During the last months, Boris Brezillon shared his work to support
> >> >>> serial flashes within Linux. First, he delivered (and merged) a new
> >> >>> layer called spi-mem. He also initiated in Linux MTD subsystem the move
> >> >>> of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> >> >>> same time a NAND core that would be shared with all NAND devices. Then,
> >> >>> he contributed a generic SPI-NAND driver, making use of this NAND core,
> >> >>> as well as some vendor code to drive a few chips.
> >> >>>
> >> >>> On top of this work, I added an 'mtd' U-Boot command to handle all sort
> >> >>> of MTD devices. This should become the default command instead of 
> >> >>> having
> >> >>> one per flash flavor ('sf', 'nand', 'spi-nand' ?).
> >> >>>
> >> >>> The series has been tested on an Ocelot board PCB123 (VSC7514),
> >> >>> featuring a Macronix SPI NAND chip.
> >> >>>
> >> >>> TL;DR: the series contains:
> >> >>> - A few patches from Linux to resynchronize some areas of the MTD 
> >> >>> layer.
> >> >>> - Various fixes and re-organization of the MTD subsystem.
> >> >>> - The introduction of the SPI-mem interface.
> >> >>> - The addition of the generic SPI-NAND driver (and its bindings).
> >> >>> - Several SPI NAND chip drivers (Macronix, Micron, Winbond).
> >> >>> - A new 'mtd' command.
> >> >>> - Support for spi-nand devices in mtdparts.
> >> >>>
> >> >>> To test your SPI-NAND device with U-Boot simply follow these lines:
> >> >>>  
> >> >>> > setenv mtdparts mtdparts=spi-nand0:1m(foo),-(bar)
> >> >>> > setenv mtdids spi-nand0=spi-nand0
> >> >>> > mtdparts # show the spi-nand device partitions
> >> >>> > ubi part bar # create a static UBI volume in the bar 
> >> >>> > partition  
> >> >>>
> >> >>> Thanks,
> >> >>> Miquèl
> >> >>>
> >> >>> Changes since v5:
> >> >>> -
> >> >>> * Included Boris fixup about the build issues.
> >> >>> * Added Rb/Ab tags from Jagan on patchs 20/21.  
> >> >>
> >> >> I can't see a pull request flow on U-Boot ML, I suppose you use a
> >> >> different mean for that purpose.
> >> >>
> >> >> Jagan, is this version OK? Is it part of your PR?  
> >> >
> >> > Travis is going on [1], will send PR once all fine.
> >> >
> >> > [1] https://travis-ci.org/openedev/u-boot-amarula/builds/411596788  
> >>
> >> There are some build issues, not quite sure whether it relates. please
> >> look into it.  
> >
> > Thanks for the reports.
> >  
> >>
> >> [2] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596814
> >> [3] https://travis-ci.org/openedev/u-boot-amarula/jobs/411596815  
> >
> > Boris supposedly fixed all the build issues related to my changes (I
> > don't think the "missing interrupt parent" in a DTS file is related),
> > please pull his branch [1].  
> 
> the DTS warnings are unrelated and can be ignored. Only the onenand_*
> stuff seems
> to be a regression.

OneNAND warnings should be gone with Boris fixups.

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Eugeniu Rosca
Hello,

FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
driver from the command line" contributes with a compiler warning, as
described in https://patchwork.ozlabs.org/patch/933310/#1952127 .

Best regards,
Eugeniu.
On Wed, Aug 8, 2018 at 8:36 AM Michal Simek  wrote:
>
> Hi Lukasz,
>
> On 22.6.2018 14:25, Jean-Jacques Hiblot wrote:
> >
> > This series implements 2 fixes to be able to use USB Ethernet gadget with 
> > the dwc3
> > driver.
> > It also adds new commands to bind/unbind a device to/from a driver and
> > update the 'dm tree' command to make it easier to use those new commands.
> > The bind/unbind commands can be used to bind the DWC3 USB gadget to the
> > usb_ether driver from the command line instead of relying on platform code.
> >
> > Changes in v3:
> > - update some commit logs
> > - factorize code based on comments from ML
> > - remove the devices before unbinding them
> > - use device_find_global_by_ofnode() to get a device by its node.
> >
> > Changes in v2:
> > - Make the bind/unbind command generic, not specific to usb device.
> > - Update the API to be able to bind/unbind based on DTS node path
> > - Add a Kconfig option to select the bind/unbind commands
> >
> > Jean-Jacques Hiblot (7):
> >   usb: gadget: Add bcdDevice for the DWC3 USB Gadget Controller
> >   net: eth-uclass: Fix for DM USB ethernet support
> >   uclass: Add dev_get_uclass_index() to get the uclass/index of a device
> >   dm: print the index of the device when dumping the dm tree
> >   dm: convert device_get_global_by_of_offset() to
> > device_get_global_by_ofnode()
> >   device: expose the functions used to remove and unbind children of a
> > device
> >   cmd: Add bind/unbind commands to bind a device to a driver from the
> > command line
> >
> >  arch/arm/mach-rockchip/rk3188-board-spl.c |   2 +-
> >  arch/arm/mach-rockchip/rk3288-board-spl.c |   2 +-
> >  arch/sandbox/dts/test.dts |  11 ++
> >  cmd/Kconfig   |   9 ++
> >  cmd/Makefile  |   1 +
> >  cmd/bind.c| 255 
> > ++
> >  configs/sandbox_defconfig |   1 +
> >  drivers/core/device-remove.c  |  30 ++--
> >  drivers/core/device.c |  19 ++-
> >  drivers/core/dump.c   |  16 +-
> >  drivers/core/uclass.c |  21 +++
> >  drivers/usb/gadget/gadget_chips.h |   2 +
> >  include/dm/device-internal.h  |  38 +
> >  include/dm/device.h   |  23 ++-
> >  include/dm/uclass-internal.h  |  11 ++
> >  net/eth-uclass.c  |   3 +-
> >  test/py/tests/test_bind.py| 178 +
> >  17 files changed, 584 insertions(+), 38 deletions(-)
> >  create mode 100644 cmd/bind.c
> >  create mode 100644 test/py/tests/test_bind.py
> >
>
> Lukasz: I see your name in patchwork.
> Are you going to take this series? Or we are waiting for sandbox testing?
>
> Thanks,
> Michal
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 00/18] efi: Enable sandbox support for EFI loader

2018-08-08 Thread Simon Glass
A limitation of the EFI loader at present is that it does not build with
sandbox. This makes it hard to write tests, since sandbox is used for most
testing in U-Boot.

This series enables the EFI loader feature. It allows sandbox to build and
run a trivial function which calls the EFI API to output a message.

Also included in v8 is support for running the full EFI self tests. These
run OK with some tweaks to a few parts of the code.

With v9, various EFI patches have been applied which change things. This
series includes a partial review of one, which makes 'bootefi test' work.
But there are still problems with 'bootefi selftest':

$ sandbox/u-boot -D -c "bootefi selftest"
...
Executing 'block device'
/home/sjg/c/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_block_device.c(385):
TODO: Wrong volume label 'xxa1', expected 'U-BOOT TEST'
map_to_sysmem: Added map from 7ffd0782d2a0 to 800
phys_to_virt: Used map from 800 to 7ffd0782d2a0
writing /u-boot.txt
find_tag: Used map from 7ffd0782d2a0 to 800
phys_to_virt: Used map from 800 to 7ffd0782d2a0
/home/sjg/c/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_block_device.c(458):
ERROR: Unexpected file content
/home/sjg/c/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest.c(109):
ERROR: Executing 'block device' failed

...

Executing 'simple network protocol'
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
DHCP Discover
/home/sjg/c/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest_snp.c(311):
ERROR: Timeout occurred
/home/sjg/c/src/third_party/u-boot/files/lib/efi_selftest/efi_selftest.c(109):
ERROR: Executing 'simple network protocol' failed

This series is at u-boot-dm/efi-working

Changes in v9:
- Add comments to bootefi_test_prepare() about the memset()s
- Add revert for "efi_loader: Rename sections to allow for implicit data"
- Drop fdt_end variable in efi_install_fdt()
- Fix 'thi' typo

Changes in v8:
- Drop 'efi: Adjust memory handling to support sandbox'
- Drop 'efi: sandbox: Add relocation constants'
- Drop 'sandbox: smbios: Update to support sandbox'
- Expand series substantially to support bootefi selftest
- Rebase to master
- Rebase to master, bringing in all EFI changes

Changes in v7:
- Drop an unnecessary comment
- Drop patch "efi: Init the 'rows' and 'cols' variables"
- Drop patches previous applied
- Update patch subject s/builder/build/

Changes in v6:
- Warn about building sandbox EFI support on something other than __x86_64__

Changes in v5:
- Add new patch to disallow CMD_BOOTEFI_SELFTEST on sandbox
- Drop call to efi_init_obj_list() which is now done in do_bootefi()
- Introduce load_options_path to specifyc U-Boot env var for load_options_path
- Rebase to master

Changes in v4:
- Rebase to master
- Update SPDX tags

Changes in v3:
- Add new patch to rename bootefi_test_finish() to bootefi_run_finish()
- Add new patch to split out test init/uninit into functions
- Add patch to create a function to set up for running EFI code
- Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)
- Rebase to master

Changes in v2:
- Rebase to master

Alexander Graf (1):
  efi_loader: Pass address to fs_read()

Simon Glass (17):
  Revert "efi_loader: Rename sections to allow for implicit data"
  efi: Don't allow CMD_BOOTEFI_SELFTEST on sandbox
  efi: sandbox: Add distroboot support
  efi: sandbox: Enable EFI loader build for sandbox
  efi: Split out test init/uninit into functions
  efi: sandbox: Add a simple 'bootefi test' command
  efi: Create a function to set up for running EFI code
  efi: Rename bootefi_test_finish() to bootefi_run_finish()
  sandbox: Align RAM buffer to the machine page size
  sandbox: Try to start the RAM buffer at a particular address
  sandbox: Add support for calling abort()
  sandbox: Enhance map_to_sysmem() to handle foreign pointers
  efi: Add a call to exit() along with why we can't use it
  efi: Relocate FDT to 127MB instead of 128MB
  efi: sandbox: Tidy up copy_fdt() to work with sandbox
  efi: Add more debugging for memory allocations
  efi: sandbox: Enable selftest command

 arch/sandbox/config.mk   |   3 -
 arch/sandbox/cpu/cpu.c   | 141 --
 arch/sandbox/cpu/os.c|  17 ++-
 arch/sandbox/cpu/state.c |   8 +
 arch/sandbox/cpu/u-boot.lds  |   9 +-
 arch/sandbox/include/asm/state.h |  21 +++
 cmd/bootefi.c| 242 +--
 configs/sandbox_defconfig|   1 +
 include/config_distro_bootcmd.h  |  11 ++
 include/efi_loader.h |   3 +
 include/os.h |   4 +
 lib/efi_loader/Kconfig   |  12 +-
 lib/efi_loader/Makefile  |   1 +
 lib/efi_loader/efi_boottime.c|  15 ++
 lib/efi_loader/efi_file.c|   5 +-
 lib/efi_loader/efi_memory.c  |  22 ++-
 lib/efi_loader/efi_test.c|  26 
 17 files changed, 439 insertio

[U-Boot] [PATCH v9 02/18] efi: Don't allow CMD_BOOTEFI_SELFTEST on sandbox

2018-08-08 Thread Simon Glass
This does not work at present and gives the following error:

output: 'ld.bfd: read in flex scanner failed
scripts/Makefile.lib:390: recipe for target 
'lib/efi_selftest/efi_selftest_miniapp_return_efi.so' failed

It may be possible to figure this out with suitable linker magic but it
does not seem to be easy. Also, we will be able to run the tests on
sandbox without using the miniapp.

So for now at least, disable this option.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5:
- Add new patch to disallow CMD_BOOTEFI_SELFTEST on sandbox

Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/efi_selftest/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig
index 59f9f36801c..b52696778dd 100644
--- a/lib/efi_selftest/Kconfig
+++ b/lib/efi_selftest/Kconfig
@@ -1,6 +1,6 @@
 config CMD_BOOTEFI_SELFTEST
bool "Allow booting an EFI efi_selftest"
-   depends on CMD_BOOTEFI
+   depends on CMD_BOOTEFI && !SANDBOX
imply FAT
imply FAT_WRITE
help
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 01/18] Revert "efi_loader: Rename sections to allow for implicit data"

2018-08-08 Thread Simon Glass
This partially reverts commit 7e21fbca26d18327cf7cabaad08df276a06a07d8.

That change broke sandbox EFI support for unknown reasons. It also changes
sandbox to use--gc-sections which we don't want.

For now I am just reverting the sandbox portion as presumably this change
is safe on other architectures.

Fixes: 7e21fbca26 (efi_loader: Rename sections to allow for implicit data)
Signed-off-by: Simon Glass 
---

Changes in v9:
- Add revert for "efi_loader: Rename sections to allow for implicit data"

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/config.mk  | 3 ---
 arch/sandbox/cpu/u-boot.lds | 9 -
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 5e7077bfe75..2babcde8815 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -5,9 +5,6 @@ PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM
 PLATFORM_LIBS += -lrt
 
-LDFLAGS_FINAL += --gc-sections
-PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
-
 # Define this to avoid linking with SDL, which requires SDL libraries
 # This can solve 'sdl-config: Command not found' errors
 ifneq ($(NO_SDL),)
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 727bcc35981..3a6cf55eb99 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -24,9 +24,8 @@ SECTIONS
}
 
.efi_runtime : {
-   *(.text.efi_runtime*)
-   *(.rodata.efi_runtime*)
-   *(.data.efi_runtime*)
+   *(efi_runtime_text)
+   *(efi_runtime_data)
}
 
.__efi_runtime_stop : {
@@ -39,8 +38,8 @@ SECTIONS
}
 
.efi_runtime_rel : {
-   *(.rel*.efi_runtime)
-   *(.rel*.efi_runtime.*)
+   *(.relefi_runtime_text)
+   *(.relefi_runtime_data)
}
 
.efi_runtime_rel_stop :
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 03/18] efi: sandbox: Add distroboot support

2018-08-08 Thread Simon Glass
With sandbox these values depend on the host system. Let's assume that it
is x86_64 for now.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7:
- Drop an unnecessary comment

Changes in v6:
- Warn about building sandbox EFI support on something other than __x86_64__

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

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

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index d672e8ebe65..75866f2abf9 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -261,6 +261,17 @@
 #elif defined(CONFIG_CPU_RISCV_64)
 #define BOOTENV_EFI_PXE_ARCH "0x1b"
 #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000"
+#elif defined(CONFIG_SANDBOX)
+/*
+ * TODO(s...@chromium.org): Consider providing a way to enable sandbox features
+ * based on the host architecture
+ */
+# ifndef __x86_64__
+#  warning "sandbox EFI support is only tested on 64-bit x86"
+# endif
+/* To support other *host* architectures this should be changed */
+#define BOOTENV_EFI_PXE_ARCH "0x7"
+#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:7:UNDI:003000"
 #else
 #error Please specify an EFI client identifier
 #endif
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 13/18] efi: Add a call to exit() along with why we can't use it

2018-08-08 Thread Simon Glass
The test should exit like any other EFI application, by calling exit()
in the boot services API. But this crashes at present on sandbox. For now,
add in the placeholder code.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/efi_loader/efi_test.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_test.c b/lib/efi_loader/efi_test.c
index 4b8d49f324b..5401a0f4715 100644
--- a/lib/efi_loader/efi_test.c
+++ b/lib/efi_loader/efi_test.c
@@ -9,8 +9,18 @@
 int efi_test(efi_handle_t image_handle, struct efi_system_table *systable)
 {
struct efi_simple_text_output_protocol *con_out = systable->con_out;
+   struct efi_boot_services *boottime = systable->boottime;
+   int ret;
 
-   con_out->output_string(con_out, L"Hello, world!\n");
+   ret = con_out->output_string(con_out, L"Hello, world!\n");
+
+   /*
+* We should really call EFI's exit() here but this crashes at present
+* on sandbox due to the incorrect use of setjmp() and longjmp(). Once
+* we can figure out how to make that work, this can be enabled.
+*/
+   if (0)
+   boottime->exit(image_handle, ret, 0, NULL);
 
return 0;
 }
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 04/18] efi: sandbox: Enable EFI loader build for sandbox

2018-08-08 Thread Simon Glass
This allows this feature to build within sandbox. This is for testing
purposes only since it is not possible for sandbox to load native code.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7:
- Update patch subject s/builder/build/

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Init the 'rows' and 'cols' vars to avoid a compiler error (gcc 4.8.4)

Changes in v2: None

 lib/efi_loader/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index ce6a09f0b43..bfd7b19d791 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -1,6 +1,6 @@
 config EFI_LOADER
bool "Support running EFI Applications in U-Boot"
-   depends on (ARM || X86 || RISCV) && OF_LIBFDT
+   depends on (ARM || X86 || RISCV || SANDBOX) && OF_LIBFDT
# We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB
depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT
# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 14/18] efi: Relocate FDT to 127MB instead of 128MB

2018-08-08 Thread Simon Glass
Sandbox only has 128MB of memory so we cannot relocate the device tree up
to start at 128MB. Use 127MB instead, which should be safe.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/bootefi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 905e659da42..6481444cca6 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -158,8 +158,8 @@ static void *copy_fdt(void *fdt)
fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE);
fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
 
-   /* Safe fdt location is at 128MB */
-   new_fdt_addr = fdt_ram_start + (128 * 1024 * 1024) + fdt_size;
+   /* Safe fdt location is at 127MB */
+   new_fdt_addr = fdt_ram_start + (127 * 1024 * 1024) + fdt_size;
if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
   EFI_RUNTIME_SERVICES_DATA, fdt_pages,
   &new_fdt_addr) != EFI_SUCCESS) {
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 05/18] efi: Split out test init/uninit into functions

2018-08-08 Thread Simon Glass
We plan to run more than one EFI test. In order to avoid duplicating code,
create functions which handle preparing for running the test and cleaning
up afterwards.

Also shorten the awfully long variable names here.

Signed-off-by: Simon Glass 
---

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

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

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

Changes in v2: None

 cmd/bootefi.c | 91 +--
 1 file changed, 67 insertions(+), 24 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index b60c151fb4a..af13492836d 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -409,6 +409,64 @@ exit:
return ret;
 }
 
+#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
+/**
+ * bootefi_test_prepare() - prepare to run an EFI test
+ *
+ * This sets things up so we can call EFI functions. This involves preparing
+ * the 'gd' pointer and setting up the load ed image data structures.
+ *
+ * @image: Pointer to a struct which will hold the loaded image info.
+ *This struct will be inited by this function before use.
+ * @obj: Pointer to a struct which will hold the loaded image object
+ *This struct will be inited by this function before use.
+ * @path: File path to the test being run (often just the test name with a
+ *backslash before it
+ * @test_func: Address of the test function that is being run
+ * @return 0 if OK, -ve on error
+ */
+static efi_status_t bootefi_test_prepare(struct efi_loaded_image *image,
+struct efi_object *obj,
+const char *path, ulong test_func)
+{
+   /* Zero out the structures since the caller did not */
+   memset(image, '\0', sizeof(*image));
+   memset(obj, '\0', sizeof(*obj));
+
+   /* Construct a dummy device path */
+   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
+ (uintptr_t)test_func,
+ (uintptr_t)test_func);
+   bootefi_image_path = efi_dp_from_file(NULL, 0, path);
+   efi_setup_loaded_image(image, obj, bootefi_device_path,
+  bootefi_image_path);
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+
+   /* Transfer environment variable efi_selftest as load options */
+   set_load_options(image, "efi_selftest");
+
+   return 0;
+}
+
+/**
+ * bootefi_test_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_test_finish(struct efi_loaded_image *image,
+   struct efi_object *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   list_del(&obj->link);
+}
+#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
+
 static int do_bootefi_bootmgr_exec(void)
 {
struct efi_device_path *device_path, *file_path;
@@ -489,31 +547,16 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
 #endif
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   struct efi_loaded_image loaded_image_info = {};
-   struct efi_object loaded_image_info_obj = {};
-
-   /* Construct a dummy device path. */
-   bootefi_device_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
- (uintptr_t)&efi_selftest,
- (uintptr_t)&efi_selftest);
-   bootefi_image_path = efi_dp_from_file(NULL, 0, "\\selftest");
-
-   efi_setup_loaded_image(&loaded_image_info,
-  &loaded_image_info_obj,
-  bootefi_device_path, bootefi_image_path);
-   /*
-* gd lives in a fixed register which may get clobbered while we
-* execute the payload. So save it here and restore it on every
-* callback entry
-*/
-   efi_save_gd();
-   /* Transfer environment variable efi_selftest as load options */
-   set_load_options(&loaded_image_info, "efi_selftest");
+   struct efi_loaded_image image;
+   struct efi_object obj;
+
+   if (bootefi_test_prepare(&image, &obj, "\\selftest",
+(uintptr_t)&efi_selftest))
+   return CMD_RET_FAILURE;
+
/* Execute the test */
-   r = efi_selfte

[U-Boot] [PATCH v9 07/18] efi: Create a function to set up for running EFI code

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

Also shorten a few variable names.

Signed-off-by: Simon Glass 
---

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

Changes in v4:
- Rebase to master

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

Changes in v2: None

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

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index edb7f786a27..54732ba3f37 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -290,6 +290,26 @@ static efi_status_t efi_install_fdt(void *fdt)
return ret;
 }
 
+static efi_status_t bootefi_run_prepare(struct efi_loaded_image *image,
+   struct efi_object *obj,
+   const char *load_options_path,
+   struct efi_device_path *device_path,
+   struct efi_device_path *image_path)
+{
+   efi_setup_loaded_image(image, obj, device_path, image_path);
+
+   /*
+* gd lives in a fixed register which may get clobbered while we execute
+* the payload. So save it here and restore it on every callback entry
+*/
+   efi_save_gd();
+
+   /* Transfer environment variable as load options */
+   set_load_options(image, load_options_path);
+
+   return 0;
+}
+
 /*
  * Load an EFI payload into a newly allocated piece of memory, register all
  * EFI objects it would want to access and jump to it.
@@ -298,8 +318,8 @@ static efi_status_t do_bootefi_exec(void *efi,
struct efi_device_path *device_path,
struct efi_device_path *image_path)
 {
-   struct efi_loaded_image loaded_image_info = {};
-   struct efi_object loaded_image_info_obj = {};
+   struct efi_loaded_image image;
+   struct efi_object obj;
struct efi_object mem_obj = {};
struct efi_device_path *memdp = NULL;
efi_status_t ret;
@@ -327,19 +347,13 @@ static efi_status_t do_bootefi_exec(void *efi,
assert(device_path && image_path);
}
 
-   efi_setup_loaded_image(&loaded_image_info, &loaded_image_info_obj,
-  device_path, image_path);
+   ret = bootefi_run_prepare(&image, &obj, "bootargs", device_path,
+ image_path);
+   if (ret)
+   return ret;
 
-   /*
-* gd lives in a fixed register which may get clobbered while we execute
-* the payload. So save it here and restore it on every callback entry
-*/
-   efi_save_gd();
-
-   /* Transfer environment variable bootargs as load options */
-   set_load_options(&loaded_image_info, "bootargs");
/* Load the EFI payload */
-   entry = efi_load_pe(efi, &loaded_image_info);
+   entry = efi_load_pe(efi, &image);
if (!entry) {
ret = EFI_LOAD_ERROR;
goto exit;
@@ -347,10 +361,10 @@ static efi_status_t do_bootefi_exec(void *efi,
 
if (memdp) {
struct efi_device_path_memory *mdp = (void *)memdp;
-   mdp->memory_type = loaded_image_info.image_code_type;
-   mdp->start_address = (uintptr_t)loaded_image_info.image_base;
+   mdp->memory_type = image.image_code_type;
+   mdp->start_address = (uintptr_t)image.image_base;
mdp->end_address = mdp->start_address +
-   loaded_image_info.image_size;
+   image.image_size;
}
 
/* we don't support much: */
@@ -360,8 +374,8 @@ static efi_status_t do_bootefi_exec(void *efi,
/* Call our payload! */
debug("%s:%d Jumping to 0x%lx\n", __func__, __LINE__, (long)entry);
 
-   if (setjmp(&loaded_image_info.exit_jmp)) {
-   ret = loaded_image_info.exit_status;
+   if (setjmp(&image.exit_jmp)) {
+   ret = image.exit_status;
goto exit;
}
 
@@ -373,7 +387,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 
/* Move into EL2 and keep running there */
armv8_switch_to_el2((ulong)entry,
-   (ulong)&loaded_image_info_obj.handle,
+   (ulong)&obj.handle,
(ulong)&systab, 0, (ulong)efi_run_in_el2,
ES_TO_AARCH64);
 
@@ -390,7 +404,7 @@ static efi_status_t do_bootefi_exec(void *efi,
secure_ram_addr(_do_nonsec_en

[U-Boot] [PATCH v9 09/18] sandbox: Align RAM buffer to the machine page size

2018-08-08 Thread Simon Glass
At present the sandbox RAM buffer is not aligned to any particular
address boundary. This makes the internal pointers somewhat random with
respect to the associated RAM buffer addresses.

Align the buffer to the page size of the machine to help with this.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 5839932b005..a1a982af2de 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -143,14 +143,15 @@ void os_tty_raw(int fd, bool allow_sigs)
 void *os_malloc(size_t length)
 {
struct os_mem_hdr *hdr;
+   int page_size = getpagesize();
 
-   hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE,
-  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+   hdr = mmap(NULL, length + page_size,
+  PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (hdr == MAP_FAILED)
return NULL;
hdr->length = length;
 
-   return hdr + 1;
+   return (void *)hdr + page_size;
 }
 
 void os_free(void *ptr)
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 06/18] efi: sandbox: Add a simple 'bootefi test' command

2018-08-08 Thread Simon Glass
This jumps to test code which can call directly into the EFI support. It
does not need a separate image so it is easy to write tests with it.

This test can be executed without causing problems to the run-time
environment (e.g. U-Boot does not need to reboot afterwards).

For now the test just outputs a message. To try it:

./sandbox/u-boot -c "bootefi test"
U-Boot 2017.09-00204-g696c9855fe (Sep 17 2017 - 16:43:53 -0600)

DRAM:  128 MiB
MMC:
Using default environment

In:serial
Out:   serial
Err:   serial
SCSI:  Net:   No ethernet found.
IDE:   Bus 0: not available
Found 0 disks
WARNING: booting without device tree
Hello, world!
Test passed

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/bootefi.c | 26 --
 include/efi_loader.h  |  3 +++
 lib/efi_loader/Kconfig| 10 ++
 lib/efi_loader/Makefile   |  1 +
 lib/efi_loader/efi_test.c | 16 
 5 files changed, 50 insertions(+), 6 deletions(-)
 create mode 100644 lib/efi_loader/efi_test.c

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index af13492836d..edb7f786a27 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -409,7 +409,6 @@ exit:
return ret;
 }
 
-#ifdef CONFIG_CMD_BOOTEFI_SELFTEST
 /**
  * bootefi_test_prepare() - prepare to run an EFI test
  *
@@ -465,7 +464,6 @@ static void bootefi_test_finish(struct efi_loaded_image 
*image,
free(image->load_options);
list_del(&obj->link);
 }
-#endif /* CONFIG_CMD_BOOTEFI_SELFTEST */
 
 static int do_bootefi_bootmgr_exec(void)
 {
@@ -497,8 +495,10 @@ static int do_bootefi_bootmgr_exec(void)
 /* Interpreter command to boot an arbitrary EFI image from memory */
 static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const 
argv[])
 {
-   unsigned long addr;
+   struct efi_loaded_image image;
+   struct efi_object obj;
char *saddr;
+   unsigned long addr;
efi_status_t r;
unsigned long fdt_addr;
void *fdt;
@@ -545,11 +545,25 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int 
argc, char * const argv[])
memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size);
} else
 #endif
+   if (IS_ENABLED(CONFIG_BOOTEFI_TEST) && !strcmp(argv[1], "test")) {
+   int ret;
+
+   if (bootefi_test_prepare(&image, &obj, "\\test",
+(ulong)&efi_test))
+   return CMD_RET_FAILURE;
+
+   ret = efi_test(&image, &systab);
+   bootefi_test_finish(&image, &obj);
+   if (ret) {
+   printf("Test failed: err=%d\n", ret);
+   return CMD_RET_FAILURE;
+   }
+   printf("Test passed\n");
+
+   return 0;
+   }
 #ifdef CONFIG_CMD_BOOTEFI_SELFTEST
if (!strcmp(argv[1], "selftest")) {
-   struct efi_loaded_image image;
-   struct efi_object obj;
-
if (bootefi_test_prepare(&image, &obj, "\\selftest",
 (uintptr_t)&efi_selftest))
return CMD_RET_FAILURE;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 57ca5502726..616dfae7b70 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -457,6 +457,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, 
efi_guid_t *vendor,
 void *efi_bootmgr_load(struct efi_device_path **device_path,
   struct efi_device_path **file_path);
 
+/* Perform EFI tests */
+int efi_test(efi_handle_t image_handle, struct efi_system_table *systab);
+
 #else /* defined(EFI_LOADER) && !defined(CONFIG_SPL_BUILD) */
 
 /* Without CONFIG_EFI_LOADER we don't have a runtime section, stub it out */
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index bfd7b19d791..254b18da744 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -23,3 +23,13 @@ config EFI_LOADER_BOUNCE_BUFFER
  Some hardware does not support DMA to full 64bit addresses. For this
  hardware we can create a bounce buffer so that payloads don't have to
  worry about platform details.
+
+config BOOTEFI_TEST
+   bool "Provide a test for the EFI loader"
+   depends on EFI_LOADER && SANDBOX
+   default y
+   help
+ Provides a test of the EFI loader functionality accessed via the
+ command line ('bootefi test'). This runs within U-Boot so does not
+ need a separate EFI application to work. It aims to include coverage
+ of all EFI code which can be accessed within sandbox.
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 1ffbf52a898..e6a23d96122 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -27,3 +27,4 @@ obj-$(CONFIG_PARTITIONS) += efi_disk.o
 obj-$(CONFIG_NET) += efi_ne

[U-Boot] [PATCH v9 11/18] sandbox: Add support for calling abort()

2018-08-08 Thread Simon Glass
This function is useful to signal that the application needs to exit
immediate. It can be caught with a debugger (e.g. gdb). Add a stub for it
so that it can be called from within sandbox when an internal error
occurs.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 5 +
 include/os.h  | 4 
 2 files changed, 9 insertions(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 1553aa687df..f8d87df7b63 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -657,3 +657,8 @@ void os_longjmp(ulong *jmp, int ret)
 {
longjmp((struct __jmp_buf_tag *)jmp, ret);
 }
+
+void os_abort(void)
+{
+   abort();
+}
diff --git a/include/os.h b/include/os.h
index c8e0f52d306..e850f879ec3 100644
--- a/include/os.h
+++ b/include/os.h
@@ -351,4 +351,8 @@ int os_setjmp(ulong *jmp, int size);
  */
 void os_longjmp(ulong *jmp, int ret);
 
+/**
+ * os_abort() - Raise SIGABRT to exit sandbox (e.g. to debugger)
+ */
+void os_abort(void);
 #endif
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 08/18] efi: Rename bootefi_test_finish() to bootefi_run_finish()

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

Rename the function and use it in both places.

Signed-off-by: Simon Glass 
---

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

Changes in v6: None
Changes in v5:
- Rebase to master

Changes in v4:
- Rebase to master

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

Changes in v2: None

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

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 54732ba3f37..905e659da42 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -310,6 +310,20 @@ static efi_status_t bootefi_run_prepare(struct 
efi_loaded_image *image,
return 0;
 }
 
+/**
+ * bootefi_run_finish() - finish up after running an EFI test
+ *
+ * @image: Pointer to a struct which holds the loaded image info
+ * @obj: Pointer to a struct which holds the loaded image object
+ */
+static void bootefi_run_finish(struct efi_loaded_image *image,
+  struct efi_object *obj)
+{
+   efi_restore_gd();
+   free(image->load_options);
+   list_del(&obj->link);
+}
+
 /*
  * Load an EFI payload into a newly allocated piece of memory, register all
  * EFI objects it would want to access and jump to it.
@@ -415,8 +429,7 @@ static efi_status_t do_bootefi_exec(void *efi,
ret = efi_do_enter(obj.handle, &systab, entry);
 
 exit:
-   /* image has returned, loaded-image obj goes *poof*: */
-   list_del(&obj.link);
+   bootefi_run_finish(&image, &obj);
if (mem_obj.handle)
list_del(&mem_obj.link);
 
@@ -457,20 +470,6 @@ static efi_status_t bootefi_test_prepare(struct 
efi_loaded_image *image,
   bootefi_device_path, bootefi_image_path);
 }
 
-/**
- * bootefi_test_finish() - finish up after running an EFI test
- *
- * @image: Pointer to a struct which holds the loaded image info
- * @obj: Pointer to a struct which holds the loaded image object
- */
-static void bootefi_test_finish(struct efi_loaded_image *image,
-   struct efi_object *obj)
-{
-   efi_restore_gd();
-   free(image->load_options);
-   list_del(&obj->link);
-}
-
 static int do_bootefi_bootmgr_exec(void)
 {
struct efi_device_path *device_path, *file_path;
@@ -559,7 +558,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
return CMD_RET_FAILURE;
 
ret = efi_test(&image, &systab);
-   bootefi_test_finish(&image, &obj);
+   bootefi_run_finish(&image, &obj);
if (ret) {
printf("Test failed: err=%d\n", ret);
return CMD_RET_FAILURE;
@@ -577,7 +576,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
 
/* Execute the test */
r = efi_selftest(obj.handle, &systab);
-   bootefi_test_finish(&image, &obj);
+   bootefi_run_finish(&image, &obj);
return r != EFI_SUCCESS;
} else
 #endif
-- 
2.18.0.597.ga71716f1ad-goog

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


Re: [U-Boot] [PATCH v2 3/5] gpio: stm32f7: Add ops get_alternate_function

2018-08-08 Thread Simon Glass
On 3 August 2018 at 09:01, Patrice Chotard  wrote:
> From: Patrick Delaunay 
>
> Allow to display alternate function index using "gpio" command.
> Example, display all gpio state :
>
> gpio status -a
>   GPIOD2: func: 12
>   GPIOD3: func: 9
>   GPIOE3: func: 9
>   GPIOG6: func: 10
>
> It's useful to control pin configuration
>
> Signed-off-by: Patrick Delaunay 
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v2:
>   - Rename get_function_number to get_alternate_function in
> drivers/gpio/stm32f7_gpio.c
>
>  drivers/gpio/stm32f7_gpio.c | 16 
>  1 file changed, 16 insertions(+)

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


[U-Boot] [PATCH v9 16/18] efi: Add more debugging for memory allocations

2018-08-08 Thread Simon Glass
Add some more verbose debugging when doing memory allocations. This might
help to find bugs later.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/efi_loader/efi_boottime.c | 15 +++
 lib/efi_loader/efi_memory.c   | 22 +-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index b9e54f551a4..851d282f79d 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -330,6 +330,7 @@ static efi_status_t EFIAPI efi_allocate_pages_ext(int type, 
int memory_type,
 
EFI_ENTRY("%d, %d, 0x%zx, %p", type, memory_type, pages, memory);
r = efi_allocate_pages(type, memory_type, pages, memory);
+
return EFI_EXIT(r);
 }
 
@@ -379,11 +380,25 @@ static efi_status_t EFIAPI efi_get_memory_map_ext(
uint32_t *descriptor_version)
 {
efi_status_t r;
+   int i, entries;
 
EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map,
  map_key, descriptor_size, descriptor_version);
r = efi_get_memory_map(memory_map_size, memory_map, map_key,
   descriptor_size, descriptor_version);
+   entries = *memory_map_size / sizeof(struct efi_mem_desc);
+   debug("   memory_map_size=%zx (%lx entries)\n", *memory_map_size,
+ (ulong)(*memory_map_size / sizeof(struct efi_mem_desc)));
+   if (memory_map) {
+   for (i = 0; i < entries; i++) {
+   struct efi_mem_desc *desc = &memory_map[i];
+
+   debug("   type %d, phys %lx, virt %lx, num_pages %lx, 
attribute %lx\n",
+ desc->type, (ulong)desc->physical_start,
+ (ulong)desc->virtual_start,
+ (ulong)desc->num_pages, (ulong)desc->attribute);
+   }
+   }
return EFI_EXIT(r);
 }
 
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 967c3f733e4..607152bc4e7 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -151,6 +151,24 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map,
return EFI_CARVE_LOOP_AGAIN;
 }
 
+static void efi_mem_print(const char *name)
+{
+   struct list_head *lhandle;
+
+   debug("   %s: memory map\n", name);
+   list_for_each(lhandle, &efi_mem) {
+   struct efi_mem_list *lmem = list_entry(lhandle,
+   struct efi_mem_list, link);
+   struct efi_mem_desc *desc = &lmem->desc;
+
+   debug("   type %d, phys %lx, virt %lx, num_pages %lx, attribute 
%lx\n",
+ desc->type, (ulong)desc->physical_start,
+ (ulong)desc->virtual_start, (ulong)desc->num_pages,
+ (ulong)desc->attribute);
+   }
+   debug("\n");
+}
+
 uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,
bool overlap_only_ram)
 {
@@ -243,6 +261,7 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, 
int memory_type,
 
/* And make sure memory is listed in descending order */
efi_mem_sort();
+   efi_mem_print(__func__);
 
return start;
 }
@@ -466,7 +485,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t 
*memory_map_size,
map_entries++;
 
map_size = map_entries * sizeof(struct efi_mem_desc);
-
+   debug("%s: map_size %lx, provided_map_size %lx\n", __func__,
+ (ulong)map_size, (ulong)provided_map_size);
*memory_map_size = map_size;
 
if (provided_map_size < map_size)
-- 
2.18.0.597.ga71716f1ad-goog

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


[U-Boot] [PATCH v9 10/18] sandbox: Try to start the RAM buffer at a particular address

2018-08-08 Thread Simon Glass
Use a starting address of 256MB which should be available. This helps to
make sandbox RAM buffers pointers more recognisable.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/os.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index a1a982af2de..1553aa687df 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -145,7 +145,12 @@ void *os_malloc(size_t length)
struct os_mem_hdr *hdr;
int page_size = getpagesize();
 
-   hdr = mmap(NULL, length + page_size,
+   /*
+* Use an address that is hopefully available to us so that pointers
+* to this memory are fairly obvious. If we end up with a different
+* address, that's fine too.
+*/
+   hdr = mmap((void *)0x1000, length + page_size,
   PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (hdr == MAP_FAILED)
return NULL;
-- 
2.18.0.597.ga71716f1ad-goog

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


Re: [U-Boot] [PATCH v2 4/5] gpio: sandbox: Rename GPIOF_(OUTPUT|HIGH|ODR) to SDBX_GPIO_(OUTPUT|HIGH|ODR)

2018-08-08 Thread Simon Glass
On 3 August 2018 at 09:01, Patrice Chotard  wrote:
> To avoid confusion with enum gpio_func_t GPIOF_OUTPUT defined in
> asm-generic/gpio.h, rename all sandbox flags GPIOF_(OUTPUT|HIGH|ODR)
> to SDBX_GPIO_(OUTPUT|HIGH|ODR)
>
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v2: None
>
>  drivers/gpio/sandbox.c | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
>

Please use a SANDBOX_ prefix instead of SDBX_

But otherwise:

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


Re: [U-Boot] [PATCH v3 2/4] serial: stm32: Replace setparity by setconfig

2018-08-08 Thread Simon Glass
On 3 August 2018 at 07:07, Patrice Chotard  wrote:
> Replace stm32_serial_setparity by stm32_serial_setconfig
> which allows to set serial bits number, parity and stop
> bits number.
> Only parity setting is implemented.
>
> Signed-off-by: Patrick Delaunay 
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v3:
>   - Replace u8 by uint for parity/bits/stop in stm32_serial_setconfig()
>
> Changes in v2:
>   - Update stm32_serial_setconfig prototype
>
>  drivers/serial/serial_stm32.c | 21 +++--
>  1 file changed, 15 insertions(+), 6 deletions(-)

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


Re: [U-Boot] [PATCH 2/2] tpm: sandbox: fix wrong assignment with a simplification

2018-08-08 Thread Simon Glass
On 5 August 2018 at 10:53, Miquel Raynal  wrote:
> The recv variable in sandbox_tpm2_fill_buf() is a pointer on a pointer
> of a char array. It means accessing *recv is the char array pointer
> itself while **recv is the first character of that array. There is no
> need for such indirection here, so simplify the code.
>
> Simplifying things will make the last assignment right: "*recv = NULL"
> is now correct. The issue has been found by the following Coverity
> Scan report:
>
> CID 183371:  Incorrect expression  (UNUSED_VALUE)
> Assigning value "4UL" to "*recv" here, but that stored value is 
> overwritten before it can be used.
> 232 *recv += sizeof(rc);
> 233
> 234 /* Add trailing \0 */
> 235 *recv = NULL;
>
> While at simplifying things, use '\0' instead of NULL when adding an
> empty char at the end of the buffer.
>
> Reported-by: Tom Rini 
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/tpm/tpm2_tis_sandbox.c | 52 
> +-
>  1 file changed, 26 insertions(+), 26 deletions(-)

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


[U-Boot] [PATCH v9 17/18] efi_loader: Pass address to fs_read()

2018-08-08 Thread Simon Glass
From: Alexander Graf 

The fs_read() function wants to get an address rather than the
pointer to a buffer.

So let's convert the passed buffer from pointer back a the address
to make efi_loader on sandbox happier.

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

Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/efi_loader/efi_file.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index e6a15bcb523..2107730ba5a 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* GUID for file system information */
@@ -232,8 +233,10 @@ static efi_status_t file_read(struct file_handle *fh, u64 
*buffer_size,
void *buffer)
 {
loff_t actread;
+   /* fs_read expects buffer address, not pointer */
+   uintptr_t buffer_addr = (uintptr_t)map_to_sysmem(buffer);
 
-   if (fs_read(fh->path, (ulong)buffer, fh->offset,
+   if (fs_read(fh->path, buffer_addr, fh->offset,
*buffer_size, &actread))
return EFI_DEVICE_ERROR;
 
-- 
2.18.0.597.ga71716f1ad-goog

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


Re: [U-Boot] [PATCH v3 3/4] dm: serial: Remove setparity ops

2018-08-08 Thread Simon Glass
On 3 August 2018 at 07:07, Patrice Chotard  wrote:
> setparity users has been updated to use new setconfig ops,
> so we can safely remove setparity ops
>
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v3:
>   - Add patch to remove obsolete setparity ops
>
> Changes in v2: None
>
>  include/serial.h | 10 --
>  1 file changed, 10 deletions(-)

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


Re: [U-Boot] [PATCH v3 4/4] sandbox: Add serial test

2018-08-08 Thread Simon Glass
On 3 August 2018 at 07:07, Patrice Chotard  wrote:
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v3:
>   - Update serial test when wrong serial options are specified
>   - Add SERIAL_CONFIG(par, bits, stop) macro to create serial mask
>
> Changes in v2:
>   - Add sandbox serial test
>
>  drivers/serial/sandbox.c | 14 +
>  include/common.h |  1 +
>  include/serial.h |  5 +
>  test/dm/Makefile |  1 +
>  test/dm/serial.c | 54 
> 
>  5 files changed, 75 insertions(+)
>  create mode 100644 test/dm/serial.c

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


Re: [U-Boot] [PATCH v2 5/5] test: dm: Add gpio get_alternate_function ops test

2018-08-08 Thread Simon Glass
On 3 August 2018 at 09:01, Patrice Chotard  wrote:
> In order to test get_alternate_function ops, add
> sandbox_gpio_set_function() and sandbox_gpio_set_alternate_function()
> to be able to configure a pin not as a GPIO and to select the
> alternate function index.
>
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v2:
>   - Rename get_function_number to get_alternate_function
> in test/dm/gpio.c, drivers/gpio/sandbox.c and in
> arch/sandbox/include/asm/gpio.h
>
>  arch/sandbox/include/asm/gpio.h | 24 
>  drivers/gpio/sandbox.c  | 27 +++
>  test/dm/gpio.c  | 13 +
>  3 files changed, 64 insertions(+)

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Michal Simek
On 8.8.2018 11:17, Eugeniu Rosca wrote:
> Hello,
> 
> FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
> driver from the command line" contributes with a compiler warning, as
> described in https://patchwork.ozlabs.org/patch/933310/#1952127 .

any other problem?

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


[U-Boot] [PATCH v9 15/18] efi: sandbox: Tidy up copy_fdt() to work with sandbox

2018-08-08 Thread Simon Glass
At present this function takes a pointer as its argument, then passes this
to efi_allocate_pages(), which actually takes an address. It uses casts,
which are not supported on sandbox.

Also the function calculates the FDT size rounded up to the neared EFI
page size, then its caller recalculates the size and adds a bit more to
it.

This function is much better written as something that works with
addresses only, and returns both the address and the size of the relocated
FDT.

Also, copy_fdt() returns NULL on error, but really should propagate the
error from efi_allocate_pages(). To do this it needs to return an
efi_status_t, not a void *.

Update the code in this way, so that it is easier to follow, and also
supports sandbox.

Signed-off-by: Simon Glass 
---

Changes in v9:
- Drop fdt_end variable in efi_install_fdt()

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/bootefi.c | 79 ---
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6481444cca6..18378f2eacc 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -131,17 +131,30 @@ static void set_load_options(struct efi_loaded_image 
*loaded_image_info,
loaded_image_info->load_options_size = size * 2;
 }
 
-static void *copy_fdt(void *fdt)
+/**
+ * copy_fdt() - Copy the device tree to a new location available to EFI
+ *
+ * The FDT is relocated into a suitable location within the EFI memory map.
+ * An additional 12KB is added to the space in case the device tree needs to be
+ * expanded later with fdt_open_into().
+ *
+ * @fdt_addr: On entry, address of start of FDT. On exit, address of relocated
+ * FDT start
+ * @fdt_sizep: Returns new size of FDT, including
+ * @return new relocated address of FDT
+ */
+static efi_status_t copy_fdt(ulong *fdt_addrp, ulong *fdt_sizep)
 {
-   u64 fdt_size = fdt_totalsize(fdt);
unsigned long fdt_ram_start = -1L, fdt_pages;
+   efi_status_t ret = 0;
+   void *fdt, *new_fdt;
u64 new_fdt_addr;
-   void *new_fdt;
+   uint fdt_size;
int i;
 
-for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-u64 ram_start = gd->bd->bi_dram[i].start;
-u64 ram_size = gd->bd->bi_dram[i].size;
+   for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+   u64 ram_start = gd->bd->bi_dram[i].start;
+   u64 ram_size = gd->bd->bi_dram[i].size;
 
if (!ram_size)
continue;
@@ -154,30 +167,37 @@ static void *copy_fdt(void *fdt)
 * Give us at least 4KB of breathing room in case the device tree needs
 * to be expanded later. Round up to the nearest EFI page boundary.
 */
-   fdt_size += 4096;
+   fdt = map_sysmem(*fdt_addrp, 0);
+   fdt_size = fdt_totalsize(fdt);
+   fdt_size += 4096 * 3;
fdt_size = ALIGN(fdt_size + EFI_PAGE_SIZE - 1, EFI_PAGE_SIZE);
fdt_pages = fdt_size >> EFI_PAGE_SHIFT;
 
/* Safe fdt location is at 127MB */
new_fdt_addr = fdt_ram_start + (127 * 1024 * 1024) + fdt_size;
-   if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-  EFI_RUNTIME_SERVICES_DATA, fdt_pages,
-  &new_fdt_addr) != EFI_SUCCESS) {
+   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+EFI_RUNTIME_SERVICES_DATA, fdt_pages,
+&new_fdt_addr);
+   if (ret != EFI_SUCCESS) {
/* If we can't put it there, put it somewhere */
new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-   if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-  EFI_RUNTIME_SERVICES_DATA, fdt_pages,
-  &new_fdt_addr) != EFI_SUCCESS) {
+   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+EFI_RUNTIME_SERVICES_DATA, fdt_pages,
+&new_fdt_addr);
+   if (ret != EFI_SUCCESS) {
printf("ERROR: Failed to reserve space for FDT\n");
-   return NULL;
+   goto done;
}
}
 
-   new_fdt = (void*)(ulong)new_fdt_addr;
+   new_fdt = map_sysmem(new_fdt_addr, fdt_size);
memcpy(new_fdt, fdt, fdt_totalsize(fdt));
fdt_set_totalsize(new_fdt, fdt_size);
 
-   return new_fdt;
+   *fdt_addrp = new_fdt_addr;
+   *fdt_sizep = fdt_size;
+done:
+   return ret;
 }
 
 static efi_status_t efi_do_enter(
@@ -250,22 +270,27 @@ static void efi_carve_out_dt_rsv(void *fdt)
}
 }
 
-static efi_status_t efi_install_fdt(void *fdt)
+static efi_status_t efi_install_fdt(ulong fdt_addr)
 {
bootm_headers_t img = { 0 };
-   ulong fdt_pages, fdt_size, fdt_star

[U-Boot] [PATCH v9 18/18] efi: sandbox: Enable selftest command

2018-08-08 Thread Simon Glass
Enable this for sandbox since it passes now.

Signed-off-by: Simon Glass 
---

Changes in v9: None
Changes in v8:
- Drop 'efi: Adjust memory handling to support sandbox'
- Drop 'efi: sandbox: Add relocation constants'
- Drop 'sandbox: smbios: Update to support sandbox'
- Expand series substantially to support bootefi selftest
- Rebase to master
- Rebase to master, bringing in all EFI changes

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- Rebase to master
- Update SPDX tags

Changes in v3:
- Rebase to master

Changes in v2:
- Rebase to master

 configs/sandbox_defconfig | 1 +
 lib/efi_selftest/Kconfig  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 61302909191..7e75643bfe6 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -205,3 +205,4 @@ CONFIG_UT_ENV=y
 CONFIG_UT_OVERLAY=y
 CONFIG_SMEM=y
 CONFIG_SANDBOX_SMEM=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig
index b52696778dd..59f9f36801c 100644
--- a/lib/efi_selftest/Kconfig
+++ b/lib/efi_selftest/Kconfig
@@ -1,6 +1,6 @@
 config CMD_BOOTEFI_SELFTEST
bool "Allow booting an EFI efi_selftest"
-   depends on CMD_BOOTEFI && !SANDBOX
+   depends on CMD_BOOTEFI
imply FAT
imply FAT_WRITE
help
-- 
2.18.0.597.ga71716f1ad-goog

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


Re: [U-Boot] [PATCH 1/2] tpm: sandbox: fix wrong check on pcr_map

2018-08-08 Thread Simon Glass
On 5 August 2018 at 10:53, Miquel Raynal  wrote:
> The second check on pcr_map in sandbox_tpm2_xfer() is wrong. It should
> check for pcr_map not being empty. Instead, it is a pure copy/paste of
> the first check which is redundant.
>
> This has been found thanks to a Coverity Scan report:
>
> CID 183370:  Memory - illegal accesses  (UNINIT)
> Using uninitialized value "pcr_index".
> put_unaligned_be32(tpm->pcr_extensions[pcr_index], recv);
>
> This is because pcr_index is initialized only if the user input is
> correct, ie. at least one valid bit is set in pcr_map.
>
> Fix the second check and also initialize pcr_index to 0 (which is
> harmless in case of error) to make Coverity Scan happy.
>
> Reported-by: Tom Rini 
> Signed-off-by: Miquel Raynal 
> ---
>  drivers/tpm/tpm2_tis_sandbox.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 

It is always nice to see a test update with a bug fix (so we test that
the problem is fixed). I'm not sure if that is possible?

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


Re: [U-Boot] [PATCH v3 1/4] dm: serial: Replace setparity by setconfig

2018-08-08 Thread Simon Glass
On 3 August 2018 at 07:07, Patrice Chotard  wrote:
> Replace setparity by more generic setconfig ops
> to allow uart parity, bits word length and stop bits
> number change.
>
> Adds SERIAL_GET_PARITY/BITS/STOP macros.
>
> Signed-off-by: Patrick Delaunay 
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v3:
>   - Update SERIAL_PAR_MASK definition
>   - Don't remove setparity ops declaration in patch 1 to not
> break bissectability
>
> Changes in v2:
>   - Update SERIAL_BITS_MASK and SERIAL_STOP_MASK
>   - Update serial_setconfig prototype
>
>  drivers/serial/serial-uclass.c | 16 ++
>  include/serial.h   | 47 
> ++
>  2 files changed, 63 insertions(+)

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


Re: [U-Boot] [PATCH v2 1/5] dm: gpio: Add get_alternate_function ops

2018-08-08 Thread Simon Glass
Hi Patrice,

+Stephen and Masahiro for comment on this vs. pinctrl.

On 3 August 2018 at 09:01, Patrice Chotard  wrote:
> From: Patrick Delaunay 
>
> When a pin is not configured as a GPIO, it could
> have several alternate function.
>
> To be able to identify the alternate function,
> add ops get_alternate_function() to request the pin
> alternate function index from the driver when pin is
> not used as gpio.
>
> Signed-off-by: Patrick Delaunay 
> Signed-off-by: Patrice Chotard 
> ---
>
> Changes in v2:
>- Rename get_function_number to get_alternate_function
>  in include/asm-generic/gpio.h
>
>  drivers/gpio/gpio-uclass.c |  6 ++
>  include/asm-generic/gpio.h | 13 +
>  2 files changed, 19 insertions(+)

Reviewed-by: Simon Glass 

But please replace 'alternative' with 'alt' as it is shorter.

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


Re: [U-Boot] [PATCH 2/4] serial: protect access to serial rx buffer

2018-08-08 Thread Simon Glass
On 3 August 2018 at 05:38, Patrick Delaunay  wrote:
> Add test to avoid access to rx buffer when this buffer is empty.
> In this case directly call getc() function to avoid issue when tstc()
> is not called.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  drivers/serial/serial-uclass.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 321d23e..4121a37 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -228,6 +228,9 @@ static int _serial_getc(struct udevice *dev)
> struct serial_dev_priv *upriv = dev_get_uclass_priv(dev);
> char val;
>
> +   if (upriv->rd_ptr == upriv->wr_ptr)
> +   return __serial_getc(dev);
> +
> val = upriv->buf[upriv->rd_ptr++];
> upriv->rd_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
>
> --
> 2.7.4
>

Reviewed-by: Simon Glass 

BTW I think the code in _serial_tstc() is wrong, or at least sub-optimal:

/* Read all available chars into the RX buffer */
while (__serial_tstc(dev)) {
   upriv->buf[upriv->wr_ptr++] = __serial_getc(dev);
   upriv->wr_ptr %= CONFIG_SERIAL_RX_BUFFER_SIZE;
}

It should call serial_getc() until it returns -EAGAIN. There should be
no need to call __serial_tstc() first,

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


Re: [U-Boot] [PATCH v2 2/2] sandbox: Enable bitrev library build

2018-08-08 Thread Simon Glass
On 3 August 2018 at 00:58, Bin Meng  wrote:
> Imply CONFIG_BITREVERSE for Sandbox.
>
> Signed-off-by: Bin Meng 
>
> ---
>
> Changes in v2:
> - Change to imply in the Kconfig
>
>  arch/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>

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


[U-Boot] [PATCH v9 12/18] sandbox: Enhance map_to_sysmem() to handle foreign pointers

2018-08-08 Thread Simon Glass
At present map_sysmem() maps an address into the sandbox RAM buffer,
return a pointer, while map_to_sysmem() goes the other way.

The mapping is currently just 1:1 since a case was not found where a more
flexible mapping was needed. PCI does have a separate and more complex
mapping, but uses its own mechanism.

However this arrange cannot handle one important case, which is where a
test declares a stack variable and passes a pointer to it into a U-Boot
function which uses map_to_sysmem() to turn it into a address. Since the
pointer is not inside emulated DRAM, this will fail.

Add a mapping feature which can handle any such pointer, mapping it to a
simple tag value which can be passed around in U-Boot as an address.

Signed-off-by: Simon Glass 
---

Changes in v9:
- Fix 'thi' typo

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/cpu.c   | 141 +--
 arch/sandbox/cpu/state.c |   8 ++
 arch/sandbox/include/asm/state.h |  21 +
 3 files changed, 161 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index cde0b055a67..e523223ebf8 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -57,14 +57,104 @@ int cleanup_before_linux_select(int flags)
return 0;
 }
 
+/**
+ * is_in_sandbox_mem() - Checks if a pointer is within sandbox's emulated DRAM
+ *
+ * This provides a way to check if a pointer is owned by sandbox (and is within
+ * its RAM) or not. Sometimes pointers come from a test which conceptually runs
+ * output sandbox, potentially with direct access to the C-library malloc()
+ * function, or the sandbox stack (which is not actually within the emulated
+ * DRAM.
+ *
+ * Such pointers obviously cannot be mapped into sandbox's DRAM, so we must
+ * detect them an process them separately, by recording a mapping to a tag,
+ * which we can use to map back to the pointer later.
+ *
+ * @ptr: Pointer to check
+ * @return true if this is within sandbox emulated DRAM, false if not
+ */
+static bool is_in_sandbox_mem(const void *ptr)
+{
+   return (const uint8_t *)ptr >= gd->arch.ram_buf &&
+   (const uint8_t *)ptr < gd->arch.ram_buf + gd->ram_size;
+}
+
+/**
+ * phys_to_virt() - Converts a sandbox RAM address to a pointer
+ *
+ * Sandbox uses U-Boot addresses from 0 to the size of DRAM. These index into
+ * the emulated DRAM buffer used by sandbox. This function converts such an
+ * address to a pointer into this buffer, which can be used to access the
+ * memory.
+ *
+ * If the address is outside this range, it is assumed to be a tag
+ */
 void *phys_to_virt(phys_addr_t paddr)
 {
-   return (void *)(gd->arch.ram_buf + paddr);
+   struct sandbox_mapmem_entry *mentry;
+   struct sandbox_state *state;
+
+   /* If the address is within emulated DRAM, calculate the value */
+   if (paddr < gd->ram_size)
+   return (void *)(gd->arch.ram_buf + paddr);
+
+   /*
+* Otherwise search out list of tags for the correct pointer previously
+* created by map_to_sysmem()
+*/
+   state = state_get_current();
+   list_for_each_entry(mentry, &state->mapmem_head, sibling_node) {
+   if (mentry->tag == paddr) {
+   printf("%s: Used map from %lx to %p\n", __func__,
+  (ulong)paddr, mentry->ptr);
+   return mentry->ptr;
+   }
+   }
+
+   printf("%s: Cannot map sandbox address %lx (SDRAM from 0 to %lx)\n",
+  __func__, (ulong)paddr, (ulong)gd->ram_size);
+   os_abort();
+
+   /* Not reached */
+   return NULL;
+}
+
+struct sandbox_mapmem_entry *find_tag(const void *ptr)
+{
+   struct sandbox_mapmem_entry *mentry;
+   struct sandbox_state *state = state_get_current();
+
+   list_for_each_entry(mentry, &state->mapmem_head, sibling_node) {
+   if (mentry->ptr == ptr) {
+   debug("%s: Used map from %p to %lx\n", __func__, ptr,
+ mentry->tag);
+   return mentry;
+   }
+   }
+   return NULL;
 }
 
-phys_addr_t virt_to_phys(void *vaddr)
+phys_addr_t virt_to_phys(void *ptr)
 {
-   return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf);
+   struct sandbox_mapmem_entry *mentry;
+
+   /*
+* If it is in emulated RAM, don't bother looking for a tag. Just
+* calculate the pointer using the provides offset into the RAM buffer.
+*/
+   if (is_in_sandbox_mem(ptr))
+   return (phys_addr_t)((uint8_t *)ptr - gd->arch.ram_buf);
+
+   mentry = find_tag(ptr);
+   if (!mentry) {
+   /* Abort so that gdb can be used here */
+   printf("%s: Cannot map sandbox address %p (SDRAM from 0 to 
%lx)\n",
+  __func__, ptr, (ulong)gd->ram_size

Re: [U-Boot] [PATCH v2 0/5] Add get_alternate_function ops

2018-08-08 Thread Simon Glass
Hi Patrice,

On 3 August 2018 at 09:01, Patrice Chotard  wrote:
>
> This series :
>   - Add new gpio ops get_alternate_function
>   - Add get_function and get_alternate_function support to stm32 gpio driver
>   - Add get_alternate_function test
>
> Changes in v2:
>- Rename get_function_number to get_alternate_function
>  in include/asm-generic/gpio.h
>   - Rename get_function_number to get_alternate_function in
> drivers/gpio/stm32f7_gpio.c
>   - Rename get_function_number to get_alternate_function
> in test/dm/gpio.c, drivers/gpio/sandbox.c and in
> arch/sandbox/include/asm/gpio.h
>
> Christophe Kerello (1):
>   gpio: stm32f7: Add ops get_function
>
> Patrice Chotard (2):
>   gpio: sandbox: Rename GPIOF_(OUTPUT|HIGH|ODR) to
> SDBX_GPIO_(OUTPUT|HIGH|ODR)
>   test: dm: Add gpio get_alternate_function ops test
>
> Patrick Delaunay (2):
>   dm: gpio: Add get_alternate_function ops
>   gpio: stm32f7: Add ops get_alternate_function
>
>  arch/sandbox/include/asm/gpio.h | 24 
>  drivers/gpio/gpio-uclass.c  |  6 +
>  drivers/gpio/sandbox.c  | 49 
> -
>  drivers/gpio/stm32f7_gpio.c | 36 ++
>  include/asm-generic/gpio.h  | 13 +++
>  test/dm/gpio.c  | 13 +++
>  6 files changed, 130 insertions(+), 11 deletions(-)
>

This series looks OK, but I am wondering how it fits with pinctrl.
(e.g. get_gpio_mux)?

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


Re: [U-Boot] [PATCH 1/4 v2] spi: spi-mem: Use 2 SPI messages instead of a single full-duplex one

2018-08-08 Thread Miquel Raynal
Hi Stefan,

Minor typo if you decide to send a v3.

Boris Brezillon  wrote on Tue, 7 Aug 2018
15:28:02 +0200:

> On Tue,  7 Aug 2018 14:16:52 +0200
> Stefan Roese  wrote:
> 
> > Some SPI controller do not support full-duplex SPI transfers. This patch
> > changes the SPI transfer into 2 separate transfers - or 1, if no data is
> > to transmitted.

  ^ be ?

> > 
> > With this change, no buffers need to be allocated anymore. We use the
> > TX and RX buffers that are passed to spi_mem_exec_op() directly.
> > 
> > Signed-off-by: Stefan Roese 
> > Suggested-by: Boris Brezillon 
> > Cc: Miquel Raynal 
> > Cc: Boris Brezillon 
> > Cc: Jagan Teki   
> 

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


Re: [U-Boot] [PATCH v1 14/17] cmd: fpga: Add support for missing fpga loadmk commands

2018-08-08 Thread Simon Glass
Hi Michal,

On 3 August 2018 at 00:13, Michal Simek  wrote:
> On 2.8.2018 22:37, Simon Glass wrote:
>> On 26 July 2018 at 08:16, Michal Simek  wrote:
>>> Not all 4 fpga loadmk FIT image commands
>>
>> I don't understand this. Can you explain what you mean?
>
> hm not sure why I have written this short commit message.
> Maybe I wanted to extend it later when I was doing rebasing.
>
> Anyway let me explain.
>
> There are ways how to call fpga loadmk
>
> 1. Full command
> fpga loadmk [dev] [address]
>
> 2. Dev setup via variable
> set fpga [dev]
> fpga loadmk [address]
>
> 3. Address setup via variable
> set fpgadata [address]
> fpga loadmk [dev]
>
> 4. Dev and address setup via variables
> set fpga [dev]
> set fpgadata [address]
> fpga loadmk
>
> Before this patch only cases 1 and 3 were working but the part of code
> was trying to support also cases 2 and 4.
> That's why I have added all these use cases to pytest to make sure that
> all of them are working fine.

OK great, thanks. Can you please expand the commit message a little?

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


Re: [U-Boot] [PATCH 3/4] console: unify fgetc function when console MUX is deactivated

2018-08-08 Thread Simon Glass
On 3 August 2018 at 05:38, Patrick Delaunay  wrote:
> Unify the fgetc function when MUX is activated or not:
> - always call tstc() : it is the normal behavior expected
>   by serial uclass (call tstc then getc) and that avoids
>   issue when SERIAL_RX_BUFFER is activated
> - reload WATCHDOG in the char waiting loop
>
> This patch allow to have the same behavior when CONSOLE_MUX is activated
> or not and avoid regression when this feature is deactivated.
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  common/console.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 

I'm not sure how to test this with the various cases...
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Eugeniu Rosca
On Wed, Aug 8, 2018 at 11:58 AM Michal Simek  wrote:
>
> On 8.8.2018 11:17, Eugeniu Rosca wrote:
> > Hello,
> >
> > FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
> > driver from the command line" contributes with a compiler warning, as
> > described in https://patchwork.ozlabs.org/patch/933310/#1952127 .
>
> any other problem?

Not from my side.

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


Re: [U-Boot] [PATCH v6 00/27] SPI-NAND support

2018-08-08 Thread Miquel Raynal
Hi Jagan,

Jagan Teki  wrote on Mon, 6 Aug 2018
23:20:19 +0530:

> Are you planning to send the next version?

I was not as we gave you a branch to pull patches from and test with
Travis if the warnings were gone [1].

Of course I can send the patches if you want them here also.

If Stefan sends a new iteration of his series I could fold the changes.

[1] https://github.com/bbrezillon/u-boot/commits/wip-spi


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


[U-Boot] [PATCH] [RFC] blk: Increase cache element size

2018-08-08 Thread Marek Vasut
Cache up to 4 kiB entries. 4 kiB is the default block size on ext4, yet
the underlying block layer devices usually report support for 512B . In
most cases, the 512B support is emulated (ie. SD cards, SSDs, USB sticks
etc.) and the real block size of those devices is much bigger.

To avoid performance degradation with such devices and FS setup, bump
the maximum cache entry size to 4 kiB.

Signed-off-by: Marek Vasut 
Cc: Tom Rini 
Cc: Simon Glass 
---
 drivers/block/blkcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c
index 294511fcdb..1fa64989d3 100644
--- a/drivers/block/blkcache.c
+++ b/drivers/block/blkcache.c
@@ -24,7 +24,7 @@ struct block_cache_node {
 static LIST_HEAD(block_cache);
 
 static struct block_cache_stats _stats = {
-   .max_blocks_per_entry = 2,
+   .max_blocks_per_entry = 8,
.max_entries = 32
 };
 
-- 
2.16.2

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Jean-Jacques Hiblot

Hi all,


On 08/08/2018 11:17, Eugeniu Rosca wrote:

Hello,

FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
driver from the command line" contributes with a compiler warning, as
described in https://patchwork.ozlabs.org/patch/933310/#1952127 .

This looks like a false positive to me.
It can be fixed by assigning an initialization value to ret.

Does that require a v4 ?

JJ


Best regards,
Eugeniu.
On Wed, Aug 8, 2018 at 8:36 AM Michal Simek  wrote:

Hi Lukasz,

On 22.6.2018 14:25, Jean-Jacques Hiblot wrote:

This series implements 2 fixes to be able to use USB Ethernet gadget with the 
dwc3
driver.
It also adds new commands to bind/unbind a device to/from a driver and
update the 'dm tree' command to make it easier to use those new commands.
The bind/unbind commands can be used to bind the DWC3 USB gadget to the
usb_ether driver from the command line instead of relying on platform code.

Changes in v3:
- update some commit logs
- factorize code based on comments from ML
- remove the devices before unbinding them
- use device_find_global_by_ofnode() to get a device by its node.

Changes in v2:
- Make the bind/unbind command generic, not specific to usb device.
- Update the API to be able to bind/unbind based on DTS node path
- Add a Kconfig option to select the bind/unbind commands

Jean-Jacques Hiblot (7):
   usb: gadget: Add bcdDevice for the DWC3 USB Gadget Controller
   net: eth-uclass: Fix for DM USB ethernet support
   uclass: Add dev_get_uclass_index() to get the uclass/index of a device
   dm: print the index of the device when dumping the dm tree
   dm: convert device_get_global_by_of_offset() to
 device_get_global_by_ofnode()
   device: expose the functions used to remove and unbind children of a
 device
   cmd: Add bind/unbind commands to bind a device to a driver from the
 command line

  arch/arm/mach-rockchip/rk3188-board-spl.c |   2 +-
  arch/arm/mach-rockchip/rk3288-board-spl.c |   2 +-
  arch/sandbox/dts/test.dts |  11 ++
  cmd/Kconfig   |   9 ++
  cmd/Makefile  |   1 +
  cmd/bind.c| 255 ++
  configs/sandbox_defconfig |   1 +
  drivers/core/device-remove.c  |  30 ++--
  drivers/core/device.c |  19 ++-
  drivers/core/dump.c   |  16 +-
  drivers/core/uclass.c |  21 +++
  drivers/usb/gadget/gadget_chips.h |   2 +
  include/dm/device-internal.h  |  38 +
  include/dm/device.h   |  23 ++-
  include/dm/uclass-internal.h  |  11 ++
  net/eth-uclass.c  |   3 +-
  test/py/tests/test_bind.py| 178 +
  17 files changed, 584 insertions(+), 38 deletions(-)
  create mode 100644 cmd/bind.c
  create mode 100644 test/py/tests/test_bind.py


Lukasz: I see your name in patchwork.
Are you going to take this series? Or we are waiting for sandbox testing?

Thanks,
Michal



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


[U-Boot] [PATCH v2 00/17] cmd: fpga: Fix fpga command handling and add some fpga tests

2018-08-08 Thread Michal Simek
Hi,

We are using this framework for a while and by adding more and more
features it requires small redesigned how commands are handled.
This is something what I have put together to improve readability of
this code and also remove code which is bogus and completely untested.

The patch
https://lists.denx.de/pipermail/u-boot/2018-June/330651.html
is also included in this series to have full picture.

Thanks,
Michal

Changes in v2:
- Extend non complete commit message

Changes in v1:
- Remove debug message checking (unfortunatelly we can't parse them)
- Add dependency on image_format_legacy and gzip
- Setup all FIT tests and legacy uimage tests
- New patch from RFC

Michal Simek (17):
  cmd: fpga: Remove fit image support passed without fpga device
  test/py: Extend fpga command to test all fpga load types
  cmd: fpga: Move error handling to do_fpga()
  cmd: fpga: Move fpga_get_op to avoid local function declaration
  cmd: fpga: Cleanup error handling in connection to FPGA_NONE
  cmd: fpga: Move parameter checking for loadfs/loads
  cmd: fpga: Remove parameter checking from fpga loadfs command
  cmd: fpga: Clean wrong_parms handling
  cmd: fpga: Create new do_fpga_wrapper for using u-boot subcommands
  cmd: fpga: Extract fpga info command to separate function
  cmd: fpga: Fix dump and all direct fpga load commands
  cmd: fpga: Fix loadfs command
  cmd: fpga: Fix loadmk command
  cmd: fpga: Add support for missing fpga loadmk commands
  cmd: fpga: Use CMD_RET_FAILURE instead of simple 1
  cmd: fpga: Fix loads command
  MAINTAINERS: Add myself as the FPGA maintainer

 MAINTAINERS|   8 +
 cmd/fpga.c | 652 +++--
 test/py/tests/test_fpga.py | 552 ++
 3 files changed, 896 insertions(+), 316 deletions(-)
 create mode 100644 test/py/tests/test_fpga.py

-- 
1.9.1

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


[U-Boot] [PATCH v2 05/17] cmd: fpga: Cleanup error handling in connection to FPGA_NONE

2018-08-08 Thread Michal Simek
Incorrect command is already handled and FPGA_NONE should be used only
one. In case of error CMD_RET_USAGE can be returned directly without any
addition logic around.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index de8505e9d4c8..af2f514dca00 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -171,11 +171,10 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 
if (dev == FPGA_INVALID_DEVICE) {
puts("FPGA device not specified\n");
-   op = FPGA_NONE;
+   return CMD_RET_USAGE;
}
 
switch (op) {
-   case FPGA_NONE:
case FPGA_INFO:
break;
 #if defined(CONFIG_CMD_FPGA_LOADFS)
@@ -219,13 +218,10 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 
if (wrong_parms) {
puts("Wrong parameters for FPGA request\n");
-   op = FPGA_NONE;
+   return CMD_RET_USAGE;
}
 
switch (op) {
-   case FPGA_NONE:
-   return CMD_RET_USAGE;
-
case FPGA_INFO:
rc = fpga_info(dev);
break;
-- 
1.9.1

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


[U-Boot] [PATCH v2 01/17] cmd: fpga: Remove fit image support passed without fpga device

2018-08-08 Thread Michal Simek
The patch applied in 2010
"cmd_fpga: cleanup help and check parameters"
(sha1: a790b5b2326be9d7c9ad9e3d9b51a8bfabc62d07"
was adding this checking

+   if (dev == FPGA_INVALID_DEVICE) {
+   puts("FPGA device not specified\n");
+   op = FPGA_NONE;
+   }

which simply broke one command flow which was
setenv fpga 
fpga loadmk  // legacy image
fpga loadmk : //fit image

Also this sequence for FIT image is completely broken
setenv fpga 
setenv fpgadata :
fpga loadmk
(Note: For legacy images this is working fine).

even from code I don't think this has ever worked properly
for fit image (dev = FPGA_INVALID_DEVICE should be rejected
by fpga core). Fit image support was in 2008 added by:
"[new uImage] Add new uImage fromat support to fpga command"
(sha1: c28c4d193dbfb20b2dd3a5447640fd6de7fd0720)

Just a summary of these facts that none found this for pretty long time
it shouldn't be a problem to remove this flow (without fpga dev)
completely to simplify the code.

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

Changes in v2: None
Changes in v1: None

I am rewriting cmd/fpga.c file to use u-boot subcommand and I found
that these flow are not working.

---
 cmd/fpga.c | 25 -
 1 file changed, 25 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 74ae80c807e2..791fe5cb7718 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -127,31 +127,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
case 3: /* fpga   */
dev = (int)simple_strtoul(argv[2], NULL, 16);
debug("%s: device = %d\n", __func__, dev);
-   /* FIXME - this is a really weak test */
-   if ((argc == 3) && (dev > fpga_count())) {
-   /* must be buffer ptr */
-   debug("%s: Assuming buffer pointer in arg 3\n",
- __func__);
-
-#if defined(CONFIG_FIT)
-   if (fit_parse_subimage(argv[2], (ulong)fpga_data,
-  &fit_addr, &fit_uname)) {
-   fpga_data = (void *)fit_addr;
-   debug("*  fpga: subimage '%s' from FIT image ",
- fit_uname);
-   debug("at 0x%08lx\n", fit_addr);
-   } else
-#endif
-   {
-   fpga_data = (void *)(uintptr_t)dev;
-   debug("*  fpga: cmdline image addr = 0x%08lx\n",
- (ulong)fpga_data);
-   }
-
-   debug("%s: fpga_data = 0x%lx\n",
- __func__, (ulong)fpga_data);
-   dev = FPGA_INVALID_DEVICE;  /* reset device num */
-   }
}
 
if (dev == FPGA_INVALID_DEVICE) {
-- 
1.9.1

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


[U-Boot] [PATCH v2 03/17] cmd: fpga: Move error handling to do_fpga()

2018-08-08 Thread Michal Simek
Clean fpga_get_op() error handling by moving checking/print to do_fpga.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 791fe5cb7718..abe683720285 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -74,6 +74,9 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
op = (int)fpga_get_op(argv[1]);
 
switch (op) {
+   case FPGA_NONE:
+   printf("Unknown fpga operation \"%s\"\n", argv[1]);
+   return CMD_RET_USAGE;
 #if defined(CONFIG_CMD_FPGA_LOADFS)
case FPGA_LOADFS:
if (argc < 9)
@@ -360,9 +363,6 @@ static int fpga_get_op(char *opstr)
op = FPGA_LOADS;
 #endif
 
-   if (op == FPGA_NONE)
-   printf("Unknown fpga operation \"%s\"\n", opstr);
-
return op;
 }
 
-- 
1.9.1

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


[U-Boot] [PATCH v2 02/17] test/py: Extend fpga command to test all fpga load types

2018-08-08 Thread Michal Simek
Add support for info, load, loadp, loadb, loadbp, loadmk_legacy,
loadmk_legacy_gz, loadmk_fit, loadfs also with variable support.

There are probably missing failed tests.

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

Changes in v2: None
Changes in v1:
- Remove debug message checking (unfortunatelly we can't parse them)
- Add dependency on image_format_legacy and gzip
- Setup all FIT tests and legacy uimage tests

 test/py/tests/test_fpga.py | 552 +
 1 file changed, 552 insertions(+)
 create mode 100644 test/py/tests/test_fpga.py

diff --git a/test/py/tests/test_fpga.py b/test/py/tests/test_fpga.py
new file mode 100644
index ..7459ce586740
--- /dev/null
+++ b/test/py/tests/test_fpga.py
@@ -0,0 +1,552 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2018, Xilinx Inc.
+#
+# Michal Simek
+# Siva Durga Prasad Paladugu
+
+import pytest
+import re
+import random
+import u_boot_utils
+
+"""
+Note: This test relies on boardenv_* containing configuration values to define
+the network available and files to be used for testing. Without this, this test
+will be automatically skipped.
+
+For example:
+
+# True if a DHCP server is attached to the network, and should be tested.
+env__net_dhcp_server = True
+
+# A list of environment variables that should be set in order to configure a
+# static IP. In this test case we atleast need serverip for performing tftpb
+# to get required files.
+env__net_static_env_vars = [
+("ipaddr", "10.0.0.100"),
+("netmask", "255.255.255.0"),
+("serverip", "10.0.0.1"),
+]
+
+# Details regarding the files that may be read from a TFTP server. .
+env__fpga_secure_readable_file = {
+"fn": "auth_bhdr_ppk1_bit.bin",
+"enckupfn": "auth_bhdr_enc_kup_load_bit.bin",
+"addr": 0x100,
+"keyaddr": 0x10,
+"keyfn": "key.txt",
+}
+
+env__fpga_under_test = {
+"dev": 0,
+"addr" : 0x100,
+"bitstream_load": "compress.bin",
+"bitstream_load_size": 1831960,
+"bitstream_loadp": "compress_pr.bin",
+"bitstream_loadp_size": 423352,
+"bitstream_loadb": "compress.bit",
+"bitstream_loadb_size": 1832086,
+"bitstream_loadbp": "compress_pr.bit",
+"bitstream_loadbp_size": 423491,
+"mkimage_legacy": "download.ub",
+"mkimage_legacy_size": 13321468,
+"mkimage_legacy_gz": "download.gz.ub",
+"mkimage_legacy_gz_size": 53632,
+"mkimage_fit": "download-fit.ub",
+"mkimage_fit_size": 13322784,
+"loadfs": "mmc 0 compress.bin",
+"loadfs_size": 1831960,
+"loadfs_block_size": 0x1,
+}
+"""
+
+import test_net
+
+def check_dev(u_boot_console):
+f = u_boot_console.config.env.get('env__fpga_under_test', None)
+if not f:
+pytest.skip('No FPGA to test')
+
+dev = f.get('dev', -1)
+if dev < 0:
+pytest.fail('No dev specified via env__fpga_under_test')
+
+return dev, f
+
+def load_file_from_var(u_boot_console, name):
+dev, f = check_dev(u_boot_console)
+
+addr = f.get('addr', -1)
+if addr < 0:
+pytest.fail('No address specified via env__fpga_under_test')
+
+test_net.test_net_dhcp(u_boot_console)
+test_net.test_net_setup_static(u_boot_console)
+bit = f['%s' % (name)]
+bit_size = f['%s_size' % (name)]
+
+expected_tftp = 'Bytes transferred = %d' % bit_size
+output = u_boot_console.run_command('tftpboot %x %s' % (addr, bit))
+assert expected_tftp in output
+
+return f, dev, addr, bit, bit_size
+
+## FPGA FAIL test ##
+expected_usage = 'fpga - loadable FPGA image support'
+
+@pytest.mark.xfail
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_fail(u_boot_console):
+# Test non valid fpga subcommand
+expected = 'fpga: non existing command'
+output = u_boot_console.run_command('fpga broken 0')
+#assert expected in output
+assert expected_usage in output
+
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_help(u_boot_console):
+# Just show help
+output = u_boot_console.run_command('fpga')
+assert expected_usage in output
+
+
+## FPGA DUMP tests ##
+
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_dump(u_boot_console):
+pytest.skip('Not implemented now')
+
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_dump_variable(u_boot_console):
+# Same as above but via "fpga" variable
+pytest.skip('Not implemented now')
+
+## FPGA INFO tests ##
+
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_info_fail(u_boot_console):
+# Maybe this can be skipped completely
+dev, f = check_dev(u_boot_console)
+
+# Multiple parameters to fpga info should fail
+expected = 'fpga: more parameters passed'
+output = u_boot_console.run_command('fpga info 0 0')
+#assert expected in output
+assert expected_usage in output
+
+@pytest.mark.buildconfigspec('cmd_fpga')
+def test_fpga_info_list(u_boot_console):
+# Maybe this can be skipped completely
+dev, f = check_

[U-Boot] [PATCH v2 04/17] cmd: fpga: Move fpga_get_op to avoid local function declaration

2018-08-08 Thread Michal Simek
Move fpga_get_op() to top of file to remove local function declaration
and also remove useless retyping.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 85 ++
 1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index abe683720285..de8505e9d4c8 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -13,9 +13,6 @@
 #include 
 #include 
 
-/* Local functions */
-static int fpga_get_op(char *opstr);
-
 /* Local defines */
 enum {
FPGA_NONE = -1,
@@ -30,6 +27,46 @@ enum {
FPGA_LOADS,
 };
 
+/*
+ * Map op to supported operations.  We don't use a table since we
+ * would just have to relocate it from flash anyway.
+ */
+static int fpga_get_op(char *opstr)
+{
+   int op = FPGA_NONE;
+
+   if (!strcmp("info", opstr))
+   op = FPGA_INFO;
+   else if (!strcmp("loadb", opstr))
+   op = FPGA_LOADB;
+   else if (!strcmp("load", opstr))
+   op = FPGA_LOAD;
+#if defined(CONFIG_CMD_FPGA_LOADP)
+   else if (!strcmp("loadp", opstr))
+   op = FPGA_LOADP;
+#endif
+#if defined(CONFIG_CMD_FPGA_LOADBP)
+   else if (!strcmp("loadbp", opstr))
+   op = FPGA_LOADBP;
+#endif
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+   else if (!strcmp("loadfs", opstr))
+   op = FPGA_LOADFS;
+#endif
+#if defined(CONFIG_CMD_FPGA_LOADMK)
+   else if (!strcmp("loadmk", opstr))
+   op = FPGA_LOADMK;
+#endif
+   else if (!strcmp("dump", opstr))
+   op = FPGA_DUMP;
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+   else if (!strcmp("loads", opstr))
+   op = FPGA_LOADS;
+#endif
+
+   return op;
+}
+
 /* - */
 /* command form:
  *   fpga
@@ -71,7 +108,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return CMD_RET_USAGE;
}
 
-   op = (int)fpga_get_op(argv[1]);
+   op = fpga_get_op(argv[1]);
 
switch (op) {
case FPGA_NONE:
@@ -326,46 +363,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return rc;
 }
 
-/*
- * Map op to supported operations.  We don't use a table since we
- * would just have to relocate it from flash anyway.
- */
-static int fpga_get_op(char *opstr)
-{
-   int op = FPGA_NONE;
-
-   if (!strcmp("info", opstr))
-   op = FPGA_INFO;
-   else if (!strcmp("loadb", opstr))
-   op = FPGA_LOADB;
-   else if (!strcmp("load", opstr))
-   op = FPGA_LOAD;
-#if defined(CONFIG_CMD_FPGA_LOADP)
-   else if (!strcmp("loadp", opstr))
-   op = FPGA_LOADP;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOADBP)
-   else if (!strcmp("loadbp", opstr))
-   op = FPGA_LOADBP;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   else if (!strcmp("loadfs", opstr))
-   op = FPGA_LOADFS;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOADMK)
-   else if (!strcmp("loadmk", opstr))
-   op = FPGA_LOADMK;
-#endif
-   else if (!strcmp("dump", opstr))
-   op = FPGA_DUMP;
-#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-   else if (!strcmp("loads", opstr))
-   op = FPGA_LOADS;
-#endif
-
-   return op;
-}
-
 #if defined(CONFIG_CMD_FPGA_LOADFS) || defined(CONFIG_CMD_FPGA_LOAD_SECURE)
 U_BOOT_CMD(fpga, 9, 1, do_fpga,
 #else
-- 
1.9.1

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


[U-Boot] [PATCH v2 06/17] cmd: fpga: Move parameter checking for loadfs/loads

2018-08-08 Thread Michal Simek
There is no reason to check parameters in separate switch before main
one. This patch is simplifying error path and checking parameters right
after assignment.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 44 +---
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index af2f514dca00..48902286f1d5 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -123,6 +123,14 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
fpga_fsinfo.interface = argv[6];
fpga_fsinfo.dev_part = argv[7];
fpga_fsinfo.filename = argv[8];
+
+   /* Blocksize can be zero */
+   if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
+   !fpga_fsinfo.filename) {
+   puts("ERR: Wrong interface, dev_part or filename\n");
+   return CMD_RET_USAGE;
+   }
+
argc = 5;
break;
 #endif
@@ -136,6 +144,19 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 NULL, 16);
fpga_sec_info.encflag = (u8)simple_strtoul(argv[6], NULL, 16);
fpga_sec_info.authflag = (u8)simple_strtoul(argv[5], NULL, 16);
+
+   if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
+   fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
+   puts("ERR: Use  for NonSecure bitstream\n");
+   return CMD_RET_USAGE;
+   }
+
+   if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
+   !fpga_sec_info.userkey_addr) {
+   puts("ERR: User key not provided\n");
+   return CMD_RET_USAGE;
+   }
+
argc = 5;
break;
 #endif
@@ -177,29 +198,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
switch (op) {
case FPGA_INFO:
break;
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   case FPGA_LOADFS:
-   /* Blocksize can be zero */
-   if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
-   !fpga_fsinfo.filename)
-   wrong_parms = 1;
-   break;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-   case FPGA_LOADS:
-   if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
-   fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
-   puts("ERR: use  for NonSecure bitstream\n");
-   wrong_parms = 1;
-   }
-
-   if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
-   !fpga_sec_info.userkey_addr) {
-   wrong_parms = 1;
-   puts("ERR:User key not provided\n");
-   }
-   break;
-#endif
case FPGA_LOAD:
case FPGA_LOADP:
case FPGA_LOADB:
-- 
1.9.1

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


[U-Boot] [PATCH v2 17/17] MAINTAINERS: Add myself as the FPGA maintainer

2018-08-08 Thread Michal Simek
FPGA subsystem requires special care that's why it should be maintained
via one tree.

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

Changes in v2: None
Changes in v1: None

 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 58b61ac05882..c9e414006999 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -376,6 +376,14 @@ F: test/py/tests/test_efi*
 F: cmd/bootefi.c
 F: tools/file2include.c
 
+FPGA
+M: Michal Simek 
+S: Maintained
+T: git git://git.denx.de/u-boot-microblaze.git
+F: drivers/fpga/
+F: cmd/fpga.c
+F: include/fpga.h
+
 FLATTENED DEVICE TREE
 M: Simon Glass 
 S: Maintained
-- 
1.9.1

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


[U-Boot] [PATCH v2 09/17] cmd: fpga: Create new do_fpga_wrapper for using u-boot subcommands

2018-08-08 Thread Michal Simek
Create command wrapper to clean fpga subcommands.
The function logic is taken from cmd_dm.c

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 42 --
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 0e5f4117c02e..ac12af2fa06d 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -331,10 +331,48 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return rc;
 }
 
+static cmd_tbl_t fpga_commands[] = {
+};
+
+static int do_fpga_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+  char *const argv[])
+{
+   cmd_tbl_t *fpga_cmd;
+   int ret;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   fpga_cmd = find_cmd_tbl(argv[1], fpga_commands,
+   ARRAY_SIZE(fpga_commands));
+
+   /* This should be removed when all functions are converted */
+   if (!fpga_cmd)
+   return do_fpga(cmdtp, flag, argc, argv);
+
+   /* FIXME This can't be reached till all functions are converted */
+   if (!fpga_cmd) {
+   debug("fpga: non existing command\n");
+   return CMD_RET_USAGE;
+   }
+
+   argc -= 2;
+   argv += 2;
+
+   if (argc > fpga_cmd->maxargs) {
+   debug("fpga: more parameters passed\n");
+   return CMD_RET_USAGE;
+   }
+
+   ret = fpga_cmd->cmd(fpga_cmd, flag, argc, argv);
+
+   return cmd_process_error(fpga_cmd, ret);
+}
+
 #if defined(CONFIG_CMD_FPGA_LOADFS) || defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-U_BOOT_CMD(fpga, 9, 1, do_fpga,
+U_BOOT_CMD(fpga, 9, 1, do_fpga_wrapper,
 #else
-U_BOOT_CMD(fpga, 6, 1, do_fpga,
+U_BOOT_CMD(fpga, 6, 1, do_fpga_wrapper,
 #endif
   "loadable FPGA image support",
   "[operation type] [device number] [image address] [image size]\n"
-- 
1.9.1

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


[U-Boot] [PATCH v2 07/17] cmd: fpga: Remove parameter checking from fpga loadfs command

2018-08-08 Thread Michal Simek
Parameter checking is dead code because all the time there must be all
params assigned. If they are not assigned there is no 9th parameters
passed and checking before return CMD_RET_USAGE.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 48902286f1d5..b03dd9dc0ace 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -124,13 +124,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
fpga_fsinfo.dev_part = argv[7];
fpga_fsinfo.filename = argv[8];
 
-   /* Blocksize can be zero */
-   if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
-   !fpga_fsinfo.filename) {
-   puts("ERR: Wrong interface, dev_part or filename\n");
-   return CMD_RET_USAGE;
-   }
-
argc = 5;
break;
 #endif
-- 
1.9.1

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


[U-Boot] [PATCH v2 11/17] cmd: fpga: Fix dump and all direct fpga load commands

2018-08-08 Thread Michal Simek
Separate dump, load, loadb, loadp and loadbp commands to separate
functions to make it clear how they are called and what parameters they
need.

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

Changes in v2: None
Changes in v1: None

Maybe they can be still groupped together with one switch/case but it
can be done later.

---
 cmd/fpga.c | 166 +
 1 file changed, 122 insertions(+), 44 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 039803870b02..9c715db80512 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -30,15 +30,42 @@ static long do_fpga_get_device(char *arg)
return dev;
 }
 
+static int do_fpga_check_params(long *dev, long *fpga_data, size_t *data_size,
+   cmd_tbl_t *cmdtp, int argc, char *const argv[])
+{
+   size_t local_data_size;
+   long local_fpga_data;
+
+   debug("%s %d, %d\n", __func__, argc, cmdtp->maxargs);
+
+   if (argc != cmdtp->maxargs) {
+   debug("fpga: incorrect parameters passed\n");
+   return CMD_RET_USAGE;
+   }
+
+   *dev = do_fpga_get_device(argv[0]);
+
+   local_fpga_data = simple_strtol(argv[1], NULL, 16);
+   if (!local_fpga_data) {
+   debug("fpga: zero fpga_data address\n");
+   return CMD_RET_USAGE;
+   }
+   *fpga_data = local_fpga_data;
+
+   local_data_size = simple_strtoul(argv[2], NULL, 16);
+   if (!local_data_size) {
+   debug("fpga: zero size\n");
+   return CMD_RET_USAGE;
+   }
+   *data_size = local_data_size;
+
+   return 0;
+}
+
 /* Local defines */
 enum {
FPGA_NONE = -1,
-   FPGA_LOAD,
-   FPGA_LOADB,
-   FPGA_DUMP,
FPGA_LOADMK,
-   FPGA_LOADP,
-   FPGA_LOADBP,
FPGA_LOADFS,
FPGA_LOADS,
 };
@@ -51,28 +78,14 @@ static int fpga_get_op(char *opstr)
 {
int op = FPGA_NONE;
 
-   if (!strcmp("loadb", opstr))
-   op = FPGA_LOADB;
-   else if (!strcmp("load", opstr))
-   op = FPGA_LOAD;
-#if defined(CONFIG_CMD_FPGA_LOADP)
-   else if (!strcmp("loadp", opstr))
-   op = FPGA_LOADP;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOADBP)
-   else if (!strcmp("loadbp", opstr))
-   op = FPGA_LOADBP;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOADFS)
-   else if (!strcmp("loadfs", opstr))
+   if (!strcmp("loadfs", opstr))
op = FPGA_LOADFS;
 #endif
 #if defined(CONFIG_CMD_FPGA_LOADMK)
else if (!strcmp("loadmk", opstr))
op = FPGA_LOADMK;
 #endif
-   else if (!strcmp("dump", opstr))
-   op = FPGA_DUMP;
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
else if (!strcmp("loads", opstr))
op = FPGA_LOADS;
@@ -208,26 +221,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
}
 
switch (op) {
-   case FPGA_LOAD:
-   rc = fpga_load(dev, fpga_data, data_size, BIT_FULL);
-   break;
-
-#if defined(CONFIG_CMD_FPGA_LOADP)
-   case FPGA_LOADP:
-   rc = fpga_load(dev, fpga_data, data_size, BIT_PARTIAL);
-   break;
-#endif
-
-   case FPGA_LOADB:
-   rc = fpga_loadbitstream(dev, fpga_data, data_size, BIT_FULL);
-   break;
-
-#if defined(CONFIG_CMD_FPGA_LOADBP)
-   case FPGA_LOADBP:
-   rc = fpga_loadbitstream(dev, fpga_data, data_size, BIT_PARTIAL);
-   break;
-#endif
-
 #if defined(CONFIG_CMD_FPGA_LOADFS)
case FPGA_LOADFS:
rc = fpga_fsload(dev, fpga_data, data_size, &fpga_fsinfo);
@@ -330,10 +323,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
break;
 #endif
 
-   case FPGA_DUMP:
-   rc = fpga_dump(dev, fpga_data, data_size);
-   break;
-
default:
printf("Unknown operation\n");
return CMD_RET_USAGE;
@@ -349,8 +338,97 @@ static int do_fpga_info(cmd_tbl_t *cmdtp, int flag, int 
argc,
return fpga_info(dev);
 }
 
+static int do_fpga_dump(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   size_t data_size = 0;
+   long fpga_data, dev;
+   int ret;
+
+   ret = do_fpga_check_params(&dev, &fpga_data, &data_size,
+  cmdtp, argc, argv);
+   if (ret)
+   return ret;
+
+   return fpga_dump(dev, (void *)fpga_data, data_size);
+}
+
+static int do_fpga_load(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   size_t data_size = 0;
+   long fpga_data, dev;
+   int ret;
+
+   ret = do_fpga_check_params(&dev, &fpga_data, &data_size,
+  cmdtp, argc, argv);
+   if (ret)
+   return ret;
+
+   return fpga_load(dev, (void *)fpga_data, data_size, BIT_FULL);
+}
+
+static int do_fpga_loadb(cmd_t

[U-Boot] [PATCH v2 08/17] cmd: fpga: Clean wrong_parms handling

2018-08-08 Thread Michal Simek
There is no reason to check parameters in separate switch. Check them
directly when they are read. Also there is no reason to check loadmk
case separately because fpga_data address must be non zero too.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 35 ---
 1 file changed, 8 insertions(+), 27 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index b03dd9dc0ace..0e5f4117c02e 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -83,7 +83,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const 
argv[])
char *devstr = env_get("fpga");
char *datastr = env_get("fpgadata");
int rc = FPGA_FAIL;
-   int wrong_parms = 0;
 #if defined(CONFIG_FIT)
const char *fit_uname = NULL;
ulong fit_addr;
@@ -160,7 +159,10 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
switch (argc) {
case 5: /* fpga */
data_size = simple_strtoul(argv[4], NULL, 16);
-
+   if (!data_size) {
+   puts("Zero data_size\n");
+   return CMD_RET_USAGE;
+   }
case 4: /* fpga*/
 #if defined(CONFIG_FIT)
if (fit_parse_subimage(argv[3], (ulong)fpga_data,
@@ -177,7 +179,10 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
  (ulong)fpga_data);
}
debug("%s: fpga_data = 0x%lx\n", __func__, (ulong)fpga_data);
-
+   if (!fpga_data) {
+   puts("Zero fpga_data address\n");
+   return CMD_RET_USAGE;
+   }
case 3: /* fpga   */
dev = (int)simple_strtoul(argv[2], NULL, 16);
debug("%s: device = %d\n", __func__, dev);
@@ -190,30 +195,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
 
switch (op) {
case FPGA_INFO:
-   break;
-   case FPGA_LOAD:
-   case FPGA_LOADP:
-   case FPGA_LOADB:
-   case FPGA_LOADBP:
-   case FPGA_DUMP:
-   if (!fpga_data || !data_size)
-   wrong_parms = 1;
-   break;
-#if defined(CONFIG_CMD_FPGA_LOADMK)
-   case FPGA_LOADMK:
-   if (!fpga_data)
-   wrong_parms = 1;
-   break;
-#endif
-   }
-
-   if (wrong_parms) {
-   puts("Wrong parameters for FPGA request\n");
-   return CMD_RET_USAGE;
-   }
-
-   switch (op) {
-   case FPGA_INFO:
rc = fpga_info(dev);
break;
 
-- 
1.9.1

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


[U-Boot] [PATCH v2 14/17] cmd: fpga: Add support for missing fpga loadmk commands

2018-08-08 Thread Michal Simek
There are ways how to call fpga loadmk

1. Full command
fpga loadmk [dev] [address]

2. Dev setup via variable
set fpga [dev]
fpga loadmk [address]

3. Address setup via variable
set fpgadata [address]
fpga loadmk [dev]

4. Dev and address setup via variables
set fpga [dev]
set fpgadata [address]
fpga loadmk

Before this patch only cases 1 and 3 are working but the part of code
was trying to support also cases 2 and 4.
This patch is adding support for cases 2 and 4 to have all of
combinations supported.

Signed-off-by: Michal Simek 
---

Changes in v2:
- Extend non complete commit message

Changes in v1:
- New patch from RFC

 cmd/fpga.c | 55 +++
 1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 9cb0116af734..de9d19dd8e91 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -22,7 +22,7 @@ static long do_fpga_get_device(char *arg)
/* Should be strtol to handle -1 cases */
dev = simple_strtol(devstr, NULL, 16);
 
-   if (arg)
+   if (dev == FPGA_INVALID_DEVICE && arg)
dev = simple_strtol(arg, NULL, 16);
 
debug("%s: device = %ld\n", __func__, dev);
@@ -312,29 +312,44 @@ static int do_fpga_loadmk(cmd_tbl_t *cmdtp, int flag, int 
argc,
ulong dev = do_fpga_get_device(argv[0]);
char *datastr = env_get("fpgadata");
 
-   if (datastr)
-   fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
+   debug("fpga: argc %x, dev %lx, datastr %s\n", argc, dev, datastr);
+
+   if (dev == FPGA_INVALID_DEVICE) {
+   debug("fpga: Invalid fpga device\n");
+   return CMD_RET_USAGE;
+   }
+
+   if (argc == 0 && !datastr) {
+   debug("fpga: No datastr passed\n");
+   return CMD_RET_USAGE;
+   }
 
if (argc == 2) {
+   datastr = argv[1];
+   debug("fpga: Full command with two args\n");
+   } else if (argc == 1 && !datastr) {
+   debug("fpga: Dev is setup - fpgadata passed\n");
+   datastr = argv[0];
+   }
+
 #if defined(CONFIG_FIT)
-   if (fit_parse_subimage(argv[1], (ulong)fpga_data,
-  &fit_addr, &fit_uname)) {
-   fpga_data = (void *)fit_addr;
-   debug("*  fpga: subimage '%s' from FIT image ",
- fit_uname);
-   debug("at 0x%08lx\n", fit_addr);
-   } else
+   if (fit_parse_subimage(datastr, (ulong)fpga_data,
+  &fit_addr, &fit_uname)) {
+   fpga_data = (void *)fit_addr;
+   debug("*  fpga: subimage '%s' from FIT image ",
+ fit_uname);
+   debug("at 0x%08lx\n", fit_addr);
+   } else
 #endif
-   {
-   fpga_data = (void *)simple_strtoul(argv[1], NULL, 16);
-   debug("*  fpga: cmdline image address = 0x%08lx\n",
- (ulong)fpga_data);
-   }
-   debug("%s: fpga_data = 0x%lx\n", __func__, (ulong)fpga_data);
-   if (!fpga_data) {
-   puts("Zero fpga_data address\n");
-   return CMD_RET_USAGE;
-   }
+   {
+   fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
+   debug("*  fpga: cmdline image address = 0x%08lx\n",
+ (ulong)fpga_data);
+   }
+   debug("%s: fpga_data = 0x%lx\n", __func__, (ulong)fpga_data);
+   if (!fpga_data) {
+   puts("Zero fpga_data address\n");
+   return CMD_RET_USAGE;
}
 
switch (genimg_get_format(fpga_data)) {
-- 
1.9.1

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


[U-Boot] [PATCH v2 16/17] cmd: fpga: Fix loads command

2018-08-08 Thread Michal Simek
Convert last loads command to fpga subcommands.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 148 +++--
 1 file changed, 36 insertions(+), 112 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 89fae86b8253..88a8e3f3186b 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -62,130 +62,57 @@ static int do_fpga_check_params(long *dev, long 
*fpga_data, size_t *data_size,
return 0;
 }
 
-/* Local defines */
-enum {
-   FPGA_NONE = -1,
-   FPGA_LOADS,
-};
-
-/*
- * Map op to supported operations.  We don't use a table since we
- * would just have to relocate it from flash anyway.
- */
-static int fpga_get_op(char *opstr)
-{
-   int op = FPGA_NONE;
-
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-   if (!strcmp("loads", opstr))
-   op = FPGA_LOADS;
-#endif
-
-   return op;
-}
-
-/* - */
-/* command form:
- *   fpga
- * where op is 'load', 'dump', or 'info'
- * If there is no device number field, the fpga environment variable is used.
- * If there is no data addr field, the fpgadata environment variable is used.
- * The info command requires no data address field.
- */
-int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+int do_fpga_loads(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
-   int op, dev = FPGA_INVALID_DEVICE;
size_t data_size = 0;
-   void *fpga_data = NULL;
-   int rc = FPGA_FAIL;
-#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+   long fpga_data, dev;
+   int ret;
struct fpga_secure_info fpga_sec_info;
 
memset(&fpga_sec_info, 0, sizeof(fpga_sec_info));
-#endif
 
-   if (argc > 9 || argc < 2) {
-   debug("%s: Too many or too few args (%d)\n", __func__, argc);
+   if (argc < 5) {
+   debug("fpga: incorrect parameters passed\n");
return CMD_RET_USAGE;
}
 
-   op = fpga_get_op(argv[1]);
-
-   switch (op) {
-   case FPGA_NONE:
-   printf("Unknown fpga operation \"%s\"\n", argv[1]);
+   if (argc == 6)
+   fpga_sec_info.userkey_addr = (u8 *)(uintptr_t)
+ simple_strtoull(argv[5],
+ NULL, 16);
+   else
+   /*
+* If 6th parameter is not passed then do_fpga_check_params
+* will get 5 instead of expected 6 which means that function
+* return CMD_RET_USAGE. Increase number of params +1 to pass
+* this.
+*/
+   argc++;
+
+   fpga_sec_info.encflag = (u8)simple_strtoul(argv[4], NULL, 16);
+   fpga_sec_info.authflag = (u8)simple_strtoul(argv[3], NULL, 16);
+
+   if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
+   fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
+   debug("fpga: Use  for NonSecure bitstream\n");
return CMD_RET_USAGE;
-#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-   case FPGA_LOADS:
-   if (argc < 7)
-   return CMD_RET_USAGE;
-   if (argc == 8)
-   fpga_sec_info.userkey_addr = (u8 *)(uintptr_t)
-simple_strtoull(argv[7],
-NULL, 16);
-   fpga_sec_info.encflag = (u8)simple_strtoul(argv[6], NULL, 16);
-   fpga_sec_info.authflag = (u8)simple_strtoul(argv[5], NULL, 16);
-
-   if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
-   fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
-   puts("ERR: Use  for NonSecure bitstream\n");
-   return CMD_RET_USAGE;
-   }
-
-   if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
-   !fpga_sec_info.userkey_addr) {
-   puts("ERR: User key not provided\n");
-   return CMD_RET_USAGE;
-   }
-
-   argc = 5;
-   break;
-#endif
-   default:
-   break;
}
 
-   switch (argc) {
-   case 5: /* fpga */
-   data_size = simple_strtoul(argv[4], NULL, 16);
-   if (!data_size) {
-   puts("Zero data_size\n");
-   return CMD_RET_USAGE;
-   }
-   case 4: /* fpga*/
-   {
-   fpga_data = (void *)simple_strtoul(argv[3], NULL, 16);
-   debug("*  fpga: cmdline image address = 0x%08lx\n",
- (ulong)fpga_data);
-   }
-   debug("%s: fpga_data = 0x%lx\n", __func__, (ulong)fpga_data);
-   if (!fpga_data)

Re: [U-Boot] [PATCH v1 14/17] cmd: fpga: Add support for missing fpga loadmk commands

2018-08-08 Thread Michal Simek
On 8.8.2018 11:56, Simon Glass wrote:
> Hi Michal,
> 
> On 3 August 2018 at 00:13, Michal Simek  wrote:
>> On 2.8.2018 22:37, Simon Glass wrote:
>>> On 26 July 2018 at 08:16, Michal Simek  wrote:
 Not all 4 fpga loadmk FIT image commands
>>>
>>> I don't understand this. Can you explain what you mean?
>>
>> hm not sure why I have written this short commit message.
>> Maybe I wanted to extend it later when I was doing rebasing.
>>
>> Anyway let me explain.
>>
>> There are ways how to call fpga loadmk
>>
>> 1. Full command
>> fpga loadmk [dev] [address]
>>
>> 2. Dev setup via variable
>> set fpga [dev]
>> fpga loadmk [address]
>>
>> 3. Address setup via variable
>> set fpgadata [address]
>> fpga loadmk [dev]
>>
>> 4. Dev and address setup via variables
>> set fpga [dev]
>> set fpgadata [address]
>> fpga loadmk
>>
>> Before this patch only cases 1 and 3 were working but the part of code
>> was trying to support also cases 2 and 4.
>> That's why I have added all these use cases to pytest to make sure that
>> all of them are working fine.
> 
> OK great, thanks. Can you please expand the commit message a little?

v2 sent.

Thanks,
Michal

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


[U-Boot] [PATCH v2 13/17] cmd: fpga: Fix loadmk command

2018-08-08 Thread Michal Simek
Convert loadmk command to fpga subcommands. Not all combinations are
working but they have never worked properly. This will be fixed later.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 238 -
 1 file changed, 123 insertions(+), 115 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 826f63371a66..9cb0116af734 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -65,7 +65,6 @@ static int do_fpga_check_params(long *dev, long *fpga_data, 
size_t *data_size,
 /* Local defines */
 enum {
FPGA_NONE = -1,
-   FPGA_LOADMK,
FPGA_LOADS,
 };
 
@@ -77,12 +76,8 @@ static int fpga_get_op(char *opstr)
 {
int op = FPGA_NONE;
 
-#if defined(CONFIG_CMD_FPGA_LOADMK)
-   if (!strcmp("loadmk", opstr))
-   op = FPGA_LOADMK;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-   else if (!strcmp("loads", opstr))
+   if (!strcmp("loads", opstr))
op = FPGA_LOADS;
 #endif
 
@@ -102,24 +97,13 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
int op, dev = FPGA_INVALID_DEVICE;
size_t data_size = 0;
void *fpga_data = NULL;
-   char *devstr = env_get("fpga");
-   char *datastr = env_get("fpgadata");
int rc = FPGA_FAIL;
-#if defined(CONFIG_FIT)
-   const char *fit_uname = NULL;
-   ulong fit_addr;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
struct fpga_secure_info fpga_sec_info;
 
memset(&fpga_sec_info, 0, sizeof(fpga_sec_info));
 #endif
 
-   if (devstr)
-   dev = (int) simple_strtoul(devstr, NULL, 16);
-   if (datastr)
-   fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
-
if (argc > 9 || argc < 2) {
debug("%s: Too many or too few args (%d)\n", __func__, argc);
return CMD_RET_USAGE;
@@ -169,15 +153,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return CMD_RET_USAGE;
}
case 4: /* fpga*/
-#if defined(CONFIG_FIT)
-   if (fit_parse_subimage(argv[3], (ulong)fpga_data,
-  &fit_addr, &fit_uname)) {
-   fpga_data = (void *)fit_addr;
-   debug("*  fpga: subimage '%s' from FIT image ",
- fit_uname);
-   debug("at 0x%08lx\n", fit_addr);
-   } else
-#endif
{
fpga_data = (void *)simple_strtoul(argv[3], NULL, 16);
debug("*  fpga: cmdline image address = 0x%08lx\n",
@@ -204,95 +179,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
rc = fpga_loads(dev, fpga_data, data_size, &fpga_sec_info);
break;
 #endif
-#if defined(CONFIG_CMD_FPGA_LOADMK)
-   case FPGA_LOADMK:
-   switch (genimg_get_format(fpga_data)) {
-#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
-   case IMAGE_FORMAT_LEGACY:
-   {
-   image_header_t *hdr =
-   (image_header_t *)fpga_data;
-   ulong data;
-   uint8_t comp;
-
-   comp = image_get_comp(hdr);
-   if (comp == IH_COMP_GZIP) {
-#if defined(CONFIG_GZIP)
-   ulong image_buf = image_get_data(hdr);
-   data = image_get_load(hdr);
-   ulong image_size = ~0UL;
-
-   if (gunzip((void *)data, ~0UL,
-  (void *)image_buf,
-  &image_size) != 0) {
-   puts("GUNZIP: error\n");
-   return 1;
-   }
-   data_size = image_size;
-#else
-   puts("Gunzip image is not supported\n");
-   return 1;
-#endif
-   } else {
-   data = (ulong)image_get_data(hdr);
-   data_size = image_get_data_size(hdr);
-   }
-   rc = fpga_load(dev, (void *)data, data_size,
-  BIT_FULL);
-   }
-   break;
-#endif
-#if defined(CONFIG_FIT)
-   case IMAGE_FORMAT_FIT:
-   {
-   const void *fit_hdr = (const void *)fpga_data;
-   int noffset;
- 

[U-Boot] [PATCH v2 15/17] cmd: fpga: Use CMD_RET_FAILURE instead of simple 1

2018-08-08 Thread Michal Simek
Use standard return command failure macro.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index de9d19dd8e91..89fae86b8253 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -371,7 +371,7 @@ static int do_fpga_loadmk(cmd_tbl_t *cmdtp, int flag, int 
argc,
if (gunzip((void *)data, ~0UL, (void *)image_buf,
   &image_size) != 0) {
puts("GUNZIP: error\n");
-   return 1;
+   return CMD_RET_FAILURE;
}
data_size = image_size;
 #else
@@ -395,32 +395,32 @@ static int do_fpga_loadmk(cmd_tbl_t *cmdtp, int flag, int 
argc,
 
if (!fit_uname) {
puts("No FIT subimage unit name\n");
-   return 1;
+   return CMD_RET_FAILURE;
}
 
if (!fit_check_format(fit_hdr)) {
puts("Bad FIT image format\n");
-   return 1;
+   return CMD_RET_FAILURE;
}
 
/* get fpga component image node offset */
noffset = fit_image_get_node(fit_hdr, fit_uname);
if (noffset < 0) {
printf("Can't find '%s' FIT subimage\n", fit_uname);
-   return 1;
+   return CMD_RET_FAILURE;
}
 
/* verify integrity */
if (!fit_image_verify(fit_hdr, noffset)) {
puts("Bad Data Hash\n");
-   return 1;
+   return CMD_RET_FAILURE;
}
 
/* get fpga subimage data address and length */
if (fit_image_get_data(fit_hdr, noffset, &fit_data,
   &data_size)) {
puts("Fpga subimage data not found\n");
-   return 1;
+   return CMD_RET_FAILURE;
}
 
return fpga_load(dev, fit_data, data_size, BIT_FULL);
@@ -428,7 +428,7 @@ static int do_fpga_loadmk(cmd_tbl_t *cmdtp, int flag, int 
argc,
 #endif
default:
puts("** Unknown image type\n");
-   return FPGA_FAIL;
+   return CMD_RET_FAILURE;
}
 }
 #endif
-- 
1.9.1

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


[U-Boot] [PATCH v2 12/17] cmd: fpga: Fix loadfs command

2018-08-08 Thread Michal Simek
Convert loadfs command to fpga subcommands.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 58 --
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 9c715db80512..826f63371a66 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -66,7 +66,6 @@ static int do_fpga_check_params(long *dev, long *fpga_data, 
size_t *data_size,
 enum {
FPGA_NONE = -1,
FPGA_LOADMK,
-   FPGA_LOADFS,
FPGA_LOADS,
 };
 
@@ -78,12 +77,8 @@ static int fpga_get_op(char *opstr)
 {
int op = FPGA_NONE;
 
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   if (!strcmp("loadfs", opstr))
-   op = FPGA_LOADFS;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOADMK)
-   else if (!strcmp("loadmk", opstr))
+   if (!strcmp("loadmk", opstr))
op = FPGA_LOADMK;
 #endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
@@ -114,10 +109,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
const char *fit_uname = NULL;
ulong fit_addr;
 #endif
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   fpga_fs_info fpga_fsinfo;
-   fpga_fsinfo.fstype = FS_TYPE_ANY;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
struct fpga_secure_info fpga_sec_info;
 
@@ -140,19 +131,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
case FPGA_NONE:
printf("Unknown fpga operation \"%s\"\n", argv[1]);
return CMD_RET_USAGE;
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   case FPGA_LOADFS:
-   if (argc < 9)
-   return CMD_RET_USAGE;
-   fpga_fsinfo.blocksize = (unsigned int)
-   simple_strtoul(argv[5], NULL, 16);
-   fpga_fsinfo.interface = argv[6];
-   fpga_fsinfo.dev_part = argv[7];
-   fpga_fsinfo.filename = argv[8];
-
-   argc = 5;
-   break;
-#endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
case FPGA_LOADS:
if (argc < 7)
@@ -221,18 +199,11 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
}
 
switch (op) {
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-   case FPGA_LOADFS:
-   rc = fpga_fsload(dev, fpga_data, data_size, &fpga_fsinfo);
-   break;
-#endif
-
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
case FPGA_LOADS:
rc = fpga_loads(dev, fpga_data, data_size, &fpga_sec_info);
break;
 #endif
-
 #if defined(CONFIG_CMD_FPGA_LOADMK)
case FPGA_LOADMK:
switch (genimg_get_format(fpga_data)) {
@@ -330,6 +301,30 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return rc;
 }
 
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+static int do_fpga_loadfs(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+   size_t data_size = 0;
+   long fpga_data, dev;
+   int ret;
+   fpga_fs_info fpga_fsinfo;
+
+   ret = do_fpga_check_params(&dev, &fpga_data, &data_size,
+  cmdtp, argc, argv);
+   if (ret)
+   return ret;
+
+   fpga_fsinfo.fstype = FS_TYPE_ANY;
+   fpga_fsinfo.blocksize = (unsigned int)simple_strtoul(argv[3], NULL, 16);
+   fpga_fsinfo.interface = argv[4];
+   fpga_fsinfo.dev_part = argv[5];
+   fpga_fsinfo.filename = argv[6];
+
+   return fpga_fsload(dev, (void *)fpga_data, data_size, &fpga_fsinfo);
+}
+#endif
+
 static int do_fpga_info(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
 {
@@ -429,6 +424,9 @@ static cmd_tbl_t fpga_commands[] = {
 #if defined(CONFIG_CMD_FPGA_LOADBP)
U_BOOT_CMD_MKENT(loadbp, 3, 1, do_fpga_loadbp, "", ""),
 #endif
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+   U_BOOT_CMD_MKENT(loadfs, 7, 1, do_fpga_loadfs, "", ""),
+#endif
 };
 
 static int do_fpga_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
-- 
1.9.1

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


[U-Boot] [PATCH v2 10/17] cmd: fpga: Extract fpga info command to separate function

2018-08-08 Thread Michal Simek
Move fpga info to U_BOOT_CMD_MKENT subcommand.
Also use strtol instead of simple_strtoul. The reason is that if -1 is
passed (or fpga info without "fpga" variable) the list of all fpgas is
shown.
This functionality is in the fpga core but it couldn't be performed.

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

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 35 +++
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index ac12af2fa06d..039803870b02 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -13,10 +13,26 @@
 #include 
 #include 
 
+static long do_fpga_get_device(char *arg)
+{
+   long dev = FPGA_INVALID_DEVICE;
+   char *devstr = env_get("fpga");
+
+   if (devstr)
+   /* Should be strtol to handle -1 cases */
+   dev = simple_strtol(devstr, NULL, 16);
+
+   if (arg)
+   dev = simple_strtol(arg, NULL, 16);
+
+   debug("%s: device = %ld\n", __func__, dev);
+
+   return dev;
+}
+
 /* Local defines */
 enum {
FPGA_NONE = -1,
-   FPGA_INFO,
FPGA_LOAD,
FPGA_LOADB,
FPGA_DUMP,
@@ -35,9 +51,7 @@ static int fpga_get_op(char *opstr)
 {
int op = FPGA_NONE;
 
-   if (!strcmp("info", opstr))
-   op = FPGA_INFO;
-   else if (!strcmp("loadb", opstr))
+   if (!strcmp("loadb", opstr))
op = FPGA_LOADB;
else if (!strcmp("load", opstr))
op = FPGA_LOAD;
@@ -194,10 +208,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
}
 
switch (op) {
-   case FPGA_INFO:
-   rc = fpga_info(dev);
-   break;
-
case FPGA_LOAD:
rc = fpga_load(dev, fpga_data, data_size, BIT_FULL);
break;
@@ -331,7 +341,16 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char 
*const argv[])
return rc;
 }
 
+static int do_fpga_info(cmd_tbl_t *cmdtp, int flag, int argc,
+   char * const argv[])
+{
+   long dev = do_fpga_get_device(argv[0]);
+
+   return fpga_info(dev);
+}
+
 static cmd_tbl_t fpga_commands[] = {
+   U_BOOT_CMD_MKENT(info, 1, 1, do_fpga_info, "", ""),
 };
 
 static int do_fpga_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
-- 
1.9.1

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


Re: [U-Boot] [RESEND PATCH V2 3/3] imx: mx7: add system suspend/resume support

2018-08-08 Thread Stefan Agner
On 08.08.2018 11:09, Anson Huang wrote:
> Hi, Stefan
> 
> Anson Huang
> Best Regards!
> 
> 
>> -Original Message-
>> From: Stefan Agner [mailto:ste...@agner.ch]
>> Sent: Wednesday, August 8, 2018 5:03 PM
>> To: Anson Huang 
>> Cc: sba...@denx.de; Fabio Estevam ;
>> albert.u.b...@aribaud.net; bryan.odonog...@linaro.org;
>> uri.mashi...@compulab.co.il; Stefan Agner ;
>> Peng Fan ; Ye Li ; s...@chromium.org;
>> u-boot@lists.denx.de; dl-linux-imx 
>> Subject: Re: [U-Boot] [RESEND PATCH V2 3/3] imx: mx7: add system
>> suspend/resume support
>>
>> Hi Anson,
>>
>> On 08.08.2018 03:17, Anson Huang wrote:
>> > This patch adds system suspend/resume support, when linux kernel
>> > enters deep sleep mode, SoC will go into below mode:
>> >
>> >  - CA7 platform goes into STOP mode;
>> >  - SoC goes into DSM mode;
>> >  - DDR goes into self-refresh mode;
>> >  - CPU0/SCU will be powered down.
>> >
>> > When wake up event arrives:
>> >
>> >  - SoC DSM mdoe exits;
>> >  - CA7 platform exit STOP mode, SCU/CPU0 power up;
>> >  - Invalidate L1 cache;
>> >  - DDR exit self-refresh mode;
>> >  - Do secure monitor mode related initialization;
>> >  - Jump to linux kernel resume entry.
>> >
>> > Belwo is the log of 1 iteration of system suspend/resume:
>> >
>> > [  338.824862] PM: suspend entry (deep) [  338.828853] PM: Syncing
>> > filesystems ... done.
>> > [  338.834433] Freezing user space processes ... (elapsed 0.001 seconds)
>> done.
>> > [  338.842939] OOM killer disabled.
>> > [  338.846182] Freezing remaining freezable tasks ... (elapsed 0.001
>> > seconds) done.
>> > [  338.869717] PM: suspend devices took 0.010 seconds [  338.877846]
>> > Disabling non-boot CPUs ...
>> > [  338.960301] Retrying again to check for CPU kill [  338.964953]
>> > CPU1 killed.
>> > [  338.968104] Enabling non-boot CPUs ...
>> > [  338.973598] CPU1 is up
>> > [  339.267155] mmc1: queuing unknown CIS tuple 0x80 (2 bytes) [
>> > 339.275833] mmc1: queuing unknown CIS tuple 0x80 (7 bytes) [
>> > 339.284158] mmc1: queuing unknown CIS tuple 0x80 (6 bytes) [
>> > 339.385065] PM: resume devices took 0.400 seconds [  339.389836] OOM
>> > killer enabled.
>> > [  339.392986] Restarting tasks ... done.
>> > [  339.398990] PM: suspend exit
>>
>> Gave this a try with a 3.18-rc6 kernel today on our Colibri iMX7, I could
>> successfully suspend and resume using RTC wakealarm.
>>
>> What is a bit weird is that sometimes the SoC seems to consume more power
>> than other times (sometimes 135mW, sometimes 60mW). Any idea where that
>> could come from?
>>
>> In any case, the system seems to wakeup just fine.
>  
> I ONLY tried the function with latest 4.18 kernel and did NOT measure
> the power, if the power you saw
> is a board level total power, then I have no idea, maybe you can
> disable all peripheral devices
> in dtb to have another try, could be some peripherals' different state
> consuming different
> power, if you can break down the power rails to VDD_ARM, VDD_SOC and VDDA_1P8,
> then I think you should be able to see the benefit, and from each
> power rails' number,
> maybe we can figure out why, but I think this patch set is mainly for
> function level, for
> power number optimization, we can have patch later, I think.

I checked VDD_ARM, it gets turned off properly. But yeah, could
definitely be related to some peripheral. Just wanted to ask you since
you just worked with it.

I agree, this finding should not hold back the merge of this patch set.

> 
> Noted that latest kernel's PCIe driver has resume issue, you have to
> disable PCIe if using 4.18 kernel.

We do not use PCIe by default, so I think it should not have any
influence.

> I suggest you to break down power rails first.

Yeah will have a closer look to all the individual rails. However, due
to other priorities I probably will do this at a later time.

Since suspend/resume does work stable:

Acked-by: Stefan Agner 
Tested-by: Stefan Agner 

--
Stefan

> 
> Anson.
>>
>> --
>> Stefan
>>
>> >
>> > The resume entry function has to initialize stack pointer before
>> > calling C code, otherwise there will be an external abort occur, in
>> > additional, invalidate L1 cache must be done in secure section as
>> > well, so this patch also adds assembly code back and keep it as simple as
>> possible.
>> >
>> > Signed-off-by: Anson Huang 
>> > ---
>> >  arch/arm/mach-imx/mx7/Makefile   |   2 +-
>> >  arch/arm/mach-imx/mx7/psci-mx7.c | 449
>> ++-
>> >  arch/arm/mach-imx/mx7/psci-suspend.S |  67 ++
>> >  3 files changed, 515 insertions(+), 3 deletions(-)  create mode
>> > 100644 arch/arm/mach-imx/mx7/psci-suspend.S
>> >
>> > diff --git a/arch/arm/mach-imx/mx7/Makefile
>> > b/arch/arm/mach-imx/mx7/Makefile index 94a0e64..f1436e2 100644
>> > --- a/arch/arm/mach-imx/mx7/Makefile
>> > +++ b/arch/arm/mach-imx/mx7/Makefile
>> > @@ -4,4 +4,4 @@
>> >  #
>> >
>> >  obj-y := soc.o clock.o clock_slice.o ddr.o snvs.o
>> > -obj-$(CONFIG_ARMV7_PSCI)  += psci-mx7.

Re: [U-Boot] Can't boot my FIT image: 'Could not find configuration node'

2018-08-08 Thread Grant Jurgensen
Hi Johann,

I apologize, that typo is actually just in the email. My actual file has
"kernel-0" in both locations. It seems my fit image is formed correctly
based on the header information:

...$ mkimage -F sel4.itb
FIT description: SeL4
Created: Tue Aug  7 10:56:42 2018
 Image 0 (kernel-0)
  Description:  SeL4 image
  Created:  Tue Aug  7 10:56:42 2018
  Type: Kernel Image
  Compression:  uncompressed
  Data Size:1033080 Bytes = 1008.87 kB = 0.99 MB
  Architecture: ARM
  OS:   QNX
  Load Address: 0x4800
  Entry Point:  0x4800
 Default Configuration: 'config-0'
 Configuration 0 (config-0)
  Description:  default config
  Kernel:   kernel-0

Likewise, I get the same information using the `iminfo` command within
u-boot.

Sorry again for the typo,
Grant

On Tue, Aug 7, 2018 at 12:16 AM Johann Neuhauser <
jneuhau...@dh-electronics.de> wrote:

> Dear Grant,
>
> I see there is a typo in your kernel node name.
>
> In the image section you wrote kerne-0 and in the config section you wrote
> kernel = "kernel-0";
> Probably this is the issue that no config and kernel  image is found.
>
> Regards,
>
> Johann Neuhauser
>
> > -Ursprüngliche Nachricht-
> > Von: U-Boot [mailto:u-boot-boun...@lists.denx.de] Im Auftrag von Grant
> > Jurgensen
> > Gesendet: Montag, 6. August 2018 19:50
> > An: u-boot@lists.denx.de
> > Betreff: [U-Boot] Can't boot my FIT image: 'Could not find configuration
> > node'
> >
> > Hi,
> >
> > I'm using U-boot to boot an ELF image. I am easily able to load the
> image into
> > memory and boot it with the `bootelf` command. However, I'd like to
> create
> > a FIT image in order to make use of the convenient hashing and secure
> boot
> > features, but I'm having trouble getting my image to boot.
> >
> > Here is my current `.its` file (currently as simple as possible until I
> get it to
> > boot):
> >
> > /dts-v1/;
> >
> > / {
> > description = "SeL4";
> > #address-cells = <1>;
> >
> > images {
> > kerne-0 {
> > description = "SeL4 image";
> > data = /incbin/("./test_app-image-arm-exynos5");
> > type = "kernel";
> > arch = "arm";
> > os = "qnx";
> > compression = "none";
> > load = <0x4800>;
> > entry = <0x4800>;
> > };
> > };
> >
> > configurations {
> > default = "config-0";
> > config-0 {
> >  description = "default config";
> >  kernel = "kernel-0";
> > };
> > };
> > };
> >
> > By the way, my ELF image isn't actually a qnx kernel. It is a sel4
> kernel,
> > however "sel4" is not an option. (I can make a uImage with `mkimage -A
> arm
> > -a 0x4800 -e 0x4800 -C none -T kernel -O qnx -d
> > test_app-image-exynos5 image` and can actually boot the resulting image
> > here with `bootm` no problem, so I believe using the qnx OS setting
> > shouldn't be a problem.)
> >
> > I am then able to create the FIT image with `mkimage -f sel4.its
> sel4.itb`.
> > I copy this image to my SD card, successfully load the fit image into
> memory
> > (with `fatload`), but then `bootm` fails with the following message:
> >
> > ## Loading kernel from FIT Image at 5000 ...
> > Could not find configuration node
> > ERROR: can't get kernel image!
> >
> > I can't make sense of this error. `iminfo` recognizes my default
> configuration,
> > yet `bootm` can't find the configuration node?
> >
> > Thanks,
> > Grant
> > ___
> > U-Boot mailing list
> > U-Boot@lists.denx.de
> > https://lists.denx.de/listinfo/u-boot
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ls1088ardb_pb: Add support for ls1088ardb_pb board.

2018-08-08 Thread Pramod Kumar
ls1088ardb-pb is another varinat of the ls1088ardb.
This board support two m.2 x2 gen 3 pcie card slot.
There is no support of sata, pcie standard slot,
miniPCIE slot and TDM in this board.

Signed-off-by: Pramod Kumar 
---
 arch/arm/Kconfig  | 14 +++
 arch/arm/cpu/armv8/Kconfig|  1 +
 board/freescale/ls1088a/Kconfig   | 43 +
 board/freescale/ls1088a/MAINTAINERS   | 18 
 board/freescale/ls1088a/Makefile  |  1 +
 board/freescale/ls1088a/ddr.h |  4 +-
 board/freescale/ls1088a/ls1088a.c | 23 -
 ... ls1088ardb_pb_qspi_SECURE_BOOT_defconfig} |  2 +-
 ...defconfig => ls1088ardb_pb_qspi_defconfig} |  2 +-
 ...ardb_pb_sdcard_qspi_SECURE_BOOT_defconfig} |  2 +-
 ...ig => ls1088ardb_pb_sdcard_qspi_defconfig} |  2 +-
 include/configs/ls1088ardb_pb.h   | 87 +++
 12 files changed, 189 insertions(+), 10 deletions(-)
 copy configs/{ls1088ardb_qspi_SECURE_BOOT_defconfig => 
ls1088ardb_pb_qspi_SECURE_BOOT_defconfig} (97%)
 copy configs/{ls1088ardb_qspi_defconfig => ls1088ardb_pb_qspi_defconfig} (97%)
 copy configs/{ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig => 
ls1088ardb_pb_sdcard_qspi_SECURE_BOOT_defconfig} (98%)
 copy configs/{ls1088ardb_sdcard_qspi_defconfig => 
ls1088ardb_pb_sdcard_qspi_defconfig} (98%)
 create mode 100644 include/configs/ls1088ardb_pb.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 63ec02403a..fec588c817 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1120,6 +1120,20 @@ config TARGET_LS1088ARDB
  development platform that supports the QorIQ LS1088A
  Layerscape Architecture processor.
 
+config TARGET_LS1088ARDB_PB
+   bool "Support ls1088ardb_pb"
+   select ARCH_LS1088A
+   select ARM64
+   select ARMV8_MULTIENTRY
+   select ARCH_MISC_INIT
+   select BOARD_LATE_INIT
+   select SUPPORT_SPL
+   help
+ Support for NXP LS1088ARDB_PB platform.
+ The LS1088A Reference design board (RDB_PB) is a high-performance
+ development platform that supports the QorIQ LS1088A
+ Layerscape Architecture processor.
+
 config TARGET_LS1021AQDS
bool "Support ls1021aqds"
select ARCH_LS1021A
diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
index c8bebabdf6..8ede276b65 100644
--- a/arch/arm/cpu/armv8/Kconfig
+++ b/arch/arm/cpu/armv8/Kconfig
@@ -100,6 +100,7 @@ config PSCI_RESET
   !TARGET_LS2080A_SIMU && !TARGET_LS2080AQDS && \
   !TARGET_LS2080ARDB && !TARGET_LS2080A_EMU && \
   !TARGET_LS1088ARDB && !TARGET_LS1088AQDS && \
+  !TARGET_LS1088ARDB_PB && \
   !TARGET_LS1012ARDB && !TARGET_LS1012AFRDM && \
   !TARGET_LS1012A2G5RDB && !TARGET_LS1012AQDS && \
   !TARGET_LS1012AFRWY && \
diff --git a/board/freescale/ls1088a/Kconfig b/board/freescale/ls1088a/Kconfig
index 8bb828e3fd..9f20d7247f 100644
--- a/board/freescale/ls1088a/Kconfig
+++ b/board/freescale/ls1088a/Kconfig
@@ -59,3 +59,46 @@ endif
 
 source "board/freescale/common/Kconfig"
 endif
+
+if TARGET_LS1088ARDB_PB
+
+config SYS_BOARD
+   default "ls1088a"
+
+config SYS_VENDOR
+   default "freescale"
+
+config SYS_SOC
+   default "fsl-layerscape"
+
+config SYS_CONFIG_NAME
+   default "ls1088ardb_pb"
+
+if SYS_LS_PPA_FW_IN_XIP
+
+config SYS_LS_PPA_FW_ADDR
+   hex "PPA Firmware Addr"
+   default 0x2040
+
+if CHAIN_OF_TRUST
+config SYS_LS_PPA_ESBC_ADDR
+   hex "PPA Firmware HDR Addr"
+   default 0x2068
+endif
+endif
+
+if (SYS_LS_PPA_FW_IN_MMC || SYS_LS_PPA_FW_IN_NAND)
+
+config SYS_LS_PPA_FW_ADDR
+   hex "PPA Firmware Addr"
+   default 0x40
+
+if CHAIN_OF_TRUST
+config SYS_LS_PPA_ESBC_ADDR
+   hex "PPA Firmware HDR Addr"
+   default 0x68
+endif
+endif
+
+source "board/freescale/common/Kconfig"
+endif
diff --git a/board/freescale/ls1088a/MAINTAINERS 
b/board/freescale/ls1088a/MAINTAINERS
index 4d804d9447..dbcac49a60 100644
--- a/board/freescale/ls1088a/MAINTAINERS
+++ b/board/freescale/ls1088a/MAINTAINERS
@@ -7,6 +7,14 @@ F: include/configs/ls1088ardb.h
 F: configs/ls1088ardb_qspi_defconfig
 F: configs/ls1088ardb_sdcard_qspi_defconfig
 
+LS1088ARDB_PB BOARD
+M: Pramod Kumar 
+S: Maintained
+F: board/freescale/ls1088a/
+F: include/configs/ls1088ardb_pb.h
+F: configs/ls1088ardb_pb_qspi_defconfig
+F: configs/ls1088ardb_pb_sdcard_qspi_defconfig
+
 LS1088AQDS BOARD
 M: Prabhakar Kushwaha 
 M: Ashish Kumar 
@@ -34,3 +42,13 @@ LS1088ARDB_SD_SECURE_BOOT BOARD
 M: Sumit Garg 
 S: Maintained
 F: configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig
+
+LS1088ARDB_PB_QSPI_SECURE_BOOT BOARD
+M:  Udit Agarwal 
+S:  Maintained
+F:  configs/ls1088ardb_pb_qspi_SECURE_BOOT_defconfig
+
+LS1088ARDB_PB_SD_SECURE_BOOT BOARD
+M:  Udit Agarwal 
+S:  Maintained
+F:   

Re: [U-Boot] [PATCH 1/1] mtd: nand: fsl_ifc: Fix handling of bitflips in erased pages

2018-08-08 Thread Kurt Kanzenbach
Hi York,

On Tue, Aug 07, 2018 at 09:52:46PM +, York Sun wrote:
> On 08/02/2018 01:03 AM, Kurt Kanzenbach wrote:
> > From: Darwin Dingel 
> >
> > This is a fix made for the fsl_ifc_nand driver on linux kernel by
> > Pavel Machek and is applied to uboot. It is currently on applied on
> > linux-mtd.
> >
> > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F9758117%2F&data=02%7C01%7Cyork.sun%40nxp.com%7C79aca70c61e943b59b1d08d5f84e77eb%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636687938268644852&sdata=PjrH%2FF6LyGA%2BpVjHfqQpn4qhvJKeRHG%2Fb3434wuQy3o%3D&reserved=0
> >
> > IFC always raises ECC errors on erased pages. It is only ignored when
> > the buffer is checked for all 0xFF by is_blank(). The problem is a
> > single bitflip will cause is_blank() and then mtd_read to fail. The fix
> > makes use of nand_check_erased_ecc_chunk() to check for empty pages
> > instead of is_blank(). This also makes sure that reads are made at ECC
> > page size granularity to get a proper bitflip count. If the number of
> > bitflips does not exceed the ECC strength, the page is considered empty
> > and the bitflips will be corrected when data is sent to the higher
> > layers (e.g. ubi).
> >
> > Signed-off-by: Darwin Dingel 
> > Cc: Pavel Machek 
> > Cc: Scott Wood 
> > Acked-by: Pavel Machek 
> > [Kurt: Replaced dev_err by printf due to compiler warnings]
> > Tested-by: Kurt Kanzenbach 
> > Signed-off-by: Kurt Kanzenbach 
> > ---
> >  drivers/mtd/nand/fsl_ifc_nand.c | 69 
> > +++--
> >  1 file changed, 39 insertions(+), 30 deletions(-)
>
> Scott,
>
> Please comment. I can bring it in with your ack.

I guess Scott stepped down as NAND maintainer (see MAINTAINERS
file). That's why I sent the patch directly to you.

Thanks,
Kurt

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


[U-Boot] [PATCH] usb: ehci: Make the PHY handling generic

2018-08-08 Thread Marek Vasut
Pull out the EHCI PHY functions into the ehci-hcd.c to let other
EHCI drivers use them.

Signed-off-by: Marek Vasut 
---
 drivers/usb/host/ehci-generic.c | 56 +++-
 drivers/usb/host/ehci-hcd.c | 57 +
 drivers/usb/host/ehci.h |  4 +++
 3 files changed, 64 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 5a56f66cfa..cc2f33826a 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -26,56 +26,6 @@ struct generic_ehci {
int reset_count;
 };
 
-static int ehci_setup_phy(struct udevice *dev, int index)
-{
-   struct generic_ehci *priv = dev_get_priv(dev);
-   int ret;
-
-   ret = generic_phy_get_by_index(dev, index, &priv->phy);
-   if (ret) {
-   if (ret != -ENOENT) {
-   dev_err(dev, "failed to get usb phy\n");
-   return ret;
-   }
-   } else {
-   ret = generic_phy_init(&priv->phy);
-   if (ret) {
-   dev_err(dev, "failed to init usb phy\n");
-   return ret;
-   }
-
-   ret = generic_phy_power_on(&priv->phy);
-   if (ret) {
-   dev_err(dev, "failed to power on usb phy\n");
-   return generic_phy_exit(&priv->phy);
-   }
-   }
-
-   return 0;
-}
-
-static int ehci_shutdown_phy(struct udevice *dev)
-{
-   struct generic_ehci *priv = dev_get_priv(dev);
-   int ret = 0;
-
-   if (generic_phy_valid(&priv->phy)) {
-   ret = generic_phy_power_off(&priv->phy);
-   if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
-   return ret;
-   }
-
-   ret = generic_phy_exit(&priv->phy);
-   if (ret) {
-   dev_err(dev, "failed to power off usb phy\n");
-   return ret;
-   }
-   }
-
-   return 0;
-}
-
 static int ehci_usb_probe(struct udevice *dev)
 {
struct generic_ehci *priv = dev_get_priv(dev);
@@ -145,7 +95,7 @@ static int ehci_usb_probe(struct udevice *dev)
}
}
 
-   err = ehci_setup_phy(dev, 0);
+   err = ehci_setup_phy(dev, &priv->phy, 0);
if (err)
goto reset_err;
 
@@ -160,7 +110,7 @@ static int ehci_usb_probe(struct udevice *dev)
return 0;
 
 phy_err:
-   ret = ehci_shutdown_phy(dev);
+   ret = ehci_shutdown_phy(dev, &priv->phy);
if (ret)
dev_err(dev, "failed to shutdown usb phy\n");
 
@@ -185,7 +135,7 @@ static int ehci_usb_remove(struct udevice *dev)
if (ret)
return ret;
 
-   ret = ehci_shutdown_phy(dev);
+   ret = ehci_shutdown_phy(dev, &priv->phy);
if (ret)
return ret;
 
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 663f748ffc..03758c2313 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1675,3 +1676,59 @@ struct dm_usb_ops ehci_usb_ops = {
 };
 
 #endif
+
+#ifdef CONFIG_PHY
+int ehci_setup_phy(struct udevice *dev, struct phy *phy, int index)
+{
+   int ret;
+
+   if (!phy)
+   return 0;
+
+   ret = generic_phy_get_by_index(dev, index, phy);
+   if (ret) {
+   if (ret != -ENOENT) {
+   dev_err(dev, "failed to get usb phy\n");
+   return ret;
+   }
+   } else {
+   ret = generic_phy_init(phy);
+   if (ret) {
+   dev_err(dev, "failed to init usb phy\n");
+   return ret;
+   }
+
+   ret = generic_phy_power_on(phy);
+   if (ret) {
+   dev_err(dev, "failed to power on usb phy\n");
+   return generic_phy_exit(phy);
+   }
+   }
+
+   return 0;
+}
+
+int ehci_shutdown_phy(struct udevice *dev, struct phy *phy)
+{
+   int ret = 0;
+
+   if (!phy)
+   return 0;
+
+   if (generic_phy_valid(phy)) {
+   ret = generic_phy_power_off(phy);
+   if (ret) {
+   dev_err(dev, "failed to power off usb phy\n");
+   return ret;
+   }
+
+   ret = generic_phy_exit(phy);
+   if (ret) {
+   dev_err(dev, "failed to power off usb phy\n");
+   return ret;
+   }
+   }
+
+   return 0;
+}
+#endif
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 07de472f91..a03dbb0039 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -288,4 +288,8 @@ int ehci_register(struct ud

[U-Boot] [PATCH] phy: Fix off-by-one error when parsing DT PHY bindings

2018-08-08 Thread Marek Vasut
The code fails to copy the last PHY phandle argument, so it is
missing from the adjusted phandle args and the consumer cannot
use it to determine what the PHY should do.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
---
 drivers/phy/phy-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 6162395e75..a0ac30aa71 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -64,7 +64,7 @@ int generic_phy_get_by_index(struct udevice *dev, int index,
return ret;
 
/* insert phy idx at first position into args array */
-   for (i = args.args_count; i > 1 ; i--)
+   for (i = args.args_count; i >= 1 ; i--)
args.args[i] = args.args[i - 1];
 
args.args_count++;
-- 
2.16.2

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


[U-Boot] [PATCH] usb: ehci: Add PHY support to ehci-pci

2018-08-08 Thread Marek Vasut
Add support for operating a PHY attached to ehci-pci. There are
systems where the EHCI controller is internally wired to a PCI
bus and has a PHY connected to it as well, ie. the R-Car Gen2.

Signed-off-by: Marek Vasut 
---
 drivers/usb/host/ehci-pci.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index a56e5bd144..fa0b88bafd 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -10,23 +10,30 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ehci.h"
 
 /* Information about a USB port */
 struct ehci_pci_priv {
struct ehci_ctrl ehci;
+   struct phy phy;
 };
 
 #ifdef CONFIG_DM_USB
-
-static void ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
+static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
  struct ehci_hcor **ret_hcor)
 {
+   struct ehci_pci_priv *priv = dev_get_priv(dev);
struct ehci_hccr *hccr;
struct ehci_hcor *hcor;
+   int ret;
u32 cmd;
 
+   ret = ehci_setup_phy(dev, &priv->phy, 0);
+   if (ret)
+   return ret;
+
hccr = (struct ehci_hccr *)dm_pci_map_bar(dev,
PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
hcor = (struct ehci_hcor *)((uintptr_t) hccr +
@@ -43,6 +50,8 @@ static void ehci_pci_init(struct udevice *dev, struct 
ehci_hccr **ret_hccr,
dm_pci_read_config32(dev, PCI_COMMAND, &cmd);
cmd |= PCI_COMMAND_MASTER;
dm_pci_write_config32(dev, PCI_COMMAND, cmd);
+
+   return 0;
 }
 
 #else
@@ -120,12 +129,27 @@ static int ehci_pci_probe(struct udevice *dev)
 {
struct ehci_hccr *hccr;
struct ehci_hcor *hcor;
+   int ret;
 
-   ehci_pci_init(dev, &hccr, &hcor);
+   ret = ehci_pci_init(dev, &hccr, &hcor);
+   if (ret)
+   return ret;
 
return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
 }
 
+static int ehci_pci_remove(struct udevice *dev)
+{
+   struct ehci_pci_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = ehci_deregister(dev);
+   if (ret)
+   return ret;
+
+   return ehci_shutdown_phy(dev, &priv->phy);
+}
+
 static const struct udevice_id ehci_pci_ids[] = {
{ .compatible = "ehci-pci" },
{ }
@@ -135,7 +159,7 @@ U_BOOT_DRIVER(ehci_pci) = {
.name   = "ehci_pci",
.id = UCLASS_USB,
.probe = ehci_pci_probe,
-   .remove = ehci_deregister,
+   .remove = ehci_pci_remove,
.of_match = ehci_pci_ids,
.ops= &ehci_usb_ops,
.platdata_auto_alloc_size = sizeof(struct usb_platdata),
-- 
2.16.2

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


[U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Marek Vasut
The PCI controller can have DT subnodes describing extra properties
of particular PCI devices, ie. a PHY attached to an EHCI controller
on a PCI bus. This patch parses those DT subnodes and assigns a node
to the PCI device instance, so that the driver can extract details
from that node and ie. configure the PHY using the PHY subsystem.

Signed-off-by: Marek Vasut 
Cc: Simon Glass 
---
 drivers/pci/pci-uclass.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 46e9c71bdf..306bea0dbf 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice *parent,
for (id = entry->match;
 id->vendor || id->subvendor || id->class_mask;
 id++) {
+   ofnode node;
+
if (!pci_match_one_id(id, find_id))
continue;
 
@@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice *parent,
goto error;
debug("%s: Match found: %s\n", __func__, drv->name);
dev->driver_data = find_id->driver_data;
+
+   dev_for_each_subnode(node, parent) {
+   phys_addr_t df, size;
+   df = ofnode_get_addr_size(node, "reg", &size);
+
+   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
+   PCI_DEV(df) == PCI_DEV(bdf)) {
+   dev->node = node;
+   break;
+   }
+   }
+
*devp = dev;
return 0;
}
-- 
2.16.2

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Eugeniu Rosca
On Wed, Aug 8, 2018 at 1:36 PM Jean-Jacques Hiblot  wrote:
>
> Hi all,
>
>
> On 08/08/2018 11:17, Eugeniu Rosca wrote:
> > Hello,
> >
> > FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
> > driver from the command line" contributes with a compiler warning, as
> > described in https://patchwork.ozlabs.org/patch/933310/#1952127 .
> This looks like a false positive to me.
> It can be fixed by assigning an initialization value to ret.
>
> Does that require a v4 ?
>
> JJ

I think having a warning-free build is a basic policy everybody is
expected to comply with.
The only right way to fix the gcc warning is to submit a v4.

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


Re: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Bin Meng
Hi Marek,

On Wed, Aug 8, 2018 at 9:03 PM, Marek Vasut  wrote:
> The PCI controller can have DT subnodes describing extra properties
> of particular PCI devices, ie. a PHY attached to an EHCI controller
> on a PCI bus. This patch parses those DT subnodes and assigns a node
> to the PCI device instance, so that the driver can extract details
> from that node and ie. configure the PHY using the PHY subsystem.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> ---
>  drivers/pci/pci-uclass.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 46e9c71bdf..306bea0dbf 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> for (id = entry->match;
>  id->vendor || id->subvendor || id->class_mask;
>  id++) {
> +   ofnode node;
> +
> if (!pci_match_one_id(id, find_id))
> continue;
>
> @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> goto error;
> debug("%s: Match found: %s\n", __func__, drv->name);
> dev->driver_data = find_id->driver_data;
> +
> +   dev_for_each_subnode(node, parent) {
> +   phys_addr_t df, size;
> +   df = ofnode_get_addr_size(node, "reg", &size);
> +
> +   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
> +   PCI_DEV(df) == PCI_DEV(bdf)) {
> +   dev->node = node;
> +   break;
> +   }

The function pci_find_and_bind_driver() is supposed to bind devices
that are NOT in the device tree. Adding device tree access in this
routine is quite odd. You can add the EHCI controller that need such
PHY subnodes in the device tree and there is no need to modify
anything I believe. If you are looking for an example, please check
pciuart0 in arch/x86/dts/crownbay.dts.

> +   }
> +
> *devp = dev;
> return 0;
> }
> --

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


Re: [U-Boot] [PATCH] spi: davinci: Full dm conversion

2018-08-08 Thread Adam Ford
On Tue, Aug 7, 2018 at 1:29 AM Jagan Teki  wrote:
>
> davinci_spi now support dt along with platform data,
> respective boards need to switch into dm for the same.
>
> Cc: Adam Ford 
> Cc: Vitaly Andrianov 
> Cc: Stefano Babic 
> Cc: Peter Howard 
> Cc: Tom Rini 
> Signed-off-by: Jagan Teki 
> ---
>  drivers/spi/Kconfig|  12 +-
>  drivers/spi/davinci_spi.c  | 289 +++--
>  include/dm/platform_data/spi_davinci.h |  15 ++
>  3 files changed, 97 insertions(+), 219 deletions(-)
>  create mode 100644 include/dm/platform_data/spi_davinci.h
>
> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
> index d046e919b4..18ebff0231 100644
> --- a/drivers/spi/Kconfig
> +++ b/drivers/spi/Kconfig
> @@ -80,6 +80,12 @@ config CADENCE_QSPI
>   used to access the SPI NOR flash on platforms embedding this
>   Cadence IP core.
>
> +config DAVINCI_SPI
> +   bool "Davinci & Keystone SPI driver"
> +   depends on ARCH_DAVINCI || ARCH_KEYSTONE
> +   help
> + Enable the Davinci SPI driver
> +
>  config DESIGNWARE_SPI
> bool "Designware SPI driver"
> help
> @@ -281,12 +287,6 @@ config FSL_QSPI
>   used to access the SPI NOR flash on platforms embedding this
>   Freescale IP core.
>
> -config DAVINCI_SPI
> -   bool "Davinci & Keystone SPI driver"
> -   depends on ARCH_DAVINCI || ARCH_KEYSTONE
> -   help
> - Enable the Davinci SPI driver
> -
>  config SH_SPI
> bool "SuperH SPI driver"
> help
> diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
> index a822858323..5007e6c618 100644
> --- a/drivers/spi/davinci_spi.c
> +++ b/drivers/spi/davinci_spi.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  /* SPIGCR0 */
>  #define SPIGCR0_SPIENA_MASK0x1
> @@ -118,9 +119,6 @@ struct davinci_spi_regs {
>
>  /* davinci spi slave */
>  struct davinci_spi_slave {
> -#ifndef CONFIG_DM_SPI
> -   struct spi_slave slave;
> -#endif
> struct davinci_spi_regs *regs;
> unsigned int freq; /* current SPI bus frequency */
> unsigned int mode; /* current SPI mode used */
> @@ -240,11 +238,43 @@ static int davinci_spi_read_write(struct 
> davinci_spi_slave *ds, unsigned
> return 0;
>  }
>
> +static int davinci_spi_set_speed(struct udevice *bus, uint max_hz)
> +{
> +   struct davinci_spi_slave *ds = dev_get_priv(bus);
>
> -static int __davinci_spi_claim_bus(struct davinci_spi_slave *ds, int cs)
> +   debug("%s speed %u\n", __func__, max_hz);
> +   if (max_hz > CONFIG_SYS_SPI_CLK / 2)
> +   return -EINVAL;
> +
> +   ds->freq = max_hz;
> +
> +   return 0;
> +}
> +
> +static int davinci_spi_set_mode(struct udevice *bus, uint mode)
> +{
> +   struct davinci_spi_slave *ds = dev_get_priv(bus);
> +
> +   debug("%s mode %u\n", __func__, mode);
> +   ds->mode = mode;
> +
> +   return 0;
> +}
> +
> +static int davinci_spi_claim_bus(struct udevice *dev)
>  {
> +   struct dm_spi_slave_platdata *slave_plat =
> +   dev_get_parent_platdata(dev);
> +   struct udevice *bus = dev->parent;
> +   struct davinci_spi_slave *ds = dev_get_priv(bus);
> unsigned int mode = 0, scalar;
>
> +   if (slave_plat->cs >= ds->num_cs) {
> +   printf("Invalid SPI chipselect\n");
> +   return -EINVAL;
> +   }
> +   ds->half_duplex = slave_plat->mode & SPI_PREAMBLE;
> +
> /* Enable the SPI hardware */
> writel(SPIGCR0_SPIRST_MASK, &ds->regs->gcr0);
> udelay(1000);
> @@ -254,7 +284,7 @@ static int __davinci_spi_claim_bus(struct 
> davinci_spi_slave *ds, int cs)
> writel(SPIGCR1_MASTER_MASK | SPIGCR1_CLKMOD_MASK, &ds->regs->gcr1);
>
> /* CS, CLK, SIMO and SOMI are functional pins */
> -   writel(((1 << cs) | SPIPC0_CLKFUN_MASK |
> +   writel(((1 << slave_plat->cs) | SPIPC0_CLKFUN_MASK |
> SPIPC0_DOFUN_MASK | SPIPC0_DIFUN_MASK), &ds->regs->pc0);
>
> /* setup format */
> @@ -292,20 +322,32 @@ static int __davinci_spi_claim_bus(struct 
> davinci_spi_slave *ds, int cs)
> return 0;
>  }
>
> -static int __davinci_spi_release_bus(struct davinci_spi_slave *ds)
> +static int davinci_spi_release_bus(struct udevice *dev)
>  {
> +   struct davinci_spi_slave *ds = dev_get_priv(dev->parent);
> +
> /* Disable the SPI hardware */
> writel(SPIGCR0_SPIRST_MASK, &ds->regs->gcr0);
>
> return 0;
>  }
>
> -static int __davinci_spi_xfer(struct davinci_spi_slave *ds,
> -   unsigned int bitlen,  const void *dout, void *din,
> -   unsigned long flags)
> +static int davinci_spi_xfer(struct udevice *dev, unsigned int bitlen,
> +   const void *dout, void *din,
> +   unsigned long flags)
>  {
> +   struct dm_spi_slave_platdata *slave =
> +   dev_get_parent_platdata(dev);
> +   struct udev

Re: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Marek Vasut
On 08/08/2018 03:14 PM, Bin Meng wrote:
> Hi Marek,
> 
> On Wed, Aug 8, 2018 at 9:03 PM, Marek Vasut  wrote:
>> The PCI controller can have DT subnodes describing extra properties
>> of particular PCI devices, ie. a PHY attached to an EHCI controller
>> on a PCI bus. This patch parses those DT subnodes and assigns a node
>> to the PCI device instance, so that the driver can extract details
>> from that node and ie. configure the PHY using the PHY subsystem.
>>
>> Signed-off-by: Marek Vasut 
>> Cc: Simon Glass 
>> ---
>>  drivers/pci/pci-uclass.c | 14 ++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
>> index 46e9c71bdf..306bea0dbf 100644
>> --- a/drivers/pci/pci-uclass.c
>> +++ b/drivers/pci/pci-uclass.c
>> @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice 
>> *parent,
>> for (id = entry->match;
>>  id->vendor || id->subvendor || id->class_mask;
>>  id++) {
>> +   ofnode node;
>> +
>> if (!pci_match_one_id(id, find_id))
>> continue;
>>
>> @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice 
>> *parent,
>> goto error;
>> debug("%s: Match found: %s\n", __func__, drv->name);
>> dev->driver_data = find_id->driver_data;
>> +
>> +   dev_for_each_subnode(node, parent) {
>> +   phys_addr_t df, size;
>> +   df = ofnode_get_addr_size(node, "reg", 
>> &size);
>> +
>> +   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
>> +   PCI_DEV(df) == PCI_DEV(bdf)) {
>> +   dev->node = node;
>> +   break;
>> +   }
> 
> The function pci_find_and_bind_driver() is supposed to bind devices
> that are NOT in the device tree. Adding device tree access in this
> routine is quite odd. You can add the EHCI controller that need such
> PHY subnodes in the device tree and there is no need to modify
> anything I believe. If you are looking for an example, please check
> pciuart0 in arch/x86/dts/crownbay.dts.

Well this does not work for me, the EHCI PCI doesn't get a DT node
assigned, check r8a7794.dtsi for the PCI devices I use.

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


[U-Boot] [PATCH] phy: rcar: Add R-Car Gen2 PHY driver

2018-08-08 Thread Marek Vasut
Add a PHY driver for the R-Car Gen2 which allows configuring the mux
connected to the EHCI controllers and USBHS controller.

Signed-off-by: Marek Vasut 
Cc: Nobuhiro Iwamatsu 
---
 drivers/phy/Kconfig |   8 ++
 drivers/phy/Makefile|   1 +
 drivers/phy/phy-rcar-gen2.c | 190 
 3 files changed, 199 insertions(+)
 create mode 100644 drivers/phy/phy-rcar-gen2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 8fc2295d03..e0822bb775 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -110,6 +110,14 @@ config STI_USB_PHY
  used by USB2 and USB3 Host controllers available on
  STiH407 SoC families.
 
+config PHY_RCAR_GEN2
+   tristate "Renesas R-Car Gen2 USB PHY"
+   depends on PHY && RCAR_GEN2
+   help
+ Support for the Renesas R-Car Gen2 USB PHY. This driver operates the
+ PHY connected to USBHS module, PCI EHCI module and USB3.0 module and
+ allows configuring the module multiplexing.
+
 config PHY_STM32_USBPHYC
tristate "STMicroelectronics STM32 SoC USB HS PHY driver"
depends on PHY && ARCH_STM32MP
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index ba0803cd04..178fb4530e 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -12,5 +12,6 @@ obj-$(CONFIG_BCM6368_USBH_PHY) += bcm6368-usbh-phy.o
 obj-$(CONFIG_PHY_SANDBOX) += sandbox-phy.o
 obj-$(CONFIG_$(SPL_)PIPE3_PHY) += ti-pipe3-phy.o
 obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o
+obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o
 obj-$(CONFIG_PHY_STM32_USBPHYC) += phy-stm32-usbphyc.o
 obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o meson-gxl-usb3.o
diff --git a/drivers/phy/phy-rcar-gen2.c b/drivers/phy/phy-rcar-gen2.c
new file mode 100644
index 00..ee70b81d88
--- /dev/null
+++ b/drivers/phy/phy-rcar-gen2.c
@@ -0,0 +1,190 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas RCar Gen2 USB PHY driver
+ *
+ * Copyright (C) 2018 Marek Vasut 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define USBHS_LPSTS0x02
+#define USBHS_UGCTRL   0x80
+#define USBHS_UGCTRL2  0x84
+#define USBHS_UGSTS0x88/* From technical update */
+
+/* Low Power Status register (LPSTS) */
+#define USBHS_LPSTS_SUSPM  0x4000
+
+/* USB General control register (UGCTRL) */
+#define USBHS_UGCTRL_CONNECT   BIT(2)
+#define USBHS_UGCTRL_PLLRESET  BIT(0)
+
+/* USB General control register 2 (UGCTRL2) */
+#define USBHS_UGCTRL2_USB2SEL  0x8000
+#define USBHS_UGCTRL2_USB2SEL_PCI  0x
+#define USBHS_UGCTRL2_USB2SEL_USB300x8000
+#define USBHS_UGCTRL2_USB0SEL  0x0030
+#define USBHS_UGCTRL2_USB0SEL_PCI  0x0010
+#define USBHS_UGCTRL2_USB0SEL_HS_USB   0x0030
+
+/* USB General status register (UGSTS) */
+#define USBHS_UGSTS_LOCK   0x0100 /* From technical update */
+
+#define PHYS_PER_CHANNEL   2
+
+struct rcar_gen2_phy {
+   fdt_addr_t  regs;
+   struct clk  clk;
+};
+
+static int rcar_gen2_phy_phy_init(struct phy *phy)
+{
+   struct rcar_gen2_phy *priv = dev_get_priv(phy->dev);
+   u16 chan = phy->id & 0x;
+   u16 mode = (phy->id >> 16) & 0x;
+   u32 clrmask, setmask;
+
+   if (chan == 0) {
+   clrmask = USBHS_UGCTRL2_USB0SEL;
+   setmask = mode ? USBHS_UGCTRL2_USB0SEL_HS_USB :
+USBHS_UGCTRL2_USB0SEL_PCI;
+   } else {
+   clrmask = USBHS_UGCTRL2_USB2SEL;
+   setmask = mode ? USBHS_UGCTRL2_USB2SEL_USB30 :
+USBHS_UGCTRL2_USB2SEL_PCI;
+   }
+   clrsetbits_le32(priv->regs + USBHS_UGCTRL2, clrmask, setmask);
+
+   return 0;
+}
+
+static int rcar_gen2_phy_phy_power_on(struct phy *phy)
+{
+   struct rcar_gen2_phy *priv = dev_get_priv(phy->dev);
+   int i;
+   u32 value;
+
+   /* Power on USBHS PHY */
+   clrbits_le32(priv->regs + USBHS_UGCTRL, USBHS_UGCTRL_PLLRESET);
+
+   setbits_le16(priv->regs + USBHS_LPSTS, USBHS_LPSTS_SUSPM);
+
+   for (i = 0; i < 20; i++) {
+   value = readl(priv->regs + USBHS_UGSTS);
+   if ((value & USBHS_UGSTS_LOCK) == USBHS_UGSTS_LOCK) {
+   setbits_le32(priv->regs + USBHS_UGCTRL,
+USBHS_UGCTRL_CONNECT);
+   return 0;
+   }
+   udelay(1);
+   }
+
+   return -ETIMEDOUT;
+}
+
+static int rcar_gen2_phy_phy_power_off(struct phy *phy)
+{
+   struct rcar_gen2_phy *priv = dev_get_priv(phy->dev);
+
+   /* Power off USBHS PHY */
+   clrbits_le32(priv->regs + USBHS_UGCTRL, USBHS_UGCTRL_CONNECT);
+
+   clrbits_le16(priv->regs + USBHS_LPSTS, USBHS_LPSTS_SUSPM);
+
+   setbits_le32(priv->regs + USBHS_UGCTRL, U

Re: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Bin Meng
Hi Marek,

On Wed, Aug 8, 2018 at 9:24 PM, Marek Vasut  wrote:
> On 08/08/2018 03:14 PM, Bin Meng wrote:
>> Hi Marek,
>>
>> On Wed, Aug 8, 2018 at 9:03 PM, Marek Vasut  wrote:
>>> The PCI controller can have DT subnodes describing extra properties
>>> of particular PCI devices, ie. a PHY attached to an EHCI controller
>>> on a PCI bus. This patch parses those DT subnodes and assigns a node
>>> to the PCI device instance, so that the driver can extract details
>>> from that node and ie. configure the PHY using the PHY subsystem.
>>>
>>> Signed-off-by: Marek Vasut 
>>> Cc: Simon Glass 
>>> ---
>>>  drivers/pci/pci-uclass.c | 14 ++
>>>  1 file changed, 14 insertions(+)
>>>
>>> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
>>> index 46e9c71bdf..306bea0dbf 100644
>>> --- a/drivers/pci/pci-uclass.c
>>> +++ b/drivers/pci/pci-uclass.c
>>> @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice 
>>> *parent,
>>> for (id = entry->match;
>>>  id->vendor || id->subvendor || id->class_mask;
>>>  id++) {
>>> +   ofnode node;
>>> +
>>> if (!pci_match_one_id(id, find_id))
>>> continue;
>>>
>>> @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice 
>>> *parent,
>>> goto error;
>>> debug("%s: Match found: %s\n", __func__, drv->name);
>>> dev->driver_data = find_id->driver_data;
>>> +
>>> +   dev_for_each_subnode(node, parent) {
>>> +   phys_addr_t df, size;
>>> +   df = ofnode_get_addr_size(node, "reg", 
>>> &size);
>>> +
>>> +   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
>>> +   PCI_DEV(df) == PCI_DEV(bdf)) {
>>> +   dev->node = node;
>>> +   break;
>>> +   }
>>
>> The function pci_find_and_bind_driver() is supposed to bind devices
>> that are NOT in the device tree. Adding device tree access in this
>> routine is quite odd. You can add the EHCI controller that need such
>> PHY subnodes in the device tree and there is no need to modify
>> anything I believe. If you are looking for an example, please check
>> pciuart0 in arch/x86/dts/crownbay.dts.
>
> Well this does not work for me, the EHCI PCI doesn't get a DT node
> assigned, check r8a7794.dtsi for the PCI devices I use.
>

I think that's because you don't specify a "compatible" string for
these two EHCI PCI nodes.

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


[U-Boot] [PATCH] usb: ehci-generic: Add vbus-supply regulator support

2018-08-08 Thread Patrice Chotard
Add vbus-supply regulator support.
On some board vbus is not controlled by the phy but by
an external regulator.

Signed-off-by: Patrice Chotard 
---

 drivers/usb/host/ehci-generic.c | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 5a56f66cfaa6..c4f34c85f798 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include "ehci.h"
+#include 
 
 /*
  * Even though here we don't explicitly use "struct ehci_ctrl"
@@ -22,6 +23,9 @@ struct generic_ehci {
struct clk *clocks;
struct reset_ctl *resets;
struct phy phy;
+#ifdef CONFIG_DM_REGULATOR
+   struct udevice *vbus_supply;
+#endif
int clock_count;
int reset_count;
 };
@@ -145,9 +149,24 @@ static int ehci_usb_probe(struct udevice *dev)
}
}
 
+#ifdef CONFIG_DM_REGULATOR
+   err = device_get_supply_regulator(dev, "vbus-supply",
+ &priv->vbus_supply);
+
+   if (priv->vbus_supply) {
+   err = regulator_set_enable(priv->vbus_supply, true);
+   if (err) {
+   pr_err("Error enabling VBUS supply\n");
+   goto reset_err;
+   }
+   } else {
+   debug("%s: No vbus supply\n", dev->name);
+   }
+#endif
+
err = ehci_setup_phy(dev, 0);
if (err)
-   goto reset_err;
+   goto regulator_err;
 
hccr = map_physmem(dev_read_addr(dev), 0x100, MAP_NOCACHE);
hcor = (struct ehci_hcor *)((uintptr_t)hccr +
@@ -164,6 +183,15 @@ phy_err:
if (ret)
dev_err(dev, "failed to shutdown usb phy\n");
 
+regulator_err:
+#ifdef CONFIG_DM_REGULATOR
+   if (priv->vbus_supply) {
+   ret = regulator_set_enable(priv->vbus_supply, false);
+   if (ret)
+   pr_err("Error disabling VBUS supply\n");
+   }
+#endif
+
 reset_err:
ret = reset_release_all(priv->resets, priv->reset_count);
if (ret)
@@ -189,6 +217,13 @@ static int ehci_usb_remove(struct udevice *dev)
if (ret)
return ret;
 
+#ifdef CONFIG_DM_REGULATOR
+   if (priv->vbus_supply) {
+   ret = regulator_set_enable(priv->vbus_supply, false);
+   if (ret)
+   return ret;
+   }
+#endif
ret =  reset_release_all(priv->resets, priv->reset_count);
if (ret)
return ret;
-- 
1.9.1

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


Re: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Marek Vasut
On 08/08/2018 03:39 PM, Bin Meng wrote:
> Hi Marek,
> 
> On Wed, Aug 8, 2018 at 9:24 PM, Marek Vasut  wrote:
>> On 08/08/2018 03:14 PM, Bin Meng wrote:
>>> Hi Marek,
>>>
>>> On Wed, Aug 8, 2018 at 9:03 PM, Marek Vasut  wrote:
 The PCI controller can have DT subnodes describing extra properties
 of particular PCI devices, ie. a PHY attached to an EHCI controller
 on a PCI bus. This patch parses those DT subnodes and assigns a node
 to the PCI device instance, so that the driver can extract details
 from that node and ie. configure the PHY using the PHY subsystem.

 Signed-off-by: Marek Vasut 
 Cc: Simon Glass 
 ---
  drivers/pci/pci-uclass.c | 14 ++
  1 file changed, 14 insertions(+)

 diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
 index 46e9c71bdf..306bea0dbf 100644
 --- a/drivers/pci/pci-uclass.c
 +++ b/drivers/pci/pci-uclass.c
 @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice 
 *parent,
 for (id = entry->match;
  id->vendor || id->subvendor || id->class_mask;
  id++) {
 +   ofnode node;
 +
 if (!pci_match_one_id(id, find_id))
 continue;

 @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice 
 *parent,
 goto error;
 debug("%s: Match found: %s\n", __func__, 
 drv->name);
 dev->driver_data = find_id->driver_data;
 +
 +   dev_for_each_subnode(node, parent) {
 +   phys_addr_t df, size;
 +   df = ofnode_get_addr_size(node, "reg", 
 &size);
 +
 +   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
 +   PCI_DEV(df) == PCI_DEV(bdf)) {
 +   dev->node = node;
 +   break;
 +   }
>>>
>>> The function pci_find_and_bind_driver() is supposed to bind devices
>>> that are NOT in the device tree. Adding device tree access in this
>>> routine is quite odd. You can add the EHCI controller that need such
>>> PHY subnodes in the device tree and there is no need to modify
>>> anything I believe. If you are looking for an example, please check
>>> pciuart0 in arch/x86/dts/crownbay.dts.
>>
>> Well this does not work for me, the EHCI PCI doesn't get a DT node
>> assigned, check r8a7794.dtsi for the PCI devices I use.
>>
> 
> I think that's because you don't specify a "compatible" string for
> these two EHCI PCI nodes.

That's perfectly fine, why should I specify it ? Linux has no problem
with it either.

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


Re: [U-Boot] [PATCH] usb: ehci-generic: Add vbus-supply regulator support

2018-08-08 Thread Marek Vasut
On 08/08/2018 04:10 PM, Patrice Chotard wrote:
> Add vbus-supply regulator support.
> On some board vbus is not controlled by the phy but by
> an external regulator.
> 
> Signed-off-by: Patrice Chotard 
> ---
> 
>  drivers/usb/host/ehci-generic.c | 37 -
>  1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
> index 5a56f66cfaa6..c4f34c85f798 100644
> --- a/drivers/usb/host/ehci-generic.c
> +++ b/drivers/usb/host/ehci-generic.c
> @@ -11,6 +11,7 @@
>  #include 
>  #include 
>  #include "ehci.h"
> +#include 
>  
>  /*
>   * Even though here we don't explicitly use "struct ehci_ctrl"
> @@ -22,6 +23,9 @@ struct generic_ehci {
>   struct clk *clocks;
>   struct reset_ctl *resets;
>   struct phy phy;
> +#ifdef CONFIG_DM_REGULATOR
> + struct udevice *vbus_supply;
> +#endif
>   int clock_count;
>   int reset_count;
>  };
> @@ -145,9 +149,24 @@ static int ehci_usb_probe(struct udevice *dev)
>   }
>   }
>  
> +#ifdef CONFIG_DM_REGULATOR
> + err = device_get_supply_regulator(dev, "vbus-supply",
> +   &priv->vbus_supply);

You're not checking err here ?

> + if (priv->vbus_supply) {
> + err = regulator_set_enable(priv->vbus_supply, true);
> + if (err) {
> + pr_err("Error enabling VBUS supply\n");
> + goto reset_err;
> + }
> + } else {
> + debug("%s: No vbus supply\n", dev->name);
> + }
> +#endif
> +
>   err = ehci_setup_phy(dev, 0);
>   if (err)
> - goto reset_err;
> + goto regulator_err;
>  
>   hccr = map_physmem(dev_read_addr(dev), 0x100, MAP_NOCACHE);
>   hcor = (struct ehci_hcor *)((uintptr_t)hccr +
> @@ -164,6 +183,15 @@ phy_err:
>   if (ret)
>   dev_err(dev, "failed to shutdown usb phy\n");
>  
> +regulator_err:
> +#ifdef CONFIG_DM_REGULATOR
> + if (priv->vbus_supply) {
> + ret = regulator_set_enable(priv->vbus_supply, false);
> + if (ret)
> + pr_err("Error disabling VBUS supply\n");
> + }
> +#endif
> +
>  reset_err:
>   ret = reset_release_all(priv->resets, priv->reset_count);
>   if (ret)
> @@ -189,6 +217,13 @@ static int ehci_usb_remove(struct udevice *dev)
>   if (ret)
>   return ret;
>  
> +#ifdef CONFIG_DM_REGULATOR
> + if (priv->vbus_supply) {
> + ret = regulator_set_enable(priv->vbus_supply, false);
> + if (ret)
> + return ret;
> + }
> +#endif
>   ret =  reset_release_all(priv->resets, priv->reset_count);
>   if (ret)
>   return ret;
> 


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


[U-Boot] [GIT PULL] u-boot-mips/master

2018-08-08 Thread Daniel Schwierzeck
Hi Tom,

I hope it's okay for post RC1, but I wanted to wait until you had the Kconfig 
sorting stuff merged.

Travis CI: https://travis-ci.org/danielschwierzeck/u-boot/builds/413538994


The following changes since commit b1aad8dbe28415695b290726199681ced969c118:

  zynqmp: Add avnet_ultra96_rev1_defconfig to the lits of boards (2018-08-07 
11:36:39 -0400)

are available in the Git repository at:

  git://git.denx.de/u-boot-mips.git master

for you to fetch changes up to 990cebf0a2c2e4dd9033c56acf7b1404a0c0f698:

  bcm968380gerg: add initial support (2018-08-08 13:38:17 +0200)


Philippe Reynes (3):
  bmips: ram: add an option to force the size of the ram
  bcm6838: add initial support
  bcm968380gerg: add initial support

Tom Rini (2):
  mips: dbau1x00: Remove this board
  mips: au1x00: Remove support for these SoCs

 arch/mips/Kconfig|   21 --
 arch/mips/Makefile   |1 -
 arch/mips/dts/brcm,bcm6838.dtsi  |   75 +
 arch/mips/dts/brcm,bcm968380gerg.dts |   40 +++
 arch/mips/include/asm/addrspace.h|6 +-
 arch/mips/mach-au1x00/Makefile   |6 -
 arch/mips/mach-au1x00/au1x00_eth.c   |  312 
 arch/mips/mach-au1x00/au1x00_ide.c   |   14 -
 arch/mips/mach-au1x00/au1x00_serial.c|  130 -
 arch/mips/mach-au1x00/au1x00_usb_ohci.c  | 1609 

 arch/mips/mach-au1x00/au1x00_usb_ohci.h  |  416 ---
 arch/mips/mach-au1x00/include/mach/au1x00.h  | 1071 
-
 arch/mips/mach-bmips/Kconfig |   25 ++
 board/broadcom/bcm968380gerg/Kconfig |   12 +
 board/broadcom/bcm968380gerg/Makefile|3 +
 board/broadcom/bcm968380gerg/bcm968380gerg.c |6 +
 board/broadcom/bcm968380gerg/board.c |6 +
 board/dbau1x00/Kconfig   |   46 ---
 board/dbau1x00/MAINTAINERS   |   10 -
 board/dbau1x00/Makefile  |7 -
 board/dbau1x00/README|   63 -
 board/dbau1x00/dbau1x00.c|  118 
 board/dbau1x00/lowlevel_init.S   |  589 
--
 board/pb1x00/Kconfig |   27 --
 board/pb1x00/MAINTAINERS |6 -
 board/pb1x00/Makefile|7 -
 board/pb1x00/README  |   63 -
 board/pb1x00/flash.c |   26 --
 board/pb1x00/lowlevel_init.S |  391 --
 board/pb1x00/pb1x00.c|  108 ---
 configs/bcm968380gerg_ram_defconfig  |   48 
 configs/dbau1000_defconfig   |   21 --
 configs/dbau1100_defconfig   |   21 --
 configs/dbau1500_defconfig   |   21 --
 configs/dbau1550_defconfig   |   16 --
 configs/dbau1550_el_defconfig|   17 --
 configs/pb1000_defconfig |   20 --
 drivers/cpu/bmips_cpu.c  |   33 +++
 drivers/ram/bmips_ram.c  |8 +-
 drivers/serial/serial.c  |2 -
 drivers/usb/gadget/gadget_chips.h|8 -
 include/configs/bmips_bcm6838.h  |   24 ++
 include/configs/broadcom_bcm968380gerg.h |9 +
 include/configs/dbau1x00.h   |  172 
 include/configs/pb1x00.h |  138 -
 include/netdev.h |1 -
 include/serial.h |1 -
 47 files changed, 291 insertions(+), 5483 deletions(-)
 create mode 100644 arch/mips/dts/brcm,bcm6838.dtsi
 create mode 100644 arch/mips/dts/brcm,bcm968380gerg.dts
 delete mode 100644 arch/mips/mach-au1x00/Makefile
 delete mode 100644 arch/mips/mach-au1x00/au1x00_eth.c
 delete mode 100644 arch/mips/mach-au1x00/au1x00_ide.c
 delete mode 100644 arch/mips/mach-au1x00/au1x00_serial.c
 delete mode 100644 arch/mips/mach-au1x00/au1x00_usb_ohci.c
 delete mode 100644 arch/mips/mach-au1x00/au1x00_usb_ohci.h
 delete mode 100644 arch/mips/mach-au1x00/include/mach/au1x00.h
 create mode 100644 board/broadcom/bcm968380gerg/Kconfig
 create mode 100644 board/broadcom/bcm968380gerg/Makefile
 create mode 100644 board/broadcom/bcm968380gerg/bcm968380gerg.c
 create mode 100644 board/broadcom/bcm968380gerg/board.c
 delete mode 100644 board/dbau1x00/Kconfig
 delete mode 100644 board/dbau1x00/MAINTAINERS
 delete mode 100644 board/dbau1x00/Makefile
 delete mode 100644 board/dbau1x00/README
 delete mode 100644 board/dbau1x00/dbau1x00.c
 delete mode 100644 board/dbau1x00/lowlevel_init.S
 delete mode 100644 board/pb1x00/Kconfig
 delete mode 100644 board

Re: [U-Boot] [PATCH] pci: Support parsing PCI controller DT subnodes

2018-08-08 Thread Bin Meng
Hi Marek,

On Wed, Aug 8, 2018 at 10:33 PM, Marek Vasut  wrote:
> On 08/08/2018 03:39 PM, Bin Meng wrote:
>> Hi Marek,
>>
>> On Wed, Aug 8, 2018 at 9:24 PM, Marek Vasut  wrote:
>>> On 08/08/2018 03:14 PM, Bin Meng wrote:
 Hi Marek,

 On Wed, Aug 8, 2018 at 9:03 PM, Marek Vasut  wrote:
> The PCI controller can have DT subnodes describing extra properties
> of particular PCI devices, ie. a PHY attached to an EHCI controller
> on a PCI bus. This patch parses those DT subnodes and assigns a node
> to the PCI device instance, so that the driver can extract details
> from that node and ie. configure the PHY using the PHY subsystem.
>
> Signed-off-by: Marek Vasut 
> Cc: Simon Glass 
> ---
>  drivers/pci/pci-uclass.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 46e9c71bdf..306bea0dbf 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -662,6 +662,8 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> for (id = entry->match;
>  id->vendor || id->subvendor || id->class_mask;
>  id++) {
> +   ofnode node;
> +
> if (!pci_match_one_id(id, find_id))
> continue;
>
> @@ -691,6 +693,18 @@ static int pci_find_and_bind_driver(struct udevice 
> *parent,
> goto error;
> debug("%s: Match found: %s\n", __func__, 
> drv->name);
> dev->driver_data = find_id->driver_data;
> +
> +   dev_for_each_subnode(node, parent) {
> +   phys_addr_t df, size;
> +   df = ofnode_get_addr_size(node, "reg", 
> &size);
> +
> +   if (PCI_FUNC(df) == PCI_FUNC(bdf) &&
> +   PCI_DEV(df) == PCI_DEV(bdf)) {
> +   dev->node = node;
> +   break;
> +   }

 The function pci_find_and_bind_driver() is supposed to bind devices
 that are NOT in the device tree. Adding device tree access in this
 routine is quite odd. You can add the EHCI controller that need such
 PHY subnodes in the device tree and there is no need to modify
 anything I believe. If you are looking for an example, please check
 pciuart0 in arch/x86/dts/crownbay.dts.
>>>
>>> Well this does not work for me, the EHCI PCI doesn't get a DT node
>>> assigned, check r8a7794.dtsi for the PCI devices I use.
>>>
>>
>> I think that's because you don't specify a "compatible" string for
>> these two EHCI PCI nodes.
>
> That's perfectly fine, why should I specify it ? Linux has no problem
> with it either.
>

Without a "compatible" string, DM does not bind any device in the
device tree to a driver, hence no device node created. This is not
Linux.

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Jean-Jacques Hiblot



On 08/08/2018 15:08, Eugeniu Rosca wrote:

On Wed, Aug 8, 2018 at 1:36 PM Jean-Jacques Hiblot  wrote:

Hi all,


On 08/08/2018 11:17, Eugeniu Rosca wrote:

Hello,

FWIW, patch "[7/7] cmd: Add bind/unbind commands to bind a device to a
driver from the command line" contributes with a compiler warning, as
described in https://patchwork.ozlabs.org/patch/933310/#1952127 .

This looks like a false positive to me.
It can be fixed by assigning an initialization value to ret.

Does that require a v4 ?

JJ

I think having a warning-free build is a basic policy everybody is
expected to comply with.
I agree. I meant that it could be fixed at the time of the commit by the 
maintainer.

Thanks,
JJ

The only right way to fix the gcc warning is to submit a v4.

Best regards,
Eugeniu.



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


Re: [U-Boot] [PATCH v7 0/8] NXP LS1046A SMMU enabling patches

2018-08-08 Thread York Sun
On 08/08/2018 02:05 AM, laurentiu.tu...@nxp.com wrote:
> From: Laurentiu Tudor 
> 
> This patch series adds the required devices setup and device tree
> fixups for SMMU enablement on NXP LS1046A chips. The approach taken
> tries to mimic the implementation of PAMU LIODN setup on booke powerpc.
> 
> First 4 patches contain some fixes and add some missing bits & pieces.
> Last 4 patches add the actual infrastructure for ICID setup, qman
> portals, fman ICID and SEC configuration.
> 
> Changes in v7:
>  - fix this build breakage introduced by patch [6/8] on booke ppc
>appearing with certain tool chain versions:
>   "drivers/misc/fsl_portals.c: In function 'fdt_fixup_qportals':
>   drivers/misc/fsl_portals.c:256:3: error: 'for' loop initial
>   declarations are only allowed in C99 or C11 mode"
>  - fixed linker error on LS1012A targets:
>   "arch/arm/cpu/armv8/built-in.o: In function
>   `fsl_lsch2_early_init_f':
>   arch/arm/cpu/armv8/fsl-layerscape/soc.c:691:
>   undefined reference to `set_icids'"
> 

Still see compiling error for ls1043a boards.

/opt/toolchains/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-elf/bin/aarch64-elf-ld.bfd:
drivers/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against
external symbol `qp_info' can not be used when making a shared object;
recompile with -fPIC

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Eugeniu Rosca
On Wed, Aug 8, 2018 at 6:18 PM Jean-Jacques Hiblot  wrote:
> On 08/08/2018 15:08, Eugeniu Rosca wrote:
[snip]
> > I think having a warning-free build is a basic policy everybody is
> > expected to comply with.
> I agree. I meant that it could be fixed at the time of the commit by the
> maintainer.

I'm not sure how well this plays with https://developercertificate.org/.
At least for my contributions, I would expect that they reach the main
tree unmodified, unless there is some trivial change in commit
metadata (which I expect to be documented). But I'll let others to
comment, who went through such kind of questions before.

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Tom Rini
On Wed, Aug 08, 2018 at 06:44:07PM +0200, Eugeniu Rosca wrote:
> On Wed, Aug 8, 2018 at 6:18 PM Jean-Jacques Hiblot  wrote:
> > On 08/08/2018 15:08, Eugeniu Rosca wrote:
> [snip]
> > > I think having a warning-free build is a basic policy everybody is
> > > expected to comply with.
> > I agree. I meant that it could be fixed at the time of the commit by the
> > maintainer.
> 
> I'm not sure how well this plays with https://developercertificate.org/.
> At least for my contributions, I would expect that they reach the main
> tree unmodified, unless there is some trivial change in commit
> metadata (which I expect to be documented). But I'll let others to
> comment, who went through such kind of questions before.

In DCO terms, it is my belief that a maintainer can make additional
changes, so long as they too add a S-o-B line.  I also like it if they
do:
[me: Did stuff]
so it's clear what changed.  But I don't think that's a conflict with
DCOs.

In custodian terms, it's a whole lot quicker if someone can directly
apply a series rather than apply, rebase (fixup a patch) and continue.
So, if you do another round and fix the problem it'll be one less thing
for the custodian to deal with.

-- 
Tom


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


Re: [U-Boot] [PATCH v7 0/8] NXP LS1046A SMMU enabling patches

2018-08-08 Thread Laurentiu Tudor
Hi York,

> From: York Sun
> Sent: Wednesday, August 8, 2018 7:23 PM
> 
> On 08/08/2018 02:05 AM, laurentiu.tu...@nxp.com wrote:
> > From: Laurentiu Tudor 
> >
> > This patch series adds the required devices setup and device tree
> > fixups for SMMU enablement on NXP LS1046A chips. The approach taken
> > tries to mimic the implementation of PAMU LIODN setup on booke powerpc.
> >
> > First 4 patches contain some fixes and add some missing bits & pieces.
> > Last 4 patches add the actual infrastructure for ICID setup, qman
> > portals, fman ICID and SEC configuration.
> >
> > Changes in v7:
> >  - fix this build breakage introduced by patch [6/8] on booke ppc
> >appearing with certain tool chain versions:
> > "drivers/misc/fsl_portals.c: In function 'fdt_fixup_qportals':
> > drivers/misc/fsl_portals.c:256:3: error: 'for' loop initial
> > declarations are only allowed in C99 or C11 mode"
> >  - fixed linker error on LS1012A targets:
> > "arch/arm/cpu/armv8/built-in.o: In function
> > `fsl_lsch2_early_init_f':
> > arch/arm/cpu/armv8/fsl-layerscape/soc.c:691:
> > undefined reference to `set_icids'"
> >
> 
> Still see compiling error for ls1043a boards.
> 
> /opt/toolchains/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-elf/bin/aarch64-
> elf-ld.bfd:
> drivers/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against
> external symbol `qp_info' can not be used when making a shared object;
> recompile with -fPIC

Ugh, no clue what causes this. Will look into it.

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


Re: [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller

2018-08-08 Thread Eugeniu Rosca
On Wed, Aug 8, 2018 at 6:54 PM Tom Rini  wrote:
>
> On Wed, Aug 08, 2018 at 06:44:07PM +0200, Eugeniu Rosca wrote:
> > On Wed, Aug 8, 2018 at 6:18 PM Jean-Jacques Hiblot  wrote:
> > > On 08/08/2018 15:08, Eugeniu Rosca wrote:
> > [snip]
> > > > I think having a warning-free build is a basic policy everybody is
> > > > expected to comply with.
> > > I agree. I meant that it could be fixed at the time of the commit by the
> > > maintainer.
> >
> > I'm not sure how well this plays with https://developercertificate.org/.
> > At least for my contributions, I would expect that they reach the main
> > tree unmodified, unless there is some trivial change in commit
> > metadata (which I expect to be documented). But I'll let others to
> > comment, who went through such kind of questions before.
>
> In DCO terms, it is my belief that a maintainer can make additional
> changes, so long as they too add a S-o-B line.  I also like it if they
> do:
> [me: Did stuff]
> so it's clear what changed.  But I don't think that's a conflict with
> DCOs.

One interesting aspect is whether the community has a chance to review
the changes occurred in the timeframe between the author's and the
maintainer's S-o-B. This seems to be elided in DCO, probably because
DCO treats all contributors equally. But obviously, the maintainer has
an outstanding status of committing the work into the tree.

It is my assumption that the maintainer should give enough time to
community to reach some agreement that the contents is ready for
merge. With this assumption in mind, it should probably be an
exception for the maintainer to perform any changes without prior
community review. This is why I noted that I expect a v4 to fix the
compiler warning (especially given that this is not a metadata
change). But don't get me wrong. My main interest is fixing the gcc
warning occurring in sandbox build with this patch-set. I am open
minded about the rest.

> In custodian terms, it's a whole lot quicker if someone can directly
> apply a series rather than apply, rebase (fixup a patch) and continue.
> So, if you do another round and fix the problem it'll be one less thing
> for the custodian to deal with.
>
> --
> Tom

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


[U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM

2018-08-08 Thread Marek Vasut
Add trivial implementation of the clk dump in case DM is enabled.
This implementation just iterates over all the clock registered
with the CLK uclass and prints their rate.

Signed-off-by: Marek Vasut 
Cc: Chin Liang See 
Cc: Dinh Nguyen 
Cc: Ley Foon Tan 
Cc: Simon Glass 
Cc: Tom Rini 
---
 cmd/clk.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/cmd/clk.c b/cmd/clk.c
index 73fb25092b..fd4231589c 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -5,11 +5,48 @@
 #include 
 #include 
 #include 
+#if defined(CONFIG_DM) && defined(CONFIG_CLK)
+#include 
+#include 
+#endif
 
 int __weak soc_clk_dump(void)
 {
+#if defined(CONFIG_DM) && defined(CONFIG_CLK)
+   struct udevice *dev;
+   struct uclass *uc;
+   struct clk clk;
+   int ret;
+
+   /* Device addresses start at 1 */
+   ret = uclass_get(UCLASS_CLK, &uc);
+   if (ret)
+   return ret;
+
+   uclass_foreach_dev(dev, uc) {
+   memset(&clk, 0, sizeof(clk));
+   ret = device_probe(dev);
+   if (ret) {
+   printf("%-30.30s : ? Hz\n", dev->name);
+   continue;
+   }
+
+   ret = clk_request(dev, &clk);
+   if (ret) {
+   printf("%-30.30s : ? Hz\n", dev->name);
+   continue;
+   }
+
+   printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk));
+
+   clk_free(&clk);
+   }
+
+   return 0;
+#else
puts("Not implemented\n");
return 1;
+#endif
 }
 
 static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
-- 
2.16.2

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


  1   2   >