Re: [PATCH 5/5] Makefile: Add provision for embedding public key in platform's dtb

2021-04-27 Thread AKASHI Takahiro
On Thu, Apr 08, 2021 at 09:58:17PM +0200, Heinrich Schuchardt wrote:
> On 4/7/21 1:53 PM, Sughosh Ganu wrote:
> > Add provision for embedding the public key used for capsule
> > authentication in the platform's dtb. This is done by invoking the
> > mkeficapsule utility which puts the public key in the efi signature
> > list(esl) format into the dtb.
> > 
> > Signed-off-by: Sughosh Ganu 
> > ---
> >   Makefile | 10 ++
> >   1 file changed, 10 insertions(+)
> > 
> > diff --git a/Makefile b/Makefile
> > index 193aa4d1c9..0d50c6a805 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1010,6 +1010,10 @@ cmd_pad_cat = $(cmd_objcopy) && $(append) || { rm -f 
> > $@; false; }
> >   quiet_cmd_lzma = LZMA$@
> >   cmd_lzma = lzma -c -z -k -9 $< > $@
> > 
> > +quiet_cmd_mkeficapsule = MKEFICAPSULE $@
> > +cmd_mkeficapsule = $(objtree)/tools/mkeficapsule -K 
> > $(CONFIG_EFI_PKEY_FILE) \
> > +   -D $@
> > +
> 
> tools/mkeficapsule --help does neither show a parameter -K nor a
> parameter -D.

This clearly shows that the feature with -K/-D has nothing to do with
creating a capsule file.
Two totally different things in one place (command).
And the dtb overlay operation can be achieved by using standard commands.

I believe that the feature should be removed from mkeficapsule.

-Takahiro Akashi


> Please, update tools/mkeficapsule.c before using these. A
> man-page for mkeficapsule in doc/usage/ would be helpful.
> 
> $ tools/mkeficapsule --help
> Usage: mkeficapsule [options] 
> Options:
> --fitnew FIT image file
> --rawnew raw image file
> --index  update image index
> --instanceupdate hardware instance
> --public-key  public key esl file
> --dtb dtb file
> --overlay   the dtb file is an overlay
> --help  print a help message
> 
> Best regards
> 
> Heinrich
> 
> >   cfg: u-boot.cfg
> > 
> >   quiet_cmd_cfgcheck = CFGCHK  $2
> > @@ -1104,8 +1108,14 @@ endif
> >   PHONY += dtbs
> >   dtbs: dts/dt.dtb
> > @:
> > +ifeq ($(CONFIG_EFI_CAPSULE_AUTHENTICATE)$(CONFIG_EFI_PKEY_DTB_EMBED),yy)
> > +dts/dt.dtb: u-boot tools
> > +   $(Q)$(MAKE) $(build)=dts dtbs
> > +   $(call cmd,mkeficapsule)
> > +else
> >   dts/dt.dtb: u-boot
> > $(Q)$(MAKE) $(build)=dts dtbs
> > +endif
> > 
> >   quiet_cmd_copy = COPY$@
> > cmd_copy = cp $< $@
> > 
> 


Re: [PATCH v2 4/4] Makefile: Add provision for embedding public key in platform's dtb

2021-04-27 Thread AKASHI Takahiro
On Mon, Apr 12, 2021 at 08:35:26PM +0530, Sughosh Ganu wrote:
> Add provision for embedding the public key used for capsule
> authentication in the platform's dtb. This is done by invoking the
> mkeficapsule utility which puts the public key in the efi signature
> list(esl) format into the dtb.
> 
> Signed-off-by: Sughosh Ganu 
> ---
> 
> Changes since V1: None
> 
>  Makefile | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index b72d8d20c0..ebd4a6477c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1011,6 +1011,10 @@ cmd_pad_cat = $(cmd_objcopy) && $(append) || { rm -f 
> $@; false; }
>  quiet_cmd_lzma = LZMA$@
>  cmd_lzma = lzma -c -z -k -9 $< > $@
>  
> +quiet_cmd_mkeficapsule = MKEFICAPSULE $@
> +cmd_mkeficapsule = $(objtree)/tools/mkeficapsule -K $(CONFIG_EFI_PKEY_FILE) \
> + -D $@

Instead, we can do

$ dtc -@ -I dts -O dtb -o pubkey.dtbo pubkey.dts
$ fdtoverlay -i test.dtb -o test_pubkey.dtb -v pubkey.dtbo

-Takahiro Akashi


> +
>  cfg: u-boot.cfg
>  
>  quiet_cmd_cfgcheck = CFGCHK  $2
> @@ -1161,8 +1165,14 @@ endif
>  PHONY += dtbs
>  dtbs: dts/dt.dtb
>   @:
> +ifeq ($(CONFIG_EFI_CAPSULE_AUTHENTICATE)$(CONFIG_EFI_PKEY_DTB_EMBED),yy)
> +dts/dt.dtb: u-boot tools
> + $(Q)$(MAKE) $(build)=dts dtbs
> + $(call cmd,mkeficapsule)
> +else
>  dts/dt.dtb: u-boot
>   $(Q)$(MAKE) $(build)=dts dtbs
> +endif
>  
>  quiet_cmd_copy = COPY$@
>cmd_copy = cp $< $@
> -- 
> 2.17.1
> 


Re: [PATCH v2 3/4] efi_capsule: Add a function to get the public key needed for capsule authentication

2021-04-27 Thread AKASHI Takahiro
Simon,

On Mon, Apr 12, 2021 at 08:35:25PM +0530, Sughosh Ganu wrote:
> Define a function which would be used in the scenario where the
> public key is stored on the platform's dtb. This dtb is concatenated
> with the u-boot binary during the build process. Platforms which have
> a different mechanism for getting the public key would define their
> own platform specific function under a different Kconfig symbol.
> 
> Signed-off-by: Sughosh Ganu 
> ---
> 
> Changes since V1:
> * Remove the weak function, and add the functionality to retrieve the
>   public key under the config symbol CONFIG_EFI_PKEY_DTB_EMBED.
> 
>  lib/efi_loader/efi_capsule.c | 43 +++-
>  1 file changed, 38 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
> index 2cc8f2dee0..d95e9377fe 100644
> --- a/lib/efi_loader/efi_capsule.c
> +++ b/lib/efi_loader/efi_capsule.c
> @@ -14,10 +14,13 @@
>  #include 
>  #include 
>  
> +#include 
>  #include 
>  #include 
>  #include 
>  
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
>  static const efi_guid_t efi_guid_firmware_management_capsule_id =
>   EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
> @@ -208,15 +211,45 @@ skip:
>  const efi_guid_t efi_guid_capsule_root_cert_guid =
>   EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
>  
> -__weak int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
> +#if defined(CONFIG_EFI_PKEY_DTB_EMBED)
> +int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
>  {
> - /* The platform is supposed to provide
> -  * a method for getting the public key
> -  * stored in the form of efi signature
> -  * list
> + /*
> +  * This is a function for retrieving the public key from the
> +  * platform's device tree. The platform's device tree has been
> +  * concatenated with the u-boot binary.
> +  * If a platform has a different mechanism to get the public
> +  * key, it can define it's own kconfig symbol and define a
> +  * function to retrieve the public key
>*/
> + const void *fdt_blob = gd->fdt_blob;
> + const void *blob;
> + const char *cnode_name = "capsule-key";
> + const char *snode_name = "signature";

# Again, "key" is not the best word to describe the value.

The syntax assumed here in a device tree (control FDT) is;
/ {
   signature {
   capsule-key = "...";
   };
   ...
};

"signature" node is already used as a directory to hold public keys
for FIT image verification (vboot).
(doc/uImage.FIT/signature.txt)

While it is unlikely that both EFI capsule authentication and
FIT image authentication are enabled at the same time, I'm a bit
concerned if the mixture of different contents might cause
some confusion.
For instance, "required-mode" which has nothing to do with UEFI capsule
may exist directly under "signagture."

Do you have any thoughts?

-Takahiro Akashi

> + int sig_node;
> + int len;
> +
> + sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
> + if (sig_node < 0) {
> + EFI_PRINT("Unable to get signature node offset\n");
> + return -FDT_ERR_NOTFOUND;
> + }
> +
> + blob = fdt_getprop(fdt_blob, sig_node, cnode_name, );
> +
> + if (!blob || len < 0) {
> + EFI_PRINT("Unable to get capsule-key value\n");
> + *pkey = NULL;
> + *pkey_len = 0;
> + return -FDT_ERR_NOTFOUND;
> + }
> +
> + *pkey = (void *)blob;
> + *pkey_len = len;
> +
>   return 0;
>  }
> +#endif /* CONFIG_EFI_PKEY_DTB_EMBED */
>  
>  efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t 
> capsule_size,
> void **image, efi_uintn_t *image_size)
> -- 
> 2.17.1
> 


Re: Kirkwood: Fix tv sec/usec normalization in kwboot

2021-04-27 Thread Stefan Roese

On 27.04.21 21:57, Dagan Martinez wrote:

 From 328c559acf6872bf0cbafe7fbb881748d5c753fb Mon Sep 17 00:00:00 2001
From: Property404 
Date: Tue, 27 Apr 2021 15:48:31 -0400
Subject: [PATCH] Kirkwood: Fix tv sec/usec normalization in kwboot

`kwboot.c` had an issue where it failed to normalize the `tv` struct in
the case where the `tv_usec` field was 100, ie one second.

This caused issues on Fedora Linux 34, where `select` would return
`EINVAL`, preventing kwboot from communicating with the board.

Signed-off-by: Property404 
---
  tools/kwboot.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 4be094c9c8..5d5d501d36 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -167,7 +167,7 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)

  tv.tv_sec = 0;
  tv.tv_usec = timeo * 1000;
-if (tv.tv_usec > 100) {
+if (tv.tv_usec >= 100) {
  tv.tv_sec += tv.tv_usec / 100;
  tv.tv_usec %= 100;
  }



Reviewed-by: Stefan Roese 

BTW: I'm not 100% sure, but my understanding is that it is preferred (or
even required) to provide a "real name" in the tags. So it might be that
"Property404" is not enough here.

Thanks,
Stefan


Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Stefan Roese

On 28.04.21 04:12, Li, Meng wrote:




-Original Message-
From: Sean Anderson 
Sent: Tuesday, April 27, 2021 10:50 PM
To: Stefan Roese ; Li, Meng ; u-
b...@lists.denx.de; chin.liang@intel.com; dinh.ngu...@intel.com;
s...@chromium.org
Subject: Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in
designware_wdt_stop() function

[Please note: This e-mail is from an EXTERNAL e-mail address]

On 4/27/21 10:23 AM, Stefan Roese wrote:
  > On 27.04.21 10:41, meng...@windriver.com wrote:
  >> From: MengLi   >>  >> In uboot command line
environment, watchdog is not able to be  >> stopped with below commands:
  >> SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200  >>
SOCFPGA_STRATIX10 # wdt stop  >> Refer to watchdog driver in linux kernel,
it is also need to reset  >> watchdog after disable it so that the disable 
action
takes effect.
  >>
  >> v2:
  >> Change "#if CONFIG_IS_ENABLED(DM_RESET)" into  >> "if
(CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable  >> into if
condition sentence.
  >
  > A few comments:
  >
  > This version changelog belongs below the "---" line.
  >
  > Please Cc interested people upon new versions, e.g. myself as I reviewed  >
this patch.
  >
  > Other that this:
  >
  > Reviewed-by: Stefan Roese   >  > Thanks,  > Stefan  >  >>
Signed-off-by: Meng Li   >> ---
  >>   drivers/watchdog/designware_wdt.c | 17 +
  >>   1 file changed, 17 insertions(+)
  >>
  >> diff --git a/drivers/watchdog/designware_wdt.c
b/drivers/watchdog/designware_wdt.c
  >> index 12f09a7a39..57cad1effc 100644
  >> --- a/drivers/watchdog/designware_wdt.c
  >> +++ b/drivers/watchdog/designware_wdt.c
  >> @@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice
*dev)
  >>   designware_wdt_reset(dev);
  >>   writel(0, priv->base + DW_WDT_CR);
  >> +if (CONFIG_IS_ENABLED(DM_RESET)) {
  >> +struct reset_ctl_bulk resets;
  >> +int ret;
  >> +
  >> +ret = reset_get_bulk(dev, );

Have you considered adding the resets to designware_wdt_priv and saving
them when we request them in probe()?



Yes! thanks for reminding me.


Yes. Since the reset gets referenced multiple times (with your addition
now), this absolutely makes sense.


But I want to fix this issue by modifying the minimum range code.
Because I and not the original person of creating this driver.
I don't want to other part of code if it is not essential.


That's not the way this open source development works. Please make the
suggested changes and submit the patch for review. The review process
with potential tests should catch potential issues.

Thanks,
Stefan


Thanks,
Limeng


--Sean

  >> +if (ret)
  >> +return ret;
  >> +
  >> +ret = reset_assert_bulk();
  >> +if (ret)
  >> +return ret;
  >> +
  >> +ret = reset_deassert_bulk();
  >> +if (ret)
  >> +return ret;
  >> +}
  >> +
  >>   return 0;
  >>   }
  >>
  >
  >
  > Viele Grüße,
  > Stefan
  >



Viele Grüße,
Stefan

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


Re: [PATCH v2 2/4] efi_loader: Kconfig: Add symbols for embedding the public key into the platform's dtb

2021-04-27 Thread AKASHI Takahiro
On Wed, Apr 28, 2021 at 01:55:18PM +0900, AKASHI Takahiro wrote:
> On Sun, Apr 25, 2021 at 09:24:39AM +0200, Heinrich Schuchardt wrote:
> > On 4/12/21 5:05 PM, Sughosh Ganu wrote:
> > > Add config options EFI_PKEY_DTB_EMBED and EFI_PKEY_FILE which are to
> > > be used for embedding the public key to be used for capsule
> > > authentication into the platform's device tree.
> > > 
> > > The embedding of the public key would take place during the platform
> > > build process.
> > > 
> > > Signed-off-by: Sughosh Ganu 
> > > ---
> > > 
> > > Changes since V1:
> > > * Provide a default name for public key file, eficapsule.esl as
> > >suggested by Heinrich.
> > > * Remove the superfluous default n statement for EFI_PKEY_DTB_EMBED
> > > 
> > >   lib/efi_loader/Kconfig | 15 +++
> > >   1 file changed, 15 insertions(+)
> > > 
> > > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > > index 79b488823a..089acc 100644
> > > --- a/lib/efi_loader/Kconfig
> > > +++ b/lib/efi_loader/Kconfig
> > > @@ -179,6 +179,21 @@ config EFI_CAPSULE_AUTHENTICATE
> > > Select this option if you want to enable capsule
> > > authentication
> > > 
> > > +config EFI_PKEY_DTB_EMBED
> > > + bool "Embed the public key in the Device Tree"
> > > + depends on EFI_CAPSULE_AUTHENTICATE
> > > + help
> > > +   Select this option if the public key used for capsule
> > > +   authentication is to be embedded into the platform's
> > > +   device tree.
> > > +
> > > +config EFI_PKEY_FILE
> > > + string "Public Key esl file to be embedded into the Device Tree"
> > > + default "eficapsule.esl"
> > 
> > This config symbol should depend on EFI_PKEY_DTB_EMBED.
> 
> What is embedded here is a *list* of X509 certificate, not a single public 
> key.
> "esl" stands for EFI Signature List.
> The symbol name as well as help text are confusing.

In addition, "signature" means a hash value of image
as well as X509 in UEFI terms.
So as far as we use efi_signature_verify(), any type of
"signature" will be allowed.

We must be clear here.

-Takahiro Akashi


> -Takahiro Akashi
> 
> > Best regards
> > 
> > Heinrich
> > 
> > > + help
> > > +   Specify the absolute path of the public key esl file that is
> > > +   to be embedded in the platform's device tree.
> > > +
> > >   config EFI_CAPSULE_FIRMWARE_FIT
> > >   bool "FMP driver for FIT image"
> > >   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
> > > 
> > 


Re: [PATCH v2 2/4] efi_loader: Kconfig: Add symbols for embedding the public key into the platform's dtb

2021-04-27 Thread AKASHI Takahiro
On Sun, Apr 25, 2021 at 09:24:39AM +0200, Heinrich Schuchardt wrote:
> On 4/12/21 5:05 PM, Sughosh Ganu wrote:
> > Add config options EFI_PKEY_DTB_EMBED and EFI_PKEY_FILE which are to
> > be used for embedding the public key to be used for capsule
> > authentication into the platform's device tree.
> > 
> > The embedding of the public key would take place during the platform
> > build process.
> > 
> > Signed-off-by: Sughosh Ganu 
> > ---
> > 
> > Changes since V1:
> > * Provide a default name for public key file, eficapsule.esl as
> >suggested by Heinrich.
> > * Remove the superfluous default n statement for EFI_PKEY_DTB_EMBED
> > 
> >   lib/efi_loader/Kconfig | 15 +++
> >   1 file changed, 15 insertions(+)
> > 
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 79b488823a..089acc 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -179,6 +179,21 @@ config EFI_CAPSULE_AUTHENTICATE
> >   Select this option if you want to enable capsule
> >   authentication
> > 
> > +config EFI_PKEY_DTB_EMBED
> > +   bool "Embed the public key in the Device Tree"
> > +   depends on EFI_CAPSULE_AUTHENTICATE
> > +   help
> > + Select this option if the public key used for capsule
> > + authentication is to be embedded into the platform's
> > + device tree.
> > +
> > +config EFI_PKEY_FILE
> > +   string "Public Key esl file to be embedded into the Device Tree"
> > +   default "eficapsule.esl"
> 
> This config symbol should depend on EFI_PKEY_DTB_EMBED.

What is embedded here is a *list* of X509 certificate, not a single public key.
"esl" stands for EFI Signature List.
The symbol name as well as help text are confusing.

-Takahiro Akashi

> Best regards
> 
> Heinrich
> 
> > +   help
> > + Specify the absolute path of the public key esl file that is
> > + to be embedded in the platform's device tree.
> > +
> >   config EFI_CAPSULE_FIRMWARE_FIT
> > bool "FMP driver for FIT image"
> > depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
> > 
> 


Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Stefan Roese

On 28.04.21 04:15, Li, Meng wrote:




-Original Message-
From: Stefan Roese 
Sent: Tuesday, April 27, 2021 10:23 PM
To: Li, Meng ; u-boot@lists.denx.de;
chin.liang@intel.com; dinh.ngu...@intel.com; s...@chromium.org
Subject: Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in
designware_wdt_stop() function

[Please note: This e-mail is from an EXTERNAL e-mail address]

On 27.04.21 10:41, meng...@windriver.com wrote:

From: MengLi 

In uboot command line environment, watchdog is not able to be stopped
with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

v2:
Change "#if CONFIG_IS_ENABLED(DM_RESET)" into "if
(CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable into if
condition sentence.


A few comments:

This version changelog belongs below the "---" line.

Please Cc interested people upon new versions, e.g. myself as I reviewed
this patch.

Other that this:

Reviewed-by: Stefan Roese 



Would you like me to add "Cc:" into comment log, too? Or only CC to
you in mail list?


That's up to you. But when you put the Cc: in the commit text (below
the Reviewed-by tag), then "git send-email" will automatically Cc all
listed addresses.

Thanks,
Stefan


Thanks,
Limeng


Thanks,
Stefan


Signed-off-by: Meng Li 
---
   drivers/watchdog/designware_wdt.c | 17 +
   1 file changed, 17 insertions(+)

diff --git a/drivers/watchdog/designware_wdt.c
b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..57cad1effc 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice *dev)
   designware_wdt_reset(dev);
   writel(0, priv->base + DW_WDT_CR);

+if (CONFIG_IS_ENABLED(DM_RESET)) {
+ struct reset_ctl_bulk resets;
+ int ret;
+
+ ret = reset_get_bulk(dev, );
+ if (ret)
+ return ret;
+
+ ret = reset_assert_bulk();
+ if (ret)
+ return ret;
+
+ ret = reset_deassert_bulk();
+ if (ret)
+ return ret;
+ }
+
   return 0;
   }





Viele Grüße,
Stefan

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



Viele Grüße,
Stefan

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


RE: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Li, Meng


> -Original Message-
> From: Stefan Roese 
> Sent: Tuesday, April 27, 2021 10:23 PM
> To: Li, Meng ; u-boot@lists.denx.de;
> chin.liang@intel.com; dinh.ngu...@intel.com; s...@chromium.org
> Subject: Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in
> designware_wdt_stop() function
> 
> [Please note: This e-mail is from an EXTERNAL e-mail address]
> 
> On 27.04.21 10:41, meng...@windriver.com wrote:
> > From: MengLi 
> >
> > In uboot command line environment, watchdog is not able to be stopped
> > with below commands:
> > SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
> > SOCFPGA_STRATIX10 # wdt stop
> > Refer to watchdog driver in linux kernel, it is also need to reset
> > watchdog after disable it so that the disable action takes effect.
> >
> > v2:
> > Change "#if CONFIG_IS_ENABLED(DM_RESET)" into "if
> > (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable into if
> > condition sentence.
> 
> A few comments:
> 
> This version changelog belongs below the "---" line.
> 
> Please Cc interested people upon new versions, e.g. myself as I reviewed
> this patch.
> 
> Other that this:
> 
> Reviewed-by: Stefan Roese 
> 

Would you like me to add "Cc:" into comment log, too? Or only CC to you in mail 
list?

Thanks,
Limeng

> Thanks,
> Stefan
> 
> > Signed-off-by: Meng Li 
> > ---
> >   drivers/watchdog/designware_wdt.c | 17 +
> >   1 file changed, 17 insertions(+)
> >
> > diff --git a/drivers/watchdog/designware_wdt.c
> > b/drivers/watchdog/designware_wdt.c
> > index 12f09a7a39..57cad1effc 100644
> > --- a/drivers/watchdog/designware_wdt.c
> > +++ b/drivers/watchdog/designware_wdt.c
> > @@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice *dev)
> >   designware_wdt_reset(dev);
> >   writel(0, priv->base + DW_WDT_CR);
> >
> > +if (CONFIG_IS_ENABLED(DM_RESET)) {
> > + struct reset_ctl_bulk resets;
> > + int ret;
> > +
> > + ret = reset_get_bulk(dev, );
> > + if (ret)
> > + return ret;
> > +
> > + ret = reset_assert_bulk();
> > + if (ret)
> > + return ret;
> > +
> > + ret = reset_deassert_bulk();
> > + if (ret)
> > + return ret;
> > + }
> > +
> >   return 0;
> >   }
> >
> >
> 
> 
> Viele Grüße,
> Stefan
> 
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: s...@denx.de


RE: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Li, Meng


> -Original Message-
> From: Sean Anderson 
> Sent: Tuesday, April 27, 2021 10:50 PM
> To: Stefan Roese ; Li, Meng ; u-
> b...@lists.denx.de; chin.liang@intel.com; dinh.ngu...@intel.com;
> s...@chromium.org
> Subject: Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in
> designware_wdt_stop() function
> 
> [Please note: This e-mail is from an EXTERNAL e-mail address]
> 
> On 4/27/21 10:23 AM, Stefan Roese wrote:
>  > On 27.04.21 10:41, meng...@windriver.com wrote:
>  >> From: MengLi   >>  >> In uboot command line
> environment, watchdog is not able to be  >> stopped with below commands:
>  >> SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200  >>
> SOCFPGA_STRATIX10 # wdt stop  >> Refer to watchdog driver in linux kernel,
> it is also need to reset  >> watchdog after disable it so that the disable 
> action
> takes effect.
>  >>
>  >> v2:
>  >> Change "#if CONFIG_IS_ENABLED(DM_RESET)" into  >> "if
> (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable  >> into if
> condition sentence.
>  >
>  > A few comments:
>  >
>  > This version changelog belongs below the "---" line.
>  >
>  > Please Cc interested people upon new versions, e.g. myself as I reviewed  >
> this patch.
>  >
>  > Other that this:
>  >
>  > Reviewed-by: Stefan Roese   >  > Thanks,  > Stefan  >  >>
> Signed-off-by: Meng Li   >> ---
>  >>   drivers/watchdog/designware_wdt.c | 17 +
>  >>   1 file changed, 17 insertions(+)
>  >>
>  >> diff --git a/drivers/watchdog/designware_wdt.c
> b/drivers/watchdog/designware_wdt.c
>  >> index 12f09a7a39..57cad1effc 100644
>  >> --- a/drivers/watchdog/designware_wdt.c
>  >> +++ b/drivers/watchdog/designware_wdt.c
>  >> @@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice
> *dev)
>  >>   designware_wdt_reset(dev);
>  >>   writel(0, priv->base + DW_WDT_CR);
>  >> +if (CONFIG_IS_ENABLED(DM_RESET)) {
>  >> +struct reset_ctl_bulk resets;
>  >> +int ret;
>  >> +
>  >> +ret = reset_get_bulk(dev, );
> 
> Have you considered adding the resets to designware_wdt_priv and saving
> them when we request them in probe()?
> 

Yes! thanks for reminding me.
But I want to fix this issue by modifying the minimum range code. Because I and 
not the original person of creating this driver.
I don't want to other part of code if it is not essential.

Thanks,
Limeng

> --Sean
> 
>  >> +if (ret)
>  >> +return ret;
>  >> +
>  >> +ret = reset_assert_bulk();
>  >> +if (ret)
>  >> +return ret;
>  >> +
>  >> +ret = reset_deassert_bulk();
>  >> +if (ret)
>  >> +return ret;
>  >> +}
>  >> +
>  >>   return 0;
>  >>   }
>  >>
>  >
>  >
>  > Viele Grüße,
>  > Stefan
>  >


Re: [PATCH v2 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

2021-04-27 Thread Masahisa Kojima
On Wed, 28 Apr 2021 at 11:35, Heinrich Schuchardt  wrote:
>
> Am 28. April 2021 03:06:15 MESZ schrieb Masahisa Kojima 
> :
> >On Tue, 27 Apr 2021 at 22:52, Heinrich Schuchardt 
> >wrote:
> >>
> >> On 27.04.21 15:08, Masahisa Kojima wrote:
> >> > This is preparation for PE/COFF measurement support.
> >> > PE/COFF image hash calculation is same in both
> >> > UEFI Secure Boot image verification and measurement in
> >> > measured boot. PE/COFF image parsing functions are
> >> > gathered into efi_image_loader.c, and exposed even if
> >> > UEFI Secure Boot is not enabled.
> >> >
> >> > This commit also adds the EFI_SIGNATURE_SUPPORT option
> >> > to decide if efi_signature.c shall be compiled.
> >> >
> >> > Signed-off-by: Masahisa Kojima 
> >> > ---
> >> >
> >> > Changes in v2:
> >> > - Remove all #ifdef from efi_image_loader.c and efi_signature.c
> >> > - Add EFI_SIGNATURE_SUPPORT option
> >> > - Explicitly include 
> >> > - Gather PE/COFF parsing functions into efi_image_loader.c
> >> > - Move efi_guid_t efi_guid_image_security_database in
> >efi_var_common.c
> >> >
> >> >
> >> >  lib/efi_loader/Kconfig|  9 
> >> >  lib/efi_loader/Makefile   |  2 +-
> >> >  lib/efi_loader/efi_image_loader.c | 73
> >+++
> >> >  lib/efi_loader/efi_signature.c| 67
> >+---
> >> >  lib/efi_loader/efi_var_common.c   |  3 ++
> >> >  5 files changed, 79 insertions(+), 75 deletions(-)
> >> >
> >> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> >> > index 0b99d7c774..f012eb7718 100644
> >> > --- a/lib/efi_loader/Kconfig
> >> > +++ b/lib/efi_loader/Kconfig
> >> > @@ -174,6 +174,7 @@ config EFI_CAPSULE_AUTHENTICATE
> >> >   select PKCS7_MESSAGE_PARSER
> >> >   select PKCS7_VERIFY
> >> >   select IMAGE_SIGN_INFO
> >> > + select EFI_SIGNATURE_SUPPORT
> >>
> >> Select means that you cannot switch it off. Is this really what you
> >> want? If you want the user to decide it is enabled, just make
> >> EFI_SIGNATURE_SUPPORT default y.
> >
> >EFI_SIGNATURE_SUPPORT is mandatory only when EFI_SECURE_BOOT or
> >EFI_CAPSULE_AUTHENTICATE is enabled, so I use "select" here.
> >
> >>
> >> >   default n
> >> >   help
> >> > Select this option if you want to enable capsule
> >> > @@ -336,6 +337,7 @@ config EFI_SECURE_BOOT
> >> >   select X509_CERTIFICATE_PARSER
> >> >   select PKCS7_MESSAGE_PARSER
> >> >   select PKCS7_VERIFY
> >> > + select EFI_SIGNATURE_SUPPORT
> >>
> >> see above
> >>
> >> >   default n
> >> >   help
> >> > Select this option to enable EFI secure boot support.
> >> > @@ -343,6 +345,13 @@ config EFI_SECURE_BOOT
> >> > it is signed with a trusted key. To do that, you need to
> >install,
> >> > at least, PK, KEK and db.
> >> >
> >> > +config EFI_SIGNATURE_SUPPORT
> >> > + bool "Enable signature verification support"
> >> > + depends on EFI_SECURE_BOOT || EFI_CAPSULE_AUTHENTICATE
> >> > + default n
> >>
> >> see above
> >
> >EFI_SIGNATURE_SUPPORT is only required in the case that
> >EFI_SECURE_BOOT or EFI_CAPSULE_AUTHENTICATE is enabled.
> >
>
> The line 'default n' is superfluous as this is default behavior.
>
> If it does not make sense to select this option manually, you would remove 
> help and short text to hide the symbol.

Hi Heinrich,

You are correct, I will update and send v3.

Thanks,
Masahisa

>
> Best regards
>
> Heinrich
>
> >>
> >> > + help
> >> > +   Select this option to enable signature verification
> >support.
> >> > +
> >> >  config EFI_ESRT
> >> >   bool "Enable the UEFI ESRT generation"
> >> >   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
> >> > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> >> > index 8bd343e258..fd344cea29 100644
> >> > --- a/lib/efi_loader/Makefile
> >> > +++ b/lib/efi_loader/Makefile
> >> > @@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) +=
> >efi_smbios.o
> >> >  obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
> >> >  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
> >> >  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
> >> > -obj-y += efi_signature.o
> >> > +obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
> >> >
> >> >  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
> >> >  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
> >> > diff --git a/lib/efi_loader/efi_image_loader.c
> >b/lib/efi_loader/efi_image_loader.c
> >> > index f53ef367ec..b8a790bcb9 100644
> >> > --- a/lib/efi_loader/efi_image_loader.c
> >> > +++ b/lib/efi_loader/efi_image_loader.c
> >> > @@ -213,7 +213,68 @@ static void efi_set_code_and_data_type(
> >> >   }
> >> >  }
> >> >
> >> > -#ifdef CONFIG_EFI_SECURE_BOOT
> >> > +/**
> >> > + * efi_image_region_add() - add an entry of region
> >> > + * @regs:Pointer to array of regions
> >> > + * @start:   Start address of region (included)
> >> > + * @end: End address of region (excluded)
> >> > + * @nocheck: flag 

Re: [PATCH v2 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

2021-04-27 Thread Heinrich Schuchardt
Am 28. April 2021 03:06:15 MESZ schrieb Masahisa Kojima 
:
>On Tue, 27 Apr 2021 at 22:52, Heinrich Schuchardt 
>wrote:
>>
>> On 27.04.21 15:08, Masahisa Kojima wrote:
>> > This is preparation for PE/COFF measurement support.
>> > PE/COFF image hash calculation is same in both
>> > UEFI Secure Boot image verification and measurement in
>> > measured boot. PE/COFF image parsing functions are
>> > gathered into efi_image_loader.c, and exposed even if
>> > UEFI Secure Boot is not enabled.
>> >
>> > This commit also adds the EFI_SIGNATURE_SUPPORT option
>> > to decide if efi_signature.c shall be compiled.
>> >
>> > Signed-off-by: Masahisa Kojima 
>> > ---
>> >
>> > Changes in v2:
>> > - Remove all #ifdef from efi_image_loader.c and efi_signature.c
>> > - Add EFI_SIGNATURE_SUPPORT option
>> > - Explicitly include 
>> > - Gather PE/COFF parsing functions into efi_image_loader.c
>> > - Move efi_guid_t efi_guid_image_security_database in
>efi_var_common.c
>> >
>> >
>> >  lib/efi_loader/Kconfig|  9 
>> >  lib/efi_loader/Makefile   |  2 +-
>> >  lib/efi_loader/efi_image_loader.c | 73
>+++
>> >  lib/efi_loader/efi_signature.c| 67
>+---
>> >  lib/efi_loader/efi_var_common.c   |  3 ++
>> >  5 files changed, 79 insertions(+), 75 deletions(-)
>> >
>> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
>> > index 0b99d7c774..f012eb7718 100644
>> > --- a/lib/efi_loader/Kconfig
>> > +++ b/lib/efi_loader/Kconfig
>> > @@ -174,6 +174,7 @@ config EFI_CAPSULE_AUTHENTICATE
>> >   select PKCS7_MESSAGE_PARSER
>> >   select PKCS7_VERIFY
>> >   select IMAGE_SIGN_INFO
>> > + select EFI_SIGNATURE_SUPPORT
>>
>> Select means that you cannot switch it off. Is this really what you
>> want? If you want the user to decide it is enabled, just make
>> EFI_SIGNATURE_SUPPORT default y.
>
>EFI_SIGNATURE_SUPPORT is mandatory only when EFI_SECURE_BOOT or
>EFI_CAPSULE_AUTHENTICATE is enabled, so I use "select" here.
>
>>
>> >   default n
>> >   help
>> > Select this option if you want to enable capsule
>> > @@ -336,6 +337,7 @@ config EFI_SECURE_BOOT
>> >   select X509_CERTIFICATE_PARSER
>> >   select PKCS7_MESSAGE_PARSER
>> >   select PKCS7_VERIFY
>> > + select EFI_SIGNATURE_SUPPORT
>>
>> see above
>>
>> >   default n
>> >   help
>> > Select this option to enable EFI secure boot support.
>> > @@ -343,6 +345,13 @@ config EFI_SECURE_BOOT
>> > it is signed with a trusted key. To do that, you need to
>install,
>> > at least, PK, KEK and db.
>> >
>> > +config EFI_SIGNATURE_SUPPORT
>> > + bool "Enable signature verification support"
>> > + depends on EFI_SECURE_BOOT || EFI_CAPSULE_AUTHENTICATE
>> > + default n
>>
>> see above
>
>EFI_SIGNATURE_SUPPORT is only required in the case that
>EFI_SECURE_BOOT or EFI_CAPSULE_AUTHENTICATE is enabled.
>

The line 'default n' is superfluous as this is default behavior.

If it does not make sense to select this option manually, you would remove help 
and short text to hide the symbol.

Best regards

Heinrich

>>
>> > + help
>> > +   Select this option to enable signature verification
>support.
>> > +
>> >  config EFI_ESRT
>> >   bool "Enable the UEFI ESRT generation"
>> >   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
>> > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
>> > index 8bd343e258..fd344cea29 100644
>> > --- a/lib/efi_loader/Makefile
>> > +++ b/lib/efi_loader/Makefile
>> > @@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) +=
>efi_smbios.o
>> >  obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
>> >  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
>> >  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
>> > -obj-y += efi_signature.o
>> > +obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
>> >
>> >  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
>> >  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
>> > diff --git a/lib/efi_loader/efi_image_loader.c
>b/lib/efi_loader/efi_image_loader.c
>> > index f53ef367ec..b8a790bcb9 100644
>> > --- a/lib/efi_loader/efi_image_loader.c
>> > +++ b/lib/efi_loader/efi_image_loader.c
>> > @@ -213,7 +213,68 @@ static void efi_set_code_and_data_type(
>> >   }
>> >  }
>> >
>> > -#ifdef CONFIG_EFI_SECURE_BOOT
>> > +/**
>> > + * efi_image_region_add() - add an entry of region
>> > + * @regs:Pointer to array of regions
>> > + * @start:   Start address of region (included)
>> > + * @end: End address of region (excluded)
>> > + * @nocheck: flag against overlapped regions
>> > + *
>> > + * Take one entry of region [@start, @end[ and insert it into the
>list.
>> > + *
>> > + * * If @nocheck is false, the list will be sorted ascending by
>address.
>> > + *   Overlapping entries will not be allowed.
>> > + *
>> > + * * If @nocheck is true, the list will be sorted ascending by
>sequence
>> > + *   of adding the entries. Overlapping is 

Re: [PATCH 1/3] usb: ehci-mx6: move mode set/detect to probe

2021-04-27 Thread Marek Vasut

On 4/28/21 3:51 AM, Tim Harvey wrote:

On Tue, Apr 27, 2021 at 10:45 AM Marek Vasut  wrote:


On 4/27/21 7:08 PM, Tim Harvey wrote:

There is no need to set and/or detect mode in of_to_plat and
accessing phy registers at that point before device power domain and
clock are enabled will cause hangs on platforms such as IMX8M Mini.

Move the mode set/detect from of_to_plat into the probe and remove
the unnecessary of_to_plat.

Signed-off-by: Tim Harvey 
---
   drivers/usb/host/ehci-mx6.c | 42 ++---
   1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 06be9deaaa..c2dfe49012 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
   return 0;
   }

-static int ehci_usb_of_to_plat(struct udevice *dev)
-{
- struct usb_plat *plat = dev_get_plat(dev);
- enum usb_dr_mode dr_mode;
-
- dr_mode = usb_get_dr_mode(dev_ofnode(dev));
-
- switch (dr_mode) {
- case USB_DR_MODE_HOST:
- plat->init_type = USB_INIT_HOST;
- break;
- case USB_DR_MODE_PERIPHERAL:
- plat->init_type = USB_INIT_DEVICE;
- break;
- case USB_DR_MODE_OTG:
- case USB_DR_MODE_UNKNOWN:
- return ehci_usb_phy_mode(dev);
- };
-
- return 0;
-}
-


[...]


@@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = {
   .name   = "ehci_mx6",
   .id = UCLASS_USB,
   .of_match = mx6_usb_ids,
- .of_to_plat = ehci_usb_of_to_plat,


I wonder why it was implemented in of_to_plat originally , maybe there
is some reason for that ?


Marek,

Looking back the commit that added the ehci_usb_ofdata_to_platdata was:
cccbddc38c43 ("usb: ehci-mx6: implement ofdata_to_platdata")

Before that there was a board-specific function that would set the
usb_plat->init_type.

The only reason to set usb_plat->init_type in of_to_plat would be so
that drivers/usb/host/usb-uclass.c would have knowledge of it but I
only see that it is set there in usb_setup_ehci_gadget.


So interaction with Gadget, that's what I was afraid of.


I added Peng, Stefano, and Simon to the thread to see if they see an
issue with doing away with of_to_plat setting the usb_plat->init_type
prior to probe.


I added Lukasz too.


Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Marek Vasut

On 4/28/21 3:55 AM, Tim Harvey wrote:

On Tue, Apr 27, 2021 at 12:52 PM Marek Vasut  wrote:


On 4/27/21 9:24 PM, Patrick Wildt wrote:

Am Tue, Apr 27, 2021 at 10:50:34AM -0700 schrieb Tim Harvey:

On Tue, Apr 27, 2021 at 10:44 AM Marek Vasut  wrote:


On 4/27/21 7:08 PM, Tim Harvey wrote:

Add support for determining host vs peripheral mode for IMX8MM
configured as OTG.

Signed-off-by: Tim Harvey 
---
drivers/usb/host/ehci-mx6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index c2dfe49012..d055d2b1fe 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
plat->init_type = USB_INIT_DEVICE;
else
plat->init_type = USB_INIT_HOST;
- } else if (is_mx7()) {
+ } else if (is_mx7() || is_imx8mm()) {


This likely also applies to 8mq/mm/mn/mp , i.e. all of them.


Agreed. Perhaps Adam, Frieder, or Fabio have something to test with? I
only have IMX8M Mini at the moment.


No, I don't think this applies to all of them, 8MM and 8MN should be
correct.

So from a historic point of view the first one that showed up is the
8MQ, which has a DesignWare xHCI controller.  There's no eHCI, so this
driver doesn't attach and there is neither the fsl,imx27-usb nor the
fsl,imx7d-usb compatible.  Hence not having imx8mq should be correct.

When the i.MX8MM showed up the biggest difference obviously was the
silicon technology, reducing temperature.  But it also replaced the
DesignWare xHCI with ... what was it, the cadence OTG controller?


chipidea


This is basically a carbon copy of the fsl,imx7d-usb (which has the
i.MX6 as heritage).  Hence imx8mm is correct here.


Not quite, the mx8mm/mn variant is a bit more complex due to the extra
power domain stuff. And the PHY/MISC bits changed from mx7 too.


Then the i.MX8MP showed up, which is builds on that, but it finally
gets the DesignWare xHCI back.  So in that regard it's more a better
version of i.MX8MQ.  The fsl,imx7d-usb compatible is not part of the
dts, hence not having imx8mp should be correct.

The i.MX8MN is new to me, but by grepping you can see that the MN also
has the fsl,imx7d-usb compatible.


Seems there is always some sort of overlap between the Ms in terms of
IPs that are reused.


Hence I think only 8MM and 8MN should be added, not 8MQ or 8MP.


I agree, 8MP also only lists xhci (likely dwc3), like original M(Q).
MN should work, I use these patches on a board with it, in host mode only.


I will re-submit and add is_imx8mn() that's what the NXP
downstream u-boot does as well.


Thanks


Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Tim Harvey
On Tue, Apr 27, 2021 at 12:52 PM Marek Vasut  wrote:
>
> On 4/27/21 9:24 PM, Patrick Wildt wrote:
> > Am Tue, Apr 27, 2021 at 10:50:34AM -0700 schrieb Tim Harvey:
> >> On Tue, Apr 27, 2021 at 10:44 AM Marek Vasut  wrote:
> >>>
> >>> On 4/27/21 7:08 PM, Tim Harvey wrote:
>  Add support for determining host vs peripheral mode for IMX8MM
>  configured as OTG.
> 
>  Signed-off-by: Tim Harvey 
>  ---
> drivers/usb/host/ehci-mx6.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
>  diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
>  index c2dfe49012..d055d2b1fe 100644
>  --- a/drivers/usb/host/ehci-mx6.c
>  +++ b/drivers/usb/host/ehci-mx6.c
>  @@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> plat->init_type = USB_INIT_DEVICE;
> else
> plat->init_type = USB_INIT_HOST;
>  - } else if (is_mx7()) {
>  + } else if (is_mx7() || is_imx8mm()) {
> >>>
> >>> This likely also applies to 8mq/mm/mn/mp , i.e. all of them.
> >>
> >> Agreed. Perhaps Adam, Frieder, or Fabio have something to test with? I
> >> only have IMX8M Mini at the moment.
> >
> > No, I don't think this applies to all of them, 8MM and 8MN should be
> > correct.
> >
> > So from a historic point of view the first one that showed up is the
> > 8MQ, which has a DesignWare xHCI controller.  There's no eHCI, so this
> > driver doesn't attach and there is neither the fsl,imx27-usb nor the
> > fsl,imx7d-usb compatible.  Hence not having imx8mq should be correct.
> >
> > When the i.MX8MM showed up the biggest difference obviously was the
> > silicon technology, reducing temperature.  But it also replaced the
> > DesignWare xHCI with ... what was it, the cadence OTG controller?
>
> chipidea
>
> > This is basically a carbon copy of the fsl,imx7d-usb (which has the
> > i.MX6 as heritage).  Hence imx8mm is correct here.
>
> Not quite, the mx8mm/mn variant is a bit more complex due to the extra
> power domain stuff. And the PHY/MISC bits changed from mx7 too.
>
> > Then the i.MX8MP showed up, which is builds on that, but it finally
> > gets the DesignWare xHCI back.  So in that regard it's more a better
> > version of i.MX8MQ.  The fsl,imx7d-usb compatible is not part of the
> > dts, hence not having imx8mp should be correct.
> >
> > The i.MX8MN is new to me, but by grepping you can see that the MN also
> > has the fsl,imx7d-usb compatible.
>
> Seems there is always some sort of overlap between the Ms in terms of
> IPs that are reused.
>
> > Hence I think only 8MM and 8MN should be added, not 8MQ or 8MP.
>
> I agree, 8MP also only lists xhci (likely dwc3), like original M(Q).
> MN should work, I use these patches on a board with it, in host mode only.

I will re-submit and add is_imx8mn() that's what the NXP
downstream u-boot does as well.

Tim


Re: [PATCH 1/3] usb: ehci-mx6: move mode set/detect to probe

2021-04-27 Thread Tim Harvey
On Tue, Apr 27, 2021 at 10:45 AM Marek Vasut  wrote:
>
> On 4/27/21 7:08 PM, Tim Harvey wrote:
> > There is no need to set and/or detect mode in of_to_plat and
> > accessing phy registers at that point before device power domain and
> > clock are enabled will cause hangs on platforms such as IMX8M Mini.
> >
> > Move the mode set/detect from of_to_plat into the probe and remove
> > the unnecessary of_to_plat.
> >
> > Signed-off-by: Tim Harvey 
> > ---
> >   drivers/usb/host/ehci-mx6.c | 42 ++---
> >   1 file changed, 16 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> > index 06be9deaaa..c2dfe49012 100644
> > --- a/drivers/usb/host/ehci-mx6.c
> > +++ b/drivers/usb/host/ehci-mx6.c
> > @@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> >   return 0;
> >   }
> >
> > -static int ehci_usb_of_to_plat(struct udevice *dev)
> > -{
> > - struct usb_plat *plat = dev_get_plat(dev);
> > - enum usb_dr_mode dr_mode;
> > -
> > - dr_mode = usb_get_dr_mode(dev_ofnode(dev));
> > -
> > - switch (dr_mode) {
> > - case USB_DR_MODE_HOST:
> > - plat->init_type = USB_INIT_HOST;
> > - break;
> > - case USB_DR_MODE_PERIPHERAL:
> > - plat->init_type = USB_INIT_DEVICE;
> > - break;
> > - case USB_DR_MODE_OTG:
> > - case USB_DR_MODE_UNKNOWN:
> > - return ehci_usb_phy_mode(dev);
> > - };
> > -
> > - return 0;
> > -}
> > -
>
> [...]
>
> > @@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = {
> >   .name   = "ehci_mx6",
> >   .id = UCLASS_USB,
> >   .of_match = mx6_usb_ids,
> > - .of_to_plat = ehci_usb_of_to_plat,
>
> I wonder why it was implemented in of_to_plat originally , maybe there
> is some reason for that ?

Marek,

Looking back the commit that added the ehci_usb_ofdata_to_platdata was:
cccbddc38c43 ("usb: ehci-mx6: implement ofdata_to_platdata")

Before that there was a board-specific function that would set the
usb_plat->init_type.

The only reason to set usb_plat->init_type in of_to_plat would be so
that drivers/usb/host/usb-uclass.c would have knowledge of it but I
only see that it is set there in usb_setup_ehci_gadget.

I added Peng, Stefano, and Simon to the thread to see if they see an
issue with doing away with of_to_plat setting the usb_plat->init_type
prior to probe.

Tim


Re: [PATCH v2 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

2021-04-27 Thread Masahisa Kojima
On Tue, 27 Apr 2021 at 22:52, Heinrich Schuchardt  wrote:
>
> On 27.04.21 15:08, Masahisa Kojima wrote:
> > This is preparation for PE/COFF measurement support.
> > PE/COFF image hash calculation is same in both
> > UEFI Secure Boot image verification and measurement in
> > measured boot. PE/COFF image parsing functions are
> > gathered into efi_image_loader.c, and exposed even if
> > UEFI Secure Boot is not enabled.
> >
> > This commit also adds the EFI_SIGNATURE_SUPPORT option
> > to decide if efi_signature.c shall be compiled.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> >
> > Changes in v2:
> > - Remove all #ifdef from efi_image_loader.c and efi_signature.c
> > - Add EFI_SIGNATURE_SUPPORT option
> > - Explicitly include 
> > - Gather PE/COFF parsing functions into efi_image_loader.c
> > - Move efi_guid_t efi_guid_image_security_database in efi_var_common.c
> >
> >
> >  lib/efi_loader/Kconfig|  9 
> >  lib/efi_loader/Makefile   |  2 +-
> >  lib/efi_loader/efi_image_loader.c | 73 +++
> >  lib/efi_loader/efi_signature.c| 67 +---
> >  lib/efi_loader/efi_var_common.c   |  3 ++
> >  5 files changed, 79 insertions(+), 75 deletions(-)
> >
> > diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> > index 0b99d7c774..f012eb7718 100644
> > --- a/lib/efi_loader/Kconfig
> > +++ b/lib/efi_loader/Kconfig
> > @@ -174,6 +174,7 @@ config EFI_CAPSULE_AUTHENTICATE
> >   select PKCS7_MESSAGE_PARSER
> >   select PKCS7_VERIFY
> >   select IMAGE_SIGN_INFO
> > + select EFI_SIGNATURE_SUPPORT
>
> Select means that you cannot switch it off. Is this really what you
> want? If you want the user to decide it is enabled, just make
> EFI_SIGNATURE_SUPPORT default y.

EFI_SIGNATURE_SUPPORT is mandatory only when EFI_SECURE_BOOT or
EFI_CAPSULE_AUTHENTICATE is enabled, so I use "select" here.

>
> >   default n
> >   help
> > Select this option if you want to enable capsule
> > @@ -336,6 +337,7 @@ config EFI_SECURE_BOOT
> >   select X509_CERTIFICATE_PARSER
> >   select PKCS7_MESSAGE_PARSER
> >   select PKCS7_VERIFY
> > + select EFI_SIGNATURE_SUPPORT
>
> see above
>
> >   default n
> >   help
> > Select this option to enable EFI secure boot support.
> > @@ -343,6 +345,13 @@ config EFI_SECURE_BOOT
> > it is signed with a trusted key. To do that, you need to install,
> > at least, PK, KEK and db.
> >
> > +config EFI_SIGNATURE_SUPPORT
> > + bool "Enable signature verification support"
> > + depends on EFI_SECURE_BOOT || EFI_CAPSULE_AUTHENTICATE
> > + default n
>
> see above

EFI_SIGNATURE_SUPPORT is only required in the case that
EFI_SECURE_BOOT or EFI_CAPSULE_AUTHENTICATE is enabled.

>
> > + help
> > +   Select this option to enable signature verification support.
> > +
> >  config EFI_ESRT
> >   bool "Enable the UEFI ESRT generation"
> >   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
> > diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> > index 8bd343e258..fd344cea29 100644
> > --- a/lib/efi_loader/Makefile
> > +++ b/lib/efi_loader/Makefile
> > @@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
> >  obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
> >  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
> >  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
> > -obj-y += efi_signature.o
> > +obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
> >
> >  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
> >  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
> > diff --git a/lib/efi_loader/efi_image_loader.c 
> > b/lib/efi_loader/efi_image_loader.c
> > index f53ef367ec..b8a790bcb9 100644
> > --- a/lib/efi_loader/efi_image_loader.c
> > +++ b/lib/efi_loader/efi_image_loader.c
> > @@ -213,7 +213,68 @@ static void efi_set_code_and_data_type(
> >   }
> >  }
> >
> > -#ifdef CONFIG_EFI_SECURE_BOOT
> > +/**
> > + * efi_image_region_add() - add an entry of region
> > + * @regs:Pointer to array of regions
> > + * @start:   Start address of region (included)
> > + * @end: End address of region (excluded)
> > + * @nocheck: flag against overlapped regions
> > + *
> > + * Take one entry of region [@start, @end[ and insert it into the list.
> > + *
> > + * * If @nocheck is false, the list will be sorted ascending by address.
> > + *   Overlapping entries will not be allowed.
> > + *
> > + * * If @nocheck is true, the list will be sorted ascending by sequence
> > + *   of adding the entries. Overlapping is allowed.
> > + *
> > + * Return:   status code
> > + */
> > +efi_status_t efi_image_region_add(struct efi_image_regions *regs,
> > +   const void *start, const void *end,
> > +   int nocheck)
>
> Why are you moving this function to a different C module?

The major goal of this patch is exposing efi_image_loader.c::efi_image_parse()
for 

Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Marek Vasut

On 4/27/21 9:24 PM, Patrick Wildt wrote:

Am Tue, Apr 27, 2021 at 10:50:34AM -0700 schrieb Tim Harvey:

On Tue, Apr 27, 2021 at 10:44 AM Marek Vasut  wrote:


On 4/27/21 7:08 PM, Tim Harvey wrote:

Add support for determining host vs peripheral mode for IMX8MM
configured as OTG.

Signed-off-by: Tim Harvey 
---
   drivers/usb/host/ehci-mx6.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index c2dfe49012..d055d2b1fe 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
   plat->init_type = USB_INIT_DEVICE;
   else
   plat->init_type = USB_INIT_HOST;
- } else if (is_mx7()) {
+ } else if (is_mx7() || is_imx8mm()) {


This likely also applies to 8mq/mm/mn/mp , i.e. all of them.


Agreed. Perhaps Adam, Frieder, or Fabio have something to test with? I
only have IMX8M Mini at the moment.


No, I don't think this applies to all of them, 8MM and 8MN should be
correct.

So from a historic point of view the first one that showed up is the
8MQ, which has a DesignWare xHCI controller.  There's no eHCI, so this
driver doesn't attach and there is neither the fsl,imx27-usb nor the
fsl,imx7d-usb compatible.  Hence not having imx8mq should be correct.

When the i.MX8MM showed up the biggest difference obviously was the
silicon technology, reducing temperature.  But it also replaced the
DesignWare xHCI with ... what was it, the cadence OTG controller?


chipidea


This is basically a carbon copy of the fsl,imx7d-usb (which has the
i.MX6 as heritage).  Hence imx8mm is correct here.


Not quite, the mx8mm/mn variant is a bit more complex due to the extra 
power domain stuff. And the PHY/MISC bits changed from mx7 too.



Then the i.MX8MP showed up, which is builds on that, but it finally
gets the DesignWare xHCI back.  So in that regard it's more a better
version of i.MX8MQ.  The fsl,imx7d-usb compatible is not part of the
dts, hence not having imx8mp should be correct.

The i.MX8MN is new to me, but by grepping you can see that the MN also
has the fsl,imx7d-usb compatible.


Seems there is always some sort of overlap between the Ms in terms of 
IPs that are reused.



Hence I think only 8MM and 8MN should be added, not 8MQ or 8MP.


I agree, 8MP also only lists xhci (likely dwc3), like original M(Q).
MN should work, I use these patches on a board with it, in host mode only.


Re: [PATCH 3/3] pci: pcie_dw_rockchip: Use udelay instead of msleep

2021-04-27 Thread Patrick Wildt
Am Tue, Apr 27, 2021 at 11:11:19AM +0530 schrieb Anand Moon:
> hi Patrick,
> 
> On Tue, 27 Apr 2021 at 01:38, Patrick Wildt  wrote:
> >
> > Am Mon, Apr 26, 2021 at 01:26:32PM + schrieb Anand Moon:
> > > Use udelay instead of msleep fix the below warning.
> >
> > You sure that's correct? the m in msleep means milli, while the u
> > in udelay means micro.  That's a factor of 1000 of a difference.
> >
> Thanks for your review comments.
> 
> Most of the u-boot driver prefers udelay and usleep_range internally
> calls udelay.
> 
> I don't have the HW to test and verify.
> 
> -Anand

Sure, I'm not complaining about that.  My point is that if you pass
e. g. 8 milliseconds to a function that takes microseconds, you need
to add the factor.

Not good: msleep(1000) -> udelay(1000)
Much better: msleep(1000) -> udelay(1000 * 1000)

Which also means that you either have to rename PERST_WAIT_MS and change
its value, or do udelay(PERST_WAIT_MS * 1000)


Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Patrick Wildt
Am Tue, Apr 27, 2021 at 10:50:34AM -0700 schrieb Tim Harvey:
> On Tue, Apr 27, 2021 at 10:44 AM Marek Vasut  wrote:
> >
> > On 4/27/21 7:08 PM, Tim Harvey wrote:
> > > Add support for determining host vs peripheral mode for IMX8MM
> > > configured as OTG.
> > >
> > > Signed-off-by: Tim Harvey 
> > > ---
> > >   drivers/usb/host/ehci-mx6.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> > > index c2dfe49012..d055d2b1fe 100644
> > > --- a/drivers/usb/host/ehci-mx6.c
> > > +++ b/drivers/usb/host/ehci-mx6.c
> > > @@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> > >   plat->init_type = USB_INIT_DEVICE;
> > >   else
> > >   plat->init_type = USB_INIT_HOST;
> > > - } else if (is_mx7()) {
> > > + } else if (is_mx7() || is_imx8mm()) {
> >
> > This likely also applies to 8mq/mm/mn/mp , i.e. all of them.
> 
> Agreed. Perhaps Adam, Frieder, or Fabio have something to test with? I
> only have IMX8M Mini at the moment.

No, I don't think this applies to all of them, 8MM and 8MN should be
correct.

So from a historic point of view the first one that showed up is the
8MQ, which has a DesignWare xHCI controller.  There's no eHCI, so this
driver doesn't attach and there is neither the fsl,imx27-usb nor the
fsl,imx7d-usb compatible.  Hence not having imx8mq should be correct.

When the i.MX8MM showed up the biggest difference obviously was the
silicon technology, reducing temperature.  But it also replaced the
DesignWare xHCI with ... what was it, the cadence OTG controller?
This is basically a carbon copy of the fsl,imx7d-usb (which has the
i.MX6 as heritage).  Hence imx8mm is correct here.

Then the i.MX8MP showed up, which is builds on that, but it finally
gets the DesignWare xHCI back.  So in that regard it's more a better
version of i.MX8MQ.  The fsl,imx7d-usb compatible is not part of the
dts, hence not having imx8mp should be correct.

The i.MX8MN is new to me, but by grepping you can see that the MN also
has the fsl,imx7d-usb compatible.

Hence I think only 8MM and 8MN should be added, not 8MQ or 8MP.

Patrick


Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Tim Harvey
On Tue, Apr 27, 2021 at 10:44 AM Marek Vasut  wrote:
>
> On 4/27/21 7:08 PM, Tim Harvey wrote:
> > Add support for determining host vs peripheral mode for IMX8MM
> > configured as OTG.
> >
> > Signed-off-by: Tim Harvey 
> > ---
> >   drivers/usb/host/ehci-mx6.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> > index c2dfe49012..d055d2b1fe 100644
> > --- a/drivers/usb/host/ehci-mx6.c
> > +++ b/drivers/usb/host/ehci-mx6.c
> > @@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> >   plat->init_type = USB_INIT_DEVICE;
> >   else
> >   plat->init_type = USB_INIT_HOST;
> > - } else if (is_mx7()) {
> > + } else if (is_mx7() || is_imx8mm()) {
>
> This likely also applies to 8mq/mm/mn/mp , i.e. all of them.

Agreed. Perhaps Adam, Frieder, or Fabio have something to test with? I
only have IMX8M Mini at the moment.

Tim


Re: [PATCH 1/3] usb: ehci-mx6: move mode set/detect to probe

2021-04-27 Thread Marek Vasut

On 4/27/21 7:08 PM, Tim Harvey wrote:

There is no need to set and/or detect mode in of_to_plat and
accessing phy registers at that point before device power domain and
clock are enabled will cause hangs on platforms such as IMX8M Mini.

Move the mode set/detect from of_to_plat into the probe and remove
the unnecessary of_to_plat.

Signed-off-by: Tim Harvey 
---
  drivers/usb/host/ehci-mx6.c | 42 ++---
  1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 06be9deaaa..c2dfe49012 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
return 0;
  }
  
-static int ehci_usb_of_to_plat(struct udevice *dev)

-{
-   struct usb_plat *plat = dev_get_plat(dev);
-   enum usb_dr_mode dr_mode;
-
-   dr_mode = usb_get_dr_mode(dev_ofnode(dev));
-
-   switch (dr_mode) {
-   case USB_DR_MODE_HOST:
-   plat->init_type = USB_INIT_HOST;
-   break;
-   case USB_DR_MODE_PERIPHERAL:
-   plat->init_type = USB_INIT_DEVICE;
-   break;
-   case USB_DR_MODE_OTG:
-   case USB_DR_MODE_UNKNOWN:
-   return ehci_usb_phy_mode(dev);
-   };
-
-   return 0;
-}
-


[...]


@@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = {
.name   = "ehci_mx6",
.id = UCLASS_USB,
.of_match = mx6_usb_ids,
-   .of_to_plat = ehci_usb_of_to_plat,


I wonder why it was implemented in of_to_plat originally , maybe there 
is some reason for that ?


Re: [PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Marek Vasut

On 4/27/21 7:08 PM, Tim Harvey wrote:

Add support for determining host vs peripheral mode for IMX8MM
configured as OTG.

Signed-off-by: Tim Harvey 
---
  drivers/usb/host/ehci-mx6.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index c2dfe49012..d055d2b1fe 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
plat->init_type = USB_INIT_DEVICE;
else
plat->init_type = USB_INIT_HOST;
-   } else if (is_mx7()) {
+   } else if (is_mx7() || is_imx8mm()) {


This likely also applies to 8mq/mm/mn/mp , i.e. all of them.


[PATCH 3/3] configs: imx8mm_venice_defconfig: add usb support

2021-04-27 Thread Tim Harvey
Enable USB support for host controller and various USB ethernet devices.

Signed-off-by: Tim Harvey 
---
 configs/imx8mm_venice_defconfig | 15 +++
 include/configs/imx8mm_venice.h |  4 
 2 files changed, 19 insertions(+)

diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig
index 01bf2f362a..0d16f8d1c0 100644
--- a/configs/imx8mm_venice_defconfig
+++ b/configs/imx8mm_venice_defconfig
@@ -48,6 +48,7 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
@@ -92,6 +93,8 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_BD71837=y
 CONFIG_SPL_DM_PMIC_BD71837=y
@@ -107,5 +110,17 @@ CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
 CONFIG_IMX_TMU=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+# CONFIG_SPL_DM_USB is not set
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_USB_ETHER_ASIX88179=y
+CONFIG_USB_ETHER_LAN75XX=y
+CONFIG_USB_ETHER_LAN78XX=y
+CONFIG_USB_ETHER_MCS7830=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_USB_ETHER_SMSC95XX=y
 CONFIG_IMX_WATCHDOG=y
 CONFIG_HEXDUMP=y
diff --git a/include/configs/imx8mm_venice.h b/include/configs/imx8mm_venice.h
index 91669255e1..5e9f4c89d1 100644
--- a/include/configs/imx8mm_venice.h
+++ b/include/configs/imx8mm_venice.h
@@ -99,6 +99,10 @@
 /* UART */
 #define CONFIG_MXC_UART_BASE   UART2_BASE_ADDR
 
+/* USB */
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
+
 /* Monitor Command Prompt */
 #define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
 #define CONFIG_SYS_CBSIZE  SZ_2K
-- 
2.17.1



[PATCH 2/3] usb: ehci-mx6: add IMX8MM OTG support

2021-04-27 Thread Tim Harvey
Add support for determining host vs peripheral mode for IMX8MM
configured as OTG.

Signed-off-by: Tim Harvey 
---
 drivers/usb/host/ehci-mx6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index c2dfe49012..d055d2b1fe 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
plat->init_type = USB_INIT_DEVICE;
else
plat->init_type = USB_INIT_HOST;
-   } else if (is_mx7()) {
+   } else if (is_mx7() || is_imx8mm()) {
phy_status = (void __iomem *)(addr +
  USBNC_PHY_STATUS_OFFSET);
val = readl(phy_status);
-- 
2.17.1



[PATCH 1/3] usb: ehci-mx6: move mode set/detect to probe

2021-04-27 Thread Tim Harvey
There is no need to set and/or detect mode in of_to_plat and
accessing phy registers at that point before device power domain and
clock are enabled will cause hangs on platforms such as IMX8M Mini.

Move the mode set/detect from of_to_plat into the probe and remove
the unnecessary of_to_plat.

Signed-off-by: Tim Harvey 
---
 drivers/usb/host/ehci-mx6.c | 42 ++---
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 06be9deaaa..c2dfe49012 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
return 0;
 }
 
-static int ehci_usb_of_to_plat(struct udevice *dev)
-{
-   struct usb_plat *plat = dev_get_plat(dev);
-   enum usb_dr_mode dr_mode;
-
-   dr_mode = usb_get_dr_mode(dev_ofnode(dev));
-
-   switch (dr_mode) {
-   case USB_DR_MODE_HOST:
-   plat->init_type = USB_INIT_HOST;
-   break;
-   case USB_DR_MODE_PERIPHERAL:
-   plat->init_type = USB_INIT_DEVICE;
-   break;
-   case USB_DR_MODE_OTG:
-   case USB_DR_MODE_UNKNOWN:
-   return ehci_usb_phy_mode(dev);
-   };
-
-   return 0;
-}
-
 static int mx6_parse_dt_addrs(struct udevice *dev)
 {
 #if !defined(CONFIG_PHY)
@@ -623,7 +601,6 @@ static int ehci_usb_probe(struct udevice *dev)
struct usb_plat *plat = dev_get_plat(dev);
struct usb_ehci *ehci = dev_read_addr_ptr(dev);
struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
-   enum usb_init_type type = plat->init_type;
struct ehci_hccr *hccr;
struct ehci_hcor *hcor;
int ret;
@@ -641,7 +618,6 @@ static int ehci_usb_probe(struct udevice *dev)
return ret;
 
priv->ehci = ehci;
-   priv->init_type = type;
 
 #if CONFIG_IS_ENABLED(CLK)
ret = clk_get_by_index(dev, 0, >clk);
@@ -657,6 +633,21 @@ static int ehci_usb_probe(struct udevice *dev)
mdelay(1);
 #endif
 
+   switch (usb_get_dr_mode(dev_ofnode(dev))) {
+   case USB_DR_MODE_HOST:
+   plat->init_type = USB_INIT_HOST;
+   break;
+   case USB_DR_MODE_PERIPHERAL:
+   plat->init_type = USB_INIT_DEVICE;
+   break;
+   case USB_DR_MODE_OTG:
+   case USB_DR_MODE_UNKNOWN:
+   ret = ehci_usb_phy_mode(dev);
+   if (ret)
+   return ret;
+   };
+   priv->init_type = plat->init_type;
+
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
ret = device_get_supply_regulator(dev, "vbus-supply",
  >vbus_supply);
@@ -680,7 +671,7 @@ static int ehci_usb_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply) {
ret = regulator_set_enable(priv->vbus_supply,
-  (type == USB_INIT_DEVICE) ?
+  (priv->init_type == USB_INIT_DEVICE) 
?
   false : true);
if (ret && ret != -ENOSYS) {
printf("Error enabling VBUS supply (ret=%i)\n", ret);
@@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = {
.name   = "ehci_mx6",
.id = UCLASS_USB,
.of_match = mx6_usb_ids,
-   .of_to_plat = ehci_usb_of_to_plat,
.probe  = ehci_usb_probe,
.remove = ehci_usb_remove,
.ops= _usb_ops,
-- 
2.17.1



Re: [PATCH v3] IOMUX: Fix buffer overflow in iomux_replace_device()

2021-04-27 Thread Tom Rini
On Mon, Apr 26, 2021 at 08:08:03AM +0900, Yuichiro Goto wrote:

> Use of strcat() against an uninitialized buffer would lead
> to buffer overflow. This patch fixes it.
> 
> Fixes: 694cd5618c ("IOMUX: Introduce iomux_replace_device()")
> Signed-off-by: Yuichiro Goto 
> Cc: Peter Robinson 
> Cc: Andy Shevchenko 
> Cc: Nicolas Saenz Julienne 
> Reviewed-by: Andy Shevchenko 
> Tested-by: Peter Robinson 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] pinctrl: single: fix a never true comparison

2021-04-27 Thread Tom Rini
On Thu, Apr 22, 2021 at 10:28:56PM +0200, Dario Binacchi wrote:

> As reported by Coverity Scan for Das U-Boot, the 'less-than-zero'
> comparison of an unsigned value is never true.
> 
> Signed-off-by: Dario Binacchi 
> Reviewed-by: Pratyush Yadav 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] pinctrl: single: check function mask to be non-zero

2021-04-27 Thread Tom Rini
On Thu, Apr 22, 2021 at 06:35:58PM +0200, Dario Binacchi wrote:

> Otherwise it can generate a division by zero, which has an undefined
> behavior.
> 
> Signed-off-by: Dario Binacchi 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] Makefile: fix generation of defaultenv.h from empty initial file

2021-04-27 Thread Tom Rini
On Thu, Apr 22, 2021 at 09:44:18AM +0200, Rasmus Villemoes wrote:

> When CONFIG_USE_DEFAULT_ENV_FILE=y and the file
> CONFIG_DEFAULT_ENV_FILE is empty (or at least doesn't contain any
> non-comment, non-empty lines), we end up feeding nothing into xxd,
> which in turn then outputs nothing. Then blindly appending ", 0x00"
> means that we end up trying to compile (roughly)
> 
> const char defaultenv[] = { , 0x00 }
> 
> which is of course broken.
> 
> To fix that, change the frobbing of the text file so that we always
> end up printing an extra empty line (which gets turned into that extra
> nul byte we need) - that corresponds better to the binary format
> consisting of a series of key=val nul terminated strings, terminated
> by an empty string.
> 
> Reported-by: Oleksandr Suvorov 
> Signed-off-by: Rasmus Villemoes 
> Reviewed-by: Oleksandr Suvorov 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/2] reset: fix reset_get_by_index_nodev index handling

2021-04-27 Thread Tom Rini
On Tue, Apr 20, 2021 at 10:42:26AM +0200, Neil Armstrong wrote:

> This fixes an issue getting resets index 1 and 3+, the spurius "> 0"
> made it return the index 0 or 1, whatever index was passed.
> 
> The dm_test_reset_base() did not catch it, but the dm_test_reset_base() 
> extension
> catches it and this fixes the regression.
> 
> This also fixes a reggression on Amlogic G12A/G12B SoCs, where HDMI output 
> was disable
> even when Linux was booting.
> 
> Fixes: ea9dc35aab ("reset: Get the RESET by index without device")
> Reported-by: B1oHazard 
> Signed-off-by: Neil Armstrong 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/2] test: reset: Extend base reset test to catch error

2021-04-27 Thread Tom Rini
On Tue, Apr 20, 2021 at 10:42:25AM +0200, Neil Armstrong wrote:

> With this extended test, we get the following failure :
> 
> => ut dm reset_base
> Test: dm_test_reset_base: reset.c
> test/dm/reset.c:52, dm_test_reset_base(): reset_method3.id == 
> reset_method3_1.id: Expected 0x14 (20), got 0x2 (2)
> Test: dm_test_reset_base: reset.c (flat tree)
> test/dm/reset.c:52, dm_test_reset_base(): reset_method3.id == 
> reset_method3_1.id: Expected 0x14 (20), got 0x2 (2)
> Failures: 2
> 
> A fix is needed in reset_get_by_index_nodev() when introduced in [1].
> 
> [1] ea9dc35aab ("reset: Get the RESET by index without device")
> 
> Signed-off-by: Neil Armstrong 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] arm: zimage: Use correct symbol to hide messages in SPL

2021-04-27 Thread Tom Rini
On Sat, Apr 17, 2021 at 09:34:37AM -0500, Samuel Holland wrote:

> When zImage support was added to SPL, the messages were hidden to reduce
> code size. However, the wrong config symbol was used. Since this file is
> only built when CONFIG_SPL_FRAMEWORK=y, the messages were always hidden.
> 
> Use the correct symbol so the messages are printed in U-Boot proper.
> Also use IS_ENABLED to drop the #ifdef.
> 
> Fixes: 431889d6ad9a ("spl: zImage support in Falcon mode")
> Signed-off-by: Samuel Holland 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH U-boot v2] fs: btrfs: fix the false alert of decompression failure

2021-04-27 Thread Tom Rini
On Sat, Apr 17, 2021 at 08:52:13PM +0800, Qu Wenruo wrote:

> There are some cases where decompressed sectors can have padding zeros.
> 
> In kernel code, we have lines to address such situation:
> 
> /*
>  * btrfs_getblock is doing a zero on the tail of the page too,
>  * but this will cover anything missing from the decompressed
>  * data.
>  */
> if (bytes < destlen)
> memset(kaddr+bytes, 0, destlen-bytes);
> kunmap_local(kaddr);
> 
> But not in U-boot code, thus we have some reports of U-boot failed to
> read compressed files in btrfs.
> 
> Fix it by doing the same thing of the kernel, for both inline and
> regular compressed extents.
> 
> Reported-by: Matwey Kornilov 
> Link: https://bugzilla.suse.com/show_bug.cgi?id=1183717
> Fixes: a26a6bedafcf ("fs: btrfs: Introduce btrfs_read_extent_inline() and 
> btrfs_read_extent_reg()")
> Signed-off-by: Qu Wenruo 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-marvell/master (watchdog related)

2021-04-27 Thread Tom Rini
On Tue, Apr 27, 2021 at 10:28:20AM +0200, Stefan Roese wrote:

> Hi Tom,
> 
> please pull the following watchdog related patches from Rasmus:
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] usb: ehci-mx6: Limit PHY address parsing to !CONFIG_PHY

2021-04-27 Thread Tim Harvey
On Tue, Apr 27, 2021 at 9:06 AM Marek Vasut  wrote:
>
> For systems which use generic PHY support and implement USB PHY driver,
> the parsing of PHY properties is unnecessary, disable it.
>
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Cc: Tim Harvey 
> Cc: Ye Li 
> Cc: uboot-imx 
> ---
>  drivers/usb/host/ehci-mx6.c | 17 -
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index 7642a31b655..06be9deaaae 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -265,6 +265,8 @@ int usb_phy_mode(int port)
>  }
>  #endif
>
> +#if !defined(CONFIG_PHY)
> +/* Should be done in the MXS PHY driver */
>  static void usb_oc_config(struct usbnc_regs *usbnc, int index)
>  {
> void __iomem *ctrl = (void __iomem *)(>ctrl[index]);
> @@ -285,6 +287,7 @@ static void usb_oc_config(struct usbnc_regs *usbnc, int 
> index)
> clrbits_le32(ctrl, UCTRL_PWR_POL);
>  #endif
>  }
> +#endif
>
>  #if !CONFIG_IS_ENABLED(DM_USB)
>  /**
> @@ -432,10 +435,12 @@ struct ehci_mx6_priv_data {
> struct clk clk;
> struct phy phy;
> enum usb_init_type init_type;
> +#if !defined(CONFIG_PHY)
> int portnr;
> void __iomem *phy_addr;
> void __iomem *misc_addr;
> void __iomem *anatop_addr;
> +#endif
>  };
>
>  static int mx6_init_after_reset(struct ehci_ctrl *dev)
> @@ -448,14 +453,14 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev)
> usb_power_config_mx6(priv->anatop_addr, priv->portnr);
> usb_power_config_mx7(priv->misc_addr);
> usb_power_config_mx7ulp(priv->phy_addr);
> -#endif
>
> usb_oc_config(priv->misc_addr, priv->portnr);
>
> -#if !defined(CONFIG_PHY) && (defined(CONFIG_MX6) || defined(CONFIG_MX7ULP))
> +#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP)
> usb_internal_phy_clock_gate(priv->phy_addr, 1);
> usb_phy_enable(ehci, priv->phy_addr);
>  #endif
> +#endif
>
>  #if CONFIG_IS_ENABLED(DM_REGULATOR)
> if (priv->vbus_supply) {
> @@ -558,6 +563,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
>
>  static int mx6_parse_dt_addrs(struct udevice *dev)
>  {
> +#if !defined(CONFIG_PHY)
> struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
> int phy_off, misc_off;
> const void *blob = gd->fdt_blob;
> @@ -594,7 +600,7 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
>
> priv->misc_addr = addr;
>
> -#if !defined(CONFIG_PHY) && defined(CONFIG_MX6)
> +#if defined(CONFIG_MX6)
> int anatop_off;
>
> /* Resolve ANATOP offset through USB PHY node */
> @@ -607,6 +613,7 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
> return -EINVAL;
>
> priv->anatop_addr = addr;
> +#endif
>  #endif
> return 0;
>  }
> @@ -661,14 +668,14 @@ static int ehci_usb_probe(struct udevice *dev)
> usb_power_config_mx6(priv->anatop_addr, priv->portnr);
> usb_power_config_mx7(priv->misc_addr);
> usb_power_config_mx7ulp(priv->phy_addr);
> -#endif
>
> usb_oc_config(priv->misc_addr, priv->portnr);
>
> -#if !defined(CONFIG_PHY) && (defined(CONFIG_MX6) || defined(CONFIG_MX7ULP))
> +#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP)
> usb_internal_phy_clock_gate(priv->phy_addr, 1);
> usb_phy_enable(ehci, priv->phy_addr);
>  #endif
> +#endif
>
>  #if CONFIG_IS_ENABLED(DM_REGULATOR)
> if (priv->vbus_supply) {
> --
> 2.30.2
>

Tested-by: Tim Harvey 

Tested on IMX8M Mini Venice
Tested on IMX6DL Ventana


[PATCH] usb: ehci-mx6: Limit PHY address parsing to !CONFIG_PHY

2021-04-27 Thread Marek Vasut
For systems which use generic PHY support and implement USB PHY driver,
the parsing of PHY properties is unnecessary, disable it.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
Cc: Tim Harvey 
Cc: Ye Li 
Cc: uboot-imx 
---
 drivers/usb/host/ehci-mx6.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 7642a31b655..06be9deaaae 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -265,6 +265,8 @@ int usb_phy_mode(int port)
 }
 #endif
 
+#if !defined(CONFIG_PHY)
+/* Should be done in the MXS PHY driver */
 static void usb_oc_config(struct usbnc_regs *usbnc, int index)
 {
void __iomem *ctrl = (void __iomem *)(>ctrl[index]);
@@ -285,6 +287,7 @@ static void usb_oc_config(struct usbnc_regs *usbnc, int 
index)
clrbits_le32(ctrl, UCTRL_PWR_POL);
 #endif
 }
+#endif
 
 #if !CONFIG_IS_ENABLED(DM_USB)
 /**
@@ -432,10 +435,12 @@ struct ehci_mx6_priv_data {
struct clk clk;
struct phy phy;
enum usb_init_type init_type;
+#if !defined(CONFIG_PHY)
int portnr;
void __iomem *phy_addr;
void __iomem *misc_addr;
void __iomem *anatop_addr;
+#endif
 };
 
 static int mx6_init_after_reset(struct ehci_ctrl *dev)
@@ -448,14 +453,14 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev)
usb_power_config_mx6(priv->anatop_addr, priv->portnr);
usb_power_config_mx7(priv->misc_addr);
usb_power_config_mx7ulp(priv->phy_addr);
-#endif
 
usb_oc_config(priv->misc_addr, priv->portnr);
 
-#if !defined(CONFIG_PHY) && (defined(CONFIG_MX6) || defined(CONFIG_MX7ULP))
+#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP)
usb_internal_phy_clock_gate(priv->phy_addr, 1);
usb_phy_enable(ehci, priv->phy_addr);
 #endif
+#endif
 
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply) {
@@ -558,6 +563,7 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
 
 static int mx6_parse_dt_addrs(struct udevice *dev)
 {
+#if !defined(CONFIG_PHY)
struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
int phy_off, misc_off;
const void *blob = gd->fdt_blob;
@@ -594,7 +600,7 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
 
priv->misc_addr = addr;
 
-#if !defined(CONFIG_PHY) && defined(CONFIG_MX6)
+#if defined(CONFIG_MX6)
int anatop_off;
 
/* Resolve ANATOP offset through USB PHY node */
@@ -607,6 +613,7 @@ static int mx6_parse_dt_addrs(struct udevice *dev)
return -EINVAL;
 
priv->anatop_addr = addr;
+#endif
 #endif
return 0;
 }
@@ -661,14 +668,14 @@ static int ehci_usb_probe(struct udevice *dev)
usb_power_config_mx6(priv->anatop_addr, priv->portnr);
usb_power_config_mx7(priv->misc_addr);
usb_power_config_mx7ulp(priv->phy_addr);
-#endif
 
usb_oc_config(priv->misc_addr, priv->portnr);
 
-#if !defined(CONFIG_PHY) && (defined(CONFIG_MX6) || defined(CONFIG_MX7ULP))
+#if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP)
usb_internal_phy_clock_gate(priv->phy_addr, 1);
usb_phy_enable(ehci, priv->phy_addr);
 #endif
+#endif
 
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
if (priv->vbus_supply) {
-- 
2.30.2



Re: [PATCH V2 24/24] ARM: imx8m: verdin-imx8mm: Enable USB Host support

2021-04-27 Thread Tim Harvey
On Mon, Apr 26, 2021, 5:35 PM Marek Vasut  wrote:
>
> On 4/27/21 2:01 AM, Tim Harvey wrote:
> [...]
> >>> Why would the power domain get probed/enabled for the usbotg2
> >>> bus but not the usbotg1 bus? Here is some debugging:
> >>> u-boot=> usb start
> >>> starting USB...
> >>> Bus usb@32e4: ehci_usb_phy_mode usb@32e4
> >>> usb@32e4 probe ret=-22
> >>> probe failed, error -22
> >>> ^^^ probe fails here because ehci_usb_phy_mode returns EINVAL for
> >>> dr_mode=otg but if we try to read the phy_status reg we will hang b/c
> >>> power domain is not enabled yet
> >>> Bus usb@32e5: imx8m_power_domain_probe gpc@303a
> >>> imx8m_power_domain_probe pgc
> >>> ^^^ why did power domain get probed on the 2nd bus and not the first?
> >>
> >> I don't know, can you have a look ?
> >
> > Marek,
> >
> > The reg domain does not get enabled for usbotg1 because
> > device_of_to_plat gets called 'before' dev_power_domain_on in
> > device_probe.
> >
> > The following will get imx8mm USB otg working:
> >
> > For OTG defer setting type until probe after clock and power have been
> > brought up.
> > index 06be9deaaa..2183ae4f9d 100644
> > --- a/drivers/usb/host/ehci-mx6.c
> > +++ b/drivers/usb/host/ehci-mx6.c
> > @@ -523,7 +523,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> >  plat->init_type = USB_INIT_DEVICE;
> >  else
> >  plat->init_type = USB_INIT_HOST;
> > -   } else if (is_mx7()) {
> > +   } else if (is_mx7() || is_imx8mm()) {
> >  phy_status = (void __iomem *)(addr +
> >USBNC_PHY_STATUS_OFFSET);
> >  val = readl(phy_status);
> > @@ -555,7 +555,10 @@ static int ehci_usb_of_to_plat(struct udevice *dev)
> >  break;
> >  case USB_DR_MODE_OTG:
> >  case USB_DR_MODE_UNKNOWN:
> > -   return ehci_usb_phy_mode(dev);
> > +   if (is_imx8mm())
>
> Does this mean OTG doesn't work on the 8MM then ?

IMX8MM USB in general still doesn't work without your:
usb: ehci-mx6: Limit PHY address parsing to !CONFIG_PHY

With your patch, IMX8MM 'host' works but 'otg' will fail probe with
-22 (due ehci_usb_phy_mode called from of_to_plat and it not having a
case for imx8mm)

>
> > +   plat->init_type = USB_INIT_HOST;
> > +   else
> > +   return ehci_usb_phy_mode(dev);
> >  };
> >
> >  return 0;
> > @@ -657,6 +660,13 @@ static int ehci_usb_probe(struct udevice *dev)
> >  mdelay(1);
> >   #endif
> >
> > +   if (is_imx8mm() && (usb_get_dr_mode(dev_ofnode(dev)) ==
> > USB_DR_MODE_OTG)) {
> > +   ret = ehci_usb_phy_mode(dev);
> > +   if (ret)
> > +   return ret;
> > +   priv->init_type = plat->init_type;
> > +   };
>
> I have to wonder, why not move the whole OTG/Host/Device detection to
> probe then ?

Yes, I think that is the right thing to do.

>
> Also, could you submit a regular patch ?

Yes, I will post patches to fix IMX8MM OTG. Can you submit your 'usb:
ehci-mx6: Limit PHY address parsing to !CONFIG_PHY' patch so I can go
on top of that or can I just pull that into my series?

Best regards,

Tim


Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Sean Anderson




On 4/27/21 10:23 AM, Stefan Roese wrote:
> On 27.04.21 10:41, meng...@windriver.com wrote:
>> From: MengLi 
>>
>> In uboot command line environment, watchdog is not able to be
>> stopped with below commands:
>> SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
>> SOCFPGA_STRATIX10 # wdt stop
>> Refer to watchdog driver in linux kernel, it is also need to reset
>> watchdog after disable it so that the disable action takes effect.
>>
>> v2:
>> Change "#if CONFIG_IS_ENABLED(DM_RESET)" into
>> "if (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable
>> into if condition sentence.
>
> A few comments:
>
> This version changelog belongs below the "---" line.
>
> Please Cc interested people upon new versions, e.g. myself as I reviewed
> this patch.
>
> Other that this:
>
> Reviewed-by: Stefan Roese 
>
> Thanks,
> Stefan
>
>> Signed-off-by: Meng Li 
>> ---
>>   drivers/watchdog/designware_wdt.c | 17 +
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/watchdog/designware_wdt.c 
b/drivers/watchdog/designware_wdt.c
>> index 12f09a7a39..57cad1effc 100644
>> --- a/drivers/watchdog/designware_wdt.c
>> +++ b/drivers/watchdog/designware_wdt.c
>> @@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice *dev)
>>   designware_wdt_reset(dev);
>>   writel(0, priv->base + DW_WDT_CR);
>> +if (CONFIG_IS_ENABLED(DM_RESET)) {
>> +struct reset_ctl_bulk resets;
>> +int ret;
>> +
>> +ret = reset_get_bulk(dev, );

Have you considered adding the resets to designware_wdt_priv and saving
them when we request them in probe()?

--Sean

>> +if (ret)
>> +return ret;
>> +
>> +ret = reset_assert_bulk();
>> +if (ret)
>> +return ret;
>> +
>> +ret = reset_deassert_bulk();
>> +if (ret)
>> +return ret;
>> +}
>> +
>>   return 0;
>>   }
>>
>
>
> Viele Grüße,
> Stefan
>


Re: [PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Stefan Roese

On 27.04.21 10:41, meng...@windriver.com wrote:

From: MengLi 

In uboot command line environment, watchdog is not able to be
stopped with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

v2:
Change "#if CONFIG_IS_ENABLED(DM_RESET)" into
"if (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable
into if condition sentence.


A few comments:

This version changelog belongs below the "---" line.

Please Cc interested people upon new versions, e.g. myself as I reviewed
this patch.

Other that this:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


Signed-off-by: Meng Li 
---
  drivers/watchdog/designware_wdt.c | 17 +
  1 file changed, 17 insertions(+)

diff --git a/drivers/watchdog/designware_wdt.c 
b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..57cad1effc 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice *dev)
designware_wdt_reset(dev);
writel(0, priv->base + DW_WDT_CR);
  
+if (CONFIG_IS_ENABLED(DM_RESET)) {

+   struct reset_ctl_bulk resets;
+   int ret;
+
+   ret = reset_get_bulk(dev, );
+   if (ret)
+   return ret;
+
+   ret = reset_assert_bulk();
+   if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk();
+   if (ret)
+   return ret;
+   }
+
return 0;
  }
  




Viele Grüße,
Stefan

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


Re: [PATCH 2/2] efi_loader: add PE/COFF image measurement

2021-04-27 Thread Masahisa Kojima
Hi Heinrich,

> > +++ b/include/tpm-v2.h
> > @@ -61,6 +61,7 @@ struct udevice;
> >   #define EV_S_CRTM_VERSION   ((u32)0x0008)
> >   #define EV_CPU_MICROCODE((u32)0x0009)
> >   #define EV_TABLE_OF_DEVICES ((u32)0x000B)
>
> Please, add a comment here that the following values are defined in the
> "TCG EFI Platform Specification".
>
> > +#define EV_EFI_BOOT_SERVICES_APPLICATION ((u32)0x8003)
>
> Please, add all EV_EFI_* constants.

I have sent v2 patch and added EV_EFI_* constants.
Anyway, EV_EFI_* are defined in the "TCG PC Client Platform Firmware
Profile Specification" and it is better to add remaining events
described in "Table 9 Event" as a separate patch.

Best Regards,
Masahisa

On Thu, 22 Apr 2021 at 17:23, Heinrich Schuchardt  wrote:
>
> On 22.04.21 10:09, Ilias Apalodimas wrote:
>  + if (!(active & alg_to_mask(hash_alg)))
>  + continue;
>  + switch (hash_alg) {
>  + case TPM2_ALG_SHA1:
> >>>
> >>> SHA1 is known to be unsafe. Why would we support it?
> >>
> >> Basically I agree with removing SHA1 support.
> >> This efi_tcg2.c implementation aims to support TCG v2, so there is no
> >> reason to keep SHA1.
> >> Anyway, SHA1 is supported in tcg2_create_digest() for the measurement
> >> other than PE/COFF image. Do we also remove SHA1 from
> >> tcg2_create_digest()?
> >>
> >
> > The hardware dictates what kind of SHAxxx you are supposed to add in the
> > EventLog and the PCRs. Why would we remove the functionality?  If someone
> > considers SHA1 unsafe, he can just disable it from his hardware and remove 
> > it
> > from the active algorithms.
> >
> >
> > Cheers
> > /Ilias
>
>
> The TCG EFI ProtocolSpecification explicitely enumerates the four
> hashing algorithms of Masahisa's patch, see chapter 6.4.3, "Related
> Definitions".
>
> So let's support them.
>
> Best regards
>
> Heinrich
>
> >
> >> For other comments, I will modify the code and send v2 patch.
> >>
> >> Thanks,
> >> Masahisa
> >>
> >>
> >> On Wed, 21 Apr 2021 at 19:57, Heinrich Schuchardt  
> >> wrote:
> >>>
> >>> On 4/15/21 3:30 PM, Masahisa Kojima wrote:
>  "TCG PC Client Platform Firmware Profile Specification"
>  requires to measure every attempt to load and execute
>  a OS Loader(a UEFI application) into PCR[4].
>  This commit adds the PE/COFF image measurement, extends PCR,
>  and appends measurement into Event Log.
> 
>  Signed-off-by: Masahisa Kojima 
>  ---
>    include/efi_loader.h  |   4 +
>    include/efi_tcg2.h|  10 ++
>    include/tpm-v2.h  |   1 +
>    lib/efi_loader/efi_image_loader.c |   7 ++
>    lib/efi_loader/efi_tcg2.c | 187 --
>    5 files changed, 199 insertions(+), 10 deletions(-)
> 
>  diff --git a/include/efi_loader.h b/include/efi_loader.h
>  index de1a496a97..b02bc93c8e 100644
>  --- a/include/efi_loader.h
>  +++ b/include/efi_loader.h
>  @@ -426,6 +426,10 @@ efi_status_t efi_disk_register(void);
>    efi_status_t efi_rng_register(void);
>    /* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
>    efi_status_t efi_tcg2_register(void);
>  +/* measure the pe-coff image, extend PCR and add Event Log */
>  +efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
>  +struct efi_loaded_image_obj *handle,
>  +struct efi_loaded_image 
>  *loaded_image_info);
>    /* Create handles and protocols for the partitions of a block device */
>    int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc 
>  *desc,
>   const char *if_typename, int diskid,
>  diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
>  index 40e241ce31..f8d46c5fd2 100644
>  --- a/include/efi_tcg2.h
>  +++ b/include/efi_tcg2.h
>  @@ -9,6 +9,8 @@
>    #if !defined _EFI_TCG2_PROTOCOL_H_
>    #define _EFI_TCG2_PROTOCOL_H_
> 
>  +#include 
> >>>
> >>> This include is already included in efi_api.h.
> >>>
>  +#include 
>    #include 
> 
>    #define EFI_TCG2_PROTOCOL_GUID \
>  @@ -53,6 +55,14 @@ struct efi_tcg2_event {
>    u8 event[];
>    } __packed;
> 
>  +struct uefi_image_load_event {
>  + efi_physical_addr_t image_location_in_memory;
>  + u64 image_length_in_memory;
>  + u64 image_link_time_address;
>  + u64 length_of_device_path;
>  + struct efi_device_path device_path[];
> >>>
> >>> A device path is not an array of struct efi_device_path. But the first
> >>> element is of this type. So ok.
> >>>
>  +} __packed;
> >>>
> >>> Why should this be __packed? You don't use arrays of this structure and
> >>> it is naturally packed.
> >>>
>  +
>    struct efi_tcg2_boot_service_capability {
>    u8 size;
>    

Re: [EXT] [PATCH v1 05/10] net: mvpp2: Fix 2.5G GMII_SPEED configurations

2021-04-27 Thread Stefan Roese

Hi Kosta,

On 27.04.21 15:48, Kostya Porotchkin wrote:

Hi, Stefan,


-Original Message-
From: Stefan Roese 
Sent: Tuesday, April 27, 2021 16:27
To: u-boot@lists.denx.de
Cc: Stefan Chulski ; Marcin Wojtas
; Nadav Haklai ; Marek Behun
; Joe Hershberger ; Kostya
Porotchkin ; Yan Markman
; sa_ip-sw-jenkins 
Subject: [EXT] [PATCH v1 05/10] net: mvpp2: Fix 2.5G GMII_SPEED
configurations

External Email

--
From: Stefan Chulski 

GMII_SPEED should be enabled for 2.5G speed

Signed-off-by: Stefan Chulski 
Reviewed-by: Yan Markman 
Reviewed-by: Kostya Porotchkin 
Tested-by: sa_ip-sw-jenkins 
Signed-off-by: Stefan Roese 
---

  drivers/net/mvpp2.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index
2043bdf10aa4..ec7cb89a94c8 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4445,7 +4445,8 @@ static void mvpp2_link_event(struct mvpp2_port
*port)
if (phydev->duplex)
val |= MVPP2_GMAC_CONFIG_FULL_DUPLEX;

-   if (phydev->speed == SPEED_1000)
+   if (phydev->speed == SPEED_1000 ||
+   phydev->speed == 2500)

[KP] Shouldn't it be "SPEED_2500"?


I agree in general. Please note that this is a verbatim copy from
your SDK version. And checking, this is not a real issue as here
the macros are defines as follows:

include/linux/ethtool.h

/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb,  5Gb, 10GbE. */
#define SPEED_1010
#define SPEED_100   100
#define SPEED_1000  1000
#define SPEED_2500  2500
#define SPEED_5000  5000
#define SPEED_1 1

We should perhaps change this some time though to always use the macro
instead of the number.

Thanks,
Stefan


Re: [PATCH v2 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

2021-04-27 Thread Heinrich Schuchardt
On 27.04.21 15:08, Masahisa Kojima wrote:
> This is preparation for PE/COFF measurement support.
> PE/COFF image hash calculation is same in both
> UEFI Secure Boot image verification and measurement in
> measured boot. PE/COFF image parsing functions are
> gathered into efi_image_loader.c, and exposed even if
> UEFI Secure Boot is not enabled.
>
> This commit also adds the EFI_SIGNATURE_SUPPORT option
> to decide if efi_signature.c shall be compiled.
>
> Signed-off-by: Masahisa Kojima 
> ---
>
> Changes in v2:
> - Remove all #ifdef from efi_image_loader.c and efi_signature.c
> - Add EFI_SIGNATURE_SUPPORT option
> - Explicitly include 
> - Gather PE/COFF parsing functions into efi_image_loader.c
> - Move efi_guid_t efi_guid_image_security_database in efi_var_common.c
>
>
>  lib/efi_loader/Kconfig|  9 
>  lib/efi_loader/Makefile   |  2 +-
>  lib/efi_loader/efi_image_loader.c | 73 +++
>  lib/efi_loader/efi_signature.c| 67 +---
>  lib/efi_loader/efi_var_common.c   |  3 ++
>  5 files changed, 79 insertions(+), 75 deletions(-)
>
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index 0b99d7c774..f012eb7718 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -174,6 +174,7 @@ config EFI_CAPSULE_AUTHENTICATE
>   select PKCS7_MESSAGE_PARSER
>   select PKCS7_VERIFY
>   select IMAGE_SIGN_INFO
> + select EFI_SIGNATURE_SUPPORT

Select means that you cannot switch it off. Is this really what you
want? If you want the user to decide it is enabled, just make
EFI_SIGNATURE_SUPPORT default y.

>   default n
>   help
> Select this option if you want to enable capsule
> @@ -336,6 +337,7 @@ config EFI_SECURE_BOOT
>   select X509_CERTIFICATE_PARSER
>   select PKCS7_MESSAGE_PARSER
>   select PKCS7_VERIFY
> + select EFI_SIGNATURE_SUPPORT

see above

>   default n
>   help
> Select this option to enable EFI secure boot support.
> @@ -343,6 +345,13 @@ config EFI_SECURE_BOOT
> it is signed with a trusted key. To do that, you need to install,
> at least, PK, KEK and db.
>
> +config EFI_SIGNATURE_SUPPORT
> + bool "Enable signature verification support"
> + depends on EFI_SECURE_BOOT || EFI_CAPSULE_AUTHENTICATE
> + default n

see above

> + help
> +   Select this option to enable signature verification support.
> +
>  config EFI_ESRT
>   bool "Enable the UEFI ESRT generation"
>   depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
> diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
> index 8bd343e258..fd344cea29 100644
> --- a/lib/efi_loader/Makefile
> +++ b/lib/efi_loader/Makefile
> @@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
>  obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
>  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
>  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
> -obj-y += efi_signature.o
> +obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
>
>  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
>  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
> diff --git a/lib/efi_loader/efi_image_loader.c 
> b/lib/efi_loader/efi_image_loader.c
> index f53ef367ec..b8a790bcb9 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -213,7 +213,68 @@ static void efi_set_code_and_data_type(
>   }
>  }
>
> -#ifdef CONFIG_EFI_SECURE_BOOT
> +/**
> + * efi_image_region_add() - add an entry of region
> + * @regs:Pointer to array of regions
> + * @start:   Start address of region (included)
> + * @end: End address of region (excluded)
> + * @nocheck: flag against overlapped regions
> + *
> + * Take one entry of region [@start, @end[ and insert it into the list.
> + *
> + * * If @nocheck is false, the list will be sorted ascending by address.
> + *   Overlapping entries will not be allowed.
> + *
> + * * If @nocheck is true, the list will be sorted ascending by sequence
> + *   of adding the entries. Overlapping is allowed.
> + *
> + * Return:   status code
> + */
> +efi_status_t efi_image_region_add(struct efi_image_regions *regs,
> +   const void *start, const void *end,
> +   int nocheck)

Why are you moving this function to a different C module?

> +{
> + struct image_region *reg;
> + int i, j;
> +
> + if (regs->num >= regs->max) {
> + EFI_PRINT("%s: no more room for regions\n", __func__);
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> + if (end < start)
> + return EFI_INVALID_PARAMETER;
> +
> + for (i = 0; i < regs->num; i++) {
> + reg = >reg[i];
> + if (nocheck)
> + continue;
> +
> + /* new data after registered region */
> + if (start >= reg->data + reg->size)
> + continue;
> +
> + /* new data 

RE: [EXT] [PATCH v1 05/10] net: mvpp2: Fix 2.5G GMII_SPEED configurations

2021-04-27 Thread Kostya Porotchkin
Hi, Stefan,

> -Original Message-
> From: Stefan Roese 
> Sent: Tuesday, April 27, 2021 16:27
> To: u-boot@lists.denx.de
> Cc: Stefan Chulski ; Marcin Wojtas
> ; Nadav Haklai ; Marek Behun
> ; Joe Hershberger ; Kostya
> Porotchkin ; Yan Markman
> ; sa_ip-sw-jenkins  jenk...@marvell.com>
> Subject: [EXT] [PATCH v1 05/10] net: mvpp2: Fix 2.5G GMII_SPEED
> configurations
> 
> External Email
> 
> --
> From: Stefan Chulski 
> 
> GMII_SPEED should be enabled for 2.5G speed
> 
> Signed-off-by: Stefan Chulski 
> Reviewed-by: Yan Markman 
> Reviewed-by: Kostya Porotchkin 
> Tested-by: sa_ip-sw-jenkins 
> Signed-off-by: Stefan Roese 
> ---
> 
>  drivers/net/mvpp2.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index
> 2043bdf10aa4..ec7cb89a94c8 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -4445,7 +4445,8 @@ static void mvpp2_link_event(struct mvpp2_port
> *port)
>   if (phydev->duplex)
>   val |= MVPP2_GMAC_CONFIG_FULL_DUPLEX;
> 
> - if (phydev->speed == SPEED_1000)
> + if (phydev->speed == SPEED_1000 ||
> + phydev->speed == 2500)
[KP] Shouldn't it be "SPEED_2500"?

>   val |= MVPP2_GMAC_CONFIG_GMII_SPEED;
>   else if (phydev->speed == SPEED_100)
>   val |= MVPP2_GMAC_CONFIG_MII_SPEED;
> --
> 2.31.1



[PATCH v1 10/10] net: mvpp2: add explicit sgmii-2500 support

2021-04-27 Thread Stefan Roese
From: Marcin Wojtas 

Until now the mvpp2 driver used an extra 'phy-speed'
DT property in order to differentiate between the
SGMII and SGMII @2.5GHz. As there is a dedicated
PHY_INTERFACE_MODE_SGMII_2500 flag to mark the latter
start using it and drop the custom flag.

Signed-off-by: Marcin Wojtas 
Reviewed-by: Stefan Chulski 
Reviewed-by: Nadav Haklai 
Tested-by: Nadav Haklai 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 28 
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index c5bfe41281d6..4c0a7b0a9f5c 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -976,8 +976,6 @@ struct mvpp2_port {
unsigned int duplex;
unsigned int speed;
 
-   unsigned int phy_speed; /* SGMII 1Gbps vs 2.5Gbps */
-
struct mvpp2_bm_pool *pool_long;
struct mvpp2_bm_pool *pool_short;
 
@@ -2875,6 +2873,7 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port)
 
switch (port->phy_interface) {
case PHY_INTERFACE_MODE_SGMII:
+   case PHY_INTERFACE_MODE_SGMII_2500:
val |= MVPP2_GMAC_INBAND_AN_MASK;
break;
case PHY_INTERFACE_MODE_1000BASEX:
@@ -2942,6 +2941,7 @@ static void mvpp2_port_loopback_set(struct mvpp2_port 
*port)
val &= ~MVPP2_GMAC_GMII_LB_EN_MASK;
 
if (port->phy_interface == PHY_INTERFACE_MODE_SGMII ||
+   port->phy_interface == PHY_INTERFACE_MODE_SGMII_2500 ||
port->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
port->phy_interface == PHY_INTERFACE_MODE_2500BASEX)
val |= MVPP2_GMAC_PCS_LB_EN_MASK;
@@ -3239,12 +3239,11 @@ static int gop_gmac_mode_cfg(struct mvpp2_port *port)
/* Set TX FIFO thresholds */
switch (port->phy_interface) {
case PHY_INTERFACE_MODE_SGMII:
-   if (port->phy_speed == 2500)
-   gop_gmac_sgmii2_5_cfg(port);
-   else
-   gop_gmac_sgmii_cfg(port);
+   gop_gmac_sgmii_cfg(port);
+   break;
+   case PHY_INTERFACE_MODE_SGMII_2500:
+   gop_gmac_sgmii2_5_cfg(port);
break;
-
case PHY_INTERFACE_MODE_1000BASEX:
gop_gmac_1000basex_cfg(port);
break;
@@ -3425,6 +3424,7 @@ static int gop_port_init(struct mvpp2_port *port)
break;
 
case PHY_INTERFACE_MODE_SGMII:
+   case PHY_INTERFACE_MODE_SGMII_2500:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
/* configure PCS */
@@ -3484,6 +3484,7 @@ static void gop_port_enable(struct mvpp2_port *port, int 
enable)
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_SGMII:
+   case PHY_INTERFACE_MODE_SGMII_2500:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
if (enable)
@@ -3520,6 +3521,7 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
phy_interface_t phy_type)
 
if (gop_id == 2) {
if (phy_type == PHY_INTERFACE_MODE_SGMII ||
+   phy_type == PHY_INTERFACE_MODE_SGMII_2500 ||
phy_type == PHY_INTERFACE_MODE_1000BASEX ||
phy_type == PHY_INTERFACE_MODE_2500BASEX)
val |= MV_NETC_GE_MAC2_SGMII;
@@ -3530,6 +3532,7 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
phy_interface_t phy_type)
 
if (gop_id == 3) {
if (phy_type == PHY_INTERFACE_MODE_SGMII ||
+   phy_type == PHY_INTERFACE_MODE_SGMII_2500 ||
phy_type == PHY_INTERFACE_MODE_1000BASEX ||
phy_type == PHY_INTERFACE_MODE_2500BASEX)
val |= MV_NETC_GE_MAC3_SGMII;
@@ -4528,6 +4531,7 @@ static void mvpp2_start_dev(struct mvpp2_port *port)
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_SGMII:
+   case PHY_INTERFACE_MODE_SGMII_2500:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
mvpp2_gmac_max_rx_size_set(port);
@@ -4838,15 +4842,6 @@ static int phy_info_parse(struct udevice *dev, struct 
mvpp2_port *port)
 >phy_tx_disable_gpio, GPIOD_IS_OUT);
 #endif
 
-   /*
-* ToDo:
-* Not sure if this DT property "phy-speed" will get accepted, so
-* this might change later
-*/
-   /* Get phy-speed for SGMII 2.5Gbps vs 1Gbps setup */
-   port->phy_speed = fdtdec_get_int(gd->fdt_blob, port_node,
-"phy-speed", 1000);
-
port->id = id;
if (port->priv->hw_version == MVPP21)
port->first_rxq = port->id * rxq_number;
@@ -5275,6 +5270,7 @@ static int mvpp2_start(struct udevice *dev)
case PHY_INTERFACE_MODE_RGMII:

[PATCH v1 09/10] net: mvpp2: allow MDIO registration for fixed links

2021-04-27 Thread Stefan Roese
From: Stefan Chulski 

Currently, there are 2 valid cases for interface, PHY
and mdio relation:
  - If an interface has PHY handler, it'll call
mdio_mii_bus_get_from_phy(), which will register
MDIO bus.
  - If we want to use fixed-link for an interface,
PHY handle is not defined in the DTS, and no
MDIO is registered.

There is a third case, for some boards (with switch),
the MDIO is used for switch configuration, but the interface
itself uses fixed link. This patch allows this option by
checking if fixed-link subnode is defined, in this case,
MDIO bus is registers, but the PHY address is set to
PHY_MAX_ADDR for this interface, so this interface will
not try to access the PHY later on.

Signed-off-by: Stefan Chulski 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 3d920e85ffef..c5bfe41281d6 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4787,16 +4787,25 @@ static int phy_info_parse(struct udevice *dev, struct 
mvpp2_port *port)
u32 id;
u32 phyaddr = 0;
int phy_mode = -1;
+   int fixed_link = 0;
int ret;
 
phy_node = fdtdec_lookup_phandle(gd->fdt_blob, port_node, "phy");
+   fixed_link = fdt_subnode_offset(gd->fdt_blob, port_node, "fixed-link");
 
if (phy_node > 0) {
int parent;
-   phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node, "reg", 0);
-   if (phyaddr < 0) {
-   dev_err(dev, "could not find phy address\n");
-   return -1;
+
+   if (fixed_link != -FDT_ERR_NOTFOUND) {
+   /* phy_addr is set to invalid value for fixed links */
+   phyaddr = PHY_MAX_ADDR;
+   } else {
+   phyaddr = fdtdec_get_int(gd->fdt_blob, phy_node,
+"reg", 0);
+   if (phyaddr < 0) {
+   dev_err(dev, "could not find phy address\n");
+   return -1;
+   }
}
parent = fdt_parent_offset(gd->fdt_blob, phy_node);
ret = uclass_get_device_by_of_offset(UCLASS_MDIO, parent,
-- 
2.31.1



[PATCH v1 06/10] net: mvpp2: AN Bypass in 1000 and 2500 basex mode

2021-04-27 Thread Stefan Roese
From: Ben Peled 

Signed-off-by: Ben Peled 
Reviewed-by: Stefan Chulski 
Reviewed-by: Kostya Porotchkin 
Tested-by: sa_ip-sw-jenkins 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index ec7cb89a94c8..879289452b15 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -3148,7 +3148,8 @@ static void gop_gmac_2500basex_cfg(struct mvpp2_port 
*port)
 * bypass enabled (link interrupt storm risk
 * otherwise).
 */
-   val = MVPP2_GMAC_EN_PCS_AN |
+   val = MVPP2_GMAC_AN_BYPASS_EN |
+   MVPP2_GMAC_EN_PCS_AN |
MVPP2_GMAC_CONFIG_GMII_SPEED  |
MVPP2_GMAC_CONFIG_FULL_DUPLEX |
MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG;
@@ -3188,7 +3189,8 @@ static void gop_gmac_1000basex_cfg(struct mvpp2_port 
*port)
 * bypass enabled (link interrupt storm risk
 * otherwise).
 */
-   val = MVPP2_GMAC_EN_PCS_AN |
+   val = MVPP2_GMAC_AN_BYPASS_EN |
+   MVPP2_GMAC_EN_PCS_AN |
MVPP2_GMAC_CONFIG_GMII_SPEED  |
MVPP2_GMAC_CONFIG_FULL_DUPLEX |
MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG;
-- 
2.31.1



[PATCH v1 07/10] net: mvpp2: remove unused define MVPP22_SMI_PHY_ADDR_REG

2021-04-27 Thread Stefan Roese
From: Ben Peled 

Signed-off-by: Ben Peled 
Reviewed-by: Stefan Chulski 
Reviewed-by: Kostya Porotchkin 
Tested-by: sa_ip-sw-jenkins 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 879289452b15..61a0ea0894a7 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -490,9 +490,6 @@ do {
\
 #define MVPP22_SMI_MISC_CFG_REG(MVPP22_SMI + 0x04)
 #define  MVPP22_SMI_POLLING_EN BIT(10)
 
-#define MVPP22_SMI_PHY_ADDR_REG(port)  (MVPP22_SMI + 0x04 + \
-(0x4 * (port)))
-
 #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK 0xff
 
 /* Descriptor ring Macros */
-- 
2.31.1



[PATCH v1 08/10] net: mvpp2: fix missing switch case break

2021-04-27 Thread Stefan Roese
From: Ben Peled 

Signed-off-by: Ben Peled 
Reviewed-by: Stefan Chulski 
Reviewed-by: Kostya Porotchkin 
Tested-by: sa_ip-sw-jenkins 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 61a0ea0894a7..3d920e85ffef 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -3247,9 +3247,11 @@ static int gop_gmac_mode_cfg(struct mvpp2_port *port)
 
case PHY_INTERFACE_MODE_1000BASEX:
gop_gmac_1000basex_cfg(port);
+   break;
 
case PHY_INTERFACE_MODE_2500BASEX:
gop_gmac_2500basex_cfg(port);
+   break;
 
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
-- 
2.31.1



[PATCH v1 04/10] net: mvpp2: remove redundant SMI address configuration

2021-04-27 Thread Stefan Roese
From: Marcin Wojtas 

Because the mvpp2 driver now relies on the PHYLIB and
the external MDIO driver, configuring low level
SMI bus settings is redundant.

Signed-off-by: Marcin Wojtas 
Tested-by: sa_ip-sw-jenkins 
Reviewed-by: Kostya Porotchkin 
Reviewed-by: Stefan Chulski 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 847007d5b487..2043bdf10aa4 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -5292,14 +5292,6 @@ static int mvpp2_write_hwaddr(struct udevice *dev)
return mvpp2_prs_update_mac_da(port, port->dev_addr);
 }
 
-static int mvpp22_smi_phy_addr_cfg(struct mvpp2_port *port)
-{
-   writel(port->phyaddr, port->priv->iface_base +
-  MVPP22_SMI_PHY_ADDR_REG(port->gop_id));
-
-   return 0;
-}
-
 static int mvpp2_base_probe(struct udevice *dev)
 {
struct mvpp2 *priv = dev_get_priv(dev);
@@ -5422,10 +5414,6 @@ static int mvpp2_probe(struct udevice *dev)
port->base = priv->iface_base + MVPP22_PORT_BASE +
port->gop_id * MVPP22_PORT_OFFSET;
 
-   /* Set phy address of the port */
-   if (port->phyaddr < PHY_MAX_ADDR)
-   mvpp22_smi_phy_addr_cfg(port);
-
/* GoP Init */
gop_port_init(port);
}
-- 
2.31.1



[PATCH v1 03/10] net: mvpp2: add 1000BaseX and 2500BaseX ppv2 support

2021-04-27 Thread Stefan Roese
From: Stefan Chulski 

Signed-off-by: Stefan Chulski 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 117 ++--
 1 file changed, 112 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 015f5329de74..847007d5b487 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -2880,6 +2880,10 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port)
case PHY_INTERFACE_MODE_SGMII:
val |= MVPP2_GMAC_INBAND_AN_MASK;
break;
+   case PHY_INTERFACE_MODE_1000BASEX:
+   case PHY_INTERFACE_MODE_2500BASEX:
+   val &= ~MVPP2_GMAC_INBAND_AN_MASK;
+   break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
val |= MVPP2_GMAC_PORT_RGMII_MASK;
@@ -2940,7 +2944,9 @@ static void mvpp2_port_loopback_set(struct mvpp2_port 
*port)
else
val &= ~MVPP2_GMAC_GMII_LB_EN_MASK;
 
-   if (port->phy_interface == PHY_INTERFACE_MODE_SGMII)
+   if (port->phy_interface == PHY_INTERFACE_MODE_SGMII ||
+   port->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
+   port->phy_interface == PHY_INTERFACE_MODE_2500BASEX)
val |= MVPP2_GMAC_PCS_LB_EN_MASK;
else
val &= ~MVPP2_GMAC_PCS_LB_EN_MASK;
@@ -3051,10 +3057,10 @@ static void gop_gmac_sgmii2_5_cfg(struct mvpp2_port 
*port)
 
val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
/*
-* Configure GIG MAC to 1000Base-X mode connected to a fiber
+* Configure GIG MAC to SGMII mode connected to a fiber
 * transceiver
 */
-   val |= MVPP2_GMAC_PORT_TYPE_MASK;
+   val &= ~MVPP2_GMAC_PORT_TYPE_MASK;
writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
 
/* configure AN 0x9268 */
@@ -3106,6 +3112,89 @@ static void gop_gmac_sgmii_cfg(struct mvpp2_port *port)
writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
 }
 
+static void gop_gmac_2500basex_cfg(struct mvpp2_port *port)
+{
+   u32 val, thresh;
+
+   /*
+* Configure minimal level of the Tx FIFO before the lower part
+* starts to read a packet
+*/
+   thresh = MVPP2_SGMII2_5_TX_FIFO_MIN_TH;
+   val = readl(port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
+   val &= ~MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK;
+   val |= MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(thresh);
+   writel(val, port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
+
+   /* Disable bypass of sync module */
+   val = readl(port->base + MVPP2_GMAC_CTRL_4_REG);
+   val |= MVPP2_GMAC_CTRL4_SYNC_BYPASS_MASK;
+   /* configure DP clock select according to mode */
+   val |= MVPP2_GMAC_CTRL4_DP_CLK_SEL_MASK;
+   /* configure QSGMII bypass according to mode */
+   val |= MVPP2_GMAC_CTRL4_QSGMII_BYPASS_ACTIVE_MASK;
+   writel(val, port->base + MVPP2_GMAC_CTRL_4_REG);
+
+   val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
+   /*
+* Configure GIG MAC to 2500Base-X mode connected to a fiber
+* transceiver
+*/
+   val |= MVPP2_GMAC_PORT_TYPE_MASK;
+   writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
+
+   /* In 2500BaseX mode, we can't negotiate speed
+* and we do not want InBand autoneg
+* bypass enabled (link interrupt storm risk
+* otherwise).
+*/
+   val = MVPP2_GMAC_EN_PCS_AN |
+   MVPP2_GMAC_CONFIG_GMII_SPEED  |
+   MVPP2_GMAC_CONFIG_FULL_DUPLEX |
+   MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG;
+   writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
+}
+
+static void gop_gmac_1000basex_cfg(struct mvpp2_port *port)
+{
+   u32 val, thresh;
+
+   /*
+* Configure minimal level of the Tx FIFO before the lower part
+* starts to read a packet
+*/
+   thresh = MVPP2_SGMII_TX_FIFO_MIN_TH;
+   val = readl(port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
+   val &= ~MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK;
+   val |= MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(thresh);
+   writel(val, port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
+
+   /* Disable bypass of sync module */
+   val = readl(port->base + MVPP2_GMAC_CTRL_4_REG);
+   val |= MVPP2_GMAC_CTRL4_SYNC_BYPASS_MASK;
+   /* configure DP clock select according to mode */
+   val &= ~MVPP2_GMAC_CTRL4_DP_CLK_SEL_MASK;
+   /* configure QSGMII bypass according to mode */
+   val |= MVPP2_GMAC_CTRL4_QSGMII_BYPASS_ACTIVE_MASK;
+   writel(val, port->base + MVPP2_GMAC_CTRL_4_REG);
+
+   val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
+   /* configure GIG MAC to 1000BASEX mode */
+   val |= MVPP2_GMAC_PORT_TYPE_MASK;
+   writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
+
+   /* In 1000BaseX mode, we can't negotiate speed (it's
+* only 1000), and we do not want InBand autoneg
+* bypass enabled (link interrupt storm risk
+* 

[PATCH v1 00/10] net: mvpp2: Sync Marvell mvpp2 driver with Marvell version

2021-04-27 Thread Stefan Roese


This patchset adds the missing ethernet mvpp2 patches from the Marvell
U-Boot SDK version to support and fix higher connection speeds. This is
done in preparation for the integration of the Octeon TX2 CN913x
support, which uses the updated version of this code.

Please note that I explicitly did not remove the incorrectly used
PHY_INTERFACE_MODE_SGMII_2500 changes from these patches. This makes it
easier to follow the Marvell downstream code. SGMII_2500 will be
removed by the follow-up patch, that I already did send a bit earlier
today. Sorry, I forgot to send this series earlier.

Thanks,
Stefan


Ben Peled (3):
  net: mvpp2: AN Bypass in 1000 and 2500 basex mode
  net: mvpp2: remove unused define MVPP22_SMI_PHY_ADDR_REG
  net: mvpp2: fix missing switch case break

Marcin Wojtas (2):
  net: mvpp2: remove redundant SMI address configuration
  net: mvpp2: add explicit sgmii-2500 support

Stefan Chulski (5):
  phy: introduce 1000BaseX and 2500BaseX modes
  net: mvpp2: add CP115 port1 10G/5G SFI support
  net: mvpp2: add 1000BaseX and 2500BaseX ppv2 support
  net: mvpp2: Fix 2.5G GMII_SPEED configurations
  net: mvpp2: allow MDIO registration for fixed links

 drivers/net/mvpp2.c | 257 +---
 include/phy_interface.h |   4 +
 2 files changed, 163 insertions(+), 98 deletions(-)

-- 
2.31.1



[PATCH v1 05/10] net: mvpp2: Fix 2.5G GMII_SPEED configurations

2021-04-27 Thread Stefan Roese
From: Stefan Chulski 

GMII_SPEED should be enabled for 2.5G speed

Signed-off-by: Stefan Chulski 
Reviewed-by: Yan Markman 
Reviewed-by: Kostya Porotchkin 
Tested-by: sa_ip-sw-jenkins 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 2043bdf10aa4..ec7cb89a94c8 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4445,7 +4445,8 @@ static void mvpp2_link_event(struct mvpp2_port *port)
if (phydev->duplex)
val |= MVPP2_GMAC_CONFIG_FULL_DUPLEX;
 
-   if (phydev->speed == SPEED_1000)
+   if (phydev->speed == SPEED_1000 ||
+   phydev->speed == 2500)
val |= MVPP2_GMAC_CONFIG_GMII_SPEED;
else if (phydev->speed == SPEED_100)
val |= MVPP2_GMAC_CONFIG_MII_SPEED;
-- 
2.31.1



[PATCH v1 02/10] net: mvpp2: add CP115 port1 10G/5G SFI support

2021-04-27 Thread Stefan Roese
From: Stefan Chulski 

1. Differ between Port1 RGMII and SFI modes in Netcomplex config.
2. Remove XPCS config from SFI mode.
   Port1 doesn't XPCS domain, XPCS config should be removed.
   Access to Port1 XPCS can cause stall.
3. Add Port1 MPCS configurations.

Signed-off-by: Stefan Chulski 
Signed-off-by: Stefan Roese 
---

 drivers/net/mvpp2.c | 75 ++---
 1 file changed, 17 insertions(+), 58 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 1cf522b8fe57..015f5329de74 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -520,8 +520,9 @@ do {
\
 /* Net Complex */
 enum mv_netc_topology {
MV_NETC_GE_MAC2_SGMII   =   BIT(0),
-   MV_NETC_GE_MAC3_SGMII   =   BIT(1),
-   MV_NETC_GE_MAC3_RGMII   =   BIT(2),
+   MV_NETC_GE_MAC2_RGMII   =   BIT(1),
+   MV_NETC_GE_MAC3_SGMII   =   BIT(2),
+   MV_NETC_GE_MAC3_RGMII   =   BIT(3),
 };
 
 enum mv_netc_phase {
@@ -3208,56 +3209,31 @@ static int gop_gpcs_reset(struct mvpp2_port *port, int 
reset)
return 0;
 }
 
-/* Set the internal mux's to the required PCS in the PI */
-static int gop_xpcs_mode(struct mvpp2_port *port, int num_of_lanes)
-{
-   u32 val;
-   int lane;
-
-   switch (num_of_lanes) {
-   case 1:
-   lane = 0;
-   break;
-   case 2:
-   lane = 1;
-   break;
-   case 4:
-   lane = 2;
-   break;
-   default:
-   return -1;
-   }
-
-   /* configure XG MAC mode */
-   val = readl(port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
-   val &= ~MVPP22_XPCS_PCSMODE_MASK;
-   val &= ~MVPP22_XPCS_LANEACTIVE_MASK;
-   val |= (2 * lane) << MVPP22_XPCS_LANEACTIVE_OFFS;
-   writel(val, port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
-
-   return 0;
-}
-
 static int gop_mpcs_mode(struct mvpp2_port *port)
 {
u32 val;
 
/* configure PCS40G COMMON CONTROL */
-   val = readl(port->priv->mpcs_base + PCS40G_COMMON_CONTROL);
+   val = readl(port->priv->mpcs_base + port->gop_id * MVPP22_PORT_OFFSET +
+   PCS40G_COMMON_CONTROL);
val &= ~FORWARD_ERROR_CORRECTION_MASK;
-   writel(val, port->priv->mpcs_base + PCS40G_COMMON_CONTROL);
+   writel(val, port->priv->mpcs_base + port->gop_id * MVPP22_PORT_OFFSET +
+  PCS40G_COMMON_CONTROL);
 
/* configure PCS CLOCK RESET */
-   val = readl(port->priv->mpcs_base + PCS_CLOCK_RESET);
+   val = readl(port->priv->mpcs_base + port->gop_id * MVPP22_PORT_OFFSET +
+   PCS_CLOCK_RESET);
val &= ~CLK_DIVISION_RATIO_MASK;
val |= 1 << CLK_DIVISION_RATIO_OFFS;
-   writel(val, port->priv->mpcs_base + PCS_CLOCK_RESET);
+   writel(val, port->priv->mpcs_base + port->gop_id * MVPP22_PORT_OFFSET +
+  PCS_CLOCK_RESET);
 
val &= ~CLK_DIV_PHASE_SET_MASK;
val |= MAC_CLK_RESET_MASK;
val |= RX_SD_CLK_RESET_MASK;
val |= TX_SD_CLK_RESET_MASK;
-   writel(val, port->priv->mpcs_base + PCS_CLOCK_RESET);
+   writel(val, port->priv->mpcs_base + port->gop_id * MVPP22_PORT_OFFSET +
+  PCS_CLOCK_RESET);
 
return 0;
 }
@@ -3300,22 +3276,6 @@ static int gop_xlg_mac_mode_cfg(struct mvpp2_port *port, 
int num_of_act_lanes)
return 0;
 }
 
-/* Set PCS to reset or exit from reset */
-static int gop_xpcs_reset(struct mvpp2_port *port, int reset)
-{
-   u32 val;
-
-   /* read - modify - write */
-   val = readl(port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
-   if (reset)
-   val &= ~MVPP22_XPCS_PCSRESET;
-   else
-   val |= MVPP22_XPCS_PCSRESET;
-   writel(val, port->priv->xpcs_base + MVPP22_XPCS_GLOBAL_CFG_0_REG);
-
-   return 0;
-}
-
 /* Set the MAC to reset or exit from reset */
 static int gop_xlg_mac_reset(struct mvpp2_port *port, int reset)
 {
@@ -3387,14 +3347,10 @@ static int gop_port_init(struct mvpp2_port *port)
num_of_act_lanes = 2;
mac_num = 0;
/* configure PCS */
-   gop_xpcs_mode(port, num_of_act_lanes);
gop_mpcs_mode(port);
/* configure MAC */
gop_xlg_mac_mode_cfg(port, num_of_act_lanes);
 
-   /* pcs unreset */
-   gop_xpcs_reset(port, 0);
-
/* mac unreset */
gop_xlg_mac_reset(port, 0);
break;
@@ -3465,6 +3421,9 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
phy_interface_t phy_type)
if (gop_id == 2) {
if (phy_type == PHY_INTERFACE_MODE_SGMII)
val |= MV_NETC_GE_MAC2_SGMII;
+   else if (phy_type == PHY_INTERFACE_MODE_RGMII ||
+phy_type == 

[PATCH v1 01/10] phy: introduce 1000BaseX and 2500BaseX modes

2021-04-27 Thread Stefan Roese
From: Stefan Chulski 

Signed-off-by: Stefan Chulski 
Signed-off-by: Stefan Roese 
---

 include/phy_interface.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/phy_interface.h b/include/phy_interface.h
index 841ade311efb..ebb18ecd40c0 100644
--- a/include/phy_interface.h
+++ b/include/phy_interface.h
@@ -25,6 +25,8 @@ typedef enum {
PHY_INTERFACE_MODE_RGMII_RXID,
PHY_INTERFACE_MODE_RGMII_TXID,
PHY_INTERFACE_MODE_RTBI,
+   PHY_INTERFACE_MODE_1000BASEX,
+   PHY_INTERFACE_MODE_2500BASEX,
PHY_INTERFACE_MODE_XGMII,
PHY_INTERFACE_MODE_XAUI,
PHY_INTERFACE_MODE_RXAUI,
@@ -55,6 +57,8 @@ static const char * const phy_interface_strings[] = {
[PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
[PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
[PHY_INTERFACE_MODE_RTBI]   = "rtbi",
+   [PHY_INTERFACE_MODE_1000BASEX]  = "1000base-x",
+   [PHY_INTERFACE_MODE_2500BASEX]  = "2500base-x",
[PHY_INTERFACE_MODE_XGMII]  = "xgmii",
[PHY_INTERFACE_MODE_XAUI]   = "xaui",
[PHY_INTERFACE_MODE_RXAUI]  = "rxaui",
-- 
2.31.1



Re: [PATCH 1/4] arm: mvebu: armada-3720-uDPU.dts: Change back to phy-mode "2500base-x"

2021-04-27 Thread Stefan Roese

Hi Jakov,

On 27.04.21 14:57, Jakov Petrina wrote:

Hi Stefan,

On 27/04/2021 11:48, Stefan Roese wrote:

With commit 8678776df6f5 (arm: mvebu: armada-3720-uDPU: fix PHY mode
definition to sgmii-2500) the PHY mode was switch to "sgmii-2500", even
when this is functionally incorrect since "2500base-x" was not supported
in U-Boot at that time. As this mode is now supported (at least present
in the headers), this patch moves back to the orinal version.



thanks, great to hear that the "2500base-x" PHY mode is now supported in 
U-Boot.


I see just now, that I somehow forgot to send the corresponding changes
to the mvpp2 driver, which include this addition of "2500base-x" to
phy_interfaces.h. I'll send those patches shortly.

Thanks,
Stefan


Signed-off-by: Stefan Roese 
Cc: Jakov Petrina 
Cc: Vladimir Vid 
Cc: Luka Perkov 
---
Jakov, Vladimir: This is completely untested. Could you please review
and let me know, if this works for you?



Unfortunately, I don't have the required hardware with me so I am not 
able to test the change.


Regards,

Jakov


Thanks,
Stefan

  arch/arm/dts/armada-3720-uDPU.dts | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/armada-3720-uDPU.dts 
b/arch/arm/dts/armada-3720-uDPU.dts

index 4b30f3cea8c7..4bf6d2eac798 100644
--- a/arch/arm/dts/armada-3720-uDPU.dts
+++ b/arch/arm/dts/armada-3720-uDPU.dts
@@ -126,14 +126,14 @@
   {
  pinctrl-0 = <_pins>;
  status = "okay";
-    phy-mode = "sgmii-2500";
+    phy-mode = "2500base-x";
  managed = "in-band-status";
  phy = <>;
  };
   {
  status = "okay";
-    phy-mode = "sgmii-2500";
+    phy-mode = "2500base-x";
  managed = "in-band-status";
  phy = <>;
  };




Viele Grüße,
Stefan

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


[PATCH v2 2/2] efi_loader: add PE/COFF image measurement

2021-04-27 Thread Masahisa Kojima
"TCG PC Client Platform Firmware Profile Specification"
requires to measure every attempt to load and execute
a OS Loader(a UEFI application) into PCR[4].
This commit adds the PE/COFF image measurement, extends PCR,
and appends measurement into Event Log.

Signed-off-by: Masahisa Kojima 
---

Changes in v2:
- Remove duplicate  include
- Remove unnecessary __packed attribute
- Add all EV_EFI_* event definition
- Create common function to prepare 8-byte aligned image
- Add measurement for EV_EFI_BOOT_SERVICES_DRIVER and
  EV_EFI_RUNTIME_SERVICES_DRIVER
- Use efi_search_protocol() to get device_path
- Add function comment


 include/efi_loader.h  |   6 +
 include/efi_tcg2.h|   9 ++
 include/tpm-v2.h  |  18 +++
 lib/efi_loader/efi_image_loader.c |  59 +++--
 lib/efi_loader/efi_tcg2.c | 207 --
 5 files changed, 275 insertions(+), 24 deletions(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index de1a496a97..9f2854a255 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -426,6 +426,10 @@ efi_status_t efi_disk_register(void);
 efi_status_t efi_rng_register(void);
 /* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
 efi_status_t efi_tcg2_register(void);
+/* measure the pe-coff image, extend PCR and add Event Log */
+efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
+  struct efi_loaded_image_obj *handle,
+  struct efi_loaded_image *loaded_image_info);
 /* Create handles and protocols for the partitions of a block device */
 int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
   const char *if_typename, int diskid,
@@ -847,6 +851,8 @@ bool efi_secure_boot_enabled(void);
 
 bool efi_capsule_auth_enabled(void);
 
+void *efi_prepare_aligned_image(void *efi, u64 *efi_size, void **new_efi);
+
 bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp,
 WIN_CERTIFICATE **auth, size_t *auth_len);
 
diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h
index 40e241ce31..bcfb98168a 100644
--- a/include/efi_tcg2.h
+++ b/include/efi_tcg2.h
@@ -9,6 +9,7 @@
 #if !defined _EFI_TCG2_PROTOCOL_H_
 #define _EFI_TCG2_PROTOCOL_H_
 
+#include 
 #include 
 
 #define EFI_TCG2_PROTOCOL_GUID \
@@ -53,6 +54,14 @@ struct efi_tcg2_event {
u8 event[];
 } __packed;
 
+struct uefi_image_load_event {
+   efi_physical_addr_t image_location_in_memory;
+   u64 image_length_in_memory;
+   u64 image_link_time_address;
+   u64 length_of_device_path;
+   struct efi_device_path device_path[];
+};
+
 struct efi_tcg2_boot_service_capability {
u8 size;
struct efi_tcg2_version structure_version;
diff --git a/include/tpm-v2.h b/include/tpm-v2.h
index df67a196cf..6e812c017c 100644
--- a/include/tpm-v2.h
+++ b/include/tpm-v2.h
@@ -62,6 +62,24 @@ struct udevice;
 #define EV_CPU_MICROCODE   ((u32)0x0009)
 #define EV_TABLE_OF_DEVICES((u32)0x000B)
 
+/*
+ * event types, cf.
+ * "TCG PC Client Platform Firmware Profile Specification", Family "2.0"
+ * rev 1.04, June 3, 2019
+ */
+#define EV_EFI_EVENT_BASE  ((u32)0x8000)
+#define EV_EFI_VARIABLE_DRIVER_CONFIG  ((u32)0x8001)
+#define EV_EFI_VARIABLE_BOOT   ((u32)0x8002)
+#define EV_EFI_BOOT_SERVICES_APPLICATION   ((u32)0x8003)
+#define EV_EFI_BOOT_SERVICES_DRIVER((u32)0x8004)
+#define EV_EFI_RUNTIME_SERVICES_DRIVER ((u32)0x8005)
+#define EV_EFI_GPT_EVENT   ((u32)0x8006)
+#define EV_EFI_ACTION  ((u32)0x8007)
+#define EV_EFI_PLATFORM_FIRMWARE_BLOB  ((u32)0x8008)
+#define EV_EFI_HANDOFF_TABLES  ((u32)0x8009)
+#define EV_EFI_HCRTM_EVENT ((u32)0x8010)
+#define EV_EFI_VARIABLE_AUTHORITY  ((u32)0x80E0)
+
 /* TPMS_TAGGED_PROPERTY Structure */
 struct tpms_tagged_property {
u32 property;
diff --git a/lib/efi_loader/efi_image_loader.c 
b/lib/efi_loader/efi_image_loader.c
index b8a790bcb9..cc548e1b88 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -302,6 +302,40 @@ static int cmp_pe_section(const void *arg1, const void 
*arg2)
return 1;
 }
 
+/**
+ * efi_prepare_aligned_image() - prepare 8-byte aligned image
+ * @efi:   pointer to the EFI binary
+ * @efi_size:  size of @efi binary
+ * @new_efi:   pointer to the newly allocated image
+ *
+ * If @efi is not 8-byte aligned, this function newly allocates
+ * the image buffer and updates @efi_size.
+ *
+ * Return: valid pointer to a image, return NULL if allocation fails.
+ */
+void *efi_prepare_aligned_image(void *efi, u64 *efi_size, void **new_efi)
+{
+   size_t new_efi_size;
+   void *p;
+
+   /*
+* Size must be 

[PATCH v2 1/2] efi_loader: expose efi_image_parse() even if UEFI Secure Boot is disabled

2021-04-27 Thread Masahisa Kojima
This is preparation for PE/COFF measurement support.
PE/COFF image hash calculation is same in both
UEFI Secure Boot image verification and measurement in
measured boot. PE/COFF image parsing functions are
gathered into efi_image_loader.c, and exposed even if
UEFI Secure Boot is not enabled.

This commit also adds the EFI_SIGNATURE_SUPPORT option
to decide if efi_signature.c shall be compiled.

Signed-off-by: Masahisa Kojima 
---

Changes in v2:
- Remove all #ifdef from efi_image_loader.c and efi_signature.c
- Add EFI_SIGNATURE_SUPPORT option
- Explicitly include 
- Gather PE/COFF parsing functions into efi_image_loader.c
- Move efi_guid_t efi_guid_image_security_database in efi_var_common.c


 lib/efi_loader/Kconfig|  9 
 lib/efi_loader/Makefile   |  2 +-
 lib/efi_loader/efi_image_loader.c | 73 +++
 lib/efi_loader/efi_signature.c| 67 +---
 lib/efi_loader/efi_var_common.c   |  3 ++
 5 files changed, 79 insertions(+), 75 deletions(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 0b99d7c774..f012eb7718 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -174,6 +174,7 @@ config EFI_CAPSULE_AUTHENTICATE
select PKCS7_MESSAGE_PARSER
select PKCS7_VERIFY
select IMAGE_SIGN_INFO
+   select EFI_SIGNATURE_SUPPORT
default n
help
  Select this option if you want to enable capsule
@@ -336,6 +337,7 @@ config EFI_SECURE_BOOT
select X509_CERTIFICATE_PARSER
select PKCS7_MESSAGE_PARSER
select PKCS7_VERIFY
+   select EFI_SIGNATURE_SUPPORT
default n
help
  Select this option to enable EFI secure boot support.
@@ -343,6 +345,13 @@ config EFI_SECURE_BOOT
  it is signed with a trusted key. To do that, you need to install,
  at least, PK, KEK and db.
 
+config EFI_SIGNATURE_SUPPORT
+   bool "Enable signature verification support"
+   depends on EFI_SECURE_BOOT || EFI_CAPSULE_AUTHENTICATE
+   default n
+   help
+ Select this option to enable signature verification support.
+
 config EFI_ESRT
bool "Enable the UEFI ESRT generation"
depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 8bd343e258..fd344cea29 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
 obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
 obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
 obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
-obj-y += efi_signature.o
+obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
 
 EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
 $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
diff --git a/lib/efi_loader/efi_image_loader.c 
b/lib/efi_loader/efi_image_loader.c
index f53ef367ec..b8a790bcb9 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -213,7 +213,68 @@ static void efi_set_code_and_data_type(
}
 }
 
-#ifdef CONFIG_EFI_SECURE_BOOT
+/**
+ * efi_image_region_add() - add an entry of region
+ * @regs:  Pointer to array of regions
+ * @start: Start address of region (included)
+ * @end:   End address of region (excluded)
+ * @nocheck:   flag against overlapped regions
+ *
+ * Take one entry of region [@start, @end[ and insert it into the list.
+ *
+ * * If @nocheck is false, the list will be sorted ascending by address.
+ *   Overlapping entries will not be allowed.
+ *
+ * * If @nocheck is true, the list will be sorted ascending by sequence
+ *   of adding the entries. Overlapping is allowed.
+ *
+ * Return: status code
+ */
+efi_status_t efi_image_region_add(struct efi_image_regions *regs,
+ const void *start, const void *end,
+ int nocheck)
+{
+   struct image_region *reg;
+   int i, j;
+
+   if (regs->num >= regs->max) {
+   EFI_PRINT("%s: no more room for regions\n", __func__);
+   return EFI_OUT_OF_RESOURCES;
+   }
+
+   if (end < start)
+   return EFI_INVALID_PARAMETER;
+
+   for (i = 0; i < regs->num; i++) {
+   reg = >reg[i];
+   if (nocheck)
+   continue;
+
+   /* new data after registered region */
+   if (start >= reg->data + reg->size)
+   continue;
+
+   /* new data preceding registered region */
+   if (end <= reg->data) {
+   for (j = regs->num - 1; j >= i; j--)
+   memcpy(>reg[j + 1], >reg[j],
+  sizeof(*reg));
+   break;
+   }
+
+   /* new data overlapping registered region */
+   EFI_PRINT("%s: new region already part of another\n", __func__);
+   

[PATCH v2 0/2] PE/COFF measurement support

2021-04-27 Thread Masahisa Kojima
This patch series add the PE/COFF measurement support.
Extending PCR and Event Log is tested with fTPM
running as a OP-TEE TA.
Unit test will be added in the separate series.

Masahisa Kojima (2):
  efi_loader: expose efi_image_parse() even if UEFI Secure Boot is
disabled
  efi_loader: add PE/COFF image measurement

 include/efi_loader.h  |   6 +
 include/efi_tcg2.h|   9 ++
 include/tpm-v2.h  |  18 +++
 lib/efi_loader/Kconfig|   9 ++
 lib/efi_loader/Makefile   |   2 +-
 lib/efi_loader/efi_image_loader.c | 132 +++
 lib/efi_loader/efi_signature.c|  67 +-
 lib/efi_loader/efi_tcg2.c | 207 --
 lib/efi_loader/efi_var_common.c   |   3 +
 9 files changed, 354 insertions(+), 99 deletions(-)

-- 
2.17.1



Re: [PATCH 1/4] arm: mvebu: armada-3720-uDPU.dts: Change back to phy-mode "2500base-x"

2021-04-27 Thread Jakov Petrina

Hi Stefan,

On 27/04/2021 11:48, Stefan Roese wrote:

With commit 8678776df6f5 (arm: mvebu: armada-3720-uDPU: fix PHY mode
definition to sgmii-2500) the PHY mode was switch to "sgmii-2500", even
when this is functionally incorrect since "2500base-x" was not supported
in U-Boot at that time. As this mode is now supported (at least present
in the headers), this patch moves back to the orinal version.



thanks, great to hear that the "2500base-x" PHY mode is now supported in 
U-Boot.



Signed-off-by: Stefan Roese 
Cc: Jakov Petrina 
Cc: Vladimir Vid 
Cc: Luka Perkov 
---
Jakov, Vladimir: This is completely untested. Could you please review
and let me know, if this works for you?



Unfortunately, I don't have the required hardware with me so I am not 
able to test the change.


Regards,

Jakov


Thanks,
Stefan

  arch/arm/dts/armada-3720-uDPU.dts | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/armada-3720-uDPU.dts 
b/arch/arm/dts/armada-3720-uDPU.dts
index 4b30f3cea8c7..4bf6d2eac798 100644
--- a/arch/arm/dts/armada-3720-uDPU.dts
+++ b/arch/arm/dts/armada-3720-uDPU.dts
@@ -126,14 +126,14 @@
   {
pinctrl-0 = <_pins>;
status = "okay";
-   phy-mode = "sgmii-2500";
+   phy-mode = "2500base-x";
managed = "in-band-status";
phy = <>;
  };
  
   {

status = "okay";
-   phy-mode = "sgmii-2500";
+   phy-mode = "2500base-x";
managed = "in-band-status";
phy = <>;
  };



[PATCH v2,2/2] driver: watchdog: enable wdt command by default

2021-04-27 Thread Meng . Li
From: MengLi 

In latest u-boot code, watchdog feature is implemented, so enable
wdt command by default.

Signed-off-by: Meng Li 
---
 configs/socfpga_stratix10_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/socfpga_stratix10_defconfig 
b/configs/socfpga_stratix10_defconfig
index 02d4ac0dae..0256afe511 100644
--- a/configs/socfpga_stratix10_defconfig
+++ b/configs/socfpga_stratix10_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_WDT=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.17.1



[PATCH v2, 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Meng . Li
From: MengLi 

In uboot command line environment, watchdog is not able to be
stopped with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

v2:
Change "#if CONFIG_IS_ENABLED(DM_RESET)" into
"if (CONFIG_IS_ENABLED(DM_RESET)) {", and define the variable
into if condition sentence.

Signed-off-by: Meng Li 
---
 drivers/watchdog/designware_wdt.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/watchdog/designware_wdt.c 
b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..57cad1effc 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -96,6 +96,23 @@ static int designware_wdt_stop(struct udevice *dev)
designware_wdt_reset(dev);
writel(0, priv->base + DW_WDT_CR);
 
+if (CONFIG_IS_ENABLED(DM_RESET)) {
+   struct reset_ctl_bulk resets;
+   int ret;
+
+   ret = reset_get_bulk(dev, );
+   if (ret)
+   return ret;
+
+   ret = reset_assert_bulk();
+   if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk();
+   if (ret)
+   return ret;
+   }
+
return 0;
 }
 
-- 
2.17.1



Re: [PATCH 1/5] clk: ti: add custom API for memory access

2021-04-27 Thread Tero Kristo

Hi Dario,

One question below.

On 25/04/2021 17:17, Dario Binacchi wrote:

As pointed by [1] and [2], commit
d64b9cdcd4 ("fdt: translate address if #size-cells = <0>") is wrong:
- It makes every 'reg' DT property translatable. It changes the address
   translation so that for an I2C 'reg' address you'll get back as reg
   the I2C controller address + reg value.
- The quirk must be fixed with platform code.

The clk_ti_get_reg_addr() is the platform code able to make the correct
address translation for the AM33xx clocks registers. Its implementation
was inspired by the Linux Kernel code.

[1] 
https://patchwork.ozlabs.org/project/uboot/patch/1614324949-61314-1-git-send-email-bmeng...@gmail.com/
[2] 
https://lore.kernel.org/linux-clk/20210402192054.7934-1-dario...@libero.it/T/

Signed-off-by: Dario Binacchi 
---

  drivers/clk/ti/clk.c | 92 
  drivers/clk/ti/clk.h | 13 +++
  2 files changed, 105 insertions(+)

diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index c999df213a..68abe053cb 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -6,10 +6,23 @@
   */
  
  #include 

+#include 
  #include 
+#include 
  #include 
+#include 
  #include "clk.h"
  
+#define CLK_MAX_MEMMAPS   10

+
+struct clk_iomap {
+   struct regmap *regmap;
+   ofnode node;
+};
+
+static unsigned int clk_memmaps_num;
+static struct clk_iomap clk_memmaps[CLK_MAX_MEMMAPS];
+
  static void clk_ti_rmw(u32 val, u32 mask, fdt_addr_t reg)
  {
u32 v;
@@ -33,3 +46,82 @@ void clk_ti_latch(fdt_addr_t reg, s8 shift)
clk_ti_rmw(0, latch, reg);
readl(reg); /* OCP barrier */
  }
+
+void clk_ti_writel(u32 val, struct clk_ti_reg *reg)
+{
+   struct clk_iomap *io = _memmaps[reg->index];
+
+   regmap_write(io->regmap, reg->offset, val);
+}
+
+u32 clk_ti_readl(struct clk_ti_reg *reg)
+{
+   struct clk_iomap *io = _memmaps[reg->index];
+   u32 val;
+
+   regmap_read(io->regmap, reg->offset, );
+   return val;
+}
+
+#if CONFIG_IS_ENABLED(AM33XX)


Why do you have this ifdef here? These drivers are not planned to be 
used by anything but am33xx, or they don't work on any other device?


-Tero


+static ofnode clk_ti_get_regmap_node(struct udevice *dev)
+{
+   ofnode node = dev_ofnode(dev), parent;
+
+   if (!ofnode_valid(node))
+   return ofnode_null();
+
+   parent = ofnode_get_parent(node);
+   if (strcmp(ofnode_get_name(parent), "clocks"))
+   return ofnode_null();
+
+   return ofnode_get_parent(parent);
+}
+#else
+static ofnode clk_ti_get_regmap_node(struct udevice *dev)
+{
+   return ofnode_null();
+}
+#endif
+
+int clk_ti_get_reg_addr(struct udevice *dev, int index, struct clk_ti_reg *reg)
+{
+   ofnode node;
+   int i, ret;
+   u32 val;
+
+   ret = ofnode_read_u32_index(dev_ofnode(dev), "reg", index, );
+   if (ret) {
+   dev_err(dev, "%s must have reg[%d]\n", ofnode_get_name(node),
+   index);
+   return ret;
+   }
+
+   /* parent = ofnode_get_parent(parent); */
+   node = clk_ti_get_regmap_node(dev);
+   if (!ofnode_valid(node)) {
+   dev_err(dev, "failed to get regmap node\n");
+   return -EFAULT;
+   }
+
+   for (i = 0; i < clk_memmaps_num; i++) {
+   if (ofnode_equal(clk_memmaps[i].node, node))
+   break;
+   }
+
+   if (i == clk_memmaps_num) {
+   if (i == CLK_MAX_MEMMAPS)
+   return -ENOMEM;
+
+   ret = regmap_init_mem(node, _memmaps[i].regmap);
+   if (ret)
+   return ret;
+
+   clk_memmaps[i].node = node;
+   clk_memmaps_num++;
+   }
+
+   reg->index = i;
+   reg->offset = val;
+   return 0;
+}
diff --git a/drivers/clk/ti/clk.h b/drivers/clk/ti/clk.h
index 601c3823f7..ea36d065ac 100644
--- a/drivers/clk/ti/clk.h
+++ b/drivers/clk/ti/clk.h
@@ -9,5 +9,18 @@
  #define _CLK_TI_H
  
  void clk_ti_latch(fdt_addr_t reg, s8 shift);

+/**
+ * struct clk_ti_reg - TI register declaration
+ * @offset: offset from the master IP module base address
+ * @index: index of the master IP module
+ */
+struct clk_ti_reg {
+   u16 offset;
+   u8 index;
+};
+
+void clk_ti_writel(u32 val, struct clk_ti_reg *reg);
+u32 clk_ti_readl(struct clk_ti_reg *reg);
+int clk_ti_get_reg_addr(struct udevice *dev, int index, struct clk_ti_reg 
*reg);
  
  #endif /* #ifndef _CLK_TI_H */






Re: [PATCH] mips: octeon: octeon_ebb7304_defconfig: Fix CFI flash setup

2021-04-27 Thread Daniel Schwierzeck
Am Montag, den 26.04.2021, 16:43 +0200 schrieb Stefan Roese:
> This patch makes the necessary adjustments in the defconfig to fully
> support the CFI flash on the Octeon EBB7304.
> 
> Signed-off-by: Stefan Roese 
> Cc: Aaron Williams 
> Cc: Chandrakala Chavva 
> Cc: Daniel Schwierzeck 
> ---
>  configs/octeon_ebb7304_defconfig | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> 

applied to u-boot-mips, thanks.

-- 
- Daniel



Re: [PATCH 0/2] reset: fix reset_get_by_index_nodev index handling

2021-04-27 Thread Tom Rini
On Tue, Apr 27, 2021 at 09:37:11AM +0200, Neil Armstrong wrote:
> Hi Tom, Simon,
> 
> On 20/04/2021 10:42, Neil Armstrong wrote:
> > A regression weas detected on Amlogic G12A/G12B SoCs, where HDMI output was 
> > disable
> > even when Linux was booting.
> > 
> > Bisect reports 139e4a1cbe ("drivers: reset: Add a managed API to get reset 
> > controllers from the DT")
> > as the offending commit.
> > 
> > But the error is in ea9dc35aab ("reset: Get the RESET by index without 
> > device") where a spurius "> 0"
> > was added to the index handling.
> > 
> > But the dm_test_reset_base() test did not catch it.
> > 
> > The first commit extends the test to catch the regression, and the second 
> > patch fixes the regression.
> 
> So you have any comment on the patch order here ? Should I push the fixed 
> test after the fix ?

I'll grab these shortly, thanks for the reminder.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] net: phy: xilinx: Break while loop over ethernet phy

2021-04-27 Thread Michal Simek
Hi Bin,

On 4/27/21 7:17 AM, Bin Meng wrote:
> Hi Michal,
> 
> On Mon, Apr 26, 2021 at 8:31 PM Michal Simek  wrote:
>>
>> The commit 6c993815bbea ("net: phy: xilinx: Be compatible with live OF
>> tree") change driver behavior to while loop which wasn't correct because
>> the driver was looping over again and again. The reason was that
>> ofnode_valid() is taking 0 as correct value.
> 
> I am still trying to understand the problem. The changes in
> 6c993815bbea sound correct from an fdtdec <=> OF API mapping
> perspective. If the new OF API does not work, the old fdtdec may fail
> too. Could you please explain a little bit?

here is behavior of origin code.

ZYNQ GEM: ff0e, mdio bus ff0e, phyaddr 12, interface rgmii-id
phy_connect_gmii2rgmii sn 11348
phy_connect_gmii2rgmii 1off -1
phy_connect_gmii2rgmii 2off -1
phy_connect_gmii2rgmii sn2 11752
phy_connect_gmii2rgmii 1off -1
phy_connect_gmii2rgmii 2off -1
phy_connect_gmii2rgmii sn2 -1
phy_connect_gmii2rgmii phydev 
eth0: ethernet@ff0e
Scanning disk m...@ff17.blk...
Found 4 disks
Hit any key to stop autoboot:  0
ZynqMP>


diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 89e3076bfd25..d0960d93ae08 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -956,22 +956,28 @@ static struct phy_device
*phy_connect_gmii2rgmii(struct mii_dev *bus,
int sn = dev_of_offset(dev);
int off;

+   printf("%s sn %d\n", __func__, sn);
while (sn > 0) {
off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,

"xlnx,gmii-to-rgmii-1.0");
+   printf("%s 1off %d\n", __func__, off);
if (off > 0) {
phydev = phy_device_create(bus, off,
   PHY_GMII2RGMII_ID, false,
   interface);
break;
}
-   if (off == -FDT_ERR_NOTFOUND)
+   printf("%s 2off %d\n", __func__, off);
+
+   if (off == -FDT_ERR_NOTFOUND) {
sn = fdt_first_subnode(gd->fdt_blob, sn);
-   else
+   printf("%s sn2 %d\n", __func__, sn);
+   } else
printf("%s: Error finding compat string:%d\n",
   __func__, off);
}

+   printf("%s phydev %p\n", __func__, phydev);
return phydev;
 }
 #endif


With latest code and some prints
ZYNQ GEM: ff0e, mdio bus ff0e, phyaddr 12, interface rgmii-id
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 2952
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset -1
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 11348
phy_connect_gmii2rgmii 1valid 1 ethernet@ff0e
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 11348
ofnode_valid: node.of_offset 11348
phy_connect_gmii2rgmii 2valid 1 ethernet@ff0e
ofnode_valid: node.of_offset -1
ofnode_valid: node.of_offset -1
ofnode_valid: node.of_offset 0
ofnode_valid: node.of_offset 0
phy_connect_gmii2rgmii 3valid 1
ofnode_valid: node.of_offset 0
ofnode_valid: node.of_offset 0
ofnode_valid: node.of_offset 0
phy_connect_gmii2rgmii 2valid 1
ofnode_valid: node.of_offset -1
ofnode_valid: node.of_offset -1
ofnode_valid: node.of_offset 0
ofnode_valid: node.of_offset 0
phy_connect_gmii2rgmii 3valid 1
...


[u-boot](debian-sent)$ git diff
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index dcdef9e661d6..56072ad55216 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -950,7 +950,10 @@ static struct phy_device
*phy_connect_gmii2rgmii(struct mii_dev *bus,
struct phy_device *phydev = NULL;
ofnode node = dev_ofnode(dev);

+   printf("%s 1valid %d %s\n", __func__, ofnode_valid(node),
ofnode_get_name(node));
+
while (ofnode_valid(node)) {
+   printf("%s 2valid %d %s\n", __func__,
ofnode_valid(node), ofnode_get_name(node));
node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0");
if (ofnode_valid(node)) {
phydev = phy_device_create(bus, 0,
@@ -962,6 +965,7 @@ static struct phy_device
*phy_connect_gmii2rgmii(struct mii_dev *bus,
}

node = ofnode_first_subnode(node);
+   printf("%s 3valid %d %s\n", __func__,
ofnode_valid(node), ofnode_get_name(node));
}

return phydev;


diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 2c0597c40739..7bfc06165e92 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -128,8 +128,10 @@ static inline bool ofnode_valid(ofnode node)
 {
if (of_live_active())
return node.np != NULL;
-   else
+   else {
+   printf("ofnode_valid: node.of_offset %ld\n",
node.of_offset);
return node.of_offset >= 0;
+   }
 

Re: [PATCH v7 00/14] mtd: spi-nor: Add support for Cypress s25hl-t/s25hs-t

2021-04-27 Thread Jagan Teki
On Tue, Apr 27, 2021 at 7:54 AM  wrote:
>
> From: Takahiro Kuwano 
>
> The S25HL-T/S25HS-T family is the Cypress Semper Flash with Quad SPI.
>
> The summary datasheets can be found in the following links.
> https://www.cypress.com/file/424146/download (256Mb/512Mb/1Gb, single die)
> https://www.cypress.com/file/499246/download (2Gb/4Gb, dual/quad die)
>
> The full version can be found in the following links (registration
> required).
> https://community.cypress.com/t5/Semper-Flash-Access-Program/Datasheet-Semper-Flash-with-Quad-SPI/ta-p/260789?attachment-id=19522
> https://community.cypress.com/t5/Semper-Flash-Access-Program/Datasheet-2Gb-MCP-Semper-Flash-with-Quad-SPI/ta-p/260823?attachment-id=29503
>
> Tested on Xilinx Zynq-7000 FPGA board.
>
> Changes since v7:
>   - Fixed return type of s25hx_t_erase_non_uniform() to 'int'

If you have core changes that indeed affect most, better to send them
only if they are fine with all builds.

https://source.denx.de/u-boot/custodians/u-boot-spi/-/pipelines/7323

Jagan.


[PATCH 4/4] net: mvpp2: Remove PHY_INTERFACE_MODE_SGMII_2500

2021-04-27 Thread Stefan Roese
As was discussed on the list, PHY_INTERFACE_MODE_SGMII_2500 is used
incorrectly in the Marvell mvpp2 network driver and the Marvell PHY
code. This patch removes the references to this macro in the mvpp2
network driver for now.

The correct support shall be implemented at a later time.

Signed-off-by: Stefan Roese 
Cc: Konstantin Porotchkin 
Cc: Stefan Chulski 
Cc: Nadav Haklai 
Cc: Marek Behun 
---
This patch is targeted on-top of the latest Marvell SERDES, mvpp2 and
PHY patches to resolve the ongoing discussion of the incorrect usage of
SGMII_2500 for now.

 drivers/net/mvpp2.c | 53 -
 1 file changed, 53 deletions(-)

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 4c0a7b0a9f5c..b0287f561e2e 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -2873,7 +2873,6 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port)
 
switch (port->phy_interface) {
case PHY_INTERFACE_MODE_SGMII:
-   case PHY_INTERFACE_MODE_SGMII_2500:
val |= MVPP2_GMAC_INBAND_AN_MASK;
break;
case PHY_INTERFACE_MODE_1000BASEX:
@@ -2941,7 +2940,6 @@ static void mvpp2_port_loopback_set(struct mvpp2_port 
*port)
val &= ~MVPP2_GMAC_GMII_LB_EN_MASK;
 
if (port->phy_interface == PHY_INTERFACE_MODE_SGMII ||
-   port->phy_interface == PHY_INTERFACE_MODE_SGMII_2500 ||
port->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
port->phy_interface == PHY_INTERFACE_MODE_2500BASEX)
val |= MVPP2_GMAC_PCS_LB_EN_MASK;
@@ -3029,48 +3027,6 @@ static int gop_bypass_clk_cfg(struct mvpp2_port *port, 
int en)
return 0;
 }
 
-static void gop_gmac_sgmii2_5_cfg(struct mvpp2_port *port)
-{
-   u32 val, thresh;
-
-   /*
-* Configure minimal level of the Tx FIFO before the lower part
-* starts to read a packet
-*/
-   thresh = MVPP2_SGMII2_5_TX_FIFO_MIN_TH;
-   val = readl(port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
-   val &= ~MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK;
-   val |= MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(thresh);
-   writel(val, port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
-
-   /* Disable bypass of sync module */
-   val = readl(port->base + MVPP2_GMAC_CTRL_4_REG);
-   val |= MVPP2_GMAC_CTRL4_SYNC_BYPASS_MASK;
-   /* configure DP clock select according to mode */
-   val |= MVPP2_GMAC_CTRL4_DP_CLK_SEL_MASK;
-   /* configure QSGMII bypass according to mode */
-   val |= MVPP2_GMAC_CTRL4_QSGMII_BYPASS_ACTIVE_MASK;
-   writel(val, port->base + MVPP2_GMAC_CTRL_4_REG);
-
-   val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
-   /*
-* Configure GIG MAC to SGMII mode connected to a fiber
-* transceiver
-*/
-   val &= ~MVPP2_GMAC_PORT_TYPE_MASK;
-   writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
-
-   /* configure AN 0x9268 */
-   val = MVPP2_GMAC_EN_PCS_AN |
-   MVPP2_GMAC_AN_BYPASS_EN |
-   MVPP2_GMAC_CONFIG_MII_SPEED  |
-   MVPP2_GMAC_CONFIG_GMII_SPEED |
-   MVPP2_GMAC_FC_ADV_EN|
-   MVPP2_GMAC_CONFIG_FULL_DUPLEX |
-   MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG;
-   writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
-}
-
 static void gop_gmac_sgmii_cfg(struct mvpp2_port *port)
 {
u32 val, thresh;
@@ -3241,9 +3197,6 @@ static int gop_gmac_mode_cfg(struct mvpp2_port *port)
case PHY_INTERFACE_MODE_SGMII:
gop_gmac_sgmii_cfg(port);
break;
-   case PHY_INTERFACE_MODE_SGMII_2500:
-   gop_gmac_sgmii2_5_cfg(port);
-   break;
case PHY_INTERFACE_MODE_1000BASEX:
gop_gmac_1000basex_cfg(port);
break;
@@ -3424,7 +3377,6 @@ static int gop_port_init(struct mvpp2_port *port)
break;
 
case PHY_INTERFACE_MODE_SGMII:
-   case PHY_INTERFACE_MODE_SGMII_2500:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
/* configure PCS */
@@ -3484,7 +3436,6 @@ static void gop_port_enable(struct mvpp2_port *port, int 
enable)
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_SGMII:
-   case PHY_INTERFACE_MODE_SGMII_2500:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
if (enable)
@@ -3521,7 +3472,6 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
phy_interface_t phy_type)
 
if (gop_id == 2) {
if (phy_type == PHY_INTERFACE_MODE_SGMII ||
-   phy_type == PHY_INTERFACE_MODE_SGMII_2500 ||
phy_type == PHY_INTERFACE_MODE_1000BASEX ||
phy_type == PHY_INTERFACE_MODE_2500BASEX)
val |= MV_NETC_GE_MAC2_SGMII;
@@ -3532,7 +3482,6 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
phy_interface_t 

[PATCH 3/4] net: phy: marvell: Remove PHY_INTERFACE_MODE_SGMII_2500

2021-04-27 Thread Stefan Roese
As was discussed on the list, PHY_INTERFACE_MODE_SGMII_2500 is used
incorrectly in the Marvell mvpp2 network driver and the Marvell PHY
code. This patch removes the references to this macro in the Marvell
PHY driver for now.

The correct support shall be implemented at a later time.

Signed-off-by: Stefan Roese 
Cc: Konstantin Porotchkin 
Cc: Stefan Chulski 
Cc: Nadav Haklai 
Cc: Marek Behun 
---
This patch is targeted on-top of the latest Marvell SERDES, mvpp2 and
PHY patches to resolve the ongoing discussion of the incorrect usage of
SGMII_2500 for now.

 drivers/net/phy/marvell.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 3bcb0033b391..8850b604ef47 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -634,8 +634,7 @@ static int m88e2110_config(struct phy_device *phydev)
/* Disabled 10G advertisement */
phy_write(phydev, 7, 0x20, 0x1e1);
} else {
-   if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500 ||
-   phydev->interface == PHY_INTERFACE_MODE_2500BASEX) {
+   if (phydev->interface == PHY_INTERFACE_MODE_2500BASEX) {
/* Disabled 10G/5G advertisements */
phy_write(phydev, 7, 0x20, 0xa1);
} else {
-- 
2.31.1



[PATCH 1/4] arm: mvebu: armada-3720-uDPU.dts: Change back to phy-mode "2500base-x"

2021-04-27 Thread Stefan Roese
With commit 8678776df6f5 (arm: mvebu: armada-3720-uDPU: fix PHY mode
definition to sgmii-2500) the PHY mode was switch to "sgmii-2500", even
when this is functionally incorrect since "2500base-x" was not supported
in U-Boot at that time. As this mode is now supported (at least present
in the headers), this patch moves back to the orinal version.

Signed-off-by: Stefan Roese 
Cc: Jakov Petrina 
Cc: Vladimir Vid 
Cc: Luka Perkov 
---
Jakov, Vladimir: This is completely untested. Could you please review
and let me know, if this works for you?

Thanks,
Stefan

 arch/arm/dts/armada-3720-uDPU.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/armada-3720-uDPU.dts 
b/arch/arm/dts/armada-3720-uDPU.dts
index 4b30f3cea8c7..4bf6d2eac798 100644
--- a/arch/arm/dts/armada-3720-uDPU.dts
+++ b/arch/arm/dts/armada-3720-uDPU.dts
@@ -126,14 +126,14 @@
  {
pinctrl-0 = <_pins>;
status = "okay";
-   phy-mode = "sgmii-2500";
+   phy-mode = "2500base-x";
managed = "in-band-status";
phy = <>;
 };
 
  {
status = "okay";
-   phy-mode = "sgmii-2500";
+   phy-mode = "2500base-x";
managed = "in-band-status";
phy = <>;
 };
-- 
2.31.1



[PATCH 2/4] arm: octeontx2: cn9130-crb.dtsi: Disable eth2 for now

2021-04-27 Thread Stefan Roese
Because of the incorrectly supported SGMII_2500 mode, this patch
disables eth2 for now until this issue will be fixed in mainline.

Also fix an incorrect comment.

Signed-off-by: Stefan Roese 
Cc: Konstantin Porotchkin 
Cc: Stefan Chulski 
Cc: Nadav Haklai 
Cc: Marek Behun 
---
This patch is targeted on-top of the latest Marvell SERDES, mvpp2 and
PHY patches to resolve the ongoing discussion of the incorrect usage of
SGMII_2500 for now.

 arch/arm/dts/cn9130-crb.dtsi | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/dts/cn9130-crb.dtsi b/arch/arm/dts/cn9130-crb.dtsi
index 657a934764ae..78b43b449b3e 100644
--- a/arch/arm/dts/cn9130-crb.dtsi
+++ b/arch/arm/dts/cn9130-crb.dtsi
@@ -232,7 +232,6 @@
 };
 
 _eth0 {
-   /* Disable it for now, as mainline does not support this IF yet */
status = "okay";
phy-mode = "sfi";
 };
@@ -247,7 +246,6 @@
 
 _eth2 {
/* Disable it for now, as mainline does not support this IF yet */
-   status = "okay";
+   status = "disabled";
phy = <_phy0>;
-   phy-mode = "sgmii-2500";
 };
-- 
2.31.1



Re: [PATCH] usb: musb-new: Extend Allwinner quirk to newer SoCs

2021-04-27 Thread Jagan Teki
On Tue, Apr 27, 2021 at 1:41 PM Andre Przywara  wrote:
>
> On Tue, 27 Apr 2021 02:37:20 +0200
> Marek Vasut  wrote:
>
> Hi,
>
> > On 4/27/21 2:03 AM, Andre Przywara wrote:
> > > As the comment in musb_regs.h describes, Allwinner saves the
> > > MUSB_CONFIGDATA register, which always return 0 on those SoCs.
> > >
> > > This is also true for the H6 and H616, so extend the quirk to those
> > > controllers as well.
> > >
> > > This fixes USB peripheral mode on H6 and H616 boards.
> > >
> > > Signed-off-by: Andre Przywara 
> > > ---
> > >   drivers/usb/musb-new/musb_regs.h | 3 ++-
> > >   1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/musb-new/musb_regs.h 
> > > b/drivers/usb/musb-new/musb_regs.h
> > > index c4d7203b851..bee1b715a95 100644
> > > --- a/drivers/usb/musb-new/musb_regs.h
> > > +++ b/drivers/usb/musb-new/musb_regs.h
> > > @@ -432,7 +432,8 @@ static inline u8 musb_read_ulpi_buscontrol(void 
> > > __iomem *mbase)
> > >   static inline u8 musb_read_configdata(void __iomem *mbase)
> > >   {
> > >   #if defined CONFIG_MACH_SUN8I_A33 || defined CONFIG_MACH_SUN8I_A83T || \
> > > -   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I
> > > +   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I || \
> > > +   defined CONFIG_SUN50I_GEN_H6
> >
> > Isn't there some better solution then ever-growing list of macros to
> > check, like e.g. a single CONFIG_MACH_SUNXI ?
>
> I was wondering the same, but I think this does not apply to the older
> SoCs (we use ARCH_SUNXI in the two functions above and below, so I
> guess the differentiation here is deliberate). I will test this later.
>
> So we could probably use the quirk also for the older, working(?) SoCs,
> but I am not sure we should do that. CONFIG_SUN50I_GEN_H6 is already a
> symbol covering multiple SoCs, so ideally we won't need to add many
> more.
> I can have a look if we have other checks like that in the code, then
> maybe define a collective symbol for newer SoCs?

The better approach is to support config_read via musb_platform_ops.
If so, we can identify the offsets to endpoint registers using SoC
musb reg space and return the relevant 16-bit config value.

Jagan.


Re: [PATCH] usb: musb-new: Extend Allwinner quirk to newer SoCs

2021-04-27 Thread Marek Vasut

On 4/27/21 10:10 AM, Andre Przywara wrote:

On Tue, 27 Apr 2021 02:37:20 +0200
Marek Vasut  wrote:

Hi,


On 4/27/21 2:03 AM, Andre Przywara wrote:

As the comment in musb_regs.h describes, Allwinner saves the
MUSB_CONFIGDATA register, which always return 0 on those SoCs.

This is also true for the H6 and H616, so extend the quirk to those
controllers as well.

This fixes USB peripheral mode on H6 and H616 boards.

Signed-off-by: Andre Przywara 
---
   drivers/usb/musb-new/musb_regs.h | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb-new/musb_regs.h b/drivers/usb/musb-new/musb_regs.h
index c4d7203b851..bee1b715a95 100644
--- a/drivers/usb/musb-new/musb_regs.h
+++ b/drivers/usb/musb-new/musb_regs.h
@@ -432,7 +432,8 @@ static inline u8 musb_read_ulpi_buscontrol(void __iomem 
*mbase)
   static inline u8 musb_read_configdata(void __iomem *mbase)
   {
   #if defined CONFIG_MACH_SUN8I_A33 || defined CONFIG_MACH_SUN8I_A83T || \
-   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I
+   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I || \
+   defined CONFIG_SUN50I_GEN_H6


Isn't there some better solution then ever-growing list of macros to
check, like e.g. a single CONFIG_MACH_SUNXI ?


I was wondering the same, but I think this does not apply to the older
SoCs (we use ARCH_SUNXI in the two functions above and below, so I
guess the differentiation here is deliberate). I will test this later.

So we could probably use the quirk also for the older, working(?) SoCs,
but I am not sure we should do that. CONFIG_SUN50I_GEN_H6 is already a
symbol covering multiple SoCs, so ideally we won't need to add many
more.
I can have a look if we have other checks like that in the code, then
maybe define a collective symbol for newer SoCs?


Yes please


[PATCH] dm: define LOG_CATEGORY for all uclass

2021-04-27 Thread Patrick Delaunay
Define LOG_CATEGORY for all uclass to allow filtering with
log command.

Signed-off-by: Patrick Delaunay 
---

 drivers/adc/adc-uclass.c| 2 ++
 drivers/ata/ahci-uclass.c   | 2 ++
 drivers/axi/axi-emul-uclass.c   | 2 ++
 drivers/axi/axi-uclass.c| 2 ++
 drivers/block/blk-uclass.c  | 2 ++
 drivers/block/ide.c | 2 ++
 drivers/bootcount/bootcount-uclass.c| 2 ++
 drivers/button/button-uclass.c  | 2 ++
 drivers/cache/cache-uclass.c| 2 ++
 drivers/clk/clk-uclass.c| 2 ++
 drivers/core/root.c | 2 ++
 drivers/core/simple-bus.c   | 2 ++
 drivers/cpu/cpu-uclass.c| 2 ++
 drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 2 ++
 drivers/dma/dma-uclass.c| 2 ++
 drivers/firmware/firmware-uclass.c  | 2 ++
 drivers/hwspinlock/hwspinlock-uclass.c  | 2 ++
 drivers/i2c/i2c-emul-uclass.c   | 2 ++
 drivers/i2c/i2c-uclass.c| 2 ++
 drivers/i2c/muxes/i2c-mux-uclass.c  | 2 ++
 drivers/input/keyboard-uclass.c | 2 ++
 drivers/led/led-uclass.c| 2 ++
 drivers/mailbox/mailbox-uclass.c| 2 ++
 drivers/misc/fs_loader.c| 3 +++
 drivers/misc/i2c_eeprom.c   | 2 ++
 drivers/misc/misc-uclass.c  | 2 ++
 drivers/misc/p2sb-uclass.c  | 2 ++
 drivers/misc/pwrseq-uclass.c| 2 ++
 drivers/mmc/mmc-uclass.c| 2 ++
 drivers/mtd/mtd-uclass.c| 2 ++
 drivers/mtd/spi/sf-uclass.c | 2 ++
 drivers/mux/mux-uclass.c| 2 ++
 drivers/nvme/nvme-uclass.c  | 2 ++
 drivers/pch/pch-uclass.c| 2 ++
 drivers/pci/pci-uclass.c| 2 ++
 drivers/pci_endpoint/pci_ep-uclass.c| 2 ++
 drivers/phy/phy-uclass.c| 2 ++
 drivers/pinctrl/pinctrl-uclass.c| 2 ++
 drivers/power/domain/power-domain-uclass.c  | 2 ++
 drivers/power/pmic/pmic-uclass.c| 2 ++
 drivers/power/regulator/regulator-uclass.c  | 2 ++
 drivers/pwm/pwm-uclass.c| 2 ++
 drivers/ram/ram-uclass.c| 2 ++
 drivers/remoteproc/rproc-uclass.c   | 3 +++
 drivers/reset/reset-uclass.c| 2 ++
 drivers/rng/rng-uclass.c| 2 ++
 drivers/rtc/rtc-uclass.c| 2 ++
 drivers/scsi/scsi-uclass.c  | 2 ++
 drivers/serial/serial-uclass.c  | 2 ++
 drivers/smem/smem-uclass.c  | 2 ++
 drivers/soc/soc-uclass.c| 2 ++
 drivers/sound/codec-uclass.c| 2 ++
 drivers/sound/i2s-uclass.c  | 2 ++
 drivers/sound/sound-uclass.c| 2 ++
 drivers/spi/spi-emul-uclass.c   | 2 ++
 drivers/spmi/spmi-uclass.c  | 2 ++
 drivers/sysinfo/sysinfo-uclass.c| 2 ++
 drivers/tee/tee-uclass.c| 2 ++
 drivers/thermal/thermal-uclass.c| 2 ++
 drivers/timer/timer-uclass.c| 2 ++
 drivers/ufs/ufs-uclass.c| 2 ++
 drivers/usb/emul/usb-emul-uclass.c  | 2 ++
 drivers/usb/gadget/udc/udc-uclass.c | 2 ++
 drivers/usb/host/usb-uclass.c   | 2 ++
 drivers/video/backlight-uclass.c| 2 ++
 drivers/video/bridge/video-bridge-uclass.c  | 2 ++
 drivers/video/display-uclass.c  | 2 ++
 drivers/video/dsi-host-uclass.c | 2 ++
 drivers/video/panel-uclass.c| 2 ++
 drivers/video/vidconsole-uclass.c   | 2 ++
 drivers/video/video-uclass.c| 2 ++
 drivers/video/video_osd-uclass.c| 2 ++
 drivers/virtio/virtio-uclass.c  | 2 ++
 drivers/w1-eeprom/w1-eeprom-uclass.c| 2 ++
 drivers/w1/w1-uclass.c  | 2 ++
 drivers/watchdog/wdt-uclass.c   | 2 ++
 drivers/xen/pvblock.c   | 3 +++
 77 files changed, 157 insertions(+)

diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c
index 8781f32855..67137ffb34 100644
--- a/drivers/adc/adc-uclass.c
+++ b/drivers/adc/adc-uclass.c
@@ -4,6 +4,8 @@
  * Przemyslaw Marczak 
  */
 
+#define LOG_CATEGORY UCLASS_ADC
+
 #include 
 #include 
 #include 
diff --git a/drivers/ata/ahci-uclass.c b/drivers/ata/ahci-uclass.c
index c4c7a03fe7..d398b50b9a 100644
--- a/drivers/ata/ahci-uclass.c
+++ b/drivers/ata/ahci-uclass.c
@@ -4,6 +4,8 @@
  * Written by Simon Glass 
  */
 
+#define LOG_CATEGORY UCLASS_AHCI
+
 #include 
 #include 
 #include 
diff --git a/drivers/axi/axi-emul-uclass.c b/drivers/axi/axi-emul-uclass.c
index b28351f1ad..793336d8c4 100644
--- a/drivers/axi/axi-emul-uclass.c
+++ b/drivers/axi/axi-emul-uclass.c
@@ -4,6 +4,8 @@
  * Mario Six, Guntermann & Drunck GmbH, mario@gdsys.cc
  */
 
+#define 

[PATCH] clk: cosmetic change in uclass

2021-04-27 Thread Patrick Delaunay
Remove the tab in clk_get_bulk to respect the coding rules.

Signed-off-by: Patrick Delaunay 
---

 drivers/clk/clk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 4ab3c402ed..b126c5ed60 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -159,7 +159,7 @@ int clk_get_by_index_nodev(ofnode node, int index, struct 
clk *clk)
 int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
 {
int i, ret, err, count;
-   
+
bulk->count = 0;
 
count = dev_count_phandle_with_args(dev, "clocks", "#clock-cells", 0);
-- 
2.17.1



Re: [PATCH v3] IOMUX: Fix buffer overflow in iomux_replace_device()

2021-04-27 Thread Peter Robinson
On Mon, Apr 26, 2021 at 12:08 AM Yuichiro Goto  wrote:
>
> Use of strcat() against an uninitialized buffer would lead
> to buffer overflow. This patch fixes it.
>
> Fixes: 694cd5618c ("IOMUX: Introduce iomux_replace_device()")
> Signed-off-by: Yuichiro Goto 
> Cc: Peter Robinson 
> Cc: Andy Shevchenko 
> Cc: Nicolas Saenz Julienne 

Tested-by: Peter Robinson 
On a RPi2/RPi3 and Cubieboard

> ---
>
> Changes for v3:
> - Add a Fixes tag in commit message
> - Refactor the patch per suggestion from Andy Shevchenko
>
> Changes for v2:
> - Add "IOMUX" in title
>
>  common/iomux.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/common/iomux.c b/common/iomux.c
> index b9088aa3b5..c428f7110a 100644
> --- a/common/iomux.c
> +++ b/common/iomux.c
> @@ -158,8 +158,12 @@ int iomux_replace_device(const int console, const char 
> *old, const char *new)
> return -ENOMEM;
> }
>
> -   strcat(tmp, ",");
> -   strcat(tmp, name);
> +   if (arg) {
> +   strcat(tmp, ",");
> +   strcat(tmp, name);
> +   }
> +   else
> +   strcpy(tmp, name);
>
> arg = tmp;
> size = strlen(tmp) + 1;
> --
> 2.17.1
>


[PATCH] armv8: layerscape: enable eMMC HS400 workarounds for LX2160A/LX2162A

2021-04-27 Thread Yangbo Lu
Enable eMMC HS400 workarounds for LX2160A/LX2162A.

Signed-off-by: Yangbo Lu 
---
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig 
b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
index 9d1ba4c771..395e5ccaad 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
+++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig
@@ -224,6 +224,8 @@ config ARCH_LX2162A
select SYS_FSL_EC1
select SYS_FSL_EC2
select SYS_FSL_ERRATUM_A050106
+   select SYS_FSL_ERRATUM_A011334
+   select SYS_FSL_ESDHC_UNRELIABLE_PULSE_DETECTION_WORKAROUND
select SYS_FSL_HAS_RGMII
select SYS_FSL_HAS_SEC
select SYS_FSL_HAS_CCN508
@@ -254,6 +256,8 @@ config ARCH_LX2160A
select SYS_FSL_EC1
select SYS_FSL_EC2
select SYS_FSL_ERRATUM_A050106
+   select SYS_FSL_ERRATUM_A011334
+   select SYS_FSL_ESDHC_UNRELIABLE_PULSE_DETECTION_WORKAROUND
select SYS_FSL_HAS_RGMII
select SYS_FSL_HAS_SEC
select SYS_FSL_HAS_CCN508
-- 
2.25.1



Please pull u-boot-marvell/master (watchdog related)

2021-04-27 Thread Stefan Roese

Hi Tom,

please pull the following watchdog related patches from Rasmus:


- WDT: Enable use of hw_margin_ms=0
- PowerPC: Introduce CONFIG_CACHE_FLUSH_WATCHDOG_THRESHOLD
- PowerPC: Misc changes and fixes to the WDT handling


Here the Azure build, without any issues:

https://dev.azure.com/sr0718/u-boot/_build/results?buildId=79=results

Thanks,
Stefan


The following changes since commit ff8cb34d79384524ed81027f7d07a31f7405c27d:

  Prepare v2021.07-rc1 (2021-04-26 20:53:51 -0400)

are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-marvell.git

for you to fetch changes up to 729c1fe656913f0d5b09e986fec9976020a3363c:

  powerpc: introduce CONFIG_CACHE_FLUSH_WATCHDOG_THRESHOLD (2021-04-27 
08:28:07 +0200)



Rasmus Villemoes (5):
  watchdog: use time_after_eq() in watchdog_reset()
  timer: mpc83xx_timer: fix build with CONFIG_{HW_, }WATCHDOG
  allow opting out of WATCHDOG_RESET() from timer interrupt
  powerpc: lib: remove leftover CONFIG_5xx
  powerpc: introduce CONFIG_CACHE_FLUSH_WATCHDOG_THRESHOLD

 README|  9 +
 arch/m68k/lib/time.c  |  2 +-
 arch/powerpc/Kconfig  |  1 +
 arch/powerpc/lib/Kconfig  |  9 +
 arch/powerpc/lib/cache.c  | 17 +
 arch/powerpc/lib/interrupts.c |  2 +-
 drivers/timer/mpc83xx_timer.c |  6 +-
 drivers/watchdog/wdt-uclass.c |  2 +-
 8 files changed, 40 insertions(+), 8 deletions(-)
 create mode 100644 arch/powerpc/lib/Kconfig


Re: [PATCH] watchdog: use time_after_eq() in watchdog_reset()

2021-04-27 Thread Stefan Roese

On 13.04.21 16:43, Rasmus Villemoes wrote:

Some boards don't work with the rate-limiting done in the generic
watchdog_reset() provided by wdt-uclass.

For example, on powerpc, get_timer() ceases working during bootm since
interrupts are disabled before the kernel image gets decompressed, and
when the decompression takes longer than the watchdog device
allows (or enough of the budget that the kernel doesn't get far enough
to assume responsibility for petting the watchdog), the result is a
non-booting board.

As a somewhat hacky workaround (because DT is supposed to describe
hardware), allow specifying hw_margin_ms=0 in device tree to
effectively disable the ratelimiting and actually ping the watchdog
every time watchdog_reset() is called. For that to work, the "has
enough time passed" check just needs to be tweaked a little to allow
the now==next_reset case as well.

Suggested-by: Christophe Leroy 
Signed-off-by: Rasmus Villemoes 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

It's the option I dislike the most (because of the DT abuse), but I
also do accept that it's the one with the minimal code impact, and
apparently the path of least resistance. So here it is.

  drivers/watchdog/wdt-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 0603ffbd36..2687135296 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -148,7 +148,7 @@ void watchdog_reset(void)
  
  	/* Do not reset the watchdog too often */

now = get_timer(0);
-   if (time_after(now, next_reset)) {
+   if (time_after_eq(now, next_reset)) {
next_reset = now + reset_period;
wdt_reset(gd->watchdog_dev);
}




Viele Grüße,
Stefan

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


Re: [PATCH v4 0/2] allow opting out of WATCHDOG_RESET() from timer interrupt

2021-04-27 Thread Stefan Roese

On 26.04.21 22:47, Tom Rini wrote:

On Mon, Apr 26, 2021 at 10:21:30PM +0200, Rasmus Villemoes wrote:

On 14/04/2021 09.18, Rasmus Villemoes wrote:

This is a resend of v3 from a year ago. Please consider applying.

v4: rebase to current master.

v3: add fixup patch for mpc83xx_timer, add documentation hunk to
README, also update m68k instead of only ppc.

v2: add documentation comment

Rasmus Villemoes (2):
   timer: mpc83xx_timer: fix build with CONFIG_{HW_,}WATCHDOG
   allow opting out of WATCHDOG_RESET() from timer interrupt

  README| 9 +
  arch/m68k/lib/time.c  | 2 +-
  arch/powerpc/lib/interrupts.c | 2 +-
  drivers/timer/mpc83xx_timer.c | 6 +-
  4 files changed, 16 insertions(+), 3 deletions(-)



ping


As watchdog stuff, Stefan?


Looks good. I've pulled all ready WDT related patches and will send
the pull request shortly.

Thanks,
Stefan


[PATCH] arm: dts: lx2162aqds: support eMMC HS400 mode on esdhc1

2021-04-27 Thread Yangbo Lu
Add properties related to eMMC HS400 mode for esdhc1.

Signed-off-by: Yangbo Lu 
---
 arch/arm/dts/fsl-lx2162a-qds-sd1-17.dtsi | 6 ++
 arch/arm/dts/fsl-lx2162a-qds-sd1-18.dtsi | 6 ++
 arch/arm/dts/fsl-lx2162a-qds-sd1-20.dtsi | 6 ++
 arch/arm/dts/fsl-lx2162a-qds.dts | 6 ++
 4 files changed, 24 insertions(+)

diff --git a/arch/arm/dts/fsl-lx2162a-qds-sd1-17.dtsi 
b/arch/arm/dts/fsl-lx2162a-qds-sd1-17.dtsi
index 60f5a4ee43..3b6fddba7c 100644
--- a/arch/arm/dts/fsl-lx2162a-qds-sd1-17.dtsi
+++ b/arch/arm/dts/fsl-lx2162a-qds-sd1-17.dtsi
@@ -56,3 +56,9 @@
reg = <0x3>;
};
 };
+
+ {
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
+   bus-width = <8>;
+};
diff --git a/arch/arm/dts/fsl-lx2162a-qds-sd1-18.dtsi 
b/arch/arm/dts/fsl-lx2162a-qds-sd1-18.dtsi
index 8e11b0680a..0f4329f587 100644
--- a/arch/arm/dts/fsl-lx2162a-qds-sd1-18.dtsi
+++ b/arch/arm/dts/fsl-lx2162a-qds-sd1-18.dtsi
@@ -59,3 +59,9 @@
reg = <0x1>;
};
 };
+
+ {
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
+   bus-width = <8>;
+};
diff --git a/arch/arm/dts/fsl-lx2162a-qds-sd1-20.dtsi 
b/arch/arm/dts/fsl-lx2162a-qds-sd1-20.dtsi
index faf4285eab..8c856a19d4 100644
--- a/arch/arm/dts/fsl-lx2162a-qds-sd1-20.dtsi
+++ b/arch/arm/dts/fsl-lx2162a-qds-sd1-20.dtsi
@@ -24,3 +24,9 @@
reg = <0x0>;
};
 };
+
+ {
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
+   bus-width = <8>;
+};
diff --git a/arch/arm/dts/fsl-lx2162a-qds.dts b/arch/arm/dts/fsl-lx2162a-qds.dts
index 341610ccf4..68cb328716 100644
--- a/arch/arm/dts/fsl-lx2162a-qds.dts
+++ b/arch/arm/dts/fsl-lx2162a-qds.dts
@@ -135,3 +135,9 @@
reg = <2>;
};
 };
+
+ {
+   mmc-hs200-1_8v;
+   mmc-hs400-1_8v;
+   bus-width = <8>;
+};
-- 
2.25.1



Re: [PATCH] usb: musb-new: Extend Allwinner quirk to newer SoCs

2021-04-27 Thread Andre Przywara
On Tue, 27 Apr 2021 02:37:20 +0200
Marek Vasut  wrote:

Hi,

> On 4/27/21 2:03 AM, Andre Przywara wrote:
> > As the comment in musb_regs.h describes, Allwinner saves the
> > MUSB_CONFIGDATA register, which always return 0 on those SoCs.
> > 
> > This is also true for the H6 and H616, so extend the quirk to those
> > controllers as well.
> > 
> > This fixes USB peripheral mode on H6 and H616 boards.
> > 
> > Signed-off-by: Andre Przywara 
> > ---
> >   drivers/usb/musb-new/musb_regs.h | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/musb-new/musb_regs.h 
> > b/drivers/usb/musb-new/musb_regs.h
> > index c4d7203b851..bee1b715a95 100644
> > --- a/drivers/usb/musb-new/musb_regs.h
> > +++ b/drivers/usb/musb-new/musb_regs.h
> > @@ -432,7 +432,8 @@ static inline u8 musb_read_ulpi_buscontrol(void __iomem 
> > *mbase)
> >   static inline u8 musb_read_configdata(void __iomem *mbase)
> >   {
> >   #if defined CONFIG_MACH_SUN8I_A33 || defined CONFIG_MACH_SUN8I_A83T || \
> > -   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I
> > +   defined CONFIG_MACH_SUNXI_H3_H5 || defined CONFIG_MACH_SUN50I || \
> > +   defined CONFIG_SUN50I_GEN_H6  
> 
> Isn't there some better solution then ever-growing list of macros to 
> check, like e.g. a single CONFIG_MACH_SUNXI ?

I was wondering the same, but I think this does not apply to the older
SoCs (we use ARCH_SUNXI in the two functions above and below, so I
guess the differentiation here is deliberate). I will test this later.

So we could probably use the quirk also for the older, working(?) SoCs,
but I am not sure we should do that. CONFIG_SUN50I_GEN_H6 is already a
symbol covering multiple SoCs, so ideally we won't need to add many
more.
I can have a look if we have other checks like that in the code, then
maybe define a collective symbol for newer SoCs?

Cheers,
Andre


Re: [PATCH 0/2] reset: fix reset_get_by_index_nodev index handling

2021-04-27 Thread Neil Armstrong
Hi Tom, Simon,

On 20/04/2021 10:42, Neil Armstrong wrote:
> A regression weas detected on Amlogic G12A/G12B SoCs, where HDMI output was 
> disable
> even when Linux was booting.
> 
> Bisect reports 139e4a1cbe ("drivers: reset: Add a managed API to get reset 
> controllers from the DT")
> as the offending commit.
> 
> But the error is in ea9dc35aab ("reset: Get the RESET by index without 
> device") where a spurius "> 0"
> was added to the index handling.
> 
> But the dm_test_reset_base() test did not catch it.
> 
> The first commit extends the test to catch the regression, and the second 
> patch fixes the regression.

So you have any comment on the patch order here ? Should I push the fixed test 
after the fix ?

Neil

> 
> Neil Armstrong (2):
>   test: reset: Extend base reset test to catch error
>   reset: fix reset_get_by_index_nodev index handling
> 
>  arch/sandbox/dts/test.dts|  4 ++--
>  drivers/reset/reset-uclass.c |  2 +-
>  test/dm/reset.c  | 39 +++-
>  3 files changed, 37 insertions(+), 8 deletions(-)
> 



Re: [RFC PATCH 3/3] net: phy: dp83869: Port the kernel driver

2021-04-27 Thread Christian Gmeiner
Hi Dan

I am interested to see the mainline support for the DP83869 phy. Is
there any progress on this patch or are there any blocker?

Am Di., 21. Apr. 2020 um 16:35 Uhr schrieb Dan Murphy :
>
> Michal
>
> On 4/21/20 7:39 AM, Michal Simek wrote:
> > On 21. 04. 20 14:04, Dan Murphy wrote:
> >> Michal
> >>
> >> On 4/21/20 3:23 AM, Michal Simek wrote:
> >>> On 20. 04. 20 20:53, Dan Murphy wrote:
>  Port the DP83869 kernel driver.
> 
>  Signed-off-by: Dan Murphy 
>  ---
> drivers/net/phy/Kconfig  |   4 +
> drivers/net/phy/Makefile |   1 +
> drivers/net/phy/dp83869.c| 440 +++
> drivers/net/phy/ti_phy_init.c|   4 +
> drivers/net/phy/ti_phy_init.h|   1 +
> include/dt-bindings/net/ti-dp83869.h |  42 +++
> 6 files changed, 492 insertions(+)
> create mode 100644 drivers/net/phy/dp83869.c
> create mode 100644 include/dt-bindings/net/ti-dp83869.h
> 
>  diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
>  index e366f10afc59..5f14bdba0a3b 100644
>  --- a/drivers/net/phy/Kconfig
>  +++ b/drivers/net/phy/Kconfig
>  @@ -252,6 +252,10 @@ config PHY_DP83867
> select PHY_TI
> bool "Texas Instruments Ethernet DP83867 PHY support"
> +config PHY_DP83869
>  +select PHY_TI
>  +bool "Texas Instruments Ethernet DP83869 PHY support"
> >>> isn't this a little bit short? I expect checkpatch should be reporting
> >>> issue with it.
> >> Yes but I was following other config flags in this file.
> > Just no reason to follow bad examples. :-)
>
> True.
>
> I will update the examples for the TI PHYs.
>
>
> >
> >
> >
> >>>
>  +
> config PHY_VITESSE
> bool "Vitesse Ethernet PHYs support"
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
>  index 9c6d31718c00..f8797319154f 100644
>  --- a/drivers/net/phy/Makefile
>  +++ b/drivers/net/phy/Makefile
>  @@ -27,6 +27,7 @@ obj-$(CONFIG_PHY_SMSC) += smsc.o
> obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
> obj-$(CONFIG_PHY_TI) += ti_phy_init.o
> obj-$(CONFIG_PHY_DP83867) += dp83867.o
>  +obj-$(CONFIG_PHY_DP83869) += dp83869.o
> obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
> obj-$(CONFIG_PHY_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
> obj-$(CONFIG_PHY_VITESSE) += vitesse.o
>  diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
>  new file mode 100644
>  index ..1eaaea20b37a
>  --- /dev/null
>  +++ b/drivers/net/phy/dp83869.c
>  @@ -0,0 +1,440 @@
>  +// SPDX-License-Identifier: GPL-2.0
>  +/* Driver for the Texas Instruments DP83869 PHY
>  + * Copyright (C) 2019 Texas Instruments Inc.
> >>> 2020?
> >> This driver was developed in 2019 and added to the 5.4 kernel so not
> >> sure we should update the copyright when side porting.
> >>
> >> At the very least I will need to add 2019-20
> > yup.
>
>
> Ack
>
> >
>  + */
>  +
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +
>  +#include 
>  +
>  +#include 
>  +
>  +#include "ti_phy_init.h"
>  +
>  +#define DP83869_PHY_ID0x2000a0f1
>  +#define DP83869_DEVADDR0x1f
>  +
>  +#define MII_DP83869_PHYCTRL0x10
>  +#define MII_DP83869_MICR0x12
>  +#define MII_DP83869_ISR0x13
>  +#define DP83869_CTRL0x1f
>  +#define DP83869_CFG40x1e
>  +
>  +/* Extended Registers */
>  +#define DP83869_GEN_CFG30x0031
>  +#define DP83869_RGMIICTL0x0032
>  +#define DP83869_STRAP_STS10x006e
>  +#define DP83869_RGMIIDCTL0x0086
>  +#define DP83869_IO_MUX_CFG0x0170
>  +#define DP83869_OP_MODE0x01df
>  +#define DP83869_FX_CTRL0x0c00
>  +
>  +#define DP83869_SW_RESETBIT(15)
>  +#define DP83869_SW_RESTARTBIT(14)
>  +
>  +/* MICR Interrupt bits */
>  +#define MII_DP83869_MICR_AN_ERR_INT_ENBIT(15)
>  +#define MII_DP83869_MICR_SPEED_CHNG_INT_ENBIT(14)
>  +#define MII_DP83869_MICR_DUP_MODE_CHNG_INT_ENBIT(13)
>  +#define MII_DP83869_MICR_PAGE_RXD_INT_ENBIT(12)
>  +#define MII_DP83869_MICR_AUTONEG_COMP_INT_ENBIT(11)
>  +#define MII_DP83869_MICR_LINK_STS_CHNG_INT_ENBIT(10)
>  +#define MII_DP83869_MICR_FALSE_CARRIER_INT_ENBIT(8)
>  +#define MII_DP83869_MICR_SLEEP_MODE_CHNG_INT_ENBIT(4)
>  +#define MII_DP83869_MICR_WOL_INT_ENBIT(3)
>  +#define MII_DP83869_MICR_XGMII_ERR_INT_ENBIT(2)
>  +#define MII_DP83869_MICR_POL_CHNG_INT_ENBIT(1)
>  +#define MII_DP83869_MICR_JABBER_INT_ENBIT(0)
>  +
>  +#define MII_DP83869_BMCR_DEFAULT(BMCR_ANENABLE | \
>  + BMCR_FULLDPLX | \
>  +

Re: [PATCH 1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

2021-04-27 Thread Stefan Roese

On 12.04.21 10:32, meng...@windriver.com wrote:

From: MengLi 

In uboot command line environment, watchdog is not able to be
stopped with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

Signed-off-by: Meng Li 
---
  drivers/watchdog/designware_wdt.c | 17 +
  1 file changed, 17 insertions(+)

diff --git a/drivers/watchdog/designware_wdt.c 
b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..63e89d38c4 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -92,10 +92,27 @@ static int designware_wdt_reset(struct udevice *dev)
  static int designware_wdt_stop(struct udevice *dev)
  {
struct designware_wdt_priv *priv = dev_get_priv(dev);
+   __maybe_unused int ret;


You add "ret" here as "__maybe_unused" and ...

  
  	designware_wdt_reset(dev);

writel(0, priv->base + DW_WDT_CR);
  
+#if CONFIG_IS_ENABLED(DM_RESET)

+   struct reset_ctl_bulk resets;


... here this struct. Please add both above as __maybe_unsed. I assume
that checkpatch and other tools will complain about variable
declarations in the code path.

BTW: It should be possible to change the above #if CONFIG_ to this

if (CONFIG_IS_ENABLED(DM_RESET)) {

Then you can put both variable declarations in here:

if (CONFIG_IS_ENABLED(DM_RESET)) {
struct reset_ctl_bulk resets;
int ret;

Please check if this works and resubmit.

Thanks,
Stefan


+
+   ret = reset_get_bulk(dev, );
+   if (ret)
+   return ret;
+
+   ret = reset_assert_bulk();
+   if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk();
+   if (ret)
+   return ret;
+#endif
+
return 0;
  }