Re: [BUG] patman: refused to send patches because of warnings

2021-12-17 Thread Tony Dinh
Hi Sean,

Just tried again with -i and it works fine now!

Thanks,
Tony

On Fri, Dec 17, 2021 at 8:02 PM Sean Anderson  wrote:
>
> On 12/17/21 10:59 PM, Tony Dinh wrote:
> > Hi Simon,
> >
> > I tried to send in patches to add support for a new board. patman
> > seems to hit a problem with "Bad divisor in main" error and refuses to
> > send the patches. The warnings are not really important, are they? In
> > some instances, we need camel cases because that is what the
> > convention in the specs for MPPs. And the #ifdef or #if is necessary
> > because the "if (IS_ENABLED(CONFIG...))" cannot be used to compile-out
> > a function. And the warnings about MAINTAINERS seem unnecessary.
> >
> > Is there an option to tell patman to ignore the warnings or checks?
> >
> > Here is the patman log.
> >
> >
> > ./tools/patman/patman -c8 send
>
> you can use -i to ignore errors
>
> --Sean
>
> >
> > Cleaned 8 patches
> > 0 errors, 1 warnings, 0 checks for
> > 0001-arm-kirkwood-Pogoplug-V4-Add-DTS-files.patch:
> > :29: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 1 warnings, 0 checks for
> > 0002-arm-kirkwood-Pogoplug-V4-Add-board-defconfig-file.patch:
> > :16: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 2 warnings, 0 checks for
> > 0003-arm-kirkwood-Pogoplug-V4-Add-Kconfig-files.patch:
> > arch/arm/mach-kirkwood/Kconfig:28: warning: please write a paragraph
> > that describes the config symbol fully
> > :39: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 1 warnings, 0 checks for
> > 0004-arm-kirkwood-Pogoplug-V4-Add-board-include-configs-f.patch:
> > :17: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 1 warnings, 0 checks for
> > 0005-arm-kirkwood-Pogoplug-V4-Add-board-kwbimage-file.patch:
> > :16: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 1 warnings, 0 checks for
> > 0006-arm-kirkwood-Pogoplug-V4-Add-board-implementation-he.patch:
> > :19: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > 0 errors, 3 warnings, 3 checks for
> > 0007-arm-kirkwood-Pogoplug-V4-Add-board-implementation.patch:
> > :23: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > board/cloudengines/pogo_v4/pogo_v4.c:49: check: Avoid CamelCase:
> > 
> > board/cloudengines/pogo_v4/pogo_v4.c:63: check: Avoid CamelCase:
> > 
> > board/cloudengines/pogo_v4/pogo_v4.c:64: check: Avoid CamelCase:
> > 
> > board/cloudengines/pogo_v4/pogo_v4.c:137: warning: Use 'if
> > (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
> > board/cloudengines/pogo_v4/pogo_v4.c:170: warning: Use 'if
> > (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
> > 0 errors, 1 warnings, 0 checks for
> > 0008-arm-kirkwood-Pogoplug-V4-Add-board-maintainer.patch:
> > :16: warning: added, moved or deleted file(s), does MAINTAINERS
> > need updating?
> > checkpatch.pl found 0 error(s), 11 warning(s), 3 checks(s)
> > Bad divisor in main::vcs_assign: 0
> > Not sending emails due to errors/warnings
> >
> > Thanks,
> > Tony
> >
>


[PATCH 8/8] arm: kirkwood: Pogoplug-V4 : Add board maintainer

2021-12-17 Thread Tony Dinh
Add board maintainer for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 board/cloudengines/pogo_v4/MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)
 create mode 100644 board/cloudengines/pogo_v4/MAINTAINERS

diff --git a/board/cloudengines/pogo_v4/MAINTAINERS 
b/board/cloudengines/pogo_v4/MAINTAINERS
new file mode 100644
index 00..35fd7858b7
--- /dev/null
+++ b/board/cloudengines/pogo_v4/MAINTAINERS
@@ -0,0 +1,6 @@
+POGO_V4 BOARD
+M: Tony Dinh 
+S: Maintained
+F: board/cloudengines/pogo_v4/
+F: include/configs/pogo_v4.h
+F: configs/pogo_v4_defconfig
-- 
2.20.1



[PATCH 7/8] arm: kirkwood: Pogoplug-V4 : Add board implementation

2021-12-17 Thread Tony Dinh
Add board implementation for Pogoplug V4

Note: currently the fdt_get_phy_addr function in this file is
duplicate in this board and many other Kirkwood boards
(eg. Sheevaplug, GoFlex Home, etc.). This function is being
factored out into common area by another patch. And because it
was written for flattree only, the patch is being rewritten to
use livetree calls.

Signed-off-by: Tony Dinh 
---

 board/cloudengines/pogo_v4/pogo_v4.c | 204 +++
 1 file changed, 204 insertions(+)
 create mode 100644 board/cloudengines/pogo_v4/pogo_v4.c

diff --git a/board/cloudengines/pogo_v4/pogo_v4.c 
b/board/cloudengines/pogo_v4/pogo_v4.c
new file mode 100644
index 00..55fc9d69e4
--- /dev/null
+++ b/board/cloudengines/pogo_v4/pogo_v4.c
@@ -0,0 +1,204 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2014-2021 Tony Dinh 
+ *
+ * Based on
+ * Copyright (C) 2012 David Purdy 
+ *
+ * Based on Kirkwood support:
+ * (C) Copyright 2009
+ * Marvell Semiconductor 
+ * Written-by: Prafulla Wadaskar 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "pogo_v4.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "pogo_v4.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_early_init_f(void)
+{
+   /*
+* default gpio configuration
+* There are maximum 64 gpios controlled through 2 sets of registers
+* the  below configuration configures mainly initial LED status
+*/
+   mvebu_config_gpio(POGO_V4_OE_VAL_LOW,
+ POGO_V4_OE_VAL_HIGH,
+ POGO_V4_OE_LOW, POGO_V4_OE_HIGH);
+
+   /* Multi-Purpose Pins Functionality configuration */
+   u32 kwmpp_config[] = {
+   MPP0_NF_IO2,
+   MPP1_NF_IO3,
+   MPP2_NF_IO4,
+   MPP3_NF_IO5,
+   MPP4_NF_IO6,
+   MPP5_NF_IO7,
+   MPP6_SYSRST_OUTn,
+   MPP7_GPO,
+   MPP8_TW_SDA,
+   MPP9_TW_SCK,
+   MPP10_UART0_TXD,
+   MPP11_UART0_RXD,
+   MPP12_SD_CLK,
+   MPP13_SD_CMD,
+   MPP14_SD_D0,
+   MPP15_SD_D1,
+   MPP16_SD_D2,
+   MPP17_SD_D3,
+   MPP18_NF_IO0,
+   MPP19_NF_IO1,
+   MPP20_SATA1_ACTn,
+   MPP21_SATA0_ACTn,
+   MPP22_GPIO, /* Green LED */
+   MPP23_GPIO,
+   MPP24_GPIO, /* Red LED */
+   MPP25_GPIO,
+   MPP26_GPIO,
+   MPP27_GPIO,
+   MPP28_GPIO,
+   MPP29_GPIO, /* Eject button */
+   MPP30_GPIO,
+   MPP31_GPIO,
+   MPP32_GPIO,
+   MPP33_GPIO,
+   MPP34_GPIO,
+   MPP35_GPIO, /* FR6192 has only 36 GPIOs */
+   0
+   };
+   kirkwood_mpp_conf(kwmpp_config, NULL);
+
+   return 0;
+}
+
+int board_late_init(void)
+{
+   /* Do late init to ensure successful enumeration of XHCI devices */
+   pci_init();
+   return 0;
+}
+
+int board_init(void)
+{
+   /* Boot parameters address */
+   gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
+
+   return 0;
+}
+
+int fdt_get_phy_addr(const char *path)
+{
+   const void *fdt = gd->fdt_blob;
+   const u32 *reg;
+   const u32 *val;
+   int node, phandle, addr;
+
+   /* Find the node by its full path */
+   node = fdt_path_offset(fdt, path);
+   if (node >= 0) {
+   /* Look up phy-handle */
+   val = fdt_getprop(fdt, node, "phy-handle", NULL);
+   if (!val) {
+   /* Look up phy (deprecated property for phy handle) */
+   val = fdt_getprop(fdt, node, "phy", NULL);
+   }
+   if (val) {
+   phandle = fdt32_to_cpu(*val);
+   if (!phandle)
+   return -FDT_ERR_NOTFOUND;
+
+   /* Follow it to its node */
+   node = fdt_node_offset_by_phandle(fdt, phandle);
+   if (node) {
+   /* Look up reg */
+   reg = fdt_getprop(fdt, node, "reg", NULL);
+   if (reg) {
+   addr = fdt32_to_cpu(*reg);
+   return addr;
+   }
+   }
+   }
+   }
+   return -FDT_ERR_NOTFOUND;
+}
+
+#if defined(CONFIG_RESET_PHY_R)
+/* Configure and initialize PHY */
+void reset_phy(void)
+{
+   u16 reg;
+   int phyaddr;
+   char *name = "ethernet-controller@72000";
+   char *eth0_path = "/ocp@f100/ethernet-controller@72000";
+
+   if (miiphy_set_current_dev(name))
+   return;
+
+   phyaddr = fdt_get_phy_addr(eth0_path);
+   if (phyaddr < 0)

[PATCH 6/8] arm: kirkwood: Pogoplug-V4 : Add board implementation header

2021-12-17 Thread Tony Dinh
Add board implementation header and Makefile for Pogoplug V4

Signed-off-by: Tony Dinh 
---

 board/cloudengines/pogo_v4/Makefile  | 10 
 board/cloudengines/pogo_v4/pogo_v4.h | 36 
 2 files changed, 46 insertions(+)
 create mode 100644 board/cloudengines/pogo_v4/Makefile
 create mode 100644 board/cloudengines/pogo_v4/pogo_v4.h

diff --git a/board/cloudengines/pogo_v4/Makefile 
b/board/cloudengines/pogo_v4/Makefile
new file mode 100644
index 00..511bf5ff7e
--- /dev/null
+++ b/board/cloudengines/pogo_v4/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2014-2021 Tony Dinh 
+#
+# Based on
+# Marvell Semiconductor 
+# Written-by: Prafulla Wadaskar 
+#
+
+obj-y  := pogo_v4.o
diff --git a/board/cloudengines/pogo_v4/pogo_v4.h 
b/board/cloudengines/pogo_v4/pogo_v4.h
new file mode 100644
index 00..bf3060de60
--- /dev/null
+++ b/board/cloudengines/pogo_v4/pogo_v4.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2014-2021 Tony Dinh 
+ *
+ * Based on
+ * Copyright (C) 2012 David Purdy 
+ *
+ * Based on Kirkwood support:
+ * (C) Copyright 2009
+ * Marvell Semiconductor 
+ * Written-by: Prafulla Wadaskar 
+ */
+
+#ifndef __POGO_V4_H
+#define __POGO_V4_H
+
+#include 
+
+/* GPIO configuration */
+#define POGO_V4_OE_LOW (~(0))
+#define POGO_V4_OE_HIGH(~(0))
+#define POGO_V4_OE_VAL_LOW BIT(29)
+#define POGO_V4_OE_VAL_HIGH0
+
+/* PHY related */
+#define MV88E1116_LED_FCTRL_REG10
+#define MV88E1116_CPRSP_CR3_REG21
+#define MV88E1116_MAC_CTRL_REG 21
+#define MV88E1116_PGADR_REG22
+#define MV88E1116_RGMII_TXTM_CTRL  BIT(4)
+#define MV88E1116_RGMII_RXTM_CTRL  BIT(5)
+
+/* button */
+#define BTN_EJECT  29
+
+#endif /* __POGO_V4_H */
-- 
2.20.1



[PATCH 5/8] arm: kirkwood: Pogoplug-V4 : Add board kwbimage file

2021-12-17 Thread Tony Dinh
Add board kwbimage file for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 board/cloudengines/pogo_v4/kwbimage.cfg | 148 
 1 file changed, 148 insertions(+)
 create mode 100644 board/cloudengines/pogo_v4/kwbimage.cfg

diff --git a/board/cloudengines/pogo_v4/kwbimage.cfg 
b/board/cloudengines/pogo_v4/kwbimage.cfg
new file mode 100644
index 00..f6294fe313
--- /dev/null
+++ b/board/cloudengines/pogo_v4/kwbimage.cfg
@@ -0,0 +1,148 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2012
+# David Purdy 
+#
+# Based on Kirkwood support:
+# (C) Copyright 2009
+# Marvell Semiconductor 
+# Written-by: Prafulla Wadaskar  marvell.com>
+
+# Boot Media configurations   (DONE)
+BOOT_FROM  nand
+NAND_ECC_MODE  default
+NAND_PAGE_SIZE 0x0800
+
+# SOC registers configuration using bootrom header extension
+# Maximum KWBIMAGE_MAX_CONFIG configurations allowed
+
+# Configure RGMII-0 interface pad voltage to 1.8V (SHOULD BE SAME)
+DATA 0xffd100e0 0x1b1b1b9b
+
+#Dram initalization for SINGLE x16 CL=3 @ 200MHz   (need CL=3 @ 200MHz?)
+DATA 0xffd01400 0x43000618 # DDR Configuration register
+# bit13-0:  0x200 (200 DDR2 clks refresh rate)
+# bit23-14: zero
+# bit24: 1= enable exit self refresh mode on DDR access
+# bit25: 1 required
+# bit29-26: zero
+# bit31-30: 01
+
+DATA 0xffd01404 0x34143000 # DDR Controller Control Low
+# bit 4:0=addr/cmd in smame cycle
+# bit 5:0=clk is driven during self refresh, we don't care for APX
+# bit 6:0=use recommended falling edge of clk for addr/cmd
+# bit14:0=input buffer always powered up
+# bit18:1=cpu lock transaction enabled
+# bit23-20: 3=recommended value for CL=3 and STARTBURST_DEL disabled bit31=0
+# bit27-24: 6= CL+3, STARTBURST sample stages, for freqs 400MHz, unbuffered 
DIMM
+# bit30-28: 3 required
+# bit31:0=no additional STARTBURST delay
+
+DATA 0xffd01408 0x11012227 # DDR Timing (Low) (active cycles value +1)
+# bit3-0:   TRAS lsbs
+# bit7-4:   TRCD
+# bit11- 8: TRP
+# bit15-12: TWR
+# bit19-16: TWTR
+# bit20:TRAS msb
+# bit23-21: 0x0
+# bit27-24: TRRD
+# bit31-28: TRTP
+
+DATA 0xffd0140c 0x0819 #  DDR Timing (High)
+# bit6-0:   TRFC
+# bit8-7:   TR2R
+# bit10-9:  TR2W
+# bit12-11: TW2W
+# bit31-13: zero required
+
+DATA 0xffd01410 0x0001 #  DDR Address Control  (changed to Dockstar 
vals)
+# bit1-0:   00, Cs0width=x16
+# bit3-2:   10, Cs0size=512Mb
+# bit5-4:   00, Cs2width=nonexistent
+# bit7-6:   00, Cs1size =nonexistent
+# bit9-8:   00, Cs2width=nonexistent
+# bit11-10: 00, Cs2size =nonexistent
+# bit13-12: 00, Cs3width=nonexistent
+# bit15-14: 00, Cs3size =nonexistent
+# bit16:0,  Cs0AddrSel
+# bit17:0,  Cs1AddrSel
+# bit18:0,  Cs2AddrSel
+# bit19:0,  Cs3AddrSel
+# bit31-20: 0 required
+
+DATA 0xffd01414 0x #  DDR Open Pages Control
+# bit0:0,  OpenPage enabled
+# bit31-1: 0 required
+
+DATA 0xffd01418 0x #  DDR Operation
+# bit3-0:   0x0, DDR cmd
+# bit31-4:  0 required
+
+DATA 0xffd0141c 0x0632 #  DDR Mode
+# bit2-0:   2, BurstLen=2 required
+# bit3: 0, BurstType=0 required
+# bit6-4:   4, CL=5(<= change to CL=3 ?)
+# bit7: 0, TestMode=0 normal
+# bit8: 0, DLL reset=0 normal
+# bit11-9:  6, auto-precharge write recovery 
+# bit12:0, PD must be zero
+# bit31-13: 0 required
+
+DATA 0xffd01420 0x0040 #  DDR Extended Mode
+# bit0:0,  DDR DLL enabled
+# bit1:0,  DDR drive strenght normal
+# bit2:0,  DDR ODT control lsd (disabled)
+# bit5-3:  000, required
+# bit6:1,  DDR ODT control msb, (disabled)
+# bit9-7:  000, required
+# bit10:   0,  differential DQS enabled
+# bit11:   0, required
+# bit12:   0, DDR output buffer enabled
+# bit31-13: 0 required
+
+DATA 0xffd01424 0xF07F #  DDR Controller Control High
+# bit2-0:  111, required
+# bit3  :  1  , MBUS Burst Chop disabled
+# bit6-4:  111, required
+# bit7  :  0
+# bit8  :  0  , no sample stage
+# bit9  :  0  , no half clock cycle addition to dataout
+# bit10 :  0  , 1/4 clock cycle skew enabled for addr/ctl signals
+# bit11 :  0  , 1/4 clock cycle skew disabled for write mesh
+# bit15-12:  required
+# bit31-16: 0required
+
+DATA 0xffd01428 0x00085520 # DDR2 ODT Read Timing (default values)
+DATA 0xffd0147c 0x8552 # DDR2 ODT Write Timing (default values)
+
+DATA 0xFFD01500 0x # CS[0]n Base address to 0x0
+DATA 0xFFD01504 0x07F1 # CS[0]n Size
+# bit0:1,  Window enabled
+# bit1:0,  Write Protect disabled
+# bit3-2:  00, CS0 hit selected
+# bit23-4: ones, required
+# bit31-24: 0x07, Size (i.e. 128MB)
+
+DATA 0xFFD0150C 0x # CS[1]n Size, window disabled
+DATA 0xFFD01514 0x # CS[2]n Size, window disabled
+DATA 0xFFD0151C 0x # CS[3]n Size, window disabled
+
+DATA 0xffd01494 0x0003 #  DDR ODT Control (Low) (DONE)
+# bit3-0:  2, ODT0Rd, MODT[0] asserted during read from DRAM CS1
+# bit

[PATCH 4/8] arm: kirkwood: Pogoplug-V4 : Add board include configs file

2021-12-17 Thread Tony Dinh
Add include configs file for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 include/configs/pogo_v4.h | 94 +++
 1 file changed, 94 insertions(+)
 create mode 100644 include/configs/pogo_v4.h

diff --git a/include/configs/pogo_v4.h b/include/configs/pogo_v4.h
new file mode 100644
index 00..b449986e8c
--- /dev/null
+++ b/include/configs/pogo_v4.h
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2014-2021 Tony Dinh 
+ *
+ * Based on
+ * Copyright (C) 2012
+ * David Purdy 
+ *
+ * Based on Kirkwood support:
+ * (C) Copyright 2009
+ * Marvell Semiconductor 
+ * Written-by: Prafulla Wadaskar 
+ */
+
+#ifndef _CONFIG_POGO_V4_H
+#define _CONFIG_POGO_V4_H
+
+/*
+ * Machine type definition and ID
+ */
+#define MACH_TYPE_POGO_V4  3960
+#define CONFIG_MACH_TYPE   MACH_TYPE_POGO_V4
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_FEROCEON_88FR131/* #define CPU Core subversion 
*/
+#define CONFIG_KW88F6192   /* SOC Name */
+
+/*
+ * Commands configuration
+ */
+#define CONFIG_SYS_NO_FLASH/* Declare no flash (NOR/SPI) */
+#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
+
+/*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
+#include "mv-common.h"
+
+/*
+ * Default environment variables
+ */
+#define CONFIG_BOOTCOMMAND \
+   "setenv bootargs $(bootargs_console); " \
+   "run bootcmd_usb; " \
+   "bootm 0x0080 0x0110 0x2c0"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+   "dtb_file=/boot/dts/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
+   "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0"\
+   "mtdids=nand0=orion_nand\0"\
+   "bootargs_console=console=ttyS0,115200\0" \
+   "bootcmd_usb=usb start; load usb 0:1 0x0080 /boot/uImage; " \
+   "load usb 0:1 0x0110 /boot/uInitrd; " \
+   "load usb 0:1 0x2c0 $dtb_file\0"
+
+/*
+ * Ethernet Driver configuration
+ */
+#ifdef CONFIG_CMD_NET
+#define CONFIG_FEATURE_COMMAND_EDITING /* for netconsole */
+#define CONFIG_MVGBE_PORTS {1, 0}  /* enable port 0 only */
+#define CONFIG_PHY_BASE_ADR0
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * File system
+ */
+#ifdef CONFIG_CMD_JFFS2
+#define CONFIG_JFFS2_NAND
+#define CONFIG_JFFS2_LZO
+#endif /* CONFIG_CMD_JFFS2 */
+
+/*
+ *  SATA Driver configuration
+ */
+#ifdef CONFIG_SATA
+#define CONFIG_SYS_SATA_MAX_DEVICE 1
+#endif /* CONFIG_SATA */
+
+/*
+ * Support large disk for SATA and USB
+ */
+#define CONFIG_SYS_64BIT_LBA
+#define CONFIG_LBA48
+
+/*
+ * Kirkwood GPIO
+ */
+#define CONFIG_KIRKWOOD_GPIO
+
+#endif /* _CONFIG_POGO_V4_H */
-- 
2.20.1



[PATCH 3/8] arm: kirkwood: Pogoplug-V4 : Add Kconfig files

2021-12-17 Thread Tony Dinh
Add Kconfig files for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 arch/arm/mach-kirkwood/Kconfig |  4 
 board/cloudengines/pogo_v4/Kconfig | 16 
 2 files changed, 20 insertions(+)
 create mode 100644 board/cloudengines/pogo_v4/Kconfig

diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index cb4e9f29ef..e8ea4a9956 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -25,6 +25,9 @@ config TARGET_LSXL
 config TARGET_POGO_E02
bool "pogo_e02 Board"
 
+config TARGET_POGO_V4
+   bool "Pogoplug V4 Board"
+
 config TARGET_DNS325
bool "dns325 Board"
 
@@ -74,6 +77,7 @@ source "board/Marvell/guruplug/Kconfig"
 source "board/Marvell/sheevaplug/Kconfig"
 source "board/buffalo/lsxl/Kconfig"
 source "board/cloudengines/pogo_e02/Kconfig"
+source "board/cloudengines/pogo_v4/Kconfig"
 source "board/d-link/dns325/Kconfig"
 source "board/iomega/iconnect/Kconfig"
 source "board/keymile/Kconfig"
diff --git a/board/cloudengines/pogo_v4/Kconfig 
b/board/cloudengines/pogo_v4/Kconfig
new file mode 100644
index 00..db3b76b4d4
--- /dev/null
+++ b/board/cloudengines/pogo_v4/Kconfig
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2014-2021 Tony Dinh 
+#
+if TARGET_POGO_V4
+
+config SYS_BOARD
+   default "pogo_v4"
+
+config SYS_VENDOR
+   default "cloudengines"
+
+config SYS_CONFIG_NAME
+   default "pogo_v4"
+
+endif
-- 
2.20.1



[PATCH 2/8] arm: kirkwood: Pogoplug V4 : Add board defconfig file

2021-12-17 Thread Tony Dinh
Add board defconfig file for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 configs/pogo_v4_defconfig | 97 +++
 1 file changed, 97 insertions(+)
 create mode 100644 configs/pogo_v4_defconfig

diff --git a/configs/pogo_v4_defconfig b/configs/pogo_v4_defconfig
new file mode 100644
index 00..b183c9c46f
--- /dev/null
+++ b/configs/pogo_v4_defconfig
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2017-2021 Tony Dinh 
+#
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_SYS_DCACHE_OFF=y
+CONFIG_ARCH_CPU_INIT=y
+CONFIG_SYS_THUMB_BUILD=y
+CONFIG_ARCH_KIRKWOOD=y
+CONFIG_SYS_TEXT_BASE=0x60
+CONFIG_TARGET_POGO_V4=y
+CONFIG_ENV_SIZE=0x2
+CONFIG_ENV_OFFSET=0xC
+CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogoplug_v4"
+CONFIG_BOOTDELAY=10
+CONFIG_BOOTSTAGE=y
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_USE_PREBOOT=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="Pogo_V4> "
+CONFIG_IDENT_STRING="\nPogoplug V4"
+CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_VERSION_VARIABLE=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_SETEXPR=y
+CONFIG_CMD_NAND=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_JFFS2=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:2M(u-boot),3M(uImage),3M(uImage2),8M(failsafe),112M(root)"
+CONFIG_MTDIDS_DEFAULT="nand0=orion_nand"
+CONFIG_CMD_UBI=y
+CONFIG_ISO_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_PARTITION_UUIDS=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_NAND=y
+CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_OF_LIBFDT=y
+CONFIG_CMD_FDT=y
+CONFIG_CMD_BOOTZ=y
+CONFIG_NETCONSOLE=y
+CONFIG_MTD=y
+CONFIG_MTD_RAW_NAND=y
+CONFIG_CMD_MTD=y
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_DEVICE=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_MVGBE=y
+CONFIG_MII=y
+CONFIG_DM=y
+CONFIG_DM_USB=y
+CONFIG_OF_CONTROL=y
+CONFIG_DM_ETH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_BLK=y
+CONFIG_CMD_SATA=y
+CONFIG_SATA_MV=y
+CONFIG_DM_MMC=y
+CONFIG_MVEBU_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_MVEBU=y
+CONFIG_PCI_PNP=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_PCI=y
+CONFIG_BOARD_LATE_INIT=y
+#
+# RTC emulation
+#
+CONFIG_CMD_DATE=y
+CONFIG_PROT_UDP=y
+CONFIG_CMD_SNTP=y
+CONFIG_CMD_DNS=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_EMULATION=y
+#
+# Turn off unused capabilities to save space
+#
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_MMC_HW_PARTITIONING is not set
-- 
2.20.1



[PATCH 1/8] arm: kirkwood: Pogoplug-V4 : Add DTS files

2021-12-17 Thread Tony Dinh
Add DTS files for Pogoplug V4 board

Signed-off-by: Tony Dinh 
---

 arch/arm/dts/Makefile |   1 +
 arch/arm/dts/kirkwood-pogoplug_v4.dts | 145 ++
 2 files changed, 146 insertions(+)
 create mode 100644 arch/arm/dts/kirkwood-pogoplug_v4.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7f622fedbd..716c6c0ed2 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -68,6 +68,7 @@ dtb-$(CONFIG_ARCH_KIRKWOOD) += \
kirkwood-openrd-client.dtb \
kirkwood-openrd-ultimate.dtb \
kirkwood-pogo_e02.dtb \
+   kirkwood-pogoplug_v4.dtb \
kirkwood-sheevaplug.dtb
 
 dtb-$(CONFIG_MACH_S900) += \
diff --git a/arch/arm/dts/kirkwood-pogoplug_v4.dts 
b/arch/arm/dts/kirkwood-pogoplug_v4.dts
new file mode 100644
index 00..b4754f600e
--- /dev/null
+++ b/arch/arm/dts/kirkwood-pogoplug_v4.dts
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2014-2021 Tony Dinh 
+ *
+ * Device tree file for the Pogoplug V4/Mobile
+ *
+ */
+
+/dts-v1/;
+
+#include "kirkwood.dtsi"
+#include "kirkwood-6192.dtsi"
+
+/ {
+   model = "Pogoplug v4";
+   compatible = "cloudengines,pogoplug-v4", "cloudengines,pogoplug-mobile",
+   "marvell,kirkwood-88f6192", "marvell,kirkwood";
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x800>;
+   };
+
+   chosen {
+   bootargs = "console=ttyS0,115200";
+   stdout-path = &uart0;
+   };
+
+   ocp@f100 {
+   pinctrl: pin-controller@1 {
+   pmx_led_green: pmx-led-green {
+   marvell,pins = "mpp22";
+   marvell,function = "gpio";
+   };
+   pmx_led_red: pmx-led-red {
+   marvell,pins = "mpp24";
+   marvell,function = "gpio";
+   };
+   pmx_button_eject: pmx-button-eject {
+   marvell,pins = "mpp29";
+   marvell,function = "gpio";
+   };
+   };
+
+   serial@12000 {
+   status = "ok";
+   };
+
+   sata@8 {
+   status = "okay";
+   nr-ports = <2>;
+   };
+
+   mvsdio@9 {
+   pinctrl-0 = <&pmx_sdio>;
+   pinctrl-names = "default";
+   status = "okay";
+   cd-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;
+   /* No WP GPIO */
+   };
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+   pinctrl-0 = <&pmx_led_red &pmx_led_green>;
+   pinctrl-names = "default";
+
+   health {
+   label = "status:green:health";
+   gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
+   default-state = "keep";
+   };
+   fault {
+   label = "status:red:fault";
+   gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-0 = <&pmx_button_eject>;
+   pinctrl-names = "default";
+
+   button@1 {
+   label = "Eject Button";
+   linux,code = ;
+   gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
+   };
+   };
+
+};
+
+&nand {
+   status = "okay";
+
+   partition@0 {
+   label = "u-boot";
+   reg = <0x000 0x20>;
+   };
+
+   partition@20 {
+   label = "uImage";
+   reg = <0x20 0x30>;
+   };
+
+   partition@50 {
+   label = "uImage2";
+   reg = <0x50 0x30>;
+   };
+
+   partition@80 {
+   label = "failsafe";
+   reg = <0x80 0x80>;
+   };
+
+   partition@100 {
+   label = "root";
+   reg = <0x100 0x700>;
+   };
+};
+
+&mdio {
+   status = "okay";
+
+   ethphy0: ethernet-phy@0 {
+   reg = <0>;
+   };
+};
+
+ð0 {
+   status = "okay";
+   ethernet0-port@0 {
+   phy-handle = <ðphy0>;
+   };
+};
+
+&pciec {
+   status = "okay";
+};
+
+&pcie0 {
+   status = "okay";
+};
-- 
2.20.1



[PATCH 0/8] arm: kirkwood: Add support for Pogoplug V4

2021-12-17 Thread Tony Dinh


Pogoplug V4 specifications:

Kirkwood 88F6192 SoC
800 MHz CPU
1Gbs Ethernet
128 MB RAM
128 MB NAND
1x USB 2.0
2x USB 3.0 (on PCIe bus)
1 SDHC slot
1x External SATA port (USM enclosure form factor slot)


Tony Dinh (8):
  arm: kirkwood: Pogoplug-V4 : Add DTS files
  arm: kirkwood: Pogoplug V4 : Add board defconfig file
  arm: kirkwood: Pogoplug-V4 : Add Kconfig files
  arm: kirkwood: Pogoplug-V4 : Add board include configs file
  arm: kirkwood: Pogoplug-V4 : Add board kwbimage file
  arm: kirkwood: Pogoplug-V4 : Add board implementation header
  arm: kirkwood: Pogoplug-V4 : Add board implementation
  arm: kirkwood: Pogoplug-V4 : Add board maintainer

 arch/arm/dts/Makefile   |   1 +
 arch/arm/dts/kirkwood-pogoplug_v4.dts   | 145 +
 arch/arm/mach-kirkwood/Kconfig  |   4 +
 board/cloudengines/pogo_v4/Kconfig  |  16 ++
 board/cloudengines/pogo_v4/MAINTAINERS  |   6 +
 board/cloudengines/pogo_v4/Makefile |  10 ++
 board/cloudengines/pogo_v4/kwbimage.cfg | 148 +
 board/cloudengines/pogo_v4/pogo_v4.c| 204 
 board/cloudengines/pogo_v4/pogo_v4.h|  36 +
 configs/pogo_v4_defconfig   |  97 +++
 include/configs/pogo_v4.h   |  94 +++
 11 files changed, 761 insertions(+)
 create mode 100644 arch/arm/dts/kirkwood-pogoplug_v4.dts
 create mode 100644 board/cloudengines/pogo_v4/Kconfig
 create mode 100644 board/cloudengines/pogo_v4/MAINTAINERS
 create mode 100644 board/cloudengines/pogo_v4/Makefile
 create mode 100644 board/cloudengines/pogo_v4/kwbimage.cfg
 create mode 100644 board/cloudengines/pogo_v4/pogo_v4.c
 create mode 100644 board/cloudengines/pogo_v4/pogo_v4.h
 create mode 100644 configs/pogo_v4_defconfig
 create mode 100644 include/configs/pogo_v4.h

-- 
2.20.1



Re: [BUG] patman: refused to send patches because of warnings

2021-12-17 Thread Sean Anderson

On 12/17/21 10:59 PM, Tony Dinh wrote:

Hi Simon,

I tried to send in patches to add support for a new board. patman
seems to hit a problem with "Bad divisor in main" error and refuses to
send the patches. The warnings are not really important, are they? In
some instances, we need camel cases because that is what the
convention in the specs for MPPs. And the #ifdef or #if is necessary
because the "if (IS_ENABLED(CONFIG...))" cannot be used to compile-out
a function. And the warnings about MAINTAINERS seem unnecessary.

Is there an option to tell patman to ignore the warnings or checks?

Here is the patman log.


./tools/patman/patman -c8 send


you can use -i to ignore errors

--Sean



Cleaned 8 patches
0 errors, 1 warnings, 0 checks for
0001-arm-kirkwood-Pogoplug-V4-Add-DTS-files.patch:
:29: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0002-arm-kirkwood-Pogoplug-V4-Add-board-defconfig-file.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 2 warnings, 0 checks for
0003-arm-kirkwood-Pogoplug-V4-Add-Kconfig-files.patch:
arch/arm/mach-kirkwood/Kconfig:28: warning: please write a paragraph
that describes the config symbol fully
:39: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0004-arm-kirkwood-Pogoplug-V4-Add-board-include-configs-f.patch:
:17: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0005-arm-kirkwood-Pogoplug-V4-Add-board-kwbimage-file.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0006-arm-kirkwood-Pogoplug-V4-Add-board-implementation-he.patch:
:19: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 3 warnings, 3 checks for
0007-arm-kirkwood-Pogoplug-V4-Add-board-implementation.patch:
:23: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
board/cloudengines/pogo_v4/pogo_v4.c:49: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:63: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:64: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:137: warning: Use 'if
(IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
board/cloudengines/pogo_v4/pogo_v4.c:170: warning: Use 'if
(IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
0 errors, 1 warnings, 0 checks for
0008-arm-kirkwood-Pogoplug-V4-Add-board-maintainer.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
checkpatch.pl found 0 error(s), 11 warning(s), 3 checks(s)
Bad divisor in main::vcs_assign: 0
Not sending emails due to errors/warnings

Thanks,
Tony





[BUG] patman: refused to send patches because of warnings

2021-12-17 Thread Tony Dinh
Hi Simon,

I tried to send in patches to add support for a new board. patman
seems to hit a problem with "Bad divisor in main" error and refuses to
send the patches. The warnings are not really important, are they? In
some instances, we need camel cases because that is what the
convention in the specs for MPPs. And the #ifdef or #if is necessary
because the "if (IS_ENABLED(CONFIG...))" cannot be used to compile-out
a function. And the warnings about MAINTAINERS seem unnecessary.

Is there an option to tell patman to ignore the warnings or checks?

Here is the patman log.


./tools/patman/patman -c8 send

Cleaned 8 patches
0 errors, 1 warnings, 0 checks for
0001-arm-kirkwood-Pogoplug-V4-Add-DTS-files.patch:
:29: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0002-arm-kirkwood-Pogoplug-V4-Add-board-defconfig-file.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 2 warnings, 0 checks for
0003-arm-kirkwood-Pogoplug-V4-Add-Kconfig-files.patch:
arch/arm/mach-kirkwood/Kconfig:28: warning: please write a paragraph
that describes the config symbol fully
:39: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0004-arm-kirkwood-Pogoplug-V4-Add-board-include-configs-f.patch:
:17: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0005-arm-kirkwood-Pogoplug-V4-Add-board-kwbimage-file.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 1 warnings, 0 checks for
0006-arm-kirkwood-Pogoplug-V4-Add-board-implementation-he.patch:
:19: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
0 errors, 3 warnings, 3 checks for
0007-arm-kirkwood-Pogoplug-V4-Add-board-implementation.patch:
:23: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
board/cloudengines/pogo_v4/pogo_v4.c:49: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:63: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:64: check: Avoid CamelCase:

board/cloudengines/pogo_v4/pogo_v4.c:137: warning: Use 'if
(IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
board/cloudengines/pogo_v4/pogo_v4.c:170: warning: Use 'if
(IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
0 errors, 1 warnings, 0 checks for
0008-arm-kirkwood-Pogoplug-V4-Add-board-maintainer.patch:
:16: warning: added, moved or deleted file(s), does MAINTAINERS
need updating?
checkpatch.pl found 0 error(s), 11 warning(s), 3 checks(s)
Bad divisor in main::vcs_assign: 0
Not sending emails due to errors/warnings

Thanks,
Tony


Re: [PATCH v8 07/32] arm: vexpress: Add a devicetree files for juno

2021-12-17 Thread Linus Walleij
On Fri, Dec 17, 2021 at 5:00 AM Simon Glass  wrote:

> Sync these file, obtained from Linux v5.15.
>
> Add a note for the maintainer, and SPDX lines where they are missing.
> The added lines are:
>
>SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
>
> Note, this matches the text in those files, but is not the same as the
> GPL-2.0 of some files.
>
> [1] https://releases.linaro.org/android/reference-lcr/juno/7.1-17.05/
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v8:
> - Enable the flash as suggested by Linus Walleij

Acked-by: Linus Walleij 

Yours,
Linus Walleij


Re: Please pull u-boot-dm/next

2021-12-17 Thread Tom Rini
On Fri, Dec 17, 2021 at 12:43:24PM -0700, Simon Glass wrote:

> Hi Tom,
> 
> This is for the -next branch.
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/10299
> 
> The following changes since commit b9c9ce8a4064c8d88f714604db856cf1cd2b40b5:
> 
>   Merge tag 'u-boot-at91-2022.04-a' of
> https://source.denx.de/u-boot/custodians/u-boot-at91 into next (2021-12-17
> 07:25:34 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-17dec21
> 
> for you to fetch changes up to 121cfe5a84d463893bd01da16417ab138f98666a:
> 
>   fdtgrep: Handle an empty output tree (2021-12-17 09:44:59 -0700)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3] timer: Add a migration message

2021-12-17 Thread Sean Anderson




On 12/17/21 6:12 PM, Simon Glass wrote:

Some boards still use the old timer mechanism. Set a deadline for them to
update to driver model. Point to some examples as well.

This needs a bit of a strange rule to avoid an error on some boards.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Push out the deadline

  Makefile   |  4 
  doc/develop/driver-model/migration.rst | 12 
  2 files changed, 16 insertions(+)

diff --git a/Makefile b/Makefile
index ab32efb4d11..7b24250103e 100644
--- a/Makefile
+++ b/Makefile
@@ -1124,6 +1124,10 @@ endif
$(call deprecated,CONFIG_DM_ETH,Ethernet drivers,v2020.07,$(CONFIG_NET))
$(call deprecated,CONFIG_DM_I2C,I2C 
drivers,v2022.04,$(CONFIG_SYS_I2C_LEGACY))
$(call deprecated,CONFIG_DM_KEYBOARD,Keyboard 
drivers,v2022.10,$(CONFIG_KEYBOARD))
+   @# CONFIG_SYS_TIMER_RATE has brackets in it for some boards which
+   @# confuses this rule. Use if() to send just a single character which
+   @# is enable to tell 'deprecated' that one of these symbols exists
+   $(call deprecated,CONFIG_TIMER,Timer drivers,v2023.01,$(if $(strip 
$(CONFIG_SYS_TIMER_RATE)$(CONFIG_SYS_TIMER_COUNTER)),x))
@# Check that this build does not use CONFIG options that we do not
@# know about unless they are in Kconfig. All the existing CONFIG
@# options are whitelisted, so new ones should not be added.
diff --git a/doc/develop/driver-model/migration.rst 
b/doc/develop/driver-model/migration.rst
index 3dbeea6537c..ed342bd4930 100644
--- a/doc/develop/driver-model/migration.rst
+++ b/doc/develop/driver-model/migration.rst
@@ -106,3 +106,15 @@ Deadline: 2022.10
  This is a legacy option which has been replaced by driver model.
  Maintainers should submit patches switching over to using CONFIG_DM_KEYBOARD 
and
  other base driver model options in time for inclusion in the 2022.10 release.
+
+CONFIG_SYS_TIMER_RATE and CONFIG_SYS_TIMER_COUNTER
+--
+Deadline: 2023.01
+
+These are legacy options which have been replaced by driver model.
+Maintainers should submit patches switching over to using CONFIG_TIMER and
+other base driver model options in time for inclusion in the 2022.10 release.
+
+There is only one method to implement, unless you want to support bootstage,
+in which case you need an early timer alsol. For example drivers, see


nit: also


+sandbox_timer.c and rockchip_timer.c



Re: [PATCH] fastboot: only look up real partition names when no alias exists

2021-12-17 Thread Sean Anderson

Hi Matthias,

On 12/16/21 5:26 AM, Matthias Schiffer wrote:

Having U-Boot look up the passed partition name even though an alias
exists is unexpected, leading to warning messages (when the alias name
doesn't exist as a real partition name) or the use of the wrong
partition.

Change part_get_info_by_name_or_alias() to consider real partitions
names only if no alias of the same name exists, allowing to use aliases
to override the configuration for existing partition names.


Much saner IMO.

I think the correct move in the long term is to add a "quiet"
parameter to do_get_part_info (and all its helpers). This is OK as an
incremental improvement.


Also change one use of strcpy() to strlcpy().

Signed-off-by: Matthias Schiffer 
---
  drivers/fastboot/fb_mmc.c | 29 -
  1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2738dc836e..fb7791d9da 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -104,23 +104,18 @@ static int part_get_info_by_name_or_alias(struct blk_desc 
**dev_desc,
  const char *name,
  struct disk_partition *info)
  {
-   int ret;
-
-   ret = do_get_part_info(dev_desc, name, info);
-   if (ret < 0) {
-   /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
-   char env_alias_name[25 + PART_NAME_LEN + 1];
-   char *aliased_part_name;
-
-   /* check for alias */
-   strcpy(env_alias_name, "fastboot_partition_alias_");
-   strlcat(env_alias_name, name, sizeof(env_alias_name));
-   aliased_part_name = env_get(env_alias_name);
-   if (aliased_part_name != NULL)
-   ret = do_get_part_info(dev_desc, aliased_part_name,
-  info);
-   }
-   return ret;
+   /* strlen("fastboot_partition_alias_") + PART_NAME_LEN + 1 */
+   char env_alias_name[25 + PART_NAME_LEN + 1];
+   char *aliased_part_name;
+
+   /* check for alias */
+   strlcpy(env_alias_name, "fastboot_partition_alias_", 
sizeof(env_alias_name));
+   strlcat(env_alias_name, name, sizeof(env_alias_name));
+   aliased_part_name = env_get(env_alias_name);
+   if (aliased_part_name)
+   name = aliased_part_name;
+
+   return do_get_part_info(dev_desc, name, info);
  }

  /**



Reviewed-by: Sean Anderson 

--Sean


Re: Broken arc toolchain

2021-12-17 Thread Simon Glass
Hi Alexey,

On Sat, 10 Jul 2021 at 16:03, Alexey Brodkin
 wrote:
>
> Hi Tom and Simon,
>
> So there're a couple of things involved indeed.
>
> As Tom correctly mentioned we used to use SNSP pre-built tools for ARC in 
> TravisCI previously. And frankly the reason was we needed something GCC 8.x 
> based while on some other arches such a new GCC triggered extra problems, see 
> https://lists.denx.de/pipermail/u-boot/2018-May/329577.html. So I updated ARC 
> pre-built versions and we kept using it.
> Now, that particular "mcpu" was never added into upstream GCC because we 
> wanted to re-implement it a bit nicer, thus any up-to-date vanilla GCC won't 
> accept it as opposed to tools built from SNPS' GCC port [which has it 
> https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/commit/84a3ee3844f9967a1b6c5923b9da4e6720c1d5bb].
> IIRC "-mcpu=hs4x_rel31" is basically an umbrella option for some options 
> combination based on generic "-mcpu=hs4x" so we may probably update HSDK-4xD 
> flags to be buildable by vanialla GGC.
>
> But anyways the simples short-term solution is to use our pre-built tools, 
> latest of which are avaialble here 
> https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/tag/arc-2021.03-release.
>  And for U-Boot elf32 version is what I would suggest to use, so please use 
> https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_elf32_le_linux_install.tar.gz.
>
> Moreover since by default for ARC we use U-Boot built-in libgcc the same one 
> little-endian toolchain might be safely used for building our big-endian 
> configs equally well.
>
> If more info or actions needed, please let me know.

Thanks for the instructions. I was able to make it work.

I hope you can get your toolchain things upstream soon!

Regards,
Simon


>
> -Alexey
>
>
>  From: Tom Rini
> Sent: Saturday, July 10, 2021 11:22 PM
> To: Simon Glass
> Cc: U-Boot Mailing List; Alexey Brodkin; Eugeniy Paltsev
> Subject: Re: Broken arc toolchain
>
> On Sat, Jul 10, 2021 at 02:11:30PM -0600, Simon Glass wrote:
>
> > Hi,
> >
> > I see this:
> >
> > $ buildman --fetch-arch arc
> >
> > Downloading toolchain for arch 'arc'
> > Checking: https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/
> > Downloading: 
> > https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-arc-linux.tar.xz
> >  Unpacking to: /home/sglass/.buildman-toolchains
> > Testing
> >   - looking in
> > '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/.'
> >   - looking in
> > '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin'
> >  - found
> > '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin/arc-linux-gcc'
> >   - looking in
> > '/home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/usr/bin'
> > Tool chain test:  OK, arch='arc', priority 5
> >
> > $ buildman -A hsdk_4xd
> > /home/sglass/.buildman-toolchains/gcc-9.2.0-nolibc/arc-linux/bin/arc-linux-
> > $ buildman hsdk_4xd
> > ...
> > arc-linux-gcc: error: unrecognized argument in option '-mcpu=hs4x_rel31
> >
> >
> > Do you have any thoughts on what is wrong, please?
>
> There's two parts.  The first part is I keep forgetting to update
> buildman to fetch the latest toolchains from kernel.org, it should be
> grabbing 11.1.0 now, not 9.2.0.  The second part is that arc, nds32 and
> xtensa have non-standard toolchain locations, see
> tools/docker/Dockerfile for where to fetch.
>
> --
> Tom


[PATCH v3] timer: Add a migration message

2021-12-17 Thread Simon Glass
Some boards still use the old timer mechanism. Set a deadline for them to
update to driver model. Point to some examples as well.

This needs a bit of a strange rule to avoid an error on some boards.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Push out the deadline

 Makefile   |  4 
 doc/develop/driver-model/migration.rst | 12 
 2 files changed, 16 insertions(+)

diff --git a/Makefile b/Makefile
index ab32efb4d11..7b24250103e 100644
--- a/Makefile
+++ b/Makefile
@@ -1124,6 +1124,10 @@ endif
$(call deprecated,CONFIG_DM_ETH,Ethernet drivers,v2020.07,$(CONFIG_NET))
$(call deprecated,CONFIG_DM_I2C,I2C 
drivers,v2022.04,$(CONFIG_SYS_I2C_LEGACY))
$(call deprecated,CONFIG_DM_KEYBOARD,Keyboard 
drivers,v2022.10,$(CONFIG_KEYBOARD))
+   @# CONFIG_SYS_TIMER_RATE has brackets in it for some boards which
+   @# confuses this rule. Use if() to send just a single character which
+   @# is enable to tell 'deprecated' that one of these symbols exists
+   $(call deprecated,CONFIG_TIMER,Timer drivers,v2023.01,$(if $(strip 
$(CONFIG_SYS_TIMER_RATE)$(CONFIG_SYS_TIMER_COUNTER)),x))
@# Check that this build does not use CONFIG options that we do not
@# know about unless they are in Kconfig. All the existing CONFIG
@# options are whitelisted, so new ones should not be added.
diff --git a/doc/develop/driver-model/migration.rst 
b/doc/develop/driver-model/migration.rst
index 3dbeea6537c..ed342bd4930 100644
--- a/doc/develop/driver-model/migration.rst
+++ b/doc/develop/driver-model/migration.rst
@@ -106,3 +106,15 @@ Deadline: 2022.10
 This is a legacy option which has been replaced by driver model.
 Maintainers should submit patches switching over to using CONFIG_DM_KEYBOARD 
and
 other base driver model options in time for inclusion in the 2022.10 release.
+
+CONFIG_SYS_TIMER_RATE and CONFIG_SYS_TIMER_COUNTER
+--
+Deadline: 2023.01
+
+These are legacy options which have been replaced by driver model.
+Maintainers should submit patches switching over to using CONFIG_TIMER and
+other base driver model options in time for inclusion in the 2022.10 release.
+
+There is only one method to implement, unless you want to support bootstage,
+in which case you need an early timer alsol. For example drivers, see
+sandbox_timer.c and rockchip_timer.c
-- 
2.34.1.173.g76aa8bc2d0-goog



Re: [PATCH 1/2] fastboot: fb_getvar: Add getvar_logical_blocksize for MXP mfgtool

2021-12-17 Thread Sean Anderson

Hi Angus,

On 12/17/21 10:41 AM, Angus Ainslie wrote:

uuu uses the blocksize to determine the upload size


Can you please elaborate on this more?



Signed-off-by: Angus Ainslie 
---
  drivers/fastboot/fb_getvar.c | 27 +++
  1 file changed, 27 insertions(+)

diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index d43f2cfee6..ff5f0d3d40 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -31,6 +31,7 @@ static void getvar_partition_type(char *part_name, char 
*response);
  static void getvar_partition_size(char *part_name, char *response);
  #endif
  static void getvar_is_userspace(char *var_parameter, char *response);
+static void getvar_logical_blocksize(char *var_parameter, char *response);
  
  static const struct {

const char *variable;
@@ -81,6 +82,9 @@ static const struct {
}, {
.variable = "is-userspace",
.dispatch = getvar_is_userspace
+   }, {
+   .variable = "logical-block-size",
+   .dispatch = getvar_logical_blocksize
}
  };
  
@@ -140,6 +144,29 @@ static void getvar_downloadsize(char *var_parameter, char *response)

fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
  }
  
+static int fb_get_block_size(void)

+{
+   int dev_no = 0;
+   struct blk_desc *dev_desc;
+
+   dev_desc = blk_get_dev("mmc", 0);


And what if your block device is not mmc 0? This code is not specific to 
fastboot mmc. What about nand?


+
+   if (!dev_desc) {
+   printf("** Block device %s %d not supported\n",
+  "mmc", 0);
+   return 0;


Why return 0? This should result in an error fastboot_response.


+   }
+   return dev_desc->blksz;
+}
+
+static void getvar_logical_blocksize(char *var_parameter, char *response)
+{
+   u32 blksz;
+
+   blksz = fb_get_block_size();
+   fastboot_response("OKAY", response, "0x%08x", blksz);


Can we combine these functions?

--Sean


+}
+
  static void getvar_serialno(char *var_parameter, char *response)
  {
const char *tmp = env_get("serial#");



[PATCH 08/12] Kconfig: Remove some symbols from the whitelist

2021-12-17 Thread Tom Rini
There are a number of symbols that are never defined, only referenced in
code imported from the Linux kernel or similar.  Drop them from the list.

Signed-off-by: Tom Rini 
---
 scripts/config_whitelist.txt | 897 ---
 1 file changed, 897 deletions(-)

diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 655eaab81812..9fae7ce8617c 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1,41 +1,24 @@
-CONFIG_64BIT_PHYS_ADDR
-CONFIG_83XX
 CONFIG_88F5182
 CONFIG_A003399_NOR_WORKAROUND
 CONFIG_A008044_WORKAROUND
-CONFIG_AEABI
 CONFIG_AM335X_USB0
 CONFIG_AM335X_USB0_MODE
 CONFIG_AM335X_USB1
 CONFIG_AM335X_USB1_MODE
-CONFIG_ANDES_PCU
-CONFIG_ANDES_PCU_BASE
-CONFIG_ARCH_ADPAG101P
-CONFIG_ARCH_HAS_ILOG2_U32
-CONFIG_ARCH_HAS_ILOG2_U64
-CONFIG_ARCH_OMAP4
-CONFIG_ARCH_RMOBILE_EXTRAM_BOOT
-CONFIG_ARCH_USE_BUILTIN_BSWAP
-CONFIG_ARC_MMU_VER
 CONFIG_ARMV7_SECURE_BASE
 CONFIG_ARMV7_SECURE_MAX_SIZE
 CONFIG_ARMV7_SECURE_RESERVE_SIZE
 CONFIG_ARMV8_SWITCH_TO_EL1
 CONFIG_ARM_GIC_BASE_ADDRESS
 CONFIG_ARP_TIMEOUT
-CONFIG_AT91C_PQFP_UHPBUG
-CONFIG_AT91RESET_EXTRST
-CONFIG_AT91RM9200
 CONFIG_AT91SAM9260EK
 CONFIG_AT91SAM9261EK
 CONFIG_AT91SAM9G10
 CONFIG_AT91SAM9G10EK
 CONFIG_AT91SAM9G20EK
 CONFIG_AT91SAM9G20EK_2MMC
-CONFIG_AT91SAM9G45EKES
 CONFIG_AT91SAM9G45_LCD_BASE
 CONFIG_AT91SAM9M10G45EK
-CONFIG_AT91_CAN
 CONFIG_AT91_EFLASH
 CONFIG_AT91_GPIO_PULLUP
 CONFIG_AT91_LED
@@ -45,13 +28,9 @@ CONFIG_ATMEL_LCD
 CONFIG_ATMEL_LCD_BGR555
 CONFIG_ATMEL_LCD_RGB565
 CONFIG_ATMEL_LEGACY
-CONFIG_ATMEL_MCI_8BIT
 CONFIG_ATMEL_SPI0
 CONFIG_AUTO_ZRELADDR
 CONFIG_BACKSIDE_L2_CACHE
-CONFIG_BCH_CONST_M
-CONFIG_BCH_CONST_PARAMS
-CONFIG_BCH_CONST_T
 CONFIG_BCM2835_GPIO
 CONFIG_BIOSEMU
 CONFIG_BITBANGMII_MULTI
@@ -72,11 +51,8 @@ CONFIG_BOARD_SIZE_LIMIT
 CONFIG_BOOTFILE
 CONFIG_BOOTMODE
 CONFIG_BOOTP_BOOTFILESIZE
-CONFIG_BOOTP_DHCP_REQUEST_DELAY
-CONFIG_BOOTP_ID_CACHE_SIZE
 CONFIG_BOOTP_MAY_FAIL
 CONFIG_BOOTP_NISDOMAIN
-CONFIG_BOOTP_RANDOM_DELAY
 CONFIG_BOOTP_SERVERIP
 CONFIG_BOOTP_TIMEOFFSET
 CONFIG_BOOTP_VENDOREX
@@ -84,7 +60,6 @@ CONFIG_BOOTROM_ERR_REG
 CONFIG_BOOTSCRIPT_ADDR
 CONFIG_BOOTSCRIPT_COPY_RAM
 CONFIG_BOOTSCRIPT_HDR_ADDR
-CONFIG_BOOTSCRIPT_KEY_HASH
 CONFIG_BOOT_RETRY_MIN
 CONFIG_BOOT_RETRY_TIME
 CONFIG_BPTR_VIRT_ADDR
@@ -97,35 +72,14 @@ CONFIG_BS_HDR_ADDR_RAM
 CONFIG_BS_HDR_SIZE
 CONFIG_BS_SIZE
 CONFIG_BTB
-CONFIG_BUILD_ENVCRC
-CONFIG_BUS_WIDTH
-CONFIG_CDP_APPLIANCE_VLAN_TYPE
-CONFIG_CDP_CAPABILITIES
-CONFIG_CDP_DEVICE_ID
-CONFIG_CDP_DEVICE_ID_PREFIX
-CONFIG_CDP_PLATFORM
-CONFIG_CDP_PORT_ID
-CONFIG_CDP_POWER_CONSUMPTION
-CONFIG_CDP_TRIGGER
-CONFIG_CDP_VERSION
-CONFIG_CFG_DATA_SECTOR
 CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
 CONFIG_CF_DSPI
 CONFIG_CF_SBF
-CONFIG_CF_V2
-CONFIG_CF_V3
-CONFIG_CF_V4
-CONFIG_CF_V4E
 CONFIG_CHAIN_BOOT_CMD
 CONFIG_CHIP_SELECTS_PER_CTRL
-CONFIG_CHIP_SELECT_QUAD_CAPABLE
 CONFIG_CHROMEOS_EXTRA_ENV_SETTINGS
 CONFIG_CI_UDC_HAS_HOSTPC
-CONFIG_CLK_1000_200_200
-CONFIG_CLK_1000_330_165
 CONFIG_CLK_1000_400_200
-CONFIG_CLK_800_330_165
-CONFIG_CLK_DEBUG
 CONFIG_CLOCKS
 CONFIG_CLOCK_SYNTHESIZER
 CONFIG_CM922T_XA10
@@ -135,11 +89,7 @@ CONFIG_CM_MULTIPLE_SSRAM
 CONFIG_CM_REMAP
 CONFIG_CM_SPD_DETECT
 CONFIG_CM_TCRAM
-CONFIG_COLDFIRE
 CONFIG_COMMON_BOOT
-CONFIG_COMPAT
-CONFIG_CONS_EXTC_PINSEL
-CONFIG_CONS_EXTC_RATE
 CONFIG_CONS_ON_SCC
 CONFIG_CONS_SCIF0
 CONFIG_CONS_SCIF1
@@ -151,39 +101,13 @@ CONFIG_CPLD_OR_PRELIM
 CONFIG_CPM2
 CONFIG_CPU_ARMV8
 CONFIG_CPU_FREQ_HZ
-CONFIG_CPU_HAS_LLSC
-CONFIG_CPU_HAS_PREFETCH
-CONFIG_CPU_HAS_SMARTMIPS
-CONFIG_CPU_HAS_SR_RB
-CONFIG_CPU_HAS_WB
-CONFIG_CPU_LITTLE_ENDIAN
-CONFIG_CPU_MICROMIPS
-CONFIG_CPU_MIPSR2
-CONFIG_CPU_MONAHANS
-CONFIG_CPU_PXA25X
-CONFIG_CPU_PXA26X
-CONFIG_CPU_PXA300
-CONFIG_CPU_TYPE_R
-CONFIG_CPU_VR41XX
 CONFIG_CQSPI_REF_CLK
-CONFIG_CS8900_BUS16
-CONFIG_CS8900_BUS32
-CONFIG_CTL_JTAG
-CONFIG_CTL_TBE
 CONFIG_CUSTOMER_BOARD_SUPPORT
 CONFIG_D2NET_V2
-CONFIG_DA850_EVM_MAX_CPU_CLK
 CONFIG_DB_784MP_GP
 CONFIG_DCACHE
-CONFIG_DCACHE_OFF
-CONFIG_DCFG_ADDR
 CONFIG_DEBUG
-CONFIG_DEBUG_FS
 CONFIG_DEBUG_LED
-CONFIG_DEBUG_LOCK_ALLOC
-CONFIG_DEBUG_SEMIHOSTING
-CONFIG_DEBUG_UART_LINFLEXUART
-CONFIG_DEBUG_WRITECOUNT
 CONFIG_DEEP_SLEEP
 CONFIG_DEFAULT
 CONFIG_DEFAULT_IMMR
@@ -194,12 +118,9 @@ CONFIG_DFU_ALT_BOOT_EMMC
 CONFIG_DFU_ALT_BOOT_SD
 CONFIG_DFU_ALT_SYSTEM
 CONFIG_DFU_ENV_SETTINGS
-CONFIG_DHCP_MIN_EXT_LEN
 CONFIG_DIALOG_POWER
 CONFIG_DIMM_SLOTS_PER_CTLR
-CONFIG_DISCONTIGMEM
 CONFIG_DISCOVER_PHY
-CONFIG_DISPLAY_AER_
 CONFIG_DM9000_BASE
 CONFIG_DM9000_BYTE_SWAPPED
 CONFIG_DM9000_DEBUG
@@ -207,33 +128,20 @@ CONFIG_DM9000_NO_SROM
 CONFIG_DM9000_USE_16BIT
 CONFIG_DMA_COHERENT
 CONFIG_DMA_COHERENT_SIZE
-CONFIG_DMA_NONCOHERENT
-CONFIG_DNET_AUTONEG_TIMEOUT
 CONFIG_DP_DDR_CTRL
 CONFIG_DP_DDR_DIMM_SLOTS_PER_CTLR
 CONFIG_DP_DDR_NUM_CTRLS
 CONFIG_DRIVER_DM9000
 CONFIG_DSP_CLUSTER_START
-CONFIG_DWCDDR21MCTL
-CONFIG_DWCDDR21MCTL_BASE
 CONFIG_DWC_AHSATA_BASE_ADDR
 CONFIG_DWC_AHSATA_PORT_ID
 CONFIG_DW_ALTDESCRIPTOR
-CONFIG_DW

[PATCH 09/12] Convert CONFIG_88F5182 et al to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_88F5182
   CONFIG_BOARD_IS_OPENRD_BASE
   CONFIG_BOARD_IS_OPENRD_CLIENT
   CONFIG_BOARD_IS_OPENRD_ULTIMATE
   CONFIG_D2NET_V2
   CONFIG_FEROCEON
   CONFIG_FEROCEON_88FR131
   CONFIG_INETSPACE_V2
   CONFIG_KW88F6192
   CONFIG_KW88F6281
   CONFIG_KW88F6702
   CONFIG_NET2BIG_V2
   CONFIG_NETSPACE_LITE_V2
   CONFIG_NETSPACE_MAX_V2
   CONFIG_NETSPACE_MINI_V2
   CONFIG_NETSPACE_V2
   CONFIG_SHEEVA_88SV131

At this point mv-plug-common.h is now only an include of mv-common.h so
remove that indirection.

Signed-off-by: Tom Rini 
---
 arch/arm/mach-kirkwood/Kconfig | 49 ++
 arch/arm/mach-orion5x/Kconfig  |  8 +
 board/LaCie/net2big_v2/Kconfig | 11 +++
 board/LaCie/netspace_v2/Kconfig| 25 +++
 board/Marvell/openrd/Kconfig   | 14 +
 configs/d2net_v2_defconfig |  1 -
 configs/inetspace_v2_defconfig |  1 -
 configs/net2big_v2_defconfig   |  2 +-
 configs/netspace_lite_v2_defconfig |  2 +-
 configs/netspace_max_v2_defconfig  |  2 +-
 configs/netspace_mini_v2_defconfig |  2 +-
 configs/netspace_v2_defconfig  |  2 +-
 configs/openrd_base_defconfig  |  1 -
 configs/openrd_client_defconfig|  2 +-
 configs/openrd_ultimate_defconfig  |  2 +-
 include/configs/SBx81LIFKW.h   |  2 --
 include/configs/SBx81LIFXCAT.h |  2 --
 include/configs/dns325.h   |  6 
 include/configs/dockstar.h |  6 
 include/configs/dreamplug.h|  7 +
 include/configs/ds109.h|  7 +
 include/configs/edminiv2.h |  3 --
 include/configs/goflexhome.h   |  6 
 include/configs/guruplug.h | 15 +
 include/configs/ib62x0.h   |  6 
 include/configs/iconnect.h |  6 
 include/configs/km/km_arm.h|  6 
 include/configs/lacie_kw.h | 11 ---
 include/configs/lsxl.h |  2 --
 include/configs/mv-plug-common.h   | 21 -
 include/configs/nas220.h   |  6 
 include/configs/nsa310s.h  |  5 ---
 include/configs/openrd.h   |  6 
 include/configs/pogo_e02.h |  6 
 include/configs/sheevaplug.h   |  7 +
 scripts/config_whitelist.txt   | 17 ---
 36 files changed, 118 insertions(+), 159 deletions(-)
 delete mode 100644 include/configs/mv-plug-common.h

diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index cb4e9f29ef6d..c060cc8546b6 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -1,66 +1,115 @@
 if ARCH_KIRKWOOD
 
+config FEROCEON_88FR131
+   bool
+
+config KW88F6192
+   bool
+
+config KW88F6281
+   bool
+
+config SHEEVA_88SV131
+   bool
+
 choice
prompt "Marvell Kirkwood board select"
optional
 
 config TARGET_OPENRD
bool "Marvell OpenRD Board"
+   select KW88F6281
+   select SHEEVA_88SV131
 
 config TARGET_DREAMPLUG
bool "DreamPlug Board"
+   select KW88F6281
+   select SHEEVA_88SV131
 
 config TARGET_DS109
bool "Synology DS109"
+   select KW88F6281
+   select SHEEVA_88SV131
 
 config TARGET_GURUPLUG
bool "GuruPlug Board"
+   select KW88F6281
+   select SHEEVA_88SV131
 
 config TARGET_SHEEVAPLUG
bool "SheevaPlug Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_LSXL
bool "lsxl Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_POGO_E02
bool "pogo_e02 Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_DNS325
bool "dns325 Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_ICONNECT
bool "iconnect Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_KM_KIRKWOOD
bool "KM Kirkwood Board"
+   select FEROCEON_88FR131
+   select KW88F6281
select VENDOR_KM
 
 config TARGET_NET2BIG_V2
bool "LaCie 2Big Network v2 NAS Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_NETSPACE_V2
bool "LaCie netspace_v2 Board"
+   select FEROCEON_88FR131
 
 config TARGET_IB62X0
bool "ib62x0 Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_DOCKSTAR
bool "Dockstar Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_GOFLEXHOME
bool "GoFlex Home Board"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_NAS220
bool "BlackArmor NAS220"
+   select FEROCEON_88FR131
+   select KW88F6192
 
 config TARGET_NSA310S
bool "Zyxel NSA310S"
+   select FEROCEON_88FR131
+   select KW88F6192
 
 config TARGET_SBx81LIFKW
bool "Allied Telesis SBx81GS24/SBx81GT40/SBx81XS6/SBx81XS16"
+   select FEROCEON_88FR131
+   select KW88F6281
 
 config TARGET_SBx81LIFXCAT
bool "Allied Telesis SBx81GP2

[PATCH 10/12] Convert CONFIG_SYS_KWD_CONFIG to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_KWD_CONFIG

Signed-off-by: Tom Rini 
---
 arch/arm/Kconfig |  8 
 arch/arm/mach-kirkwood/include/mach/config.h |  9 -
 arch/arm/mach-mvebu/include/mach/config.h|  9 -
 configs/SBx81LIFKW_defconfig |  1 +
 configs/SBx81LIFXCAT_defconfig   |  1 +
 configs/crs305-1g-4s-bit_defconfig   |  1 +
 configs/crs305-1g-4s_defconfig   |  1 +
 configs/crs326-24g-2s-bit_defconfig  |  1 +
 configs/crs326-24g-2s_defconfig  |  1 +
 configs/crs328-4c-20s-4s-bit_defconfig   |  1 +
 configs/crs328-4c-20s-4s_defconfig   |  1 +
 configs/d2net_v2_defconfig   |  1 +
 configs/db-xc3-24g4xg_defconfig  |  1 +
 configs/dns325_defconfig |  1 +
 configs/dockstar_defconfig   |  1 +
 configs/dreamplug_defconfig  |  1 +
 configs/ds109_defconfig  |  1 +
 configs/goflexhome_defconfig |  1 +
 configs/guruplug_defconfig   |  1 +
 configs/ib62x0_defconfig |  1 +
 configs/iconnect_defconfig   |  1 +
 configs/inetspace_v2_defconfig   |  1 +
 configs/km_kirkwood_128m16_defconfig |  1 +
 configs/km_kirkwood_defconfig|  1 +
 configs/km_kirkwood_pci_defconfig|  1 +
 configs/kmcoge5un_defconfig  |  1 +
 configs/kmnusa_defconfig |  1 +
 configs/kmsuse2_defconfig|  1 +
 configs/lschlv2_defconfig|  1 +
 configs/lsxhl_defconfig  |  1 +
 configs/nas220_defconfig |  1 +
 configs/net2big_v2_defconfig |  1 +
 configs/netspace_lite_v2_defconfig   |  1 +
 configs/netspace_max_v2_defconfig|  1 +
 configs/netspace_mini_v2_defconfig   |  1 +
 configs/netspace_v2_defconfig|  1 +
 configs/nsa310s_defconfig|  1 +
 configs/openrd_base_defconfig|  1 +
 configs/openrd_client_defconfig  |  1 +
 configs/openrd_ultimate_defconfig|  1 +
 configs/pogo_e02_defconfig   |  1 +
 configs/sheevaplug_defconfig |  1 +
 include/configs/SBx81LIFKW.h |  5 -
 include/configs/SBx81LIFXCAT.h   |  5 -
 include/configs/crs3xx-98dx3236.h|  1 -
 include/configs/db-xc3-24g4xg.h  |  6 --
 include/configs/km_kirkwood.h|  9 -
 include/configs/lacie_kw.h   | 18 --
 include/configs/lsxl.h   | 11 ---
 scripts/config_whitelist.txt |  1 -
 50 files changed, 47 insertions(+), 74 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4bfca750c27b..08a06cd9e235 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -2046,6 +2046,14 @@ config ISW_ENTRY_ADDR
  image headers.
 endif
 
+config SYS_KWD_CONFIG
+   string "kwbimage config file path"
+   depends on ARCH_KIRKWOOD || ARCH_MVEBU
+   default "arch/arm/mach-mvebu/kwbimage.cfg"
+   help
+ Path within the source directory to the kwbimage.cfg file to use
+ when packaging the U-Boot image for use.
+
 source "arch/arm/mach-apple/Kconfig"
 
 source "arch/arm/mach-aspeed/Kconfig"
diff --git a/arch/arm/mach-kirkwood/include/mach/config.h 
b/arch/arm/mach-kirkwood/include/mach/config.h
index 9fd90611bd98..eb9502361eef 100644
--- a/arch/arm/mach-kirkwood/include/mach/config.h
+++ b/arch/arm/mach-kirkwood/include/mach/config.h
@@ -27,15 +27,6 @@
 #define CONFIG_KIRKWOOD_RGMII_PAD_1V8  /* Set RGMII Pad voltage to 1.8V */
 #define CONFIG_KIRKWOOD_PCIE_INIT   /* Enable PCIE Port0 for kernel */
 
-/*
- * By default kwbimage.cfg from board specific folder is used
- * If for some board, different configuration file need to be used,
- * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
- */
-#ifndef CONFIG_SYS_KWD_CONFIG
-#defineCONFIG_SYS_KWD_CONFIG   $(CONFIG_BOARDDIR)/kwbimage.cfg
-#endif /* CONFIG_SYS_KWD_CONFIG */
-
 /* Kirkwood has 2k of Security SRAM, use it for SP */
 #define CONFIG_SYS_INIT_SP_ADDR0xC8012000
 
diff --git a/arch/arm/mach-mvebu/include/mach/config.h 
b/arch/arm/mach-mvebu/include/mach/config.h
index 6ecd394a533d..681f64961f0b 100644
--- a/arch/arm/mach-mvebu/include/mach/config.h
+++ b/arch/arm/mach-mvebu/include/mach/config.h
@@ -27,15 +27,6 @@
 
 #define CONFIG_SYS_L2_PL310
 
-/*
- * By default the generated mvebu kwbimage.cfg is used
- * If for some board, different configuration file need to be used,
- * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
- */
-#ifndef CONFIG_SYS_KWD_CONFIG
-#defineCONFIG_SYS_KWD_CONFIG   arch/arm/mach-mvebu/kwbimage.cfg
-#endif /* CONFIG_SYS_KWD_CONFIG */
-

[PATCH 12/12] Convert CONFIG_JFFS2_DEV et al to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_JFFS2_DEV
   CONFIG_JFFS2_LZO
   CONFIG_JFFS2_NAND
   CONFIG_JFFS2_PART_OFFSET
   CONFIG_JFFS2_PART_SIZE

Signed-off-by: Tom Rini 
---
 README |  3 ---
 cmd/Kconfig| 21 +
 cmd/jffs2.c| 12 
 configs/devkit8000_defconfig   |  4 
 configs/ethernut5_defconfig|  1 +
 configs/ids8313_defconfig  |  1 +
 configs/nas220_defconfig   |  2 ++
 configs/pm9263_defconfig   |  3 +++
 fs/jffs2/Kconfig   | 12 
 include/configs/M5329EVB.h |  4 
 include/configs/M5373EVB.h |  4 
 include/configs/devkit8000.h   |  9 -
 include/configs/ethernut5.h|  3 ---
 include/configs/ids8313.h  |  3 ---
 include/configs/imx27lite-common.h |  1 -
 include/configs/nas220.h   |  6 --
 include/configs/pm9263.h   |  5 -
 include/configs/stmark2.h  |  3 ---
 scripts/config_whitelist.txt   |  4 
 19 files changed, 44 insertions(+), 57 deletions(-)

diff --git a/README b/README
index 7d46c567a3f9..e1d74b3aa86e 100644
--- a/README
+++ b/README
@@ -1028,9 +1028,6 @@ The following options need to be configured:
sending again an USB request to the device.
 
 - Journaling Flash filesystem support:
-   CONFIG_JFFS2_NAND
-   Define these for a default partition on a NAND device
-
CONFIG_SYS_JFFS2_FIRST_SECTOR,
CONFIG_SYS_JFFS2_FIRST_BANK, CONFIG_SYS_JFFS2_NUM_BANKS
Define these for a default partition on a NOR device
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 7747ab50a042..ef82f794b557 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2219,6 +2219,27 @@ config CMD_JFFS2
  provide the ability to load files, list directories and obtain
  filesystem information.
 
+config JFFS2_DEV
+   string "Default device for JFFS2"
+   depends on CMD_JFFS2
+   default "nor0"
+   help
+ The default device to use with the jffs2 command.
+
+config JFFS2_PART_OFFSET
+   hex "Default offset within flash to locate the JFFS2 image"
+   depends on CMD_JFFS2
+   default 0x0
+   help
+ The default offset within flash to locate the JFFS2 image.
+
+config JFFS2_PART_SIZE
+   hex "Default size of JFFS2 partition"
+   depends on CMD_JFFS2
+   default 0x
+   help
+ The default size of the JFFS2 partition
+
 config CMD_MTDPARTS
bool "MTD partition support"
depends on MTD
diff --git a/cmd/jffs2.c b/cmd/jffs2.c
index 63bd55263a29..6f15b57b6a18 100644
--- a/cmd/jffs2.c
+++ b/cmd/jffs2.c
@@ -360,11 +360,7 @@ int mtdparts_init(void)
/* id */
id->mtd_id = "single part";
 
-#if defined(CONFIG_JFFS2_DEV)
dev_name = CONFIG_JFFS2_DEV;
-#else
-   dev_name = "nor0";
-#endif
 
if ((mtd_id_parse(dev_name, NULL, &id->type, &id->num) != 0) ||
(mtd_device_validate(id->type, id->num, &size) 
!= 0)) {
@@ -382,17 +378,9 @@ int mtdparts_init(void)
part->name = "static";
part->auto_name = 0;
 
-#if defined(CONFIG_JFFS2_PART_SIZE)
part->size = CONFIG_JFFS2_PART_SIZE;
-#else
-   part->size = SIZE_REMAINING;
-#endif
 
-#if defined(CONFIG_JFFS2_PART_OFFSET)
part->offset = CONFIG_JFFS2_PART_OFFSET;
-#else
-   part->offset = 0x;
-#endif
 
part->dev = current_mtd_dev;
INIT_LIST_HEAD(&part->link);
diff --git a/configs/devkit8000_defconfig b/configs/devkit8000_defconfig
index 4017eb69add8..4034f9ca7512 100644
--- a/configs/devkit8000_defconfig
+++ b/configs/devkit8000_defconfig
@@ -27,6 +27,9 @@ CONFIG_CMD_NAND_LOCK_UNLOCK=y
 CONFIG_BOOTP_DNS2=y
 CONFIG_BOOTP_NTPSERVER=y
 CONFIG_CMD_JFFS2=y
+CONFIG_JFFS2_DEV="nand0"
+CONFIG_JFFS2_PART_OFFSET=0x68
+CONFIG_JFFS2_PART_SIZE=0xF98
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=nand"
 
CONFIG_MTDPARTS_DEFAULT="mtdparts=nand:512k(x-loader),1920k(u-boot),128k(u-boot-env),4m(kernel),-(fs)"
@@ -50,4 +53,5 @@ CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
 CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
 CONFIG_CONS_INDEX=3
+CONFIG_JFFS2_NAND=y
 CONFIG_OF_LIBFDT=y
diff --git a/configs/ethernut5_defconfig b/configs/ethernut5_defconfig
index e7ebfef38619..1821b23ed5f2 100644
--- a/configs/ethernut5_defconfig
+++ b/configs/ethernut5_defconfig
@@ -81,3 +81,4 @@ CONFIG_ATMEL_USART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_USB=y
+CONFIG_JFFS2_NAND=y
diff --git a/configs/ids8313_defconfig b/configs/ids8313_defconfig
index 4ee97ae7..246cc3d045f8 100644
--- a/configs/ids8313_defconfig
+++ b/configs/ids8313_defconfig
@@ -199,4 +199,5 @@ CONFIG_TSEC_ENET=y
 CONFIG_RTC_PCF8563=y
 CONFIG_SYS_NS16550=y
 CONFIG_WATCHDOG=y
+CON

[PATCH 11/12] Convert CONFIG_KIRKWOOD_GPIO to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_KIRKWOOD_GPIO

Signed-off-by: Tom Rini 
---
 configs/SBx81LIFKW_defconfig | 1 +
 configs/SBx81LIFXCAT_defconfig   | 1 +
 configs/d2net_v2_defconfig   | 1 +
 configs/dns325_defconfig | 1 +
 configs/inetspace_v2_defconfig   | 1 +
 configs/km_kirkwood_128m16_defconfig | 1 +
 configs/km_kirkwood_defconfig| 1 +
 configs/km_kirkwood_pci_defconfig| 1 +
 configs/kmcoge5un_defconfig  | 1 +
 configs/kmnusa_defconfig | 1 +
 configs/kmsuse2_defconfig| 1 +
 configs/lschlv2_defconfig| 1 +
 configs/lsxhl_defconfig  | 1 +
 configs/nas220_defconfig | 1 +
 configs/net2big_v2_defconfig | 1 +
 configs/netspace_lite_v2_defconfig   | 1 +
 configs/netspace_max_v2_defconfig| 1 +
 configs/netspace_mini_v2_defconfig   | 1 +
 configs/netspace_v2_defconfig| 1 +
 drivers/gpio/Kconfig | 5 +
 include/configs/SBx81LIFKW.h | 1 -
 include/configs/SBx81LIFXCAT.h   | 1 -
 include/configs/dns325.h | 1 -
 include/configs/km/km_arm.h  | 1 -
 include/configs/lacie_kw.h   | 1 -
 include/configs/lsxl.h   | 2 --
 include/configs/nas220.h | 2 --
 scripts/config_whitelist.txt | 1 -
 28 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/configs/SBx81LIFKW_defconfig b/configs/SBx81LIFKW_defconfig
index ec7c7eb29565..77f44f6329ed 100644
--- a/configs/SBx81LIFKW_defconfig
+++ b/configs/SBx81LIFKW_defconfig
@@ -35,6 +35,7 @@ CONFIG_ENV_SPI_MAX_HZ=2000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NETCONSOLE=y
 CONFIG_DM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
diff --git a/configs/SBx81LIFXCAT_defconfig b/configs/SBx81LIFXCAT_defconfig
index a3ddabd65758..b84e3bd9d6ac 100644
--- a/configs/SBx81LIFXCAT_defconfig
+++ b/configs/SBx81LIFXCAT_defconfig
@@ -37,6 +37,7 @@ CONFIG_ENV_SPI_MAX_HZ=2000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_NETCONSOLE=y
 CONFIG_DM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
diff --git a/configs/d2net_v2_defconfig b/configs/d2net_v2_defconfig
index 8e1bb2d4a01a..a856202d110e 100644
--- a/configs/d2net_v2_defconfig
+++ b/configs/d2net_v2_defconfig
@@ -47,6 +47,7 @@ CONFIG_ENV_ADDR=0x7
 CONFIG_NETCONSOLE=y
 CONFIG_DM=y
 CONFIG_SATA_MV=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_SYS_I2C_SLAVE=0x0
diff --git a/configs/dns325_defconfig b/configs/dns325_defconfig
index c1da0f545c63..144fd30706b5 100644
--- a/configs/dns325_defconfig
+++ b/configs/dns325_defconfig
@@ -41,6 +41,7 @@ CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
 CONFIG_NETCONSOLE=y
 CONFIG_DM=y
+CONFIG_KIRKWOOD_GPIO=y
 # CONFIG_MMC is not set
 CONFIG_MTD=y
 CONFIG_MTD_RAW_NAND=y
diff --git a/configs/inetspace_v2_defconfig b/configs/inetspace_v2_defconfig
index 0af49d45f0c3..8779e58b9322 100644
--- a/configs/inetspace_v2_defconfig
+++ b/configs/inetspace_v2_defconfig
@@ -47,6 +47,7 @@ CONFIG_ENV_ADDR=0x7
 CONFIG_NETCONSOLE=y
 CONFIG_DM=y
 CONFIG_SATA_MV=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_SYS_I2C_SLAVE=0x0
diff --git a/configs/km_kirkwood_128m16_defconfig 
b/configs/km_kirkwood_128m16_defconfig
index c9832d3d51e4..f4b1abfd6a9d 100644
--- a/configs/km_kirkwood_128m16_defconfig
+++ b/configs/km_kirkwood_128m16_defconfig
@@ -49,6 +49,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SOFT=y
 CONFIG_SYS_I2C_SOFT_SLAVE=0x0
diff --git a/configs/km_kirkwood_defconfig b/configs/km_kirkwood_defconfig
index b0a268e370d5..eba4f097775d 100644
--- a/configs/km_kirkwood_defconfig
+++ b/configs/km_kirkwood_defconfig
@@ -49,6 +49,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SOFT=y
 CONFIG_SYS_I2C_SOFT_SLAVE=0x0
diff --git a/configs/km_kirkwood_pci_defconfig 
b/configs/km_kirkwood_pci_defconfig
index 38c4c1e2e483..5d19c5117602 100644
--- a/configs/km_kirkwood_pci_defconfig
+++ b/configs/km_kirkwood_pci_defconfig
@@ -50,6 +50,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SOFT=y
 CONFIG_SYS_I2C_SOFT_SLAVE=0x0
diff --git a/configs/kmcoge5un_defconfig b/configs/kmcoge5un_defconfig
index f46f45d64abf..9124504e3232 100644
--- a/configs/kmcoge5un_defconfig
+++ b/configs/kmcoge5un_defconfig
@@ -53,6 +53,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NETCONSOLE=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_BOOTCOUNT_RAM=y
+CONFIG_KIRKWOOD_GPIO=y
 CONFIG_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_SOFT=y
 CONFIG_SYS_I2C_SOFT_SLAVE=0x0
diff --git a/configs/kmnusa_defconfig b/configs/kmnusa_defconfig
index

[PATCH 04/12] serial: arm_dcc: Use CONFIG_ARM64 not CONFIG_CPU_ARMV8

2021-12-17 Thread Tom Rini
The only place we use CONFIG_CPU_ARMV8 was in the arm_dcc serial driver.
Switch this to CONFIG_ARM64 today, and if in the future we need finer
granularity tuning here, a new CONFIG_SERIAL option needs to be
introduced.

Signed-off-by: Tom Rini 
---
 drivers/serial/arm_dcc.c| 2 +-
 include/configs/meson64.h   | 1 -
 include/configs/mt8183.h| 1 -
 include/configs/mt8512.h| 2 --
 include/configs/mt8516.h| 1 -
 include/configs/mt8518.h| 2 --
 include/configs/xilinx_versal.h | 2 --
 include/configs/xilinx_zynqmp.h | 2 --
 8 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/serial/arm_dcc.c b/drivers/serial/arm_dcc.c
index dfcb6fd69812..a402a123b6d6 100644
--- a/drivers/serial/arm_dcc.c
+++ b/drivers/serial/arm_dcc.c
@@ -51,7 +51,7 @@
 #define status_dcc(x)  \
__asm__ volatile ("mrc p14, 0, %0, c14, c0, 0\n" : "=r" (x))
 
-#elif defined(CONFIG_CPU_ARMV8)
+#elif defined(CONFIG_ARM64)
 /*
  * ARMV8
  */
diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index cb202d61..44f2967fc6b3 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -29,7 +29,6 @@
 #define STDIN_CFG "serial"
 #endif
 
-#define CONFIG_CPU_ARMV8
 #define CONFIG_REMAKE_ELF
 #define CONFIG_SYS_MAXARGS 32
 #define CONFIG_SYS_CBSIZE  1024
diff --git a/include/configs/mt8183.h b/include/configs/mt8183.h
index ebd2b326ade0..2b4e976aa1fe 100644
--- a/include/configs/mt8183.h
+++ b/include/configs/mt8183.h
@@ -11,7 +11,6 @@
 
 #include 
 
-#define CONFIG_CPU_ARMV8
 #define COUNTER_FREQUENCY  1300
 
 #define CONFIG_SYS_NS16550_SERIAL
diff --git a/include/configs/mt8512.h b/include/configs/mt8512.h
index 8882a5a40970..9c443db9f52d 100644
--- a/include/configs/mt8512.h
+++ b/include/configs/mt8512.h
@@ -13,8 +13,6 @@
 
 #define CONFIG_SYS_NONCACHED_MEMORYSZ_1M
 
-#define CONFIG_CPU_ARMV8
-
 #define COUNTER_FREQUENCY  1300
 
 #define CONFIG_SYS_BOOTM_LEN   SZ_64M
diff --git a/include/configs/mt8516.h b/include/configs/mt8516.h
index 12840b883dec..47132c1db1d2 100644
--- a/include/configs/mt8516.h
+++ b/include/configs/mt8516.h
@@ -11,7 +11,6 @@
 
 #include 
 
-#define CONFIG_CPU_ARMV8
 #define COUNTER_FREQUENCY  1300
 
 #define CONFIG_SYS_NS16550_SERIAL
diff --git a/include/configs/mt8518.h b/include/configs/mt8518.h
index 593c6a11d742..49ee926b0c94 100644
--- a/include/configs/mt8518.h
+++ b/include/configs/mt8518.h
@@ -13,8 +13,6 @@
 
 #define CONFIG_SYS_NONCACHED_MEMORYSZ_1M
 
-#define CONFIG_CPU_ARMV8
-
 #define COUNTER_FREQUENCY  1300
 
 /* DRAM definition */
diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h
index 43486457a45d..03539a41b49f 100644
--- a/include/configs/xilinx_versal.h
+++ b/include/configs/xilinx_versal.h
@@ -26,8 +26,6 @@
 #endif
 
 /* Serial setup */
-#define CONFIG_CPU_ARMV8
-
 #define CONFIG_SYS_BAUDRATE_TABLE \
{ 4800, 9600, 19200, 38400, 57600, 115200 }
 
diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
index d683d12e95b9..f4b7f305bf75 100644
--- a/include/configs/xilinx_zynqmp.h
+++ b/include/configs/xilinx_zynqmp.h
@@ -26,8 +26,6 @@
 #endif
 
 /* Serial setup */
-#define CONFIG_CPU_ARMV8
-
 #define CONFIG_SYS_BAUDRATE_TABLE \
{ 4800, 9600, 19200, 38400, 57600, 115200 }
 
-- 
2.25.1



[PATCH 07/12] Convert CONFIG_CPU_FREQ_HZ to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_FREQ_HZ

Cc: Michal Simek 
Signed-off-by: Tom Rini 
---
 arch/arm/mach-zynqmp-r5/Kconfig| 6 ++
 configs/xilinx_zynqmp_r5_defconfig | 1 +
 include/configs/xilinx_zynqmp_r5.h | 3 ---
 include/configs/zynq-common.h  | 5 -
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-zynqmp-r5/Kconfig b/arch/arm/mach-zynqmp-r5/Kconfig
index 5e0175413395..f14514b3c7c1 100644
--- a/arch/arm/mach-zynqmp-r5/Kconfig
+++ b/arch/arm/mach-zynqmp-r5/Kconfig
@@ -21,6 +21,12 @@ config SYS_CONFIG_NAME
  Based on this option include/configs/.h header
  will be used for board configuration.
 
+config CPU_FREQ_HZ
+   int "CPU frequency"
+   default 8
+   help
+ The value, in Hz, that the CPU clock is running at.
+
 config SYS_MALLOC_F_LEN
default 0x600
 
diff --git a/configs/xilinx_zynqmp_r5_defconfig 
b/configs/xilinx_zynqmp_r5_defconfig
index a9c3c4a03e81..98f46cf0205a 100644
--- a/configs/xilinx_zynqmp_r5_defconfig
+++ b/configs/xilinx_zynqmp_r5_defconfig
@@ -9,6 +9,7 @@ CONFIG_ENV_SIZE=0x2
 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-r5"
 CONFIG_DEBUG_UART_BASE=0xff01
 CONFIG_DEBUG_UART_CLOCK=1
+CONFIG_CPU_FREQ_HZ=5
 CONFIG_DEBUG_UART=y
 CONFIG_SYS_LOAD_ADDR=0x0
 CONFIG_BOOTSTAGE=y
diff --git a/include/configs/xilinx_zynqmp_r5.h 
b/include/configs/xilinx_zynqmp_r5.h
index 6d5b81e05e16..3ec99e062df5 100644
--- a/include/configs/xilinx_zynqmp_r5.h
+++ b/include/configs/xilinx_zynqmp_r5.h
@@ -8,9 +8,6 @@
 
 #define CONFIG_EXTRA_ENV_SETTINGS
 
-/* CPU clock */
-#define CONFIG_CPU_FREQ_HZ 5
-
 /* Serial drivers */
 /* The following table includes the supported baudrates */
 #define CONFIG_SYS_BAUDRATE_TABLE  \
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index 8f8a9c7479c3..88c6490d81cd 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -9,11 +9,6 @@
 #ifndef __CONFIG_ZYNQ_COMMON_H
 #define __CONFIG_ZYNQ_COMMON_H
 
-/* CPU clock */
-#ifndef CONFIG_CPU_FREQ_HZ
-# define CONFIG_CPU_FREQ_HZ8
-#endif
-
 #define CONFIG_REMAKE_ELF
 
 /* Cache options */
-- 
2.25.1



[PATCH 05/12] Convert CONFIG_CPU_PXA27X to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_PXA27X

Signed-off-by: Tom Rini 
---
 arch/arm/Kconfig | 6 +-
 include/configs/colibri_pxa270.h | 1 -
 scripts/config_whitelist.txt | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 594aec2b92d7..4bfca750c27b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -311,6 +311,10 @@ config CPU_PXA
select SYS_CACHE_SHIFT_5
imply SYS_ARM_MMU
 
+config CPU_PXA27X
+   bool
+   select CPU_PXA
+
 config CPU_SA1100
bool
select SYS_CACHE_SHIFT_5
@@ -1765,7 +1769,7 @@ config TARGET_SL28
 
 config TARGET_COLIBRI_PXA270
bool "Support colibri_pxa270"
-   select CPU_PXA
+   select CPU_PXA27X
select GPIO_EXTRA_HEADER
 
 config ARCH_UNIPHIER
diff --git a/include/configs/colibri_pxa270.h b/include/configs/colibri_pxa270.h
index 22eab7779b01..0be7f5a416d0 100644
--- a/include/configs/colibri_pxa270.h
+++ b/include/configs/colibri_pxa270.h
@@ -12,7 +12,6 @@
 /*
  * High Level Board Configuration Options
  */
-#defineCONFIG_CPU_PXA27X   1   /* Marvell PXA270 CPU */
 /* Avoid overwriting factory configuration block */
 #define CONFIG_BOARD_SIZE_LIMIT0x4
 
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index a9bbd5078a87..2bc2d5b146bd 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -162,7 +162,6 @@ CONFIG_CPU_MIPSR2
 CONFIG_CPU_MONAHANS
 CONFIG_CPU_PXA25X
 CONFIG_CPU_PXA26X
-CONFIG_CPU_PXA27X
 CONFIG_CPU_PXA300
 CONFIG_CPU_SH7751
 CONFIG_CPU_TYPE_R
-- 
2.25.1



[PATCH 03/12] Convert CONFIG_SYS_I2C_EEPROM_ADDR_LEN to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_SYS_I2C_EEPROM_ADDR_LEN

Signed-off-by: Tom Rini 
---
 include/configs/km/km-mpc832x.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index aac1e999e40a..888bb2981f7b 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -58,6 +58,3 @@
 
 #define CONFIG_SYS_KMBEC_FPGA_BASE 0xE800
 #define CONFIG_SYS_KMBEC_FPGA_SIZE 128
-
-/* EEprom support */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-- 
2.25.1



[PATCH 06/12] Convert CONFIG_CPU_SH7751 to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_CPU_SH7751

Signed-off-by: Tom Rini 
---
 arch/sh/Kconfig  | 6 +-
 include/configs/r2dplus.h| 1 -
 scripts/config_whitelist.txt | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 7836869c55dc..7e6cb7015896 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -4,13 +4,17 @@ menu "SuperH architecture"
 config CPU_SH4
bool
 
+config CPU_SH7751
+   bool
+   select CPU_SH4
+
 choice
prompt "Target select"
optional
 
 config TARGET_R2DPLUS
bool "Renesas R2D-PLUS"
-   select CPU_SH4
+   select CPU_SH7751
 
 endchoice
 
diff --git a/include/configs/r2dplus.h b/include/configs/r2dplus.h
index 680d16d547c4..8e86830e61be 100644
--- a/include/configs/r2dplus.h
+++ b/include/configs/r2dplus.h
@@ -1,7 +1,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CONFIG_CPU_SH7751  1
 #define __LITTLE_ENDIAN__  1
 
 /* SCIF */
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 2bc2d5b146bd..655eaab81812 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -163,7 +163,6 @@ CONFIG_CPU_MONAHANS
 CONFIG_CPU_PXA25X
 CONFIG_CPU_PXA26X
 CONFIG_CPU_PXA300
-CONFIG_CPU_SH7751
 CONFIG_CPU_TYPE_R
 CONFIG_CPU_VR41XX
 CONFIG_CQSPI_REF_CLK
-- 
2.25.1



[PATCH 01/12] Convert CONFIG_83XX_PCICLK to Kconfig

2021-12-17 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_83XX_PCICLK

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc83xx/Kconfig | 7 +++
 configs/kmcoge5ne_defconfig  | 1 +
 configs/kmopti2_defconfig| 1 +
 configs/kmsupx5_defconfig| 1 +
 configs/kmtegr1_defconfig| 1 +
 configs/kmtepr2_defconfig| 1 +
 configs/tuge1_defconfig  | 1 +
 configs/tuxx1_defconfig  | 1 +
 include/configs/km/km-mpc8309.h  | 5 -
 include/configs/km/km-mpc832x.h  | 5 -
 include/configs/kmcoge5ne.h  | 5 -
 scripts/config_whitelist.txt | 1 -
 12 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/Kconfig b/arch/powerpc/cpu/mpc83xx/Kconfig
index d58d278c6da8..bcd837508789 100644
--- a/arch/powerpc/cpu/mpc83xx/Kconfig
+++ b/arch/powerpc/cpu/mpc83xx/Kconfig
@@ -188,6 +188,13 @@ source "arch/powerpc/cpu/mpc83xx/sysio/Kconfig"
 source "arch/powerpc/cpu/mpc83xx/arbiter/Kconfig"
 source "arch/powerpc/cpu/mpc83xx/initreg/Kconfig"
 
+config 83XX_PCICLK
+   hex "PCI clock frequency"
+   default 0xDEADBEEF
+   help
+ If required, the PCI clock frequency to use when configuring
+ the host bridge.
+
 config FSL_ELBC
bool
 
diff --git a/configs/kmcoge5ne_defconfig b/configs/kmcoge5ne_defconfig
index 461f2e381224..53f7abc3fd09 100644
--- a/configs/kmcoge5ne_defconfig
+++ b/configs/kmcoge5ne_defconfig
@@ -156,6 +156,7 @@ CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_DBYP_PLL_BYPASSED=y
 CONFIG_LCRR_EADC_2=y
 CONFIG_LCRR_CLKDIV_4=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmopti2_defconfig b/configs/kmopti2_defconfig
index 01709052c1a2..d230638548b8 100644
--- a/configs/kmopti2_defconfig
+++ b/configs/kmopti2_defconfig
@@ -139,6 +139,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmsupx5_defconfig b/configs/kmsupx5_defconfig
index 7802be8af4c8..b0b59262dec3 100644
--- a/configs/kmsupx5_defconfig
+++ b/configs/kmsupx5_defconfig
@@ -119,6 +119,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmtegr1_defconfig b/configs/kmtegr1_defconfig
index e2bf945bc3dc..53aaf6caa25c 100644
--- a/configs/kmtegr1_defconfig
+++ b/configs/kmtegr1_defconfig
@@ -118,6 +118,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/kmtepr2_defconfig b/configs/kmtepr2_defconfig
index 98f613ce16e3..b333769dc4f5 100644
--- a/configs/kmtepr2_defconfig
+++ b/configs/kmtepr2_defconfig
@@ -139,6 +139,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/tuge1_defconfig b/configs/tuge1_defconfig
index 9272a0cb4214..6078b46410af 100644
--- a/configs/tuge1_defconfig
+++ b/configs/tuge1_defconfig
@@ -119,6 +119,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/configs/tuxx1_defconfig b/configs/tuxx1_defconfig
index 38875b39c12f..cc9bbab8c6bb 100644
--- a/configs/tuxx1_defconfig
+++ b/configs/tuxx1_defconfig
@@ -141,6 +141,7 @@ CONFIG_ACR_APARK_MASTER=y
 CONFIG_ACR_PARKM_USB_I2C1_BOOT=y
 CONFIG_LCRR_EADC_1=y
 CONFIG_LCRR_CLKDIV_2=y
+CONFIG_83XX_PCICLK=0x3ef1480
 CONFIG_SYS_LOAD_ADDR=0x10
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_STDOUT_VIA_ALIAS=y
diff --git a/include/configs/km/km-mpc8309.h b/include/configs/km/km-mpc8309.h
index 47a335bcf8ff..98204bd3c692 100644
--- a/include/configs/km/km-mpc8309.h
+++ b/include/configs/km/km-mpc8309.h
@@ -5,11 +5,6 @@
 
 #define CONFIG_KM_DEF_ARCH "arch=ppc_82xx\0"
 
-/*
- * System Clock Setup
- */
-#define CONFIG_83XX_PCICLK 6600
-
 /* QE microcode/firmware address */
 /* between the u-boot partition and env */
 
diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index d985ab7a65a9..54018daa68e6 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -3,11 +3,6 @@
  */
 #define CONFIG_KM8321  /* Keymile PBEC8321 board specific */
 
-/*
- * System Clock Setup
- */
-#define CONFIG_83XX_PCICLK 6600
-
 /*
  * System IO Config
  */
diff --git a/include/configs/kmcoge5ne.h b

[PATCH 02/12] ppc: mpc83xx: Remove unused CONFIG symbols

2021-12-17 Thread Tom Rini
Neither of these symbols are referenced anywhere else, so remove them.

Signed-off-by: Tom Rini 
---
 arch/powerpc/cpu/mpc83xx/start.S | 2 --
 include/configs/km/km-mpc832x.h  | 5 -
 2 files changed, 7 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S
index 91c8778e5033..0944d1910573 100644
--- a/arch/powerpc/cpu/mpc83xx/start.S
+++ b/arch/powerpc/cpu/mpc83xx/start.S
@@ -14,8 +14,6 @@
 #include 
 #include 
 
-#define CONFIG_83XX1   /* needed for Linux kernel header 
files*/
-
 #include 
 #include 
 
diff --git a/include/configs/km/km-mpc832x.h b/include/configs/km/km-mpc832x.h
index 54018daa68e6..aac1e999e40a 100644
--- a/include/configs/km/km-mpc832x.h
+++ b/include/configs/km/km-mpc832x.h
@@ -1,8 +1,3 @@
-/*
- * High Level Configuration Options
- */
-#define CONFIG_KM8321  /* Keymile PBEC8321 board specific */
-
 /*
  * System IO Config
  */
-- 
2.25.1



Re: [PATCH 2/2] fastboot: fb_mmc: Add mfgtool all partition size

2021-12-17 Thread Sean Anderson




On 12/17/21 10:42 AM, Angus Ainslie wrote:

NXP mfgtool uses all to specify the entire partition

Signed-off-by: Angus Ainslie 
---
  drivers/fastboot/fb_mmc.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 2738dc836e..9ebf392252 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -84,6 +84,13 @@ static int do_get_part_info(struct blk_desc **dev_desc, 
const char *name,
/* First try partition names on the default device */
*dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
if (*dev_desc) {
+   if (!strncmp(name, "all", strlen("all"))) {
+   info->blksz = (*dev_desc)->blksz;
+   info->size = (*dev_desc)->lba;
+   info->start = 0;
+   return 0;
+   }
+
ret = part_get_info_by_name(*dev_desc, name, info);
if (ret >= 0)
return ret;



This can be done with "partition" 0. If you need compatibility, use an alias.

--Sean


[PATCH v1 2/5] dts: allow dts files in board directory

2021-12-17 Thread Troy Kisky
Let the board specific dts files live in the board directory.

Signed-off-by: Troy Kisky 
---
 dts/Makefile | 11 +--
 scripts/Makefile.lib |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dts/Makefile b/dts/Makefile
index cb311138295..09b46f9fcfd 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -13,7 +13,9 @@ endif
 ifneq ($(EXT_DTB),)
 DTB := $(EXT_DTB)
 else
-DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
+ifneq "$(ARCH)" "arm64"
+DTB := $(patsubst $(srctree)/%.dts,%.dtb,$(shell find 
"$(srctree)/board/$(BOARDDIR)" $(srctree)/arch/$(ARCH)/dts/ -type f -name 
$(DEVICE_TREE).dts))
+endif
 endif
 
 $(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
@@ -40,8 +42,13 @@ $(DTB): arch-dtbs
/bin/false)
 
 PHONY += arch-dtbs
+ifneq "$(patsubst board/$(BOARDDIR)/%,,$(DTB))" ""
 arch-dtbs:
$(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
+else
+arch-dtbs:
+   $(Q)$(MAKE) $(build)="board/$(BOARDDIR)" dtbs
+endif
 
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
@@ -63,4 +70,4 @@ spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
 clean-files := dt.dtb.S
 
 # Let clean descend into dts directories
-subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 
../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts
+subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts 
../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts 
../$(patsubst $(srctree)/%/,%,$(dir $(shell find $(srctree)/board -type f -name 
"*.dtb")))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 39f03398ed8..18fe42f378f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -183,6 +183,7 @@ u_boot_dtsi = $(strip $(u_boot_dtsi_options_debug) \
 
 # Modified for U-Boot
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc\
+-I$(srctree)/board/$(BOARDDIR)  \
 -I$(srctree)/arch/$(ARCH)/dts   \
 -I$(srctree)/arch/$(ARCH)/dts/include   \
 -Iinclude   \
-- 
2.32.0



[PATCH v1 4/5] genboardcfg: allow defconfigs in board directory

2021-12-17 Thread Troy Kisky
The adds boards whose defconfigs are in the board's directory.

Signed-off-by: Troy Kisky 
---
 tools/genboardscfg.py | 37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py
index 4ee7aa1f891..60e2fe5cf3e 100755
--- a/tools/genboardscfg.py
+++ b/tools/genboardscfg.py
@@ -37,6 +37,13 @@ COMMENT_BLOCK = '''#
 ''' % __file__
 
 ### helper functions ###
+def find_defconfig_in_board_subdir(f):
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in filenames:
+if filename == f:
+return True
+return False
+
 def try_remove(f):
 """Remove a file ignoring 'No such file or directory' error."""
 try:
@@ -76,6 +83,14 @@ def output_is_new(output):
 if ctime < os.path.getctime(filepath):
 return False
 
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in fnmatch.filter(filenames, '*'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+filepath = os.path.join(dirpath, filename)
+if ctime < os.path.getctime(filepath):
+return False
+
 for (dirpath, dirnames, filenames) in os.walk('.'):
 for filename in filenames:
 if (fnmatch.fnmatch(filename, '*~') or
@@ -94,7 +109,8 @@ def output_is_new(output):
 continue
 defconfig = line.split()[6] + '_defconfig'
 if not os.path.exists(os.path.join(CONFIG_DIR, defconfig)):
-return False
+if not find_defconfig_in_board_subdir(defconfig):
+return False
 
 return True
 
@@ -231,6 +247,12 @@ def scan_defconfigs(jobs=1):
 continue
 all_defconfigs.append(os.path.join(dirpath, filename))
 
+for (dirpath, dirnames, filenames) in os.walk('board'):
+for filename in fnmatch.filter(filenames, '*_defconfig'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+all_defconfigs.append(os.path.join(dirpath, filename))
+
 total_boards = len(all_defconfigs)
 processes = []
 queues = []
@@ -346,6 +368,19 @@ class MaintainersDatabase:
 targets = []
 maintainers = []
 status = '-'
+
+front, match, rear = file.partition('board/')
+if match:
+front, match, rear = file.partition('/MAINTAINERS')
+if front:
+for (dirpath, dirnames, filenames) in os.walk(front):
+for filename in fnmatch.filter(filenames, '*_defconfig'):
+if fnmatch.fnmatch(filename, '.*'):
+continue
+front, match, rear = filename.rpartition('_defconfig')
+if match and not rear:
+targets.append(front)
+
 if targets:
 for target in targets:
 self.database[target] = (status, maintainers)
-- 
2.32.0



[PATCH v1 5/5] nitrogen6x: move board specific files to nitrogen6x directory

2021-12-17 Thread Troy Kisky
This makes it clearer which board uses a file.

Signed-off-by: Troy Kisky 
---
 arch/arm/dts/Makefile   |  3 ---
 board/boundary/nitrogen6x/MAINTAINERS   | 13 -
 board/boundary/nitrogen6x/Makefile  | 13 +
 .../boundary/nitrogen6x}/imx6dl-nitrogen6x.dts  |  0
 .../boundary/nitrogen6x}/imx6q-nitrogen6x.dts   |  0
 .../boundary/nitrogen6x}/imx6q-sabrelite.dts|  0
 .../boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi|  0
 .../boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi |  0
 .../boundary/nitrogen6x}/mx6qsabrelite_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6dl2g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6dl_defconfig  |  0
 .../boundary/nitrogen6x}/nitrogen6q2g_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6q_defconfig   |  0
 .../boundary/nitrogen6x}/nitrogen6s1g_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6s_defconfig   |  0
 .../boundary/nitrogen6x}/nitrogen6x.h   |  2 +-
 16 files changed, 14 insertions(+), 17 deletions(-)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6dl-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-sabrelite.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi 
(100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi 
(100%)
 rename {configs => board/boundary/nitrogen6x}/mx6qsabrelite_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s1g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s_defconfig (100%)
 rename {include/configs => board/boundary/nitrogen6x}/nitrogen6x.h (98%)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7f622fedbda..a864a6dd4b8 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -744,7 +744,6 @@ dtb-y += \
imx6dl-mba6a.dtb \
imx6dl-mba6b.dtb \
imx6dl-mamoj.dtb \
-   imx6dl-nitrogen6x.dtb \
imx6dl-pico.dtb \
imx6dl-udoo.dtb \
imx6dl-riotboard.dtb \
@@ -792,13 +791,11 @@ dtb-y += \
imx6q-mba6a.dtb \
imx6q-mba6b.dtb \
imx6q-mccmon6.dtb\
-   imx6q-nitrogen6x.dtb \
imx6q-novena.dtb \
imx6q-pico.dtb \
imx6q-phytec-mira-rdk-nand.dtb \
imx6q-udoo.dtb \
imx6q-sabreauto.dtb \
-   imx6q-sabrelite.dtb \
imx6q-sabresd.dtb \
imx6q-tbs2910.dtb \
imx6q-wandboard-revd1.dtb \
diff --git a/board/boundary/nitrogen6x/MAINTAINERS 
b/board/boundary/nitrogen6x/MAINTAINERS
index 17018d69f64..b11bc1f20d1 100644
--- a/board/boundary/nitrogen6x/MAINTAINERS
+++ b/board/boundary/nitrogen6x/MAINTAINERS
@@ -1,17 +1,4 @@
 NITROGEN6X BOARD
 M: Troy Kisky 
 S: Maintained
-F: arch/arm/dts/imx6dl-nitrogen6x.dts
-F: arch/arm/dts/imx6q-nitrogen6x.dts
-F: arch/arm/dts/imx6q-sabrelite.dts
-F: arch/arm/dts/imx6qdl-nitrogen6x.dtsi
-F: arch/arm/dts/imx6qdl-sabrelite.dtsi
 F: board/boundary/nitrogen6x/
-F: include/configs/nitrogen6x.h
-F: configs/mx6qsabrelite_defconfig
-F: configs/nitrogen6dl_defconfig
-F: configs/nitrogen6dl2g_defconfig
-F: configs/nitrogen6q_defconfig
-F: configs/nitrogen6q2g_defconfig
-F: configs/nitrogen6s_defconfig
-F: configs/nitrogen6s1g_defconfig
diff --git a/board/boundary/nitrogen6x/Makefile 
b/board/boundary/nitrogen6x/Makefile
index c8433bd7488..dd627411fa9 100644
--- a/board/boundary/nitrogen6x/Makefile
+++ b/board/boundary/nitrogen6x/Makefile
@@ -5,3 +5,16 @@
 # Copyright (C) 2013, Boundary Devices 
 
 obj-y  := nitrogen6x.o
+
+dtb-y += imx6dl-nitrogen6x.dtb \
+   imx6q-nitrogen6x.dtb \
+   imx6q-sabrelite.dtb \
+
+# Add any required device tree compiler flags here
+DTC_FLAGS += -a 0x8
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+   @:
+
+clean-files := $(dtb-y)
diff --git a/arch/arm/dts/imx6dl-nitrogen6x.dts 
b/board/boundary/nitrogen6x/imx6dl-nitrogen6x.dts
similarity index 100%
rename from arch/arm/dts/imx6dl-nitrogen6x.dts
rename to board/boundary/nitrogen6x/imx6dl-nitrogen6x.dts
diff --git a/arch/arm/dts/imx6q-nitrogen6x.dts 
b/board/boundary/nitrogen6x/imx6q-nitrogen6x.dts
similarity index 100%
rename from arch/arm/dts/imx6q-nitrogen6x.dts
rename to board/boundary/nitrogen6x/imx6q-nitrogen6x.dts
diff --git a/arch/arm/dts/imx6q-sabrelite.dts 
b/board/boundary/nitrogen6x/imx6q-sabrelite.dts
similarity index 100%
rename from arch/arm/dts/imx6q-sabrelite.dts
rename to board/boundary/nitrogen6x/imx6q-sabrelite.dts
diff --git a/arch/arm/d

[PATCH v1 3/5] scripts: Makefile.autoconf: allow CONFIG_SYS_CONFIG_NAME file to live in board directory

2021-12-17 Thread Troy Kisky
Let the board specific include file live in the board directory.

Signed-off-by: Troy Kisky 
---
 scripts/Makefile.autoconf | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 8a3efdb2db0..6a725a3e2ff 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -103,9 +103,14 @@ define filechk_config_h
echo \#define CONFIG_$$i\
| sed '/=/ {s/=//;q; } ; { s/$$/1/; }'; \
done;   \
-   echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
+   config_boarddir=board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);   \
+   echo \#define CONFIG_BOARDDIR $$config_boarddir;\
echo \#include \;  \
-   echo \#include \; \
+   if [ -f $(srctree)/$$config_boarddir/$(CONFIG_SYS_CONFIG_NAME).h ] ; 
then   \
+   echo \#include 
\"../$$config_boarddir/$(CONFIG_SYS_CONFIG_NAME).h\"; \
+   else\
+   echo \#include \; \
+   fi; \
echo \#include \;\
echo \#include \; \
echo \#include \;)
-- 
2.32.0



[PATCH v1 1/5] kconfig: allow defconfigs to live in board directory

2021-12-17 Thread Troy Kisky
This will reduce the size of the configs directory, and
make it more clear which board directory uses the defconfig
file.

Signed-off-by: Troy Kisky 
---
 scripts/kconfig/Makefile | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 12e525ee31f..307262e00de 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -92,8 +92,15 @@ else
 endif
 endif
 
+%_defconfig: SHELL:=/bin/bash
 %_defconfig: $(obj)/conf
-   $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
+   $(Q)readarray -d '' names < <(find $(srctree)/configs $(srctree)/board 
-type f -name $@ -print0); \
+   if (test $${#names[*]} -eq 1); then \
+   $< $(silent) --defconfig="$${names[0]}" $(Kconfig); \
+   else \
+   echo "$@" not found or ambiguous error; \
+   echo "$${names[@]}"; exit 1; \
+   fi
 
 # Added for U-Boot (backward compatibility)
 %_config: %_defconfig
-- 
2.32.0



[PATCH v1 0/5] Move board specific files to board directory

2021-12-17 Thread Troy Kisky
This series intends to let board specific files live in the boards
directory. The last patch moves files for nitrogen6x.
I have tested it with buildman

./tools/buildman/buildman boundary -b denx_master

But it is likely the more scripts then just tools/genboardscfg.py would
need to be updated.

Troy Kisky (5):
  kconfig: allow defconfigs to live in board directory
  dts: allow dts files in board directory
  scripts: Makefile.autoconf: allow CONFIG_SYS_CONFIG_NAME file to live
in board directory
  genboardcfg: allow defconfigs in board directory
  nitrogen6x: move board specific files to nitrogen6x directory

 arch/arm/dts/Makefile |  3 --
 board/boundary/nitrogen6x/MAINTAINERS | 13 ---
 board/boundary/nitrogen6x/Makefile| 13 +++
 .../nitrogen6x}/imx6dl-nitrogen6x.dts |  0
 .../boundary/nitrogen6x}/imx6q-nitrogen6x.dts |  0
 .../boundary/nitrogen6x}/imx6q-sabrelite.dts  |  0
 .../nitrogen6x}/imx6qdl-nitrogen6x.dtsi   |  0
 .../nitrogen6x}/imx6qdl-sabrelite.dtsi|  0
 .../nitrogen6x}/mx6qsabrelite_defconfig   |  0
 .../nitrogen6x}/nitrogen6dl2g_defconfig   |  0
 .../nitrogen6x}/nitrogen6dl_defconfig |  0
 .../nitrogen6x}/nitrogen6q2g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6q_defconfig |  0
 .../nitrogen6x}/nitrogen6s1g_defconfig|  0
 .../boundary/nitrogen6x}/nitrogen6s_defconfig |  0
 .../boundary/nitrogen6x}/nitrogen6x.h |  2 +-
 dts/Makefile  | 11 +-
 scripts/Makefile.autoconf |  9 -
 scripts/Makefile.lib  |  1 +
 scripts/kconfig/Makefile  |  9 -
 tools/genboardscfg.py | 37 ++-
 21 files changed, 75 insertions(+), 23 deletions(-)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6dl-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-nitrogen6x.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6q-sabrelite.dts (100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-nitrogen6x.dtsi 
(100%)
 rename {arch/arm/dts => board/boundary/nitrogen6x}/imx6qdl-sabrelite.dtsi 
(100%)
 rename {configs => board/boundary/nitrogen6x}/mx6qsabrelite_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6dl_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q2g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6q_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s1g_defconfig (100%)
 rename {configs => board/boundary/nitrogen6x}/nitrogen6s_defconfig (100%)
 rename {include/configs => board/boundary/nitrogen6x}/nitrogen6x.h (98%)

-- 
2.32.0



Timer migration to driver model

2021-12-17 Thread Simon Glass
Hi,

I've sent a patch to set a deadline for migration to CONFIG_TIMER,
i.e. using driver model for timers. This catches quite a lot of
boards, so please take a look.

Regards,
Simon


[PATCH v11] driver: spi: add bcm iproc qspi support

2021-12-17 Thread Roman Bacik
From: Rayagonda Kokatanur 

IPROC qspi driver supports both BSPI and MSPI modes.

Signed-off-by: Rayagonda Kokatanur 
Signed-off-by: Bharat Gooty 
Acked-by: Rayagonda Kokatanur 

Signed-off-by: Roman Bacik 
---

Changes in v11:
- fix condition for readl_poll_timeout in bspi_read_via_raf

Changes in v10:
- remove binding document
- use defined values for delays and timeouts
- replace timer-based logic with readl_poll_timeout
- format selected commands to single line
- remove unnecessary entries from struct bcmspi_priv
- simplify and move bspi strap override to bspi_set_flex_mode

Changes in v9:
- merge bspi_set_4byte_mode to bspi_set_flex_mode
- simplify bspi_set_flex_mode using data from spi_mem_op
- rename mode_4byte to bspi_4byte
- use BIT(x) istead of 1cmd.opcode for BSPI_CMD_AND_MODE_BYTE_REG
- move iproc_qspi.c to spi

Changes in v4:
- move iproc_qspi.c from spi to mtd/spi
- remove iproc_qspi.h
- rename IPROC_QSPI to SPI_FLASH_IPROC

Changes in v3:
- fix warning by including linux/delay.h
- change ofdata_to_platdata to of_to_plat
- change priv_auto_alloc_size to priv_auto

Changes in v2:
- remove include spi-nor.h
- define and use named BITs for writing register values
- remove bspi_set_4byte_mode() method

 drivers/spi/Kconfig  |   6 +
 drivers/spi/Makefile |   1 +
 drivers/spi/iproc_qspi.c | 573 +++
 3 files changed, 580 insertions(+)
 create mode 100644 drivers/spi/iproc_qspi.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d07e9a28af82..faebc212753e 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -178,6 +178,12 @@ config ICH_SPI
  access the SPI NOR flash on platforms embedding this Intel
  ICH IP core.
 
+config IPROC_QSPI
+   bool "Broadcom iProc QSPI Flash Controller driver"
+   help
+ Enable Broadcom iProc QSPI Flash Controller driver.
+ This driver can be used to access the SPI NOR flash.
+
 config KIRKWOOD_SPI
bool "Marvell Kirkwood SPI Driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d2f24bccefd3..869763187062 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_SYNQUACER_SPI) += spi-synquacer.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
+obj-$(CONFIG_IPROC_QSPI) += iproc_qspi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
diff --git a/drivers/spi/iproc_qspi.c b/drivers/spi/iproc_qspi.c
new file mode 100644
index ..0f9c2f9729c4
--- /dev/null
+++ b/drivers/spi/iproc_qspi.c
@@ -0,0 +1,573 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020-2021 Broadcom
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Delay required to change the mode of operation */
+#define BUSY_DELAY_US  1
+#define BUSY_TIMEOUT_US20
+#define DWORD_ALIGNED(a)   (!(((ulong)(a)) & 3))
+
+/* Chip attributes */
+#define QSPI_AXI_CLK   17500
+#define SPBR_MIN   8U
+#define SPBR_MAX   255U
+#define NUM_CDRAM  16U
+
+#define CDRAM_PCS0 2
+#define CDRAM_CONT BIT(7)
+#define CDRAM_BITS_EN  BIT(6)
+#define CDRAM_QUAD_MODEBIT(8)
+#define CDRAM_RBIT_INPUT   BIT(10)
+#define MSPI_SPE   BIT(6)
+#define MSPI_CONT_AFTER_CMDBIT(7)
+
+/* Register fields */
+#define MSPI_SPCR0_MSB_BITS_8  0x0020
+#define BSPI_RAF_CONTROL_START_MASK0x0001
+#define BSPI_RAF_STATUS_SESSION_BUSY_MASK  0x0001
+#define BSPI_RAF_STATUS_FIFO_EMPTY_MASK0x0002
+#define BSPI_STRAP_OVERRIDE_DATA_QUAD_SHIFT3
+#define BSPI_STRAP_OVERRIDE_4BYTE_SHIFT2
+#define BSPI_STRAP_OVERRIDE_DATA_DUAL_SHIFT1
+#define BSPI_STRAP_OVERRIDE_SHIFT  0
+#define BSPI_BPC_DATA_SHIFT0
+#define BSPI_BPC_MODE_SHIFT8
+#define BSPI_BPC_ADDR_SHIFT16
+#define BSPI_BPC_CMD_SHIFT 24
+#define BSPI_BPP_ADDR_SHIFT16
+
+/* MSPI registers */
+#define MSPI_SPCR0_LSB_REG 0x000
+#define MSPI_SPCR0_MSB_REG 0x004
+#define MSPI_SPCR1_LSB_REG 0x008
+#define MSPI_SPCR1_MSB_REG 0x00c
+#define MSPI_NEWQP_REG 0x010
+#define MSPI_ENDQP_REG 0x014
+#define MSPI_SPCR2_REG 

[PATCH v6 21/27] x86: efi: Show the system-table revision

2021-12-17 Thread Simon Glass
Show the revision of this table as it can be important.

Also update the 'efi table' entry to show the actual address of the EFI
table rather than our table that points to it. This saves a step and the
intermediate table has nothing else in it.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix Alo typo in commit message

Changes in v5:
- Fix grammar in commit message

Changes in v3:
- Add new patch to show the system-table revision

 arch/x86/cpu/efi/payload.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index d2aa889a2b9..b7778565b19 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -296,8 +297,14 @@ void setup_efi_info(struct efi_info *efi_info)
 void efi_show_bdinfo(void)
 {
struct efi_entry_systable *table = NULL;
+   struct efi_system_table *sys_table;
int size, ret;
 
ret = efi_info_get(EFIET_SYS_TABLE, (void **)&table, &size);
-   bdinfo_print_num_l("efi_table", (ulong)table);
+   if (!ret) {
+   bdinfo_print_num_l("efi_table", table->sys_table);
+   sys_table = (struct efi_system_table *)(uintptr_t)
+   table->sys_table;
+   bdinfo_print_num_l(" revision", sys_table->fw_revision);
+   }
 }
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH] arm: rmobile: rzg2_beacon: Migrate reset to SYSRESET_PSCI

2021-12-17 Thread Adam Ford
Instead of a custom cpu_reset function, use the sysreset_psci
instead to reduce redundant code clutter.

Signed-off-by: Adam Ford 

diff --git a/board/beacon/beacon-rzg2m/beacon-rzg2m.c 
b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
index df6044a429..4b41c6fdaa 100644
--- a/board/beacon/beacon-rzg2m/beacon-rzg2m.c
+++ b/board/beacon/beacon-rzg2m/beacon-rzg2m.c
@@ -6,7 +6,6 @@
 #include 
 #include 
 #include 
-#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -18,15 +17,6 @@ int board_init(void)
return 0;
 }
 
-#define RST_BASE   0xE616
-#define RST_CA57RESCNT (RST_BASE + 0x40)
-#define RST_CODE   0xA5A5000F
-
-void reset_cpu(void)
-{
-   writel(RST_CODE, RST_CA57RESCNT);
-}
-
 #if IS_ENABLED(CONFIG_MULTI_DTB_FIT)
 int board_fit_config_name_match(const char *name)
 {
diff --git a/configs/rzg2_beacon_defconfig b/configs/rzg2_beacon_defconfig
index 6c48c3b8c9..55d4982721 100644
--- a/configs/rzg2_beacon_defconfig
+++ b/configs/rzg2_beacon_defconfig
@@ -70,6 +70,8 @@ CONFIG_SCIF_CONSOLE=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_RENESAS_RPC_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
-- 
2.32.0



Please pull u-boot-dm/next

2021-12-17 Thread Simon Glass
Hi Tom,

This is for the -next branch.

https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/10299

The following changes since commit b9c9ce8a4064c8d88f714604db856cf1cd2b40b5:

  Merge tag 'u-boot-at91-2022.04-a' of
https://source.denx.de/u-boot/custodians/u-boot-at91 into next (2021-12-17
07:25:34 -0500)

are available in the Git repository at:

  git://git.denx.de/u-boot-dm.git tags/dm-pull-17dec21

for you to fetch changes up to 121cfe5a84d463893bd01da16417ab138f98666a:

  fdtgrep: Handle an empty output tree (2021-12-17 09:44:59 -0700)


binman support for ATF FIP
fdtgrep fixes for empty devicetree


Andy Shevchenko (2):
  binman: Do not pollute source tree when build with `make O=...`
  binman: Use less hard coded magic when inserting new PATH

Ivan Mikhaylov (1):
  iot2050: binman: add missing-msg for blobs

Simon Glass (5):
  binman: Add a utility module for ATF FIP
  binman: Add support for ATF FIP
  Convert CONFIG_PHYSMEM to Kconfig
  fdtgrep: Correct alignment of struct section
  fdtgrep: Handle an empty output tree

 README   |   8 -
 arch/Kconfig |   2 +
 arch/arm/dts/k3-am65-iot2050-boot-image.dtsi |   5 +
 boot/fdt_region.c|  43 ++-
 include/configs/edison.h |   3 -
 include/configs/sandbox.h|   2 -
 include/configs/x86-common.h |   2 -
 include/fdt_region.h |   1 +
 lib/Kconfig  |  10 +
 scripts/config_whitelist.txt |   1 -
 tools/binman/entries.rst | 154 +++
 tools/binman/etype/atf_fip.py| 273 +++
 tools/binman/fip_util.py | 653
++
 tools/binman/fip_util_test.py| 405

 tools/binman/ftest.py| 217 +++
 tools/binman/main.py |  27 +-
 tools/binman/missing-blob-help   |  11 +
 tools/binman/test/203_fip.dts|  21 ++
 tools/binman/test/204_fip_other.dts  |  22 ++
 tools/binman/test/205_fip_no_type.dts|  15 ++
 tools/binman/test/206_fip_uuid.dts   |  22 ++
 tools/binman/test/207_fip_ls.dts |  25 ++
 tools/binman/test/208_fip_replace.dts|  33 +++
 tools/binman/test/209_fip_missing.dts|  19 ++
 tools/binman/test/210_fip_size.dts   |  19 ++
 tools/binman/test/211_fip_bad_align.dts  |  18 ++
 tools/binman/test/212_fip_collection.dts |  24 ++
 tools/fdtgrep.c  |   3 +-
 28 files changed, 2008 insertions(+), 30 deletions(-)
 create mode 100644 tools/binman/etype/atf_fip.py
 create mode 100755 tools/binman/fip_util.py
 create mode 100755 tools/binman/fip_util_test.py
 create mode 100644 tools/binman/test/203_fip.dts
 create mode 100644 tools/binman/test/204_fip_other.dts
 create mode 100644 tools/binman/test/205_fip_no_type.dts
 create mode 100644 tools/binman/test/206_fip_uuid.dts
 create mode 100644 tools/binman/test/207_fip_ls.dts
 create mode 100644 tools/binman/test/208_fip_replace.dts
 create mode 100644 tools/binman/test/209_fip_missing.dts
 create mode 100644 tools/binman/test/210_fip_size.dts
 create mode 100644 tools/binman/test/211_fip_bad_align.dts
 create mode 100644 tools/binman/test/212_fip_collection.dts

Regards,
Simon


[PATCH v6 24/27] x86: efi: Round out the link script for 64-bit EFI

2021-12-17 Thread Simon Glass
Make sure the linker lists are in the right place and drop the eh_frame
section, which is not needed.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to round out the link script for 64-bit EFI

 arch/x86/lib/elf_x86_64_efi.lds | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds
index b436429b33e..75727400aa4 100644
--- a/arch/x86/lib/elf_x86_64_efi.lds
+++ b/arch/x86/lib/elf_x86_64_efi.lds
@@ -63,6 +63,7 @@ SECTIONS
*(.rela.data*)
*(.rela.got)
*(.rela.stab)
+*(.rela.u_boot_list*)
}
 
. = ALIGN(4096);
@@ -70,9 +71,11 @@ SECTIONS
. = ALIGN(4096);
.dynstr : { *(.dynstr) }
. = ALIGN(4096);
+
+/DISCARD/ : { *(.eh_frame) }
+
.ignored.reloc : {
*(.rela.reloc)
-   *(.eh_frame)
*(.note.GNU-stack)
}
 
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 23/27] x86: efi: Tweak the code used for the 64-bit EFI app

2021-12-17 Thread Simon Glass
Add an empty CPU init function to avoid fiddling with low-level CPU
features in the app. Set up the C runtime correctly for 64-bit use
and avoid clearing BSS, since this is done by EFI when U-Boot is loaded.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to tweak the code used for the 64-bit EFI app

 arch/x86/cpu/x86_64/cpu.c | 5 +
 arch/x86/lib/Makefile | 5 ++---
 arch/x86/lib/relocate.c   | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c
index a3674e8e29a..6a387612916 100644
--- a/arch/x86/cpu/x86_64/cpu.c
+++ b/arch/x86/cpu/x86_64/cpu.c
@@ -45,3 +45,8 @@ int cpu_phys_address_size(void)
 {
return CONFIG_CPU_ADDR_BITS;
 }
+
+int x86_cpu_init_f(void)
+{
+   return 0;
+}
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 18757b29aa9..e5235b7c4f4 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -65,9 +65,8 @@ endif
 
 lib-$(CONFIG_USE_PRIVATE_LIBGCC) += div64.o
 
-ifeq ($(CONFIG_$(SPL_)X86_64),)
-obj-$(CONFIG_EFI_APP) += crt0_ia32_efi.o reloc_ia32_efi.o
-endif
+obj-$(CONFIG_EFI_APP_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o
+obj-$(CONFIG_EFI_APP_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o
 
 ifneq ($(CONFIG_EFI_STUB),)
 
diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c
index 6fe51516477..9060d19d46a 100644
--- a/arch/x86/lib/relocate.c
+++ b/arch/x86/lib/relocate.c
@@ -35,6 +35,7 @@ int copy_uboot_to_ram(void)
return 0;
 }
 
+#ifndef CONFIG_EFI_APP
 int clear_bss(void)
 {
ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
@@ -46,6 +47,7 @@ int clear_bss(void)
 
return 0;
 }
+#endif
 
 #if CONFIG_IS_ENABLED(X86_64)
 static void do_elf_reloc_fixups64(unsigned int text_base, uintptr_t size,
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 26/27] x86: efi: Set the correct link flags for the 64-bit EFI app

2021-12-17 Thread Simon Glass
At present some 32-bit settings are used with the 64-bit app. Fix this by
separating out the two cases.

Be careful not to break the 64-bit payload, which needs to build a 64-bit
EFI stub with a 32-bit U-Boot.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to set the correct link flags for the 64-bit EFI app

 arch/x86/config.mk | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 589f2aed2bc..889497b6bd7 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -20,6 +20,11 @@ IS_32BIT := y
 endif
 endif
 
+EFI_IS_32BIT := $(IS_32BIT)
+ifdef CONFIG_EFI_STUB_64BIT
+EFI_IS_32BIT :=
+endif
+
 ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
@@ -44,8 +49,14 @@ CFLAGS_EFI := -fpic -fshort-wchar
 # Compiler flags to be removed when building UEFI applications
 CFLAGS_NON_EFI := -mregparm=3 -fstack-protector-strong
 
-ifeq ($(CONFIG_EFI_STUB_64BIT),)
+ifeq ($(IS_32BIT),y)
+EFIPAYLOAD_BFDARCH = i386
+else
 CFLAGS_EFI += $(call cc-option, -mno-red-zone)
+EFIPAYLOAD_BFDARCH = x86_64
+endif
+
+ifeq ($(EFI_IS_32BIT),y)
 EFIARCH = ia32
 EFIPAYLOAD_BFDTARGET = elf32-i386
 else
@@ -53,8 +64,6 @@ EFIARCH = x86_64
 EFIPAYLOAD_BFDTARGET = elf64-x86-64
 endif
 
-EFIPAYLOAD_BFDARCH = i386
-
 LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
 EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
 OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 27/27] efi: Build the 64-bit app properly

2021-12-17 Thread Simon Glass
Now that the linker crash is resolved, build the 64-bit EFI app, including
all the required code.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to build the 64-bit app properly
- Add various patches to fix up the 64-bit app so that it boots

Changes in v2:
- Add new patch to support the efi command in the app

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 18fe6fdb440..83f2e04c225 100644
--- a/Makefile
+++ b/Makefile
@@ -1772,9 +1772,9 @@ else
 quiet_cmd_u-boot__ ?= LD  $@
   cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@  
\
-T u-boot.lds $(u-boot-init)
\
-   $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive)  
\
+   --whole-archive 
\
$(u-boot-main)  
\
-   $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive)   
\
+   --no-whole-archive  
\
$(PLATFORM_LIBS) -Map u-boot.map;   
\
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 25/27] x86: efi: Don't use the 64-bit link script for the EFI app

2021-12-17 Thread Simon Glass
That script is not intended for use with EFI, so update the logic to avoid
using it.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to avoid using the 64-bit link script for the EFI app

 arch/x86/cpu/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/cpu/config.mk b/arch/x86/cpu/config.mk
index d3033b41603..87e242a2065 100644
--- a/arch/x86/cpu/config.mk
+++ b/arch/x86/cpu/config.mk
@@ -9,7 +9,7 @@ LDPPFLAGS += -DRESET_VEC_LOC=$(CONFIG_RESET_VEC_LOC)
 LDPPFLAGS += -DSTART_16=$(CONFIG_SYS_X86_START16)
 
 ifdef CONFIG_X86_64
-ifndef CONFIG_SPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_EFI_APP),)
 LDSCRIPT = $(srctree)/arch/x86/cpu/u-boot-64.lds
 endif
 endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 20/27] efi: Support the efi command in the app

2021-12-17 Thread Simon Glass
At present the 'efi' command only works in the EFI payload. Update it to
work in the app too, so the memory map can be examined.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 cmd/Makefile  |  2 +-
 cmd/efi.c | 48 ---
 include/efi.h | 15 +++
 lib/efi/efi_app.c | 33 
 4 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/cmd/Makefile b/cmd/Makefile
index 891819ae0f6..df50625bde7 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -58,7 +58,7 @@ obj-$(CONFIG_CMD_EXTENSION) += extension_board.o
 obj-$(CONFIG_CMD_ECHO) += echo.o
 obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
 obj-$(CONFIG_CMD_EEPROM) += eeprom.o
-obj-$(CONFIG_EFI_STUB) += efi.o
+obj-$(CONFIG_EFI) += efi.o
 obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
 obj-$(CONFIG_CMD_ELF) += elf.o
 obj-$(CONFIG_HUSH_PARSER) += exit.o
diff --git a/cmd/efi.c b/cmd/efi.c
index d2400acbbba..c0384e0db28 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static const char *const type_name[] = {
"reserved",
"loader_code",
@@ -217,37 +219,53 @@ static void efi_print_mem_table(struct efi_mem_desc 
*desc, int desc_size,
 static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
-   struct efi_mem_desc *desc;
-   struct efi_entry_memmap *map;
+   struct efi_mem_desc *orig, *desc;
+   uint version, key;
+   int desc_size;
int size, ret;
bool skip_bs;
 
skip_bs = !argc || *argv[0] != 'a';
-   ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
-   switch (ret) {
-   case -ENOENT:
-   printf("No EFI table available\n");
-   goto done;
-   case -EPROTONOSUPPORT:
-   printf("Incorrect EFI table version\n");
-   goto done;
+   if (IS_ENABLED(CONFIG_EFI_APP)) {
+   ret = efi_get_mmap(&orig, &size, &key, &desc_size, &version);
+   if (ret) {
+   printf("Cannot read memory map (err=%d)\n", ret);
+   return CMD_RET_FAILURE;
+   }
+   } else {
+   struct efi_entry_memmap *map;
+
+   ret = efi_info_get(EFIET_MEMORY_MAP, (void **)&map, &size);
+   switch (ret) {
+   case -ENOENT:
+   printf("No EFI table available\n");
+   goto done;
+   case -EPROTONOSUPPORT:
+   printf("Incorrect EFI table version\n");
+   goto done;
+   }
+   orig = map->desc;
+   desc_size = map->desc_size;
+   version = map->version;
}
-   printf("EFI table at %lx, memory map %p, size %x, version %x, descr. 
size %#x\n",
-  gd->arch.table, map, size, map->version, map->desc_size);
-   if (map->version != EFI_MEM_DESC_VERSION) {
+   printf("EFI table at %lx, memory map %p, size %x, key %x, version %x, 
descr. size %#x\n",
+  gd->arch.table, orig, size, key, version, desc_size);
+   if (version != EFI_MEM_DESC_VERSION) {
printf("Incorrect memory map version\n");
ret = -EPROTONOSUPPORT;
goto done;
}
 
-   desc = efi_build_mem_table(map->desc, size, map->desc_size, skip_bs);
+   desc = efi_build_mem_table(orig, size, desc_size, skip_bs);
if (!desc) {
ret = -ENOMEM;
goto done;
}
 
-   efi_print_mem_table(desc, map->desc_size, skip_bs);
+   efi_print_mem_table(desc, desc_size, skip_bs);
free(desc);
+   if (IS_ENABLED(CONFIG_EFI_APP))
+   free(orig);
 done:
if (ret)
printf("Error: %d\n", ret);
diff --git a/include/efi.h b/include/efi.h
index d6d73c5fab4..bd23a867136 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -610,4 +610,19 @@ int efi_store_memory_map(struct efi_priv *priv);
  */
 int efi_call_exit_boot_services(void);
 
+/**
+ * efi_get_mmap() - Get the memory map from EFI
+ *
+ * This is used in the app. The caller must free *@descp when done
+ *
+ * @descp: Returns allocated pointer to EFI memory map table
+ * @sizep: Returns size of table in bytes
+ * @keyp:  Returns memory-map key
+ * @desc_sizep:Returns size of each @desc_base record
+ * @versionp:  Returns version number of memory map
+ * @return 0 on success, -ve on error
+ */
+int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
+int *desc_sizep, uint *versionp);
+
 #endif /* _LINUX_EFI_H */
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index b2d2de1dc3a..d798bf98ca6 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -32,6 +32,39 @@ int efi_info_get(enum efi_entry_t type, void **datap, int 
*sizep)
return -ENOSYS;
 }
 
+int efi_get_mmap(struct efi_mem_

[PATCH v6 22/27] x86: efi: Don't set up global_data again with EFI

2021-12-17 Thread Simon Glass
Since EFI does not relocate and uses the same global_data pointer
throughout the board-init process, drop this unnecessary setup, to avoid
a hang.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to avoid setting up global_data again with EFI

 common/board_r.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 31a59c585a8..8b5948100b1 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -817,9 +817,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 * TODO(s...@chromium.org): Consider doing this for all archs, or
 * dropping the new_gd parameter.
 */
-#if CONFIG_IS_ENABLED(X86_64)
-   arch_setup_gd(new_gd);
-#endif
+   if (CONFIG_IS_ENABLED(X86_64) && !IS_ENABLED(CONFIG_EFI_APP))
+   arch_setup_gd(new_gd);
 
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
int i;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 19/27] x86: efi: Update efi_get_next_mem_desc() to avoid needing a map

2021-12-17 Thread Simon Glass
At present this function requires a pointer to struct efi_entry_memmap
but the only field used in there is the desc_size. We want to be able
to use it from the app, so update it to use desc_size directly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/cpu/efi/payload.c |  8 
 cmd/efi.c  | 34 ++
 include/efi.h  |  4 ++--
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index 3a9f7d72868..d2aa889a2b9 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -50,7 +50,7 @@ ulong board_get_usable_ram_top(ulong total_size)
 
end = (struct efi_mem_desc *)((ulong)map + size);
desc = map->desc;
-   for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->type != EFI_CONVENTIONAL_MEMORY ||
desc->physical_start >= 1ULL << 32)
continue;
@@ -88,7 +88,7 @@ int dram_init(void)
end = (struct efi_mem_desc *)((ulong)map + size);
gd->ram_size = 0;
desc = map->desc;
-   for (; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   for (; desc < end; desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->type < EFI_MMAP_IO)
gd->ram_size += desc->num_pages << EFI_PAGE_SHIFT;
}
@@ -113,7 +113,7 @@ int dram_init_banksize(void)
desc = map->desc;
for (num_banks = 0;
 desc < end && num_banks < CONFIG_NR_DRAM_BANKS;
-desc = efi_get_next_mem_desc(map, desc)) {
+desc = efi_get_next_mem_desc(desc, map->desc_size)) {
/*
 * We only use conventional memory and ignore
 * anything less than 1MB.
@@ -196,7 +196,7 @@ unsigned int install_e820_map(unsigned int max_entries,
 
end = (struct efi_mem_desc *)((ulong)map + size);
for (desc = map->desc; desc < end;
-desc = efi_get_next_mem_desc(map, desc)) {
+desc = efi_get_next_mem_desc(desc, map->desc_size)) {
if (desc->num_pages == 0)
continue;
 
diff --git a/cmd/efi.c b/cmd/efi.c
index f2ed26bd4b2..d2400acbbba 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -75,16 +75,17 @@ static int h_cmp_entry(const void *v1, const void *v2)
 /**
  * efi_build_mem_table() - make a sorted copy of the memory table
  *
- * @map:   Pointer to EFI memory map table
+ * @desc_base: Pointer to EFI memory map table
  * @size:  Size of table in bytes
+ * @desc_size: Size of each @desc_base record
  * @skip_bs:   True to skip boot-time memory and merge it with conventional
  * memory. This will significantly reduce the number of table
  * entries.
  * Return: pointer to the new table. It should be freed with free() by the
  * caller.
  */
-static void *efi_build_mem_table(struct efi_entry_memmap *map, int size,
-bool skip_bs)
+static void *efi_build_mem_table(struct efi_mem_desc *desc_base, int size,
+int desc_size, bool skip_bs)
 {
struct efi_mem_desc *desc, *end, *base, *dest, *prev;
int count;
@@ -95,15 +96,16 @@ static void *efi_build_mem_table(struct efi_entry_memmap 
*map, int size,
debug("%s: Cannot allocate %#x bytes\n", __func__, size);
return NULL;
}
-   end = (struct efi_mem_desc *)((ulong)map + size);
-   count = ((ulong)end - (ulong)map->desc) / map->desc_size;
-   memcpy(base, map->desc, (ulong)end - (ulong)map->desc);
-   qsort(base, count, map->desc_size, h_cmp_entry);
+   end = (void *)desc_base + size;
+   count = ((ulong)end - (ulong)desc_base) / desc_size;
+   memcpy(base, desc_base, (ulong)end - (ulong)desc_base);
+   qsort(base, count, desc_size, h_cmp_entry);
prev = NULL;
addr = 0;
dest = base;
-   end = (struct efi_mem_desc *)((ulong)base + count * map->desc_size);
-   for (desc = base; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
+   end = (struct efi_mem_desc *)((ulong)base + count * desc_size);
+   for (desc = base; desc < end;
+desc = efi_get_next_mem_desc(desc, desc_size)) {
bool merge = true;
u32 type = desc->type;
 
@@ -116,7 +118,7 @@ static void *efi_build_mem_table(struct efi_entry_memmap 
*map, int size,
if (skip_bs && is_boot_services(desc->type))
type = EFI_CONVENTIONAL_MEMORY;
 
-   memcpy(dest, desc, map->desc_size);
+   memcpy(dest, desc, desc_size);
dest->type = type;
if (!skip_bs || !prev)
merge = false;
@@ -131,7 +133,7 @@ static void *efi_build_mem_table(struct 

[PATCH v6 17/27] efi: Show when allocated pages are used

2021-12-17 Thread Simon Glass
Add a message here so that both paths of memory allocation are reported.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Use log_info() instead of printf()

 lib/efi/efi_app.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 2a6740b836a..b2d2de1dc3a 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv *priv)
ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
   priv->image_data_type, pages, &addr);
if (ret) {
-   printf("(using pool %lx) ", ret);
+   log_info("(using pool %lx) ", ret);
priv->ram_base = (ulong)efi_malloc(priv, CONFIG_EFI_RAM_SIZE,
   &ret);
if (!priv->ram_base)
return ret;
priv->use_pool_for_malloc = true;
} else {
+   log_info("(using allocated RAM address %lx) ", (ulong)addr);
priv->ram_base = addr;
}
gd->ram_size = pages << 12;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 18/27] efi: Allow easy selection of serial-only operation

2021-12-17 Thread Simon Glass
Add info about how to select vidconsole or serial.

Also set up a demo boot command.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add a better boot command too

 include/configs/efi-x86_app.h | 25 +
 1 file changed, 25 insertions(+)

diff --git a/include/configs/efi-x86_app.h b/include/configs/efi-x86_app.h
index 6061a6db0a4..33afb7ca0f9 100644
--- a/include/configs/efi-x86_app.h
+++ b/include/configs/efi-x86_app.h
@@ -10,8 +10,33 @@
 
 #undef CONFIG_TPM_TIS_BASE_ADDRESS
 
+/*
+ * Select the output device: Put an 'x' prefix before one of these to disable 
it
+ */
+
+/*
+ * Video output - can normally continue after exit_boot_services has been
+ * called, since output to the display does not require EFI services at that
+ * point. U-Boot sets up the console memory and does its own drawing.
+ */
 #define CONFIG_STD_DEVICES_SETTINGS"stdin=serial\0" \
"stdout=vidconsole\0" \
"stderr=vidconsole\0"
 
+/*
+ * Serial output with no console. Run qemu with:
+ *
+ *-display none -serial mon:stdio
+ *
+ * This will hang or fail to output on the console after exit_boot_services is
+ * called.
+ */
+#define xCONFIG_STD_DEVICES_SETTINGS   "stdin=serial\0" \
+   "stdout=serial\0" \
+   "stderr=serial\0"
+
+#undef CONFIG_BOOTCOMMAND
+
+#define CONFIG_BOOTCOMMAND "part list efi 0; fatls efi 0:1"
+
 #endif
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 14/27] efi: Move exit_boot_services into a function

2021-12-17 Thread Simon Glass
At present this code is inline in the app and stub. But they do the same
thing. The difference is that the stub does it immediately and the app
doesn't want to do it until the end (when it boots a kernel) or not at
all, if returning to UEFI.

Move it into a function so it can be called as needed.

Also store the memory map so that it can be accessed within the app if
needed.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix typo in function comment

Changes in v2:
- Add a sentence about what the patch does

 include/efi.h  | 32 ++
 lib/efi/efi.c  | 68 ++
 lib/efi/efi_app.c  |  3 ++
 lib/efi/efi_stub.c | 66 
 4 files changed, 114 insertions(+), 55 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index ca301db7cb5..ca4afaf524b 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -407,6 +407,12 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
  * @sys_table: Pointer to system table
  * @boot: Pointer to boot-services table
  * @run: Pointer to runtime-services table
+ * @memmap_key: Key returned from get_memory_map()
+ * @memmap_desc: List of memory-map records
+ * @memmap_alloc: Amount of memory allocated for memory map list
+ * @memmap_size Size of memory-map list in bytes
+ * @memmap_desc_size: Size of an individual memory-map record, in bytes
+ * @memmap_version: Memory-map version
  *
  * @use_pool_for_malloc: true if all allocation should go through the EFI 
'pool'
  * methods allocate_pool() and free_pool(); false to use 'pages' methods
@@ -424,6 +430,12 @@ struct efi_priv {
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
+   efi_uintn_t memmap_key;
+   struct efi_mem_desc *memmap_desc;
+   efi_uintn_t memmap_alloc;
+   efi_uintn_t memmap_size;
+   efi_uintn_t memmap_desc_size;
+   u32 memmap_version;
 
/* app: */
bool use_pool_for_malloc;
@@ -574,4 +586,24 @@ void efi_putc(struct efi_priv *priv, const char ch);
  */
 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
 
+/**
+ * efi_store_memory_map() - Collect the memory-map info from EFI
+ *
+ * Collect the memory info and store it for later use, e.g. in calling
+ * exit_boot_services()
+ *
+ * @priv:  Pointer to private EFI structure
+ * @return 0 if OK, non-zero on error
+ */
+int efi_store_memory_map(struct efi_priv *priv);
+
+/**
+ * efi_call_exit_boot_services() - Handle the exit-boot-service procedure
+ *
+ * Tell EFI we don't want their boot services anymore
+ *
+ * Return: 0 if OK, non-zero on error
+ */
+int efi_call_exit_boot_services(void);
+
 #endif /* _LINUX_EFI_H */
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index cd6bf47b180..20da88c9151 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -135,3 +135,71 @@ void efi_free(struct efi_priv *priv, void *ptr)
 
boot->free_pool(ptr);
 }
+
+int efi_store_memory_map(struct efi_priv *priv)
+{
+   struct efi_boot_services *boot = priv->sys_table->boottime;
+   efi_uintn_t size, desc_size;
+   efi_status_t ret;
+
+   /* Get the memory map so we can switch off EFI */
+   size = 0;
+   ret = boot->get_memory_map(&size, NULL, &priv->memmap_key,
+  &priv->memmap_desc_size,
+  &priv->memmap_version);
+   if (ret != EFI_BUFFER_TOO_SMALL) {
+   printhex2(EFI_BITS_PER_LONG);
+   putc(' ');
+   printhex2(ret);
+   puts(" No memory map\n");
+   return ret;
+   }
+   /*
+* Since doing a malloc() may change the memory map and also we want to
+* be able to read the memory map in efi_call_exit_boot_services()
+* below, after more changes have happened
+*/
+   priv->memmap_alloc = size + 1024;
+   priv->memmap_size = priv->memmap_alloc;
+   priv->memmap_desc = efi_malloc(priv, size, &ret);
+   if (!priv->memmap_desc) {
+   printhex2(ret);
+   puts(" No memory for memory descriptor\n");
+   return ret;
+   }
+
+   ret = boot->get_memory_map(&priv->memmap_size, priv->memmap_desc,
+  &priv->memmap_key, &desc_size,
+  &priv->memmap_version);
+   if (ret) {
+   printhex2(ret);
+   puts(" Can't get memory map\n");
+   return ret;
+   }
+
+   return 0;
+}
+
+int efi_call_exit_boot_services(void)
+{
+   struct efi_priv *priv = efi_get_priv();
+   const struct efi_boot_services *boot = priv->boot;
+   efi_uintn_t size;
+   u32 version;
+   efi_status_t ret;
+
+   size = priv->memmap_alloc;
+   ret = boot->get_memory_map(&size, priv->memmap_desc,
+  &priv->memmap_key,
+  &priv->memmap_desc_size

[PATCH v6 13/27] efi: Share struct efi_priv between the app and stub code

2021-12-17 Thread Simon Glass
At present each of these has its own static variable and helper functions.
Move them into a shared file.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/efi.h  | 21 +
 lib/efi/efi.c  | 29 +
 lib/efi/efi_app.c  | 21 ++---
 lib/efi/efi_stub.c |  7 ---
 4 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/include/efi.h b/include/efi.h
index 6622a733e6e..ca301db7cb5 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -474,6 +474,27 @@ extern char _binary_u_boot_bin_start[], 
_binary_u_boot_bin_end[];

EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
EFI_VARIABLE_APPEND_WRITE)
 
+/**
+ * efi_get_priv() - Get access to the EFI-private information
+ *
+ * This struct it used by both the stub and the app to record things about the
+ * EFI environment. It is not available in U-Boot proper after the stub has
+ * jumped there. Use efi_info_get() to obtain info in that case.
+ *
+ * @return pointer to private info
+ */
+struct efi_priv *efi_get_priv(void);
+
+/**
+ * efi_set_priv() - Set up a pointer to the EFI-private information
+ *
+ * This is called in the stub and app to record the location of this
+ * information.
+ *
+ * @priv: New location of private data
+ */
+void efi_set_priv(struct efi_priv *priv);
+
 /**
  * efi_get_sys_table() - Get access to the main EFI system table
  *
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index 69e52e45748..cd6bf47b180 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
+ * Functions shared by the app and stub
+ *
  * Copyright (c) 2015 Google, Inc
  *
  * EFI information obtained here:
@@ -17,6 +19,33 @@
 #include 
 #include 
 
+static struct efi_priv *global_priv;
+
+struct efi_priv *efi_get_priv(void)
+{
+   return global_priv;
+}
+
+void efi_set_priv(struct efi_priv *priv)
+{
+   global_priv = priv;
+}
+
+struct efi_system_table *efi_get_sys_table(void)
+{
+   return global_priv->sys_table;
+}
+
+struct efi_boot_services *efi_get_boot(void)
+{
+   return global_priv->boot;
+}
+
+unsigned long efi_get_ram_base(void)
+{
+   return global_priv->ram_base;
+}
+
 /*
  * Global declaration of gd.
  *
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 6a71cef7acb..122945e1ddd 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -27,23 +27,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct efi_priv *global_priv;
-
-struct efi_system_table *efi_get_sys_table(void)
-{
-   return global_priv->sys_table;
-}
-
-struct efi_boot_services *efi_get_boot(void)
-{
-   return global_priv->boot;
-}
-
-unsigned long efi_get_ram_base(void)
-{
-   return global_priv->ram_base;
-}
-
 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
 {
return -ENOSYS;
@@ -337,7 +320,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
/* Set up access to EFI data structures */
efi_init(priv, "App", image, sys_table);
 
-   global_priv = priv;
+   efi_set_priv(priv);
 
/*
 * Set up the EFI debug UART so that printf() works. This is
@@ -363,7 +346,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
 
 static void efi_exit(void)
 {
-   struct efi_priv *priv = global_priv;
+   struct efi_priv *priv = efi_get_priv();
 
free_memory(priv);
printf("U-Boot EFI exiting\n");
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index e8a594cb2aa..b4e9f49a6df 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -31,7 +31,6 @@
 #error "This file needs to be ported for use on architectures"
 #endif
 
-static struct efi_priv *global_priv;
 static bool use_uart;
 
 struct __packed desctab_info {
@@ -63,6 +62,8 @@ void _debug_uart_init(void)
 
 void putc(const char ch)
 {
+   struct efi_priv *priv = efi_get_priv();
+
if (ch == '\n')
putc('\r');
 
@@ -73,7 +74,7 @@ void putc(const char ch)
;
outb(ch, (ulong)&com_port->thr);
} else {
-   efi_putc(global_priv, ch);
+   efi_putc(priv, ch);
}
 }
 
@@ -313,7 +314,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
puts(" efi_init() failed\n");
return ret;
}
-   global_priv = priv;
+   efi_set_priv(priv);
 
cs32 = get_codeseg32();
if (cs32 < 0)
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 15/27] efi: Check for failure when initing the app

2021-12-17 Thread Simon Glass
The stub checks for failure with efi_init(). Add this for the app as well.
It is unlikely that anything can be done, but we may as well stop.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Use 'U-Boot' instead of 'ARP' typo

 lib/efi/efi_app.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 2024ecc37b6..2a6740b836a 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -318,8 +318,11 @@ efi_status_t EFIAPI efi_main(efi_handle_t image,
efi_status_t ret;
 
/* Set up access to EFI data structures */
-   efi_init(priv, "App", image, sys_table);
-
+   ret = efi_init(priv, "App", image, sys_table);
+   if (ret) {
+   printf("Failed to set up U-Boot: err=%lx\n", ret);
+   return ret;
+   }
efi_set_priv(priv);
 
/*
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 16/27] efi: Mention that efi_info_get() is only used in the stub

2021-12-17 Thread Simon Glass
This provides access to EFI tables after U-Boot has exited boot services.
It is not needed in the app since boot services remain alive and we can
just call them whenever needed.

Add a comment to explain this.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix 'stuff' typo in comment
- Update to 'This function' in comment

Changes in v2:
- Fix 'as' typo

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

diff --git a/include/efi.h b/include/efi.h
index ca4afaf524b..0aa07193640 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -578,6 +578,10 @@ void efi_putc(struct efi_priv *priv, const char ch);
 /**
  * efi_info_get() - get an entry from an EFI table
  *
+ * This function is called from U-Boot proper to read information set up by the
+ * EFI stub. It can only be used when running from the EFI stub, not when 
U-Boot
+ * is running as an app.
+ *
  * @type:  Entry type to search for
  * @datap: Returns pointer to entry data
  * @sizep: Returns pointer to entry size
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 12/27] efi: Add a few comments to the stub

2021-12-17 Thread Simon Glass
Comment some functions that need more information.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Fix comment style in setup_info_table()

 lib/efi/efi_stub.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index b3393e47fae..e8a594cb2aa 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -225,6 +225,22 @@ static int get_codeseg32(void)
return cs32;
 }
 
+/**
+ * setup_info_table() - sets up a table containing information from EFI
+ *
+ * We must call exit_boot_services() before jumping out of the stub into U-Boot
+ * proper, so that U-Boot has full control of peripherals, memory, etc.
+ *
+ * Once we do this, we cannot call any boot-services functions so we must find
+ * out everything we need to before doing that.
+ *
+ * Set up a struct efi_info_hdr table which can hold various records (e.g.
+ * struct efi_entry_memmap) with information obtained from EFI.
+ *
+ * @priv: Pointer to our private information which contains the list
+ * @size: Size of the table to allocate
+ * Return: 0 if OK, non-zero on error
+ */
 static int setup_info_table(struct efi_priv *priv, int size)
 {
struct efi_info_hdr *info;
@@ -248,6 +264,12 @@ static int setup_info_table(struct efi_priv *priv, int 
size)
return 0;
 }
 
+/**
+ * add_entry_addr() - Add a new entry to the efi_info list
+ *
+ * @priv: Pointer to our private information which contains the list
+ *
+ */
 static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
   void *ptr1, int size1, void *ptr2, int size2)
 {
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 09/27] efi: Drop device_path from struct efi_priv

2021-12-17 Thread Simon Glass
This is not used anywhere drop it.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Move device_path path change to its own patch

 include/efi.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/efi.h b/include/efi.h
index 908c5dc6ebd..77e599c256e 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -402,7 +402,6 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
 
 struct efi_priv {
efi_handle_t parent_image;
-   struct efi_device_path *device_path;
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 11/27] efi: Fix ll_boot_init() operation with the app

2021-12-17 Thread Simon Glass
This should return false when the EFI app is running, since UEFI has done
the required low-level init. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 include/init.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/init.h b/include/init.h
index f2cd46dead0..3ce7b8b95bd 100644
--- a/include/init.h
+++ b/include/init.h
@@ -15,7 +15,7 @@
 #include 
 
 /* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */
-#ifdef CONFIG_EFI_STUB
+#ifdef CONFIG_EFI
 #define ll_boot_init() false
 #else
 #include 
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 10/27] efi: Add comments to struct efi_priv

2021-12-17 Thread Simon Glass
This structure is uncommented. Fix it.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Drop comments that confuse sphinx
- Move device_path path change to its own patch

 include/efi.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/include/efi.h b/include/efi.h
index 77e599c256e..6622a733e6e 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -400,14 +400,37 @@ static inline struct efi_mem_desc *efi_get_next_mem_desc(
return (struct efi_mem_desc *)((ulong)desc + map->desc_size);
 }
 
+/**
+ * struct efi_priv - Information about the environment provided by EFI
+ *
+ * @parent_image: image passed into the EFI app or stub
+ * @sys_table: Pointer to system table
+ * @boot: Pointer to boot-services table
+ * @run: Pointer to runtime-services table
+ *
+ * @use_pool_for_malloc: true if all allocation should go through the EFI 
'pool'
+ * methods allocate_pool() and free_pool(); false to use 'pages' methods
+ * allocate_pages() and free_pages()
+ * @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE)
+ * @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE)
+ *
+ * @info: Header of the info list, holding info collected by the stub and 
passed
+ * to U-Boot
+ * @info_size: Size of the info list, in bytes from @info
+ * @next_hdr: Pointer to where to put the next header when adding to the list
+ */
 struct efi_priv {
efi_handle_t parent_image;
struct efi_system_table *sys_table;
struct efi_boot_services *boot;
struct efi_runtime_services *run;
+
+   /* app: */
bool use_pool_for_malloc;
unsigned long ram_base;
unsigned int image_data_type;
+
+   /* stub: */
struct efi_info_hdr *info;
unsigned int info_size;
void *next_hdr;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 04/27] efi: Locate all block devices in the app

2021-12-17 Thread Simon Glass
When starting the app, locate all block devices and make them available
to U-Boot. This allows listing partitions and accessing files in
filesystems.

EFI also has the concept of 'disks', meaning boot media. For now, this
is not obviously useful in U-Boot, but add code to at least locate these.
This can be expanded later as needed.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Add comment for dm_scan_other()
- Add comment for free_memory()
- Drop setup_disks() as U-Boot does not support it
- Fix 'have have' typo
- Update comment format for devpath_is_partition()

Changes in v2:
- Don't export efi_bind_block()
- Only bind devices for media devices, not for partitions
- Show devices that are processed
- Store device path in struct efi_media_plat
- Update documentation

 doc/develop/uefi/u-boot_on_efi.rst |   4 +-
 include/efi.h  |   6 +-
 include/efi_api.h  |  15 ++
 lib/efi/efi_app.c  | 216 +
 4 files changed, 236 insertions(+), 5 deletions(-)

diff --git a/doc/develop/uefi/u-boot_on_efi.rst 
b/doc/develop/uefi/u-boot_on_efi.rst
index 5f2f850f071..8f81b799072 100644
--- a/doc/develop/uefi/u-boot_on_efi.rst
+++ b/doc/develop/uefi/u-boot_on_efi.rst
@@ -265,9 +265,7 @@ This work could be extended in a number of ways:
 
 - Figure out how to solve the interrupt problem
 
-- Add more drivers to the application side (e.g. block devices, USB,
-  environment access). This would mostly be an academic exercise as a strong
-  use case is not readily apparent, but it might be fun.
+- Add more drivers to the application side (e.g.USB, environment access).
 
 - Avoid turning off boot services in the stub. Instead allow U-Boot to make
   use of boot services in case it wants to. It is unclear what it might want
diff --git a/include/efi.h b/include/efi.h
index 0ec5913ddd1..908c5dc6ebd 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -419,10 +419,12 @@ struct efi_priv {
  *
  * @handle: handle of the controller on which this driver is installed
  * @blkio: block io protocol proxied by this driver
+ * @device_path: EFI path to the device
  */
 struct efi_media_plat {
-   efi_handle_thandle;
-   struct efi_block_io *blkio;
+   efi_handle_t handle;
+   struct efi_block_io *blkio;
+   struct efi_device_path *device_path;
 };
 
 /* Base address of the EFI image */
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012bc..ec9fa89a935 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -2035,4 +2035,19 @@ struct efi_firmware_management_protocol {
const u16 *package_version_name);
 };
 
+#define EFI_DISK_IO_PROTOCOL_GUID  \
+   EFI_GUID(0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, \
+0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
+
+struct efi_disk {
+   u64 revision;
+   efi_status_t (EFIAPI *read_disk)(struct efi_disk *this, u32 media_id,
+u64 offset, efi_uintn_t buffer_size,
+void *buffer);
+
+   efi_status_t (EFIAPI *write_disk)(struct efi_disk *this, u32 media_id,
+ u64 offset, efi_uintn_t buffer_size,
+ void *buffer);
+};
+
 #endif
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index f61665686c5..6a71cef7acb 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -21,6 +21,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +49,64 @@ int efi_info_get(enum efi_entry_t type, void **datap, int 
*sizep)
return -ENOSYS;
 }
 
+/**
+ * efi_print_str() - Print a UFT-16 string to the U-Boot console
+ *
+ * @str: String to print
+ */
+static void efi_print_str(const u16 *str)
+{
+   while (*str) {
+   int ch = *str++;
+
+   if (ch > ' ' && ch < 127)
+   putc(ch);
+   }
+}
+
+/**
+ * efi_bind_block() - bind a new block device to an EFI device
+ *
+ * Binds a new top-level EFI_MEDIA device as well as a child block device so
+ * that the block device can be accessed in U-Boot.
+ *
+ * The device can then be accessed using 'part list efi 0', 'fat ls efi 0:1',
+ * for example, just like any other interface type.
+ *
+ * @handle: handle of the controller on which this driver is installed
+ * @blkio: block io protocol proxied by this driver
+ * @device_path: EFI device path structure for this
+ * @len: Length of @device_path in bytes
+ * @devp: Returns the bound device
+ * @return 0 if OK, -ve on error
+ */
+int efi_bind_block(efi_handle_t handle, struct efi_block_io *blkio,
+  struct efi_device_path *device_path, int len,
+  struct udevice **devp)
+{
+   struct efi_media_plat plat;
+   struct udevice *dev;
+   char name[18];
+   int ret;
+
+   plat.handle = handle;
+   plat.blkio = blkio;
+   plat.device_path = malloc(device

[PATCH v6 08/27] x86: efi: Add room for the binman definition in the dtb

2021-12-17 Thread Simon Glass
At present only 4KB of spare space is left in the DTB when building the
EFI app. Increase this to 32KB so there is plenty of space to insert the
binman definition. This cannot be expanded later (as with OF_SEPARATE)
because the ELF image has already been built.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/dts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/dts/Makefile b/arch/x86/dts/Makefile
index be209aaaf8f..5c8c05ec499 100644
--- a/arch/x86/dts/Makefile
+++ b/arch/x86/dts/Makefile
@@ -24,7 +24,7 @@ dtb-y += bayleybay.dtb \
 
 targets += $(dtb-y)
 
-DTC_FLAGS += -R 4 -p 0x1000
+DTC_FLAGS += -R 4 -p $(if $(CONFIG_EFI_APP),0x8000,0x1000)
 
 PHONY += dtbs
 dtbs: $(addprefix $(obj)/, $(dtb-y))
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 06/27] x86: Allow booting a kernel from the EFI app

2021-12-17 Thread Simon Glass
At present this is disabled, but it should work so long as the kernel does
not need EFI services. Enable it and add a note about remaining work.

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Update documentation

 arch/x86/lib/bootm.c   | 11 +++
 doc/develop/uefi/u-boot_on_efi.rst |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 667e5e689e3..57cba5c65d3 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -179,10 +179,14 @@ int boot_linux_kernel(ulong setup_base, ulong 
load_address, bool image_64bit)
* U-Boot is setting them up that way for itself in
* arch/i386/cpu/cpu.c.
*
-   * Note that we cannot currently boot a kernel while running as
-   * an EFI application. Please use the payload option for that.
+   * Note: this is incomplete for EFI kernels!
+   *
+   * This can boot a kernel while running as an EFI application,
+   * but if the kernel requires EFI support then that support needs
+   * to be enabled first (see EFI_LOADER). Also the EFI information
+   * must enabled with setup_efi_info(). See setup_zimage() for
+   * how this is done with the stub.
*/
-#ifndef CONFIG_EFI_APP
__asm__ __volatile__ (
"movl $0, %%ebp\n"
"cli\n"
@@ -191,7 +195,6 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, 
bool image_64bit)
[boot_params] "S"(setup_base),
"b"(0), "D"(0)
);
-#endif
}
 
/* We can't get to here */
diff --git a/doc/develop/uefi/u-boot_on_efi.rst 
b/doc/develop/uefi/u-boot_on_efi.rst
index 8f81b799072..acad6397e81 100644
--- a/doc/develop/uefi/u-boot_on_efi.rst
+++ b/doc/develop/uefi/u-boot_on_efi.rst
@@ -269,7 +269,7 @@ This work could be extended in a number of ways:
 
 - Avoid turning off boot services in the stub. Instead allow U-Boot to make
   use of boot services in case it wants to. It is unclear what it might want
-  though.
+  though. It is better to use the app.
 
 Where is the code?
 --
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 05/27] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
At present only the backspace key is supported in U-Boot, when running as
an EFI app. Add support for arrows, home and end as well, to make the CLI
more friendly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/serial/serial_efi.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
index 33ddbd6080c..0067576389d 100644
--- a/drivers/serial/serial_efi.c
+++ b/drivers/serial/serial_efi.c
@@ -24,6 +24,9 @@ struct serial_efi_priv {
bool have_key;
 };
 
+/* Convert a lower-case character to its ctrl-char equivalent */
+#define CTL_CH(c)  ((c) - 'a' + 1)
+
 int serial_efi_setbrg(struct udevice *dev, int baudrate)
 {
return 0;
@@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv)
 static int serial_efi_getc(struct udevice *dev)
 {
struct serial_efi_priv *priv = dev_get_priv(dev);
+   char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
int ret, ch;
 
ret = serial_efi_get_key(priv);
@@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
 * key scan code of 8. Handle this so that backspace works correctly
 * in the U-Boot command line.
 */
-   if (!ch && priv->key.scan_code == 8)
-   ch = 8;
+   if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
+   ch = conv_scan[priv->key.scan_code];
+   if (ch >= 'a')
+   ch -= 'a' - 1;
+   }
debug(" [%x %x %x] ", ch, priv->key.unicode_char, priv->key.scan_code);
 
return ch;
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 07/27] x86: Don't process the kernel command line unless enabled

2021-12-17 Thread Simon Glass
If the 'bootm' command is not enabled then this code is not available and
this causes a link error. Fix it.

Note that for the EFI app, there is no indication of missing code. It just
hangs!

Signed-off-by: Simon Glass 
---

(no changes since v1)

 arch/x86/lib/zimage.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 7ce02226ef9..9cc04490307 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -365,11 +365,14 @@ int setup_zimage(struct boot_params *setup_base, char 
*cmd_line, int auto_boot,
strcpy(cmd_line, (char *)cmdline_force);
else
build_command_line(cmd_line, auto_boot);
-   ret = bootm_process_cmdline(cmd_line, max_size, BOOTM_CL_ALL);
-   if (ret) {
-   printf("Cmdline setup failed (max_size=%x, 
bootproto=%x, err=%d)\n",
-  max_size, bootproto, ret);
-   return ret;
+   if (IS_ENABLED(CONFIG_CMD_BOOTM)) {
+   ret = bootm_process_cmdline(cmd_line, max_size,
+   BOOTM_CL_ALL);
+   if (ret) {
+   printf("Cmdline setup failed (max_size=%x, 
bootproto=%x, err=%d)\n",
+  max_size, bootproto, ret);
+   return ret;
+   }
}
printf("Kernel command line: \"");
puts(cmd_line);
-- 
2.34.1.173.g76aa8bc2d0-goog



[PATCH v6 03/27] efi: Add a media/block driver for EFI block devices

2021-12-17 Thread Simon Glass
Add a block driver which handles read/write for EFI block devices. This
driver actually already exists ('efi_block') but is not really suitable
for use as a real U-Boot driver:

- The operations do not provide a udevice
- The code is designed for running as part of EFI loader, so uses
EFI_PRINT() and EFI_CALL().
- The bind method probes the device, which is not permitted
- It uses 'EFI' as its parent device

The new driver is more 'normal', just requiring its platform data be set
up in advance.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

(no changes since v2)

Changes in v2:
- Drop mention of partitions from the commit message

 drivers/block/Kconfig   |  10 
 drivers/block/Makefile  |   1 +
 drivers/block/efi_blk.c | 115 
 include/efi.h   |  11 
 4 files changed, 137 insertions(+)
 create mode 100644 drivers/block/efi_blk.c

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 755fdccb574..8235430497d 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -82,6 +82,16 @@ config EFI_MEDIA_SANDBOX
  EFI_MEDIA uclass. It does not do anything useful, since sandbox does
  not actually support running on top of UEFI.
 
+config EFI_MEDIA_BLK
+   bool "EFI media block driver"
+   depends on EFI_APP
+   default y
+   help
+ Enables a block driver for providing access to UEFI devices. This
+ allows use of block devices detected by the underlying UEFI
+ implementation. With this it is possible to use filesystems on these
+ devices, for example.
+
 endif  # EFI_MEDIA
 
 config IDE
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 3778633da1d..b221a7c6eea 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
 
 obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
 obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
+obj-$(CONFIG_EFI_MEDIA_BLK) += efi_blk.o
diff --git a/drivers/block/efi_blk.c b/drivers/block/efi_blk.c
new file mode 100644
index 000..9d25ecbf37f
--- /dev/null
+++ b/drivers/block/efi_blk.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Block driver for EFI devices
+ * This supports a media driver of UCLASS_EFI with a child UCLASS_BLK
+ * It allows block-level access to EFI devices made available via EFI boot
+ * services
+ *
+ * Copyright 2021 Google LLC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct efi_block_plat {
+   struct efi_block_io *blkio;
+};
+
+/**
+ * Read from block device
+ *
+ * @dev:   device
+ * @blknr: first block to be read
+ * @blkcnt:number of blocks to read
+ * @buffer:output buffer
+ * Return: number of blocks transferred
+ */
+static ulong efi_bl_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+void *buffer)
+{
+   struct efi_block_plat *plat = dev_get_plat(dev);
+   struct efi_block_io *io = plat->blkio;
+   efi_status_t ret;
+
+   log_debug("read buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr,
+ (ulong)blkcnt);
+   ret = io->read_blocks(io, io->media->media_id, blknr,
+ blkcnt * io->media->block_size, buffer);
+   log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK,
+ ret & ~EFI_ERROR_MASK);
+   if (ret)
+   return 0;
+
+   return blkcnt;
+}
+
+/**
+ * Write to block device
+ *
+ * @dev:   device
+ * @blknr: first block to be write
+ * @blkcnt:number of blocks to write
+ * @buffer:input buffer
+ * Return: number of blocks transferred
+ */
+static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
+ const void *buffer)
+{
+   struct efi_block_plat *plat = dev_get_plat(dev);
+   struct efi_block_io *io = plat->blkio;
+   efi_status_t ret;
+
+   log_debug("write buf=%p, block=%lx, count=%lx: ", buffer, (ulong)blknr,
+ (ulong)blkcnt);
+   ret = io->write_blocks(io, io->media->media_id, blknr,
+  blkcnt * io->media->block_size, (void *)buffer);
+   log_debug("ret=%lx (dec %ld)\n", ret & ~EFI_ERROR_MASK,
+ ret & ~EFI_ERROR_MASK);
+   if (ret)
+   return 0;
+
+   return blkcnt;
+}
+
+/* Block device driver operators */
+static const struct blk_ops efi_blk_ops = {
+   .read   = efi_bl_read,
+   .write  = efi_bl_write,
+};
+
+U_BOOT_DRIVER(efi_block) = {
+   .name   = "efi_block",
+   .id = UCLASS_BLK,
+   .ops= &efi_blk_ops,
+   .plat_auto  = sizeof(struct efi_block_plat),
+};
+
+static int efi_media_bind(struct udevice *dev)
+{
+   struct efi_media_plat *plat = dev_get_plat(dev);
+   struct efi_block_plat *blk_plat;
+   struct udevice *blk;
+   int ret;
+
+   ret = b

[PATCH v6 02/27] efi: Add EFI uclass for media

2021-12-17 Thread Simon Glass
At present UCLASS_EFI_LOADER is used to represent an EFI filesystem among
other things. The only driver that uses this uclass is in fact not a real
U-Boot driver, since its operations do not include a struct udevice.

Rather than mess with this, create a new UCLASS_EFI_MEDIA uclass to handle
EFI media such as disks. Make this the uclass to use for devices provided
by a UEFI implementation loading U-Boot as an EFI application, so that it
can be used with 'part list', for example.

The existing implementation using UCLASS_EFI remains as is, for
discussion.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

Changes in v6:
- Reword commit message
- Update comment for UCLASS_EFI_MEDIA (within space constraints)

Changes in v2:
- Add MAINTAINERS entry
- Show the correct interface type with 'part list'
- Update the commit message to explain things better

 MAINTAINERS  |  3 +++
 arch/sandbox/dts/test.dts|  4 
 disk/part.c  |  5 -
 drivers/block/Kconfig| 23 +++
 drivers/block/Makefile   |  3 +++
 drivers/block/blk-uclass.c   |  2 ++
 drivers/block/efi-media-uclass.c | 15 +++
 drivers/block/sb_efi_media.c | 20 
 include/blk.h|  1 +
 include/dm/uclass-id.h   |  1 +
 test/dm/Makefile |  1 +
 test/dm/efi_media.c  | 24 
 12 files changed, 101 insertions(+), 1 deletion(-)
 create mode 100644 drivers/block/efi-media-uclass.c
 create mode 100644 drivers/block/sb_efi_media.c
 create mode 100644 test/dm/efi_media.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9045e509d73..5b162ad2978 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -714,8 +714,11 @@ W: 
https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html
 F: board/efi/efi-x86_app
 F: configs/efi-x86_app*
 F: doc/develop/uefi/u-boot_on_efi.rst
+F: drivers/block/efi-media-uclass.c
+F: drivers/block/sb_efi_media.c
 F: lib/efi/efi_app.c
 F: scripts/build-efi.sh
+F: test/dm/efi_media.c
 
 EFI PAYLOAD
 M: Heinrich Schuchardt 
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index e5261bb9fa2..48ca3e1e472 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -499,6 +499,10 @@
compatible = "sandbox,clk-ccf";
};
 
+   efi-media {
+   compatible = "sandbox,efi-media";
+   };
+
eth@10002000 {
compatible = "sandbox,eth";
reg = <0x10002000 0x1000>;
diff --git a/disk/part.c b/disk/part.c
index fe1ebd4adf7..e857a9f9585 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -296,8 +296,11 @@ static void print_part_header(const char *type, struct 
blk_desc *dev_desc)
case IF_TYPE_VIRTIO:
puts("VirtIO");
break;
+   case IF_TYPE_EFI_MEDIA:
+   puts("EFI");
+   break;
default:
-   puts ("UNKNOWN");
+   puts("UNKNOWN");
break;
}
printf (" device %d  --   Partition Type: %s\n\n",
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 56a4eec05ac..755fdccb574 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -61,6 +61,29 @@ config TPL_BLOCK_CACHE
help
  This option enables the disk-block cache in TPL
 
+config EFI_MEDIA
+   bool "Support EFI media drivers"
+   default y if EFI || SANDBOX
+   help
+ Enable this to support media devices on top of UEFI. This enables
+ just the uclass so you also need a specific driver to make this do
+ anything.
+
+ For sandbox there is a test driver.
+
+if EFI_MEDIA
+
+config EFI_MEDIA_SANDBOX
+   bool "Sandbox EFI media driver"
+   depends on SANDBOX
+   default y
+   help
+ Enables a simple sandbox media driver, used for testing just the
+ EFI_MEDIA uclass. It does not do anything useful, since sandbox does
+ not actually support running on top of UEFI.
+
+endif  # EFI_MEDIA
+
 config IDE
bool "Support IDE controllers"
select HAVE_BLOCK_DEVICE
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 94ab5c6f906..3778633da1d 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -14,3 +14,6 @@ obj-$(CONFIG_IDE) += ide.o
 endif
 obj-$(CONFIG_SANDBOX) += sandbox.o
 obj-$(CONFIG_$(SPL_TPL_)BLOCK_CACHE) += blkcache.o
+
+obj-$(CONFIG_EFI_MEDIA) += efi-media-uclass.o
+obj-$(CONFIG_EFI_MEDIA_SANDBOX) += sb_efi_media.o
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index a7470ae28d5..4ae8af6d609 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = "sata",
[IF_TYPE_HOST]  = "host",
[IF_TYPE_NVME]  = "nvme",
+

[PATCH v6 01/27] efi: Rename UCLASS_EFI and IF_TYPE_EFI

2021-12-17 Thread Simon Glass
These names are better used for access to devices provided by an EFI
layer. Use EFI_LOADER instead here, since these are only available in
U-Boot's EFI_LOADER layer.

Signed-off-by: Simon Glass 
Reviewed-by: Heinrich Schuchardt 
---

Changes in v6:
- Update comment to UCLASS_EFI_LOADER

Changes in v5:
- Add new patch to resolve EFI/EFI_LOADER conflict

 doc/develop/uefi/uefi.rst | 8 
 drivers/block/blk-uclass.c| 4 ++--
 include/blk.h | 2 +-
 include/dm/uclass-id.h| 2 +-
 lib/efi_driver/efi_block_device.c | 8 
 lib/efi_driver/efi_uclass.c   | 8 
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index f17138f5c76..a3e2656ab81 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -620,12 +620,12 @@ EFI_DRIVER_BINDING_PROTOCOL implementation for the UEFI 
drivers.
 
 A linker created list is used to keep track of the UEFI drivers. To create an
 entry in the list the UEFI driver uses the U_BOOT_DRIVER macro specifying
-UCLASS_EFI as the ID of its uclass, e.g::
+UCLASS_EFI_LOADER as the ID of its uclass, e.g::
 
 /* Identify as UEFI driver */
 U_BOOT_DRIVER(efi_block) = {
 .name  = "EFI block driver",
-.id= UCLASS_EFI,
+.id= UCLASS_EFI_LOADER,
 .ops   = &driver_ops,
 };
 
@@ -651,8 +651,8 @@ UEFI block IO driver
 The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
 
 When connected it creates a new U-Boot block IO device with interface type
-IF_TYPE_EFI, adds child controllers mapping the partitions, and installs the
-EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
+IF_TYPE_EFI_LOADER, adds child controllers mapping the partitions, and installs
+the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with 
the
 software iPXE to boot from iSCSI network drives [4].
 
 This driver is only available if U-Boot is configured with::
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 83682dcc181..a7470ae28d5 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -28,7 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = "sata",
[IF_TYPE_HOST]  = "host",
[IF_TYPE_NVME]  = "nvme",
-   [IF_TYPE_EFI]   = "efi",
+   [IF_TYPE_EFI_LOADER]= "efiloader",
[IF_TYPE_VIRTIO]= "virtio",
[IF_TYPE_PVBLOCK]   = "pvblock",
 };
@@ -44,7 +44,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_SATA]  = UCLASS_AHCI,
[IF_TYPE_HOST]  = UCLASS_ROOT,
[IF_TYPE_NVME]  = UCLASS_NVME,
-   [IF_TYPE_EFI]   = UCLASS_EFI,
+   [IF_TYPE_EFI_LOADER]= UCLASS_EFI_LOADER,
[IF_TYPE_VIRTIO]= UCLASS_VIRTIO,
[IF_TYPE_PVBLOCK]   = UCLASS_PVBLOCK,
 };
diff --git a/include/blk.h b/include/blk.h
index f0cc7ca1a28..f0835c3fed5 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -34,7 +34,7 @@ enum if_type {
IF_TYPE_SATA,
IF_TYPE_HOST,
IF_TYPE_NVME,
-   IF_TYPE_EFI,
+   IF_TYPE_EFI_LOADER,
IF_TYPE_PVBLOCK,
IF_TYPE_VIRTIO,
 
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index fd139b9b2a0..2d05694982b 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -48,7 +48,7 @@ enum uclass_id {
UCLASS_DMA, /* Direct Memory Access */
UCLASS_DSA, /* Distributed (Ethernet) Switch Architecture */
UCLASS_ECDSA,   /* Elliptic curve cryptographic device */
-   UCLASS_EFI, /* EFI managed devices */
+   UCLASS_EFI_LOADER,  /* Devices created by UEFI apps and drivers */
UCLASS_ETH, /* Ethernet device */
UCLASS_ETH_PHY, /* Ethernet PHY device */
UCLASS_FIRMWARE,/* Firmware */
diff --git a/lib/efi_driver/efi_block_device.c 
b/lib/efi_driver/efi_block_device.c
index 0937e3595a4..04cb3ef0d4e 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -147,7 +147,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
if (!obj)
return -ENOENT;
 
-   devnum = blk_find_max_devnum(IF_TYPE_EFI);
+   devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER);
if (devnum == -ENODEV)
devnum = 0;
else if (devnum < 0)
@@ -159,8 +159,8 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
sprintf(name, "efiblk#%d", devnum);
 
/* Create driver model udevice for the EFI block io device */
-   ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI, devnum,
-   io->media->block_size,
+   ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI_LOADER,
+  

[PATCH v6 00/27] efi: Improvements to U-Boot running on top of UEFI

2021-12-17 Thread Simon Glass
At present U-Boot can be built as an EFI app, but it is really just for
testing, with very few features. Instead, the payload build is used for
booting on top of UEFI, where U-Boot takes over the machine immediately
and supplies its own drivers.

But the app could be made more useful.

This series provides access to EFI block devices and the video console
within U-Boot. It also restructures the app to make it possible to boot
a kernel, although further work is needed to implement this.

This can be thought of as making U-Boot perform a little like 'grub', in
that it runs purely based on UEFI-provided services.

Of course a lot more work is required, but this is a start.

Note: It would be very useful to include qemu tests of the app and stub
in CI.

This is available at u-boot-dm/efi-working

Changes in v6:
- Add comment for dm_scan_other()
- Add comment for free_memory()
- Drop setup_disks() as U-Boot does not support it
- Fix 'have have' typo
- Fix 'stuff' typo in comment
- Fix Alo typo in commit message
- Fix comment style in setup_info_table()
- Fix typo in function comment
- Reword commit message
- Update comment for UCLASS_EFI_MEDIA (within space constraints)
- Update comment format for devpath_is_partition()
- Update comment to UCLASS_EFI_LOADER
- Update to 'This function' in comment
- Use 'U-Boot' instead of 'ARP' typo

Changes in v5:
- Add new patch to avoid setting up global_data again with EFI
- Add new patch to avoid using the 64-bit link script for the EFI app
- Add new patch to build the 64-bit app properly
- Add new patch to resolve EFI/EFI_LOADER conflict
- Add new patch to round out the link script for 64-bit EFI
- Add new patch to set the correct link flags for the 64-bit EFI app
- Add new patch to tweak the code used for the 64-bit EFI app
- Add various patches to fix up the 64-bit app so that it boots
- Fix grammar in commit message

Changes in v3:
- Add new patch to show the system-table revision
- Drop comments that confuse sphinx
- Move device_path path change to its own patch

Changes in v2:
- Add MAINTAINERS entry
- Add a better boot command too
- Add a sentence about what the patch does
- Add new patch to support the efi command in the app
- Don't export efi_bind_block()
- Drop mention of partitions from the commit message
- Fix 'as' typo
- Only bind devices for media devices, not for partitions
- Show devices that are processed
- Show the correct interface type with 'part list'
- Store device path in struct efi_media_plat
- Update documentation
- Update the commit message to explain things better
- Use log_info() instead of printf()

Simon Glass (27):
  efi: Rename UCLASS_EFI and IF_TYPE_EFI
  efi: Add EFI uclass for media
  efi: Add a media/block driver for EFI block devices
  efi: Locate all block devices in the app
  efi: serial: Support arrow keys
  x86: Allow booting a kernel from the EFI app
  x86: Don't process the kernel command line unless enabled
  x86: efi: Add room for the binman definition in the dtb
  efi: Drop device_path from struct efi_priv
  efi: Add comments to struct efi_priv
  efi: Fix ll_boot_init() operation with the app
  efi: Add a few comments to the stub
  efi: Share struct efi_priv between the app and stub code
  efi: Move exit_boot_services into a function
  efi: Check for failure when initing the app
  efi: Mention that efi_info_get() is only used in the stub
  efi: Show when allocated pages are used
  efi: Allow easy selection of serial-only operation
  x86: efi: Update efi_get_next_mem_desc() to avoid needing a map
  efi: Support the efi command in the app
  x86: efi: Show the system-table revision
  x86: efi: Don't set up global_data again with EFI
  x86: efi: Tweak the code used for the 64-bit EFI app
  x86: efi: Round out the link script for 64-bit EFI
  x86: efi: Don't use the 64-bit link script for the EFI app
  x86: efi: Set the correct link flags for the 64-bit EFI app
  efi: Build the 64-bit app properly

 MAINTAINERS|   3 +
 Makefile   |   4 +-
 arch/sandbox/dts/test.dts  |   4 +
 arch/x86/config.mk |  15 +-
 arch/x86/cpu/config.mk |   2 +-
 arch/x86/cpu/efi/payload.c |  17 +-
 arch/x86/cpu/x86_64/cpu.c  |   5 +
 arch/x86/dts/Makefile  |   2 +-
 arch/x86/lib/Makefile  |   5 +-
 arch/x86/lib/bootm.c   |  11 +-
 arch/x86/lib/elf_x86_64_efi.lds|   5 +-
 arch/x86/lib/relocate.c|   2 +
 arch/x86/lib/zimage.c  |  13 +-
 cmd/Makefile   |   2 +-
 cmd/efi.c  |  78 +
 common/board_r.c   |   5 +-
 disk/part.c|   5 +-
 doc/develop/uefi/u-boot_on_efi.rst |   6 +-
 doc/develop/uefi/uefi.rst  |   8 +-
 drivers/block/Kconfig  |  33 
 drivers/block/Makefile |   4 +
 drivers/block/blk-uclass.c |   6 +-
 drivers/block/efi-media-uclass.c   |  15 ++
 drivers/block/e

USB 2.0 Test Errors when XHCI driver is loaded on RZ/G2

2021-12-17 Thread Adam Ford
I have an RZ/G2 family of boards which has a USB 2.0 controller
connected to a hub with 4 ports on it.

I'm trying to run some hardware tests on the USB and when I issue the command:
usb test 0 1 P

I get a strange error and subsequently a message that looks like it's
executing successfully, however the usb test signal is not present on
the USB port.

=> usb test 0 1 P
Setting Test_Packet mode on downstream facing port 1...
The request port(1024) exceeds maximum port number
^--The error message
Test mode successfully set. Use 'usb start' to return to normal operation.
^--The appearance of a successful command.

The error message that reads "The request port(1024) exceeds..." is
coming from the rcar XHCI driver, but that is not the driver hosting
the USB hub or USB device attached.

=> usb tree
USB device tree:
  1  Hub (5 Gb/s, 0mA)
 U-Boot XHCI Host Controller

  1  Hub (480 Mb/s, 0mA)
 u-boot EHCI Host Controller

  1  Hub (480 Mb/s, 0mA)
  |  u-boot EHCI Host Controller
  |
  +-2  Hub (480 Mb/s, 2mA)
|
+-3  Mass Storage (480 Mb/s, 224mA)
 SanDisk Cruzer 4C530001210813101175

=>

If I disable the XHCI driver, and run the same commands, the error
message goes away, and the USB test signal is present on the USB
correct port, but the test signal is missing with the XHCI driver is
loaded, so it leads me to believe that the message is being propagated
to the wrong controller.  Somehow, by the time the message reaches the
XHCI controller, it also changes the port number to 1024 which is
clearly also incorrect.

USB dev 0 appears as my thumb drive

=> usb dev 0

Device 0: Vendor: SanDisk Rev: 1.00 Prod: Cruzer
Type: Removable Hard Disk
Capacity: 120864.0 MB = 118.0 GB (247529472 x 512)
... is now current device
=>


Does anyone have any suggestions on how to troubleshoot this?   I was
wondering if the hub numbers should be unique instead of all being the
number 1.

thanks for any advice.


Re: [PATCH 3/3] cmd: efi: efidebug print ECPT table

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

Signed-off-by: Jose Marinho 
---
  cmd/efidebug.c   | 41 +
  include/efi_loader.h |  2 ++
  2 files changed, 43 insertions(+)

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a53a5029fa..c3246e1820 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -889,6 +889,38 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int 
flag,
return CMD_RET_SUCCESS;
  }

+#ifdef CONFIG_EFI_ECPT
+static int do_efi_ecpt(struct cmd_tbl *cmdtp, int flag,
+  int argc, char * const argv[])
+{
+   struct efi_conformance_profiles_table *ecpt;
+
+   if (argc != 1)
+   return CMD_RET_USAGE;
+
+   for (int idx = 0; idx < systab.nr_tables; idx++)
+   if (!guidcmp(&efi_ecpt_guid, &systab.tables[idx].guid))
+   ecpt = (struct efi_system_resource_table 
*)systab.tables[idx].table;
+
+   if (!ecpt) {
+   log_info("ECPT: table not present\n");
+   return CMD_RET_SUCCESS;
+   }
+
+   const int num_profiles = ecpt->number_of_profiles;
+
+   printf("\n");
+   printf("ECPT: version:%d\n", ecpt->version);
+   printf("ECPT: num profiles:%d\n", num_profiles);
+
+   for (int i = 0; i < num_profiles; i++)
+   printf("ECPT: profile %d = %pUL\n", i, 
&ecpt->conformance_profiles[i]);
+   printf("\n");
+
+   return CMD_RET_SUCCESS;
+}
+#endif /* CONFIG_EFI_ECPT */
+
  /**
   * create_initrd_dp() - Create a special device for our Boot### option
   *
@@ -1681,6 +1713,11 @@ static struct cmd_tbl cmd_efidebug_sub[] = {
 "", ""),
U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info,
 "", ""),
+#ifdef CONFIG_EFI_ECPT
+   U_BOOT_CMD_MKENT(ecpt, CONFIG_SYS_MAXARGS, 1, do_efi_ecpt,
+"", ""),
+#endif
+
  };

  /**
@@ -1769,6 +1806,10 @@ static char efidebug_help_text[] =
"  - show UEFI memory map\n"
"efidebug tables\n"
"  - show UEFI configuration tables\n"
+#ifdef CONFIG_EFI_ECPT
+   "efidebug ecpt\n"
+   "  - show UEFI conformance profiles table\n"
+#endif
  #ifdef CONFIG_CMD_BOOTEFI_BOOTMGR
"efidebug test bootmgr\n"
"  - run simple bootmgr for test\n"
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d20ff396d0..d60a340136 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -310,6 +310,8 @@ extern const efi_guid_t 
efi_guid_firmware_management_protocol;
  extern const efi_guid_t efi_esrt_guid;
  /* GUID of the SMBIOS table */
  extern const efi_guid_t smbios_guid;
+/* GUID for the ECPT */
+extern const efi_guid_t efi_ecpt_guid;

  extern char __efi_runtime_start[], __efi_runtime_stop[];
  extern char __efi_runtime_rel_start[], __efi_runtime_rel_stop[];


Our interest is to keep the U-Boot binary size small. I see no need to
print the ECPT table.

What make more sense is a unit test that checks the consistency of the
table.

Best regards

Heinrich


Re: [PATCH 0/3] Conformance Profiles Table support in U-boot

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

The Conformance Profiles Table (ECPT) table will be included in the UEFI
specification 2.9+.


The change suggested in
https://bugzilla.tianocore.org/show_bug.cgi?id=3591
is a not well designed: How could the missing of a table ever be taken
as a sign of compliance?

How would an application make use of the table?
What information does it provide that is not better obtained from API calls?

As the table is not defined in UEFI 2.9 and no software uses it, why
should we implement it?

Best regards

Heinrich


The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

This patch set implements the ECPT table in U-boot.

Jose Marinho (3):
   efi: Create ECPT table
   efi: ECPT add EBBRv2.0 conformance profile
   cmd: efi: efidebug print ECPT table

  cmd/efidebug.c   | 45 +++
  include/efi_api.h| 14 ++
  include/efi_loader.h |  9 
  lib/efi_loader/Kconfig   | 12 +
  lib/efi_loader/Makefile  |  1 +
  lib/efi_loader/efi_conformance.c | 75 
  lib/efi_loader/efi_setup.c   |  6 +++
  7 files changed, 162 insertions(+)
  create mode 100644 lib/efi_loader/efi_conformance.c





Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Fabio Estevam
On Fri, Dec 17, 2021 at 2:03 PM Adam Ford  wrote:

> I didn't think Driver model was a requirement for SPL.

That's my understanding as well.

> > I had problems getting the dwc3 to initialize properly when using the
> > device model in the SPL. I'm currently just using this in the SPL and
> > the device model in u-boot.
> >
> > I'll take another shot at initializing the dwc3 in the SPL with the DM.
>
> Could we compromise by putting the #define statements in an ifdef to
> only enable them when SPL is being built?

This looks like a a good idea.


Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Fri, 17 Dec 2021 at 10:14, Heinrich Schuchardt  wrote:
>
> On 12/17/21 17:37, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:
> >>
> >> On 12/4/21 07:56, Simon Glass wrote:
> >>> At present only the backspace key is supported in U-Boot, when running as
> >>> an EFI app. Add support for arrows, home and end as well, to make the CLI
> >>> more friendly.
> >>>
> >>> Signed-off-by: Simon Glass 
> >>> ---
> >>>
> >>> (no changes since v1)
> >>>
> >>>drivers/serial/serial_efi.c | 11 +--
> >>>1 file changed, 9 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
> >>> index 33ddbd6080c..0067576389d 100644
> >>> --- a/drivers/serial/serial_efi.c
> >>> +++ b/drivers/serial/serial_efi.c
> >>> @@ -24,6 +24,9 @@ struct serial_efi_priv {
> >>>bool have_key;
> >>>};
> >>>
> >>> +/* Convert a lower-case character to its ctrl-char equivalent */
> >>> +#define CTL_CH(c)((c) - 'a' + 1)
> >>> +
> >>>int serial_efi_setbrg(struct udevice *dev, int baudrate)
> >>>{
> >>>return 0;
> >>> @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv 
> >>> *priv)
> >>>static int serial_efi_getc(struct udevice *dev)
> >>>{
> >>>struct serial_efi_priv *priv = dev_get_priv(dev);
> >>> + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
> >>>int ret, ch;
> >>>
> >>>ret = serial_efi_get_key(priv);
> >>> @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
> >>> * key scan code of 8. Handle this so that backspace works 
> >>> correctly
> >>> * in the U-Boot command line.
> >>> */
> >>> - if (!ch && priv->key.scan_code == 8)
> >>> - ch = 8;
> >>> + if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
> >>> + ch = conv_scan[priv->key.scan_code];
> >>> + if (ch >= 'a')
> >>> + ch -= 'a' - 1;
> >>
> >> This is not what a serial console would use in Linux. Just try U-Boot's
> >> conitrace command. If you use the following, we get compatibility with
> >> the rest of U-Boot:
> >>
> >> 1b 5b 32 7e - insert
> >> 1b 5b 33 7e - delete
> >> 1b 5b 35 7e - page up
> >> 1b 5b 36 7e - page down
> >> 1b 5b 41 - up
> >> 1b 5b 42 - down
> >> 1b 5b 43 - right
> >> 1b 5b 44 - left
> >> 1b 5b 46 - end
> >> 1b 5b 48 - home
> >
> > That's more complicated since it requires the serial driver to convert
> > one character into multiple. We can always add it later if needed. But
> > this does command-line history, etc. working in the app.
>
> Yes you will need a ring buffer as in the USB keyboard driver.
>
> lib/efi_loader/efi_console.c only understands the multi-byte sequences.
> I do not know if there are other places which have the same limitation.

The ones I am using here are the official U-Boot codes. Perhaps
EFI_LOADER should be fixed, but this doesn't matter for the EFI app.

In any case, this work can be done later if needed.

Regards,
Simon


Re: [PATCH v5 25/29] image: Remove #ifdefs from select_ramdisk()

2021-12-17 Thread Neil Armstrong
Hi,

On 09/10/2021 03:41, Tom Rini wrote:
> On Sat, Sep 25, 2021 at 07:43:38PM -0600, Simon Glass wrote:
> 
>> Use boolean variables to deal with the strange #ifdef logic of this
>> function, so we can remove the #ifdefs.
>>
>> Signed-off-by: Simon Glass 
> 
> Applied to u-boot/master, thanks!
> 

This commit causes an abort on Libretech-CC when trying to load an initrd 
(using libretech-cc_defconfig & gcc-arm-9.2-2019.12):

U-Boot 2021.10-00076-gf33a2c1bd0 (Dec 17 2021 - 18:21:08 +0100) libretech-cc

Model: Libre Computer AML-S905X-CC
SoC:   Amlogic Meson GXL (S905X) Revision 21:d (84:2)
DRAM:  2 GiB
MMC:   mmc@72000: 0, mmc@74000: 1
Loading Environment from nowhere... OK
In:serial
Out:   serial
Err:   serial
[BL31]: tee size: 0
[BL31]: tee size: 0
Net:   eth0: ethernet@c941
Hit any key to stop autoboot:  0
(ROM USB boot)
## Executing script at 0800

Moving Image from 0x808 to 0x820, end=a6c
"Synchronous Abort" handler, esr 0x96000210
elr: 0101bd44 lr : 0101bf3c (reloc)
elr: 7df70d44 lr : 7df70f3c
x0 :  x1 : 7dfcd6fc
x2 : 0003 x3 : 
x4 : 7bf74b20 x5 : 0030
x6 :  x7 : 0002
x8 : 7bf441c0 x9 : 
x10: 7fff x11: 
x12: 0a6c x13: 0a6b
x14: 7bf49210 x15: 0020
x16: 7df853bc x17: 
x18: 7bf52dd0 x19: 7dff4e98
x20: 7dff4f88 x21: 7dff4f90
x22: 0016 x23: 7bf74b20
x24:  x25: 7bf74b48
x26:  x27: 
x28: 7bf74b70 x29: 7bf481f0

Code: a9017fff 97f5 a8c27bfd d65f03c0 (b942)
Resetting CPU ...

Abort is probably in genimg_get_format()

Reverting on master fixes the issue.

Neil


Re: [PATCH u-boot-next 00/12] Common U-Boot macros for PCI Configuration Mechanism #1

2021-12-17 Thread Pali Rohár
Hello! Could you look and review at this patch series?

On Friday 26 November 2021 11:42:40 Pali Rohár wrote:
> This patch series add new U-Boot macros for composing Config Address for
> PCI Configuration Mechanism #1 as defined in PCI Local Bus Specification,
> including extended variant (which do not have any formal specification)
> and then use these new macros (PCI_CONF1_ADDRESS and PCI_CONF1_EXT_ADDRESS)
> in all PCI drivers that use Config Address according to PCI Configuration
> Mechanism #1.
> 
> PCI Configuration Mechanism #1 was originally specified for x86 platforms
> and it is still supported on x86 together with PCIe ECAM. Nowadays lot of
> non-ECAM-compliant ARM PCIe controllers use only extended variant of this
> address construction and some of them requires cleared Enable bit. Extended
> variant is also supported by x86 AMD Barcelona (and new) CPUs, but U-Boot
> code does not provide this support yet.
> 
> Note that it exists also PCI Configuration Mechanism #2, but this one was
> removed from PCI Local Bus Specification revision 3.0 and seems that it is
> not used by any PCI driver in U-Boot. So I have not added macros for this
> mechanism in this patch series.
> 
> Because lot of hardware still use this (rather old) mechanism, relevant
> U-Boot PCI and PCIe drivers have own ad-hoc code address construction,
> which is repeated and written in different ways.
> 
> This patch series is code cleanup of these PCIe drivers to use common
> U-Boot macros for PCI Configuration Mechanism #1.
> 
> The last change is fixing construction of Config Address in PCI driver
> sh7751. Construction with this change matches Linux kernel code and also
> U-Boot code prior commit mentioned in commit message.
> 
> I have tested this patch series only for PCI mvebu driver on A385 board and
> it is working fine. So Please properly review all other changes. Ideally
> test them.
> 
> I have run CI tests with these changes on github and everything passed:
> https://github.com/u-boot/u-boot/pull/101
> 
> Please let me know what do you think about this change.
> 
> Pali Rohár (12):
>   pci: Add standard PCI Config Address macros
>   pci: gt64120: Use PCI_CONF1_ADDRESS() macro
>   pci: mpc85xx: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: msc01: Use PCI_CONF1_ADDRESS() macro
>   pci: mvebu: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: tegra: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: fsl: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: mediatek: Use PCI_CONF1_EXT_ADDRESS() macro
>   pci: sh7780: Use PCI_CONF1_ADDRESS() macro
>   x86: pci: Use PCI_CONF1_ADDRESS() macro
>   m68k: mcf5445x: pci: Use PCI_CONF1_ADDRESS() macro
>   pci: sh7751: Fix access to config space via PCI_CONF1_ADDRESS() macro
> 
>  arch/m68k/cpu/mcf5445x/pci.c |  7 +++---
>  arch/x86/cpu/pci.c   |  4 ++--
>  drivers/pci/pci_gt64120.c|  7 ++
>  drivers/pci/pci_mpc85xx.c|  4 ++--
>  drivers/pci/pci_msc01.c  |  7 ++
>  drivers/pci/pci_mvebu.c  | 17 --
>  drivers/pci/pci_sh7751.c | 29 ++-
>  drivers/pci/pci_sh7780.c |  8 +++
>  drivers/pci/pci_tegra.c  | 11 +++--
>  drivers/pci/pcie_fsl.c   | 10 
>  drivers/pci/pcie_mediatek.c  | 17 +++---
>  include/gt64120.h| 12 --
>  include/msc01.h  |  9 
>  include/pci.h| 45 
>  14 files changed, 83 insertions(+), 104 deletions(-)
> 
> -- 
> 2.20.1
> 


[PATCH] arm: mvebu: Use printf for printing fatal errors

2021-12-17 Thread Pali Rohár
There is no point to hide/disable fatal errors via debug() macro.
Print fatal errors loudly.

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-mvebu/spl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 29a8adc9d79c..609495097585 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -313,7 +313,7 @@ void board_init_f(ulong dummy)
 
ret = spl_init();
if (ret) {
-   debug("spl_init() failed: %d\n", ret);
+   printf("spl_init() failed: %d\n", ret);
hang();
}
 
@@ -329,7 +329,7 @@ void board_init_f(ulong dummy)
/* Setup DDR */
ret = ddr3_init();
if (ret) {
-   debug("ddr3_init() failed: %d\n", ret);
+   printf("ddr3_init() failed: %d\n", ret);
hang();
}
 #endif
-- 
2.20.1



[PATCH v10] driver: spi: add bcm iproc qspi support

2021-12-17 Thread Roman Bacik
IPROC qspi driver supports both BSPI and MSPI modes.

Signed-off-by: Rayagonda Kokatanur 
Signed-off-by: Bharat Gooty 
Acked-by: Rayagonda Kokatanur 
Signed-off-by: Roman Bacik 
---

Changes in v10:
- remove binding document
- use defined values for delays and timeouts
- replace timer-based logic with readl_poll_timeout
- format selected commands to single line
- remove unnecessary entries from struct bcmspi_priv
- simplify and move bspi strap override to bspi_set_flex_mode

Changes in v9:
- merge bspi_set_4byte_mode to bspi_set_flex_mode
- simplify bspi_set_flex_mode using data from spi_mem_op
- rename mode_4byte to bspi_4byte
- use BIT(x) istead of 1cmd.opcode for BSPI_CMD_AND_MODE_BYTE_REG
- move iproc_qspi.c to spi

Changes in v4:
- move iproc_qspi.c from spi to mtd/spi
- remove iproc_qspi.h
- rename IPROC_QSPI to SPI_FLASH_IPROC

Changes in v3:
- fix warning by including linux/delay.h
- change ofdata_to_platdata to of_to_plat
- change priv_auto_alloc_size to priv_auto

Changes in v2:
- remove include spi-nor.h
- define and use named BITs for writing register values
- remove bspi_set_4byte_mode() method

 drivers/spi/Kconfig  |   6 +
 drivers/spi/Makefile |   1 +
 drivers/spi/iproc_qspi.c | 578 +++
 3 files changed, 585 insertions(+)
 create mode 100644 drivers/spi/iproc_qspi.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d07e9a28af82..faebc212753e 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -178,6 +178,12 @@ config ICH_SPI
  access the SPI NOR flash on platforms embedding this Intel
  ICH IP core.
 
+config IPROC_QSPI
+   bool "Broadcom iProc QSPI Flash Controller driver"
+   help
+ Enable Broadcom iProc QSPI Flash Controller driver.
+ This driver can be used to access the SPI NOR flash.
+
 config KIRKWOOD_SPI
bool "Marvell Kirkwood SPI Driver"
help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d2f24bccefd3..869763187062 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_SYNQUACER_SPI) += spi-synquacer.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
+obj-$(CONFIG_IPROC_QSPI) += iproc_qspi.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
 obj-$(CONFIG_MPC8XX_SPI) += mpc8xx_spi.o
diff --git a/drivers/spi/iproc_qspi.c b/drivers/spi/iproc_qspi.c
new file mode 100644
index ..2eb09058c286
--- /dev/null
+++ b/drivers/spi/iproc_qspi.c
@@ -0,0 +1,578 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020-2021 Broadcom
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Delay required to change the mode of operation */
+#define BUSY_DELAY_US  1
+#define BUSY_TIMEOUT_US20
+#define DWORD_ALIGNED(a)   (!(((ulong)(a)) & 3))
+
+/* Chip attributes */
+#define QSPI_AXI_CLK   17500
+#define SPBR_MIN   8U
+#define SPBR_MAX   255U
+#define NUM_CDRAM  16U
+
+#define CDRAM_PCS0 2
+#define CDRAM_CONT BIT(7)
+#define CDRAM_BITS_EN  BIT(6)
+#define CDRAM_QUAD_MODEBIT(8)
+#define CDRAM_RBIT_INPUT   BIT(10)
+#define MSPI_SPE   BIT(6)
+#define MSPI_CONT_AFTER_CMDBIT(7)
+
+/* Register fields */
+#define MSPI_SPCR0_MSB_BITS_8  0x0020
+#define BSPI_RAF_CONTROL_START_MASK0x0001
+#define BSPI_RAF_STATUS_SESSION_BUSY_MASK  0x0001
+#define BSPI_RAF_STATUS_FIFO_EMPTY_MASK0x0002
+#define BSPI_STRAP_OVERRIDE_DATA_QUAD_SHIFT3
+#define BSPI_STRAP_OVERRIDE_4BYTE_SHIFT2
+#define BSPI_STRAP_OVERRIDE_DATA_DUAL_SHIFT1
+#define BSPI_STRAP_OVERRIDE_SHIFT  0
+#define BSPI_BPC_DATA_SHIFT0
+#define BSPI_BPC_MODE_SHIFT8
+#define BSPI_BPC_ADDR_SHIFT16
+#define BSPI_BPC_CMD_SHIFT 24
+#define BSPI_BPP_ADDR_SHIFT16
+
+/* MSPI registers */
+#define MSPI_SPCR0_LSB_REG 0x000
+#define MSPI_SPCR0_MSB_REG 0x004
+#define MSPI_SPCR1_LSB_REG 0x008
+#define MSPI_SPCR1_MSB_REG 0x00c
+#define MSPI_NEWQP_REG 0x010
+#define MSPI_ENDQP_REG 0x014
+#define MSPI_SPCR2_REG 0x018
+#define MSPI_STATUS_REG0x020
+#define MSPI_CPTQP_RE

[PATCH] arm: mvebu: Remove commented example code

2021-12-17 Thread Pali Rohár
Include file debug_uart.h already contains documentation how to use it.

Signed-off-by: Pali Rohár 
---
 arch/arm/mach-mvebu/spl.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 6a9e1d860cf7..29a8adc9d79c 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -5,7 +5,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -303,18 +302,6 @@ void board_init_f(ulong dummy)
 */
board_early_init_f();
 
-   /* Example code showing how to enable the debug UART on MVEBU */
-#ifdef EARLY_UART
-   /*
-* Debug UART can be used from here if required:
-*
-* debug_uart_init();
-* printch('a');
-* printhex8(0x1234);
-* printascii("string");
-*/
-#endif
-
/*
 * Use special translation offset for SPL. This needs to be
 * configured *before* spl_init() is called as this function
-- 
2.20.1



Re: [PATCH 2/3] efi: ECPT add EBBRv2.0 conformance profile

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

Display the EBBRv2.0 conformance in the ECPT table.

The EBBRv2.0 conformance profile is set in the ECPT if
CONFIG_EFI_EBBR_2_0_CONFORMANCE=y.
The config defaults to 'n'.


Signed-off-by: Jose Marinho 
---
  include/efi_api.h| 4 
  lib/efi_loader/Kconfig   | 6 ++
  lib/efi_loader/efi_conformance.c | 9 +
  3 files changed, 19 insertions(+)

diff --git a/include/efi_api.h b/include/efi_api.h
index 6fd4f04de3..49919caa35 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -230,6 +230,10 @@ enum efi_reset_type {
EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)

+#define EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID \
+   EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
+0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
+
  struct efi_conformance_profiles_table {
u16 version;
u16 number_of_profiles;
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index b2398976f4..ab7476f68b 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -373,4 +373,10 @@ config EFI_ECPT
help
  Enabling this option created the ECPT UEFI table.

+config EFI_EBBR_2_0_CONFORMANCE
+   bool "Add the EBBRv2.0 conformance entry to the ECPT table"
+   depends on EFI_ECPT


With this dependency the symbol EFI_EBBR_2_0_CONFORMANCE is superfluous.

Can we add EFI_EBBR_2_0_CONFORMANCE unconditionally or are there
relevant configuration flags in U-Boot that must be enabled to claim
EBBR 2.0 compliance? E.g.

* CONFIG_CMD_BOOTEFI_BOOTMGR
* CONFIG_EFI_GET_TIME
* CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT

Best regards

Heinrich


+   default n
+   help
+ Enabling this option adds the EBBRv2.0 conformance entry to the ECPT 
UEFI table.
  endif
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
index 86c26d6b79..b490ff3326 100644
--- a/lib/efi_loader/efi_conformance.c
+++ b/lib/efi_loader/efi_conformance.c
@@ -12,6 +12,7 @@
  #include 

  const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+const efi_guid_t efi_ebbr_2_0_guid = EFI_CONFORMANCE_PROFILE_EBBR_2_0_GUID;

  #define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1

@@ -29,6 +30,9 @@ efi_status_t efi_ecpt_register(void)

EFI_PRINT("ECPT table creation start\n");

+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE))
+   num_entries++;
+
ecpt_size = num_entries * sizeof(efi_guid_t)
+ sizeof(struct efi_conformance_profiles_table);
ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
@@ -44,6 +48,11 @@ efi_status_t efi_ecpt_register(void)
ecpt->version = EFI_CONFORMANCE_PROFILES_TABLE_VERSION;
ecpt->number_of_profiles = num_entries;

+   if (IS_ENABLED(CONFIG_EFI_EBBR_2_0_CONFORMANCE)) {
+   num_entries--;
+   guidcpy(&ecpt->conformance_profiles[num_entries], 
&efi_ecpt_guid);
+   }
+
if (num_entries)
EFI_PRINT("ECPT check conformance profiles, not all entries 
populated in table\n");





Re: [PATCH 1/3] efi: Create ECPT table

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 13:55, Jose Marinho wrote:

The ECPT table will be included in the UEFI specification 2.9+.
The ECPT table was introduced in UEFI following the code-first path. The
acceptance ticket can be viewed at:
https://bugzilla.tianocore.org/show_bug.cgi?id=3591

The Conformance Profiles table is a UEFI configuration table that contains
GUID of the UEFI profiles that the UEFI implementation conforms with.

The ECPT table is created when CONFIG_EFI_ECPT=y.
The config is set by default.

Signed-off-by: Jose Marinho 
---
  cmd/efidebug.c   |  4 ++
  include/efi_api.h| 10 +
  include/efi_loader.h |  7 
  lib/efi_loader/Kconfig   |  6 +++
  lib/efi_loader/Makefile  |  1 +
  lib/efi_loader/efi_conformance.c | 66 
  lib/efi_loader/efi_setup.c   |  6 +++
  7 files changed, 100 insertions(+)
  create mode 100644 lib/efi_loader/efi_conformance.c

diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index a977ca9c72..a53a5029fa 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -619,6 +619,10 @@ static const struct {
"TCG2 Final Events Table",
EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
},
+   {
+   "EFI Conformance Profiles Table",
+   EFI_CONFORMANCE_PROFILES_TABLE_GUID,


Just as side note. Consider sending a patch for GRUB to amend:

grub-core/commands/efi/lsefisystab.c
include/grub/efi/api.h


+   },
  };

  /**
diff --git a/include/efi_api.h b/include/efi_api.h
index 80109f012b..6fd4f04de3 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -226,6 +226,16 @@ enum efi_reset_type {
EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)

+#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \
+   EFI_GUID(0x36122546, 0xf7ef, 0x4c8f, 0xbd, 0x9b, \
+0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b)
+
+struct efi_conformance_profiles_table {
+   u16 version;
+   u16 number_of_profiles;
+   efi_guid_t  conformance_profiles[];
+} __packed;
+
  struct efi_capsule_header {
efi_guid_t capsule_guid;
u32 header_size;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index d52e399841..d20ff396d0 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -976,6 +976,13 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
   */
  efi_status_t efi_esrt_register(void);

+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void);
+
  /**
   * efi_esrt_populate() - Populates the ESRT entries from the FMP instances
   * present in the system.
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 700dc838dd..b2398976f4 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -367,4 +367,10 @@ config EFI_ESRT
help
  Enabling this option creates the ESRT UEFI system table.

+config EFI_ECPT
+   bool "Enable the UEFI ECPT generation"
+   default y
+   help
+ Enabling this option created the ECPT UEFI table.
+
  endif
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index fd344cea29..9f5a0cebd1 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
  obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
  obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
  obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
+obj-$(CONFIG_EFI_ECPT) += efi_conformance.o

  EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
  $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c
new file mode 100644
index 00..86c26d6b79
--- /dev/null
+++ b/lib/efi_loader/efi_conformance.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  EFI conformance profile table
+ *
+ *  Copyright (C) 2022 Arm Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
+
+#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1
+
+/**
+ * efi_ecpt_register() - Install the ECPT system table.
+ *
+ * Return: status code
+ */
+efi_status_t efi_ecpt_register(void)
+{
+   int num_entries = 0;


Shouldn't we add EFI_CONFORMANCE_PROFILES_EBBR_2_0_GUID as entry?
What would be the point of adding an empty ECPT table?


+   struct efi_conformance_profiles_table *ecpt;
+   efi_status_t ret;
+   size_t ecpt_size = 0;
+
+   EFI_PRINT("ECPT table creation start\n");


This function is not called via the EFI API. Please, use log_debug().

Best regards

Heinrich


+
+   ecpt_size = num_entries * sizeof(efi_guid_t)
+   + sizeof(struct efi_conformance_profiles_table);
+   ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, ecpt_size,
+   (void **)&ecpt);

Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Heinrich Schuchardt

On 12/17/21 17:37, Simon Glass wrote:

Hi Heinrich,

On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:


On 12/4/21 07:56, Simon Glass wrote:

At present only the backspace key is supported in U-Boot, when running as
an EFI app. Add support for arrows, home and end as well, to make the CLI
more friendly.

Signed-off-by: Simon Glass 
---

(no changes since v1)

   drivers/serial/serial_efi.c | 11 +--
   1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
index 33ddbd6080c..0067576389d 100644
--- a/drivers/serial/serial_efi.c
+++ b/drivers/serial/serial_efi.c
@@ -24,6 +24,9 @@ struct serial_efi_priv {
   bool have_key;
   };

+/* Convert a lower-case character to its ctrl-char equivalent */
+#define CTL_CH(c)((c) - 'a' + 1)
+
   int serial_efi_setbrg(struct udevice *dev, int baudrate)
   {
   return 0;
@@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv *priv)
   static int serial_efi_getc(struct udevice *dev)
   {
   struct serial_efi_priv *priv = dev_get_priv(dev);
+ char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
   int ret, ch;

   ret = serial_efi_get_key(priv);
@@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
* key scan code of 8. Handle this so that backspace works correctly
* in the U-Boot command line.
*/
- if (!ch && priv->key.scan_code == 8)
- ch = 8;
+ if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
+ ch = conv_scan[priv->key.scan_code];
+ if (ch >= 'a')
+ ch -= 'a' - 1;


This is not what a serial console would use in Linux. Just try U-Boot's
conitrace command. If you use the following, we get compatibility with
the rest of U-Boot:

1b 5b 32 7e - insert
1b 5b 33 7e - delete
1b 5b 35 7e - page up
1b 5b 36 7e - page down
1b 5b 41 - up
1b 5b 42 - down
1b 5b 43 - right
1b 5b 44 - left
1b 5b 46 - end
1b 5b 48 - home


That's more complicated since it requires the serial driver to convert
one character into multiple. We can always add it later if needed. But
this does command-line history, etc. working in the app.


Yes you will need a ring buffer as in the USB keyboard driver.

lib/efi_loader/efi_console.c only understands the multi-byte sequences.
I do not know if there are other places which have the same limitation.

Best regards

Heinrich



Regards,
Simon




Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Adam Ford
On Fri, Dec 17, 2021 at 10:35 AM Angus Ainslie  wrote:
>
> Hi Fabio,
>
> On 2021-12-17 08:28, Fabio Estevam wrote:
> > Hi Angus,
> >
> > On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:
> >>
> >> Add the USB regs for SDP mode
> >>
> >> Signed-off-by: Angus Ainslie 
> >> ---
> >>  arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
> >>  1 file changed, 5 insertions(+)
> >>
> >> diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> index 8cb499d3a3..bd474f88a6 100644
> >> --- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> +++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> >> @@ -103,6 +103,11 @@
> >> IMX_CSPI2_BASE, \
> >> IMX_CSPI3_BASE
> >>
> >> +#define USB1_BASE_ADDR 0x3810
> >> +#define USB2_BASE_ADDR 0x3820
> >> +#define USB1_PHY_BASE_ADDR 0x381F
> >> +#define USB2_PHY_BASE_ADDR 0x382F
> >
> > Some time ago I sent a similar patch and the feedback from Marek was
> > that these
> > base addresses should be retrieved from the devicetree instead.

I didn't think Driver model was a requirement for SPL.

>
> I had problems getting the dwc3 to initialize properly when using the
> device model in the SPL. I'm currently just using this in the SPL and
> the device model in u-boot.
>
> I'll take another shot at initializing the dwc3 in the SPL with the DM.

Could we compromise by putting the #define statements in an ifdef to
only enable them when SPL is being built?


>
> Thanks
> Angus


Re: [PATCH 2/2] fdtgrep: Handle an empty output tree

2021-12-17 Thread Simon Glass
In strange cases it is possible for fdtgrep to find nothing to output.
Typically this means that the resulting SPL device tree is not going to
allow anything to boot, but at present the tree is actually invalid,
since it only has an END tag in the struct region.

The FDT spec requires at least a root node. So add a special case to
include at least this, if the FDT_REG_SUPERNODES flag is set.

This ensures that grepping an empty tree still produces a valid tree.

Also add comments to the enum since it is not completely obvious from
the names now.

The typical symptom of this problem is a message from binman:

   pylibfdt error -11: FDT_ERR_BADSTRUCTURE

Signed-off-by: Simon Glass 
---

 boot/fdt_region.c| 43 +--
 include/fdt_region.h |  1 +
 2 files changed, 38 insertions(+), 6 deletions(-)

Applied to u-boot-dm/next, thanks!


Re: [PATCH 1/2] fdtgrep: Correct alignment of struct section

2021-12-17 Thread Simon Glass
When outputting a devicetree we should not align the struct section to a
16-byte boundary. The normal position is fine, which is 8-byte aligned.

This avoids leaving adding 8 extra zero bytes in the output tree in the
case where the reserved section is empty (i.e has 16 zero bytes).

Signed-off-by: Simon Glass 
---

 tools/fdtgrep.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Applied to u-boot-dm/next, thanks!


Re: [PATCH v5 22/28] x86: efi: Show the system-table revision

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 13:34, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > Show the revision of this table as it can be important.
> >
> > Alo update the 'efi table' entry to show the actual address of the EFI
>
> %s/Alo/Also/
>
> > table rather than our table that points to it. This saves a step and the
> > intermediate table has nothing else in it.
>
> Should this information been shown by the 'efi' command instead of 'bdinfo'?

Perhaps we should add an 'efi info' command for this and various other
things. We could show a lot more info.

But as you know, I like to have EFI more integrated into U-Boot and
the bdinfo command is used for all sorts of subsystems. It is a
natural place for people to look for the basics.

Regards,
Simon


Re: [PATCH v5 21/28] efi: Support the efi command in the app

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 13:27, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > At present the 'efi' command only works in the EFI payload. Update it to
> > work in the app too, so the memory map can be examined.
>
> cmd/efi.c seems to be duplicating function do_efi_show_memmap(). In a
> future patch we should try to move to using common code for commands efi
> and efidebug.

Yes and that depends on EFI_LOADER. Perhaps one day we can have a
common helper for this, e.g. in lib/efi ?

Regards,
Simon


Re: [PATCH v5 15/28] efi: Move exit_boot_services into a function

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Sat, 4 Dec 2021 at 12:13, Heinrich Schuchardt  wrote:
>
> On 12/4/21 16:56, Simon Glass wrote:
> > At present this code is inline in the app and stub. But they do the same
> > thing. The difference is that the stub does it immediately and the app
> > doesn't want to do it until the end (when it boots a kernel) or not at
> > all, if returning to UEFI.
> >
> > Move it into a function so it can be called as needed.
> >
> > Also store the memory map so that it can be accessed within the app if
> > needed.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Add a sentence about what the patch does
> >
> >   include/efi.h  | 32 ++
> >   lib/efi/efi.c  | 68 ++
> >   lib/efi/efi_app.c  |  3 ++
> >   lib/efi/efi_stub.c | 66 
> >   4 files changed, 114 insertions(+), 55 deletions(-)
> >
[..]

> > +/**
> > + * efi_store_memory_map() - Collect the memory-map info from EFI
> > + *
> > + * Collect the memory info and store it for later use, e.g. in calling
> > + * exit_boot_services()
> > + *
> > + * @priv:Pointer to private EFI structure
> > + * @return 0 if OK, non-zero on error
>
> %s/@return/Return:/

I will have to try to remember that. We are on our 3rd comment style now.

>
> Cf.
> https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
>

[..]

>
> Missing function description
>
> > +int efi_call_exit_boot_services(void)

Putting your comment above the code you refer to defeats 'patman
status -C', so could you please put it below?

The comment is in the header file as this is an exported function.

Regards,
Simon


Re: [PATCH v5 18/28] efi: Show when allocated pages are used

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:55, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > Add a message here so that both paths of memory allocation are reported.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v2)
> >
> > Changes in v2:
> > - Use log_info() instead of printf()
> >
> >   lib/efi/efi_app.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> > index e454f1a1564..36e3f1de427 100644
> > --- a/lib/efi/efi_app.c
> > +++ b/lib/efi/efi_app.c
> > @@ -121,13 +121,14 @@ static efi_status_t setup_memory(struct efi_priv 
> > *priv)
> >   ret = boot->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> >  priv->image_data_type, pages, &addr);
> >   if (ret) {
>
> If AllocatePages() fails the system is out of memory. Just return to the
> calling firmware with EFI_OUT_OF_RESOURCES.

I have left this as it is as sometimes it is possible to allocate from
the pool even if allocate_pages() fails. I hit this on an Intel
platform some years ago.

In any case your comment does not relate to this patch.

Regards,
Simon


Re: [PATCH v5 05/28] efi: serial: Support arrow keys

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:44, Heinrich Schuchardt  wrote:
>
> On 12/4/21 07:56, Simon Glass wrote:
> > At present only the backspace key is supported in U-Boot, when running as
> > an EFI app. Add support for arrows, home and end as well, to make the CLI
> > more friendly.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v1)
> >
> >   drivers/serial/serial_efi.c | 11 +--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c
> > index 33ddbd6080c..0067576389d 100644
> > --- a/drivers/serial/serial_efi.c
> > +++ b/drivers/serial/serial_efi.c
> > @@ -24,6 +24,9 @@ struct serial_efi_priv {
> >   bool have_key;
> >   };
> >
> > +/* Convert a lower-case character to its ctrl-char equivalent */
> > +#define CTL_CH(c)((c) - 'a' + 1)
> > +
> >   int serial_efi_setbrg(struct udevice *dev, int baudrate)
> >   {
> >   return 0;
> > @@ -49,6 +52,7 @@ static int serial_efi_get_key(struct serial_efi_priv 
> > *priv)
> >   static int serial_efi_getc(struct udevice *dev)
> >   {
> >   struct serial_efi_priv *priv = dev_get_priv(dev);
> > + char conv_scan[10] = {0, 'p', 'n', 'f', 'b', 'a', 'e', 0, 8};
> >   int ret, ch;
> >
> >   ret = serial_efi_get_key(priv);
> > @@ -63,8 +67,11 @@ static int serial_efi_getc(struct udevice *dev)
> >* key scan code of 8. Handle this so that backspace works correctly
> >* in the U-Boot command line.
> >*/
> > - if (!ch && priv->key.scan_code == 8)
> > - ch = 8;
> > + if (!ch && priv->key.scan_code < sizeof(conv_scan)) {
> > + ch = conv_scan[priv->key.scan_code];
> > + if (ch >= 'a')
> > + ch -= 'a' - 1;
>
> This is not what a serial console would use in Linux. Just try U-Boot's
> conitrace command. If you use the following, we get compatibility with
> the rest of U-Boot:
>
> 1b 5b 32 7e - insert
> 1b 5b 33 7e - delete
> 1b 5b 35 7e - page up
> 1b 5b 36 7e - page down
> 1b 5b 41 - up
> 1b 5b 42 - down
> 1b 5b 43 - right
> 1b 5b 44 - left
> 1b 5b 46 - end
> 1b 5b 48 - home

That's more complicated since it requires the serial driver to convert
one character into multiple. We can always add it later if needed. But
this does command-line history, etc. working in the app.

Regards,
Simon


Re: [PATCH v5 04/28] efi: Locate all block devices in the app

2021-12-17 Thread Simon Glass
Hi Heinrich,

On Thu, 9 Dec 2021 at 12:23, Heinrich Schuchardt  wrote:
>
> On 12/4/21 10:43, Heinrich Schuchardt wrote:
> > On 12/4/21 16:56, Simon Glass wrote:
> >> When starting the app, locate all block devices and make them available
> >> to U-Boot. This allows listing partitions and accessing files in
> >> filesystems.
> >>
> >> EFI also has the concept of 'disks', meaning boot media. For now, this
> >> is not obviously useful in U-Boot, but add code to at least locate these.
> >> This can be expanded later as needed.
> >>
> >> Series-changes; 2
> >> - Store device path in struct efi_media_plat
> >> - Don't export efi_bind_block()
> >> - Only bind devices for media devices, not for partitions
> >> - Show devices that are processed
> >> - Update documentation
> >>
> >> Signed-off-by: Simon Glass 
> >> ---
> >>
> >> (no changes since v1)
> >>
> >>   doc/develop/uefi/u-boot_on_efi.rst |   4 +-
> >>   include/efi.h  |   6 +-
> >>   include/efi_api.h  |  15 ++
> >>   lib/efi/efi_app.c  | 223 +
> >>   4 files changed, 243 insertions(+), 5 deletions(-)
[..]

> >> +static int setup_disks(void)
> >> +{
> >> +/* This is not fully implemented yet */
>
> see hint below.
>
> >> +return 0;
> >> +
> >> +efi_guid_t efi_disk_guid = EFI_DISK_IO_PROTOCOL_GUID;
>
> U-Boot does not implement the EFI_DISK_IO_PROTOCOL. So you will not be
> able to run U-Boot as an EFI app loaded by U-Boot which might be nice
> for testing.
>
> The more basic protocol is the EFI_BLOCK_IO_PROTOCOL. The difference is
> that the EFI_BLOCK_IO_PROTOCOL requires using a properly aligned buffer.
>
> >> +struct efi_boot_services *boot = efi_get_boot();
> >> +struct efi_disk *disk;
> >> +int ret;
> >> +
> >> +if (!boot)
> >> +return log_msg_ret("sys", -ENOSYS);
> >> +ret = boot->locate_protocol(&efi_disk_guid, NULL, (void **)&disk);
>
> If you want to find all handles implementing a protocol, you can use
> EFI_BOOT_SERVICES.LocateHandleBuffer() with SearchType ByProtocol.
>
> I guess we should add this patch to U-Boot once it is completed.

OK, let's drop this code then.

[..]
Regards,
Simon


Re: [PATCH 2/2] doc: add Arm Juno board documentation

2021-12-17 Thread Simon Glass
On Tue, 14 Dec 2021 at 10:55, Andre Przywara  wrote:
>
> The Juno Arm development board is an open, vendor-neutral, Armv8-A
> development platform.
> Add documentation that briefly outlines the hardware, and describes
> building and installation of U-Boot.
>
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/armltd/index.rst |   1 +
>  doc/board/armltd/juno.rst  | 117 +
>  2 files changed, 118 insertions(+)
>  create mode 100644 doc/board/armltd/juno.rst
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/2] doc: Add documentation for the Arm VExpress64 board configs

2021-12-17 Thread Simon Glass
Hi Andre,

On Tue, 14 Dec 2021 at 10:55, Andre Przywara  wrote:
>
> From: Peter Hoyes 
>
> Create a new documentation section for Arm Ltd boards with a sub-page
> for the FVP VExpress64 system.
>
> Signed-off-by: Peter Hoyes 
> [Andre: remove Juno stub]
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/armltd/fvp64.rst | 30 ++
>  doc/board/armltd/index.rst | 10 ++
>  doc/board/index.rst|  1 +
>  3 files changed, 41 insertions(+)
>  create mode 100644 doc/board/armltd/fvp64.rst
>  create mode 100644 doc/board/armltd/index.rst
>
> diff --git a/doc/board/armltd/fvp64.rst b/doc/board/armltd/fvp64.rst
> new file mode 100644
> index 00..9817b0aa3f
> --- /dev/null
> +++ b/doc/board/armltd/fvp64.rst
> @@ -0,0 +1,30 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +Fixed Virtual Platforms
> +===
> +
> +The Fixed Virtual Platforms (FVP) are complete software simulations of an Arm
> +system, including processor, memory and peripherals. They are set out in a
> +"programmer's view", which gives a comprehensive model on which to build and
> +test software.
> +
> +The supported FVPs are available free of charge and can be downloaded from 
> the
> +Arm developer site [1]_ (user registration might be required).
> +
> +Supported features:
> +
> + * GICv3
> + * Generic timer
> + * PL011 UART
> +
> +The default configuration assumes that U-Boot is bootstrapped using a 
> suitable
> +bootloader, such as Trusted Firmware-A [4]_. The u-boot binary can be passed

TF-A has become a bootloader?!

> +into the TF-A build: ``make PLAT= all fip BL33=u-boot.bin``

What is  in this case?

> +
> +The FVPs can be debugged using Arm Development Studio [2]_.
> +
> +References
> +--
> +
> +.. [1] 
> https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms
> +.. [2] 
> https://developer.arm.com/tools-and-software/embedded/arm-development-studio
> diff --git a/doc/board/armltd/index.rst b/doc/board/armltd/index.rst
> new file mode 100644
> index 00..caa6fd2bb0
> --- /dev/null
> +++ b/doc/board/armltd/index.rst
> @@ -0,0 +1,10 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +.. Copyright (C) 2021 Arm Ltd.
> +
> +ARM Ltd. boards and emulated systems
> +
> +
> +.. toctree::
> +   :maxdepth: 2
> +
> +   fvp64
> diff --git a/doc/board/index.rst b/doc/board/index.rst
> index 74ea33e081..78b486538b 100644
> --- a/doc/board/index.rst
> +++ b/doc/board/index.rst
> @@ -11,6 +11,7 @@ Board-specific doc
> AndesTech/index
> amlogic/index
> apple/index
> +   armltd/index
> atmel/index
> congatec/index
> coreboot/index
> --
> 2.25.1
>

Regards,
Simon


Re: [PATCH] doc: board: Add Calxeda Highbank/Midway documentation

2021-12-17 Thread Simon Glass
Hi Andre,

On Tue, 14 Dec 2021 at 10:47, Andre Przywara  wrote:
>
> The Calxeda servers are using U-Boot as the primary bootloader, which
> was shipped as part of a firmware upgrade package.
> Even though the machines are considered legacy at this point, the port
> still works, so deserves some documentation.
>
> Signed-off-by: Andre Przywara 
> ---
>  doc/board/highbank/highbank.rst | 78 +
>  doc/board/highbank/index.rst|  9 
>  doc/board/index.rst |  1 +
>  3 files changed, 88 insertions(+)
>  create mode 100644 doc/board/highbank/highbank.rst
>  create mode 100644 doc/board/highbank/index.rst

Reviewed-by: Simon Glass 

nits below

>
> diff --git a/doc/board/highbank/highbank.rst b/doc/board/highbank/highbank.rst
> new file mode 100644
> index 00..654ef8a026
> --- /dev/null
> +++ b/doc/board/highbank/highbank.rst
> @@ -0,0 +1,78 @@
> +Calxeda Highbank/Midway board support
> +=
> +
> +The Calxeda ECX-1000 ("Highbank") and ECX-2000 ("Midway") were ARM based

s/were/are/

Present tense is much easier to understand.

> +servers, providing high-density cluster systems. A single motherboard could
> +host between 12 and 48 nodes, each with their own quad-core ARMv7
> +processor, private DRAM and peripherals, connected through a high-bandwith
> +and low-latency "fabric" network. Multiple motherboards could be connected
> +together, to extend this fabric.
> +
> +For the purpose of U-Boot we just care about a single node, this can be
> +used as a single system, just using the fabric to connect to some Ethernet
> +network. Each node boots on its own, either from a local hard disk, or
> +via the network.
> +
> +The earlier ECX-1000 nodes ("Highbank") contain four ARM Cortex-A9 cores,
> +a Cortex-M3 system controller, three 10GBit/s MACs and five SATA
> +controllers. The DRAM is limited to 4GB.
> +
> +The later ECX-2000 nodes ("Midway") use four Cortex-A15 cores, alongside
> +two Cortex-A7 management cores, and support up to 32GB of DRAM, while
> +keeping the other peripherals.
> +
> +For the purpose of U-Boot those two SoCs are very similar, so we offer
> +one build target. The subtle differences are handled at runtime.
> +Calxeda as a company is long defunct, and the remaining systems are
> +considered legacy at this point.
> +
> +Bgilding U-Boot

Building

> +---
> +There is only one defconfig to cover both systems::
> +
> +$ make highbank_defconfig
> +$ make
> +
> +This will create ``u-boot.bin``, which could become part of the firmware 
> update
> +package, or could be chainloaded by the existing U-Boot, see below for more
> +details.
> +
> +Boot process
> +
> +Upon powering up a node (which would be controlled by some BMC style

s/would be/is/

We don't really care about tense, IMO. I suggest dropping 'would' and
'was', etc.

> +management controller on the motherboard), the system controller ("ECME")
> +would start and do some system initialisation (fabric registration,
> +DRAM init, clock setup). It would load the device tree binary, some secure
> +monitor code (``a9boot``/``a15boot``) and a U-Boot binary from SPI flash
> +into DRAM, then power up the actual application cores (ARM Cortex-A9/A15).
> +They would start executing ``a9boot``/``a15boot``, registering the PSCI SMC
> +handlers, then dropping into U-Boot, but in non-secure state (HYP mode on
> +the A15s).
> +
> +U-Boot would act as a mere loader, trying to find some ``boot.scr`` file on
> +the local hard disks, or reverting to PXE boot.
> +
> +Updating U-Boot
> +---
> +The U-Boot binary is loaded from SPI flash, which is controlled exclusively
> +by the ECME. This can be reached via IPMI using the LANplus transport 
> protocol.
> +Updating the SPI flash content requires vendor specific additions to the
> +IPMI protocol, support for which was never upstreamed to ipmitool or
> +FreeIPMI. Some older repositories for `ipmitool`_, the `pyipmi`_ library and
> +a Python `management script`_ to update the SPI flash can be found on Github.
> +
> +A simpler and safer way to get an up-to-date U-Boot running, is chainloading
> +it via the legacy U-Boot::
> +
> +$ mkimage -A arm -O u-boot -T standalone -C none -a 0x8000 -e 0x8000 \
> +  -n U-Boot -d u-boot.bin u-boot-highbank.img
> +
> +Then load this image file, either from hard disk, or via TFTP, from the
> +existing U-Boot, and execute it with bootm::
> +
> +=> tftpboot 0x8000 u-boot-highbank.img
> +=> bootm
> +
> +.. _`ipmitool`: https://github.com/Cynerva/ipmitool
> +.. _`pyipmi`: https://pypi.org/project/pyipmi/
> +.. _`management script`: https://github.com/Cynerva/cxmanage
> diff --git a/doc/board/highbank/index.rst b/doc/board/highbank/index.rst
> new file mode 100644
> index 00..b6975ca496
> --- /dev/null
> +++ b/doc/board/highbank/index.rst
> @@ -0,0 +1,9 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +
> +Highbank
> +
> +
> +.. toctre

Re: [PATCH] sunxi: add board documentation

2021-12-17 Thread Simon Glass
Hi Andre,

On Sun, 12 Dec 2021 at 18:03, Andre Przywara  wrote:
>
> Add some long overdue instructions for building and installing U-Boot on
> Allwinner SoC based boards.
> This describes the building process, including TF-A and crust, plus
> installation to SD card, eMMC and SPI flash, both from Linux and U-Boot
> itself. Also describe FEL booting.
>
> Signed-off-by: Andre Przywara 
> ---
> Hi,
>
> please have a look whether this makes sense. Feel free to just try something,
> and point out ambiguities or missing bits. For missing topics, please
> send a follow-up patch ;-)
>
> Also this is quite long, shall this be split up in two (or more) files?
>
> This is what rst.ninjs.org made of it, if you prefer to read it formatted:
> https://paste.c-net.org/PleasantNeedy
>
> Cheers,
> Andre
>
>  doc/board/allwinner/index.rst |   9 +
>  doc/board/allwinner/sunxi.rst | 304 ++
>  2 files changed, 313 insertions(+)
>  create mode 100644 doc/board/allwinner/index.rst
>  create mode 100644 doc/board/allwinner/sunxi.rst

Reviewed-by: Simon Glass 

I agree that a follow-on patch to remove the duplicated files would be
helpful, but this patch is a big step forward on its own.

It would be interesting to convert sunxi to use binman.

Regards,
Simon


Re: [PATCH v2] phy: zynqmp: Add serdes/psgtr driver

2021-12-17 Thread Simon Glass
Hi Michal,

On Wed, 15 Dec 2021 at 02:58, Michal Simek  wrote:
>
> Add PSGTR driver for Xilinx ZynqMP.
> The most of configurations are taken from Linux kernel psgtr driver.
>
> USB3.0 and SGMII configurations are tested on SOM. In SGMII case also
> IOU_SLCR reg is updated to get proper clock setup and signal detection
> configuration.
>
> Signed-off-by: Michal Simek 
> ---
>
> Changes in v2:
> - Add phy power on sequence
> - Use NUM_LANES in for loop
> - Use dev_remap_addr_name
> - Fix clk handling
>
>  MAINTAINERS  |   1 +
>  drivers/phy/Kconfig  |   7 +
>  drivers/phy/Makefile |   1 +
>  drivers/phy/phy-zynqmp.c | 760 +++
>  4 files changed, 769 insertions(+)
>  create mode 100644 drivers/phy/phy-zynqmp.c

Reviewed-by: Simon Glass 

Various nits below.

>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index de42663ac1ea..b36a4c44716b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -611,6 +611,7 @@ F:  drivers/mmc/zynq_sdhci.c
>  F: drivers/mtd/nand/raw/zynq_nand.c
>  F: drivers/net/phy/xilinx_phy.c
>  F: drivers/net/zynq_gem.c
> +F: drivers/phy/phy-zynqmp.c
>  F: drivers/serial/serial_zynq.c
>  F: drivers/reset/reset-zynqmp.c
>  F: drivers/rtc/zynqmp_rtc.c
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 4767d215f337..d79798429b18 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -281,6 +281,13 @@ config PHY_IMX8MQ_USB
> help
>   Support the USB3.0 PHY in NXP i.MX8MQ SoC
>
> +config PHY_XILINX_ZYNQMP
> +   tristate "Xilinx ZynqMP PHY driver"
> +   depends on PHY && ARCH_ZYNQMP
> +   help
> + Enable this to support ZynqMP High Speed Gigabit Transceiver
> + that is part of ZynqMP SoC.
> +
>  source "drivers/phy/rockchip/Kconfig"
>  source "drivers/phy/cadence/Kconfig"
>  source "drivers/phy/ti/Kconfig"
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 13a8ade8919f..bf9b40932fe3 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -38,5 +38,6 @@ obj-$(CONFIG_MT76X8_USB_PHY) += mt76x8-usb-phy.o
>  obj-$(CONFIG_PHY_DA8XX_USB) += phy-da8xx-usb.o
>  obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o
>  obj-$(CONFIG_PHY_IMX8MQ_USB) += phy-imx8mq-usb.o
> +obj-$(CONFIG_PHY_XILINX_ZYNQMP) += phy-zynqmp.o
>  obj-y += cadence/
>  obj-y += ti/
> diff --git a/drivers/phy/phy-zynqmp.c b/drivers/phy/phy-zynqmp.c
> new file mode 100644
> index ..1f43e6441af6
> --- /dev/null
> +++ b/drivers/phy/phy-zynqmp.c
> @@ -0,0 +1,760 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * phy-zynqmp.c - PHY driver for Xilinx ZynqMP GT.
> + *
> + * Copyright (C) 2018-2021 Xilinx Inc.
> + *
> + * Author: Anurag Kumar Vulisha 
> + * Author: Subbaraya Sundeep 
> + * Author: Laurent Pinchart 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Please check ordering

https://www.denx.de/wiki/U-Boot/CodingStyle

[..]

> +/* Protocol Type parameters */
> +#define XPSGTR_TYPE_USB0   0  /* USB controller 0 */
> +#define XPSGTR_TYPE_USB1   1  /* USB controller 1 */
> +#define XPSGTR_TYPE_SATA_0 2  /* SATA controller lane 0 */
> +#define XPSGTR_TYPE_SATA_1 3  /* SATA controller lane 1 */
> +#define XPSGTR_TYPE_PCIE_0 4  /* PCIe controller lane 0 */
> +#define XPSGTR_TYPE_PCIE_1 5  /* PCIe controller lane 1 */
> +#define XPSGTR_TYPE_PCIE_2 6  /* PCIe controller lane 2 */
> +#define XPSGTR_TYPE_PCIE_3 7  /* PCIe controller lane 3 */
> +#define XPSGTR_TYPE_DP_0   8  /* Display Port controller lane 0 
> */
> +#define XPSGTR_TYPE_DP_1   9  /* Display Port controller lane 1 
> */
> +#define XPSGTR_TYPE_SGMII0 10 /* Ethernet SGMII controller 0 */
> +#define XPSGTR_TYPE_SGMII1 11 /* Ethernet SGMII controller 1 */
> +#define XPSGTR_TYPE_SGMII2 12 /* Ethernet SGMII controller 2 */
> +#define XPSGTR_TYPE_SGMII3 13 /* Ethernet SGMII controller 3 */

Could use an enum...

> +
> +/* Timeout values */
> +#define TIMEOUT_US 1000
> +
> +#define IOU_SLCR_GEM_CLK_CTRL  0x308
> +#define GEM_CTRL_GEM_SGMII_MODEBIT(2)
> +#define GEM_CTRL_GEM_REF_SRC_SEL   BIT(1)
> +
> +#define IOU_SLCR_GEM_CTRL  0x360
> +#define GEM_CTRL_GEM_SGMII_SD  BIT(0)
> +
> +/**
> + * struct xpsgtr_ssc - structure to hold SSC settings for a lane
> + * @refclk_rate: PLL reference clock frequency
> + * @pll_ref_clk: value to be written to register for corresponding ref clk 
> rate
> + * @steps: number of steps of SSC (Spread Spectrum Clock)
> + * @step_size: step size of each step
> + */
> +struct xpsgtr_ssc {
> +   u32 refclk_rate;
> +   u8  pll_ref_clk;
> +   u32 steps;
> + 

Re: Are dt-bindings headers part of the device tree spec?

2021-12-17 Thread Simon Glass
Hi Sean,

On Wed, 15 Dec 2021 at 08:53, Sean Anderson  wrote:
>
>
> Hi all,
>
> I'm reviewing a clock driver [1], and the submitter has deviated from
> the defines used by Linux. For example, where Linux might have
>
> #define CLOCK_FOOBAR 5
>
> his driver might have
>
> #define CLK_FUBAR 6
>
> Which means that both the device tree source and the resulting device
> tree binary will be different.
>
> As I understand it, we try to be compatible with Linux on these things.
> However, it is unclear to me if include/dt-bindings is also part of
> this, or just the things in Documentation/devicetree/bindings. And if it
> is, do we need to have compatible sources, compatible binaries, or both?
> In general, I think we should try to have the same headers as well, but
> is it permitted to allow deviations with reasonable justification?

I think they should be the same, including the name and value. It gets
too confusing otherwise.

If there are conversions needed for U-Boot, perhaps they could be
handled by some #defines in the driver or another file in U-Boot.

Regards,
Simon

>
> --Sean
>
> [1] 
> https://lore.kernel.org/u-boot/de6e75a083647dfeec3058dd4dcc0419b08e155c.1637285375.git.weijie@mediatek.com/


Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Angus Ainslie

Hi Fabio,

On 2021-12-17 08:28, Fabio Estevam wrote:

Hi Angus,

On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:


Add the USB regs for SDP mode

Signed-off-by: Angus Ainslie 
---
 arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
b/arch/arm/include/asm/arch-imx8m/imx-regs.h

index 8cb499d3a3..bd474f88a6 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -103,6 +103,11 @@
IMX_CSPI2_BASE, \
IMX_CSPI3_BASE

+#define USB1_BASE_ADDR 0x3810
+#define USB2_BASE_ADDR 0x3820
+#define USB1_PHY_BASE_ADDR 0x381F
+#define USB2_PHY_BASE_ADDR 0x382F


Some time ago I sent a similar patch and the feedback from Marek was 
that these

base addresses should be retrieved from the devicetree instead.


I had problems getting the dwc3 to initialize properly when using the 
device model in the SPL. I'm currently just using this in the SPL and 
the device model in u-boot.


I'll take another shot at initializing the dwc3 in the SPL with the DM.

Thanks
Angus


Re: [PATCH 2/3] arch: imx8m: imx-regs.h add the USB regs

2021-12-17 Thread Fabio Estevam
Hi Angus,

On Fri, Dec 17, 2021 at 12:21 PM Angus Ainslie  wrote:
>
> Add the USB regs for SDP mode
>
> Signed-off-by: Angus Ainslie 
> ---
>  arch/arm/include/asm/arch-imx8m/imx-regs.h | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h 
> b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> index 8cb499d3a3..bd474f88a6 100644
> --- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
> +++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
> @@ -103,6 +103,11 @@
> IMX_CSPI2_BASE, \
> IMX_CSPI3_BASE
>
> +#define USB1_BASE_ADDR 0x3810
> +#define USB2_BASE_ADDR 0x3820
> +#define USB1_PHY_BASE_ADDR 0x381F
> +#define USB2_PHY_BASE_ADDR 0x382F

Some time ago I sent a similar patch and the feedback from Marek was that these
base addresses should be retrieved from the devicetree instead.


  1   2   >