[PATCH v2 4/8] board: presidio-asic: Add I2C support

2020-02-26 Thread Alex Nemirovsky
Add I2C board support for Cortina Access Presidio Engineering Board

Signed-off-by: Alex Nemirovsky 
---

Changes in v2: None

 configs/cortina_presidio-asic-emmc_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cortina_presidio-asic-emmc_defconfig 
b/configs/cortina_presidio-asic-emmc_defconfig
index e10008a..e45e23c 100644
--- a/configs/cortina_presidio-asic-emmc_defconfig
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -10,6 +10,7 @@ CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_BOOTDELAY=3
 CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_WDT=y
@@ -24,6 +25,8 @@ CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
 # CONFIG_NET is not set
 CONFIG_DM=y
 CONFIG_CORTINA_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_CA=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_CORTINA=y
-- 
2.7.4



[PATCH v2 0/8] Cortina Access Drivers Package 2

2020-02-26 Thread Alex Nemirovsky


This release adds the following drivers and
integrates support  into the Cortina Access
Presidio Engineering Board:

CA SoC eMMC/SD controller
CA SoC I2C controller
CA Soc LED controller
CA SPI NAND and NOR controller

Changes in v2:
- Add I2C controller
- Add LED controller
- Add SPI NAND and NOR controller

Alex Nemirovsky (3):
  board: presidio-asic: Add eMMC board support
  board: presidio-asic: Add I2C support
  board: presidio-asic: Add SPI NAND and NOR support

Arthur Li (2):
  mmc: ca_dw_mmc: add DesignWare based DM support for CA SoCs
  i2c: i2c-cortina: added CA I2C support

Jway Lin (2):
  led: led_cortina: Add CAxxx LED support
  board: presidio: add LED support

Pengpeng Chen (1):
  spi: ca_sflash: Add CA SPI Flash Controller

 MAINTAINERS  |  10 +
 arch/arm/dts/ca-presidio-engboard.dts|  39 +-
 board/cortina/presidio-asic/presidio.c   |  16 +-
 configs/cortina_presidio-asic-emmc_defconfig |  38 ++
 configs/cortina_presidio-asic-spi-nand_defconfig |  48 ++
 configs/cortina_presidio-asic-spi-nor_defconfig  |  59 +++
 drivers/i2c/Kconfig  |   7 +
 drivers/i2c/Makefile |   1 +
 drivers/i2c/i2c-cortina.c| 346 ++
 drivers/i2c/i2c-cortina.h|  92 
 drivers/led/Kconfig  |   8 +
 drivers/led/Makefile |   1 +
 drivers/led/led_cortina.c| 308 
 drivers/mmc/Kconfig  |  11 +
 drivers/mmc/Makefile |   1 +
 drivers/mmc/ca_dw_mmc.c  | 181 +++
 drivers/spi/Kconfig  |   8 +
 drivers/spi/Makefile |   1 +
 drivers/spi/ca_sflash.c  | 575 +++
 19 files changed, 1744 insertions(+), 6 deletions(-)
 create mode 100644 configs/cortina_presidio-asic-emmc_defconfig
 create mode 100644 configs/cortina_presidio-asic-spi-nand_defconfig
 create mode 100644 configs/cortina_presidio-asic-spi-nor_defconfig
 create mode 100644 drivers/i2c/i2c-cortina.c
 create mode 100644 drivers/i2c/i2c-cortina.h
 create mode 100644 drivers/led/led_cortina.c
 create mode 100644 drivers/mmc/ca_dw_mmc.c
 create mode 100644 drivers/spi/ca_sflash.c

-- 
2.7.4



[PATCH v2 2/8] board: presidio-asic: Add eMMC board support

2020-02-26 Thread Alex Nemirovsky
Add initial eMMC support for Cortina Access Presidio
Engineering Board

Signed-off-by: Alex Nemirovsky 
---

Changes in v2: None

 configs/cortina_presidio-asic-emmc_defconfig | 33 
 1 file changed, 33 insertions(+)
 create mode 100644 configs/cortina_presidio-asic-emmc_defconfig

diff --git a/configs/cortina_presidio-asic-emmc_defconfig 
b/configs/cortina_presidio-asic-emmc_defconfig
new file mode 100644
index 000..e10008a
--- /dev/null
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -0,0 +1,33 @@
+CONFIG_ARM=y
+# CONFIG_SYS_ARCH_TIMER is not set
+CONFIG_TARGET_PRESIDIO_ASIC=y
+CONFIG_SYS_TEXT_BASE=0x0400
+CONFIG_ENV_SIZE=0x2
+CONFIG_DM_GPIO=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_IDENT_STRING="Presidio-SoC"
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_R=y
+CONFIG_SYS_PROMPT="G3#"
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_WDT=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_SMC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_DEFAULT_DEVICE_TREE="ca-presidio-engboard"
+# CONFIG_NET is not set
+CONFIG_DM=y
+CONFIG_CORTINA_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_CORTINA=y
+CONFIG_DM_SERIAL=y
+CONFIG_CORTINA_UART=y
+CONFIG_WDT=y
+CONFIG_WDT_CORTINA=y
-- 
2.7.4



[PATCH v2 1/8] mmc: ca_dw_mmc: add DesignWare based DM support for CAxxxx SoCs

2020-02-26 Thread Alex Nemirovsky
From: Arthur Li 

Initial DesignWare based DM support for Cortina Access CA SoCs.

Signed-off-by: Arthur Li 
Signed-off-by: Alex Nemirovsky 

---

Changes in v2:
- Add I2C controller
- Add LED controller
- Add SPI NAND and NOR controller

 MAINTAINERS |   2 +
 drivers/mmc/Kconfig |  11 +++
 drivers/mmc/Makefile|   1 +
 drivers/mmc/ca_dw_mmc.c | 181 
 4 files changed, 195 insertions(+)
 create mode 100644 drivers/mmc/ca_dw_mmc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 82e4159..bb45d3c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -180,6 +180,7 @@ F:  board/cortina/common/
 F: drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
+F: drivers/mmc/ca_dw_mmc.c
 
 ARM/CZ.NIC TURRIS MOX SUPPORT
 M: Marek Behun 
@@ -670,6 +671,7 @@ F:  board/cortina/common/
 F: drivers/gpio/cortina_gpio.c
 F: drivers/watchdog/cortina_wdt.c
 F: drivers/serial/serial_cortina.c
+F: drivers/mmc/ca_dw_mmc.c
 
 MIPS MSCC
 M: Gregory CLEMENT 
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 2f0eedc..bb38787 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -205,6 +205,17 @@ config MMC_DW
  block, this provides host support for SD and MMC interfaces, in both
  PIO, internal DMA mode and external DMA mode.
 
+config MMC_DW_CORTINA
+   bool "Cortina specific extensions for Synopsys DW Memory Card Interface"
+   depends on DM_MMC
+   depends on MMC_DW
+   depends on BLK
+   default n
+   help
+ This selects support for Cortina SoC specific extensions to the
+ Synopsys DesignWare Memory Card Interface driver. Select this option
+ for platforms based on Cortina CA Soc's.
+
 config MMC_DW_EXYNOS
bool "Exynos specific extensions for Synopsys DW Memory Card Interface"
depends on ARCH_EXYNOS
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 9c1f8e5..615b724 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -20,6 +20,7 @@ endif
 obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
 obj-$(CONFIG_MMC_DAVINCI)  += davinci_mmc.o
 obj-$(CONFIG_MMC_DW)   += dw_mmc.o
+obj-$(CONFIG_MMC_DW_CORTINA)   += ca_dw_mmc.o
 obj-$(CONFIG_MMC_DW_EXYNOS)+= exynos_dw_mmc.o
 obj-$(CONFIG_MMC_DW_K3)+= hi6220_dw_mmc.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)  += rockchip_dw_mmc.o
diff --git a/drivers/mmc/ca_dw_mmc.c b/drivers/mmc/ca_dw_mmc.c
new file mode 100644
index 000..acbc850
--- /dev/null
+++ b/drivers/mmc/ca_dw_mmc.c
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2019 Cortina Access
+ * Arthur Li 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SD_CLK_SEL_MASK (0x3)
+#define SD_DLL_DEFAULT  (0x143000)
+#define SD_SCLK_MAX (2)
+
+#define SD_CLK_SEL_200MHZ (0x2)
+#define SD_CLK_SEL_100MHZ (0x1)
+
+#define IO_DRV_SD_DS_OFFSET (16)
+#define IO_DRV_SD_DS_MASK   (0xff << IO_DRV_SD_DS_OFFSET)
+
+#define MIN_FREQ (40)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct ca_mmc_plat {
+   struct mmc_config cfg;
+   struct mmc mmc;
+};
+
+struct ca_dwmmc_priv_data {
+   struct dwmci_host host;
+   void __iomem *sd_dll_reg;
+   void __iomem *io_drv_reg;
+   u8 ds;
+};
+
+static void ca_dwmci_clksel(struct dwmci_host *host)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u32 val = readl(priv->sd_dll_reg);
+
+   if (host->bus_hz >= 2) {
+   val &= ~SD_CLK_SEL_MASK;
+   val |= SD_CLK_SEL_200MHZ;
+   } else if (host->bus_hz >= 1) {
+   val &= ~SD_CLK_SEL_MASK;
+   val |= SD_CLK_SEL_100MHZ;
+   } else {
+   val &= ~SD_CLK_SEL_MASK;
+   }
+
+   writel(val, priv->sd_dll_reg);
+}
+
+static void ca_dwmci_board_init(struct dwmci_host *host)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u32 val = readl(priv->io_drv_reg);
+
+   writel(SD_DLL_DEFAULT, priv->sd_dll_reg);
+
+   val &= ~IO_DRV_SD_DS_MASK;
+   if (priv && priv->ds)
+   val |= priv->ds << IO_DRV_SD_DS_OFFSET;
+   writel(val, priv->io_drv_reg);
+}
+
+unsigned int ca_dwmci_get_mmc_clock(struct dwmci_host *host, uint freq)
+{
+   struct ca_dwmmc_priv_data *priv = host->priv;
+   u8 sd_clk_sel = readl(priv->sd_dll_reg) & SD_CLK_SEL_MASK;
+   u8 clk_div;
+
+   switch (sd_clk_sel) {
+   case 2:
+   clk_div = 1;
+   break;
+   case 1:
+   clk_div = 2;
+   break;
+   default:
+   clk_div = 4;
+   }
+
+   return SD_SCLK_MAX / clk_div / (host->div + 1);
+}
+
+static int ca_dwmmc_ofdata_to_platdata(struct udevice *dev)
+{
+   struct ca_dwmmc_priv_data *priv = dev_get_priv(dev);
+   struct dwmci_host *host = 

Re: [PATCH 05/10] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()【请注意,邮件由s...@google.com代发】

2020-02-26 Thread Kever Yang

Hi Simon,

On 2020/2/20 上午10:23, Simon Glass wrote:

Hi Kever,

On Tue, 18 Feb 2020 at 18:55, Kever Yang  wrote:

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

Signed-off-by: Kever Yang 
---

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

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

-   plat->base = devfdt_get_addr(dev);
+   plat->base = dev_read_addr(dev);

-   plat->maximum_speed = usb_get_maximum_speed(node);
+   plat->maximum_speed = usb_get_maximum_speed(ofnode_to_offset(node));
 if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
 pr_info("No USB maximum speed specified. Using super speed\n");
 plat->maximum_speed = USB_SPEED_SUPER;
 }

-   plat->dr_mode = usb_get_dr_mode(node);
+   plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));

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



I do convert usb_get_dr_mode() to use livetree at 9/10 of this patch set.

I have to clean all the related code first, and then convert 
usb_get_dr_mode() and


usb_get_maximum_speed() to livetree one by one. If the convert happen first,

I have to merge the 3rd~10th patches into one patch and not so good for 
review.



Thanks,

- Kever




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


Regards,
Simon







Re: [PATCH 06/10] usb: host: dwc3-sti-glue: Migrate to use ofnode API

2020-02-26 Thread Kever Yang

Hi Patrice,

On 2020/2/20 下午4:53, Patrice CHOTARD wrote:

Hi Kever

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

Use ofnode_ instead of fdt_ or fdtdec_ APIs so that the driver can support
live DT.

Signed-off-by: Kever Yang 
---

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

diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index ad7cf6e6b5..36c7d4037c 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -10,8 +10,6 @@
  #include 
  #include 
  #include 
-#include 
-#include 
  #include 
  #include 
  #include 
@@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice 
*dev)
int ret;
u32 reg[4];
  
-	ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),

-  "reg", reg, ARRAY_SIZE(reg));
+   ret = ofnode_read_u32_array(dev->node, "reg", reg, ARRAY_SIZE(reg));
if (ret) {
pr_err("unable to find st,stih407-dwc3 reg property(%d)\n", 
ret);
return ret;
@@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct 
udevice *dev)
  static int sti_dwc3_glue_bind(struct udevice *dev)
  {
struct sti_dwc3_glue_platdata *plat = dev_get_platdata(dev);
-   int dwc3_node;
+   ofnode dwc3_node;
  
-	/* check if one subnode is present */

-   dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
-   if (dwc3_node <= 0) {
-   pr_err("Can't find subnode for %s\n", dev->name);
-   return -ENODEV;
+   /* Find snps,dwc3 node from subnode */
+   ofnode_for_each_subnode(node, dev->node) {
+   if (ofnode_device_is_compatible(node, "snps,dwc3"))
+   dwc3_node = node;
}
  
-	/* check if the subnode compatible string is the dwc3 one*/

-   if (fdt_node_check_compatible(gd->fdt_blob, dwc3_node,
- "snps,dwc3") != 0) {
+   if (!ofnode_valid(node)) {
pr_err("Can't find dwc3 subnode for %s\n", dev->name);
return -ENODEV;
}
  
  	/* retrieve the DWC3 dual role mode */

-   plat->mode = usb_get_dr_mode(dwc3_node);
+   plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node));
if (plat->mode == USB_DR_MODE_UNKNOWN)
/* by default set dual role mode to HOST */
plat->mode = USB_DR_MODE_HOST;

Using stih410-b2260_defconfig, this path doesn't compile, see below:

In file included from board/st/stih410-b2260/board.c:9:
include/linux/usb/otg.h:26:34: error: unknown type name ‘ofnode’
  enum usb_dr_mode usb_get_dr_mode(ofnode node);



This has been fixed in the version 2.

Thanks,

- Kever


   ^~
include/linux/usb/otg.h:35:45: error: unknown type name ‘ofnode’
  enum usb_device_speed usb_get_maximum_speed(ofnode node);
  ^~
   CC  drivers/spi/spi.o
   CC  drivers/usb/common/common.o
scripts/Makefile.build:278: recipe for target 'board/st/stih410-b2260/board.o' 
failed
make[1]: *** [board/st/stih410-b2260/board.o] Error 1
   CC  drivers/serial/serial_sti_asc.o
Makefile:1728: recipe for target 'board/st/stih410-b2260' failed
make: *** [board/st/stih410-b2260] Error 2
make: *** Waiting for unfinished jobs
   CC  drivers/usb/dwc3/core.o
   CC  drivers/usb/eth/usb_ether.o
   CC  drivers/usb/eth/asix.o
   CC  common/main.o
   CC  drivers/usb/eth/mcs7830.o
   CC  drivers/usb/gadget/epautoconf.o
   CC  drivers/fastboot/fb_getvar.o
   CC  drivers/usb/eth/smsc95xx.o
   LD  drivers/spi/built-in.o
   CC  drivers/usb/dwc3/gadget.o
   CC  cmd/version.o
   CC  drivers/usb/dwc3/ep0.o
   CC  drivers/usb/gadget/config.o
   LD  drivers/usb/common/built-in.o
   LD  drivers/serial/built-in.o
   LD  common/built-in.o
In file included from drivers/usb/dwc3/core.h:23,
  from drivers/usb/dwc3/gadget.c:28:
include/linux/usb/otg.h:26:34: error: unknown type name ‘ofnode’
  enum usb_dr_mode usb_get_dr_mode(ofnode node);
   ^~
In file included from drivers/usb/dwc3/core.h:23,
  from drivers/usb/dwc3/ep0.c:25:
include/linux/usb/otg.h:26:34: error: unknown type name ‘ofnode’
  enum usb_dr_mode usb_get_dr_mode(ofnode node);
   ^~
   CC  drivers/usb/gadget/usbstring.o
include/linux/usb/otg.h:35:45: error: unknown type name ‘ofnode’
  enum usb_device_speed usb_get_maximum_speed(ofnode node);
  ^~
include/linux/usb/otg.h:35:45: error: unknown type name ‘ofnode’
  enum usb_device_speed usb_get_maximum_speed(ofnode node);
  ^~
   CC  drivers/usb/gadget/g_dnl.o
scripts/Makefile.build:278: recipe for target 

Re: [PATCH v6 16/16] travis: add packages for UEFI secure boot test

2020-02-26 Thread AKASHI Takahiro
On Wed, Feb 26, 2020 at 09:28:56AM -0500, Tom Rini wrote:
> On Wed, Feb 26, 2020 at 01:54:48PM +0900, AKASHI Takahiro wrote:
> 
> > Pytest for UEFI secure boot will use several host commands.
> > In particular, Test setup relies on efitools, whose version must be v1.5.2
> > or later. So fetch a new version of deb package directly.
> > Please note it has a dependency on mtools, which must also be installed
> > along wih efitools.
> > 
> > In addition, the path, '/sbin', is added to PATH for use of sgdisk and
> > mkfs.
> > 
> > Signed-off-by: AKASHI Takahiro 
> 
> Note that I just re-reviewed the Dockerfile for Azure / GitLab and all
> of the listed tools as well as updated efitools are already included.
> So the expectation is that when the tests are enabled, Azure / GitLab
> should run them and succeed.
> 
> Reviewed-by: Tom Rini 

Thank you for the confirmation!
-Takahiro Akashi


> -- 
> Tom




Re: [PATCH] misc: k3_avs: Fix possible NULL pointer deference

2020-02-26 Thread Lokesh Vutla



On 14/02/20 5:52 PM, Vignesh Raghavendra wrote:
> Its possible that k3_avs_priv is NULL because the driver may not have
> been probed yet. Therefore check if pointer is valid before
> dereferencing it.
> 
> Signed-off-by: Vignesh Raghavendra 

Applied to u-boot-ti

Thanks and regards,
Lokesh



Re: [U-Boot] [PATCH] defconfig: k2x_hs: Remove DTB_RESELECT to fix DHCP issue

2020-02-26 Thread Lokesh Vutla



On 14/02/20 7:35 PM, Andrew F. Davis wrote:
> From: Madan Srinivas 
> 
> This fixes the inadvertent definition of CONFIG_DTB_RESELECT and
> CONFIG_MULTI_DTB_FIT in the K2x HS defconfigs, that happened as part of
> a resync of the defconfigs.
> 
> The inclusion of these config options causes ethernet to stop working on
> K2x HS devices as they interfere with the installation of the secure
> boot monitor.
> 
> This patch also removes the above configs for the K2 GP devices, as they
> are not needed, and to keep the differences between the GP and HS
> defconfigs to a minimum.
> 
> Signed-off-by: Madan Srinivas 
> Signed-off-by: Andrew F. Davis 

Applied to u-boot-ti

Thanks and regards,
Lokesh


[GIT PULL] TI changes for v2020.04-rc4

2020-02-26 Thread Lokesh Vutla
Hi Tom,

Please find the pull request for v2020.04-rc4 containing TI specific changes.

Travis-CI build: https://travis-ci.org/lokeshvutla/u-boot/builds/655346045 

Thanks and regards,
Lokesh

The following changes since commit 548ce227d3d852455c6395c0cec30af0cda77b09:

  Prepare v2020.04-rc3 (2020-02-26 07:53:20 -0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-ti.git tags/ti-v2020.04-rc4

for you to fetch changes up to 8bef0597e46db229220de3a9c76bf448b290db62:

  defconfig: k2x_hs: Remove DTB_RESELECT to fix DHCP issue (2020-02-26 18:35:29 
+0530)


Below are the changes in this PR:

- Minor fix in AVS class 0 driver
- DHCP fixes in Keystone2 HS platforms.


Madan Srinivas (1):
  defconfig: k2x_hs: Remove DTB_RESELECT to fix DHCP issue

Vignesh Raghavendra (1):
  misc: k3_avs: Fix possible NULL pointer deference

 configs/k2e_evm_defconfig | 2 --
 configs/k2e_hs_evm_defconfig  | 2 --
 configs/k2hk_evm_defconfig| 2 --
 configs/k2hk_hs_evm_defconfig | 2 --
 configs/k2l_evm_defconfig | 2 --
 drivers/misc/k3_avs.c | 4 
 6 files changed, 4 insertions(+), 10 deletions(-)

-- 
2.23.0



Re: [PATCH v3][ 4/6] board: tbs2910: enable CONFIG_DISTRO_DEFAULTS

2020-02-26 Thread Denis 'GNUtoo' Carikli
On Mon, 10 Feb 2020 09:40:50 -0500
Tom Rini  wrote:
> That said, the "bring in PXE" part of DISTRO_DEFAULTS predates sysboot
> being pulled out of the PXE code, where it was historically
> introduced. I would like to see a patch to change this part,
> stand-alone and CC'ing the distribution folks that might have
> something to say about this.  I know there are use-cases for it, but
> I don't know how critical they are to be everywhere by default vs
> opt-in.  Thanks all!
I've done the patch, but I've not sent it yet.

With it, if board are using things like func(PXE, pxe, na) in
BOOT_TARGET_DEVICES, it will breaks the compilation, and we would have
an error that looks like that:
> In file included from include/configs/tbs2910.h:19,
>  from include/config.h:5,
>  from include/common.h:16,
>  from env/common.c:10:
> include/config_distro_bootcmd.h:398:2: error: expected '}' before
> 'BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE'
> 398 |
> BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE

Should I still send the patch as-is by mentioning that issue somehow,
in order to start a discussion on the topic?

Or would I need to do more in depth changes before sending the patch?

In the later case I would also need to find some time to do that, so it
might not be done that fast.

Denis.


pgptxkGO6brFq.pgp
Description: OpenPGP digital signature


[PATCH][v4 5/6] board: tbs2910: Enable distro_boot support.

2020-02-26 Thread Denis 'GNUtoo' Carikli
This keeps the compatibility with the old bootcmd.

The fdtfile environment variable also needed to be set to
imx6q-tbs2910.dtb to enable booting mainline kernels
otherwise with extlinux.conf it tries to load
mx6-tbs2910.dtb instead.

With arm-linux-gnueabi-gcc 9.2.0-1 from the Parabola
GNU/Linux distribution, we have the following size
differences:
- text: +2041 bytes
- data: 0 bytes
- bss: 0 bytes
- total: +2041 bytes

Signed-off-by: Denis 'GNUtoo' Carikli 
---
Changelog:
In addition to the changes requested I also did the
following changes:
- I removed func(PXE, pxe, na) from the BOOT_TARGET_DEVICES
- I removed func(DHCP, dhcp, na) from the BOOT_TARGET_DEVICES
---
 configs/tbs2910_defconfig |  3 ++-
 include/configs/tbs2910.h | 19 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 1cf09bb741..b3a8e11a57 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -11,10 +11,11 @@ CONFIG_CMD_HDMIDETECT=y
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=3
-CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else 
run bootcmd_mmc; fi"
+CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else 
run bootcmd_mmc || run distro_bootcmd; fi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start; if hdmidet; then run 
set_con_hdmi; else run set_con_serial; fi"
 CONFIG_PRE_CONSOLE_BUFFER=y
+CONFIG_DEFAULT_FDT_FILE="imx6q-tbs2910.dtb"
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SYS_PROMPT="Matrix U-Boot> "
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index 3975f4cc8b..9380406529 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -8,6 +8,15 @@
 #ifndef __TBS2910_CONFIG_H
 #define __TBS2910_CONFIG_H
 
+#define BOOT_TARGET_DEVICES(func) \
+   func(MMC, mmc, 0) \
+   func(MMC, mmc, 1) \
+   func(MMC, mmc, 2) \
+   func(SATA, sata, 0) \
+   func(USB, usb, 0)
+
+#include 
+
 #include "mx6_common.h"
 
 /* General configuration */
@@ -80,6 +89,12 @@
 #define CONFIG_BOARD_SIZE_LIMIT392192 /* (CONFIG_ENV_OFFSET - 
1024) */
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
+   "fdt_addr=0x1300\0" \
+   "fdt_addr_r=0x1300\0" \
+   "kernel_addr_r=0x10008000\0" \
+   "pxefile_addr_r=0x10008000\0" \
+   "ramdisk_addr_r=0x1800\0" \
+   "scriptaddr=0x1400\0" \
"bootargs_mmc1=console=ttymxc0,115200 di0_primary console=tty1\0" \
"bootargs_mmc2=video=mxcfb0:dev=hdmi,1920x1080M@60 " \
"video=mxcfb1:off video=mxcfb2:off fbmem=28M\0" \
@@ -102,6 +117,8 @@
"setenv stderr serial,vga\0" \
"stderr=serial,vga\0" \
"stdin=serial,usbkbd\0" \
-   "stdout=serial,vga\0"
+   "stdout=serial,vga\0" \
+   "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
+   BOOTENV
 
 #endif/* __TBS2910_CONFIG_H * */
-- 
2.25.1



[PATCH][v4 6/6] board: tbs2910: add documentation

2020-02-26 Thread Denis 'GNUtoo' Carikli
This documents the u-boot installation procedure and the
hardware in order to get started.

Signed-off-by: Denis 'GNUtoo' Carikli 
---
 doc/board/index.rst   |   1 +
 doc/board/tbs/index.rst   |   9 ++
 doc/board/tbs/tbs2910.rst | 179 ++
 3 files changed, 189 insertions(+)
 create mode 100644 doc/board/tbs/index.rst
 create mode 100644 doc/board/tbs/tbs2910.rst

diff --git a/doc/board/index.rst b/doc/board/index.rst
index b8b956d730..4564c8245f 100644
--- a/doc/board/index.rst
+++ b/doc/board/index.rst
@@ -16,4 +16,5 @@ Board-specific doc
renesas/index
rockchip/index
sifive/index
+   tbs/index
xilinx/index
diff --git a/doc/board/tbs/index.rst b/doc/board/tbs/index.rst
new file mode 100644
index 00..b677bc624f
--- /dev/null
+++ b/doc/board/tbs/index.rst
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+TBS
+===
+
+.. toctree::
+   :maxdepth: 2
+
+   tbs2910
diff --git a/doc/board/tbs/tbs2910.rst b/doc/board/tbs/tbs2910.rst
new file mode 100644
index 00..2fc84c66ec
--- /dev/null
+++ b/doc/board/tbs/tbs2910.rst
@@ -0,0 +1,179 @@
+TBS2910 Matrix ARM miniPC
+=
+
+Building
+
+To build u-boot for the TBS2910 Matrix ARM miniPC, you can use the following
+procedure:
+
+First add the ARM toolchain to your PATH
+
+Then setup the ARCH and cross compilation environment variables.
+
+When this is done you can then build u-boot for the TBS2910 Matrix ARM miniPC
+with the following commands:
+
+.. code-block:: none
+
+   make mrproper
+   make tbs2910_defconfig
+   make
+
+Once the build is complete, you can find the resulting image as u-boot.imx in
+the current directory.
+
+UART
+
+The UART voltage is at 3.3V and its settings are 115200bps 8N1
+
+BOOT/UPDATE boot switch:
+
+The BOOT/UPDATE switch (SW11) is connected to the BOOT_MODE0 and
+BOOT_MODE1 SoC pins. It has "BOOT" and "UPDATE" markings both on
+the PCB and on the plastic case.
+
+When set to the "UPDATE" position, the SoC will use the "Boot From Fuses"
+configuration, and since BT_FUSE_SEL is 0, this makes the SOC jump to serial
+downloader.
+
+When set in the "BOOT" position, the SoC will use the "Internal boot"
+configuration, and since BT_FUSE_SEL is 0, it will then use the GPIO pins
+for the boot configuration.
+
+SW6 binary DIP switch array on the PCB revision 2.1:
+
+On that PCB revision, SW6 has 8 positions.
+
+Switching a position to ON sets the corresponding
+register to 1.
+
+See the following table for a correspondence between the switch positions and
+registers:
+
+===
+Switch positionRegister
+===
+1  BOOT_CFG2[3]
+2  BOOT_CFG2[4]
+3  BOOT_CFG2[5]
+4  BOOT_CFG2[6]
+5  BOOT_CFG1[4]
+6  BOOT_CFG1[5]
+7  BOOT_CFG1[6]
+8  BOOT_CFG1[7]
+===
+
+For example:
+
+  - To boot from the eMMC: 1:ON , 2:ON, 3:ON, 4:OFF, 5:OFF, 6:ON, 7:ON, 8:ON
+  - To boot from the microSD slot: 1: ON, 2: OFF, 3: OFF, 4: OFF, 5:OFF, 6:OFF,
+7:ON, 8:OFF
+  - To boot from the SD slot: 1: OFF, 2: ON, 3: OFF, 4: OFF, 5:OFF, 6:OFF, 
7:ON,
+8:OFF
+  - To boot from SATA: 5:OFF, 6:ON, 7:OFF, 8:OFF
+
+You can refer to the BOOT_CFG registers in the I.MX6Q reference manual for
+additional details.
+
+SW6 binary DIP switch array on the PCB revision 2.3:
+
+On that PCB revision, SW6 has only 4 positions.
+
+Switching a position to ON sets the corresponding
+register to 1.
+
+See the following table for a correspondence between the switch positions and
+registers:
+
+===
+Switch positionRegister
+===
+1  BOOT_CFG2[3]
+2  BOOT_CFG2[4]
+3  BOOT_CFG2[5]
+4  BOOT_CFG1[5]
+===
+
+For example:
+
+- To boot from the eMMC: 1:ON, 2:ON, 3:ON, 4:ON
+- To boot from the microSD slot: 1:ON, 2:OFF, 3:OFF, 4:OFF
+- To boot from the SD slot: 1:OFF, 2:ON, 3:OFF, 4:OFF
+
+You can refer to the BOOT_CFG registers in the I.MX6Q reference manual for
+additional details.
+
+Loading u-boot from USB:
+
+If you need to load u-boot from USB, you can use the following instructions:
+
+First build imx_usb_loader, as we will need it to load u-boot from USB. This
+can be done with the following commands:
+
+.. code-block:: none
+
+   git clone git://github.com/boundarydevices/imx_usb_loader.git
+   cd imx_usb_loader
+   make
+
+This will create the resulting imx_usb binary.
+
+When this is done, you can copy the u-boot.imx image that you built earlier
+in in the imx_usb_loader directory.
+
+You will then need to power off the TBS2910 Matrix ARM miniPC and make sure 
that
+the boot switch is 

[PATCH][v4 3/6] board: tbs2910: move CONFIG_BOOTCOMMAND from header to defconfig

2020-02-26 Thread Denis 'GNUtoo' Carikli
This doesn't affect the size of the image: with
arm-linux-gnueabi-gcc 9.2.0-1 from the Parabola GNU/Linux
distribution, the text, data, bss and total sizes remain
unchanged.

Signed-off-by: Denis 'GNUtoo' Carikli 
---
 configs/tbs2910_defconfig | 2 ++
 include/configs/tbs2910.h | 8 
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index fcaa101044..5603bef64e 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -10,6 +10,8 @@ CONFIG_PRE_CON_BUF_ADDR=0x7c00
 CONFIG_CMD_HDMIDETECT=y
 CONFIG_AHCI=y
 CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else 
run bootcmd_mmc; fi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start; if hdmidet; then run 
set_con_hdmi; else run set_con_serial; fi"
 CONFIG_PRE_CONSOLE_BUFFER=y
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index b598fca1ec..3975f4cc8b 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -104,12 +104,4 @@
"stdin=serial,usbkbd\0" \
"stdout=serial,vga\0"
 
-#define CONFIG_BOOTCOMMAND \
-   "mmc rescan; " \
-   "if run bootcmd_up1; then " \
-   "run bootcmd_up2; " \
-   "else " \
-   "run bootcmd_mmc; " \
-   "fi"
-
 #endif/* __TBS2910_CONFIG_H * */
-- 
2.25.1



[PATCH][v4 4/6] board: tbs2910: enable CONFIG_DISTRO_DEFAULTS

2020-02-26 Thread Denis 'GNUtoo' Carikli
The side effect is that it increase the size of the
resultimg image, which is already very close to the
size limit.

With arm-linux-gnueabi-gcc 9.2.0-1 from the Parabola
GNU/Linux distribution, we have the following size
increase:
- text: 8744 bytes
- data: 132 bytes
- bss: 60 bytes
- total: 8936 bytes

Signed-off-by: Denis 'GNUtoo' Carikli 
---
 configs/tbs2910_defconfig | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 5603bef64e..1cf09bb741 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -9,18 +9,15 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_PRE_CON_BUF_ADDR=0x7c00
 CONFIG_CMD_HDMIDETECT=y
 CONFIG_AHCI=y
+CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=3
-CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="mmc rescan; if run bootcmd_up1; then run bootcmd_up2; else 
run bootcmd_mmc; fi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="echo PCI:; pci enum; pci 1; usb start; if hdmidet; then run 
set_con_hdmi; else run set_con_serial; fi"
 CONFIG_PRE_CONSOLE_BUFFER=y
-CONFIG_SUPPORT_RAW_INITRD=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOARD_EARLY_INIT_F=y
-CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="Matrix U-Boot> "
-CONFIG_CMD_BOOTZ=y
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
 # CONFIG_BOOTM_VXWORKS is not set
@@ -31,22 +28,14 @@ CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
-CONFIG_CMD_PART=y
 CONFIG_CMD_PCI=y
 CONFIG_CMD_SATA=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_MII=y
-CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_EXT4=y
 CONFIG_CMD_EXT4_WRITE=y
-CONFIG_CMD_FAT=y
-CONFIG_CMD_FS_GENERIC=y
-CONFIG_EFI_PARTITION=y
+# CONFIG_ISO_PARTITION is not set
 CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-tbs2910"
@@ -76,7 +65,6 @@ CONFIG_RTC_DS1307=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
-CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
 CONFIG_USB_GADGET=y
-- 
2.25.1



[PATCH][v4 2/6] board: tbs2910: disable CONFIG_GZIP

2020-02-26 Thread Denis 'GNUtoo' Carikli
As that the resulting image is already very close to the
size limit, and that CONFIG_GZIP is not strictly required,
removing it shouldn't hurt.

With arm-linux-gnueabi-gcc 9.2.0-1 from the Parabola
GNU/Linux distribution we have the following size
reduction:
- text: 9752
- data: 0
- bss: 16
- total: 9768

Signed-off-by: Denis 'GNUtoo' Carikli 
---
 configs/tbs2910_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 570ae850e4..fcaa101044 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -86,5 +86,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_I2C_EDID=y
 CONFIG_VIDEO_IPUV3=y
 CONFIG_VIDEO=y
+# CONFIG_GZIP is not set
 CONFIG_OF_LIBFDT_ASSUME_MASK=0xff
 # CONFIG_EFI_LOADER is not set
-- 
2.25.1



[PATCH][v4 1/6] board: tbs2910: disable loadb and loads commands

2020-02-26 Thread Denis 'GNUtoo' Carikli
The loadb and loads commands are not needed for booting.

There are also more reliable and faster alternatives to
loadb and loads that can be used with the current configuration.

As that the resulting image is already very close to the
size limit, removing the loadb and loads commands shouldn't
hurt.

With arm-linux-gnueabi-gcc 9.2.0-1 from the Parabola
GNU/Linux distribution we have the following size
reduction:
- text: 6733 bytes
- data: 116 bytes
- bss: 1172 bytes
- total: 8021 bytes

Acked-by: Soeren Moch 
Signed-off-by: Denis 'GNUtoo' Carikli 
---
 configs/tbs2910_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 61d4c74324..570ae850e4 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -26,6 +26,8 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_PCI=y
-- 
2.25.1



Re: [PATCH 4/4] imx: pmic: Set proper pmic name for iMX53 HSC|DDC boards

2020-02-26 Thread Jaehoon Chung
On 2/26/20 8:37 PM, Lukasz Majewski wrote:
> After the
> commit 4213609cc7fb ("drivers: core: use strcmp when find device by name")
> the exact DTS node name for PMIC device must be provided.
> 
> This patch fixes this issue by providing full DTS node name ('mc34708@8').
> 
> Signed-off-by: Lukasz Majewski 

Reviewed-by: Jaehoon Chug 

> ---
> 
>  board/k+p/kp_imx53/kp_imx53.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/k+p/kp_imx53/kp_imx53.c b/board/k+p/kp_imx53/kp_imx53.c
> index 2f57310e27..eb5b67d1e6 100644
> --- a/board/k+p/kp_imx53/kp_imx53.c
> +++ b/board/k+p/kp_imx53/kp_imx53.c
> @@ -48,7 +48,7 @@ static int power_init(void)
>   struct udevice *dev;
>   int ret;
>  
> - ret = pmic_get("mc34708", );
> + ret = pmic_get("mc34708@8", );
>   if (ret) {
>   printf("%s: mc34708 not found !\n", __func__);
>   return ret;
> 



sunxi: Pine A64 LTS crashes for make pine64-lts_defconfig + CONFIG_LOG

2020-02-26 Thread Heinrich Schuchardt

Hello Jagan, hello Maxime,

when I try to enable additional options in .config for the Pine A64 LTS
I end up in an endless loop returning into the ARM trusted firmware
(ATF) and then SPL.

Do you have an idea where to search? Do we run into an image size problem?

Here is an example:

make pine64-lts_defconfig

CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=6
CONFIG_LOG_CONSOLE=y

make

U-Boot SPL 2020.04-rc3-dirty (Feb 26 2020 - 22:23:31 +)
DRAM:MBUS port 0 cfg0 00ad cfg1 00500064
MBUS port 1 cfg0 0608 cfg1 01000578
MBUS port 2 cfg0 020d cfg1 00600100
MBUS port 3 cfg0 0109 cfg1 00640050
MBUS port 4 cfg0 0709 cfg1 01000640
MBUS port 5 cfg0 0109 cfg1 0080
MBUS port 6 cfg0 0109 cfg1 00400080
MBUS port 7 cfg0 010d cfg1 00400080
MBUS port 8 cfg0 010d cfg1 00400080
MBUS port 9 cfg0 0409 cfg1 00400100
MBUS port 10 cfg0 2209 cfg1 08001800
MBUS port 11 cfg0 0509 cfg1 00400090
 2048 MiB
SPL malloc() before relocation used 0x0 bytes (0 KB)
>>SPL: board_init_r()
Trying to boot from MMC1
init mmc 0 resource
init mmc 0 clock and io
mmc 0 set mod-clk req 2400 parent 2400 n 1 m 1 rate 2400
init mmc 2 resource
init mmc 2 clock and io
mmc 2 set mod-clk req 2400 parent 2400 n 1 m 1 rate 2400
clock is disabled (0Hz)
set ios: bus_width: 0, clock: 0
set ios: bus_width: 1, clock: 0
clock is enabled (40Hz)
set ios: bus_width: 1, clock: 40
mmc 0 set mod-clk req 40 parent 2400 n 4 m 15 rate 40
mmc 0, cmd 0(0x80008000), arg 0x
mmc resp 0x
mmc 0, cmd 8(0x8148), arg 0x01aa
mmc resp 0x01aa
mmc 0, cmd 55(0x8177), arg 0x
mmc resp 0x0120
mmc 0, cmd 41(0x8069), arg 0x4030
mmc resp 0x40ff8000
mmc 0, cmd 55(0x8177), arg 0x
mmc resp 0x0120
mmc 0, cmd 41(0x8069), arg 0x4030
mmc resp 0xc0ff8000
mmc 0, cmd 2(0x81c2), arg 0x
mmc resp 0x0600db0b 0x80009d5a 0x55333247 0x03534453
mmc 0, cmd 3(0x8143), arg 0x
mmc resp 0x0520
mmc 0, cmd 9(0x81c9), arg 0x
mmc resp 0x0a4040c3 0xedc87f80 0x5b59 0x400e0032
mmc 0, cmd 7(0x8147), arg 0x
mmc resp 0x0700
mmc 0, cmd 55(0x8177), arg 0x
mmc resp 0x0920
mmc 0, cmd 51(0x80002373), arg 0x
trans data 8 bytes
cacl timeout 78 msec
mmc resp 0x0920
mmc 0, cmd 6(0x80002346), arg 0x00f1
trans data 64 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc 0, cmd 55(0x8177), arg 0x
mmc resp 0x0920
mmc 0, cmd 6(0x8146), arg 0x0002
mmc resp 0x0920
set ios: bus_width: 4, clock: 40
mmc 0 set mod-clk req 40 parent 2400 n 4 m 15 rate 40
mmc 0, cmd 6(0x80002346), arg 0x80f1
trans data 64 bytes
cacl timeout 78 msec
mmc resp 0x0900
clock is enabled (5000Hz)
set ios: bus_width: 4, clock: 5000
mmc 0 set mod-clk req 5000 parent 6 n 1 m 12 rate 5000
spl: mmc boot mode: raw
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 17(0x80002351), arg 0x0050
trans data 512 bytes
cacl timeout 78 msec
mmc resp 0x0900
hdr read sector 50, count=1
Found FIT
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 18(0x80003352), arg 0x0050
trans data 1024 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc cmd 12 check rsp busy
fit read sector 50, sectors=2, dst=49fffa40, count=2, size=0x394
Selecting config 'sun50i-a64-pine64-lts'firmware: 'uboot'
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 18(0x80003352), arg 0x0051
trans data 635904 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc cmd 12 check rsp busy
External data: dst=4a00, offset=394, size=9b218
Selecting config 'sun50i-a64-pine64-lts'fdt: 'fdt_1'
Can't get 'load' property from FIT 0x49fffa40, node: offset 436, name
fdt_1 (FDT_ERR_NOTFOUND)
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 18(0x80003352), arg 0x0583
trans data 19968 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc cmd 12 check rsp busy
External data: dst=4a09b240, offset=a6734, size=4b6d
Selecting config 'sun50i-a64-pine64-lts'loadables: 'atf'
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 18(0x80003352), arg 0x052a
trans data 46080 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc cmd 12 check rsp busy
External data: dst=44000, offset=9b5ac, size=b185
Selecting config 'sun50i-a64-pine64-lts'fdt: 'fdt_1'
Can't get 'load' property from FIT 0x49fffa40, node: offset 436, name
fdt_1 (FDT_ERR_NOTFOUND)
mmc 0, cmd 16(0x8150), arg 0x0200
mmc resp 0x0900
mmc 0, cmd 18(0x80003352), arg 0x0583
trans data 19968 bytes
cacl timeout 78 msec
mmc resp 0x0900
mmc cmd 12 check rsp busy
External data: dst=4f1c0, offset=a6734, size=4b6d
Selecting config 'sun50i-a64-pine64-lts'no string for index 1
Jumping to U-Boot
SPL malloc() used 0x330 bytes (0 KB)
loaded - jumping to U-Boot...
image entry point: 0x44000
NOTICE:  BL31: v2.2(debug):v2.2-784-g896d684de

Re: [PATCH 1/2] rpi: add an RPi Kconfig to configure size of initial page reservation

2020-02-26 Thread Kyle Evans
On Wed, Feb 26, 2020 at 3:38 PM  wrote:
>
> From: Kyle Evans 
>
> While the nearly-universal default for the Raspberry Pi family is to use
> spin tables and the spin table implementation provided by the Raspberry Pi
> Foundation, FreeBSD and others may use a PSCI implementation instead.
>
> Accommodate these setups by allowing them to configure for more than one
> page to be reserved in the initial reservation.  The default reservation
> remains as one page.
>

Apologies... this patch 1/2 was a mis-fire, to be replaced by "[PATCH
1/2] rpi: Kconfig option for initial page reservation" -- perhaps time
to step away from the terminal for the day.


[PATCH 2/2] rpi: use the newly-added RPI_EFI_NR_SPIN_PAGES

2020-02-26 Thread kevans
From: Kyle Evans 

Some systems may use a slightly larger stub to do PSCI for booting the RPi
family.  The number of pages has been made configurable so that operating
systems building U-Boot for use in these kinds of environments can reserve
more memory in the EFI memory map.

Signed-off-by: Kyle Evans 
---
 board/raspberrypi/rpi/rpi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index e367ba3092..0206a093d4 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -489,7 +489,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 
 #ifdef CONFIG_EFI_LOADER
/* Reserve the spin table */
-   efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
+   efi_add_memory_map(0, CONFIG_RPI_EFI_NR_SPIN_PAGES,
+  EFI_RESERVED_MEMORY_TYPE, 0);
 #endif
 
return 0;
-- 
2.25.1



[PATCH 1/2] rpi: Kconfig option for initial page reservation

2020-02-26 Thread kevans
From: Kyle Evans 

While the nearly-universal default for the Raspberry Pi family is to use
spin tables and the spin table implementation provided by the Raspberry Pi
Foundation, FreeBSD and others may use a PSCI implementation instead.

Accommodate these setups by allowing them to configure for more than one
page to be reserved in the initial reservation.  The default reservation
remains as one page.

Signed-off-by: Kyle Evans 
---
 arch/arm/mach-bcm283x/Kconfig |  2 ++
 board/raspberrypi/rpi/Kconfig | 10 ++
 2 files changed, 12 insertions(+)
 create mode 100644 board/raspberrypi/rpi/Kconfig

diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
index 00419bf254..e6eb904e7f 100644
--- a/arch/arm/mach-bcm283x/Kconfig
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -209,4 +209,6 @@ config SYS_SOC
 config SYS_CONFIG_NAME
default "rpi"
 
+source "board/raspberrypi/rpi/Kconfig"
+
 endmenu
diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig
new file mode 100644
index 00..e40088fde1
--- /dev/null
+++ b/board/raspberrypi/rpi/Kconfig
@@ -0,0 +1,10 @@
+if SYS_BOARD = "rpi"
+
+config RPI_EFI_NR_SPIN_PAGES
+   int "Spin table page count"
+   default 1
+   help
+ Number of pages to reserve starting at page 0 for spin tables in the 
EFI
+ memory map
+
+endif
-- 
2.25.1



[PATCH 1/2] rpi: add an RPi Kconfig to configure size of initial page reservation

2020-02-26 Thread kevans
From: Kyle Evans 

While the nearly-universal default for the Raspberry Pi family is to use
spin tables and the spin table implementation provided by the Raspberry Pi
Foundation, FreeBSD and others may use a PSCI implementation instead.

Accommodate these setups by allowing them to configure for more than one
page to be reserved in the initial reservation.  The default reservation
remains as one page.

Signed-off-by: Kyle Evans 
---
 arch/arm/mach-bcm283x/Kconfig |  2 ++
 board/raspberrypi/rpi/Kconfig | 10 ++
 2 files changed, 12 insertions(+)
 create mode 100644 board/raspberrypi/rpi/Kconfig

diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
index 00419bf254..e6eb904e7f 100644
--- a/arch/arm/mach-bcm283x/Kconfig
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -209,4 +209,6 @@ config SYS_SOC
 config SYS_CONFIG_NAME
default "rpi"
 
+source "board/raspberrypi/rpi/Kconfig"
+
 endmenu
diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig
new file mode 100644
index 00..e40088fde1
--- /dev/null
+++ b/board/raspberrypi/rpi/Kconfig
@@ -0,0 +1,10 @@
+if SYS_BOARD = "rpi"
+
+config RPI_EFI_NR_SPIN_PAGES
+   int "Spin table page count"
+   default 1
+   help
+ Number of pages to reserve starting at page 0 for spin tables in the 
EFI
+ memory map
+
+endif
-- 
2.25.1



[PATCH v5 5/6] test: log: test syslog logging driver

2020-02-26 Thread Heinrich Schuchardt
Provide unit tests for the syslog logging driver.

Signed-off-by: Heinrich Schuchardt 
---
v5:
no change
v4:
provide more comments
move uts and expected to a common structure
expect 'uboot:' not 'uboot[1]:' in syslog message
v3:
new patch
---
 test/log/Makefile  |   4 +
 test/log/syslog_test.c | 280 +
 2 files changed, 284 insertions(+)
 create mode 100644 test/log/syslog_test.c

diff --git a/test/log/Makefile b/test/log/Makefile
index 98178f5e2b..4c92550f6e 100644
--- a/test/log/Makefile
+++ b/test/log/Makefile
@@ -8,6 +8,10 @@ ifdef CONFIG_UT_LOG

 obj-y += test-main.o

+ifdef CONFIG_SANDBOX
+obj-$(CONFIG_LOG_SYSLOG) += syslog_test.o
+endif
+
 ifndef CONFIG_LOG
 obj-$(CONFIG_CONSOLE_RECORD) += nolog_test.o
 endif
diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c
new file mode 100644
index 00..6ca5760eac
--- /dev/null
+++ b/test/log/syslog_test.c
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020, Heinrich Schuchardt 
+ *
+ * Logging function tests for CONFIG_LOG_SYSLOG=y.
+ *
+ * Invoke the test with: ./u-boot -d arch/sandbox/dts/test.dtb
+ */
+
+/* Override CONFIG_LOG_MAX_LEVEL */
+#define LOG_DEBUG
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/**
+ * struct sb_log_env - private data for sandbox ethernet driver
+ *
+ * This structure is used for the private data of the sandbox ethernet
+ * driver.
+ *
+ * @expected:  string expected to be written by the syslog driver
+ * @uts:   unit test state
+ */
+struct sb_log_env {
+   const char *expected;
+   struct unit_test_state *uts;
+};
+
+/**
+ * sb_log_tx_handler() - transmit callback function
+ *
+ * This callback function is invoked when a network package is sent using the
+ * sandbox Ethernet driver. The private data of the driver holds a sb_log_env
+ * structure with the unit test state and the expected UDP payload.
+ *
+ * The following checks are executed:
+ *
+ * * the Ethernet packet indicates a IP broadcast message
+ * * the IP header is for a local UDP broadcast message to port 514
+ * * the UDP payload matches the expected string
+ *
+ * After testing the pointer to the expected string is set to NULL to signal
+ * that the callback function has been called.
+ *
+ * @dev:   sandbox ethernet device
+ * @packet:Ethernet packet
+ * @len:   length of Ethernet packet
+ * Return: 0 = success
+ */
+static int sb_log_tx_handler(struct udevice *dev, void *packet,
+unsigned int len)
+{
+   struct eth_sandbox_priv *priv = dev_get_priv(dev);
+   struct sb_log_env *env = priv->priv;
+   /* uts is updated by the ut_assert* macros */
+   struct unit_test_state *uts = env->uts;
+   char *buf = packet;
+   struct ethernet_hdr *eth_hdr = packet;
+   struct ip_udp_hdr *ip_udp_hdr;
+
+   /* Check Ethernet header */
+   ut_asserteq_mem(_hdr->et_dest, net_bcast_ethaddr, ARP_HLEN);
+   ut_asserteq(ntohs(eth_hdr->et_protlen), PROT_IP);
+
+   /* Check IP header */
+   buf += sizeof(struct ethernet_hdr);
+   ip_udp_hdr = (struct ip_udp_hdr *)buf;
+   ut_asserteq(ip_udp_hdr->ip_p, IPPROTO_UDP);
+   ut_asserteq(ip_udp_hdr->ip_dst.s_addr, 0x);
+   ut_asserteq(ntohs(ip_udp_hdr->udp_dst), 514);
+   ut_asserteq(UDP_HDR_SIZE + strlen(env->expected) + 1,
+   ntohs(ip_udp_hdr->udp_len));
+
+   /* Check payload */
+   buf += sizeof(struct ip_udp_hdr);
+   ut_asserteq_mem(env->expected, buf,
+   ntohs(ip_udp_hdr->udp_len) - UDP_HDR_SIZE);
+
+   /* Signal that the callback function has been executed */
+   env->expected = NULL;
+
+   return 0;
+}
+
+/**
+ * syslog_test_log_err() - test log_err() function
+ *
+ * @uts:   unit test state
+ * Return: 0 = success
+ */
+static int syslog_test_log_err(struct unit_test_state *uts)
+{
+   int old_log_level = gd->default_log_level;
+   struct sb_log_env env;
+
+   gd->log_fmt = LOGF_DEFAULT;
+   gd->default_log_level = LOGL_INFO;
+   env_set("ethact", "eth@10002000");
+   env_set("log_hostname", "sandbox");
+   env.expected = "<3>sandbox uboot: syslog_test_log_err() "
+  "testing log_err\n";
+   env.uts = uts;
+   sandbox_eth_set_tx_handler(0, sb_log_tx_handler);
+   /* Used by ut_assert macros in the tx_handler */
+   sandbox_eth_set_priv(0, );
+   log_err("testing %s\n", "log_err");
+   /* Check that the callback function was called */
+   sandbox_eth_set_tx_handler(0, NULL);
+   gd->default_log_level = old_log_level;
+
+   return 0;
+}
+LOG_TEST(syslog_test_log_err);
+
+/**
+ * syslog_test_log_warning() - test log_warning() function
+ *
+ * @uts:   unit test state
+ * Return: 0 = success
+ */
+static int syslog_test_log_warning(struct 

[PATCH v5 2/6] log: syslog driver

2020-02-26 Thread Heinrich Schuchardt
Provide a log driver that broadcasts RFC 3164 messages to syslog servers.
rsyslog is one implementation of such a server.

The messages are sent to the local broadcast address 255.255.255.255 on
port 514.

The environment variable log_hostname can be used to provide the HOSTNAME
field for the messages. The optional TIMESTAMP field of RFC 3164 is not
provided.

Signed-off-by: Heinrich Schuchardt 
---
v5:
do not build syslog driver in SPL
v4:
no change
---
 MAINTAINERS |   2 +-
 common/Kconfig  |   7 +++
 common/Makefile |   1 +
 common/log_syslog.c | 117 
 doc/README.log  |   3 ++
 5 files changed, 129 insertions(+), 1 deletion(-)
 create mode 100644 common/log_syslog.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 1842569f24..c1ff620c4a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -631,7 +631,7 @@ LOGGING
 M: Simon Glass 
 S: Maintained
 T: git https://gitlab.denx.de/u-boot/u-boot.git
-F: common/log.c
+F: common/log*
 F: cmd/log.c
 F: test/log/log_test.c
 F: test/py/tests/test_log.py
diff --git a/common/Kconfig b/common/Kconfig
index cedd353e89..af0a009a8e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -774,6 +774,13 @@ config TPL_LOG_CONSOLE
  log message is shown - other details like level, category, file and
  line number are omitted.

+config LOG_SYSLOG
+   bool "Log output to syslog server"
+   depends on LOG && NET
+   help
+ Enables a log driver which broadcasts log records via UDP port 514
+ to syslog servers.
+
 config LOG_TEST
bool "Provide a test for logging"
depends on LOG && UNIT_TEST
diff --git a/common/Makefile b/common/Makefile
index 896e4af91d..dd54118091 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -131,6 +131,7 @@ obj-$(CONFIG_DFU_OVER_USB) += dfu.o
 obj-y += command.o
 obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
 obj-$(CONFIG_$(SPL_TPL_)LOG_CONSOLE) += log_console.o
+obj-$(CONFIG_$(SPL_TPL_)LOG_SYSLOG) += log_syslog.o
 obj-y += s_record.o
 obj-$(CONFIG_CMD_LOADB) += xyzModem.o
 obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o
diff --git a/common/log_syslog.c b/common/log_syslog.c
new file mode 100644
index 00..5e3e20e8a4
--- /dev/null
+++ b/common/log_syslog.c
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Log to syslog.
+ *
+ * Copyright (c) 2020, Heinrich Schuchardt 
+ */
+
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define BUFFER_SIZE 480
+
+static void append(char **buf, char *buf_end, const char *fmt, ...)
+{
+   va_list args;
+   size_t size = buf_end - *buf;
+
+   va_start(args, fmt);
+   vsnprintf(*buf, size, fmt, args);
+   va_end(args);
+   *buf += strlen(*buf);
+}
+
+static int log_syslog_emit(struct log_device *ldev, struct log_rec *rec)
+{
+   int ret;
+   int fmt = gd->log_fmt;
+   char msg[BUFFER_SIZE];
+   char *msg_end = msg + BUFFER_SIZE;
+   char *ptr = msg;
+   char *iphdr;
+   char *log_msg;
+   int eth_hdr_size;
+   struct in_addr bcast_ip;
+   static int processing_msg;
+   unsigned int log_level;
+   char *log_hostname;
+
+   /* Fend off messages from the network stack while writing a message */
+   if (processing_msg)
+   return 0;
+
+   processing_msg = 1;
+
+   /* Setup packet buffers */
+   net_init();
+   /* Disable hardware and put it into the reset state */
+   eth_halt();
+   /* Set current device according to environment variables */
+   eth_set_current();
+   /* Get hardware ready for send and receive operations */
+   ret = eth_init();
+   if (ret < 0) {
+   eth_halt();
+   goto out;
+   }
+
+   memset(msg, 0, BUFFER_SIZE);
+
+   /* Set ethernet header */
+   eth_hdr_size = net_set_ether((uchar *)ptr, net_bcast_ethaddr, PROT_IP);
+   ptr += eth_hdr_size;
+   iphdr = ptr;
+   ptr += IP_UDP_HDR_SIZE;
+   log_msg = ptr;
+
+   /*
+* The syslog log levels defined in RFC 5424 match the U-Boot ones up to
+* level 7 (debug).
+*/
+   log_level = rec->level;
+   if (log_level > 7)
+   log_level = 7;
+   /* Leave high bits as 0 to write a 'kernel message' */
+
+   /* Write log message to buffer */
+   append(, msg_end, "<%u>", log_level);
+   log_hostname = env_get("log_hostname");
+   if (log_hostname)
+   append(, msg_end, "%s ", log_hostname);
+   append(, msg_end, "uboot: ");
+   if (fmt & (1 << LOGF_LEVEL))
+   append(, msg_end, "%s.",
+  log_get_level_name(rec->level));
+   if (fmt & (1 << LOGF_CAT))
+   append(, msg_end, "%s,",
+  log_get_cat_name(rec->cat));
+   if (fmt & (1 << LOGF_FILE))
+   append(, msg_end, "%s:", rec->file);
+   if (fmt & (1 << LOGF_LINE))
+   

[PATCH v5 4/6] test: log functions with CONFIG_LOG=n

2020-02-26 Thread Heinrich Schuchardt
If CONFIG_LOG=n, we still expect output for log_err(), log_warning(),
log_notice(), log_info() and in case of DEBUG=1 also for log_debug().

Provide unit tests verifying this.

The tests depend on:

CONFIG_CONSOLE_RECORD=y
CONFIG_LOG=n
CONFIG_UT_LOG=y

It may be necessary to increase the value of CONFIG_SYS_MALLOC_F_LEN to
accommodate CONFIG_CONSOLE_RECORD=y.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v5:
no change
v4:
no change
---
 MAINTAINERS   |   2 +-
 include/test/log.h|  16 +
 include/test/suites.h |   1 +
 test/Kconfig  |   9 +++
 test/Makefile |   2 +-
 test/cmd_ut.c |   6 ++
 test/log/Makefile |  10 
 test/log/nolog_test.c | 135 ++
 test/log/test-main.c  |  20 +++
 9 files changed, 199 insertions(+), 2 deletions(-)
 create mode 100644 include/test/log.h
 create mode 100644 test/log/nolog_test.c
 create mode 100644 test/log/test-main.c

diff --git a/MAINTAINERS b/MAINTAINERS
index c1ff620c4a..9c2b7bf4c2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -633,7 +633,7 @@ S:  Maintained
 T: git https://gitlab.denx.de/u-boot/u-boot.git
 F: common/log*
 F: cmd/log.c
-F: test/log/log_test.c
+F: test/log/
 F: test/py/tests/test_log.py

 MALI DISPLAY PROCESSORS
diff --git a/include/test/log.h b/include/test/log.h
new file mode 100644
index 00..c661cde75a
--- /dev/null
+++ b/include/test/log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020, Heinrich Schuchardt 
+ *
+ * Tests for logging functions
+ */
+
+#ifndef __TEST_LOG_H__
+#define __TEST_LOG_H__
+
+#include 
+
+/* Declare a new logging test */
+#define LOG_TEST(_name) UNIT_TEST(_name, 0, log_test)
+
+#endif /* __TEST_LOG_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index 0748185eaf..39ad81a90f 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -30,6 +30,7 @@ int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, 
char *const argv[]);
 int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
diff --git a/test/Kconfig b/test/Kconfig
index cb51b46721..32e6197dca 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -30,6 +30,15 @@ config UT_LIB_ASN1

 endif

+config UT_LOG
+   bool "Unit tests for logging functions"
+   depends on UNIT_TEST
+   default y
+   help
+ Enables the 'ut log' command which tests logging functions like
+ log_err().
+ See also CONFIG_LOG_TEST which provides the 'log test' command.
+
 config UT_TIME
bool "Unit tests for time functions"
depends on UNIT_TEST
diff --git a/test/Makefile b/test/Makefile
index 2fe41f489c..2971d0d87f 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -10,5 +10,5 @@ obj-$(CONFIG_SANDBOX) += compression.o
 obj-$(CONFIG_SANDBOX) += print_ut.o
 obj-$(CONFIG_UT_TIME) += time_ut.o
 obj-$(CONFIG_UT_UNICODE) += unicode_ut.o
-obj-$(CONFIG_$(SPL_)LOG) += log/
+obj-y += log/
 obj-$(CONFIG_UNIT_TEST) += lib/
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index a3a9d49f7e..7fdcdbb1a6 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -60,6 +60,9 @@ static cmd_tbl_t cmd_ut_sub[] = {
 #ifdef CONFIG_UT_LIB
U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""),
 #endif
+#ifdef CONFIG_UT_LOG
+   U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""),
+#endif
 #ifdef CONFIG_UT_TIME
U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
 #endif
@@ -125,6 +128,9 @@ static char ut_help_text[] =
 #ifdef CONFIG_UT_LIB
"ut lib [test-name] - test library functions\n"
 #endif
+#ifdef CONFIG_UT_LOG
+   "ut log [test-name] - test logging functions\n"
+#endif
 #ifdef CONFIG_UT_OPTEE
"ut optee [test-name]\n"
 #endif
diff --git a/test/log/Makefile b/test/log/Makefile
index e0d0a4745f..98178f5e2b 100644
--- a/test/log/Makefile
+++ b/test/log/Makefile
@@ -3,3 +3,13 @@
 # Copyright (c) 2017 Google, Inc

 obj-$(CONFIG_LOG_TEST) += log_test.o
+
+ifdef CONFIG_UT_LOG
+
+obj-y += test-main.o
+
+ifndef CONFIG_LOG
+obj-$(CONFIG_CONSOLE_RECORD) += nolog_test.o
+endif
+
+endif # CONFIG_UT_LOG
diff --git a/test/log/nolog_test.c b/test/log/nolog_test.c
new file mode 100644
index 00..84619521c9
--- /dev/null
+++ b/test/log/nolog_test.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2020, Heinrich Schuchardt 
+ *
+ * Logging function tests for CONFIG_LOG=n.
+ */
+
+/* Needed for 

[PATCH v5 6/6] configs: sandbox: enable LOG_SYSLOG

2020-02-26 Thread Heinrich Schuchardt
For testing purposes enable the syslog logging driver.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v5:
no change
v4:
no change
---
 configs/sandbox64_defconfig| 1 +
 configs/sandbox_defconfig  | 1 +
 configs/sandbox_flattree_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index 941b1fd2c7..035900eb42 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -18,6 +18,7 @@ CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_LOG_MAX_LEVEL=6
+CONFIG_LOG_SYSLOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7b02b8de7c..49610a2f76 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -19,6 +19,7 @@ CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_LOG_MAX_LEVEL=6
+CONFIG_LOG_SYSLOG=y
 CONFIG_LOG_ERROR_RETURN=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_ANDROID_AB=y
diff --git a/configs/sandbox_flattree_defconfig 
b/configs/sandbox_flattree_defconfig
index 0049da3d48..22d54678e0 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -15,6 +15,7 @@ CONFIG_CONSOLE_RECORD=y
 CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
 CONFIG_SILENT_CONSOLE=y
 CONFIG_LOG_MAX_LEVEL=6
+CONFIG_LOG_SYSLOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_CMD_CPU=y
 CONFIG_CMD_LICENSE=y
--
2.25.0



[PATCH v5 0/6] log: syslog logging driver

2020-02-26 Thread Heinrich Schuchardt
This patch series provides a logging driver to send syslog messages via
UDP port 514 to a syslog server and a unit test for the syslog driver.
For testing LOG_SYSLOG is enabled on the sandbox.

For CONFIG_LOG=n a patch enables printf() or debug() output for log_*
functions. A unit test for this use case is provided.

v5:
do not build syslog driver in SPL
v4:
correct syslog test (expect 'uboot:' not 'uboot[1]:')
provide more comments for syslog test

*** BLURB HERE ***

Heinrich Schuchardt (6):
  log: correct CONFIG_LOG_TEST prerequisites
  log: syslog driver
  log: output for CONFIG_LOG=n
  test: log functions with CONFIG_LOG=n
  test: log: test syslog logging driver
  configs: sandbox: enable LOG_SYSLOG

 MAINTAINERS|   4 +-
 common/Kconfig |   9 +-
 common/Makefile|   1 +
 common/log_syslog.c| 117 
 configs/sandbox64_defconfig|   1 +
 configs/sandbox_defconfig  |   1 +
 configs/sandbox_flattree_defconfig |   1 +
 doc/README.log |   3 +
 include/log.h  |  10 +-
 include/test/log.h |  16 ++
 include/test/suites.h  |   1 +
 test/Kconfig   |   9 +
 test/Makefile  |   2 +-
 test/cmd_ut.c  |   6 +
 test/log/Makefile  |  14 ++
 test/log/nolog_test.c  | 135 ++
 test/log/syslog_test.c | 280 +
 test/log/test-main.c   |  20 +++
 18 files changed, 621 insertions(+), 9 deletions(-)
 create mode 100644 common/log_syslog.c
 create mode 100644 include/test/log.h
 create mode 100644 test/log/nolog_test.c
 create mode 100644 test/log/syslog_test.c
 create mode 100644 test/log/test-main.c

--
2.25.0



[PATCH v5 1/6] log: correct CONFIG_LOG_TEST prerequisites

2020-02-26 Thread Heinrich Schuchardt
An error

undefined reference to `do_log_test'

occurs for CONFIG_CMD_LOG=y, CONFIG_LOG_TEST=y, CONGIG_UNIT_TEST=n

Make CONFIG_UNIT_TEST a prerequisite.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v5:
no change
v4:
no change
---
 common/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 46e4193fc8..cedd353e89 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -776,7 +776,7 @@ config TPL_LOG_CONSOLE

 config LOG_TEST
bool "Provide a test for logging"
-   depends on LOG
+   depends on LOG && UNIT_TEST
default y if SANDBOX
help
  This enables a 'log test' command to test logging. It is normally
--
2.25.0



[PATCH v5 3/6] log: output for CONFIG_LOG=n

2020-02-26 Thread Heinrich Schuchardt
If CONFIG_LOG=n, we should still output errors, warnings, notices, infos,
and for DEBUG=1 also debug messages.

Signed-off-by: Heinrich Schuchardt 
Reviewed-by: Simon Glass 
---
v5:
no change
v4:
no change
---
 include/log.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/log.h b/include/log.h
index 62fb8afbd0..0453876001 100644
--- a/include/log.h
+++ b/include/log.h
@@ -115,11 +115,11 @@ static inline int _log_nop(enum log_category_t cat, enum 
log_level_t level,
 #define log_io(_fmt...)log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
 #else
 #define _LOG_MAX_LEVEL LOGL_INFO
-#define log_err(_fmt...)   log_nop(LOG_CATEGORY, LOGL_ERR, ##_fmt)
-#define log_warning(_fmt...)   log_nop(LOG_CATEGORY, LOGL_WARNING, ##_fmt)
-#define log_notice(_fmt...)log_nop(LOG_CATEGORY, LOGL_NOTICE, ##_fmt)
-#define log_info(_fmt...)  log_nop(LOG_CATEGORY, LOGL_INFO, ##_fmt)
-#define log_debug(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
+#define log_err(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_warning(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_notice(_fmt, ...)  printf(_fmt, ##__VA_ARGS__)
+#define log_info(_fmt, ...)printf(_fmt, ##__VA_ARGS__)
+#define log_debug(_fmt, ...)   debug(_fmt, ##__VA_ARGS__)
 #define log_content(_fmt...)   log_nop(LOG_CATEGORY, \
LOGL_DEBUG_CONTENT, ##_fmt)
 #define log_io(_fmt...)log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, 
##_fmt)
--
2.25.0



Re: [PATCH 1/1] drivers/rng: add Amlogic hardware RNG driver

2020-02-26 Thread Heinrich Schuchardt

On 2/26/20 8:32 PM, Sughosh Ganu wrote:



On Wed, 26 Feb 2020 at 23:34, Heinrich Schuchardt mailto:xypron.g...@gmx.de>> wrote:

On 2/26/20 11:51 AM, Sughosh Ganu wrote:
 >
 > On Tue, 25 Feb 2020 at 03:56, Heinrich Schuchardt
mailto:xypron.g...@gmx.de>
 > >> wrote:
 >
 >     Add support for the hardware random number generator of
Amlogic SOCs.
 >
 >     Signed-off-by: Heinrich Schuchardt mailto:xypron.g...@gmx.de>
 >     >>
 >     ---
 >       drivers/rng/Kconfig     |   8 +++
 >       drivers/rng/Makefile    |   1 +
 >       drivers/rng/meson-rng.c | 120

 >       3 files changed, 129 insertions(+)
 >       create mode 100644 drivers/rng/meson-rng.c
 >
 >     diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
 >     index c1aa43b823..edb6152bb9 100644
 >     --- a/drivers/rng/Kconfig
 >     +++ b/drivers/rng/Kconfig
 >     @@ -8,6 +8,14 @@ config DM_RNG
 >
 >       if DM_RNG
 >
 >     +config RNG_MESON
 >     +       bool "Amlogic Meson Random Number Generator support"
 >     +       depends on ARCH_MESON
 >     +       default y
 >     +       help
 >     +         Enable support for hardware random number generator
 >     +         of Amlogic Meson SoCs.
 >     +
 >       config RNG_SANDBOX
 >              bool "Sandbox random number generator"
 >              depends on SANDBOX
 >     diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
 >     index 3517005541..6a8a66779b 100644
 >     --- a/drivers/rng/Makefile
 >     +++ b/drivers/rng/Makefile
 >     @@ -4,5 +4,6 @@
 >       #
 >
 >       obj-$(CONFIG_DM_RNG) += rng-uclass.o
 >     +obj-$(CONFIG_RNG_MESON) += meson-rng.o
 >       obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
 >       obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
 >     diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
 >     new file mode 100644
 >     index 00..4b81a62353
 >     --- /dev/null
 >     +++ b/drivers/rng/meson-rng.c
 >     @@ -0,0 +1,120 @@
 >     +// SPDX-License-Identifier: GPL-2.0-or-later
 >     +/*
 >     + * Copyright 2020, Heinrich Schuchardt mailto:xypron.g...@gmx.de>
 >     >>
 >     + *
 >     + * Driver for Amlogic hardware random number generator
 >     + */
 >     +
 >     +#include 
 >     +#include 
 >     +#include 
 >     +#include 
 >     +#include 
 >     +
 >     +struct meson_rng_platdata {
 >     +       fdt_addr_t base;
 >     +       struct clk clk;
 >     +};
 >     +
 >     +/**
 >     + * meson_rng_read() - fill buffer with random bytes
 >     + *
 >     + * @buffer:    buffer to receive data
 >     + * @size:      size of buffer
 >     + *
 >     + * Return:     0
 >     + */
 >     +static int meson_rng_read(struct udevice *dev, void *data,
size_t len)
 >     +{
 >     +       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
 >     +       char *buffer = (char *)data;
 >     +
 >     +       while (len) {
 >     +               u32 rand = readl(pdata->base);
 >     +               size_t step;
 >
 >
 > I believe declaration of variables in the middle of the function is
 > frowned upon. Can be moved to the start of the function.

rand is defined at the top of the smallest possible code block
delineated by braces.

C compilers before C99 required you to put definitions at the top of
functions. This led to the unsafe coding practice to reuse the same
variable for different purposes in the same function. Currently we are
using -std=gnu11.

U-Boot uses cppcheck in Gitlab CI. Cppcheck gives you a warning if you
could reduce the scope of a variable.

Neither the U-Boot coding style guide
https://www.denx.de/wiki/U-Boot/CodingStyle
nor the Linux kernel coding style guide
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
recommend such unsafe practice.


Yes, I had checked that this is not mentioned in the coding style
guides. But i have seen Wolfgang mention this on multiple occasions as
part of his review comments earlier, one example being [1].


https://lists.denx.de/pipermail/u-boot/2020-January/397651.html
has a variable definition which is not at the start of code block
delineated by {} but in the middle of the code block. I agree with
Wolfgang that this is not advisable.

Best regards

Heinrich




If you look at other parts of the U-Boot code, you will find that in
lots of places variables are defined in the smallest possible code block
(e.g. fs/fat/fat.c, 

[PATCH] rk3399: Add four clocks to clock driver needed by framebuffer

2020-02-26 Thread Wolfram Joost

This patch adds the four clock gates

- ACLK_VOP0
- ACLK_VOP1
- HCLK_VOP0
- HCLK_VOP1

to the rockchip rk3399 clock drivers.

These clock gates were referenced by arch/arm/dts/rk3399.dtsi for
vopb and vopl.

The driver drivers/video/rockchip/rk3399_vop.c won't get probed
without these clocks and the framebuffer does not work.
---
 drivers/clk/rockchip/clk_rk3399.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/clk/rockchip/clk_rk3399.c 
b/drivers/clk/rockchip/clk_rk3399.c

index 865b80cc0f..a3628d4a4c 100644
--- a/drivers/clk/rockchip/clk_rk3399.c
+++ b/drivers/clk/rockchip/clk_rk3399.c
@@ -923,6 +923,11 @@ static ulong rk3399_clk_get_rate(struct clk *clk)
case DCLK_VOP0:
case DCLK_VOP1:
break;
+   case ACLK_VOP0:
+   case ACLK_VOP1:
+   case HCLK_VOP0:
+   case HCLK_VOP1:
+   break;
case PCLK_EFUSE1024NS:
break;
case SCLK_SARADC:
@@ -994,6 +999,12 @@ static ulong rk3399_clk_set_rate(struct clk *clk, 
ulong rate)

case DCLK_VOP1:
ret = rk3399_vop_set_clk(priv->cru, clk->id, rate);
break;
+   case ACLK_VOP0:
+   case ACLK_VOP1:
+   case HCLK_VOP0:
+   case HCLK_VOP1:
+   /* clock gates are enabled by default */
+   break;
case SCLK_DDRCLK:
ret = rk3399_ddr_set_clk(priv->cru, rate);
break;
--
2.25.1



Re: [PATCH 1/1] drivers/rng: add Amlogic hardware RNG driver

2020-02-26 Thread Sughosh Ganu
On Wed, 26 Feb 2020 at 23:34, Heinrich Schuchardt 
wrote:

> On 2/26/20 11:51 AM, Sughosh Ganu wrote:
> >
> > On Tue, 25 Feb 2020 at 03:56, Heinrich Schuchardt  > > wrote:
> >
> > Add support for the hardware random number generator of Amlogic SOCs.
> >
> > Signed-off-by: Heinrich Schuchardt  > >
> > ---
> >   drivers/rng/Kconfig |   8 +++
> >   drivers/rng/Makefile|   1 +
> >   drivers/rng/meson-rng.c | 120
> 
> >   3 files changed, 129 insertions(+)
> >   create mode 100644 drivers/rng/meson-rng.c
> >
> > diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
> > index c1aa43b823..edb6152bb9 100644
> > --- a/drivers/rng/Kconfig
> > +++ b/drivers/rng/Kconfig
> > @@ -8,6 +8,14 @@ config DM_RNG
> >
> >   if DM_RNG
> >
> > +config RNG_MESON
> > +   bool "Amlogic Meson Random Number Generator support"
> > +   depends on ARCH_MESON
> > +   default y
> > +   help
> > + Enable support for hardware random number generator
> > + of Amlogic Meson SoCs.
> > +
> >   config RNG_SANDBOX
> >  bool "Sandbox random number generator"
> >  depends on SANDBOX
> > diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
> > index 3517005541..6a8a66779b 100644
> > --- a/drivers/rng/Makefile
> > +++ b/drivers/rng/Makefile
> > @@ -4,5 +4,6 @@
> >   #
> >
> >   obj-$(CONFIG_DM_RNG) += rng-uclass.o
> > +obj-$(CONFIG_RNG_MESON) += meson-rng.o
> >   obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
> >   obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
> > diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
> > new file mode 100644
> > index 00..4b81a62353
> > --- /dev/null
> > +++ b/drivers/rng/meson-rng.c
> > @@ -0,0 +1,120 @@
> > +// SPDX-License-Identifier: GPL-2.0-or-later
> > +/*
> > + * Copyright 2020, Heinrich Schuchardt  > >
> > + *
> > + * Driver for Amlogic hardware random number generator
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct meson_rng_platdata {
> > +   fdt_addr_t base;
> > +   struct clk clk;
> > +};
> > +
> > +/**
> > + * meson_rng_read() - fill buffer with random bytes
> > + *
> > + * @buffer:buffer to receive data
> > + * @size:  size of buffer
> > + *
> > + * Return: 0
> > + */
> > +static int meson_rng_read(struct udevice *dev, void *data, size_t
> len)
> > +{
> > +   struct meson_rng_platdata *pdata = dev_get_platdata(dev);
> > +   char *buffer = (char *)data;
> > +
> > +   while (len) {
> > +   u32 rand = readl(pdata->base);
> > +   size_t step;
> >
> >
> > I believe declaration of variables in the middle of the function is
> > frowned upon. Can be moved to the start of the function.
>
> rand is defined at the top of the smallest possible code block
> delineated by braces.
>
> C compilers before C99 required you to put definitions at the top of
> functions. This led to the unsafe coding practice to reuse the same
> variable for different purposes in the same function. Currently we are
> using -std=gnu11.
>
> U-Boot uses cppcheck in Gitlab CI. Cppcheck gives you a warning if you
> could reduce the scope of a variable.
>
> Neither the U-Boot coding style guide
> https://www.denx.de/wiki/U-Boot/CodingStyle
> nor the Linux kernel coding style guide
> https://www.kernel.org/doc/html/v4.10/process/coding-style.html
> recommend such unsafe practice.
>

Yes, I had checked that this is not mentioned in the coding style guides.
But i have seen Wolfgang mention this on multiple occasions as part of his
review comments earlier, one example being [1].


>
> If you look at other parts of the U-Boot code, you will find that in
> lots of places variables are defined in the smallest possible code block
> (e.g. fs/fat/fat.c, fs/ext4/ext4_common.c). Due to our legacy we still
> carry a lot of code lines not following this rule.
>
> But anyway if you still want it in a different way, I will resubmit.
>

I don't have a strong opinion on this. I was simply stating what I thought
to be a coding style in u-boot based on some earlier review comments that I
have seen.

-sughosh

[1] - https://lists.denx.de/pipermail/u-boot/2020-January/397651.html


[PATCH 1/1] doc: driver-model: there is no UCLASS_ETHERNET

2020-02-26 Thread Heinrich Schuchardt
%s/UCLASS_ETHERNET/UCLASS_ETH/g

Signed-off-by: Heinrich Schuchardt 
---
Resenct cc u-boot@lists.denx.de
---
 doc/driver-model/design.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/driver-model/design.rst b/doc/driver-model/design.rst
index 5247ecc276..e37b51bf43 100644
--- a/doc/driver-model/design.rst
+++ b/doc/driver-model/design.rst
@@ -579,7 +579,7 @@ a USB bus with several devices attached to it, each from a 
different (made
 up) uclass::

xhci_usb (UCLASS_USB)
-  eth (UCLASS_ETHERNET)
+  eth (UCLASS_ETH)
   camera (UCLASS_CAMERA)
   flash (UCLASS_FLASH_STORAGE)

--
2.25.0



Re: [U-Boot-Custodians] RFC: Migration target date for DM_ETH

2020-02-26 Thread Heinrich Schuchardt

On 2/26/20 7:58 PM, Christophe Leroy wrote:



Le 09/08/2019 à 08:30, Heinrich Schuchardt a écrit :

Currently dozens of boards still do not use the driver model for the
network devices. This makes integration between devices in the UEFI
sub-system with the U-Boot devices complicated.

See: https://travis-ci.org/xypron2/u-boot/builds/569675547

In doc/driver-model/migration.rst I am missing a migration target day
for DM_ETH. Shouldn't define one? 2020-07 should be realistic.


Is there some guidance and/or examples on how to proceed to migrate an
Ethernet driver to DM_ETH, as there is for an SPI driver
(doc/driver-model/spi-howto.rst)

I'm looking at converting the mpc8xx_fec driver.


git grep -n UCLASS_ETH

yields many examples you could use for reference.

Have a look at doc/device-tree-bindings/net/ethernet.txt.

Best regards

Heinrich


Re: [PATCH 1/1] include/ata.h: remove invalid links

2020-02-26 Thread Heinrich Schuchardt

On 2/26/20 5:05 AM, Tom Rini wrote:

On Wed, Feb 26, 2020 at 04:57:51AM +0100, Heinrich Schuchardt wrote:

On 2/25/20 10:30 PM, Tom Rini wrote:

On Tue, Feb 25, 2020 at 10:04:53PM +0100, Heinrich Schuchardt wrote:


Remove invalid URLs for "Information Technology - AT Attachment-3 Interface
(ATA-3)".

Signed-off-by: Heinrich Schuchardt 
---
   include/ata.h | 4 
   1 file changed, 4 deletions(-)

diff --git a/include/ata.h b/include/ata.h
index 3f4e4a0234..aecb9cd589 100644
--- a/include/ata.h
+++ b/include/ata.h
@@ -7,10 +7,6 @@
   /*
* Most of the following information was derived from the document
* "Information Technology - AT Attachment-3 Interface (ATA-3)"
- * which can be found at:
- * http://www.dt.wdc.com/ata/ata-3/ata3r5v.zip
- * ftp://poctok.iae.nsk.su/pub/asm/Documents/IDE/ATA3R5V.ZIP
- * ftp://ftp.fee.vutbr.cz/pub/doc/io/ata/ata-3/ata3r5v.zip
*/

   #ifndef  _ATA_H


In this case, it looks like some of the relevant information about the
spec, "Revision 5v" is encoded in the URL.  I can't find a new link for
it, but we should keep that information in the comment.  Thanks!



Hello Tom,

revision 5v is an early draft of ANSI X3.298-1997. On Jan 27th, 1997
there was a draft 7b. Google finds it when you look for 'ata-3-std.pdf
site:github.com'.

The final standard ANSI X3.298-1997 is for sale here:
https://webstore.ansi.org/standards/incits/ansix32981997


Yes.


So I think we should simply point to the standard.


I think we need to note what revision of the standard we wrote to, for
future "hey, wait, there's a corner case we get wrong because we coded
to an old draft" issues.



ata.h includes libata.h which is at least partially based on ATA/ATAPI-7
(a later standard than ATA-3). Many defines in ata.h are simply
duplicate or unused and should be removed. ata.h contains definitions of
variables that are not in the draft 7b ATA-3 standard.

I have no document indicating if there ever was a revision 5v or if this
is just our assumption due to the file name.

As ata.h is not based on a single revision of the ATA standard a
reference to some draft revision will not provide guidance to any future
developer. The future developer anyway will not have access to such a
revision.

Best regards

Heinrich


Re: [U-Boot-Custodians] RFC: Migration target date for DM_ETH

2020-02-26 Thread Christophe Leroy




Le 09/08/2019 à 08:30, Heinrich Schuchardt a écrit :

Currently dozens of boards still do not use the driver model for the
network devices. This makes integration between devices in the UEFI
sub-system with the U-Boot devices complicated.

See: https://travis-ci.org/xypron2/u-boot/builds/569675547

In doc/driver-model/migration.rst I am missing a migration target day
for DM_ETH. Shouldn't define one? 2020-07 should be realistic.


Is there some guidance and/or examples on how to proceed to migrate an 
Ethernet driver to DM_ETH, as there is for an SPI driver 
(doc/driver-model/spi-howto.rst)


I'm looking at converting the mpc8xx_fec driver.

Thanks,
Christophe


Re: [PATCH] raspberrypi: reserve first two pages in efi memory map

2020-02-26 Thread Kyle Evans
On Wed, Feb 26, 2020 at 12:26 PM Kyle Evans  wrote:
>
> On Wed, Feb 26, 2020 at 12:06 PM Matthias Brugger  wrote:
> >
> >
> >
> > On 26/02/2020 15:03, kev...@freebsd.org wrote:
> > > From: Kyle Evans 
> > >
> > > The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> > > in the first two pages of memory. Without this reservation, the next stage
> > > or OS assume they're free to use the second page and may get catastrophic
> > > results from clobbering it.
> > >
> > > Signed-off-by: Kyle Evans 
> > > Cc: Matthias Brugger 
> > > ---
> > >  board/raspberrypi/rpi/rpi.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> > > index e367ba3092..d3f9bd16ac 100644
> > > --- a/board/raspberrypi/rpi/rpi.c
> > > +++ b/board/raspberrypi/rpi/rpi.c
> > > @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
> > >   lcd_dt_simplefb_add_node(blob);
> > >
> > >  #ifdef CONFIG_EFI_LOADER
> > > - /* Reserve the spin table */
> > > - efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> > > + /* Reserve the first two pages for spin table/psci stub. */
> > > + efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
> >
> > Is this that changed recently or was the memory reservation wrong from the
> > beginning?
> >
>
> As far as I can tell it just wasn't quite accounted for in the initial
> reservation -- Linux presumably uses spin-table as described in the
> DTS, where-as FreeBSD opts for PSCI instead since it's available. I
> don't have a good intuition for who else may be using PSCI for RPi; we
> may be in the minority.
>
> FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do
> not account for PSCI stubs -- I've filed an issue[1] there, as well.
>
> Thanks,
>
> Kyle Evans
>
> [1] https://github.com/raspberrypi/firmware/issues/1340

Upon further examination, it looks like I've managed to confuse myself
and we're using our own stub derived from the upstream spintable
stuff... let's disregard this patch, I'll look into rolling up a new
one as both upstream implementation and ours should pass the required
reservation size through to U-Boot via x1.


Pull request for UEFI sub-system for efi-2020-04-rc4

2020-02-26 Thread Heinrich Schuchardt

The following changes since commit 548ce227d3d852455c6395c0cec30af0cda77b09:

  Prepare v2020.04-rc3 (2020-02-26 07:53:20 -0500)

are available in the Git repository at:

  https://gitlab.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2020-04-rc4

for you to fetch changes up to 76be687288dc618eabd1ef643488cd5bd93f84ff:

  efi_loader: implement EFI_RT_PROPERTIES_TABLE (2020-02-26 19:32:09 +0100)


Pull request for UEFI sub-system for efi-2020-04-rc4

UEFI spec 2.8 errata A replaces the RuntimeServicesSupported variable
defined in UEFI spec 2.8 by the configuration table
EFI_RT_PROPERTIES_TABLE. So let's follow suit.


Heinrich Schuchardt (1):
  efi_loader: implement EFI_RT_PROPERTIES_TABLE

 cmd/efidebug.c   |  4 
 include/efi_api.h| 12 
 lib/efi_loader/efi_runtime.c | 36 
 lib/efi_loader/efi_setup.c   |  8 
 4 files changed, 48 insertions(+), 12 deletions(-)


Re: [PATCH] raspberrypi: reserve first two pages in efi memory map

2020-02-26 Thread Kyle Evans
On Wed, Feb 26, 2020 at 12:06 PM Matthias Brugger  wrote:
>
>
>
> On 26/02/2020 15:03, kev...@freebsd.org wrote:
> > From: Kyle Evans 
> >
> > The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> > in the first two pages of memory. Without this reservation, the next stage
> > or OS assume they're free to use the second page and may get catastrophic
> > results from clobbering it.
> >
> > Signed-off-by: Kyle Evans 
> > Cc: Matthias Brugger 
> > ---
> >  board/raspberrypi/rpi/rpi.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> > index e367ba3092..d3f9bd16ac 100644
> > --- a/board/raspberrypi/rpi/rpi.c
> > +++ b/board/raspberrypi/rpi/rpi.c
> > @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
> >   lcd_dt_simplefb_add_node(blob);
> >
> >  #ifdef CONFIG_EFI_LOADER
> > - /* Reserve the spin table */
> > - efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> > + /* Reserve the first two pages for spin table/psci stub. */
> > + efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
>
> Is this that changed recently or was the memory reservation wrong from the
> beginning?
>

As far as I can tell it just wasn't quite accounted for in the initial
reservation -- Linux presumably uses spin-table as described in the
DTS, where-as FreeBSD opts for PSCI instead since it's available. I
don't have a good intuition for who else may be using PSCI for RPi; we
may be in the minority.

FWIW, /memreserve/ in the upstream (raspberrypi/firmware) DTB also do
not account for PSCI stubs -- I've filed an issue[1] there, as well.

Thanks,

Kyle Evans

[1] https://github.com/raspberrypi/firmware/issues/1340


Re: [PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL

2020-02-26 Thread Giulio Benetti

On 2/26/20 6:59 PM, Fabio Estevam wrote:

Hi Giulio,

On Wed, Feb 26, 2020 at 2:54 PM Giulio Benetti
 wrote:


Yes, it's a good idea. Doing this I've taken this[1] as example.
So I don't know where in u-boot PLLs are initialized according to a dts
file, can you please provide me an example? I will be happy to modify
this according to that!


In the kernel device trees we use the 'assigned-clocks' and
'assigned-clock-parents' properties to establish a clock parent
relationship.

I suggest we follow the same approach in U-Boot.


Oh, I've seen now, need to study it before, but now in my mind it's 
getting more clear how that works. But will this work even if shrinked 
CCF in u-boot can't set parent clocks(at least this is what I've 
understood)? I mean, basically here for LCDIF I see that only last 
divider get set for achieving pixel-clock, while all parents are get 
only to recalcute the "last divider parent clock".


Also, I can't understand, is it ok setting PLL5 to 650Mhz and un-bypass 
it? The problem is only about clk_set_parent() for LCDIF?


Because if a peripheral would set a PLL5 frequency and another 
peripheral use it as parent, then it would set it again.


Best regards
--
Giulio Benetti
Benetti Engineering sas


Re: [PATCH] raspberrypi: reserve first two pages in efi memory map

2020-02-26 Thread Matthias Brugger



On 26/02/2020 15:03, kev...@freebsd.org wrote:
> From: Kyle Evans 
> 
> The psci stub provided by Raspberry Pi is around 5k in size, thus residing
> in the first two pages of memory. Without this reservation, the next stage
> or OS assume they're free to use the second page and may get catastrophic
> results from clobbering it.
> 
> Signed-off-by: Kyle Evans 
> Cc: Matthias Brugger 
> ---
>  board/raspberrypi/rpi/rpi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index e367ba3092..d3f9bd16ac 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
>   lcd_dt_simplefb_add_node(blob);
>  
>  #ifdef CONFIG_EFI_LOADER
> - /* Reserve the spin table */
> - efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
> + /* Reserve the first two pages for spin table/psci stub. */
> + efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);

Is this that changed recently or was the memory reservation wrong from the
beginning?

Reagrds,
Matthias

>  #endif
>  
>   return 0;
> 


Re: [PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL

2020-02-26 Thread Fabio Estevam
Hi Giulio,

On Wed, Feb 26, 2020 at 2:54 PM Giulio Benetti
 wrote:

> Yes, it's a good idea. Doing this I've taken this[1] as example.
> So I don't know where in u-boot PLLs are initialized according to a dts
> file, can you please provide me an example? I will be happy to modify
> this according to that!

In the kernel device trees we use the 'assigned-clocks' and
'assigned-clock-parents' properties to establish a clock parent
relationship.

I suggest we follow the same approach in U-Boot.

Thanks


Re: [PATCH 1/1] drivers/rng: add Amlogic hardware RNG driver

2020-02-26 Thread Heinrich Schuchardt

On 2/26/20 11:51 AM, Sughosh Ganu wrote:


On Tue, 25 Feb 2020 at 03:56, Heinrich Schuchardt mailto:xypron.g...@gmx.de>> wrote:

Add support for the hardware random number generator of Amlogic SOCs.

Signed-off-by: Heinrich Schuchardt mailto:xypron.g...@gmx.de>>
---
  drivers/rng/Kconfig     |   8 +++
  drivers/rng/Makefile    |   1 +
  drivers/rng/meson-rng.c | 120 
  3 files changed, 129 insertions(+)
  create mode 100644 drivers/rng/meson-rng.c

diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
index c1aa43b823..edb6152bb9 100644
--- a/drivers/rng/Kconfig
+++ b/drivers/rng/Kconfig
@@ -8,6 +8,14 @@ config DM_RNG

  if DM_RNG

+config RNG_MESON
+       bool "Amlogic Meson Random Number Generator support"
+       depends on ARCH_MESON
+       default y
+       help
+         Enable support for hardware random number generator
+         of Amlogic Meson SoCs.
+
  config RNG_SANDBOX
         bool "Sandbox random number generator"
         depends on SANDBOX
diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
index 3517005541..6a8a66779b 100644
--- a/drivers/rng/Makefile
+++ b/drivers/rng/Makefile
@@ -4,5 +4,6 @@
  #

  obj-$(CONFIG_DM_RNG) += rng-uclass.o
+obj-$(CONFIG_RNG_MESON) += meson-rng.o
  obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
  obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
new file mode 100644
index 00..4b81a62353
--- /dev/null
+++ b/drivers/rng/meson-rng.c
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2020, Heinrich Schuchardt mailto:xypron.g...@gmx.de>>
+ *
+ * Driver for Amlogic hardware random number generator
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct meson_rng_platdata {
+       fdt_addr_t base;
+       struct clk clk;
+};
+
+/**
+ * meson_rng_read() - fill buffer with random bytes
+ *
+ * @buffer:    buffer to receive data
+ * @size:      size of buffer
+ *
+ * Return:     0
+ */
+static int meson_rng_read(struct udevice *dev, void *data, size_t len)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+       char *buffer = (char *)data;
+
+       while (len) {
+               u32 rand = readl(pdata->base);
+               size_t step;


I believe declaration of variables in the middle of the function is
frowned upon. Can be moved to the start of the function.


rand is defined at the top of the smallest possible code block
delineated by braces.

C compilers before C99 required you to put definitions at the top of
functions. This led to the unsafe coding practice to reuse the same
variable for different purposes in the same function. Currently we are
using -std=gnu11.

U-Boot uses cppcheck in Gitlab CI. Cppcheck gives you a warning if you
could reduce the scope of a variable.

Neither the U-Boot coding style guide
https://www.denx.de/wiki/U-Boot/CodingStyle
nor the Linux kernel coding style guide
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
recommend such unsafe practice.

If you look at other parts of the U-Boot code, you will find that in
lots of places variables are defined in the smallest possible code block
(e.g. fs/fat/fat.c, fs/ext4/ext4_common.c). Due to our legacy we still
carry a lot of code lines not following this rule.

But anyway if you still want it in a different way, I will resubmit.

Best regards

Heinrich



Other than that,
Reviewed-by: Sughosh Ganu mailto:sughosh.g...@linaro.org>>

-sughosh

+
+               if (len >= 4)
+                       step = 4;
+               else
+                       step = len;
+               memcpy(buffer, , step);
+               buffer += step;
+               len -= step;
+       }
+       return 0;
+}
+
+/**
+ * meson_rng_probe() - probe rng device
+ *
+ * @dev:       device
+ * Return:     0 if ok
+ */
+static int meson_rng_probe(struct udevice *dev)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+       int err;
+
+       err = clk_enable(>clk);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+/**
+ * meson_rng_remove() - deinitialize rng device
+ *
+ * @dev:       device
+ * Return:     0 if ok
+ */
+static int meson_rng_remove(struct udevice *dev)
+{
+       struct meson_rng_platdata *pdata = dev_get_platdata(dev);
+
+       return clk_disable(>clk);
+}
+
+/**
+ * meson_rng_ofdata_to_platdata() - transfer device tree data to
plaform data
+ *
+ * @dev:       device
+ * Return: 

[PATCH] configs: am335x_evm: Enable Fastboot

2020-02-26 Thread Sam Protsenko
This config option was present in am335x_boneblack_defconfig, but we
have to use generic am335x_evm_defconfig now, as BBB defconfig was
removed in commit 8fa7f65dd02c ("configs: Remove
am335x_boneblack_defconfig"). So this patch merely brings that option
back.

Tested on BeagleBone Black:

=> fastboot 0
$ fastboot flash rootfs rootfs.img

Fixes: 8fa7f65dd02c ("configs: Remove am335x_boneblack_defconfig")
Signed-off-by: Sam Protsenko 
---
 configs/am335x_evm_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index b5579f6686..2fe9f86f1a 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -44,6 +44,9 @@ CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_FLASH=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
+CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_DM_I2C=y
 CONFIG_MISC=y
 CONFIG_DM_MMC=y
-- 
2.24.1



Re: [PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL

2020-02-26 Thread Giulio Benetti

Hi Fabio,

On 2/26/20 6:37 PM, Fabio Estevam wrote:

Hi Giulio,

On Wed, Feb 26, 2020 at 2:16 PM Giulio Benetti
 wrote:


mxsfb needs PLL5 as source, so let's setup it and set it as source for
mxsfb(lcdif).

Signed-off-by: Giulio Benetti 
---
  drivers/clk/imx/clk-imxrt1050.c | 13 -
  1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index e33d426363..2819ffb9ac 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -238,9 +238,9 @@ static int imxrt1050_clk_probe(struct udevice *dev)
 clk_dm(IMXRT1050_CLK_LCDIF,
imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));

-#ifdef CONFIG_SPL_BUILD
 struct clk *clk, *clk1;

+#ifdef CONFIG_SPL_BUILD
 /* bypass pll1 before setting its rate */
 clk_get_by_id(IMXRT1050_CLK_PLL1_REF_SEL, );
 clk_get_by_id(IMXRT1050_CLK_PLL1_BYPASS, );
@@ -271,7 +271,18 @@ static int imxrt1050_clk_probe(struct udevice *dev)

 clk_get_by_id(IMXRT1050_CLK_PLL3_BYPASS, );
 clk_set_parent(clk1, clk);
+#else
+   /* Set PLL5 for LCDIF to its default 650Mhz */
+   clk_get_by_id(IMXRT1050_CLK_PLL5_VIDEO, );
+   clk_enable(clk);
+   clk_set_rate(clk, 65000UL);
+
+   clk_get_by_id(IMXRT1050_CLK_PLL5_BYPASS, );
+   clk_set_parent(clk1, clk);

+   /* Configure PLL5 as LCDIF source */
+   clk_get_by_id(IMXRT1050_CLK_LCDIF_SEL, );
+   clk_set_parent(clk1, clk);


This is more like a board design decision and IMHO should not be
hardcoded as part of the clock driver.

Other users may want to use a different clock source for the eLCDIF driver.

Setting the clock parent in board device tree makes more sense.


Yes, it's a good idea. Doing this I've taken this[1] as example.
So I don't know where in u-boot PLLs are initialized according to a dts 
file, can you please provide me an example? I will be happy to modify 
this according to that!


Thank you

[1]: 
https://gitlab.denx.de/u-boot/u-boot/blob/master/drivers/clk/imx/clk-imx8mm.c#L398-409


Best regards
--
Giulio Benetti
Benetti Engineering sas


[PATCH] configs: am335x_evm: Enable DFU over TFTP support

2020-02-26 Thread Sam Protsenko
DFU over TFTP flashing method might be helpful in order to speed-up the
flashing process of big images (as DFU works over USB EP0, which is
quite slow). Also, it's a good backup option in the case when USB got
broken (either in software or hardware), to avoid resorting to SD card
boot.

This config option was present in am335x_boneblack_defconfig, but we
have to use generic am335x_evm_defconfig now, as BBB defconfig was
removed in commit 8fa7f65dd02c ("configs: Remove
am335x_boneblack_defconfig"). So this patch merely brings that option
back.

Tested on BeagleBone Black:

=> setenv dfu_alt_info $dfu_alt_info_emmc
=> setenv ipaddr 192.168.0.100
=> setenv serverip 192.168.0.1
=> setenv updatefile update_uboot.itb
=> dfu tftp mmc 1

Where 'update_uboot.its' file looks like this:

/dts-v1/;

/ {
description = "Automatic U-Boot update";
#address-cells = <1>;

images {
u-boot.img.raw-1 {
description = "U-Boot binary";
data = /incbin/("u-boot.img");
compression = "none";
type = "firmware";
load = <0x6>;
hash-1 {
algo = "sha1";
};
};
};
};

And 'update_uboot.itb' is generated as follows:

$ mkimage -f update_uboot.its update_uboot.itb

Newly flashed U-Boot works fine.

Fixes: 8fa7f65dd02c ("configs: Remove am335x_boneblack_defconfig")
Signed-off-by: Sam Protsenko 
---
 configs/am335x_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 8fd90a6f37..2fe9f86f1a 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -39,6 +39,7 @@ CONFIG_SPL_ENV_IS_NOWHERE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_CLK=y
 CONFIG_CLK_CDCE9XX=y
+CONFIG_DFU_TFTP=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
-- 
2.24.1



Re: [PATCH 00/18] i.MXRT1050 add LCDIF support

2020-02-26 Thread Giulio Benetti

Forgot to mention that this patchset needs this patch before:
https://patchwork.ozlabs.org/patch/1232248/

--
Giulio Benetti
Benetti Engineering sas

On 2/26/20 6:15 PM, Giulio Benetti wrote:

This patchset add support for LCDIF on i.MXRT1050 evk. This requires
PLL5 to be setup, mxsfb needs to use display_timing to retrieve if Lcd
has inverted PIXCLOCK from dts.

With this patchset applied we temporary loose DCache support until it will
get implemented, since a function in mxsfb.c is needed for setting cache
behaviour. Anyway this way Lcd will show the console same way as serial
does.

Also I've moved private sunxi_ctfb_mode_to_display_timing() to videomodes
since I need it for mxfsb.c too, then having a unified function to convert
from ctfb_mode to display_timing.

Giulio Benetti (18):
   clk: imx: pllv3: add enable_bit
   clk: imx: imxrt1050-clk: fix typo in clock name "video:"
   clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL
   videomodes: add helper function to convert from ctfb to display_timing
   sunxi: display: use common video_ctfb_mode_to_display_timing()
   video: mxsfb: add support for DM CLK
   video: mxsfb: add support for i.MXRT
   video: mxsfb: refactor for using display_timings
   video: mxsfb: enable setting HSYNC negative polarity
   video: mxsfb: enable setting VSYNC negative polarity
   video: mxsfb: enable setting PIXDATA on negative edge
   video: mxsfb: enable setting ENABLE negative polarity
   imxrt1050_evk: add 16bpp video support if video layer enabled
   ARM: dts: i.mxrt1050: add lcdif node
   ARM: dts: imxrt1050: allow this dtsi file to be compiled in Linux
   arch: arm: dts: imxrt1050-evk: add lcdif node
   configs: imxrt1050-evk: enable video support/console
   configs: imxrt1050-evk: temporary disable DCACHE

  arch/arm/dts/imxrt1050-evk.dts | 57 +
  arch/arm/dts/imxrt1050.dtsi| 14 +++-
  arch/arm/include/asm/arch-imxrt/imx-regs.h |  6 ++
  arch/arm/include/asm/mach-imx/regs-lcdif.h |  6 +-
  configs/imxrt1050-evk_defconfig|  6 ++
  drivers/clk/imx/clk-imxrt1050.c| 15 +++-
  drivers/clk/imx/clk-pllv3.c|  9 +++
  drivers/video/mxsfb.c  | 94 ++
  drivers/video/sunxi/sunxi_display.c| 33 +---
  drivers/video/videomodes.c | 29 +++
  drivers/video/videomodes.h |  3 +
  include/configs/imxrt1050-evk.h| 15 
  12 files changed, 216 insertions(+), 71 deletions(-)





Re: [PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL

2020-02-26 Thread Fabio Estevam
Hi Giulio,

On Wed, Feb 26, 2020 at 2:16 PM Giulio Benetti
 wrote:
>
> mxsfb needs PLL5 as source, so let's setup it and set it as source for
> mxsfb(lcdif).
>
> Signed-off-by: Giulio Benetti 
> ---
>  drivers/clk/imx/clk-imxrt1050.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
> index e33d426363..2819ffb9ac 100644
> --- a/drivers/clk/imx/clk-imxrt1050.c
> +++ b/drivers/clk/imx/clk-imxrt1050.c
> @@ -238,9 +238,9 @@ static int imxrt1050_clk_probe(struct udevice *dev)
> clk_dm(IMXRT1050_CLK_LCDIF,
>imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));
>
> -#ifdef CONFIG_SPL_BUILD
> struct clk *clk, *clk1;
>
> +#ifdef CONFIG_SPL_BUILD
> /* bypass pll1 before setting its rate */
> clk_get_by_id(IMXRT1050_CLK_PLL1_REF_SEL, );
> clk_get_by_id(IMXRT1050_CLK_PLL1_BYPASS, );
> @@ -271,7 +271,18 @@ static int imxrt1050_clk_probe(struct udevice *dev)
>
> clk_get_by_id(IMXRT1050_CLK_PLL3_BYPASS, );
> clk_set_parent(clk1, clk);
> +#else
> +   /* Set PLL5 for LCDIF to its default 650Mhz */
> +   clk_get_by_id(IMXRT1050_CLK_PLL5_VIDEO, );
> +   clk_enable(clk);
> +   clk_set_rate(clk, 65000UL);
> +
> +   clk_get_by_id(IMXRT1050_CLK_PLL5_BYPASS, );
> +   clk_set_parent(clk1, clk);
>
> +   /* Configure PLL5 as LCDIF source */
> +   clk_get_by_id(IMXRT1050_CLK_LCDIF_SEL, );
> +   clk_set_parent(clk1, clk);

This is more like a board design decision and IMHO should not be
hardcoded as part of the clock driver.

Other users may want to use a different clock source for the eLCDIF driver.

Setting the clock parent in board device tree makes more sense.


[PATCH 16/18] arch: arm: dts: imxrt1050-evk: add lcdif node

2020-02-26 Thread Giulio Benetti
Add lcdif node and its pinctrl.

Signed-off-by: Giulio Benetti 
---
 arch/arm/dts/imxrt1050-evk.dts | 57 ++
 1 file changed, 57 insertions(+)

diff --git a/arch/arm/dts/imxrt1050-evk.dts b/arch/arm/dts/imxrt1050-evk.dts
index 56b75986e2..f3e3baa6dc 100644
--- a/arch/arm/dts/imxrt1050-evk.dts
+++ b/arch/arm/dts/imxrt1050-evk.dts
@@ -185,6 +185,33 @@
0x17061
>;
};
+
+   pinctrl_lcdif: lcdifgrp {
+   u-boot,dm-spl;
+   fsl,pins = <
+   MXRT1050_IOMUXC_GPIO_B0_00_LCD_CLK  
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_01_LCD_ENABLE   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_02_LCD_HSYNC
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_03_LCD_VSYNC
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_04_LCD_DATA00   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_05_LCD_DATA01   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_06_LCD_DATA02   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_07_LCD_DATA03   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_08_LCD_DATA04   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_09_LCD_DATA05   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_10_LCD_DATA06   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_11_LCD_DATA07   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_12_LCD_DATA08   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_13_LCD_DATA09   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_14_LCD_DATA10   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B0_15_LCD_DATA11   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B1_01_LCD_DATA13   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B1_02_LCD_DATA14   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B1_03_LCD_DATA15   
0x1b0b1
+   MXRT1050_IOMUXC_GPIO_B1_15_GPIO2_IO31   
0x0b069
+   MXRT1050_IOMUXC_GPIO_AD_B0_02_GPIO1_IO02
0x0b069
+   >;
+   };
};
 };
 
@@ -198,3 +225,33 @@
 
cd-gpios = < 28 GPIO_ACTIVE_LOW>;
 };
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_lcdif>;
+   display = <>;
+   status = "okay";
+
+   display0: display0 {
+   bits-per-pixel = <16>;
+   bus-width = <16>;
+
+   display-timings {
+   timing0: timing0 {
+   clock-frequency = <930>;
+   hactive = <480>;
+   vactive = <272>;
+   hback-porch = <4>;
+   hfront-porch = <8>;
+   vback-porch = <4>;
+   vfront-porch = <8>;
+   hsync-len = <41>;
+   vsync-len = <10>;
+   de-active = <1>;
+   pixelclk-active = <0>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   };
+   };
+   };
+};
-- 
2.20.1



[PATCH] configs: am335x_evm: Use default log level

2020-02-26 Thread Sam Protsenko
Commit 920e3343 ("configs: am335x_evm: Reduce size of SPL") reduces
log level from 4 (default) to 3 in order to reduce SPL size. Arguably
the disadvantages of such a decision outweigh the benefits:

  (+) reducing SPL footprint by 1 KiB, but even with loglevel=4 we still
  have 2 KiB of SRAM left
  (-) we are missing error messages printed with pr_err() in U-Boot
  proper

One can argue that loglevel can be increased locally for debugging
purposes, which is true. But this way users are missing helpful messages
when something goes wrong, which is really confusing. E.g. when trying
to do "dfu tftp" without "dfu_alt_info" variable set, the only message
we can see is:

exit not allowed from main input shell.

while whith loglevel=4 user can see what is actually missing:

"dfu_alt_info" env variable not defined!

Bottom line: U-Boot proper shouldn't suffer of shortcomings because of
premature optimizations in SPL.

Let's use default loglevel, as we are not running out of SRAM yet. When
(and if) we run out of SRAM, we'll see the error message during the
build, as RAM size value in SPL linker script will be violated. Then we
can think about reducing loglevel only in SPL (e.g. by separating
CONFIG_SPL_LOGLEVEL option from CONFIG_LOGLEVEL).

Fixes: 920e3343 ("configs: am335x_evm: Reduce size of SPL")
Signed-off-by: Sam Protsenko 
---
 configs/am335x_evm_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 335aa8cfa1..19fec02b5e 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -8,7 +8,6 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_OF_BOARD_SETUP=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_LOGLEVEL=3
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_ARCH_MISC_INIT=y
-- 
2.24.1



[PATCH 17/18] configs: imxrt1050-evk: enable video support/console

2020-02-26 Thread Giulio Benetti
Enable DM_VIDEO subsystem and its BACKLIGHT_GPIO. Then enable
SYS_WHITE_ON_BLACK to have classic black background on display. Need
also to enable CONFIG_SYS_CONSOLE_ENV_OVERWRITE to retrieve
stdin/stdout/stderr from CONFIG_EXTRA_ENV_SETTINGS.

Signed-off-by: Giulio Benetti 
---
 configs/imxrt1050-evk_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/configs/imxrt1050-evk_defconfig b/configs/imxrt1050-evk_defconfig
index 71970552c0..810f391fdc 100644
--- a/configs/imxrt1050-evk_defconfig
+++ b/configs/imxrt1050-evk_defconfig
@@ -17,6 +17,7 @@ CONFIG_SPL_TEXT_BASE=0x20209000
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SD_BOOT=y
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SPL_BOARD_INIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
@@ -62,6 +63,9 @@ CONFIG_IMXRT_SDRAM=y
 CONFIG_FSL_LPUART=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
+CONFIG_DM_VIDEO=y
+CONFIG_BACKLIGHT_GPIO=y
+CONFIG_SYS_WHITE_ON_BLACK=y
 CONFIG_SHA1=y
 CONFIG_SHA256=y
 CONFIG_HEXDUMP=y
-- 
2.20.1



[PATCH 18/18] configs: imxrt1050-evk: temporary disable DCACHE

2020-02-26 Thread Giulio Benetti
mxsfb needs a dcache function not implemented in cortex-M7, so for the
moment let's keep dcache not enabled.

Signed-off-by: Giulio Benetti 
---
 configs/imxrt1050-evk_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/imxrt1050-evk_defconfig b/configs/imxrt1050-evk_defconfig
index 810f391fdc..25d0ba191c 100644
--- a/configs/imxrt1050-evk_defconfig
+++ b/configs/imxrt1050-evk_defconfig
@@ -1,4 +1,6 @@
 CONFIG_ARM=y
+CONFIG_SYS_DCACHE_OFF=y
+# CONFIG_SPL_SYS_DCACHE_OFF is not set
 CONFIG_ARCH_IMXRT=y
 CONFIG_SYS_TEXT_BASE=0x80002000
 CONFIG_SPL_GPIO_SUPPORT=y
-- 
2.20.1



[PATCH 13/18] imxrt1050_evk: add 16bpp video support if video layer enabled

2020-02-26 Thread Giulio Benetti
i.MXRT1050 provides mxsfb compatible lcd controller, so let's enable
video mxsfb driver with 16bpp depth if CONFIG_DM_VIDEO is selected since
board has 16bpp only connection.

Signed-off-by: Giulio Benetti 
---
 include/configs/imxrt1050-evk.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/include/configs/imxrt1050-evk.h b/include/configs/imxrt1050-evk.h
index cdec657fb0..3a6b972d9a 100644
--- a/include/configs/imxrt1050-evk.h
+++ b/include/configs/imxrt1050-evk.h
@@ -30,6 +30,21 @@
 
 #define CONFIG_SYS_MMC_ENV_DEV 0   /* USDHC1 */
 
+#ifdef CONFIG_DM_VIDEO
+#define CONFIG_VIDEO_MXS
+#define CONFIG_VIDEO_LOGO
+#define CONFIG_SPLASH_SCREEN
+#define CONFIG_SPLASH_SCREEN_ALIGN
+#define CONFIG_BMP_16BPP
+#define CONFIG_VIDEO_BMP_RLE8
+#define CONFIG_VIDEO_BMP_LOGO
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+   "stdin=serial\0" \
+   "stdout=serial,vidconsole\0" \
+   "stderr=serial,vidconsole\0"
+#endif
+
 /*
  * Configuration of the external SDRAM memory
  */
-- 
2.20.1



[PATCH 14/18] ARM: dts: i.mxrt1050: add lcdif node

2020-02-26 Thread Giulio Benetti
Add lcdif node to SoC.

Signed-off-by: Giulio Benetti 
---
 arch/arm/dts/imxrt1050.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/imxrt1050.dtsi b/arch/arm/dts/imxrt1050.dtsi
index b1d98e6feb..0123f4788c 100644
--- a/arch/arm/dts/imxrt1050.dtsi
+++ b/arch/arm/dts/imxrt1050.dtsi
@@ -13,6 +13,7 @@
 
 / {
aliases {
+   display0 = 
gpio0 = 
gpio1 = 
gpio2 = 
@@ -142,5 +143,14 @@
interrupt-controller;
#interrupt-cells = <2>;
};
+
+   lcdif: lcdif@402b8000 {
+   compatible = "fsl,imxrt-lcdif";
+   reg = <0x402b8000 0x1>;
+   interrupts = ;
+   clocks = < IMXRT1050_CLK_LCDIF>;
+   clock-names = "per";
+   status = "disabled";
+   };
};
 };
-- 
2.20.1



[PATCH 08/18] video: mxsfb: refactor for using display_timings

2020-02-26 Thread Giulio Benetti
struct display_timings provides more informations such clock and DE
polarity, so let's refactor the code to use struct display_timings
instead of struct ctfb_res_modes, so we'll become able to get clock and
DE polarity settings and set register according to them in the next patch.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 54 ++-
 1 file changed, 23 insertions(+), 31 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 6826ba3d1b..cdd6dfaced 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -54,7 +54,7 @@ __weak void mxsfb_system_setup(void)
  */
 
 static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
-struct ctfb_res_modes *mode, int bpp)
+struct display_timing *timings, int bpp)
 {
struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
uint32_t word_len = 0, bus_width = 0;
@@ -70,14 +70,14 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
return;
}
 
-   ret = clk_set_rate(_clk, PS2KHZ(mode->pixclock) * 1000);
+   ret = clk_set_rate(_clk, timings->pixelclock.typ);
if (ret < 0) {
dev_err(dev, "Failed to set mxs clk: %d\n", ret);
return;
}
 #else
/* Kick in the LCDIF clock */
-   mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock));
+   mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);
 #endif
 
/* Restart the LCDIF block */
@@ -115,25 +115,25 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 
mxsfb_system_setup();
 
-   writel((mode->yres << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) | mode->xres,
-   >hw_lcdif_transfer_count);
+   writel((timings->vactive.typ << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) |
+   timings->hactive.typ, >hw_lcdif_transfer_count);
 
writel(LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL |
LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT |
LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |
-   mode->vsync_len, >hw_lcdif_vdctrl0);
-   writel(mode->upper_margin + mode->lower_margin +
-   mode->vsync_len + mode->yres,
+   timings->vsync_len.typ, >hw_lcdif_vdctrl0);
+   writel(timings->vback_porch.typ + timings->vfront_porch.typ +
+   timings->vsync_len.typ + timings->vactive.typ,
>hw_lcdif_vdctrl1);
-   writel((mode->hsync_len << LCDIF_VDCTRL2_HSYNC_PULSE_WIDTH_OFFSET) |
-   (mode->left_margin + mode->right_margin +
-   mode->hsync_len + mode->xres),
+   writel((timings->hsync_len.typ << 
LCDIF_VDCTRL2_HSYNC_PULSE_WIDTH_OFFSET) |
+   (timings->hback_porch.typ + timings->hfront_porch.typ +
+   timings->hsync_len.typ + timings->hactive.typ),
>hw_lcdif_vdctrl2);
-   writel(((mode->left_margin + mode->hsync_len) <<
+   writel(((timings->hback_porch.typ + timings->hsync_len.typ) <<
LCDIF_VDCTRL3_HORIZONTAL_WAIT_CNT_OFFSET) |
-   (mode->upper_margin + mode->vsync_len),
+   (timings->vback_porch.typ + timings->vsync_len.typ),
>hw_lcdif_vdctrl3);
-   writel((0 << LCDIF_VDCTRL4_DOTCLK_DLY_SEL_OFFSET) | mode->xres,
+   writel((0 << LCDIF_VDCTRL4_DOTCLK_DLY_SEL_OFFSET) | 
timings->hactive.typ,
>hw_lcdif_vdctrl4);
 
writel(fb_addr, >hw_lcdif_cur_buf);
@@ -154,11 +154,11 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
writel(LCDIF_CTRL_RUN, >hw_lcdif_ctrl_set);
 }
 
-static int mxs_probe_common(struct udevice *dev, struct ctfb_res_modes *mode,
+static int mxs_probe_common(struct udevice *dev, struct display_timing 
*timings,
int bpp, u32 fb)
 {
/* Start framebuffer */
-   mxs_lcd_init(dev, fb, mode, bpp);
+   mxs_lcd_init(dev, fb, timings, bpp);
 
 #ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
/*
@@ -224,6 +224,7 @@ void *video_hw_init(void)
char *penv;
void *fb = NULL;
struct ctfb_res_modes mode;
+   struct display_timing timings;
 
puts("Video: ");
 
@@ -280,7 +281,9 @@ void *video_hw_init(void)
 
printf("%s\n", panel.modeIdent);
 
-   ret = mxs_probe_common(NULL, , bpp, (u32)fb);
+   video_ctfb_mode_to_display_timing(, );
+
+   ret = mxs_probe_common(NULL, , bpp, (u32)fb);
if (ret)
goto dealloc_fb;
 
@@ -334,7 +337,6 @@ static int mxs_video_probe(struct udevice *dev)
struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
 
-   struct ctfb_res_modes mode;
struct display_timing timings;
u32 bpp = 0;
u32 fb_start, fb_end;
@@ -347,17 +349,7 @@ static int mxs_video_probe(struct udevice *dev)
if (ret)
return ret;
 
-

[PATCH 15/18] ARM: dts: imxrt1050: allow this dtsi file to be compiled in Linux

2020-02-26 Thread Giulio Benetti
Linux doesn't provide skeleton.dtsi file so let's remove its include and
provide #address-cells/size-cells = <1> that were defined in
skeleton.dtsi before.

Signed-off-by: Giulio Benetti 
---
 arch/arm/dts/imxrt1050.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/imxrt1050.dtsi b/arch/arm/dts/imxrt1050.dtsi
index 0123f4788c..7cfe5f5c95 100644
--- a/arch/arm/dts/imxrt1050.dtsi
+++ b/arch/arm/dts/imxrt1050.dtsi
@@ -4,7 +4,6 @@
  * Author(s): Giulio Benetti 
  */
 
-#include "skeleton.dtsi"
 #include "armv7-m.dtsi"
 #include 
 #include 
@@ -12,6 +11,9 @@
 #include 
 
 / {
+   #address-cells = <1>;
+   #size-cells = <1>;
+
aliases {
display0 = 
gpio0 = 
-- 
2.20.1



[PATCH 12/18] video: mxsfb: enable setting ENABLE negative polarity

2020-02-26 Thread Giulio Benetti
ENABLE signal can now be flipped by writing its bitmask on vdctrl0
register.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 648e1c22fe..8a5a61c9fb 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -131,6 +131,9 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
vdctrl0 |= LCDIF_VDCTRL0_VSYNC_POL;
if(flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
vdctrl0 |= LCDIF_VDCTRL0_DOTCLK_POL;
+   if(flags & DISPLAY_FLAGS_DE_HIGH)
+   vdctrl0 |= LCDIF_VDCTRL0_ENABLE_POL;
+
writel(vdctrl0, >hw_lcdif_vdctrl0);
writel(timings->vback_porch.typ + timings->vfront_porch.typ +
timings->vsync_len.typ + timings->vactive.typ,
-- 
2.20.1



[PATCH 07/18] video: mxsfb: add support for i.MXRT

2020-02-26 Thread Giulio Benetti
Add support for i.MXRT by adding CONFIG_IMXRT in register structure and
adding .compatible = "fsl,imxrt-lcdif".

Signed-off-by: Giulio Benetti 
---
 arch/arm/include/asm/arch-imxrt/imx-regs.h | 6 ++
 arch/arm/include/asm/mach-imx/regs-lcdif.h | 6 +++---
 drivers/video/mxsfb.c  | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-imxrt/imx-regs.h 
b/arch/arm/include/asm/arch-imxrt/imx-regs.h
index 4f1d439f6f..44c95dcd11 100644
--- a/arch/arm/include/asm/arch-imxrt/imx-regs.h
+++ b/arch/arm/include/asm/arch-imxrt/imx-regs.h
@@ -17,4 +17,10 @@
 
 #define ANATOP_BASE_ADDR   0x400d8000
 
+#define MXS_LCDIF_BASE 0x402b8000
+
+#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
+#include 
+#endif
+
 #endif /* __ASM_ARCH_IMX_REGS_H__ */
diff --git a/arch/arm/include/asm/mach-imx/regs-lcdif.h 
b/arch/arm/include/asm/mach-imx/regs-lcdif.h
index b4c430a35c..5874638796 100644
--- a/arch/arm/include/asm/mach-imx/regs-lcdif.h
+++ b/arch/arm/include/asm/mach-imx/regs-lcdif.h
@@ -22,7 +22,7 @@ struct mxs_lcdif_regs {
defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL) || \
defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) || \
defined(CONFIG_MX7) || defined(CONFIG_MX7ULP) || \
-   defined(CONFIG_IMX8M)
+   defined(CONFIG_IMX8M) || defined(CONFIG_IMXRT)
mxs_reg_32(hw_lcdif_ctrl2)  /* 0x20 */
 #endif
mxs_reg_32(hw_lcdif_transfer_count) /* 0x20/0x30 */
@@ -49,7 +49,7 @@ struct mxs_lcdif_regs {
mxs_reg_32(hw_lcdif_csc_coeffctrl2) /* 0x130 */
mxs_reg_32(hw_lcdif_csc_coeffctrl3) /* 0x140 */
mxs_reg_32(hw_lcdif_csc_coeffctrl4) /* 0x150 */
-   mxs_reg_32(hw_lcdif_csc_offset) /* 0x160 */
+   mxs_reg_32(hw_lcdif_csc_offset) /* 0x160 */
mxs_reg_32(hw_lcdif_csc_limit)  /* 0x170 */
 
 #if defined(CONFIG_MX23)
@@ -61,7 +61,7 @@ struct mxs_lcdif_regs {
defined(CONFIG_MX6SL) || defined(CONFIG_MX6SLL) || \
defined(CONFIG_MX6UL) || defined(CONFIG_MX6ULL) || \
defined(CONFIG_MX7) || defined(CONFIG_MX7ULP) || \
-   defined(CONFIG_IMX8M)
+   defined(CONFIG_IMX8M) || defined(CONFIG_IMXRT)
mxs_reg_32(hw_lcdif_crc_stat)   /* 0x1a0 */
 #endif
mxs_reg_32(hw_lcdif_lcdif_stat) /* 0x1d0/0x1b0 */
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index f21f8247d9..6826ba3d1b 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -440,6 +440,7 @@ static const struct udevice_id mxs_video_ids[] = {
{ .compatible = "fsl,imx23-lcdif" },
{ .compatible = "fsl,imx28-lcdif" },
{ .compatible = "fsl,imx7ulp-lcdif" },
+   { .compatible = "fsl,imxrt-lcdif" },
{ /* sentinel */ }
 };
 
-- 
2.20.1



[PATCH 11/18] video: mxsfb: enable setting PIXDATA on negative edge

2020-02-26 Thread Giulio Benetti
DOTCLK signal can now be flipped by writing its bitmask on vdctrl0
register.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 4d33e24e1a..648e1c22fe 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -129,6 +129,8 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
vdctrl0 |= LCDIF_VDCTRL0_HSYNC_POL;
if(flags & DISPLAY_FLAGS_VSYNC_HIGH)
vdctrl0 |= LCDIF_VDCTRL0_VSYNC_POL;
+   if(flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+   vdctrl0 |= LCDIF_VDCTRL0_DOTCLK_POL;
writel(vdctrl0, >hw_lcdif_vdctrl0);
writel(timings->vback_porch.typ + timings->vfront_porch.typ +
timings->vsync_len.typ + timings->vactive.typ,
-- 
2.20.1



[PATCH 09/18] video: mxsfb: enable setting HSYNC negative polarity

2020-02-26 Thread Giulio Benetti
HSYNC signal can now be flipped according to display_flags bitmaks by
writing its bitmask on vdctrl0 register.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index cdd6dfaced..9912cf3d82 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -57,8 +57,10 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 struct display_timing *timings, int bpp)
 {
struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+   const enum display_flags flags = timings->flags;
uint32_t word_len = 0, bus_width = 0;
uint8_t valid_data = 0;
+   uint32_t vdctrl0;
 
 #if CONFIG_IS_ENABLED(CLK)
struct clk per_clk;
@@ -118,10 +120,14 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
writel((timings->vactive.typ << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) |
timings->hactive.typ, >hw_lcdif_transfer_count);
 
-   writel(LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL |
-   LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT |
-   LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |
-   timings->vsync_len.typ, >hw_lcdif_vdctrl0);
+   vdctrl0 = LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL |
+ LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT |
+ LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |
+ timings->vsync_len.typ;
+
+   if(flags & DISPLAY_FLAGS_HSYNC_HIGH)
+   vdctrl0 |= LCDIF_VDCTRL0_HSYNC_POL;
+   writel(vdctrl0, >hw_lcdif_vdctrl0);
writel(timings->vback_porch.typ + timings->vfront_porch.typ +
timings->vsync_len.typ + timings->vactive.typ,
>hw_lcdif_vdctrl1);
-- 
2.20.1



[PATCH 06/18] video: mxsfb: add support for DM CLK

2020-02-26 Thread Giulio Benetti
Allow using DM CLK instead of mxs_set_lcdclk() so we can avoid to
implement a special function to set lcd clock on i.MXRT.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 585af3d571..f21f8247d9 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2011-2013 Marek Vasut 
  */
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,14 +53,32 @@ __weak void mxsfb_system_setup(void)
  *  le:89,ri:164,up:23,lo:10,hs:10,vs:10,sync:0,vmode:0
  */
 
-static void mxs_lcd_init(u32 fb_addr, struct ctfb_res_modes *mode, int bpp)
+static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
+struct ctfb_res_modes *mode, int bpp)
 {
struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
uint32_t word_len = 0, bus_width = 0;
uint8_t valid_data = 0;
 
+#if CONFIG_IS_ENABLED(CLK)
+   struct clk per_clk;
+   int ret;
+
+   ret = clk_get_by_name(dev, "per", _clk);
+   if (ret) {
+   dev_err(dev, "Failed to get mxs clk: %d\n", ret);
+   return;
+   }
+
+   ret = clk_set_rate(_clk, PS2KHZ(mode->pixclock) * 1000);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set mxs clk: %d\n", ret);
+   return;
+   }
+#else
/* Kick in the LCDIF clock */
mxs_set_lcdclk(MXS_LCDIF_BASE, PS2KHZ(mode->pixclock));
+#endif
 
/* Restart the LCDIF block */
mxs_reset_block(>hw_lcdif_ctrl_reg);
@@ -135,10 +154,11 @@ static void mxs_lcd_init(u32 fb_addr, struct 
ctfb_res_modes *mode, int bpp)
writel(LCDIF_CTRL_RUN, >hw_lcdif_ctrl_set);
 }
 
-static int mxs_probe_common(struct ctfb_res_modes *mode, int bpp, u32 fb)
+static int mxs_probe_common(struct udevice *dev, struct ctfb_res_modes *mode,
+   int bpp, u32 fb)
 {
/* Start framebuffer */
-   mxs_lcd_init(fb, mode, bpp);
+   mxs_lcd_init(dev, fb, mode, bpp);
 
 #ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
/*
@@ -260,7 +280,7 @@ void *video_hw_init(void)
 
printf("%s\n", panel.modeIdent);
 
-   ret = mxs_probe_common(, bpp, (u32)fb);
+   ret = mxs_probe_common(NULL, , bpp, (u32)fb);
if (ret)
goto dealloc_fb;
 
@@ -337,7 +357,7 @@ static int mxs_video_probe(struct udevice *dev)
mode.vsync_len = timings.vsync_len.typ;
mode.pixclock = HZ2PS(timings.pixelclock.typ);
 
-   ret = mxs_probe_common(, bpp, plat->base);
+   ret = mxs_probe_common(dev, , bpp, plat->base);
if (ret)
return ret;
 
-- 
2.20.1



[PATCH 10/18] video: mxsfb: enable setting VSYNC negative polarity

2020-02-26 Thread Giulio Benetti
VSYNC signal can now be flipped by writing its bitmask on vdctrl0
register.

Signed-off-by: Giulio Benetti 
---
 drivers/video/mxsfb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 9912cf3d82..4d33e24e1a 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -127,6 +127,8 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 
if(flags & DISPLAY_FLAGS_HSYNC_HIGH)
vdctrl0 |= LCDIF_VDCTRL0_HSYNC_POL;
+   if(flags & DISPLAY_FLAGS_VSYNC_HIGH)
+   vdctrl0 |= LCDIF_VDCTRL0_VSYNC_POL;
writel(vdctrl0, >hw_lcdif_vdctrl0);
writel(timings->vback_porch.typ + timings->vfront_porch.typ +
timings->vsync_len.typ + timings->vactive.typ,
-- 
2.20.1



[PATCH 03/18] clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL

2020-02-26 Thread Giulio Benetti
mxsfb needs PLL5 as source, so let's setup it and set it as source for
mxsfb(lcdif).

Signed-off-by: Giulio Benetti 
---
 drivers/clk/imx/clk-imxrt1050.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index e33d426363..2819ffb9ac 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -238,9 +238,9 @@ static int imxrt1050_clk_probe(struct udevice *dev)
clk_dm(IMXRT1050_CLK_LCDIF,
   imx_clk_gate2("lcdif", "lcdif_podf", base + 0x70, 28));
 
-#ifdef CONFIG_SPL_BUILD
struct clk *clk, *clk1;
 
+#ifdef CONFIG_SPL_BUILD
/* bypass pll1 before setting its rate */
clk_get_by_id(IMXRT1050_CLK_PLL1_REF_SEL, );
clk_get_by_id(IMXRT1050_CLK_PLL1_BYPASS, );
@@ -271,7 +271,18 @@ static int imxrt1050_clk_probe(struct udevice *dev)
 
clk_get_by_id(IMXRT1050_CLK_PLL3_BYPASS, );
clk_set_parent(clk1, clk);
+#else
+   /* Set PLL5 for LCDIF to its default 650Mhz */
+   clk_get_by_id(IMXRT1050_CLK_PLL5_VIDEO, );
+   clk_enable(clk);
+   clk_set_rate(clk, 65000UL);
+
+   clk_get_by_id(IMXRT1050_CLK_PLL5_BYPASS, );
+   clk_set_parent(clk1, clk);
 
+   /* Configure PLL5 as LCDIF source */
+   clk_get_by_id(IMXRT1050_CLK_LCDIF_SEL, );
+   clk_set_parent(clk1, clk);
 #endif
 
return 0;
-- 
2.20.1



[PATCH 04/18] videomodes: add helper function to convert from ctfb to display_timing

2020-02-26 Thread Giulio Benetti
This function converts from "struct ctf_res_modes" to
"struct display_timing".

Signed-off-by: Giulio Benetti 
---
 drivers/video/videomodes.c | 29 +
 drivers/video/videomodes.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
index ac25b45f81..89003eea72 100644
--- a/drivers/video/videomodes.c
+++ b/drivers/video/videomodes.c
@@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct 
edid_detailed_timing *t,
 
return 0;
 }
+
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+  struct display_timing *timing)
+{
+   timing->pixelclock.typ = mode->pixclock_khz * 1000;
+
+   timing->hactive.typ = mode->xres;
+   timing->hfront_porch.typ = mode->right_margin;
+   timing->hback_porch.typ = mode->left_margin;
+   timing->hsync_len.typ = mode->hsync_len;
+
+   timing->vactive.typ = mode->yres;
+   timing->vfront_porch.typ = mode->lower_margin;
+   timing->vback_porch.typ = mode->upper_margin;
+   timing->vsync_len.typ = mode->vsync_len;
+
+   timing->flags = 0;
+
+   if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
+   timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+   else
+   timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
+   if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
+   timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+   else
+   timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
+   if (mode->vmode == FB_VMODE_INTERLACED)
+   timing->flags |= DISPLAY_FLAGS_INTERLACED;
+}
diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
index 29a3db4ae3..6713f96d19 100644
--- a/drivers/video/videomodes.h
+++ b/drivers/video/videomodes.h
@@ -92,3 +92,6 @@ int video_get_option_int(const char *options, const char 
*name, int def);
 
 int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
 struct ctfb_res_modes *mode);
+
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+  struct display_timing *timing);
-- 
2.20.1



[PATCH 00/18] i.MXRT1050 add LCDIF support

2020-02-26 Thread Giulio Benetti
This patchset add support for LCDIF on i.MXRT1050 evk. This requires
PLL5 to be setup, mxsfb needs to use display_timing to retrieve if Lcd
has inverted PIXCLOCK from dts.

With this patchset applied we temporary loose DCache support until it will
get implemented, since a function in mxsfb.c is needed for setting cache
behaviour. Anyway this way Lcd will show the console same way as serial
does.

Also I've moved private sunxi_ctfb_mode_to_display_timing() to videomodes
since I need it for mxfsb.c too, then having a unified function to convert
from ctfb_mode to display_timing.

Giulio Benetti (18):
  clk: imx: pllv3: add enable_bit
  clk: imx: imxrt1050-clk: fix typo in clock name "video:"
  clk: imx: clk-imxrt1050: setup PLL5 for video in non-SPL
  videomodes: add helper function to convert from ctfb to display_timing
  sunxi: display: use common video_ctfb_mode_to_display_timing()
  video: mxsfb: add support for DM CLK
  video: mxsfb: add support for i.MXRT
  video: mxsfb: refactor for using display_timings
  video: mxsfb: enable setting HSYNC negative polarity
  video: mxsfb: enable setting VSYNC negative polarity
  video: mxsfb: enable setting PIXDATA on negative edge
  video: mxsfb: enable setting ENABLE negative polarity
  imxrt1050_evk: add 16bpp video support if video layer enabled
  ARM: dts: i.mxrt1050: add lcdif node
  ARM: dts: imxrt1050: allow this dtsi file to be compiled in Linux
  arch: arm: dts: imxrt1050-evk: add lcdif node
  configs: imxrt1050-evk: enable video support/console
  configs: imxrt1050-evk: temporary disable DCACHE

 arch/arm/dts/imxrt1050-evk.dts | 57 +
 arch/arm/dts/imxrt1050.dtsi| 14 +++-
 arch/arm/include/asm/arch-imxrt/imx-regs.h |  6 ++
 arch/arm/include/asm/mach-imx/regs-lcdif.h |  6 +-
 configs/imxrt1050-evk_defconfig|  6 ++
 drivers/clk/imx/clk-imxrt1050.c| 15 +++-
 drivers/clk/imx/clk-pllv3.c|  9 +++
 drivers/video/mxsfb.c  | 94 ++
 drivers/video/sunxi/sunxi_display.c| 33 +---
 drivers/video/videomodes.c | 29 +++
 drivers/video/videomodes.h |  3 +
 include/configs/imxrt1050-evk.h| 15 
 12 files changed, 216 insertions(+), 71 deletions(-)

-- 
2.20.1



[PATCH 05/18] sunxi: display: use common video_ctfb_mode_to_display_timing()

2020-02-26 Thread Giulio Benetti
Since video_ctfb_mode_to_display_timing() has been implemented by moving
sunxi_ctfb_mode_to_display_timing() to video_modes.c and it's meant to be
used by other video subsystem, let's use it instead of local
sunxi_ctfb_mode_to_display_timing().

Signed-off-by: Giulio Benetti 
---
 drivers/video/sunxi/sunxi_display.c | 33 ++---
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/drivers/video/sunxi/sunxi_display.c 
b/drivers/video/sunxi/sunxi_display.c
index 31f0aa7ddc..a6a62c83ef 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -615,35 +615,6 @@ static void sunxi_lcdc_backlight_enable(void)
gpio_direction_output(pin, PWM_ON);
 }
 
-static void sunxi_ctfb_mode_to_display_timing(const struct ctfb_res_modes 
*mode,
- struct display_timing *timing)
-{
-   timing->pixelclock.typ = mode->pixclock_khz * 1000;
-
-   timing->hactive.typ = mode->xres;
-   timing->hfront_porch.typ = mode->right_margin;
-   timing->hback_porch.typ = mode->left_margin;
-   timing->hsync_len.typ = mode->hsync_len;
-
-   timing->vactive.typ = mode->yres;
-   timing->vfront_porch.typ = mode->lower_margin;
-   timing->vback_porch.typ = mode->upper_margin;
-   timing->vsync_len.typ = mode->vsync_len;
-
-   timing->flags = 0;
-
-   if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
-   timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
-   else
-   timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
-   if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
-   timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
-   else
-   timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
-   if (mode->vmode == FB_VMODE_INTERLACED)
-   timing->flags |= DISPLAY_FLAGS_INTERLACED;
-}
-
 static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
  bool for_ext_vga_dac)
 {
@@ -673,7 +644,7 @@ static void sunxi_lcdc_tcon0_mode_set(const struct 
ctfb_res_modes *mode,
lcdc_pll_set(ccm, 0, mode->pixclock_khz, _div, _double,
 sunxi_is_composite());
 
-   sunxi_ctfb_mode_to_display_timing(mode, );
+   video_ctfb_mode_to_display_timing(mode, );
lcdc_tcon0_mode_set(lcdc, , clk_div, for_ext_vga_dac,
sunxi_display.depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
 }
@@ -689,7 +660,7 @@ static void sunxi_lcdc_tcon1_mode_set(const struct 
ctfb_res_modes *mode,
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
struct display_timing timing;
 
-   sunxi_ctfb_mode_to_display_timing(mode, );
+   video_ctfb_mode_to_display_timing(mode, );
lcdc_tcon1_mode_set(lcdc, , use_portd_hvsync,
sunxi_is_composite());
 
-- 
2.20.1



[PATCH 02/18] clk: imx: imxrt1050-clk: fix typo in clock name "video:"

2020-02-26 Thread Giulio Benetti
"video:" must be "video", ":" is a typo.

Signed-off-by: Giulio Benetti 
---
 drivers/clk/imx/clk-imxrt1050.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index 44ca52c013..e33d426363 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -90,7 +90,7 @@ static const char *const usdhc_sels[] = { "pll2_pfd2_396m", 
"pll2_pfd0_352m", };
 static const char *const lpuart_sels[] = { "pll3_80m", "osc", };
 static const char *const semc_alt_sels[] = { "pll2_pfd2_396m", 
"pll3_pfd1_664_62m", };
 static const char *const semc_sels[] = { "periph_sel", "semc_alt_sel", };
-static const char *const lcdif_sels[] = { "pll2_sys", "pll3_pfd3_454_74m", 
"pll5_video:", "pll2_pfd0_352m", "pll2_pfd1_594m", "pll3_pfd1_664_62m"};
+static const char *const lcdif_sels[] = { "pll2_sys", "pll3_pfd3_454_74m", 
"pll5_video", "pll2_pfd0_352m", "pll2_pfd1_594m", "pll3_pfd1_664_62m"};
 
 static int imxrt1050_clk_probe(struct udevice *dev)
 {
-- 
2.20.1



[PATCH 01/18] clk: imx: pllv3: add enable_bit

2020-02-26 Thread Giulio Benetti
pllv3 PLLs have powerdown/up bits but enable bits too. Specifically
"enable bit" enable the pll output, so when dis/enabling pll by
setting/clearing power_bit we must also set/clear enable_bit.

Signed-off-by: Giulio Benetti 
---
 drivers/clk/imx/clk-pllv3.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
index 525442debf..b4a9d587e1 100644
--- a/drivers/clk/imx/clk-pllv3.c
+++ b/drivers/clk/imx/clk-pllv3.c
@@ -25,6 +25,7 @@
 #define PLL_DENOM_OFFSET   0x20
 
 #define BM_PLL_POWER   (0x1 << 12)
+#define BM_PLL_ENABLE  (0x1 << 13)
 #define BM_PLL_LOCK(0x1 << 31)
 
 struct clk_pllv3 {
@@ -32,6 +33,7 @@ struct clk_pllv3 {
void __iomem*base;
u32 power_bit;
boolpowerup_set;
+   u32 enable_bit;
u32 div_mask;
u32 div_shift;
 };
@@ -83,6 +85,9 @@ static int clk_pllv3_generic_enable(struct clk *clk)
val |= pll->power_bit;
else
val &= ~pll->power_bit;
+
+   val |= pll->enable_bit;
+
writel(val, pll->base);
 
return 0;
@@ -98,6 +103,9 @@ static int clk_pllv3_generic_disable(struct clk *clk)
val &= ~pll->power_bit;
else
val |= pll->power_bit;
+
+   val &= ~pll->enable_bit;
+
writel(val, pll->base);
 
return 0;
@@ -238,6 +246,7 @@ struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const 
char *name,
return ERR_PTR(-ENOMEM);
 
pll->power_bit = BM_PLL_POWER;
+   pll->enable_bit = BM_PLL_ENABLE;
 
switch (type) {
case IMX_PLLV3_GENERIC:
-- 
2.20.1



Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Andy Shevchenko
On Wed, Feb 26, 2020 at 5:27 PM Bin Meng  wrote:
> On Wed, Feb 26, 2020 at 11:01 PM Andy Shevchenko
>  wrote:
> > On Wed, Feb 26, 2020 at 2:59 PM Tom Rini  wrote:

...

> > Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
> > has not been pulled).
> >
>
> Yes, it's currently in the x86 tree and will be in rc4.

Thank you, Bin, for clarifying!

-- 
With Best Regards,
Andy Shevchenko


Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Andy Shevchenko
On Wed, Feb 26, 2020 at 5:57 PM Lukasz Majewski  wrote:
> > On Wed, Feb 26, 2020 at 05:01:29PM +0200, Andy Shevchenko wrote:
> > > On Wed, Feb 26, 2020 at 2:59 PM Tom Rini 
> > > wrote:

...

> > > Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
> > > has not been pulled).
> >
> > I don't see the PR here, sorry!
> >
> > > And one inconvenience: DFU timeout API feature requires one small
> > > fix which is in Lukasz branch, but by some reason didn't make rc3.
> >
> > And I think this is coming via the USB tree perhaps?
>
> I've sent PR on last Friday (with Andy on CC):
> [GIT] Pull request: u-boot-dfu (21.02.2020)
>
> It shall be pulled by Marek soon to the u-boot-usb tree.

Thank you, Lukasz!

I saw it, but it was some discussion and seems now it's being resolved.

-- 
With Best Regards,
Andy Shevchenko


[cmd]:"env edit" vs "env set",do we need both options for "env" command ??

2020-02-26 Thread Adarsh Babu Kalepalli
Hi,

Are'nt "env edit" vs "env set" redundant ??.
"env edit" allows modification of the environment variable value in the
next line,whereas "env set" requires the mention of the environment
variable value in the same line.

If the values for environment variables are not provided ,in either case
they would be deleted.

Can we have only one of these commands ??.

A single line description for "set" sub-command of "env" with mention to
that additional feature will provide better clarity.

Regards,
Adarsh


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

2020-02-26 Thread Christophe Leroy




Le 25/02/2020 à 17:40, Tom Rini a écrit :

On Thu, Feb 20, 2020 at 07:39:51AM +, Christophe Leroy wrote:


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

Select CONFIG_HW_WATCHDOG and make hw_watchdog_reset() visible.

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

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

Fixes: f3729ba6e7b2 ("watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup")
Fixes: b3134ffbd944 ("watchdog: Kconfig: Sort entry alphabetically")
Signed-off-by: Christophe Leroy 
Cc: Stefan Roese 
Cc: Patrice Chotard 
Reviewed-by: Stefan Roese 


Please note that as-is this causes a build failure:
+(MCR3000) In file included from ../arch/powerpc/cpu/mpc8xx/cpu.c:23:0:
+(MCR3000) ../include/watchdog.h:32:4: error: #error "Configuration error: 
CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG can't be used together."
+(MCR3000)  #  error "Configuration error: CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG 
can't be used  together."
+(MCR3000) ^
+(MCR3000) make[2]: *** [arch/powerpc/cpu/mpc8xx/cpu.o] Error 1
+(MCR3000) make[1]: *** [arch/powerpc/cpu/mpc8xx] Error 2
+(MCR3000) make: *** [sub-make] Error 2



Right.

CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG are mutually exclusive but 
CONFIG_WDT implicitely selects CONFIG_WATCHDOG since commit 06985289d452 
("watchdog: Implement generic watchdog_reset() version")


I've just sent a patch to fix that. Please take both together.

Christophe


[PATCH] watchdog: Don't select CONFIG_WATCHDOG and CONFIG_HW_WATCHDOG at the same time

2020-02-26 Thread Christophe Leroy
Commit 06985289d452 ("watchdog: Implement generic watchdog_reset()
version") introduced an automatic selection of CONFIG_WATCHDOG by
CONFIG_WDT. But for boards selecting CONFIG_HW_WATCHDOG, like
boards have a powerpc 8xx, CONFIG_WATCHDOG shall not be selected
as they are mutually exclusive.

Make CONFIG_WATCHDOG dependent on !CONFIG_HW_WATCHDOG

Fixes: 06985289d452 ("watchdog: Implement generic watchdog_reset() version")
Cc: Stefan Roese 
Signed-off-by: Christophe Leroy 
---
 drivers/watchdog/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index fbb561b995f1..d24c1e48353f 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -2,6 +2,7 @@ menu "Watchdog Timer Support"
 
 config WATCHDOG
bool "Enable U-Boot watchdog reset"
+   depends on !HW_WATCHDOG
help
  This option enables U-Boot watchdog support where U-Boot is using
  watchdog_reset function to service watchdog device in U-Boot. Enable
-- 
2.25.0



Re: [PATCH] usb: ehci: Fix "EHCI timed out on TD - token=XXXX" error on ehci-hcd

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 12:29:55PM +0100, Lukasz Majewski wrote:

> This patch aims to improve robustness of 'usb' command operation on the
> ehci-hcd IP block as it ports to contemporary U-Boot the patch described
> and provided in [1] (originally applicable to U-Boot 2016.05).
> 
> According to the fix author - "rayvt" (from [1]):
> 
> TD stands for "Queue Element Transfer Descriptor (qTD)", which is a micro-code
> instruction for the EHCI USB chip.
> The "token" field is detailed information, control, and status of the TD's 
> data
> transfer. In particular, the rightmost byte is the status field. 0x80 bit 
> means
> the TD is active and the data transfer has not yet completed. 0x08 bit means
> there was some sort of data transfer error (XactErr).
> 
> If the drive gets a transfer error, it refuses to do any other I/O transfer
> until the error is properly cleared and reset. U-boot did not do this, so 
> every
> subsequent disk read would get a timeout error because the drive would not 
> send
> any data. The fix is to properly clear and reset the USB disk when it gets a
> transfer error.
> 
> Every read operation starts at the maximum block size. When the USB pendrive 
> is
> not able to correctly serve this data read request, the dynamic reduction of 
> IO
> size is performed. Up to six tries (with smaller IO block each time) are
> attempted.
> 
> A related problem is that some drives are slow to come up. Linux handles this 
> by
> issuing a spinup command and allowing more time for the drive to respond. The
> same idea is applied in this fix.
> 
> On TPC70 (i.MX6Q) once per ~10 times (without this patch):
> 
> Bus usb@2184200: USB EHCI 1.00
> scanning bus usb@2184200 for devices... 2 USB Device(s) found
>scanning usb for storage devices... 1 Storage Device(s) found
> EHCI timed out on TD - token=0x1f8c80
> 
> Performance impact:
> 
> With U-Boot -master in mainline:
> 16869440 bytes read in 979 ms (16.4 MiB/s)
> 
> With this patch:
> 16869440 bytes read in 1219 ms (13.2 MiB/s)
> 
> Links:
> [1] - https://forum.doozan.com/read.php?3,35295,35295#msg-35295
> [2] - 
> https://www.dropbox.com/s/nrkrd1no63viuu8/uboot-bodhi-2016.05-timeoutTD.patch?dl=0
> 
> Signed-off-by: Lukasz Majewski 
> [Unfortunately, the original patch [2] did not contain S-o-B from the original
> author - "rayvt"]

This problem was seen in Beagleboard xM as well and reported by
Guillaume back in January, so:
Reported-by: Guillaume Gardet 

And on board, I can confirm the problem also goes away now so:

Tested-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Lukasz Majewski
Hi Tom,

> On Wed, Feb 26, 2020 at 05:01:29PM +0200, Andy Shevchenko wrote:
> > On Wed, Feb 26, 2020 at 2:59 PM Tom Rini 
> > wrote:  
> > >
> > > Hey all,
> > >
> > > It's two days late, but here is v2020.04-rc3.  The series to add
> > > htmldocs tests to CI that I added on Monday took longer than I had
> > > expected to go all green in CI.  I was going to do this yesterday
> > > after applying the fixes that I pushed but got side-tracked, so
> > > here we are.  
> > 
> > Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
> > has not been pulled).  
> 
> I don't see the PR here, sorry!
> 
> > And one inconvenience: DFU timeout API feature requires one small
> > fix which is in Lukasz branch, but by some reason didn't make rc3.  
> 
> And I think this is coming via the USB tree perhaps?

I've sent PR on last Friday (with Andy on CC):
[GIT] Pull request: u-boot-dfu (21.02.2020)

It shall be pulled by Marek soon to the u-boot-usb tree.

>  Or is it in the
> clk part itself?  Thanks!
> 




Best regards,

Lukasz Majewski

--

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


pgpOv9uyzKkuE.pgp
Description: OpenPGP digital signature


Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 05:01:29PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 26, 2020 at 2:59 PM Tom Rini  wrote:
> >
> > Hey all,
> >
> > It's two days late, but here is v2020.04-rc3.  The series to add
> > htmldocs tests to CI that I added on Monday took longer than I had
> > expected to go all green in CI.  I was going to do this yesterday after
> > applying the fixes that I pushed but got side-tracked, so here we are.
> 
> Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
> has not been pulled).

I don't see the PR here, sorry!

> And one inconvenience: DFU timeout API feature requires one small fix
> which is in Lukasz branch, but by some reason didn't make rc3.

And I think this is coming via the USB tree perhaps?  Or is it in the
clk part itself?  Thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] cmd: fat: remove unused includes

2020-02-26 Thread Simon Glass
On Tue, 25 Feb 2020 at 22:26, Heinrich Schuchardt  wrote:
>
> Remove unused includes from cmd/fat.c.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/fat.c | 6 --
>  1 file changed, 6 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] README: replace reference to boards.cfg

2020-02-26 Thread Simon Glass
On Mon, 24 Feb 2020 at 10:36, Heinrich Schuchardt  wrote:
>
> boards.cfg is not delivered with the U-Boot source. So it is preferable to
> look at configs/*_defconfig to identify available deconfigs.
>
> Fix a typo.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  README | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/README b/README
> index 8cfa92fac9..d5d10d142e 100644
> --- a/README
> +++ b/README
> @@ -3203,9 +3203,9 @@ is done by typing:
> make NAME_defconfig
>
>  where "NAME_defconfig" is the name of one of the existing configu-
> -rations; see boards.cfg for supported names.
> +rations; see configs/*_defconfig for supported names.

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] Kconfig: fix typos in CMD_BEDBUG description

2020-02-26 Thread Simon Glass
On Tue, 25 Feb 2020 at 12:44, Heinrich Schuchardt  wrote:
>
> Fix documentation bug reported by 'make refcheckdocs'.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/2] Makefile: Add environment variable DEVICE_TREE to header

2020-02-26 Thread Simon Glass
Hi Michal,

On Tue, 18 Feb 2020 at 09:02, Michal Simek  wrote:
>
> Users have option to overwrite default device tree
> (CONFIG_DEFAULT_DEVICE_TREE) via environment variable DEVICE_TREE.
>
> Feature has been added long time ago by commit 74de8c9a1672
> ("dts/Makefile: Build the user specified dts") for a little bit different
> reason.
>
> But this variable can be also used for different purpose like choosing
> proper configuration from FIT image in SPL.
> And this is the functionality I would like to use on Xilinx Zynq devices
> that current u-boot.img can be composed in the same way based on OF_LIST
> and different configuration is taken based on platform specific SPL.
> SPL requires low level ps7_init_gpl configuration that's why different
> boards require different SPL with fixed board_fit_config_name_match().
>
> Signed-off-by: Michal Simek 
> ---
>
> I have done it in this way but maybe there is any smarter way how this can
> be done. Also macro name can change if you want.

Can you please add a bit of documentation to doc/README.fdt-control ?

> ---
>  Makefile | 14 +-
>  arch/arm/mach-zynq/spl.c |  8 ++--
>  2 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 0af89e0a7881..15f7cce445f6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -483,6 +483,7 @@ endif
>  version_h := include/generated/version_autogenerated.h
>  timestamp_h := include/generated/timestamp_autogenerated.h
>  defaultenv_h := include/generated/defaultenv_autogenerated.h
> +dt_h := include/generated/dt.h
>
>  no-dot-config-targets := clean clobber mrproper distclean \
>  help %docs check% coccicheck \
> @@ -1768,7 +1769,7 @@ endif
>  # prepare2 creates a makefile if using a separate output directory
>  prepare2: prepare3 outputmakefile cfg
>
> -prepare1: prepare2 $(version_h) $(timestamp_h) \
> +prepare1: prepare2 $(version_h) $(timestamp_h) $(dt_h) \
> include/config/auto.conf
>  ifeq ($(wildcard $(LDSCRIPT)),)
> @echo >&2 "  Could not find linker script."
> @@ -1834,12 +1835,23 @@ define filechk_defaultenv.h
>  xxd -i ; echo ", 0x00" ; )
>  endef
>
> +define filechk_dt.h
> +   (if test -n "$${DEVICE_TREE}"; then \

I think this can be:

ifneq($(DEVICE_TREE),)

> +   echo \#define DEVICE_TREE \"$(DEVICE_TREE)\"; \
> +   else \
> +   echo \#define DEVICE_TREE CONFIG_DEFAULT_DEVICE_TREE; \
> +   fi)
> +endef
> +
>  $(version_h): include/config/uboot.release FORCE
> $(call filechk,version.h)
>
>  $(timestamp_h): $(srctree)/Makefile FORCE
> $(call filechk,timestamp.h)
>
> +$(dt_h): $(srctree)/Makefile FORCE
> +   $(call filechk,dt.h)
> +
>  $(defaultenv_h): $(CONFIG_DEFAULT_ENV_FILE:"%"=%) FORCE
> $(call filechk,defaultenv.h)
>
> diff --git a/arch/arm/mach-zynq/spl.c b/arch/arm/mach-zynq/spl.c
> index 96ba90fb7a76..e89e46c1038d 100644
> --- a/arch/arm/mach-zynq/spl.c
> +++ b/arch/arm/mach-zynq/spl.c
> @@ -6,6 +6,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -89,8 +90,11 @@ void spl_board_prepare_for_boot(void)
>  int board_fit_config_name_match(const char *name)
>  {
> /* Just empty function now - can't decide what to choose */
> -   debug("%s: %s\n", __func__, name);
> +   debug("%s: Check %s, default %s\n", __func__, name, DEVICE_TREE);
>
> -   return 0;
> +   if (!strcmp(name, DEVICE_TREE))
> +   return 0;
> +
> +   return -1;
>  }
>  #endif
> --
> 2.25.0
>

Regards,
Simon


Re: [PATCH 1/1] doc: fix references to driver-model

2020-02-26 Thread Simon Glass
On Tue, 25 Feb 2020 at 12:35, Heinrich Schuchardt  wrote:
>
> Fix some errors pointed out by 'make refcheckdocs'.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  doc/README.drivers.eth | 2 +-
>  doc/README.fdt-control | 2 +-
>  drivers/i2c/davinci_i2c.c  | 2 +-
>  drivers/i2c/kona_i2c.c | 2 +-
>  drivers/i2c/sh_i2c.c   | 2 +-
>  drivers/i2c/soft_i2c.c | 2 +-
>  tools/dtoc/dtb_platdata.py | 4 ++--
>  tools/dtoc/dtoc.py | 2 +-
>  8 files changed, 9 insertions(+), 9 deletions(-)

Reviewed-by: Simon Glass 


Re: [U-Boot] [PATCH v2 08/10] bootstage: Correct relocation algorithm

2020-02-26 Thread Simon Glass
Hi Heinrich,

On Sat, 25 Jan 2020 at 01:59, Heinrich Schuchardt  wrote:
>
> On 10/22/19 1:26 AM, Simon Glass wrote:
> > At present bootstage relocation assumes that it is possible to point back
> > to memory available before relocation, so it does not relocate the
> > strings. However this is not the case on some platforms, such as x86 which
> > uses the cache as RAM and loses access to this when the cache is enabled.
> >
> > Move the relocation step to before U-Boot relocates, expand the allocated
> > region to include space for the strings and relocate the strings at the
> > same time as the bootstage records.
> >
> > This ensures that bootstage data can remain accessible from TPL through
> > SPL to U-Boot before/after relocation.
> >
> > Signed-off-by: Simon Glass 
>
> Hello Simon,
>
> this merged patch seems to be incorrect. I compiled sandbox_defconfig
> with clang and ran it with valgrind.
>
> We allocate memory in bootstage_init() for gd->bootstage. But from
> bootstage_get_size() we return a size that is larger than what we have
> allocated and use that larger memory area in reloc_bootstage(). See
> output below.

Yes that's right. This is a bit tricky.

The original malloc() does not include space for strings, since the
caller passes them in and we just use pointers.

When we relocate we copy the structure but then also write out the
strings after it.

The only obvious solution is to store the total size of the bootstage
record in the bootstage_data record, probably adding a version number
as well.

Regards,
Simon


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

2020-02-26 Thread Simon Glass
Hi Michae,

On Mon, 24 Feb 2020 at 22:10, Michael Trimarchi
 wrote:
>
> Memory reserved for the simple framebuffer should not be used
> and part of memory linear mapping. See
> https://patchwork.kernel.org/patch/10486131/ for more detailed
> background information and discussion.
>
> Signed-off-by: Michael Trimarchi 
> ---
> Changes RFC -> v1:
> - Fix compilation issue on RFC
> - change node name from display_reserved to display-reserved
> ---
>  drivers/video/meson/meson_vpu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Is the binding file for this in U-Boot? If not can you please add it?

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

Needs to return an error code which needs to be checked by caller.

> --
> 2.17.1
>

Regards,
Simon


Re: [PATCH] spl.h: make self-contained

2020-02-26 Thread Simon Glass
On Mon, 24 Feb 2020 at 10:26, Masahiro Yamada  wrote:
>
> The static inline function spl_phase needs .
>
> Some functions take pointers to struct blk_desc or image_header.
> Add forward declarations.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
>  include/spl.h | 4 
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass 


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

2020-02-26 Thread Simon Glass
Hi Michael,

On Mon, 24 Feb 2020 at 22:10, Michael Trimarchi
 wrote:
>
> The intent is to reserve memory _and_ prevent it from being included
> in the kernel's linear map. For thos reason it is also necessary to include 
> the
> 'no-map' property for this reserved-mem node.
>
> From Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:
>
> no-map (optional) - empty property
> - Indicates the operating system must not create a virtual mapping
>   of the region as part of its standard mapping of system memory,
>   nor permit speculative access to it under any circumstances other
>   than under the control of the device driver using the region.
>
> Signed-off-by: Michael Trimarchi 
> ---
> Changes: RFC->v1
> - Add a better commit message
> ---
>  common/fdt_support.c  | 40 
>  include/fdt_support.h | 11 +++
>  2 files changed, 51 insertions(+)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 02cf5c6241..a3662f4358 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -410,6 +410,46 @@ static int fdt_pack_reg(const void *fdt, void *buf, u64 
> *address, u64 *size,
> return p - (char *)buf;
>  }
>
> +int fdt_fixup_reserved_memory(void *blob, const char *area, u64 start[], u64 
> size[])
> +{
> +   int offs, len;
> +   const char *subpath;
> +   const char *path = "/reserved-memory";
> +   fdt32_t address_cells = cpu_to_fdt32(fdt_address_cells(blob, 0));
> +   fdt32_t size_cells = cpu_to_fdt32(fdt_size_cells(blob, 0));
> +   u8 temp[16]; /* Up to 64-bit address + 64-bit size */
> +
> +   offs = fdt_path_offset(blob, path);
> +   if (offs < 0) {
> +   debug("Node %s not found\n", path);
> +   path = "/";
> +   subpath = "reserved-memory";
> +   offs = fdt_path_offset(blob, path);

Error check

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

Need error-checking on these three

> +   }
> +
> +   offs = fdt_add_subnode(blob, offs, area ? : "private");

Is this in a binding file somewhere?

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

return offs

> +   }
> +
> +   fdt_setprop(blob, offs, "no-map", NULL, 0);

and this?

Also needs error check

> +   len = fdt_pack_reg(blob, temp, start, size, 1);
> +   fdt_setprop(blob, offs, "reg", temp, len);

blank line before return

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

Really we should return an FDT_ERR always. -1 is not a good idea and
in fact is an FDT_ERR

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

Regards,
Simon


Re: [PATCH] dm: make uclass_find_first_device() return error when no defice is found

2020-02-26 Thread Simon Glass
Hi Masahiro,

On Mon, 24 Feb 2020 at 23:58, Masahiro Yamada
 wrote:
>
> uclass_find_first_device() succeeds even if it cannot find any device.
> So, the caller must check the return code and also *devp is not NULL.
>
> Returning -ENODEV will be sensible in this case.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
> If this patch is acceptable, I want to fold this
> into my pull request because it need it
> for my another patch:
> http://patchwork.ozlabs.org/patch/1238000/
>
>  drivers/core/uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

I sort-of agree and have thought about this a lot.

But what are you doing in the case of uclass_find_next_device()?

Also what about the tests and other code that expects the current behaviour?

>
> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> index 58b19a421091..3580974f3b85 100644
> --- a/drivers/core/uclass.c
> +++ b/drivers/core/uclass.c
> @@ -227,7 +227,7 @@ int uclass_find_first_device(enum uclass_id id, struct 
> udevice **devp)
> if (ret)
> return ret;
> if (list_empty(>dev_head))
> -   return 0;
> +   return -ENODEV;
>
> *devp = list_first_entry(>dev_head, struct udevice, uclass_node);
>
> --
> 2.17.1
>

Regards,
Simon


Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Bin Meng
Hi Andy,

On Wed, Feb 26, 2020 at 11:01 PM Andy Shevchenko
 wrote:
>
> On Wed, Feb 26, 2020 at 2:59 PM Tom Rini  wrote:
> >
> > Hey all,
> >
> > It's two days late, but here is v2020.04-rc3.  The series to add
> > htmldocs tests to CI that I added on Monday took longer than I had
> > expected to go all green in CI.  I was going to do this yesterday after
> > applying the fixes that I pushed but got side-tracked, so here we are.
>
> Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
> has not been pulled).
>

Yes, it's currently in the x86 tree and will be in rc4.

> And one inconvenience: DFU timeout API feature requires one small fix
> which is in Lukasz branch, but by some reason didn't make rc3.

Regards,
Bin


Re: [PATCH 3/7] Kconfig: Escape variables to make in default strings

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 11:35:18AM +0900, Masahiro Yamada wrote:
> On Tue, Feb 25, 2020 at 3:05 AM Tom Rini  wrote:
> >
> > We have some variables that need to include a variable to pass to make
> > to evaluate later, typically ARCH and BOARDDIR, to find a file to use.
> > The way we're doing this today isn't correct but works.  With an update
> > to Kconfig we will need to escape these properly, so do so.
> >
> > Cc: Masahiro Yamada 
> > Signed-off-by: Tom Rini 
> > ---
> >  arch/arm/mach-davinci/Kconfig | 2 +-
> >  arch/arm/mach-orion5x/Kconfig | 2 +-
> >  common/spl/Kconfig| 4 ++--
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
> > index 8a81c078811d..83f749c0440a 100644
> > --- a/arch/arm/mach-davinci/Kconfig
> > +++ b/arch/arm/mach-davinci/Kconfig
> > @@ -135,6 +135,6 @@ source "board/davinci/da8xxevm/Kconfig"
> >  source "board/lego/ev3/Kconfig"
> >
> >  config SPL_LDSCRIPT
> > -   default "board/$(BOARDDIR)/u-boot-spl-da850evm.lds"
> > +   default "board/\$(BOARDDIR)/u-boot-spl-da850evm.lds"
> 
> 
> Only one file path for this.
> 
> $ find  . -name  u-boot-spl-da850evm.lds
> ./board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> 
> 
> I prefer hard-coding.
> 
> default "board/davinci/da8xxevm/u-boot-spl-da850evm.lds"

Done, new patch.

> >  endif
> > diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig
> > index 2984a3edda21..c4bc524eb81e 100644
> > --- a/arch/arm/mach-orion5x/Kconfig
> > +++ b/arch/arm/mach-orion5x/Kconfig
> > @@ -16,6 +16,6 @@ config SYS_SOC
> >  source "board/LaCie/edminiv2/Kconfig"
> >
> >  config SPL_LDSCRIPT
> > -   default "$(CPUDIR)/orion5x/u-boot-spl.lds" if ORION5X
> > +   default "\$(CPUDIR)/orion5x/u-boot-spl.lds" if ORION5X
> 
> Ditto.
> 
> We know the directory path of orion5x.
> 
> $ find  . -name orion5x
> ./arch/arm/cpu/arm926ejs/orion5x
> 
> You can hard-code it.

Done, new patch.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/7] Kconfig: Remove redundant variable sets

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 11:41:02AM +0900, Masahiro Yamada wrote:
> On Tue, Feb 25, 2020 at 3:06 AM Tom Rini  wrote:
> >
> > In a few places we have Kconfig entries that set SPL_LDSCRIPT to what is
> > the default value anyways.  Drop these.
> >
> > Cc: Michal Simek 
> > Cc: Rick Chen 
> > Cc: Philippe Reynes 
> > Cc: Eric Jarrige 
> > Signed-off-by: Tom Rini 
> > ---
> 
> I see more in defconfig files.
> 
> $ cd configs
> $ git grep SPL_LDSCRIPT
> axm_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"
> brppt2_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"
> mx31pdk_defconfig:CONFIG_SPL_LDSCRIPT="arch/arm/cpu/u-boot-spl.lds"
> taurus_defconfig:CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/cpu/u-boot-spl.lds"

Re-checking, all 4 of these cases are overriding the default, but the
cases of $(ARCH) aren't helpful and should just be 'arm' so I'll do
that.

-- 
Tom


signature.asc
Description: PGP signature


Re: [ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Andy Shevchenko
On Wed, Feb 26, 2020 at 2:59 PM Tom Rini  wrote:
>
> Hey all,
>
> It's two days late, but here is v2020.04-rc3.  The series to add
> htmldocs tests to CI that I added on Monday took longer than I had
> expected to go all green in CI.  I was going to do this yesterday after
> applying the fixes that I pushed but got side-tracked, so here we are.

Still Edison doesn't boot (IIRC I saw Bin's PR which by some reason
has not been pulled).

And one inconvenience: DFU timeout API feature requires one small fix
which is in Lukasz branch, but by some reason didn't make rc3.

>
> Once again, for a changelog,
> git log --merges v2020.04-rc2..v2020.04-rc3
> and as always, I ask for more details in the PRs people send me so I can
> put them in the merge commit.
>
> The final release is still on schedule for April 6th and I plan to open
> my -next branch on March 2nd.  Thanks all!
>
> --
> Tom



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v6 16/16] travis: add packages for UEFI secure boot test

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 01:54:48PM +0900, AKASHI Takahiro wrote:

> Pytest for UEFI secure boot will use several host commands.
> In particular, Test setup relies on efitools, whose version must be v1.5.2
> or later. So fetch a new version of deb package directly.
> Please note it has a dependency on mtools, which must also be installed
> along wih efitools.
> 
> In addition, the path, '/sbin', is added to PATH for use of sgdisk and
> mkfs.
> 
> Signed-off-by: AKASHI Takahiro 

Note that I just re-reviewed the Dockerfile for Azure / GitLab and all
of the listed tools as well as updated efitools are already included.
So the expectation is that when the tests are enabled, Azure / GitLab
should run them and succeed.

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] efi_selftest: Ensure we include the object directory for generated headers

2020-02-26 Thread Tom Rini
On Wed, Feb 26, 2020 at 09:53:23AM +0900, Masahiro Yamada wrote:
> Hi Tom,
> 
> 
> On Sat, Feb 22, 2020 at 6:52 AM Tom Rini  wrote:
> >
> > On Fri, Feb 21, 2020 at 10:34:01PM +0100, Heinrich Schuchardt wrote:
> > > On 2/21/20 9:48 PM, Tom Rini wrote:
> > > > The current rules for generating -I lines for objects gives us both
> > > > -I/full/src/path/lib/efi_selftest and -Ilib/efi_selftest.  However, if
> > > > we re-sync the Kbuild logic we no longer get the latter implicitly.  We
> > > > will need to be explicit in such cases, so do so.
> > > >
> > > > Cc: Heinrich Schuchardt 
> > > > Cc: Masahiro Yamada 
> > > > Signed-off-by: Tom Rini 
> > >
> > > Hello Tom,
> > >
> > > yes, in lib/efi_selftest we have generated includes, so
> > > -Ilib/efi_selftest is relevant.
> > >
> > > Do you have a git branch with the Kconfig changes for reference and 
> > > testing?
> >
> > Currently WIP/kbuild-resync-v1-v4.18 but please bear in mind I'm (a)
> > rebase it and (b) it doesn't even build sandbox_spl right now (more of
> > this type of error, but my non-CI world build will finish up shortly and
> > I'll grab all of the places I need to make a fix like this there).
> >
> > --
> > Tom
> 
> 
> This is one way to suppress the build error for O= builds.
> 
> But, please notice this is caused by the re-sync mistake.
> 
> 
> You partially imported
> commit db547ef1906400eb34682e43035dd4d81b9fdcfb
> from Linux.
> 
> You imported the change in scripts/Kbuild.include
> but did not the change in scripts/Makefile.lib
> 
> That's why you needed to add -I$(objtree)/$(obj)
> all over the places.

Ah, I see what happened now too.  It was that db547ef19064 didn't apply
cleanly as we were missing two previous changes in that area and in
hunting down and verifying those changes I missed the second hunk.  For
the other two changes, I'll verify those were only to
scripts/Kbuild.include and fix it up.  Thanks again!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] raspberrypi: reserve first two pages in efi memory map

2020-02-26 Thread kevans
From: Kyle Evans 

The psci stub provided by Raspberry Pi is around 5k in size, thus residing
in the first two pages of memory. Without this reservation, the next stage
or OS assume they're free to use the second page and may get catastrophic
results from clobbering it.

Signed-off-by: Kyle Evans 
Cc: Matthias Brugger 
---
 board/raspberrypi/rpi/rpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index e367ba3092..d3f9bd16ac 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -488,8 +488,8 @@ int ft_board_setup(void *blob, bd_t *bd)
lcd_dt_simplefb_add_node(blob);
 
 #ifdef CONFIG_EFI_LOADER
-   /* Reserve the spin table */
-   efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
+   /* Reserve the first two pages for spin table/psci stub. */
+   efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
 #endif
 
return 0;
-- 
2.25.1



[PATCH 03/15] spi: spi-mem: allow specifying whether an op is DTR or not

2020-02-26 Thread Pratyush Yadav
Each phase is given a separate 'is_dtr' field so mixed protocols like
4S-4D-4D can be supported.

Signed-off-by: Pratyush Yadav 
---
 drivers/spi/spi-mem.c | 24 
 include/spi-mem.h |  8 
 2 files changed, 32 insertions(+)

diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
index e900c997bd..218496d8d2 100644
--- a/drivers/spi/spi-mem.c
+++ b/drivers/spi/spi-mem.c
@@ -104,6 +104,16 @@ void spi_controller_dma_unmap_mem_op_data(struct 
spi_controller *ctlr,
 EXPORT_SYMBOL_GPL(spi_controller_dma_unmap_mem_op_data);
 #endif /* __UBOOT__ */
 
+static int spi_check_dtr_req(struct spi_slave *slave, bool tx)
+{
+   u32 mode = slave->mode;
+
+   if ((tx && (mode & SPI_TX_DTR)) || (!tx && (mode & SPI_RX_DTR)))
+   return 0;
+
+   return -ENOTSUPP;
+}
+
 static int spi_check_buswidth_req(struct spi_slave *slave, u8 buswidth, bool 
tx)
 {
u32 mode = slave->mode;
@@ -158,6 +168,20 @@ bool spi_mem_default_supports_op(struct spi_slave *slave,
   op->data.dir == SPI_MEM_DATA_OUT))
return false;
 
+   if (op->cmd.is_dtr && spi_check_dtr_req(slave, true))
+   return false;
+
+   if (op->addr.is_dtr && spi_check_dtr_req(slave, true))
+   return false;
+
+   if (op->dummy.is_dtr &&
+   spi_check_dtr_req(slave, true))
+   return false;
+
+   if (op->data.is_dtr &&
+   spi_check_dtr_req(slave, op->data.dir == SPI_MEM_DATA_OUT))
+   return false;
+
return true;
 }
 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);
diff --git a/include/spi-mem.h b/include/spi-mem.h
index 36814efa86..1ae5f2b302 100644
--- a/include/spi-mem.h
+++ b/include/spi-mem.h
@@ -72,6 +72,7 @@ enum spi_mem_data_dir {
  * struct spi_mem_op - describes a SPI memory operation
  * @cmd.buswidth: number of IO lines used to transmit the command
  * @cmd.opcode: operation opcode
+ * @cmd.is_dtr: whether the command opcode should be sent in DTR mode or not
  * @addr.nbytes: number of address bytes to send. Can be zero if the operation
  *  does not need to send an address
  * @addr.buswidth: number of IO lines used to transmit the address cycles
@@ -79,11 +80,14 @@ enum spi_mem_data_dir {
  *   Note that only @addr.nbytes are taken into account in this
  *   address value, so users should make sure the value fits in the
  *   assigned number of bytes.
+ * @addr.is_dtr: whether the address should be sent in DTR mode or not
  * @dummy.nbytes: number of dummy bytes to send after an opcode or address. Can
  *   be zero if the operation does not require dummy bytes
  * @dummy.buswidth: number of IO lanes used to transmit the dummy bytes
+ * @dummy.is_dtr: whether the dummy bytes should be sent in DTR mode or not
  * @data.buswidth: number of IO lanes used to send/receive the data
  * @data.dir: direction of the transfer
+ * @data.is_dtr: whether the data should be sent in DTR mode or not
  * @data.buf.in: input buffer
  * @data.buf.out: output buffer
  */
@@ -91,23 +95,27 @@ struct spi_mem_op {
struct {
u8 buswidth;
u8 opcode;
+   bool is_dtr;
} cmd;
 
struct {
u8 nbytes;
u8 buswidth;
u64 val;
+   bool is_dtr;
} addr;
 
struct {
u8 nbytes;
u8 buswidth;
+   bool is_dtr;
} dummy;
 
struct {
u8 buswidth;
enum spi_mem_data_dir dir;
unsigned int nbytes;
+   bool is_dtr;
/* buf.{in,out} must be DMA-able. */
union {
void *in;
-- 
2.25.0



[PATCH 07/15] mtd: spi-nor-core: Add a ->setup() hook

2020-02-26 Thread Pratyush Yadav
nor->setup() can be used by flashes to configure settings in case they
have any peculiarities that can't be easily expressed by the generic
spi-nor framework. This includes things like different opcodes, dummy
cycles, page size, uniform/non-uniform sector sizes, etc.

Move related declarations to avoid forward declarations.

Inspired by the Linux kernel's setup() hook.

Signed-off-by: Pratyush Yadav 
---
 drivers/mtd/spi/spi-nor-core.c |  84 +++
 drivers/mtd/spi/spi-nor-tiny.c |  22 
 include/linux/mtd/spi-nor.h| 192 ++---
 3 files changed, 147 insertions(+), 151 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 7b6ad495ac..7b85754e2b 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -1441,71 +1441,6 @@ static int spansion_no_read_cr_quad_enable(struct 
spi_nor *nor)
 #endif /* CONFIG_SPI_FLASH_SFDP_SUPPORT */
 #endif /* CONFIG_SPI_FLASH_SPANSION */
 
-struct spi_nor_read_command {
-   u8  num_mode_clocks;
-   u8  num_wait_states;
-   u8  opcode;
-   enum spi_nor_protocol   proto;
-};
-
-struct spi_nor_pp_command {
-   u8  opcode;
-   enum spi_nor_protocol   proto;
-};
-
-enum spi_nor_read_command_index {
-   SNOR_CMD_READ,
-   SNOR_CMD_READ_FAST,
-   SNOR_CMD_READ_1_1_1_DTR,
-
-   /* Dual SPI */
-   SNOR_CMD_READ_1_1_2,
-   SNOR_CMD_READ_1_2_2,
-   SNOR_CMD_READ_2_2_2,
-   SNOR_CMD_READ_1_2_2_DTR,
-
-   /* Quad SPI */
-   SNOR_CMD_READ_1_1_4,
-   SNOR_CMD_READ_1_4_4,
-   SNOR_CMD_READ_4_4_4,
-   SNOR_CMD_READ_1_4_4_DTR,
-
-   /* Octo SPI */
-   SNOR_CMD_READ_1_1_8,
-   SNOR_CMD_READ_1_8_8,
-   SNOR_CMD_READ_8_8_8,
-   SNOR_CMD_READ_1_8_8_DTR,
-
-   SNOR_CMD_READ_MAX
-};
-
-enum spi_nor_pp_command_index {
-   SNOR_CMD_PP,
-
-   /* Quad SPI */
-   SNOR_CMD_PP_1_1_4,
-   SNOR_CMD_PP_1_4_4,
-   SNOR_CMD_PP_4_4_4,
-
-   /* Octo SPI */
-   SNOR_CMD_PP_1_1_8,
-   SNOR_CMD_PP_1_8_8,
-   SNOR_CMD_PP_8_8_8,
-
-   SNOR_CMD_PP_MAX
-};
-
-struct spi_nor_flash_parameter {
-   u64 size;
-   u32 page_size;
-
-   struct spi_nor_hwcaps   hwcaps;
-   struct spi_nor_read_command reads[SNOR_CMD_READ_MAX];
-   struct spi_nor_pp_command   page_programs[SNOR_CMD_PP_MAX];
-
-   int (*quad_enable)(struct spi_nor *nor);
-};
-
 static void
 spi_nor_set_read_settings(struct spi_nor_read_command *read,
  u8 num_mode_clocks,
@@ -2363,9 +2298,10 @@ static int spi_nor_select_erase(struct spi_nor *nor,
return 0;
 }
 
-static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
-const struct spi_nor_flash_parameter *params,
-const struct spi_nor_hwcaps *hwcaps)
+static int spi_nor_default_setup(struct spi_nor *nor,
+const struct flash_info *info,
+const struct spi_nor_flash_parameter *params,
+const struct spi_nor_hwcaps *hwcaps)
 {
u32 ignored_mask, shared_mask;
bool enable_quad_io;
@@ -2424,6 +2360,16 @@ static int spi_nor_setup(struct spi_nor *nor, const 
struct flash_info *info,
return 0;
 }
 
+static int spi_nor_setup(struct spi_nor *nor, const struct flash_info *info,
+const struct spi_nor_flash_parameter *params,
+const struct spi_nor_hwcaps *hwcaps)
+{
+   if (!nor->setup)
+   return 0;
+
+   return nor->setup(nor, info, params, hwcaps);
+}
+
 static int spi_nor_init(struct spi_nor *nor)
 {
int err;
@@ -2489,6 +2435,8 @@ int spi_nor_scan(struct spi_nor *nor)
nor->read_reg = spi_nor_read_reg;
nor->write_reg = spi_nor_write_reg;
 
+   nor->setup = spi_nor_default_setup;
+
if (spi->mode & SPI_RX_OCTAL) {
hwcaps.mask |= SNOR_HWCAPS_READ_1_1_8;
 
diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c
index ccc0ab07af..b76b7ca60a 100644
--- a/drivers/mtd/spi/spi-nor-tiny.c
+++ b/drivers/mtd/spi/spi-nor-tiny.c
@@ -543,28 +543,6 @@ static int spansion_read_cr_quad_enable(struct spi_nor 
*nor)
 }
 #endif /* CONFIG_SPI_FLASH_SPANSION */
 
-struct spi_nor_read_command {
-   u8  num_mode_clocks;
-   u8  num_wait_states;
-   u8  opcode;
-   enum spi_nor_protocol   proto;
-};
-
-enum spi_nor_read_command_index {
-   SNOR_CMD_READ,
-   SNOR_CMD_READ_FAST,
-
-   /* Quad SPI */
-   SNOR_CMD_READ_1_1_4,
-
-   SNOR_CMD_READ_MAX
-};
-
-struct spi_nor_flash_parameter {
-   struct spi_nor_hwcaps   hwcaps;
-   struct spi_nor_read_command 

[PATCH 10/15] mtd: spi-nor-core: Add support for DTR protocol

2020-02-26 Thread Pratyush Yadav
Double Transfer Rate (DTR) is SPI protocol in which data is transferred
on each clock edge as opposed to on each clock cycle. Make
framework-level changes to allow supporting flashes in DTR mode.

Right now, mixed DTR modes are not supported. So, for example a mode
like 4S-4D-4D will not work. All phases need to be either DTR or STR.

Signed-off-by: Pratyush Yadav 
---
 drivers/mtd/spi/sf_internal.h  |  1 +
 drivers/mtd/spi/spi-nor-core.c | 90 --
 include/linux/mtd/spi-nor.h| 32 +++-
 3 files changed, 95 insertions(+), 28 deletions(-)

diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
index d689b673ce..5780c81287 100644
--- a/drivers/mtd/spi/sf_internal.h
+++ b/drivers/mtd/spi/sf_internal.h
@@ -67,6 +67,7 @@ struct flash_info {
 #define USE_CLSR   BIT(14) /* use CLSR command */
 #define SPI_NOR_HAS_SST26LOCK  BIT(15) /* Flash supports lock/unlock via BPR */
 #define SPI_NOR_OCTAL_READ  BIT(16) /* Flash supports Octal Read */
+#define SPI_NOR_OCTAL_DTR_READ BIT(17) /* Flash supports Octal DTR Read */
 
/* Part specific fixup hooks. */
const struct spi_nor_fixups *fixups;
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 94e99eb99f..2915d0b721 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -176,6 +176,45 @@ struct spi_nor_fixups {
 
 #endif /* SPI_FLASH_SFDP_SUPPORT */
 
+/**
+ * spi_nor_setup_op() - Set up common properties of a spi-mem op.
+ * @nor:   pointer to a 'struct spi_nor'
+ * @op:pointer to the 'struct spi_mem_op' whose 
properties
+ * need to be initialized.
+ * @proto: the protocol from which the properties need to be set.
+ */
+static void spi_nor_setup_op(const struct spi_nor *nor,
+struct spi_mem_op *op,
+const enum spi_nor_protocol proto)
+{
+   op->cmd.buswidth = spi_nor_get_protocol_inst_nbits(proto);
+
+   if (op->addr.nbytes)
+   op->addr.buswidth = spi_nor_get_protocol_addr_nbits(proto);
+
+   if (op->dummy.nbytes)
+   op->dummy.buswidth = spi_nor_get_protocol_addr_nbits(proto);
+
+   if (op->data.buf.in || op->data.buf.out)
+   op->data.buswidth = spi_nor_get_protocol_data_nbits(proto);
+
+   if (spi_nor_protocol_is_dtr(proto)) {
+   /*
+* spi-mem supports mixed DTR modes, but right now we can only
+* have all phases either DTR or STR. IOW, spi-mem can have
+* something like 4S-4D-4D, but spi-nor can't. So, set all 4
+* phases to either DTR or STR.
+*/
+   op->cmd.is_dtr = op->addr.is_dtr = op->dummy.is_dtr =
+   op->data.is_dtr = true;
+
+   /* 2 bytes per clock cycle in DTR mode. */
+   op->dummy.nbytes *= 2;
+
+   op->cmd.ext_type = nor->cmd_ext;
+   }
+}
+
 static int spi_nor_read_write_reg(struct spi_nor *nor, struct spi_mem_op
*op, void *buf)
 {
@@ -194,6 +233,8 @@ static int spi_nor_read_reg(struct spi_nor *nor, u8 code, 
u8 *val, int len)
  SPI_MEM_OP_DATA_IN(len, NULL, 1));
int ret;
 
+   spi_nor_setup_op(nor, , nor->reg_proto);
+
ret = spi_nor_read_write_reg(nor, , val);
if (ret < 0)
dev_dbg(>spimem->spi->dev, "error %d reading %x\n", ret,
@@ -209,6 +250,8 @@ static int spi_nor_write_reg(struct spi_nor *nor, u8 
opcode, u8 *buf, int len)
  SPI_MEM_OP_NO_DUMMY,
  SPI_MEM_OP_DATA_OUT(len, NULL, 1));
 
+   spi_nor_setup_op(nor, , nor->reg_proto);
+
return spi_nor_read_write_reg(nor, , buf);
 }
 
@@ -223,14 +266,12 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, 
loff_t from, size_t len,
size_t remaining = len;
int ret;
 
-   /* get transfer protocols. */
-   op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->read_proto);
-   op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->read_proto);
-   op.dummy.buswidth = op.addr.buswidth;
-   op.data.buswidth = spi_nor_get_protocol_data_nbits(nor->read_proto);
+   spi_nor_setup_op(nor, , nor->read_proto);
 
/* convert the dummy cycles to the number of bytes */
op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;
+   if (spi_nor_protocol_is_dtr(nor->read_proto))
+   op.dummy.nbytes *= 2;
 
while (remaining) {
op.data.nbytes = remaining < UINT_MAX ? remaining : UINT_MAX;
@@ -260,14 +301,11 @@ static ssize_t spi_nor_write_data(struct spi_nor *nor, 
loff_t to, size_t len,
   SPI_MEM_OP_DATA_OUT(len, buf, 1));
int ret;
 
-   /* get transfer protocols. */
-   op.cmd.buswidth = 

[PATCH 02/15] spi: set mode bits for "spi-rx-dtr" and "spi-tx-dtr"

2020-02-26 Thread Pratyush Yadav
These two DT properties express DTR receive and transmit capabilities of
a SPI flash and controller. Introduce two new mode bits: SPI_RX_DTR and
SPI_TX_DTR which correspond to the new DT properties. Set these bits
when the two corresponding properties are present in the device tree.

Signed-off-by: Pratyush Yadav 
---
 drivers/spi/spi-uclass.c | 9 +
 include/spi.h| 2 ++
 2 files changed, 11 insertions(+)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 4a02d95a34..74e4b5b3ad 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -435,6 +435,7 @@ int spi_slave_ofdata_to_platdata(struct udevice *dev,
 {
int mode = 0;
int value;
+   bool dtr;
 
plat->cs = dev_read_u32_default(dev, "reg", -1);
plat->max_hz = dev_read_u32_default(dev, "spi-max-frequency",
@@ -487,6 +488,14 @@ int spi_slave_ofdata_to_platdata(struct udevice *dev,
break;
}
 
+   dtr = dev_read_bool(dev, "spi-rx-dtr");
+   if (dtr)
+   mode |= SPI_RX_DTR;
+
+   dtr = dev_read_bool(dev, "spi-tx-dtr");
+   if (dtr)
+   mode |= SPI_TX_DTR;
+
plat->mode = mode;
 
return 0;
diff --git a/include/spi.h b/include/spi.h
index 852f570eaa..64558a5145 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -32,6 +32,8 @@
 #define SPI_RX_QUADBIT(13) /* receive with 4 wires */
 #define SPI_TX_OCTAL   BIT(14) /* transmit with 8 wires */
 #define SPI_RX_OCTAL   BIT(15) /* receive with 8 wires */
+#define SPI_TX_DTR BIT(16) /* transmit in DTR protocol */
+#define SPI_RX_DTR BIT(17) /* receive in DTR protocol */
 
 /* Header byte that marks the start of the message */
 #define SPI_PREAMBLE_END_BYTE  0xec
-- 
2.25.0



[ANN] U-Boot v2020.04-rc3 released

2020-02-26 Thread Tom Rini
Hey all,

It's two days late, but here is v2020.04-rc3.  The series to add
htmldocs tests to CI that I added on Monday took longer than I had
expected to go all green in CI.  I was going to do this yesterday after
applying the fixes that I pushed but got side-tracked, so here we are.

Once again, for a changelog, 
git log --merges v2020.04-rc2..v2020.04-rc3
and as always, I ask for more details in the PRs people send me so I can
put them in the merge commit.

The final release is still on schedule for April 6th and I plan to open
my -next branch on March 2nd.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 01/15] dt-bindings: spi: allow expressing DTR capability

2020-02-26 Thread Pratyush Yadav
Allow spi devices to express DTR receive and transmit capabilities via
the properties "spi-rx-dtr" and "spi-tx-dtr".

Signed-off-by: Pratyush Yadav 
---
Corresponding Kernel DT patch at
https://lore.kernel.org/linux-mtd/20200226093703.19765-2-p.ya...@ti.com/

 doc/device-tree-bindings/spi/spi-bus.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/device-tree-bindings/spi/spi-bus.txt 
b/doc/device-tree-bindings/spi/spi-bus.txt
index 420ec9529f..0d55303a0e 100644
--- a/doc/device-tree-bindings/spi/spi-bus.txt
+++ b/doc/device-tree-bindings/spi/spi-bus.txt
@@ -59,6 +59,10 @@ contain the following properties.
   used for MOSI. Defaults to 1 if not present.
 - spi-rx-bus-width - (optional) The bus width(number of data wires) that
   used for MISO. Defaults to 1 if not present.
+- spi-tx-dtr   - (optional) Its presence indicates bus can transmit in DTR
+protocol.
+- spi-rx-dtr   - (optional) Its presence indicates bus can receive in DTR
+protocol.
 - spi-half-duplex  - (optional) Indicates that the SPI bus should wait for
  a header byte before reading data from the slave.

--
2.25.0



  1   2   >