Re: [PATCH 1/4 v5] watchdog: Implement generic watchdog_reset() version

2020-02-19 Thread Rasmus Villemoes
On 20/02/2020 07.43, Stefan Roese wrote:
> On 20.02.20 07:38, Christophe Leroy wrote:
> 
> 
> 
> +void watchdog_reset(void)
> +{
> +    static ulong next_reset;
> +    ulong now;
> +
> +    /* Exit if GD is not ready or watchdog is not initialized yet */
> +    if (!gd || !(gd->flags & GD_FLG_WDT_READY))
> +    return;
> +
> +    /* Do not reset the watchdog too often */
> +    now = get_timer(0);
> +    if (now > next_reset) {
> +    next_reset = now + 1000;    /* reset every 1000ms */
> +    wdt_reset(gd->watchdog_dev);
> +    }

 This is a problem for the MPC8xx.

 When running with a MPC8xx at 132MHz clock, the watchdog will fire
 about 1s after the last refresh. So the above makes the board unusable.
>>>
>>> So you need a shorted delay between the wdt_reset() calls? Is this
>>> correct? We could introduce a new Kconfig option which defaults to
>>> 1000 (ms) and you can "select" a shorter value for MPC8xx.
>>
>> Exactly. However, why is this limitation needed at all ? Why is it a
>> problem to refresh more often ?
> 
> Very likely its not. What is a reasonable value for your platform? 100
> or 500ms? I think we could change it to default to a shorter value, but
> such a change should go in early in the merge window, so that other
> platforms have a bit of time to test it.
> 
> Please feel free to send a patch for this and please add a comment to
> explain, why the delay is this "short".

IMO, this should come from DT. For a gpio watchdog (which for some
reason U-Boot doesn't have a generic driver for) the linux kernel uses a
hw_margin_ms property that tells the core how often the watchdog must be
pinged - that could be generalized to apply for all, with 1000ms as a
default if not set. And I've seen boards with a gpio watchdog with a
timeout of 200 ms.

Also, I'm wondering why that generic _reset only handles one watchdog
device? I can easily imagine needing to reset both, say, an external
gpio-triggered one and also the SOC's/CPU's built-in one. Why not loop
over all DM watchdogs, and have the next_reset/hw_margin etc. metadata
live with the watchdog device instead of in static variable/build-time
constants?

Rasmus


[PATCH] watchdog: mpc8xx: Revert the 8xx watchdog back to CONFIG_HW_WATCHDOG

2020-02-19 Thread Christophe Leroy
Commit f3729ba6e7b2 ("watchdog: mpc8xx_wdt: Watchdog driver and macros
cleanup") switched the watchdog to CONFIG_WATCHDOG. But this is not
compatible with the 8xx because it starts the watchdog HW timer at
reset and must be serviced from the very beginning including while
U-boot is executed in the firmware before relocation in RAM.

Select CONFIG_HW_WATCHDOG and make hw_watchdog_reset() visible.

Meanwhile, finalise the cleanup of arch/powerpc/cpu/mpc8xx/Kconfig by
removing the lines put in comment in that commit, and also remove
again the selection of CONFIG_MPC8xx_WATCHDOG which was removed by
that commit and brought back by mistake by commit b3134ffbd944
("watchdog: Kconfig: Sort entry alphabetically")

Note that there was an 'imply WATCHDOG' in the original commit but
it disappeared in the Kconfig alphabetical sorting, so no need to
remove it here.

Fixes: f3729ba6e7b2 ("watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup")
Fixes: b3134ffbd944 ("watchdog: Kconfig: Sort entry alphabetically")
Signed-off-by: Christophe Leroy 
Cc: Stefan Roese 
Cc: Patrice Chotard 
---
 arch/powerpc/cpu/mpc8xx/Kconfig | 4 
 drivers/watchdog/Kconfig| 2 +-
 drivers/watchdog/mpc8xx_wdt.c   | 2 +-
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/cpu/mpc8xx/Kconfig b/arch/powerpc/cpu/mpc8xx/Kconfig
index 3e8ea3852959..f11231737656 100644
--- a/arch/powerpc/cpu/mpc8xx/Kconfig
+++ b/arch/powerpc/cpu/mpc8xx/Kconfig
@@ -25,10 +25,6 @@ config MPC885
 
 endchoice
 
-#config MPC8xx_WATCHDOG
-#  bool "Watchdog"
-#  select HW_WATCHDOG
-
 config 8xx_GCLK_FREQ
int "CPU GCLK Frequency"
 
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 36fbdce55208..fbb561b995f1 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -118,7 +118,7 @@ config WDT_CORTINA
 config WDT_MPC8xx
bool "MPC8xx watchdog timer support"
depends on WDT && MPC8xx
-   select CONFIG_MPC8xx_WATCHDOG
+   select HW_WATCHDOG
help
   Select this to enable mpc8xx watchdog timer
 
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c
index 8a7a4c5bc6c3..c8b104d8f567 100644
--- a/drivers/watchdog/mpc8xx_wdt.c
+++ b/drivers/watchdog/mpc8xx_wdt.c
@@ -11,7 +11,7 @@
 #include 
 #include 
 
-static void hw_watchdog_reset(void)
+void hw_watchdog_reset(void)
 {
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
 
-- 
2.25.0



Try to use AHAB but ahab.c is not compiled

2020-02-19 Thread Oliver Graute
Hello Peng,

I try to use AHAB feature on my board. First of all I just want to
perform a "ahab_status". I enabled CONFIG_AHAB_BOOT=y in my config but
ahab.c isn't compiled. The ahab.o is missing after compilation.
Is there anything else to consider? Do I overlook something?

Best regards,

Oliver


Re: Please pull mmc mmc-2-19-2020

2020-02-19 Thread Masahiro Yamada
Hi Peng,



On Thu, Feb 20, 2020 at 3:52 PM Peng Fan  wrote:
>
> > Subject: Re: Please pull mmc mmc-2-19-2020
> >
> > Hi Peng,
> >
> > On Thu, Feb 20, 2020 at 1:34 PM Tom Rini  wrote:
> > >
> > > On Thu, Feb 20, 2020 at 01:56:41AM +, Peng Fan wrote:
> > >
> > > > Hi Tom
> > > >
> > > > Please pull mmc-2-29-2020.
> > > >
> > >
> > > NAK, this breaks nios2:
> > >  nios2:  +   10m50 3c120
> > > +(10m50,3c120) ../drivers/net/altera_tse.c: In function 
> > > 'altera_tse_probe':
> > > +(10m50,3c120) ../drivers/net/altera_tse.c:646:15: error: implicit
> > declaration of function 'dma_alloc_coherent'; did you mean 'lmb_alloc_addr'?
> > [-Werror=implicit-function-declaration]
> > > +(10m50,3c120) desc_mem = dma_alloc_coherent(len, &addr);
> > > +(10m50,3c120)^~
> > > +(10m50,3c120)lmb_alloc_addr
> > > +(10m50,3c120) ../drivers/net/altera_tse.c:646:13: error: assignment
> > makes pointer from integer without a cast [-Werror=int-conversion]
> > > +(10m50,3c120)  ^
> > > +(10m50,3c120) cc1: all warnings being treated as errors
> > > +(10m50,3c120) make[2]: *** [drivers/net/altera_tse.o] Error 1
> > > +(10m50,3c120) make[1]: *** [drivers/net] Error 2
> > > +(10m50,3c120) make: *** [sub-make] Error 2
>
> I not met such issue in github ci.
>
> > >
> > > --
> > > Tom
> >
> >
> > Agh, something strange happens somehow in the following commit.
> >
> > commit 87a6590d6eb500db95bcdb09c16efb16559f67c6
> > Author: Masahiro Yamada 
> > Date:   Fri Feb 14 16:40:20 2020 +0900
> >
> > dma-mapping: add  for all architectures
> >
> >
> >
> > Peng,
> >
> > Could you replace it with this?
>
> Replaced. If there still build issue, I'll drop this single patch in this 
> pull request.


No, you cannot do it.

If you dropped it, the following error would come back again.
https://lists.denx.de/pipermail/u-boot/2020-February/400180.html


I confirmed nios2 builds passed, so I hope it will be OK this time.


--
Best Regards
Masahiro Yamada


RE: Please pull mmc mmc-2-19-2020

2020-02-19 Thread Peng Fan
> Subject: Re: Please pull mmc mmc-2-19-2020
> 
> Hi Peng,
> 
> On Thu, Feb 20, 2020 at 1:34 PM Tom Rini  wrote:
> >
> > On Thu, Feb 20, 2020 at 01:56:41AM +, Peng Fan wrote:
> >
> > > Hi Tom
> > >
> > > Please pull mmc-2-29-2020.
> > >
> >
> > NAK, this breaks nios2:
> >  nios2:  +   10m50 3c120
> > +(10m50,3c120) ../drivers/net/altera_tse.c: In function 'altera_tse_probe':
> > +(10m50,3c120) ../drivers/net/altera_tse.c:646:15: error: implicit
> declaration of function 'dma_alloc_coherent'; did you mean 'lmb_alloc_addr'?
> [-Werror=implicit-function-declaration]
> > +(10m50,3c120) desc_mem = dma_alloc_coherent(len, &addr);
> > +(10m50,3c120)^~
> > +(10m50,3c120)lmb_alloc_addr
> > +(10m50,3c120) ../drivers/net/altera_tse.c:646:13: error: assignment
> makes pointer from integer without a cast [-Werror=int-conversion]
> > +(10m50,3c120)  ^
> > +(10m50,3c120) cc1: all warnings being treated as errors
> > +(10m50,3c120) make[2]: *** [drivers/net/altera_tse.o] Error 1
> > +(10m50,3c120) make[1]: *** [drivers/net] Error 2
> > +(10m50,3c120) make: *** [sub-make] Error 2

I not met such issue in github ci.

> >
> > --
> > Tom
> 
> 
> Agh, something strange happens somehow in the following commit.
> 
> commit 87a6590d6eb500db95bcdb09c16efb16559f67c6
> Author: Masahiro Yamada 
> Date:   Fri Feb 14 16:40:20 2020 +0900
> 
> dma-mapping: add  for all architectures
> 
> 
> 
> Peng,
> 
> Could you replace it with this?

Replaced. If there still build issue, I'll drop this single patch in this pull 
request.

Thanks,
Peng.

> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatchw
> ork.ozlabs.org%2Fpatch%2F1241209%2F&data=02%7C01%7Cpeng.fan%
> 40nxp.com%7C7dfca232910b461e892508d7b5c46682%7C686ea1d3bc2b4c6
> fa92cd99c5c301635%7C0%7C0%7C637177727450297022&sdata=bwE9
> pa9V80pmSD6%2FP4vMfBNt8xkJ%2B8R60%2FwM1xkhNGY%3D&reserv
> ed=0
> 
> (Or, just revert the diff for arch/nios2/include/asm/dma-mapping)
> 
> 
> 
> 
> --
> Best Regards
> Masahiro Yamada


Re: [PATCH 3/4 v5] watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup

2020-02-19 Thread Christophe Leroy




On 02/20/2020 05:37 AM, Stefan Roese wrote:

Hi Christophe,

On 19.02.20 20:15, Christophe Leroy wrote:

Hi Stefan,

On 04/25/2019 07:17 AM, Stefan Roese wrote:

With the generic watchdog driver now implemented, this patch removes
some legacy stuff from the MPC8xx watchdog driver and its Kconfig
integration. CONFIG_MPC8xx_WATCHDOG is completely removed and
hw_watchdog_reset() is made static, as the watchdog will now get
serviced via the DM infrastructure if enabled via CONFIG_WATCHDOG.

Signed-off-by: Stefan Roese 
Cc: Christophe Leroy 
---
v5:
- No change

v4:
- New patch

arch/powerpc/Kconfig    | 2 +-
  arch/powerpc/cpu/mpc8xx/Kconfig | 6 +++---
  drivers/watchdog/Kconfig    | 1 -
  drivers/watchdog/Makefile   | 2 +-
  drivers/watchdog/mpc8xx_wdt.c   | 4 +---
  5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c727d9162c..0b1629ba62 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -35,7 +35,7 @@ config MPC8xx
  bool "MPC8xx"
  select BOARD_EARLY_INIT_F
  imply CMD_REGINFO
-    imply MPC8xx_WATCHDOG
+    imply WDT_MPC8xx
  endchoice
diff --git a/arch/powerpc/cpu/mpc8xx/Kconfig 
b/arch/powerpc/cpu/mpc8xx/Kconfig

index b0e90a0f20..3e8ea38529 100644
--- a/arch/powerpc/cpu/mpc8xx/Kconfig
+++ b/arch/powerpc/cpu/mpc8xx/Kconfig
@@ -25,9 +25,9 @@ config MPC885
  endchoice
-config MPC8xx_WATCHDOG
-    bool "Watchdog"
-    select HW_WATCHDOG
+#config MPC8xx_WATCHDOG
+#    bool "Watchdog"
+#    select HW_WATCHDOG


If HW_WATCHDOG is not selected, we have a problem in cpu_init_f() 
(arch/powerpc/cpu/mpc8xx/cpu_init.c) with the following line, and the 
board with restart every second.


#ifndef CONFIG_HW_WATCHDOG
 /* deactivate watchdog if not enabled in config */
 out_be32(&immr->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & 
~SYPCR_SWE);

#endif

Should this be changed to use CONFIG_WATCHDOG instead ?


Yes, that sound reasonable.



Looking at it more closely, I think there is something going wrong.

watchdog_reset() in wdt-uclass.c bails out without pinging the watchdog 
until GD_FLG_WDT_READY is set. But this is set in initr_watchdog().
It means that all WATCHDOG_RESET() until then are now ignored. This 
means all the phase during which Uboot execute from firmware until 
relocation do not service the watchdog anymore. The watchdog is ON since 
the CPU reset and must be serviced until someone decides to disable it, 
in which case it can't be re-enabled later. This means we can't disable 
it early to re-enable it once DM is ready.


And if I understand correctly doc/README.watchdog, that's exactly what 
CONFIG_HW_WATCHDOG is made for.


So I think that we just can't switch mpc8xx to CONFIG_WATCHDOG 
(include/wdt.c clears makes the difference between Hardware watchdogs 
and software watchdogs), it must remain with CONFIG_HW_WATCHDOG


Christophe




Re: [PATCH] lib: Improve _parse_integer_fixup_radix base 16 detection

2020-02-19 Thread Michal Simek
čt 13. 2. 2020 v 13:30 odesílatel Tom Rini  napsal:
>
> On Thu, Feb 13, 2020 at 08:33:09AM +0100, Michal Simek wrote:
> > pá 7. 2. 2020 v 13:07 odesílatel Michal Simek  
> > napsal:
> > >
> > > Base autodetection is failing for this case:
> > > if test 257 -gt 3ae; then echo first; else echo second; fi
> > >
> > > It is because base for 3ae is recognized by _parse_integer_fixup_radix() 
> > > as
> > > 10. The patch is checking all chars to make sure that they are not 'a' or
> > > up. If they are base needs to be in hex.
> > >
> > > Signed-off-by: Michal Simek 
> > > ---
> > >
> > >  lib/strto.c | 18 +-
> > >  1 file changed, 17 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/strto.c b/lib/strto.c
> > > index 55ff9f7437d5..14821c87f16d 100644
> > > --- a/lib/strto.c
> > > +++ b/lib/strto.c
> > > @@ -22,9 +22,25 @@ static const char *_parse_integer_fixup_radix(const 
> > > char *s, unsigned int *base)
> > > *base = 16;
> > > else
> > > *base = 8;
> > > -   } else
> > > +   } else {
> > > +   int i;
> > > +
> > > *base = 10;
> > > +
> > > +   for (i = 0; ; i++) {
> > > +   char var = s[i];
> > > +
> > > +   if (var == '\n')

here should be \0

> > > +   break;
> > > +
> > > +   if (var >= 'a') {

Colleague also suggested to check also till f here.

Will create v2 on this.

M



-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


Re: [PATCH 1/4 v5] watchdog: Implement generic watchdog_reset() version

2020-02-19 Thread Stefan Roese

On 20.02.20 07:38, Christophe Leroy wrote:




+void watchdog_reset(void)
+{
+    static ulong next_reset;
+    ulong now;
+
+    /* Exit if GD is not ready or watchdog is not initialized yet */
+    if (!gd || !(gd->flags & GD_FLG_WDT_READY))
+    return;
+
+    /* Do not reset the watchdog too often */
+    now = get_timer(0);
+    if (now > next_reset) {
+    next_reset = now + 1000;    /* reset every 1000ms */
+    wdt_reset(gd->watchdog_dev);
+    }


This is a problem for the MPC8xx.

When running with a MPC8xx at 132MHz clock, the watchdog will fire 
about 1s after the last refresh. So the above makes the board unusable.


So you need a shorted delay between the wdt_reset() calls? Is this
correct? We could introduce a new Kconfig option which defaults to
1000 (ms) and you can "select" a shorter value for MPC8xx.


Exactly. However, why is this limitation needed at all ? Why is it a 
problem to refresh more often ?


Very likely its not. What is a reasonable value for your platform? 100
or 500ms? I think we could change it to default to a shorter value, but
such a change should go in early in the merge window, so that other
platforms have a bit of time to test it.

Please feel free to send a patch for this and please add a comment to
explain, why the delay is this "short".

Thanks,
Stefan


Re: [PATCH 1/4 v5] watchdog: Implement generic watchdog_reset() version

2020-02-19 Thread Christophe Leroy




On 02/20/2020 05:43 AM, Stefan Roese wrote:

Hi Christophe

On 19.02.20 20:21, Christophe Leroy wrote:



Le 25/04/2019 à 09:17, Stefan Roese a écrit :

This patch tries to implement a generic watchdog_reset() function that
can be used by all boards that want to service the watchdog device in
U-Boot. This watchdog servicing is enabled via CONFIG_WATCHDOG.

Without this approach, new boards or platforms needed to implement a
board specific version of this functionality, mostly copy'ing the same
code over and over again into their board or platforms code base.

With this new generic function, the scattered other functions are now
removed to be replaced by the generic one. The new version also enables
the configuration of the watchdog timeout via the DT "timeout-sec"
property (if enabled via CONFIG_OF_CONTROL).

This patch also adds a new flag to the GD flags, to flag that the
watchdog is ready to use and adds the pointer to the watchdog device
to the GD. This enables us to remove the global "watchdog_dev"
variable, which was prone to cause problems because of its potentially
very early use in watchdog_reset(), even before the BSS is cleared.

Signed-off-by: Stefan Roese 
Cc: Heiko Schocher 
Cc: Tom Rini 
Cc: Michal Simek 
Cc: "Marek Behún" 
Cc: Daniel Schwierzeck 
Cc: Maxim Sloyko 
Cc: Erik van Luijk 
Cc: Ryder Lee 
Cc: Weijie Gao 
Cc: Simon Glass 
Cc: "Álvaro Fernández Rojas" 
Cc: Philippe Reynes 
Cc: Christophe Leroy 
Cc: Chris Packham 
Reviewed-by: Michal Simek 
Tested-by: Michal Simek  (on zcu100)
---


[...]

diff --git a/drivers/watchdog/wdt-uclass.c 
b/drivers/watchdog/wdt-uclass.c

index 23b7e3360d..bbfac4f0f9 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -10,6 +10,8 @@
  #include 
  #include 
+DECLARE_GLOBAL_DATA_PTR;
+
  int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
  {
  const struct wdt_ops *ops = device_get_ops(dev);
@@ -63,6 +65,30 @@ int wdt_expire_now(struct udevice *dev, ulong flags)
  return ret;
  }
+#if defined(CONFIG_WATCHDOG)
+/*
+ * Called by macro WATCHDOG_RESET. This function be called *very* 
early,
+ * so we need to make sure, that the watchdog driver is ready before 
using

+ * it in this function.
+ */
+void watchdog_reset(void)
+{
+    static ulong next_reset;
+    ulong now;
+
+    /* Exit if GD is not ready or watchdog is not initialized yet */
+    if (!gd || !(gd->flags & GD_FLG_WDT_READY))
+    return;
+
+    /* Do not reset the watchdog too often */
+    now = get_timer(0);
+    if (now > next_reset) {
+    next_reset = now + 1000;    /* reset every 1000ms */
+    wdt_reset(gd->watchdog_dev);
+    }


This is a problem for the MPC8xx.

When running with a MPC8xx at 132MHz clock, the watchdog will fire 
about 1s after the last refresh. So the above makes the board unusable.


So you need a shorted delay between the wdt_reset() calls? Is this
correct? We could introduce a new Kconfig option which defaults to
1000 (ms) and you can "select" a shorter value for MPC8xx.


Exactly. However, why is this limitation needed at all ? Why is it a 
problem to refresh more often ?



Christophe


Re: [RFC PATCH 2/2] video: meson: Use reserving memory function without kernel linear mapping

2020-02-19 Thread Michael Nazzareno Trimarchi
Hi

On Thu, Feb 20, 2020 at 4:05 AM Simon Glass  wrote:
>
> Hi Michael,
>
> On Wed, 19 Feb 2020 at 11:43, Michael Trimarchi
>  wrote:
> >
> > Memory reserved for the simple framebuffer should not be used
> > and part of memory linear mapping
> >
> > Signed-off-by: Michael Trimarchi 
> > ---
> >  drivers/video/meson/meson_vpu.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
>
> Is there a binding file for this? Please add it to a patch.
>

This is an example how to use it. I need to repost it. There is a
compilation issue
later. I need only to have some feedback from Neil because I can not
test this board

> >
> > diff --git a/drivers/video/meson/meson_vpu.c 
> > b/drivers/video/meson/meson_vpu.c
> > index 4eb66398d0..134e011b82 100644
> > --- a/drivers/video/meson/meson_vpu.c
> > +++ b/drivers/video/meson/meson_vpu.c
> > @@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt)
> >  * at the end of the RAM and we strip this portion from the kernel
> >  * allowed region
> >  */
> > -   mem_start = gd->bd->bi_dram[0].start;
> > -   mem_size = gd->bd->bi_dram[0].size - meson_fb.fb_size;
> > -   ret = fdt_fixup_memory_banks(fdt, &mem_start, &mem_size, 1);
> > +   mem_start = meson_fb.base;
> > +   mem_size = meson_fb.fb_size;
> > +   ret = fdt_fixup_reserved_memory(blob, "display_reserved", 
> > &mem_start, &mem_size);
>
> Odd that this uses underscore...normally bindings use hyphen.
>

Will fix. There are few things that I need to change here because
sunxi, meson use simpleframe buffer
but they have some code duplication

Micheal

> > if (ret) {
> > eprintf("Cannot setup simplefb: Error reserving memory\n");
> > return;
> > --
> > 2.17.1
> >
>
> Regards,
> Simon


Re: [PATCH 1/4 v5] watchdog: Implement generic watchdog_reset() version

2020-02-19 Thread Stefan Roese

Hi Christophe

On 19.02.20 20:21, Christophe Leroy wrote:



Le 25/04/2019 à 09:17, Stefan Roese a écrit :

This patch tries to implement a generic watchdog_reset() function that
can be used by all boards that want to service the watchdog device in
U-Boot. This watchdog servicing is enabled via CONFIG_WATCHDOG.

Without this approach, new boards or platforms needed to implement a
board specific version of this functionality, mostly copy'ing the same
code over and over again into their board or platforms code base.

With this new generic function, the scattered other functions are now
removed to be replaced by the generic one. The new version also enables
the configuration of the watchdog timeout via the DT "timeout-sec"
property (if enabled via CONFIG_OF_CONTROL).

This patch also adds a new flag to the GD flags, to flag that the
watchdog is ready to use and adds the pointer to the watchdog device
to the GD. This enables us to remove the global "watchdog_dev"
variable, which was prone to cause problems because of its potentially
very early use in watchdog_reset(), even before the BSS is cleared.

Signed-off-by: Stefan Roese 
Cc: Heiko Schocher 
Cc: Tom Rini 
Cc: Michal Simek 
Cc: "Marek Behún" 
Cc: Daniel Schwierzeck 
Cc: Maxim Sloyko 
Cc: Erik van Luijk 
Cc: Ryder Lee 
Cc: Weijie Gao 
Cc: Simon Glass 
Cc: "Álvaro Fernández Rojas" 
Cc: Philippe Reynes 
Cc: Christophe Leroy 
Cc: Chris Packham 
Reviewed-by: Michal Simek 
Tested-by: Michal Simek  (on zcu100)
---


[...]

diff --git a/drivers/watchdog/wdt-uclass.c 
b/drivers/watchdog/wdt-uclass.c

index 23b7e3360d..bbfac4f0f9 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -10,6 +10,8 @@
  #include 
  #include 
+DECLARE_GLOBAL_DATA_PTR;
+
  int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
  {
  const struct wdt_ops *ops = device_get_ops(dev);
@@ -63,6 +65,30 @@ int wdt_expire_now(struct udevice *dev, ulong flags)
  return ret;
  }
+#if defined(CONFIG_WATCHDOG)
+/*
+ * Called by macro WATCHDOG_RESET. This function be called *very* early,
+ * so we need to make sure, that the watchdog driver is ready before 
using

+ * it in this function.
+ */
+void watchdog_reset(void)
+{
+    static ulong next_reset;
+    ulong now;
+
+    /* Exit if GD is not ready or watchdog is not initialized yet */
+    if (!gd || !(gd->flags & GD_FLG_WDT_READY))
+    return;
+
+    /* Do not reset the watchdog too often */
+    now = get_timer(0);
+    if (now > next_reset) {
+    next_reset = now + 1000;    /* reset every 1000ms */
+    wdt_reset(gd->watchdog_dev);
+    }


This is a problem for the MPC8xx.

When running with a MPC8xx at 132MHz clock, the watchdog will fire about 
1s after the last refresh. So the above makes the board unusable.


So you need a shorted delay between the wdt_reset() calls? Is this
correct? We could introduce a new Kconfig option which defaults to
1000 (ms) and you can "select" a shorter value for MPC8xx.

Would this work for you?

Is that really necessary to restrict the refresh like this in the core 
part of Watchdog driver ?


It seems to work for most cases (all until I hear of this MPC8xx issue).

Thanks,
Stefan


Re: [PATCH 3/4 v5] watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup

2020-02-19 Thread Stefan Roese

Hi Christophe,

On 19.02.20 20:15, Christophe Leroy wrote:

Hi Stefan,

On 04/25/2019 07:17 AM, Stefan Roese wrote:

With the generic watchdog driver now implemented, this patch removes
some legacy stuff from the MPC8xx watchdog driver and its Kconfig
integration. CONFIG_MPC8xx_WATCHDOG is completely removed and
hw_watchdog_reset() is made static, as the watchdog will now get
serviced via the DM infrastructure if enabled via CONFIG_WATCHDOG.

Signed-off-by: Stefan Roese 
Cc: Christophe Leroy 
---
v5:
- No change

v4:
- New patch

arch/powerpc/Kconfig    | 2 +-
  arch/powerpc/cpu/mpc8xx/Kconfig | 6 +++---
  drivers/watchdog/Kconfig    | 1 -
  drivers/watchdog/Makefile   | 2 +-
  drivers/watchdog/mpc8xx_wdt.c   | 4 +---
  5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c727d9162c..0b1629ba62 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -35,7 +35,7 @@ config MPC8xx
  bool "MPC8xx"
  select BOARD_EARLY_INIT_F
  imply CMD_REGINFO
-    imply MPC8xx_WATCHDOG
+    imply WDT_MPC8xx
  endchoice
diff --git a/arch/powerpc/cpu/mpc8xx/Kconfig 
b/arch/powerpc/cpu/mpc8xx/Kconfig

index b0e90a0f20..3e8ea38529 100644
--- a/arch/powerpc/cpu/mpc8xx/Kconfig
+++ b/arch/powerpc/cpu/mpc8xx/Kconfig
@@ -25,9 +25,9 @@ config MPC885
  endchoice
-config MPC8xx_WATCHDOG
-    bool "Watchdog"
-    select HW_WATCHDOG
+#config MPC8xx_WATCHDOG
+#    bool "Watchdog"
+#    select HW_WATCHDOG


If HW_WATCHDOG is not selected, we have a problem in cpu_init_f() 
(arch/powerpc/cpu/mpc8xx/cpu_init.c) with the following line, and the 
board with restart every second.


#ifndef CONFIG_HW_WATCHDOG
 /* deactivate watchdog if not enabled in config */
 out_be32(&immr->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE);
#endif

Should this be changed to use CONFIG_WATCHDOG instead ?


Yes, that sound reasonable.

Thanks,
Stefan


Re: Please pull mmc mmc-2-19-2020

2020-02-19 Thread Masahiro Yamada
Hi Peng,

On Thu, Feb 20, 2020 at 1:34 PM Tom Rini  wrote:
>
> On Thu, Feb 20, 2020 at 01:56:41AM +, Peng Fan wrote:
>
> > Hi Tom
> >
> > Please pull mmc-2-29-2020.
> >
>
> NAK, this breaks nios2:
>  nios2:  +   10m50 3c120
> +(10m50,3c120) ../drivers/net/altera_tse.c: In function 'altera_tse_probe':
> +(10m50,3c120) ../drivers/net/altera_tse.c:646:15: error: implicit 
> declaration of function 'dma_alloc_coherent'; did you mean 'lmb_alloc_addr'? 
> [-Werror=implicit-function-declaration]
> +(10m50,3c120) desc_mem = dma_alloc_coherent(len, &addr);
> +(10m50,3c120)^~
> +(10m50,3c120)lmb_alloc_addr
> +(10m50,3c120) ../drivers/net/altera_tse.c:646:13: error: assignment makes 
> pointer from integer without a cast [-Werror=int-conversion]
> +(10m50,3c120)  ^
> +(10m50,3c120) cc1: all warnings being treated as errors
> +(10m50,3c120) make[2]: *** [drivers/net/altera_tse.o] Error 1
> +(10m50,3c120) make[1]: *** [drivers/net] Error 2
> +(10m50,3c120) make: *** [sub-make] Error 2
>
> --
> Tom


Agh, something strange happens somehow in the following commit.

commit 87a6590d6eb500db95bcdb09c16efb16559f67c6
Author: Masahiro Yamada 
Date:   Fri Feb 14 16:40:20 2020 +0900

dma-mapping: add  for all architectures



Peng,

Could you replace it with this?
http://patchwork.ozlabs.org/patch/1241209/

(Or, just revert the diff for arch/nios2/include/asm/dma-mapping)




-- 
Best Regards
Masahiro Yamada


[PATCH v4 04/11] dma-mapping: add for all architectures

2020-02-19 Thread Masahiro Yamada
To avoid "asm/dma-mapping.h: No such file or directory" error,
we need something.

Signed-off-by: Masahiro Yamada 
---

Changes in v4:
  - Keep nios2 port as-is

Changes in v2:
  - New patch

 arch/arc/include/asm/dma-mapping.h| 1 +
 arch/m68k/include/asm/dma-mapping.h   | 1 +
 arch/microblaze/include/asm/dma-mapping.h | 1 +
 arch/mips/include/asm/dma-mapping.h   | 1 +
 arch/powerpc/include/asm/dma-mapping.h| 1 +
 arch/sandbox/include/asm/dma-mapping.h| 1 +
 arch/sh/include/asm/dma-mapping.h | 1 +
 arch/xtensa/include/asm/dma-mapping.h | 1 +
 8 files changed, 8 insertions(+)
 create mode 100644 arch/arc/include/asm/dma-mapping.h
 create mode 100644 arch/m68k/include/asm/dma-mapping.h
 create mode 100644 arch/microblaze/include/asm/dma-mapping.h
 create mode 100644 arch/mips/include/asm/dma-mapping.h
 create mode 100644 arch/powerpc/include/asm/dma-mapping.h
 create mode 100644 arch/sandbox/include/asm/dma-mapping.h
 create mode 100644 arch/sh/include/asm/dma-mapping.h
 create mode 100644 arch/xtensa/include/asm/dma-mapping.h

diff --git a/arch/arc/include/asm/dma-mapping.h 
b/arch/arc/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/arc/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/m68k/include/asm/dma-mapping.h 
b/arch/m68k/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/m68k/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/microblaze/include/asm/dma-mapping.h 
b/arch/microblaze/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/microblaze/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/mips/include/asm/dma-mapping.h 
b/arch/mips/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/powerpc/include/asm/dma-mapping.h 
b/arch/powerpc/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/sandbox/include/asm/dma-mapping.h 
b/arch/sandbox/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/sandbox/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/sh/include/asm/dma-mapping.h 
b/arch/sh/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/sh/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
diff --git a/arch/xtensa/include/asm/dma-mapping.h 
b/arch/xtensa/include/asm/dma-mapping.h
new file mode 100644
index ..853b0877b33d
--- /dev/null
+++ b/arch/xtensa/include/asm/dma-mapping.h
@@ -0,0 +1 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
-- 
2.17.1



[PATCH 2/3] mmc: check the flags of host_caps about broken-cd

2020-02-19 Thread Jaehoon Chung
broken-cd is provided to dt-property.
Then it's set to MMC_CAP_NEEDS_POLL flag.

Signed-off-by: Jaehoon Chung 
---
 drivers/mmc/mmc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b50fcbf6cf..cac60ea034 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2846,11 +2846,11 @@ int mmc_start_init(struct mmc *mmc)
mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(SD_LEGACY) |
 MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT;
 
-#if !defined(CONFIG_MMC_BROKEN_CD)
-   no_card = mmc_getcd(mmc) == 0;
-#else
-   no_card = 0;
-#endif
+   if (mmc->host_caps & MMC_CAP_NEEDS_POLL)
+   no_card = 0;
+   else
+   no_card = mmc_getcd(mmc) == 0;
+
 #if !CONFIG_IS_ENABLED(DM_MMC)
/* we pretend there's no card when init is NULL */
no_card = no_card || (mmc->cfg->ops->init == NULL);
-- 
2.25.0



[PATCH 1/3] mmc: jz_mmc; add MMC_CAP_NEEDS_POLL by default

2020-02-19 Thread Jaehoon Chung
Add MMC_CAP_NEEDS_POLL by default.

Signed-off-by: Jaehoon Chung 
---
 drivers/mmc/jz_mmc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/jz_mmc.c b/drivers/mmc/jz_mmc.c
index 8d4f886cb4..df995bda2f 100644
--- a/drivers/mmc/jz_mmc.c
+++ b/drivers/mmc/jz_mmc.c
@@ -395,7 +395,8 @@ static struct jz_mmc_plat jz_mmc_plat_static = {
.voltages = MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 |
MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 |
MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36,
-   .host_caps = MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS,
+   .host_caps = MMC_MODE_4BIT | MMC_MODE_HS_52MHz | MMC_MODE_HS |
+   MMC_CAP_NEEDS_POLL,
 
.f_min = 375000,
.f_max = 4800,
@@ -452,7 +453,8 @@ static int jz_mmc_ofdata_to_platdata(struct udevice *dev)
cfg = &plat->cfg;
 
cfg->name = "MSC";
-   cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
+   cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS |
+   MMC_CAP_NEEDS_POLL;
 
ret = mmc_of_parse(dev, cfg);
if (ret < 0) {
-- 
2.25.0



[PATCH 3/3] mmc: Kconfig: remove MMC_BROKEN_CD configuration

2020-02-19 Thread Jaehoon Chung
Remove MMC_BROKEN_CD configuration.
It doesn't need to use configuration, instead use broken-cd property.

Signed-off-by: Jaehoon Chung 
---
 configs/brppt2_defconfig| 1 -
 configs/ci20_mmc_defconfig  | 1 -
 configs/meerkat96_defconfig | 1 -
 drivers/mmc/Kconfig | 5 -
 4 files changed, 8 deletions(-)

diff --git a/configs/brppt2_defconfig b/configs/brppt2_defconfig
index f94ea28376..5d1dfde36e 100644
--- a/configs/brppt2_defconfig
+++ b/configs/brppt2_defconfig
@@ -68,7 +68,6 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
 # CONFIG_SPL_BLK is not set
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_I2C_MXC=y
-CONFIG_MMC_BROKEN_CD=y
 # CONFIG_SPL_DM_MMC is not set
 CONFIG_FSL_ESDHC=y
 CONFIG_MTD=y
diff --git a/configs/ci20_mmc_defconfig b/configs/ci20_mmc_defconfig
index a0b0772f40..f31a3c44f4 100644
--- a/configs/ci20_mmc_defconfig
+++ b/configs/ci20_mmc_defconfig
@@ -34,7 +34,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_JZ4780_EFUSE=y
 CONFIG_MMC=y
-CONFIG_MMC_BROKEN_CD=y
 CONFIG_DM_MMC=y
 # CONFIG_MMC_HW_PARTITIONING is not set
 CONFIG_MMC_IO_VOLTAGE=y
diff --git a/configs/meerkat96_defconfig b/configs/meerkat96_defconfig
index 45f12115ba..d358ed23a5 100644
--- a/configs/meerkat96_defconfig
+++ b/configs/meerkat96_defconfig
@@ -34,7 +34,6 @@ CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-meerkat96"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_MMC_BROKEN_CD=y
 CONFIG_DM_MMC=y
 CONFIG_FSL_ESDHC=y
 CONFIG_MTD=y
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 2f0eedc22f..3722e7bc13 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -18,11 +18,6 @@ config MMC_WRITE
help
  Enable write access to MMC and SD Cards
 
-config MMC_BROKEN_CD
-   bool "Poll for broken card detection case"
-   help
- If card  detection feature is broken, just poll to detect.
-
 config DM_MMC
bool "Enable MMC controllers using Driver Model"
depends on DM
-- 
2.25.0



[PATCH 0/3] Remove CONFIG_MMC_BROKEN_CD

2020-02-19 Thread Jaehoon Chung
CONFIG_MMC_BROKEN_CD needs not to define to Kconfig.
broken-cd is already provide to dt-property.
If want to poll card-detect, set to broken-cd instead of enabling 
CONFIG_MMC_BROKEN_CD.

When checked the boards that is eabled CONFIG_MMC_BROKEN_CD,
it also used the value of dt as broken-cd.

Jaehoon Chung (3):
  mmc: jz_mmc; add MMC_CAP_NEEDS_POLL by default
  mmc: check the flags of host_caps about broken-cd
  mmc: Kconfig: remove MMC_BROKEN_CD configuration

 configs/brppt2_defconfig|  1 -
 configs/ci20_mmc_defconfig  |  1 -
 configs/meerkat96_defconfig |  1 -
 drivers/mmc/Kconfig |  5 -
 drivers/mmc/jz_mmc.c|  6 --
 drivers/mmc/mmc.c   | 10 +-
 6 files changed, 9 insertions(+), 15 deletions(-)

-- 
2.25.0



Re: Please pull mmc mmc-2-19-2020

2020-02-19 Thread Tom Rini
On Thu, Feb 20, 2020 at 01:56:41AM +, Peng Fan wrote:

> Hi Tom
> 
> Please pull mmc-2-29-2020.
> 

NAK, this breaks nios2:
 nios2:  +   10m50 3c120
+(10m50,3c120) ../drivers/net/altera_tse.c: In function 'altera_tse_probe':
+(10m50,3c120) ../drivers/net/altera_tse.c:646:15: error: implicit declaration 
of function 'dma_alloc_coherent'; did you mean 'lmb_alloc_addr'? 
[-Werror=implicit-function-declaration]
+(10m50,3c120) desc_mem = dma_alloc_coherent(len, &addr);
+(10m50,3c120)^~
+(10m50,3c120)lmb_alloc_addr
+(10m50,3c120) ../drivers/net/altera_tse.c:646:13: error: assignment makes 
pointer from integer without a cast [-Werror=int-conversion]
+(10m50,3c120)  ^
+(10m50,3c120) cc1: all warnings being treated as errors
+(10m50,3c120) make[2]: *** [drivers/net/altera_tse.o] Error 1
+(10m50,3c120) make[1]: *** [drivers/net] Error 2
+(10m50,3c120) make: *** [sub-make] Error 2

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 0/6] rockchip: efuse: add support for more platfroms

2020-02-19 Thread Finley Xiao
Finley Xiao (6):
  rockchip: efuse: Add support for rk3288 efuse
  rockchip: efuse: Add support for rk3066a efuse
  rockchip: efuse: Add support for rk3188 efuse
  rockchip: efuse: Add support for rk322x efuse
  rockchip: efuse: Add support for rk3328 non-secure efuse
  rockchip: efuse: Add support for rk1808 non-secure efuse

 drivers/misc/rockchip-efuse.c | 271 +-
 1 file changed, 267 insertions(+), 4 deletions(-)

-- 
2.11.0





[PATCH 2/6] rockchip: efuse: Add support for rk3066a efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3066a.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index f01d877e33..3f2c64b105 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -208,6 +208,10 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 
 static const struct udevice_id rockchip_efuse_ids[] = {
{
+   .compatible = "rockchip,rk3066a-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3288-efuse",
.data = (ulong)&rockchip_rk3288_efuse_read,
},
-- 
2.11.0





[PATCH 4/6] rockchip: efuse: Add support for rk322x efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk322x.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index e549d5d282..175a7fe2f5 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -216,6 +216,10 @@ static const struct udevice_id rockchip_efuse_ids[] = {
.data = (ulong)&rockchip_rk3288_efuse_read,
},
{
+   .compatible = "rockchip,rk322x-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3288-efuse",
.data = (ulong)&rockchip_rk3288_efuse_read,
},
-- 
2.11.0





[PATCH 2/2] rockchip: efuse: Add support for rk1808 non-secure efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk1808.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 114 ++
 1 file changed, 114 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 68762d3f6f..778e29f30d 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -16,6 +16,46 @@
 #include 
 #include 
 
+#define T_CSB_P_S  0
+#define T_PGENB_P_S0
+#define T_LOAD_P_S 0
+#define T_ADDR_P_S 0
+#define T_STROBE_P_S   (0 + 110) /* 1.1us */
+#define T_CSB_P_L  (0 + 110 + 1000 + 20) /* 200ns */
+#define T_PGENB_P_L(0 + 110 + 1000 + 20)
+#define T_LOAD_P_L (0 + 110 + 1000 + 20)
+#define T_ADDR_P_L (0 + 110 + 1000 + 20)
+#define T_STROBE_P_L   (0 + 110 + 1000) /* 10us */
+#define T_CSB_R_S  0
+#define T_PGENB_R_S0
+#define T_LOAD_R_S 0
+#define T_ADDR_R_S 2
+#define T_STROBE_R_S   (2 + 3)
+#define T_CSB_R_L  (2 + 3 + 3 + 3)
+#define T_PGENB_R_L(2 + 3 + 3 + 3)
+#define T_LOAD_R_L (2 + 3 + 3 + 3)
+#define T_ADDR_R_L (2 + 3 + 3 + 2)
+#define T_STROBE_R_L   (2 + 3 + 3)
+
+#define T_CSB_P0x28
+#define T_PGENB_P  0x2c
+#define T_LOAD_P   0x30
+#define T_ADDR_P   0x34
+#define T_STROBE_P 0x38
+#define T_CSB_R0x3c
+#define T_PGENB_R  0x40
+#define T_LOAD_R   0x44
+#define T_ADDR_R   0x48
+#define T_STROBE_R 0x4c
+
+#define RK1808_USER_MODE   BIT(0)
+#define RK1808_INT_FINISH  BIT(0)
+#define RK1808_AUTO_ENBBIT(0)
+#define RK1808_AUTO_RD BIT(1)
+#define RK1808_A_SHIFT 16
+#define RK1808_A_MASK  0x3ff
+#define RK1808_NBYTES  4
+
 #define RK3288_A_SHIFT  6
 #define RK3288_A_MASK   0x3ff
 #define RK3288_NFUSES   32
@@ -109,6 +149,76 @@ U_BOOT_CMD(
 );
 #endif
 
+static void rk1808_efuse_timing_init(void __iomem *base)
+{
+   static bool init;
+
+   if (init)
+   return;
+
+   /* enable auto mode */
+   writel(readl(base) & (~RK1808_USER_MODE), base);
+
+   /* setup efuse timing */
+   writel((T_CSB_P_S << 16) | T_CSB_P_L, base + T_CSB_P);
+   writel((T_PGENB_P_S << 16) | T_PGENB_P_L, base + T_PGENB_P);
+   writel((T_LOAD_P_S << 16) | T_LOAD_P_L, base + T_LOAD_P);
+   writel((T_ADDR_P_S << 16) | T_ADDR_P_L, base + T_ADDR_P);
+   writel((T_STROBE_P_S << 16) | T_STROBE_P_L, base + T_STROBE_P);
+   writel((T_CSB_R_S << 16) | T_CSB_R_L, base + T_CSB_R);
+   writel((T_PGENB_R_S << 16) | T_PGENB_R_L, base + T_PGENB_R);
+   writel((T_LOAD_R_S << 16) | T_LOAD_R_L, base + T_LOAD_R);
+   writel((T_ADDR_R_S << 16) | T_ADDR_R_L, base + T_ADDR_R);
+   writel((T_STROBE_R_S << 16) | T_STROBE_R_L, base + T_STROBE_R);
+
+   init = true;
+}
+
+static int rockchip_rk1808_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   unsigned int addr_start, addr_end, addr_offset, addr_len;
+   u32 out_value, status;
+   u8 *buffer;
+   int ret = 0, i = 0;
+
+   rk1808_efuse_timing_init(plat->base);
+
+   addr_start = rounddown(offset, RK1808_NBYTES) / RK1808_NBYTES;
+   addr_end = roundup(offset + size, RK1808_NBYTES) / RK1808_NBYTES;
+   addr_offset = offset % RK1808_NBYTES;
+   addr_len = addr_end - addr_start;
+
+   buffer = calloc(1, sizeof(*buffer) * addr_len * RK1808_NBYTES);
+   if (!buffer)
+   return -ENOMEM;
+
+   while (addr_len--) {
+   writel(RK1808_AUTO_RD | RK1808_AUTO_ENB |
+  ((addr_start++ & RK1808_A_MASK) << RK1808_A_SHIFT),
+  &efuse->auto_ctrl);
+   udelay(2);
+   status = readl(&efuse->int_status);
+   if (!(status & RK1808_INT_FINISH)) {
+   ret = -EIO;
+   goto err;
+   }
+   out_value = readl(&efuse->dout2);
+   writel(RK1808_INT_FINISH, &efuse->int_status);
+
+   memcpy(&buffer[i], &out_value, RK1808_NBYTES);
+   i += RK1808_NBYTES;
+   }
+   memcpy(buf, buffer + addr_offset, size);
+err:
+   free(buffer);
+
+   return ret;
+}
+
 static int rockchip_rk3288_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -273,6 +383,10 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 
 static const struct udevice_id rockchip_efuse_ids[] = 

[PATCH 3/6] rockchip: efuse: Add support for rk3188 efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3188.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 3f2c64b105..e549d5d282 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -212,6 +212,10 @@ static const struct udevice_id rockchip_efuse_ids[] = {
.data = (ulong)&rockchip_rk3288_efuse_read,
},
{
+   .compatible = "rockchip,rk3188-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3288-efuse",
.data = (ulong)&rockchip_rk3288_efuse_read,
},
-- 
2.11.0





[PATCH 2/6] rockchip: efuse: Add support for rk3066a efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3066a.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index f01d877e33..3f2c64b105 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -208,6 +208,10 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 
 static const struct udevice_id rockchip_efuse_ids[] = {
{
+   .compatible = "rockchip,rk3066a-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3288-efuse",
.data = (ulong)&rockchip_rk3288_efuse_read,
},
-- 
2.11.0





[PATCH 1/6] rockchip: efuse: Add support for rk3288 efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3288.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 76 ---
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 2520c6a38e..f01d877e33 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -15,6 +15,15 @@
 #include 
 #include 
 
+#define RK3288_A_SHIFT  6
+#define RK3288_A_MASK   0x3ff
+#define RK3288_NFUSES   32
+#define RK3288_BYTES_PER_FUSE   1
+#define RK3288_PGENBBIT(3)
+#define RK3288_LOAD BIT(2)
+#define RK3288_STROBE   BIT(1)
+#define RK3288_CSB  BIT(0)
+
 #define RK3399_A_SHIFT  16
 #define RK3399_A_MASK   0x3ff
 #define RK3399_NFUSES   32
@@ -27,6 +36,9 @@
 #define RK3399_STROBE   BIT(1)
 #define RK3399_CSB  BIT(0)
 
+typedef int (*EFUSE_READ)(struct udevice *dev, int offset, void *buf,
+ int size);
+
 struct rockchip_efuse_regs {
u32 ctrl;  /* 0x00  efuse control register */
u32 dout;  /* 0x04  efuse data out register */
@@ -53,7 +65,7 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 */
 
struct udevice *dev;
-   u8 fuses[128];
+   u8 fuses[128] = {0};
int ret;
 
/* retrieve the device */
@@ -77,12 +89,55 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 }
 
 U_BOOT_CMD(
-   rk3399_dump_efuses, 1, 1, dump_efuses,
+   rockchip_dump_efuses, 1, 1, dump_efuses,
"Dump the content of the efuses",
""
 );
 #endif
 
+static int rockchip_rk3288_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   u8 *buffer = buf;
+   int max_size = RK3288_NFUSES * RK3288_BYTES_PER_FUSE;
+
+   if (size > (max_size - offset))
+   size = max_size - offset;
+
+   /* Switch to read mode */
+   writel(RK3288_LOAD | RK3288_PGENB, &efuse->ctrl);
+   udelay(1);
+
+   while (size--) {
+   writel(readl(&efuse->ctrl) &
+(~(RK3288_A_MASK << RK3288_A_SHIFT)),
+&efuse->ctrl);
+   /* set addr */
+   writel(readl(&efuse->ctrl) |
+((offset++ & RK3288_A_MASK) << RK3288_A_SHIFT),
+&efuse->ctrl);
+   udelay(1);
+   /* strobe low to high */
+   writel(readl(&efuse->ctrl) |
+RK3288_STROBE, &efuse->ctrl);
+   ndelay(60);
+   /* read data */
+   *buffer++ = readl(&efuse->dout);
+   /* reset strobe to low */
+   writel(readl(&efuse->ctrl) &
+(~RK3288_STROBE), &efuse->ctrl);
+   udelay(1);
+   }
+
+   /* Switch to standby mode */
+   writel(RK3288_PGENB | RK3288_CSB, &efuse->ctrl);
+
+   return 0;
+}
+
 static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -130,7 +185,13 @@ static int rockchip_rk3399_efuse_read(struct udevice *dev, 
int offset,
 static int rockchip_efuse_read(struct udevice *dev, int offset,
   void *buf, int size)
 {
-   return rockchip_rk3399_efuse_read(dev, offset, buf, size);
+   EFUSE_READ efuse_read = NULL;
+
+   efuse_read = (EFUSE_READ)dev_get_driver_data(dev);
+   if (!efuse_read)
+   return -EINVAL;
+
+   return (*efuse_read)(dev, offset, buf, size);
 }
 
 static const struct misc_ops rockchip_efuse_ops = {
@@ -146,7 +207,14 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 }
 
 static const struct udevice_id rockchip_efuse_ids[] = {
-   { .compatible = "rockchip,rk3399-efuse" },
+   {
+   .compatible = "rockchip,rk3288-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
+   .compatible = "rockchip,rk3399-efuse",
+   .data = (ulong)&rockchip_rk3399_efuse_read,
+   },
{}
 };
 
-- 
2.11.0





[PATCH 0/6] rockchip: efuse: add support for more paltforms

2020-02-19 Thread Finley Xiao
Finley Xiao (6):
  rockchip: efuse: Add support for rk3288 efuse
  rockchip: efuse: Add support for rk3066a efuse
  rockchip: efuse: Add support for rk3188 efuse
  rockchip: efuse: Add support for rk322x efuse
  rockchip: efuse: Add support for rk3328 non-secure efuse
  rockchip: efuse: Add support for rk1808 non-secure efuse

 drivers/misc/rockchip-efuse.c | 271 +-
 1 file changed, 267 insertions(+), 4 deletions(-)

-- 
2.11.0





[PATCH 1/2] rockchip: efuse: Add support for rk3328 non-secure efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3328.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 69 +++
 1 file changed, 69 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 175a7fe2f5..68762d3f6f 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define RK3288_A_SHIFT  6
@@ -24,6 +25,15 @@
 #define RK3288_STROBE   BIT(1)
 #define RK3288_CSB  BIT(0)
 
+#define RK3328_INT_STATUS  0x0018
+#define RK3328_DOUT0x0020
+#define RK3328_AUTO_CTRL   0x0024
+#define RK3328_INT_FINISH  BIT(0)
+#define RK3328_AUTO_ENBBIT(0)
+#define RK3328_AUTO_RD BIT(1)
+#define RK3328_NO_SECURE_BYTES 32
+#define RK3328_SECURE_BYTES96
+
 #define RK3399_A_SHIFT  16
 #define RK3399_A_MASK   0x3ff
 #define RK3399_NFUSES   32
@@ -47,6 +57,10 @@ struct rockchip_efuse_regs {
u32 jtag_pass; /* 0x10  JTAG password */
u32 strobe_finish_ctrl;
   /* 0x14  efuse strobe finish control register */
+   u32 int_status;/* 0x18 */
+   u32 reserved;  /* 0x1c */
+   u32 dout2; /* 0x20 */
+   u32 auto_ctrl; /* 0x24 */
 };
 
 struct rockchip_efuse_platdata {
@@ -138,6 +152,57 @@ static int rockchip_rk3288_efuse_read(struct udevice *dev, 
int offset,
return 0;
 }
 
+static int rockchip_rk3328_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   unsigned int addr_start, addr_end, addr_offset, addr_len;
+   u32 out_value, status;
+   u8 *buffer;
+   int ret = 0, i = 0, j = 0;
+
+   /* Max non-secure Byte */
+   if (size > RK3328_NO_SECURE_BYTES)
+   size = RK3328_NO_SECURE_BYTES;
+
+   /* 128 Byte efuse, 96 Byte for secure, 32 Byte for non-secure */
+   offset += RK3328_SECURE_BYTES;
+   addr_start = rounddown(offset, RK3399_BYTES_PER_FUSE) /
+  RK3399_BYTES_PER_FUSE;
+   addr_end = roundup(offset + size, RK3399_BYTES_PER_FUSE) /
+  RK3399_BYTES_PER_FUSE;
+   addr_offset = offset % RK3399_BYTES_PER_FUSE;
+   addr_len = addr_end - addr_start;
+
+   buffer = calloc(1, sizeof(*buffer) * addr_len * RK3399_BYTES_PER_FUSE);
+   if (!buffer)
+   return -ENOMEM;
+
+   for (j = 0; j < addr_len; j++) {
+   writel(RK3328_AUTO_RD | RK3328_AUTO_ENB |
+  ((addr_start++ & RK3399_A_MASK) << RK3399_A_SHIFT),
+  &efuse->auto_ctrl);
+   udelay(5);
+   status = readl(&efuse->int_status);
+   if (!(status & RK3328_INT_FINISH)) {
+   ret = -EIO;
+   goto err;
+   }
+   out_value = readl(&efuse->dout2);
+   writel(RK3328_INT_FINISH, &efuse->int_status);
+
+   memcpy(&buffer[i], &out_value, RK3399_BYTES_PER_FUSE);
+   i += RK3399_BYTES_PER_FUSE;
+   }
+   memcpy(buf, buffer + addr_offset, size);
+err:
+   free(buffer);
+
+   return ret;
+}
+
 static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -224,6 +289,10 @@ static const struct udevice_id rockchip_efuse_ids[] = {
.data = (ulong)&rockchip_rk3288_efuse_read,
},
{
+   .compatible = "rockchip,rk3328-efuse",
+   .data = (ulong)&rockchip_rk3328_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3399-efuse",
.data = (ulong)&rockchip_rk3399_efuse_read,
},
-- 
2.11.0





[PATCH 1/2] rockchip: efuse: Add support for rk3328 non-secure efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3328.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 69 +++
 1 file changed, 69 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 175a7fe2f5..68762d3f6f 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define RK3288_A_SHIFT  6
@@ -24,6 +25,15 @@
 #define RK3288_STROBE   BIT(1)
 #define RK3288_CSB  BIT(0)
 
+#define RK3328_INT_STATUS  0x0018
+#define RK3328_DOUT0x0020
+#define RK3328_AUTO_CTRL   0x0024
+#define RK3328_INT_FINISH  BIT(0)
+#define RK3328_AUTO_ENBBIT(0)
+#define RK3328_AUTO_RD BIT(1)
+#define RK3328_NO_SECURE_BYTES 32
+#define RK3328_SECURE_BYTES96
+
 #define RK3399_A_SHIFT  16
 #define RK3399_A_MASK   0x3ff
 #define RK3399_NFUSES   32
@@ -47,6 +57,10 @@ struct rockchip_efuse_regs {
u32 jtag_pass; /* 0x10  JTAG password */
u32 strobe_finish_ctrl;
   /* 0x14  efuse strobe finish control register */
+   u32 int_status;/* 0x18 */
+   u32 reserved;  /* 0x1c */
+   u32 dout2; /* 0x20 */
+   u32 auto_ctrl; /* 0x24 */
 };
 
 struct rockchip_efuse_platdata {
@@ -138,6 +152,57 @@ static int rockchip_rk3288_efuse_read(struct udevice *dev, 
int offset,
return 0;
 }
 
+static int rockchip_rk3328_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   unsigned int addr_start, addr_end, addr_offset, addr_len;
+   u32 out_value, status;
+   u8 *buffer;
+   int ret = 0, i = 0, j = 0;
+
+   /* Max non-secure Byte */
+   if (size > RK3328_NO_SECURE_BYTES)
+   size = RK3328_NO_SECURE_BYTES;
+
+   /* 128 Byte efuse, 96 Byte for secure, 32 Byte for non-secure */
+   offset += RK3328_SECURE_BYTES;
+   addr_start = rounddown(offset, RK3399_BYTES_PER_FUSE) /
+  RK3399_BYTES_PER_FUSE;
+   addr_end = roundup(offset + size, RK3399_BYTES_PER_FUSE) /
+  RK3399_BYTES_PER_FUSE;
+   addr_offset = offset % RK3399_BYTES_PER_FUSE;
+   addr_len = addr_end - addr_start;
+
+   buffer = calloc(1, sizeof(*buffer) * addr_len * RK3399_BYTES_PER_FUSE);
+   if (!buffer)
+   return -ENOMEM;
+
+   for (j = 0; j < addr_len; j++) {
+   writel(RK3328_AUTO_RD | RK3328_AUTO_ENB |
+  ((addr_start++ & RK3399_A_MASK) << RK3399_A_SHIFT),
+  &efuse->auto_ctrl);
+   udelay(5);
+   status = readl(&efuse->int_status);
+   if (!(status & RK3328_INT_FINISH)) {
+   ret = -EIO;
+   goto err;
+   }
+   out_value = readl(&efuse->dout2);
+   writel(RK3328_INT_FINISH, &efuse->int_status);
+
+   memcpy(&buffer[i], &out_value, RK3399_BYTES_PER_FUSE);
+   i += RK3399_BYTES_PER_FUSE;
+   }
+   memcpy(buf, buffer + addr_offset, size);
+err:
+   free(buffer);
+
+   return ret;
+}
+
 static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -224,6 +289,10 @@ static const struct udevice_id rockchip_efuse_ids[] = {
.data = (ulong)&rockchip_rk3288_efuse_read,
},
{
+   .compatible = "rockchip,rk3328-efuse",
+   .data = (ulong)&rockchip_rk3328_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3399-efuse",
.data = (ulong)&rockchip_rk3399_efuse_read,
},
-- 
2.11.0





[PATCH 0/6] rockchip: efuse: add support for more platfroms

2020-02-19 Thread Finley Xiao
Finley Xiao (6):
  rockchip: efuse: Add support for rk3288 efuse
  rockchip: efuse: Add support for rk3066a efuse
  rockchip: efuse: Add support for rk3188 efuse
  rockchip: efuse: Add support for rk322x efuse
  rockchip: efuse: Add support for rk3328 non-secure efuse
  rockchip: efuse: Add support for rk1808 non-secure efuse

 drivers/misc/rockchip-efuse.c | 271 +-
 1 file changed, 267 insertions(+), 4 deletions(-)

-- 
2.11.0





[PATCH 2/2] rockchip: efuse: Add support for rk1808 non-secure efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk1808.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 114 ++
 1 file changed, 114 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 68762d3f6f..778e29f30d 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -16,6 +16,46 @@
 #include 
 #include 
 
+#define T_CSB_P_S  0
+#define T_PGENB_P_S0
+#define T_LOAD_P_S 0
+#define T_ADDR_P_S 0
+#define T_STROBE_P_S   (0 + 110) /* 1.1us */
+#define T_CSB_P_L  (0 + 110 + 1000 + 20) /* 200ns */
+#define T_PGENB_P_L(0 + 110 + 1000 + 20)
+#define T_LOAD_P_L (0 + 110 + 1000 + 20)
+#define T_ADDR_P_L (0 + 110 + 1000 + 20)
+#define T_STROBE_P_L   (0 + 110 + 1000) /* 10us */
+#define T_CSB_R_S  0
+#define T_PGENB_R_S0
+#define T_LOAD_R_S 0
+#define T_ADDR_R_S 2
+#define T_STROBE_R_S   (2 + 3)
+#define T_CSB_R_L  (2 + 3 + 3 + 3)
+#define T_PGENB_R_L(2 + 3 + 3 + 3)
+#define T_LOAD_R_L (2 + 3 + 3 + 3)
+#define T_ADDR_R_L (2 + 3 + 3 + 2)
+#define T_STROBE_R_L   (2 + 3 + 3)
+
+#define T_CSB_P0x28
+#define T_PGENB_P  0x2c
+#define T_LOAD_P   0x30
+#define T_ADDR_P   0x34
+#define T_STROBE_P 0x38
+#define T_CSB_R0x3c
+#define T_PGENB_R  0x40
+#define T_LOAD_R   0x44
+#define T_ADDR_R   0x48
+#define T_STROBE_R 0x4c
+
+#define RK1808_USER_MODE   BIT(0)
+#define RK1808_INT_FINISH  BIT(0)
+#define RK1808_AUTO_ENBBIT(0)
+#define RK1808_AUTO_RD BIT(1)
+#define RK1808_A_SHIFT 16
+#define RK1808_A_MASK  0x3ff
+#define RK1808_NBYTES  4
+
 #define RK3288_A_SHIFT  6
 #define RK3288_A_MASK   0x3ff
 #define RK3288_NFUSES   32
@@ -109,6 +149,76 @@ U_BOOT_CMD(
 );
 #endif
 
+static void rk1808_efuse_timing_init(void __iomem *base)
+{
+   static bool init;
+
+   if (init)
+   return;
+
+   /* enable auto mode */
+   writel(readl(base) & (~RK1808_USER_MODE), base);
+
+   /* setup efuse timing */
+   writel((T_CSB_P_S << 16) | T_CSB_P_L, base + T_CSB_P);
+   writel((T_PGENB_P_S << 16) | T_PGENB_P_L, base + T_PGENB_P);
+   writel((T_LOAD_P_S << 16) | T_LOAD_P_L, base + T_LOAD_P);
+   writel((T_ADDR_P_S << 16) | T_ADDR_P_L, base + T_ADDR_P);
+   writel((T_STROBE_P_S << 16) | T_STROBE_P_L, base + T_STROBE_P);
+   writel((T_CSB_R_S << 16) | T_CSB_R_L, base + T_CSB_R);
+   writel((T_PGENB_R_S << 16) | T_PGENB_R_L, base + T_PGENB_R);
+   writel((T_LOAD_R_S << 16) | T_LOAD_R_L, base + T_LOAD_R);
+   writel((T_ADDR_R_S << 16) | T_ADDR_R_L, base + T_ADDR_R);
+   writel((T_STROBE_R_S << 16) | T_STROBE_R_L, base + T_STROBE_R);
+
+   init = true;
+}
+
+static int rockchip_rk1808_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   unsigned int addr_start, addr_end, addr_offset, addr_len;
+   u32 out_value, status;
+   u8 *buffer;
+   int ret = 0, i = 0;
+
+   rk1808_efuse_timing_init(plat->base);
+
+   addr_start = rounddown(offset, RK1808_NBYTES) / RK1808_NBYTES;
+   addr_end = roundup(offset + size, RK1808_NBYTES) / RK1808_NBYTES;
+   addr_offset = offset % RK1808_NBYTES;
+   addr_len = addr_end - addr_start;
+
+   buffer = calloc(1, sizeof(*buffer) * addr_len * RK1808_NBYTES);
+   if (!buffer)
+   return -ENOMEM;
+
+   while (addr_len--) {
+   writel(RK1808_AUTO_RD | RK1808_AUTO_ENB |
+  ((addr_start++ & RK1808_A_MASK) << RK1808_A_SHIFT),
+  &efuse->auto_ctrl);
+   udelay(2);
+   status = readl(&efuse->int_status);
+   if (!(status & RK1808_INT_FINISH)) {
+   ret = -EIO;
+   goto err;
+   }
+   out_value = readl(&efuse->dout2);
+   writel(RK1808_INT_FINISH, &efuse->int_status);
+
+   memcpy(&buffer[i], &out_value, RK1808_NBYTES);
+   i += RK1808_NBYTES;
+   }
+   memcpy(buf, buffer + addr_offset, size);
+err:
+   free(buffer);
+
+   return ret;
+}
+
 static int rockchip_rk3288_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -273,6 +383,10 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 
 static const struct udevice_id rockchip_efuse_ids[] = 

[PATCH 1/6] rockchip: efuse: Add support for rk3288 efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3288.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 76 ---
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 2520c6a38e..f01d877e33 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -15,6 +15,15 @@
 #include 
 #include 
 
+#define RK3288_A_SHIFT  6
+#define RK3288_A_MASK   0x3ff
+#define RK3288_NFUSES   32
+#define RK3288_BYTES_PER_FUSE   1
+#define RK3288_PGENBBIT(3)
+#define RK3288_LOAD BIT(2)
+#define RK3288_STROBE   BIT(1)
+#define RK3288_CSB  BIT(0)
+
 #define RK3399_A_SHIFT  16
 #define RK3399_A_MASK   0x3ff
 #define RK3399_NFUSES   32
@@ -27,6 +36,9 @@
 #define RK3399_STROBE   BIT(1)
 #define RK3399_CSB  BIT(0)
 
+typedef int (*EFUSE_READ)(struct udevice *dev, int offset, void *buf,
+ int size);
+
 struct rockchip_efuse_regs {
u32 ctrl;  /* 0x00  efuse control register */
u32 dout;  /* 0x04  efuse data out register */
@@ -53,7 +65,7 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 */
 
struct udevice *dev;
-   u8 fuses[128];
+   u8 fuses[128] = {0};
int ret;
 
/* retrieve the device */
@@ -77,12 +89,55 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 }
 
 U_BOOT_CMD(
-   rk3399_dump_efuses, 1, 1, dump_efuses,
+   rockchip_dump_efuses, 1, 1, dump_efuses,
"Dump the content of the efuses",
""
 );
 #endif
 
+static int rockchip_rk3288_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   u8 *buffer = buf;
+   int max_size = RK3288_NFUSES * RK3288_BYTES_PER_FUSE;
+
+   if (size > (max_size - offset))
+   size = max_size - offset;
+
+   /* Switch to read mode */
+   writel(RK3288_LOAD | RK3288_PGENB, &efuse->ctrl);
+   udelay(1);
+
+   while (size--) {
+   writel(readl(&efuse->ctrl) &
+(~(RK3288_A_MASK << RK3288_A_SHIFT)),
+&efuse->ctrl);
+   /* set addr */
+   writel(readl(&efuse->ctrl) |
+((offset++ & RK3288_A_MASK) << RK3288_A_SHIFT),
+&efuse->ctrl);
+   udelay(1);
+   /* strobe low to high */
+   writel(readl(&efuse->ctrl) |
+RK3288_STROBE, &efuse->ctrl);
+   ndelay(60);
+   /* read data */
+   *buffer++ = readl(&efuse->dout);
+   /* reset strobe to low */
+   writel(readl(&efuse->ctrl) &
+(~RK3288_STROBE), &efuse->ctrl);
+   udelay(1);
+   }
+
+   /* Switch to standby mode */
+   writel(RK3288_PGENB | RK3288_CSB, &efuse->ctrl);
+
+   return 0;
+}
+
 static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -130,7 +185,13 @@ static int rockchip_rk3399_efuse_read(struct udevice *dev, 
int offset,
 static int rockchip_efuse_read(struct udevice *dev, int offset,
   void *buf, int size)
 {
-   return rockchip_rk3399_efuse_read(dev, offset, buf, size);
+   EFUSE_READ efuse_read = NULL;
+
+   efuse_read = (EFUSE_READ)dev_get_driver_data(dev);
+   if (!efuse_read)
+   return -EINVAL;
+
+   return (*efuse_read)(dev, offset, buf, size);
 }
 
 static const struct misc_ops rockchip_efuse_ops = {
@@ -146,7 +207,14 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 }
 
 static const struct udevice_id rockchip_efuse_ids[] = {
-   { .compatible = "rockchip,rk3399-efuse" },
+   {
+   .compatible = "rockchip,rk3288-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
+   .compatible = "rockchip,rk3399-efuse",
+   .data = (ulong)&rockchip_rk3399_efuse_read,
+   },
{}
 };
 
-- 
2.11.0





[PATCH 1/6] rockchip: efuse: Add support for rk3288 efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3288.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 76 ---
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index 2520c6a38e..f01d877e33 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -15,6 +15,15 @@
 #include 
 #include 
 
+#define RK3288_A_SHIFT  6
+#define RK3288_A_MASK   0x3ff
+#define RK3288_NFUSES   32
+#define RK3288_BYTES_PER_FUSE   1
+#define RK3288_PGENBBIT(3)
+#define RK3288_LOAD BIT(2)
+#define RK3288_STROBE   BIT(1)
+#define RK3288_CSB  BIT(0)
+
 #define RK3399_A_SHIFT  16
 #define RK3399_A_MASK   0x3ff
 #define RK3399_NFUSES   32
@@ -27,6 +36,9 @@
 #define RK3399_STROBE   BIT(1)
 #define RK3399_CSB  BIT(0)
 
+typedef int (*EFUSE_READ)(struct udevice *dev, int offset, void *buf,
+ int size);
+
 struct rockchip_efuse_regs {
u32 ctrl;  /* 0x00  efuse control register */
u32 dout;  /* 0x04  efuse data out register */
@@ -53,7 +65,7 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 */
 
struct udevice *dev;
-   u8 fuses[128];
+   u8 fuses[128] = {0};
int ret;
 
/* retrieve the device */
@@ -77,12 +89,55 @@ static int dump_efuses(cmd_tbl_t *cmdtp, int flag,
 }
 
 U_BOOT_CMD(
-   rk3399_dump_efuses, 1, 1, dump_efuses,
+   rockchip_dump_efuses, 1, 1, dump_efuses,
"Dump the content of the efuses",
""
 );
 #endif
 
+static int rockchip_rk3288_efuse_read(struct udevice *dev, int offset,
+ void *buf, int size)
+{
+   struct rockchip_efuse_platdata *plat = dev_get_platdata(dev);
+   struct rockchip_efuse_regs *efuse =
+   (struct rockchip_efuse_regs *)plat->base;
+   u8 *buffer = buf;
+   int max_size = RK3288_NFUSES * RK3288_BYTES_PER_FUSE;
+
+   if (size > (max_size - offset))
+   size = max_size - offset;
+
+   /* Switch to read mode */
+   writel(RK3288_LOAD | RK3288_PGENB, &efuse->ctrl);
+   udelay(1);
+
+   while (size--) {
+   writel(readl(&efuse->ctrl) &
+(~(RK3288_A_MASK << RK3288_A_SHIFT)),
+&efuse->ctrl);
+   /* set addr */
+   writel(readl(&efuse->ctrl) |
+((offset++ & RK3288_A_MASK) << RK3288_A_SHIFT),
+&efuse->ctrl);
+   udelay(1);
+   /* strobe low to high */
+   writel(readl(&efuse->ctrl) |
+RK3288_STROBE, &efuse->ctrl);
+   ndelay(60);
+   /* read data */
+   *buffer++ = readl(&efuse->dout);
+   /* reset strobe to low */
+   writel(readl(&efuse->ctrl) &
+(~RK3288_STROBE), &efuse->ctrl);
+   udelay(1);
+   }
+
+   /* Switch to standby mode */
+   writel(RK3288_PGENB | RK3288_CSB, &efuse->ctrl);
+
+   return 0;
+}
+
 static int rockchip_rk3399_efuse_read(struct udevice *dev, int offset,
  void *buf, int size)
 {
@@ -130,7 +185,13 @@ static int rockchip_rk3399_efuse_read(struct udevice *dev, 
int offset,
 static int rockchip_efuse_read(struct udevice *dev, int offset,
   void *buf, int size)
 {
-   return rockchip_rk3399_efuse_read(dev, offset, buf, size);
+   EFUSE_READ efuse_read = NULL;
+
+   efuse_read = (EFUSE_READ)dev_get_driver_data(dev);
+   if (!efuse_read)
+   return -EINVAL;
+
+   return (*efuse_read)(dev, offset, buf, size);
 }
 
 static const struct misc_ops rockchip_efuse_ops = {
@@ -146,7 +207,14 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 }
 
 static const struct udevice_id rockchip_efuse_ids[] = {
-   { .compatible = "rockchip,rk3399-efuse" },
+   {
+   .compatible = "rockchip,rk3288-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
+   .compatible = "rockchip,rk3399-efuse",
+   .data = (ulong)&rockchip_rk3399_efuse_read,
+   },
{}
 };
 
-- 
2.11.0





[PATCH 2/6] rockchip: efuse: Add support for rk3066a efuse

2020-02-19 Thread Finley Xiao
This adds the necessary data for handling eFuse on the rk3066a.

Signed-off-by: Finley Xiao 
---
 drivers/misc/rockchip-efuse.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/rockchip-efuse.c b/drivers/misc/rockchip-efuse.c
index f01d877e33..3f2c64b105 100644
--- a/drivers/misc/rockchip-efuse.c
+++ b/drivers/misc/rockchip-efuse.c
@@ -208,6 +208,10 @@ static int rockchip_efuse_ofdata_to_platdata(struct 
udevice *dev)
 
 static const struct udevice_id rockchip_efuse_ids[] = {
{
+   .compatible = "rockchip,rk3066a-efuse",
+   .data = (ulong)&rockchip_rk3288_efuse_read,
+   },
+   {
.compatible = "rockchip,rk3288-efuse",
.data = (ulong)&rockchip_rk3288_efuse_read,
},
-- 
2.11.0





Re: [RFC PATCH 1/2] common: fdt: Add a function for reserving memory without kernel linear mapping

2020-02-19 Thread Simon Glass
Hi Michael,

On Wed, 19 Feb 2020 at 11:43, Michael Trimarchi
 wrote:
>
> We need to reserve memory and not put in kernel linear mapping.
> This avoid problem during memory remapping from the simple
> frame buffer in linux kernel
>
> Signed-off-by: Michael Trimarchi 
> ---
>  common/fdt_support.c  | 40 
>  include/fdt_support.h | 11 +++
>  2 files changed, 51 insertions(+)

Reviewed-by: Simon Glass 

nits below

>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 02cf5c6241..a3662f4358 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 
> *address, u64 *size,
> return p - (char *)buf;
>  }
>
> +int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 
> size[])
> +{
> +   int offs, len;
> +   const char *subpath;
> +   const char *path = "/reserved-memory";
> +   fdt32_t address_cells = cpu_to_fdt32(fdt_address_cells(blob, 0));
> +   fdt32_t size_cells = cpu_to_fdt32(fdt_size_cells(blob, 0));
> +   u8 temp[16]; /* Up to 64-bit address + 64-bit size */
> +
> +   offs = fdt_path_offset(blob, path);
> +   if (offs < 0) {
> +   debug("Node %s not found\n", path);
> +   path = "/";
> +   subpath = "reserved-memory";
> +   offs = fdt_path_offset(blob, path);

This is always 0 by definition.

> +   offs = fdt_add_subnode(blob, offs, subpath);
> +   if (offs < 0) {
> +   printf("Could not create %s%s node.\n", path, 
> subpath);
> +   return -1;

This is -EPERM. I think it would be better to return ofs.

> +   }
> +   path = "/reserved-memory";
> +   offs = fdt_path_offset(blob, path);
> +
> +   fdt_setprop(blob, offs, "#address-cells", &address_cells, 
> sizeof(address_cells));
> +   fdt_setprop(blob, offs, "#size-cells", &size_cells, 
> sizeof(size_cells));
> +   fdt_setprop(blob, offs, "ranges", NULL, 0);
> +   }
> +
> +   offs = fdt_add_subnode(blob, offs, area ? : "private");
> +   if (offs < 0) {
> +   printf("Could not create %s%s node.\n", path, subpath);
> +   return -1;

and here

> +   }
> +
> +   fdt_setprop(blob, offs, "no-map", NULL, 0);
> +   len = fdt_pack_reg(blob, temp, start, size, 1);
> +   fdt_setprop(blob, offs, "reg", temp, len);

blank line before return

> +   return 0;
> +}
> +
>  #if CONFIG_NR_DRAM_BANKS > 4
>  #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS
>  #else
> diff --git a/include/fdt_support.h b/include/fdt_support.h
> index ba14acd7f6..7c8a280f53 100644
> --- a/include/fdt_support.h
> +++ b/include/fdt_support.h
> @@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,
>   */
>  int fdt_fixup_memory(void *blob, u64 start, u64 size);
>
> +/**
> + * Setup the memory reserved node in the DT. Creates one if none was 
> existing before.
> + *
> + * @param blob FDT blob to update
> + * @param area Reserved area name
> + * @param startBegin of DRAM mapping in physical memory
> + * @param size Size of the single memory bank
> + * @return 0 if ok, or -1 or -FDT_ERR_... on error

check this

> + */
> +int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 
> size[]);
> +
>  /**
>   * Fill the DT memory node with multiple memory banks.
>   * Creates the node if none was existing before.
> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH 7/8] Revert "power-domain: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit 4f51188e47921b17e6b3ce9606c8e71234c9f2df.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/power/domain/bcm6328-power-domain.c | 2 +-
>  drivers/power/domain/imx8-power-domain-legacy.c | 2 +-
>  drivers/power/domain/imx8-power-domain.c| 2 +-
>  drivers/power/domain/imx8m-power-domain.c   | 2 +-
>  drivers/power/domain/meson-ee-pwrc.c| 2 +-
>  drivers/power/domain/meson-gx-pwrc-vpu.c| 2 +-
>  drivers/power/domain/mtk-power-domain.c | 2 +-
>  drivers/power/domain/power-domain-uclass.c  | 2 +-
>  drivers/power/domain/sandbox-power-domain.c | 2 +-
>  drivers/power/domain/tegra186-power-domain.c| 2 +-
>  drivers/power/domain/ti-sci-power-domain.c  | 2 +-
>  include/power-domain-uclass.h   | 4 ++--
>  12 files changed, 13 insertions(+), 13 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 2/8] Revert "mtd: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:39, Simon Goldschmidt
 wrote:
>
> This reverts commit 8d38a8459b0de45f5ff41f3e11c278a5cf395fd0.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/mtd/mtdcore.c | 4 ++--
>  drivers/mtd/nand/raw/denali.c | 2 +-
>  drivers/mtd/nand/spi/core.c   | 2 +-
>  drivers/mtd/nand/spi/gigadevice.c | 2 +-
>  drivers/mtd/nand/spi/macronix.c   | 2 +-
>  drivers/mtd/nand/spi/micron.c | 2 +-
>  drivers/mtd/nand/spi/winbond.c| 2 +-
>  include/linux/mtd/mtd.h   | 4 ++--
>  8 files changed, 10 insertions(+), 10 deletions(-)

Please do add a commit message.

Reviewed-by: Simon Glass 


Re: [PATCH 8/8] Revert "mailbox: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit cc92c3cc68a9053f53b2814e9233d86553cc998e.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/mailbox/k3-sec-proxy.c   | 2 +-
>  drivers/mailbox/mailbox-uclass.c | 4 ++--
>  drivers/mailbox/sandbox-mbox.c   | 2 +-
>  drivers/mailbox/stm32-ipcc.c | 2 +-
>  drivers/mailbox/tegra-hsp.c  | 2 +-
>  include/mailbox-uclass.h | 4 ++--
>  6 files changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 4/8] Revert "clk: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit fb8c0d595f1ad83bee5dd398b59b0ee16d8d15a9.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/clk/clk-ti-sci.c  | 2 +-
>  drivers/clk/clk-uclass.c  | 4 ++--
>  drivers/clk/clk_sandbox.c | 2 +-
>  drivers/clk/tegra/tegra-car-clk.c | 2 +-
>  include/clk-uclass.h  | 4 ++--
>  5 files changed, 7 insertions(+), 7 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 6/8] Revert "reset: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit 94474b25c3a60a746bf641a975c3db239dae29b9.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/reset/reset-bcm6345.c   | 2 +-
>  drivers/reset/reset-hisilicon.c | 2 +-
>  drivers/reset/reset-hsdk.c  | 2 +-
>  drivers/reset/reset-imx7.c  | 2 +-
>  drivers/reset/reset-mediatek.c  | 2 +-
>  drivers/reset/reset-meson.c | 2 +-
>  drivers/reset/reset-mtmips.c| 2 +-
>  drivers/reset/reset-rockchip.c  | 2 +-
>  drivers/reset/reset-socfpga.c   | 2 +-
>  drivers/reset/reset-sunxi.c | 2 +-
>  drivers/reset/reset-ti-sci.c| 2 +-
>  drivers/reset/reset-uclass.c| 2 +-
>  drivers/reset/reset-uniphier.c  | 2 +-
>  drivers/reset/sandbox-reset.c   | 2 +-
>  drivers/reset/sti-reset.c   | 2 +-
>  drivers/reset/stm32-reset.c | 2 +-
>  drivers/reset/tegra-car-reset.c | 2 +-
>  drivers/reset/tegra186-reset.c  | 2 +-
>  include/reset-uclass.h  | 4 ++--
>  19 files changed, 20 insertions(+), 20 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 5/8] Revert "gpio: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit 093152f275e036e54d48b3d9fc0adbc1ca4cc5b0.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/gpio/gpio-rcar.c   | 2 +-
>  drivers/gpio/gpio-uclass.c | 8 
>  include/asm-generic/gpio.h | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 3/8] Revert "dma: Rename free() to rfree()"

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:40, Simon Goldschmidt
 wrote:
>
> This reverts commit aae95882232a24ee49c89d0356febf3685a87c8a.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
>  drivers/dma/dma-uclass.c   | 4 ++--
>  drivers/dma/sandbox-dma-test.c | 4 ++--
>  drivers/dma/ti/k3-udma.c   | 4 ++--
>  include/dma-uclass.h   | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass 

But a commit message would be nice.


Re: [PATCH 1/8] malloc: implement USE_DL_PREFIX via inline functions

2020-02-19 Thread Simon Glass
On Wed, 19 Feb 2020 at 12:39, Simon Goldschmidt
 wrote:
>
> Commit cfda60f99ae2 ("sandbox: Use a prefix for all allocation functions")
> introduced preprocessor macros for malloc/free etc.
>
> This is bad practice as it essentially makes 'free' a reserved keyword and
> resulted in quite a bit of renaming to avoid that reserved keyword.
>
> A better solution is to define the allocation functions as 'static inline'.
>
> As a side effect, exports.h must not export malloc/free for sandbox.
>
> Signed-off-by: Simon Goldschmidt 
> ---
>
> A side-effect is that exports.h may not declare malloc/free. I'm not really
> sure if this is correct, but for sandbox, it should probably be ok?

Is it possible to fix this? E.g. don't use inline for these two
functions on sandbox?

>
>  include/_exports.h |  2 ++
>  include/exports.h  |  2 ++
>  include/malloc.h   | 44 +---
>  3 files changed, 33 insertions(+), 15 deletions(-)

Reviewed-by: Simon Glass 


Re: [RFC PATCH 2/2] video: meson: Use reserving memory function without kernel linear mapping

2020-02-19 Thread Simon Glass
Hi Michael,

On Wed, 19 Feb 2020 at 11:43, Michael Trimarchi
 wrote:
>
> Memory reserved for the simple framebuffer should not be used
> and part of memory linear mapping
>
> Signed-off-by: Michael Trimarchi 
> ---
>  drivers/video/meson/meson_vpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Is there a binding file for this? Please add it to a patch.

>
> diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c
> index 4eb66398d0..134e011b82 100644
> --- a/drivers/video/meson/meson_vpu.c
> +++ b/drivers/video/meson/meson_vpu.c
> @@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt)
>  * at the end of the RAM and we strip this portion from the kernel
>  * allowed region
>  */
> -   mem_start = gd->bd->bi_dram[0].start;
> -   mem_size = gd->bd->bi_dram[0].size - meson_fb.fb_size;
> -   ret = fdt_fixup_memory_banks(fdt, &mem_start, &mem_size, 1);
> +   mem_start = meson_fb.base;
> +   mem_size = meson_fb.fb_size;
> +   ret = fdt_fixup_reserved_memory(blob, "display_reserved", &mem_start, 
> &mem_size);

Odd that this uses underscore...normally bindings use hyphen.

> if (ret) {
> eprintf("Cannot setup simplefb: Error reserving memory\n");
> return;
> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH] bdinfo: Show information about fdt blob via bdinfo

2020-02-19 Thread Simon Glass
On Tue, 18 Feb 2020 at 22:19, Heiko Schocher  wrote:
>
> PowerPC target supports OF booting, so print the
> fdt address and size in bdinfo.
>
> Signed-off-by: Heiko Schocher 
> ---
> Travis build:
> https://travis-ci.org/hsdenx/u-boot-test/builds/651885430
>
>  cmd/bdinfo.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Simon Glass 


Re: [PATCH 1/2] rockchip: elgin-rv1108: Use syscon API to get grf base

2020-02-19 Thread Simon Glass
On Tue, 18 Feb 2020 at 18:46, Kever Yang  wrote:
>
> Use syscon API to get grf base instead of get from dts.
>
> Signed-off-by: Kever Yang 
> ---
>
>  board/elgin/elgin_rv1108/elgin_rv1108.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH v2 0/4] x86: Improve support for chain-loading U-Boot

2020-02-19 Thread Simon Glass
Hi Andy,

On Wed, 19 Feb 2020 at 02:37, Andy Shevchenko  wrote:
>
> On Wed, Feb 19, 2020 at 4:46 AM Simon Glass  wrote:
> >
> > This little series adds a few checks into the code to allow better
> > operation when booting a build from a previous-state loader such as
> > coreboot.
> >
> > At present we have a 'coreboot' target but this runs very different code
> > from the bare-metal targets, such as coral. There is very little in common
> > between them.
> >
> > It is useful to be able to boot the same U-Boot on a device, with or
> > without a first-stage bootloader. For example, with chromebook_coral, it
> > is helpful for testing to be able to boot the same U-Boot (complete with
> > FSP) on bare metal and from coreboot. It allows checking of things like
> > CPU speed, comparing registers, ACPI tables and the like.
> >
> > The idea is to change ll_boot_init() to false, and rebuild without changing
> > anything else.
> >
> > This series makes the most important changes to allow coral to boot on
> > coreboot.
>
> Is there any patchwork instance or branch which I may use for testing?

Yes I always push to u-boot-dm before sending.

This one is in branch cor3chain-working

It will be collected into patchwork automatically, normally a few
minutes after sending.

Regards,
Simon


Re: [PATCH 2/2] rockchip: evb-rv1108: Use syscon API to get grf base

2020-02-19 Thread Simon Glass
On Tue, 18 Feb 2020 at 18:46, Kever Yang  wrote:
>
> Use syscon API to get grf base instead of get from dts.
>
> Signed-off-by: Kever Yang 
> ---
>
>  board/rockchip/evb_rv1108/evb_rv1108.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 

You might consider putting this code in a BOARD driver.


Re: [PATCH 0/8] malloc: implement USE_DL_PREFIX using inline functions

2020-02-19 Thread Simon Glass
Hi Simon,

On Wed, 19 Feb 2020 at 12:39, Simon Goldschmidt
 wrote:
>
> Commit cfda60f99ae2 ("sandbox: Use a prefix for all allocation functions")
> introduced preprocessor macros for malloc/free etc.
>
> This is bad practice as it essentially makes 'free' a reserved keyword and
> resulted in quite a bit of renaming to avoid that reserved keyword.
>
> A better solution is to define the allocation functions as 'static inline'.
>
> This should go in before the release, as it's a regression not seen before
> the last release.
>
> A side-effect is that exports.h may not declare malloc/free. I'm not really
> sure if this is correct, but for sandbox, it should probably be ok?

Well it is OK for now, until we want to add tests for the API.

Tom may have a better idea on this.

Regards,
Simon


Re: [PATCH 2/2] rockchip: video: Convert to use APIs which support live DT

2020-02-19 Thread Simon Glass
Hi Kever,

On Tue, 18 Feb 2020 at 18:45, Kever Yang  wrote:
>
> Use ofnode_ or dev_ APIs instead of fdt_ and fdtdec_ APIs so that the
> driver can support live DT.
>
> Signed-off-by: Kever Yang 
> ---
>
>  drivers/video/rockchip/rk3288_mipi.c |  1 -
>  drivers/video/rockchip/rk3399_mipi.c |  1 -
>  drivers/video/rockchip/rk_edp.c  |  2 +-
>  drivers/video/rockchip/rk_lvds.c | 10 --
>  drivers/video/rockchip/rk_mipi.c | 11 +--
>  5 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/video/rockchip/rk3288_mipi.c 
> b/drivers/video/rockchip/rk3288_mipi.c
> index 65891ce45c..5b2dc2ad02 100644
> --- a/drivers/video/rockchip/rk3288_mipi.c
> +++ b/drivers/video/rockchip/rk3288_mipi.c
> @@ -8,7 +8,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include "rk_mipi.h"
> diff --git a/drivers/video/rockchip/rk3399_mipi.c 
> b/drivers/video/rockchip/rk3399_mipi.c
> index a5b7ba69a8..03e1349509 100644
> --- a/drivers/video/rockchip/rk3399_mipi.c
> +++ b/drivers/video/rockchip/rk3399_mipi.c
> @@ -8,7 +8,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include "rk_mipi.h"
> diff --git a/drivers/video/rockchip/rk_edp.c b/drivers/video/rockchip/rk_edp.c
> index 4330725a25..e617a974a5 100644
> --- a/drivers/video/rockchip/rk_edp.c
> +++ b/drivers/video/rockchip/rk_edp.c
> @@ -995,7 +995,7 @@ static int rk_edp_ofdata_to_platdata(struct udevice *dev)
>  {
> struct rk_edp_priv *priv = dev_get_priv(dev);
>
> -   priv->regs = (struct rk3288_edp *)devfdt_get_addr(dev);
> +   priv->regs = dev_read_addr_ptr(dev);
> priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
>
> return 0;
> diff --git a/drivers/video/rockchip/rk_lvds.c 
> b/drivers/video/rockchip/rk_lvds.c
> index cae8bada32..92e70f6317 100644
> --- a/drivers/video/rockchip/rk_lvds.c
> +++ b/drivers/video/rockchip/rk_lvds.c
> @@ -171,13 +171,11 @@ int rk_lvds_read_timing(struct udevice *dev, struct 
> display_timing *timing)
>  static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
>  {
> struct rk_lvds_priv *priv = dev_get_priv(dev);
> -   const void *blob = gd->fdt_blob;
> -   int node = dev_of_offset(dev);
> int ret;
> -   priv->regs = (void *)devfdt_get_addr(dev);
> +   priv->regs = dev_read_addr_ptr(dev);
> priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
>
> -   ret = fdtdec_get_int(blob, node, "rockchip,output", -1);
> +   ret = dev_read_s32_default(dev, "rockchip,output", -1);

if (!dev_read_s32(...) {

> if (ret != -1) {
> priv->output = ret;
> debug("LVDS output : %d\n", ret);
> @@ -186,7 +184,7 @@ static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
> priv->output = LVDS_OUTPUT_RGB;
> }
>
> -   ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1);
> +   ret = dev_read_s32_default(dev, "rockchip,data-mapping", -1);
> if (ret != -1) {

Same here

> priv->format = ret;
> debug("LVDS data-mapping : %d\n", ret);
> @@ -195,7 +193,7 @@ static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
> priv->format = LVDS_FORMAT_JEIDA;
> }
>
> -   ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1);
> +   ret = dev_read_s32_default(dev, "rockchip,data-width", -1);

and here

> if (ret != -1) {
> debug("LVDS data-width : %d\n", ret);
> if (ret == 24) {
> diff --git a/drivers/video/rockchip/rk_mipi.c 
> b/drivers/video/rockchip/rk_mipi.c
> index a77bdfd24d..f1c21bb8d7 100644
> --- a/drivers/video/rockchip/rk_mipi.c
> +++ b/drivers/video/rockchip/rk_mipi.c
> @@ -8,7 +8,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include "rk_mipi.h"
> @@ -76,7 +75,7 @@ static void rk_mipi_dsi_write(uintptr_t regs, u32 reg, u32 
> val)
>  int rk_mipi_dsi_enable(struct udevice *dev,
>const struct display_timing *timing)
>  {
> -   int node, timing_node;
> +   ofnode node, timing_node;
> int val;
> struct rk_mipi_priv *priv = dev_get_priv(dev);
> uintptr_t regs = priv->regs;
> @@ -119,10 +118,10 @@ int rk_mipi_dsi_enable(struct udevice *dev,
> rk_mipi_dsi_write(regs, VID_PKT_SIZE, 0x4b0);
>
> /* Set dpi color coding depth 24 bit */
> -   timing_node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(dev),
> -
> "display-timings");
> -   node = fdt_first_subnode(gd->fdt_blob, timing_node);
> -   val = fdtdec_get_int(gd->fdt_blob, node, "bits-per-pixel", -1);
> +   timing_node = ofnode_find_subnode(dev->node, "display-timings");
> +   node = ofnode_first_subnode(timing_node);
> +
> +   val = ofnode_read_u32_default(node, "bits-per-pixel", -1);
> switch (val) {
>

Re: [PATCH 1/2] rockchip: video: Use ofnode_decode_display_timing() to parse timing

2020-02-19 Thread Simon Glass
On Tue, 18 Feb 2020 at 18:45, Kever Yang  wrote:
>
> Use ofnode_decode_display_timing() instead of
> fdtdec_decode_display_timing() to parse display timing, so that we can
> support live DT.
>
> Signed-off-by: Kever Yang 
> ---
>
>  drivers/video/rockchip/rk_lvds.c | 3 +--
>  drivers/video/rockchip/rk_mipi.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass 


[PATCH v2 8/9] usb: Use ofnode as usb_get_dr_mode() parameter

2020-02-19 Thread Kever Yang
ofnode is more common and no need to convert to offset after we migrate
other API to use ofnode.

Signed-off-by: Kever Yang 
Acked-by: Neil Armstrong 
---

Changes in v2:
- add ofnode.h in otg.h to avoid build error

 drivers/usb/cdns3/core.c   | 4 ++--
 drivers/usb/common/common.c| 7 +++
 drivers/usb/dwc3/dwc3-generic.c| 6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +-
 drivers/usb/gadget/dwc2_udc_otg.c  | 5 ++---
 drivers/usb/host/dwc3-sti-glue.c   | 2 +-
 drivers/usb/host/ehci-mx6.c| 2 +-
 drivers/usb/host/xhci-dwc3.c   | 3 +--
 drivers/usb/musb-new/ti-musb.c | 2 +-
 include/linux/usb/otg.h| 6 --
 10 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 75c3d4f200..ce846488a8 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -108,7 +108,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
enum usb_dr_mode dr_mode;
int ret = 0;
 
-   dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+   dr_mode = usb_get_dr_mode(dev->node);
cdns->role = USB_ROLE_NONE;
 
/*
@@ -398,7 +398,7 @@ int cdns3_bind(struct udevice *parent)
}
 
name = ofnode_get_name(node);
-   dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+   dr_mode = usb_get_dr_mode(node);
 
switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index a55def5aba..4300f711a9 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -7,7 +7,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = {
[USB_DR_MODE_OTG]   = "otg",
 };
 
-enum usb_dr_mode usb_get_dr_mode(int node)
+enum usb_dr_mode usb_get_dr_mode(ofnode node)
 {
-   const void *fdt = gd->fdt_blob;
const char *dr_mode;
int i;
 
-   dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
+   dr_mode = ofnode_read_string(node, "dr_mode");
if (!dr_mode) {
pr_err("usb dr_mode not found\n");
return USB_DR_MODE_UNKNOWN;
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index ced0f53bfd..7178f12b47 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -98,7 +98,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice 
*dev)
plat->maximum_speed = USB_SPEED_SUPER;
}
 
-   plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+   plat->dr_mode = usb_get_dr_mode(node);
if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
@@ -295,7 +295,7 @@ static int dwc3_glue_bind(struct udevice *parent)
 
debug("%s: subnode name: %s\n", __func__, name);
 
-   dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+   dr_mode = usb_get_dr_mode(node);
 
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
@@ -398,7 +398,7 @@ static int dwc3_glue_probe(struct udevice *dev)
while (child) {
enum usb_dr_mode dr_mode;
 
-   dr_mode = usb_get_dr_mode(dev_of_offset(child));
+   dr_mode = usb_get_dr_mode(child->node);
device_find_next_child(&child);
if (ops && ops->select_dr_mode)
ops->select_dr_mode(dev, index, dr_mode);
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c 
b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 832bcd70ff..d4453f8784 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
}
 #endif
 
-   priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev));
+   priv->otg_mode = usb_get_dr_mode(dev->node);
 
ret = dwc3_meson_g12a_usb_init(priv);
if (ret)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c 
b/drivers/usb/gadget/dwc2_udc_otg.c
index 496abf38e7..b9c814cf73 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -1039,13 +1039,12 @@ void dwc2_phy_shutdown(struct udevice *dev, struct phy 
*usb_phys, int num_phys)
 static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 {
struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
-   int node = dev_of_offset(dev);
ulong drvdata;
void (*set_params)(struct dwc2_plat_otg_data *data);
int ret;
 
-   if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
-   usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
+   if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
+   usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
dev_dbg(dev, "Invalid mode\n");
return -ENODEV;
}
diff --git a/drivers

[PATCH v2 6/9] usb: host: dwc3-sti-glue: Migrate to use ofnode API

2020-02-19 Thread Kever Yang
Use ofnode_ instead of fdt_ or fdtdec_ APIs so that the driver can support
live DT.

Signed-off-by: Kever Yang 
---

Changes in v2:
- fix build error for ofnode not define

 drivers/usb/host/dwc3-sti-glue.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index ad7cf6e6b5..ae9573ab8a 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -10,8 +10,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice 
*dev)
int ret;
u32 reg[4];
 
-   ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
-  "reg", reg, ARRAY_SIZE(reg));
+   ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
if (ret) {
pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", 
ret);
return ret;
@@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct 
udevice *dev)
 static int sti_dwc3_glue_bind(struct udevice *dev)
 {
struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
-   int dwc3_node;
+   ofnode node, dwc3_node;
 
-   /* check if one subnode is present */
-   dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
-   if (dwc3_node <= 0) {
-   pr_err("Can't find subnode for %s\n", dev->name);
-   return -ENODEV;
+   /* Find snps,dwc3 node from subnode */
+   ofnode_for_each_subnode(node, dev->node) {
+   if (ofnode_device_is_compatible(node, "snps,dwc3"))
+   dwc3_node = node;
}
 
-   /* check if the subnode compatible string is the dwc3 one*/
-   if (fdt_node_check_compatible(gd->fdt_blob, dwc3_node,
- "snps,dwc3") != 0) {
+   if (!ofnode_valid(node)) {
pr_err("Can't find dwc3 subnode for %s\n", dev->name);
return -ENODEV;
}
 
/* retrieve the DWC3 dual role mode */
-   plat->mode = usb_get_dr_mode(dwc3_node);
+   plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node));
if (plat->mode == USB_DR_MODE_UNKNOWN)
/* by default set dual role mode to HOST */
plat->mode = USB_DR_MODE_HOST;
-- 
2.17.1



[PATCH v2 9/9] usb: Use ofnode as usb_get_maximum_speed() parameter

2020-02-19 Thread Kever Yang
ofnode is more common and no need to convert to offset after we migrate
other API to use ofnode.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/cdns3/gadget.c  | 2 +-
 drivers/usb/common/common.c | 5 ++---
 drivers/usb/dwc3/dwc3-generic.c | 2 +-
 include/linux/usb/otg.h | 4 ++--
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 22e90a5717..8ebe64e8b3 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2579,7 +2579,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
if (!priv_dev->onchip_buffers)
priv_dev->onchip_buffers = 256;
 
-   max_speed = usb_get_maximum_speed(dev_of_offset(cdns->dev));
+   max_speed = usb_get_maximum_speed(dev_ofnode(cdns->dev));
 
/* Check the maximum_speed parameter */
switch (max_speed) {
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 4300f711a9..0db281b970 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -47,13 +47,12 @@ static const char *const speed_names[] = {
[USB_SPEED_SUPER] = "super-speed",
 };
 
-enum usb_device_speed usb_get_maximum_speed(int node)
+enum usb_device_speed usb_get_maximum_speed(ofnode node)
 {
-   const void *fdt = gd->fdt_blob;
const char *max_speed;
int i;
 
-   max_speed = fdt_getprop(fdt, node, "maximum-speed", NULL);
+   max_speed = ofnode_read_string(node, "maximum-speed");
if (!max_speed) {
pr_err("usb maximum-speed not found\n");
return USB_SPEED_UNKNOWN;
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 7178f12b47..febcfc0f54 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -92,7 +92,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice 
*dev)
 
plat->base = dev_read_addr(dev);
 
-   plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
+   plat->maximum_speed = usb_get_maximum_speed(node);
if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
pr_info("No USB maximum speed specified. Using super speed\n");
plat->maximum_speed = USB_SPEED_SUPER;
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 4f1f8ceb54..c19b916be9 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -29,11 +29,11 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node);
 
 /**
  * usb_get_maximum_speed() - Get maximum speed for given device
- * @node: Node offset to the given device
+ * @node: ofnode of the given device
  *
  * The function gets phy interface string from property 'maximum-speed',
  * and returns the correspondig enum usb_device_speed
  */
-enum usb_device_speed usb_get_maximum_speed(int node);
+enum usb_device_speed usb_get_maximum_speed(ofnode node);
 
 #endif /* __LINUX_USB_OTG_H */
-- 
2.17.1



[PATCH v2 5/9] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()

2020-02-19 Thread Kever Yang
Use more common API so that we can support live DT.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/dwc3/dwc3-generic.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 820cc7075c..ced0f53bfd 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
 {
struct dwc3_generic_plat *plat = dev_get_platdata(dev);
-   int node = dev_of_offset(dev);
+   ofnode node = dev->node;
 
-   plat->base = devfdt_get_addr(dev);
+   plat->base = dev_read_addr(dev);
 
-   plat->maximum_speed = usb_get_maximum_speed(node);
+   plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
pr_info("No USB maximum speed specified. Using super speed\n");
plat->maximum_speed = USB_SPEED_SUPER;
}
 
-   plat->dr_mode = usb_get_dr_mode(node);
+   plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
-- 
2.17.1



[PATCH v2 4/9] usb: dwc3-generic: Migrate to use ofnode API for bind function

2020-02-19 Thread Kever Yang
Use ofnode_ instead of fdt_ APIs so that the driver can support live DT.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/dwc3/dwc3-generic.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 3e116b2c5c..820cc7075c 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -284,20 +284,18 @@ struct dwc3_glue_ops ti_ops = {
 
 static int dwc3_glue_bind(struct udevice *parent)
 {
-   const void *fdt = gd->fdt_blob;
-   int node;
+   ofnode node;
int ret;
 
-   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-node = fdt_next_subnode(fdt, node)) {
-   const char *name = fdt_get_name(fdt, node, NULL);
+   ofnode_for_each_subnode(node, parent->node) {
+   const char *name = ofnode_get_name(node);
enum usb_dr_mode dr_mode;
struct udevice *dev;
const char *driver = NULL;
 
debug("%s: subnode name: %s\n", __func__, name);
 
-   dr_mode = usb_get_dr_mode(node);
+   dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
 
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
@@ -322,7 +320,7 @@ static int dwc3_glue_bind(struct udevice *parent)
continue;
 
ret = device_bind_driver_to_node(parent, driver, name,
-offset_to_ofnode(node), &dev);
+node, &dev);
if (ret) {
debug("%s: not able to bind usb device mode\n",
  __func__);
-- 
2.17.1



[PATCH v2 2/9] usb: ehci-msm: Use dev interface to get device address

2020-02-19 Thread Kever Yang
Use dev_read_addr_ptr() instead of devfdt_get_addr() so that we can support
live DT.

Signed-off-by: Kever Yang 
Reviewed-by: Ramon Fried 
---

Changes in v2: None

 drivers/usb/host/ehci-msm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 5c257ccf4d..dd92808ff7 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -10,8 +10,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -108,7 +106,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
struct msm_ehci_priv *priv = dev_get_priv(dev);
 
priv->ulpi_vp.port_num = 0;
-   priv->ehci = (void *)devfdt_get_addr(dev);
+   priv->ehci = dev_read_addr_ptr(dev);
 
if (priv->ehci == (void *)FDT_ADDR_T_NONE)
return -EINVAL;
-- 
2.17.1



[PATCH v2 3/9] usb: cdns3: Migrate to use ofnode API for bind function

2020-02-19 Thread Kever Yang
Use ofnode_ instead of fdt_ APIs so that the driver can support live DT.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/cdns3/core.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index f947e6983c..75c3d4f200 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -384,23 +384,21 @@ static const struct udevice_id cdns3_ids[] = {
 
 int cdns3_bind(struct udevice *parent)
 {
-   int from = dev_of_offset(parent);
-   const void *fdt = gd->fdt_blob;
enum usb_dr_mode dr_mode;
struct udevice *dev;
const char *driver;
const char *name;
-   int node;
+   ofnode node;
int ret;
 
-   node = fdt_node_offset_by_compatible(fdt, from, "cdns,usb3");
-   if (node < 0) {
+   node = ofnode_by_compatible(parent->node, "cdns,usb3");
+   if (!ofnode_valid(node)) {
ret = -ENODEV;
goto fail;
}
 
-   name = fdt_get_name(fdt, node, NULL);
-   dr_mode = usb_get_dr_mode(node);
+   name = ofnode_get_name(node);
+   dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
 
switch (dr_mode) {
 #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \
@@ -422,8 +420,7 @@ int cdns3_bind(struct udevice *parent)
goto fail;
};
 
-   ret = device_bind_driver_to_node(parent, driver, name,
-offset_to_ofnode(node), &dev);
+   ret = device_bind_driver_to_node(parent, driver, name, node, &dev);
if (ret) {
printf("%s: not able to bind usb device mode\n",
   __func__);
-- 
2.17.1



[PATCH v2 7/9] usb: musb-new: Migrate to use ofnode API

2020-02-19 Thread Kever Yang
Use ofnode_ instead of fdt_ APIs so that the driver can support live DT.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/musb-new/ti-musb.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 00759f3e83..69252a7222 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -285,28 +285,26 @@ U_BOOT_DRIVER(ti_musb_peripheral) = {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 static int ti_musb_wrapper_bind(struct udevice *parent)
 {
-   const void *fdt = gd->fdt_blob;
-   int node;
+   ofnode node;
int ret;
 
-   for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-node = fdt_next_subnode(fdt, node)) {
+   ofnode_for_each_subnode(node, parent->node) {
struct udevice *dev;
-   const char *name = fdt_get_name(fdt, node, NULL);
+   const char *name = ofnode_get_name(node);
enum usb_dr_mode dr_mode;
struct driver *drv;
 
if (strncmp(name, "usb@", 4))
continue;
 
-   dr_mode = usb_get_dr_mode(node);
+   dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
/* Bind MUSB device */
ret = device_bind_driver_to_node(parent,
 "ti-musb-peripheral",
 name,
-offset_to_ofnode(node),
+node,
 &dev);
if (ret)
pr_err("musb - not able to bind usb peripheral 
node\n");
@@ -316,7 +314,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
ret = device_bind_driver_to_node(parent,
 "ti-musb-host",
 name,
-offset_to_ofnode(node),
+node,
 &dev);
if (ret)
pr_err("musb - not able to bind usb host 
node\n");
-- 
2.17.1



[PATCH v2 1/9] usb: dwc3-of-simple: Drop redundant inclding header file

2020-02-19 Thread Kever Yang
The fdtdec.h is no use in this file, remove the include code.

Signed-off-by: Kever Yang 
---

Changes in v2: None

 drivers/usb/host/dwc3-of-simple.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/dwc3-of-simple.c 
b/drivers/usb/host/dwc3-of-simple.c
index 45df614b09..e4abc6f3b9 100644
--- a/drivers/usb/host/dwc3-of-simple.c
+++ b/drivers/usb/host/dwc3-of-simple.c
@@ -12,7 +12,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.17.1



[PATCH v2 0/9] usb: Covert to support Live DT

2020-02-19 Thread Kever Yang


This patch set convert to use APIs leading with dev_ or ofnode_ which
supports live DT instead of fdt_ or fdtdec or devfdt_.
Two functions update there parameter from offset to ofnode:
- usb_get_maximum_speed()
- usb_get_dr_mode()

For V2 update:
Drop below patch after include ofnode.h in otg.h:
[PATCH 09/10] usb: Use ofnode as usb_get_dr_mode() parameter


Changes in v2:
- fix build error for ofnode not define
- add ofnode.h in otg.h to avoid build error

Kever Yang (9):
  usb: dwc3-of-simple: Drop redundant inclding header file
  usb: ehci-msm: Use dev interface to get device address
  usb: cdns3: Migrate to use ofnode API for bind function
  usb: dwc3-generic: Migrate to use ofnode API for bind function
  usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
  usb: host: dwc3-sti-glue: Migrate to use ofnode API
  usb: musb-new: Migrate to use ofnode API
  usb: Use ofnode as usb_get_dr_mode() parameter
  usb: Use ofnode as usb_get_maximum_speed() parameter

 drivers/usb/cdns3/core.c   | 15 ++-
 drivers/usb/cdns3/gadget.c |  2 +-
 drivers/usb/common/common.c| 12 +---
 drivers/usb/dwc3/dwc3-generic.c| 16 +++-
 drivers/usb/dwc3/dwc3-meson-g12a.c |  2 +-
 drivers/usb/gadget/dwc2_udc_otg.c  |  5 ++---
 drivers/usb/host/dwc3-of-simple.c  |  1 -
 drivers/usb/host/dwc3-sti-glue.c   | 20 +++-
 drivers/usb/host/ehci-msm.c|  4 +---
 drivers/usb/host/ehci-mx6.c|  2 +-
 drivers/usb/host/xhci-dwc3.c   |  3 +--
 drivers/usb/musb-new/ti-musb.c | 12 +---
 include/linux/usb/otg.h| 10 ++
 13 files changed, 43 insertions(+), 61 deletions(-)

-- 
2.17.1



RE: [PATCH v2 11/21] arm: socfpga: Secure register access for clock manager (SoC 64bits)

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> > From: Chee Hong Ang 
> >
> > Allow clock manager driver to access the System Manager's Boot Scratch
> > Register 0 in non-secure mode (EL2) on SoC 64bits platform.
> >
> > Signed-off-by: Chee Hong Ang 
> > ---
> >  arch/arm/mach-socfpga/clock_manager_agilex.c | 5 +++--
> >  arch/arm/mach-socfpga/clock_manager_s10.c| 5 +++--
> >  2 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/mach-socfpga/clock_manager_agilex.c
> > b/arch/arm/mach-socfpga/clock_manager_agilex.c
> > index 4ee2b7b..e5a0998 100644
> > --- a/arch/arm/mach-socfpga/clock_manager_agilex.c
> > +++ b/arch/arm/mach-socfpga/clock_manager_agilex.c
> > @@ -12,6 +12,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -65,8 +66,8 @@ unsigned int cm_get_l4_sys_free_clk_hz(void)
> >
> >  u32 cm_get_qspi_controller_clk_hz(void)
> >  {
> > -   return readl(socfpga_get_sysmgr_addr() +
> > -SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
> > +   return socfpga_secure_reg_read32(socfpga_get_sysmgr_addr() +
> > +
> SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
> >  }
> >
> >  void cm_print_clock_quick_summary(void)
> > diff --git a/arch/arm/mach-socfpga/clock_manager_s10.c
> > b/arch/arm/mach-socfpga/clock_manager_s10.c
> > index 05e4212..02578cc 100644
> > --- a/arch/arm/mach-socfpga/clock_manager_s10.c
> > +++ b/arch/arm/mach-socfpga/clock_manager_s10.c
> > @@ -9,6 +9,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  DECLARE_GLOBAL_DATA_PTR;
> >
> > @@ -385,8 +386,8 @@ unsigned int cm_get_l4_sp_clk_hz(void)
> >
> >  unsigned int cm_get_qspi_controller_clk_hz(void)
> >  {
> > -   return readl(socfpga_get_sysmgr_addr() +
> > -SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
> > +   return socfpga_secure_reg_read32(socfpga_get_sysmgr_addr() +
> > +
> SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
> >  }
> >
> >  unsigned int cm_get_spi_controller_clk_hz(void)
> 
> Shouldn't the IO accessors already provide the necessary abstraction ?
This function accesses the system manager registers, therefore it is required
to call the secure register read function to make sure it still can access
the system manager register if it's running EL2 (non-secure).


RE: [PATCH v2 05/21] arm: socfpga: Override 'lowlevel_init' to support ATF

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> [...]
> > diff --git a/arch/arm/mach-socfpga/lowlevel_init.S
> > b/arch/arm/mach-socfpga/lowlevel_init.S
> > new file mode 100644
> > index 000..68053a0
> > --- /dev/null
> > +++ b/arch/arm/mach-socfpga/lowlevel_init.S
> 
> This should be some lowlevel_init_64.S to make it clear it's only for
> arm64 platforms.
OK. It makes sense. Thanks.
> 
> > @@ -0,0 +1,85 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (C) 2019, Intel Corporation  */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +ENTRY(lowlevel_init)
> > +   mov x29, lr /* Save LR */
> > +
> > +#if defined(CONFIG_GICV2) || defined(CONFIG_GICV3) #ifdef
> > +CONFIG_SPL_ATF
> > +   branch_if_slave x0, 2f
> > +#else
> > +   branch_if_slave x0, 1f
> > +#endif
> > +
> > +   ldr x0, =GICD_BASE
> > +   bl  gic_init_secure
> > +#ifdef CONFIG_SPL_BUILD
> > +   b   2f
> > +#else
> > +   b   3f
> > +#endif
> 
> Can't this be done in C code ? Can we reduce the ifdeffery ?
This lowlevel_init function is shared by SPL and U-Boot and they
run in slightly different flow.
I don't think this can be done in C code but let me see what I can
do to further optimize the flow to reduce the ifdeffery.


Re: [PATCH 05/10] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()

2020-02-19 Thread Simon Glass
Hi Kever,

On Tue, 18 Feb 2020 at 18:55, Kever Yang  wrote:
>
> Use more common API so that we can support live DT.
>
> Signed-off-by: Kever Yang 
> ---
>
>  drivers/usb/dwc3/dwc3-generic.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 820cc7075c..ced0f53bfd 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
>  static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
>  {
> struct dwc3_generic_plat *plat = dev_get_platdata(dev);
> -   int node = dev_of_offset(dev);
> +   ofnode node = dev->node;
>
> -   plat->base = devfdt_get_addr(dev);
> +   plat->base = dev_read_addr(dev);
>
> -   plat->maximum_speed = usb_get_maximum_speed(node);
> +   plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
> if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
> pr_info("No USB maximum speed specified. Using super 
> speed\n");
> plat->maximum_speed = USB_SPEED_SUPER;
> }
>
> -   plat->dr_mode = usb_get_dr_mode(node);
> +   plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));

This won't work with livetree. Can you convert usb_get_dr_mode() to
use livetree? Then you can pass the dev or the node.

> if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
> pr_err("Invalid usb mode setup\n");
> return -ENODEV;
> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH v3] cmd: Add command to dump drivers and compatible strings

2020-02-19 Thread Simon Glass
Hi Bin,

On Wed, 19 Feb 2020 at 08:45, Bin Meng  wrote:
>
> Hi Simon,
>
> On Fri, Feb 7, 2020 at 1:46 AM Simon Glass  wrote:
> >
> > On Thu, 6 Feb 2020 at 10:03, Sean Anderson  wrote:
> > >
> > > This adds a subcommand to dm to dump out what drivers are installed, and 
> > > their
> > > compatible strings. I have found this useful in ensuring that I have the 
> > > correct
> > > drivers compiled, and that I have put in the correct compatible strings.
> > >
> > > Signed-off-by: Sean Anderson 
> > > Reviewed-by: Bin Meng 
> > > Tested-by: Bin Meng 
> > >
> > > ---
> > >
> > > Changes in v3:
> > > - Add python test
> > >
> > > Changes in v2:
> > > - Check if entry->of_match is NULL before accessing it
> > > - Remove trailing newline in help message
> > >
> > >  cmd/dm.c | 12 +++-
> > >  drivers/core/dump.c  | 20 
> > >  include/dm/util.h|  3 +++
> > >  test/py/tests/test_dm.py | 17 +
>
> Is this what you're looking for? I thought we need something in
> test/dm C test cases instead?

I would prefer C but this test only runs two commands so is not too bad.

Regards,
Simon


RE: [PATCH v2 06/21] configs: socfpga: Enable FIT image loading with ATF support

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> > From: Chee Hong Ang 
> >
> > SPL now loads ATF (BL31), U-Boot proper and DTB from FIT image. The
> > new boot flow with ATF support is as follow:
> >
> > SPL -> ATF (BL31) -> U-Boot proper -> OS (Linux)
> >
> > Signed-off-by: Chee Hong Ang 
> > ---
> >  configs/socfpga_agilex_defconfig| 8 +++-
> >  configs/socfpga_stratix10_defconfig | 8 +++-
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/configs/socfpga_agilex_defconfig
> > b/configs/socfpga_agilex_defconfig
> > index 693a774..0065ff0 100644
> > --- a/configs/socfpga_agilex_defconfig
> > +++ b/configs/socfpga_agilex_defconfig
> > @@ -1,6 +1,6 @@
> >  CONFIG_ARM=y
> >  CONFIG_ARCH_SOCFPGA=y
> > -CONFIG_SYS_TEXT_BASE=0x1000
> > +CONFIG_SYS_TEXT_BASE=0x20
> 
> Why did the text base change ?
This defconfig support ATF.
ATF will occupy from this address range (0x1000)
U-Boot now starts at 0x20.
> 
> >  CONFIG_SYS_MALLOC_F_LEN=0x2000
> >  CONFIG_ENV_SIZE=0x1000
> >  CONFIG_ENV_OFFSET=0x200
> > @@ -10,10 +10,16 @@ CONFIG_TARGET_SOCFPGA_AGILEX_SOCDK=y
> >  CONFIG_IDENT_STRING="socfpga_agilex"
> >  CONFIG_SPL_FS_FAT=y
> >  CONFIG_SPL_TEXT_BASE=0xFFE0
> > +CONFIG_FIT=y
> > +CONFIG_SPL_LOAD_FIT=y
> > +CONFIG_SPL_FIT_SOURCE="board/altera/soc64/its/fit_spl_atf.its"
> >  CONFIG_BOOTDELAY=5
> > +CONFIG_SPL_LEGACY_IMAGE_SUPPORT=y
> 
> Is legacy image support really needed ?
Let me check. Will get rid of this if it's not needed. Thanks.


RE: [PATCH v2 01/21] configs: agilex: Remove CONFIG_OF_EMBED

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> > From: Chee Hong Ang 
> >
> > CONFIG_OF_EMBED was primarily enabled to support the agilex spl hex
> > file requirements.  Since this option now produces a warning during
> > build, and the spl hex can be created using alternate methods,
> > CONFIG_OF_EMBED is no longer needed.
> >
> > Signed-off-by: Chee Hong Ang 
> 
> If I apply just this patch, is the platform still bootable ?
Yes. I tested on the platform.
There is a similar patch from Dalon for Stratix10 and it still yet to be applied
to mainline:
https://lists.denx.de/pipermail/u-boot/2019-September/384906.html

I hope the patch from Dalon get applied to mainline before these patchsets.

In fact, this "CONFIG_OF_EMBED" produce warning during build.
Better get rid of this.


RE: [PATCH v2 10/21] arm: socfpga: Add secure register access helper functions for SoC 64bits

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> > From: Chee Hong Ang 
> >
> > These secure register access functions allow U-Boot proper running at
> > EL2 (non-secure) to access System Manager's secure registers by
> > calling the ATF's PSCI runtime services (EL3/secure). If these helper
> > functions are called from secure mode (EL3), the helper function will
> > direct access the secure registers without calling the ATF's PSCI
> > runtime services.
> >
> > Signed-off-by: Chee Hong Ang 
> > ---
> >  arch/arm/mach-socfpga/Makefile |  6 +++
> >  .../mach-socfpga/include/mach/secure_reg_helper.h  | 20 
> >  arch/arm/mach-socfpga/secure_reg_helper.c  | 57
> ++
> >  3 files changed, 83 insertions(+)
> >  create mode 100644
> > arch/arm/mach-socfpga/include/mach/secure_reg_helper.h
> >  create mode 100644 arch/arm/mach-socfpga/secure_reg_helper.c
> >
> > diff --git a/arch/arm/mach-socfpga/Makefile
> > b/arch/arm/mach-socfpga/Makefile index 3310e92..e59587b 100644
> > --- a/arch/arm/mach-socfpga/Makefile
> > +++ b/arch/arm/mach-socfpga/Makefile
> > @@ -53,6 +53,12 @@ obj-y+= wrap_pinmux_config_s10.o
> >  obj-y  += wrap_pll_config_s10.o
> >  endif
> >
> > +ifndef CONFIG_SPL_BUILD
> > +ifdef CONFIG_SPL_ATF
> > +obj-y  += secure_reg_helper.o
> 
> obj-$(FOO) += bar.o , you don't need the inner ifdef
OK. It's cleaner. Thanks.
> 
> > +endif
> > +endif
> 
> [...]
> 
> > +++ b/arch/arm/mach-socfpga/include/mach/secure_reg_helper.h
> > @@ -0,0 +1,20 @@
> > +/* SPDX-License-Identifier: GPL-2.0
> > + *
> > + * Copyright (C) 2019 Intel Corporation 
> > + *
> > + */
> > +
> > +#ifndef_SECURE_REG_HELPER_H_
> > +#define_SECURE_REG_HELPER_H_
> > +
> > +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF)
> > +u32 socfpga_secure_reg_read32(phys_addr_t reg_addr); void
> > +socfpga_secure_reg_write32(u32 val, phys_addr_t reg_addr); void
> > +socfpga_secure_reg_update32(phys_addr_t reg_addr, u32 mask, u32 val);
> > +#else
> > +#define socfpga_secure_reg_read32  readl
> > +#define socfpga_secure_reg_write32 writel
> > +#define socfpga_secure_reg_update32clrsetbits_le32
> > +#endif
> 
> I think I don't understand how this is supposed to work. Would every place in 
> U-
> Boot have to be patched to call these functions now ?

Not every register access need this. Only those accessing registers in secure 
zone such
as 'System Manager' registers need to call this. It's basically determine 
whether the driver
should issue SMC/PSCI call if it's running in EL2 (non-secure) or access the 
registers directly
by simply using readl/writel and etc if it's running in EL3 (secure).
Accessing those registers in secure zone in non-secure mode (EL2) will cause 
SError exception.
So we can determine this behaviour in compile time:
SPL always running in EL3. So it just simply fallback to use 
readl/writel/clrsetbits_le32.

For U-Boot proper (SSBL), there are 2 scenarios:
1) If CONFIG_SPL_ATF is defined, it means ATF is supported. It implies that 
U-Boot proper will be
running in EL2 (non-secure), then it will use SMC/PSCI calls to access the 
secure registers.

2) CONFIG_SPL_ATF is not defined, no ATF support. U-Boot proper will be running 
in EL3 which
will fall back to simply using the direct access functions (readl/writel and 
etc).
> 
> [...]


Please pull mmc mmc-2-19-2020

2020-02-19 Thread Peng Fan
Hi Tom

Please pull mmc-2-29-2020.


sdhci: code clean-up and fix cache coherency problem
enable cache snooping on mpc830x
Fix build error when MMC_WRITE disabled


CI: https://travis-ci.org/MrVan/u-boot/builds/652476827

Thanks,
Peng

The following changes since commit f2a73d6867ef973fbb8471cc87058205999b5e5c:

  Merge tag 'u-boot-stm32-20200214' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-stm (2020-02-14 07:31:47 -0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-mmc.git tags/mmc-2-19-2020

for you to fetch changes up to 5cc25dcd5d79ef85fdad807a3e5a7af10333cfc3:

  mmc: sdhci: fix missing cache invalidation after reading by DMA (2020-02-19 
21:27:31 +0800)


Bharat Kumar Reddy Gooty (1):
  drivers: mmc: rpmb: Use R1 response

Jaehoon Chung (1):
  mmc: fix the build error when MMC_WRITE is disabled

Masahiro Yamada (14):
  mmc: sdhci-cadence: send tune request twice to work around errata
  mmc: check the return value of mmc_select_mode_and_width()
  mmc: remove unneeded forward declarations
  dma-mapping: fix the prototype of dma_map_single()
  dma-mapping: fix the prototype of dma_unmap_single()
  dma-mapping: move dma_map_(un)single() to 
  dma-mapping: add  for all architectures
  mmc: sdhci: put the aligned buffer pointer to struct sdhci_host
  mmc: sdhci: reduce code duplication for aligned buffer
  mmc: sdhci: use lower_32_bit2() and upper_32_bits() for setting adma_addr
  mmc: sdhci: remove unneeded casts
  mmc: add mmc_get_dma_dir() helper
  mmc: sdhci: use dma_map_single() instead of flush_cache() before DMA
  mmc: sdhci: fix missing cache invalidation after reading by DMA

Rasmus Villemoes (1):
  mmc: fsl_esdhc: actually enable cache snooping on mpc830x

 arch/arc/include/asm/dma-mapping.h|  1 +
 arch/arm/include/asm/dma-mapping.h| 29 +
 arch/m68k/include/asm/dma-mapping.h   |  1 +
 arch/microblaze/include/asm/dma-mapping.h |  1 +
 arch/mips/include/asm/dma-mapping.h   |  1 +
 arch/nds32/include/asm/dma-mapping.h  | 27 +--
 arch/nios2/include/asm/dma-mapping.h  | 25 +
 arch/powerpc/include/asm/dma-mapping.h|  1 +
 arch/riscv/include/asm/dma-mapping.h  | 29 +
 arch/sandbox/include/asm/dma-mapping.h|  1 +
 arch/sh/include/asm/dma-mapping.h |  1 +
 arch/x86/include/asm/dma-mapping.h| 29 +
 arch/xtensa/include/asm/dma-mapping.h |  1 +
 drivers/dma/ti/k3-udma.c  |  2 +-
 drivers/mmc/fsl_esdhc.c   | 15 +--
 drivers/mmc/mmc.c |  8 +++-
 drivers/mmc/rpmb.c|  5 +
 drivers/mmc/sdhci-cadence.c   | 21 +
 drivers/mmc/sdhci.c   | 96 
++--
 drivers/mmc/tmio-common.c |  5 ++---
 drivers/mtd/nand/raw/denali.c |  5 ++---
 drivers/net/altera_tse.c  |  2 +-
 drivers/net/ftmac110.c|  2 +-
 drivers/net/macb.c|  4 ++--
 drivers/soc/ti/k3-navss-ringacc.c |  2 +-
 drivers/ufs/ufs.c |  2 +-
 drivers/usb/cdns3/gadget.c|  2 +-
 drivers/usb/dwc3/core.c   |  8 
 drivers/usb/dwc3/gadget.c |  2 +-
 drivers/usb/gadget/udc/udc-core.c |  4 ++--
 include/linux/dma-mapping.h   | 63 
+++
 include/mmc.h |  6 ++
 include/sdhci.h   |  3 +++
 33 files changed, 188 insertions(+), 216 deletions(-)
 create mode 100644 arch/arc/include/asm/dma-mapping.h
 create mode 100644 arch/m68k/include/asm/dma-mapping.h
 create mode 100644 arch/microblaze/include/asm/dma-mapping.h
 create mode 100644 arch/mips/include/asm/dma-mapping.h
 create mode 100644 arch/powerpc/include/asm/dma-mapping.h
 create mode 100644 arch/sandbox/include/asm/dma-mapping.h
 create mode 100644 arch/sh/include/asm/dma-mapping.h
 create mode 100644 arch/xtensa/include/asm/dma-mapping.h
 create mode 100644 include/linux/dma-mapping.h


Re: [PATCH 05/10] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()

2020-02-19 Thread Kever Yang

Hi Marek,

On 2020/2/20 上午1:07, Marek Vasut wrote:

On 2/19/20 2:54 AM, Kever Yang wrote:

Use more common API so that we can support live DT.

Signed-off-by: Kever Yang 
---

  drivers/usb/dwc3/dwc3-generic.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 820cc7075c..ced0f53bfd 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,
  static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
  {
struct dwc3_generic_plat *plat = dev_get_platdata(dev);
-   int node = dev_of_offset(dev);
+   ofnode node = dev->node;

Can't you just do ofnode_of_offset() here, once , instead of having it
all over the function ?



The "all over the function" is only twice, and this convert will removed 
at follow up patch which


update the function parameter from offset to ofnode.

So I think this change is acceptable for this patch.


Thanks,

- Kever





RE: [PATCH v2 09/21] arm: socfpga: Define SMC function identifiers for PSCI SiP services

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> [...]
> > +++ b/include/linux/intel-smc.h
> > @@ -0,0 +1,374 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/*
> > + * Copyright (C) 2017-2018, Intel Corporation
> 
> 2020 ?
This file is new in U-Boot but it already exists in Linux kernel and adapted 
from there.
Should I change it to 2020 ?
> 
> [...]
> 
> > + */
> > +#define INTEL_SIP_SMC_RETURN_UNKNOWN_FUNCTION
>   0x
> > +#define INTEL_SIP_SMC_STATUS_OK0x0
> > +#define INTEL_SIP_SMC_FPGA_CONFIG_STATUS_BUSY  0x1
> > +#define INTEL_SIP_SMC_FPGA_CONFIG_STATUS_REJECTED   0x2
> > +#define INTEL_SIP_SMC_FPGA_CONFIG_STATUS_ERROR 0x4
> > +#define INTEL_SIP_SMC_REG_ERROR0x5
> > +#define INTEL_SIP_SMC_RSU_ERROR0x7
> 
> Indent with tabs
OK.
> 
> [...]
> 
> > +/*
> > + * Request INTEL_SIP_SMC_MBOX_SEND_CMD
> > + *
> > + * Sync call used by service driver at EL1 to send mailbox command to SDM
> > + *
> > + * Call register usage:
> > + * a0 INTEL_SIP_SMC_MBOX_SEND_CMD
> > + * a1 Mailbox command
> > + * a2 64bit physical address pointer to command's arguments
> > + * a3 Length of the argument
> > + * a4 Urgent command enable = 1 / disable = 0
> > + * a5 64bit physical address pointer to a buffer for receiving responses
> > + * a6 Length of the buffer
> > + *
> > + * Return status
> > + * a0 INTEL_SIP_SMC_STATUS_OK or INTEL_SIP_SMC_RSU_ERROR.
> > + * a1 Status of mailbox response
> > + * a2 64bit physical address pointer to a buffer for receiving responses
> > + * a3 Received length in the buffer
> > + */
> > +#define INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD 30
> > +#define INTEL_SIP_SMC_MBOX_SEND_CMD \
> > +
>   INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_MBOX_SEN
> D_CMD)
> 
> Is this macro a function call or a value ?
It adds some value on top of  ' INTEL_SIP_SMC_FUNCID_MBOX_SEND_CMD ' through 
some
bitwise operation to produce a final value. So it's a value.


RE: [PATCH v2 08/21] arm: socfpga: Add SMC helper function for Intel SOCFPGA (64bits)

2020-02-19 Thread Ang, Chee Hong
> On 2/19/20 1:25 PM, chee.hong@intel.com wrote:
> [...]
> 
> > +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_ATF) int
> > +invoke_smc(u32 func_id, u64 *args, int arg_len, u64 *ret_arg, int
> > +ret_len) {
> > +   int i;
> > +   struct pt_regs regs;
> > +
> > +   memset(®s, 0, sizeof(regs));
> > +
> > +   regs.regs[0] = func_id;
> > +
> > +   if (args) {
> > +   for (i = 0; i < arg_len; i++)
> > +   regs.regs[i + 1] = args[i];
> 
> Is this memcpy() ?
Will change this.
> 
> > +   }
> > +
> > +   smc_call(®s);
> > +
> > +   if (ret_arg) {
> > +   for (i = 0; i < ret_len; i++)
> > +   ret_arg[i] = regs.regs[i + 1];
> 
> memcpy() ?
Will change this too. Thanks.


Re: Pull request for UEFI sub-system for efi-2020-04-rc3

2020-02-19 Thread Tom Rini
On Wed, Feb 19, 2020 at 07:40:30PM +0100, Heinrich Schuchardt wrote:

> The following changes since commit f2a73d6867ef973fbb8471cc87058205999b5e5c:
> 
>   Merge tag 'u-boot-stm32-20200214' of
> https://gitlab.denx.de/u-boot/custodians/u-boot-stm (2020-02-14 07:31:47
> -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2020-04-rc3
> 
> for you to fetch changes up to 0e228853b520611a0ee6fe2b9bd7a0bc3f8c30fc:
> 
>   efi_loader: EFI_RNG_PROTOCOL (2020-02-19 12:53:36 +0100)
> 
> No problems showed up in Gitlab CI:
> https://gitlab.denx.de/u-boot/custodians/u-boot-efi/pipelines/2252
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [U-Boot] Please pull from u-boot-i2c

2020-02-19 Thread Tom Rini
On Tue, Feb 18, 2020 at 12:51:34PM +0100, Heiko Schocher wrote:

> Hello Tom,
> 
> please pull from u-boot-i2c master branch:
> 
> The following changes since commit f2a73d6867ef973fbb8471cc87058205999b5e5c:
> 
>   Merge tag 'u-boot-stm32-20200214' of
> https://gitlab.denx.de/u-boot/custodians/u-boot-stm (2020-02-14 07:31:47
> -0500)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-i2c.git 
> tags/bugfixes-for-v2020.04
> 
> for you to fetch changes up to 64d44c4e9f4fe048aca69db7b6a208ab9e55f9b2:
> 
>   i2c: designware_i2c: Correct the selection of speed mode (2020-02-18 
> 08:16:45 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PING][PATCH] Optionally: Set the serial# environment variable on the i.MX7.

2020-02-19 Thread Mark G
Enabling this new option allows the kernel to obtain the unique ID of the 
CPU when not using ATAGS.


Signed-off-by: Mark G 
---
diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index a2131ca07c..64ceb36ed8 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -39,7 +39,7 @@ extern void udc_disconnect(void);
 #endif

 struct tag_serialnr;
-#ifdef CONFIG_SERIAL_TAG
+#if defined(CONFIG_SERIAL_TAG) || defined(CONFIG_SET_SERIAL_ENV)
  #define BOOTM_ENABLE_SERIAL_TAG   1
 void get_board_serial(struct tag_serialnr *serialnr);
 #else
diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
index 286d36589d..4cf14d43c0 100644
--- a/arch/arm/mach-imx/mx7/Kconfig
+++ b/arch/arm/mach-imx/mx7/Kconfig
@@ -71,6 +71,13 @@ config TARGET_COLIBRI_IMX7

 endchoice

+config SET_SERIAL_ENV
+   bool "Set serial number variable from the OCOTP"
+   help
+ Selecting this option will populate the serial# environment
+ variable with a unique identifier from the i.MX7 CPU. The
+ Linux kernel will use this as the serial number of the machine.
+
 config SYS_SOC
default "mx7"

diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 4aafeed188..208400a4a7 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -344,11 +344,24 @@ int arch_misc_init(void)
sec_init();
 #endif

+#ifdef CONFIG_SET_SERIAL_ENV
+   {
+   struct tag_serialnr serialnr;
+   char serialbuf[sizeof(serialnr) * 2 + 8];
+
+   get_board_serial(&serialnr);
+   snprintf(serialbuf, sizeof(serialbuf),
+"%08lx%08lx",
+(ulong)serialnr.high, (ulong)serialnr.low);
+   env_set("serial#", serialbuf);
+   }
+#endif
+
return 0;
 }
 #endif

-#ifdef CONFIG_SERIAL_TAG
+#if defined(CONFIG_SERIAL_TAG) || defined(CONFIG_SET_SERIAL_ENV)
 /*
  * OCOTP_TESTER
  * i.MX 7Solo Applications Processor Reference Manual, Rev. 0.1, 08/2016
--
2.17.1



Re: [PATCH 1/1] efi_loader: implement EFI_RT_PROPERTIES_TABLE

2020-02-19 Thread Ard Biesheuvel
On Wed, 19 Feb 2020 at 21:00, Heinrich Schuchardt  wrote:
>
> UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable
> defined in UEFI spec 2.8 by the configuration table
> EFI_RT_PROPERTIES_TABLE. So let's follow suit.
>
> Cc: Ard Biesheuvel 
> Signed-off-by: Heinrich Schuchardt 

I have tested this on u-boot+linux/arm64 running on QEMU, with my
kernel patches that take this table into account [0], and compared to
EDK2 (which implements variable services, and doesn't produce this
table), I get

--- edk2.log 2020-02-19 22:42:58.767456976 +0100
+++ uboot.log 2020-02-19 22:42:46.907642320 +0100
@@ -9,7 +9,6 @@
 [] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo
Giometti 
 [] PTP clock support registered
 [] EDAC MC: Ver: 3.0.0
-[] Registered efivars operations
 [] FPGA manager framework
 [] Advanced Linux Sound Architecture Driver Initialized.
 [] clocksource: Switched to clocksource arch_sys_counter

(modulo the timestamps, of course)
So the table is being taken into account, and the EFI variable drivers
are no longer loaded.

Thanks for getting this sorted so quickly, the errata A spec was only
released today :-)


Tested-by: Ard Biesheuvel 



[0] https://lore.kernel.org/linux-efi/20200219171907.11894-1-a...@kernel.org/

> ---
>  cmd/efidebug.c   |  4 
>  include/efi_api.h| 12 
>  lib/efi_loader/efi_runtime.c | 36 
>  lib/efi_loader/efi_setup.c   |  8 
>  4 files changed, 48 insertions(+), 12 deletions(-)
>
> diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> index 576e95b395..d291ae54af 100644
> --- a/cmd/efidebug.c
> +++ b/cmd/efidebug.c
> @@ -264,6 +264,10 @@ static const struct {
> "SMBIOS table",
> SMBIOS_TABLE_GUID,
> },
> +   {
> +   "Runtime properties",
> +   EFI_RT_PROPERTIES_TABLE_GUID,
> +   },
>  };
>
>  /**
> diff --git a/include/efi_api.h b/include/efi_api.h
> index 22396172e1..b7b68cb7a1 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -228,6 +228,18 @@ struct efi_capsule_header {
>  #define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES0x1000
>  #define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO   0x2000
>
> +#define EFI_RT_PROPERTIES_TABLE_GUID \
> +   EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
> +0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
> +
> +#define EFI_RT_PROPERTIES_TABLE_VERSION0x1
> +
> +struct efi_rt_properties_table {
> +   u16 version;
> +   u16 length;
> +   u32 runtime_services_supported;
> +};
> +
>  struct efi_runtime_services {
> struct efi_table_hdr hdr;
> efi_status_t (EFIAPI *get_time)(struct efi_time *time,
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 4b3c843b2c..4be51335bc 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -18,6 +18,10 @@
>  /* For manual relocation support */
>  DECLARE_GLOBAL_DATA_PTR;
>
> +/* GUID of the runtime properties table */
> +static const efi_guid_t efi_rt_properties_table_guid =
> +   EFI_RT_PROPERTIES_TABLE_GUID;
> +
>  struct efi_runtime_mmio_list {
> struct list_head link;
> void **ptr;
> @@ -94,9 +98,28 @@ static __efi_runtime_data efi_uintn_t efi_descriptor_size;
>   * handle a good number of runtime callbacks
>   */
>
> +/**
> + * efi_init_runtime_supported() - create runtime properties table
> + *
> + * Create a configuration table specifying which services are available at
> + * runtime.
> + *
> + * Return: status code
> + */
>  efi_status_t efi_init_runtime_supported(void)
>  {
> -   u16 efi_runtime_services_supported =
> +   efi_status_t ret;
> +   struct efi_rt_properties_table *rt_table;
> +
> +   ret = efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
> +   sizeof(struct efi_rt_properties_table),
> +   (void **)&rt_table);
> +   if (ret != EFI_SUCCESS)
> +   return ret;
> +
> +   rt_table->version = EFI_RT_PROPERTIES_TABLE_VERSION;
> +   rt_table->length = sizeof(struct efi_rt_properties_table);
> +   rt_table->runtime_services_supported =
> EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP |
> EFI_RT_SUPPORTED_CONVERT_POINTER;
>
> @@ -105,15 +128,12 @@ efi_status_t efi_init_runtime_supported(void)
>  * as well as efi_runtime_services.
>  */
>  #ifdef CONFIG_EFI_HAVE_RUNTIME_RESET
> -   efi_runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
> +   rt_table->runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
>  #endif
>
> -   return EFI_CALL(efi_set_variable(L"RuntimeServicesSupported",
> -&efi_global_variable_guid,
> -EFI_VARIABLE_BOOTSERVICE_ACCESS |
> -   

Re: [RESEND PATCH 10/10] test: sandbox: add test for erase command

2020-02-19 Thread Stephen Warren

On 2/12/20 11:45 AM, Patrick Delaunay wrote:

Add test for the erase command tested on ENV in EXT4.



-""" env_location: ENVL_EXT4 (2)
+""" env location: ENVL_EXT4 (2)



-""" restore env_location: ENVL_NOWHERE (12)
+""" restore env location: ENVL_NOWHERE (12)


Was there a whitespace mistake in the earlier path or something? I can't 
see a diff here...


Re: [RESEND PATCH 06/10] test: environment in ext4

2020-02-19 Thread Stephen Warren

On 2/12/20 11:44 AM, Patrick Delaunay wrote:

Add basic test to persistent environment in ext4:
save and load in host ext4 file 'uboot.env'.

On first execution a empty EXT4 file system is created in
persistent data dir: env.ext4.img.



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



+def mk_env_ext4(state_test_env):
+c = state_test_env.u_boot_console
+
+"""Create a empty ext4 file system volume.
+"""
+filename = 'env.ext4.img'
+persistent = c.config.persistent_data_dir + '/' + filename


The test seems to want to delete this file at the end, and re-create it 
each time. Why store it in the persistent data directory in that case?



+if os.path.exists(persistent):
+c.log.action('Disk image file ' + persistent + ' already exists')


... and why just delete it and re-create it if a stale copy exists?


+else:
+try:
+check_call('rm -f %s' % persistent, shell=True)


why not:

check_call('rm -f ' + persistent)

That has simpler string operations, and I don't think any of these 
commands need shell=True, since they don't contain any shell 
metacharacters? Same comment for most of the other commands.



+def test_env_ext4(state_test_env):



+""" env_location: ENVL_EXT4 (2)
+"""


I think that'd be better as a regular comment:

# env_location: ENVL_EXT4 (2)

If there's a reason to make it a docstring, lets put the trailing """ on 
the same line since it's a short piece of text.



+response = c.run_command('env_loc 2')
+assert 'Saving Environment to EXT4' in response
+
+response = c.run_command('env_loc 2')
+assert 'Loading Environment from EXT4... OK' in response


Can't both assert invocations run on the same response? Or, does the 
env_loc command do different things based on some other state; that 
would feel pretty nasty.


Re: [PATCH 1/4] wdt: Add CONFIG_DESIGNWARE_WATCHDOG to Kconfig

2020-02-19 Thread Sean Anderson
On 2/3/20 3:13 AM, Marek Vasut wrote:
> On 2/2/20 7:02 PM, Sean Anderson wrote:
>>> btw what's the motivation for this series, are you hitting some issues
>>> with the WDT on SoCFPGA ?
>>
>> This watchdog appears on the Kendryte K210 CPU, which I am adding
>> support for. The rest of the board uses devicetree to configure drivers,
>> so I wanted to add support for this watchdog as well.
>>
> 
> You should be able to use what's in u-boot-socfpga/master then. Please
> give it a try.
> 

This patch series works except that I still need "[PATCH 2/4] arm: Move
asm/utils.h to log2.h". I will include it with my k210 support series,
since it is specific to that board.

--Sean



Re: m68k hangs silently

2020-02-19 Thread Simon Glass
Hi Angelo,

On Wed, 19 Feb 2020 at 07:36, Angelo Dureghello
 wrote:
>
> Hi Simon,
>
> after this commit:
>
> commit 29f7d05a347ab7a42577c67fdfb787ef91537302
> Author: Simon Glass 
> Date:   Sun Dec 29 21:19:17 2019 -0700
>
> dm: core: Move ofdata_to_platdata() call earlier
>
> This method is supposed to extract platform data from the device tree. It
> should be done before the device itself is probed. Move it earlier in the
> device_probe() function.
>
> Signed-off-by: Simon Glass 
>
> stmark2 (mcf5441x based board) hangs silently.
>
> I am debugging into this, since seems to be something wrong in my arch
> files, or related dm drivers, but if you have any hint about where to
> look, welcome.

Good to have a JTAG debugger or at least a working DEBUG_UART.

It could be that you have one device relying on another's ofdata, but
the reading of it is in the probe() method instead of
ofdata_to_platdata().

Also make sure you have proper error checking in these methods since
silent failure (e.g. to read an address) can cause invalid data to be
used by the driver.

You can also enable CONFIG_LOG_ERROR_RETURN if you are using log_ret()
or log_msg_ret() in your drivers.

I can't actually even find the serial driver for m68k so I don't think
I will be much help...

Regards,
Simon


Re: [PATCH v3] cmd: Add command to dump drivers and compatible strings

2020-02-19 Thread Sean Anderson
On 2/19/20 10:45 AM, Bin Meng wrote:
> Hi Simon,
> 
> On Fri, Feb 7, 2020 at 1:46 AM Simon Glass  wrote:
>>
>> On Thu, 6 Feb 2020 at 10:03, Sean Anderson  wrote:
>>>
>>> This adds a subcommand to dm to dump out what drivers are installed, and 
>>> their
>>> compatible strings. I have found this useful in ensuring that I have the 
>>> correct
>>> drivers compiled, and that I have put in the correct compatible strings.
>>>
>>> Signed-off-by: Sean Anderson 
>>> Reviewed-by: Bin Meng 
>>> Tested-by: Bin Meng 
>>>
>>> ---
>>>
>>> Changes in v3:
>>> - Add python test
>>>
>>> Changes in v2:
>>> - Check if entry->of_match is NULL before accessing it
>>> - Remove trailing newline in help message
>>>
>>>  cmd/dm.c | 12 +++-
>>>  drivers/core/dump.c  | 20 
>>>  include/dm/util.h|  3 +++
>>>  test/py/tests/test_dm.py | 17 +
> 
> Is this what you're looking for? I thought we need something in
> test/dm C test cases instead?

Tests for commands seem to be python tests. I considered writing a dm
test, but afiak that seems to be for testing function calls. There does
not seem to be an easy way to grab the console output. Additionally,
where would the authoritative list of installed drivers come from? The
easiest way would be to just use the same api that the command is using,
but this doesn't really test anything. As it is, the current test does
an ok job at correlating different methods of accessing the DM system
from the associated commands. It will also catch null-dereference bugs
like the one I found during testing.

--Sean



Re: [PATCH 2/8] Revert "mtd: Rename free() to rfree()"

2020-02-19 Thread Fabio Estevam
On Wed, Feb 19, 2020 at 4:40 PM Simon Goldschmidt
 wrote:
>
> This reverts commit 8d38a8459b0de45f5ff41f3e11c278a5cf395fd0.

You missed to explain the reason for the revert.


Re: [PATCH v4 14/17] riscv: Try to get cpu frequency from device tree

2020-02-19 Thread Sean Anderson
On 2/19/20 11:12 AM, Bin Meng wrote:
> Hi Sean,
> 
> On Tue, Feb 11, 2020 at 2:05 PM Sean Anderson  wrote:
>>
>> Instead of always using the "clock-frequency" property to determine cpu
>> frequency, try using a clock in "clocks" if it exists. This patch also
>> fixes a bug where there could be spurious higher frequencies if sizeof(u32)
>> != sizeof(ulong).
>>
> 
> I just realized the commit title looked a little bit confusing.
> 
> I think it could be more specific like:
> 
> riscv: Try to get cpu frequency from a "clocks" node if it exists
> 
> ?
> 
> Regards,
> Bin
> 

That makes sense to me.

--Sean


[PATCH 1/1] efi_loader: implement EFI_RT_PROPERTIES_TABLE

2020-02-19 Thread Heinrich Schuchardt
UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable
defined in UEFI spec 2.8 by the configuration table
EFI_RT_PROPERTIES_TABLE. So let's follow suit.

Cc: Ard Biesheuvel 
Signed-off-by: Heinrich Schuchardt 
---
 cmd/efidebug.c   |  4 
 include/efi_api.h| 12 
 lib/efi_loader/efi_runtime.c | 36 
 lib/efi_loader/efi_setup.c   |  8 
 4 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 576e95b395..d291ae54af 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -264,6 +264,10 @@ static const struct {
"SMBIOS table",
SMBIOS_TABLE_GUID,
},
+   {
+   "Runtime properties",
+   EFI_RT_PROPERTIES_TABLE_GUID,
+   },
 };

 /**
diff --git a/include/efi_api.h b/include/efi_api.h
index 22396172e1..b7b68cb7a1 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -228,6 +228,18 @@ struct efi_capsule_header {
 #define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES0x1000
 #define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO   0x2000

+#define EFI_RT_PROPERTIES_TABLE_GUID \
+   EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
+0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
+
+#define EFI_RT_PROPERTIES_TABLE_VERSION0x1
+
+struct efi_rt_properties_table {
+   u16 version;
+   u16 length;
+   u32 runtime_services_supported;
+};
+
 struct efi_runtime_services {
struct efi_table_hdr hdr;
efi_status_t (EFIAPI *get_time)(struct efi_time *time,
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 4b3c843b2c..4be51335bc 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -18,6 +18,10 @@
 /* For manual relocation support */
 DECLARE_GLOBAL_DATA_PTR;

+/* GUID of the runtime properties table */
+static const efi_guid_t efi_rt_properties_table_guid =
+   EFI_RT_PROPERTIES_TABLE_GUID;
+
 struct efi_runtime_mmio_list {
struct list_head link;
void **ptr;
@@ -94,9 +98,28 @@ static __efi_runtime_data efi_uintn_t efi_descriptor_size;
  * handle a good number of runtime callbacks
  */

+/**
+ * efi_init_runtime_supported() - create runtime properties table
+ *
+ * Create a configuration table specifying which services are available at
+ * runtime.
+ *
+ * Return: status code
+ */
 efi_status_t efi_init_runtime_supported(void)
 {
-   u16 efi_runtime_services_supported =
+   efi_status_t ret;
+   struct efi_rt_properties_table *rt_table;
+
+   ret = efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
+   sizeof(struct efi_rt_properties_table),
+   (void **)&rt_table);
+   if (ret != EFI_SUCCESS)
+   return ret;
+
+   rt_table->version = EFI_RT_PROPERTIES_TABLE_VERSION;
+   rt_table->length = sizeof(struct efi_rt_properties_table);
+   rt_table->runtime_services_supported =
EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP |
EFI_RT_SUPPORTED_CONVERT_POINTER;

@@ -105,15 +128,12 @@ efi_status_t efi_init_runtime_supported(void)
 * as well as efi_runtime_services.
 */
 #ifdef CONFIG_EFI_HAVE_RUNTIME_RESET
-   efi_runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
+   rt_table->runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
 #endif

-   return EFI_CALL(efi_set_variable(L"RuntimeServicesSupported",
-&efi_global_variable_guid,
-EFI_VARIABLE_BOOTSERVICE_ACCESS |
-EFI_VARIABLE_RUNTIME_ACCESS,
-sizeof(efi_runtime_services_supported),
-&efi_runtime_services_supported));
+   ret = efi_install_configuration_table(&efi_rt_properties_table_guid,
+ rt_table);
+   return ret;
 }

 /**
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index de7b616c6d..2060307b05 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -122,13 +122,13 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;

-   /* Indicate supported runtime services */
-   ret = efi_init_runtime_supported();
+   /* Initialize system table */
+   ret = efi_initialize_system_table();
if (ret != EFI_SUCCESS)
goto out;

-   /* Initialize system table */
-   ret = efi_initialize_system_table();
+   /* Indicate supported runtime services */
+   ret = efi_init_runtime_supported();
if (ret != EFI_SUCCESS)
goto out;

--
2.25.0



[PATCH 8/8] Revert "mailbox: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit cc92c3cc68a9053f53b2814e9233d86553cc998e.

Signed-off-by: Simon Goldschmidt 
---

 drivers/mailbox/k3-sec-proxy.c   | 2 +-
 drivers/mailbox/mailbox-uclass.c | 4 ++--
 drivers/mailbox/sandbox-mbox.c   | 2 +-
 drivers/mailbox/stm32-ipcc.c | 2 +-
 drivers/mailbox/tegra-hsp.c  | 2 +-
 include/mailbox-uclass.h | 4 ++--
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mailbox/k3-sec-proxy.c b/drivers/mailbox/k3-sec-proxy.c
index a560209f03..0546752f5f 100644
--- a/drivers/mailbox/k3-sec-proxy.c
+++ b/drivers/mailbox/k3-sec-proxy.c
@@ -293,7 +293,7 @@ static int k3_sec_proxy_recv(struct mbox_chan *chan, void 
*data)
 struct mbox_ops k3_sec_proxy_mbox_ops = {
.of_xlate = k3_sec_proxy_of_xlate,
.request = k3_sec_proxy_request,
-   .rfree = k3_sec_proxy_free,
+   .free = k3_sec_proxy_free,
.send = k3_sec_proxy_send,
.recv = k3_sec_proxy_recv,
 };
diff --git a/drivers/mailbox/mailbox-uclass.c b/drivers/mailbox/mailbox-uclass.c
index 291f5c218e..f408f05cf9 100644
--- a/drivers/mailbox/mailbox-uclass.c
+++ b/drivers/mailbox/mailbox-uclass.c
@@ -106,8 +106,8 @@ int mbox_free(struct mbox_chan *chan)
 
debug("%s(chan=%p)\n", __func__, chan);
 
-   if (ops->rfree)
-   return ops->rfree(chan);
+   if (ops->free)
+   return ops->free(chan);
 
return 0;
 }
diff --git a/drivers/mailbox/sandbox-mbox.c b/drivers/mailbox/sandbox-mbox.c
index 25e23eb05b..0f09dfa951 100644
--- a/drivers/mailbox/sandbox-mbox.c
+++ b/drivers/mailbox/sandbox-mbox.c
@@ -88,7 +88,7 @@ static const struct udevice_id sandbox_mbox_ids[] = {
 
 struct mbox_ops sandbox_mbox_mbox_ops = {
.request = sandbox_mbox_request,
-   .rfree = sandbox_mbox_free,
+   .free = sandbox_mbox_free,
.send = sandbox_mbox_send,
.recv = sandbox_mbox_recv,
 };
diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
index 13e642ab70..c58d9fa001 100644
--- a/drivers/mailbox/stm32-ipcc.c
+++ b/drivers/mailbox/stm32-ipcc.c
@@ -154,7 +154,7 @@ static const struct udevice_id stm32_ipcc_ids[] = {
 
 struct mbox_ops stm32_ipcc_mbox_ops = {
.request = stm32_ipcc_request,
-   .rfree = stm32_ipcc_free,
+   .free = stm32_ipcc_free,
.send = stm32_ipcc_send,
.recv = stm32_ipcc_recv,
 };
diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index 60f6a38321..00fc3972f9 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -176,7 +176,7 @@ static const struct udevice_id tegra_hsp_ids[] = {
 struct mbox_ops tegra_hsp_mbox_ops = {
.of_xlate = tegra_hsp_of_xlate,
.request = tegra_hsp_request,
-   .rfree = tegra_hsp_free,
+   .free = tegra_hsp_free,
.send = tegra_hsp_send,
.recv = tegra_hsp_recv,
 };
diff --git a/include/mailbox-uclass.h b/include/mailbox-uclass.h
index 3c60c76506..e0618aad97 100644
--- a/include/mailbox-uclass.h
+++ b/include/mailbox-uclass.h
@@ -49,14 +49,14 @@ struct mbox_ops {
 */
int (*request)(struct mbox_chan *chan);
/**
-* rfree - Free a previously requested channel.
+* free - Free a previously requested channel.
 *
 * This is the implementation of the client mbox_free() API.
 *
 * @chan:   The channel to free.
 * @return 0 if OK, or a negative error code.
 */
-   int (*rfree)(struct mbox_chan *chan);
+   int (*free)(struct mbox_chan *chan);
/**
* send - Send a message over a mailbox channel
*
-- 
2.20.1



[PATCH 6/8] Revert "reset: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit 94474b25c3a60a746bf641a975c3db239dae29b9.

Signed-off-by: Simon Goldschmidt 
---

 drivers/reset/reset-bcm6345.c   | 2 +-
 drivers/reset/reset-hisilicon.c | 2 +-
 drivers/reset/reset-hsdk.c  | 2 +-
 drivers/reset/reset-imx7.c  | 2 +-
 drivers/reset/reset-mediatek.c  | 2 +-
 drivers/reset/reset-meson.c | 2 +-
 drivers/reset/reset-mtmips.c| 2 +-
 drivers/reset/reset-rockchip.c  | 2 +-
 drivers/reset/reset-socfpga.c   | 2 +-
 drivers/reset/reset-sunxi.c | 2 +-
 drivers/reset/reset-ti-sci.c| 2 +-
 drivers/reset/reset-uclass.c| 2 +-
 drivers/reset/reset-uniphier.c  | 2 +-
 drivers/reset/sandbox-reset.c   | 2 +-
 drivers/reset/sti-reset.c   | 2 +-
 drivers/reset/stm32-reset.c | 2 +-
 drivers/reset/tegra-car-reset.c | 2 +-
 drivers/reset/tegra186-reset.c  | 2 +-
 include/reset-uclass.h  | 4 ++--
 19 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/reset/reset-bcm6345.c b/drivers/reset/reset-bcm6345.c
index c1f1e7f70b..f26582479e 100644
--- a/drivers/reset/reset-bcm6345.c
+++ b/drivers/reset/reset-bcm6345.c
@@ -53,7 +53,7 @@ static int bcm6345_reset_request(struct reset_ctl *rst)
 }
 
 struct reset_ops bcm6345_reset_reset_ops = {
-   .rfree = bcm6345_reset_free,
+   .free = bcm6345_reset_free,
.request = bcm6345_reset_request,
.rst_assert = bcm6345_reset_assert,
.rst_deassert = bcm6345_reset_deassert,
diff --git a/drivers/reset/reset-hisilicon.c b/drivers/reset/reset-hisilicon.c
index a678b8f745..54a254f9cb 100644
--- a/drivers/reset/reset-hisilicon.c
+++ b/drivers/reset/reset-hisilicon.c
@@ -73,7 +73,7 @@ static int hisi_reset_of_xlate(struct reset_ctl *rst,
 static const struct reset_ops hisi_reset_reset_ops = {
.of_xlate = hisi_reset_of_xlate,
.request = hisi_reset_request,
-   .rfree = hisi_reset_free,
+   .free = hisi_reset_free,
.rst_assert = hisi_reset_assert,
.rst_deassert = hisi_reset_deassert,
 };
diff --git a/drivers/reset/reset-hsdk.c b/drivers/reset/reset-hsdk.c
index f9a432a7a2..213d6c87be 100644
--- a/drivers/reset/reset-hsdk.c
+++ b/drivers/reset/reset-hsdk.c
@@ -81,7 +81,7 @@ static int hsdk_reset_noop(struct reset_ctl *rst_ctl)
 
 static const struct reset_ops hsdk_reset_ops = {
.request= hsdk_reset_noop,
-   .rfree  = hsdk_reset_noop,
+   .free   = hsdk_reset_noop,
.rst_assert = hsdk_reset_noop,
.rst_deassert   = hsdk_reset_reset,
 };
diff --git a/drivers/reset/reset-imx7.c b/drivers/reset/reset-imx7.c
index a61855e9ed..59d7088c9f 100644
--- a/drivers/reset/reset-imx7.c
+++ b/drivers/reset/reset-imx7.c
@@ -273,7 +273,7 @@ static int imx7_reset_request(struct reset_ctl *rst)
 
 static const struct reset_ops imx7_reset_reset_ops = {
.request = imx7_reset_request,
-   .rfree = imx7_reset_free,
+   .free = imx7_reset_free,
.rst_assert = imx7_reset_assert,
.rst_deassert = imx7_reset_deassert,
 };
diff --git a/drivers/reset/reset-mediatek.c b/drivers/reset/reset-mediatek.c
index 6d17f52ac7..0680abbe28 100644
--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -57,7 +57,7 @@ static int mediatek_reset_deassert(struct reset_ctl 
*reset_ctl)
 
 struct reset_ops mediatek_reset_ops = {
.request = mediatek_reset_request,
-   .rfree = mediatek_reset_free,
+   .free = mediatek_reset_free,
.rst_assert = mediatek_reset_assert,
.rst_deassert = mediatek_reset_deassert,
 };
diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c
index 70f96355b3..180780061e 100644
--- a/drivers/reset/reset-meson.c
+++ b/drivers/reset/reset-meson.c
@@ -63,7 +63,7 @@ static int meson_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops meson_reset_ops = {
.request = meson_reset_request,
-   .rfree = meson_reset_free,
+   .free = meson_reset_free,
.rst_assert = meson_reset_assert,
.rst_deassert = meson_reset_deassert,
 };
diff --git a/drivers/reset/reset-mtmips.c b/drivers/reset/reset-mtmips.c
index 677de0a6f9..5df95f1324 100644
--- a/drivers/reset/reset-mtmips.c
+++ b/drivers/reset/reset-mtmips.c
@@ -46,7 +46,7 @@ static int mtmips_reset_deassert(struct reset_ctl *reset_ctl)
 
 static const struct reset_ops mtmips_reset_ops = {
.request= mtmips_reset_request,
-   .rfree  = mtmips_reset_free,
+   .free   = mtmips_reset_free,
.rst_assert = mtmips_reset_assert,
.rst_deassert   = mtmips_reset_deassert,
 };
diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c
index 100afc8103..a4dc103951 100644
--- a/drivers/reset/reset-rockchip.c
+++ b/drivers/reset/reset-rockchip.c
@@ -77,7 +77,7 @@ static int rockchip_reset_deassert(struct reset_ctl 
*reset_ctl)
 
 struct reset_ops rockchip_reset_ops = {
.request = rockchip_reset_request,
-   .rfree = rockchip_reset_free,
+   .free = rockchip_res

[PATCH 5/8] Revert "gpio: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit 093152f275e036e54d48b3d9fc0adbc1ca4cc5b0.

Signed-off-by: Simon Goldschmidt 
---

 drivers/gpio/gpio-rcar.c   | 2 +-
 drivers/gpio/gpio-uclass.c | 8 
 include/asm-generic/gpio.h | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 9dc4cd6042..25bbbcde4b 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -130,7 +130,7 @@ static int rcar_gpio_free(struct udevice *dev, unsigned 
offset)
 
 static const struct dm_gpio_ops rcar_gpio_ops = {
.request= rcar_gpio_request,
-   .rfree  = rcar_gpio_free,
+   .free   = rcar_gpio_free,
.direction_input= rcar_gpio_direction_input,
.direction_output   = rcar_gpio_direction_output,
.get_value  = rcar_gpio_get_value,
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0a22441d38..90fbed455b 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -364,8 +364,8 @@ int _dm_gpio_free(struct udevice *dev, uint offset)
uc_priv = dev_get_uclass_priv(dev);
if (!uc_priv->name[offset])
return -ENXIO;
-   if (gpio_get_ops(dev)->rfree) {
-   ret = gpio_get_ops(dev)->rfree(dev, offset);
+   if (gpio_get_ops(dev)->free) {
+   ret = gpio_get_ops(dev)->free(dev, offset);
if (ret)
return ret;
}
@@ -1043,8 +1043,8 @@ static int gpio_post_bind(struct udevice *dev)
if (!reloc_done) {
if (ops->request)
ops->request += gd->reloc_off;
-   if (ops->rfree)
-   ops->rfree += gd->reloc_off;
+   if (ops->free)
+   ops->free += gd->reloc_off;
if (ops->direction_input)
ops->direction_input += gd->reloc_off;
if (ops->direction_output)
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 05777e6afe..d6cf18744f 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -248,7 +248,7 @@ int gpio_xlate_offs_flags(struct udevice *dev, struct 
gpio_desc *desc,
  */
 struct dm_gpio_ops {
int (*request)(struct udevice *dev, unsigned offset, const char *label);
-   int (*rfree)(struct udevice *dev, unsigned int offset);
+   int (*free)(struct udevice *dev, unsigned offset);
int (*direction_input)(struct udevice *dev, unsigned offset);
int (*direction_output)(struct udevice *dev, unsigned offset,
int value);
-- 
2.20.1



[PATCH 2/8] Revert "mtd: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit 8d38a8459b0de45f5ff41f3e11c278a5cf395fd0.

Signed-off-by: Simon Goldschmidt 
---

 drivers/mtd/mtdcore.c | 4 ++--
 drivers/mtd/nand/raw/denali.c | 2 +-
 drivers/mtd/nand/spi/core.c   | 2 +-
 drivers/mtd/nand/spi/gigadevice.c | 2 +-
 drivers/mtd/nand/spi/macronix.c   | 2 +-
 drivers/mtd/nand/spi/micron.c | 2 +-
 drivers/mtd/nand/spi/winbond.c| 2 +-
 include/linux/mtd/mtd.h   | 4 ++--
 8 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index f8d3f4d246..4567e5eb7a 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1180,10 +1180,10 @@ int mtd_ooblayout_free(struct mtd_info *mtd, int 
section,
if (!mtd || section < 0)
return -EINVAL;
 
-   if (!mtd->ooblayout || !mtd->ooblayout->rfree)
+   if (!mtd->ooblayout || !mtd->ooblayout->free)
return -ENOTSUPP;
 
-   return mtd->ooblayout->rfree(mtd, section, oobfree);
+   return mtd->ooblayout->free(mtd, section, oobfree);
 }
 EXPORT_SYMBOL_GPL(mtd_ooblayout_free);
 
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index f51d3e25c7..550fb7c771 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -1160,7 +1160,7 @@ static int denali_ooblayout_free(struct mtd_info *mtd, 
int section,
 
 static const struct mtd_ooblayout_ops denali_ooblayout_ops = {
.ecc = denali_ooblayout_ecc,
-   .rfree = denali_ooblayout_free,
+   .free = denali_ooblayout_free,
 };
 
 static int denali_multidev_fixup(struct denali_nand_info *denali)
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index cd624ec6ae..5e3704e4d0 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1023,7 +1023,7 @@ static int spinand_noecc_ooblayout_free(struct mtd_info 
*mtd, int section,
 
 static const struct mtd_ooblayout_ops spinand_noecc_ooblayout = {
.ecc = spinand_noecc_ooblayout_ecc,
-   .rfree = spinand_noecc_ooblayout_free,
+   .free = spinand_noecc_ooblayout_free,
 };
 
 static int spinand_init(struct spinand_device *spinand)
diff --git a/drivers/mtd/nand/spi/gigadevice.c 
b/drivers/mtd/nand/spi/gigadevice.c
index 0b228dcb5b..4c8bb1e12d 100644
--- a/drivers/mtd/nand/spi/gigadevice.c
+++ b/drivers/mtd/nand/spi/gigadevice.c
@@ -104,7 +104,7 @@ static int gd5fxgq4xexxg_ecc_get_status(struct 
spinand_device *spinand,
 
 static const struct mtd_ooblayout_ops gd5fxgq4xexxg_ooblayout = {
.ecc = gd5fxgq4xexxg_ooblayout_ecc,
-   .rfree = gd5fxgq4xexxg_ooblayout_free,
+   .free = gd5fxgq4xexxg_ooblayout_free,
 };
 
 static const struct spinand_info gigadevice_spinand_table[] = {
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
index 67d092be2c..2948e2ea41 100644
--- a/drivers/mtd/nand/spi/macronix.c
+++ b/drivers/mtd/nand/spi/macronix.c
@@ -48,7 +48,7 @@ static int mx35lfxge4ab_ooblayout_free(struct mtd_info *mtd, 
int section,
 
 static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = {
.ecc = mx35lfxge4ab_ooblayout_ecc,
-   .rfree = mx35lfxge4ab_ooblayout_free,
+   .free = mx35lfxge4ab_ooblayout_free,
 };
 
 static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
index 687306e33e..718c4b42ca 100644
--- a/drivers/mtd/nand/spi/micron.c
+++ b/drivers/mtd/nand/spi/micron.c
@@ -64,7 +64,7 @@ static int mt29f2g01abagd_ooblayout_free(struct mtd_info 
*mtd, int section,
 
 static const struct mtd_ooblayout_ops mt29f2g01abagd_ooblayout = {
.ecc = mt29f2g01abagd_ooblayout_ecc,
-   .rfree = mt29f2g01abagd_ooblayout_free,
+   .free = mt29f2g01abagd_ooblayout_free,
 };
 
 static int mt29f2g01abagd_ecc_get_status(struct spinand_device *spinand,
diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c
index 6ede98c85d..b05cd70457 100644
--- a/drivers/mtd/nand/spi/winbond.c
+++ b/drivers/mtd/nand/spi/winbond.c
@@ -60,7 +60,7 @@ static int w25m02gv_ooblayout_free(struct mtd_info *mtd, int 
section,
 
 static const struct mtd_ooblayout_ops w25m02gv_ooblayout = {
.ecc = w25m02gv_ooblayout_ecc,
-   .rfree = w25m02gv_ooblayout_free,
+   .free = w25m02gv_ooblayout_free,
 };
 
 static int w25m02gv_select_target(struct spinand_device *spinand,
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 1b9151714c..ceffd994de 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -129,8 +129,8 @@ struct mtd_oob_region {
 struct mtd_ooblayout_ops {
int (*ecc)(struct mtd_info *mtd, int section,
   struct mtd_oob_region *oobecc);
-   int (*rfree)(struct mtd_info *mtd, int section,
-struct mtd_oob_region *oobfree);
+   int (*free)(struct mtd_info *mtd, int section,
+   struct mtd_oob_region *oobfree);
 };
 
 /*
-- 
2.20.1



[PATCH 3/8] Revert "dma: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit aae95882232a24ee49c89d0356febf3685a87c8a.

Signed-off-by: Simon Goldschmidt 
---

 drivers/dma/dma-uclass.c   | 4 ++--
 drivers/dma/sandbox-dma-test.c | 4 ++--
 drivers/dma/ti/k3-udma.c   | 4 ++--
 include/dma-uclass.h   | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/dma-uclass.c b/drivers/dma/dma-uclass.c
index 9d5a7fc796..68e17ed1f9 100644
--- a/drivers/dma/dma-uclass.c
+++ b/drivers/dma/dma-uclass.c
@@ -123,10 +123,10 @@ int dma_free(struct dma *dma)
 
debug("%s(dma=%p)\n", __func__, dma);
 
-   if (!ops->rfree)
+   if (!ops->free)
return 0;
 
-   return ops->rfree(dma);
+   return ops->free(dma);
 }
 
 int dma_enable(struct dma *dma)
diff --git a/drivers/dma/sandbox-dma-test.c b/drivers/dma/sandbox-dma-test.c
index 234a7d2134..e8c809fa64 100644
--- a/drivers/dma/sandbox-dma-test.c
+++ b/drivers/dma/sandbox-dma-test.c
@@ -89,7 +89,7 @@ static int sandbox_dma_request(struct dma *dma)
return 0;
 }
 
-static int sandbox_dma_rfree(struct dma *dma)
+static int sandbox_dma_free(struct dma *dma)
 {
struct sandbox_dma_dev *ud = dev_get_priv(dma->dev);
struct sandbox_dma_chan *uc;
@@ -230,7 +230,7 @@ static const struct dma_ops sandbox_dma_ops = {
.transfer   = sandbox_dma_transfer,
.of_xlate   = sandbox_dma_of_xlate,
.request= sandbox_dma_request,
-   .rfree  = sandbox_dma_rfree,
+   .free   = sandbox_dma_free,
.enable = sandbox_dma_enable,
.disable= sandbox_dma_disable,
.send   = sandbox_dma_send,
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index f274100f32..d6eb6d9339 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1553,7 +1553,7 @@ static int udma_request(struct dma *dma)
return 0;
 }
 
-static int udma_rfree(struct dma *dma)
+static int udma_free(struct dma *dma)
 {
struct udma_dev *ud = dev_get_priv(dma->dev);
struct udma_chan *uc;
@@ -1848,7 +1848,7 @@ static const struct dma_ops udma_ops = {
.transfer   = udma_transfer,
.of_xlate   = udma_of_xlate,
.request= udma_request,
-   .rfree  = udma_rfree,
+   .free   = udma_free,
.enable = udma_enable,
.disable= udma_disable,
.send   = udma_send,
diff --git a/include/dma-uclass.h b/include/dma-uclass.h
index 340437acc1..a1d9d26ac5 100644
--- a/include/dma-uclass.h
+++ b/include/dma-uclass.h
@@ -58,14 +58,14 @@ struct dma_ops {
 */
int (*request)(struct dma *dma);
/**
-* rfree - Free a previously requested dma.
+* free - Free a previously requested dma.
 *
 * This is the implementation of the client dma_free() API.
 *
 * @dma: The DMA to free.
 * @return 0 if OK, or a negative error code.
 */
-   int (*rfree)(struct dma *dma);
+   int (*free)(struct dma *dma);
/**
 * enable() - Enable a DMA Channel.
 *
-- 
2.20.1



[PATCH 7/8] Revert "power-domain: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit 4f51188e47921b17e6b3ce9606c8e71234c9f2df.

Signed-off-by: Simon Goldschmidt 
---

 drivers/power/domain/bcm6328-power-domain.c | 2 +-
 drivers/power/domain/imx8-power-domain-legacy.c | 2 +-
 drivers/power/domain/imx8-power-domain.c| 2 +-
 drivers/power/domain/imx8m-power-domain.c   | 2 +-
 drivers/power/domain/meson-ee-pwrc.c| 2 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c| 2 +-
 drivers/power/domain/mtk-power-domain.c | 2 +-
 drivers/power/domain/power-domain-uclass.c  | 2 +-
 drivers/power/domain/sandbox-power-domain.c | 2 +-
 drivers/power/domain/tegra186-power-domain.c| 2 +-
 drivers/power/domain/ti-sci-power-domain.c  | 2 +-
 include/power-domain-uclass.h   | 4 ++--
 12 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/power/domain/bcm6328-power-domain.c 
b/drivers/power/domain/bcm6328-power-domain.c
index a6426bee27..e261d22b50 100644
--- a/drivers/power/domain/bcm6328-power-domain.c
+++ b/drivers/power/domain/bcm6328-power-domain.c
@@ -63,7 +63,7 @@ static const struct udevice_id bcm6328_power_domain_ids[] = {
 };
 
 struct power_domain_ops bcm6328_power_domain_ops = {
-   .rfree = bcm6328_power_domain_free,
+   .free = bcm6328_power_domain_free,
.off = bcm6328_power_domain_off,
.on = bcm6328_power_domain_on,
.request = bcm6328_power_domain_request,
diff --git a/drivers/power/domain/imx8-power-domain-legacy.c 
b/drivers/power/domain/imx8-power-domain-legacy.c
index 6f01a60b34..f489083f2d 100644
--- a/drivers/power/domain/imx8-power-domain-legacy.c
+++ b/drivers/power/domain/imx8-power-domain-legacy.c
@@ -297,7 +297,7 @@ static const struct udevice_id imx8_power_domain_ids[] = {
 
 struct power_domain_ops imx8_power_domain_ops = {
.request = imx8_power_domain_request,
-   .rfree = imx8_power_domain_free,
+   .free = imx8_power_domain_free,
.on = imx8_power_domain_on,
.off = imx8_power_domain_off,
.of_xlate = imx8_power_domain_of_xlate,
diff --git a/drivers/power/domain/imx8-power-domain.c 
b/drivers/power/domain/imx8-power-domain.c
index 571146e19d..eaf8635899 100644
--- a/drivers/power/domain/imx8-power-domain.c
+++ b/drivers/power/domain/imx8-power-domain.c
@@ -74,7 +74,7 @@ static const struct udevice_id imx8_power_domain_ids[] = {
 
 struct power_domain_ops imx8_power_domain_ops_v2 = {
.request = imx8_power_domain_request,
-   .rfree = imx8_power_domain_free,
+   .free = imx8_power_domain_free,
.on = imx8_power_domain_on,
.off = imx8_power_domain_off,
 };
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
index 5b6467cda7..48a3fca6bd 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -122,7 +122,7 @@ static const struct udevice_id imx8m_power_domain_ids[] = {
 
 struct power_domain_ops imx8m_power_domain_ops = {
.request = imx8m_power_domain_request,
-   .rfree = imx8m_power_domain_free,
+   .free = imx8m_power_domain_free,
.on = imx8m_power_domain_on,
.off = imx8m_power_domain_off,
.of_xlate = imx8m_power_domain_of_xlate,
diff --git a/drivers/power/domain/meson-ee-pwrc.c 
b/drivers/power/domain/meson-ee-pwrc.c
index 7082c80bfa..f09bc03811 100644
--- a/drivers/power/domain/meson-ee-pwrc.c
+++ b/drivers/power/domain/meson-ee-pwrc.c
@@ -354,7 +354,7 @@ static int meson_ee_pwrc_of_xlate(struct power_domain 
*power_domain,
 }
 
 struct power_domain_ops meson_ee_pwrc_ops = {
-   .rfree = meson_ee_pwrc_free,
+   .free = meson_ee_pwrc_free,
.off = meson_ee_pwrc_off,
.on = meson_ee_pwrc_on,
.request = meson_ee_pwrc_request,
diff --git a/drivers/power/domain/meson-gx-pwrc-vpu.c 
b/drivers/power/domain/meson-gx-pwrc-vpu.c
index 12cdfcdd1f..8381cb226d 100644
--- a/drivers/power/domain/meson-gx-pwrc-vpu.c
+++ b/drivers/power/domain/meson-gx-pwrc-vpu.c
@@ -271,7 +271,7 @@ static int meson_pwrc_vpu_of_xlate(struct power_domain 
*power_domain,
 }
 
 struct power_domain_ops meson_gx_pwrc_vpu_ops = {
-   .rfree = meson_pwrc_vpu_free,
+   .free = meson_pwrc_vpu_free,
.off = meson_pwrc_vpu_off,
.on = meson_pwrc_vpu_on,
.request = meson_pwrc_vpu_request,
diff --git a/drivers/power/domain/mtk-power-domain.c 
b/drivers/power/domain/mtk-power-domain.c
index 3ff7ca1bef..dcf33678d7 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -398,7 +398,7 @@ static const struct udevice_id mtk_power_domain_ids[] = {
 };
 
 struct power_domain_ops mtk_power_domain_ops = {
-   .rfree = scpsys_power_free,
+   .free = scpsys_power_free,
.off = scpsys_power_off,
.on = scpsys_power_on,
.request = scpsys_power_request,
diff --git a/drivers/power/domain/power-domain-uclass.c 
b/drivers/power/domain/power-domain-uclass.c
index d9c623b56e.

[PATCH 4/8] Revert "clk: Rename free() to rfree()"

2020-02-19 Thread Simon Goldschmidt
This reverts commit fb8c0d595f1ad83bee5dd398b59b0ee16d8d15a9.

Signed-off-by: Simon Goldschmidt 
---

 drivers/clk/clk-ti-sci.c  | 2 +-
 drivers/clk/clk-uclass.c  | 4 ++--
 drivers/clk/clk_sandbox.c | 2 +-
 drivers/clk/tegra/tegra-car-clk.c | 2 +-
 include/clk-uclass.h  | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-ti-sci.c b/drivers/clk/clk-ti-sci.c
index 82241d9f3f..e272003d30 100644
--- a/drivers/clk/clk-ti-sci.c
+++ b/drivers/clk/clk-ti-sci.c
@@ -206,7 +206,7 @@ static const struct udevice_id ti_sci_clk_of_match[] = {
 static struct clk_ops ti_sci_clk_ops = {
.of_xlate = ti_sci_clk_of_xlate,
.request = ti_sci_clk_request,
-   .rfree = ti_sci_clk_free,
+   .free = ti_sci_clk_free,
.get_rate = ti_sci_clk_get_rate,
.set_rate = ti_sci_clk_set_rate,
.set_parent = ti_sci_clk_set_parent,
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 71878474eb..24353fae53 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -426,10 +426,10 @@ int clk_free(struct clk *clk)
return 0;
ops = clk_dev_ops(clk->dev);
 
-   if (!ops->rfree)
+   if (!ops->free)
return 0;
 
-   return ops->rfree(clk);
+   return ops->free(clk);
 }
 
 ulong clk_get_rate(struct clk *clk)
diff --git a/drivers/clk/clk_sandbox.c b/drivers/clk/clk_sandbox.c
index 768fbb7c52..7059979606 100644
--- a/drivers/clk/clk_sandbox.c
+++ b/drivers/clk/clk_sandbox.c
@@ -108,7 +108,7 @@ static struct clk_ops sandbox_clk_ops = {
.enable = sandbox_clk_enable,
.disable= sandbox_clk_disable,
.request= sandbox_clk_request,
-   .rfree  = sandbox_clk_free,
+   .free   = sandbox_clk_free,
 };
 
 static int sandbox_clk_probe(struct udevice *dev)
diff --git a/drivers/clk/tegra/tegra-car-clk.c 
b/drivers/clk/tegra/tegra-car-clk.c
index 6083f14e75..1f0e2dc95b 100644
--- a/drivers/clk/tegra/tegra-car-clk.c
+++ b/drivers/clk/tegra/tegra-car-clk.c
@@ -81,7 +81,7 @@ static int tegra_car_clk_disable(struct clk *clk)
 
 static struct clk_ops tegra_car_clk_ops = {
.request = tegra_car_clk_request,
-   .rfree = tegra_car_clk_free,
+   .free = tegra_car_clk_free,
.get_rate = tegra_car_clk_get_rate,
.set_rate = tegra_car_clk_set_rate,
.enable = tegra_car_clk_enable,
diff --git a/include/clk-uclass.h b/include/clk-uclass.h
index dac42dab36..e76d98e2f6 100644
--- a/include/clk-uclass.h
+++ b/include/clk-uclass.h
@@ -53,14 +53,14 @@ struct clk_ops {
 */
int (*request)(struct clk *clock);
/**
-* rfree - Free a previously requested clock.
+* free - Free a previously requested clock.
 *
 * This is the implementation of the client clk_free() API.
 *
 * @clock:  The clock to free.
 * @return 0 if OK, or a negative error code.
 */
-   int (*rfree)(struct clk *clock);
+   int (*free)(struct clk *clock);
/**
 * get_rate() - Get current clock rate.
 *
-- 
2.20.1



[PATCH 1/8] malloc: implement USE_DL_PREFIX via inline functions

2020-02-19 Thread Simon Goldschmidt
Commit cfda60f99ae2 ("sandbox: Use a prefix for all allocation functions")
introduced preprocessor macros for malloc/free etc.

This is bad practice as it essentially makes 'free' a reserved keyword and
resulted in quite a bit of renaming to avoid that reserved keyword.

A better solution is to define the allocation functions as 'static inline'.

As a side effect, exports.h must not export malloc/free for sandbox.

Signed-off-by: Simon Goldschmidt 
---

A side-effect is that exports.h may not declare malloc/free. I'm not really
sure if this is correct, but for sandbox, it should probably be ok?

 include/_exports.h |  2 ++
 include/exports.h  |  2 ++
 include/malloc.h   | 44 +---
 3 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/include/_exports.h b/include/_exports.h
index 0dee05f077..acfbf97c17 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -22,9 +22,11 @@
EXPORT_FUNC(dummy, void, install_hdlr, void)
EXPORT_FUNC(dummy, void, free_hdlr, void)
 #endif
+#ifndef CONFIG_SANDBOX
EXPORT_FUNC(malloc, void *, malloc, size_t)
 #if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
EXPORT_FUNC(free, void, free, void *)
+#endif
 #endif
EXPORT_FUNC(udelay, void, udelay, unsigned long)
EXPORT_FUNC(get_timer, unsigned long, get_timer, unsigned long)
diff --git a/include/exports.h b/include/exports.h
index cbd16fc518..5d161824c8 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -25,10 +25,12 @@ void puts(const char*);
 int printf(const char* fmt, ...);
 void install_hdlr(int, interrupt_handler_t, void*);
 void free_hdlr(int);
+#ifndef CONFIG_SANDBOX
 void *malloc(size_t);
 #if !CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
 void free(void*);
 #endif
+#endif
 void __udelay(unsigned long);
 unsigned long get_timer(unsigned long);
 int vprintf(const char *, va_list);
diff --git a/include/malloc.h b/include/malloc.h
index f66c2e8617..50d4873b08 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -897,21 +897,6 @@ void malloc_simple_info(void);
 # define pvALLOc   dlpvalloc
 # define mALLINFo  dlmallinfo
 # define mALLOPt   dlmallopt
-
-/* Ensure that U-Boot actually uses these too */
-#define calloc dlcalloc
-#define free(ptr) dlfree(ptr)
-#define malloc(x) dlmalloc(x)
-#define memalign dlmemalign
-#define realloc dlrealloc
-#define valloc dlvalloc
-#define pvalloc dlpvalloc
-#define mallinfo() dlmallinfo()
-#define mallopt dlmallopt
-#define malloc_trim dlmalloc_trim
-#define malloc_usable_size dlmalloc_usable_size
-#define malloc_stats dlmalloc_stats
-
 # else /* USE_DL_PREFIX */
 # define cALLOccalloc
 # define fREe  free
@@ -966,6 +951,35 @@ voidmalloc_stats();
 int mALLOPt();
 struct mallinfo mALLINFo();
 # endif
+
+# ifdef USE_DL_PREFIX
+/* Ensure that U-Boot actually uses the redefined functions: */
+static inline void *calloc(size_t n, size_t elem_size)
+{
+   return dlcalloc(n, elem_size);
+}
+
+static inline void free(void *ptr) { dlfree(ptr); }
+static inline void *malloc(size_t bytes) { return dlmalloc(bytes); }
+static inline void *memalign(size_t alignment, size_t bytes)
+{
+   return dlmemalign(alignment, bytes);
+}
+
+static inline void *realloc(void *oldmem, size_t bytes)
+{
+   return dlrealloc(oldmem, bytes);
+}
+
+static inline void *valloc(size_t bytes) { return dlvalloc(bytes); }
+static inline void *pvalloc(size_t bytes) { return dlpvalloc(bytes); }
+static inline struct mallinfo mallinfo(void) { return dlmallinfo(); }
+static inline int mallopt(int param_number, int value)
+{
+   return dlmallopt(param_number, value);
+}
+# endif
+
 #endif
 #pragma GCC visibility pop
 
-- 
2.20.1



[PATCH 0/8] malloc: implement USE_DL_PREFIX using inline functions

2020-02-19 Thread Simon Goldschmidt
Commit cfda60f99ae2 ("sandbox: Use a prefix for all allocation functions")
introduced preprocessor macros for malloc/free etc.

This is bad practice as it essentially makes 'free' a reserved keyword and
resulted in quite a bit of renaming to avoid that reserved keyword.

A better solution is to define the allocation functions as 'static inline'.

This should go in before the release, as it's a regression not seen before
the last release.

A side-effect is that exports.h may not declare malloc/free. I'm not really
sure if this is correct, but for sandbox, it should probably be ok?


Simon Goldschmidt (8):
  malloc: implement USE_DL_PREFIX via inline functions
  Revert "mtd: Rename free() to rfree()"
  Revert "dma: Rename free() to rfree()"
  Revert "clk: Rename free() to rfree()"
  Revert "gpio: Rename free() to rfree()"
  Revert "reset: Rename free() to rfree()"
  Revert "power-domain: Rename free() to rfree()"
  Revert "mailbox: Rename free() to rfree()"

 drivers/clk/clk-ti-sci.c  |  2 +-
 drivers/clk/clk-uclass.c  |  4 +-
 drivers/clk/clk_sandbox.c |  2 +-
 drivers/clk/tegra/tegra-car-clk.c |  2 +-
 drivers/dma/dma-uclass.c  |  4 +-
 drivers/dma/sandbox-dma-test.c|  4 +-
 drivers/dma/ti/k3-udma.c  |  4 +-
 drivers/gpio/gpio-rcar.c  |  2 +-
 drivers/gpio/gpio-uclass.c|  8 ++--
 drivers/mailbox/k3-sec-proxy.c|  2 +-
 drivers/mailbox/mailbox-uclass.c  |  4 +-
 drivers/mailbox/sandbox-mbox.c|  2 +-
 drivers/mailbox/stm32-ipcc.c  |  2 +-
 drivers/mailbox/tegra-hsp.c   |  2 +-
 drivers/mtd/mtdcore.c |  4 +-
 drivers/mtd/nand/raw/denali.c |  2 +-
 drivers/mtd/nand/spi/core.c   |  2 +-
 drivers/mtd/nand/spi/gigadevice.c |  2 +-
 drivers/mtd/nand/spi/macronix.c   |  2 +-
 drivers/mtd/nand/spi/micron.c |  2 +-
 drivers/mtd/nand/spi/winbond.c|  2 +-
 drivers/power/domain/bcm6328-power-domain.c   |  2 +-
 .../power/domain/imx8-power-domain-legacy.c   |  2 +-
 drivers/power/domain/imx8-power-domain.c  |  2 +-
 drivers/power/domain/imx8m-power-domain.c |  2 +-
 drivers/power/domain/meson-ee-pwrc.c  |  2 +-
 drivers/power/domain/meson-gx-pwrc-vpu.c  |  2 +-
 drivers/power/domain/mtk-power-domain.c   |  2 +-
 drivers/power/domain/power-domain-uclass.c|  2 +-
 drivers/power/domain/sandbox-power-domain.c   |  2 +-
 drivers/power/domain/tegra186-power-domain.c  |  2 +-
 drivers/power/domain/ti-sci-power-domain.c|  2 +-
 drivers/reset/reset-bcm6345.c |  2 +-
 drivers/reset/reset-hisilicon.c   |  2 +-
 drivers/reset/reset-hsdk.c|  2 +-
 drivers/reset/reset-imx7.c|  2 +-
 drivers/reset/reset-mediatek.c|  2 +-
 drivers/reset/reset-meson.c   |  2 +-
 drivers/reset/reset-mtmips.c  |  2 +-
 drivers/reset/reset-rockchip.c|  2 +-
 drivers/reset/reset-socfpga.c |  2 +-
 drivers/reset/reset-sunxi.c   |  2 +-
 drivers/reset/reset-ti-sci.c  |  2 +-
 drivers/reset/reset-uclass.c  |  2 +-
 drivers/reset/reset-uniphier.c|  2 +-
 drivers/reset/sandbox-reset.c |  2 +-
 drivers/reset/sti-reset.c |  2 +-
 drivers/reset/stm32-reset.c   |  2 +-
 drivers/reset/tegra-car-reset.c   |  2 +-
 drivers/reset/tegra186-reset.c|  2 +-
 include/_exports.h|  2 +
 include/asm-generic/gpio.h|  2 +-
 include/clk-uclass.h  |  4 +-
 include/dma-uclass.h  |  4 +-
 include/exports.h |  2 +
 include/linux/mtd/mtd.h   |  4 +-
 include/mailbox-uclass.h  |  4 +-
 include/malloc.h  | 44 ---
 include/power-domain-uclass.h |  4 +-
 include/reset-uclass.h|  4 +-
 60 files changed, 105 insertions(+), 87 deletions(-)

-- 
2.20.1



Re: [PATCH 1/4 v5] watchdog: Implement generic watchdog_reset() version

2020-02-19 Thread Christophe Leroy




Le 25/04/2019 à 09:17, Stefan Roese a écrit :

This patch tries to implement a generic watchdog_reset() function that
can be used by all boards that want to service the watchdog device in
U-Boot. This watchdog servicing is enabled via CONFIG_WATCHDOG.

Without this approach, new boards or platforms needed to implement a
board specific version of this functionality, mostly copy'ing the same
code over and over again into their board or platforms code base.

With this new generic function, the scattered other functions are now
removed to be replaced by the generic one. The new version also enables
the configuration of the watchdog timeout via the DT "timeout-sec"
property (if enabled via CONFIG_OF_CONTROL).

This patch also adds a new flag to the GD flags, to flag that the
watchdog is ready to use and adds the pointer to the watchdog device
to the GD. This enables us to remove the global "watchdog_dev"
variable, which was prone to cause problems because of its potentially
very early use in watchdog_reset(), even before the BSS is cleared.

Signed-off-by: Stefan Roese 
Cc: Heiko Schocher 
Cc: Tom Rini 
Cc: Michal Simek 
Cc: "Marek Behún" 
Cc: Daniel Schwierzeck 
Cc: Maxim Sloyko 
Cc: Erik van Luijk 
Cc: Ryder Lee 
Cc: Weijie Gao 
Cc: Simon Glass 
Cc: "Álvaro Fernández Rojas" 
Cc: Philippe Reynes 
Cc: Christophe Leroy 
Cc: Chris Packham 
Reviewed-by: Michal Simek 
Tested-by: Michal Simek  (on zcu100)
---


[...]


diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 23b7e3360d..bbfac4f0f9 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -10,6 +10,8 @@
  #include 
  #include 
  
+DECLARE_GLOBAL_DATA_PTR;

+
  int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
  {
const struct wdt_ops *ops = device_get_ops(dev);
@@ -63,6 +65,30 @@ int wdt_expire_now(struct udevice *dev, ulong flags)
return ret;
  }
  
+#if defined(CONFIG_WATCHDOG)

+/*
+ * Called by macro WATCHDOG_RESET. This function be called *very* early,
+ * so we need to make sure, that the watchdog driver is ready before using
+ * it in this function.
+ */
+void watchdog_reset(void)
+{
+   static ulong next_reset;
+   ulong now;
+
+   /* Exit if GD is not ready or watchdog is not initialized yet */
+   if (!gd || !(gd->flags & GD_FLG_WDT_READY))
+   return;
+
+   /* Do not reset the watchdog too often */
+   now = get_timer(0);
+   if (now > next_reset) {
+   next_reset = now + 1000;/* reset every 1000ms */
+   wdt_reset(gd->watchdog_dev);
+   }


This is a problem for the MPC8xx.

When running with a MPC8xx at 132MHz clock, the watchdog will fire about 
1s after the last refresh. So the above makes the board unusable.


Is that really necessary to restrict the refresh like this in the core 
part of Watchdog driver ?



+}
+#endif
+
  static int wdt_post_bind(struct udevice *dev)
  {
  #if defined(CONFIG_NEEDS_MANUAL_RELOC)


Thanks,
Christophe


Re: [PATCH 3/4 v5] watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup

2020-02-19 Thread Christophe Leroy

Hi Stefan,

On 04/25/2019 07:17 AM, Stefan Roese wrote:

With the generic watchdog driver now implemented, this patch removes
some legacy stuff from the MPC8xx watchdog driver and its Kconfig
integration. CONFIG_MPC8xx_WATCHDOG is completely removed and
hw_watchdog_reset() is made static, as the watchdog will now get
serviced via the DM infrastructure if enabled via CONFIG_WATCHDOG.

Signed-off-by: Stefan Roese 
Cc: Christophe Leroy 
---
v5:
- No change

v4:
- New patch

arch/powerpc/Kconfig| 2 +-
  arch/powerpc/cpu/mpc8xx/Kconfig | 6 +++---
  drivers/watchdog/Kconfig| 1 -
  drivers/watchdog/Makefile   | 2 +-
  drivers/watchdog/mpc8xx_wdt.c   | 4 +---
  5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c727d9162c..0b1629ba62 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -35,7 +35,7 @@ config MPC8xx
bool "MPC8xx"
select BOARD_EARLY_INIT_F
imply CMD_REGINFO
-   imply MPC8xx_WATCHDOG
+   imply WDT_MPC8xx
  
  endchoice
  
diff --git a/arch/powerpc/cpu/mpc8xx/Kconfig b/arch/powerpc/cpu/mpc8xx/Kconfig

index b0e90a0f20..3e8ea38529 100644
--- a/arch/powerpc/cpu/mpc8xx/Kconfig
+++ b/arch/powerpc/cpu/mpc8xx/Kconfig
@@ -25,9 +25,9 @@ config MPC885
  
  endchoice
  
-config MPC8xx_WATCHDOG

-   bool "Watchdog"
-   select HW_WATCHDOG
+#config MPC8xx_WATCHDOG
+#  bool "Watchdog"
+#  select HW_WATCHDOG


If HW_WATCHDOG is not selected, we have a problem in cpu_init_f() 
(arch/powerpc/cpu/mpc8xx/cpu_init.c) with the following line, and the 
board with restart every second.


#ifndef CONFIG_HW_WATCHDOG
/* deactivate watchdog if not enabled in config */
out_be32(&immr->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE);
#endif

Should this be changed to use CONFIG_WATCHDOG instead ?


  
  config 8xx_GCLK_FREQ

int "CPU GCLK Frequency"
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index aa8e725573..3bce0aa0b8 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -151,7 +151,6 @@ config WDT_MT7621
  config WDT_MPC8xx
bool "MPC8xx watchdog timer support"
depends on WDT && MPC8xx
-   select CONFIG_MPC8xx_WATCHDOG


This is brought back by a later patch from Patrice. Unwanted I guess ?

Christophe


Unwanted change in Kconfig for mpc8xx_wdt watchdog ?

2020-02-19 Thread Christophe Leroy

Hello Patrice,


In commit b3134ffbd9 ("watchdog: Kconfig: Sort entry alphabetically") 
you bring back the line "select CONFIG_MPC8xx_WATCHDOG" removed by 
Stefan in commit f3729ba6e7 ("watchdog: mpc8xx_wdt: Watchdog driver and 
macros cleanup") three weeks before.


Was that wanted ?

Thanks
Christophe


[PATCH V2] ARM: socfpga: Add initial support for the ABB SECU board

2020-02-19 Thread Marek Vasut
From: Holger Brunck 

Add initial support for the ABB SECU board, which is an ArriaV-based
SoCFPGA system with ethernet and booting from Denali NAND.

Signed-off-by: Holger Brunck 
Cc: Ley Foon Tan 
Cc: Simon Goldschmidt 
---
V2: Use CONFIG_SYS_I2C_EEPROM_ADDR in printf() in ivm.c
Enable CONFIG_SYS_NAND_USE_FLASH_BBT
---
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/socfpga_arria5_secu1.dts   | 130 +
 arch/arm/mach-socfpga/Kconfig   |  10 +
 board/keymile/Kconfig   |  11 +-
 board/keymile/common/ivm.c  |  19 +-
 board/keymile/secu1/Makefile|   7 +
 board/keymile/secu1/qts/iocsr_config.h  | 694 
 board/keymile/secu1/qts/pinmux_config.h | 218 
 board/keymile/secu1/qts/pll_config.h|  83 +++
 board/keymile/secu1/qts/sdram_config.h  | 327 +++
 board/keymile/secu1/socfpga.c   |  67 +++
 configs/socfpga_secu1_defconfig |  84 +++
 include/configs/socfpga_arria5_secu1.h  | 131 +
 13 files changed, 1778 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_arria5_secu1.dts
 create mode 100644 board/keymile/secu1/Makefile
 create mode 100644 board/keymile/secu1/qts/iocsr_config.h
 create mode 100644 board/keymile/secu1/qts/pinmux_config.h
 create mode 100644 board/keymile/secu1/qts/pll_config.h
 create mode 100644 board/keymile/secu1/qts/sdram_config.h
 create mode 100644 board/keymile/secu1/socfpga.c
 create mode 100644 configs/socfpga_secu1_defconfig
 create mode 100644 include/configs/socfpga_arria5_secu1.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index be4cf029d0..9c593b2c98 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -333,6 +333,7 @@ dtb-$(CONFIG_THUNDERX) += thunderx-88xx.dtb
 
 dtb-$(CONFIG_ARCH_SOCFPGA) +=  \
socfpga_agilex_socdk.dtb\
+   socfpga_arria5_secu1.dtb\
socfpga_arria5_socdk.dtb\
socfpga_arria10_socdk_sdmmc.dtb \
socfpga_cyclone5_mcvevk.dtb \
diff --git a/arch/arm/dts/socfpga_arria5_secu1.dts 
b/arch/arm/dts/socfpga_arria5_secu1.dts
new file mode 100644
index 00..dadf766682
--- /dev/null
+++ b/arch/arm/dts/socfpga_arria5_secu1.dts
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2016-2020 ABB
+ */
+
+#include "socfpga_arria5.dtsi"
+#include "socfpga-common-u-boot.dtsi"
+#include 
+
+/ {
+   model = "ABB SoC SECU1 Board";
+   compatible = "altr,socfpga-secu1", "altr,socfpga";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   bootargs = "console=ttyS0,115200";
+   };
+
+   memory {
+   name = "memory";
+   device_type = "memory";
+   reg = <0x0 0x2000>; /* 512MB */
+   };
+
+   aliases {
+   /*
+* this allow the ethaddr uboot environment variable contents
+* to be added to the gmac0 device tree blob.
+*/
+   ethernet0 = &gmac0;
+   spi0 = &spi1;
+   };
+
+   i2c_gpio: i2c@0 {
+   compatible = "i2c-gpio";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   gpios = <&portc 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)/* SDA 
*/
+&portc 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;  /* SCL 
*/
+   i2c-gpio,delay-us = <5>;/* ~100 kHz */
+   i2c-gpio,deblock;
+
+   temp_sensor@48 {
+   compatible = "national,lm75";
+   reg = <0x48>;
+   };
+
+   eeprom@50 {
+   compatible = "at,24c08";
+   reg = <0x50>;
+   };
+
+   rtc: rtc@68 {
+   compatible = "st,m41st87";
+   reg = <0x68>;
+   interrupt-parent = <&intc>;
+   interrupts = <0 42 0x4>;
+   };
+   };
+
+   regulator_3_3v: 3-3-v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+&gmac0 {
+   status = "okay";
+   phy-mode = "rgmii";
+   fixed-link {
+   speed = <1000>;
+   full-duplex;
+   };
+};
+
+&gpio0 {
+   status = "okay";
+};
+
+&gpio1 {
+   status = "okay";
+};
+
+&gpio2 {
+   status = "okay";
+};
+
+&mmc0 {
+   vmmc-supply = <®ulator_3_3v>;
+   vqmmc-supply = <®ulator_3_3v>;
+   bus-width = <4>;
+   u-boot,dm-pre-reloc;
+};
+
+&nand0 {
+   status = "okay";
+};
+
+&porta {
+   bank-name = "porta";
+};
+
+&portb {
+   bank-name = "portb";
+};
+
+&portc {
+   bank-name = "portc";
+};
+
+&spi1

[RFC PATCH 1/2] common: fdt: Add a function for reserving memory without kernel linear mapping

2020-02-19 Thread Michael Trimarchi
We need to reserve memory and not put in kernel linear mapping.
This avoid problem during memory remapping from the simple
frame buffer in linux kernel

Signed-off-by: Michael Trimarchi 
---
 common/fdt_support.c  | 40 
 include/fdt_support.h | 11 +++
 2 files changed, 51 insertions(+)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 02cf5c6241..a3662f4358 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 
*address, u64 *size,
return p - (char *)buf;
 }
 
+int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 
size[])
+{
+   int offs, len;
+   const char *subpath;
+   const char *path = "/reserved-memory";
+   fdt32_t address_cells = cpu_to_fdt32(fdt_address_cells(blob, 0));
+   fdt32_t size_cells = cpu_to_fdt32(fdt_size_cells(blob, 0));
+   u8 temp[16]; /* Up to 64-bit address + 64-bit size */
+
+   offs = fdt_path_offset(blob, path);
+   if (offs < 0) {
+   debug("Node %s not found\n", path);
+   path = "/";
+   subpath = "reserved-memory";
+   offs = fdt_path_offset(blob, path);
+   offs = fdt_add_subnode(blob, offs, subpath);
+   if (offs < 0) {
+   printf("Could not create %s%s node.\n", path, subpath);
+   return -1;
+   }
+   path = "/reserved-memory";
+   offs = fdt_path_offset(blob, path);
+
+   fdt_setprop(blob, offs, "#address-cells", &address_cells, 
sizeof(address_cells));
+   fdt_setprop(blob, offs, "#size-cells", &size_cells, 
sizeof(size_cells));
+   fdt_setprop(blob, offs, "ranges", NULL, 0);
+   }
+
+   offs = fdt_add_subnode(blob, offs, area ? : "private");
+   if (offs < 0) {
+   printf("Could not create %s%s node.\n", path, subpath);
+   return -1;
+   }
+
+   fdt_setprop(blob, offs, "no-map", NULL, 0);
+   len = fdt_pack_reg(blob, temp, start, size, 1);
+   fdt_setprop(blob, offs, "reg", temp, len);
+   return 0;
+}
+
 #if CONFIG_NR_DRAM_BANKS > 4
 #define MEMORY_BANKS_MAX CONFIG_NR_DRAM_BANKS
 #else
diff --git a/include/fdt_support.h b/include/fdt_support.h
index ba14acd7f6..7c8a280f53 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -93,6 +93,17 @@ void do_fixup_by_compat_u32(void *fdt, const char *compat,
  */
 int fdt_fixup_memory(void *blob, u64 start, u64 size);
 
+/**
+ * Setup the memory reserved node in the DT. Creates one if none was existing 
before.
+ *
+ * @param blob FDT blob to update
+ * @param area Reserved area name
+ * @param startBegin of DRAM mapping in physical memory
+ * @param size Size of the single memory bank
+ * @return 0 if ok, or -1 or -FDT_ERR_... on error
+ */
+int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 
size[]);
+
 /**
  * Fill the DT memory node with multiple memory banks.
  * Creates the node if none was existing before.
-- 
2.17.1



[RFC PATCH 2/2] video: meson: Use reserving memory function without kernel linear mapping

2020-02-19 Thread Michael Trimarchi
Memory reserved for the simple framebuffer should not be used
and part of memory linear mapping

Signed-off-by: Michael Trimarchi 
---
 drivers/video/meson/meson_vpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/meson/meson_vpu.c b/drivers/video/meson/meson_vpu.c
index 4eb66398d0..134e011b82 100644
--- a/drivers/video/meson/meson_vpu.c
+++ b/drivers/video/meson/meson_vpu.c
@@ -173,9 +173,9 @@ static void meson_vpu_setup_simplefb(void *fdt)
 * at the end of the RAM and we strip this portion from the kernel
 * allowed region
 */
-   mem_start = gd->bd->bi_dram[0].start;
-   mem_size = gd->bd->bi_dram[0].size - meson_fb.fb_size;
-   ret = fdt_fixup_memory_banks(fdt, &mem_start, &mem_size, 1);
+   mem_start = meson_fb.base;
+   mem_size = meson_fb.fb_size;
+   ret = fdt_fixup_reserved_memory(blob, "display_reserved", &mem_start, 
&mem_size);
if (ret) {
eprintf("Cannot setup simplefb: Error reserving memory\n");
return;
-- 
2.17.1



[RFC PATCH 0/2] Update reserved memory for simple framebuffer

2020-02-19 Thread Michael Trimarchi
Reserved memory for simple frame buffer should be created in a different
way:

+   aliases {
+   display0 = &lcdif;
+   };
+
+   reserved-memory {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   display_reserved: framebuffer@86fa2000 {
+   reg = <0x86fa2000 0x8>;
+   no-map;
+   };
+
+   };

We add a function to change the loaded dts and inject those information.
I have added another patch for meson. Right now I'm testing on tinker-s
board

Michael Trimarchi (2):
  common: fdt: Add a function for reserving memory without kernel linear
mapping
  video: meson: Use reserving memory function without kernel linear
mapping

 common/fdt_support.c| 40 +
 drivers/video/meson/meson_vpu.c |  6 ++---
 include/fdt_support.h   | 11 +
 3 files changed, 54 insertions(+), 3 deletions(-)

-- 
2.17.1



  1   2   >