[PATCH] ARM: mach-imx: Add missing ocotp dependency to protonic-imx6 platform

2022-11-02 Thread Robin van der Gracht
The protonic-imx6 board code calls imx_ocotp_read/write_field functions.
Compiling without IMX_OCOTP results in a build failure.

Signed-off-by: Robin van der Gracht 
---
 arch/arm/mach-imx/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index dcb70c8c1a..b95c6e456e 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -350,6 +350,7 @@ config MACH_PROTONIC_IMX6
select ARCH_IMX6
select ARCH_IMX6UL
select ARM_USE_COMPRESSED_DTB
+   select IMX_OCOTP
 
 config MACH_PROTONIC_IMX8M
bool "Protonic-Holland i.MX8Mx based boards"
-- 
2.37.2




Re: [PATCH] Kbuild: link barebox with -z noexecstack

2022-11-02 Thread Ahmad Fatoum
On 02.11.22 13:48, Ahmad Fatoum wrote:
> We don't care for permission of ELF segments, but GNU ld (BFD)
> does and now with binutils 2.39+, it reports:
> 
>   ld: warning: defaultenv/defaultenv-2-menu.bbenv.o: missing
>   .note.GNU-stack section implies executable stack
> 
>   ld: NOTE: This behaviour is deprecated and will be removed in a future
>   version of the linker
> 
> Instead of touching all assembly objects and scripts creating them to
> add the section, just set -z noexecstack at link-time. This is already
> the LLVM linker (lld) default.
> 
> Reported-by: Christian Melki 
> Signed-off-by: Ahmad Fatoum 
> ---

Please dismiss. I think we should just add it to KBUILD_LDFLAGS globally.

>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 26a0999a2e20..e57b8a4a1364 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
>  KBUILD_AFLAGS_MODULE := -DMODULE
>  KBUILD_CFLAGS_MODULE := -DMODULE
>  
> -LDFLAGS_barebox  := -Map barebox.map
> +LDFLAGS_barebox  := -Map barebox.map -z noexecstack
>  
>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
>  LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |




[PATCH] Kbuild: link barebox with -z noexecstack

2022-11-02 Thread Ahmad Fatoum
We don't care for permission of ELF segments, but GNU ld (BFD)
does and now with binutils 2.39+, it reports:

  ld: warning: defaultenv/defaultenv-2-menu.bbenv.o: missing
  .note.GNU-stack section implies executable stack

  ld: NOTE: This behaviour is deprecated and will be removed in a future
  version of the linker

Instead of touching all assembly objects and scripts creating them to
add the section, just set -z noexecstack at link-time. This is already
the LLVM linker (lld) default.

Reported-by: Christian Melki 
Signed-off-by: Ahmad Fatoum 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 26a0999a2e20..e57b8a4a1364 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS_MODULE := -DMODULE
 KBUILD_CFLAGS_MODULE := -DMODULE
 
-LDFLAGS_barebox:= -Map barebox.map
+LDFLAGS_barebox:= -Map barebox.map -z noexecstack
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
-- 
2.37.2




Re: [PATCH 14/14] imx-bbu-nand-fcb: Add fcb command

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 12:01:15PM +0100, Marco Felsch wrote:
> On 22-11-02, Sascha Hauer wrote:
> > On Wed, Nov 02, 2022 at 09:44:41AM +0100, Marco Felsch wrote:
> > > > +static void dump_fcb_n(struct fcb_block **fcbs, int n)
> > > > +{
> > > > +   int i;
> > > > +
> > > > +   if (!n || !fcbs[n])
> > > > +   goto skip_compare;
> > > > +
> > > > +   for (i = 0; i < n; i++) {
> > > > +   if (!fcbs[i] || !fcbs[n])
> > > > +   continue;
> > > > +
> > > > +   if (!memcmp(fcbs[i], fcbs[n], sizeof(struct 
> > > > fcb_block))) {
> > > > +   printf("FCB block#%d: same as FCB block#%d\n", 
> > > > n, i);
> > > > +   return;
> > > > +   }
> > > > +   }
> > > > +
> > > > +skip_compare:
> > > > +   if (fcbs[n]) {
> > > > +   printf("FCB block#%d:\n", n);
> > > > +   dump_fcb(fcbs[n]);
> > > > +   } else {
> > > > +   printf("FCB block#%d: NULL\n", n);
> > > > +   }
> > > > +}
> > > > +
> > > > +#ifdef CONFIG_ARCH_IMX28
> > > 
> > > Why this #ifdef? Can't we do this by cpu_is_mx28()?
> > 
> > i.MX28 is a different architecture in barebox, it's in
> > arch/arm/mach-mxs/. We do not have the cpu_is_mx7() and cpu_is_mx6ul()
> > macros there.
> 
> Argh.. always messing the mxs/mxc stuff up in my head. Got your point,
> but shouldn't we add the macros instead of adding the #ifdef here?

Right. We have several cpu_is_mx* macros there already, so we can just
add the missing ones and avoid the ifdeffery.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 11:07:44AM +0100, Oleksij Rempel wrote:
> Unify all printing messages and make use of dev_ instead of pr_.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boards/skov-imx6/board.c | 62 +++
>  1 file changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm/boards/skov-imx6/board.c 
> b/arch/arm/boards/skov-imx6/board.c
> index ab8b229a69..d23730221f 100644
> --- a/arch/arm/boards/skov-imx6/board.c
> +++ b/arch/arm/boards/skov-imx6/board.c
> @@ -33,21 +33,21 @@ static int eth_of_fixup_node(struct device_node *root, 
> const char *node_path,
>   unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
>  
>   ethaddr_to_string(ethaddr, ethaddr_str);
> - pr_err("The mac-address %s is invalid.\n", ethaddr_str);
> + dev_err(skov_priv->dev, "The mac-address %s is invalid.\n", 
> ethaddr_str);

Ah, ok, here is that change. This patch should rather be before 3/4.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 11:07:43AM +0100, Oleksij Rempel wrote:
> We have two external ports and different MAC addresses on each port. So,
> assign different MAC to the LAN2. The address on LAN1 is the
> system default address.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boards/skov-imx6/board.c | 47 ++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/skov-imx6/board.c 
> b/arch/arm/boards/skov-imx6/board.c
> index 3c51b76735..ab8b229a69 100644
> --- a/arch/arm/boards/skov-imx6/board.c
> +++ b/arch/arm/boards/skov-imx6/board.c
> @@ -17,6 +17,12 @@
>  
>  #include "version.h"
>  
> +struct skov_imx6_priv {
> + struct device_d *dev;
> +};
> +
> +static struct skov_imx6_priv *skov_priv;
> +
>  static int eth_of_fixup_node(struct device_node *root, const char *node_path,
>const u8 *ethaddr)
>  {
> @@ -542,6 +548,34 @@ static void skov_init_board(const struct 
> board_description *variant)
>   }
>  }
>  
> +/* */

Did you want to write a comment here?

> +static int skov_set_switch_lan2_mac(struct skov_imx6_priv *priv)
> +{
> + const char *state = "/state/ethaddr/eth2";
> + struct device_node *lan2_np;
> + u8 ethaddr[ETH_ALEN];
> + int ret;
> +
> + ret = get_mac_address_from_env_variable("state.ethaddr.eth2", ethaddr);
> + if (ret || !is_valid_ether_addr(ethaddr)) {
> + ret = get_default_mac_address_from_state_node(state, ethaddr);
> + if (ret || !is_valid_ether_addr(ethaddr)) {
> + dev_err(priv->dev, "can't get MAC for LAN2\n");
> + return -ENODEV;
> + }
> + }
> +
> + lan2_np = of_find_node_by_path("/mdio/switch@0/ports/ports@1");
> + if (!lan2_np) {
> + dev_err(priv->dev, "LAN2 node not found\n");
> + return -ENODEV;
> + }
> +
> + of_eth_register_ethaddr(lan2_np, ethaddr);
> +
> + return 0;
> +}
> +
>  static int skov_switch_test(void)
>  {
>   struct device_d *sw_dev;
> @@ -561,8 +595,11 @@ static int skov_switch_test(void)
>   goto no_switch;
>   }
>  
> - if (dev_is_probed(sw_dev))
> + if (dev_is_probed(sw_dev)) {
> + skov_set_switch_lan2_mac(skov_priv);
> + /* even if we fail, continue to boot as good as possible */
>   return 0;
> + }

This introduction of skov_priv to have a struct device_d * around for
dev_err is good, but is not subject to this patch. Please either make an
extra patch from it and use dev_err consistently or just stick to the
currently used pr_err.

>  
>  no_switch:
>   skov_have_switch = false;
> @@ -584,6 +621,7 @@ late_initcall(skov_switch_test);
>  
>  static int skov_imx6_probe(struct device_d *dev)
>  {
> + struct skov_imx6_priv *priv;
>   unsigned v = 0;
>   const struct board_description *variant;
>  
> @@ -603,6 +641,13 @@ static int skov_imx6_probe(struct device_d *dev)
>  
>   skov_board_no = v;
>  
> + priv = xzalloc(sizeof(*priv));
> + if (!priv)
> + return -ENOMEM;

xzalloc does not return with an error.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 11:07:41AM +0100, Oleksij Rempel wrote:
> Enable poromisc mode by default to allow using multiple MAC address on
> same FEC interfaces.

s/poromisc/promiscuous/

> 
> We already use poromisc mode on designware stmmac, so it will make
> behavior more consistent on different systems.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  drivers/net/fec_imx.c | 3 +++
>  drivers/net/fec_imx.h | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 673555a48a..9aa4b4f595 100644
> --- a/drivers/net/fec_imx.c
> +++ b/drivers/net/fec_imx.c
> @@ -262,6 +262,9 @@ static int fec_init(struct eth_device *dev)
>*/
>   rcntl = FEC_R_CNTRL_MAX_FL(1518);
>  
> + /* Set promisc mode to make switches with different ethaddr work */
> + rcntl |= FEC_R_CNTRL_PROMISC;
> +

Shouldn't we rather enable promiscuous mode in an extra callback?
In the end we want promiscuous mode only in specific cases, not
generally.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH 14/14] imx-bbu-nand-fcb: Add fcb command

2022-11-02 Thread Marco Felsch
On 22-11-02, Sascha Hauer wrote:
> On Wed, Nov 02, 2022 at 09:44:41AM +0100, Marco Felsch wrote:
> > > +static void dump_fcb_n(struct fcb_block **fcbs, int n)
> > > +{
> > > + int i;
> > > +
> > > + if (!n || !fcbs[n])
> > > + goto skip_compare;
> > > +
> > > + for (i = 0; i < n; i++) {
> > > + if (!fcbs[i] || !fcbs[n])
> > > + continue;
> > > +
> > > + if (!memcmp(fcbs[i], fcbs[n], sizeof(struct fcb_block))) {
> > > + printf("FCB block#%d: same as FCB block#%d\n", n, i);
> > > + return;
> > > + }
> > > + }
> > > +
> > > +skip_compare:
> > > + if (fcbs[n]) {
> > > + printf("FCB block#%d:\n", n);
> > > + dump_fcb(fcbs[n]);
> > > + } else {
> > > + printf("FCB block#%d: NULL\n", n);
> > > + }
> > > +}
> > > +
> > > +#ifdef CONFIG_ARCH_IMX28
> > 
> > Why this #ifdef? Can't we do this by cpu_is_mx28()?
> 
> i.MX28 is a different architecture in barebox, it's in
> arch/arm/mach-mxs/. We do not have the cpu_is_mx7() and cpu_is_mx6ul()
> macros there.

Argh.. always messing the mxs/mxc stuff up in my head. Got your point,
but shouldn't we add the macros instead of adding the #ifdef here?

Regards,
  Marco

> 
> Sascha
> 
> -- 
> Pengutronix e.K.   | |
> Steuerwalder Str. 21   | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
> Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
> 



Re: [PATCH 14/14] imx-bbu-nand-fcb: Add fcb command

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 09:44:41AM +0100, Marco Felsch wrote:
> > +static void dump_fcb_n(struct fcb_block **fcbs, int n)
> > +{
> > +   int i;
> > +
> > +   if (!n || !fcbs[n])
> > +   goto skip_compare;
> > +
> > +   for (i = 0; i < n; i++) {
> > +   if (!fcbs[i] || !fcbs[n])
> > +   continue;
> > +
> > +   if (!memcmp(fcbs[i], fcbs[n], sizeof(struct fcb_block))) {
> > +   printf("FCB block#%d: same as FCB block#%d\n", n, i);
> > +   return;
> > +   }
> > +   }
> > +
> > +skip_compare:
> > +   if (fcbs[n]) {
> > +   printf("FCB block#%d:\n", n);
> > +   dump_fcb(fcbs[n]);
> > +   } else {
> > +   printf("FCB block#%d: NULL\n", n);
> > +   }
> > +}
> > +
> > +#ifdef CONFIG_ARCH_IMX28
> 
> Why this #ifdef? Can't we do this by cpu_is_mx28()?

i.MX28 is a different architecture in barebox, it's in
arch/arm/mach-mxs/. We do not have the cpu_is_mx7() and cpu_is_mx6ul()
macros there.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



[PATCH] ARM: rk356x: rk3568-evb: add missing new line to log message

2022-11-02 Thread Ahmad Fatoum
If ADC is available, but read out returns an error, we end up with a log
line that's not new line terminated. Fix this.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/boards/rockchip-rk3568-evb/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boards/rockchip-rk3568-evb/board.c 
b/arch/arm/boards/rockchip-rk3568-evb/board.c
index 212c801c93d3..ef886e67ed15 100644
--- a/arch/arm/boards/rockchip-rk3568-evb/board.c
+++ b/arch/arm/boards/rockchip-rk3568-evb/board.c
@@ -94,7 +94,7 @@ static int rk3568_evb_detect_hwid(void)
return 0;
 
 err_hwid:
-   pr_err("couldn't retrieve hardware ID");
+   pr_err("couldn't retrieve hardware ID\n");
return ret;
 }
 late_initcall(rk3568_evb_detect_hwid);
-- 
2.30.2




[PATCH v1 2/4] net: dsa: fix of_device_ensure_probed*() for switch ports

2022-11-02 Thread Oleksij Rempel
Crete ports by using of_platform_device_create() in the same way as it
is used by of_device_ensure_probed*(). Otherwise we are creating
multiple devices for the same node.

At same time we need to link dummy driver to make this logic work.

Signed-off-by: Oleksij Rempel 
---
 drivers/net/dsa.c | 18 +-
 include/dsa.h |  2 +-
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
index 040ba897e2..ee07f08eef 100644
--- a/drivers/net/dsa.c
+++ b/drivers/net/dsa.c
@@ -59,7 +59,7 @@ static int dsa_port_probe(struct eth_device *edev)
int ret;
 
if (ops->port_probe) {
-   interface = of_get_phy_mode(dp->dev.device_node);
+   interface = of_get_phy_mode(dp->dev->device_node);
ret = ops->port_probe(dp, dp->index, interface);
if (ret)
return ret;
@@ -93,7 +93,7 @@ static int dsa_port_start(struct eth_device *edev)
if (dp->enabled)
return -EBUSY;
 
-   interface = of_get_phy_mode(dp->dev.device_node);
+   interface = of_get_phy_mode(dp->dev->device_node);
 
if (ops->port_pre_enable) {
/* In case of RMII interface we need to enable RMII clock
@@ -235,21 +235,13 @@ static int dsa_switch_register_edev(struct dsa_switch *ds,
struct eth_device *edev;
struct device_d *dev;
struct dsa_port *dp;
-   int ret;
 
ds->dp[port] = xzalloc(sizeof(*dp));
-
dp = ds->dp[port];
-   dev = &dp->dev;
-
-   dev_set_name(dev, "dsa_port");
-   dev->id = DEVICE_ID_DYNAMIC;
-   dev->parent = ds->dev;
-   dev->device_node = dn;
 
-   ret = register_device(dev);
-   if (ret)
-   return ret;
+   dev = of_platform_device_create(dn, ds->dev);
+   of_platform_device_dummy_drv(dev);
+   dp->dev = dev;
 
dp->rx_buf = xmalloc(DSA_PKTSIZE);
dp->ds = ds;
diff --git a/include/dsa.h b/include/dsa.h
index 75a939f2cb..f428aa74a5 100644
--- a/include/dsa.h
+++ b/include/dsa.h
@@ -58,7 +58,7 @@ struct dsa_ops {
 };
 
 struct dsa_port {
-   struct device_d dev;
+   struct device_d *dev;
struct dsa_switch *ds;
unsigned int index;
struct eth_device edev;
-- 
2.30.2




[PATCH v1 3/4] ARM: boards: skov-imx6: assigned separate MAC address to LAN2

2022-11-02 Thread Oleksij Rempel
We have two external ports and different MAC addresses on each port. So,
assign different MAC to the LAN2. The address on LAN1 is the
system default address.

Signed-off-by: Oleksij Rempel 
---
 arch/arm/boards/skov-imx6/board.c | 47 ++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/skov-imx6/board.c 
b/arch/arm/boards/skov-imx6/board.c
index 3c51b76735..ab8b229a69 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -17,6 +17,12 @@
 
 #include "version.h"
 
+struct skov_imx6_priv {
+   struct device_d *dev;
+};
+
+static struct skov_imx6_priv *skov_priv;
+
 static int eth_of_fixup_node(struct device_node *root, const char *node_path,
 const u8 *ethaddr)
 {
@@ -542,6 +548,34 @@ static void skov_init_board(const struct board_description 
*variant)
}
 }
 
+/* */
+static int skov_set_switch_lan2_mac(struct skov_imx6_priv *priv)
+{
+   const char *state = "/state/ethaddr/eth2";
+   struct device_node *lan2_np;
+   u8 ethaddr[ETH_ALEN];
+   int ret;
+
+   ret = get_mac_address_from_env_variable("state.ethaddr.eth2", ethaddr);
+   if (ret || !is_valid_ether_addr(ethaddr)) {
+   ret = get_default_mac_address_from_state_node(state, ethaddr);
+   if (ret || !is_valid_ether_addr(ethaddr)) {
+   dev_err(priv->dev, "can't get MAC for LAN2\n");
+   return -ENODEV;
+   }
+   }
+
+   lan2_np = of_find_node_by_path("/mdio/switch@0/ports/ports@1");
+   if (!lan2_np) {
+   dev_err(priv->dev, "LAN2 node not found\n");
+   return -ENODEV;
+   }
+
+   of_eth_register_ethaddr(lan2_np, ethaddr);
+
+   return 0;
+}
+
 static int skov_switch_test(void)
 {
struct device_d *sw_dev;
@@ -561,8 +595,11 @@ static int skov_switch_test(void)
goto no_switch;
}
 
-   if (dev_is_probed(sw_dev))
+   if (dev_is_probed(sw_dev)) {
+   skov_set_switch_lan2_mac(skov_priv);
+   /* even if we fail, continue to boot as good as possible */
return 0;
+   }
 
 no_switch:
skov_have_switch = false;
@@ -584,6 +621,7 @@ late_initcall(skov_switch_test);
 
 static int skov_imx6_probe(struct device_d *dev)
 {
+   struct skov_imx6_priv *priv;
unsigned v = 0;
const struct board_description *variant;
 
@@ -603,6 +641,13 @@ static int skov_imx6_probe(struct device_d *dev)
 
skov_board_no = v;
 
+   priv = xzalloc(sizeof(*priv));
+   if (!priv)
+   return -ENOMEM;
+
+   priv->dev = dev;
+   skov_priv = priv;
+
globalvar_add_simple_int("board.no", &skov_board_no, "%u");
globalvar_add_simple("board.variant", variant->variant);
globalvar_add_simple("board.revision",variant->revision);
-- 
2.30.2




[PATCH v1 4/4] ARM: boards: skov-imx6: convert all pr_ to dev_ prints

2022-11-02 Thread Oleksij Rempel
Unify all printing messages and make use of dev_ instead of pr_.

Signed-off-by: Oleksij Rempel 
---
 arch/arm/boards/skov-imx6/board.c | 62 +++
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boards/skov-imx6/board.c 
b/arch/arm/boards/skov-imx6/board.c
index ab8b229a69..d23730221f 100644
--- a/arch/arm/boards/skov-imx6/board.c
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -33,21 +33,21 @@ static int eth_of_fixup_node(struct device_node *root, 
const char *node_path,
unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
 
ethaddr_to_string(ethaddr, ethaddr_str);
-   pr_err("The mac-address %s is invalid.\n", ethaddr_str);
+   dev_err(skov_priv->dev, "The mac-address %s is invalid.\n", 
ethaddr_str);
return -EINVAL;
}
 
node = of_find_node_by_path_from(root, node_path);
if (!node) {
-   pr_err("Did not find node %s to fix up with stored 
mac-address.\n",
-  node_path);
+   dev_err(skov_priv->dev, "Did not find node %s to fix up with 
stored mac-address.\n",
+   node_path);
return -ENOENT;
}
 
ret = of_set_property(node, "mac-address", ethaddr, ETH_ALEN, 1);
if (ret)
-   pr_err("Setting mac-address property of %s failed with: %s.\n",
-  node->full_name, strerror(-ret));
+   dev_err(skov_priv->dev, "Setting mac-address property of %s 
failed with: %s.\n",
+   node->full_name, strerror(-ret));
 
return ret;
 }
@@ -60,7 +60,7 @@ static int eth_of_fixup_node_from_eth_device(struct 
device_node *root,
 
edev = eth_get_byname(ethname);
if (!edev) {
-   pr_err("Did not find eth device \"%s\" to copy mac-address 
from.\n", ethname);
+   dev_err(skov_priv->dev, "Did not find eth device \"%s\" to copy 
mac-address from.\n", ethname);
return -ENOENT;
}
 
@@ -74,14 +74,14 @@ static int get_mac_address_from_env_variable(const char 
*env, u8 ethaddr[ETH_ALE
 
ethaddr_str = getenv(env);
if (!ethaddr_str) {
-   pr_err("State variable %s storing the mac-address not 
found.\n", env);
+   dev_err(skov_priv->dev, "State variable %s storing the 
mac-address not found.\n", env);
return -ENOENT;
}
 
ret = string_to_ethaddr(ethaddr_str, ethaddr);
if (ret < 0) {
-   pr_err("Could not convert \"%s\" in state variable %s into 
mac-address.\n",
-  ethaddr_str, env);
+   dev_err(skov_priv->dev, "Could not convert \"%s\" in state 
variable %s into mac-address.\n",
+   ethaddr_str, env);
return -EINVAL;
}
 
@@ -96,13 +96,13 @@ static int get_default_mac_address_from_state_node(const 
char *state_node_path,
 
node = of_find_node_by_path(state_node_path);
if (!node) {
-   pr_err("Node %s defining the state variable not found.\n", 
state_node_path);
+   dev_err(skov_priv->dev, "Node %s defining the state variable 
not found.\n", state_node_path);
return -ENOENT;
}
 
ret = of_property_read_u8_array(node, "default", ethaddr, ETH_ALEN);
if (ret) {
-   pr_err("Node %s has no property \"default\" of proper type.\n", 
state_node_path);
+   dev_err(skov_priv->dev, "Node %s has no property \"default\" of 
proper type.\n", state_node_path);
return -ENOENT;
}
 
@@ -346,18 +346,18 @@ static void skov_imx6_no_switch(struct device_node *root)
if (node) {
ret = of_device_disable(node);
if (ret)
-   pr_warn("Can't disable %s\n", fec_alias);
+   dev_warn(skov_priv->dev, "Can't disable %s\n", 
fec_alias);
} else {
-   pr_warn("Can't find node by alias: %s\n", fec_alias);
+   dev_warn(skov_priv->dev, "Can't find node by alias: %s\n", 
fec_alias);
}
 
node = of_find_node_by_alias(root, "mdio-gpio0");
if (node) {
ret = of_device_disable(node);
if (ret)
-   pr_warn("Can't disable mdio-gpio0 node\n");
+   dev_warn(skov_priv->dev, "Can't disable mdio-gpio0 
node\n");
} else {
-   pr_warn("Can't find mdio-gpio0 node\n");
+   dev_warn(skov_priv->dev, "Can't find mdio-gpio0 node\n");
}
 }
 
@@ -404,7 +404,7 @@ static void skov_imx6_switch(struct device_node *root)
if (ret) {
ret = skov_imx6_switch_port(root, old);
if (ret)
-   pr_err("Filed to set mac address\n");
+   dev_err(skov_priv->dev, "Filed to set mac address\n");
}
 }
 
@@ -429,7 +429,7 @@ static int skov_

[PATCH v1 1/4] drivers: net: fec_imx: fix receive issue with external switch

2022-11-02 Thread Oleksij Rempel
Enable poromisc mode by default to allow using multiple MAC address on
same FEC interfaces.

We already use poromisc mode on designware stmmac, so it will make
behavior more consistent on different systems.

Signed-off-by: Oleksij Rempel 
---
 drivers/net/fec_imx.c | 3 +++
 drivers/net/fec_imx.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 673555a48a..9aa4b4f595 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -262,6 +262,9 @@ static int fec_init(struct eth_device *dev)
 */
rcntl = FEC_R_CNTRL_MAX_FL(1518);
 
+   /* Set promisc mode to make switches with different ethaddr work */
+   rcntl |= FEC_R_CNTRL_PROMISC;
+
rcntl |= FEC_R_CNTRL_MII_MODE;
/*
 * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 316eefe48f..9bb1c64b55 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -58,6 +58,7 @@
 #define FEC_R_CNTRL_RMII_10T   (1 << 9) /* i.MX28 specific */
 #define FEC_R_CNTRL_RMII_MODE  (1 << 8) /* i.MX28 specific */
 #define FEC_R_CNTRL_FCE(1 << 5)
+#define FEC_R_CNTRL_PROMISC(1 << 3)
 #define FEC_R_CNTRL_MII_MODE   (1 << 2)
 
 #define FEC_IEVENT_HBERR0x8000 /* Note: Not on i.MX28 */
-- 
2.30.2




Re: [PATCH] ARM: i.MX8M: atf: prefix log messages via pr_fmt()

2022-11-02 Thread Ahmad Fatoum
On 02.11.22 09:19, Sascha Hauer wrote:
> On Wed, Nov 02, 2022 at 08:58:41AM +0100, Marco Felsch wrote:
>> On 22-11-01, Ahmad Fatoum wrote:
>>> We have a couple of log messages in the file, so ensure they are
>>> appropriately prefixed.
>>>
>>> Signed-off-by: Ahmad Fatoum 
>>> ---
>>>  arch/arm/mach-imx/atf.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
>>> index 5301c0fbe8e5..67462bc36189 100644
>>> --- a/arch/arm/mach-imx/atf.c
>>> +++ b/arch/arm/mach-imx/atf.c
>>> @@ -1,5 +1,7 @@
>>>  // SPDX-License-Identifier: GPL-2.0-only
>>>  
>>> +#define pr_fmt(fmt) "imx8m-atf: " fmt
>>
>> Just "atf:" or "imx-atf:"? This code may shared with upcoming imx
>> processors as well, so "imx8m-atf:" would be a bit to specific.
> 
> "imx-atf: " sounds appropriate.

That's confusing, because users may believe this is actual imx-atf output.
Looking at the two log messages in the file, they are both about SDPS
(serial download), so all suggestions are misleading. Perhaps the file
should just be renamed. Please dismiss this patch.

> 
> Sascha
> 
> 
>>
>> Regards,
>>   Marco
>>
>>> +
>>>  #include 
>>>  #include 
>>>  #include 
>>> -- 
>>> 2.30.2
>>>
>>>
>>>
>>
>>
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |




[PATCH] commands: uptime: add note about caveats

2022-11-02 Thread Ahmad Fatoum
Normally timer overrun is not that much of a problem, because there
where it matters, we usually have an is_timeout() in the loop that reads
the timer often enough. This doesn't necessarily hold for the new uptime
command and basically anything can happen between subsequent calls and
if get_time_ns() is not called often enough during that time, we end up
with an inaccurate uptime. Mention this in the extended help text.

Signed-off-by: Ahmad Fatoum 
---
Can be squashed into original commit.
---
 commands/uptime.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/commands/uptime.c b/commands/uptime.c
index a9a8c650b698..d67538631c8f 100644
--- a/commands/uptime.c
+++ b/commands/uptime.c
@@ -66,6 +66,9 @@ static int do_uptime(int argc, char *argv[])
 BAREBOX_CMD_HELP_START(uptime)
 BAREBOX_CMD_HELP_TEXT("This command formats the number of elapsed nanoseconds")
 BAREBOX_CMD_HELP_TEXT("as measured with the current clocksource")
+BAREBOX_CMD_HELP_TEXT("Note: Timekeeping is co-operative. If long running code 
does")
+BAREBOX_CMD_HELP_TEXT("not use delay/is_timeout/get_time_ns/getchar functions")
+BAREBOX_CMD_HELP_TEXT("timer may overrun resulting in incorrect results")
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT ("-n", "output elapsed time in nanoseconds")
 BAREBOX_CMD_HELP_END
-- 
2.30.2




Re: [PATCH 13/14] ARM: i.MX: xload nand: Implement i.MX7 support

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 09:41:18AM +0100, Marco Felsch wrote:
> Hi Sascha,
> 
> On 22-11-01, Sascha Hauer wrote:
> > i.MX7 xload NAND support works like on i.MX6, but the FCB is in a
> > different format. The FCB page uses BCH62 ECC, has 8 ECC chunks with
> > 128 bytes each with a resulting total page size of 1862 bytes. Also
> > the page data is written with a pseudo randomizer enabled.
> > 
> > Signed-off-by: Sascha Hauer 
> > ---
> >  arch/arm/mach-imx/include/mach/imx7-regs.h |  1 +
> >  arch/arm/mach-imx/include/mach/xload.h |  1 +
> >  arch/arm/mach-imx/xload-gpmi-nand.c| 95 --
> >  3 files changed, 91 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/mach-imx/include/mach/imx7-regs.h 
> > b/arch/arm/mach-imx/include/mach/imx7-regs.h
> > index 1ee7d86e0e..379be9e062 100644
> > --- a/arch/arm/mach-imx/include/mach/imx7-regs.h
> > +++ b/arch/arm/mach-imx/include/mach/imx7-regs.h
> > @@ -118,6 +118,7 @@
> >  #define MX7_ENET1_BASE_ADDR(MX7_AIPS3_BASE_ADDR + 0x3E)
> >  #define MX7_ENET2_BASE_ADDR(MX7_AIPS3_BASE_ADDR + 0x3F)
> >  
> > +#defineMX7_APBH_BASE   0x3300
> >  #define MX7_GPMI_BASE  0x33002000
> >  #define MX7_BCH_BASE   0x33004000
> >  
> > diff --git a/arch/arm/mach-imx/include/mach/xload.h 
> > b/arch/arm/mach-imx/include/mach/xload.h
> > index 82bf663c42..ca0055aee2 100644
> > --- a/arch/arm/mach-imx/include/mach/xload.h
> > +++ b/arch/arm/mach-imx/include/mach/xload.h
> > @@ -12,6 +12,7 @@ int imx6_spi_start_image(int instance);
> >  int imx6_esdhc_start_image(int instance);
> >  int imx6_nand_start_image(void);
> >  int imx7_esdhc_start_image(int instance);
> > +int imx7_nand_start_image(void);
> >  int imx8m_esdhc_load_image(int instance, bool start);
> >  int imx8mn_esdhc_load_image(int instance, bool start);
> >  int imx8mp_esdhc_load_image(int instance, bool start);
> > diff --git a/arch/arm/mach-imx/xload-gpmi-nand.c 
> > b/arch/arm/mach-imx/xload-gpmi-nand.c
> > index 7e4033d74f..edffd69e6b 100644
> > --- a/arch/arm/mach-imx/xload-gpmi-nand.c
> > +++ b/arch/arm/mach-imx/xload-gpmi-nand.c
> > @@ -13,6 +13,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  
> > @@ -228,7 +229,7 @@ static uint32_t mxs_nand_aux_status_offset(void)
> >  }
> >  
> >  static int mxs_nand_read_page(struct mxs_nand_info *info, int writesize,
> > -   int oobsize, int pagenum, void *databuf, int raw)
> > +   int oobsize, int pagenum, void *databuf, int raw, bool 
> > randomizer)
> 
> Here the change comes, so this anwers my question.

Yes, moved the offending hunk here.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH 14/14] imx-bbu-nand-fcb: Add fcb command

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> The FCB on NAND has a special page layout and thus can't be read with
> the normal MTD driver. Add a fcb command for printing information about
> the installed FCB on the console.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  commands/Kconfig  |   9 ++
>  common/imx-bbu-nand-fcb.c | 195 --
>  2 files changed, 153 insertions(+), 51 deletions(-)
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 9894ecb9aa..cab72b9226 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -326,6 +326,15 @@ config CMD_SLICE
> command can be used to print informations about slices and also to 
> manipulate
> them on the command line for debugging purposes.
>  
> +config CMD_FCB
> + depends on BAREBOX_UPDATE_IMX_NAND_FCB
> + tristate
> + prompt "fcb"
> + help
> +   Several i.MX SoCs booting from NAND flash need a so called Flash 
> Control Block
> +   at the beginning of the NAND device. The fcb command prints 
> information about
> +   the FCB.
> +
>  # end Information commands
>  endmenu
>  
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index 05bee912e4..39425c7fc3 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -14,6 +14,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -284,57 +286,57 @@ static __maybe_unused void dump_fcb(void *buf)
>  {
>   struct fcb_block *fcb = buf;
>  
> - pr_debug("Checksum:   0x%08x\n", fcb->Checksum);
> - pr_debug("FingerPrint:0x%08x\n", fcb->FingerPrint);
> - pr_debug("Version:0x%08x\n", fcb->Version);
> - pr_debug("DataSetup:  0x%02x\n", fcb->DataSetup);
> - pr_debug("DataHold:   0x%02x\n", fcb->DataHold);
> - pr_debug("AddressSetup:   0x%02x\n", fcb->AddressSetup);
> - pr_debug("DSAMPLE_TIME:   0x%02x\n", fcb->DSAMPLE_TIME);
> - pr_debug("NandTimingState:0x%02x\n", fcb->NandTimingState);
> - pr_debug("REA:0x%02x\n", fcb->REA);
> - pr_debug("RLOH:   0x%02x\n", fcb->RLOH);
> - pr_debug("RHOH:   0x%02x\n", fcb->RHOH);
> - pr_debug("PageDataSize:   0x%08x\n", fcb->PageDataSize);
> - pr_debug("TotalPageSize:  0x%08x\n", fcb->TotalPageSize);
> - pr_debug("SectorsPerBlock:0x%08x\n", fcb->SectorsPerBlock);
> - pr_debug("NumberOfNANDs:  0x%08x\n", fcb->NumberOfNANDs);
> - pr_debug("TotalInternalDie:   0x%08x\n", fcb->TotalInternalDie);
> - pr_debug("CellType:   0x%08x\n", fcb->CellType);
> - pr_debug("EccBlockNEccType:   0x%08x\n", fcb->EccBlockNEccType);
> - pr_debug("EccBlock0Size:  0x%08x\n", fcb->EccBlock0Size);
> - pr_debug("EccBlockNSize:  0x%08x\n", fcb->EccBlockNSize);
> - pr_debug("EccBlock0EccType:   0x%08x\n", fcb->EccBlock0EccType);
> - pr_debug("MetadataBytes:  0x%08x\n", fcb->MetadataBytes);
> - pr_debug("NumEccBlocksPerPage:0x%08x\n", 
> fcb->NumEccBlocksPerPage);
> - pr_debug("EccBlockNEccLevelSDK:   0x%08x\n", 
> fcb->EccBlockNEccLevelSDK);
> - pr_debug("EccBlock0SizeSDK:   0x%08x\n", fcb->EccBlock0SizeSDK);
> - pr_debug("EccBlockNSizeSDK:   0x%08x\n", fcb->EccBlockNSizeSDK);
> - pr_debug("EccBlock0EccLevelSDK:   0x%08x\n", 
> fcb->EccBlock0EccLevelSDK);
> - pr_debug("NumEccBlocksPerPageSDK: 0x%08x\n", 
> fcb->NumEccBlocksPerPageSDK);
> - pr_debug("MetadataBytesSDK:   0x%08x\n", fcb->MetadataBytesSDK);
> - pr_debug("EraseThreshold: 0x%08x\n", fcb->EraseThreshold);
> - pr_debug("BootPatch:  0x%08x\n", fcb->BootPatch);
> - pr_debug("PatchSectors:   0x%08x\n", fcb->PatchSectors);
> - pr_debug("Firmware1_startingPage: 0x%08x\n", 
> fcb->Firmware1_startingPage);
> - pr_debug("Firmware2_startingPage: 0x%08x\n", 
> fcb->Firmware2_startingPage);
> - pr_debug("PagesInFirmware1:   0x%08x\n", fcb->PagesInFirmware1);
> - pr_debug("PagesInFirmware2:   0x%08x\n", fcb->PagesInFirmware2);
> - pr_debug("DBBTSearchAreaStartAddress: 0x%08x\n", 
> fcb->DBBTSearchAreaStartAddress);
> - pr_debug("BadBlockMarkerByte: 0x%08x\n", 
> fcb->BadBlockMarkerByte);
> - pr_debug("BadBlockMarkerStartBit: 0x%08x\n", 
> fcb->BadBlockMarkerStartBit);
> - pr_debug("BBMarkerPhysicalOffset: 0x%08x\n", 
> fcb->BBMarkerPhysicalOffset);
> - pr_debug("BCHType:0x%08x\n", fcb->BCHType);
> - pr_debug("TMTiming2_ReadLatency:  0x%08x\n", 
> fcb->TMTiming2_ReadLatency);
> - pr_debug("TMTiming2_PreambleDelay:0x%08x\n", 
> fcb->TMTiming2_PreambleDel

Re: [PATCH 13/14] ARM: i.MX: xload nand: Implement i.MX7 support

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> i.MX7 xload NAND support works like on i.MX6, but the FCB is in a
> different format. The FCB page uses BCH62 ECC, has 8 ECC chunks with
> 128 bytes each with a resulting total page size of 1862 bytes. Also
> the page data is written with a pseudo randomizer enabled.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  arch/arm/mach-imx/include/mach/imx7-regs.h |  1 +
>  arch/arm/mach-imx/include/mach/xload.h |  1 +
>  arch/arm/mach-imx/xload-gpmi-nand.c| 95 --
>  3 files changed, 91 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/imx7-regs.h 
> b/arch/arm/mach-imx/include/mach/imx7-regs.h
> index 1ee7d86e0e..379be9e062 100644
> --- a/arch/arm/mach-imx/include/mach/imx7-regs.h
> +++ b/arch/arm/mach-imx/include/mach/imx7-regs.h
> @@ -118,6 +118,7 @@
>  #define MX7_ENET1_BASE_ADDR  (MX7_AIPS3_BASE_ADDR + 0x3E)
>  #define MX7_ENET2_BASE_ADDR  (MX7_AIPS3_BASE_ADDR + 0x3F)
>  
> +#define  MX7_APBH_BASE   0x3300
>  #define MX7_GPMI_BASE0x33002000
>  #define MX7_BCH_BASE 0x33004000
>  
> diff --git a/arch/arm/mach-imx/include/mach/xload.h 
> b/arch/arm/mach-imx/include/mach/xload.h
> index 82bf663c42..ca0055aee2 100644
> --- a/arch/arm/mach-imx/include/mach/xload.h
> +++ b/arch/arm/mach-imx/include/mach/xload.h
> @@ -12,6 +12,7 @@ int imx6_spi_start_image(int instance);
>  int imx6_esdhc_start_image(int instance);
>  int imx6_nand_start_image(void);
>  int imx7_esdhc_start_image(int instance);
> +int imx7_nand_start_image(void);
>  int imx8m_esdhc_load_image(int instance, bool start);
>  int imx8mn_esdhc_load_image(int instance, bool start);
>  int imx8mp_esdhc_load_image(int instance, bool start);
> diff --git a/arch/arm/mach-imx/xload-gpmi-nand.c 
> b/arch/arm/mach-imx/xload-gpmi-nand.c
> index 7e4033d74f..edffd69e6b 100644
> --- a/arch/arm/mach-imx/xload-gpmi-nand.c
> +++ b/arch/arm/mach-imx/xload-gpmi-nand.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -228,7 +229,7 @@ static uint32_t mxs_nand_aux_status_offset(void)
>  }
>  
>  static int mxs_nand_read_page(struct mxs_nand_info *info, int writesize,
> - int oobsize, int pagenum, void *databuf, int raw)
> + int oobsize, int pagenum, void *databuf, int raw, bool 
> randomizer)

Here the change comes, so this anwers my question.

Regards,
  Marco

>  {
>   void __iomem *bch_regs = info->bch_base;
>   unsigned column = 0;
> @@ -332,6 +333,12 @@ static int mxs_nand_read_page(struct mxs_nand_info 
> *info, int writesize,
>   d->pio_words[4] = (dma_addr_t)databuf;
>   d->pio_words[5] = (dma_addr_t)(databuf + writesize);
>  
> + if (randomizer) {
> + d->pio_words[2] |= GPMI_ECCCTRL_RANDOMIZER_ENABLE |
> +GPMI_ECCCTRL_RANDOMIZER_TYPE2;
> + d->pio_words[3] |= (pagenum % 256) << 16;
> + }
> +
>   /* Compile DMA descriptor - disable the BCH block. */
>   d = &info->desc[descnum++];
>   d->data = MXS_DMA_DESC_NAND_WAIT_4_READY |
> @@ -841,7 +848,7 @@ static uint32_t calc_chksum(void *buf, size_t size)
>   return ~chksum;
>  }
>  
> -static int get_fcb(struct mxs_nand_info *info, void *databuf)
> +static int imx6_get_fcb(struct mxs_nand_info *info, void *databuf)
>  {
>   int i, pagenum, ret;
>   uint32_t checksum;
> @@ -849,13 +856,13 @@ static int get_fcb(struct mxs_nand_info *info, void 
> *databuf)
>  
>   /* First page read fails, this shouldn't be necessary */
>   mxs_nand_read_page(info, info->organization.pagesize,
> - info->organization.oobsize, 0, databuf, 1);
> + info->organization.oobsize, 0, databuf, 1, false);
>  
>   for (i = 0; i < 4; i++) {
>   pagenum = info->organization.pages_per_eraseblock * i;
>  
>   ret = mxs_nand_read_page(info, info->organization.pagesize,
> - info->organization.oobsize, pagenum, databuf, 1);
> + info->organization.oobsize, pagenum, databuf, 1, false);
>   if (ret)
>   continue;
>  
> @@ -887,6 +894,66 @@ static int get_fcb(struct mxs_nand_info *info, void 
> *databuf)
>   return -EINVAL;
>  }
>  
> +static int imx7_get_fcb_n(struct mxs_nand_info *info, void *databuf, int num)
> +{
> + int ret;
> + int flips = 0;
> + uint8_t *status;
> + int i;
> +
> + ret = mxs_nand_read_page(info, BCH62_WRITESIZE, BCH62_OOBSIZE,
> +  info->organization.pages_per_eraseblock * num, 
> databuf, 0, true);
> + if (ret)
> + return ret;
> +
> + /* Loop over status bytes, accumulating ECC status. */
> + status = databuf + BCH62_WRITESIZE + 32;
> +
> + for (i = 0; i < 8; i++) {
> + sw

Re: [PATCH 12/14] ARM: i.MX: xload nand: Move mxs_nand_mode_fcb_62bit() to header file

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> mxs_nand_mode_fcb_62bit() can be shared between the regular MTD NAND
> driver and the upcoming i.MX7 xload driver. Move to header file.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  drivers/mtd/nand/nand_mxs.c | 34 ++
>  include/soc/imx/gpmi-nand.h | 27 +++
>  2 files changed, 29 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
> index b162c23743..79a8fbdefa 100644
> --- a/drivers/mtd/nand/nand_mxs.c
> +++ b/drivers/mtd/nand/nand_mxs.c
> @@ -1123,36 +1123,6 @@ static int mxs_nand_block_markbad(struct nand_chip 
> *chip , loff_t ofs)
>   return 0;
>  }
>  
> -#define BCH62_WRITESIZE  1024
> -#define BCH62_OOBSIZE838
> -#define BCH62_PAGESIZE   (BCH62_WRITESIZE + BCH62_OOBSIZE)
> -
> -static void mxs_nand_mode_fcb_62bit(struct mxs_nand_info *nand_info)
> -{
> - void __iomem *bch_regs;
> - u32 fl0, fl1;
> -
> - bch_regs = nand_info->bch_base;
> -
> - /* 8 ecc_chunks */
> - fl0 = FIELD_PREP(BCH_FLASHLAYOUT0_NBLOCKS, 7);
> - /* 32 bytes for metadata */
> - fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_META_SIZE, 32);
> - /* using ECC62 level to be performed */
> - fl0 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT0_ECC0, 0x1f);
> - /* 0x20 * 4 bytes of the data0 block */
> - fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_DATA0_SIZE, 0x20);
> - writel(fl0, bch_regs + BCH_FLASH0LAYOUT0);
> -
> - /* 1024 for data + 838 for OOB */
> - fl1 = FIELD_PREP(BCH_FLASHLAYOUT1_PAGE_SIZE, BCH62_PAGESIZE);
> - /* using ECC62 level to be performed */
> - fl1 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT1_ECCN, 0x1f);
> - /* 0x20 * 4 bytes of the data0 block */
> - fl1 |= FIELD_PREP(BCH_FLASHLAYOUT1_DATAN_SIZE, 0x20);
> - writel(fl1, bch_regs + BCH_FLASH0LAYOUT1);
> -}
> -
>  int mxs_nand_read_fcb_bch62(unsigned int block, void *buf, size_t size)
>  {
>   struct nand_chip *chip;
> @@ -1174,7 +1144,7 @@ int mxs_nand_read_fcb_bch62(unsigned int block, void 
> *buf, size_t size)
>  
>   page = block * (mtd->erasesize / mtd->writesize);
>  
> - mxs_nand_mode_fcb_62bit(nand_info);
> + mxs_nand_mode_fcb_62bit(nand_info->bch_base);
>  
>   nand_read_page_op(chip, page, 0, NULL, 0);
>  
> @@ -1238,7 +1208,7 @@ int mxs_nand_write_fcb_bch62(unsigned int block, void 
> *buf, size_t size)
>   nand_info = chip->priv;
>   channel = nand_info->dma_channel_base;
>  
> - mxs_nand_mode_fcb_62bit(nand_info);
> + mxs_nand_mode_fcb_62bit(nand_info->bch_base);
>  
>   nand_select_target(chip, 0);
>  
> diff --git a/include/soc/imx/gpmi-nand.h b/include/soc/imx/gpmi-nand.h
> index f7a2caa1d6..8c30dee8ab 100644
> --- a/include/soc/imx/gpmi-nand.h
> +++ b/include/soc/imx/gpmi-nand.h
> @@ -111,4 +111,31 @@
>  
>  #define  MXS_NAND_BCH_TIMEOUT1
>  
> +#define BCH62_WRITESIZE  1024
> +#define BCH62_OOBSIZE838
> +#define BCH62_PAGESIZE   (BCH62_WRITESIZE + BCH62_OOBSIZE)
> +

Nit: Maybe put a small comment here so we can easily see why we are
doing this.

Regards,
  Marco

> +static void mxs_nand_mode_fcb_62bit(void __iomem *bch_regs)
> +{
> + u32 fl0, fl1;
> +
> + /* 8 ecc_chunks */
> + fl0 = FIELD_PREP(BCH_FLASHLAYOUT0_NBLOCKS, 7);
> + /* 32 bytes for metadata */
> + fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_META_SIZE, 32);
> + /* using ECC62 level to be performed */
> + fl0 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT0_ECC0, 0x1f);
> + /* 0x20 * 4 bytes of the data0 block */
> + fl0 |= FIELD_PREP(BCH_FLASHLAYOUT0_DATA0_SIZE, 0x20);
> + writel(fl0, bch_regs + BCH_FLASH0LAYOUT0);
> +
> + /* 1024 for data + 838 for OOB */
> + fl1 = FIELD_PREP(BCH_FLASHLAYOUT1_PAGE_SIZE, BCH62_PAGESIZE);
> + /* using ECC62 level to be performed */
> + fl1 |= FIELD_PREP(IMX6_BCH_FLASHLAYOUT1_ECCN, 0x1f);
> + /* 0x20 * 4 bytes of the data0 block */
> + fl1 |= FIELD_PREP(BCH_FLASHLAYOUT1_DATAN_SIZE, 0x20);
> + writel(fl1, bch_regs + BCH_FLASH0LAYOUT1);
> +}
> +
>  #endif /* __SOC_IMX_GPMI_NAND_H */
> -- 
> 2.30.2
> 
> 
> 



Re: [PATCH 08/14] ARM: i.MX: xload nand: Pull ECC status checking out of read page

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> The read page code can be reused by upcoming i.MX7 support, but the ECC
> checking will be different. Pull ECC status checking out of the read
> page code to make that reusable on i.MX7.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  arch/arm/mach-imx/xload-gpmi-nand.c | 42 -
>  1 file changed, 29 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/xload-gpmi-nand.c 
> b/arch/arm/mach-imx/xload-gpmi-nand.c
> index dc4cc45be0..543ec108ba 100644
> --- a/arch/arm/mach-imx/xload-gpmi-nand.c
> +++ b/arch/arm/mach-imx/xload-gpmi-nand.c
> @@ -236,8 +236,6 @@ static int mxs_nand_read_page(struct mxs_nand_info *info, 
> int writesize,
>   int cmd_queue_len;
>   u8 *cmd_buf;
>   int ret;
> - uint8_t *status;
> - int i;
>   int timeout;
>   int descnum = 0;
>   int max_pagenum = info->nand_size /
> @@ -375,20 +373,26 @@ static int mxs_nand_read_page(struct mxs_nand_info 
> *info, int writesize,
>   writel(BCH_CTRL_COMPLETE_IRQ,
>   bch_regs + BCH_CTRL + STMP_OFFSET_REG_CLR);
>  
> - /* Loop over status bytes, accumulating ECC status. */
> - status = databuf + writesize + mxs_nand_aux_status_offset();
> - for (i = 0; i < writesize / MXS_NAND_CHUNK_DATA_CHUNK_SIZE; i++) {
> - if (status[i] == 0xfe) {
> - ret = -EBADMSG;
> - goto err;
> - }
> - }
> -
>   ret = 0;
>  err:
>   return ret;
>  }
>  
> +static int mxs_nand_get_ecc_status(struct mxs_nand_info *info, void *databuf)
> +{
> + uint8_t *status;
> + int i;
> +
> + /* Loop over status bytes, accumulating ECC status. */
> + status = databuf + info->organization.pagesize + 
> mxs_nand_aux_status_offset();
> + for (i = 0; i < info->organization.pagesize / 
> MXS_NAND_CHUNK_DATA_CHUNK_SIZE; i++) {
> + if (status[i] == 0xfe)
> + return -EBADMSG;
> + }
> +
> + return 0;
> +}
> +
>  static int mxs_nand_get_read_status(struct mxs_nand_info *info, void 
> *databuf)
>  {
>   int ret;
> @@ -851,6 +855,10 @@ static int get_fcb(struct mxs_nand_info *info, void 
> *databuf)
>   if (ret)
>   continue;
>  
> + ret = mxs_nand_get_ecc_status(info, databuf);
> + if (ret)
> + continue;
> +
>   memcpy(fcb, databuf + mxs_nand_aux_status_offset(),
>   sizeof(*fcb));
>  
> @@ -886,7 +894,11 @@ static int get_dbbt(struct mxs_nand_info *info, void 
> *databuf)
>   page = startpage + i * info->organization.pages_per_eraseblock;
>  
>   ret = mxs_nand_read_page(info, info->organization.pagesize,
> - info->organization.oobsize, page, databuf, 0);
> + info->organization.oobsize, page, databuf, 0, false);

Maybe I didn't saw the change, but where did you changed the function
declaration?

Regards,
  Marco

> + if (ret)
> + continue;
> +
> + ret = mxs_nand_get_ecc_status(info, databuf);
>   if (ret)
>   continue;
>  
> @@ -900,7 +912,11 @@ static int get_dbbt(struct mxs_nand_info *info, void 
> *databuf)
>   return -ENOENT;
>  
>   ret = mxs_nand_read_page(info, info->organization.pagesize,
> - info->organization.oobsize, page + 4, databuf, 0);
> + info->organization.oobsize, page + 4, databuf, 0, 
> false);
> + if (ret)
> + continue;
> +
> + ret = mxs_nand_get_ecc_status(info, databuf);
>   if (ret)
>   continue;
>  
> -- 
> 2.30.2
> 
> 
> 



Re: [PATCH 1/3] include: debug_ll: define puthexc_ll

2022-11-02 Thread Sascha Hauer
On Wed, Oct 19, 2022 at 02:38:15PM +0200, Ahmad Fatoum wrote:
> puthex_ll prints a single zero-padded unsigned long, which for a single
> byte is not very readable, especially on 64-bit systems. Define
> puthexc_ll() as well, which just accepts a byte and formats its nibbles
> as hexadecimal characters.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
>  include/debug_ll.h | 16 ++--
>  1 file changed, 14 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/include/debug_ll.h b/include/debug_ll.h
> index 735033b314cc..856a157bf52c 100644
> --- a/include/debug_ll.h
> +++ b/include/debug_ll.h
> @@ -33,17 +33,25 @@ static inline void putc_ll(char value)
>   PUTC_LL(value);
>  }
>  
> -static inline void puthex_ll(unsigned long value)
> +static inline void puthexc_ll(unsigned char value)
>  {
>   int i; unsigned char ch;
>  
> - for (i = sizeof(unsigned long) * 2; i--; ) {
> + for (i = 2; i--; ) {
>   ch = ((value >> (i * 4)) & 0xf);
>   ch += (ch >= 10) ? 'a' - 10 : '0';
>   putc_ll(ch);
>   }
>  }
>  
> +static inline void puthex_ll(unsigned long value)
> +{
> + int i;
> +
> + for (i = sizeof(unsigned long); i--; )
> + puthexc_ll(value >> (i * 8));
> +}
> +
>  /*
>   * Be careful with puts_ll, it only works if the binary is running at the
>   * link address which often is not the case during early startup. If in doubt
> @@ -66,6 +74,10 @@ static inline void putc_ll(char value)
>  {
>  }
>  
> +static inline void puthexc_ll(unsigned char value)
> +{
> +}
> +
>  static inline void puthex_ll(unsigned long value)
>  {
>  }
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH 03/14] ARM: i.MX: xload nand: add common readid

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> mxs_nand_check_onfi() and mxs_nand_read_id() setup the same DMA
> descriptors with only a small difference. factor out a common
> read_id function from it and share the code.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  arch/arm/mach-imx/xload-gpmi-nand.c | 148 ++--
>  1 file changed, 54 insertions(+), 94 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/xload-gpmi-nand.c 
> b/arch/arm/mach-imx/xload-gpmi-nand.c
> index 6ac9af762f..ffbd5c22e3 100644
> --- a/arch/arm/mach-imx/xload-gpmi-nand.c
> +++ b/arch/arm/mach-imx/xload-gpmi-nand.c
> @@ -668,7 +668,7 @@ static int mxs_nand_get_onfi(struct mxs_nand_info *info, 
> void *databuf)
>   return ret;
>  }
>  
> -static int mxs_nand_check_onfi(struct mxs_nand_info *info, void *databuf)
> +static int mxs_nand_read_id(struct mxs_nand_info *info, u8 adr, void 
> *databuf, size_t len)
>  {
>   int ret;
>   u8 *cmd_buf;
> @@ -676,13 +676,6 @@ static int mxs_nand_check_onfi(struct mxs_nand_info 
> *info, void *databuf)
>   int descnum = 0;
>   int cmd_queue_len;
>  
> - struct onfi_header {
> - u8 byte0;
> - u8 byte1;
> - u8 byte2;
> - u8 byte3;
> - } onfi_head;
> -
>   memset(info->desc, 0,
>   sizeof(*info->desc) * MXS_NAND_DMA_DESCRIPTOR_COUNT);
>  
> @@ -692,7 +685,7 @@ static int mxs_nand_check_onfi(struct mxs_nand_info 
> *info, void *databuf)
>   d = &info->desc[descnum++];
>   d->address = (dma_addr_t)(cmd_buf);
>   cmd_buf[cmd_queue_len++] = NAND_CMD_READID;
> - cmd_buf[cmd_queue_len++] = 0x20;
> + cmd_buf[cmd_queue_len++] = adr;
>  
>   d->data = DMACMD_COMMAND_DMA_READ |
>   DMACMD_WAIT4END |
> @@ -710,13 +703,13 @@ static int mxs_nand_check_onfi(struct mxs_nand_info 
> *info, void *databuf)
>   d = &info->desc[descnum++];
>   d->data = DMACMD_WAIT4END |
>   DMACMD_PIO_WORDS(1) |
> - DMACMD_XFER_COUNT(sizeof(struct onfi_header)) |
> + DMACMD_XFER_COUNT(len) |
>   DMACMD_COMMAND_DMA_WRITE;
>   d->pio_words[0] = GPMI_CTRL0_COMMAND_MODE_READ |
>   GPMI_CTRL0_WORD_LENGTH |
>   FIELD_PREP(GPMI_CTRL0_CS, info->cs) |
>   GPMI_CTRL0_ADDRESS_NAND_DATA |
> - (sizeof(struct onfi_header));
> + len;
>   d->address = (dma_addr_t)databuf;
>  
>   /* Compile DMA descriptor - de-assert the NAND lock and interrupt. */
> @@ -725,119 +718,86 @@ static int mxs_nand_check_onfi(struct mxs_nand_info 
> *info, void *databuf)
>  
>   /* Execute the DMA chain. */
>   ret = mxs_dma_run(info->dma_channel, info->desc, descnum);
> - if (ret) {
> + if (ret)
>   pr_err("DMA read error\n");
> - return ret;
> - }
>  
> - memcpy(&onfi_head, databuf, sizeof(struct onfi_header));
> + return ret;
> +}
> +
> +struct onfi_header {
> + u8 byte0;
> + u8 byte1;
> + u8 byte2;
> + u8 byte3;
> +};
> +
> +static int mxs_nand_check_onfi(struct mxs_nand_info *info, void *databuf)
> +{
> + int ret;
> + struct onfi_header *onfi_head = databuf;
> +
> + ret = mxs_nand_read_id(info, 0x20, databuf, sizeof(struct onfi_header));
> + if (ret)
> + return ret;
>  
> - pr_debug("ONFI Byte0: 0x%x\n", onfi_head.byte0);
> - pr_debug("ONFI Byte1: 0x%x\n", onfi_head.byte1);
> - pr_debug("ONFI Byte2: 0x%x\n", onfi_head.byte2);
> - pr_debug("ONFI Byte3: 0x%x\n", onfi_head.byte3);
> + pr_debug("ONFI Byte0: 0x%x\n", onfi_head->byte0);
> + pr_debug("ONFI Byte1: 0x%x\n", onfi_head->byte1);
> + pr_debug("ONFI Byte2: 0x%x\n", onfi_head->byte2);
> + pr_debug("ONFI Byte3: 0x%x\n", onfi_head->byte3);
>  
>   /* check if returned values correspond to ascii characters "ONFI" */
> - if (onfi_head.byte0 != 0x4f || onfi_head.byte1 != 0x4e ||
> - onfi_head.byte2 != 0x46 || onfi_head.byte3 != 0x49)
> + if (onfi_head->byte0 != 0x4f || onfi_head->byte1 != 0x4e ||
> + onfi_head->byte2 != 0x46 || onfi_head->byte3 != 0x49)

Nit: Should we change the compare to something like this:
  onfi_head->byte0 != 'O'
  onfi_head->byte1 != 'N'

This way we can remove the comment.

>   return 1;
>  
>   return 0;
>  }
>  
> +struct readid_data {
> + u8 byte0;
> + u8 byte1;
> + u8 byte2;
> + u8 byte3;
> + u8 byte4;
> +} id_data;

The id_data variable is unsused.

Regards,
  Marco

>  static int mxs_nand_get_readid(struct mxs_nand_info *info, void *databuf)
>  {
>   int ret;
> - u8 *cmd_buf;
> - struct mxs_dma_cmd *d;
> - int descnum = 0;
> - int cmd_queue_len;
> -
> - struct readid_data {
> - u8 byte0;
> - u8 byte1;
> - u8 byte2;
> - u8 byte3;
> - u8 byte4;
> - } id_data;
> -
> - memset(info->desc, 0,
> - sizeof(*info->desc) * MXS_NAND_DMA_DE

Re: [PATCH] ARM: i.MX8M: atf: prefix log messages via pr_fmt()

2022-11-02 Thread Sascha Hauer
On Wed, Nov 02, 2022 at 08:58:41AM +0100, Marco Felsch wrote:
> On 22-11-01, Ahmad Fatoum wrote:
> > We have a couple of log messages in the file, so ensure they are
> > appropriately prefixed.
> > 
> > Signed-off-by: Ahmad Fatoum 
> > ---
> >  arch/arm/mach-imx/atf.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
> > index 5301c0fbe8e5..67462bc36189 100644
> > --- a/arch/arm/mach-imx/atf.c
> > +++ b/arch/arm/mach-imx/atf.c
> > @@ -1,5 +1,7 @@
> >  // SPDX-License-Identifier: GPL-2.0-only
> >  
> > +#define pr_fmt(fmt) "imx8m-atf: " fmt
> 
> Just "atf:" or "imx-atf:"? This code may shared with upcoming imx
> processors as well, so "imx8m-atf:" would be a bit to specific.

"imx-atf: " sounds appropriate.

Sascha


> 
> Regards,
>   Marco
> 
> > +
> >  #include 
> >  #include 
> >  #include 
> > -- 
> > 2.30.2
> > 
> > 
> > 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH] ARM: dts: i.MX8MP: increase off-on delay on the SD Vcc regulator

2022-11-02 Thread Sascha Hauer
On Tue, Nov 01, 2022 at 02:30:50PM +0100, Marco Felsch wrote:
> This commit is required to fix the SD card detection mechanism. Without
> this commit the SD card (auto-)detection fails when booted from this
> sd-card:
> 
>   mmc1: Query interface conditions failed: -110
>   mmc1: SD operation condition set timed out
> 
> The commit is ported from U-Boot:
> 
> | commit 247bbeb74c186963d9365db3136d0285618bd9a7
> | Author: Andrey Zhizhikin 
> | Date:   Sat Dec 5 17:29:17 2020 +
> |
> | ARM: dts: imx8m: increase off-on delay on the SD Vcc regulator
> |
> | Some SD Card controller and power circuitry has increased capacitance,
> | which keeps the internal logic remains powered after regulator is switch
> | off. This is generally the case when card is switched to SD104 mode,
> | where a power cycle should be performed. In case if the card internal
> | logic remains powered, it causes a subsequent failure of mode
> | transition, effectively leading to failed enumeration.
> |
> | Introduce a delay of 20 msec in order to provide a possibility for
> | internal card circuitry to drain voltages and perform a power cycle
> | correctly.
> |
> | Similar fix is done in commit c49d0ac38a76 ("ARM: dts: rmobile: Increase
> | off-on delay on the SD Vcc regulator") targeted Renesas SOCs.
> |
> | Signed-off-by: Andrey Zhizhikin 
> | Cc: Stefano Babic 
> 
> Signed-off-by: Marco Felsch 
> ---
>  arch/arm/dts/imx8mp-evk.dts | 4 
>  1 file changed, 4 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/dts/imx8mp-evk.dts b/arch/arm/dts/imx8mp-evk.dts
> index 3264ade4b8..77b438287c 100644
> --- a/arch/arm/dts/imx8mp-evk.dts
> +++ b/arch/arm/dts/imx8mp-evk.dts
> @@ -35,6 +35,10 @@
>   reset-deassert-us = <10>;
>  };
>  
> +®_usdhc2_vmmc {
> + off-on-delay-us = <2>;
> +};
> +
>  &usdhc2 {
>   #address-cells = <1>;
>   #size-cells = <1>;
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH 02/14] ARM: i.MX: xload nand: Use common register defines

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> We have a set of GPMI register defines in include/, so use them for the
> xload driver as well.
> 
> Signed-off-by: Sascha Hauer 
> ---
>  arch/arm/mach-imx/xload-gpmi-nand.c | 66 -
>  1 file changed, 17 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/xload-gpmi-nand.c 
> b/arch/arm/mach-imx/xload-gpmi-nand.c
> index 3a4f331ce6..6ac9af762f 100644
> --- a/arch/arm/mach-imx/xload-gpmi-nand.c
> +++ b/arch/arm/mach-imx/xload-gpmi-nand.c
> @@ -11,6 +11,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 

missing bitfield.h include.

Also should we say in the commit message that we are using the
FIELD_PREP now by this change?

Regards,
  Marco


>  
> @@ -203,39 +204,6 @@ static int mxs_dma_run(struct mxs_dma_chan *pchan, 
> struct mxs_dma_cmd *pdesc,
>  
>  /* - NAND driver part -- 
> */
>  
> -#define  GPMI_CTRL0  0x
> -#define  GPMI_CTRL0_RUN  (1 << 29)
> -#define  GPMI_CTRL0_DEV_IRQ_EN   (1 << 28)
> -#define  GPMI_CTRL0_UDMA (1 << 26)
> -#define  GPMI_CTRL0_COMMAND_MODE_MASK(0x3 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_OFFSET  24
> -#define  GPMI_CTRL0_COMMAND_MODE_WRITE   (0x0 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_READ(0x1 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_READ_AND_COMPARE(0x2 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_WAIT_FOR_READY  (0x3 << 24)
> -#define  GPMI_CTRL0_WORD_LENGTH  (1 << 23)
> -#define  GPMI_CTRL0_CS(cs)   ((cs) << 20)
> -#define  GPMI_CTRL0_ADDRESS_MASK (0x7 << 17)
> -#define  GPMI_CTRL0_ADDRESS_OFFSET   17
> -#define  GPMI_CTRL0_ADDRESS_NAND_DATA(0x0 << 17)
> -#define  GPMI_CTRL0_ADDRESS_NAND_CLE (0x1 << 17)
> -#define  GPMI_CTRL0_ADDRESS_NAND_ALE (0x2 << 17)
> -#define  GPMI_CTRL0_ADDRESS_INCREMENT(1 << 16)
> -#define  GPMI_CTRL0_XFER_COUNT_MASK  0x
> -#define  GPMI_CTRL0_XFER_COUNT_OFFSET0
> -
> -#define  GPMI_ECCCTRL_ECC_CMD_DECODE (0x0 << 13)
> -#define  GPMI_ECCCTRL_ENABLE_ECC (1 << 12)
> -#define  GPMI_ECCCTRL_BUFFER_MASK_BCH_PAGE   0x1ff
> -
> -#define  BCH_CTRL0x
> -#define  BCH_CTRL_COMPLETE_IRQ   (1 << 0)
> -
> -#define  MXS_NAND_DMA_DESCRIPTOR_COUNT   6
> -#define  MXS_NAND_CHUNK_DATA_CHUNK_SIZE  512
> -#define  MXS_NAND_METADATA_SIZE  10
> -#define  MXS_NAND_COMMAND_BUFFER_SIZE128
> -
>  struct mxs_nand_info {
>   void __iomem *io_base;
>   void __iomem *bch_base;
> @@ -352,7 +320,7 @@ static int mxs_nand_read_page(struct mxs_nand_info *info, 
> int writesize,
>  
>   d->pio_words[0] = GPMI_CTRL0_COMMAND_MODE_WRITE |
>   GPMI_CTRL0_WORD_LENGTH |
> - GPMI_CTRL0_CS(info->cs) |
> + FIELD_PREP(GPMI_CTRL0_CS, info->cs) |
>   GPMI_CTRL0_ADDRESS_NAND_CLE |
>   GPMI_CTRL0_ADDRESS_INCREMENT |
>   cmd_queue_len;
> @@ -372,7 +340,7 @@ static int mxs_nand_read_page(struct mxs_nand_info *info, 
> int writesize,
>  
>   d->pio_words[0] = GPMI_CTRL0_COMMAND_MODE_WRITE |
>   GPMI_CTRL0_WORD_LENGTH |
> - GPMI_CTRL0_CS(info->cs) |
> + FIELD_PREP(GPMI_CTRL0_CS, info->cs) |
>   GPMI_CTRL0_ADDRESS_NAND_CLE |
>   GPMI_CTRL0_ADDRESS_INCREMENT |
>   cmd_queue_len;
> @@ -386,7 +354,7 @@ static int mxs_nand_read_page(struct mxs_nand_info *info, 
> int writesize,
>  
>   d->pio_words[0] = GPMI_CTRL0_COMMAND_MODE_WAIT_FOR_READY |
>   GPMI_CTRL0_WORD_LENGTH |
> - GPMI_CTRL0_CS(info->cs) |
> + FIELD_PREP(GPMI_CTRL0_CS, info->cs) |
>   GPMI_CTRL0_ADDRESS_NAND_DATA;
>  
>   if (raw) {
> @@ -398,7 +366,7 @@ static int mxs_nand_read_page(struct mxs_nand_info *info, 
> int writesize,
>   DMACMD_COMMAND_DMA_WRITE;
>   d->pio_words[0] = GPMI_CTRL0_COMMAND_MODE_READ |
>   GPMI_CTRL0_WORD_LENGTH |
> - GPMI_CTRL0_CS(info->cs) |
> + FIELD_PREP(GPMI_CTRL0_CS, info->cs) |
>   GPMI_CTRL0_ADDRESS_NAND_DATA |
>   (writesize + oobsize);
>   d->address = (dma_addr_t)databuf;
> @@ -408,7 +376,7 @@ static int mxs_nand_read_page(struct mxs

Re: [PATCH 01/14] mtd: nand: nand-mxs: Move register definitions to separate file

2022-11-02 Thread Marco Felsch
Hi Sascha,

On 22-11-01, Sascha Hauer wrote:
> The GPMI registers are needed in the MTD GPMI driver and also in the
> xload-gpmi driver. So far both use their own set of register defines.
> Move the MTD GPMI register defines to include/ so that we can use them
> in the xload driver as well.

Nit: Should we note that we are replacing the manual bitops by
FIELD_PREP?

Regards,
  Marco

> 
> Signed-off-by: Sascha Hauer 
> ---
>  drivers/mtd/nand/nand_mxs.c | 186 ++--
>  include/soc/imx/gpmi-nand.h | 114 ++
>  2 files changed, 145 insertions(+), 155 deletions(-)
>  create mode 100644 include/soc/imx/gpmi-nand.h
> 
> diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
> index 5faa17a4bd..d711708ff2 100644
> --- a/drivers/mtd/nand/nand_mxs.c
> +++ b/drivers/mtd/nand/nand_mxs.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -32,139 +33,10 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "internals.h"
>  
> -#define  MX28_BLOCK_SFTRST   (1 << 31)
> -#define  MX28_BLOCK_CLKGATE  (1 << 30)
> -
> -#define GPMI_CTRL0   0x
> -#define  GPMI_CTRL0_RUN  (1 << 29)
> -#define  GPMI_CTRL0_DEV_IRQ_EN   (1 << 28)
> -/* Disable for now since we don't need it and it is different on MX23.
> -#define  GPMI_CTRL0_LOCK_CS  (1 << 27)
> -*/
> -#define  GPMI_CTRL0_UDMA (1 << 26)
> -#define  GPMI_CTRL0_COMMAND_MODE_MASK(0x3 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_OFFSET  24
> -#define  GPMI_CTRL0_COMMAND_MODE_WRITE   (0x0 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_READ(0x1 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_READ_AND_COMPARE(0x2 << 24)
> -#define  GPMI_CTRL0_COMMAND_MODE_WAIT_FOR_READY  (0x3 << 24)
> -#define  GPMI_CTRL0_WORD_LENGTH  (1 << 23)
> -/* Careful: Is 0x3 on MX23
> -#define  GPMI_CTRL0_CS_MASK  (0x7 << 20)
> -*/
> -#define  GPMI_CTRL0_CS_OFFSET20
> -#define  GPMI_CTRL0_ADDRESS_MASK (0x7 << 17)
> -#define  GPMI_CTRL0_ADDRESS_OFFSET   17
> -#define  GPMI_CTRL0_ADDRESS_NAND_DATA(0x0 << 17)
> -#define  GPMI_CTRL0_ADDRESS_NAND_CLE (0x1 << 17)
> -#define  GPMI_CTRL0_ADDRESS_NAND_ALE (0x2 << 17)
> -#define  GPMI_CTRL0_ADDRESS_INCREMENT(1 << 16)
> -#define  GPMI_CTRL0_XFER_COUNT_MASK  0x
> -#define  GPMI_CTRL0_XFER_COUNT_OFFSET0
> -
> -#define GPMI_CTRL1   0x0060
> -#define GPMI_CTRL1_SET   0x0064
> -#define GPMI_CTRL1_CLR   0x0068
> -#define  GPMI_CTRL1_DECOUPLE_CS  (1 << 24)
> -#define  GPMI_CTRL1_WRN_DLY(d)   (((d) & 0x3) << 
> 22)
> -#define  GPMI_CTRL1_TIMEOUT_IRQ_EN   (1 << 20)
> -#define  GPMI_CTRL1_GANGED_RDYBUSY   (1 << 19)
> -#define  GPMI_CTRL1_BCH_MODE (1 << 18)
> -#define  GPMI_CTRL1_DLL_ENABLE   (1 << 17)
> -#define  GPMI_CTRL1_HALF_PERIOD  (1 << 16)
> -#define  GPMI_CTRL1_RDN_DELAY(d) (((d) & 0xf) << 
> 12)
> -#define  GPMI_CTRL1_DMA2ECC_MODE (1 << 11)
> -#define  GPMI_CTRL1_DEV_IRQ  (1 << 10)
> -#define  GPMI_CTRL1_TIMEOUT_IRQ  (1 << 9)
> -#define  GPMI_CTRL1_BURST_EN (1 << 8)
> -#define  GPMI_CTRL1_ABORT_WAIT_REQUEST   (1 << 7)
> -#define  GPMI_CTRL1_ABORT_WAIT_FOR_READY_CHANNEL_MASK(0x7 << 4)
> -#define  GPMI_CTRL1_ABORT_WAIT_FOR_READY_CHANNEL_OFFSET  4
> -#define  GPMI_CTRL1_DEV_RESET(1 << 3)
> -#define  GPMI_CTRL1_ATA_IRQRDY_POLARITY  (1 << 2)
> -#define  GPMI_CTRL1_CAMERA_MODE  (1 << 1)
> -#define  GPMI_CTRL1_GPMI_MODE(1 << 0)
> -
> -#define BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS   0x0
> -#define BV_GPMI_CTRL1_WRN_DLY_SEL_6_TO_10NS  0x1
> -#define BV_GPMI_CTRL1_WRN_DLY_SEL_7_TO_12NS  0x2
> -#define BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY   0x3
> -
> -#define GPMI_TIMING0 0x0070
> -
> -#define  GPMI_TIMING0_ADDRESS_SETUP(d)   (((d) & 0xff) 
> << 16)
> -

Re: [PATCH v2 1/2] ARM: socfpga: Fix SDRAM firewall init

2022-11-02 Thread Sascha Hauer
On Tue, Nov 01, 2022 at 11:33:26AM +0100, Vyacheslav Yurkov wrote:
> From: Vyacheslav Yurkov 
> 
> Incorrect enable bits were used in initialization sequence of SDRAM
> firewall. This enables the FPGA to access regions of SDRAM, which were
> previously inaccessible.
> 
> Signed-off-by: Vyacheslav Yurkov 
> ---
>  arch/arm/mach-socfpga/arria10-sdram.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-socfpga/arria10-sdram.c 
> b/arch/arm/mach-socfpga/arria10-sdram.c
> index 35c355df71..b7eade0b17 100644
> --- a/arch/arm/mach-socfpga/arria10-sdram.c
> +++ b/arch/arm/mach-socfpga/arria10-sdram.c
> @@ -486,7 +486,7 @@ static int arria10_sdram_firewall_setup(void)
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_MPUREGION3ADDR);
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM0REGION0ADDR);
>  
> - mpu_en |= ARRIA10_NOC_FW_DDR_MPU_MPUREG1EN;
> + mpu_en |= ARRIA10_NOC_FW_DDR_MPU_F2SDR0REG0EN;
>   writel(mpu_en, ARRIA10_SDR_FW_MPU_FPGA_EN);
>  
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM0REGION1ADDR);
> @@ -494,7 +494,7 @@ static int arria10_sdram_firewall_setup(void)
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM0REGION3ADDR);
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM1REGION0ADDR);
>  
> - mpu_en |= ARRIA10_NOC_FW_DDR_MPU_MPUREG2EN;
> + mpu_en |= ARRIA10_NOC_FW_DDR_MPU_F2SDR1REG0EN;
>   writel(mpu_en, ARRIA10_SDR_FW_MPU_FPGA_EN);
>  
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM1REGION1ADDR);
> @@ -502,7 +502,7 @@ static int arria10_sdram_firewall_setup(void)
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM1REGION3ADDR);
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM2REGION0ADDR);
>  
> - mpu_en |= ARRIA10_NOC_FW_DDR_MPU_MPUREG3EN;
> + mpu_en |= ARRIA10_NOC_FW_DDR_MPU_F2SDR2REG0EN;
>   writel(mpu_en, ARRIA10_SDR_FW_MPU_FPGA_EN);
>  
>   writel(0x, ARRIA10_SDR_FW_MPU_FPGA_FPGA2SDRAM2REGION1ADDR);
> -- 
> 2.25.1
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH v2 1/2] commands: add new uptime command

2022-11-02 Thread Sascha Hauer
On Tue, Nov 01, 2022 at 07:37:56AM +0100, Ahmad Fatoum wrote:
> We have a time command to record the delta of get_time_ns() to time
> command execution, but have no command to just print get_time_ns().
> 
> Such a command can be useful to debug clocksources or to verify that a
> system is still running and hasn't been reset by a yet unhandled
> watchdog in-between.
> 
> Make development a bit easier by providing a new uptime command.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 -> v2:
>   - use getopt (Sascha)
>   - drop other patches
> ---

Applied, thanks

Sascha

>  commands/Kconfig  | 13 
>  commands/Makefile |  1 +
>  commands/uptime.c | 79 +++
>  3 files changed, 93 insertions(+)
>  create mode 100644 commands/uptime.c
> 
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 2ce990b5616a..a59616ad1474 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -2289,6 +2289,19 @@ config CMD_TIME
> Note: This command depends on COMMAND being interruptible,
> otherwise the timer may overrun resulting in incorrect results
>  
> +config CMD_UPTIME
> + bool "uptime"
> + help
> +   uptime - Tell how long barebox has been running
> +
> +   Usage: uptime [-n]
> +
> +   This command formats the number of elapsed nanoseconds
> +   as measured with the current clocksource.
> +
> +   Options:
> + -n  output elapsed time in nanoseconds
> +
>  config CMD_STATE
>   tristate
>   depends on STATE
> diff --git a/commands/Makefile b/commands/Makefile
> index 68d0d05365a5..cac1d4f2535b 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -80,6 +80,7 @@ obj-$(CONFIG_CMD_WD)+= wd.o
>  obj-$(CONFIG_CMD_LED_TRIGGER)+= trigger.o
>  obj-$(CONFIG_CMD_USB)+= usb.o
>  obj-$(CONFIG_CMD_TIME)   += time.o
> +obj-$(CONFIG_CMD_UPTIME) += uptime.o
>  obj-$(CONFIG_CMD_OFTREE) += oftree.o
>  obj-$(CONFIG_CMD_OF_DIFF)+= of_diff.o
>  obj-$(CONFIG_CMD_OF_PROPERTY)+= of_property.o
> diff --git a/commands/uptime.c b/commands/uptime.c
> new file mode 100644
> index ..a9a8c650b698
> --- /dev/null
> +++ b/commands/uptime.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define NSEC_PER_MINUTE  (NSEC_PER_SEC * 60LL)
> +#define NSEC_PER_HOUR(NSEC_PER_MINUTE * 60LL)
> +#define NSEC_PER_DAY (NSEC_PER_HOUR * 24LL)
> +#define NSEC_PER_WEEK(NSEC_PER_DAY * 7LL)
> +
> +static bool print_with_unit(u64 val, const char *unit, bool comma)
> +{
> + if (!val)
> + return comma;
> +
> + printf("%s%llu %s%s", comma ? ", " : "", val, unit, val > 1 ? "s" : "");
> + return true;
> +}
> +
> +static int do_uptime(int argc, char *argv[])
> +{
> + u64 timestamp, weeks, days, hours, minutes;
> + bool comma = false;
> + int opt;
> +
> + timestamp = get_time_ns();
> +
> + while((opt = getopt(argc, argv, "n")) > 0) {
> + switch(opt) {
> + case 'n':
> + printf("up %lluns\n", timestamp);
> + return 0;
> + default:
> + return COMMAND_ERROR_USAGE;
> + }
> + }
> +
> + if (optind != argc)
> + return COMMAND_ERROR_USAGE;
> +
> + printf("up ");
> +
> + weeks = div64_u64_rem(timestamp, NSEC_PER_WEEK, ×tamp);
> + days = div64_u64_rem(timestamp, NSEC_PER_DAY, ×tamp);
> + hours = div64_u64_rem(timestamp, NSEC_PER_HOUR, ×tamp);
> + minutes = div64_u64_rem(timestamp, NSEC_PER_MINUTE, ×tamp);
> +
> + comma = print_with_unit(weeks, "week", false);
> + comma = print_with_unit(days, "day", comma);
> + comma = print_with_unit(hours, "hour", comma);
> + comma = print_with_unit(minutes, "minute", comma);
> +
> + if (!comma) {
> + u64 seconds = div64_u64_rem(timestamp, NSEC_PER_SEC, 
> ×tamp);
> + print_with_unit(seconds, "second", false);
> + }
> +
> + printf("\n");
> +
> + return 0;
> +}
> +
> +BAREBOX_CMD_HELP_START(uptime)
> +BAREBOX_CMD_HELP_TEXT("This command formats the number of elapsed 
> nanoseconds")
> +BAREBOX_CMD_HELP_TEXT("as measured with the current clocksource")
> +BAREBOX_CMD_HELP_TEXT("Options:")
> +BAREBOX_CMD_HELP_OPT ("-n", "output elapsed time in nanoseconds")
> +BAREBOX_CMD_HELP_END
> +
> +BAREBOX_CMD_START(uptime)
> + .cmd= do_uptime,
> + BAREBOX_CMD_DESC("Tell how long barebox has been running")
> + BAREBOX_CMD_OPTS("[-n]")
> + BAREBOX_CMD_GROUP(CMD_GRP_MISC)
> + BAREBOX_CMD_HELP(cmd_uptime_help)
> +BAREBOX_CMD_END
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0

Re: [PATCH] lib: string: implement mempcpy

2022-11-02 Thread Sascha Hauer
On Tue, Nov 01, 2022 at 07:43:10AM +0100, Ahmad Fatoum wrote:
> mempcpy(3) is a GNU libc extension that like stpcpy returns not the
> start of the destination buffer, but the first byte after its end.
> 
> Provide it as it is useful when concatenating buffers or known-size
> strings.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 -> v2:
>   - split off function from series using it. Other series needs
> commits reordered.

Applied, thanks

Sascha

> ---
>  include/string.h | 1 +
>  lib/string.c | 5 +
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/string.h b/include/string.h
> index 2cc727fd1d7a..596440ca8164 100644
> --- a/include/string.h
> +++ b/include/string.h
> @@ -4,6 +4,7 @@
>  
>  #include 
>  
> +void *mempcpy(void *dest, const void *src, size_t count);
>  int strtobool(const char *str, int *val);
>  char *strsep_unescaped(char **, const char *);
>  char *stpcpy(char *dest, const char *src);
> diff --git a/lib/string.c b/lib/string.c
> index fd4d7da10a7c..edd36da4d4f2 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -603,6 +603,11 @@ void *__memcpy(void * dest, const void *src, size_t 
> count)
>   __alias(__default_memcpy);
>  #endif
>  
> +void *mempcpy(void *dest, const void *src, size_t count)
> +{
> + return memcpy(dest, src, count) + count;
> +}
> +EXPORT_SYMBOL(mempcpy);
>  
>  #ifndef __HAVE_ARCH_MEMMOVE
>  /**
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH] ARM: i.MX8M: atf: prefix log messages via pr_fmt()

2022-11-02 Thread Marco Felsch
On 22-11-01, Ahmad Fatoum wrote:
> We have a couple of log messages in the file, so ensure they are
> appropriately prefixed.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
>  arch/arm/mach-imx/atf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
> index 5301c0fbe8e5..67462bc36189 100644
> --- a/arch/arm/mach-imx/atf.c
> +++ b/arch/arm/mach-imx/atf.c
> @@ -1,5 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  
> +#define pr_fmt(fmt) "imx8m-atf: " fmt

Just "atf:" or "imx-atf:"? This code may shared with upcoming imx
processors as well, so "imx8m-atf:" would be a bit to specific.

Regards,
  Marco

> +
>  #include 
>  #include 
>  #include 
> -- 
> 2.30.2
> 
> 
> 



Re: [PATCH v2] test: self: only include ramfs selftest when CONFIG_SELFTEST_FS_RAMFS=y

2022-11-02 Thread Sascha Hauer
On Tue, Nov 01, 2022 at 07:32:16AM +0100, Ahmad Fatoum wrote:
> So far, we ignored the symbol and built the test always when
> CONFIG_SELFTEST=y and CONFIG_FS_RAMFS=y.
> 
> Signed-off-by: Ahmad Fatoum 
> ---
> v1 -> v2:
>   - moved out of other series. No other changes.
>  test/self/Kconfig  | 2 +-
>  test/self/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/test/self/Kconfig b/test/self/Kconfig
> index f3cb6601e3b8..5c6981959921 100644
> --- a/test/self/Kconfig
> +++ b/test/self/Kconfig
> @@ -33,7 +33,7 @@ config SELFTEST_ENABLE_ALL
>   select SELFTEST_PROGRESS_NOTIFIER
>   select SELFTEST_OF_MANIPULATION
>   select SELFTEST_ENVIRONMENT_VARIABLES if ENVIRONMENT_VARIABLES
> - select SELFTEST_FS_RAMFS
> + imply SELFTEST_FS_RAMFS
>   imply SELFTEST_TFTP
>   help
> Selects all self-tests compatible with current configuration
> diff --git a/test/self/Makefile b/test/self/Makefile
> index 6f2c0d394034..c7c729cba0e0 100644
> --- a/test/self/Makefile
> +++ b/test/self/Makefile
> @@ -6,4 +6,4 @@ obj-$(CONFIG_SELFTEST_PRINTF) += printf.o
>  obj-$(CONFIG_SELFTEST_PROGRESS_NOTIFIER) += progress-notifier.o
>  obj-$(CONFIG_SELFTEST_OF_MANIPULATION) += of_manipulation.o 
> of_manipulation.dtb.o
>  obj-$(CONFIG_SELFTEST_ENVIRONMENT_VARIABLES) += envvar.o
> -obj-$(CONFIG_FS_RAMFS) += ramfs.o
> +obj-$(CONFIG_SELFTEST_FS_RAMFS) += ramfs.o
> -- 
> 2.30.2
> 
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH] net: e1000: fix s in log messages

2022-11-02 Thread Sascha Hauer
On Mon, Oct 31, 2022 at 10:33:19AM +0300, Denis Orlov wrote:
> We do not have an edev.dev set up yet when we are filling in the device
> structure and reading an EEPROM in probe. Besides, using hw->dev for
> those messages seems more appropriate.
> 
> Signed-off-by: Denis Orlov 
> ---
>  drivers/net/e1000/eeprom.c | 6 +++---
>  drivers/net/e1000/main.c   | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
> index 1072bc54ef..27143bd6d0 100644
> --- a/drivers/net/e1000/eeprom.c
> +++ b/drivers/net/e1000/eeprom.c
> @@ -800,7 +800,7 @@ int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
>  
>   /* Read the EEPROM */
>   if (e1000_read_eeprom(hw, 0, EEPROM_CHECKSUM_REG + 1, buf) < 0) {
> - dev_err(&hw->edev.dev, "Unable to read EEPROM!\n");
> + dev_err(hw->dev, "Unable to read EEPROM!\n");
>   return -E1000_ERR_EEPROM;
>   }
>  
> @@ -816,8 +816,8 @@ int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
>   return 0;
>  
>   /* Hrm, verification failed, print an error */
> - dev_err(&hw->edev.dev, "EEPROM checksum is incorrect!\n");
> - dev_err(&hw->edev.dev, "  ...register was 0x%04hx, calculated 
> 0x%04hx\n",
> + dev_err(hw->dev, "EEPROM checksum is incorrect!\n");
> + dev_err(hw->dev, "  ...register was 0x%04hx, calculated 0x%04hx\n",
>   checksum_reg, checksum);
>  
>   return -E1000_ERR_EEPROM;
> diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
> index 363730de0a..1f84cf2949 100644
> --- a/drivers/net/e1000/main.c
> +++ b/drivers/net/e1000/main.c
> @@ -3226,7 +3226,7 @@ static int e1000_sw_init(struct eth_device *edev)
>   /* identify the MAC */
>   result = e1000_set_mac_type(hw);
>   if (result) {
> - dev_err(&hw->edev.dev, "Unknown MAC Type\n");
> + dev_err(hw->dev, "Unknown MAC Type\n");
>   return result;
>   }
>  
> -- 
> 2.30.2
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |



Re: [PATCH] reset: add missing stub for of_reset_control_get()

2022-11-02 Thread Sascha Hauer
On Mon, Oct 31, 2022 at 10:34:29AM +0300, Denis Orlov wrote:
> Every other function in reset.h has a corresponding stub that is used
> when the option RESET_CONTROLLER is disabled in config. This allows for
> code that uses this function to still be compilable even when the reset
> controller subsystem is disabled.
> 
> Signed-off-by: Denis Orlov 
> ---
>  include/linux/reset.h | 6 ++
>  1 file changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/include/linux/reset.h b/include/linux/reset.h
> index c1282a84c7..2d788547f4 100644
> --- a/include/linux/reset.h
> +++ b/include/linux/reset.h
> @@ -48,6 +48,12 @@ static inline int reset_control_deassert(struct 
> reset_control *rstc)
>   return 0;
>  }
>  
> +static inline struct reset_control *
> +of_reset_control_get(struct device_node *node, const char *id)
> +{
> + return NULL;
> +}
> +
>  static inline struct reset_control *
>  reset_control_get(struct device_d *dev, const char *id)
>  {
> -- 
> 2.30.2
> 
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |