[PATCH 0/2] ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO baseboard

2023-03-07 Thread Neil Armstrong
Add support for both the BananaPi BPI-CM4 module and the BananaPi
baseboard which is compatible with the RaspberryPi CM4IO baseboard.


The BananaPi BPI-CM4 module follows the CM4 specifications at [1],
but with a single HDMI port and a single DSI output.

The current CM4IO baseboard DT should work fine on the Raspberry CM4
baseboard and other derivatives baseboards, but proper DT should
be written for other baseboards.

The DT is imported from the submission done at [2] and applied
at [3].

[1] https://datasheets.raspberrypi.com/cm4io/cm4io-datasheet.pdf
[2] 
https://lore.kernel.org/all/20230303-topic-amlogic-upstream-bpi-cm4-v2-0-2ecfde76f...@linaro.org/
[3] https://git.kernel.org/amlogic/c/0262f2736978b1763363224698f47112a148dab0

Signed-off-by: Neil Armstrong 
---
Neil Armstrong (2):
  ARM: dts: import initial DT for BPI-CM4 module with BPI-CM4IO baseboard
  ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO 
baseboard

 arch/arm/dts/Makefile  |   1 +
 .../dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi  |   6 +
 arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts | 165 +
 arch/arm/dts/meson-g12b-bananapi-cm4.dtsi  | 388 +
 board/amlogic/u200/MAINTAINERS |   1 +
 configs/bananapi-cm4-cm4io_defconfig   |  84 +
 doc/board/amlogic/index.rst|   1 +
 7 files changed, 646 insertions(+)
---
base-commit: b08ffdffdce95e267e782366f4a77bf6b5537b28
change-id: 20230307-u-boot-cm4-1311815d8371

Best regards,
-- 
Neil Armstrong 



[PATCH 1/2] ARM: dts: import initial DT for BPI-CM4 module with BPI-CM4IO baseboard

2023-03-07 Thread Neil Armstrong
Import initial support for BPI-CM4 module with BPI-CM4IO baseboard
from the Linux submission applied at [1].

The BananaPi BPI-CM4 module follows the CM4 specifications at [2],
but with a single HDMI port and a single DSI output.

The current CM4IO baseboard DT should work fine on the Raspberry CM4
baseboard and other derivatives baseboards, but proper DT should
be written for other baseboards.

[1] https://git.kernel.org/amlogic/c/0262f2736978b1763363224698f47112a148dab0
[2] https://datasheets.raspberrypi.com/cm4io/cm4io-datasheet.pdf

Signed-off-by: Neil Armstrong 
---
 arch/arm/dts/Makefile  |   1 +
 arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts | 165 +++
 arch/arm/dts/meson-g12b-bananapi-cm4.dtsi  | 388 +
 3 files changed, 554 insertions(+)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index c160e884bf..0c149b636a 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -212,6 +212,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-g12b-odroid-n2.dtb \
meson-g12b-odroid-n2l.dtb \
meson-g12b-odroid-n2-plus.dtb \
+   meson-g12b-bananapi-cm4-cm4io.dtb \
meson-sm1-bananapi-m5.dtb \
meson-sm1-khadas-vim3l.dtb \
meson-sm1-odroid-c4.dtb \
diff --git a/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts 
b/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts
new file mode 100644
index 00..1b0c3881c6
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2023 Neil Armstrong 
+ */
+
+/dts-v1/;
+
+#include "meson-g12b-bananapi-cm4.dtsi"
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "bananapi,bpi-cm4io", "bananapi,bpi-cm4", "amlogic,a311d", 
"amlogic,g12b";
+   model = "BananaPi BPI-CM4IO Baseboard with BPI-CM4 Module";
+
+   aliases {
+   ethernet0 = ðmac;
+   i2c0 = &i2c1;
+   i2c1 = &i2c3;
+   };
+
+   adc-keys {
+   compatible = "adc-keys";
+   io-channels = <&saradc 2>;
+   io-channel-names = "buttons";
+   keyup-threshold-microvolt = <171>;
+
+   button-function {
+   label = "Function";
+   linux,code = ;
+   press-threshold-microvolt = <1>;
+   };
+   };
+
+   hdmi_connector: hdmi-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <&hdmi_tx_tmds_out>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-blue {
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio_ao GPIOAO_7 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+
+   led-green {
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   sound {
+   compatible = "amlogic,axg-sound-card";
+   model = "BPI-CM4IO";
+   audio-aux-devs = <&tdmout_b>;
+   audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
+   "TDMOUT_B IN 1", "FRDDR_B OUT 1",
+   "TDMOUT_B IN 2", "FRDDR_C OUT 1",
+   "TDM_B Playback", "TDMOUT_B OUT";
+
+   assigned-clocks = <&clkc CLKID_MPLL2>,
+ <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>;
+   assigned-clock-parents = <0>, <0>, <0>;
+   assigned-clock-rates = <294912000>,
+  <270950400>,
+  <393216000>;
+
+   dai-link-0 {
+   sound-dai = <&frddr_a>;
+   };
+
+   dai-link-1 {
+   sound-dai = <&frddr_b>;
+   };
+
+   dai-link-2 {
+   sound-dai = <&frddr_c>;
+   };
+
+   /* 8ch hdmi interface */
+   dai-link-3 {
+   sound-dai = <&tdmif_b>;
+   dai-format = "i2s";
+   dai-t

[PATCH 2/2] ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO baseboard

2023-03-07 Thread Neil Armstrong
Add support for both the BananaPi BPI-CM4 module and the BananaPi
baseboard which is compatible with the RaspberryPi CM4IO baseboard.

The BananaPi BPI-CM4 module follows the CM4 specifications at [1],
but with a single HDMI port and a single DSI output.

The current CM4IO baseboard DT should work fine on the Raspberry CM4
baseboard and other derivatives baseboards, but proper DT should
be written for other baseboards.

[1] https://datasheets.raspberrypi.com/cm4io/cm4io-datasheet.pdf

Signed-off-by: Neil Armstrong 
---
 .../dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi  |  6 ++
 board/amlogic/u200/MAINTAINERS |  1 +
 configs/bananapi-cm4-cm4io_defconfig   | 84 ++
 doc/board/amlogic/index.rst|  1 +
 4 files changed, 92 insertions(+)

diff --git a/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi 
b/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi
new file mode 100644
index 00..a60ba27806
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2023 Neil Armstrong 
+ */
+
+#include "meson-g12-common-u-boot.dtsi"
diff --git a/board/amlogic/u200/MAINTAINERS b/board/amlogic/u200/MAINTAINERS
index 47cec234a1..7535e489d1 100644
--- a/board/amlogic/u200/MAINTAINERS
+++ b/board/amlogic/u200/MAINTAINERS
@@ -4,6 +4,7 @@ S:  Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/u200/
 F: configs/u200_defconfig
+F: configs/bananapi-cm4-cm4io_defconfig
 F: configs/bananapi-m5_defconfig
 F: configs/radxa-zero_defconfig
 F: doc/board/amlogic/u200.rst
diff --git a/configs/bananapi-cm4-cm4io_defconfig 
b/configs/bananapi-cm4-cm4io_defconfig
new file mode 100644
index 00..0801b9d06f
--- /dev/null
+++ b/configs/bananapi-cm4-cm4io_defconfig
@@ -0,0 +1,84 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-bananapi-cm4-cm4io"
+CONFIG_MESON_G12A=y
+CONFIG_DEBUG_UART_BASE=0xff803000
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING="bpi-cm4io"
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_REMAKE_ELF=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_SYS_MAXARGS=32
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_BUTTON=y
+CONFIG_BUTTON_ADC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_MDIO_MUX=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_MDIO_MUX_MESON_G12A=y
+CONFIG_PCI=y
+CONFIG_PCIE_DW_MESON=y
+CONFIG_MESON_G12A_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_G12A=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_MESON_G12A=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index f945f672dd..e51b904582 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -22,6 +22,7 @@ This matrix concerns the actual source code version.
 |   |   | JetHub J80  |  | 
|| Odroid-Go-  | BananaPi-M5  |
 |   |   | |  | 
|| Ultra   |  |
 |   |   | |  | 
|| Odroid-N2L  |  |
+|   |   | |  | 
   

Re: [PATCH 0/2] ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO baseboard

2023-03-14 Thread Neil Armstrong
Hi,

On Tue, 07 Mar 2023 09:20:23 +0100, Neil Armstrong wrote:
> Add support for both the BananaPi BPI-CM4 module and the BananaPi
> baseboard which is compatible with the RaspberryPi CM4IO baseboard.
> 
> The BananaPi BPI-CM4 module follows the CM4 specifications at [1],
> but with a single HDMI port and a single DSI output.
> 
> The current CM4IO baseboard DT should work fine on the Raspberry CM4
> baseboard and other derivatives baseboards, but proper DT should
> be written for other baseboards.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-next)

[1/2] ARM: dts: import initial DT for BPI-CM4 module with BPI-CM4IO baseboard
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/384bfe31c8d77b69542e3bf76f823a42329847aa
[2/2] ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO 
baseboard
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/cc073f6c2241ff8adf2fc2869bd1a6fcf379a172

-- 
Neil



Re: [PATCH] ARM: meson: odroid-go-ultra: setup PMIC regulators are board init

2023-03-14 Thread Neil Armstrong
Hi,

On Fri, 10 Feb 2023 11:25:07 +0100, Neil Armstrong wrote:
> The Odroid Go Ultra has 2 chained PMICs RK818 and RK818, and needs
> an adjustment on the BUCK and LDO values.
> 
> Add the initial regulators values in -u-boot.dtsi & run the initial
> regulator setup in a new odroid-go-ultra board.
> 
> Proper OTG and BOOST regulators are still missing to have USB-A
> host properly working.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-next)

[1/1] ARM: meson: odroid-go-ultra: setup PMIC regulators are board init
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/de58694f0d5431627d7389f50a6b2034a682ba24

-- 
Neil



Re: [PATCH 30/33] doc: boards: amlogic: add documentation for BananaPi CM4IO

2023-03-20 Thread Neil Armstrong

On 20/03/2023 12:46, Christian Hewitt wrote:

Add build instructions for the BananaPi BPI-CM4IO carrier board with
BPI-CM4 module.

Signed-off-by: Christian Hewitt 
---
  board/amlogic/u200/MAINTAINERS   |   1 -
  board/amlogic/w400/MAINTAINERS   |   2 +
  doc/board/amlogic/bananapi-cm4io.rst | 152 +++
  doc/board/amlogic/index.rst  |   1 +
  4 files changed, 155 insertions(+), 1 deletion(-)
  create mode 100644 doc/board/amlogic/bananapi-cm4io.rst






+
+U-Boot Signing with Pre-Built FIP repo
+--
+
+.. code-block:: bash
+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip
+$ mkdir my-output-dir
+$ ./build-fip.sh bananapi-cm4io /path/to/u-boot/u-boot.bin my-output-dir



This should be bananapi-m2s since the same is used, or we should duplicate it 
for cm4io/cm4.

Neil






Re: [PATCH 30/33] doc: boards: amlogic: add documentation for BananaPi CM4IO

2023-03-20 Thread neil . armstrong

On 20/03/2023 13:23, Christian Hewitt wrote:



On 20 Mar 2023, at 4:13 pm, Neil Armstrong  wrote:

On 20/03/2023 12:46, Christian Hewitt wrote:

Add build instructions for the BananaPi BPI-CM4IO carrier board with
BPI-CM4 module.
Signed-off-by: Christian Hewitt 
---
  board/amlogic/u200/MAINTAINERS   |   1 -
  board/amlogic/w400/MAINTAINERS   |   2 +
  doc/board/amlogic/bananapi-cm4io.rst | 152 +++
  doc/board/amlogic/index.rst  |   1 +
  4 files changed, 155 insertions(+), 1 deletion(-)
  create mode 100644 doc/board/amlogic/bananapi-cm4io.rst





+
+U-Boot Signing with Pre-Built FIP repo
+--
+
+.. code-block:: bash
+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip
+$ mkdir my-output-dir
+$ ./build-fip.sh bananapi-cm4io /path/to/u-boot/u-boot.bin my-output-dir



This should be bananapi-m2s since the same is used, or we should duplicate it 
for cm4io/cm4.


https://github.com/LibreELEC/amlogic-boot-fip/tree/master/bananapi-cm4io

^ It’s the same FIPs that were submitted for M2S but for packaging
reasons I cloned them (users struggle to find images not explicitly
named for their board). I’ll submit patches for the M2S and M2-Pro
boards once this series is accepted (hopefully).


Ack, so no changes needed then !



Christian




[GIT PULL] Please pull u-boot-amlogic-20230131

2023-03-22 Thread Neil Armstrong



Hi Tom,

A single change to enable the odroid-go-ultra PMIC regulator at boot.

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/15691

Thanks,
Neil

The following changes since commit 88e08fc5f6e508eac46cd1dfb0379b11ae032c0a:

  Prepare v2023.04-rc4 (2023-03-13 20:52:48 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20230322

for you to fetch changes up to de58694f0d5431627d7389f50a6b2034a682ba24:

  ARM: meson: odroid-go-ultra: setup PMIC regulators are board init (2023-03-14 
09:03:16 +0100)


- odroid-go-ultra: setup PMIC regulators at board init


Neil Armstrong (1):
  ARM: meson: odroid-go-ultra: setup PMIC regulators are board init

 .../arm/dts/meson-g12b-odroid-go-ultra-u-boot.dtsi |  8 
 board/amlogic/odroid-go-ultra/MAINTAINERS  |  7 +++
 board/amlogic/odroid-go-ultra/Makefile |  5 +
 board/amlogic/odroid-go-ultra/odroid-go-ultra.c| 22 ++
 configs/odroid-go-ultra_defconfig  |  4 ++--
 5 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 board/amlogic/odroid-go-ultra/MAINTAINERS
 create mode 100644 board/amlogic/odroid-go-ultra/Makefile
 create mode 100644 board/amlogic/odroid-go-ultra/odroid-go-ultra.c


Re: [PATCH 00/33] doc: board: amlogic: spring clean-up of Amlogic docs

2023-03-22 Thread Neil Armstrong
Hi,

On Mon, 20 Mar 2023 11:45:36 +, Christian Hewitt wrote:
> Amlogic documentation spans U-Boot support from 2015-current resulting
> in older content being harder to follow. And due to many international
> contributors the docs also contain grammar quirks.
> 
> This series reworks all board documents to be more consistent. There is
> deliberate emphasis on using the amlogic-boot-fip repo for signing tasks
> as this is easier for most users to follow. The original/longer signing
> process (described as Manual Signing) has been tidied up.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-test)

[01/33] doc: boards: amlogic: update documentation for index page

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/862b7c1fcc5e94c7d91cc9caf22c7b6205b7fffd
[02/33] doc: boards: amlogic: update documentation for boot-flow

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4ce746b8cf07ed4c532a36fda587104d667bf54a
[03/33] doc: boards: amlogic: update documentation for pre-generated-fip's

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/3d1744b392ae57adfa1c068acb9f94a44cc82070
[04/33] doc: boards: amlogic: update documentation for Beelink GT-King

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/d0d4a85d14b18dda87ef0111a03644a9886aebd4
[05/33] doc: boards: amlogic: update documentation for Beelink GT-King Pro

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/c03d19d5dc0e20dde9c4b34feb0f47c59a82a640
[06/33] doc: boards: amlogic: update documentation for JetHub J100

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/cf43c9f7d3c7b4b83a94a9ff961b0807f4f92c47
[07/33] doc: boards: amlogic: update documentation for JetHub J80

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/47ab069e9a9dd047dcad3c984d8e6cbcb6e26a04
[08/33] doc: boards: amlogic: update documentation for Khadas VIM

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/329794577adf7e53ba1e0c3a86686e21655965c1
[09/33] doc: boards: amlogic: update documentation for Khadas VIM2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/e3de21c60685d15fd5746b23a7d72545889580cd
[10/33] doc: boards: amlogic: update documentation for Khadas VIM3

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/de54d4cc16b9d4bfdda196dac5bdbd0d8128cd02
[11/33] doc: boards: amlogic: update documentation for Khadas VIM3L

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/3240318b212d46e1e5ea4af92eec6b26b67f5ad4
[12/33] doc: boards: amlogic: update documentation for LaFrite

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/cb197ca63debc82d23a8ca419623278839b6ff48
[13/33] doc: boards: amlogic: update documentation for LePotato

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ba07d965dd5ee74e66c32bc5a3fce5c69ed4b2d2
[14/33] doc: boards: amlogic: update documentation for NanoPi-K2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/7c7ecc84f1c1edb79e7e2b1e0070b288cf1e22fc
[15/33] doc: boards: amlogic: update documentation for ODROID-C2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/665633ec055d15989e187861ea419518bf517017
[16/33] doc: boards: amlogic: update documentation for ODROID-C4

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4760b2e8e2e46ad61ab7ed91733786d9a9e4696c
[17/33] doc: boards: amlogic: update documentation for ODROID GO ULTRA

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/144ffe96aa1638028593afa2b669bcf08ac0ad38
[18/33] doc: boards: amlogic: update documentation for ODROID-N2/N2+

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/11a1fc1d305e773f27135adad56cbcc5e1c2bd6a
[19/33] doc: boards: amlogic: update documentation for ODROID-N2L

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/6ba5d42c42752829b22f80748972716d5bb27c59
[20/33] doc: boards: amlogic: update documentation for P200

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/f0b8c1f6a54b8ef45972a18e969250d859c9a866
[21/33] doc: boards: amlogic: update documentation for P201

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/db6b333e37c2a98e2bcc09a5545635aaeb2c1301
[22/33] doc: boards: amlogic: update documentation for Q200

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/3ce3109c3783c27aa18b0a17eb6d8ead23f92d85
[23/33] doc: boards: amlogic: update documentation for Radxa Zero

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/1b23862b4177151b477d740e8760d45978549926
[24/33] doc: boards: amlogic: update documentation for S400

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/aabf0dcb31dce2443975ab21871fa320

Re: [PATCH 01/13] docs: boards: amlogic: add bananapi-m5 to u200 maintainer file

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

The bananapi-m5 docs are missing from the file, so add them.

Signed-off-by: Christian Hewitt 
---
  board/amlogic/u200/MAINTAINERS | 1 +
  1 file changed, 1 insertion(+)

diff --git a/board/amlogic/u200/MAINTAINERS b/board/amlogic/u200/MAINTAINERS
index 47cec234a1..919e349922 100644
--- a/board/amlogic/u200/MAINTAINERS
+++ b/board/amlogic/u200/MAINTAINERS
@@ -7,4 +7,5 @@ F:  configs/u200_defconfig
  F:configs/bananapi-m5_defconfig
  F:configs/radxa-zero_defconfig
  F:doc/board/amlogic/u200.rst
+F: doc/board/amlogic/bananapi-m5.rst
  F:doc/board/amlogic/radxa-zero.rst


Reviewed-by: Neil Armstrong 


Re: [PATCH 04/13] docs: boards: amlogic: add documentation for BananaPi M2-Pro

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Add build docs for the BPI-M2-PRO board.

Signed-off-by: Christian Hewitt 
---
  board/amlogic/u200/MAINTAINERS   |   2 +
  doc/board/amlogic/bananapi-m2pro.rst | 142 +++
  doc/board/amlogic/index.rst  |   1 +
  3 files changed, 145 insertions(+)
  create mode 100644 doc/board/amlogic/bananapi-m2pro.rst

diff --git a/board/amlogic/u200/MAINTAINERS b/board/amlogic/u200/MAINTAINERS
index 919e349922..f429c212ba 100644
--- a/board/amlogic/u200/MAINTAINERS
+++ b/board/amlogic/u200/MAINTAINERS
@@ -4,8 +4,10 @@ S: Maintained
  L:u-boot-amlo...@groups.io
  F:board/amlogic/u200/
  F:configs/u200_defconfig
+F: configs/bananapi-m2pro_defconfig
  F:configs/bananapi-m5_defconfig
  F:configs/radxa-zero_defconfig
  F:doc/board/amlogic/u200.rst
+F: doc/board/amlogic/bananapi-m2pro.rst
  F:doc/board/amlogic/bananapi-m5.rst
  F:doc/board/amlogic/radxa-zero.rst
diff --git a/doc/board/amlogic/bananapi-m2pro.rst 
b/doc/board/amlogic/bananapi-m2pro.rst
new file mode 100644
index 00..6c2974f323
--- /dev/null
+++ b/doc/board/amlogic/bananapi-m2pro.rst
@@ -0,0 +1,142 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+U-Boot for BananaPi BPI-M2-PRO (S905X3)
+===
+
+BananaPi BPI-M2-PRO is a Single Board Computer manufactured by Sinovoip with 
the
+following specification:
+
+ - Amlogic S905X3 Arm Cortex-A55 quad-core SoC
+ - 2GB DDR4 SDRAM
+ - 16GB eMMC
+ - Gigabit Ethernet
+ - RTL8821CU USB WiFi (a/b/g/n/ac) + BT 5.0
+ - HDMI 2.1 display
+ - 40-pin GPIO header
+ - 2x USB 3.0 Host
+ - 1x DC Jack (power)
+ - microSD
+ - UART serial
+ - Infrared receiver
+
+Schematics are available from the manufacturer: 
https://wiki.banana-pi.org/Banana_Pi_BPI-M2_Pro
+
+U-Boot Compilation
+--
+
+.. code-block:: bash
+
+$ export CROSS_COMPILE=aarch64-none-elf-
+$ make bananapi-m2pro_defconfig
+$ make
+
+U-Boot Signing with Pre-Built FIP repo
+--
+
+.. code-block:: bash


Please add a newline here otherwise the doc fails to build, here and the other 
doc patches.

Thanks,

Neil


+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip
+$ mkdir my-output-dir
+$ ./build-fip.sh bananapi-m2pro /path/to/u-boot/u-boot.bin my-output-dir
+
+U-Boot Manual Signing
+-
+
+Amlogic does not provide sources for the firmware and tools needed to create a 
bootloader
+image so it is necessary to obtain binaries from sources published by the 
board vendor:
+
+.. code-block:: bash
+
+$ wget 
https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+$ wget 
https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+$ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
+$ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
+$ export 
PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
+
+$ DIR=bananapi-m2pro
+$ git clone --depth 1 https://github.com/Dangku/amlogic-u-boot.git -b 
odroidg12-v2015.01-c4-m5 $DIR
+
+$ cd $DIR
+$ make bananapi_m2pro_defconfig
+$ make
+$ export UBOOTDIR=$PWD
+
+Go back to the mainline U-Boot source tree then:
+
+.. code-block:: bash
+
+$ mkdir fip
+
+$ wget 
https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh
 -O fip/blx_fix.sh
+$ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
+$ cp $UBOOTDIR/build/board/bananapi/bananpi_m5/firmware/acs.bin fip/
+$ cp $UBOOTDIR/fip/g12a/bl2.bin fip/
+$ cp $UBOOTDIR/fip/g12a/bl30.bin fip/
+$ cp $UBOOTDIR/fip/g12a/bl31.img fip/
+$ cp $UBOOTDIR/fip/g12a/ddr3_1d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/ddr4_1d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/ddr4_2d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/diag_lpddr4.fw fip/
+$ cp $UBOOTDIR/fip/g12a/lpddr3_1d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/lpddr4_1d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/lpddr4_2d.fw fip/
+$ cp $UBOOTDIR/fip/g12a/piei.fw fip/
+$ cp $UBOOTDIR/fip/g12a/aml_ddr.fw fip/
+$ cp u-boot.bin fip/bl33.bin
+
+$ sh fip/blx_fix.sh \
+ fip/bl30.bin \
+ fip/zero_tmp \
+ fip/bl30_zero.bin \
+ fip/bl301.bin \
+ fip/bl301_zero.bin \
+ fip/bl30_new.bin \
+ bl30
+
+$ sh fip/blx_fix.sh \
+ fip/bl2.bin \
+ fip/zero_tmp \
+ fip/bl2_zero.bin \
+ fip/acs.bin \
+ fip/bl21_zero.bin \
+ fip/bl2_new.bin \
+ bl2
+
+$ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl30sig --input fip/bl30_new.bin \
+  --output fip/bl30_new.bin.g12a.enc \
+  --level v3
+$ $UBOOTDIR/fip/g1

Re: [PATCH 02/13] ARM: dts: add support for BananaPi M2-Pro

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Import the board dts from the linux-amlogic/for-next (6.4-rc1)
branch. This involves spliting the BPI-M5 dts into a dtsi and
then reusing this for the M2-Pro.

Signed-off-by: Christian Hewitt 
---
  arch/arm/dts/Makefile |   5 +-
  .../dts/meson-sm1-bananapi-m2-pro-u-boot.dtsi |  14 +
  arch/arm/dts/meson-sm1-bananapi-m2-pro.dts|  97 
  arch/arm/dts/meson-sm1-bananapi-m5.dts| 427 +
  arch/arm/dts/meson-sm1-bananapi.dtsi  | 435 ++
  5 files changed, 550 insertions(+), 428 deletions(-)
  create mode 100644 arch/arm/dts/meson-sm1-bananapi-m2-pro-u-boot.dtsi
  create mode 100644 arch/arm/dts/meson-sm1-bananapi-m2-pro.dts
  create mode 100644 arch/arm/dts/meson-sm1-bananapi.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0c149b636a..d6139429e5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -205,14 +205,15 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-g12a-sei510.dtb \
meson-g12a-u200.dtb \
meson-g12b-a311d-khadas-vim3.dtb \
+   meson-g12b-bananapi-cm4-cm4io.dtb \
+   meson-g12b-gsking-x.dtb \
meson-g12b-gtking.dtb \
meson-g12b-gtking-pro.dtb \
-   meson-g12b-gsking-x.dtb \
meson-g12b-odroid-go-ultra.dtb \
meson-g12b-odroid-n2.dtb \
meson-g12b-odroid-n2l.dtb \
meson-g12b-odroid-n2-plus.dtb \
-   meson-g12b-bananapi-cm4-cm4io.dtb \
+   meson-sm1-bananapi-m2-pro.dtb \
meson-sm1-bananapi-m5.dtb \
meson-sm1-khadas-vim3l.dtb \
meson-sm1-odroid-c4.dtb \
diff --git a/arch/arm/dts/meson-sm1-bananapi-m2-pro-u-boot.dtsi 
b/arch/arm/dts/meson-sm1-bananapi-m2-pro-u-boot.dtsi
new file mode 100644
index 00..4a1aeda565
--- /dev/null
+++ b/arch/arm/dts/meson-sm1-bananapi-m2-pro-u-boot.dtsi
@@ -0,0 +1,14 @@
+
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2021 BayLibre, SAS
+ * Author: Neil Armstrong 
+ */
+
+#include "meson-sm1-u-boot.dtsi"
+
+ðmac {
+   snps,reset-gpio = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
+   snps,reset-delays-us = <0 1 100>;
+   snps,reset-active-low;
+};
diff --git a/arch/arm/dts/meson-sm1-bananapi-m2-pro.dts 
b/arch/arm/dts/meson-sm1-bananapi-m2-pro.dts
new file mode 100644
index 00..586034316e
--- /dev/null
+++ b/arch/arm/dts/meson-sm1-bananapi-m2-pro.dts
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2021 BayLibre SAS
+ * Author: Neil Armstrong 
+ */
+
+/dts-v1/;
+
+#include "meson-sm1-bananapi.dtsi"
+#include 
+
+/ {
+   compatible = "bananapi,bpi-m2-pro", "amlogic,sm1";
+   model = "Banana Pi BPI-M2-PRO";
+
+   sound {
+   compatible = "amlogic,axg-sound-card";
+   model = "BPI-M2-PRO";
+   audio-aux-devs = <&tdmout_b>;
+   audio-routing = "TDMOUT_B IN 0", "FRDDR_A OUT 1",
+   "TDMOUT_B IN 1", "FRDDR_B OUT 1",
+   "TDMOUT_B IN 2", "FRDDR_C OUT 1",
+   "TDM_B Playback", "TDMOUT_B OUT";
+
+   assigned-clocks = <&clkc CLKID_MPLL2>,
+ <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>;
+   assigned-clock-parents = <0>, <0>, <0>;
+   assigned-clock-rates = <294912000>,
+  <270950400>,
+  <393216000>;
+
+   dai-link-0 {
+   sound-dai = <&frddr_a>;
+   };
+
+   dai-link-1 {
+   sound-dai = <&frddr_b>;
+   };
+
+   dai-link-2 {
+   sound-dai = <&frddr_c>;
+   };
+
+   /* 8ch hdmi interface */
+   dai-link-3 {
+   sound-dai = <&tdmif_b>;
+   dai-format = "i2s";
+   dai-tdm-slot-tx-mask-0 = <1 1>;
+   dai-tdm-slot-tx-mask-1 = <1 1>;
+   dai-tdm-slot-tx-mask-2 = <1 1>;
+   dai-tdm-slot-tx-mask-3 = <1 1>;
+   mclk-fs = <256>;
+
+   codec {
+   sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>;
+   };
+   };
+
+   /* hdmi glue */
+   dai-link-4 {
+   sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>;
+
+   codec {
+   sound-dai = <&

Re: [PATCH 03/13] boards: add BananaPi M2-Pro defconfig

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Add configuration for the BananaPi M2-Pro board.

Signed-off-by: Christian Hewitt 
---
  configs/bananapi-m2-pro_defconfig | 76 +++
  1 file changed, 76 insertions(+)
  create mode 100644 configs/bananapi-m2-pro_defconfig

diff --git a/configs/bananapi-m2-pro_defconfig 
b/configs/bananapi-m2-pro_defconfig
new file mode 100644
index 00..28b603fe20
--- /dev/null
+++ b/configs/bananapi-m2-pro_defconfig
@@ -0,0 +1,76 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-bananapi-m2-pro"
+CONFIG_MESON_G12A=y
+CONFIG_DEBUG_UART_BASE=0xff803000
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING="bpi-m2-pro"
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_REMAKE_ELF=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_SYS_MAXARGS=32
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_MDIO_MUX=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_MDIO_MUX_MESON_G12A=y
+CONFIG_MESON_G12A_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_G12A=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_MESON_G12A=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y


Reviewed-by: Neil Armstrong 


Re: [PATCH 05/13] ARM: dts: add support for BananaPi M2S

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Import the device-tree from linux-amlogic/for-next (Linux 6.4-rc1)
and omit the NPU node from the A311D board variant dts as this is
not supported under U-Boot.

Signed-off-by: Christian Hewitt 
---
  arch/arm/dts/Makefile |   1 +
  .../arm/dts/meson-g12b-a311d-bananapi-m2s.dts |  33 ++
  arch/arm/dts/meson-g12b-bananapi-u-boot.dtsi  |   7 +
  arch/arm/dts/meson-g12b-bananapi.dtsi | 521 ++
  .../arm/dts/meson-g12b-s922x-bananapi-m2s.dts |  14 +
  5 files changed, 576 insertions(+)
  create mode 100644 arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts
  create mode 100644 arch/arm/dts/meson-g12b-bananapi-u-boot.dtsi
  create mode 100644 arch/arm/dts/meson-g12b-bananapi.dtsi
  create mode 100644 arch/arm/dts/meson-g12b-s922x-bananapi-m2s.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index d6139429e5..eb20524a99 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -204,6 +204,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-g12a-radxa-zero.dtb \
meson-g12a-sei510.dtb \
meson-g12a-u200.dtb \
+   meson-g12b-a311d-bananapi-m2s.dtb \
meson-g12b-a311d-khadas-vim3.dtb \
meson-g12b-bananapi-cm4-cm4io.dtb \
meson-g12b-gsking-x.dtb \
diff --git a/arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts 
b/arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts
new file mode 100644
index 00..31365316b2
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2023 Christian Hewitt 
+ */
+
+/dts-v1/;
+
+#include "meson-g12b-a311d.dtsi"
+#include "meson-g12b-bananapi.dtsi"
+
+/ {
+   compatible = "bananapi,bpi-m2s", "amlogic,a311d", "amlogic,g12b";
+   model = "BananaPi M2S";
+
+   aliases {
+   i2c0 = &i2c1;
+   i2c1 = &i2c3;
+   };
+};
+
+/* Camera (CSI) bus */
+&i2c1 {
+   status = "okay";
+   pinctrl-0 = <&i2c1_sda_h6_pins>, <&i2c1_sck_h7_pins>;
+   pinctrl-names = "default";
+};
+
+/* Display (DSI) bus */
+&i2c3 {
+   status = "okay";
+   pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>;
+   pinctrl-names = "default";
+};
diff --git a/arch/arm/dts/meson-g12b-bananapi-u-boot.dtsi 
b/arch/arm/dts/meson-g12b-bananapi-u-boot.dtsi
new file mode 100644
index 00..236f2468dc
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-bananapi-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ */
+
+#include "meson-g12-common-u-boot.dtsi"
diff --git a/arch/arm/dts/meson-g12b-bananapi.dtsi 
b/arch/arm/dts/meson-g12b-bananapi.dtsi
new file mode 100644
index 00..83709787eb
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-bananapi.dtsi
@@ -0,0 +1,521 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 BayLibre, SAS
+ * Author: Neil Armstrong 
+ * Copyright (c) 2023 Christian Hewitt 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   aliases {
+   serial0 = &uart_AO;
+   ethernet0 = ðmac;
+   rtc1 = &vrtc;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>; /* 2 GiB or 4 GiB */
+   };
+
+   adc-keys {
+   compatible = "adc-keys";
+   io-channels = <&saradc 2>;
+   io-channel-names = "buttons";
+   keyup-threshold-microvolt = <171>;
+
+   button-function {
+   label = "RST";
+   linux,code = ;
+   press-threshold-microvolt = <1>;
+   };
+   };
+
+   emmc_pwrseq: emmc-pwrseq {
+   compatible = "mmc-pwrseq-emmc";
+   reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
+   };
+
+   fan0: pwm-fan {
+   compatible = "pwm-fan";
+   #cooling-cells = <2>;
+   cooling-min-state = <0>;
+   cooling-max-state = <3>;
+   cooling-levels = <0 120 170 220>;
+   pwms = <&pwm_cd 1 4 0>;
+   };
+
+   hdmi-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <&hdmi_tx_tmds_out>;
+   };
+   };
+   };
+
+   leds {
+   

Re: [PATCH 06/13] boards: add BananaPi M2S defconfig

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Add configuration for the Bananapi BPI-M2S.

Signed-off-by: Christian Hewitt 
---
  configs/bananapi-m2s_defconfig | 82 ++
  1 file changed, 82 insertions(+)
  create mode 100644 configs/bananapi-m2s_defconfig

diff --git a/configs/bananapi-m2s_defconfig b/configs/bananapi-m2s_defconfig
new file mode 100644
index 00..3109e0ce48
--- /dev/null
+++ b/configs/bananapi-m2s_defconfig
@@ -0,0 +1,82 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-a311d-bananapi-m2s"
+CONFIG_MESON_G12A=y
+CONFIG_DEBUG_UART_BASE=0xff803000
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" bpi-m2s"
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_DEBUG_UART=y
+CONFIG_AHCI=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_REMAKE_ELF=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_SYS_MAXARGS=32
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_AHCI_PCI=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_MDIO_MUX=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_MDIO_MUX_MESON_G12A=y
+CONFIG_PCI=y
+CONFIG_PCIE_DW_MESON=y
+CONFIG_MESON_G12A_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_G12A=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_MESON_G12A=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y


Reviewed-by: Neil Armstrong 


Re: [PATCH 08/13] ARM: dts: add support for Radxa Zero2

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Import the device-tree from linux-amlogic/for-next (Linux 6.4-rc1)
to support the Radxa-Zero2 board.

Signed-off-by: Christian Hewitt 
---
  arch/arm/dts/Makefile |   1 +
  .../dts/meson-g12b-radxa-zero2-u-boot.dtsi|   7 +
  arch/arm/dts/meson-g12b-radxa-zero2.dts   | 489 ++
  3 files changed, 497 insertions(+)
  create mode 100644 arch/arm/dts/meson-g12b-radxa-zero2-u-boot.dtsi
  create mode 100644 arch/arm/dts/meson-g12b-radxa-zero2.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index eb20524a99..42da335bb5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -214,6 +214,7 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-g12b-odroid-n2.dtb \
meson-g12b-odroid-n2l.dtb \
meson-g12b-odroid-n2-plus.dtb \
+   meson-g12b-radxa-zero2.dtb \
meson-sm1-bananapi-m2-pro.dtb \
meson-sm1-bananapi-m5.dtb \
meson-sm1-khadas-vim3l.dtb \
diff --git a/arch/arm/dts/meson-g12b-radxa-zero2-u-boot.dtsi 
b/arch/arm/dts/meson-g12b-radxa-zero2-u-boot.dtsi
new file mode 100644
index 00..236f2468dc
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-radxa-zero2-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 BayLibre, SAS.
+ * Author: Neil Armstrong 
+ */
+
+#include "meson-g12-common-u-boot.dtsi"
diff --git a/arch/arm/dts/meson-g12b-radxa-zero2.dts 
b/arch/arm/dts/meson-g12b-radxa-zero2.dts
new file mode 100644
index 00..890f5bfebb
--- /dev/null
+++ b/arch/arm/dts/meson-g12b-radxa-zero2.dts
@@ -0,0 +1,489 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 BayLibre, SAS
+ * Author: Neil Armstrong 
+ * Copyright (c) 2019 Christian Hewitt 
+ * Copyright (c) 2022 Radxa Limited
+ * Author: Yuntian Zhang 
+ */
+
+/dts-v1/;
+
+#include "meson-g12b-a311d.dtsi"
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "radxa,zero2", "amlogic,a311d", "amlogic,g12b";
+   model = "Radxa Zero2";
+
+   aliases {
+   serial0 = &uart_AO;
+   serial2 = &uart_A;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   poll-interval = <100>;
+   power-button {
+   label = "power";
+   linux,code = ;
+   gpios = <&gpio_ao GPIOAO_3 (GPIO_ACTIVE_LOW | 
GPIO_PULL_UP)>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led-green {
+   color = ;
+   function = LED_FUNCTION_STATUS;
+   gpios = <&gpio GPIOA_12 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+
+   hdmi-connector {
+   compatible = "hdmi-connector";
+   type = "a";
+
+   port {
+   hdmi_connector_in: endpoint {
+   remote-endpoint = <&hdmi_tx_tmds_out>;
+   };
+   };
+   };
+
+   emmc_pwrseq: emmc-pwrseq {
+   compatible = "mmc-pwrseq-emmc";
+   reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
+   };
+
+   sdio_pwrseq: sdio-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
+   clocks = <&wifi32k>;
+   clock-names = "ext_clock";
+   };
+
+   ao_5v: regulator-ao-5v {
+   compatible = "regulator-fixed";
+   regulator-name = "AO_5V";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   };
+
+   vcc_1v8: regulator-vcc-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "VCC_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <&vcc_3v3>;
+   regulator-always-on;
+   };
+
+   vcc_3v3: regulator-vcc-3v3 {
+   compatible = "regulator-fixed";
+   regulator-name = "VCC_3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <&vdd

Re: [PATCH 09/13] boards: amlogic: add Radxa Zero2 defconfig

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Add board configuration for the Radxa Zero2.

Signed-off-by: Christian Hewitt 
---
  configs/radxa-zero2_defconfig | 77 +++
  1 file changed, 77 insertions(+)
  create mode 100644 configs/radxa-zero2_defconfig

diff --git a/configs/radxa-zero2_defconfig b/configs/radxa-zero2_defconfig
new file mode 100644
index 00..2218b0db7d
--- /dev/null
+++ b/configs/radxa-zero2_defconfig
@@ -0,0 +1,77 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-radxa-zero2"
+CONFIG_MESON_G12A=y
+CONFIG_DEBUG_UART_BASE=0xff803000
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" radxa-zero2"
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_REMAKE_ELF=y
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_SYS_MAXARGS=32
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+# CONFIG_PHY_REALTEK is not set
+CONFIG_DM_MDIO=y
+CONFIG_DM_MDIO_MUX=y
+# CONFIG_ETH_DESIGNWARE_MESON8B is not set
+CONFIG_MDIO_MUX_MESON_G12A=y
+CONFIG_MESON_G12A_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_G12A=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_DWC3=y
+CONFIG_USB_DWC3=y
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_MESON_G12A=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e
+CONFIG_USB_GADGET_PRODUCT_NUM=0xfada
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y


Reviewed-by: Neil Armstrong 


Re: [PATCH 11/13] ARM: dts: add support for WeTek Hub and WeTek Play2

2023-03-23 Thread Neil Armstrong

On 23/03/2023 07:54, Christian Hewitt wrote:

Import the dts files from linux-amlogic/for-next (Linux 6.4-rc1) and
add the old PHY reset bindings for dwmac to the u-boot.dtsi until we
support the new bindings in the PHY node. Without this the PHY is not
functional in u-boot or Linux.

Signed-off-by: Christian Hewitt 
---
  arch/arm/dts/Makefile |   2 +
  arch/arm/dts/meson-gxbb-wetek-hub.dts |  58 +
  arch/arm/dts/meson-gxbb-wetek-play2.dts   | 119 +
  arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi |  13 +
  arch/arm/dts/meson-gxbb-wetek.dtsi| 292 ++
  5 files changed, 484 insertions(+)
  create mode 100644 arch/arm/dts/meson-gxbb-wetek-hub.dts
  create mode 100644 arch/arm/dts/meson-gxbb-wetek-play2.dts
  create mode 100644 arch/arm/dts/meson-gxbb-wetek-u-boot.dtsi
  create mode 100644 arch/arm/dts/meson-gxbb-wetek.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 42da335bb5..1c843882d1 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -191,6 +191,8 @@ dtb-$(CONFIG_ARCH_MESON) += \
meson-gxbb-nanopi-k2.dtb \
meson-gxbb-p200.dtb \
meson-gxbb-p201.dtb \
+   meson-gxbb-wetek-hub.dtb \
+   meson-gxbb-wetek-play2.dtb \
meson-gxl-s805x-libretech-ac.dtb \
meson-gxl-s905d-libretech-pc.dtb \
meson-gxl-s905w-jethome-jethub-j80.dtb \
diff --git a/arch/arm/dts/meson-gxbb-wetek-hub.dts 
b/arch/arm/dts/meson-gxbb-wetek-hub.dts
new file mode 100644
index 00..58733017ed
--- /dev/null
+++ b/arch/arm/dts/meson-gxbb-wetek-hub.dts
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2016 BayLibre, Inc.
+ * Author: Neil Armstrong 
+ */
+
+/dts-v1/;
+
+#include "meson-gxbb-wetek.dtsi"
+#include 
+
+/ {
+   compatible = "wetek,hub", "amlogic,meson-gxbb";
+   model = "WeTek Hub";
+
+   sound {
+   compatible = "amlogic,gx-sound-card";
+   model = "WETEK-HUB";
+   assigned-clocks = <&clkc CLKID_MPLL0>,
+ <&clkc CLKID_MPLL1>,
+ <&clkc CLKID_MPLL2>;
+   assigned-clock-parents = <0>, <0>, <0>;
+   assigned-clock-rates = <294912000>,
+  <270950400>,
+  <393216000>;
+   status = "okay";
+
+   dai-link-0 {
+   sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
+   };
+
+   dai-link-1 {
+   sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
+   dai-format = "i2s";
+   mclk-fs = <256>;
+
+   codec-0 {
+   sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
+   };
+   };
+
+   dai-link-2 {
+   sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
+
+   codec-0 {
+   sound-dai = <&hdmi_tx>;
+   };
+   };
+   };
+};
+
+&aiu {
+   status = "okay";
+};
+
+&ir {
+   linux,rc-map-name = "rc-wetek-hub";
+};
diff --git a/arch/arm/dts/meson-gxbb-wetek-play2.dts 
b/arch/arm/dts/meson-gxbb-wetek-play2.dts
new file mode 100644
index 00..505ffcd8eb
--- /dev/null
+++ b/arch/arm/dts/meson-gxbb-wetek-play2.dts
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2016 BayLibre, Inc.
+ * Author: Neil Armstrong 
+ */
+
+/dts-v1/;
+
+#include "meson-gxbb-wetek.dtsi"
+#include 
+#include 
+
+/ {
+   compatible = "wetek,play2", "amlogic,meson-gxbb";
+   model = "WeTek Play 2";
+
+   spdif_dit: audio-codec-0 {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   status = "okay";
+   sound-name-prefix = "DIT";
+   };
+
+   leds {
+   led-wifi {
+   label = "wetek-play:wifi-status";
+   gpios = <&gpio GPIODV_26 GPIO_ACTIVE_HIGH>;
+   default-state = "off";
+   };
+
+   led-ethernet {
+   label = "wetek-play:ethernet-status";
+   gpios = <&gpio GPIODV_27 GPIO_ACTIVE_HIGH>;
+   default-state = "off";
+   };
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   poll-interval = <100>;
+
+   button {
+   label = "reset";
+  

Re: [PATCH 12/13] boards: amlogic: add WeTek Hub and WeTek Play2 defconfig

2023-03-23 Thread Neil Armstrong

On 23/03/2023 08:04, Christian Hewitt wrote:




On 23 Mar 2023, at 10:54 am, Christian Hewitt via groups.io 
 wrote:

Add configurations for the WeTek Hub and WeTek Play2 boards along
with files for the wetek-gxbb board family to ensure the ethernet
MAC is correctly discovered. Set myself as the maintainer for the
board family.


^ should read just "Add configurations for the WeTek Hub and WeTek Play2
boards” as the board-family changes were dropped (not needed). I can
send a v2 for this patch alone (or would you prefer the series?)


Please send a v2 of the whole serie including the doc fixes!

Thanks,
Neil



Christian



Signed-off-by: Christian Hewitt 
---
board/amlogic/p200/MAINTAINERS |  2 +
configs/wetek-hub_defconfig| 70 ++
configs/wetek-play2_defconfig  | 70 ++
3 files changed, 142 insertions(+)
create mode 100644 configs/wetek-hub_defconfig
create mode 100644 configs/wetek-play2_defconfig

diff --git a/board/amlogic/p200/MAINTAINERS b/board/amlogic/p200/MAINTAINERS
index 33ca3df5c6..264218e3be 100644
--- a/board/amlogic/p200/MAINTAINERS
+++ b/board/amlogic/p200/MAINTAINERS
@@ -7,6 +7,8 @@ F:  board/amlogic/p200/
F:  configs/nanopi-k2_defconfig
F:  configs/odroid-c2_defconfig
F:  configs/p200_defconfig
+F: configs/wetek-hub_defconfig
+F: configs/wetek-play2_defconfig
F:  doc/board/amlogic/p200.rst
F:  doc/board/amlogic/nanopi-k2.rst
F:  doc/board/amlogic/odroid-c2.rst
diff --git a/configs/wetek-hub_defconfig b/configs/wetek-hub_defconfig
new file mode 100644
index 00..634833f7fe
--- /dev/null
+++ b/configs/wetek-hub_defconfig
@@ -0,0 +1,70 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" wetek-hub"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-wetek-hub"
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_ADC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SARADC_MESON=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MESON=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_PHY=y
+CONFIG_MESON_GXBB_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXBB=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/wetek-play2_defconfig b/configs/wetek-play2_defconfig
new file mode 100644
index 00..6d33b09a94
--- /dev/null
+++ b/configs/wetek-play2_defconfig
@@ -0,0 +1,70 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" wetek-play2"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-wetek-play2"
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_ADC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SARADC_MESON=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MESON=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_PHY=y
+CONFIG_MESON_GXBB_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXBB=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y

Re: [PATCH v2 1/1] drivers: rng: add support for Meson S4

2023-10-12 Thread neil . armstrong

Hi,

On 10/10/2023 13:13, Alexey Romanov wrote:

For some Amlogic SOC's, mechanism to obtain random number
has been changed. For example, S4 now uses status bit waiting algo.

Signed-off-by: Alexey Romanov 
---
  drivers/rng/meson-rng.c | 72 -
  1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
index e0a1e8c7e0..ba60325b94 100644
--- a/drivers/rng/meson-rng.c
+++ b/drivers/rng/meson-rng.c
@@ -10,10 +10,23 @@
  #include 
  #include 
  #include 
+#include 
+
+#define RNG_DATA   0x00
+#define RNG_S4_DATA0x08
+#define RNG_S4_CFG 0x00
+
+#define RUN_BITBIT(0)
+#define SEED_READY_STS_BIT BIT(31)
+
+struct meson_rng_priv {
+   u32 (*read)(fdt_addr_t base);
+};
  
  struct meson_rng_plat {

fdt_addr_t base;
struct clk clk;
+   struct meson_rng_priv *priv;
  };
  
  /**

@@ -27,10 +40,11 @@ struct meson_rng_plat {
  static int meson_rng_read(struct udevice *dev, void *data, size_t len)
  {
struct meson_rng_plat *pdata = dev_get_plat(dev);
+   struct meson_rng_priv *priv = pdata->priv;
char *buffer = (char *)data;
  
  	while (len) {

-   u32 rand = readl(pdata->base);
+   u32 rand = priv->read(pdata->base);
size_t step;
  
  		if (len >= 4)

@@ -44,6 +58,47 @@ static int meson_rng_read(struct udevice *dev, void *data, 
size_t len)
return 0;
  }
  
+static int meson_rng_wait_status(void __iomem *cfg_addr, int bit)

+{
+   u32 status = 0;
+   int ret;
+
+   ret = readl_relaxed_poll_timeout(cfg_addr,
+status, !(status & bit),
+1);
+   if (ret)
+   return -EBUSY;
+
+   return 0;
+}
+
+static u32 meson_common_rng_read(fdt_addr_t base)
+{
+   return readl(base);
+}
+
+static u32 meson_s4_rng_read(fdt_addr_t base)
+{
+   void __iomem *cfg_addr = (void *)base + RNG_S4_CFG;
+   int err;
+
+   writel_relaxed(readl_relaxed(cfg_addr) | SEED_READY_STS_BIT, cfg_addr);
+
+   err = meson_rng_wait_status(cfg_addr, SEED_READY_STS_BIT);
+   if (err) {
+   pr_err("Seed isn't ready, try again\n");
+   return err;
+   }
+
+   err = meson_rng_wait_status(cfg_addr, RUN_BIT);
+   if (err) {
+   pr_err("Can't get random number, try again\n");
+   return err;
+   }
+
+   return readl_relaxed(base + RNG_S4_DATA);
+}
+
  /**
   * meson_rng_probe() - probe rng device
   *
@@ -59,6 +114,8 @@ static int meson_rng_probe(struct udevice *dev)
if (err)
return err;
  
+	pdata->priv = dev_get_driver_data(dev);

+
return 0;
  }
  
@@ -102,9 +159,22 @@ static const struct dm_rng_ops meson_rng_ops = {

.read = meson_rng_read,
  };
  
+static const struct meson_rng_priv meson_rng_priv = {

+   .read = meson_common_rng_read,
+};
+
+static const struct meson_rng_priv meson_rng_priv_s4 = {
+   .read = meson_s4_rng_read,
+};
+
  static const struct udevice_id meson_rng_match[] = {
{
.compatible = "amlogic,meson-rng",
+   .data = (ulong)&meson_rng_priv,
+   },
+   {
+   .compatible = "amlogic,meson-s4-rng",
+   .data = (ulong)&meson_rng_priv_s4,
},
{},
  };


I get:
+drivers/rng/meson-rng.c: In function 'meson_rng_probe':
+drivers/rng/meson-rng.c:117:21: error: assignment to 'struct meson_rng_priv *' 
from 'ulong' {aka 'long unsigned int'} makes pointer from integer without a 
cast [-Werror=int-conversion]
+  117 | pdata->priv = dev_get_driver_data(dev);

while building in CI.

Thanks,
Neil


Re: [PATCH v3 1/1] drivers: rng: add support for Meson S4

2023-10-12 Thread neil . armstrong

On 12/10/2023 09:58, Alexey Romanov wrote:

For some Amlogic SOC's, mechanism to obtain random number
has been changed. For example, S4 now uses status bit waiting algo.

Signed-off-by: Alexey Romanov 
---
  drivers/rng/meson-rng.c | 72 -
  1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/rng/meson-rng.c b/drivers/rng/meson-rng.c
index e0a1e8c7e0..fd2988e91b 100644
--- a/drivers/rng/meson-rng.c
+++ b/drivers/rng/meson-rng.c
@@ -10,10 +10,23 @@
  #include 
  #include 
  #include 
+#include 
+
+#define RNG_DATA   0x00
+#define RNG_S4_DATA0x08
+#define RNG_S4_CFG 0x00
+
+#define RUN_BITBIT(0)
+#define SEED_READY_STS_BIT BIT(31)
+
+struct meson_rng_priv {
+   u32 (*read)(fdt_addr_t base);
+};
  
  struct meson_rng_plat {

fdt_addr_t base;
struct clk clk;
+   struct meson_rng_priv *priv;
  };
  
  /**

@@ -27,10 +40,11 @@ struct meson_rng_plat {
  static int meson_rng_read(struct udevice *dev, void *data, size_t len)
  {
struct meson_rng_plat *pdata = dev_get_plat(dev);
+   struct meson_rng_priv *priv = pdata->priv;
char *buffer = (char *)data;
  
  	while (len) {

-   u32 rand = readl(pdata->base);
+   u32 rand = priv->read(pdata->base);
size_t step;
  
  		if (len >= 4)

@@ -44,6 +58,47 @@ static int meson_rng_read(struct udevice *dev, void *data, 
size_t len)
return 0;
  }
  
+static int meson_rng_wait_status(void __iomem *cfg_addr, int bit)

+{
+   u32 status = 0;
+   int ret;
+
+   ret = readl_relaxed_poll_timeout(cfg_addr,
+status, !(status & bit),
+1);
+   if (ret)
+   return -EBUSY;
+
+   return 0;
+}
+
+static u32 meson_common_rng_read(fdt_addr_t base)
+{
+   return readl(base);
+}
+
+static u32 meson_s4_rng_read(fdt_addr_t base)
+{
+   void __iomem *cfg_addr = (void *)base + RNG_S4_CFG;
+   int err;
+
+   writel_relaxed(readl_relaxed(cfg_addr) | SEED_READY_STS_BIT, cfg_addr);
+
+   err = meson_rng_wait_status(cfg_addr, SEED_READY_STS_BIT);
+   if (err) {
+   pr_err("Seed isn't ready, try again\n");
+   return err;
+   }
+
+   err = meson_rng_wait_status(cfg_addr, RUN_BIT);
+   if (err) {
+   pr_err("Can't get random number, try again\n");
+   return err;
+   }
+
+   return readl_relaxed(base + RNG_S4_DATA);
+}
+
  /**
   * meson_rng_probe() - probe rng device
   *
@@ -59,6 +114,8 @@ static int meson_rng_probe(struct udevice *dev)
if (err)
return err;
  
+	pdata->priv = (struct meson_rng_priv *)dev_get_driver_data(dev);

+
return 0;
  }
  
@@ -102,9 +159,22 @@ static const struct dm_rng_ops meson_rng_ops = {

.read = meson_rng_read,
  };
  
+static const struct meson_rng_priv meson_rng_priv = {

+   .read = meson_common_rng_read,
+};
+
+static const struct meson_rng_priv meson_rng_priv_s4 = {
+   .read = meson_s4_rng_read,
+};
+
  static const struct udevice_id meson_rng_match[] = {
{
.compatible = "amlogic,meson-rng",
+   .data = (ulong)&meson_rng_priv,
+   },
+   {
+   .compatible = "amlogic,meson-s4-rng",
+   .data = (ulong)&meson_rng_priv_s4,
},
{},
  };


Reviewed-by: Neil Armstrong 


Re: [PATCH v3 0/8] Add SM uclass and Meson SM driver

2023-10-12 Thread neil . armstrong

Hi,

On 21/09/2023 10:13, Alexey Romanov wrote:

Hello!

At the moment, there is no single general approach to using
secure monitor in U-Boot, there is only the smc_call() function,
over which everyone builds their own add-ons. This patchset
is designed to solve this problem by adding a new uclass -
SM_UCLASS. This UCLASS export following generic API:

1. sm_call() - generic SMC call to the secure-monitor
2. sm_call_read() - retrieve data from secure-monitor
3. sm_call_write() - send data to secure-monitor

In the future, it is necessary to completely get rid of raw
smc_call() calls, replacing them with the use of SM_UCLASS
based drivers.

V2:

- Add SM UCLASS
- Add SM sandbox driver
- Add test for sandbox driver
- Meson Secure Monitor driver now based on SM_UCLASS
- Fix include order in arch/arm/mach-meson/sm.c

Also, during the discussion in V1 of this patchset, it was
discussed to create MESON_SM_UCLASS, but I considered such
a uclass to be too arch-specific. That's why I suggest
SM_UCLASS, which is not so arch-specific: secure monitor can
used for whole ARM devices, not only for Amlogic SoC's.

V3:

- Fix typos in commit messages
- Use uclass_first_device_err() instead of uclass_get_device_by_name()
- Return -ENOSYS instead of -EPROTONOSUPPORT if SM_UCLASS option not
implemented

Alexey Romanov (8):
   drivers: introduce Secure Monitor uclass
   sandbox: add sandbox sm uclass driver
   sandbox: dts: add meson secure monitor node
   sandbox: add tests for UCLASS_SM
   sandbox: defconfig: enable CONFIG_SM option
   drivers: introduce Meson Secure Monitor driver
   arch: meson: sm: set correct order of the includes
   arch: meson: use secure monitor driver

  MAINTAINERS |   1 +
  arch/arm/mach-meson/Kconfig |   1 +
  arch/arm/mach-meson/sm.c| 116 +++--
  arch/sandbox/dts/test.dts   |   4 +
  configs/sandbox_defconfig   |   1 +
  drivers/Kconfig |   2 +
  drivers/Makefile|   1 +
  drivers/sm/Kconfig  |   9 ++
  drivers/sm/Makefile |   5 +
  drivers/sm/meson-sm.c   | 198 
  drivers/sm/sandbox-sm.c |  76 ++
  drivers/sm/sm-uclass.c  |  55 ++
  include/dm/uclass-id.h  |   1 +
  include/meson/sm.h  |  19 
  include/sandbox-sm.h|  18 
  include/sm-uclass.h |  72 +
  include/sm.h|  67 
  test/dm/Makefile|   1 +
  test/dm/sm.c|  65 
  19 files changed, 656 insertions(+), 56 deletions(-)
  create mode 100644 drivers/sm/Kconfig
  create mode 100644 drivers/sm/Makefile
  create mode 100644 drivers/sm/meson-sm.c
  create mode 100644 drivers/sm/sandbox-sm.c
  create mode 100644 drivers/sm/sm-uclass.c
  create mode 100644 include/meson/sm.h
  create mode 100644 include/sandbox-sm.h
  create mode 100644 include/sm-uclass.h
  create mode 100644 include/sm.h
  create mode 100644 test/dm/sm.c



This serie breaks other boards:
+binman: Error 1 running 'mkimage -d 
./mkimage-in-simple-bin.mkimage-u-boot-tpl:./mkimage-in-simple-bin.mkimage-u-boot-spl
 -n px30 -T rksd ./idbloader.img': Error: SPL image is too large (size 0x3000 
than 0x2800)
+Error: Bad parameters for image type
+Usage: mkimage [-T type] -l image
+  -l ==> list image header information
+  -T ==> parse image file as 'type'
+  -q ==> quiet
+   mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d 
data_file[:data_file...] image
+  -A ==> set architecture to 'arch'
+  -O ==> set operating system to 'os'
+  -T ==> set image type to 'type'
+  -C ==> set compression type 'comp'
+  -a ==> set load address to 'addr' (hex)
+  -e ==> set entry point to 'ep' (hex)
+  -n ==> set image name to 'name'
+  -R ==> set second image name to 'name'
+  -d ==> use image data from 'datafile'
+  -x ==> set XIP (execute in place)
+  -s ==> create an image with no data
+  -v ==> verbose
+   mkimage [-D dtc_options] [-f fit-image.its|-f auto|-f auto-conf|-F] [-b  [-b 
]] [-E] [-B size] [-i ] fit-image
+file is used with -f auto, it may occur multiple times.
+  -D => set all options for device tree compiler
+  -f => input filename for FIT source
+  -i => input filename for ramdisk file
+  -E => place data outside of the FIT structure
+  -B => align size in hex for FIT structure and, with -E, for the 
external data
+  -b => append the device tree binary to the FIT
+  -t => update the timestamp in the FIT
+Signing / verified boot options: [-k keydir] [-K dtb] [ -c ] [-p 
addr] [-r] [-N engine]
+  -k => set directory containing private keys
+  -K => write public keys to this .dtb file
+  -g => set key name hint
+  -G => use this signing key (in lieu of -k)
+  -c => add comment in signatu

Re: [PATCH v1] drivers: don't compile Secure Monitor UCLASS unconditionally

2023-10-15 Thread Neil Armstrong

Le 13/10/2023 à 15:04, Alexey Romanov a écrit :

It makes no sense to compile Secure Monitor unconditionally.
For example, this break the SPL build on boards with a small
allowed SPL image size.

Fixes: 126fbbefd89e ("drivers: introduce Secure Monitor uclass")

Signed-off-by: Alexey Romanov 
---
  drivers/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index b7bd3633b1..1a768fed2b 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_$(SPL_TPL_)VIRTIO) += virtio/
  obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
  obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
  obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
+obj-$(CONFIG_$(SPL_TPL_)SM) += sm/
  obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
  obj-$(CONFIG_XEN) += xen/
  obj-$(CONFIG_$(SPL_)FPGA) += fpga/
@@ -124,4 +125,3 @@ obj-$(CONFIG_DM_RNG) += rng/
  endif
  
  obj-y += soc/

-obj-y += sm/


Thanks, squashed into 126fbbefd89e ("drivers: introduce Secure Monitor uclass")

Neil


Re: [PATCH v3 0/1] hwrng: meson - add support for S4

2023-10-15 Thread neil . armstrong
From: Neil Armstrong 

Hi,

On Thu, 12 Oct 2023 10:58:24 +0300, Alexey Romanov wrote:
> This patch adds support for Meson S4 series
> hardware number generator using new algo.
> 
> V2:
> 
> - Sync with Linux version.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/1] drivers: rng: add support for Meson S4
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a92345610ed3596bc25de08b17cb29c86b508e6c

-- 
Neil


Re: [PATCH v2 0/2] Meson A1: add HW RNG and AO Secure nodes

2023-10-15 Thread neil . armstrong
From: Neil Armstrong 

Hi,

On Tue, 10 Oct 2023 13:06:15 +0300, Alexey Romanov wrote:
> This patchest adds HW RNG and AO Secure definition
> in device tree for Amlogic A1-series.
> 
> V2:
> 
> - Rebased over latest amlogic U-Boot branch.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/2] meson-a1: dts: add hw rng node
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/87dfb37d54e59f89b61d43970861ad81d66f38ca
[2/2] meson-a1: dts: add ao secure node
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/7b4116f8f78f73906da59cbc93c7874948323e4b

-- 
Neil


[GIT PULL] Please pull u-boot-amlogic-20231015

2023-10-15 Thread Neil Armstrong

Hi Tom,

A set of changes mostly concerning Amlogic A1 & S4 SoCs for USB, Secure Monitor
and RNG bringup.


The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/18138

Thanks,
Neil

The following changes since commit 997bef3c6d22d12c7fd092fb831bf94d114c9f6f:

  Merge branch '2023-10-11-port-gen_compile_commands_py' (2023-10-11 13:25:01 
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20231015

for you to fetch changes up to 7cd53e0d5203f8e25bb69d2e675769888fcbc754:

  arch: meson: use secure monitor driver (2023-10-15 12:23:48 +0200)


- add Amlogic A1 clock driver
- add Amlogic A1 reset support
- add USB Device support for Amlogic A1
- enable RNG on Amlogic A1 & Amlogic S4
- move Amlogic Secure Monitor to standalone driver


Alexey Romanov (18):
  dt-bindings: reset: add Meson A1 reset bindings
  reset: add support for Amlogic A1 family
  phy: get rid of raw hex values
  phy: move clk enable/disable in init/exit
  phy: support Amlogic A1 family
  dwc3: add support for Amlogic A1 family
  ad401: enable USB stack
  meson-a1: dts: add hw rng node
  meson-a1: dts: add ao secure node
  drivers: rng: add support for Meson S4
  drivers: introduce Secure Monitor uclass
  sandbox: add sandbox sm uclass driver
  sandbox: dts: add meson secure monitor node
  sandbox: add tests for UCLASS_SM
  sandbox: defconfig: enable CONFIG_SM option
  drivers: introduce Meson Secure Monitor driver
  arch: meson: sm: set correct order of the includes
  arch: meson: use secure monitor driver

Igor Prusov (3):
  dt-bindings: clock: Add Amlogic A1 clock bindings
  clk: Add clock driver for Amlogic A1
  a1: clk: Add missing USB_PHY_IN and USB_PHY gates

 MAINTAINERS|   1 +
 arch/arm/dts/meson-a1.dtsi |  11 +
 arch/arm/include/asm/arch-meson/clock-a1.h |  23 +
 arch/arm/mach-meson/Kconfig|   1 +
 arch/arm/mach-meson/sm.c   | 116 ++--
 arch/sandbox/dts/test.dts  |   4 +
 configs/ad401_defconfig|   3 +
 configs/sandbox_defconfig  |   1 +
 drivers/Kconfig|   2 +
 drivers/Makefile   |   1 +
 drivers/clk/meson/Kconfig  |   8 +
 drivers/clk/meson/Makefile |   1 +
 drivers/clk/meson/a1.c | 729 +
 drivers/phy/Kconfig|   2 +-
 drivers/phy/meson-g12a-usb2.c  | 235 ++-
 drivers/reset/reset-meson.c|  42 +-
 drivers/rng/meson-rng.c|  72 +-
 drivers/sm/Kconfig |   9 +
 drivers/sm/Makefile|   5 +
 drivers/sm/meson-sm.c  | 198 ++
 drivers/sm/sandbox-sm.c|  76 +++
 drivers/sm/sm-uclass.c |  55 ++
 drivers/usb/dwc3/dwc3-meson-g12a.c |  79 ++-
 include/dm/uclass-id.h |   1 +
 .../clock/amlogic,a1-peripherals-clkc.h| 168 +
 include/dt-bindings/clock/amlogic,a1-pll-clkc.h|  25 +
 include/dt-bindings/reset/amlogic,meson-a1-reset.h |  76 +++
 include/meson/sm.h |  19 +
 include/sandbox-sm.h   |  18 +
 include/sm-uclass.h|  72 ++
 include/sm.h   |  67 ++
 test/dm/Makefile   |   1 +
 test/dm/sm.c   |  65 ++
 33 files changed, 2095 insertions(+), 91 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-meson/clock-a1.h
 create mode 100644 drivers/clk/meson/a1.c
 create mode 100644 drivers/sm/Kconfig
 create mode 100644 drivers/sm/Makefile
 create mode 100644 drivers/sm/meson-sm.c
 create mode 100644 drivers/sm/sandbox-sm.c
 create mode 100644 drivers/sm/sm-uclass.c
 create mode 100644 include/dt-bindings/clock/amlogic,a1-peripherals-clkc.h
 create mode 100644 include/dt-bindings/clock/amlogic,a1-pll-clkc.h
 create mode 100644 include/dt-bindings/reset/amlogic,meson-a1-reset.h
 create mode 100644 include/meson/sm.h
 create mode 100644 include/sandbox-sm.h
 create mode 100644 include/sm-uclass.h
 create mode 100644 include/sm.h
 create mode 100644 test/dm/sm.c


Re: [PATCH v4 4/8] clk: amlogic: Move driver and ops structs

2023-10-18 Thread Neil Armstrong

On 17/10/2023 18:56, Igor Prusov wrote:

Move driver and ops structs to avoid forward declaration after switching
to dump in clk_ops.

Signed-off-by: Igor Prusov 
---
  drivers/clk/meson/a1.c | 34 +-
  1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/clk/meson/a1.c b/drivers/clk/meson/a1.c
index 1075ba7333..e3fa9db7d0 100644
--- a/drivers/clk/meson/a1.c
+++ b/drivers/clk/meson/a1.c
@@ -601,14 +601,6 @@ static int meson_clk_set_parent(struct clk *clk, struct 
clk *parent_clk)
return meson_mux_set_parent_by_id(clk, parent_clk->id);
  }
  
-static struct clk_ops meson_clk_ops = {

-   .disable= meson_clk_disable,
-   .enable = meson_clk_enable,
-   .get_rate   = meson_clk_get_rate,
-   .set_rate   = meson_clk_set_rate,
-   .set_parent = meson_clk_set_parent,
-};
-
  static int meson_clk_probe(struct udevice *dev)
  {
struct meson_clk *priv = dev_get_priv(dev);
@@ -638,15 +630,6 @@ static const struct udevice_id meson_clk_ids[] = {
{ }
  };
  
-U_BOOT_DRIVER(meson_clk) = {

-   .name   = "meson-clk-a1",
-   .id = UCLASS_CLK,
-   .of_match   = meson_clk_ids,
-   .priv_auto  = sizeof(struct meson_clk),
-   .ops= &meson_clk_ops,
-   .probe  = meson_clk_probe,
-};
-
  static const char *meson_clk_get_name(struct clk *clk, int id)
  {
const struct meson_clk_info *info;
@@ -727,3 +710,20 @@ int soc_clk_dump(void)
  
  	return 0;

  }
+
+static struct clk_ops meson_clk_ops = {
+   .disable= meson_clk_disable,
+   .enable = meson_clk_enable,
+   .get_rate   = meson_clk_get_rate,
+   .set_rate   = meson_clk_set_rate,
+   .set_parent = meson_clk_set_parent,
+};
+
+U_BOOT_DRIVER(meson_clk) = {
+   .name   = "meson-clk-a1",
+   .id = UCLASS_CLK,
+   .of_match   = meson_clk_ids,
+   .priv_auto  = sizeof(struct meson_clk),
+   .ops= &meson_clk_ops,
+   .probe  = meson_clk_probe,
+};


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 1/2] serial: amlogic: Add UART compatible for A1 board

2023-10-18 Thread Neil Armstrong

On 17/10/2023 23:32, Igor Prusov wrote:

Add additional compatible to allow using serial driver with A1 board.
After compatible change in DTS [1], serial_meson driver should still be
able to work with console device.

[1] https://lore.kernel.org/all/20230705181833.16137-8-ddroko...@sberdevices.ru/

Signed-off-by: Igor Prusov 
---
  drivers/serial/serial_meson.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
index 934de2ab23..be5f380f85 100644
--- a/drivers/serial/serial_meson.c
+++ b/drivers/serial/serial_meson.c
@@ -232,6 +232,7 @@ static const struct dm_serial_ops meson_serial_ops = {
  static const struct udevice_id meson_serial_ids[] = {
{ .compatible = "amlogic,meson-uart" },
{ .compatible = "amlogic,meson-gx-uart" },
+   { .compatible = "amlogic,meson-a1-uart" },
    { }
  };
  


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 2/2] arm: meson-a1: dts: Sync DT with Linux

2023-10-18 Thread Neil Armstrong
 power-domains = <&pwrc PWRC_SD_EMMC_ID>;
+   status = "disabled";
+   };
+   };
+
+   usb: usb@fe004400 {
+   status = "disabled";
+   compatible = "amlogic,meson-a1-usb-ctrl";
+   reg = <0x0 0xfe004400 0x0 0xa0>;
+   interrupts = ;
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   clocks = <&clkc_periphs CLKID_USB_CTRL>,
+    <&clkc_periphs CLKID_USB_BUS>,
+<&clkc_periphs CLKID_USB_CTRL_IN>;
+   clock-names = "usb_ctrl", "usb_bus", "xtal_usb_ctrl";
+   resets = <&reset RESET_USBCTRL>;
+   reset-name = "usb_ctrl";
+
+   dr_mode = "otg";
+
+   phys = <&usb2_phy1>;
+   phy-names = "usb2-phy1";
+
+   dwc3: usb@ff40 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0xff40 0x0 0x10>;
+   interrupts = ;
+   dr_mode = "host";
+   snps,dis_u2_susphy_quirk;
+   snps,quirk-frame-length-adjustment = <0x20>;
+   snps,parkmode-disable-ss-quirk;
+   };
+
+   dwc2: usb@ff50 {
+   compatible = "amlogic,meson-a1-usb", 
"snps,dwc2";
+   reg = <0x0 0xff50 0x0 0x4>;
+   interrupts = ;
+   phys = <&usb2_phy1>;
+   phy-names = "usb2-phy";
+   clocks = <&clkc_periphs CLKID_USB_PHY>;
+   clock-names = "otg";
+   dr_mode = "peripheral";
+   g-rx-fifo-size = <192>;
+   g-np-tx-fifo-size = <128>;
+   g-tx-fifo-size = <128 128 16 16 16>;
+   };
};
  
  		gic: interrupt-controller@ff901000 {


Reviewed-by: Neil Armstrong 


Re: [PATCH] phy: meson-g12a-usb2: fix ret check on power_domain_get

2023-10-18 Thread neil . armstrong

On 17/10/2023 20:57, Guillaume La Roque wrote:

Patch which add A1 SoC support create a regression on khadas vim3/vim3l
boards when we try to use fastboot command:

   => fastboot usb 0
   failed to get power domain
   failed to get power domain
   No USB device found
   USB init failed: -19

Add ENOENT check on ret in probe function.

Fixes: 5533c883ce10 ("phy: support Amlogic A1 family")

Signed-off-by: Guillaume La Roque 
---
  drivers/phy/meson-g12a-usb2.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index 4ba3992bda70..3958d2404b85 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -328,12 +328,12 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
  
  #if CONFIG_IS_ENABLED(POWER_DOMAIN)

ret = power_domain_get(dev, &priv->pwrdm);
-   if (ret < 0 && ret != -ENODEV) {
-   pr_err("failed to get power domain\n");
+   if (ret < 0 && ret != -ENODEV && ret != -ENOENT) {
+   pr_err("failed to get power domain : %d\n", ret);
return ret;
}
  
-	if (ret != -ENODEV) {

+   if (ret != -ENODEV && ret != -ENOENT) {
ret = power_domain_on(&priv->pwrdm);
if (ret < 0) {
pr_err("failed to enable power domain\n");


Reviewed-by: Neil Armstrong 


Re: [PATCH] phy: meson-g12a-usb2: fix ret check on power_domain_get

2023-10-18 Thread Neil Armstrong
Hi,

On Tue, 17 Oct 2023 20:57:25 +0200, Guillaume La Roque wrote:
> Patch which add A1 SoC support create a regression on khadas vim3/vim3l
> boards when we try to use fastboot command:
> 
>   => fastboot usb 0
>   failed to get power domain
>   failed to get power domain
>   No USB device found
>   USB init failed: -19
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/1] phy: meson-g12a-usb2: fix ret check on power_domain_get
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/f699cb1dd5f4c55aa3f593c226ec797730d02f10

-- 
Neil



Re: [PATCH v1 0/2] arm: dts: meson-a1 Sync DT with Linux

2023-10-18 Thread Neil Armstrong
Hi,

On Wed, 18 Oct 2023 00:32:09 +0300, Igor Prusov wrote:
> This series syncs Device Tree for Amlogic A1 with Linux. Currently
> DTS in Linix has different compatible string for serial devices, which
> is not recognized by serial_meson driver, so new compatible is added to
> driver as well. Additional driver changes are not required because new
> compatible only differentiates between ttyAML and ttyS names for serial
> console devices.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/2] serial: amlogic: Add UART compatible for A1 board
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/43a0b2cb9be2320615aa1cfc5318857ebce3b488
[2/2] arm: meson-a1: dts: Sync DT with Linux
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/14a21f1a80afc58d52dc72e35f27d3a47d36c082

-- 
Neil



[GIT PULL] Please pull u-boot-amlogic-20231023

2023-10-23 Thread Neil Armstrong

Hi Tom,

An important fix for USB Gadget on G12/SM1 boards and a welcome DT sync for the 
Amlogic A1 DT.

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/18256

Thanks,
Neil

The following changes since commit e65b5d35c9116485366bb08138043d51220551da:

  Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh 
(2023-10-17 09:15:56 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20231023

for you to fetch changes up to 14a21f1a80afc58d52dc72e35f27d3a47d36c082:

  arm: meson-a1: dts: Sync DT with Linux (2023-10-18 09:46:01 +0200)


- sync A1 with Linux and add missing UART compatible
- fix USB2 gadget init on G12/SM1 based Boards


Guillaume La Roque (1):
  phy: meson-g12a-usb2: fix ret check on power_domain_get

Igor Prusov (2):
  serial: amlogic: Add UART compatible for A1 board
  arm: meson-a1: dts: Sync DT with Linux

 arch/arm/dts/meson-a1.dtsi| 356 +-
 drivers/phy/meson-g12a-usb2.c |   6 +-
 drivers/serial/serial_meson.c |   1 +
 3 files changed, 355 insertions(+), 8 deletions(-)


[PATCH 0/4] ARM: meson: Add boot over DFU RAM as an USB boot step

2023-10-23 Thread Neil Armstrong
Add boot over DFU RAM as an alternate to running script at
a fixed address like done today.

The main culprit is that it's not possible to do that
on G12A/SM1 platforms due to changes in the USB boot protocol.

With this, U-Boot will present a DFU device with a ram slot where
the Host could write a fitImage or legacy U-Boot image, then with the
detach command boot will continue trying to boot the uploaded image.

Signed-off-by: Neil Armstrong 
---
Neil Armstrong (4):
  ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs
  configs: meson64: declare addr out of EXTRA_ENV_SETTINGS
  configs: meson64: add alternate USB DFU boot target
  ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget

 configs/ad401_defconfig   |  2 ++
 configs/bananapi-cm4-cm4io_defconfig  |  6 
 configs/bananapi-m2-pro_defconfig |  6 
 configs/bananapi-m2s_defconfig|  6 
 configs/bananapi-m5_defconfig |  6 
 configs/beelink-gsking-x_defconfig|  6 
 configs/beelink-gt1-ultimate_defconfig|  6 
 configs/beelink-gtking_defconfig  |  6 
 configs/beelink-gtkingpro_defconfig   |  6 
 configs/jethub_j100_defconfig |  6 
 configs/jethub_j80_defconfig  |  6 
 configs/khadas-vim2_defconfig |  6 
 configs/khadas-vim3_android_ab_defconfig  |  4 +++
 configs/khadas-vim3_android_defconfig |  4 +++
 configs/khadas-vim3_defconfig |  6 
 configs/khadas-vim3l_android_ab_defconfig |  4 +++
 configs/khadas-vim3l_android_defconfig|  4 +++
 configs/khadas-vim3l_defconfig|  6 
 configs/khadas-vim_defconfig  |  6 
 configs/libretech-ac_defconfig|  6 
 configs/libretech-cc_defconfig|  6 
 configs/libretech-cc_v2_defconfig |  6 
 configs/libretech-s905d-pc_defconfig  |  6 
 configs/libretech-s912-pc_defconfig   |  6 
 configs/nanopi-k2_defconfig   |  4 +++
 configs/odroid-c2_defconfig   |  4 +++
 configs/odroid-c4_defconfig   |  6 
 configs/odroid-go-ultra_defconfig |  6 
 configs/odroid-hc4_defconfig  |  6 
 configs/odroid-n2_defconfig   |  6 
 configs/odroid-n2l_defconfig  |  6 
 configs/p200_defconfig|  4 +++
 configs/p201_defconfig|  4 +++
 configs/p212_defconfig|  4 +++
 configs/radxa-zero2_defconfig |  6 
 configs/radxa-zero_defconfig  |  6 
 configs/s400_defconfig|  6 
 configs/sei510_defconfig  |  6 
 configs/sei610_defconfig  |  6 
 configs/u200_defconfig|  6 
 configs/videostrong-kii-pro_defconfig |  4 +++
 configs/wetek-core2_defconfig |  6 
 configs/wetek-hub_defconfig   |  4 +++
 configs/wetek-play2_defconfig |  4 +++
 include/configs/meson64.h | 49 ++-
 45 files changed, 278 insertions(+), 7 deletions(-)
---
base-commit: 9a0cf3993f71043ba08c315572c54622de42d447
change-id: 20231023-usb-dfu-boot-f47849f9fb34

Best regards,
-- 
Neil Armstrong 



[PATCH 1/4] ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs

2023-10-23 Thread Neil Armstrong
Allow all boards to boot with a fitImage, but keep support for
Legacy image format for now.

Signed-off-by: Neil Armstrong 
---
 configs/bananapi-cm4-cm4io_defconfig  | 4 
 configs/bananapi-m2-pro_defconfig | 4 
 configs/bananapi-m2s_defconfig| 4 
 configs/bananapi-m5_defconfig | 4 
 configs/beelink-gsking-x_defconfig| 4 
 configs/beelink-gt1-ultimate_defconfig| 4 
 configs/beelink-gtking_defconfig  | 4 
 configs/beelink-gtkingpro_defconfig   | 4 
 configs/jethub_j100_defconfig | 4 
 configs/jethub_j80_defconfig  | 4 
 configs/khadas-vim2_defconfig | 4 
 configs/khadas-vim3_android_ab_defconfig  | 4 
 configs/khadas-vim3_android_defconfig | 4 
 configs/khadas-vim3_defconfig | 4 
 configs/khadas-vim3l_android_ab_defconfig | 4 
 configs/khadas-vim3l_android_defconfig| 4 
 configs/khadas-vim3l_defconfig| 4 
 configs/khadas-vim_defconfig  | 4 
 configs/libretech-ac_defconfig| 4 
 configs/libretech-cc_defconfig| 4 
 configs/libretech-cc_v2_defconfig | 4 
 configs/libretech-s905d-pc_defconfig  | 4 
 configs/libretech-s912-pc_defconfig   | 4 
 configs/nanopi-k2_defconfig   | 4 
 configs/odroid-c2_defconfig   | 4 
 configs/odroid-c4_defconfig   | 4 
 configs/odroid-go-ultra_defconfig | 4 
 configs/odroid-hc4_defconfig  | 4 
 configs/odroid-n2_defconfig   | 4 
 configs/odroid-n2l_defconfig  | 4 
 configs/p200_defconfig| 4 
 configs/p201_defconfig| 4 
 configs/p212_defconfig| 4 
 configs/radxa-zero2_defconfig | 4 
 configs/radxa-zero_defconfig  | 4 
 configs/s400_defconfig| 4 
 configs/sei510_defconfig  | 4 
 configs/sei610_defconfig  | 4 
 configs/u200_defconfig| 4 
 configs/videostrong-kii-pro_defconfig | 4 
 configs/wetek-core2_defconfig | 4 
 configs/wetek-hub_defconfig   | 4 
 configs/wetek-play2_defconfig | 4 
 43 files changed, 172 insertions(+)

diff --git a/configs/bananapi-cm4-cm4io_defconfig 
b/configs/bananapi-cm4-cm4io_defconfig
index bb43cc41e5..5fa4b8952a 100644
--- a/configs/bananapi-cm4-cm4io_defconfig
+++ b/configs/bananapi-cm4-cm4io_defconfig
@@ -17,6 +17,10 @@ CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_PCI=y
 CONFIG_DEBUG_UART=y
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
diff --git a/configs/bananapi-m2-pro_defconfig 
b/configs/bananapi-m2-pro_defconfig
index 4f8cec9956..6c16953383 100644
--- a/configs/bananapi-m2-pro_defconfig
+++ b/configs/bananapi-m2-pro_defconfig
@@ -16,6 +16,10 @@ CONFIG_IDENT_STRING="bpi-m2-pro"
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
diff --git a/configs/bananapi-m2s_defconfig b/configs/bananapi-m2s_defconfig
index 3dd8ddcdca..eb3bb17c9a 100644
--- a/configs/bananapi-m2s_defconfig
+++ b/configs/bananapi-m2s_defconfig
@@ -18,6 +18,10 @@ CONFIG_PCI=y
 CONFIG_DEBUG_UART=y
 CONFIG_AHCI=y
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
diff --git a/configs/bananapi-m5_defconfig b/configs/bananapi-m5_defconfig
index 696d2fcc5c..0895af81be 100644
--- a/configs/bananapi-m5_defconfig
+++ b/configs/bananapi-m5_defconfig
@@ -16,6 +16,10 @@ CONFIG_IDENT_STRING="bpi-m5"
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
diff --git a/configs/beelink-gsking-x_defconfig 
b/configs/beelink-gsking-x_defconfig
index c022097390..8cd0cff6ce 100644
--- a/configs/beelink-gsking-x_defconfig
+++ b/configs/beelink-gsking-x_defconfig
@@ -17,6 +17,10 @@ CONFIG_IDENT_STRING=" beelink"
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_REMAKE_ELF=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_OF_BOARD_SETUP=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_MISC_INIT_R=y
diff --git a/configs/beelink-gt1-ultimate_defconfig 
b/configs/beelink-gt1-ultimate_defconfig
index c0d22c4147..5156dedca8 10

[PATCH 2/4] configs: meson64: declare addr out of EXTRA_ENV_SETTINGS

2023-10-23 Thread Neil Armstrong
In order to reuse addresses for DFU RAM, define them separately,
it's cleaner and will be easier to override.

Signed-off-by: Neil Armstrong 
---
 include/configs/meson64.h | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index 801cdae470..a64817ec9b 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -84,6 +84,15 @@
func(DHCP, dhcp, na)
 #endif
 
+#define BOOTM_SIZE __stringify(0x170)
+#define KERNEL_ADDR_R  __stringify(0x0808)
+#define KERNEL_COMP_ADDR_R __stringify(0x0d08)
+#define FDT_ADDR_R __stringify(0x08008000)
+#define SCRIPT_ADDR_R  __stringify(0x0800)
+#define PXEFILE_ADDR_R __stringify(0x0108)
+#define FDTOVERLAY_ADDR_R  __stringify(0x0100)
+#define RAMDISK_ADDR_R __stringify(0x1300)
+
 #include 
 
 #ifndef CFG_EXTRA_ENV_SETTINGS
@@ -91,14 +100,14 @@
"stdin=" STDIN_CFG "\0" \
"stdout=" STDOUT_CFG "\0" \
"stderr=" STDOUT_CFG "\0" \
-   "kernel_comp_addr_r=0x0d08\0" \
+   "kernel_comp_addr_r=" KERNEL_COMP_ADDR_R "\0" \
"kernel_comp_size=0x200\0" \
-   "fdt_addr_r=0x08008000\0" \
-   "scriptaddr=0x0800\0" \
-   "kernel_addr_r=0x0808\0" \
-   "pxefile_addr_r=0x0108\0" \
-   "fdtoverlay_addr_r=0x0100\0" \
-   "ramdisk_addr_r=0x1300\0" \
+   "fdt_addr_r=" FDT_ADDR_R "\0" \
+   "scriptaddr=" SCRIPT_ADDR_R "\0" \
+   "kernel_addr_r=" KERNEL_ADDR_R "\0" \
+   "pxefile_addr_r=" PXEFILE_ADDR_R "\0" \
+   "fdtoverlay_addr_r=" FDTOVERLAY_ADDR_R "\0" \
+   "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
BOOTENV
 #endif

-- 
2.34.1



[PATCH 3/4] configs: meson64: add alternate USB DFU boot target

2023-10-23 Thread Neil Armstrong
Add boot over DFU RAM as an alternate to running script at
a fixed address like done today.

The main culprit is that it's not possible to do that
on G12A/Sm1 platforms due to changes in the USB boot protocol.

With this, U-Boot will present a DFU device with a ram slot where
the Host could write a fitImage or legacy U-Boot image, then with the
detach command boot will continue trying to boot the uploaded image.

Signed-off-by: Neil Armstrong 
---
 include/configs/meson64.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index a64817ec9b..efab9a624d 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -53,6 +53,30 @@
 #define BOOTENV_DEV_NAME_ROMUSB(devtypeu, devtypel, instance)  \
"romusb "
 
+/*
+ * Fallback to "USB DFU" boot if script is not at scriptaddr
+ *
+ * DFU will expose the kernel_addr_r memory range as DFU entry,
+ * then with `dfu-util --detach`, booting the uploaded image
+ * will be attempted:
+ * $ dfu-util -a 0 -D fitImage
+ * $ dfu-util -a 0 -e
+ */
+#if CONFIG_IS_ENABLED(USB_GADGET) && CONFIG_IS_ENABLED(DFU_RAM)
+   #define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance) \
+   "bootcmd_usbdfu=" \
+   "if test \"${boot_source}\" = \"usb\"; then " \
+   "dfu 0 ram 0 60;" \
+   "bootm ${kernel_addr_r};" \
+   "fi\0"
+
+   #define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance) \
+   "usbdfu "
+#else
+   #define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance)
+   #define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance)
+#endif
+
 #ifdef CONFIG_CMD_USB
 #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
 #else
@@ -74,6 +98,7 @@
 #ifndef BOOT_TARGET_DEVICES
 #define BOOT_TARGET_DEVICES(func) \
func(ROMUSB, romusb, na)  \
+   func(USB_DFU, usbdfu, na)  \
func(MMC, mmc, 0) \
func(MMC, mmc, 1) \
func(MMC, mmc, 2) \
@@ -109,6 +134,7 @@
"fdtoverlay_addr_r=" FDTOVERLAY_ADDR_R "\0" \
"ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
+   "dfu_alt_info=fitimage ram " KERNEL_ADDR_R " 0x400 \0" \
BOOTENV
 #endif
 

-- 
2.34.1



[PATCH 4/4] ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget

2023-10-23 Thread Neil Armstrong
Enable DFU as an alternate USB boot method when script wasn't
uploaded, this fixes USB full boot on G12/SM1 boards.

Signed-off-by: Neil Armstrong 
---
 configs/ad401_defconfig| 2 ++
 configs/bananapi-cm4-cm4io_defconfig   | 2 ++
 configs/bananapi-m2-pro_defconfig  | 2 ++
 configs/bananapi-m2s_defconfig | 2 ++
 configs/bananapi-m5_defconfig  | 2 ++
 configs/beelink-gsking-x_defconfig | 2 ++
 configs/beelink-gt1-ultimate_defconfig | 2 ++
 configs/beelink-gtking_defconfig   | 2 ++
 configs/beelink-gtkingpro_defconfig| 2 ++
 configs/jethub_j100_defconfig  | 2 ++
 configs/jethub_j80_defconfig   | 2 ++
 configs/khadas-vim2_defconfig  | 2 ++
 configs/khadas-vim3_defconfig  | 2 ++
 configs/khadas-vim3l_defconfig | 2 ++
 configs/khadas-vim_defconfig   | 2 ++
 configs/libretech-ac_defconfig | 2 ++
 configs/libretech-cc_defconfig | 2 ++
 configs/libretech-cc_v2_defconfig  | 2 ++
 configs/libretech-s905d-pc_defconfig   | 2 ++
 configs/libretech-s912-pc_defconfig| 2 ++
 configs/odroid-c4_defconfig| 2 ++
 configs/odroid-go-ultra_defconfig  | 2 ++
 configs/odroid-hc4_defconfig   | 2 ++
 configs/odroid-n2_defconfig| 2 ++
 configs/odroid-n2l_defconfig   | 2 ++
 configs/radxa-zero2_defconfig  | 2 ++
 configs/radxa-zero_defconfig   | 2 ++
 configs/s400_defconfig | 2 ++
 configs/sei510_defconfig   | 2 ++
 configs/sei610_defconfig   | 2 ++
 configs/u200_defconfig | 2 ++
 configs/wetek-core2_defconfig  | 2 ++
 32 files changed, 64 insertions(+)

diff --git a/configs/ad401_defconfig b/configs/ad401_defconfig
index b9aca3ab0d..c78014ef93 100644
--- a/configs/ad401_defconfig
+++ b/configs/ad401_defconfig
@@ -21,6 +21,7 @@ CONFIG_BOOTCOMMAND="run storeboot"
 CONFIG_SYS_PROMPT="ad401 # "
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 # CONFIG_CMD_LOADB is not set
@@ -34,6 +35,7 @@ CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
+CONFIG_DFU_RAM=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MESON=y
 CONFIG_LED=y
diff --git a/configs/bananapi-cm4-cm4io_defconfig 
b/configs/bananapi-cm4-cm4io_defconfig
index 5fa4b8952a..116147fc9a 100644
--- a/configs/bananapi-cm4-cm4io_defconfig
+++ b/configs/bananapi-cm4-cm4io_defconfig
@@ -27,6 +27,7 @@ CONFIG_MISC_INIT_R=y
 CONFIG_SYS_MAXARGS=32
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
@@ -41,6 +42,7 @@ CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_ADC=y
+CONFIG_DFU_RAM=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
 CONFIG_DM_MDIO=y
diff --git a/configs/bananapi-m2-pro_defconfig 
b/configs/bananapi-m2-pro_defconfig
index 6c16953383..2a3958b0fd 100644
--- a/configs/bananapi-m2-pro_defconfig
+++ b/configs/bananapi-m2-pro_defconfig
@@ -26,6 +26,7 @@ CONFIG_MISC_INIT_R=y
 CONFIG_SYS_MAXARGS=32
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
@@ -37,6 +38,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
+CONFIG_DFU_RAM=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
 CONFIG_DM_MDIO=y
diff --git a/configs/bananapi-m2s_defconfig b/configs/bananapi-m2s_defconfig
index eb3bb17c9a..405ce3a93a 100644
--- a/configs/bananapi-m2s_defconfig
+++ b/configs/bananapi-m2s_defconfig
@@ -28,6 +28,7 @@ CONFIG_MISC_INIT_R=y
 CONFIG_SYS_MAXARGS=32
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
@@ -40,6 +41,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
+CONFIG_DFU_RAM=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
 CONFIG_DM_MDIO=y
diff --git a/configs/bananapi-m5_defconfig b/configs/bananapi-m5_defconfig
index 0895af81be..6de5d5fe7b 100644
--- a/configs/bananapi-m5_defconfig
+++ b/configs/bananapi-m5_defconfig
@@ -26,6 +26,7 @@ CONFIG_MISC_INIT_R=y
 CONFIG_SYS_MAXARGS=32
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is not set
 CONFIG_CMD_MMC=y
@@ -37,6 +38,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
+CONFIG_DFU_RAM=y
 CONFIG_MMC_MESON_GX=y
 CONFIG_PHY_REALTEK=y
 CONFIG_DM_MDIO=y
diff --git a/configs/beelink-gsking-x_defconfig 
b/configs/beelink-gsking-x_defconfig
index 8cd0cff6ce..99e36e970a 100644
--- a/configs/beelink-gsking-x_defconfig
+++ b/configs/beelink-gsking-x_defconfig
@@ -27,6 +27,7 @@ CONFIG_MISC_INIT_R=y
 CONFIG_SYS_MAXARGS=32
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
+CONFIG_CMD_DFU=y
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_LOADS is 

Re: [PATCH] configs: khadas-vim3*_android: fix environment saving

2023-10-26 Thread Neil Armstrong

On 26/10/2023 15:41, Mattijs Korpershoek wrote:

The environment is used to configure some additional boot features such as:
* extra boot arguments
* enable AVB (Android Verified Boot) verification

Right now, we cannot store it in eMMC:

   Loading Environment from nowhere... OK

Fix it by enabling the appropriate options in the defconfig

Fixes: b749d5ecdc06 ("configs: meson64_android: define raw parts for 
bootloader")
Signed-off-by: Mattijs Korpershoek 
---
  configs/khadas-vim3_android_ab_defconfig  | 4 
  configs/khadas-vim3_android_defconfig | 4 
  configs/khadas-vim3l_android_ab_defconfig | 4 
  configs/khadas-vim3l_android_defconfig| 4 
  4 files changed, 16 insertions(+)

diff --git a/configs/khadas-vim3_android_ab_defconfig 
b/configs/khadas-vim3_android_ab_defconfig
index ccd6f6f8a075..0abccb64ee15 100644
--- a/configs/khadas-vim3_android_ab_defconfig
+++ b/configs/khadas-vim3_android_ab_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
  CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
  CONFIG_DM_GPIO=y
  CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-a311d-khadas-vim3"
  CONFIG_OF_LIBFDT_OVERLAY=y
@@ -45,7 +46,10 @@ CONFIG_CMD_AB_SELECT=y
  CONFIG_CMD_REGULATOR=y
  CONFIG_CMD_AVB=y
  CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
  CONFIG_ADC=y
  CONFIG_SARADC_MESON=y
  CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3_android_defconfig 
b/configs/khadas-vim3_android_defconfig
index 5c3d565971d6..33ede5262295 100644
--- a/configs/khadas-vim3_android_defconfig
+++ b/configs/khadas-vim3_android_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
  CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
  CONFIG_DM_GPIO=y
  CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-a311d-khadas-vim3"
  CONFIG_OF_LIBFDT_OVERLAY=y
@@ -43,7 +44,10 @@ CONFIG_CMD_USB_MASS_STORAGE=y
  CONFIG_CMD_REGULATOR=y
  CONFIG_CMD_AVB=y
  CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
  CONFIG_ADC=y
  CONFIG_SARADC_MESON=y
  CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3l_android_ab_defconfig 
b/configs/khadas-vim3l_android_ab_defconfig
index 0d6de8001382..8f32f8e8ad5b 100644
--- a/configs/khadas-vim3l_android_ab_defconfig
+++ b/configs/khadas-vim3l_android_ab_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
  CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
  CONFIG_DM_GPIO=y
  CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-khadas-vim3l"
  CONFIG_OF_LIBFDT_OVERLAY=y
@@ -45,7 +46,10 @@ CONFIG_CMD_AB_SELECT=y
  CONFIG_CMD_REGULATOR=y
  CONFIG_CMD_AVB=y
  CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
  CONFIG_ADC=y
  CONFIG_SARADC_MESON=y
  CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3l_android_defconfig 
b/configs/khadas-vim3l_android_defconfig
index 827752f24373..443c10aee3d0 100644
--- a/configs/khadas-vim3l_android_defconfig
+++ b/configs/khadas-vim3l_android_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
  CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
  CONFIG_DM_GPIO=y
  CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-khadas-vim3l"
  CONFIG_OF_LIBFDT_OVERLAY=y
@@ -43,7 +44,10 @@ CONFIG_CMD_USB_MASS_STORAGE=y
  CONFIG_CMD_REGULATOR=y
  CONFIG_CMD_AVB=y
  CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
  CONFIG_ADC=y
  CONFIG_SARADC_MESON=y
  CONFIG_BUTTON=y

---
base-commit: 14a21f1a80afc58d52dc72e35f27d3a47d36c082
change-id: 20231026-fix-saveenv-eb5484622282

Best regards,


Reviewed-by: Neil Armstrong 


Re: [PATCH] configs: khadas-vim3*_android: fix environment saving

2023-10-26 Thread Neil Armstrong
Hi,

On Thu, 26 Oct 2023 15:41:31 +0200, Mattijs Korpershoek wrote:
> The environment is used to configure some additional boot features such as:
> * extra boot arguments
> * enable AVB (Android Verified Boot) verification
> 
> Right now, we cannot store it in eMMC:
> 
>   Loading Environment from nowhere... OK
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/1] configs: khadas-vim3*_android: fix environment saving
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8a08092ddba82e18e8ed1ef84580aff00b419fbb

-- 
Neil



Re: [PATCH 0/4] ARM: meson: Add boot over DFU RAM as an USB boot step

2023-10-26 Thread Neil Armstrong
Hi,

On Mon, 23 Oct 2023 14:41:33 +0200, Neil Armstrong wrote:
> Add boot over DFU RAM as an alternate to running script at
> a fixed address like done today.
> 
> The main culprit is that it's not possible to do that
> on G12A/SM1 platforms due to changes in the USB boot protocol.
> 
> With this, U-Boot will present a DFU device with a ram slot where
> the Host could write a fitImage or legacy U-Boot image, then with the
> detach command boot will continue trying to boot the uploaded image.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/4] ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/50ad9d01b6124b9730de957e1901d177094748f6
[2/4] configs: meson64: declare addr out of EXTRA_ENV_SETTINGS
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/72f63d85fefebed59921456bb29138fbd9f73bb7
[3/4] configs: meson64: add alternate USB DFU boot target
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4aa027b3f8c1b018ab50570ccf337587cc6178f8
[4/4] ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/07057ad9be7d400d9d9f02f3c1507fe2d8071c19

-- 
Neil



Re: [PATCH v2 0/2] ARM: amlogic: Add A1 SPIFC support

2023-10-26 Thread Neil Armstrong
Hi,

On Wed, 25 Oct 2023 01:51:38 +0300, Igor Prusov wrote:
> A1 family boards have new version of SPIFC controller, that is
> incompatible with meson_spifc driver. This series ports A1 SPIFC driver
> from Linux and enables it for ad401 board.
> 
> Changes in V2:
>  - more details in Kconfig help message
>  - removed unused field of struct amlogic_spifc_a1
>  - add missed check for NULL during probe
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/2] spi: add support for Amlogic A1 SPI Flash Controller
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/bb6c1ebf99da01f2cdd2aaf751cc35723ed202e6
[2/2] ARM: amlogic: ad401: enable SPIFC
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/f22373511ca75bb098c3195e47f91d2b1ee8bc53

-- 
Neil



[GIT PULL] Please pull u-boot-amlogic-20231027

2023-10-27 Thread Neil Armstrong

Hi Tom,

A late PR to:
- fix environment saving for new Android boot features on vim3*_android
- Add SPIFC support for Amlogic A1
- Add DFU RAM boot step when booting over USB, fixing full USB boot for G12/SM1 
boards

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/18322

Thanks,
Neil

The following changes since commit fb428b61819444b9337075f49c72f326f5d12085:

  Merge branch '2023-10-24-assorted-general-fixes-and-updates' (2023-10-24 
19:12:21 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20231027

for you to fetch changes up to 892e04bc965400772e1b84e6450a7919deca0e0b:

  ARM: amlogic: ad401: enable SPIFC (2023-10-26 17:56:58 +0200)


- Fix environment saving for new Android boot features on vim3*_android
- Add SPIFC support for Amlogic A1
- Add DFU RAM boot step when booting over USB


Igor Prusov (2):
  spi: add support for Amlogic A1 SPI Flash Controller
  ARM: amlogic: ad401: enable SPIFC

Mattijs Korpershoek (1):
  configs: khadas-vim3*_android: fix environment saving

Neil Armstrong (4):
  ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs
  configs: meson64: declare addr out of EXTRA_ENV_SETTINGS
  configs: meson64: add alternate USB DFU boot target
  ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget

 configs/ad401_defconfig   |   1 +
 configs/bananapi-cm4-cm4io_defconfig  |   6 +
 configs/bananapi-m2-pro_defconfig |   6 +
 configs/bananapi-m2s_defconfig|   6 +
 configs/bananapi-m5_defconfig |   6 +
 configs/beelink-gsking-x_defconfig|   6 +
 configs/beelink-gt1-ultimate_defconfig|   6 +
 configs/beelink-gtking_defconfig  |   6 +
 configs/beelink-gtkingpro_defconfig   |   6 +
 configs/jethub_j100_defconfig |   6 +
 configs/jethub_j80_defconfig  |   6 +
 configs/khadas-vim2_defconfig |   6 +
 configs/khadas-vim3_android_ab_defconfig  |   8 +
 configs/khadas-vim3_android_defconfig |   8 +
 configs/khadas-vim3_defconfig |   6 +
 configs/khadas-vim3l_android_ab_defconfig |   8 +
 configs/khadas-vim3l_android_defconfig|   8 +
 configs/khadas-vim3l_defconfig|   6 +
 configs/khadas-vim_defconfig  |   6 +
 configs/libretech-ac_defconfig|   6 +
 configs/libretech-cc_defconfig|   6 +
 configs/libretech-cc_v2_defconfig |   6 +
 configs/libretech-s905d-pc_defconfig  |   6 +
 configs/libretech-s912-pc_defconfig   |   6 +
 configs/nanopi-k2_defconfig   |   4 +
 configs/odroid-c2_defconfig   |   4 +
 configs/odroid-c4_defconfig   |   6 +
 configs/odroid-go-ultra_defconfig |   6 +
 configs/odroid-hc4_defconfig  |   6 +
 configs/odroid-n2_defconfig   |   6 +
 configs/odroid-n2l_defconfig  |   6 +
 configs/p200_defconfig|   4 +
 configs/p201_defconfig|   4 +
 configs/p212_defconfig|   4 +
 configs/radxa-zero2_defconfig |   6 +
 configs/radxa-zero_defconfig  |   6 +
 configs/s400_defconfig|   6 +
 configs/sei510_defconfig  |   6 +
 configs/sei610_defconfig  |   6 +
 configs/u200_defconfig|   6 +
 configs/videostrong-kii-pro_defconfig |   4 +
 configs/wetek-core2_defconfig |   6 +
 configs/wetek-hub_defconfig   |   4 +
 configs/wetek-play2_defconfig |   4 +
 drivers/spi/Kconfig   |   9 +
 drivers/spi/Makefile  |   1 +
 drivers/spi/meson_spifc_a1.c  | 384 ++
 include/configs/meson64.h |  49 +++-
 48 files changed, 687 insertions(+), 7 deletions(-)
 create mode 100644 drivers/spi/meson_spifc_a1.c


Re: [PATCH] MAINTAINERS: update Qualcomm maintainer

2023-10-31 Thread Neil Armstrong

On 31/10/2023 16:19, Caleb Connolly wrote:

As Ramon has been inactive for some time now, add myself and Neil
Armstrong to maintain Qualcomm efforts going forwards.

Signed-off-by: Caleb Connolly 
---
I greatly appreciate the work done by Ramon Fried in keeping Qualcomm
support alive in U-Boot the last few years. However it's clear that
he hasn't been very active for some time now.

I am currently working on a large cleanup effort to modernise Qualcomm
support and enable several new reference platforms. To better facilitate
this and to handle Qualcomm support going forwards, make myself maintainer
of ARM SNAPDRAGON as well as my colleague Neil Armstrong (Amlogic
maintainer).

I hope Ramon continues to participate in discussions and reviews going
forward.
---
base-commit: cbba1b7766bd93d74e28202c46e69095ac13760b

// Caleb (they/them)
---
  MAINTAINERS | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cde778bc4d3d..be3666d14047 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -567,7 +567,8 @@ S:  Supported
  F:arch/arm/dts/am335x-sancloud*
  
  ARM SNAPDRAGON

-M: Ramon Fried 
+M: Caleb Connolly 
+M: Neil Armstrong 
  S:Maintained
  F:arch/arm/mach-snapdragon/
  F:drivers/gpio/msm_gpio.c



Obviously:
Acked-by: Neil Armstrong 

Thanks Caleb, cleanup of mach-snapdragon is welcome and I'll be happy to 
participate!

Neil


Re: [PATCH v1 1/2] clk: a1: add new clocks for USB stack

2023-11-02 Thread neil . armstrong

On 01/11/2023 15:04, Alexey Romanov wrote:

Since we sync device tree with Linux, we have to add this
clock definition for USB stack.

Signed-off-by: Alexey Romanov 
---
  drivers/clk/meson/a1.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/clk/meson/a1.c b/drivers/clk/meson/a1.c
index 1075ba7333..d0f5bb3753 100644
--- a/drivers/clk/meson/a1.c
+++ b/drivers/clk/meson/a1.c
@@ -241,6 +241,12 @@ static const struct meson_clk_info *meson_clocks[] = {
[CLKID_USB_PHY_IN] = CLK_GATE("usb_phy_in", A1_SYS_OSCIN_CTRL, 2,
EXTERNAL_XTAL
),
+   [CLKID_USB_CTRL_IN] = CLK_GATE("usb_ctrl_in", A1_SYS_OSCIN_CTRL, 3,
+   EXTERNAL_XTAL
+   ),
+   [CLKID_USB_CTRL] = CLK_GATE("usb_ctrl", A1_SYS_CLK_EN0, 28,
+   CLKID_SYS
+   ),
[CLKID_USB_PHY] = CLK_GATE("usb_phy", A1_SYS_CLK_EN0, 27,
CLKID_SYS
),


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 2/2] drivers: sm: bind child sm devices in the device tree

2023-11-02 Thread neil . armstrong

On 01/11/2023 15:04, Alexey Romanov wrote:

From: Dmitry Rokosov 

One well-known sm child device that provides secure power control is the
Secure Power Controller. This device utilizes SMC calls to communicate
with power domains on the secure monitor side.

Signed-off-by: Dmitry Rokosov 
Signed-off-by: Alexey Romanov 
---
  drivers/sm/meson-sm.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/sm/meson-sm.c b/drivers/sm/meson-sm.c
index faef369f35..1dd1584855 100644
--- a/drivers/sm/meson-sm.c
+++ b/drivers/sm/meson-sm.c
@@ -194,6 +194,7 @@ U_BOOT_DRIVER(meson_sm) = {
.id = UCLASS_SM,
.of_match = meson_sm_ids,
.probe = meson_sm_probe,
+   .bind = dm_scan_fdt_dev,
.priv_auto = sizeof(struct meson_sm_priv),
.ops = &sm_ops,
  };


Reviewed-by: Neil Armstrong 


[PATCH] ARM: configs: libretech-ac: enable USB_DFU like in meson64.h

2023-11-02 Thread Neil Armstrong
USB_DFU was added in meson64.h but is missing in libretech-ac.h,
fix this to enable DFU RAM boot for libretech-ac.

Fixes 4aa027b3f8 ("configs: meson64: add alternate USB DFU boot target")

Signed-off-by: Neil Armstrong 
---
 include/configs/libretech-ac.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/libretech-ac.h b/include/configs/libretech-ac.h
index bf20d31543..16239f2520 100644
--- a/include/configs/libretech-ac.h
+++ b/include/configs/libretech-ac.h
@@ -11,6 +11,7 @@
 
 #define BOOT_TARGET_DEVICES(func) \
func(ROMUSB, romusb, na)  \
+   func(USB_DFU, usbdfu, na)  \
func(MMC, mmc, 0) \
BOOT_TARGET_DEVICES_USB(func) \
func(PXE, pxe, na) \

---
base-commit: a803f87202aa48974bdff4d8100464a8288931e4
change-id: 20231102-libretech-ac-fix-dfu-dbd8109d552d

Best regards,
-- 
Neil Armstrong 



Re: [PATCH v1 0/2] Meson A1: fix USB and NAND stack

2023-11-06 Thread Neil Armstrong
Hi,

On Wed, 01 Nov 2023 17:04:55 +0300, Alexey Romanov wrote:
> After a recent sync device tree with the Linux Kernel,
> some drivers broke. These patchset will fix that.
> 
> Alexey Romanov (1):
>   clk: a1: add new clocks for USB stack
> 
> Dmitry Rokosov (1):
>   drivers: sm: bind child sm devices in the device tree
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/2] clk: a1: add new clocks for USB stack
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8ec790399aa88bb8d0a02282e411f34584c74950
[2/2] drivers: sm: bind child sm devices in the device tree
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/e9f4f7789cdcda342b2f7edb82a6141f82f4c7c2

-- 
Neil



Re: [PATCH] ARM: configs: libretech-ac: enable USB_DFU like in meson64.h

2023-11-06 Thread Neil Armstrong
Hi,

On Thu, 02 Nov 2023 14:49:58 +0100, Neil Armstrong wrote:
> USB_DFU was added in meson64.h but is missing in libretech-ac.h,
> fix this to enable DFU RAM boot for libretech-ac.
> 
> Fixes 4aa027b3f8 ("configs: meson64: add alternate USB DFU boot target")
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/1] ARM: configs: libretech-ac: enable USB_DFU like in meson64.h
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/c550e81171940932664a85bda315a6a073aae23c

-- 
Neil



[GIT PULL] Please pull u-boot-amlogic-20231106

2023-11-06 Thread Neil Armstrong

Hi Tom,

A little set of fix for:
- also enable DFU RAM boot for libretech-ac, since it uses a different config 
header
- SM probe fix
- A1 USB missing clocks

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/18452

Thanks,
Neil

The following changes since commit a4c83bda17196bf5d1ce640844595aaeced6465e:

  Merge branch '2023-11-03-assorted-tegra-improvements' (2023-11-04 09:55:39 
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20231106

for you to fetch changes up to c550e81171940932664a85bda315a6a073aae23c:

  ARM: configs: libretech-ac: enable USB_DFU like in meson64.h (2023-11-06 
09:46:05 +0100)


- fixup to also enabled DFU RAM boot for libretech-ac
- sm fix to bind child sm devices in the device tree
- add missing A1 clocks for USB stack


Alexey Romanov (1):
  clk: a1: add new clocks for USB stack

Dmitry Rokosov (1):
  drivers: sm: bind child sm devices in the device tree

Neil Armstrong (1):
  ARM: configs: libretech-ac: enable USB_DFU like in meson64.h

 drivers/clk/meson/a1.c | 6 ++
 drivers/sm/meson-sm.c  | 1 +
 include/configs/libretech-ac.h | 1 +
 3 files changed, 8 insertions(+)


Re: [PATCH v1 1/2] drivers: firmware: introduce Meson Secure Monitor driver

2023-08-22 Thread neil . armstrong

On 21/08/2023 21:11, Simon Glass wrote:

Hi Neil,

On Mon, 21 Aug 2023 at 03:16, neil.armstr...@linaro.org
 wrote:


Hi,

On 16/07/2023 01:40, Simon Glass wrote:

Hi,

On Thu, 13 Jul 2023 at 23:30, AKASHI Takahiro
 wrote:


On Tue, Jul 11, 2023 at 01:13:29PM -0600, Simon Glass wrote:

+AKASHI Takahiro


Me?


Yes, I'm asking for your help to try to clean this stuff up.


The thread is long and hard to answer directly, but as AKASHI
said there's no point to add a SMC class since it's only the message
passing instruction, and there's no point using remoteproc since the
firmware runs on a separate secure state of the same CPU.

And I don't see how we can actually define a finite set of ops because
none of the secure firmware interfaces has even similar functions.

So a new UCLASS for each firmware interface should be added, not sure
this is scalable or required since those firmwares are mainly SoC or
vendor specific, except the PSCI or other ARM specific interfaces of course.

So I think UCLASS_FIRMWARE is good enough since it avoids using UCLASS_MISC,
but it should be probably documented somewhere that the ops are implementation
defined.


Yes it needs docs...but what exactly is the 'firmware' uclass? I
assumed it was for loading firmware into a device, but it seems that
it is something else?


Nop, it's based on the same "firmware" naming as Linux, which is an interface
with a system control firmware like PSCI, SCPI... not to interact with loadable
co-processors.

Systems do have multiple interfaces implemented like PSCI, SCPI, OPTEE and other
vendor specific ones like Alexey is changing, all via the same instruction call.



Perhaps we should have a UCLASS_SVC (supervisor call) or something
like that, rather than continuing with firmware?


I have no opinion on that, I don't think the call type is significant here.

Neil



[..]

Regards,
Simon




Re: [PATCH v2 0/1] meson: Demonstration of using binman to produce the image

2023-08-31 Thread neil . armstrong

On 31/08/2023 05:37, Simon Glass wrote:

Hi Ferass,

On Wed, 30 Aug 2023 at 11:53, Ferass El Hafidi
 wrote:


Hi Simon,


So I wonder how best to move this forward so that we can build things
using binman and everything works?


It's still not ready yet, but I'm working on porting U-Boot SPL to some
Amlogic SoCs [1]. I'm currently working on Amlogic S905 boards, but
eventually I'll work on Amlogic S905X devices too. And speaking of
signing, Jonas Karlman wrote amlimage, and integrated it into mkimage,
and I applied his patch to my tree. There's a few things to be aware of
about Amlogic signing and binaries in general, however.

amlimage was intended for use with U-Boot SPL, which obviously has
no support for Amlogic's FIP format and as such amlimage will only do as
little as possible to get the bootROM to load U-Boot SPL. Most of the
packaging format is handled by BL2. The fact that the signing process is
completly different across SoC generations makes it difficult to
implement them all into one single tool (and by which I mean all of it,
not just signing BL2 for the bootROM to run it, that's mostly the same
across SoCs). amlimage has been confirmed to work on GXBB (ODROID-C2 and
the KII Pro set-top box), GXL (librecomputer lepotato), and SM1 (ODROID-C4).

My U-Boot SPL port is still rather incomplete. As of today, it still
can't boot anything from any storage device. The goal eventually is to
be able to load upstream TF-A BL31 and U-Boot+linux.

While Amlogic distributes proprietary BL31 binaries upstream Trusted
Firmware-A has a port for some Amlogic SoCs [2], but as far as I know
SM1 (which is the SoC generation your ODROID-C4 is using) is still
unsupported. GXBB, GXL, AXG, and G12A are all supported however, but the
overall port still lacks some features the proprietary implementation
has.

As for the SCP firmware (aka. BL30) I'm not aware of any
reverse-engineering efforts for that.



Thanks for your efforts on this. I look forward to seeing where it ends up.


Honestly, in my opinion, including proprietary and poorly-written
Amlogic utilities lacking a proper license, into U-Boot looks like a bad idea.


With Binman, we don't really include them in U-Boot; we allow them to
be fetched easily so that a complete build can be produced.

I don't like it either, but for users it is better than doing the
build manually.


I'll rather spend time and effort to have a fully-upstream TF-A boot chain
for Amlogic SoC (when possible) that maintaining support for bulky closed-source
x86-64 binary only tools. The tools aren't even officially distributed.

Neil





[1]: https://git.vitali64.duckdns.org/misc/u-boot-kii-pro.git/log/?h=wip/spl
[2]: 
https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/amlogic

Cheers.



Regards,
Simon




Re: [PATCH] cmd: pxe: add alias devicetree-overlay for fdtoverlays

2022-09-20 Thread Neil Armstrong

Hi,

On 19/09/2022 20:50, Edoardo Tomelleri wrote:

This adds keyword devicetree-overlay as an alias for fdtoverlays in
extlinux (sysboot) and pxe to better follow the Boot Loader Specification,
improves documentation around them by adding an example for both
fdtoverlays and devicetree-overlay and the environment variable required
for this feature.


The patch looks fine, especially the doc part which is a great +

Concerning the alias name, can you specify in the patch the link to the
Boot Loader Specification ? And probably update the PXE doc but reusing
the same wording.



Signed-off-by: Edoardo Tomelleri 
---

  boot/pxe_utils.c   |  2 ++
  doc/README.pxe |  4 
  doc/develop/distro.rst | 26 ++
  3 files changed, 32 insertions(+)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index a364fa8bb5..d5c215ae2c 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -380,6 +380,7 @@ err:
  
  /**

   * label_boot_fdtoverlay() - Loads fdt overlays specified in 'fdtoverlays'
+ * or 'devicetree-overlay'
   *
   * @ctx: PXE context
   * @label: Label to process
@@ -809,6 +810,7 @@ static const struct token keywords[] = {
{"devicetreedir", T_FDTDIR},
{"fdtdir", T_FDTDIR},
{"fdtoverlays", T_FDTOVERLAYS},
+   {"devicetree-overlay", T_FDTOVERLAYS},
{"ontimeout", T_ONTIMEOUT,},
{"ipappend", T_IPAPPEND,},
{"background", T_BACKGROUND,},
diff --git a/doc/README.pxe b/doc/README.pxe
index 75caa01c4a..14aa078d52 100644
--- a/doc/README.pxe
+++ b/doc/README.pxe
@@ -163,6 +163,8 @@ fdtoverlays  [...] - if this label is chosen, use 
tftp to retrieve the DT
and then applied in the load order to the fdt blob 
stored at the
address indicated in the fdt_addr_r environment 
variable.
  
+devicetree-overlay  [...] - alias for fdtoverlays, see above.

+
  kaslrseed   - set this label to request random number from hwrng as 
kaslr seed.
  
  append 	- use  as the kernel command line when booting this

@@ -178,6 +180,8 @@ fdt - if this label is chosen, use tftp to 
retrieve the fdt blob
  the fdt_addr_r environment variable, and that address will
  be passed to bootm.
  
+devicetree- alias for fdt, see above.

+
  fdtdir- if this label is chosen, use tftp to retrieve a fdt blob
  relative to . If the fdtfile environment variable
  is set, / is retrieved. Otherwise, the
diff --git a/doc/develop/distro.rst b/doc/develop/distro.rst
index 3ee3dac6a2..920e173548 100644
--- a/doc/develop/distro.rst
+++ b/doc/develop/distro.rst
@@ -81,6 +81,8 @@ as specified at BootLoaderSpec_:
  * Does not document the fdtdir option, which automatically selects the DTB to
pass to the kernel.
  
+See also doc/README.pxe under 'pxe file format'.

+
  One example extlinux.conf generated by the Fedora installer is::
  
  # extlinux.conf generated by anaconda

@@ -115,6 +117,25 @@ One example extlinux.conf generated by the Fedora 
installer is::
  fdtdir /boot/dtb-3.16.0-0.rc6.git1.1.fc22.armv7hl+lpae
  
  
+One example of hand-crafted extlinux.conf::

+
+   menu title Select kernel
+   timeout 100
+
+   label Arch with uart devicetree overlay
+   kernel /arch/Image.gz
+   initrd /arch/initramfs-linux.img
+   fdt /dtbs/arch/board.dtb
+   fdtoverlays /dtbs/arch/overlay/uart0-gpio0-1.dtbo
+   append console=ttyS0,115200 console=tty1 rw 
root=UUID=fc0d0284-ca84-4194-bf8a-4b9da8d66908
+
+   label Arch with uart devicetree overlay but with Boot Loader Specification 
keys
+   kernel /arch/Image.gz
+   initrd /arch/initramfs-linux.img
+   devicetree /dtbs/arch/board.dtb
+   devicetree-overlay /dtbs/arch/overlay/uart0-gpio0-1.dtbo
+   append console=ttyS0,115200 console=tty1 rw 
root=UUID=fc0d0284-ca84-4194-bf8a-4b9da8d66908
+
  Another hand-crafted network boot configuration file is::
  
  TIMEOUT 100

@@ -214,6 +235,11 @@ fdt_addr_r:
  
A size of 1MB for the FDT/DTB seems reasonable.
  
+fdtoverlay_addr_r:

+  Mandatory. The location in RAM where DTB overlays will be temporarily
+  stored and then applied in the load order to the fdt blob stored at the
+  address indicated in the fdt_addr_r environment variable.
+
  fdtfile:
Mandatory. the name of the DTB file for the specific board for instance
the espressobin v5 board the value is "marvell/armada-3720-espressobin.dtb"




Re: [PATCH v2] cmd: pxe: add alias devicetree-overlay for fdtoverlays

2022-09-21 Thread Neil Armstrong
D=fc0d0284-ca84-4194-bf8a-4b9da8d66908
+
+   label Arch with uart devicetree overlay but with Boot Loader Specification 
keys
+   kernel /arch/Image.gz
+   initrd /arch/initramfs-linux.img
+   devicetree /dtbs/arch/board.dtb
+   devicetree-overlay /dtbs/arch/overlay/uart0-gpio0-1.dtbo
+   append console=ttyS0,115200 console=tty1 rw 
root=UUID=fc0d0284-ca84-4194-bf8a-4b9da8d66908
+
  Another hand-crafted network boot configuration file is::
  
  TIMEOUT 100

@@ -214,6 +235,11 @@ fdt_addr_r:
  
A size of 1MB for the FDT/DTB seems reasonable.
  
+fdtoverlay_addr_r:

+  Mandatory. The location in RAM where DTB overlays will be temporarily
+  stored and then applied in the load order to the fdt blob stored at the
+  address indicated in the fdt_addr_r environment variable.
+
  fdtfile:
Mandatory. the name of the DTB file for the specific board for instance
the espressobin v5 board the value is "marvell/armada-3720-espressobin.dtb"
@@ -408,7 +434,7 @@ way in future u-boot versions.  In particular the _boot
  variables (e.g. mmc_boot, usb_boot) are a strictly internal implementation
  detail and must not be used as a public interface.
  
-.. _BootLoaderSpec: http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/

+.. _`Boot Loader Specification`: https://systemd.io/BOOT_LOADER_SPECIFICATION/
  
  .. sectionauthor:: (C) Copyright 2014 Red Hat Inc.

  .. sectionauthor:: Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights 
reserved.


Thanks for updating the doc and link to the spec !

Reviewed-by: Neil Armstrong 


Re: [PATCH] arm: amlogic: add setbrg op to serial device

2022-09-22 Thread Neil Armstrong

Hi,

Sorry for the delay...

On 18/09/2022 18:17, Edoardo Tomelleri wrote:

Implement setbrg in amlogic/meson serial device with driver model
similar to how the meson_uart.c driver does it in Linux. Also
configure (probe) the serial device with the new reg5 register.

Signed-off-by: Edoardo Tomelleri 
---

  drivers/serial/serial_meson.c | 70 +++
  include/configs/meson64.h |  7 
  2 files changed, 77 insertions(+)

diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c
index d69ec221..90c370cf 100644
--- a/drivers/serial/serial_meson.c
+++ b/drivers/serial/serial_meson.c
@@ -7,9 +7,11 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
+#include 
  
  struct meson_uart {

u32 wfifo;
@@ -17,6 +19,7 @@ struct meson_uart {
u32 control;
u32 status;
u32 misc;
+   u32 reg5; /* New baud control register */
  };
  
  struct meson_serial_plat {

@@ -42,6 +45,35 @@ struct meson_serial_plat {
  #define AML_UART_RX_RST   BIT(23)
  #define AML_UART_CLR_ERR  BIT(24)
  
+/* AML_UART_REG5 bits */

+#define AML_UART_REG5_XTAL_DIV2BIT(27)
+#define AML_UART_REG5_XTAL_CLK_SEL BIT(26) /* default 0 (div by 3), 1 for 
no div */
+#define AML_UART_REG5_USE_XTAL_CLK BIT(24) /* default 1 (use crystal as 
clock source) */
+#define AML_UART_REG5_USE_NEW_BAUD BIT(23) /* default 1 (use new baud rate 
register) */
+#define AML_UART_REG5_BAUD_MASK0x7f
+
+static u32 meson_calc_baud_divisor(ulong src_rate, u32 baud)
+{
+   /*
+* Usually src_rate is 24 MHz (from crystal) as clock source for serial
+* device. Since 8 Mb/s is the maximum supported baud rate, use div by 3
+* to derive baud rate. This choice is used also in meson_serial_setbrg.
+*/
+   return DIV_ROUND_CLOSEST(src_rate / 3, baud) - 1;
+}
+
+static void meson_serial_set_baud(struct meson_uart *uart, ulong src_rate, u32 
baud)
+{
+   /*
+* Set crystal divided by 3 (regardless of device tree clock property)
+* as clock source and the corresponding divisor to approximate baud
+*/
+   u32 divisor = meson_calc_baud_divisor(src_rate, baud);
+   u32 val = AML_UART_REG5_USE_XTAL_CLK | AML_UART_REG5_USE_NEW_BAUD |
+   (divisor & AML_UART_REG5_BAUD_MASK);
+   writel(val, &uart->reg5);
+}
+
  static void meson_serial_init(struct meson_uart *uart)
  {
u32 val;
@@ -59,7 +91,14 @@ static int meson_serial_probe(struct udevice *dev)
  {
struct meson_serial_plat *plat = dev_get_plat(dev);
struct meson_uart *const uart = plat->reg;
+   struct clk per_clk;
+   int ret = clk_get_by_name(dev, "baud", &per_clk);
+
+   if (ret)
+   return ret;
+   ulong rate = clk_get_rate(&per_clk);
  
+	meson_serial_set_baud(uart, rate, CONFIG_BAUDRATE);

meson_serial_init(uart);
  
  	return 0;

@@ -111,6 +150,36 @@ static int meson_serial_putc(struct udevice *dev, const 
char ch)
return 0;
  }
  
+static int meson_serial_setbrg(struct udevice *dev, const int baud)

+{
+   /*
+* Change device baud rate if baud is reasonable (considering a 23 bit
+* counter with an 8 MHz clock input) and the actual baud
+* rate is within 2% of the requested value (2% is arbitrary).
+*/
+   if (baud < 1 || baud > 800)
+   return -EINVAL;
+
+   struct meson_serial_plat *const plat = dev_get_plat(dev);
+   struct meson_uart *const uart = plat->reg;
+   struct clk per_clk;
+   int ret = clk_get_by_name(dev, "baud", &per_clk);
+
+   if (ret)
+   return ret;
+   ulong rate = clk_get_rate(&per_clk);
+   u32 divisor = meson_calc_baud_divisor(rate, baud);
+   u32 calc_baud = (rate / 3) / (divisor + 1);
+   u32 calc_err = baud > calc_baud ? baud - calc_baud : calc_baud - baud;
+
+   if (((calc_err * 100) / baud) > 2)
+   return -EINVAL;
+
+   meson_serial_set_baud(uart, rate, baud);
+
+   return 0;
+}
+
  static int meson_serial_pending(struct udevice *dev, bool input)
  {
struct meson_serial_plat *plat = dev_get_plat(dev);
@@ -154,6 +223,7 @@ static const struct dm_serial_ops meson_serial_ops = {
.putc = meson_serial_putc,
.pending = meson_serial_pending,
.getc = meson_serial_getc,
+   .setbrg = meson_serial_setbrg,
  };
  
  static const struct udevice_id meson_serial_ids[] = {

diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index 196e58ed..01413a02 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -16,6 +16,13 @@
  #define GICC_BASE 0xc4302000
  #endif
  
+/* Serial drivers */

+/* The following table includes the supported baudrates */
+#define CONFIG_SYS_BAUDRATE_TABLE  \
+   {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, \
+

Re: [PATCH] arm: amlogic: add setbrg op to serial device

2022-09-23 Thread neil . armstrong

Hi,

On 22/09/2022 20:51, Edoardo Tomelleri wrote:

Hello,
Il giorno gio 22 set 2022 alle ore 18:51 Neil Armstrong
 ha scritto:


Hi,

Sorry for the delay...

No problem, don't worry


Looks good !

If someone can test it ? otherwise I'll take it for next release.

...does it count if I've tested it? I have a radxa zero board (S905Y2
chip), this started as an experimentation
with editing register values in memory "for fun" and I decided to try
to make a patch out of it.


Yes it's perfect, thanks a lot for the test results !


I do not have an oscilloscope so I can not accurately measure the baud
rate, but the logic is the same as
in linux and using an USB to UART (PL2303) adapter console input and
loady command work fine.
I've just repeated a small test: I'm using picocom and lrzsz in ymodem
mode under WSL, the usb adapter
is forwarded to WSL using usbip, but this should not change anything
at this kind of speed (I hope).
Here are some results sending a 1 MB test file (created once from /dev/urandom):
picocom v3.1

port is: /dev/ttyUSB0
flowcontrol: none
baudrate is: 115200
parity is  : none
databits are   : 8
stopbits are   : 1
[...]
send_cmd is: sz --ymodem -vv
receive_cmd is : rz -vv -E
[...]
@115200
Bytes Sent:1048576   BPS:7762
@230400
Bytes Sent:1048576   BPS:16372
@460800
Bytes Sent:1048576   BPS:26681
@50
Bytes Sent:1048576   BPS:27689
@50 (2nd run)
Bytes Sent:1048576   BPS:27207

At this point I stopped testing, I think my adapter is not good enough
and that the logic
is correct (I've read amlogic's public datasheets [1], but I've not
found a formula specified there),
Reading address (for hardware device UARTAO1, that _of course_ is not
listed there)
md.l 0xff803014 1
ff803014: 018f
This corresponds to REG5 of device UARTAO1, with bits 24 (USE_XTAL_CLK), 23
(use new baud rate) set, and bits 27 and 26 clear (so 24 MHz crystal
clock is divided by 3),
NEW_BAUD_RATE is f, so baud rate should be (8 MHz / (15 + 1)) = 500K.

Other than that, I noticed that setting the env variable baudrate is
restricted to values allowed
in a compile time config, loady is not and loady ignores the return
value of meson_serial_setbrg
(it returns -EINVAL if for example a baudrate higher than 8'000'000 is
requested), here's a test
(with env variable baudrate=50):
=> loady 0x0100 801
## Switch baudrate to 801 bps and press ENTER ...
## Ready for binary (ymodem) download to 0x0100 at 801 bps...
C
*** file: ./dest
$ sz --ymodem -vv ./dest
Sending: dest
Bytes Sent:1048576   BPS:27781
Sending:
Ymodem sectors/kbytes sent:   0/ 0k
Transfer complete

*** exit status: 0 ***
## Total Size  = 0x0010 = 1048576 Bytes
## Start Addr  = 0x0100
## Switch baudrate to 50 bps and press ESC ...
=>

setbrg fails, the baud rate register is left at the 500'000 setting
and that's it.
I think the "for fun" experiment has gone a bit too far.

Edoardo
[1] 
https://dl.radxa.com/zero/docs/hw/IO%20Interface%ef%bc%8dS905Y2%20Datasheet.pdf


I'll apply it then.

Acked-by: Neil Armstrong 

Please send more patches with such quality !

Thanks,
Neil


Re: [PATCH] arm: amlogic: add setbrg op to serial device

2022-09-23 Thread Neil Armstrong

On 23/09/2022 10:23, Neil Armstrong via groups.io wrote:

Hi,

On 22/09/2022 20:51, Edoardo Tomelleri wrote:

Hello,
Il giorno gio 22 set 2022 alle ore 18:51 Neil Armstrong
 ha scritto:


Hi,

Sorry for the delay...

No problem, don't worry


Looks good !

If someone can test it ? otherwise I'll take it for next release.

...does it count if I've tested it? I have a radxa zero board (S905Y2
chip), this started as an experimentation
with editing register values in memory "for fun" and I decided to try
to make a patch out of it.


Yes it's perfect, thanks a lot for the test results !


I do not have an oscilloscope so I can not accurately measure the baud
rate, but the logic is the same as
in linux and using an USB to UART (PL2303) adapter console input and
loady command work fine.
I've just repeated a small test: I'm using picocom and lrzsz in ymodem
mode under WSL, the usb adapter
is forwarded to WSL using usbip, but this should not change anything
at this kind of speed (I hope).
Here are some results sending a 1 MB test file (created once from /dev/urandom):
picocom v3.1

port is    : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 115200
parity is  : none
databits are   : 8
stopbits are   : 1
[...]
send_cmd is    : sz --ymodem -vv
receive_cmd is : rz -vv -E
[...]
@115200
Bytes Sent:1048576   BPS:7762
@230400
Bytes Sent:1048576   BPS:16372
@460800
Bytes Sent:1048576   BPS:26681
@50
Bytes Sent:1048576   BPS:27689
@50 (2nd run)
Bytes Sent:1048576   BPS:27207

At this point I stopped testing, I think my adapter is not good enough
and that the logic
is correct (I've read amlogic's public datasheets [1], but I've not
found a formula specified there),
Reading address (for hardware device UARTAO1, that _of course_ is not
listed there)
md.l 0xff803014 1
ff803014: 018f
This corresponds to REG5 of device UARTAO1, with bits 24 (USE_XTAL_CLK), 23
(use new baud rate) set, and bits 27 and 26 clear (so 24 MHz crystal
clock is divided by 3),
NEW_BAUD_RATE is f, so baud rate should be (8 MHz / (15 + 1)) = 500K.

Other than that, I noticed that setting the env variable baudrate is
restricted to values allowed
in a compile time config, loady is not and loady ignores the return
value of meson_serial_setbrg
(it returns -EINVAL if for example a baudrate higher than 8'000'000 is
requested), here's a test
(with env variable baudrate=50):
=> loady 0x0100 801
## Switch baudrate to 801 bps and press ENTER ...
## Ready for binary (ymodem) download to 0x0100 at 801 bps...
C
*** file: ./dest
$ sz --ymodem -vv ./dest
Sending: dest
Bytes Sent:1048576   BPS:27781
Sending:
Ymodem sectors/kbytes sent:   0/ 0k
Transfer complete

*** exit status: 0 ***
## Total Size  = 0x0010 = 1048576 Bytes
## Start Addr  = 0x0100
## Switch baudrate to 50 bps and press ESC ...
=>

setbrg fails, the baud rate register is left at the 500'000 setting
and that's it.
I think the "for fun" experiment has gone a bit too far.

Edoardo
[1] 
https://dl.radxa.com/zero/docs/hw/IO%20Interface%ef%bc%8dS905Y2%20Datasheet.pdf


I'll apply it then.

Acked-by: Neil Armstrong 


Oops :
Acked-by: Neil Armstrong 



Please send more patches with such quality !

Thanks,
Neil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#1349): https://groups.io/g/u-boot-amlogic/message/1349
Mute This Topic: https://groups.io/mt/93775646/900740
Group Owner: u-boot-amlogic+ow...@groups.io
Unsubscribe: https://groups.io/g/u-boot-amlogic/unsub 
[neil.armstr...@linaro.org]
-=-=-=-=-=-=-=-=-=-=-=-






Re: [PATCH] arm: amlogic: add setbrg op to serial device

2022-09-23 Thread Neil Armstrong
Hi,

On Sun, 18 Sep 2022 18:17:01 +0200, Edoardo Tomelleri wrote:
> Implement setbrg in amlogic/meson serial device with driver model
> similar to how the meson_uart.c driver does it in Linux. Also
> configure (probe) the serial device with the new reg5 register.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-test)

[1/1] arm: amlogic: add setbrg op to serial device
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/7802c3ac52ab44c5243b3ef328ab406de47a2364

-- 
Neil


[GIT PULL] Please pull u-boot-amlogic-20220809

2022-08-09 Thread Neil Armstrong



Hi Tom,

Here's changes for next release:
- fixup error on efuse commands return
- add documentation on boot flow

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/13087

Thanks,
Neil

The following changes since commit 2d2c61ff0460740d9ec5a44dbef9255a8c690696:

  Merge tag 'efi-2022-07-rc7' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2022-07-06 09:17:08 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20220809

for you to fetch changes up to 3145e0d0ff0837647351f2ca261b4cde779f83e0:

  ARM: meson: fixup error on efuse commands return (2022-08-08 09:56:38 +0200)


- fixup error on efuse commands return
- add documentation on boot flow


Jerome Brunet (1):
  ARM: meson: fixup error on efuse commands return

Neil Armstrong (1):
  doc: board: amlogic: add documentation on boot flow

 arch/arm/mach-meson/sm.c|   9 +--
 doc/board/amlogic/boot-flow.rst | 134 
 doc/board/amlogic/index.rst |   1 +
 3 files changed, 138 insertions(+), 6 deletions(-)
 create mode 100644 doc/board/amlogic/boot-flow.rst


[PATCH] MAINTAINERS: Update email of Neil Armstrong

2022-08-16 Thread Neil Armstrong
From: Neil Armstrong 

My professional e-mail will change and the BayLibre one will
bounce after mid-september of 2022.

This updates the MAINTAINERS files and adds an entry in the
.mailmap file.

Signed-off-by: Neil Armstrong 
---
 .mailmap| 1 +
 MAINTAINERS | 2 +-
 board/amlogic/odroid-n2/MAINTAINERS | 2 +-
 board/amlogic/p200/MAINTAINERS  | 2 +-
 board/amlogic/p201/MAINTAINERS  | 2 +-
 board/amlogic/p212/MAINTAINERS  | 2 +-
 board/amlogic/q200/MAINTAINERS  | 2 +-
 board/amlogic/s400/MAINTAINERS  | 2 +-
 board/amlogic/sei510/MAINTAINERS| 2 +-
 board/amlogic/sei610/MAINTAINERS| 2 +-
 board/amlogic/u200/MAINTAINERS  | 2 +-
 board/amlogic/vim3/MAINTAINERS  | 2 +-
 board/amlogic/w400/MAINTAINERS  | 2 +-
 13 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/.mailmap b/.mailmap
index f27f366bcb..8acce4b2bf 100644
--- a/.mailmap
+++ b/.mailmap
@@ -49,6 +49,7 @@ Michal Simek  
 Michal Simek  
 Michal Simek  
 Michal Simek  
+Neil Armstrong  
 Nicolas Saenz Julienne  
 Patrice Chotard  
 Patrick Delaunay  
diff --git a/MAINTAINERS b/MAINTAINERS
index fa8c13fc7d..f0dfbc5450 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -143,7 +143,7 @@ F:  arch/arm/mach-socfpga/
 F: drivers/sysreset/sysreset_socfpga*
 
 ARM AMLOGIC SOC SUPPORT
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 T: git https://source.denx.de/u-boot/custodians/u-boot-amlogic.git
diff --git a/board/amlogic/odroid-n2/MAINTAINERS 
b/board/amlogic/odroid-n2/MAINTAINERS
index 43724e6fdd..23cc8e73b1 100644
--- a/board/amlogic/odroid-n2/MAINTAINERS
+++ b/board/amlogic/odroid-n2/MAINTAINERS
@@ -1,5 +1,5 @@
 ODROID-N2
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/odroid-n2/
diff --git a/board/amlogic/p200/MAINTAINERS b/board/amlogic/p200/MAINTAINERS
index 1df9b8b24b..33ca3df5c6 100644
--- a/board/amlogic/p200/MAINTAINERS
+++ b/board/amlogic/p200/MAINTAINERS
@@ -1,6 +1,6 @@
 P200
 M: Beniamino Galvani 
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/p200/
diff --git a/board/amlogic/p201/MAINTAINERS b/board/amlogic/p201/MAINTAINERS
index 1501b6280d..4549d01cad 100644
--- a/board/amlogic/p201/MAINTAINERS
+++ b/board/amlogic/p201/MAINTAINERS
@@ -1,5 +1,5 @@
 P201
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/p201/
diff --git a/board/amlogic/p212/MAINTAINERS b/board/amlogic/p212/MAINTAINERS
index 3d622af29b..b2e3205fdf 100644
--- a/board/amlogic/p212/MAINTAINERS
+++ b/board/amlogic/p212/MAINTAINERS
@@ -1,5 +1,5 @@
 P212
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/p212/
diff --git a/board/amlogic/q200/MAINTAINERS b/board/amlogic/q200/MAINTAINERS
index ba7c12b2c1..9c84cca27e 100644
--- a/board/amlogic/q200/MAINTAINERS
+++ b/board/amlogic/q200/MAINTAINERS
@@ -1,5 +1,5 @@
 Q200
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/q200/
diff --git a/board/amlogic/s400/MAINTAINERS b/board/amlogic/s400/MAINTAINERS
index fb46b1bbbf..ca51bb6b3b 100644
--- a/board/amlogic/s400/MAINTAINERS
+++ b/board/amlogic/s400/MAINTAINERS
@@ -1,5 +1,5 @@
 S400
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/s400/
diff --git a/board/amlogic/sei510/MAINTAINERS b/board/amlogic/sei510/MAINTAINERS
index c01c1d60df..c6039bc82e 100644
--- a/board/amlogic/sei510/MAINTAINERS
+++ b/board/amlogic/sei510/MAINTAINERS
@@ -1,5 +1,5 @@
 SEI510
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/sei510/
diff --git a/board/amlogic/sei610/MAINTAINERS b/board/amlogic/sei610/MAINTAINERS
index 092178b2c8..799ad687f0 100644
--- a/board/amlogic/sei610/MAINTAINERS
+++ b/board/amlogic/sei610/MAINTAINERS
@@ -1,5 +1,5 @@
 SEI610
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/sei610/
diff --git a/board/amlogic/u200/MAINTAINERS b/board/amlogic/u200/MAINTAINERS
index a259d12886..47cec234a1 100644
--- a/board/amlogic/u200/MAINTAINERS
+++ b/board/amlogic/u200/MAINTAINERS
@@ -1,5 +1,5 @@
 U200
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/u200/
diff --git a/board/amlogic/vim3/MAINTAINERS b/board/amlogic/vim3/MAINTAINERS
index d8848495c7..c5f8d9cc5c 100644
--- a/board/amlogic/vim3/MAINTAINERS
+++ b/board/amlogic/vim3/MAINTAINERS
@@ -1,5 +1,5 @@
 VIM3
-M: Neil Armstrong 
+M: Neil Armstrong 
 S: Maintained
 L: u-boot-amlo...@groups.io
 F: board/amlogic/vim3/
diff --git a/board/amlogic

Re: [PATCH] MAINTAINERS: Update email of Neil Armstrong

2022-08-19 Thread Neil Armstrong

Hi Tom,

On 16/08/2022 11:58, Neil Armstrong wrote:

From: Neil Armstrong 

My professional e-mail will change and the BayLibre one will
bounce after mid-september of 2022.

This updates the MAINTAINERS files and adds an entry in the
.mailmap file.

Signed-off-by: Neil Armstrong 
---

[..]

Can you apply this or should I send it via a PR ?

Thanks,
Neil


Re: [PATCH v2 05/14] docs: boards: amlogic: add documentation for BananaPi M2-Pro

2023-03-23 Thread Neil Armstrong
 \
+  --output fip/bl30_new.bin.enc \
+  --level v3 --type bl30
+$ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl31.img \
+  --output fip/bl31.img.enc \
+  --level v3 --type bl31
+$ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl33.bin 
--compress lz4 \
+  --output fip/bl33.bin.enc \
+  --level v3 --type bl33 --compress lz4
+$ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl2sig --input fip/bl2_new.bin \
+  --output fip/bl2.n.bin.sig
+$ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bootmk \
+  --output fip/u-boot.bin \
+  --bl2 fip/bl2.n.bin.sig \
+  --bl30 fip/bl30_new.bin.enc \
+  --bl31 fip/bl31.img.enc \
+  --bl33 fip/bl33.bin.enc \
+  --ddrfw1 fip/ddr4_1d.fw \
+  --ddrfw2 fip/ddr4_2d.fw \
+  --ddrfw3 fip/ddr3_1d.fw \
+  --ddrfw4 fip/piei.fw \
+  --ddrfw5 fip/lpddr4_1d.fw \
+  --ddrfw6 fip/lpddr4_2d.fw \
+  --ddrfw7 fip/diag_lpddr4.fw \
+  --ddrfw8 fip/aml_ddr.fw \
+  --ddrfw9 fip/lpddr3_1d.fw \
+  --level v3
+
+Then write the image to SD or eMMC with:
+
+.. code-block:: bash
+
+$ DEV=/dev/boot_device
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 
seek=1
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 9b76bca427..8388acdd11 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -86,6 +86,7 @@ Board Documentation
 :maxdepth: 1
  
 bananapi-cm4io

+   bananapi-m2pro
 bananapi-m5
 beelink-gskingx
 beelink-gtking


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 08/14] docs: boards: amlogic: add documentation for BananaPi M2S

2023-03-23 Thread Neil Armstrong
rypt_g12b --bl3sig --input 
fip/bl30_new.bin.g12a.enc \
+   --output fip/bl30_new.bin.enc \
+   --level v3 --type bl30
+$ $UBDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
+   --output fip/bl31.img.enc \
+   --level v3 --type bl31
+$ $UBDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin 
--compress lz4 \
+   --output fip/bl33.bin.enc \
+   --level v3 --type bl33 --compress lz4
+$ $UBDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
+   --output fip/bl2.n.bin.sig
+$ $UBDIR/fip/g12b/aml_encrypt_g12b --bootmk \
+   --output fip/u-boot.bin \
+   --bl2 fip/bl2.n.bin.sig \
+   --bl30 fip/bl30_new.bin.enc \
+   --bl31 fip/bl31.img.enc \
+   --bl33 fip/bl33.bin.enc \
+   --ddrfw1 fip/ddr4_1d.fw \
+   --ddrfw2 fip/ddr4_2d.fw \
+   --ddrfw3 fip/ddr3_1d.fw \
+   --ddrfw4 fip/piei.fw \
+   --ddrfw5 fip/lpddr4_1d.fw \
+   --ddrfw6 fip/lpddr4_2d.fw \
+   --ddrfw7 fip/diag_lpddr4.fw \
+   --ddrfw8 fip/aml_ddr.fw \
+   --ddrfw9 fip/lpddr3_1d.fw \
+   --level v3
+
+Then write the image to SD or eMMC with:
+
+.. code-block:: bash
+
+$ DEV=/dev/boot_device
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 
seek=1
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 8388acdd11..fa1b362731 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -87,6 +87,7 @@ Board Documentation
  
 bananapi-cm4io

 bananapi-m2pro
+   bananapi-m2s
 bananapi-m5
 beelink-gskingx
 beelink-gtking


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 11/14] doc: boards: amlogic: add documentation for Radxa Zero2

2023-03-23 Thread Neil Armstrong

On 23/03/2023 15:31, Christian Hewitt wrote:

Add build docs for the Radxa Zero2 board.

Signed-off-by: Christian Hewitt 
---
  board/amlogic/w400/MAINTAINERS|  2 +
  doc/board/amlogic/index.rst   |  1 +
  doc/board/amlogic/radxa-zero2.rst | 80 +++
  3 files changed, 83 insertions(+)
  create mode 100644 doc/board/amlogic/radxa-zero2.rst

diff --git a/board/amlogic/w400/MAINTAINERS b/board/amlogic/w400/MAINTAINERS
index 042b523056..117f79ea04 100644
--- a/board/amlogic/w400/MAINTAINERS
+++ b/board/amlogic/w400/MAINTAINERS
@@ -5,6 +5,8 @@ L:  u-boot-amlo...@groups.io
  F:board/amlogic/w400/
  F:configs/bananapi-cm4-cm4io_defconfig
  F:configs/bananapi-m2s_defconfig
+F: configs/radxa-zero2_defconfig
  F:doc/board/amlogic/w400.rst
  F:doc/board/amlogic/bananapi-cm4io.rst
  F:doc/board/amlogic/bananapi-m2s.rst
+F: doc/board/amlogic/radxa-zero2.rst
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index fa1b362731..71b7e1f3ed 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -112,6 +112,7 @@ Board Documentation
 p212
 q200
 radxa-zero
+   radxa-zero2
 sei510
 sei610
 s400
diff --git a/doc/board/amlogic/radxa-zero2.rst 
b/doc/board/amlogic/radxa-zero2.rst
new file mode 100644
index 00..dccf592459
--- /dev/null
+++ b/doc/board/amlogic/radxa-zero2.rst
@@ -0,0 +1,80 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+U-Boot for Radxa Zero2 (A311D)
+==
+
+Radxa Zero2 is a small form factor SBC based on the Amlogic A311D chipset with 
the
+following specification:
+
+- Amlogic A311D (Quad A73 + Dual A53) CPU
+- 4GB LPDDR4 RAM
+- 32/64/128GB eMMC
+- Mali G52-MP4 GPU
+- HDMI 2.1 output (micro)
+- BCM4345 WiFi (2.4/5GHz a/b/g/n/ac) and BT 5.0
+- 1x USB 2.0 port - Type C (OTG)
+- 1x USB 3.0 port - Type C (Host)
+- 1x micro SD Card slot
+- 40 Pin GPIO header
+
+Schematics are available on request from Radxa.
+
+U-Boot Compilation
+--
+
+.. code-block:: bash
+
+$ export CROSS_COMPILE=aarch64-none-elf-
+$ make radxa-zero2_defconfig
+$ make
+
+U-Boot Signing with Pre-Built FIP repo
+--
+
+.. code-block:: bash
+
+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip
+$ mkdir my-output-dir
+$ ./build-fip.sh radxa-zero2 /path/to/u-boot/u-boot.bin my-output-dir
+
+U-Boot Manual Signing
+-
+
+Amlogic does not provide sources for the firmware and tools needed to create a 
bootloader
+image so it is necessary to obtain binaries from sources published by the 
board vendor:
+
+.. code-block:: bash
+
+$ git clone -b radxa-zero-v2021.07 https://github.com/radxa/u-boot.git
+$ git clone https://github.com/radxa/fip.git
+
+$ sudo apt-get install -y gcc-aarch64-linux-gnu device-tree-compiler 
libncurses5 libncurses5-dev
+$ sudo apt-get install -y bc python dosfstools flex build-essential 
libssl-dev mtools
+
+$ wget 
https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
+$ sudo tar xvf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz -C /opt
+
+$ export 
CROSS_COMPILE=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf-
+$ export ARCH=arm
+$ cd u-boot
+$ make radxa-zero2_defconfig
+$ make
+
+$ cp u-boot.bin ../fip/radxa-zero2/bl33.bin
+$ cd ../fip/radxa-zero2
+$ make
+
+This will generate the signed U-Boot binaries:
+
+.. code-block:: bash
+
+$ u-boot.bin u-boot.bin.sd.bin u-boot.bin.usb.bl2 u-boot.bin.usb.tpl
+
+Then write U-Boot to SD or eMMC with:
+
+.. code-block:: bash
+
+$ DEV=/dev/boot_device
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 
seek=1
+$ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 13/14] boards: amlogic: add WeTek Hub and WeTek Play2 defconfig

2023-03-23 Thread Neil Armstrong

On 23/03/2023 15:31, Christian Hewitt wrote:

Add configurations for the WeTek Hub and WeTek Play2 boards.

Signed-off-by: Christian Hewitt 
---
  board/amlogic/p200/MAINTAINERS |  2 +
  configs/wetek-hub_defconfig| 70 ++
  configs/wetek-play2_defconfig  | 70 ++
  3 files changed, 142 insertions(+)
  create mode 100644 configs/wetek-hub_defconfig
  create mode 100644 configs/wetek-play2_defconfig

diff --git a/board/amlogic/p200/MAINTAINERS b/board/amlogic/p200/MAINTAINERS
index 33ca3df5c6..264218e3be 100644
--- a/board/amlogic/p200/MAINTAINERS
+++ b/board/amlogic/p200/MAINTAINERS
@@ -7,6 +7,8 @@ F:  board/amlogic/p200/
  F:configs/nanopi-k2_defconfig
  F:configs/odroid-c2_defconfig
  F:configs/p200_defconfig
+F: configs/wetek-hub_defconfig
+F: configs/wetek-play2_defconfig
  F:doc/board/amlogic/p200.rst
  F:doc/board/amlogic/nanopi-k2.rst
  F:doc/board/amlogic/odroid-c2.rst
diff --git a/configs/wetek-hub_defconfig b/configs/wetek-hub_defconfig
new file mode 100644
index 00..634833f7fe
--- /dev/null
+++ b/configs/wetek-hub_defconfig
@@ -0,0 +1,70 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" wetek-hub"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-wetek-hub"
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_ADC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SARADC_MESON=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MESON=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_PHY=y
+CONFIG_MESON_GXBB_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXBB=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/wetek-play2_defconfig b/configs/wetek-play2_defconfig
new file mode 100644
index 00..6d33b09a94
--- /dev/null
+++ b/configs/wetek-play2_defconfig
@@ -0,0 +1,70 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_TEXT_BASE=0x0100
+CONFIG_SYS_LOAD_ADDR=0x100
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x2000
+CONFIG_DM_GPIO=y
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=2400
+CONFIG_IDENT_STRING=" wetek-play2"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-wetek-play2"
+CONFIG_DEBUG_UART=y
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
+CONFIG_OF_BOARD_SETUP=y
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_MISC_INIT_R=y
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+CONFIG_CMD_ADC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+CONFIG_OF_CONTROL=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SARADC_MESON=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_MESON=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_PHY_REALTEK=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE_MESON8B=y
+CONFIG_PHY=y
+CONFIG_MESON_GXBB_USB_PHY=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXBB=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RESET=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
+CONFIG_SYSINFO=y
+CONFIG_SYSINFO_SMBIOS=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_KEYBOARD=y
+CONFIG_VIDEO=y
+# CONFIG_VIDEO_BPP8 is not set
+# CONFIG_VIDEO_BPP16 is not set
+CONFIG_SYS_WHITE_ON_BLACK=y
+CONFIG_VIDEO_MESON=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_OF_LIBFDT_OVERLAY=y


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 14/14] doc: boards: amlogic: add documentation for WeTek Hub and WeTek Play2

2023-03-23 Thread Neil Armstrong
play2.rst
new file mode 100644
index 00..cd7759f7f4
--- /dev/null
+++ b/doc/board/amlogic/wetek-play2.rst
@@ -0,0 +1,115 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+U-Boot for WeTek Play2 (S905)
+=
+
+WeTek Play2 is an Android STB manufactured by WeTek with the following 
specification:
+
+ - Amlogic S905 ARM Cortex-A53 quad-core SoC @ 1.5GHz
+ - ARM Mali 450 GPU
+ - 2GB DDR3 SDRAM
+ - 8GB eMMC
+ - Gigabit Ethernet
+ - AP6335 (v1) or AP6255 (v2) WiFi (b/g/n) and BT 4.0
+ - HDMI 2.0 4K/60Hz display
+ - 2x USB 2.0 host
+ - 1x USB 2.0 otg
+ - microSD
+ - UART jack
+ - Infrared receiver
+ - Power LED (blue)
+ - Power button (case, front)
+ - Reset button (underside)
+ - DVB Card: DVB-S or DVB-T/C or ATSC
+
+Schematics are not publicly available but have been shared privately to 
maintainers.
+
+U-Boot Compilation
+--
+
+.. code-block:: bash
+
+$ export CROSS_COMPILE=aarch64-none-elf-
+$ make wetek-play2_defconfig
+$ make
+
+U-Boot Signing with Pre-Built FIP repo
+--
+
+.. code-block:: bash
+
+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip
+$ mkdir my-output-dir
+$ ./build-fip.sh wetek-play2 /path/to/u-boot/u-boot.bin my-output-dir
+
+U-Boot Manual Signing
+-
+
+Amlogic does not provide sources for the firmware and tools needed to create a 
bootloader
+image and WeTek has not publicly shared the U-Boot sources needed to build FIP 
binaries
+for signing. However you can download them from the amlogic-fip-repo.
+
+.. code-block:: bash
+$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
+$ cd amlogic-boot-fip/wetek-play2
+$ export FIPDIR=$PWD
+
+Go back to the mainline U-Boot source tree then:
+
+.. code-block:: bash
+
+$ mkdir fip
+
+$ cp $FIPDIR/bl2.bin fip/
+$ cp $FIPDIR/acs.bin fip/
+$ cp $FIPDIR/bl21.bin fip/
+$ cp $FIPDIR/bl30.bin fip/
+$ cp $FIPDIR/bl301.bin fip/
+$ cp $FIPDIR/bl31.img fip/
+$ cp u-boot.bin fip/bl33.bin
+
+$ $FIPDIR/blx_fix.sh \
+  fip/bl30.bin \
+  fip/zero_tmp \
+  fip/bl30_zero.bin \
+  fip/bl301.bin \
+  fip/bl301_zero.bin \
+  fip/bl30_new.bin \
+  bl30
+
+$ $FIPDIR/fip_create --bl30 fip/bl30_new.bin \
+ --bl31 fip/bl31.img \
+ --bl33 fip/bl33.bin \
+ fip/fip.bin
+
+$ sed -i 's/\x73\x02\x08\x91/\x1F\x20\x03\xD5/' fip/bl2.bin
+$ python3 $FIPDIR/acs_tool.py fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
+
+$ $FIPDIR/blx_fix.sh \
+  fip/bl2_acs.bin \
+  fip/zero_tmp \
+  fip/bl2_zero.bin \
+  fip/bl21.bin \
+  fip/bl21_zero.bin \
+  fip/bl2_new.bin \
+  bl2
+
+$ cat fip/bl2_new.bin fip/fip.bin > fip/boot_new.bin
+
+$ $FIPDIR/aml_encrypt_gxb --bootsig \
+  --input fip/boot_new.bin
+  --output fip/u-boot.bin
+
+Then write U-Boot to SD or eMMC with:
+
+.. code-block:: bash
+
+$ DEV=/dev/boot_device
+$ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 conv=fsync
+$ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 seek=9 skip=8 
count=87 conv=fsync,notrunc
+$ dd if=/dev/zero of=fip/u-boot.bin.gxbb bs=512 seek=8 count=1 
conv=fsync,notrunc
+$ dd if=bl1.bin.hardkernel of=fip/u-boot.bin.gxbb bs=512 seek=2 skip=2 
count=1 conv=fsync,notrunc
+$ ./aml_chksum fip/u-boot.bin.gxbb
+$ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
+$ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=1 count=440


Reviewed-by: Neil Armstrong 


Re: (subset) [PATCH v2 00/14] boards: amlogic: add BananaPi/Radxa/WeTek boards

2023-03-23 Thread Neil Armstrong
Hi,

On Thu, 23 Mar 2023 14:31:28 +, Christian Hewitt wrote:
> This series adds support for the following boards which are
> tested and booting fine with 2023.04-rc4:
> 
> - BananaPi M2-Pro (S905X3)
> - BananaPi M2S (A311D or S922X)
> - Radxa Zero2 (A311D)
> - WeTek Hub (S905)
> - WeTek Play2 (S905)
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-test)

[01/14] docs: boards: amlogic: add bananapi-m5 to u200 maintainer file

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/86e59bdd4d55c46fbe7bd856fa16e27c970f407f
[03/14] ARM: dts: add support for BananaPi M2-Pro

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4170731c4a9dfb5583d45453f323be7975521c18
[04/14] boards: add BananaPi M2-Pro defconfig

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/d33260a5054b716baa5336f2c788e0e07ae46417
[05/14] docs: boards: amlogic: add documentation for BananaPi M2-Pro

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/b2fc35e5f138c6e7449c925324891dbbb70bb400
[06/14] ARM: dts: add support for BananaPi M2S

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/56a92bd4f443634ea6a50bb4b7269e1c04c9e00b
[07/14] boards: add BananaPi M2S defconfig

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/43c67ddf59ff7a4dc62fc0d4c49fe3d54463bc66
[08/14] docs: boards: amlogic: add documentation for BananaPi M2S

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/40f1eea84e2845deda5ce5fbf6c4f8fb1bb85463
[09/14] ARM: dts: add support for Radxa Zero2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/3016f6fb9e4c506ce751b36215cc1ac44aca31b0
[10/14] boards: amlogic: add Radxa Zero2 defconfig

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/2c57d114d2716e75fa0b4e8f0149215437f603a8
[11/14] doc: boards: amlogic: add documentation for Radxa Zero2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/37eda34cb5afb230df00b7ebc74c8164b89cbc4c
[12/14] ARM: dts: add support for WeTek Hub and WeTek Play2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/b07e8fb073aa1b847e9ceb563b76808c88be2af9
[13/14] boards: amlogic: add WeTek Hub and WeTek Play2 defconfig

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/fcb0fb2bd6d9e4042bed21685da893f5765305eb
[14/14] doc: boards: amlogic: add documentation for WeTek Hub and WeTek Play2

https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/f097eedf0c04fc6307e22b4b707aa3b47c921b4c

-- 
Neil



Re: [PATCH] boards: amlogic: switch LibreTech-CC v2 and WeTek Core2 to EE powerdomain

2023-03-27 Thread Neil Armstrong

On 26/03/2023 08:06, Christian Hewitt wrote:

The LibreTech-CC (LePotato) v2 and WeTek Core2 boards are still using
the older GX VPU powerdomain driver. Update their configs to use the
newer EE driver like other Amlogic boards [0].

[0] 
https://lore.kernel.org/all/20201106101901.2472557-5-narmstr...@baylibre.com/T/#u

Signed-off-by: Christian Hewitt 
---
  configs/libretech-cc_v2_defconfig | 2 +-
  configs/wetek-core2_defconfig | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/libretech-cc_v2_defconfig 
b/configs/libretech-cc_v2_defconfig
index 30b1651554..ea71f055d9 100644
--- a/configs/libretech-cc_v2_defconfig
+++ b/configs/libretech-cc_v2_defconfig
@@ -51,7 +51,7 @@ CONFIG_MESON_GXL_USB_PHY=y
  CONFIG_PINCTRL=y
  CONFIG_PINCTRL_MESON_GXL=y
  CONFIG_POWER_DOMAIN=y
-CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
  CONFIG_DEBUG_UART_ANNOUNCE=y
  CONFIG_DEBUG_UART_SKIP_INIT=y
  CONFIG_MESON_SERIAL=y
diff --git a/configs/wetek-core2_defconfig b/configs/wetek-core2_defconfig
index f5149fc002..07d2587f77 100644
--- a/configs/wetek-core2_defconfig
+++ b/configs/wetek-core2_defconfig
@@ -44,7 +44,7 @@ CONFIG_MESON_GXL_USB_PHY=y
  CONFIG_PINCTRL=y
  CONFIG_PINCTRL_MESON_GXL=y
  CONFIG_POWER_DOMAIN=y
-CONFIG_MESON_GX_VPU_POWER_DOMAIN=y
+CONFIG_MESON_EE_POWER_DOMAIN=y
  CONFIG_DM_REGULATOR=y
  CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DEBUG_UART_ANNOUNCE=y


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 1/1] RFC: Move Odroid-C2 to use binman to produce the image

2023-04-03 Thread Neil Armstrong

Hi Simon !

On 01/04/2023 20:54, Simon Glass wrote:

This shows how binman can be used to replace the long and complicated
instructions with an automated build. It is still complicated to read
but users don't have to worry about the details.

It needs some tidying up and only supports Odroid-C2 at present.


Like the v1, the work is really nice, but the dependency on vendor binary-only
tools doesn't make feel confident about merging this.

We have open source implementation for all boards, but still dependeing on
tools we must manually build isn't optimal.

What would be optimal would be to re-implement those tools into python
libraries and merge them into the u-boot tree then use them from binman.

But this could be merged as first step, them the python libaray could be
modified to support the binary tools & a probable python re-implementation.

Neil



Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to -next

  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
  arch/arm/mach-meson/Kconfig  |   1 +
  doc/board/amlogic/odroid-c4.rst  | 127 +--
  tools/binman/etype/aml_encrypt.py| 124 ++
  tools/binman/ftest.py|   3 +
  tools/binman/missing-blob-help   |   6 +
  tools/binman/test/213_aml_encrypt.dts|  38 ++
  tools/binman/test/214_list_no_dtb.dts|  23 
  8 files changed, 337 insertions(+), 92 deletions(-)
  create mode 100644 tools/binman/etype/aml_encrypt.py
  create mode 100644 tools/binman/test/213_aml_encrypt.dts
  create mode 100644 tools/binman/test/214_list_no_dtb.dts

diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi 
b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
index 963bf96b2567..b221ce6920b0 100644
--- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
+++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
@@ -6,6 +6,113 @@
  
  #include "meson-sm1-u-boot.dtsi"
  
+/{

+   binman {
+   /* run --bootmk on all the included inputs */
+   aml-encrypt {
+   missing-msg = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bootmk";
+   aml-level = "v3";
+
+   /* produce a bl2, containing signed bl2 binaries */
+   bl2 {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl2sig";
+
+   /* sign the binary contaiing bl2 and acs */
+   aml-input {
+   type = "section";
+   bl2 {
+   type = "blob-ext";
+   size = <0xe000>;
+   filename = "bl2.bin";
+   };
+   acs {
+   type = "blob-ext";
+   size = <0x1000>;
+   filename = "acs.bin";
+   };
+   };
+   };
+
+   /* produce a bl30, containing signed bl30 binaries */
+   bl30 {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl3sig";
+   aml-level = "v3";
+   aml-type = "bl30";
+
+   /* sign the binary contaiing bl30 and bl301 */
+   aml-input {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl30sig";
+   aml-level = "v3";
+
+   /*
+* put bl30 and bl301 together, with
+* the necessary paddiung
+*/
+   aml-input {
+   type = "section";
+   bl30 {
+   type = "blob-ext";
+   size = <0xa000>;
+   filename = "bl30.bin";
+   };
+   bl301 {
+   type = "blob-ext";
+   size = <0x3400>;
+

Re: [PATCHv8 1/3] ARM: dts: add support for Beelink GT1 Ultimate

2023-04-05 Thread Neil Armstrong
Hi,

On Tue, 28 Mar 2023 04:11:52 +0800, Karl Chan wrote:
> Import the device-tree from linux-amlogic/for-next (Linux 6.3-rc1).
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/3] ARM: dts: add support for Beelink GT1 Ultimate
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/e054cc7475d939c1bfce5833d16b43c8a75ebd67

-- 
Neil



Re: [PATCHv8 2/3] boards: amlogic: add Beelink GT1 Ultimate defconfig

2023-04-05 Thread Neil Armstrong
Hi,

On Tue, 28 Mar 2023 04:13:14 +0800, Karl Chan wrote:
> Add configuration for the Beelink GT1 Ultimate board.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[2/3] boards: amlogic: add Beelink GT1 Ultimate defconfig
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/93a997d00b77402dea95bca79e45371b79d07708

-- 
Neil



Re: [PATCHv8 3/3] doc: boards: amlogic: add documentation for Beelink GT1 Ultimate

2023-04-05 Thread Neil Armstrong
Hi,

On Tue, 28 Mar 2023 04:15:15 +0800, Karl Chan wrote:
> Add build instructions for the Beelink GT1 Ultimate board.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[3/3] doc: boards: amlogic: add documentation for Beelink GT1 Ultimate
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8ee577815e301f3c8403c508507ca009ea606e58

-- 
Neil



Re: [PATCH v2 1/1] RFC: Move Odroid-C2 to use binman to produce the image

2023-04-06 Thread neil . armstrong

On 05/04/2023 20:38, Simon Glass wrote:

Hi Neil,

On Mon, 3 Apr 2023 at 19:31, Neil Armstrong  wrote:


Hi Simon !

On 01/04/2023 20:54, Simon Glass wrote:

This shows how binman can be used to replace the long and complicated
instructions with an automated build. It is still complicated to read
but users don't have to worry about the details.

It needs some tidying up and only supports Odroid-C2 at present.


Like the v1, the work is really nice, but the dependency on vendor binary-only
tools doesn't make feel confident about merging this.


So long as we can download it from somewhere, that is OK, or at least
better than nothing. Is there a standard download location for the
tools?


There's no "official" location, historically the tools was shipped with the
buildroot fork in the u-boot sources, but it has been moved into different
repos now they do not ship buildroot anymore, and we can only find those tools
on the SBC vendor u-boot sources.

And the tools have the same name but only support different SoCs, there's no
versioning, licence nor documentation... so relying on those tools is a 
nightmare.

This is why we made a central repository with the tools + binaries for
each board with an easy script to generate the bootable binary:
https://github.com/LibreELEC/amlogic-boot-fip
and documented at:
https://u-boot.readthedocs.io/en/latest/board/amlogic/pre-generated-fip.html





We have open source implementation for all boards, but still dependeing on
tools we must manually build isn't optimal.

What would be optimal would be to re-implement those tools into python
libraries and merge them into the u-boot tree then use them from binman.


Or C, perhaps? Then binman can call the tools.


Yes, but the open source tools aren't heavily maintained, have different ABIs...

Supporting GXBB and GXL/G12A is impossible, the binary format is totally 
different
for example so we should import 2 different tools.





But this could be merged as first step, them the python libaray could be
modified to support the binary tools & a probable python re-implementation.


Yes I think it would good to get this in, even if it only supports a
few boards. It is easy to add more, when possible.


If this can rely on the amlogic-boot-fip repo, then why not, then we can find
a native solution to replace calling those tools.

Thanks,
Neil



Regards,
SImon




[GIT PULL] Please pull uu-boot-amlogic-20230417

2023-04-17 Thread Neil Armstrong

Hi Tom,

A big set of changes for the next release, it adds 7 new boards:
- BPI-CM4IO
- BananaPi M2-Pro
- BananaPi M2S
- Radxa Zero2
- WeTek Hub
- WeTek Play2
- Beelink GT1 Ultimate
with a welcome doc cleanup!
Finally a simple change to use the right powerdomain driver for LibreTech-CC v2 
and WeTek Core2.

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/16023

Thanks,
Neil

The following changes since commit 12c1e5782401abca1a8cff578d1911a9ca7d2e7d:

  Merge branch 'master' of 
https://source.denx.de/u-boot/custodians/u-boot-marvell (2023-04-14 10:50:55 
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
tags/u-boot-amlogic-20230417

for you to fetch changes up to 411d6af8b6a278effbaf1d02aa51280b2f5f8008:

  doc: boards: amlogic: add documentation for Beelink GT1 Ultimate (2023-04-17 
11:06:08 +0200)


- Add initial support for BPI-CM4
- Spring Cleanup of Amlogic board documentation
- add support for BananaPi M2-Pro
- add support for BananaPi M2S
- add support for Radxa Zero2
- add support for WeTek Hub and WeTek Play2
- switch LibreTech-CC v2 and WeTek Core2 to EE powerdomain
- add support for Beelink GT1 Ultimate


Christian Hewitt (47):
  doc: boards: amlogic: update documentation for index page
  doc: boards: amlogic: update documentation for boot-flow
  doc: boards: amlogic: update documentation for pre-generated-fip's
  doc: boards: amlogic: update documentation for Beelink GT-King
  doc: boards: amlogic: update documentation for Beelink GT-King Pro
  doc: boards: amlogic: update documentation for JetHub J100
  doc: boards: amlogic: update documentation for JetHub J80
  doc: boards: amlogic: update documentation for Khadas VIM
  doc: boards: amlogic: update documentation for Khadas VIM2
  doc: boards: amlogic: update documentation for Khadas VIM3
  doc: boards: amlogic: update documentation for Khadas VIM3L
  doc: boards: amlogic: update documentation for LaFrite
  doc: boards: amlogic: update documentation for LePotato
  doc: boards: amlogic: update documentation for NanoPi-K2
  doc: boards: amlogic: update documentation for ODROID-C2
  doc: boards: amlogic: update documentation for ODROID-C4
  doc: boards: amlogic: update documentation for ODROID GO ULTRA
  doc: boards: amlogic: update documentation for ODROID-N2/N2+
  doc: boards: amlogic: update documentation for ODROID-N2L
  doc: boards: amlogic: update documentation for P200
  doc: boards: amlogic: update documentation for P201
  doc: boards: amlogic: update documentation for Q200
  doc: boards: amlogic: update documentation for Radxa Zero
  doc: boards: amlogic: update documentation for S400
  doc: boards: amlogic: update documentation for SEI510
  doc: boards: amlogic: update documentation for SEI610
  doc: boards: amlogic: update documentation for U200
  doc: boards: amlogic: update documentation for W400
  doc: boards: amlogic: update documentation for WeTek Core2
  doc: boards: amlogic: add documentation for BananaPi CM4IO
  doc: boards: amlogic: add documentation for BananaPi M5
  doc: boards: amlogic: add documentation for GS-King-X
  doc: boards: amlogic: add documentation for ODROID-HC4
  docs: boards: amlogic: add bananapi-m5 to u200 maintainer file
  ARM: dts: add support for BananaPi M2-Pro
  boards: add BananaPi M2-Pro defconfig
  docs: boards: amlogic: add documentation for BananaPi M2-Pro
  ARM: dts: add support for BananaPi M2S
  boards: add BananaPi M2S defconfig
  docs: boards: amlogic: add documentation for BananaPi M2S
  ARM: dts: add support for Radxa Zero2
  boards: amlogic: add Radxa Zero2 defconfig
  doc: boards: amlogic: add documentation for Radxa Zero2
  ARM: dts: add support for WeTek Hub and WeTek Play2
  boards: amlogic: add WeTek Hub and WeTek Play2 defconfig
  doc: boards: amlogic: add documentation for WeTek Hub and WeTek Play2
  boards: amlogic: switch LibreTech-CC v2 and WeTek Core2 to EE powerdomain

Karl Chan (3):
  ARM: dts: add support for Beelink GT1 Ultimate
  boards: amlogic: add Beelink GT1 Ultimate defconfig
  doc: boards: amlogic: add documentation for Beelink GT1 Ultimate

Neil Armstrong (2):
  ARM: dts: import initial DT for BPI-CM4 module with BPI-CM4IO baseboard
  ARM: meson: Add initial support for BPI-CM4 module with BPI-CM4IO 
baseboard

 arch/arm/dts/Makefile  |   9 +-
 arch/arm/dts/meson-g12b-a311d-bananapi-m2s.dts |  33 ++
 .../dts/meson-g12b-bananapi-cm4-cm4io-u-boot.dtsi  |   6 +
 arch/arm/dts/meson-g12b-bananapi-cm4-cm4io.dts | 165 +++
 arch/arm/dts/meson-g12b-bananapi-cm4.dtsi  | 388 ++

Re: [PATCH v3 0/8] Add SM uclass and Meson SM driver

2023-09-28 Thread neil . armstrong

On 21/09/2023 10:13, Alexey Romanov wrote:

Hello!

At the moment, there is no single general approach to using
secure monitor in U-Boot, there is only the smc_call() function,
over which everyone builds their own add-ons. This patchset
is designed to solve this problem by adding a new uclass -
SM_UCLASS. This UCLASS export following generic API:

1. sm_call() - generic SMC call to the secure-monitor
2. sm_call_read() - retrieve data from secure-monitor
3. sm_call_write() - send data to secure-monitor

In the future, it is necessary to completely get rid of raw
smc_call() calls, replacing them with the use of SM_UCLASS
based drivers.

V2:

- Add SM UCLASS
- Add SM sandbox driver
- Add test for sandbox driver
- Meson Secure Monitor driver now based on SM_UCLASS
- Fix include order in arch/arm/mach-meson/sm.c

Also, during the discussion in V1 of this patchset, it was
discussed to create MESON_SM_UCLASS, but I considered such
a uclass to be too arch-specific. That's why I suggest
SM_UCLASS, which is not so arch-specific: secure monitor can
used for whole ARM devices, not only for Amlogic SoC's.

V3:

- Fix typos in commit messages
- Use uclass_first_device_err() instead of uclass_get_device_by_name()
- Return -ENOSYS instead of -EPROTONOSUPPORT if SM_UCLASS option not
implemented

Alexey Romanov (8):
   drivers: introduce Secure Monitor uclass
   sandbox: add sandbox sm uclass driver
   sandbox: dts: add meson secure monitor node
   sandbox: add tests for UCLASS_SM
   sandbox: defconfig: enable CONFIG_SM option
   drivers: introduce Meson Secure Monitor driver
   arch: meson: sm: set correct order of the includes
   arch: meson: use secure monitor driver

  MAINTAINERS |   1 +
  arch/arm/mach-meson/Kconfig |   1 +
  arch/arm/mach-meson/sm.c| 116 +++--
  arch/sandbox/dts/test.dts   |   4 +
  configs/sandbox_defconfig   |   1 +
  drivers/Kconfig |   2 +
  drivers/Makefile|   1 +
  drivers/sm/Kconfig  |   9 ++
  drivers/sm/Makefile |   5 +
  drivers/sm/meson-sm.c   | 198 
  drivers/sm/sandbox-sm.c |  76 ++
  drivers/sm/sm-uclass.c  |  55 ++
  include/dm/uclass-id.h  |   1 +
  include/meson/sm.h  |  19 
  include/sandbox-sm.h|  18 
  include/sm-uclass.h |  72 +
  include/sm.h|  67 
  test/dm/Makefile|   1 +
  test/dm/sm.c|  65 
  19 files changed, 656 insertions(+), 56 deletions(-)
  create mode 100644 drivers/sm/Kconfig
  create mode 100644 drivers/sm/Makefile
  create mode 100644 drivers/sm/meson-sm.c
  create mode 100644 drivers/sm/sandbox-sm.c
  create mode 100644 drivers/sm/sm-uclass.c
  create mode 100644 include/meson/sm.h
  create mode 100644 include/sandbox-sm.h
  create mode 100644 include/sm-uclass.h
  create mode 100644 include/sm.h
  create mode 100644 test/dm/sm.c



Reviewed-by: Neil Armstrong 

I'll apply it for next u-boot release,

Thanks,
Neil


Re: [PATCH v2 0/2] clk: amlogic: a1: Add Amlogic A1 clock driver

2023-09-28 Thread Neil Armstrong

On 25/09/2023 17:52, Igor Prusov wrote:

This series adds dt-bindings and driver implementation for Amlogic A1
PLL and Peripherals clock controllers.

V1: 
https://lore.kernel.org/all/20230917101308.1250-1-ivpru...@salutedevices.com/

V1 -> V2:
  - Add more verbose comments for driver

Igor Prusov (2):
   dt-bindings: clock: Add Amlogic A1 clock bindings
   clk: Add clock driver for Amlogic A1

  arch/arm/include/asm/arch-meson/clock-a1.h|  23 +
  drivers/clk/meson/Kconfig |   8 +
  drivers/clk/meson/Makefile|   1 +
  drivers/clk/meson/a1.c| 723 ++
  .../clock/amlogic,a1-peripherals-clkc.h   | 168 
  .../dt-bindings/clock/amlogic,a1-pll-clkc.h   |  25 +
  6 files changed, 948 insertions(+)
  create mode 100644 arch/arm/include/asm/arch-meson/clock-a1.h
  create mode 100644 drivers/clk/meson/a1.c
  create mode 100644 include/dt-bindings/clock/amlogic,a1-peripherals-clkc.h
  create mode 100644 include/dt-bindings/clock/amlogic,a1-pll-clkc.h



Reviewed-by: Neil Armstrong 

I'll apply it for next u-boot release,

Thanks,
Neil


Re: [PATCH] mmc: Add SPL_MMC_PWRSEQ to fix link issue when building SPL

2023-09-28 Thread Neil Armstrong

On 25/09/2023 23:55, Jonas Karlman wrote:

With MMC_PWRSEQ enabled the following link issue may happen when
building SPL and SPL_PWRSEQ is not enabled.

   aarch64-linux-gnu-ld.bfd: drivers/mmc/meson_gx_mmc.o: in function 
`meson_mmc_probe':
   drivers/mmc/meson_gx_mmc.c:295: undefined reference to `pwrseq_set_power'

Fix this by adding a SPL_MMC_PWRSEQ Kconfig option used to enable mmc
pwrseq support in SPL.

Also add depends on DM_GPIO to fix following link issue:

   aarch64-linux-gnu-ld.bfd: drivers/mmc/mmc-pwrseq.o: in function 
`mmc_pwrseq_set_power':
   drivers/mmc/mmc-pwrseq.c:26: undefined reference to `gpio_request_by_name'
   aarch64-linux-gnu-ld.bfd: drivers/mmc/mmc-pwrseq.c:29: undefined reference 
to `dm_gpio_set_value'
   aarch64-linux-gnu-ld.bfd: drivers/mmc/mmc-pwrseq.c:31: undefined reference 
to `dm_gpio_set_value'

Signed-off-by: Jonas Karlman 
---
  drivers/mmc/Kconfig   | 10 +-
  drivers/mmc/Makefile  |  2 +-
  drivers/mmc/meson_gx_mmc.c|  2 +-
  drivers/mmc/rockchip_dw_mmc.c |  2 +-
  include/mmc.h |  4 ++--
  5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index de01b9687bad..a9931d39412d 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -20,11 +20,19 @@ config MMC_WRITE
  
  config MMC_PWRSEQ

bool "HW reset support for eMMC"
-   depends on PWRSEQ
+   depends on PWRSEQ && DM_GPIO
help
  Ths select Hardware reset support aka pwrseq-emmc for eMMC
  devices.
  
+config SPL_MMC_PWRSEQ

+   bool "HW reset support for eMMC in SPL"
+   depends on SPL_PWRSEQ && SPL_DM_GPIO
+   default y if MMC_PWRSEQ
+   help
+ Ths select Hardware reset support aka pwrseq-emmc for eMMC
+ devices in SPL.
+
  config MMC_BROKEN_CD
bool "Poll for broken card detection case"
help
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 2c65c4765ab2..0a79dd058bef 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += mmc_bootdev.o
  endif
  
  obj-$(CONFIG_$(SPL_TPL_)MMC_WRITE) += mmc_write.o

-obj-$(CONFIG_MMC_PWRSEQ) += mmc-pwrseq.o
+obj-$(CONFIG_$(SPL_)MMC_PWRSEQ) += mmc-pwrseq.o
  obj-$(CONFIG_MMC_SDHCI_ADMA_HELPERS) += sdhci-adma.o
  
  ifndef CONFIG_$(SPL_)BLK

diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index fcf4f03d1e24..0825c0a2a838 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -288,7 +288,7 @@ static int meson_mmc_probe(struct udevice *dev)
  
  	mmc_set_clock(mmc, cfg->f_min, MMC_CLK_ENABLE);
  
-#ifdef CONFIG_MMC_PWRSEQ

+#if CONFIG_IS_ENABLED(MMC_PWRSEQ)
/* Enable power if needed */
ret = mmc_pwrseq_get_power(dev, cfg);
if (!ret) {
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 72c820ee6330..ad4529d6afa8 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -145,7 +145,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
  
  	host->fifo_mode = priv->fifo_mode;
  
-#ifdef CONFIG_MMC_PWRSEQ

+#if CONFIG_IS_ENABLED(MMC_PWRSEQ)
/* Enable power if needed */
ret = mmc_pwrseq_get_power(dev, &plat->cfg);
if (!ret) {
diff --git a/include/mmc.h b/include/mmc.h
index 1022db3ffa7c..9aef31ea5deb 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -590,7 +590,7 @@ struct mmc_config {
uint f_max;
uint b_max;
unsigned char part_type;
-#ifdef CONFIG_MMC_PWRSEQ
+#if CONFIG_IS_ENABLED(MMC_PWRSEQ)
struct udevice *pwr_dev;
  #endif
  };
@@ -808,7 +808,7 @@ int mmc_deinit(struct mmc *mmc);
   */
  int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg);
  
-#ifdef CONFIG_MMC_PWRSEQ

+#if CONFIG_IS_ENABLED(MMC_PWRSEQ)
  /**
   * mmc_pwrseq_get_power() - get a power device from device tree
   *


Reviewed-by: Neil Armstrong 


Re: [RFT PATCH 0/2] mmc: meson-gx: improve MMC reliabilty

2023-09-28 Thread Neil Armstrong

Hi,

On 15/09/2023 18:01, Jerome Brunet wrote:

Amlogic MMC on the GX (and later) SoCs has been problematic for years,
especially with u-boot.

Linux has been fairly stable for a few years. It is using a fixed phase
setting with Core = 180, Tx = 0 and Rx = 0 (the latter cannot be set
starting from the v3 MMC IPs)

Still the results were not good with those settings with u-boot, on some
sm1 based platforms. U-boot then started using a 270 core phase for sm1
only.  This worked for most sm1 platforms but problems persist on others.

The proposal with this patchset is to use 270 for the ID phase, 180
otherwise.  This works well on the platforms I have tested (Libretech's
boards and VIM3L)

It would be great if others could test this and report whether this work
for them or not.

If the results are good, this might be ported to Linux as well (... but the
situation is less critical there)

Jerome Brunet (2):
   mmc: meson-gx: clean up and align on Linux settings
   mmc: meson-gx: set 270 core phase during the identification

  drivers/mmc/meson_gx_mmc.c | 50 ++
  drivers/mmc/meson_gx_mmc.h |  9 +--
  2 files changed, 31 insertions(+), 28 deletions(-)



I'll apply on my test branch which triggers my autobuilder providing 
ready-to-boot
binaries for most of the supported platforms:
https://gitlab.com/superna/amlogic-u-boot-autotest/-/pipelines

Neil


Re: [PATCH v3 0/8] Add SM uclass and Meson SM driver

2023-09-28 Thread Neil Armstrong
Hi,

On Thu, 21 Sep 2023 11:13:33 +0300, Alexey Romanov wrote:
> At the moment, there is no single general approach to using
> secure monitor in U-Boot, there is only the smc_call() function,
> over which everyone builds their own add-ons. This patchset
> is designed to solve this problem by adding a new uclass -
> SM_UCLASS. This UCLASS export following generic API:
> 
> 1. sm_call() - generic SMC call to the secure-monitor
> 2. sm_call_read() - retrieve data from secure-monitor
> 3. sm_call_write() - send data to secure-monitor
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-next)

[1/8] drivers: introduce Secure Monitor uclass
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/126fbbefd89e0baa7e1a8ecdc4e00b9ff9e776ea
[2/8] sandbox: add sandbox sm uclass driver
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ac830089c0075d1f6ee51e22d51244f7f1a2554f
[3/8] sandbox: dts: add meson secure monitor node
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/0b488d719015c3b77685dd116a0095b4677e84a3
[4/8] sandbox: add tests for UCLASS_SM
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/80da22b9e45d2cd7d1eaed4e94724def7d4c7970
[5/8] sandbox: defconfig: enable CONFIG_SM option
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/b655672dabcf4f6f5ffe2fb92abd447ea0a20101
[6/8] drivers: introduce Meson Secure Monitor driver
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/e7c31d9ee0606dc52a15eb6e8ef5e46978608681
[7/8] arch: meson: sm: set correct order of the includes
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/a0fe285b1f625ff872b1cb8c79abb072cc154ece
[8/8] arch: meson: use secure monitor driver
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/4908461153e8b194703c5ae757a5032df3af2c50

-- 
Neil



Re: [PATCH v2 0/2] clk: amlogic: a1: Add Amlogic A1 clock driver

2023-09-28 Thread Neil Armstrong
Hi,

On Mon, 25 Sep 2023 18:52:07 +0300, Igor Prusov wrote:
> This series adds dt-bindings and driver implementation for Amlogic A1
> PLL and Peripherals clock controllers.
> 
> V1: 
> https://lore.kernel.org/all/20230917101308.1250-1-ivpru...@salutedevices.com/
> 
> V1 -> V2:
>  - Add more verbose comments for driver
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-next)

[1/2] dt-bindings: clock: Add Amlogic A1 clock bindings
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/afc86079bff6e2f70df3eee9c2c30be07d9f7082
[2/2] clk: Add clock driver for Amlogic A1
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/def23a39851d52cadd29854a33e3db29ee4a6d26

-- 
Neil



Re: [RFT PATCH 0/2] mmc: meson-gx: improve MMC reliabilty

2023-09-28 Thread neil . armstrong
From: Neil Armstrong 

Hi,

On Fri, 15 Sep 2023 18:01:28 +0200, Jerome Brunet wrote:
> Amlogic MMC on the GX (and later) SoCs has been problematic for years,
> especially with u-boot.
> 
> Linux has been fairly stable for a few years. It is using a fixed phase
> setting with Core = 180, Tx = 0 and Rx = 0 (the latter cannot be set
> starting from the v3 MMC IPs)
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic-test)

[1/2] mmc: meson-gx: clean up and align on Linux settings
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/1f505e80e20918bcd388ccff6b33d749fbf31945
[2/2] mmc: meson-gx: set 270 core phase during the identification
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/100f9e63762e02a65a441d7dd6a2923b62824c8a

This triggered the following build 
https://gitlab.com/superna/amlogic-u-boot-autotest/-/pipelines/1019397571
which will produce ready-to-boot binaries on most of the supported platforms
in https://github.com/LibreELEC/amlogic-boot-fip FIP repo.

-- 
Neil


Re: [PATCH v1 8/8] arch: a1: introduce USB initialization functionality

2023-10-03 Thread neil . armstrong

Hi,

On 02/10/2023 18:58, Alexey Romanov wrote:

This is entrypoint for USB stack initialization. Function
board_usb_init will be called from cmd/fastboot.c code.


This should not be needed anymore, using DM_USB_GADGET should work,
look how it was changed for G12A/SM1 and GXL/AXG:
https://lore.kernel.org/all/20221024-meson-dm-usb-v1-0-2ab077a50...@baylibre.com
and
https://lore.kernel.org/all/20230117-u-boot-usb-gxl-otg-dm-v1-0-2853f6d75...@linaro.org

Neil



Signed-off-by: Alexey Romanov 
---
  arch/arm/mach-meson/board-a1.c | 89 ++
  1 file changed, 89 insertions(+)

diff --git a/arch/arm/mach-meson/board-a1.c b/arch/arm/mach-meson/board-a1.c
index 967bb67182..781d5cfb33 100644
--- a/arch/arm/mach-meson/board-a1.c
+++ b/arch/arm/mach-meson/board-a1.c
@@ -4,12 +4,17 @@
   */
  
  #include 

+#include 
+#include 
  #include 
  #include 
  #include 
  #include 
  #include 
  #include 
+#include 
+#include 
+#include 
  
  phys_size_t get_effective_memsize(void)

  {
@@ -57,3 +62,87 @@ static struct mm_region a1_mem_map[] = {
  };
  
  struct mm_region *mem_map = a1_mem_map;

+
+#if CONFIG_IS_ENABLED(USB_DWC3_MESON_G12A) && \
+   CONFIG_IS_ENABLED(USB_GADGET_DWC2_OTG)
+
+static struct dwc2_plat_otg_data meson_a1_dwc2_data;
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+   int node, dwc2_node;
+   const void *blob = gd->fdt_blob;
+   struct udevice *dev;
+   int ret;
+
+   node = fdt_node_offset_by_compatible(blob, -1,
+"amlogic,meson-a1-usb-ctrl");
+   if (node < 0) {
+   pr_err("not found usb-control node\n");
+   return -ENODEV;
+   }
+
+   if (!fdtdec_get_is_enabled(blob, node)) {
+   pr_err("usb is disabled in the device tree\n");
+   return -ENODEV;
+   }
+
+   ret = uclass_get_device_by_of_offset(UCLASS_SIMPLE_BUS, node, &dev);
+   if (ret) {
+   pr_err("not found usb-control device\n");
+   return ret;
+   }
+
+   dwc2_node = fdt_node_offset_by_compatible(blob, node,
+ "amlogic,meson-a1-usb");
+   if (dwc2_node < 0) {
+   pr_err("not found dwc2 node\n");
+   return -ENODEV;
+   }
+
+   if (!fdtdec_get_is_enabled(blob, dwc2_node)) {
+   pr_err("dwc2 is disabled in the device tree\n");
+   return -ENODEV;
+   }
+
+   meson_a1_dwc2_data.regs_otg = fdtdec_get_addr(blob, dwc2_node, "reg");
+   if (meson_a1_dwc2_data.regs_otg == FDT_ADDR_T_NONE) {
+   pr_err("can't get base address\n");
+   return -ENODATA;
+   }
+
+   meson_a1_dwc2_data.rx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
+   "g-rx-fifo-size", 0);
+   if (meson_a1_dwc2_data.rx_fifo_sz < 0) {
+   pr_err("failed to get g-rx-fifo-size value\n");
+   return -ENODATA;
+   }
+
+   meson_a1_dwc2_data.np_tx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
+   "g-np-tx-fifo-size", 0);
+   if (meson_a1_dwc2_data.np_tx_fifo_sz < 0) {
+   pr_err("failed to get g-np-tx-fifo-size value\n");
+   return -ENODATA;
+   }
+
+   meson_a1_dwc2_data.tx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
+   "g-tx-fifo-size", 0);
+   if (meson_a1_dwc2_data.tx_fifo_sz < 0) {
+   pr_err("failed to get g-tx-fifo-size value\n");
+   return -ENODATA;
+   }
+
+   ret = dwc3_meson_g12a_force_mode(dev, USB_DR_MODE_PERIPHERAL);
+   if (ret) {
+   pr_err("failed to force usb mode to peripheral\n");
+   return ret;
+   }
+
+   return dwc2_udc_probe(&meson_a1_dwc2_data);
+}
+
+int board_usb_cleanup(int index, enum usb_init_type init)
+{
+   return 0;
+}
+#endif




Re: [PATCH v1 1/8] dt-bindings: reset: add Meson A1 reset bindings

2023-10-03 Thread neil . armstrong

On 02/10/2023 18:58, Alexey Romanov wrote:

Get this from Linux 6.6-rc3.

Signed-off-by: Alexey Romanov 
---
  .../reset/amlogic,meson-a1-reset.h| 76 +++
  1 file changed, 76 insertions(+)
  create mode 100644 include/dt-bindings/reset/amlogic,meson-a1-reset.h

diff --git a/include/dt-bindings/reset/amlogic,meson-a1-reset.h 
b/include/dt-bindings/reset/amlogic,meson-a1-reset.h
new file mode 100644
index 00..2c749c655e
--- /dev/null
+++ b/include/dt-bindings/reset/amlogic,meson-a1-reset.h
@@ -0,0 +1,76 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
+ * Author: Xingyu Chen 
+ *
+ * Copyright (c) 2023, SberDevices, Inc.
+ * Author: Alexey Romanov 
+ */
+
+#ifndef _DT_BINDINGS_AMLOGIC_MESON_A1_RESET_H
+#define _DT_BINDINGS_AMLOGIC_MESON_A1_RESET_H
+
+/* RESET0  */
+/* 0   */
+#define RESET_AM2AXI_VAD   1
+/* 2-3 */
+#define RESET_PSRAM4
+#define RESET_PAD_CTRL 5
+/* 6   */
+#define RESET_TEMP_SENSOR  7
+#define RESET_AM2AXI_DEV   8
+/* 9   */
+#define RESET_SPICC_A  10
+#define RESET_MSR_CLK  11
+#define RESET_AUDIO12
+#define RESET_ANALOG_CTRL  13
+#define RESET_SAR_ADC  14
+#define RESET_AUDIO_VAD15
+#define RESET_CEC  16
+#define RESET_PWM_EF   17
+#define RESET_PWM_CD   18
+#define RESET_PWM_AB   19
+/* 20  */
+#define RESET_IR_CTRL  21
+#define RESET_I2C_S_A  22
+/* 23  */
+#define RESET_I2C_M_D  24
+#define RESET_I2C_M_C  25
+#define RESET_I2C_M_B  26
+#define RESET_I2C_M_A  27
+#define RESET_I2C_PROD_AHB 28
+#define RESET_I2C_PROD 29
+/* 30-31   */
+
+/* RESET1  */
+#define RESET_ACODEC   32
+#define RESET_DMA  33
+#define RESET_SD_EMMC_A34
+/* 35  */
+#define RESET_USBCTRL  36
+/* 37  */
+#define RESET_USBPHY   38
+/* 39-41   */
+#define RESET_RSA  42
+#define RESET_DMC  43
+/* 44  */
+#define RESET_IRQ_CTRL 45
+/* 46  */
+#define RESET_NIC_VAD  47
+#define RESET_NIC_AXI  48
+#define RESET_RAMA 49
+#define RESET_RAMB 50
+/* 51-52   */
+#define RESET_ROM  53
+#define RESET_SPIFC54
+#define RESET_GIC  55
+#define RESET_UART_C   56
+#define RESET_UART_B   57
+#define RESET_UART_A   58
+#define RESET_OSC_RING 59
+/* 60-63   */
+
+/* RESET2  */
+/* 64-95   */
+
+#endif


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 2/8] reset: add support for Amlogic A1 family

2023-10-03 Thread neil . armstrong

On 02/10/2023 18:58, Alexey Romanov wrote:

This patch adds reset support for the Amlogic A1 family.
We add the structure meson_reset_drvdata, which in the future
will allow this driver to be used for other families by declaring
only the correct parameters reg_count and level_offset.

Signed-off-by: Alexey Romanov 
---
  drivers/reset/reset-meson.c | 42 +++--
  1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c
index 64bc696f13..9d0c8b354f 100644
--- a/drivers/reset/reset-meson.c
+++ b/drivers/reset/reset-meson.c
@@ -13,18 +13,26 @@
  #include 
  #include 
  #include 
+#include 
  
-#define REG_COUNT	8

  #define BITS_PER_REG  32
-#define LEVEL_OFFSET   0x7c
+
+struct meson_reset_drvdata {
+   unsigned int reg_count;
+   unsigned int level_offset;
+};
  
  struct meson_reset_priv {

struct regmap *regmap;
+   struct meson_reset_drvdata *drvdata;
  };
  
  static int meson_reset_request(struct reset_ctl *reset_ctl)

  {
-   if (reset_ctl->id > (REG_COUNT * BITS_PER_REG))
+   struct meson_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   struct meson_reset_drvdata *data = priv->drvdata;
+
+   if (reset_ctl->id > (data->reg_count * BITS_PER_REG))
return -EINVAL;
  
  	return 0;

@@ -33,9 +41,10 @@ static int meson_reset_request(struct reset_ctl *reset_ctl)
  static int meson_reset_level(struct reset_ctl *reset_ctl, bool assert)
  {
struct meson_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   struct meson_reset_drvdata *data = priv->drvdata;
uint bank = reset_ctl->id / BITS_PER_REG;
uint offset = reset_ctl->id % BITS_PER_REG;
-   uint reg_offset = LEVEL_OFFSET + (bank << 2);
+   uint reg_offset = data->level_offset + (bank << 2);
uint val;
  
  	regmap_read(priv->regmap, reg_offset, &val);

@@ -64,15 +73,36 @@ struct reset_ops meson_reset_ops = {
.rst_deassert = meson_reset_deassert,
  };
  
+static const struct meson_reset_drvdata meson_gxbb_data = {

+   .reg_count = 8,
+   .level_offset = 0x7c,
+};
+
+static const struct meson_reset_drvdata meson_a1_data = {
+   .reg_count = 3,
+   .level_offset = 0x40,
+};
+
  static const struct udevice_id meson_reset_ids[] = {
-   { .compatible = "amlogic,meson-gxbb-reset" },
-   { .compatible = "amlogic,meson-axg-reset" },
+   {
+   .compatible = "amlogic,meson-gxbb-reset",
+   .data = (ulong)&meson_gxbb_data,
+   },
+   {
+   .compatible = "amlogic,meson-axg-reset",
+   .data = (ulong)&meson_gxbb_data,
+   },
+   {
+   .compatible = "amlogic,meson-a1-reset",
+   .data = (ulong)&meson_a1_data,
+   },
{ }
  };
  
  static int meson_reset_probe(struct udevice *dev)

  {
struct meson_reset_priv *priv = dev_get_priv(dev);
+   priv->drvdata = (struct meson_reset_drvdata *)dev_get_driver_data(dev);
  
  	return regmap_init_mem(dev_ofnode(dev), &priv->regmap);

  }


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 3/8] phy: get rid of raw hex values

2023-10-03 Thread neil . armstrong
  
  	/* UnReset PLL */

-   regmap_write(priv->regmap, PHY_CTRL_R16, 0x19400414);
+   regmap_write(priv->regmap, PHY_CTRL_R16,
+   FIELD_PREP(PHY_CTRL_R16_MPLL_M, 20) |
+   FIELD_PREP(PHY_CTRL_R16_MPLL_N, 1) |
+   PHY_CTRL_R16_MPLL_LOAD |
+   FIELD_PREP(PHY_CTRL_R16_MPLL_LOCK_LONG, 1) |
+   PHY_CTRL_R16_MPLL_FAST_LOCK |
+   PHY_CTRL_R16_MPLL_EN);
  
  	/* PHY Tuning */

-   regmap_write(priv->regmap, PHY_CTRL_R20, 0xfe18);
-   regmap_write(priv->regmap, PHY_CTRL_R4, 0x8000fff);
+   regmap_write(priv->regmap, PHY_CTRL_R20,
+   FIELD_PREP(PHY_CTRL_R20_USB2_OTG_VBUS_TRIM_2_0, 4) |
+   PHY_CTRL_R20_USB2_OTG_VBUSDET_EN |
+   FIELD_PREP(PHY_CTRL_R20_USB2_DMON_SEL_3_0, 15) |
+   PHY_CTRL_R20_USB2_EDGE_DRV_EN |
+   FIELD_PREP(PHY_CTRL_R20_USB2_EDGE_DRV_TRIM_1_0, 3) |
+   FIELD_PREP(PHY_CTRL_R20_USB2_BGR_ADJ_4_0, 0) |
+   FIELD_PREP(PHY_CTRL_R20_USB2_BGR_VREF_4_0, 0) |
+   FIELD_PREP(PHY_CTRL_R20_USB2_BGR_DBG_1_0, 0));
+
+   regmap_write(priv->regmap, PHY_CTRL_R4,
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_7_0, 0xf) |
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_15_8, 0xf) |
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_23_16, 0xf) |
+   PHY_CTRL_R4_TEST_BYPASS_MODE_EN |
+   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_1_0, 0) |
+   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_3_2, 0));
  
  	/* Tuning Disconnect Threshold */

-   regmap_write(priv->regmap, PHY_CTRL_R3, 0x34);
+   regmap_write(priv->regmap, PHY_CTRL_R3,
+   FIELD_PREP(PHY_CTRL_R3_SQUELCH_REF, 0) |
+   FIELD_PREP(PHY_CTRL_R3_HSDIC_REF, 1) |
+   FIELD_PREP(PHY_CTRL_R3_DISC_THRESH, 3));
  
  	/* Analog Settings */

regmap_write(priv->regmap, PHY_CTRL_R14, 0);
-   regmap_write(priv->regmap, PHY_CTRL_R13, 0x78000);
+   regmap_write(priv->regmap, PHY_CTRL_R13,
+   PHY_CTRL_R13_UPDATE_PMA_SIGNALS |
+   FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7));
  
  	return 0;

  }


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 4/8] phy: move clk enable/disable in init/exit

2023-10-03 Thread neil . armstrong

On 02/10/2023 18:58, Alexey Romanov wrote:

It is better to place clk_enable() in phy_meson_g12a_usb2_init()
and clk_disable() in phy_meson_g12a_usb2_exit().

For more detailed information, please see comments in the review of
a similar driver in the Linux Kernel:

https://lore.kernel.org/all/CAFBinCCEhobbyKHuKDWzTYCQWgNT1-e8=7hmhq1mvt6cueo...@mail.gmail.com/

Signed-off-by: Alexey Romanov 
---
  drivers/phy/meson-g12a-usb2.c | 19 ---
  1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index 2e366b16ae..7b028784a0 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -160,6 +160,14 @@ static int phy_meson_g12a_usb2_init(struct phy *phy)
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
int ret;
  
+#if CONFIG_IS_ENABLED(CLK)

+   ret = clk_enable(&priv->clk);
+   if (ret && ret != -ENOSYS && ret != -ENOTSUPP) {
+   pr_err("failed to enable PHY clock\n");
+   return ret;
+   }
+#endif
+
ret = reset_assert(&priv->reset);
udelay(1);
ret |= reset_deassert(&priv->reset);
@@ -252,6 +260,10 @@ static int phy_meson_g12a_usb2_exit(struct phy *phy)
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
int ret;
  
+#if CONFIG_IS_ENABLED(CLK)

+   clk_disable(&priv->clk);
+#endif
+
ret = reset_assert(&priv->reset);
if (ret)
return ret;
@@ -289,13 +301,6 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
ret = clk_get_by_index(dev, 0, &priv->clk);
if (ret < 0)
return ret;
-
-   ret = clk_enable(&priv->clk);
-   if (ret && ret != -ENOSYS && ret != -ENOTSUPP) {
-   pr_err("failed to enable PHY clock\n");
-   clk_free(&priv->clk);
-   return ret;
-   }
  #endif
  
  	return 0;


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 5/8] phy: support Amlogic A1 family

2023-10-03 Thread neil . armstrong

On 02/10/2023 18:58, Alexey Romanov wrote:

Setting G12A and A1 is similar, so we can use G12A phy
driver with little changes.

Signed-off-by: Alexey Romanov 
---
  drivers/phy/Kconfig   |  2 +-
  drivers/phy/meson-g12a-usb2.c | 77 ---
  2 files changed, 64 insertions(+), 15 deletions(-)

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index cf4d5908d7..60be62907d 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -190,7 +190,7 @@ config MESON_GXL_USB_PHY
  
  config MESON_G12A_USB_PHY

bool "Amlogic Meson G12A USB PHYs"
-   depends on PHY && ARCH_MESON && MESON_G12A
+   depends on PHY && ARCH_MESON && (MESON_G12A || MESON_A1)
imply REGMAP
help
  This is the generic phy driver for the Amlogic Meson G12A
diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index 7b028784a0..c1b9baa7b7 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -18,6 +18,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  
@@ -146,18 +147,28 @@

  #define RESET_COMPLETE_TIME   1000
  #define PLL_RESET_COMPLETE_TIME   100
  
+enum meson_soc_id {

+   MESON_SOC_A1,
+   MESON_SOC_G12A,
+};
+
  struct phy_meson_g12a_usb2_priv {
struct regmap   *regmap;
  #if CONFIG_IS_ENABLED(CLK)
struct clk  clk;
  #endif
struct reset_ctlreset;
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+   struct power_domain pwrdm;
+#endif
+   int soc_id;
  };
  
  static int phy_meson_g12a_usb2_init(struct phy *phy)

  {
struct udevice *dev = phy->dev;
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
+   u32 value;
int ret;
  
  #if CONFIG_IS_ENABLED(CLK)

@@ -196,8 +207,7 @@ static int phy_meson_g12a_usb2_init(struct phy *phy)
FIELD_PREP(PHY_CTRL_R17_MPLL_FILTER_PVT2, 2) |
FIELD_PREP(PHY_CTRL_R17_MPLL_FILTER_PVT1, 9));
  
-	regmap_write(priv->regmap, PHY_CTRL_R18,

-   FIELD_PREP(PHY_CTRL_R18_MPLL_LKW_SEL, 1) |
+   value = FIELD_PREP(PHY_CTRL_R18_MPLL_LKW_SEL, 1) |
FIELD_PREP(PHY_CTRL_R18_MPLL_LK_W, 9) |
FIELD_PREP(PHY_CTRL_R18_MPLL_LK_S, 0x27) |
FIELD_PREP(PHY_CTRL_R18_MPLL_PFD_GAIN, 1) |
@@ -209,6 +219,11 @@ static int phy_meson_g12a_usb2_init(struct phy *phy)
FIELD_PREP(PHY_CTRL_R18_MPLL_ADJ_LDO, 1) |
PHY_CTRL_R18_MPLL_ACG_RANGE;
  
+	if (priv->soc_id == MESON_SOC_A1)

+   value |= PHY_CTRL_R18_MPLL_DCO_CLK_SEL;
+
+   regmap_write(priv->regmap, PHY_CTRL_R18, value);
+
udelay(PLL_RESET_COMPLETE_TIME);
  
  	/* UnReset PLL */

@@ -231,13 +246,19 @@ static int phy_meson_g12a_usb2_init(struct phy *phy)
FIELD_PREP(PHY_CTRL_R20_USB2_BGR_VREF_4_0, 0) |
FIELD_PREP(PHY_CTRL_R20_USB2_BGR_DBG_1_0, 0));
  
-	regmap_write(priv->regmap, PHY_CTRL_R4,

-   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_7_0, 0xf) |
-   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_15_8, 0xf) |
-   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_23_16, 0xf) |
-   PHY_CTRL_R4_TEST_BYPASS_MODE_EN |
-   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_1_0, 0) |
-   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_3_2, 0));
+   if (priv->soc_id == MESON_SOC_G12A)
+   regmap_write(priv->regmap, PHY_CTRL_R4,
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_7_0, 0xf) |
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_15_8, 0xf) |
+   FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_23_16, 0xf) |
+   PHY_CTRL_R4_TEST_BYPASS_MODE_EN |
+   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_1_0, 0) |
+   FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_3_2, 0));
+   else if (priv->soc_id == MESON_SOC_A1)
+   regmap_write(priv->regmap, PHY_CTRL_R21,
+   PHY_CTRL_R21_USB2_CAL_ACK_EN |
+   PHY_CTRL_R21_USB2_TX_STRG_PD |
+   FIELD_PREP(PHY_CTRL_R21_USB2_OTG_ACA_TRIM_1_0, 2));
  
  	/* Tuning Disconnect Threshold */

regmap_write(priv->regmap, PHY_CTRL_R3,
@@ -246,10 +267,15 @@ static int phy_meson_g12a_usb2_init(struct phy *phy)
FIELD_PREP(PHY_CTRL_R3_DISC_THRESH, 3));
  
  	/* Analog Settings */

-   regmap_write(priv->regmap, PHY_CTRL_R14, 0);
-   regmap_write(priv->regmap, PHY_CTRL_R13,
-   PHY_CTRL_R13_UPDATE_PMA_SIGNALS |
-   FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7));
+   if (priv->soc_id == MESON_SOC_G12A) {
+   regmap_write(priv->regmap, PHY_CTRL_R14, 0);
+   regmap_write(priv->regmap, PHY_CTRL_R13,
+   PHY_CTRL_R13_UPDATE_PMA_SIGNALS |
+   FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7))

Re: [PATCH v1 6/8] a1: clk: Add missing CLKID_USB_PHY_IN gate

2023-10-03 Thread neil . armstrong

On 02/10/2023 18:58, Alexey Romanov wrote:

From: Igor Prusov 

We use this clock in dwc3 driver.

Signed-off-by: Igor Prusov 
---
  drivers/clk/meson/a1.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/drivers/clk/meson/a1.c b/drivers/clk/meson/a1.c
index 3aec42f33b..1540e1875b 100644
--- a/drivers/clk/meson/a1.c
+++ b/drivers/clk/meson/a1.c
@@ -238,6 +238,9 @@ static const struct meson_clk_info *meson_clocks[] = {
[CLKID_FIXPLL_IN] = CLK_GATE("fixpll_in", A1_SYS_OSCIN_CTRL, 1,
EXTERNAL_XTAL
),
+   [CLKID_USB_PHY_IN] = CLK_GATE("usb_phy_in", A1_SYS_OSCIN_CTRL, 2,
+   EXTERNAL_XTAL
+   ),
[CLKID_SARADC] = CLK_GATE("saradc", A1_SAR_ADC_CLK_CTR, 8,
-ENOENT
    ),


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 7/8] dwc3: add support for Amlogic A1 family

2023-10-03 Thread neil . armstrong
ames = dwc3_meson_g12a_phy_names,
+   .phy_cnt = ARRAY_SIZE(dwc3_meson_g12a_phy_names),
+   .clk_init = dwc3_meson_g12a_clk_init,
+};
+
+static const struct dwc3_meson_g12a_drvdata meson_a1_drvdata = {
+   .phy_names = dwc3_meson_a1_phy_names,
+   .phy_cnt = ARRAY_SIZE(dwc3_meson_a1_phy_names),
+   .clk_init = dwc3_meson_a1_clk_init,
+};
+
  static const struct udevice_id dwc3_meson_g12a_ids[] = {
-   { .compatible = "amlogic,meson-g12a-usb-ctrl" },
+   {
+   .compatible = "amlogic,meson-g12a-usb-ctrl",
+   .data = (ulong)&meson_g12a_drvdata,
+   },
+   {
+   .compatible = "amlogic,meson-a1-usb-ctrl",
+   .data = (ulong)&meson_a1_drvdata,
+   },
{ }
  };
  


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 5/8] phy: support Amlogic A1 family

2023-10-03 Thread neil . armstrong
PMA_SIGNALS |
+   FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7));
+   } else if (priv->soc_id == MESON_SOC_A1) {
+   regmap_write(priv->regmap, PHY_CTRL_R13,
+   FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7));
+   }
  
  	return 0;

  }
@@ -281,6 +307,8 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
int ret;
  
+	priv->soc_id = (enum meson_soc_id)dev_get_driver_data(dev);

+
ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap);
if (ret)
return ret;
@@ -297,6 +325,22 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
return ret;
}
  
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)

+   ret = power_domain_get(dev, &priv->pwrdm);
+   if (ret < 0 && ret != -ENODEV) {
+   pr_err("failed to get power domain\n");
+   return ret;
+   }
+
+   if (ret != -ENODEV) {
+   ret = power_domain_on(&priv->pwrdm);
+   if (ret < 0) {
+   pr_err("failed to enable power domain\n");
+   return ret;
+   }
+   }
+#endif
+
  #if CONFIG_IS_ENABLED(CLK)
ret = clk_get_by_index(dev, 0, &priv->clk);
if (ret < 0)
@@ -307,7 +351,14 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
  }
  
  static const struct udevice_id meson_g12a_usb2_phy_ids[] = {

-   { .compatible = "amlogic,g12a-usb2-phy" },
+   {
+   .compatible = "amlogic,g12a-usb2-phy",
+   .data = (ulong)MESON_SOC_G12A,
+   },
+   {
+   .compatible = "amlogic,a1-usb2-phy",
+   .data = (ulong)MESON_SOC_A1,
+   },
{ }
  };
  


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 6/8] a1: clk: Add missing USB_PHY_IN and USB_PHY gates

2023-10-03 Thread neil . armstrong

On 03/10/2023 13:28, Alexey Romanov wrote:

From: Igor Prusov 

We use this clocks in dwc3 driver.

Signed-off-by: Igor Prusov 
Signed-off-by: Alexey Romanov 
---
  drivers/clk/meson/a1.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/clk/meson/a1.c b/drivers/clk/meson/a1.c
index 3aec42f33b..1075ba7333 100644
--- a/drivers/clk/meson/a1.c
+++ b/drivers/clk/meson/a1.c
@@ -238,6 +238,12 @@ static const struct meson_clk_info *meson_clocks[] = {
[CLKID_FIXPLL_IN] = CLK_GATE("fixpll_in", A1_SYS_OSCIN_CTRL, 1,
EXTERNAL_XTAL
),
+   [CLKID_USB_PHY_IN] = CLK_GATE("usb_phy_in", A1_SYS_OSCIN_CTRL, 2,
+   EXTERNAL_XTAL
+   ),
+   [CLKID_USB_PHY] = CLK_GATE("usb_phy", A1_SYS_CLK_EN0, 27,
+   CLKID_SYS
+   ),
[CLKID_SARADC] = CLK_GATE("saradc", A1_SAR_ADC_CLK_CTR, 8,
    -ENOENT
),


Reviewed-by: Neil Armstrong 


Re: [PATCH v2 8/8] ad401: enable USB stack

2023-10-03 Thread neil . armstrong

On 03/10/2023 13:28, Alexey Romanov wrote:

Currently we have all drivers for use USB stack on A1-series
SoC's. Let's enable USB options for the Amlogic AD401 reference A1
SoC board.

Signed-off-by: Alexey Romanov 
---
  configs/ad401_defconfig | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/configs/ad401_defconfig b/configs/ad401_defconfig
index 529e553bac..b02ff47b7a 100644
--- a/configs/ad401_defconfig
+++ b/configs/ad401_defconfig
@@ -51,4 +51,7 @@ CONFIG_DEBUG_UART_SKIP_INIT=y
  CONFIG_MESON_SERIAL=y
  CONFIG_SPI=y
  CONFIG_DM_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
+CONFIG_USB_GADGET=y
  CONFIG_WDT=y


Reviewed-by: Neil Armstrong 


Re: [PATCH v1 2/2] ARM: amlogic: ad401: enable SPIFC

2023-10-04 Thread Neil Armstrong

On 03/10/2023 22:29, Igor Prusov wrote:

From: Igor Prusov 

Enable Amlogic A1 SPI FLash Controller support.

Signed-off-by: Igor Prusov 
---
  configs/ad401_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/ad401_defconfig b/configs/ad401_defconfig
index 31752cc7f5..9a88e20a6a 100644
--- a/configs/ad401_defconfig
+++ b/configs/ad401_defconfig
@@ -51,4 +51,5 @@ CONFIG_DEBUG_UART_SKIP_INIT=y
  CONFIG_MESON_SERIAL=y
  CONFIG_SPI=y
  CONFIG_DM_SPI=y
+CONFIG_MESON_SPIFC_A1=y
  CONFIG_WDT=y


Reviewed-by: Neil Armstrong 


Re: [PATCH v3 6/8] drivers: introduce Meson Secure Monitor driver

2023-10-04 Thread neil . armstrong

Hi,

On 21/09/2023 10:13, Alexey Romanov wrote:

This patch adds an implementation of the Meson Secure Monitor
driver based on UCLASS_SM.

Signed-off-by: Alexey Romanov 
Reviewed-by: Simon Glass 
---
  MAINTAINERS   |   1 +
  drivers/sm/Kconfig|   7 ++
  drivers/sm/Makefile   |   1 +
  drivers/sm/meson-sm.c | 198 ++
  include/meson/sm.h|  19 
  5 files changed, 226 insertions(+)
  create mode 100644 drivers/sm/meson-sm.c
  create mode 100644 include/meson/sm.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 6c64427782..bdc364fd4c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -158,6 +158,7 @@ F:  drivers/net/phy/meson-gxl.c
  F:drivers/adc/meson-saradc.c
  F:drivers/phy/meson*
  F:drivers/mmc/meson_gx_mmc.c
+F: drivers/sm/meson-sm.c
  F:drivers/spi/meson_spifc.c
  F:drivers/pinctrl/meson/
  F:drivers/power/domain/meson-gx-pwrc-vpu.c
diff --git a/drivers/sm/Kconfig b/drivers/sm/Kconfig
index 6cc6d55578..b4cc3f768e 100644
--- a/drivers/sm/Kconfig
+++ b/drivers/sm/Kconfig
@@ -1,2 +1,9 @@
  config SM
bool "Enable Secure Monitor driver support"
+
+config MESON_SM
+   bool "Amlogic Secure Monitor driver"
+   depends on SM
+   default n


I get:
WARNING: unmet direct dependencies detected for MESON_SM
  Depends on [n]: SM [=n]
  Selected by [y]:
  - MESON64_COMMON [=y] && ARM [=y] && ARCH_MESON [=y]


so I think this should be:
  select SM
instead of:
  depends on SM

Could you post a fix so I can send the PR ?

Neil



+   help
+ Say y here to enable the Amlogic secure monitor driver.
diff --git a/drivers/sm/Makefile b/drivers/sm/Makefile
index af5f475c2b..da81ee898a 100644
--- a/drivers/sm/Makefile
+++ b/drivers/sm/Makefile
@@ -2,3 +2,4 @@
  
  obj-y += sm-uclass.o

  obj-$(CONFIG_SANDBOX) += sandbox-sm.o
+obj-$(CONFIG_MESON_SM) += meson-sm.o
diff --git a/drivers/sm/meson-sm.c b/drivers/sm/meson-sm.c
new file mode 100644
index 00..25adaf4560
--- /dev/null
+++ b/drivers/sm/meson-sm.c
@@ -0,0 +1,198 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023 SberDevices, Inc.
+ *
+ * Author: Alexey Romanov 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct meson_sm_cmd {
+   u32 smc_id;
+};
+
+#define SET_CMD(index, id) \
+   [index] = { \
+   .smc_id = (id), \
+   }
+
+struct meson_sm_data {
+   u32 cmd_get_shmem_in;
+   u32 cmd_get_shmem_out;
+   unsigned int shmem_size;
+   struct meson_sm_cmd cmd[];
+};
+
+struct meson_sm_priv {
+   void *sm_shmem_in;
+   void *sm_shmem_out;
+   const struct meson_sm_data *data;
+};
+
+static unsigned long __meson_sm_call(u32 cmd, const struct pt_regs *args)
+{
+   struct pt_regs r = *args;
+
+   r.regs[0] = cmd;
+   smc_call(&r);
+
+   return r.regs[0];
+};
+
+static u32 meson_sm_get_cmd(const struct meson_sm_data *data,
+   u32 cmd_index)
+{
+   struct meson_sm_cmd cmd;
+
+   if (cmd_index >= MESON_SMC_CMD_COUNT)
+   return 0;
+
+   cmd = data->cmd[cmd_index];
+   return cmd.smc_id;
+}
+
+static int meson_sm_call(struct udevice *dev, u32 cmd_index, s32 *retval,
+struct pt_regs *args)
+{
+   struct meson_sm_priv *priv = dev_get_priv(dev);
+   u32 cmd, ret;
+
+   cmd = meson_sm_get_cmd(priv->data, cmd_index);
+   if (!cmd)
+   return -ENOENT;
+
+   ret = __meson_sm_call(cmd, args);
+   if (retval)
+   *retval = ret;
+
+   return 0;
+}
+
+static int meson_sm_call_read(struct udevice *dev, void *buffer, size_t size,
+ u32 cmd_index, struct pt_regs *args)
+{
+   struct meson_sm_priv *priv = dev_get_priv(dev);
+   s32 nbytes;
+   int ret;
+
+   if (!buffer || size > priv->data->shmem_size)
+   return -EINVAL;
+
+   ret = meson_sm_call(dev, cmd_index, &nbytes, args);
+   if (ret)
+   return ret;
+
+   if (nbytes < 0 || nbytes > size)
+   return -ENOBUFS;
+
+   /* In some cases (for example GET_CHIP_ID command),
+* SMC doesn't return the number of bytes read, even
+* though the bytes were actually read into sm_shmem_out.
+* So this check is needed.
+*/
+   ret = nbytes;
+   if (!nbytes)
+   nbytes = size;
+
+   memcpy(buffer, priv->sm_shmem_out, nbytes);
+
+   return ret;
+}
+
+static int meson_sm_call_write(struct udevice *dev, void *buffer, size_t size,
+  u32 cmd_index, struct pt_regs *args)
+{
+   struct meson_sm_priv *priv = dev_get_priv(dev);
+   s32 nbytes;
+   int ret;
+
+   if (!buffer || size > priv->data->shmem_size)
+   return -EINVAL;
+
+   memcpy(priv->sm_shmem_in, buffer, size);
+
+   ret = meson_sm_call

Re: [PATCH v2 0/8] Support USB for Meson A1

2023-10-04 Thread neil . armstrong

On 03/10/2023 13:28, Alexey Romanov wrote:

Hello!

This patchset adds USB stack support for Amlogic A1 SoC's
series. Made reset / phy / dwc3 drivers more flexible and
added support for A1 board.

V2:

- Made power domain for PHY optional.
- Add missing CLKID_USB_PHY gate.
- Drop patch with USB stack initialization in board-a1.c.
Instead of, enable CONFIG_DM_USB_GADGET for AD401 board.
- Support A1 in g12a_child_pre_probe/post_remove functions
in dwc3 driver.


Alexey Romanov (7):
   dt-bindings: reset: add Meson A1 reset bindings
   reset: add support for Amlogic A1 family
   phy: get rid of raw hex values
   phy: move clk enable/disable in init/exit
   phy: support Amlogic A1 family
   dwc3: add support for Amlogic A1 family
   ad401: enable USB stack

Igor Prusov (1):
   a1: clk: Add missing USB_PHY_IN and USB_PHY gates

  configs/ad401_defconfig   |   3 +
  drivers/clk/meson/a1.c|   6 +
  drivers/phy/Kconfig   |   2 +-
  drivers/phy/meson-g12a-usb2.c | 235 --
  drivers/reset/reset-meson.c   |  42 +++-
  drivers/usb/dwc3/dwc3-meson-g12a.c|  73 +-
  .../reset/amlogic,meson-a1-reset.h|  76 ++
  7 files changed, 403 insertions(+), 34 deletions(-)
  create mode 100644 include/dt-bindings/reset/amlogic,meson-a1-reset.h



The PHY and DWC3 patches don't apply cleanly, could you rebase on top of:
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commits/u-boot-amlogic

Thanks,
Neil


Re: [PATCH v1] drivers: sm: fix build warning

2023-10-05 Thread neil . armstrong

On 05/10/2023 10:19, Alexey Romanov wrote:

This fixes following warning during u-boot build:
WARNING: unmet direct dependencies detected for MESON_SM
   Depends on [n]: SM [=n]
   Selected by [y]:
   - MESON64_COMMON [=y] && ARM [=y] && ARCH_MESON [=y]

Fixes: 9849712e7655 ("drivers: introduce Meson Secure Monitor driver")

Signed-off-by: Alexey Romanov 
Signed-off-by: Igor Prusov 
---
  drivers/sm/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/sm/Kconfig b/drivers/sm/Kconfig
index b4cc3f768e..f0987275d2 100644
--- a/drivers/sm/Kconfig
+++ b/drivers/sm/Kconfig
@@ -3,7 +3,7 @@ config SM
  
  config MESON_SM

bool "Amlogic Secure Monitor driver"
-   depends on SM
+   select SM
default n
help
  Say y here to enable the Amlogic secure monitor driver.


Thanks,

Squashed into 9849712e7655 ("drivers: introduce Meson Secure Monitor driver")

Neil


Re: [PATCH v3 0/8] Support USB for Meson A1

2023-10-05 Thread neil . armstrong
From: Neil Armstrong 

Hi,

On Thu, 5 Oct 2023 11:54:21 +0300, Alexey Romanov wrote:
> This patchset adds USB stack support for Amlogic A1 SoC's
> series. Made reset / phy / dwc3 drivers more flexible and
> added support for A1 board.
> 
> V2:
> 
> - Made power domain for PHY optional.
> - Add missing CLKID_USB_PHY gate.
> - Drop patch with USB stack initialization in board-a1.c.
> Instead of, enable CONFIG_DM_USB_GADGET for AD401 board.
> - Support A1 in g12a_child_pre_probe/post_remove functions
> in dwc3 driver.
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic 
(u-boot-amlogic)

[1/8] dt-bindings: reset: add Meson A1 reset bindings
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/fccbc810551a7e1c821ac23d5e8fd27c12ded1b2
[2/8] reset: add support for Amlogic A1 family
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/29ad8b0401dc9a75a15077f2a38363659091580e
[3/8] phy: get rid of raw hex values
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/11572764d44783870cc61ac2f0435bd555222ef6
[4/8] phy: move clk enable/disable in init/exit
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/ac7f5b2f768d298fe84ab36d363853748ae23243
[5/8] phy: support Amlogic A1 family
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/66defb628f658df97e426ab13dc620b9bf6277ab
[6/8] a1: clk: Add missing USB_PHY_IN and USB_PHY gates
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/84b0d40f3adb03074a80a58e4e655b422bce40ce
[7/8] dwc3: add support for Amlogic A1 family
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/8a4781ff2e51d5831b7d236a327c5fb13849b689
[8/8] ad401: enable USB stack
  
https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/686a98392fc1beaf544c8cf65f48b781a56a5148

-- 
Neil


Re: [RFC PATCH v1 1/5] ARM: dts: Add Amlogic Meson A1 DT from Linux 6.3-rc7

2023-05-04 Thread Neil Armstrong
mes = "xtal", "pclk", "baud";
+   status = "disabled";
+   };
+
+   uart_AO_B: serial@2000 {
+   compatible = "amlogic,meson-gx-uart",
+"amlogic,meson-ao-uart";
+   reg = <0x0 0x2000 0x0 0x18>;
+   interrupts = ;
+   clocks = <&xtal>, <&xtal>, <&xtal>;
+   clock-names = "xtal", "pclk", "baud";
+   status = "disabled";
+   };
+   };
+
+   gic: interrupt-controller@ff901000 {
+   compatible = "arm,gic-400";
+   reg = <0x0 0xff901000 0x0 0x1000>,
+ <0x0 0xff902000 0x0 0x2000>,
+ <0x0 0xff904000 0x0 0x2000>,
+ <0x0 0xff906000 0x0 0x2000>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <3>;
+   #address-cells = <0>;
+   };
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   xtal: xtal-clk {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   clock-output-names = "xtal";
+   #clock-cells = <0>;
+   };
+};
diff --git a/include/dt-bindings/gpio/meson-a1-gpio.h 
b/include/dt-bindings/gpio/meson-a1-gpio.h
new file mode 100644
index 00..40e57a5ff1
--- /dev/null
+++ b/include/dt-bindings/gpio/meson-a1-gpio.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
+/*
+ * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
+ * Author: Qianggui Song 
+ */
+
+#ifndef _DT_BINDINGS_MESON_A1_GPIO_H
+#define _DT_BINDINGS_MESON_A1_GPIO_H
+
+#define GPIOP_00
+#define GPIOP_11
+#define GPIOP_22
+#define GPIOP_33
+#define GPIOP_44
+#define GPIOP_55
+#define GPIOP_66
+#define GPIOP_77
+#define GPIOP_88
+#define GPIOP_99
+#define GPIOP_10   10
+#define GPIOP_11   11
+#define GPIOP_12   12
+#define GPIOB_013
+#define GPIOB_114
+#define GPIOB_215
+#define GPIOB_316
+#define GPIOB_417
+#define GPIOB_518
+#define GPIOB_619
+#define GPIOX_020
+#define GPIOX_121
+#define GPIOX_222
+#define GPIOX_323
+#define GPIOX_424
+#define GPIOX_525
+#define GPIOX_626
+#define GPIOX_727
+#define GPIOX_828
+#define GPIOX_929
+#define GPIOX_10   30
+#define GPIOX_11   31
+#define GPIOX_12   32
+#define GPIOX_13   33
+#define GPIOX_14   34
+#define GPIOX_15   35
+#define GPIOX_16   36
+#define GPIOF_037
+#define GPIOF_138
+#define GPIOF_239
+#define GPIOF_340
+#define GPIOF_441
+#define GPIOF_542
+#define GPIOF_6    43
+#define GPIOF_744
+#define GPIOF_845
+#define GPIOF_946
+#define GPIOF_10   47
+#define GPIOF_11   48
+#define GPIOF_12   49
+#define GPIOA_050
+#define GPIOA_151
+#define GPIOA_252
+#define GPIOA_353
+#define GPIOA_454
+#define GPIOA_555
+#define GPIOA_656
+#define GPIOA_757
+#define GPIOA_858
+#define GPIOA_959
+#define GPIOA_10   60
+#define GPIOA_11   61
+
+#endif /* _DT_BINDINGS_MESON_A1_GPIO_H */


Reviewed-by: Neil Armstrong 


Re: [RFC PATCH v1 2/5] ARM: dts: sync meson-a1-ad401 from Linux 6.3-rc7

2023-05-04 Thread Neil Armstrong

On 24/04/2023 20:01, Igor Prusov wrote:

Add meson-a1-ad401.dts file from Linux 6.3-rc7

Signed-off-by: Igor Prusov 
---
  arch/arm/dts/Makefile   |  1 +
  arch/arm/dts/meson-a1-ad401.dts | 30 ++
  2 files changed, 31 insertions(+)
  create mode 100644 arch/arm/dts/meson-a1-ad401.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 3385948d22..8de35c5454 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -185,6 +185,7 @@ dtb-$(CONFIG_ARCH_S5P4418) += \
s5p4418-nanopi2.dtb
  
  dtb-$(CONFIG_ARCH_MESON) += \

+   meson-a1-ad401.dtb \
meson-axg-s400.dtb \
meson-axg-jethome-jethub-j100.dtb \
meson-gxbb-nanopi-k2.dtb \
diff --git a/arch/arm/dts/meson-a1-ad401.dts b/arch/arm/dts/meson-a1-ad401.dts
new file mode 100644
index 00..69c25c68c3
--- /dev/null
+++ b/arch/arm/dts/meson-a1-ad401.dts
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
+ */
+
+/dts-v1/;
+
+#include "meson-a1.dtsi"
+
+/ {
+   compatible = "amlogic,ad401", "amlogic,a1";
+   model = "Amlogic Meson A1 AD401 Development Board";
+
+   aliases {
+   serial0 = &uart_AO_B;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x800>;
+   };
+};
+
+&uart_AO_B {
+   status = "okay";
+};


Reviewed-by: Neil Armstrong 


Re: [RFC PATCH v1 3/5] ARM: meson: add A1 support

2023-05-04 Thread Neil Armstrong

On 24/04/2023 20:01, Igor Prusov wrote:

Add support for Amlogic A1 SoC family.

Signed-off-by: Igor Prusov 
Signed-off-by: Evgeny Bachinin 
---
  arch/arm/include/asm/arch-meson/a1.h | 20 ++
  arch/arm/mach-meson/Kconfig  |  6 +++
  arch/arm/mach-meson/Makefile |  1 +
  arch/arm/mach-meson/board-a1.c   | 59 
  include/configs/meson64.h|  3 ++
  5 files changed, 89 insertions(+)
  create mode 100644 arch/arm/include/asm/arch-meson/a1.h
  create mode 100644 arch/arm/mach-meson/board-a1.c

diff --git a/arch/arm/include/asm/arch-meson/a1.h 
b/arch/arm/include/asm/arch-meson/a1.h
new file mode 100644
index 00..86d1a68de8
--- /dev/null
+++ b/arch/arm/include/asm/arch-meson/a1.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2023 SberDevices, Inc.
+ * Author: Igor Prusov 
+ */
+
+#ifndef __MESON_A1_H__
+#define __MESON_A1_H__
+
+#define A1_SYSCTRL_BASE0xfe005800
+
+/* SYSCTRL registers */
+#define A1_SYSCTRL_ADDR(off)   (A1_SYSCTRL_BASE + ((off) << 2))
+
+#define A1_SYSCTRL_SEC_STATUS_REG4 A1_SYSCTRL_ADDR(0xc4)
+
+#define A1_SYSCTRL_MEM_SIZE_MASK   0x
+#define A1_SYSCTRL_MEM_SIZE_SHIFT  16
+
+#endif /* __MESON_A1_H__ */
diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
index 6cba2c40dd..519ed563c0 100644
--- a/arch/arm/mach-meson/Kconfig
+++ b/arch/arm/mach-meson/Kconfig
@@ -51,6 +51,12 @@ config MESON_G12A
help
  Select this if your SoC is an S905X/D2
  
+config MESON_A1

+   bool "A1"
+   select MESON64_COMMON
+   help
+ Select this if your SoC is an A113L
+
  endchoice
  
  config SYS_SOC

diff --git a/arch/arm/mach-meson/Makefile b/arch/arm/mach-meson/Makefile
index a9e4046f80..535b0878b9 100644
--- a/arch/arm/mach-meson/Makefile
+++ b/arch/arm/mach-meson/Makefile
@@ -6,3 +6,4 @@ obj-y += board-common.o sm.o board-info.o
  obj-$(CONFIG_MESON_GX) += board-gx.o
  obj-$(CONFIG_MESON_AXG) += board-axg.o
  obj-$(CONFIG_MESON_G12A) += board-g12a.o
+obj-$(CONFIG_MESON_A1) += board-a1.o
diff --git a/arch/arm/mach-meson/board-a1.c b/arch/arm/mach-meson/board-a1.c
new file mode 100644
index 00..967bb67182
--- /dev/null
+++ b/arch/arm/mach-meson/board-a1.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2023 SberDevices, Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+phys_size_t get_effective_memsize(void)
+{
+   return ((readl(A1_SYSCTRL_SEC_STATUS_REG4) & A1_SYSCTRL_MEM_SIZE_MASK)
+   >> A1_SYSCTRL_MEM_SIZE_SHIFT) * SZ_1M;
+}
+
+void meson_init_reserved_memory(__maybe_unused void *fdt)
+{
+}
+
+int meson_get_boot_device(void)
+{
+   return -ENOSYS;
+}
+
+static struct mm_region a1_mem_map[] = {
+   {
+   .virt = 0xUL,
+   .phys = 0xUL,
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+   PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0x8000UL,
+   .phys = 0x8000UL,
+   .size = 0x7FE0UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+   PTE_BLOCK_NON_SHARE |
+   PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /*
+* This mem region contains in/out shared memory with bl31,
+* hence it's marked as NORMAL memory type
+*/
+   .virt = 0xFFE0UL,
+   .phys = 0xFFE0UL,
+   .size = 0x0020UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+   PTE_BLOCK_INNER_SHARE
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = a1_mem_map;
diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index 9244601284..801cdae470 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -11,6 +11,9 @@
  #if (defined(CONFIG_MESON_AXG) || defined(CONFIG_MESON_G12A))
  #define GICD_BASE 0xffc01000
  #define GICC_BASE 0xffc02000
+#elif defined(CONFIG_MESON_A1)
+#define GICD_BASE  0xff901000
+#define GICC_BASE  0xff902000
  #else /* MESON GXL and GXBB */
  #define GICD_BASE 0xc4301000
  #define GICC_BASE 0xc4302000


Reviewed-by: Neil Armstrong 


  1   2   3   4   5   6   7   8   9   10   >