Re: [RESEND PATCH] usb: max3420: add the gadget driver

2020-06-16 Thread Lukasz Majewski
Hi Jassi,

> ... a polite ping, Lukasz.

The only excuse for so long lack of my response are my personal issues
caused by the covid-19.

Sorry for that..

> 
> On Sun, Jun 7, 2020 at 3:59 PM  wrote:
> >
> > From: Jassi Brar 
> >
> > MAX3420 implements FullSpeed USB Device over SPI.
> > Another version MAX3421, also implements USB Host mode.
> > This driver should be good for the device mode of max3421 as well.
> >
> > Signed-off-by: Jassi Brar 
> > ---
> >  drivers/usb/gadget/Kconfig|   6 +
> >  drivers/usb/gadget/Makefile   |   1 +
> >  drivers/usb/gadget/gadget_chips.h |   8 +
> >  drivers/usb/gadget/max3420_udc.c  | 875
> > ++ 4 files changed, 890 insertions(+)
> >  create mode 100644 drivers/usb/gadget/max3420_udc.c
> >
> > diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> > index 46aa3fe954..7c0df5c264 100644
> > --- a/drivers/usb/gadget/Kconfig
> > +++ b/drivers/usb/gadget/Kconfig
> > @@ -105,6 +105,12 @@ config CI_UDC
> >   Say Y here to enable device controller functionality of
> > the ChipIdea driver.
> >
> > +config USB_GADGET_MAX3420
> > +   bool "MAX3420 USB Over SPI"
> > +   depends on DM_SPI
> > +   help
> > + MAX3420, from MAXIM, implements USB-over-SPI Full-Speed
> > device controller. +
> >  config USB_GADGET_VBUS_DRAW
> > int "Maximum VBUS Power usage (2-500 mA)"
> > range 2 500
> > diff --git a/drivers/usb/gadget/Makefile
> > b/drivers/usb/gadget/Makefile index 70f3bf43e7..f560068b41 100644
> > --- a/drivers/usb/gadget/Makefile
> > +++ b/drivers/usb/gadget/Makefile
> > @@ -20,6 +20,7 @@ obj-$(CONFIG_USB_GADGET_BCM_UDC_OTG_PHY) +=
> > bcm_udc_otg_phy.o obj-$(CONFIG_USB_GADGET_DWC2_OTG) +=
> > dwc2_udc_otg.o obj-$(CONFIG_USB_GADGET_DWC2_OTG_PHY) +=
> > dwc2_udc_otg_phy.o obj-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
> > +obj-$(CONFIG_USB_GADGET_MAX3420) += max3420_udc.o
> >  obj-$(CONFIG_CI_UDC)   += ci_udc.o
> >  ifndef CONFIG_SPL_BUILD
> >  obj-$(CONFIG_USB_GADGET_DOWNLOAD) += g_dnl.o
> > diff --git a/drivers/usb/gadget/gadget_chips.h
> > b/drivers/usb/gadget/gadget_chips.h index 91b0285244..587204cfb7
> > 100644 --- a/drivers/usb/gadget/gadget_chips.h
> > +++ b/drivers/usb/gadget/gadget_chips.h
> > @@ -155,6 +155,12 @@
> >  #define gadget_is_cdns3(g)0
> >  #endif
> >
> > +#ifdef CONFIG_USB_GADGET_MAX3420
> > +#define gadget_is_max3420(g)(!strcmp("max3420-udc",
> > (g)->name)) +#else
> > +#define gadget_is_max3420(g)0
> > +#endif
> > +

Ok.

> >  /**
> >   * usb_gadget_controller_number - support bcdDevice id convention
> >   * @gadget: the controller being driven
> > @@ -216,5 +222,7 @@ static inline int
> > usb_gadget_controller_number(struct usb_gadget *gadget) return 0x23;
> > else if (gadget_is_cdns3(gadget))
> > return 0x24;
> > +   else if (gadget_is_max3420(gadget))
> > +   return 0x25;
> > return -ENOENT;
> >  }
> > diff --git a/drivers/usb/gadget/max3420_udc.c
> > b/drivers/usb/gadget/max3420_udc.c new file mode 100644
> > index 00..7267d482b8
> > --- /dev/null
> > +++ b/drivers/usb/gadget/max3420_udc.c
> > @@ -0,0 +1,875 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define MAX3420_MAX_EPS4
> > +#define EP_MAX_PACKET  64  /* Same for all Endpoints */
> > +#define EPNAME_SIZE16  /* Buffer size for endpoint
> > name */ +
> > +#define ACKSTATBIT(0)
> > +
> > +#define MAX3420_SPI_DIR_RD 0   /* read register from
> > MAX3420 */ +#define MAX3420_SPI_DIR_WR 1   /* write
> > register to MAX3420 */ +
> > +/* SPI commands: */
> > +#define MAX3420_SPI_DIR_SHIFT  1
> > +#define MAX3420_SPI_REG_SHIFT  3
> > +
> > +#define MAX3420_REG_EP0FIFO0
> > +#define MAX3420_REG_EP1FIFO1
> > +#define MAX3420_REG_EP2FIFO2
> > +#define MAX3420_REG_EP3FIFO3
> > +#define MAX3420_REG_SUDFIFO4
> > +#define MAX3420_REG_EP0BC  5
> > +#define MAX3420_REG_EP1BC  6
> > +#define MAX3420_REG_EP2BC  7
> > +#define MAX3420_REG_EP3BC  8
> > +
> > +#define MAX3420_REG_EPSTALLS   9
> > +   #define bACKSTATBIT(6)
> > +   #define bSTLSTATBIT(5)
> > +   #define bSTLEP3IN   BIT(4)
> > +   #define bSTLEP2IN   BIT(3)
> > +   #define bSTLEP1OUT  BIT(2)
> > +   #define bSTLEP0OUT  BIT(1)
> > +   #define bSTLEP0IN   BIT(0)
> > +
> > +#define MAX3420_REG_CLRTOGS10
> > +   #define bEP3DISAB   BIT(7)
> > +   #define bEP2DISAB   BIT(6)
> > +   #define bEP1DISAB   BIT(5)
> > +   #define bCTGEP3IN   BIT(4)
> > +   #define bCTGEP2IN   BIT(3)
> > +   #define bCTGEP1OUT  BIT(2)
> > +
> > +#define MAX3420_REG_EPIRQ  11
> > +#define MAX3420_REG_EPIEN  12
> > +   #def

[PATCH v2 3/9] env: correctly handle result in env_init

2020-06-16 Thread Patrick Delaunay
Don't return error with ret=-ENOENT when the optional ops drv->init
is absent but only if env_driver_lookup doesn't found driver.

This patch correct an issue for the code
  if (!env_init())
 env_load()
When only ext4 is supported (CONFIG_ENV_IS_IN_EXT4),
as the backend env/ext4.c doesn't define an ops .init

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

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

diff --git a/env/env.c b/env/env.c
index dcc25c030b..819c88f729 100644
--- a/env/env.c
+++ b/env/env.c
@@ -295,7 +295,10 @@ int env_init(void)
int prio;
 
for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); prio++) {
-   if (!drv->init || !(ret = drv->init()))
+   ret = 0;
+   if (drv->init)
+   ret = drv->init();
+   if (!ret)
env_set_inited(drv->location);
 
debug("%s: Environment %s init done (ret=%d)\n", __func__,
-- 
2.17.1



[PATCH v2 0/9] env: ext4: corrections and add test for env in ext4

2020-06-16 Thread Patrick Delaunay


Hi,

V2 is only a rebase and adaptation of the serie [1].

In this serie, I add sandbox test with CONFIG_ENV_IS_NOWHERE
activated with other location: at least one CONFIG_ENV_IS_IN_...
is defined and  ENV_IS_IN_DEVICE is automatically defined.

To test this feature, I activate and test ENV_IS_IN_EXT4
in sandbox; I add a new command "env_loc" to change this
ENV location.

This serie depends on previous env test introduced in [2]
"cmd: env: add option for quiet output on env info"

To be able to test invalid file (bad CRC), I also add the support of
the command "env erase" for EXT4 env location.

[1] http://patchwork.ozlabs.org/project/uboot/list/?series=158160
[2] http://patchwork.ozlabs.org/project/uboot/list/?series=183438

Regards

Patrick


Changes in v2:
- change cmd_tbl_t to struct cmd_tbl
- use CONFIG_IS_ENABLED to set .erase (same as .save)

Patrick Delaunay (9):
  env: add absolute path at CONFIG_ENV_EXT4_FILE
  env: ext4: set gd->env_valid
  env: correctly handle result in env_init
  sandbox: activate env in ext4 support
  sandbox: support the change of env location
  test: environment in ext4
  env: ext4: introduce new function env_ext4_save_buffer
  env: ext4: add support of command env erase
  test: sandbox: add test for erase command

 board/sandbox/sandbox.c|  52 +++
 configs/sandbox64_defconfig|   5 ++
 configs/sandbox_defconfig  |   5 ++
 configs/sandbox_flattree_defconfig |   5 ++
 configs/sandbox_spl_defconfig  |   5 ++
 env/Kconfig|   2 +-
 env/env.c  |   5 +-
 env/ext4.c |  54 ---
 test/py/tests/test_env.py  | 103 +
 9 files changed, 226 insertions(+), 10 deletions(-)

-- 
2.17.1



[PATCH v2 6/9] test: environment in ext4

2020-06-16 Thread Patrick Delaunay
Add basic test to persistent environment in ext4:
save and load in host ext4 file 'uboot.env'.

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

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 test/py/tests/test_env.py | 87 +++
 1 file changed, 87 insertions(+)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index cbdb41031c..6f1d94b953 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -4,6 +4,10 @@
 
 # Test operation of shell commands relating to environment variables.
 
+import os
+import os.path
+from subprocess import call, check_call
+
 import pytest
 import u_boot_utils
 
@@ -380,3 +384,86 @@ def test_env_info_quiet(state_test_env):
 assert response == ""
 response = c.run_command('echo $?')
 assert response == "1"
+
+def mk_env_ext4(state_test_env):
+c = state_test_env.u_boot_console
+
+"""Create a empty ext4 file system volume.
+"""
+filename = 'env.ext4.img'
+persistent = c.config.persistent_data_dir + '/' + filename
+fs_img = c.config.result_dir  + '/' + filename
+
+if os.path.exists(persistent):
+c.log.action('Disk image file ' + persistent + ' already exists')
+else:
+try:
+check_call('rm -f %s' % persistent, shell=True)
+check_call('dd if=/dev/zero of=%s bs=1M count=16'
+% persistent, shell=True)
+check_call('mkfs.ext4 -O ^metadata_csum %s' % persistent, 
shell=True)
+except CalledProcessError:
+call('rm -f %s' % persistent, shell=True)
+raise
+
+call('cp -f %s %s' % (persistent, fs_img), shell=True)
+return fs_img
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_nvedit_info')
+@pytest.mark.buildconfigspec('cmd_echo')
+@pytest.mark.buildconfigspec('env_is_in_ext4')
+def test_env_ext4(state_test_env):
+
+c = state_test_env.u_boot_console
+
+fs_img = mk_env_ext4(state_test_env)
+c.run_command('host bind 0  %s' % fs_img)
+
+response = c.run_command('ext4ls host 0:0')
+assert 'uboot.env' not in response
+
+""" env location: ENVL_EXT4 (2)
+"""
+response = c.run_command('env_loc 2')
+assert 'Saving Environment to EXT4' in response
+
+response = c.run_command('env_loc 2')
+assert 'Loading Environment from EXT4... OK' in response
+
+response = c.run_command('ext4ls host 0:0')
+assert '8192 uboot.env' in response
+
+response = c.run_command('env info')
+assert 'env_valid = valid' in response
+assert 'env_ready = true' in response
+assert 'env_use_default = false' in response
+
+response = c.run_command('env info -p -d')
+assert 'Environment was loaded from persistent storage' in response
+assert 'Environment can be persisted' in response
+
+response = c.run_command('env info -d -q')
+assert response == ""
+response = c.run_command('echo $?')
+assert response == "1"
+
+response = c.run_command('env info -p -q')
+assert response == ""
+response = c.run_command('echo $?')
+assert response == "0"
+
+""" restore env location: ENVL_NOWHERE (12)
+"""
+c.run_command('env_loc 12')
+
+response = c.run_command('env info')
+assert 'env_valid = valid' in response
+assert 'env_ready = true' in response
+assert 'env_use_default = true' in response
+
+response = c.run_command('env info -p -d')
+assert 'Default environment is used' in response
+assert 'Environment cannot be persisted' in response
+
+call('rm -f %s' % fs_img, shell=True)
-- 
2.17.1



[PATCH v2 1/9] env: add absolute path at CONFIG_ENV_EXT4_FILE

2020-06-16 Thread Patrick Delaunay
Add the absolute path to the default value of
CONFIG_ENV_EXT4_FILE = "/uboot.env".

This patch avoid the error :
  Saving Environment to EXT4... File System is consistent
  Please supply Absolute path

Signed-off-by: Patrick Delaunay 
---

For information, it is the value used today by all the boards:

dragonboard820c_defconfig:29:CONFIG_ENV_EXT4_FILE="/uboot.env"
hikey960_defconfig:25:CONFIG_ENV_EXT4_FILE="/uboot.env"
stm32mp15_basic_defconfig:64:CONFIG_ENV_EXT4_FILE="/uboot.env"
stm32mp15_trusted_defconfig:50:CONFIG_ENV_EXT4_FILE="/uboot.env"


(no changes since v1)

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

diff --git a/env/Kconfig b/env/Kconfig
index ca7fef682b..9dad1cf8c1 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -469,7 +469,7 @@ config ENV_EXT4_DEVICE_AND_PART
 config ENV_EXT4_FILE
string "Name of the EXT4 file to use for the environment"
depends on ENV_IS_IN_EXT4
-   default "uboot.env"
+   default "/uboot.env"
help
  It's a string of the EXT4 file name. This file use to store the
  environment (explicit path to the file)
-- 
2.17.1



[PATCH v2 5/9] sandbox: support the change of env location

2020-06-16 Thread Patrick Delaunay
Add support of environment location with a new sandbox command
'env_loc'.

When the user change the environment location with the command
'env_loc ' the env is reinitialized and saved;
the GD_FLG_ENV_DEFAULT flag is also updated.

When the user set the same env location, the environment is
re-loaded.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- change cmd_tbl_t to struct cmd_tbl

 board/sandbox/sandbox.c | 42 -
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 9cb5fe5c75..bd99141fa8 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +22,9 @@
  */
 gd_t *gd;
 
+/* env location: current location used during test */
+static enum env_location sandbox_env_location = ENVL_NOWHERE;
+
 /* Add a simple GPIO device */
 U_BOOT_DEVICE(gpio_sandbox) = {
.name = "gpio_sandbox",
@@ -53,9 +57,45 @@ enum env_location env_get_location(enum env_operation op, 
int prio)
 
gd->env_load_prio = 0;
 
-   return ENVL_NOWHERE;
+   return sandbox_env_location;
 }
 
+static int do_env_loc(struct cmd_tbl *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+   enum env_location loc;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+
+   loc = (enum env_location)simple_strtoul(argv[1], NULL, 10);
+   if (loc >= ENVL_COUNT)
+   return CMD_RET_FAILURE;
+
+   if (sandbox_env_location != loc) {
+   sandbox_env_location = loc;
+   if (loc == ENVL_NOWHERE) {
+   gd->flags |= GD_FLG_ENV_DEFAULT;
+   gd->env_valid = ENV_VALID;
+   } else {
+   if (gd->flags & GD_FLG_ENV_DEFAULT) {
+   gd->flags &= ~GD_FLG_ENV_DEFAULT;
+   if (!env_init())
+   env_save();
+   }
+   }
+   } else {
+   if (!env_init())
+   env_load();
+   }
+
+   return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(env_loc, 2, 1, do_env_loc,
+  "set the environment location", "[loc]"
+);
+
 int dram_init(void)
 {
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
-- 
2.17.1



[PATCH v2 4/9] sandbox: activate env in ext4 support

2020-06-16 Thread Patrick Delaunay
The default environment is still used with "ENVL_NOWHERE"
indicated by the weak function env_get_location() and
activated by CONFIG_ENV_IS_NOWHERE.

Signed-off-by: Patrick Delaunay 
Reviewed-by: Simon Glass 
---

(no changes since v1)

 board/sandbox/sandbox.c| 12 
 configs/sandbox64_defconfig|  4 
 configs/sandbox_defconfig  |  4 
 configs/sandbox_flattree_defconfig |  4 
 configs/sandbox_spl_defconfig  |  4 
 5 files changed, 28 insertions(+)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 1372003018..9cb5fe5c75 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -44,6 +45,17 @@ unsigned long timer_read_counter(void)
 }
 #endif
 
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+   /* only one location supported */
+   if (prio != 0)
+   return ENVL_UNKNOWN;
+
+   gd->env_load_prio = 0;
+
+   return ENVL_NOWHERE;
+}
+
 int dram_init(void)
 {
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index a2410b3368..b70272c0b0 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -81,6 +81,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox64"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 0c9e0b9f1f..715f5dc39d 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -90,6 +90,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_OF_LIVE=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index bc4819f998..ce806270bd 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -64,6 +64,10 @@ CONFIG_AMIGA_PARTITION=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_REGMAP=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index 64f2ed5102..ea11c9bded 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -80,6 +80,10 @@ CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
 CONFIG_SPL_OF_PLATDATA=y
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="host"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
 CONFIG_NETCONSOLE=y
 CONFIG_IP_DEFRAG=y
 CONFIG_SPL_DM=y
-- 
2.17.1



[PATCH v2 8/9] env: ext4: add support of command env erase

2020-06-16 Thread Patrick Delaunay
Add support of opts erase for env in ext4,
this opts is used by command 'env erase'.

This command only fill the env file (CONFIG_ENV_EXT4_FILE)
with 0, the CRC and the saved environment becomes invalid.

Signed-off-by: Patrick Delaunay 
---

Changes in v2:
- use CONFIG_IS_ENABLED to set .erase (same as .save)

 env/ext4.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/env/ext4.c b/env/ext4.c
index 027a721b69..7a104c1615 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -99,6 +99,23 @@ static int env_ext4_save(void)
return 0;
 }
 
+static int env_ext4_erase(void)
+{
+   env_t   env_new;
+   int err;
+
+   memset(&env_new, 0, sizeof(env_t));
+
+   err = env_ext4_save_buffer(&env_new);
+   if (err)
+   return err;
+
+   gd->env_valid = ENV_INVALID;
+   puts("done\n");
+
+   return 0;
+}
+
 static int env_ext4_load(void)
 {
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -156,4 +173,6 @@ U_BOOT_ENV_LOCATION(ext4) = {
ENV_NAME("EXT4")
.load   = env_ext4_load,
.save   = ENV_SAVE_PTR(env_ext4_save),
+   .erase  = CONFIG_IS_ENABLED(CMD_ERASEENV) ? env_ext4_erase :
+   NULL,
 };
-- 
2.17.1



[PATCH v2 2/9] env: ext4: set gd->env_valid

2020-06-16 Thread Patrick Delaunay
Add a missing initialization of gd->env_valid in env_ext4_load
as it is already done in some other env device.

Set gd->env_valid = ENV_VALID in env_ext4_save() and env_ext4_load().

This patch allows to have a correct information in 'env info' command.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 env/ext4.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/env/ext4.c b/env/ext4.c
index 8e90bb71b7..ac9f126bec 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -32,6 +32,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 __weak const char *env_ext4_get_intf(void)
 {
return (const char *)CONFIG_ENV_EXT4_INTERFACE;
@@ -79,6 +81,7 @@ static int env_ext4_save(void)
CONFIG_ENV_EXT4_FILE, ifname, dev, part);
return 1;
}
+   gd->env_valid = ENV_VALID;
 
puts("done\n");
return 0;
@@ -124,7 +127,11 @@ static int env_ext4_load(void)
goto err_env_relocate;
}
 
-   return env_import(buf, 1);
+   err = env_import(buf, 1);
+   if (!err)
+   gd->env_valid = ENV_VALID;
+
+   return err;
 
 err_env_relocate:
env_set_default(NULL, 0);
-- 
2.17.1



[PATCH v2 7/9] env: ext4: introduce new function env_ext4_save_buffer

2020-06-16 Thread Patrick Delaunay
Split the function env_ext4_save to prepare the erase support.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 env/ext4.c | 28 
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/env/ext4.c b/env/ext4.c
index ac9f126bec..027a721b69 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -44,9 +44,8 @@ __weak const char *env_ext4_get_dev_part(void)
return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
 }
 
-static int env_ext4_save(void)
+static int env_ext4_save_buffer(env_t *env_new)
 {
-   env_t   env_new;
struct blk_desc *dev_desc = NULL;
struct disk_partition info;
int dev, part;
@@ -54,10 +53,6 @@ static int env_ext4_save(void)
const char *ifname = env_ext4_get_intf();
const char *dev_and_part = env_ext4_get_dev_part();
 
-   err = env_export(&env_new);
-   if (err)
-   return err;
-
part = blk_get_device_part_str(ifname, dev_and_part,
   &dev_desc, &info, 1);
if (part < 0)
@@ -72,7 +67,7 @@ static int env_ext4_save(void)
return 1;
}
 
-   err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)&env_new,
+   err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)env_new,
   sizeof(env_t), FILETYPE_REG);
ext4fs_close();
 
@@ -81,9 +76,26 @@ static int env_ext4_save(void)
CONFIG_ENV_EXT4_FILE, ifname, dev, part);
return 1;
}
-   gd->env_valid = ENV_VALID;
 
+   return 0;
+}
+
+static int env_ext4_save(void)
+{
+   env_t   env_new;
+   int err;
+
+   err = env_export(&env_new);
+   if (err)
+   return err;
+
+   err = env_ext4_save_buffer(&env_new);
+   if (err)
+   return err;
+
+   gd->env_valid = ENV_VALID;
puts("done\n");
+
return 0;
 }
 
-- 
2.17.1



[PATCH v2 9/9] test: sandbox: add test for erase command

2020-06-16 Thread Patrick Delaunay
Add test for the erase command tested on ENV in EXT4.

Signed-off-by: Patrick Delaunay 
---

(no changes since v1)

 configs/sandbox64_defconfig|  1 +
 configs/sandbox_defconfig  |  1 +
 configs/sandbox_flattree_defconfig |  1 +
 configs/sandbox_spl_defconfig  |  1 +
 test/py/tests/test_env.py  | 16 
 5 files changed, 20 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index b70272c0b0..3913b6392e 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -27,6 +27,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 715f5dc39d..c59e20579d 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -31,6 +31,7 @@ CONFIG_CMD_ABOOTIMG=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_EFI=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index ce806270bd..99b750b4f8 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -24,6 +24,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_NVEDIT_INFO=y
 CONFIG_LOOPW=y
 CONFIG_CMD_MD5SUM=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index ea11c9bded..52e7625bd7 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -32,6 +32,7 @@ CONFIG_CMD_BOOTEFI_HELLO=y
 # CONFIG_CMD_ELF is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
+CONFIG_CMD_ERASEENV=y
 CONFIG_CMD_ENV_CALLBACK=y
 CONFIG_CMD_ENV_FLAGS=y
 CONFIG_CMD_NVEDIT_INFO=y
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 6f1d94b953..a71b4c2571 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -453,6 +453,22 @@ def test_env_ext4(state_test_env):
 response = c.run_command('echo $?')
 assert response == "0"
 
+response = c.run_command('env erase')
+assert 'OK' in response
+
+response = c.run_command('env_loc 2')
+assert 'Loading Environment from EXT4... ' in response
+assert 'bad CRC, using default environment' in response
+
+response = c.run_command('env info')
+assert 'env_valid = invalid' in response
+assert 'env_ready = true' in response
+assert 'env_use_default = true' in response
+
+response = c.run_command('env info -p -d')
+assert 'Default environment is used' in response
+assert 'Environment can be persisted' in response
+
 """ restore env location: ENVL_NOWHERE (12)
 """
 c.run_command('env_loc 12')
-- 
2.17.1



RE: [PATCH v4 4/4] test: env: add test for env info sub-command

2020-06-16 Thread Patrick DELAUNAY
Hi Stephen,

> From: Stephen Warren 
> Sent: mardi 16 juin 2020 00:09
> 
> On 6/15/20 8:01 AM, Patrick Delaunay wrote:
> > Add a pytest for testing the env info sub-command:
> >
> > test_env_info: test command with several option
> >
> > test_env_info_quiet: test the result of the sub-command with quiet
> > option, '-q' as used for support in shell test; for example:
> >   if env info -p -d -q; then env save; fi
> 
> > diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
> 
> > +@pytest.mark.boardspec('sandbox')
> > +@pytest.mark.buildconfigspec('cmd_nvedit_info')
> > +def test_env_info(state_test_env):
> 
> The body of these tests doesn't look like it tests something that's specific 
> to
> sandbox, so I'm not sure why the test function is marked to only run on 
> sandbox.
> Is it simply because other boards may store the environment differently and/or
> have valid saved environment in flash, so the responses to e.g. "env info" 
> aren't
> the same everywhere? If so, I imagine that test_env_info_quiet() doesn't need 
> to
> be sandbox-only, since there's no output in that case.

The test is not really sandbox specific but I don't have easy way to know on 
real board
the ENV configuration (for the resut of command env info -p -d).

In the test, I assume that  at least  CONFIG_ENV_IS_ is activated (for 
persistent storage) 
and if this target is selected in the weak function env_get_location.
And "env save" as be not be executed (default environment is used). 

And with quiet option, the test  the environment if is persistent  (result of 
"env -p -q" is 0)
or using default ("env -d -q" result is 0).

And in the next patch 
http://patchwork.ozlabs.org/project/uboot/patch/20200616074048.7898-10-patrick.delau...@st.com/

As the command "env erase" is not always supported according he environment 
target.

I could test on real hardware but I need to check if I test all the possible 
result.

Patrick


[PATCHv3 0/6] omap4/omap5: convert to DM model

2020-06-16 Thread Tero Kristo
Hi,

This is a combined series of both omap4/omap5 DM conversion in one.
The main change across all the boards in this version is to drop SPI
support completely. SPI is only available on expansion headers on the
omap4 panda / omap5 uevm boards, and it is impossible for the authors of
the patches in this series to both complete the SPI conversion to DM model,
and test it, so it was deemed better to drop it completely.

Again, if someone from community needs the SPI support later, it should
be relatively straightforward to add it back with proper expertise /
tools.

-Tero


--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


[PATCHv3 4/6] omap4: sdp: convert to device model

2020-06-16 Thread Tero Kristo
From: Peter Ujfalusi 

Convert omap4 sdp to device model.

Signed-off-by: Peter Ujfalusi 
Signed-off-by: Tero Kristo 
---
v3:
  * dropped SPI support

 arch/arm/dts/Makefile   |  4 
 board/ti/sdp4430/sdp.c  | 12 
 configs/omap4_sdp4430_defconfig | 12 +---
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index dd574f57fa..70cf05f2b8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -852,6 +852,10 @@ dtb-$(CONFIG_TARGET_OMAP4_PANDA) += \
omap4-panda.dtb \
omap4-panda-es.dtb
 
+dtb-$(CONFIG_TARGET_OMAP4_SDP4430) += \
+   omap4-sdp.dtb \
+   omap4-sdp-es23plus.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D2_PTC_EK) += \
at91-sama5d2_ptc_ek.dtb
 
diff --git a/board/ti/sdp4430/sdp.c b/board/ti/sdp4430/sdp.c
index a5b3504045..5b294ea79b 100644
--- a/board/ti/sdp4430/sdp.c
+++ b/board/ti/sdp4430/sdp.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -91,6 +92,17 @@ void board_mmc_power_init(void)
 #endif
 #endif
 
+#if defined(CONFIG_SPL_OS_BOOT)
+int spl_start_uboot(void)
+{
+   /* break into full u-boot on 'c' */
+   if (serial_tstc() && serial_getc() == 'c')
+   return 1;
+
+   return 0;
+}
+#endif /* CONFIG_SPL_OS_BOOT */
+
 /*
  * get_board_rev() - get board revision
  */
diff --git a/configs/omap4_sdp4430_defconfig b/configs/omap4_sdp4430_defconfig
index 219721388f..e9a8a90786 100644
--- a/configs/omap4_sdp4430_defconfig
+++ b/configs/omap4_sdp4430_defconfig
@@ -5,6 +5,7 @@ CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_ENV_OFFSET=0xE
 CONFIG_OMAP44XX=y
 CONFIG_TARGET_OMAP4_SDP4430=y
+CONFIG_DEFAULT_DEVICE_TREE="omap4-sdp"
 CONFIG_CMD_BAT=y
 CONFIG_SPL=y
 CONFIG_SPL_TEXT_BASE=0x4030
@@ -12,6 +13,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run 
findfdt; run init_console; run envboot; run distro_bootcmd"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_DEFAULT_FDT_FILE="omap4-sdp.dtb"
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_SPL_I2C_SUPPORT is not set
 # CONFIG_SPL_NAND_SUPPORT is not set
@@ -19,20 +21,22 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_EXT4_WRITE=y
+CONFIG_OF_CONTROL=y
 # CONFIG_EFI_PARTITION is not set
 CONFIG_SPL_PARTITION_UUIDS=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_DM=y
+CONFIG_DM_MMC=y
 CONFIG_MMC_OMAP_HS=y
 CONFIG_CONS_INDEX=3
 CONFIG_SYS_NS16550=y
-CONFIG_SPI=y
-CONFIG_OMAP3_SPI=y
+# CONFIG_SPI is not set
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_MUSB_UDC=y
 CONFIG_USB_OMAP3=y
 CONFIG_USB_GADGET=y
@@ -40,3 +44,5 @@ CONFIG_FAT_WRITE=y
 # CONFIG_REGEX is not set
 CONFIG_OF_LIBFDT=y
 # CONFIG_EFI_LOADER is not set
+CONFIG_SYS_MALLOC_F_LEN=0x4000
+CONFIG_DM_ETH=y
-- 
2.17.1

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


[PATCHv3 2/6] omap4: panda: convert to device model

2020-06-16 Thread Tero Kristo
Convert omap4 panda to device model.

Signed-off-by: Tero Kristo 
---
v3:
  * dropped SPI support
v2:
  * dropped some apparently dead USB EHCI init code, this was just
causing a compile time warning.

 arch/arm/dts/Makefile  |  4 +++
 arch/arm/dts/omap4-u-boot.dtsi | 39 ++
 board/ti/panda/panda.c | 50 --
 configs/omap4_panda_defconfig  | 12 ++--
 4 files changed, 64 insertions(+), 41 deletions(-)
 create mode 100644 arch/arm/dts/omap4-u-boot.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 12ec6c71dc..dd574f57fa 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -848,6 +848,10 @@ dtb-$(CONFIG_TARGET_OMAP3_BEAGLE) += \
 dtb-$(CONFIG_TARGET_OMAP3_IGEP00X0) += \
omap3-igep0020.dtb
 
+dtb-$(CONFIG_TARGET_OMAP4_PANDA) += \
+   omap4-panda.dtb \
+   omap4-panda-es.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D2_PTC_EK) += \
at91-sama5d2_ptc_ek.dtb
 
diff --git a/arch/arm/dts/omap4-u-boot.dtsi b/arch/arm/dts/omap4-u-boot.dtsi
new file mode 100644
index 00..4a6bafd6ed
--- /dev/null
+++ b/arch/arm/dts/omap4-u-boot.dtsi
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * U-Boot additions
+ *
+ * (C) Copyright 2020 Tero Kristo 
+ */
+
+&l4_cfg {
+   segment@0 {
+   /* SCM Core */
+   target-module@2000 {
+   compatible = "simple-bus";
+   };
+
+   /* USB HS */
+   target-module@64000 {
+   compatible = "simple-bus";
+   };
+   };
+};
+
+&l4_per {
+   segment@0 {
+   /* UART3 */
+   target-module@2 {
+   compatible = "simple-bus";
+   };
+
+   /* I2C1 */
+   target-module@7 {
+   compatible = "simple-bus";
+   };
+
+   /* MMC1 */
+   target-module@9c000 {
+   compatible = "simple-bus";
+   };
+   };
+};
diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
index 9ebecfdbf5..232d999a29 100644
--- a/board/ti/panda/panda.c
+++ b/board/ti/panda/panda.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,12 +20,6 @@
 
 #include "panda_mux_data.h"
 
-#ifdef CONFIG_USB_EHCI_HCD
-#include 
-#include 
-#include 
-#endif
-
 #define PANDA_ULPI_PHY_TYPE_GPIO   182
 #define PANDA_BOARD_ID_1_GPIO  101
 #define PANDA_ES_BOARD_ID_1_GPIO48
@@ -55,6 +50,17 @@ int board_init(void)
return 0;
 }
 
+#if defined(CONFIG_SPL_OS_BOOT)
+int spl_start_uboot(void)
+{
+   /* break into full u-boot on 'c' */
+   if (serial_tstc() && serial_getc() == 'c')
+   return 1;
+
+   return 0;
+}
+#endif /* CONFIG_SPL_OS_BOOT */
+
 int board_eth_init(bd_t *bis)
 {
return 0;
@@ -305,38 +311,6 @@ void board_mmc_power_init(void)
 #endif
 #endif
 
-#ifdef CONFIG_USB_EHCI_HCD
-
-static struct omap_usbhs_board_data usbhs_bdata = {
-   .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
-   .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
-};
-
-int ehci_hcd_init(int index, enum usb_init_type init,
-   struct ehci_hccr **hccr, struct ehci_hcor **hcor)
-{
-   int ret;
-   unsigned int utmi_clk;
-
-   /* Now we can enable our port clocks */
-   utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
-   utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
-   setbits_le32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, utmi_clk);
-
-   ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
-   if (ret < 0)
-   return ret;
-
-   return 0;
-}
-
-int ehci_hcd_stop(int index)
-{
-   return omap_ehci_hcd_stop();
-}
-#endif
-
 /*
  * get_board_rev() - get board revision
  */
diff --git a/configs/omap4_panda_defconfig b/configs/omap4_panda_defconfig
index 3ac6319d2d..f8d37f4728 100644
--- a/configs/omap4_panda_defconfig
+++ b/configs/omap4_panda_defconfig
@@ -2,12 +2,14 @@ CONFIG_ARM=y
 CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_OMAP44XX=y
 CONFIG_TARGET_OMAP4_PANDA=y
+CONFIG_DEFAULT_DEVICE_TREE="omap4-panda"
 CONFIG_SPL=y
 CONFIG_SPL_TEXT_BASE=0x4030
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTCOMMAND="if test ${boot_fit} -eq 1; then run update_to_fit; fi; run 
findfdt; run init_console; run envboot; run distro_bootcmd"
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
+CONFIG_DEFAULT_FDT_FILE="omap4-panda.dtb"
 CONFIG_VERSION_VARIABLE=y
 # CONFIG_SPL_FS_EXT4 is not set
 # CONFIG_SPL_I2C_SUPPORT is not set
@@ -18,21 +20,23 @@ CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_SPI=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_EXT4_WRITE=y
+CONFIG_OF_CONTROL=y
 CONFIG_ENV_IS_IN_FAT=y
 CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
 CONFIG_SYS_REL

[PATCHv3 6/6] omap5: uevm: convert to device model

2020-06-16 Thread Tero Kristo
Convert omap5 uevm board to device model.

Signed-off-by: Tero Kristo 
---
v3:
  * dropped SPI support

 arch/arm/dts/omap5-u-boot.dtsi | 42 ++
 board/ti/omap5_uevm/evm.c  | 78 +-
 configs/omap5_uevm_defconfig   | 13 --
 3 files changed, 62 insertions(+), 71 deletions(-)

diff --git a/arch/arm/dts/omap5-u-boot.dtsi b/arch/arm/dts/omap5-u-boot.dtsi
index 39071e223d..5a1c7bc9fe 100644
--- a/arch/arm/dts/omap5-u-boot.dtsi
+++ b/arch/arm/dts/omap5-u-boot.dtsi
@@ -7,6 +7,7 @@
  * Based on "dra7.dtsi"
  */
 
+#ifdef CONFIG_DRA7XX
 /{
chosen {
tick-timer = &timer2;
@@ -105,3 +106,44 @@
 &i2c1 {
u-boot,dm-spl;
 };
+
+#else /* OMAP54XX */
+&l4_cfg {
+   segment@0 {
+   /* SCM Core */
+   target-module@2000 {
+   compatible = "simple-bus";
+   };
+
+   /* USB HS */
+   target-module@64000 {
+   compatible = "simple-bus";
+   };
+   };
+};
+
+&l4_per {
+   segment@0 {
+   /* UART3 */
+   target-module@2 {
+   compatible = "simple-bus";
+   };
+
+   /* I2C1 */
+   target-module@7 {
+   compatible = "simple-bus";
+   };
+
+   /* MMC1 */
+   target-module@9c000 {
+   compatible = "simple-bus";
+   };
+
+   /* MMC2 */
+   target-module@b4000 {
+   compatible = "simple-bus";
+   };
+   };
+};
+
+#endif
diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
index e35f319b46..319bb6aa64 100644
--- a/board/ti/omap5_uevm/evm.c
+++ b/board/ti/omap5_uevm/evm.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -149,39 +150,21 @@ int board_init(void)
return 0;
 }
 
-int board_eth_init(bd_t *bis)
+#if defined(CONFIG_SPL_OS_BOOT)
+int spl_start_uboot(void)
 {
+   /* break into full u-boot on 'c' */
+   if (serial_tstc() && serial_getc() == 'c')
+   return 1;
+
return 0;
 }
+#endif /* CONFIG_SPL_OS_BOOT */
 
-#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_XHCI_OMAP)
-static void enable_host_clocks(void)
+int board_eth_init(bd_t *bis)
 {
-   int auxclk;
-   int hs_clk_ctrl_val = (OPTFCLKEN_HSIC60M_P3_CLK |
-   OPTFCLKEN_HSIC480M_P3_CLK |
-   OPTFCLKEN_HSIC60M_P2_CLK |
-   OPTFCLKEN_HSIC480M_P2_CLK |
-   OPTFCLKEN_UTMI_P3_CLK | OPTFCLKEN_UTMI_P2_CLK);
-
-   /* Enable port 2 and 3 clocks*/
-   setbits_le32((*prcm)->cm_l3init_hsusbhost_clkctrl, hs_clk_ctrl_val);
-
-   /* Enable port 2 and 3 usb host ports tll clocks*/
-   setbits_le32((*prcm)->cm_l3init_hsusbtll_clkctrl,
-   (OPTFCLKEN_USB_CH1_CLK_ENABLE | 
OPTFCLKEN_USB_CH2_CLK_ENABLE));
-#ifdef CONFIG_USB_XHCI_OMAP
-   /* Enable the USB OTG Super speed clocks */
-   setbits_le32((*prcm)->cm_l3init_usb_otg_ss_clkctrl,
-   (OPTFCLKEN_REFCLK960M | OTG_SS_CLKCTRL_MODULEMODE_HW));
-#endif
-
-   auxclk = readl((*prcm)->scrm_auxclk1);
-   /* Request auxilary clock */
-   auxclk |= AUXCLK_ENABLE_MASK;
-   writel(auxclk, (*prcm)->scrm_auxclk1);
+   return 0;
 }
-#endif
 
 /**
  * @brief misc_init_r - Configure EVM board specific configurations
@@ -223,45 +206,6 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
-#ifdef CONFIG_USB_EHCI_HCD
-static struct omap_usbhs_board_data usbhs_bdata = {
-   .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
-   .port_mode[1] = OMAP_EHCI_PORT_MODE_HSIC,
-   .port_mode[2] = OMAP_EHCI_PORT_MODE_HSIC,
-};
-
-int ehci_hcd_init(int index, enum usb_init_type init,
-   struct ehci_hccr **hccr, struct ehci_hcor **hcor)
-{
-   int ret;
-
-   enable_host_clocks();
-
-   ret = omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
-   if (ret < 0) {
-   puts("Failed to initialize ehci\n");
-   return ret;
-   }
-
-   return 0;
-}
-
-int ehci_hcd_stop(void)
-{
-   return omap_ehci_hcd_stop();
-}
-
-void usb_hub_reset_devices(struct usb_hub_device *hub, int port)
-{
-   /* The LAN9730 needs to be reset after the port power has been set. */
-   if (port == 3) {
-   gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, 0);
-   udelay(10);
-   gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, 1);
-   }
-}
-#endif
-
 #ifdef CONFIG_USB_XHCI_OMAP
 /**
  * @brief board_usb_init - Configure EVM board specific configurations
@@ -276,8 +220,6 @@ int board_usb_init(int index, enum usb_init_type init)
ret = palmas_enable_ss_ldo();
 #endif
 
-   enable_host_clocks();
-
return 0;
 }
 #endif
diff --git a/co

[PATCHv3 3/6] omap4: Copy device tree from Linux 5.7.y for SDP4430

2020-06-16 Thread Tero Kristo
From: Peter Ujfalusi 

Copy all device tree files required for omap4 sdp4430 support from
mainline Linux.

Signed-off-by: Peter Ujfalusi 
Signed-off-by: Tero Kristo 
---
 arch/arm/dts/omap4-sdp-es23plus.dts |  14 +
 arch/arm/dts/omap4-sdp.dts  | 713 
 2 files changed, 727 insertions(+)
 create mode 100644 arch/arm/dts/omap4-sdp-es23plus.dts
 create mode 100644 arch/arm/dts/omap4-sdp.dts

diff --git a/arch/arm/dts/omap4-sdp-es23plus.dts 
b/arch/arm/dts/omap4-sdp-es23plus.dts
new file mode 100644
index 00..42154520d3
--- /dev/null
+++ b/arch/arm/dts/omap4-sdp-es23plus.dts
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ */
+#include "omap4-sdp.dts"
+
+/* SDP boards with 4430 ES2.3+ or 4460 have external pullups on SCL & SDA */
+&dss_hdmi_pins {
+   pinctrl-single,pins = <
+   OMAP4_IOPAD(0x09a, PIN_INPUT | MUX_MODE0)   /* 
hdmi_cec.hdmi_cec */
+   OMAP4_IOPAD(0x09c, PIN_INPUT | MUX_MODE0)   /* 
hdmi_scl.hdmi_scl */
+   OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0)   /* 
hdmi_sda.hdmi_sda */
+   >;
+};
diff --git a/arch/arm/dts/omap4-sdp.dts b/arch/arm/dts/omap4-sdp.dts
new file mode 100644
index 00..91480ac1f3
--- /dev/null
+++ b/arch/arm/dts/omap4-sdp.dts
@@ -0,0 +1,713 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ */
+/dts-v1/;
+
+#include "omap443x.dtsi"
+#include "elpida_ecb240abacn.dtsi"
+#include "omap4-mcpdm.dtsi"
+
+/ {
+   model = "TI OMAP4 SDP board";
+   compatible = "ti,omap4-sdp", "ti,omap4430", "ti,omap4";
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x4000>; /* 1 GB */
+   };
+
+   aliases {
+   display0 = &lcd0;
+   display1 = &lcd1;
+   display2 = &hdmi0;
+   };
+
+   vdd_eth: fixedregulator-vdd-eth {
+   pinctrl-names = "default";
+   pinctrl-0 = <&enet_enable_gpio>;
+
+   compatible = "regulator-fixed";
+   regulator-name = "VDD_ETH";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = <&gpio2 16 GPIO_ACTIVE_HIGH>;  /* gpio line 48 */
+   enable-active-high;
+   regulator-boot-on;
+   startup-delay-us = <25000>;
+   };
+
+   vbat: fixedregulator-vbat {
+   compatible = "regulator-fixed";
+   regulator-name = "VBAT";
+   regulator-min-microvolt = <375>;
+   regulator-max-microvolt = <375>;
+   regulator-boot-on;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   debug0 {
+   label = "omap4:green:debug0";
+   gpios = <&gpio2 29 GPIO_ACTIVE_HIGH>; /* 61 */
+   };
+
+   debug1 {
+   label = "omap4:green:debug1";
+   gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>; /* 30 */
+   };
+
+   debug2 {
+   label = "omap4:green:debug2";
+   gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; /* 7 */
+   };
+
+   debug3 {
+   label = "omap4:green:debug3";
+   gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; /* 8 */
+   };
+
+   debug4 {
+   label = "omap4:green:debug4";
+   gpios = <&gpio2 18 GPIO_ACTIVE_HIGH>; /* 50 */
+   };
+
+   user1 {
+   label = "omap4:blue:user";
+   gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* 169 */
+   };
+
+   user2 {
+   label = "omap4:red:user";
+   gpios = <&gpio6 10 GPIO_ACTIVE_HIGH>; /* 170 */
+   };
+
+   user3 {
+   label = "omap4:green:user";
+   gpios = <&gpio5 11 GPIO_ACTIVE_HIGH>; /* 139 */
+   };
+   };
+
+   pwmleds {
+   compatible = "pwm-leds";
+   kpad {
+   label = "omap4::keypad";
+   pwms = <&twl_pwm 0 7812500>;
+   max-brightness = <127>;
+   };
+
+   charging {
+   label = "omap4:green:chrg";
+   pwms = <&twl_pwmled 0 7812500>;
+   max-brightness = <255>;
+   };
+   };
+
+   backlight {
+   compatible = "pwm-backlight";
+   pwms = <&twl_pwm 1 7812500>;
+   brightness-levels = <
+   0 10 20 30 40
+   50 60 70 80 90
+  

Re: [PATCH 1/2] board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

2020-06-16 Thread Patrice CHOTARD
Hi

On 6/5/20 9:24 AM, Patrick Delaunay wrote:
> From: Etienne Carriere 
>
> Fix the sequence in stm32mp1 fdt.c that disables OP-TEE resources
> defined in FDT when U-boot detects OP-TEE firmware is not present.
>
> Before this change, helper function stm32_fdt_disable_optee()
> set property status to "disabled" for the OP-TEE reserved memory
> nodes but this has no impact since Linux kernel does not consider
> the status property for reserved-memory subnodes. This change
> make U-Boot to attempt to delete the node instead.
>
> Fixes: 4a1b975dac02 ("board: stm32mp1: reserve memory for OP-TEE in device 
> tree")
> Signed-off-by: Etienne Carriere 
> Signed-off-by: Patrick Delaunay 
> ---
>
>  arch/arm/mach-stm32mp/fdt.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
> index c723b223e0..959f12efe1 100644
> --- a/arch/arm/mach-stm32mp/fdt.c
> +++ b/arch/arm/mach-stm32mp/fdt.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
>  /*
> - * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
> + * Copyright (C) 2019-2020, STMicroelectronics - All Rights Reserved
>   */
>  
>  #include 
> @@ -224,19 +224,23 @@ static void stm32_fdt_disable_optee(void *blob)
>  {
>   int off, node;
>  
> + /* Delete "optee" firmware node */
>   off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
>   if (off >= 0 && fdtdec_get_is_enabled(blob, off))
> - fdt_status_disabled(blob, off);
> + fdt_del_node(blob, off);
>  
> - /* Disabled "optee@..." reserved-memory node */
> + /* Delete "optee@..." reserved-memory node */
>   off = fdt_path_offset(blob, "/reserved-memory/");
>   if (off < 0)
>   return;
>   for (node = fdt_first_subnode(blob, off);
>node >= 0;
>node = fdt_next_subnode(blob, node)) {
> - if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
> - fdt_status_disabled(blob, node);
> + if (strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
> + continue;
> +
> + if (fdt_del_node(blob, node))
> + printf("Failed to remove optee reserved-memory node\n");
>   }
>  }
>  

Reviewed-by: Patrice Chotard 

Thanks

Re: [Uboot-stm32] [PATCH 2/2] dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

2020-06-16 Thread Patrice CHOTARD
Hi

On 6/5/20 9:24 AM, Patrick Delaunay wrote:
> From: Etienne Carriere 
>
> Add OP-TEE firmware node in stm32mp15 U-Boot DTSI. This node is
> needed since commit [1] that changed U-Boot/stm32mp15 to detect
> OP-TEE availability by probing the resource instead of relying on
> U-Boot configuration. The software sequence implemented by [1] is
> fine but U-Boot DTS/DTSI files were not updated accordingly since,
> hence OP-TEE presence is never detected by U-Boot, preventing Linux
> kernel from using OP-TEE resources.
>
> For consistency and to synchronize stm32mp15 DTSI files (excluding
> U-Boot specific DTSI files) with the Linux kernel ones, this change
> also moves the OP-TEE reserved memory nodes from board generic DTSI
> files to U-Boot specific board DTSI files.
>
> Link: [1] commit 43df0a159df6 ("stm32mp1: dynamically detect op-tee presence")
> Signed-off-by: Etienne Carriere 
> Signed-off-by: Patrick Delaunay 
> ---
>
>  arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++
>  arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++
>  arch/arm/dts/stm32mp157c-ed1.dts |  5 -
>  arch/arm/dts/stm32mp15xx-dkx.dtsi|  5 -
>  4 files changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi 
> b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> index c52abeb1e7..3fedb6f1e1 100644
> --- a/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi
> @@ -20,6 +20,21 @@
>   st,fastboot-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
>   st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
>   };
> +
> + firmware {
> + optee {
> + compatible = "linaro,optee-tz";
> + method = "smc";
> + };
> + };
> +
> + reserved-memory {
> + optee@de00 {
> + reg = <0xde00 0x0200>;
> + no-map;
> + };
> + };
> +
>   led {
>   red {
>   label = "error";
> diff --git a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi 
> b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> index 84af7fa47b..a07c585415 100644
> --- a/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> +++ b/arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi
> @@ -21,6 +21,20 @@
>   st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
>   };
>  
> + firmware {
> + optee {
> + compatible = "linaro,optee-tz";
> + method = "smc";
> + };
> + };
> +
> + reserved-memory {
> + optee@fe00 {
> + reg = <0xfe00 0x0200>;
> + no-map;
> + };
> + };
> +
>   led {
>   red {
>   label = "error";
> diff --git a/arch/arm/dts/stm32mp157c-ed1.dts 
> b/arch/arm/dts/stm32mp157c-ed1.dts
> index 4fb71100f5..186dc46754 100644
> --- a/arch/arm/dts/stm32mp157c-ed1.dts
> +++ b/arch/arm/dts/stm32mp157c-ed1.dts
> @@ -70,11 +70,6 @@
>   reg = <0xe800 0x800>;
>   no-map;
>   };
> -
> - optee@fe00 {
> - reg = <0xfe00 0x0200>;
> - no-map;
> - };
>   };
>  
>   aliases {
> diff --git a/arch/arm/dts/stm32mp15xx-dkx.dtsi 
> b/arch/arm/dts/stm32mp15xx-dkx.dtsi
> index 812e370ee4..7589c6f9dc 100644
> --- a/arch/arm/dts/stm32mp15xx-dkx.dtsi
> +++ b/arch/arm/dts/stm32mp15xx-dkx.dtsi
> @@ -58,11 +58,6 @@
>   reg = <0xd400 0x400>;
>   no-map;
>   };
> -
> - optee@de00 {
> - reg = <0xde00 0x0200>;
> - no-map;
> - };
>   };
>  
>   led {

Reviewed-by: Patrice Chotard 

Thanks



[PATCH u-boot v2 0/4] r8152: support more chips

2020-06-16 Thread Hayes Wang
v2:
For patch #1, replace u32 with u8 for rtl_reset_bmu().

For patch #3, use USB_BP(n) to replace USB_BP_0 ~ USB_BP_7.
Write the registers in bulk for rtl_clear_bp().

For patch #4, add a macro for the magic value. Remove type casts.
Write the register in bulk, if it is possible. Reduce indent.

v1:
The first two patched are some improvements. And the last two patches
are used to support RTL8153B and RTL8154B.

Hayes Wang (4):
  eth/r8152: reset bmu after disabling Tx/Rx
  eth/r8152: reset PHY after setting it
  eth/r8152: modify rtl_clear_bp function
  eth/r8152: support RTL8153B/RTL8154B

 drivers/usb/eth/r8152.c| 223 +-
 drivers/usb/eth/r8152.h|  71 +--
 drivers/usb/eth/r8152_fw.c | 239 +
 3 files changed, 493 insertions(+), 40 deletions(-)

-- 
2.21.1



[PATCH u-boot v2 2/4] eth/r8152: reset PHY after setting it

2020-06-16 Thread Hayes Wang
Some settings of PHY have to work after resetting PHY.

Signed-off-by: Hayes Wang 
---
 drivers/usb/eth/r8152.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c
index 041cb22dd3..7f988543a1 100644
--- a/drivers/usb/eth/r8152.c
+++ b/drivers/usb/eth/r8152.c
@@ -947,7 +947,7 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, 
u16 speed, u8 duplex)
return -EINVAL;
}
 
-   bmcr = BMCR_ANENABLE | BMCR_ANRESTART;
+   bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET;
}
 
if (tp->supports_gmii)
-- 
2.21.1



[PATCH u-boot v2 3/4] eth/r8152: modify rtl_clear_bp function

2020-06-16 Thread Hayes Wang
The original rtl_clear_bp() is used to clear the firmware of both
PLA and USB MCU. The new one could clear the firmware of PLA or
USB independently. It is unnecessary to clear firmware, if there
is no one to be updated.

Besides, clear the firmware by writing the relative registers in
bulk.

Signed-off-by: Hayes Wang 
---
 drivers/usb/eth/r8152.h| 13 ++---
 drivers/usb/eth/r8152_fw.c | 58 ++
 2 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/eth/r8152.h b/drivers/usb/eth/r8152.h
index 4daf4ee87d..710637d7a2 100644
--- a/drivers/usb/eth/r8152.h
+++ b/drivers/usb/eth/r8152.h
@@ -95,16 +95,9 @@
 #define USB_MISC_0 0xd81a
 #define USB_AFE_CTRL2  0xd824
 #define USB_WDT11_CTRL 0xe43c
-#define USB_BP_BA  0xfc26
-#define USB_BP_0   0xfc28
-#define USB_BP_1   0xfc2a
-#define USB_BP_2   0xfc2c
-#define USB_BP_3   0xfc2e
-#define USB_BP_4   0xfc30
-#define USB_BP_5   0xfc32
-#define USB_BP_6   0xfc34
-#define USB_BP_7   0xfc36
-#define USB_BP_EN  0xfc38
+#define USB_BP_BA  PLA_BP_BA
+#define USB_BP(n)  (0xfc28 + 2 * (n))
+#define USB_BP_EN  PLA_BP_EN
 
 /* OCP Registers */
 #define OCP_ALDPS_CONFIG   0x2010
diff --git a/drivers/usb/eth/r8152_fw.c b/drivers/usb/eth/r8152_fw.c
index f953b0384b..2da1f221b4 100644
--- a/drivers/usb/eth/r8152_fw.c
+++ b/drivers/usb/eth/r8152_fw.c
@@ -729,28 +729,30 @@ static u16 r8153_pla_patch_d_bp[] = {
0xfc2e, 0x, 0xfc30, 0x, 0xfc32, 0x, 0xfc34, 0x,
0xfc36, 0x, 0xfc38, 0x0007 };
 
-static void rtl_clear_bp(struct r8152 *tp)
+static void rtl_clear_bp(struct r8152 *tp, u16 type)
 {
-   ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_0, 0);
-   ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_2, 0);
-   ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_4, 0);
-   ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_6, 0);
-   ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_0, 0);
-   ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_2, 0);
-   ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_4, 0);
-   ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_6, 0);
+   u8 zeros[16] = {0};
+
+   switch (tp->version) {
+   case RTL_VER_01:
+   case RTL_VER_02:
+   case RTL_VER_07:
+   break;
+   case RTL_VER_03:
+   case RTL_VER_04:
+   case RTL_VER_05:
+   case RTL_VER_06:
+   ocp_write_byte(tp, type, PLA_BP_EN, 0);
+   break;
+   default:
+   break;
+   }
 
-   mdelay(6);
+   generic_ocp_write(tp, USB_BP(0), 0xff, sizeof(zeros), zeros, type);
 
-   ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_BA, 0);
-   ocp_write_word(tp, MCU_TYPE_USB, USB_BP_BA, 0);
-}
+   mdelay(6);
 
-static void r8153_clear_bp(struct r8152 *tp)
-{
-   ocp_write_byte(tp, MCU_TYPE_PLA, PLA_BP_EN, 0);
-   ocp_write_byte(tp, MCU_TYPE_USB, USB_BP_EN, 0);
-   rtl_clear_bp(tp);
+   ocp_write_word(tp, type, PLA_BP_BA, 0);
 }
 
 static void r8152b_set_dq_desc(struct r8152 *tp)
@@ -826,7 +828,7 @@ void r8152b_firmware(struct r8152 *tp)
int i;
 
r8152b_set_dq_desc(tp);
-   rtl_clear_bp(tp);
+   rtl_clear_bp(tp, MCU_TYPE_PLA);
 
generic_ocp_write(tp, 0xf800, 0x3f,
  sizeof(r8152b_pla_patch_a),
@@ -847,7 +849,7 @@ void r8152b_firmware(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_PLA, 0xb098, 0x0200);
ocp_write_word(tp, MCU_TYPE_PLA, 0xb092, 0x7030);
} else if (tp->version == RTL_VER_02) {
-   rtl_clear_bp(tp);
+   rtl_clear_bp(tp, MCU_TYPE_PLA);
 
generic_ocp_write(tp, 0xf800, 0xff,
  sizeof(r8152b_pla_patch_a2),
@@ -866,8 +868,6 @@ void r8153_firmware(struct r8152 *tp)
int i;
 
if (tp->version == RTL_VER_03) {
-   r8153_clear_bp(tp);
-
r8153_pre_ram_code(tp, 0x7000);
 
for (i = 0; i < ARRAY_SIZE(r8153_ram_code_a); i += 2)
@@ -887,7 +887,8 @@ void r8153_firmware(struct r8152 *tp)
r8153_post_ram_code(tp);
 
r8153_wdt1_end(tp);
-   r8153_clear_bp(tp);
+
+   rtl_clear_bp(tp, MCU_TYPE_USB);
 
ocp_write_word(tp, MCU_TYPE_USB, USB_BP_EN, 0x);
generic_ocp_write(tp, 0xf800, 0xff,
@@ -904,6 +905,8 @@ void r8153_firmware(struct r8152 *tp)
ocp_write_word(tp, MCU_TYPE_PLA, 0xd38e, 0x0082);
}
 
+   rtl_clear_bp(tp, MCU_TYPE_PLA);
+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_EN, 0x);
generic_ocp_write(tp, 0xf800, 0xff,
  sizeof(r8153_pla_patch_b),
@@ -932,7 +935,8 @@ void r8153_firmware(struct r8152

[PATCH u-boot v2 1/4] eth/r8152: reset bmu after disabling Tx/Rx

2020-06-16 Thread Hayes Wang
Reset bmu after disabling Tx/Rx. This is used to clear the FIFO of
Tx/Rx. The remained data may be transferred after Tx/Rx is re-enabled.
And it results in garbage data.

Signed-off-by: Hayes Wang 
---
 drivers/usb/eth/r8152.c | 14 ++
 drivers/usb/eth/r8152.h |  7 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c
index f201a1789b..041cb22dd3 100644
--- a/drivers/usb/eth/r8152.c
+++ b/drivers/usb/eth/r8152.c
@@ -568,6 +568,17 @@ static void r8153_power_cut_en(struct r8152 *tp, bool 
enable)
ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data);
 }
 
+static void rtl_reset_bmu(struct r8152 *tp)
+{
+   u8 ocp_data;
+
+   ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_BMU_RESET);
+   ocp_data &= ~(BMU_RESET_EP_IN | BMU_RESET_EP_OUT);
+   ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_RESET, ocp_data);
+   ocp_data |= BMU_RESET_EP_IN | BMU_RESET_EP_OUT;
+   ocp_write_byte(tp, MCU_TYPE_USB, USB_BMU_RESET, ocp_data);
+}
+
 static int r8152_read_mac(struct r8152 *tp, unsigned char *macaddr)
 {
int ret;
@@ -786,6 +797,7 @@ static void r8153_first_init(struct r8152 *tp)
r8153_hw_phy_cfg(tp);
 
rtl8152_nic_reset(tp);
+   rtl_reset_bmu(tp);
 
ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL);
ocp_data &= ~NOW_IS_OOB;
@@ -832,6 +844,7 @@ static void r8153_enter_oob(struct r8152 *tp)
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data);
 
rtl_disable(tp);
+   rtl_reset_bmu(tp);
 
rtl8152_reinit_ll(tp);
 
@@ -873,6 +886,7 @@ static void rtl8153_disable(struct r8152 *tp)
 {
r8153_disable_aldps(tp);
rtl_disable(tp);
+   rtl_reset_bmu(tp);
 }
 
 static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 
duplex)
diff --git a/drivers/usb/eth/r8152.h b/drivers/usb/eth/r8152.h
index 10e0da8eb1..4daf4ee87d 100644
--- a/drivers/usb/eth/r8152.h
+++ b/drivers/usb/eth/r8152.h
@@ -89,9 +89,10 @@
 #define USB_TX_DMA 0xd434
 #define USB_TOLERANCE  0xd490
 #define USB_LPM_CTRL   0xd41a
+#define USB_BMU_RESET  0xd4b0
 #define USB_UPS_CTRL   0xd800
-#define USB_MISC_0 0xd81a
 #define USB_POWER_CUT  0xd80a
+#define USB_MISC_0 0xd81a
 #define USB_AFE_CTRL2  0xd824
 #define USB_WDT11_CTRL 0xe43c
 #define USB_BP_BA  0xfc26
@@ -324,6 +325,10 @@
 #define TEST_MODE_DISABLE  0x0001
 #define TX_SIZE_ADJUST10x0100
 
+/* USB_BMU_RESET */
+#define BMU_RESET_EP_IN0x01
+#define BMU_RESET_EP_OUT   0x02
+
 /* USB_UPS_CTRL */
 #define POWER_CUT  0x0100
 
-- 
2.21.1



[PATCH u-boot v2 4/4] eth/r8152: support RTL8153B/RTL8154B

2020-06-16 Thread Hayes Wang
This is used to support RTL8153B and RTL8154B.

Signed-off-by: Hayes Wang 
---
 drivers/usb/eth/r8152.c| 207 -
 drivers/usb/eth/r8152.h|  41 +++-
 drivers/usb/eth/r8152_fw.c | 170 ++
 3 files changed, 414 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c
index 7f988543a1..d8fb0acd0f 100644
--- a/drivers/usb/eth/r8152.c
+++ b/drivers/usb/eth/r8152.c
@@ -68,6 +68,8 @@ static const struct r8152_version r8152_versions[] = {
{ 0x5c20, RTL_VER_05, 1 },
{ 0x5c30, RTL_VER_06, 1 },
{ 0x4800, RTL_VER_07, 0 },
+   { 0x6000, RTL_VER_08, 1 },
+   { 0x6010, RTL_VER_09, 1 },
 };
 
 static
@@ -331,6 +333,12 @@ void sram_write(struct r8152 *tp, u16 addr, u16 data)
ocp_reg_write(tp, OCP_SRAM_DATA, data);
 }
 
+static u16 sram_read(struct r8152 *tp, u16 addr)
+{
+   ocp_reg_write(tp, OCP_SRAM_ADDR, addr);
+   return ocp_reg_read(tp, OCP_SRAM_DATA);
+}
+
 int r8152_wait_for_bit(struct r8152 *tp, bool ocp_reg, u16 type, u16 index,
   const u32 mask, bool set, unsigned int timeout)
 {
@@ -467,12 +475,56 @@ static void r8153_set_rx_early_timeout(struct r8152 *tp)
 {
u32 ocp_data = tp->coalesce / 8;
 
-   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_TIMEOUT, ocp_data);
+   switch (tp->version) {
+   case RTL_VER_03:
+   case RTL_VER_04:
+   case RTL_VER_05:
+   case RTL_VER_06:
+   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_TIMEOUT,
+  ocp_data);
+   break;
+
+   case RTL_VER_08:
+   case RTL_VER_09:
+   /* The RTL8153B uses USB_RX_EXTRA_AGGR_TMR for rx timeout
+* primarily. For USB_RX_EARLY_TIMEOUT, we fix it to 1264ns.
+*/
+   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_TIMEOUT,
+  RX_AUXILIARY_TIMER / 8);
+   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EXTRA_AGGR_TMR,
+  ocp_data);
+   break;
+
+   default:
+   debug("** %s Invalid Device\n", __func__);
+   break;
+   }
 }
 
 static void r8153_set_rx_early_size(struct r8152 *tp)
 {
-   u32 ocp_data = (RTL8152_AGG_BUF_SZ - RTL8153_RMS) / 4;
+   u32 ocp_data = (RTL8152_AGG_BUF_SZ - RTL8153_RMS -
+   sizeof(struct rx_desc));
+
+   switch (tp->version) {
+   case RTL_VER_03:
+   case RTL_VER_04:
+   case RTL_VER_05:
+   case RTL_VER_06:
+   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE,
+  ocp_data / 4);
+   break;
+
+   case RTL_VER_08:
+   case RTL_VER_09:
+   ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE,
+  ocp_data / 8);
+   break;
+
+   default:
+   debug("** %s Invalid Device\n", __func__);
+   break;
+   }
 
ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data);
 }
@@ -540,6 +592,19 @@ static void r8153_u1u2en(struct r8152 *tp, bool enable)
usb_ocp_write(tp, USB_TOLERANCE, BYTE_EN_SIX_BYTES, sizeof(u1u2), u1u2);
 }
 
+static void r8153b_u1u2en(struct r8152 *tp, bool enable)
+{
+   u16 ocp_data;
+
+   ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_LPM_CONFIG);
+   if (enable)
+   ocp_data |= LPM_U1U2_EN;
+   else
+   ocp_data &= ~LPM_U1U2_EN;
+
+   ocp_write_word(tp, MCU_TYPE_USB, USB_LPM_CONFIG, ocp_data);
+}
+
 static void r8153_u2p3en(struct r8152 *tp, bool enable)
 {
u32 ocp_data;
@@ -784,6 +849,71 @@ static void r8153_hw_phy_cfg(struct r8152 *tp)
sram_write(tp, SRAM_10M_AMP2, 0x0208);
 }
 
+static u32 r8152_efuse_read(struct r8152 *tp, u8 addr)
+{
+   u32 ocp_data;
+
+   ocp_write_word(tp, MCU_TYPE_PLA, PLA_EFUSE_CMD, EFUSE_READ_CMD | addr);
+   ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EFUSE_CMD);
+   ocp_data = (ocp_data & EFUSE_DATA_BIT16) << 9;  /* data of bit16 */
+   ocp_data |= ocp_read_word(tp, MCU_TYPE_PLA, PLA_EFUSE_DATA);
+
+   return ocp_data;
+}
+
+static void r8153b_hw_phy_cfg(struct r8152 *tp)
+{
+   u32 ocp_data;
+   u16 data;
+
+   data = r8152_mdio_read(tp, MII_BMCR);
+   if (data & BMCR_PDOWN) {
+   data &= ~BMCR_PDOWN;
+   r8152_mdio_write(tp, MII_BMCR, data);
+   }
+
+   /* U1/U2/L1 idle timer. 500 us */
+   ocp_write_word(tp, MCU_TYPE_USB, USB_U1U2_TIMER, 500);
+
+   r8153b_firmware(tp);
+
+   data = sram_read(tp, SRAM_GREEN_CFG);
+   data |= R_TUNE_EN;
+   sram_write(tp, SRAM_GREEN_CFG, data);
+   data = ocp_reg_read(tp, OCP_NCTL_CFG);
+   data |= PGA_RETURN_EN;
+   ocp_reg_write(tp, OCP_NCTL_CFG, data);
+
+   /* ADC Bias Calibration:
+* read efuse offset 0x7d to get a 17-bit data. Remove the dummy/fake
+ 

RE: [PATCH 1/2] board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

2020-06-16 Thread Patrick DELAUNAY
Hi,

> From: Patrick DELAUNAY 
> Sent: vendredi 5 juin 2020 09:24
> 
> From: Etienne Carriere 
> 
> Fix the sequence in stm32mp1 fdt.c that disables OP-TEE resources defined in
> FDT when U-boot detects OP-TEE firmware is not present.
> 
> Before this change, helper function stm32_fdt_disable_optee() set property 
> status
> to "disabled" for the OP-TEE reserved memory nodes but this has no impact 
> since
> Linux kernel does not consider the status property for reserved-memory
> subnodes. This change make U-Boot to attempt to delete the node instead.
> 
> Fixes: 4a1b975dac02 ("board: stm32mp1: reserve memory for OP-TEE in device
> tree")
> Signed-off-by: Etienne Carriere 
> Signed-off-by: Patrick Delaunay 
> ---
> 

Applied to u-boot-stm/master, thanks!

Regards

Patrick


RE: [PATCH 2/2] dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

2020-06-16 Thread Patrick DELAUNAY
Hi, 

> From: Patrick DELAUNAY 
> Sent: vendredi 5 juin 2020 09:25
> 
> From: Etienne Carriere 
> 
> Add OP-TEE firmware node in stm32mp15 U-Boot DTSI. This node is needed
> since commit [1] that changed U-Boot/stm32mp15 to detect OP-TEE availability
> by probing the resource instead of relying on U-Boot configuration. The 
> software
> sequence implemented by [1] is fine but U-Boot DTS/DTSI files were not updated
> accordingly since, hence OP-TEE presence is never detected by U-Boot,
> preventing Linux kernel from using OP-TEE resources.
> 
> For consistency and to synchronize stm32mp15 DTSI files (excluding U-Boot
> specific DTSI files) with the Linux kernel ones, this change also moves the 
> OP-
> TEE reserved memory nodes from board generic DTSI files to U-Boot specific
> board DTSI files.
> 
> Link: [1] commit 43df0a159df6 ("stm32mp1: dynamically detect op-tee presence")
> Signed-off-by: Etienne Carriere 
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++
> arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++
>  arch/arm/dts/stm32mp157c-ed1.dts |  5 -
>  arch/arm/dts/stm32mp15xx-dkx.dtsi|  5 -
>  4 files changed, 29 insertions(+), 10 deletions(-)
> 

Applied to u-boot-stm/master, thanks!

Regards

Patrick


Re: [PATCH v2 04/25] x86: mp_init: Switch parameter names in start_aps()

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

> -"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 04/25] x86: mp_init: Switch parameter names in start_aps()
> 
> These parameters are named differently from elsewhere in this file. Switch
> them to avoid confusion.
> 
> Also add comments to this function.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add comments to explain what start_aps() does
> 
>  arch/x86/cpu/mp_init.c | 25 +++--
>  1 file changed, 19 insertions(+), 6 deletions(-)

Reviewed-by: Wolfgang Wallner 


Re: [PATCH v2 10/25] x86: mp: Support APs waiting for instructions

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 10/25] x86: mp: Support APs waiting for instructions
> 
> At present the APs (non-boot CPUs) are inited once and then parked ready
> for the OS to use them. However in some cases we want to send new requests
> through, such as to change MTRRs and keep them consistent across CPUs.
> 
> Change the last state of the flight plan to go into a wait loop, accepting
> instructions from the main CPU.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add more comments
> 
>  arch/x86/cpu/mp_init.c| 126 +++---
>  arch/x86/include/asm/mp.h |  11 
>  2 files changed, 128 insertions(+), 9 deletions(-)

[snip]

> @@ -455,6 +478,86 @@ static int get_bsp(struct udevice **devp, int 
> *cpu_countp)
>   return dev->req_seq;
>  }
>  
> +/**
> + * read_callback() - Read the pointer in a callback slot
> + *
> + * This is called by APs to read their callback slow to see if there is a

Typo: callback slot

> + * pointer to new instructions
> + *
> + * @slot: Pointer to the AP's callback slot
> + * @return value of that pointer
> + */
> +static struct mp_callback *read_callback(struct mp_callback **slot)
> +{
> + struct mp_callback *ret;
> +
> + asm volatile ("mov  %1, %0\n"
> + : "=r" (ret)
> + : "m" (*slot)
> + : "memory"
> + );
> + return ret;
> +}

[snip]


Reviewed-by: Wolfgang Wallner 


Re: [PATCH v2 13/25] x86: mp: Allow running functions on multiple CPUs

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 13/25] x86: mp: Allow running functions on multiple CPUs
> 
> Add a way to run a function on a selection of CPUs. This supports either
> a single CPU, all CPUs, just the main CPU or just the 'APs', in Intel
> terminology.
> 
> It works by writing into a mailbox and then waiting for the CPUs to notice
> it, take action and indicate they are done.
> 
> When SMP is not yet enabled, this just calls the function on the main CPU.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add a comment to run_ap_work()
> 
>  arch/x86/cpu/mp_init.c| 96 ---
>  arch/x86/include/asm/mp.h | 30 
>  2 files changed, 120 insertions(+), 6 deletions(-)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v2 17/25] x86: Don't enable SMP in SPL

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 17/25] x86: Don't enable SMP in SPL
> 
> SMP should be set up in U-Boot where possible, not SPL. Disable it in SPL.
> For 64-bit U-Boot we should find a way to allow SMP operations in U-Boot,
> but this is somewhat more complicated. For now that is disabled too.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add a new patch to avoid enabling SMP in SPL
> 
>  arch/x86/cpu/Makefile | 2 +-
>  arch/x86/include/asm/mp.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v2 18/25] x86: coral: Update the memory map

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 18/25] x86: coral: Update the memory map
> 
> This currently excludes the temporary memory used to start up the APs.
> Add it.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add new patch to add AP_DEFAULT_BASE to coral's memory map
> 
>  doc/board/google/chromebook_coral.rst | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/doc/board/google/chromebook_coral.rst 
> b/doc/board/google/chromebook_coral.rst
> index 40bd9397d4..c39f1e310c 100644
> --- a/doc/board/google/chromebook_coral.rst
> +++ b/doc/board/google/chromebook_coral.rst
> @@ -188,6 +188,7 @@ Partial memory map
>  fef0  1000 CONFIG_BOOTSTAGE_STASH_ADDR
>  fef0   Base of CAR region
>  
> +   3   AP_DEFAULT_BASE (used to start up additional CPUs)
> f   CONFIG_ROM_TABLE_ADDR
>12   BSS (defined in u-boot-spl.lds)
>20   FSP-S (which is run after U-Boot is relocated)
> -- 
> 2.27.0.290.gba653c62da-goog

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v2 20/25] x86: mtrr: Add support for writing to MTRRs on any CPU

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 20/25] x86: mtrr: Add support for writing to MTRRs on any 
> CPU
> 
> To enable support for the 'mtrr' command, add a way to perform MTRR
> operations on selected CPUs.
> 
> This works by setting up a little 'operation' structure and sending it
> around the CPUs for action.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Keep things building by temporarily renaming the function in cmd/
> 
>  arch/x86/cpu/mtrr.c | 81 +
>  arch/x86/include/asm/mtrr.h | 21 ++
>  cmd/x86/mtrr.c  |  6 +--
>  3 files changed, 105 insertions(+), 3 deletions(-)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v2 24/25] x86: mp: Add more comments to the module

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

> -"Simon Glass"  schrieb: -
> Betreff: [PATCH v2 24/25] x86: mp: Add more comments to the module
> 
> Add a description of how this module works and also some missing function
> comments.

Great to see more documenation :)

> 
> Drop struct cpu_map since it is not used.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v2:
> - Add a new patch with more comments
> 
>  arch/x86/cpu/mp_init.c| 91 ++-
>  arch/x86/include/asm/mp.h | 14 +-
>  2 files changed, 102 insertions(+), 3 deletions(-)
> 

[snip]

> + *
> + * After being started, each AP runs the code in ap_start16, switches to 
> 32-bit
> + * mode, runs the code at ap_start, then jumps to c_handler which is 
> ap_init().
> + * This runs a very simple 'flight plan' described in* mp_steps. This sets up

Should this be "in *mp_steps"? Or "in mp_steps"?

[snip]

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 05/35] acpi: Support generation of ACPI code

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 05/35] acpi: Support generation of ACPI code
> 
> Add a new file to handle generating ACPI code programatically. This is
> used when information must be dynamically added to the tables, e.g. the
> SSDT.
> 
> Initial support is just for writing simple values. Also add a 'base' value
> so that the table can be freed. This likely doesn't happen in normal code,
> but is nice to do in tests.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> (no changes since v2)
> 
> Changes in v2:
> - Update to add a new 'base' field to struct acpi_ctx
> - Free the memory allocated to the table and context
> 
>  include/acpi/acpigen.h | 49 ++
>  include/dm/acpi.h  |  2 ++
>  lib/acpi/Makefile  |  1 +
>  lib/acpi/acpi_table.c  |  1 +
>  lib/acpi/acpigen.c | 38 +++
>  test/dm/Makefile   |  1 +
>  test/dm/acpigen.c  | 69 ++
>  7 files changed, 161 insertions(+)
>  create mode 100644 include/acpi/acpigen.h
>  create mode 100644 lib/acpi/acpigen.c
>  create mode 100644 test/dm/acpigen.c

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 12/35] acpi: Support generation of SPI descriptor

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 12/35] acpi: Support generation of SPI descriptor
> 
> Add a function to write a SPI descriptor to the generated ACPI code.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> - Make acpi_device_write_spi() static
> - Add an extra comment about scope to acpi_device_set_spi()
> - Use BIT() in a few places
> - Resist the temptation to go to >80 characters
> 
> Changes in v2:
> - Fix memset of SPI descriptor
> 
>  drivers/spi/sandbox_spi.c  |  11 
>  include/acpi/acpi_device.h |  36 +++
>  include/spi.h  |   4 +-
>  lib/acpi/acpi_device.c | 124 +
>  test/dm/acpigen.c  |  36 +++
>  5 files changed, 209 insertions(+), 2 deletions(-)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 20/35] acpi: Support writing a GPIO

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 20/35] acpi: Support writing a GPIO
> 
> Allowing writing out a reference to a GPIO within the ACPI output. This
> can be used by ACPI code to access a GPIO at runtime.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> - Use an enum for the GPIO priority
> - Add error checking
> 
>  include/acpi/acpi_dp.h | 20 
>  lib/acpi/acpi_dp.c | 23 +++
>  test/dm/acpi_dp.c  | 40 
>  3 files changed, 83 insertions(+)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 21/35] acpi: Support copying properties from device tree to ACPI

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 21/35] acpi: Support copying properties from device tree 
> to ACPI
> 
> Some drivers in Linux support both device tree and ACPI. U-Boot itself
> uses Linux device-tree bindings for its own configuration but does not use
> ACPI.
> 
> It is convenient to copy these values over to the device tree for passing
> to linux. Add some convenience functions to help with this.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> - Fix incorrect function names and arguments in commments
> - Add error checking for acpi_dp_add...() functions
> 
>  arch/sandbox/dts/test.dts |  1 +
>  include/acpi/acpi_dp.h| 51 +
>  lib/acpi/acpi_dp.c| 56 
>  test/dm/acpi_dp.c | 67 +++
>  4 files changed, 175 insertions(+)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 29/35] acpi: Support ordering SSDT data by device

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 29/35] acpi: Support ordering SSDT data by device
> 
> Add a /chosen property to control the order in which the data appears
> in the SSDT. This allows matching up U-Boot's output from a dump of the
> known-good data obtained from within Linux.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> - Make find_item() static and rename to find_acpi_item()
> - Rename build_type() and add a comment
> 
> Changes in v1:
> - Generalise the ACPI function recursion with acpi_recurse_method()
> 
>  arch/sandbox/dts/test.dts   |  5 +-
>  doc/device-tree-bindings/chosen.txt |  9 
>  drivers/core/acpi.c | 75 +
>  test/dm/acpi.c  | 15 +++---
>  4 files changed, 96 insertions(+), 8 deletions(-)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 30/35] x86: Allow devices to write an SSDT

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 30/35] x86: Allow devices to write an SSDT
> 
> Call the new core function to write the SSDT. This is made up of fragments
> generated by devices that have the fill_ssdt() method.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> Drop coreboot_acpi_ids enum
> 
> Changes in v1:
> - Use OEM_TABLE_ID instead of ACPI_TABLE_CREATOR
> - Update ACPI_DSTATUS enum
> - Drop writing of coreboot tables
> 
>  arch/x86/lib/acpi_table.c | 29 +
>  1 file changed, 29 insertions(+)

Reviewed-by: Wolfgang Wallner 



Re: [PATCH v3 32/35] x86: Allow devices to write to DSDT

2020-06-16 Thread Wolfgang Wallner
Hi Simon,

-"Simon Glass"  schrieb: -
> Betreff: [PATCH v3 32/35] x86: Allow devices to write to DSDT
> 
> Call the new core function to inject ASL programmatically into the DSDT.
> This is made up of fragments generated by devices that have the
> inject_dsdt() method. The normal, compiled ASL file is added after this.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v3:
> - Refactor the code to remove the extra memcpy()
> - Recalculate the DSDT checksum only once
> - Add a comment as to why the checksum byte is set to 0
> 
>  arch/x86/lib/acpi_table.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)

Reviewed-by: Wolfgang Wallner 



[PULL] Pull request: u-boot-stm32 for v2020.07= u-boot-stm32-20200616

2020-06-16 Thread Patrick DELAUNAY
Hi Tom,

Please pull the STM32 related patches for v2020.07:  u-boot-stm32-20200528

With the following changes:
- fix boot with OP-TEE for stm32mp15 boards

CI status:
https://gitlab.denx.de/u-boot/custodians/u-boot-stm/pipelines/3689

Thanks,
Patrick

The following changes since commit 287be3294af6179782f8a561afca427620504581:

  Merge branch '2020-06-15-misc-bugfixes' (2020-06-15 11:24:42 -0400)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-stm.git 
tags/u-boot-stm32-20200616

for you to fetch changes up to 9e696965065c43b59901e49e75435b1549fa55c7:

  dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI (2020-06-16 10:39:28 
+0200)


- fix boot with OP-TEE for stm32mp15 boards


Etienne Carriere (2):
  board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes
  dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++
 arch/arm/dts/stm32mp157c-ed1.dts |  5 -
 arch/arm/dts/stm32mp15xx-dkx.dtsi|  5 -
 arch/arm/mach-stm32mp/fdt.c  | 14 +-
 5 files changed, 38 insertions(+), 15 deletions(-)


Re: [PATCH 1/2] board: amlogic: move boards doc into doc/board/amlogic

2020-06-16 Thread Neil Armstrong
Hi,

On 16/06/2020 06:35, Anand Moon wrote:
> Hi Neil,
> 
> On Thu, 11 Jun 2020 at 19:20, Neil Armstrong  wrote:
>>
>> Move the natural text Amlogic board README files to doc/board/amlogic
>> into reStructuredText and :
>> - add reStructuredText markup for bash code
>> - fix secondary titles markup
>> - move board support into global support matrix
>>
>> Signed-off-by: Neil Armstrong 
> 
> Can you also update the following information for flashing u-boot image for 
> eMMC
> 
> # Binaries should be available in fip directory :
> fip/
>  | ...
>  |-- u-boot.bin (for eMMC)
>  |-- u-boot.bin.sd.bin (for SDCard)
> 
> And the following for eMMC
> 
> [0] https://github.com/BayLibre/u-boot/tree/readme#install-on-emmc
> 
> So that it's clear which image should be used for particular booting device.

Sure, I'll send it as an update after the V2 of this patchset.

Neil

> 
> -Anand
> 
>> ---
>>  doc/board/amlogic/index.rst   |  95 +
>>  .../board/amlogic/khadas-vim.rst  | 138 +++--
>>  .../board/amlogic/khadas-vim2.rst | 138 ++---
>>  .../board/amlogic/khadas-vim3.rst | 189 +
>>  .../board/amlogic/khadas-vim3l.rst| 189 +
>>  .../board/amlogic/libretech-ac.rst| 142 ++---
>>  .../board/amlogic/libretech-cc.rst| 139 +++--
>>  .../board/amlogic/nanopi-k2.rst   | 136 +++--
>>  .../board/amlogic/odroid-c2.rst   |  50 +++--
>>  .../board/amlogic/odroid-n2.rst   | 187 +
>>  .../README.p200 => doc/board/amlogic/p200.rst | 136 ++---
>>  .../README.p201 => doc/board/amlogic/p201.rst | 136 ++---
>>  .../README.p212 => doc/board/amlogic/p212.rst | 136 ++---
>>  .../README.q200 => doc/board/amlogic/q200.rst | 136 ++---
>>  .../s400/README => doc/board/amlogic/s400.rst | 150 +++---
>>  .../README => doc/board/amlogic/sei510.rst| 190 -
>>  .../README => doc/board/amlogic/sei610.rst| 185 +
>>  .../u200/README => doc/board/amlogic/u200.rst | 188 -
>>  .../README.w400 => doc/board/amlogic/w400.rst | 192 +-
>>  doc/board/index.rst   |   1 +
>>  20 files changed, 1484 insertions(+), 1369 deletions(-)
>>  create mode 100644 doc/board/amlogic/index.rst
>>  rename board/amlogic/p212/README.khadas-vim => 
>> doc/board/amlogic/khadas-vim.rst (24%)
>>  rename board/amlogic/q200/README.khadas-vim2 => 
>> doc/board/amlogic/khadas-vim2.rst (26%)
>>  rename board/amlogic/w400/README.khadas-vim3 => 
>> doc/board/amlogic/khadas-vim3.rst (20%)
>>  rename board/amlogic/w400/README.khadas-vim3l => 
>> doc/board/amlogic/khadas-vim3l.rst (19%)
>>  rename board/amlogic/p212/README.libretech-ac => 
>> doc/board/amlogic/libretech-ac.rst (21%)
>>  rename board/amlogic/p212/README.libretech-cc => 
>> doc/board/amlogic/libretech-cc.rst (46%)
>>  rename board/amlogic/p200/README.nanopi-k2 => 
>> doc/board/amlogic/nanopi-k2.rst (24%)
>>  rename board/amlogic/p200/README.odroid-c2 => 
>> doc/board/amlogic/odroid-c2.rst (56%)
>>  rename board/amlogic/w400/README.odroid-n2 => 
>> doc/board/amlogic/odroid-n2.rst (19%)
>>  rename board/amlogic/p200/README.p200 => doc/board/amlogic/p200.rst (24%)
>>  rename board/amlogic/p201/README.p201 => doc/board/amlogic/p201.rst (24%)
>>  rename board/amlogic/p212/README.p212 => doc/board/amlogic/p212.rst (24%)
>>  rename board/amlogic/q200/README.q200 => doc/board/amlogic/q200.rst (24%)
>>  rename board/amlogic/s400/README => doc/board/amlogic/s400.rst (21%)
>>  rename board/amlogic/sei510/README => doc/board/amlogic/sei510.rst (14%)
>>  rename board/amlogic/sei610/README => doc/board/amlogic/sei610.rst (16%)
>>  rename board/amlogic/u200/README => doc/board/amlogic/u200.rst (17%)
>>  rename board/amlogic/w400/README.w400 => doc/board/amlogic/w400.rst (17%)
>>
>> diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
>> new file mode 100644
>> index 00..3730419167
>> --- /dev/null
>> +++ b/doc/board/amlogic/index.rst
>> @@ -0,0 +1,95 @@
>> +.. SPDX-License-Identifier: GPL-2.0+
>> +
>> +Amlogic
>> +===
>> +
>> +Hardware Support Matrix
>> +---
>> +
>> +An up-do-date matrix is also available on: http://linux-meson.com
>> +
>> +This matrix concerns the actual source code version.
>> +
>> ++---+---+--+--+++-+--+
>> +|  | S905  | S905X| S912 | 
>> A113X  | S905X2 | S922X   | S905X3   |
>> +|  |   | S805X| S905D|  
>>   | S905D2 | A311D   | S905D3   |
>> +|  |   |  |  |  
>>   | S905Y2 | |  |
>> ++

[PATCH 1/1] spl: fix ext4fs_mount return code handling

2020-06-16 Thread Heiko Thiery
From: Thomas Schaefer 

- Despite other ext4 filesystem functions, ext4fs_mount returns
  0 in case of error.
- This leads to u-boot crash in case that an SD card
  with valid partition table but without ext4 filesystem created
  in a partition is found on SD card.
- Fix this by returning a proper error code of '-1' from spl_load_image_ext
  function in case of ext4fs_mount error.

Signed-off-by: Thomas Schaefer 
[hthiery: slightly reword the commit message]
Signed-off-by: Heiko Thiery 
---
 common/spl/spl_ext.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 3898041d10..c8d137ed98 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -32,6 +32,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: ext4fs mount err - %d\n", __func__, err);
 #endif
+   err = -1; /* ext4fs_mount returns 0 in case of error! */
goto end;
}
 
-- 
2.20.1



[PATCH 1/1] spl: fix ext4fs_mount return code handling

2020-06-16 Thread Heiko Thiery
From: Thomas Schaefer 

- Despite other ext4 filesystem functions, ext4fs_mount returns
  0 in case of error.
- This leads to u-boot crash in case that an SD card
  with valid partition table but without ext4 filesystem created
  in a partition is found on SD card.
- Fix this by returning a proper error code of '-1' from spl_load_image_ext
  function in case of ext4fs_mount error.

Signed-off-by: Thomas Schaefer 
[hthiery: slightly reword the commit message]
Signed-off-by: Heiko Thiery 
---
 common/spl/spl_ext.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 3898041d10..c8d137ed98 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -32,6 +32,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: ext4fs mount err - %d\n", __func__, err);
 #endif
+   err = -1; /* ext4fs_mount returns 0 in case of error! */
goto end;
}
 
-- 
2.20.1



[PATCH v3] arm: socfpga: add board support for ic-automation moritz III

2020-06-16 Thread Nico Becker
Changes for v3:
- Resend via git send-email
Changes for v2:
- Coding Style cleanup

Signed-off-by: Nico Becker 
---
 arch/arm/dts/Makefile |   3 +-
 ...ocfpga_cyclone5_ica_moritz_iii-u-boot.dtsi |  45 ++
 .../dts/socfpga_cyclone5_ica_moritz_iii.dts   | 123 
 arch/arm/mach-socfpga/Kconfig |   8 +
 board/ic-automation/moritz_iii/MAINTAINERS|   8 +
 board/ic-automation/moritz_iii/Makefile   |   8 +
 .../moritz_iii/moritz_iii_board.c | 126 
 .../moritz_iii/qts/iocsr_config.h | 658 ++
 .../moritz_iii/qts/pinmux_config.h| 218 ++
 .../ic-automation/moritz_iii/qts/pll_config.h |  83 +++
 .../moritz_iii/qts/sdram_config.h | 344 +
 board/ic-automation/moritz_iii/socfpga.c  |   5 +
 configs/socfpga_moritz_iii_defconfig  |  74 ++
 include/configs/socfpga_ica_moritz_iii.h  |  46 ++
 14 files changed, 1748 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts
 create mode 100644 board/ic-automation/moritz_iii/MAINTAINERS
 create mode 100644 board/ic-automation/moritz_iii/Makefile
 create mode 100644 board/ic-automation/moritz_iii/moritz_iii_board.c
 create mode 100644 board/ic-automation/moritz_iii/qts/iocsr_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/pinmux_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/pll_config.h
 create mode 100644 board/ic-automation/moritz_iii/qts/sdram_config.h
 create mode 100644 board/ic-automation/moritz_iii/socfpga.c
 create mode 100644 configs/socfpga_moritz_iii_defconfig
 create mode 100644 include/configs/socfpga_ica_moritz_iii.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9900b44274..198ad36686 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -356,7 +356,8 @@ dtb-$(CONFIG_ARCH_SOCFPGA) +=   
\
socfpga_cyclone5_socrates.dtb   \
socfpga_cyclone5_sr1500.dtb \
socfpga_cyclone5_vining_fpga.dtb\
-   socfpga_stratix10_socdk.dtb
+   socfpga_stratix10_socdk.dtb \
+   socfpga_cyclone5_ica_moritz_iii.dtb
 
 dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb  \
dra72-evm-revc.dtb dra71-evm.dtb dra76-evm.dtb
diff --git a/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi 
b/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi
new file mode 100644
index 00..3ba01d1fd9
--- /dev/null
+++ b/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii-u-boot.dtsi
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * U-Boot additions
+ *
+ * Copyright (C) 2012 Altera Corporation 
+ * Copyright (c) 2018 Simon Goldschmidt
+ */
+
+#include "socfpga-common-u-boot.dtsi"
+
+/{
+   aliases {
+   spi0 = "/soc/spi@ff705000";
+   udc0 = &usb1;
+   };
+};
+
+&watchdog0 {
+   status = "disabled";
+};
+
+&mmc {
+   u-boot,dm-pre-reloc;
+};
+
+&qspi {
+   u-boot,dm-pre-reloc;
+};
+
+&uart0 {
+   clock-frequency = <1>;
+   u-boot,dm-pre-reloc;
+};
+
+&porta {
+   bank-name = "porta";
+};
+
+&portb {
+   bank-name = "portb";
+};
+
+&portc {
+   bank-name = "portc";
+};
diff --git a/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts 
b/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts
new file mode 100644
index 00..d81f8ea5bf
--- /dev/null
+++ b/arch/arm/dts/socfpga_cyclone5_ica_moritz_iii.dts
@@ -0,0 +1,123 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2020 Nico Becker ic-automation GmbH 

+ */
+
+#include "socfpga_cyclone5.dtsi"
+
+/ {
+   model = "ic-automation Moritz III";
+   compatible = "ic-automation,moritz_iii", "altr,socfpga-cyclone5", 
"altr,socfpga";
+
+   chosen {
+   bootargs = "earlyprintk";
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   name = "memory";
+   device_type = "memory";
+   reg = <0x0 0x4000>; /* 1GB */
+   };
+
+   aliases {
+   /* this allow the ethaddr uboot environmnet variable contents
+* to be added to the gmac1 device tree blob.
+*/
+   ethernet0 = &gmac1;
+   };
+
+  fpga_bridge3: fpga_bridge@ffc25080 {
+   compatible = "altr,socfpga-fpga2sdram-bridge";
+   reg = <0xffc25080 0x4>;
+   };
+
+   regulator_3_3v: 3-3-v-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "3.3V";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   };
+};
+
+&gmac1 {
+   status = "okay";
+   phy-mode = "rgmii";
+
+   rxd0-skew-ps = <0>;
+   rxd1

Re: [PATCH v2 12/23] logicpd: Drop omap3 zoom1

2020-06-16 Thread Nishanth Menon
On 23:45-20200613, Jagan Teki wrote:
> On Wed, May 27, 2020 at 6:27 PM Jagan Teki  wrote:
> >
> > OF_CONTROL, DM_SPI and other driver model migration deadlines
> > are expired for this board.
> >
> > Drop it.
> >
> > Cc: Nishanth Menon 
> 
> Any comments?
I think this should be fine. OMAP3 ES1.0 on which zoom1 was based on,
  has'nt had users for some time.

  If there are any specific user still wanting to keep this platform
  alive, please speak up.

-- 
Regards,
Nishanth Menon


Re: [PATCH] regulator: fix: enable gpio when requested

2020-06-16 Thread Tom Rini
On Mon, Apr 27, 2020 at 11:09:47AM +0200, Mark Kettenis wrote:

> The fix in commit b7adcdd073c0 has the side-effect that the regulator
> will be disabled when requesting the relevant gpio in
> regulator_common_ofdata_to_platdata() and enabled in
> regulator_pre_probe() when the regulator was already enabled.
> This leads to a short interruption in the 3.3V power to the PCIe
> slot on the firefly-rk3399 which makes an ADATA SX8000NP NVMe SSD
> unhappy.
> 
> Fix this by setting the GPIOD_IS_OUT_ACTIVE flag again when the
> 'regulator-boot-on' property is set, but check for this property
> explicitly instead of relying on the "boot_on" member of
> the uclass platdata.
> 
> Signed-off-by: Mark Kettenis 
> Tested-by: Patrice Chotard 

So, before this patch, my i.MX6D cuboxi platform with FEC ethernet does
not work (dhcp never gets an IP) nor does it work after this patch, and
I'm going to bisect things as it did work as of commit d8a3f5259a36
("Merge tag 'u-boot-imx-20200107' of
https://gitlab.denx.de/u-boot/custodians/u-boot-imx";).  As Lukasz's
concern is that this will break things like FEC ethernet, I believe what
I see is enough datapoints to say that the area in question needs more
investigation.  A follow-up patch from someone that tests multiple
platforms where we know we have seen oddities (firefly-rk3399, whatever
i.MX platform Lukasz was using, cuboxi) seems needed.  With that said:

Applied to u-boot/master now as it fixes some known issues and is
suspected but not confirmed to not break what b7adcdd073c0 was
addressing.

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request for UEFI sub-system for efi-2020-07-rc5

2020-06-16 Thread Tom Rini
On Mon, Jun 15, 2020 at 09:31:19PM +0200, Heinrich Schuchardt wrote:

> The following changes since commit 9d886fd6a0888f121cd280d11434812a386045a2:
> 
>   Merge https://gitlab.denx.de/u-boot/custodians/u-boot-spi (2020-06-12
> 17:20:35 -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2020-07-rc5
> 
> for you to fetch changes up to 4bb4249b39ce7284408c4d604a656be941427e63:
> 
>   efi_loader: printf code in efi_image_parse() (2020-06-14 21:07:20 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 01/10] dtoc: add support to scan drivers

2020-06-16 Thread Simon Glass
Hi Walter,

On Fri, 12 Jun 2020 at 11:38, Walter Lozano  wrote:
>
>
> On 11/6/20 23:22, Simon Glass wrote:
> > Hi Walter,
> >
> > On Thu, 11 Jun 2020 at 13:07, Walter Lozano  
> > wrote:
> >> Hi Simon,
> >>
> >> On 11/6/20 14:22, Simon Glass wrote:
> >>> Hi Walter,
> >>>
> >>> On Thu, 11 Jun 2020 at 11:11, Walter Lozano  
> >>> wrote:
>  Hi Simon
> 
>  On 11/6/20 13:45, Simon Glass wrote:
> > Hi Walter,
> >
> > On Mon, 8 Jun 2020 at 09:49, Walter Lozano 
> >  wrote:
> >> Hi Simon,
> >>
> >> On 4/6/20 12:59, Simon Glass wrote:
> >>> Hi Walter,
> >>>
> >>> On Fri, 29 May 2020 at 12:15, Walter Lozano 
> >>>  wrote:
>  Currently dtoc scans dtbs to convert them to struct platdata and
>  to generate U_BOOT_DEVICE entries. These entries need to be filled
>  with the driver name, but at this moment the information used is the
>  compatible name present in the dtb. This causes that only nodes with
>  a compatible name that matches a driver name generate a working
>  entry.
> 
>  In order to improve this behaviour, this patch adds to dtoc the
>  capability of scan drivers source code to generate a list of valid 
>  driver
>  names. This allows to rise a warning in the case that an 
>  U_BOOT_DEVICE
>  entry will try to use a name not valid.
> 
>  Additionally, in order to add more flexibility to the solution, adds 
>  the
>  U_BOOT_DRIVER_ALIAS macro, which generates no code at all, but 
>  allows an
>  easy way to declare driver name aliases. Thanks to this, dtoc can 
>  look
>  for the driver name based on its alias when it populates the 
>  U_BOOT_DEVICE
>  entry.
> 
>  Signed-off-by: Walter Lozano 
>  ---
>   include/dm/device.h|  7 
>   tools/dtoc/dtb_platdata.py | 83 
>  --
>   2 files changed, 86 insertions(+), 4 deletions(-)
> 
>  diff --git a/include/dm/device.h b/include/dm/device.h
>  index 975eec5d0e..2cfe10766f 100644
>  --- a/include/dm/device.h
>  +++ b/include/dm/device.h
>  @@ -282,6 +282,13 @@ struct driver {
>   #define DM_GET_DRIVER(__name)   
> \
>  ll_entry_get(struct driver, __name, driver)
> 
>  +/**
>  + * Declare a macro to state a alias for a driver name. This macro 
>  will
>  + * produce no code but its information will be parsed by tools like
>  + * dtoc
>  + */
>  +#define U_BOOT_DRIVER_ALIAS(__name, __alias)
>  +
>   /**
>    * dev_get_platdata() - Get the platform data for a device
>    *
>  diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
>  index ecfe0624d1..23cfda2f88 100644
>  --- a/tools/dtoc/dtb_platdata.py
>  +++ b/tools/dtoc/dtb_platdata.py
>  @@ -13,6 +13,8 @@ static data.
> 
>   import collections
>   import copy
>  +import os
>  +import re
>   import sys
> 
>   from dtoc import fdt
>  @@ -140,6 +142,9 @@ class DtbPlatdata(object):
>   _include_disabled: true to include nodes marked status 
>  = "disabled"
>   _outfile: The current output file (sys.stdout or a real 
>  file)
>   _lines: Stashed list of output lines for outputting in 
>  the future
>  +_aliases: Dict that hold aliases for compatible strings
> >>> key: The driver name, i.e. the part between brackets in 
> >>> U_BOOT_DRIVER(xx)  ??
> >>> value: ...
> >> Noted.
>  +_drivers: List of valid driver names found in drivers/
>  +_driver_aliases: Dict that holds aliases for driver names
> >>> key:
> >>> vaue:
> >> OK.
>   """
>   def __init__(self, dtb_fname, include_disabled):
>   self._fdt = None
>  @@ -149,6 +154,35 @@ class DtbPlatdata(object):
>   self._outfile = None
>   self._lines = []
>   self._aliases = {}
>  +self._drivers = []
>  +self._driver_aliases = {}
>  +
>  +def get_normalized_compat_name(self, node):
>  +"""Get a node's normalized compat name
>  +
>  +Returns a valid driver name by retrieving node's first 
>  compatible
>  +string as a C identifier and perfomrming a check against 
>  _drivers
> >>> performing
> >> Noted.
>  +and a lookup in driver_alias

Re: [PATCH v2] i2c: eeprom: Use reg property instead of offset and size

2020-06-16 Thread Simon Glass
On Mon, 15 Jun 2020 at 07:41, Michal Simek  wrote:
>
> Remove adhoc dt binding for fixed-partition definition for i2c eeprom.
> fixed-partition are using reg property instead of offset/size pair.
>
> Signed-off-by: Michal Simek 
> ---
>
> Changes in v2:
> - Bootcount tested on zynqmp zcu104
> - Add missing address/size cells
> - Use dev_read_addr_size_index
> - Check parameters
>
> Just build tested - ge_bx50v3_defconfig
> Definitely please retest on hardware.
>
> ---
>  arch/arm/dts/imx53-ppd-uboot.dtsi| 15 +--
>  arch/arm/dts/imx6q-bx50v3-uboot.dtsi | 12 +++-
>  drivers/misc/i2c_eeprom.c| 20 ++--
>  3 files changed, 26 insertions(+), 21 deletions(-)
>

We have a sandbox I2C EEPROM, so you should be able to use the
existing test, right?

REgards,
Simon


Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge

2020-06-16 Thread Simon Glass
Hi Nicolas,

On Fri, 12 Jun 2020 at 10:47, Nicolas Saenz Julienne
 wrote:
>
> There is no distinction in DT between the PCI controller device and the
> root bridge, whereas such distinction exists from dm's perspective. Make
> sure the root bridge ofnode is assigned to the controller's platform
> device node.
>
> This permits setups like this to work correctly:
>
> pcie {
> compatible = "...";
> ...
> dev {
> reg = <0 0 0 0 0>;
> ...
> };
> };
>
> Without this the dev node is assigned to the root bridge and the
> actual device search starts one level lower than expected.
>
> Signed-off-by: Nicolas Saenz Julienne 
> ---
>  drivers/pci/pci-uclass.c | 15 ++-
>  1 file changed, 14 insertions(+), 1 deletion(-)

Can you update the tests to handle this case please?

Regards,
Simon


Re: [PATCH v2 29/49] tegra: Drop the unused non-binman code

2020-06-16 Thread Simon Glass
Hi Stephen,

On Mon, 15 Jun 2020 at 16:03, Stephen Warren  wrote:
>
> On 6/13/20 8:57 PM, Simon Glass wrote:
> > This has been in the Makefile long enough to ensure migration is complete.
> > Drop it.
>
> > diff --git a/Makefile b/Makefile
>
> > -OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary 
> > --pad-to=$(CONFIG_SYS_TEXT_BASE)
> > -u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot-nodtb.bin FORCE
> > - $(call if_changed,pad_cat)
> > -
> > -OBJCOPYFLAGS_u-boot-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
> > -u-boot-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
> > - $(call if_changed,pad_cat)
>
> I don't see any replacement rules for those two binaries. Is the intent
> to force all users not to use them any more; is that what "migration is
> complete" means? Note that there are users of these files, so if this
> change/series truly is removing them it will break those users; see:
>
> > https://github.com/NVIDIA/tegra-uboot-flasher-scripts/blob/master/build#L166

Binman produces all three images when run, so we don't need makefile
rules for them anymore. It still produces the files. But let me know
if there are any problems.

Migration complete just means that there was a reason we had to keep
these rules before, and I hope it has gone away.

Regards,
Simon


Re: [PATCH v2] i2c: eeprom: Use reg property instead of offset and size

2020-06-16 Thread Michal Simek



On 16. 06. 20 15:43, Simon Glass wrote:
> On Mon, 15 Jun 2020 at 07:41, Michal Simek  wrote:
>>
>> Remove adhoc dt binding for fixed-partition definition for i2c eeprom.
>> fixed-partition are using reg property instead of offset/size pair.
>>
>> Signed-off-by: Michal Simek 
>> ---
>>
>> Changes in v2:
>> - Bootcount tested on zynqmp zcu104
>> - Add missing address/size cells
>> - Use dev_read_addr_size_index
>> - Check parameters
>>
>> Just build tested - ge_bx50v3_defconfig
>> Definitely please retest on hardware.
>>
>> ---
>>  arch/arm/dts/imx53-ppd-uboot.dtsi| 15 +--
>>  arch/arm/dts/imx6q-bx50v3-uboot.dtsi | 12 +++-
>>  drivers/misc/i2c_eeprom.c| 20 ++--
>>  3 files changed, 26 insertions(+), 21 deletions(-)
>>
> 
> We have a sandbox I2C EEPROM, so you should be able to use the
> existing test, right?

The way how I have tested it was via drivers/bootcount/i2c-eeprom.c
driver which define which eeprom stores it.
Do you have any existing tests for bootcount done via sandbox?

If bootcount is not the right way to go then doing this code should be
better way. It means just define some partitions (0 size - for failure,
then proper range, proper write, write behind size for failure).

Thanks,
Michal



Re: [PATCH v2 1/6] crypto/fsl: make SEC%u status line consistent

2020-06-16 Thread Horia Geantă
On 6/4/2020 6:48 PM, Michael Walle wrote:
> Align the status line with all the other output in U-Boot.
> 
> Before the change:
> DDR3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
> SEC0: RNG instantiated
> WDT:   Started with servicing (60s timeout)
> 
> After the change:
> DDR3.9 GiB (DDR3, 32-bit, CL=11, ECC on)
> SEC0:  RNG instantiated
> WDT:   Started with servicing (60s timeout)
> 
> Signed-off-by: Michael Walle 
Reviewed-by: Horia Geantă 

Thanks,
Horia


Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge

2020-06-16 Thread Nicolas Saenz Julienne
On Tue, 2020-06-16 at 07:43 -0600, Simon Glass wrote:
> Hi Nicolas,
> 
> On Fri, 12 Jun 2020 at 10:47, Nicolas Saenz Julienne
>  wrote:
> > There is no distinction in DT between the PCI controller device and the
> > root bridge, whereas such distinction exists from dm's perspective. Make
> > sure the root bridge ofnode is assigned to the controller's platform
> > device node.
> > 
> > This permits setups like this to work correctly:
> > 
> > pcie {
> > compatible = "...";
> > ...
> > dev {
> > reg = <0 0 0 0 0>;
> > ...
> > };
> > };
> > 
> > Without this the dev node is assigned to the root bridge and the
> > actual device search starts one level lower than expected.
> > 
> > Signed-off-by: Nicolas Saenz Julienne 
> > ---
> >  drivers/pci/pci-uclass.c | 15 ++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> Can you update the tests to handle this case please?

I'd be glad to, but I'm not familiar with the test FW in u-booy, coud give me
some pointers on where/how to test this?

Regards,
Nicolas



signature.asc
Description: This is a digitally signed message part


Re: [PATCH] checkpatch: fix a false check against wchar/utf-16 string

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 02:43:07PM +0900, AKASHI Takahiro wrote:

> UEFI subsystem uses utf-16 string, but checkpatch.pl complains
> about any occurrences of L"xxx" which is definitely legal.
> So just suppress this kind of warning.
> Precautiously, we will check u"xxx" as well.
> 
> Signed-off-by: AKASHI Takahiro 
> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index edba36565167..b3697720787c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5462,7 +5462,7 @@ sub process {
>   }
>  
>  # concatenated string without spaces between elements
> - if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ 
> /[A-Za-z0-9_]$String/) {
> + if ($line =~ /$String[A-Za-z0-9_]/ || $line =~ 
> /([A-Za-z0-9_]+[Lu]|[A-Za-z0-9_]*[A-KM-Za-tv-z0-9_])$String/) {
>   if (CHK("CONCATENATED_STRING",
>   "Concatenated strings should use spaces between 
> elements\n" . $herecurr) &&
>   $fix) {

This looks like a generic checkpatch issue.  I think we're a little out
of sync with the kernel's v5.7 but this doesn't look to be fixed there
either.  Can you please submit it upstream?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v3 0/2] imx: support for conga-QMX8 board

2020-06-16 Thread Oliver Graute
Second patch is still needed for booting. Tipps to get rid of that patch would
be helpfull.

Between u-boot-imx-20200511 and u-boot-imx-20200609 something more is broken,
I run into this issue:

U-Boot 2020.07-rc3-2-gbf3f929aa6 (Jun 16 2020 - 14:36:58 +0200)

CPU:   NXP i.MX8QM RevB A53 at 1200 MHz

Model: Congatec QMX8 Qseven series
Board: conga-QMX8
Build: SCFW 494c97f3, SECO-FW d7523fe8, ATF 09c5cc9
Boot:  SD2
DRAM:  6 GiB
Device 'gpio@5d09': seq 0 is in use by 'gpio@5d08'
Device 'gpio@5d0a': seq 1 is in use by 'gpio@5d09'
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:serial@5a06
Out:   serial@5a06
Err:   serial@5a06
"Synchronous Abort" handler, esr 0x9604
elr: 8005cf48 lr : 80022f94 (reloc)
elr: fff22f48 lr : ffee8f94
x0 : fdaf3540 x1 : fff2d8a0
x2 :  x3 : 
x4 :  x5 : fdaf3540
x6 : fff068a8 x7 : fff3bca0
x8 : fdaf3ac0 x9 : 0008
x10: fdaecb30 x11: fdaefdd0
x12:  x13: 0200
x14: fdadebf8 x15: 
x16: 1080 x17: 
x18: fdae4da0 x19: 0002
x20: fff3b000 x21: 7fec6000
x22:  x23: 
x24:  x25: 
x26:  x27: 
x28:  x29: fdadfd90

Code: aa0503e4 17f2 aa0003e5 d283 (386368a4)
Resetting CPU ...

resetting ...


Oliver Graute (2):
  imx: support for conga-QMX8 board
  hack to boot with 2020.01

 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/imx8qm-cgtqmx8.dts | 427 +
 arch/arm/mach-imx/imx8/Kconfig  |   7 +
 board/congatec/cgtqmx8/Kconfig  |  14 +
 board/congatec/cgtqmx8/MAINTAINERS  |   6 +
 board/congatec/cgtqmx8/Makefile |  11 +
 board/congatec/cgtqmx8/README   |  46 +++
 board/congatec/cgtqmx8/cgtqmx8.c| 479 
 board/congatec/cgtqmx8/imximage.cfg |  21 ++
 board/congatec/cgtqmx8/spl.c|  76 +
 board/congatec/common/Kconfig   |  48 +++
 board/congatec/common/Makefile  |  23 ++
 board/congatec/common/mmc.c |  50 +++
 configs/cgtqmx8_defconfig   |  82 +
 drivers/core/device.c   |   7 +-
 include/configs/cgtqmx8.h   | 194 +++
 16 files changed, 1487 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/dts/imx8qm-cgtqmx8.dts
 create mode 100644 board/congatec/cgtqmx8/Kconfig
 create mode 100644 board/congatec/cgtqmx8/MAINTAINERS
 create mode 100644 board/congatec/cgtqmx8/Makefile
 create mode 100644 board/congatec/cgtqmx8/README
 create mode 100644 board/congatec/cgtqmx8/cgtqmx8.c
 create mode 100644 board/congatec/cgtqmx8/imximage.cfg
 create mode 100644 board/congatec/cgtqmx8/spl.c
 create mode 100644 board/congatec/common/Kconfig
 create mode 100644 board/congatec/common/Makefile
 create mode 100644 board/congatec/common/mmc.c
 create mode 100644 configs/cgtqmx8_defconfig
 create mode 100644 include/configs/cgtqmx8.h

-- 
2.17.1



[PATCH v3] imx: support for conga-QMX8 board

2020-06-16 Thread Oliver Graute
Add i.MX8QM qmx8 congatec board support

U-Boot 2020.04-2-g1ff5446a63 (Jun 16 2020 - 13:47:28 +0200)

CPU:   NXP i.MX8QM RevB A53 at 1200 MHz

Model: Congatec QMX8 Qseven series
Board: conga-QMX8
Build: SCFW 494c97f3, SECO-FW d7523fe8, ATF 09c5cc9
Boot:  SD2
DRAM:  6 GiB
Device 'gpio@5d09': seq 0 is in use by 'gpio@5d08'
Device 'gpio@5d0a': seq 1 is in use by 'gpio@5d09'
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:serial@5a06
Out:   serial@5a06
Err:   serial@5a06
switch to partitions #0, OK
mmc2 is current device
Net:   eth0: ethernet@5b04
Hit any key to stop autoboot:  0

Signed-off-by: Oliver Graute 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Simon Glass 
Cc: Ye Li 
Cc: uboot-imx 
---
 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/imx8qm-cgtqmx8.dts | 427 +
 arch/arm/mach-imx/imx8/Kconfig  |   7 +
 board/congatec/cgtqmx8/Kconfig  |  14 +
 board/congatec/cgtqmx8/MAINTAINERS  |   6 +
 board/congatec/cgtqmx8/Makefile |  11 +
 board/congatec/cgtqmx8/README   |  57 
 board/congatec/cgtqmx8/cgtqmx8.c| 478 
 board/congatec/cgtqmx8/imximage.cfg |  21 ++
 board/congatec/cgtqmx8/spl.c|  76 +
 board/congatec/common/Kconfig   |  48 +++
 board/congatec/common/Makefile  |  23 ++
 board/congatec/common/mmc.c |  50 +++
 configs/cgtqmx8_defconfig   |  82 +
 include/configs/cgtqmx8.h   | 194 +++
 15 files changed, 1454 insertions(+)
 create mode 100644 arch/arm/dts/imx8qm-cgtqmx8.dts
 create mode 100644 board/congatec/cgtqmx8/Kconfig
 create mode 100644 board/congatec/cgtqmx8/MAINTAINERS
 create mode 100644 board/congatec/cgtqmx8/Makefile
 create mode 100644 board/congatec/cgtqmx8/README
 create mode 100644 board/congatec/cgtqmx8/cgtqmx8.c
 create mode 100644 board/congatec/cgtqmx8/imximage.cfg
 create mode 100644 board/congatec/cgtqmx8/spl.c
 create mode 100644 board/congatec/common/Kconfig
 create mode 100644 board/congatec/common/Makefile
 create mode 100644 board/congatec/common/mmc.c
 create mode 100644 configs/cgtqmx8_defconfig
 create mode 100644 include/configs/cgtqmx8.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9900b44274..6eb6399468 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -735,6 +735,7 @@ dtb-$(CONFIG_ARCH_MX7ULP) += imx7ulp-com.dtb \
 dtb-$(CONFIG_ARCH_IMX8) += \
fsl-imx8qm-apalis.dtb \
fsl-imx8qm-mek.dtb \
+   imx8qm-cgtqmx8.dtb \
imx8qm-rom7720-a1.dtb \
fsl-imx8qxp-ai_ml.dtb \
fsl-imx8qxp-colibri.dtb \
diff --git a/arch/arm/dts/imx8qm-cgtqmx8.dts b/arch/arm/dts/imx8qm-cgtqmx8.dts
new file mode 100644
index 00..43334147bb
--- /dev/null
+++ b/arch/arm/dts/imx8qm-cgtqmx8.dts
@@ -0,0 +1,427 @@
+// SPDX-License-Identifier:GPL-2.0+
+/*
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
+ * Copyright 2017 congatec AG
+ * Copyright (C) 2019 Oliver Graute 
+ */
+
+/dts-v1/;
+
+/* First 128KB is for PSCI ATF. */
+/memreserve/ 0x8000 0x0002;
+
+#include "fsl-imx8qm.dtsi"
+
+/ {
+   model = "Congatec QMX8 Qseven series";
+   compatible = "fsl,imx8qm-qmx8", "fsl,imx8qm";
+
+   chosen {
+   bootargs = "console=ttyLP0,115200 
earlycon=lpuart32,0x5a06,115200";
+   stdout-path = &lpuart0;
+   };
+
+   regulators {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   reg_usdhc2_vmmc: usdhc2_vmmc {
+   compatible = "regulator-fixed";
+   regulator-name = "sw-3p3-sd1";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = <&gpio4 7 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   off-on-delay-us = <3000>;
+   };
+
+   reg_usdhc3_vmmc: usdhc3_vmmc {
+   compatible = "regulator-fixed";
+   regulator-name = "sw-3p3-sd2";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   gpio = <&gpio4 9 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   off-on-delay-us = <3000>;
+   };
+   };
+};
+
+&fec1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_fec1>;
+   phy-mode = "rgmii";
+   phy-handle = <ðphy0>;
+   fsl,magic-packet;
+   fsl,rgmii_txc_dly;
+   fsl,rgmii_rxc_dly;
+   status = "okay";
+
+   mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@6 {
+   compatible = "ethernet-phy-ieee802.3-c22";
+   reg = <6>;

[PATCH 2/2] hack to boot with 2020.01

2020-06-16 Thread Oliver Graute
As proposed here:

https://lists.denx.de/pipermail/u-boot/2020-January/396749.html

Both of my imx8qm boards (Advantech and Congatec) aren't booting
2020.01 without this change. Whats the proper way to fix this on my side?
---
 drivers/core/device.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index a7408d9c76..2bff618f6c 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -448,11 +448,8 @@ int device_probe(struct udevice *dev)
 
if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent &&
(device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) &&
-   !(drv->flags & DM_FLAG_DEFAULT_PD_CTRL_OFF)) {
-   ret = dev_power_domain_on(dev);
-   if (ret)
-   goto fail;
-   }
+   !(drv->flags & DM_FLAG_DEFAULT_PD_CTRL_OFF))
+   dev_power_domain_on(dev);
 
ret = uclass_pre_probe_device(dev);
if (ret)
-- 
2.17.1



[PATCH] checkpatch.pl: Fully re-sync with v5.7

2020-06-16 Thread Tom Rini
While commit 048a648298b1 ("checkpatch.pl: Update to v5.7") largely
re-syncs us with checkpatch.pl from v5.7 there are a number of things
missing still.  Re-copy the script and again take care to keep our
allowed debug prints and now localized checks intact.

Fixes: 048a648298b1 ("checkpatch.pl: Update to v5.7")
Signed-off-by: Tom Rini 
---
 scripts/checkpatch.pl | 408 +++---
 1 file changed, 302 insertions(+), 106 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index edba36565167..9544e57352b3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -62,7 +62,10 @@ my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
 my $u_boot = 0;
 my $color = "auto";
-my $allow_c99_comments = 1;
+my $allow_c99_comments = 1; # Can be overridden by --ignore 
C99_COMMENT_TOLERANCE
+# git output parsing needs US English output, so first set backtick child 
process LANGUAGE
+my $git_command ='export LANGUAGE=en_US.UTF-8; git';
+my $tabsize = 8;
 
 sub help {
my ($exitcode) = @_;
@@ -99,6 +102,7 @@ Options:
  if exceeded, warn on patches
  requires --strict for use with --file
   --min-conf-desc-length=n   set the min description length, if shorter, warn
+  --tab-size=n   set the number of spaces for tab (default 
$tabsize)
   --root=PATHPATH to the kernel tree root
   --no-summary   suppress the per-file summary
   --mailback only produce a report in case of warnings/errors
@@ -217,6 +221,7 @@ GetOptions(
'list-types!'   => \$list_types,
'max-line-length=i' => \$max_line_length,
'min-conf-desc-length=i' => \$min_conf_desc_length,
+   'tab-size=i'=> \$tabsize,
'root=s'=> \$root,
'summary!'  => \$summary,
'mailback!' => \$mailback,
@@ -270,6 +275,9 @@ if ($color =~ /^[01]$/) {
die "Invalid color mode: $color\n";
 }
 
+# skip TAB size 1 to avoid additional checks on $tabsize - 1
+die "Invalid TAB size: $tabsize\n" if ($tabsize < 2);
+
 sub hash_save_array_words {
my ($hashRef, $arrayRef) = @_;
 
@@ -473,8 +481,19 @@ our $logFunctions = qr{(?x:
seq_vprintf|seq_printf|seq_puts
 )};
 
+our $allocFunctions = qr{(?x:
+   (?:(?:devm_)?
+   (?:kv|k|v)[czm]alloc(?:_node|_array)? |
+   kstrdup(?:_const)? |
+   kmemdup(?:_nul)?) |
+   (?:\w+)?alloc_skb(?:_ip_align)? |
+   # dev_alloc_skb/netdev_alloc_skb, et al
+   dma_alloc_coherent
+)};
+
 our $signature_tags = qr{(?xi:
Signed-off-by:|
+   Co-developed-by:|
Acked-by:|
Tested-by:|
Reviewed-by:|
@@ -580,6 +599,27 @@ foreach my $entry (@mode_permission_funcs) {
 }
 $mode_perms_search = "(?:${mode_perms_search})";
 
+our %deprecated_apis = (
+   "synchronize_rcu_bh"=> "synchronize_rcu",
+   "synchronize_rcu_bh_expedited"  => "synchronize_rcu_expedited",
+   "call_rcu_bh"   => "call_rcu",
+   "rcu_barrier_bh"=> "rcu_barrier",
+   "synchronize_sched" => "synchronize_rcu",
+   "synchronize_sched_expedited"   => "synchronize_rcu_expedited",
+   "call_rcu_sched"=> "call_rcu",
+   "rcu_barrier_sched" => "rcu_barrier",
+   "get_state_synchronize_sched"   => "get_state_synchronize_rcu",
+   "cond_synchronize_sched"=> "cond_synchronize_rcu",
+);
+
+#Create a search pattern for all these strings to speed up a loop below
+our $deprecated_apis_search = "";
+foreach my $entry (keys %deprecated_apis) {
+   $deprecated_apis_search .= '|' if ($deprecated_apis_search ne "");
+   $deprecated_apis_search .= $entry;
+}
+$deprecated_apis_search = "(?:${deprecated_apis_search})";
+
 our $mode_perms_world_writable = qr{
S_IWUGO |
S_IWOTH |
@@ -777,12 +817,12 @@ sub build_types {
  }x;
$Type   = qr{
$NonptrType
-   
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
+   
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
(?:\s+$Inline|\s+$Modifier)*
  }x;
$TypeMisordered = qr{
$NonptrTypeMisordered
-   
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
+   
(?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
(?:\s+$Inline|\s+$Modifier)*
  }x;
$Declare= qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
@@ -847,14 +887,18 @@ sub seed_camelcase_file {
}
 }
 
+our %maintained_status = ();
+
 

Re: [PATCH 1/1] spl: fix ext4fs_mount return code handling

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 01:59:03PM +0200, Heiko Thiery wrote:

> From: Thomas Schaefer 
> 
> - Despite other ext4 filesystem functions, ext4fs_mount returns
>   0 in case of error.
> - This leads to u-boot crash in case that an SD card
>   with valid partition table but without ext4 filesystem created
>   in a partition is found on SD card.
> - Fix this by returning a proper error code of '-1' from spl_load_image_ext
>   function in case of ext4fs_mount error.
> 
> Signed-off-by: Thomas Schaefer 
> [hthiery: slightly reword the commit message]
> Signed-off-by: Heiko Thiery 
> ---
>  common/spl/spl_ext.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
> index 3898041d10..c8d137ed98 100644
> --- a/common/spl/spl_ext.c
> +++ b/common/spl/spl_ext.c
> @@ -32,6 +32,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
>  #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
>   printf("%s: ext4fs mount err - %d\n", __func__, err);
>  #endif
> + err = -1; /* ext4fs_mount returns 0 in case of error! */
>   goto end;
>   }

Looking over the code, we should return -1 directly here, goto end isn't
going to provide more useful information as we don't have a "real" error
code to tell the user.  With that change please add:

Reviewed-by: Tom Rini 

and post v2, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/2] hack to boot with 2020.01

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 04:27:22PM +0200, Oliver Graute wrote:

> As proposed here:
> 
> https://lists.denx.de/pipermail/u-boot/2020-January/396749.html
> 
> Both of my imx8qm boards (Advantech and Congatec) aren't booting
> 2020.01 without this change. Whats the proper way to fix this on my side?

Did you mean to say something newer than that?  I thought something
around here had finally been debugged and fixed at least in some of the
failing cases.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] common: hash: Remove a debug printf statement

2020-06-16 Thread Tom Rini
On Mon, Jun 15, 2020 at 09:47:04AM +0200, Harald Seiler wrote:

> Remove a left-over debug printf that was introduced with SHA512 support.
> 
> Fixes: d16b38f42704 ("Add support for SHA384 and SHA512")
> Signed-off-by: Harald Seiler 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] ARM: dts: stm32: add reset support to uart nodes on stm32mp15x

2020-06-16 Thread Patrick Delaunay
STM32 serial can be reset via reset controller.
Add the support of reset to uart nodes on stm32mp15x.

Signed-off-by: Patrick Delaunay 
---

 arch/arm/dts/stm32mp15-u-boot.dtsi | 32 ++
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-u-boot.dtsi 
b/arch/arm/dts/stm32mp15-u-boot.dtsi
index 1279589a56..39591ec202 100644
--- a/arch/arm/dts/stm32mp15-u-boot.dtsi
+++ b/arch/arm/dts/stm32mp15-u-boot.dtsi
@@ -175,6 +175,38 @@
compatible = "st,stm32-sdmmc2", "arm,pl18x", "arm,primecell";
 };
 
+&usart1 {
+   resets = <&rcc USART1_R>;
+};
+
+&usart2 {
+   resets = <&rcc USART2_R>;
+};
+
+&usart3 {
+   resets = <&rcc USART3_R>;
+};
+
+&uart4 {
+   resets = <&rcc UART4_R>;
+};
+
+&uart5 {
+   resets = <&rcc UART5_R>;
+};
+
+&usart6 {
+   resets = <&rcc USART6_R>;
+};
+
+&uart7 {
+   resets = <&rcc UART7_R>;
+};
+
+&uart8{
+   resets = <&rcc UART8_R>;
+};
+
 &usbotg_hs {
compatible = "st,stm32mp1-hsotg", "snps,dwc2";
 };
-- 
2.17.1



[PATCH] power: axp209: Limit inrush current for A20-OLinuXino_MICRO

2020-06-16 Thread Cédric Félizard
This commit enables the work done in commit ef52605e for the
A20-OLinuXino_MICRO{,-eMMC} boards. It was previously used only for the
A20-OLinuXino-Lime2{,-eMMC} boards but is also needed for the MICRO
boards. Without this, the board consistently hangs upon reboot. Note
that a cold boot works fine though.

I don't have -eMMC board variant to double check but the quirk is most
likely present as well so I patched
configs/A20-OLinuXino_MICRO-eMMC_defconfig too.

The issue occurs with revision G of the board and most likely previous
revisions as well since the faulty capacitance on LDO3's output hasn't
been modified since the initial release of the board.

Many thanks to Marex in #u-boot @ irc.freenode.net for helping me
debugging this.
---
 configs/A20-OLinuXino_MICRO-eMMC_defconfig | 1 +
 configs/A20-OLinuXino_MICRO_defconfig  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/A20-OLinuXino_MICRO-eMMC_defconfig 
b/configs/A20-OLinuXino_MICRO-eMMC_defconfig
index 3317aceef5..c2e810741c 100644
--- a/configs/A20-OLinuXino_MICRO-eMMC_defconfig
+++ b/configs/A20-OLinuXino_MICRO-eMMC_defconfig
@@ -19,6 +19,7 @@ CONFIG_MII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SUN7I_GMAC_FORCE_TXERR=y
 CONFIG_AXP_ALDO3_VOLT=2800
+CONFIG_AXP_ALDO3_INRUSH_QUIRK=y
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/A20-OLinuXino_MICRO_defconfig 
b/configs/A20-OLinuXino_MICRO_defconfig
index d5bb51ff26..e9269b2998 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -20,6 +20,7 @@ CONFIG_MII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SUN7I_GMAC_FORCE_TXERR=y
 CONFIG_AXP_ALDO3_VOLT=2800
+CONFIG_AXP_ALDO3_INRUSH_QUIRK=y
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
 CONFIG_USB_EHCI_HCD=y
-- 
2.27.0



Mainlining advice for new (MStar/SigmaStar) ARMv7 SoC family

2020-06-16 Thread Daniel Palmer
Hi all,

I'm attempting to get initial support for MStar/Sigmastar's family of
ARMv7 chips into Linux
and I thought I should probably at least attempt to mainling the
u-boot support while I'm at it.

I did some googling and couldn't find a "how to mainline a new SoC"
guide for u-boot so if
possible could I get some advice on how I should go about this.

Right now I have a very janky tree that can either piggy back the
vendor's second stage
bootloader (bootloader after bootrom) or on some of the chips produce
an SPL that can
run straight after the bootrom exits.

I need to chop it up into acceptable parts but I'm not sure how that would look.
For Linux I'm attempting to get in a small patch set[0] that adds the
initial device tree prefixes
and then adds just enough machine specific bits to get to a shell from
an initramfs.

For u-boot would enough to load a kernel very slowly via loady be a good target?
As the platform is device tree based do I need to wait until my
prefixes get accepted to even start?

Thanks,

Daniel

0 - 
https://lore.kernel.org/linux-arm-kernel/20200616121525.1409790-1-dan...@0x0f.com/


Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread David Woodhouse
The Banana Pi R2 bootloader will load U-Boot from either the internal
eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both
work from U-Boot. Both also work from Linux, whichever device is booted
from.

If booted from SD, the internal eMMC cannot be accessed from U-Boot.
This makes it slightly difficult for me to write a U-Boot script which
installs OpenWRT from the SD card to the internal eMMC...


From SD:

U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100) 

CPU:   MediaTek MT7623 E3   
DRAM:  2 GiB
WDT:   Started with servicing (60s timeout) 
MMC:   mmc@1123: 0, mmc@1124: 1 
Loading Environment from FAT... ** No device specified **   
## Warning: Unknown environment variable type 'i'   
## Warning: Unknown environment variable type 'i'   
## Warning: Unknown environment variable type 'i'   
In:serial   
Out:   serial   
Err:   serial   
Hit any key to stop autoboot:  0
U-Boot> mmc list
mmc@1123: 0 
mmc@1124: 1 
U-Boot> mmc dev 0   
CMD_SEND:0  
ARG  0x 
MMC_RSP_NONE
CMD_SEND:8  
ARG  0x01aa 
RET  -110   
CMD_SEND:55 
ARG  0x 
RET  -110   
CMD_SEND:0  
ARG  0x 
MMC_RSP_NONE
CMD_SEND:1  
ARG  0x 
MMC_RSP_R3,4 0x 
CMD_SEND:2  
ARG  0x 
RET  -110   
U-Boot> mmc dev 1   
CMD_SEND:0  
ARG  0x 
MMC_RSP_NONE
CMD_SEND:8  
ARG  0x01aa 
MMC_RSP_R1,5,6,7 0x01aa 
CMD_SEND:55 
ARG  0x 
MMC_RSP_R1,5,6,7 0x0120 
CMD_SEND:41 
ARG  0x4030 
MMC_RSP_R3,4 0x00ff8000 
CMD_SEND:55 
ARG  0x 
MMC_RSP_R1,5,6,7 0x0120 
CMD_SEND:41 
ARG  0x4030 
MMC_RSP_R3,4 0x80ff8000 
CMD_SEND:2  

[PATCH] board: st: stm32mp1: increase teed partition

2020-06-16 Thread Patrick Delaunay
With TEE 3.7.0, the partition teed (OP-TEE pageable
code and data) need to increase up to 512KB in NOR device.

Signed-off-by: Patrick Delaunay 
---

 board/st/common/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/st/common/Kconfig b/board/st/common/Kconfig
index 015ba40939..750dbb6451 100644
--- a/board/st/common/Kconfig
+++ b/board/st/common/Kconfig
@@ -39,7 +39,7 @@ config MTDPARTS_NOR0_BOOT
 
 config MTDPARTS_NOR0_TEE
string "mtd tee partitions for nor0"
-   default "256k(teeh),256k(teed),256k(teex)"
+   default "256k(teeh),512k(teed),256k(teex)"
depends on SYS_MTDPARTS_RUNTIME && ARCH_STM32MP
help
  This define the tee partitions added in mtparts dynamically
-- 
2.17.1



Re: Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread Michael Nazzareno Trimarchi
Hi David

On Tue, Jun 16, 2020 at 6:16 PM David Woodhouse  wrote:
>
> The Banana Pi R2 bootloader will load U-Boot from either the internal
> eMMC, or the external SD card if the latter is present.
>
> If booted from the eMMC (and an SD card is subsequently inserted), both
> work from U-Boot. Both also work from Linux, whichever device is booted
> from.
>
> If booted from SD, the internal eMMC cannot be accessed from U-Boot.
> This makes it slightly difficult for me to write a U-Boot script which
> installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Michael

>
>
> From SD:
>
> U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100)
>
> CPU:   MediaTek MT7623 E3
> DRAM:  2 GiB
> WDT:   Started with servicing (60s timeout)
> MMC:   mmc@1123: 0, mmc@1124: 1
> Loading Environment from FAT... ** No device specified **
> ## Warning: Unknown environment variable type 'i'
> ## Warning: Unknown environment variable type 'i'
> ## Warning: Unknown environment variable type 'i'
> In:serial
> Out:   serial
> Err:   serial
> Hit any key to stop autoboot:  0
> U-Boot> mmc list
> mmc@1123: 0
> mmc@1124: 1
> U-Boot> mmc dev 0
> CMD_SEND:0
> ARG  0x
> MMC_RSP_NONE
> CMD_SEND:8
> ARG  0x01aa
> RET  -110
> CMD_SEND:55
> ARG  0x
> RET  -110
> CMD_SEND:0
> ARG  0x
> MMC_RSP_NONE
> CMD_SEND:1
> ARG  0x
> MMC_RSP_R3,4 0x
> CMD_SEND:2
> ARG  0x
> RET  -110
> U-Boot> mmc dev 1
> CMD_SEND:0
> ARG  0x
> MMC_RSP_NONE
> CMD_SEND:8
> ARG  0x01aa
> MMC_RSP_R1,5,6,7 0x01aa
> CMD_SEND:55
> ARG  0x
> MMC_RSP_R1,5,6,7 0x0120
> CMD_SEND:41
> ARG  0x4030
> MMC_RSP_R3,4 0x00ff8000
> CMD_SEND:55
> ARG  0x
> MMC_RSP_R1,5,6,7 0x0120
> CMD_SEND:41
> ARG  0x4030
> MMC_RSP_R3,4 0x80ff8000
> CMD_SEND:2
> ARG  0x
> MMC_RSP_R2   0x744a6055
>  0x53442020
>  0x104059f3
>  0x34013be5
>
> DUMPING DATA
> 000 - 74 4a 60 55
> 004 - 53 44 20 20
> 008 - 10 40 59 f3
> 012 - 34 01 3b e5
> CMD_SEND:3
> ARG  0x
> MMC_RSP_R1,5,6,7 0x59b40520
> CMD_SEND:9
> ARG  0x59b4
> MMC_RSP_R2   0x007f0032
>  0x5b5a83bd
>  0x6db7ff80
>  0x0a80008d
>
> DUMPING DATA
> 000 - 00 7f 00 32
> 004 - 5b 5a 83 bd
> 008 - 6d b7 ff 80
> 012 - 0a 80 00 8d
> CMD_SEND:7
> ARG  0x59b4
> MMC_RSP_R1,5,6,7 0x0700
> CMD_SEND:55
> ARG  0x59b4
> MMC_RSP_R1,5,6,7 0x0920
> CMD_SEND:51
> ARG  0x
> MMC_RSP_R1,5,6,7 0x0920
> CMD_SEND:6
> ARG  0x00f1
> MMC_RSP_R1,5,6,7 0x0900
> CMD_SEND:55
> ARG  0x59b4
> MMC_RSP_R1,5,6,7 0x0920
> CMD_SEND:6
> ARG  0x0002
> MMC_RSP_R1,5,6,7 0x0920
> CMD_SEND:6
> ARG  0x80f1
> MMC_RSP_R1,5,6,7 0x0900
> CMD_SEND:55
> ARG  0x59b4
> MMC_RSP_R1,5,6,7 0x0920
> CMD_SEND:13
> ARG  0x
> MMC_RSP_R1,5,6,7 0x00

[PATCH] arm: stm32mp: stm32prog: add "Device Name" in iproduct during DFU USB enumeration

2020-06-16 Thread Patrick Delaunay
Add "Device Name" in iproduct during DFU USB enumeration
to have this information in STM32CubeProgrammer trace
(this tools is compatible with @Name since v2.3)

Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c 
b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c
index 969245e199..30547f94c9 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c
@@ -197,10 +197,12 @@ bool stm32prog_usb_loop(struct stm32prog_data *data, int 
dev)
bool result;
/* USB download gadget for STM32 Programmer */
char product[128];
+   char name[SOC_NAME_SIZE];
 
+   get_soc_name(name);
snprintf(product, sizeof(product),
-"USB download gadget@Device ID /0x%03X, @Revision ID /0x%04X",
-get_cpu_dev(), get_cpu_rev());
+"USB download gadget@Device ID /0x%03X, @Revision ID /0x%04X, 
@Name /%s,",
+get_cpu_dev(), get_cpu_rev(), name);
g_dnl_set_product(product);
 
if (stm32prog_data->phase == PHASE_FLASHLAYOUT) {
-- 
2.17.1



[PATCH] arm: stm32mp: protect DBGMCU_IDC access with BSEC

2020-06-16 Thread Patrick Delaunay
As debugger must be totally closed on Sec closed chip,
the DBGMCU_IDC register is no more accessible (self
hosted debug is disabled with OTP).

This patch adds a function bsec_dbgswenable() to check
if the DBGMCU registers are available before to access them:
BSEC_DENABLE.DBGSWENABLE = self hosted debug status.

Signed-off-by: Patrick Delaunay 
---

 arch/arm/mach-stm32mp/bsec.c  | 25 +++
 arch/arm/mach-stm32mp/cpu.c   | 22 
 arch/arm/mach-stm32mp/include/mach/bsec.h |  7 +++
 3 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/bsec.h

diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index fc39230113..c4b33ff241 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -8,6 +8,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +22,7 @@
 #define BSEC_OTP_WRDATA_OFF0x008
 #define BSEC_OTP_STATUS_OFF0x00C
 #define BSEC_OTP_LOCK_OFF  0x010
+#define BSEC_DENABLE_OFF   0x014
 #define BSEC_DISTURBED_OFF 0x01C
 #define BSEC_ERROR_OFF 0x034
 #define BSEC_WRLOCK_OFF0x04C /* OTP write permananet 
lock */
@@ -46,6 +48,9 @@
 #define BSEC_MODE_PROGFAIL_MASK0x10
 #define BSEC_MODE_PWR_MASK 0x20
 
+/* DENABLE Register */
+#define BSEC_DENABLE_DBGSWENABLE   BIT(10)
+
 /*
  * OTP Lock services definition
  * Value must corresponding to the bit number in the register
@@ -505,3 +510,23 @@ U_BOOT_DRIVER(stm32mp_bsec) = {
.probe = stm32mp_bsec_probe,
 #endif
 };
+
+bool bsec_dbgswenable(void)
+{
+   struct udevice *dev;
+   struct stm32mp_bsec_platdata *plat;
+   int ret;
+
+   ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec), &dev);
+   if (ret || !dev) {
+   pr_debug("bsec driver not available\n");
+   return false;
+   }
+
+   plat = dev_get_platdata(dev);
+   if (readl(plat->base + BSEC_DENABLE_OFF) & BSEC_DENABLE_DBGSWENABLE)
+   return true;
+
+   return false;
+}
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 472b140321..382067190c 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -155,8 +156,13 @@ static void dbgmcu_init(void)
 {
setbits_le32(RCC_DBGCFGR, RCC_DBGCFGR_DBGCKEN);
 
-   /* Freeze IWDG2 if Cortex-A7 is in debug mode */
-   setbits_le32(DBGMCU_APB4FZ1, DBGMCU_APB4FZ1_IWDG2);
+   /*
+* Freeze IWDG2 if Cortex-A7 is in debug mode
+* done in TF-A for TRUSTED boot and
+* DBGMCU access is controlled by BSEC_DENABLE.DBGSWENABLE
+   */
+   if (!IS_ENABLED(CONFIG_TFABOOT) && bsec_dbgswenable())
+   setbits_le32(DBGMCU_APB4FZ1, DBGMCU_APB4FZ1_IWDG2);
 }
 #endif /* !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD) */
 
@@ -276,9 +282,17 @@ void enable_caches(void)
 
 static u32 read_idc(void)
 {
-   setbits_le32(RCC_DBGCFGR, RCC_DBGCFGR_DBGCKEN);
+   /* DBGMCU access is controlled by BSEC_DENABLE.DBGSWENABLE */
+   if (bsec_dbgswenable()) {
+   setbits_le32(RCC_DBGCFGR, RCC_DBGCFGR_DBGCKEN);
 
-   return readl(DBGMCU_IDC);
+   return readl(DBGMCU_IDC);
+   }
+
+   if (CONFIG_IS_ENABLED(STM32MP15x))
+   return CPU_DEV_STM32MP15; /* STM32MP15x and unknown revision */
+   else
+   return 0x0;
 }
 
 u32 get_cpu_dev(void)
diff --git a/arch/arm/mach-stm32mp/include/mach/bsec.h 
b/arch/arm/mach-stm32mp/include/mach/bsec.h
new file mode 100644
index 00..252eac3946
--- /dev/null
+++ b/arch/arm/mach-stm32mp/include/mach/bsec.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2020, STMicroelectronics - All Rights Reserved
+ */
+
+/* check self hosted debug status = BSEC_DENABLE.DBGSWENABLE */
+bool bsec_dbgswenable(void);
-- 
2.17.1



[PATCH] configs: stm32mp1: only support SD card after NOR in bootcmd_stm32mp

2020-06-16 Thread Patrick Delaunay
In the boot command used in ST boards, bootcmd_stm32mp, only support
the SD card as second stage, where is found the bootfs with DISTRO.

Signed-off-by: Patrick Delaunay 
---

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

diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h
index f271b84a59..baaf2ff89c 100644
--- a/include/configs/stm32mp1.h
+++ b/include/configs/stm32mp1.h
@@ -123,7 +123,7 @@
  * for serial/usb: execute the stm32prog command
  * for mmc boot (eMMC, SD card), boot only on the same device
  * for nand or spi-nand boot, boot with on ubifs partition on UBI partition
- * for nor boot, use the default order
+ * for nor boot, use SD card = mmc0
  */
 #define STM32MP_BOOTCMD "bootcmd_stm32mp=" \
"echo \"Boot over ${boot_device}${boot_instance}!\";" \
@@ -136,6 +136,8 @@
"if test ${boot_device} = nand ||" \
  " test ${boot_device} = spi-nand ;" \
"then env set boot_targets ubifs0; fi;" \
+   "if test ${boot_device} = nor;" \
+   "then env set boot_targets mmc0; fi;" \
"run distro_bootcmd;" \
"fi;\0"
 
-- 
2.17.1



Re: Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread David Woodhouse
On Tue, 2020-06-16 at 18:21 +0200, Michael Nazzareno Trimarchi wrote:
> Hi David
> 
> On Tue, Jun 16, 2020 at 6:16 PM David Woodhouse  wrote:
> > 
> > The Banana Pi R2 bootloader will load U-Boot from either the internal
> > eMMC, or the external SD card if the latter is present.
> > 
> > If booted from the eMMC (and an SD card is subsequently inserted), both
> > work from U-Boot. Both also work from Linux, whichever device is booted
> > from.
> > 
> > If booted from SD, the internal eMMC cannot be accessed from U-Boot.
> > This makes it slightly difficult for me to write a U-Boot script which
> > installs OpenWRT from the SD card to the internal eMMC...
> 
> I'm thinking that bootrom do the right job for you when both are working.

Yes. It does seem likely that when loading U-Boot from the eMMC, the
preloader is initialising it for us. But when the preloader loads
U-Boot from the SD card, it possibly doesn't initialise the eMMC
controller at all.

The Linux driver does cope with this, and drives the internal eMMC.
Perhaps there's just some init code missing from the U-Boot mtk-sd
driver?





smime.p7s
Description: S/MIME cryptographic signature


Re: Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread Michael Nazzareno Trimarchi
On Tue, Jun 16, 2020 at 6:57 PM David Woodhouse  wrote:
>
> On Tue, 2020-06-16 at 18:21 +0200, Michael Nazzareno Trimarchi wrote:
> > Hi David
> >
> > On Tue, Jun 16, 2020 at 6:16 PM David Woodhouse  wrote:
> > >
> > > The Banana Pi R2 bootloader will load U-Boot from either the internal
> > > eMMC, or the external SD card if the latter is present.
> > >
> > > If booted from the eMMC (and an SD card is subsequently inserted), both
> > > work from U-Boot. Both also work from Linux, whichever device is booted
> > > from.
> > >
> > > If booted from SD, the internal eMMC cannot be accessed from U-Boot.
> > > This makes it slightly difficult for me to write a U-Boot script which
> > > installs OpenWRT from the SD card to the internal eMMC...
> >
> > I'm thinking that bootrom do the right job for you when both are working.
>
> Yes. It does seem likely that when loading U-Boot from the eMMC, the
> preloader is initialising it for us. But when the preloader loads
> U-Boot from the SD card, it possibly doesn't initialise the eMMC
> controller at all.
>
> The Linux driver does cope with this, and drives the internal eMMC.
> Perhaps there's just some init code missing from the U-Boot mtk-sd
> driver?

what dts are you using and config? I don't find Banana PI R2

Micheal

>
>
>


-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |


Re: Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread David Woodhouse
On Tue, 2020-06-16 at 18:59 +0200, Michael Nazzareno Trimarchi wrote:
> On Tue, Jun 16, 2020 at 6:57 PM David Woodhouse  wrote:
> > 
> > On Tue, 2020-06-16 at 18:21 +0200, Michael Nazzareno Trimarchi wrote:
> > > Hi David
> > > 
> > > On Tue, Jun 16, 2020 at 6:16 PM David Woodhouse  
> > > wrote:
> > > > 
> > > > The Banana Pi R2 bootloader will load U-Boot from either the internal
> > > > eMMC, or the external SD card if the latter is present.
> > > > 
> > > > If booted from the eMMC (and an SD card is subsequently inserted), both
> > > > work from U-Boot. Both also work from Linux, whichever device is booted
> > > > from.
> > > > 
> > > > If booted from SD, the internal eMMC cannot be accessed from U-Boot.
> > > > This makes it slightly difficult for me to write a U-Boot script which
> > > > installs OpenWRT from the SD card to the internal eMMC...
> > > 
> > > I'm thinking that bootrom do the right job for you when both are working.
> > 
> > Yes. It does seem likely that when loading U-Boot from the eMMC, the
> > preloader is initialising it for us. But when the preloader loads
> > U-Boot from the SD card, it possibly doesn't initialise the eMMC
> > controller at all.
> > 
> > The Linux driver does cope with this, and drives the internal eMMC.
> > Perhaps there's just some init code missing from the U-Boot mtk-sd
> > driver?
> 
> what dts are you using and config? I don't find Banana PI R2

It's mt7623n_bpir2_defconfig


smime.p7s
Description: S/MIME cryptographic signature


Re: [PATCH v2 12/12] mips: octeon: Add minimal Octeon 3 EBB7304 EVK support

2020-06-16 Thread Daniel Schwierzeck



Am 14.05.20 um 11:59 schrieb Stefan Roese:
> This patch adds very basic minimal support for the Marvell Octeon 3
> CN73xx based EBB7304 EVK. Please note that the basic Octeon port does
> not support DDR3/4 initialization yet. To still use U-Boot on with this
> port, the L2 cache (4MiB) is used as RAM. This way, U-Boot can boot
> to the prompt on this board.
> 
> Supported devices:
> - UART
> - reset
> - CFI parallel NOR flash
> 
> Signed-off-by: Stefan Roese 
> 
> ---
> 
> Changes in v2:
> - Removed CONFIG_SYS_MIPS_TIMER_FREQ
> 
>  arch/mips/dts/Makefile   |  1 +
>  arch/mips/dts/mrvl,octeon-ebb7304.dts| 96 
>  arch/mips/mach-octeon/Kconfig| 14 
>  board/Marvell/octeon_ebb7304/Kconfig | 19 +
>  board/Marvell/octeon_ebb7304/MAINTAINERS |  7 ++
>  board/Marvell/octeon_ebb7304/Makefile|  8 ++
>  board/Marvell/octeon_ebb7304/board.c | 12 +++
>  configs/octeon_ebb7304_defconfig | 34 +
>  include/configs/octeon_common.h  | 25 ++
>  include/configs/octeon_ebb7304.h | 20 +
>  10 files changed, 236 insertions(+)
>  create mode 100644 arch/mips/dts/mrvl,octeon-ebb7304.dts
>  create mode 100644 board/Marvell/octeon_ebb7304/Kconfig
>  create mode 100644 board/Marvell/octeon_ebb7304/MAINTAINERS
>  create mode 100644 board/Marvell/octeon_ebb7304/Makefile
>  create mode 100644 board/Marvell/octeon_ebb7304/board.c
>  create mode 100644 configs/octeon_ebb7304_defconfig
>  create mode 100644 include/configs/octeon_common.h
>  create mode 100644 include/configs/octeon_ebb7304.h
> 
> diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
> index f711e9fb59..dc85901dca 100644
> --- a/arch/mips/dts/Makefile
> +++ b/arch/mips/dts/Makefile
> @@ -18,6 +18,7 @@ dtb-$(CONFIG_BOARD_COMTREND_VR3032U) += 
> comtrend,vr-3032u.dtb
>  dtb-$(CONFIG_BOARD_COMTREND_WAP5813N) += comtrend,wap-5813n.dtb
>  dtb-$(CONFIG_BOARD_HUAWEI_HG556A) += huawei,hg556a.dtb
>  dtb-$(CONFIG_BOARD_MT7628_RFB) += mediatek,mt7628-rfb.dtb
> +dtb-$(CONFIG_TARGET_OCTEON_EBB7304) += mrvl,octeon-ebb7304.dtb
>  dtb-$(CONFIG_BOARD_NETGEAR_CG3100D) += netgear,cg3100d.dtb
>  dtb-$(CONFIG_BOARD_NETGEAR_DGND3700V2) += netgear,dgnd3700v2.dtb
>  dtb-$(CONFIG_BOARD_SAGEM_FAST1704) += sagem,f...@st1704.dtb
> diff --git a/arch/mips/dts/mrvl,octeon-ebb7304.dts 
> b/arch/mips/dts/mrvl,octeon-ebb7304.dts
> new file mode 100644
> index 00..4e9c2de7d4
> --- /dev/null
> +++ b/arch/mips/dts/mrvl,octeon-ebb7304.dts
> @@ -0,0 +1,96 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Marvell / Cavium Inc. EVB CN7300
> + */
> +
> +/dts-v1/;
> +
> +/include/ "mrvl,cn73xx.dtsi"
> +
> +/ {
> + model = "cavium,ebb7304";
> + compatible = "cavium,ebb7304";
> +
> + aliases {
> + serial0 = &uart0;
> + };
> +
> + chosen {
> + stdout-path = &uart0;
> + };
> +};
> +
> +&bootbus {
> + /*
> +  * bootbus CS0 for CFI flash is remapped (0x1fc0. -> 1f40.)
> +  * as the initial size is too small for the 8MiB flash device
> +  */
> + ranges = <0 0  0   0x1f40  0xc0>,
> +  <1 0  0x1 0x1000  0>,
> +  <2 0  0x1 0x2000  0>,
> +  <3 0  0x1 0x3000  0>,
> +  <4 0  0   0x1d02  0x1>,
> +  <5 0  0x1 0x5000  0>,
> +  <6 0  0x1 0x6000  0>,
> +  <7 0  0x1 0x7000  0>;
> +
> + cavium,cs-config@0 {
> + compatible = "cavium,octeon-3860-bootbus-config";
> + cavium,cs-index = <0>;
> + cavium,t-adr  = <10>;
> + cavium,t-ce   = <50>;
> + cavium,t-oe   = <50>;
> + cavium,t-we   = <35>;
> + cavium,t-rd-hld = <25>;
> + cavium,t-wr-hld = <35>;
> + cavium,t-pause  = <0>;
> + cavium,t-wait   = <50>;
> + cavium,t-page   = <30>;
> + cavium,t-rd-dly = <0>;
> + cavium,page-mode = <1>;
> + cavium,pages = <8>;
> + cavium,bus-width = <8>;
> + };
> +
> + cavium,cs-config@4 {
> + compatible = "cavium,octeon-3860-bootbus-config";
> + cavium,cs-index = <4>;
> + cavium,t-adr  = <10>;
> + cavium,t-ce   = <10>;
> + cavium,t-oe   = <160>;
> + cavium,t-we   = <100>;
> + cavium,t-rd-hld = <10>;
> + cavium,t-wr-hld = <0>;
> + cavium,t-pause  = <50>;
> + cavium,t-wait   = <50>;
> + cavium,t-page   = <10>;
> + cavium,t-rd-dly = <10>;
> + cavium,pages = <0>;
> + cavium,bus-width = <8>;
> + };
> +
> + flash0: nor@0,0 {
> + compatible = "cfi-flash";
> + reg = <0 0 0x80>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + partition@0 {
> + lab

Re: [PATCH v2 10/12] mips: octeon: Initial minimal support for the Marvell Octeon SoC

2020-06-16 Thread Daniel Schwierzeck



Am 14.05.20 um 11:59 schrieb Stefan Roese:
> From: Aaron Williams 
> 
> This patch adds very basic support for the Octeon III SoCs. Only
> CFI parallel NOR flash and UART is supported for now.
> 
> Please note that the basic Octeon port does not include the DDR3/4
> initialization yet. This will be added in some follow-up patches
> later. To still use U-Boot on with this port, the L2 cache (4MiB on
> Octeon III CN73xx) is used as RAM. This way, U-Boot can boot to the
> prompt on such boards.
> 
> Signed-off-by: Aaron Williams 
> Signed-off-by: Stefan Roese 
> 
> ---
> 
> Changes in v2:
> - Remove custom start.S and use common start.S. Minimal custom lowlevel
>   init code is currently added in the custom lowlevel_init.S. This needs
>   to be extended with necessary code, like errata handling etc. But for
>   a very first basic port, this seems to be all thats needed to boot on
>   the EBB7304 to the prompt.
> - Removed select CREATE_ARCH_SYMLINK
> - Removed Octeon II support, as its currently no added in this patchset
> - Added cache.c to add the platform specific cache functions as no-ops
>   for Octeon as the platform is cache coherent
> - Removed CONFIG_MIPS_CACHE_COHERENT
> - Added CONFIG_CPU_CAVIUM_OCTEON to Kconfig and selected it for Octeon
>   to enable better sync with the Linux files in the future
> - Add get_tbclk() -> no need to define CONFIG_SYS_MIPS_TIMER_FREQ any more
> 
>  MAINTAINERS   |  6 ++
>  arch/mips/Kconfig | 43 +++
>  arch/mips/Makefile|  3 +
>  arch/mips/mach-octeon/Kconfig | 53 +
>  arch/mips/mach-octeon/Makefile| 10 +++
>  arch/mips/mach-octeon/cache.c | 20 +
>  arch/mips/mach-octeon/clock.c | 27 +++
>  arch/mips/mach-octeon/cpu.c   | 55 ++
>  arch/mips/mach-octeon/dram.c  | 27 +++
>  arch/mips/mach-octeon/include/ioremap.h   | 30 
>  arch/mips/mach-octeon/include/mach/cavm-reg.h | 42 +++
>  arch/mips/mach-octeon/include/mach/clock.h| 24 ++
>  arch/mips/mach-octeon/lowlevel_init.S | 75 +++
>  scripts/config_whitelist.txt  |  1 -
>  14 files changed, 415 insertions(+), 1 deletion(-)
>  create mode 100644 arch/mips/mach-octeon/Kconfig
>  create mode 100644 arch/mips/mach-octeon/Makefile
>  create mode 100644 arch/mips/mach-octeon/cache.c
>  create mode 100644 arch/mips/mach-octeon/clock.c
>  create mode 100644 arch/mips/mach-octeon/cpu.c
>  create mode 100644 arch/mips/mach-octeon/dram.c
>  create mode 100644 arch/mips/mach-octeon/include/ioremap.h
>  create mode 100644 arch/mips/mach-octeon/include/mach/cavm-reg.h
>  create mode 100644 arch/mips/mach-octeon/include/mach/clock.h
>  create mode 100644 arch/mips/mach-octeon/lowlevel_init.S
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ec59ce8b88..7f4c325df4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -752,6 +752,12 @@ M:   Ezequiel Garcia 
>  S:   Maintained
>  F:   arch/mips/mach-jz47xx/
>  
> +MIPS Octeon
> +M:   Aaron Williams 
> +S:   Maintained
> +F:   arch/mips/mach-octeon/
> +F:   arch/mips/include/asm/arch-octeon/
> +
>  MMC
>  M:   Peng Fan 
>  S:   Maintained
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 48e754cc46..bc5ad0c3ff 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -106,6 +106,25 @@ config ARCH_JZ47XX
>   select OF_CONTROL
>   select DM
>  
> +config ARCH_OCTEON
> + bool "Support Marvell Octeon CN7xxx platforms"
> + select CPU_CAVIUM_OCTEON
> + select DISPLAY_CPUINFO
> + select DMA_ADDR_T_64BIT
> + select DM
> + select DM_SERIAL
> + select MIPS_INIT_STACK_IN_SRAM
> + select MIPS_L2_CACHE
> + select MIPS_TUNE_OCTEON3
> + select MIPS_SRAM_INIT
> + select ROM_EXCEPTION_VECTORS
> + select SUPPORTS_BIG_ENDIAN
> + select SUPPORTS_CPU_MIPS64_OCTEON
> + select PHYS_64BIT
> + select OF_CONTROL
> + select OF_LIVE
> + imply CMD_DM
> +
>  config MACH_PIC32
>   bool "Support Microchip PIC32"
>   select DM
> @@ -160,6 +179,7 @@ source "arch/mips/mach-bmips/Kconfig"
>  source "arch/mips/mach-jz47xx/Kconfig"
>  source "arch/mips/mach-pic32/Kconfig"
>  source "arch/mips/mach-mtmips/Kconfig"
> +source "arch/mips/mach-octeon/Kconfig"
>  
>  if MIPS
>  
> @@ -233,6 +253,14 @@ config CPU_MIPS64_R6
> Choose this option to build a kernel for release 6 or later of the
> MIPS64 architecture.
>  
> +config CPU_MIPS64_OCTEON
> + bool "Marvell Octeon series of CPUs"
> + depends on SUPPORTS_CPU_MIPS64_OCTEON
> + select 64BIT
> + help
> +  Choose this option for Marvell Octeon CPUs.  These CPUs are between
> +  MIPS64 R5 and R6 with other extensions.
> +
>  endchoice
>  
>  menu "General setup"
> @@ -398,6 +426,12 @@ config SUPPORTS_CPU_MIPS64_R2
>  config SUPPORTS_CPU_MIPS64_R6
>

Re: [PATCH v2 00/12] mips: Add initial Octeon MIPS64 base support

2020-06-16 Thread Daniel Schwierzeck
Hi Stefan,

Am 15.06.20 um 09:49 schrieb Stefan Roese:

>>
>>> Actually I wanted to do a more complete header sync with Linux and
>>> submit some minimal refactorings of start.S so that you have a better
>>> working base. Unfortuneately I hadn't time to do so in the last 3 weeks.
>>
>> I understand. Is there something I can help you with, to speed this
>> up?
> 
> Again, can I assist with some of your tasks? I really would like to see
> the base Octeon support appear in mainline U-Boot in the upcoming
> merge window. Please see below.

my current work state is pushed to u-boot-mips in branches
header_sync_v2 and lowlevel_refactoring. That should be enough for the
first refactoring step for the next merge window. I'll try to send
patches soon. With this you can also drop patches 2/12 and 8/12.

> 
>>> Regarding the copying to L2 cache: could we do this later and add the
>>> init stuff at first? So we could have functionality at first and then
>>> boot time optimization later. This also would give me some more time to
>>> refactor the start.S hooks which would give you a better base for
>>> implementing such optimizations.
>>
>> IIUYC, then your main reason that I should remove the L2 cache copy
>> is, that you would like to refactor start.S first and add some hooks
>> for e.g. this L2C cache copy, where it would fit better than currently
>> in mips_sram_init(). I definitely promise to re-work this Octeon early
>> boot code to fit into your refactored start.S, once its ready. This
>> way, you wouldn't be pressed in time to get this rework done. And we
>> have a chance to get this Octeon base support integrated in a "decent"
>> state (bootup time, please see DDR4 init below) soon.
>>
>> There are other reasons, beside the boot speedup, for the L2 cache
>> copy:
>>
>> Running from L2 cache also helps with re-mapping the CFI flash
>> bootmap, so that the 8 MiB flash can be fully accessed. Otherwise
>> the flash is too big for the initial bootmap size and things like
>> environement can't be accessed.
>>
>> The DDR init code that I'm currently working on - I'm actually
>> preparing the first patchset right now - is only tested with this
>> configration right now.
>>
>> I'm also working on other peripheral drivers for Octeon. Some have
>> already started (like USB) and others are on my list. All this work
>> is pretty painful without the boot speedup, as e.g. the DDR4 init
>> will take very long (many minutes compared to a few seconds, as I've
>> been told).
>>
>> But of course this is your call. If you insist on removing the L2 cache
>> copy from the base Octeon port, then I will re-visit the patchet and
>> try to address it.

I had a deeper look into it, but I still can't understand why and how
this L2 copy even works. Especially after a cold-boot from flash without
any Octeon specific CPU initialization.

U-Boot is a position-dependent binary and all branches and jumps are
implemented with absolute addresses. You can't simply add an offset to
$pc (except when changing KSEG) and expect U-Boot to be running from the
new location. That's why we have the relocation step and the reloc table
where all absolute addresses are fixed relative to the relocation address.

Assembly dump of the current patch series:

8000 <_start>:
ENTRY(_start)
/* U-Boot entry point */
b   reset
8000:   113fb   8500 
 mtc0   zero, CP0_COUNT # clear cp0 count for most accurate boot timing
8004:   40804800mtc0zero,$9
...
8500 :
1:  mfc0t0, CP0_EBASE
8500:   400c7801mfc0t0,$15,1
and t0, t0, EBASE_CPUNUM
8504:   318c03ffandit0,t0,0x3ff

/* Hang if this isn't the first CPU in the system */
2:  beqzt0, 4f
8508:   1184beqzt0,851c 
 nop
850c:   nop
3:  wait
8510:   4220wait
b   3b
8514:   1000fffeb   8510 
 nop
8518:   nop

/* Init CP0 Status */
4:  mfc0t0, CP0_STATUS
851c:   400c6000mfc0t0,$12
...

If you boot off from flash at bfc0, the very first
instruction will jump to 8500. This can only work if there
is already some magic memory/TLB mapping from bfc0 to
8000 or I-caches are already active.

Could you describe the basic system design (or share some documents)
i.e. how CPUs, busses, cache coherency engine, memory controller, flash
are connected and at which addresses them are mapped? And how the boot
process works? Are the I-caches already active when booting from flash?
This would really help me for understanding the code ;)

Also the complete copy of the U-Boot binary to L2 cache breaks the
U-Boot design philosophy. The task o

Re: [PULL] Pull request: u-boot-stm32 for v2020.07= u-boot-stm32-20200616

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 11:58:58AM +, Patrick DELAUNAY wrote:

> Hi Tom,
> 
> Please pull the STM32 related patches for v2020.07:  u-boot-stm32-20200528
> 
> With the following changes:
> - fix boot with OP-TEE for stm32mp15 boards
> 
> CI status:
> https://gitlab.denx.de/u-boot/custodians/u-boot-stm/pipelines/3689
> 
> Thanks,
> Patrick
> 
> The following changes since commit 287be3294af6179782f8a561afca427620504581:
> 
>   Merge branch '2020-06-15-misc-bugfixes' (2020-06-15 11:24:42 -0400)
> 
> are available in the Git repository at:
> 
>   https://gitlab.denx.de/u-boot/custodians/u-boot-stm.git 
> tags/u-boot-stm32-20200616
> 
> for you to fetch changes up to 9e696965065c43b59901e49e75435b1549fa55c7:
> 
>   dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI (2020-06-16 10:39:28 
> +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v1 00/13] This patch-series includes updates for Toradex modules:

2020-06-16 Thread Igor Opaniuk
1. Environment clean-up (dropping legacy emmcboot, sdboot wrappers)
2. Boot count support for multiple modules
3. Distro Boot fixes

Igor Opaniuk (6):
  apalis-tk1: enable distroboot
  apalis-tk1: fix setting fdtfile value
  toradex: imx: enable BOOTCOUNT feature
  apalis_imx6: boot env configuration updates
  colibri_imx7: boot env configuration updates
  colibri_imx6: boot env configuration updates

Marcel Ziswiler (1):
  apalis-imx8: enable of_system_setup

Max Krummenacher (3):
  apalis/colibri-imx8: re-enable CONFIG_IMX_SCU_THERMAL
  colibri_vf_defconfig: enable part cmd
  configs/colibri_vf.h: drop sdboot in favour of distro_bootcmd

Oleksandr Suvorov (1):
  colibri-imx8x: declare consoleargs

Stefan Agner (2):
  colibri_imx7: add addresses required for distro boot
  colibri-imx6ull/imx7: define bootubipart for distro boot

 configs/apalis-imx8qm_defconfig |  2 ++
 configs/apalis-tk1_defconfig|  2 +-
 configs/apalis_imx6_defconfig   |  3 +++
 configs/colibri-imx6ull_defconfig   |  3 +++
 configs/colibri-imx8qxp_defconfig   |  1 +
 configs/colibri_imx6_defconfig  |  3 +++
 configs/colibri_imx7_defconfig  |  3 +++
 configs/colibri_imx7_emmc_defconfig |  3 +++
 configs/colibri_vf_defconfig|  3 +--
 include/configs/apalis-tk1.h| 51 ++---
 include/configs/apalis_imx6.h   | 29 +
 include/configs/colibri-imx6ull.h   |  1 +
 include/configs/colibri-imx8x.h |  8 +++---
 include/configs/colibri_imx6.h  | 29 +
 include/configs/colibri_imx7.h  | 28 +++-
 include/configs/colibri_vf.h| 18 +
 16 files changed, 46 insertions(+), 141 deletions(-)

-- 
2.7.4



[PATCH v1 05/13] colibri-imx6ull/imx7: define bootubipart for distro boot

2020-06-16 Thread Igor Opaniuk
From: Stefan Agner 

When using distro boot to boot from UBI volumes the boot partition
has been hardcoded to "UBI" (capital letters). However, our default
MTD layout uses "ubi" (lower case letter). Define "ubi" as the
default UBI partition for distro boot for Toradex. This allows to
use distro boot without having to redefine the MTD partition layout
which is useful for TorizonCore.

Signed-off-by: Stefan Agner 
---

 include/configs/colibri-imx6ull.h | 1 +
 include/configs/colibri_imx7.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/configs/colibri-imx6ull.h 
b/include/configs/colibri-imx6ull.h
index 2d3b4c1..c80fb96 100644
--- a/include/configs/colibri-imx6ull.h
+++ b/include/configs/colibri-imx6ull.h
@@ -88,6 +88,7 @@
NFS_BOOTCMD \
UBI_BOOTCMD \
UBOOT_UPDATE \
+   "bootubipart=ubi\0" \
"console=ttymxc0\0" \
"defargs=user_debug=30\0" \
"dfu_alt_info=" DFU_ALT_NAND_INFO "\0" \
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index b550bc6..b3f660b 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -169,6 +169,7 @@
MODULE_EXTRA_ENV_SETTINGS \
UBOOT_UPDATE \
"boot_file=zImage\0" \
+   "bootubipart=ubi\0" \
"console=ttymxc0\0" \
"defargs=\0" \
"fdt_board=eval-v3\0" \
-- 
2.7.4



[PATCH v1 01/13] apalis-imx8: enable of_system_setup

2020-06-16 Thread Igor Opaniuk
From: Marcel Ziswiler 

Enable CONFIG_OF_SYSTEM_DEFAULT for Apalis iMX8.

Signed-off-by: Marcel Ziswiler 
---

 configs/apalis-imx8qm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/apalis-imx8qm_defconfig b/configs/apalis-imx8qm_defconfig
index 4c27c33..fdc1e4e 100644
--- a/configs/apalis-imx8qm_defconfig
+++ b/configs/apalis-imx8qm_defconfig
@@ -9,6 +9,7 @@ CONFIG_TARGET_APALIS_IMX8=y
 CONFIG_NR_DRAM_BANKS=3
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
+CONFIG_OF_SYSTEM_SETUP=y
 
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/toradex/apalis-imx8/apalis-imx8qm-imximage.cfg"
 CONFIG_LOG=y
 CONFIG_VERSION_VARIABLE=y
-- 
2.7.4



[PATCH v1 04/13] colibri_imx7: add addresses required for distro boot

2020-06-16 Thread Igor Opaniuk
From: Stefan Agner 

Define addresses required for full distro boot support.

Signed-off-by: Stefan Agner 
---

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

diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 09722f4..b550bc6 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -109,8 +109,9 @@
"bootm_size=0x1000\0" \
"fdt_addr_r=0x8200\0" \
"kernel_addr_r=0x8100\0" \
+   "pxefile_addr_r=0x8710\0" \
"ramdisk_addr_r=0x8210\0" \
-   "scriptaddr=0x8250\0"
+   "scriptaddr=0x8700\0"
 
 #define NFS_BOOTCMD \
"nfsargs=ip=:eth0: root=/dev/nfs\0" \
-- 
2.7.4



[PATCH v1 06/13] colibri_vf_defconfig: enable part cmd

2020-06-16 Thread Igor Opaniuk
From: Max Krummenacher 

This allows to boot from SD/USB with passing the rootfs partition via UUID.

Signed-off-by: Max Krummenacher 
---

 configs/colibri_vf_defconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/configs/colibri_vf_defconfig b/configs/colibri_vf_defconfig
index c494fb4..ed0acbe 100644
--- a/configs/colibri_vf_defconfig
+++ b/configs/colibri_vf_defconfig
@@ -18,8 +18,6 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ARCH_MISC_INIT=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_HUSH_PARSER=y
-# CONFIG_CMDLINE_EDITING is not set
-# CONFIG_AUTO_COMPLETE is not set
 # CONFIG_SYS_LONGHELP is not set
 CONFIG_SYS_PROMPT="Colibri VFxx # "
 # CONFIG_CMD_BOOTD is not set
@@ -39,6 +37,7 @@ CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_SETEXPR is not set
-- 
2.7.4



[PATCH v1 03/13] colibri-imx8x: declare consoleargs

2020-06-16 Thread Igor Opaniuk
From: Oleksandr Suvorov 

Store all console-related kernel parameters
in dedicated variable.

Signed-off-by: Oleksandr Suvorov 
---

 include/configs/colibri-imx8x.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index da9226e..7d00707 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -62,7 +62,7 @@
 #define BOOTENV_RUN_NET_USB_START ""
 
 #define CONFIG_MFG_ENV_SETTINGS \
-   "mfgtool_args=setenv bootargs console=${console},${baudrate} " \
+   "mfgtool_args=setenv bootargs ${consoleargs} " \
"rdinit=/linuxrc g_mass_storage.stall=0 " \
"g_mass_storage.removable=1 g_mass_storage.idVendor=0x066F " \
"g_mass_storage.idProduct=0x37FF " \
@@ -81,7 +81,7 @@
M4_BOOT_ENV \
MEM_LAYOUT_ENV_SETTINGS \
"boot_file=Image\0" \
-   "console=ttyLP3 earlycon\0" \
+   "consoleargs=console=ttyLP3,${baudrate} earlycon\0" \
"fdt_addr=0x8300\0" \
"fdt_file=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
"fdtfile=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
@@ -89,11 +89,11 @@
"image=Image\0" \
"initrd_addr=0x8380\0" \
"initrd_high=0x\0" \
-   "mmcargs=setenv bootargs console=${console},${baudrate} " \
+   "mmcargs=setenv bootargs ${consoleargs} " \
"root=PARTUUID=${uuid} rootwait " \
"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
"mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
-   "netargs=setenv bootargs console=${console},${baudrate} " \
+   "netargs=setenv bootargs ${consoleargs} " \
"root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp " \
"${vidargs}\0" \
"nfsboot=run netargs; dhcp ${loadaddr} ${image}; tftp ${fdt_addr} " \
-- 
2.7.4



[PATCH v1 02/13] apalis/colibri-imx8: re-enable CONFIG_IMX_SCU_THERMAL

2020-06-16 Thread Igor Opaniuk
From: Max Krummenacher 

This got dropped by a global 'make savedefconfig' resync as
required patches are still in flight.

Signed-off-by: Max Krummenacher 
---

 configs/apalis-imx8qm_defconfig   | 1 +
 configs/colibri-imx8qxp_defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/apalis-imx8qm_defconfig b/configs/apalis-imx8qm_defconfig
index fdc1e4e..289d644 100644
--- a/configs/apalis-imx8qm_defconfig
+++ b/configs/apalis-imx8qm_defconfig
@@ -62,4 +62,5 @@ CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_DM_SERIAL=y
 CONFIG_FSL_LPUART=y
 CONFIG_DM_THERMAL=y
+CONFIG_IMX_SCU_THERMAL=y
 # CONFIG_EFI_LOADER is not set
diff --git a/configs/colibri-imx8qxp_defconfig 
b/configs/colibri-imx8qxp_defconfig
index d86cefa..57b48e3 100644
--- a/configs/colibri-imx8qxp_defconfig
+++ b/configs/colibri-imx8qxp_defconfig
@@ -59,4 +59,5 @@ CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_DM_SERIAL=y
 CONFIG_FSL_LPUART=y
 CONFIG_DM_THERMAL=y
+CONFIG_IMX_SCU_THERMAL=y
 # CONFIG_EFI_LOADER is not set
-- 
2.7.4



[PATCH v1 08/13] apalis-tk1: enable distroboot

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

1. Use distro_bootcmd as default boot command instead of
legacy emmcboot wrapper.
2. Drop emmcboot and sdboot wrappers.
3. Provide proper boot order for Distro Boot.

Signed-off-by: Igor Opaniuk 
---

 configs/apalis-tk1_defconfig |  2 +-
 include/configs/apalis-tk1.h | 51 
 2 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/configs/apalis-tk1_defconfig b/configs/apalis-tk1_defconfig
index 868303a..db66d68 100644
--- a/configs/apalis-tk1_defconfig
+++ b/configs/apalis-tk1_defconfig
@@ -11,7 +11,7 @@ CONFIG_SPL_TEXT_BASE=0x80108000
 CONFIG_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=1
-CONFIG_BOOTCOMMAND="run emmcboot; setenv fdtfile 
${soc}-${fdt-module}-${fdt_board}.dtb && run distro_bootcmd"
+CONFIG_BOOTCOMMAND="setenv fdtfile ${soc}-${fdt-module}-${fdt_board}.dtb && 
run distro_bootcmd"
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_VERSION_VARIABLE=y
diff --git a/include/configs/apalis-tk1.h b/include/configs/apalis-tk1.h
index 965259c..6f73606 100644
--- a/include/configs/apalis-tk1.h
+++ b/include/configs/apalis-tk1.h
@@ -34,6 +34,20 @@
 /* General networking support */
 #define CONFIG_TFTP_TSIZE
 
+/*
+ * Custom Distro Boot configuration:
+ * 1. 8bit SD port (MMC1)
+ * 2. 4bit SD port (MMC2)
+ * 3. eMMC (MMC0)
+ */
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, 1) \
+   func(MMC, mmc, 2) \
+   func(MMC, mmc, 0) \
+   func(USB, usb, 0) \
+   func(PXE, pxe, na) \
+   func(DHCP, dhcp, na)
+
 #undef CONFIG_IPADDR
 #define CONFIG_IPADDR  192.168.10.2
 #define CONFIG_NETMASK 255.255.255.0
@@ -54,24 +68,6 @@
"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
 
-#define EMMC_BOOTCMD \
-   "set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} " \
-   "ro rootfstype=ext4 rootwait\0" \
-   "emmcboot=run setup; run emmcfinduuid; run set_emmcargs; " \
-   "setenv bootargs ${defargs} ${emmcargs} " \
-   "${setupargs} ${vidargs}; echo Booting from internal eMMC; " \
-   "run emmcdtbload; " \
-   "load mmc ${emmcdev}:${emmcbootpart} ${kernel_addr_r} " \
-   "${boot_file} && run fdt_fixup && " \
-   "bootz ${kernel_addr_r} - ${dtbparam}\0" \
-   "emmcbootpart=1\0" \
-   "emmcdev=0\0" \
-   "emmcdtbload=setenv dtbparam; load mmc ${emmcdev}:${emmcbootpart} " \
-   "${fdt_addr_r} ${soc}-${fdt_module}-${fdt_board}.dtb && " \
-   "setenv dtbparam ${fdt_addr_r}\0" \
-   "emmcfinduuid=part uuid mmc ${mmcdev}:${emmcrootpart} uuid\0" \
-   "emmcrootpart=2\0"
-
 #define NFS_BOOTCMD \
"nfsargs=ip=:eth0:on root=/dev/nfs rw\0" \
"nfsboot=pci enum; run setup; setenv bootargs ${defargs} ${nfsargs} " \
@@ -82,23 +78,6 @@
"${soc}-${fdt_module}-${fdt_board}.dtb " \
"&& setenv dtbparam ${fdt_addr_r}\0"
 
-#define SD_BOOTCMD \
-   "set_sdargs=setenv sdargs ip=off root=PARTUUID=${uuid} ro " \
-   "rootfstype=ext4 rootwait\0" \
-   "sdboot=run setup; run sdfinduuid; run set_sdargs; " \
-   "setenv bootargs ${defargs} ${sdargs} ${setupargs} " \
-   "${vidargs}; echo Booting from SD card in 8bit slot...; " \
-   "run sddtbload; load mmc ${sddev}:${sdbootpart} " \
-   "${kernel_addr_r} ${boot_file} && run fdt_fixup && " \
-   "bootz ${kernel_addr_r} - ${dtbparam}\0" \
-   "sdbootpart=1\0" \
-   "sddev=1\0" \
-   "sddtbload=setenv dtbparam; load mmc ${sddev}:${sdbootpart} " \
-   "${fdt_addr_r} ${soc}-${fdt_module}-${fdt_board}.dtb " \
-   "&& setenv dtbparam ${fdt_addr_r}\0" \
-   "sdfinduuid=part uuid mmc ${sddev}:${sdrootpart} uuid\0" \
-   "sdrootpart=2\0"
-
 #define BOARD_EXTRA_ENV_SETTINGS \
"boot_file=zImage\0" \
"console=ttyS0\0" \
@@ -106,12 +85,10 @@
"usb_port_owner_info=2 lane_owner_info=6 emc_max_dvfs=0 " \
"user_debug=30 pcie_aspm=off\0" \
"dfu_alt_info=" DFU_ALT_EMMC_INFO "\0" \
-   EMMC_BOOTCMD \
"fdt_board=eval\0" \
"fdt_fixup=;\0" \
"fdt_module=" FDT_MODULE "\0" \
NFS_BOOTCMD \
-   SD_BOOTCMD \
UBOOT_UPDATE \
"setethupdate=if env exists ethaddr; then; else setenv ethaddr " \
"00:14:2d:00:00:00; fi; pci enum && tftpboot ${loadaddr} " \
-- 
2.7.4



[PATCH v1 10/13] toradex: imx: enable BOOTCOUNT feature

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

This introduces automatic boot counter that increases after every
reset.After a power-on reset, it will be initialized with 1,
and each reboot will increment the value by 1. By default it's
disabled if bootlimit isn't set.

To enable this feature you have set bootcount limit ("bootlimit"),
alternate boot action ("altbootcmd") that will be performed if
the new value of bootcount exceeds the value of bootlimit, and
"upgrade_available" to let U-Boot automatically increase and save
the counter value after every reset:

> setenv bootlimit 5
> setenv upgrade_available 1
> setenv altbootcmd "bootm ..."

In case the bootlimit exceeds, the message will be shown and
albootcmd executed:
Warning: Bootlimit (5) exceeded. Using altbootcmd.

To reset bootcount run:
> bootcount reset

Print current value:
> bootcount print

Signed-off-by: Igor Opaniuk 
---

 configs/apalis_imx6_defconfig   | 3 +++
 configs/colibri-imx6ull_defconfig   | 3 +++
 configs/colibri_imx6_defconfig  | 3 +++
 configs/colibri_imx7_defconfig  | 3 +++
 configs/colibri_imx7_emmc_defconfig | 3 +++
 5 files changed, 15 insertions(+)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index 6b0f0e4..65162a2 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -53,6 +53,7 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_PMIC=y
@@ -65,6 +66,8 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=4096
 CONFIG_DWC_AHSATA=y
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
diff --git a/configs/colibri-imx6ull_defconfig 
b/configs/colibri-imx6ull_defconfig
index 74a67a0..ce145cd 100644
--- a/configs/colibri-imx6ull_defconfig
+++ b/configs/colibri-imx6ull_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_MTDPARTS=y
@@ -54,6 +55,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DFU_NAND=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 44a3ff8..ca33327 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -52,6 +52,7 @@ CONFIG_CMD_USB_SDP=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_CMD_NFS is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_UUID=y
@@ -64,6 +65,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_DM_I2C=y
 CONFIG_DM_MMC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig
index 7596478..89ee6e5 100644
--- a/configs/colibri_imx7_defconfig
+++ b/configs/colibri_imx7_defconfig
@@ -40,6 +40,7 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_BOOTP_PXE is not set
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 # CONFIG_CMD_HASH is not set
 CONFIG_CMD_MTDPARTS=y
@@ -54,6 +55,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_FSL_CAAM=y
 CONFIG_DFU_NAND=y
 CONFIG_DM_I2C=y
diff --git a/configs/colibri_imx7_emmc_defconfig 
b/configs/colibri_imx7_emmc_defconfig
index c23ff97..13a3aae 100644
--- a/configs/colibri_imx7_emmc_defconfig
+++ b/configs/colibri_imx7_emmc_defconfig
@@ -38,6 +38,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_BMP=y
+CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 # CONFIG_CMD_HASH is not set
 # CONFIG_ISO_PARTITION is not set
@@ -48,6 +49,8 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_IP_DEFRAG=y
 CONFIG_TFTP_BLOCKSIZE=16352
+CONFIG_BOOTCOUNT_LIMIT=y
+CONFIG_BOOTCOUNT_ENV=y
 CONFIG_FSL_CAAM=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x8200
-- 
2.7.4



[PATCH v1 09/13] apalis-tk1: fix setting fdtfile value

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

s/fdt-module/fdt_module/g, as we don't use dash in fdt_file anymore.

Fixes: 4c63a601("apalis-tk1: support v1.2 hardware revision")
Signed-off-by: Igor Opaniuk 
---

 configs/apalis-tk1_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/apalis-tk1_defconfig b/configs/apalis-tk1_defconfig
index db66d68..42e320e 100644
--- a/configs/apalis-tk1_defconfig
+++ b/configs/apalis-tk1_defconfig
@@ -11,7 +11,7 @@ CONFIG_SPL_TEXT_BASE=0x80108000
 CONFIG_FIT=y
 CONFIG_OF_SYSTEM_SETUP=y
 CONFIG_BOOTDELAY=1
-CONFIG_BOOTCOMMAND="setenv fdtfile ${soc}-${fdt-module}-${fdt_board}.dtb && 
run distro_bootcmd"
+CONFIG_BOOTCOMMAND="setenv fdtfile ${soc}-${fdt_module}-${fdt_board}.dtb && 
run distro_bootcmd"
 CONFIG_CONSOLE_MUX=y
 CONFIG_SYS_STDIO_DEREGISTER=y
 CONFIG_VERSION_VARIABLE=y
-- 
2.7.4



[PATCH v1 07/13] configs/colibri_vf.h: drop sdboot in favour of distro_bootcmd

2020-06-16 Thread Igor Opaniuk
From: Max Krummenacher 

The distro bootscript uses kernel_image to get the file name of
the kernel, so change that variable name.
UBI boot has precedence in the default boot command. If one wants
to boot from SD with a working NAND installation stop in U-Boot
and enter:

setenv fdtfile ${soc}-colibri-${fdt_board}.dtb && run distro_bootcmd

Signed-off-by: Max Krummenacher 
---

 include/configs/colibri_vf.h | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h
index 7d17bd8..012350d 100644
--- a/include/configs/colibri_vf.h
+++ b/include/configs/colibri_vf.h
@@ -69,21 +69,6 @@
"tftp ${fdt_addr_r} ${soc}-colibri-${fdt_board}.dtb && " \
"run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}\0" \
 
-#define SD_BOOTCMD \
-   "set_sdargs=setenv sdargs root=PARTUUID=${uuid} ro rootwait\0"  \
-   "sdboot=run setup; run sdfinduuid; run set_sdargs; " \
-   "setenv bootargs ${defargs} ${sdargs} ${mtdparts} " \
-   "${setupargs} ${vidargs}; echo Booting from MMC/SD card...; " \
-   "load mmc ${sddev}:${sdbootpart} ${kernel_addr_r} ${kernel_file} && " \
-   "load mmc ${sddev}:${sdbootpart} ${fdt_addr_r} " \
-   "${soc}-colibri-${fdt_board}.dtb && " \
-   "run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}\0" \
-   "sdbootpart=1\0" \
-   "sddev=0\0" \
-   "sdfinduuid=part uuid mmc ${sddev}:${sdrootpart} uuid\0" \
-   "sdrootpart=2\0"
-
-
 #define UBI_BOOTCMD \
"ubiargs=ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs " \
"ubi.fm_autoconvert=1\0" \
@@ -112,7 +97,6 @@
BOOTENV \
MEM_LAYOUT_ENV_SETTINGS \
NFS_BOOTCMD \
-   SD_BOOTCMD \
UBI_BOOTCMD \
UBOOT_UPDATE \
"console=ttyLP0\0" \
@@ -120,7 +104,7 @@
"dfu_alt_info=" DFU_ALT_NAND_INFO "\0" \
"fdt_board=eval-v3\0" \
"fdt_fixup=;\0" \
-   "kernel_file=zImage\0" \
+   "kernel_image=zImage\0" \
"mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
"setsdupdate=mmc rescan && set interface mmc && " \
"fatload ${interface} 0:1 ${loadaddr} flash_blk.img && " \
-- 
2.7.4



[PATCH v1 13/13] colibri_imx6: boot env configuration updates

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

1. Drop legacy emmcboot wrapper from env.
2. Change the "boot try" order. Default one is: SD -> eMMC -> USB -> DHCP
3. Drop DFU defines

Signed-off-by: Igor Opaniuk 
---

 include/configs/colibri_imx6.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 6beef25..7271f29 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -83,6 +83,7 @@
 #define BOOT_TARGET_DEVICES(func) \
func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
+   func(MMC, mmc, 0) \
func(USB, usb, 0) \
func(DHCP, dhcp, na)
 #include 
@@ -92,14 +93,6 @@
 #define BOOTENV
 #endif /* CONFIG_SPL_BUILD */
 
-#define DFU_ALT_EMMC_INFO \
-   "u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
-   "boot part 0 1;" \
-   "rootfs part 0 2;" \
-   "zImage fat 0 1;" \
-   "imx6dl-colibri-eval-v3.dtb fat 0 1;" \
-   "imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
-
 #define UBOOT_UPDATE \
"uboot_hwpart=1\0" \
"uboot_blk=8a\0" \
@@ -111,24 +104,6 @@
"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
 
-#define EMMC_BOOTCMD \
-   "set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} "\
-   "rw,noatime rootfstype=ext4 " \
-   "rootwait\0" \
-   "emmcboot=run setup; run emmcfinduuid; run set_emmcargs; " \
-   "setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
-   "${vidargs}; echo Booting from internal eMMC chip...; " \
-   "run emmcdtbload; load mmc ${emmcdev}:${emmcbootpart} " \
-   "${kernel_addr_r} ${boot_file} && run fdt_fixup && " \
-   "bootz ${kernel_addr_r} ${dtbparam}\0" \
-   "emmcbootpart=1\0" \
-   "emmcdev=0\0" \
-   "emmcdtbload=setenv dtbparam; load mmc ${emmcdev}:${emmcbootpart} " \
-   "${fdt_addr_r} ${fdt_file} && " \
-   "setenv dtbparam \" - ${fdt_addr_r}\" && true\0" \
-   "emmcfinduuid=part uuid mmc ${mmcdev}:${emmcrootpart} uuid\0" \
-   "emmcrootpart=2\0"
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"bootm_size=0x1000\0" \
"fdt_addr_r=0x1210\0" \
@@ -156,8 +131,6 @@
"boot_file=zImage\0" \
"console=ttymxc0\0" \
"defargs=enable_wait_mode=off galcore.contiguousSize=50331648\0" \
-   "dfu_alt_info=" DFU_ALT_EMMC_INFO "\0" \
-   EMMC_BOOTCMD \
"fdt_file=" FDT_FILE "\0" \
"fdt_fixup=;\0" \
MEM_LAYOUT_ENV_SETTINGS \
-- 
2.7.4



[PATCH v1 11/13] apalis_imx6: boot env configuration updates

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

1. Drop legacy emmcboot wrapper from env.
2. Change the "boot try" order. Default one is: SD -> eMMC -> USB -> DHCP
3. Drop DFU defines

Signed-off-by: Igor Opaniuk 
---

 include/configs/apalis_imx6.h | 29 +
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index d5a0625..dd99096 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -93,9 +93,9 @@
 
 #ifndef CONFIG_SPL_BUILD
 #define BOOT_TARGET_DEVICES(func) \
-   func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
func(MMC, mmc, 2) \
+   func(MMC, mmc, 0) \
func(USB, usb, 0) \
func(DHCP, dhcp, na)
 #include 
@@ -105,14 +105,6 @@
 #define BOOTENV
 #endif /* CONFIG_SPL_BUILD */
 
-#define DFU_ALT_EMMC_INFO \
-   "u-boot.imx raw 0x2 0x3ff mmcpart 0;" \
-   "boot part 0 1;" \
-   "rootfs part 0 2;" \
-   "zImage fat 0 1;" \
-   "imx6q-apalis-eval.dtb fat 0 1;" \
-   "imx6q-apalis-cam-eval.dtb fat 0 1"
-
 #define UBOOT_UPDATE \
"uboot_hwpart=1\0" \
"uboot_blk=8a\0" \
@@ -124,23 +116,6 @@
"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
 
-#define EMMC_BOOTCMD \
-   "set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} " \
-   "ro,noatime rootfstype=ext4 rootwait\0" \
-   "emmcboot=run setup; run emmcfinduuid; run set_emmcargs; " \
-   "setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
-   "${vidargs}; echo Booting from internal eMMC chip...; " \
-   "run emmcdtbload; load mmc ${emmcdev}:${emmcbootpart} " \
-   "${kernel_addr_r} ${boot_file} && run fdt_fixup && " \
-   "bootz ${kernel_addr_r} ${dtbparam}\0" \
-   "emmcbootpart=1\0" \
-   "emmcdev=0\0" \
-   "emmcdtbload=setenv dtbparam; load mmc ${emmcdev}:${emmcbootpart} " \
-   "${fdt_addr_r} ${fdt_file} && " \
-   "setenv dtbparam \" - ${fdt_addr_r}\" && true\0" \
-   "emmcfinduuid=part uuid mmc ${mmcdev}:${emmcrootpart} uuid\0" \
-   "emmcrootpart=2\0"
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"bootm_size=0x2000\0" \
"fdt_addr_r=0x1210\0" \
@@ -173,8 +148,6 @@
"boot_file=zImage\0" \
"console=ttymxc0\0" \
"defargs=enable_wait_mode=off vmalloc=400M\0" \
-   "dfu_alt_info=" DFU_ALT_EMMC_INFO "\0" \
-   EMMC_BOOTCMD \
"fdt_file=" FDT_FILE "\0" \
"fdt_fixup=;\0" \
MEM_LAYOUT_ENV_SETTINGS \
-- 
2.7.4



[PATCH v1 12/13] colibri_imx7: boot env configuration updates

2020-06-16 Thread Igor Opaniuk
From: Igor Opaniuk 

1. Drop legacy emmcboot wrapper from env.
2. Change the "boot try" order. Default one is: SD -> eMMC -> USB -> DHCP
3. Drop DFU defines

Signed-off-by: Igor Opaniuk 
---

 include/configs/colibri_imx7.h | 24 +---
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index b3f660b..1afa937 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -88,23 +88,6 @@
"mmc read ${android_fdt_addr} ${env_start} ${env_size}; " \
"bootm ${loadaddr} ${loadaddr} ${android_fdt_addr}\0 "
 
-#define EMMC_BOOTCMD \
-   "set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} ro " \
-   "rootfstype=ext4 rootwait\0" \
-   "emmcboot=run setup; run emmcfinduuid; run set_emmcargs; " \
-   "setenv bootargs ${defargs} ${emmcargs} ${setupargs} " \
-   "${vidargs}; echo Booting from internal eMMC chip...; " \
-   "run m4boot && " \
-   "load mmc ${emmcdev}:${emmcbootpart} ${fdt_addr_r} " \
-   "${soc}-colibri-emmc-${fdt_board}.dtb && " \
-   "load mmc ${emmcdev}:${emmcbootpart} ${kernel_addr_r} " \
-   "${boot_file} && run fdt_fixup && " \
-   "bootz ${kernel_addr_r} - ${fdt_addr_r}\0" \
-   "emmcbootpart=1\0" \
-   "emmcdev=0\0" \
-   "emmcfinduuid=part uuid mmc ${emmcdev}:${emmcrootpart} uuid\0" \
-   "emmcrootpart=2\0"
-
 #define MEM_LAYOUT_ENV_SETTINGS \
"bootm_size=0x1000\0" \
"fdt_addr_r=0x8200\0" \
@@ -144,7 +127,6 @@
"setenv fdtfile ${soc}-colibri-emmc-${fdt_board}.dtb && run 
distro_bootcmd;"
 #define MODULE_EXTRA_ENV_SETTINGS \
"variant=-emmc\0" \
-   EMMC_BOOTCMD \
EMMC_ANDROID_BOOTCMD
 #endif
 
@@ -155,8 +137,8 @@
func(DHCP, dhcp, na)
 #elif defined(CONFIG_TARGET_COLIBRI_IMX7_EMMC)
 #define BOOT_TARGET_DEVICES(func) \
-   func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
+   func(MMC, mmc, 0) \
func(USB, usb, 0) \
func(DHCP, dhcp, na)
 #endif
@@ -239,10 +221,6 @@
 
 #define CONFIG_USBD_HS
 
-/* USB Device Firmware Update support */
-#define CONFIG_SYS_DFU_DATA_BUF_SIZE   SZ_16M
-#define DFU_DEFAULT_POLL_TIMEOUT   300
-
 #if defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
 #define CONFIG_VIDEO_MXS
 #define CONFIG_VIDEO_LOGO
-- 
2.7.4



Re: Can't access mmc #0 on mt7623 when booted from external SD

2020-06-16 Thread Michael Nazzareno Trimarchi
Hi

On Tue, Jun 16, 2020 at 7:07 PM David Woodhouse  wrote:
>
> On Tue, 2020-06-16 at 18:59 +0200, Michael Nazzareno Trimarchi wrote:
> > On Tue, Jun 16, 2020 at 6:57 PM David Woodhouse  wrote:
> > >
> > > On Tue, 2020-06-16 at 18:21 +0200, Michael Nazzareno Trimarchi wrote:
> > > > Hi David
> > > >
> > > > On Tue, Jun 16, 2020 at 6:16 PM David Woodhouse  
> > > > wrote:
> > > > >
> > > > > The Banana Pi R2 bootloader will load U-Boot from either the internal
> > > > > eMMC, or the external SD card if the latter is present.
> > > > >
> > > > > If booted from the eMMC (and an SD card is subsequently inserted), 
> > > > > both
> > > > > work from U-Boot. Both also work from Linux, whichever device is 
> > > > > booted
> > > > > from.
> > > > >
> > > > > If booted from SD, the internal eMMC cannot be accessed from U-Boot.
> > > > > This makes it slightly difficult for me to write a U-Boot script which
> > > > > installs OpenWRT from the SD card to the internal eMMC...
> > > >
> > > > I'm thinking that bootrom do the right job for you when both are 
> > > > working.
> > >
> > > Yes. It does seem likely that when loading U-Boot from the eMMC, the
> > > preloader is initialising it for us. But when the preloader loads
> > > U-Boot from the SD card, it possibly doesn't initialise the eMMC
> > > controller at all.
> > >
> > > The Linux driver does cope with this, and drives the internal eMMC.
> > > Perhaps there's just some init code missing from the U-Boot mtk-sd
> > > driver?
> >
> > what dts are you using and config? I don't find Banana PI R2
>
> It's mt7623n_bpir2_defconfig

Have you already tried to dump the pinmux using the cmd? in both
situation?

Micahel



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |


U-Boot atheros PHY support and cubox ethernet

2020-06-16 Thread Tom Rini
Hey all,

In commit 4346df3392c0 ("phy: atheros: Make RGMII Tx delays actually
configurable for AR8035") we brought in changes to get in to line with
upstream linux kernel support for this PHY and in turn deal with more
"driver was wrong, DT was wrong too" changes.  Now the problem I have is
that ethernet on my Hummingboard doesn't work AND as far as I can tell,
the DTB is correct and saying phy-mode = "rgmii-id" now not "rgmii".  It
also looks to match what's in v5.7 for the kernel.  What do I need to do
here next?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: U-Boot atheros PHY support and cubox ethernet

2020-06-16 Thread Vladimir Oltean
Hi Tom,

On Tue, 16 Jun 2020 at 22:55, Tom Rini  wrote:
>
> Hey all,
>
> In commit 4346df3392c0 ("phy: atheros: Make RGMII Tx delays actually
> configurable for AR8035") we brought in changes to get in to line with
> upstream linux kernel support for this PHY and in turn deal with more
> "driver was wrong, DT was wrong too" changes.  Now the problem I have is
> that ethernet on my Hummingboard doesn't work AND as far as I can tell,
> the DTB is correct and saying phy-mode = "rgmii-id" now not "rgmii".  It
> also looks to match what's in v5.7 for the kernel.  What do I need to do
> here next?  Thanks!
>
> --
> Tom

Reverting 4346df3392c0 makes your interface work?
What is the DTS path that your hummingboard uses?

Thanks,
-Vladimir


[PATCH v2 1/1] spl: fix ext4fs_mount return code handling

2020-06-16 Thread Heiko Thiery
From: Thomas Schaefer 

- Despite other ext4 filesystem functions, ext4fs_mount returns
  0 in case of error.
- This leads to u-boot crash in case that an SD card
  with valid partition table but without ext4 filesystem created
  in a partition is found on SD card.
- Fix this by returning a proper error code of '-1' from spl_load_image_ext
  function in case of ext4fs_mount error.

Signed-off-by: Thomas Schaefer 
[hthiery: slightly reword the commit message]
Signed-off-by: Heiko Thiery 
Reviewed-by: Tom Rini 
---
v1 -> v2:
 - directly return -1 instead of goto end (Tom Rini).
---

 common/spl/spl_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 3898041d10..d73f062762 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -32,7 +32,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: ext4fs mount err - %d\n", __func__, err);
 #endif
-   goto end;
+   return -1;
}
 
err = ext4fs_open(filename, &filelen);
-- 
2.20.1



Re: U-Boot atheros PHY support and cubox ethernet

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 10:58:26PM +0300, Vladimir Oltean wrote:
> Hi Tom,
> 
> On Tue, 16 Jun 2020 at 22:55, Tom Rini  wrote:
> >
> > Hey all,
> >
> > In commit 4346df3392c0 ("phy: atheros: Make RGMII Tx delays actually
> > configurable for AR8035") we brought in changes to get in to line with
> > upstream linux kernel support for this PHY and in turn deal with more
> > "driver was wrong, DT was wrong too" changes.  Now the problem I have is
> > that ethernet on my Hummingboard doesn't work AND as far as I can tell,
> > the DTB is correct and saying phy-mode = "rgmii-id" now not "rgmii".  It
> > also looks to match what's in v5.7 for the kernel.  What do I need to do
> > here next?  Thanks!
> >
> > --
> > Tom
> 
> Reverting 4346df3392c0 makes your interface work?

Yup.

> What is the DTS path that your hummingboard uses?

Good question.  Per board/solidrun/mx6cuboxi/mx6cuboxi.c:
/*
 * This is not a perfect match. Avoid dependency on the DM GPIO driver
 * needed
 * for accurate board detection. Hummingboard2 DT is good enough for
 * U-Boot on
 * all Hummingboard/Cubox-i platforms.
 */
so arch/arm/dts/imx6dl-hummingboard2-emmc-som-v15.dts is the base.  But
the board really is the original hummingboard platform.  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: U-Boot atheros PHY support and cubox ethernet

2020-06-16 Thread Vladimir Oltean
On Tue, 16 Jun 2020 at 23:10, Tom Rini  wrote:
>
> On Tue, Jun 16, 2020 at 10:58:26PM +0300, Vladimir Oltean wrote:
> > Hi Tom,
> >
> > On Tue, 16 Jun 2020 at 22:55, Tom Rini  wrote:
> > >
> > > Hey all,
> > >
> > > In commit 4346df3392c0 ("phy: atheros: Make RGMII Tx delays actually
> > > configurable for AR8035") we brought in changes to get in to line with
> > > upstream linux kernel support for this PHY and in turn deal with more
> > > "driver was wrong, DT was wrong too" changes.  Now the problem I have is
> > > that ethernet on my Hummingboard doesn't work AND as far as I can tell,
> > > the DTB is correct and saying phy-mode = "rgmii-id" now not "rgmii".  It
> > > also looks to match what's in v5.7 for the kernel.  What do I need to do
> > > here next?  Thanks!
> > >
> > > --
> > > Tom
> >
> > Reverting 4346df3392c0 makes your interface work?
>
> Yup.
>
> > What is the DTS path that your hummingboard uses?
>
> Good question.  Per board/solidrun/mx6cuboxi/mx6cuboxi.c:
> /*
>  * This is not a perfect match. Avoid dependency on the DM GPIO driver
>  * needed
>  * for accurate board detection. Hummingboard2 DT is good enough for
>  * U-Boot on
>  * all Hummingboard/Cubox-i platforms.
>  */
> so arch/arm/dts/imx6dl-hummingboard2-emmc-som-v15.dts is the base.  But
> the board really is the original hummingboard platform.  Thanks!
>
> --
> Tom

Does it work if you say PHY_INTERFACE_MODE_RGMII_ID here?
https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fec_mxc.c#L1232

-Vladimir


Re: U-Boot atheros PHY support and cubox ethernet

2020-06-16 Thread Tom Rini
On Tue, Jun 16, 2020 at 11:21:08PM +0300, Vladimir Oltean wrote:
> On Tue, 16 Jun 2020 at 23:10, Tom Rini  wrote:
> >
> > On Tue, Jun 16, 2020 at 10:58:26PM +0300, Vladimir Oltean wrote:
> > > Hi Tom,
> > >
> > > On Tue, 16 Jun 2020 at 22:55, Tom Rini  wrote:
> > > >
> > > > Hey all,
> > > >
> > > > In commit 4346df3392c0 ("phy: atheros: Make RGMII Tx delays actually
> > > > configurable for AR8035") we brought in changes to get in to line with
> > > > upstream linux kernel support for this PHY and in turn deal with more
> > > > "driver was wrong, DT was wrong too" changes.  Now the problem I have is
> > > > that ethernet on my Hummingboard doesn't work AND as far as I can tell,
> > > > the DTB is correct and saying phy-mode = "rgmii-id" now not "rgmii".  It
> > > > also looks to match what's in v5.7 for the kernel.  What do I need to do
> > > > here next?  Thanks!
> > > >
> > > > --
> > > > Tom
> > >
> > > Reverting 4346df3392c0 makes your interface work?
> >
> > Yup.
> >
> > > What is the DTS path that your hummingboard uses?
> >
> > Good question.  Per board/solidrun/mx6cuboxi/mx6cuboxi.c:
> > /*
> >  * This is not a perfect match. Avoid dependency on the DM GPIO driver
> >  * needed
> >  * for accurate board detection. Hummingboard2 DT is good enough for
> >  * U-Boot on
> >  * all Hummingboard/Cubox-i platforms.
> >  */
> > so arch/arm/dts/imx6dl-hummingboard2-emmc-som-v15.dts is the base.  But
> > the board really is the original hummingboard platform.  Thanks!
> >
> > --
> > Tom
> 
> Does it work if you say PHY_INTERFACE_MODE_RGMII_ID here?
> https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fec_mxc.c#L1232

No change.  And to be clear, I bisect'd the issue down and at that
commit, reverting it fixes ethernet.  It doesn't revert cleanly (nor
obviously to me) on master.

-- 
Tom


signature.asc
Description: PGP signature


  1   2   3   >